Skip to content

Commit

Permalink
Fix issue override general settings in Article Widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Oct 23, 2024
1 parent aad4a18 commit e8a90cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions framework/fields/astroidlayoutdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ protected function getInput() {
foreach ($row['cols'] as $col) {
foreach ($col['elements'] as $element) {
if (isset($form_template[$element['type']]) && $form_template[$element['type']]['info']['element_type'] == 'widget') {
$availableForm = Helper\AstroidForm::getAvailableFormArray($form_template[$element['type']]['content']);
$availableElements = [];
foreach ($element['params'] as $availableElement) {
if (isset($availableForm[$availableElement['name']])) {
$availableElements[] = $availableElement;
}
}
$element['params'] = $availableElements;
$article_data = Path::clean(JPATH_SITE . '/media/templates/site/' . $article_layout->template . '/astroid/article_widget_data/'. $id . '_' . $element['id'] . '.json');
if (file_exists($article_data)) {
$widget_data = file_get_contents($article_data);
Expand Down
15 changes: 15 additions & 0 deletions framework/library/astroid/Helper/AstroidForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,19 @@ public function getForm()
{
return $this->form;
}

public static function getAvailableFormArray($fieldsets = []): array
{
$arr = [];
foreach ($fieldsets as $fieldset) {
foreach ($fieldset->childs as $group) {
foreach ($group['fields'] as $field) {
if (isset($field['name']) && !empty($field['name'])) {
$arr[$field['name']] = true;
}
}
}
}
return $arr;
}
}

0 comments on commit e8a90cf

Please sign in to comment.