XF 2.2 A Little Help

Ozzy47

Well-known member
I've made an addon that separates the addons in the ACP into four tabs, Active, Installable, Legacy and Inactive. Seems to work pretty good, but one issue that has come up is some users are experiencing issues switching between tabs.

separate add-ons.gif

Others are experiencing a 8 second delay between tabs. I've not had any issues with this in over a year of running the addon. Here is the PHP code:
PHP:
<?php

namespace OzzModz\SeparateAddons\XF\Admin\Controller;

/**
 * Class AddOn
 *
 * Extends \XF\Admin\Controller\AddOn
 *
 * @package OzzModz\SeparateAddons\XF\Admin\Controller
 */

class AddOn extends XFCP_AddOn
{
    public function actionIndex()
    {
        $parent = parent::actionIndex();

        $disabledAddOns = [];

        $installed = $parent->getParam('installed');

        foreach ($installed AS $id => $addOn)
        {
            if(!$addOn->active)
            {
                $disabledAddOns[$id] = $addOn;
                unset($installed[$id]);
            }
        }

        $parent->setParam('disabled_addons', $disabledAddOns);
        $parent->setParam('installed', $installed);

        $tab = $this->filter('tab', 'str');

        if(!$tab)
        {
            switch ($parent)
            {
                case (!$tab && !empty($parent->getParam('installed')) ? $tab = 'installed' : '');
                 break;
                    
                 case (!empty($parent->getParam('upgradeable')) ? $tab = 'upgradeable' : '');
                 break;

                 case (!$tab && !empty($parent->getParam('installable')) ? $tab = 'installable' : '');
                 break;

                 case (!$tab && !empty($parent->getParam('legacy')) ? $tab = 'legacy' : '');
                 break;

                 case (!$tab && !empty($parent->getParam('disabled')) ? $tab = 'disabled' : '');
                 break;
            }
        }

    $parent->setParam('tab', $tab);

    return $parent;
    }
}

Here is the HTML in the template modification:
HTML:
<xf:macro name="addon_list_block" arg-installed="!" arg-upgradeable="!" arg-installable="!" arg-legacy="!" arg-disabled="!" arg-tab="">

    <div class="block">
        <div class="block-container">

            <h2 class="block-tabHeader tabs hScroller" data-xf-init="tabs h-scroller" role="tablist">
            <span class="hScroller-scroll is-calculated">
                <a class="tabs-tab {{ $tab == 'installed' ? 'is-active' : '' }}" role="tab" tabindex="0" aria-controls="installed" href="{{ link('add-ons', {}, {'tab': 'installed'}) }}">{{ phrase('ozzmodzSeparateAddons_active') }}</a>
                <xf:if is="$upgradeable"><a class="tabs-tab {{ (!$tab || $tab == 'upgradeable') ? 'is-active' : '' }}" role="tab" tabindex="0" aria-controls="upgradeable" href="{{ link('add-ons', {}, {'tab': 'upgradeable'}) }}">{{ phrase('upgradeable_add_ons') }}</a></xf:if>           
                <xf:if is="$installable"><a class="tabs-tab {{ ($tab == 'installable' || (!$tab && !$upgradeable)) ? 'is-active' : '' }}" role="tab" tabindex="0" aria-controls="installable" href="{{ link('add-ons', {}, {'tab': 'installable'}) }}">{{ phrase('installable_add_ons') }}</a></xf:if>
                <xf:if is="$legacy"><a class="tabs-tab {{ $tab == 'legacy' ? 'is-active' : '' }}" role="tab" tabindex="0" aria-controls="legacy" href="{{ link('add-ons', {}, {'tab': 'legacy'}) }}">{{ phrase('legacy_add_ons') }}</a></xf:if>
                <xf:if is="$disabled"><a class="tabs-tab {{ $tab == 'disabled' ? 'is-active' : '' }}" role="tab" tabindex="0" aria-controls="disabled" href="{{ link('add-ons', {}, {'tab': 'disabled'}) }}">{{ phrase('ozzmodzSeparateAddons_inactive') }}</a></xf:if>
                </span><i class="hScroller-action hScroller-action--end" aria-hidden="true"></i><i class="hScroller-action hScroller-action--start" aria-hidden="true"></i>
            </h2>
            <xf:if is="$tab == 'installed'">
                <xf:set var="$addOns" value="{$installed}" />
            
                <xf:elseif is="!$tab || $tab == 'upgradeable'" />
                <xf:set var="$addOns" value="{$upgradeable}" />

                <xf:elseif is="$tab == 'installable'" />
                <xf:set var="$addOns" value="{$installable}" />

                <xf:elseif is="$tab == 'legacy'" />
                <xf:set var="$addOns" value="{$legacy}" />

                <xf:elseif is="$tab == 'disabled'" />
                <xf:set var="$addOns" value="{$disabled}" />
            </xf:if>

            <xf:if is="$addOns is not empty">
                <ol class="block-body">
                    <xf:foreach loop="$addOns" value="$addOn">
                        <xf:macro name="addon_list_item" arg-addOn="{$addOn}" />
                    </xf:foreach>
                </ol>

                <xf:else />

            </xf:if>
        </div>

        <xf:if is="!$addOns">
            <div class="blockMessage">{{ phrase('ozzmodz_advancedacp_no_addons_found') }}</div>
        </xf:if>
    </div>

</xf:macro>

Can anyone spot any issues with the code that would cause such issues for some people?
 
Top