Joomla-cms: Iconover never used in "custom" button function

Created on 28 Jul 2020  路  11Comments  路  Source: joomla/joomla-cms

Problem identified

file:
ToolbarButton.php

seems the $iconOver created in
https://github.com/joomla/joomla-cms/blob/6d0c5c06f69cf26e8261baeab812caa3a6eecf30/administrator/components/com_templates/src/View/Template/HtmlView.php#L250

public static function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true, $formId = null)
{
    $bar = Toolbar::getInstance('toolbar');

    // Strip extension.
    $icon = preg_replace('#\.[^.]*$#', '', $icon);

    // Add a standard button.
    $bar->appendButton('Standard', $icon, $alt, $task, $listSelect, $formId);
}

Proposed solution

Open questions

How do we address this. I'm not sure where/how it is/should be used.

No Code Attached Yet

Most helpful comment

It also works fine with
ToolbarHelper::custom('template.cropImage', 'fas fa-crop', '', 'COM_TEMPLATES_BUTTON_CROP', false);

There are so many files concerned by toolbar that It's confusing.
Libraries/src/
Screen Shot 2020-07-30 at 08 12 20

Layouts
Screen Shot 2020-07-30 at 08 14 21

The js is created in media/system/js/ (from build/system/js/)
Screen Shot 2020-07-30 at 08 16 39

All 11 comments

$iconOver The image to display when moused over.

$iconOver The image to display when moused over.

correct, however, it doesn't & can't since the icon is never passed to the button.
Thats my point

Indeed. Same in 3.x.
Useless param. It is a remaining of... Joomla 1.5...

1.5

/**
    * Writes a custom option and task button for the button bar
    * @param string The task to perform (picked up by the switch($task) blocks
    * @param string The image to display
    * @param string The image to display when moused over
    * @param string The alt text for the icon image
    * @param boolean True if required to check that a standard list item is checked
    */
    function custom( $task='', $icon=NULL, $iconOver='', $alt='', $listSelect=true ) {

        $icon   = ( $iconOver ? $iconOver : $icon );
        $image  = JHTML::_('image.site',  $icon, '/images/', NULL, NULL, $alt );

        if ($listSelect) {
            $message = JText::sprintf( 'Please make a selection from the list to', JText::_( $alt ) );
            $message = addslashes($message);
            $onclick = "javascript:if (document.adminForm.boxchecked.value == 0){ alert('".  $message . "');}else{submitbutton('$task')}";
        } else {
            $onclick = "javascript:submitbutton('$task')";
        }

        ?>
        <td>
            <a class="toolbar" onclick="<?php echo $onclick ;?>">
                <?php echo $image; ?></a>
        </td>
        <?php
    }

then we should deprecate that option and remove all the existing $iconOvers from the toolbarhelper:: calls?

OR add it into all possible occurrence of toolbar and modify the js to use it?

I tested modifying
ToolbarHelper::custom('template.cropImage', 'fas fa-crop', 'fas fa-crop', 'COM_TEMPLATES_BUTTON_CROP', false);
by taking off one of the , 'fas fa-crop'

and the result is that the icon loses its opacity and can't be clicked i.e. disabled.

It works again if I use
ToolbarHelper::custom('template.cropImage', 'fas fa-crop', 'whatever', 'COM_TEMPLATES_BUTTON_CROP', false);

weird...

where would the js be that creates the button?

It also works fine with
ToolbarHelper::custom('template.cropImage', 'fas fa-crop', '', 'COM_TEMPLATES_BUTTON_CROP', false);

There are so many files concerned by toolbar that It's confusing.
Libraries/src/
Screen Shot 2020-07-30 at 08 12 20

Layouts
Screen Shot 2020-07-30 at 08 14 21

The js is created in media/system/js/ (from build/system/js/)
Screen Shot 2020-07-30 at 08 16 39

discussion moved to https://github.com/joomla/joomla-cms/pull/31211. Going to need input on best solution.

Was this page helpful?
0 / 5 - 0 ratings