<?php
/*
 * @component UserPoints
 * @copyright Copyright (C) 2015-2022 Bernard Gilly - Adrien Roussel - Martin Brampton
 * @license : GNU/GPL
 * @Website : https://remository.com
 */
namespace BlackSheepResearch\Component\UserPoints\Administrator\Viewers;

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Toolbar\ToolbarHelper;
use BlackSheepResearch\Component\UserPoints\Site\WebAssetManager;

class CpanelHTML extends AdminHTML {

    public function show($tpl = null) {

        $language = Factory::getLanguage();
        $this->tag = $language->getTag();
        WebAssetManager::getInstance('com_userpoints')->useStyle('fontello.styles')->useStyle('cpanel.styles');
        $logo = '<img src="' . Uri::root() . 'administrator/components/com_userpoints/assets/images/icon-48-userpoints.png" />&nbsp;&nbsp;';

        ToolbarHelper::title($logo . 'UserPoints :: ' . Text::_('AUP_CPANEL'), 'cpanel');
        ToolbarHelper::custom('cpanel', 'refresh.png', 'refresh.png', Text::_('AUP_REFRESH'), false);
        $this->getPrefHelpToolbar();

        $this->pane = UPJPane::getInstance('Sliders');

        /*
          $scriptMigration = "	window.addEvent('domready', function(){
          $$('a.rpcmigrate').addEvent('click', function(e){
          // stop the default link event
          // new Event(e).stop();
          var url = '".Uri::base(true)."/components/com_userpoints/install/migration_1.5.x.php;
          var myAjax = new Request({
          url:url,
          method: 'get',
          onComplete: function(responseText) {
          $('migration').set('html', responseText);
          }
          });
          myAjax.send();
          });
          });";
          $document->addScriptDeclaration($scriptMigration);
         */

        parent::display($tpl);
    }

    protected function aup_createIconPanel($link, $class, $text, $javascript = '') {
        if ($link) {
            ?>
            <div class="pull-left">
                <ul style="list-style:none;">
                    <li>
                        <a class="btn btn-large thumbnail height-100 width-130 " href="<?php echo $link; ?>" <?php echo $javascript; ?>>
                            <h1><i class="<?php echo $class; ?> hasTooltip" title="<?php echo $text; ?>"></i></h1>
                            <div class="clearfix"></div>
                            <span class="small"><?php echo $text; ?></span>
                        </a>
                    </li>
                </ul>
            </div>
            <?php
        } else {
            ?>
            <div class="pull-left">
                <ul style="list-style:none;">
                    <li>
                        <a class="btn thumbnail height-100 width-130 center" href="" <?php echo $javascript; ?>>
                            <img src="<?php echo $image; ?>" alt="<?php echo $text; ?>" align="top" style="margin-top: 10px;" border="0" />
                            <div class="clearfix"></div>
                            <span class="small" style="color:#BCBCBC;"><?php echo $text; ?></span>
                        </a>
                    </li>
                </ul>
            </div>
            <?php
        }
    }

}
