Exemplo n.º 1
0
    public function __construct()
    {
        static $loaded = false;
        if ($loaded) {
            return true;
        }
        $jConfig = JFactory::getConfig();
        defined('DS') || define('DS', DIRECTORY_SEPARATOR);
        require_once JPATH_SITE . '/components/com_sobipro/lib/sobi.php';
        if (method_exists($jConfig, 'getValue')) {
            Sobi::Init(JPATH_SITE, JFactory::getConfig()->getValue('config.language'));
        } else {
            Sobi::Init(JPATH_SITE, JFactory::getConfig()->get('config.language'));
        }
        if (!defined('SOBI_CMS')) {
            define('SOBI_CMS', version_compare(JVERSION, '3.0.0', 'ge') ? 'joomla3' : (version_compare(JVERSION, '1.6.0', 'ge') ? 'joomla16' : 'joomla15'));
        }
        SPLoader::loadClass('mlo.input');
        define('SOBIPRO_ADM', true);
        define('SOBI_ADM_PATH', JPATH_ADMINISTRATOR . '/components/com_sobipro');
        $adm = str_replace(JPATH_ROOT, null, JPATH_ADMINISTRATOR);
        define('SOBI_ADM_FOLDER', $adm);
        define('SOBI_ADM_LIVE_PATH', $adm . '/components/com_sobipro');
        SPLang::load('com_sobipro.sys');
        $head = SPFactory::header();
        if (SOBI_CMS == 'joomla3') {
            $head->addJsFile(array('sobipro', 'jqnc', 'adm.sobipro', 'adm.jmenu'));
        } else {
            $head->addJsFile(array('sobipro', 'jquery', 'adm.sobipro', 'adm.jmenu', 'jquery-migrate'));
        }
        if (SOBI_CMS != 'joomla3') {
            $head->addCssFile('bootstrap.bootstrap')->addJsFile(array('bootstrap'))->addCSSCode('
							#jform_request_SOBI_SELECT_SECTION-lbl { margin-top: 8px; }
                            #jform_request_cid-lbl { margin-top: 8px; }
                            #jform_request_eid-lbl { margin-top: 18px; }
                            #jform_request_sid-lbl { margin-top: 20px; }
                            #jform_request_sptpl-lbl { margin-top: 8px; }
                            .typeahead-width { width: 320px; }
					');
        } else {
            $head->addCSSCode('
                .typeahead-width { width: 70%; }
            ');
        }
        // Joomla! 1.5
        $this->cid = SPRequest::arr('cid');
        // Joomla! 1.6+
        if (!(count($this->cid) && is_numeric($this->cid[0]))) {
            $this->cid = SPRequest::int('id', 0);
        }
        $this->determineTask();
        $strings = array('objects' => array('entry' => Sobi::Txt('OTYPE_ENTRY'), 'category' => Sobi::Txt('OTYPE_CATEGORY'), 'section' => Sobi::Txt('OTYPE_SECTION')), 'labels' => array('category' => Sobi::Txt('SOBI_SELECT_CATEGORY'), 'entry' => Sobi::Txt('SOBI_SELECT_ENTRY')), 'task' => $this->task);
        $strings = json_encode($strings);
        $head->addJsCode("SPJmenuFixTask( '{$this->taskName}' );")->addJsFile('bootstrap.typeahead')->addJsCode("var SPJmenuStrings = {$strings}");
        if ($this->task != 'list.date') {
            if (SOBI_CMS == 'joomla3') {
                $head->addJsCode('SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( "#spCalendar" ).parent().parent().css( "display", "none" ); } );');
            } else {
                $head->addJsCode('SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( "#spCalendar" ).parent().css( "display", "none" ); } );');
            }
        } else {
            $head->addCSSCode('.SobiProCalendar .chzn-container {width: 100px!important; } ');
            $head->addCSSCode('.SobiProCalendar select {width: inherit;} ');
        }
        $head->send();
        parent::__construct();
        $loaded = true;
    }