Skip to content

Commit

Permalink
Quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdesign committed Jul 7, 2023
1 parent f033e15 commit a7e9cbe
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 64 deletions.
26 changes: 12 additions & 14 deletions plg_cck_field_jumenutitle/jumenutitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,19 @@ public function onCCK_FieldPrepareContent(&$field, string $value = '', array &$c

self::g_onCCK_FieldPrepareContent($field, $config);

$item = Factory::getApplication()->getMenu()->getActive();
$item = Factory::getApplication()->getMenu()->getActive();
$options2 = JCckDev::fromJSON($field->options2);

$class = $field->css . $field->markup_class;
$class = ($options2[ 'title_class' ] ? $options2[ 'title_class' ] . ' ' : '') . $field->css . $field->markup_class;
$class = $class ? ' class="' . trim($class) . '"' : '';

$html = '<h2 class="' . $class . '">';
$html = '<h2' . $class . '>';

if($item->getParams()->get('menu-anchor_css'))
{
$options2 = JCckDev::fromJSON($field->options2);
$html .= (new FileLayout('icon', JPATH_SITE . '/plugins/cck_field/jumenutitle/tmpl'))->render([
$html .= (new FileLayout('icon', JPATH_SITE . '/plugins/cck_field/jumenutitle/tmpl'))->render([
'sprite' => $options2[ 'sprite' ],
'icon' => $field->location,
'icon' => $item->getParams()->get('menu-anchor_css'),
'size' => $options2[ 'size' ],
'class' => ($options2[ 'class' ] ? : '')
]);
Expand All @@ -167,7 +167,6 @@ public function onCCK_FieldPrepareContent(&$field, string $value = '', array &$c
$html .= '<span class="uk-text-middle">' . $item->title . '</span>';
$html .= '</h2>';

// Set
$field->html = $html;
$field->value = '';
$field->label = '';
Expand All @@ -193,19 +192,19 @@ public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = [], $inh
self::$path = self::g_getPath(self::$type . '/');
self::g_onCCK_FieldPrepareForm($field, $config);

$item = Factory::getApplication()->getMenu()->getActive();
$item = Factory::getApplication()->getMenu()->getActive();
$options2 = JCckDev::fromJSON($field->options2);

$class = $field->css . $field->markup_class;
$class = ($options2[ 'title_class' ] ? $options2[ 'title_class' ] . ' ' : '') . $field->css . $field->markup_class;
$class = $class ? ' class="' . trim($class) . '"' : '';

$form = '<h2 class="' . $class . '">';
$form = '<h2' . $class . '>';

if($item->getParams()->get('menu-anchor_css'))
{
$options2 = JCckDev::fromJSON($field->options2);
$form .= (new FileLayout('icon', JPATH_SITE . '/plugins/cck_field/jumenutitle/tmpl'))->render([
$form .= (new FileLayout('icon', JPATH_SITE . '/plugins/cck_field/jumenutitle/tmpl'))->render([
'sprite' => $options2[ 'sprite' ],
'icon' => $field->location,
'icon' => $item->getParams()->get('menu-anchor_css'),
'size' => $options2[ 'size' ],
'class' => ($options2[ 'class' ] ? : '')
]);
Expand All @@ -214,7 +213,6 @@ public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = [], $inh
$form .= '<span class="uk-text-middle">' . $item->title . '</span>';
$form .= '</h2>';

// Set
$field->form = $form;
$field->value = '';
$field->label = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ PLG_CCK_FIELD_JUMENUTITLE_LABEL2 = "JUMenuTitle"
PLG_CCK_FIELD_JUMENUTITLE_DESC = "JUMenuTitle"
PLG_CCK_FIELD_GROUP_HTML = "HTML"
COM_CCK_SPRITE_PATH = "Path to SVG sprite"
COM_CCK_ICON_SIZE = "Icon Size"
COM_CCK_ICON_CLASS = "Icon Class"
COM_CCK_TITLE_CLASS = "Title Class"
COM_CCK_ADD_SPRITE_PATH = "First, add the path to the svg-sprite relative to the site root. For example: <code>/app/icons/sprite.svg</code>. After saving, you will be able to choose your icon"
71 changes: 21 additions & 50 deletions plg_cck_field_jumenutitle/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,71 +14,42 @@

$options2 = JCckDev::fromJSON($this->item->options2);

$icons = [];
if(@$options2[ 'sprite' ])
$icons = [];
$sprite = 'templates/admin/app/icons/icons.svg';
if(is_file(JPATH_SITE . '/' . @$options2[ 'sprite' ]))
{
$sprite = JPATH_SITE . '/templates/admin/app/icons/icons.svg';
if(is_file(JPATH_SITE . '/' . @$options2[ 'sprite' ]))
{
$sprite = JPATH_SITE . '/' . @$options2[ 'sprite' ];
}

if(is_file($sprite))
{
$dom = new DOMDocument;
$dom->loadXML($sprite);

$symbols = $dom->getElementsByTagName('symbol');

$items = [];
foreach($symbols as $symbol)
{
$items[] = $symbol->getAttribute('id');
}

$icons = [
'storage_field' => 'location',
'options' => implode('||', $items),
'required' => 'required'
];
}
$sprite = @$options2[ 'sprite' ];
}

JCckDev::forceStorage();

$sprite_icons = '';
$sprite_size = '';
$sprite_class = '';
if(@$options2[ 'sprite' ])
{
$sprite_icons = JCckDev::renderForm('core_icons', $this->item->location, $config, $icons);
$sprite_size = JCckDev::renderForm('core_dev_text', @$options2[ 'size' ], $config, [
'label' => 'Size',
'defaultvalue' => '24',
'size' => 50,
'storage_field' => 'json[options2][size]'
]);
$sprite_class = JCckDev::renderForm('core_dev_text', @$options2[ 'class' ], $config, [
'label' => 'Class',
'size' => 50,
'storage_field' => 'json[options2][class]'
]);
}

$displayData = [
'config' => $config,
'form' => [
[
'fields' => [
JCckDev::renderForm('core_dev_text', @$options2[ 'sprite' ], $config, [
'label' => 'Sprite Path',
'required' => 'required',
'defaultvalue' => $sprite,
'size' => 50,
'storage_field' => 'json[options2][sprite]'
]),
$sprite_icons,
$sprite_size,
$sprite_class
JCckDev::renderForm('core_dev_text', @$options2[ 'size' ], $config, [
'label' => 'Icon Size',
'defaultvalue' => '24',
'size' => 50,
'storage_field' => 'json[options2][size]'
]),
JCckDev::renderForm('core_dev_text', @$options2[ 'class' ], $config, [
'label' => 'Icon Class',
'size' => 50,
'storage_field' => 'json[options2][class]'
]),
JCckDev::renderForm('core_dev_text', @$options2[ 'title_class' ], $config, [
'label' => 'Title Class',
'size' => 50,
'storage_field' => 'json[options2][title_class]'
])
]
],
[
Expand Down

0 comments on commit a7e9cbe

Please sign in to comment.