Пример #1
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     // Check if this view is used for module editing page.
     $moduleEdit = JRequest::getCmd('moduleedit', '');
     $active_positions = array();
     $model = $this->getModel('changeposition');
     if (!$moduleEdit) {
         $moduleid = $app->getUserState('com_poweradmin.changeposition.moduleid');
     } else {
         $moduleid = array(JRequest::getCmd('moduleid', ''));
     }
     for ($i = 0; $i < count($moduleid); $i++) {
         $active_positions[] = "\$('#" . $model->getModulePosition($moduleid[$i]) . "-jsnposition').addClass('active-position').attr('title', 'Active position');";
     }
     JSNHtmlAsset::addScript(JURI::root(true) . '/media/jui/js/jquery.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.jquery.noconflict.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.functions.js');
     //$document->addScript(JSN_POWERADMIN_LIB_JSNJS_URI. 'jsn.filter.visualmode.js');
     //Enable position filter.
     $this->setFilterable(true);
     $customScript = "\n\t\t\tvar baseUrl  = '" . JURI::root() . "';\n\t\t\tvar moduleid = new Array();\n\t\t\tmoduleid = [" . @implode(",", $moduleid) . "];\n\t\t\t(function (\$){\n\t\t\t\t\$(document).ready(function (){\n\t\t\t\t\t" . implode(PHP_EOL, $active_positions) . "\n\t\t\t\t});\n\t\t\t})(JoomlaShine.jQuery);\n \t\t";
     $this->addCustomScripts($customScript);
     //Callback after position clicked.
     if (!$moduleEdit) {
         $onPostionClick = "\n \t\t\tif ( !\$(this).hasClass('active-position') ){\n\t\t\t\tJoomlaShine.jQuery.setPosition(moduleid, \$(this).attr('id').replace('-jsnposition', ''));\n \t\t\t\tparent.JoomlaShine.jQuery('.ui-dialog-content').dialog('close');\n \t\t\t}\n \t\t\t";
     } else {
         $onPostionClick = "\n \t\t\tif ( !\$(this).hasClass('active-position') ){\n \t\t\t\tvar posName = \$(this).attr('id').replace('-jsnposition', '');\n \t\t\t\tparent.JoomlaShine.jQuery('#jform_position').val(posName);\n \t\t\t\tparent.modal.close();\n \t\t\t}\n \t\t\t";
     }
     $this->addPositionClickCallBack($onPostionClick);
     $template = JSNTemplateHelper::getInstance();
     $onPositionClick = '';
     $initFilter = '';
     $displayNotice = $app->input->getInt('notice');
     $bypassNotif = $app->input->getVar('bypassNotif', '');
     // Get template author.
     $templateAuthor = $template->getAuthor();
     JSNPositionsHelper::dispatchTemplateFramework($templateAuthor);
     $document->addStyleSheet(JSN_URL_ASSETS . '/joomlashine/css/jsn-positions.css');
     if (JSNVersion::isJoomlaCompatible('3.0')) {
         $document->addScript(JURI::root(true) . '/media/jui/js/jquery.js');
     } else {
         $document->addScript(JSN_URL_ASSETS . '/3rd-party/jquery/jquery-1.8.2.js');
     }
     if (isset($this->filterEnabled) and $this->filterEnabled) {
         $document->addScript(JSN_URL_ASSETS . '/joomlashine/js/positions.filter.js');
         $initFilter = 'changeposition = new JoomlaShine.jQuery.visualmodeFilter({});';
     }
     if (isset($this->customScripts)) {
         $document->addScriptDeclaration(implode('\\n', $this->customScripts));
     }
     $onPositionClick = isset($this->onPositionClickCallBack) ? implode('\\n', $this->onPositionClickCallBack) : '';
     // Get JSN Template Framework version
     $db = JFactory::getDbo();
     $q = $db->getQuery(true);
     $q->select('manifest_cache');
     $q->from('#__extensions');
     $q->where("element = 'jsntplframework'");
     $q->where("type = 'plugin'", 'AND');
     $q->where("folder = 'system'", 'AND');
     $db->setQuery($q);
     // Load dependency installation status.
     $res = $db->loadObject();
     $res = json_decode($res->manifest_cache);
     $jsnTplFwVersion = $res->version;
     $jsnTemplateCustomJs = '';
     if (version_compare($jsnTplFwVersion, '2.0.1', '<=')) {
         $jsnTemplateCustomJs = "\$('body').addClass('jsn-bootstrap');";
     }
     $_customScript = "\n\t\t\tvar changeposition;\n\t\t\t(function(\$){\n\t\t\t\t\$(document).ready(function (){\n\t\t\t\t\tvar posOutline\t= \$('.jsn-position');\n\t\t\t\t\tvar _idAlter\t= false;\n\t\t\t\t\tif (\$('.jsn-position').length == 0) {\n\t\t\t\t\t\tposOutline\t= \$('.mod-preview');\n\t\t\t\t\t\t_idAlter\t= true;\n\t\t\t\t\t}else{\n\t\t\t\t\t\tposOutline.css({'z-index':'9999', 'position':'relative'});\n\t\t\t\t\t}\n\t\t\t\t\tposOutline.each(function(){\n\t\t\t\t\t\tif(_idAlter){\n\t\t\t\t\t\t\tpreviewInfo = \$(this).children('.mod-preview-info').text();\n\n\t\t\t\t\t\t\t_splitted = previewInfo.split('[');\n\t\t\t\t\t\t\tif(_splitted.length > 1){\n\t\t\t\t\t\t\t\tposname\t= _splitted[0];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t_splitted = posname.split(': ');\n\t\t\t\t\t\t\tif(_splitted.length > 1){\n\t\t\t\t\t\t\t\tposname\t= _splitted[1];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tposname = \$.trim(posname);\n\n\t\t\t\t\t\t\t\$(this).attr('id', posname + '-jsnposition');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\$(this)[0].oncontextmenu = function() {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.click(function () {\n\t\t\t\t\t\t" . $onPositionClick . "\n\t\t\t\t\t});\n\t\t\t\t\t" . $jsnTemplateCustomJs . "\n\t\t\t\t});\n\t\t\t\t" . $initFilter . "\n\t\t\t\t\n\t\t\t})(jQuery);\n\t\t";
     $document->addScriptDeclaration($_customScript);
     $previewModulePositionsIsEnabled = JComponentHelper::getParams('com_templates')->get('template_positions_display', 0);
     if (!$previewModulePositionsIsEnabled) {
         /**
          * Get config class
          */
         JSNFactory::localimport('libraries.joomlashine.config');
         JSNConfig::extension('com_templates', array('template_positions_display' => 1));
     }
     $config = JFactory::getConfig();
     $secret = $config->get('secret');
     $jsnrender = JSNPositionsRender::getInstance();
     $jsnrender->renderPage(JURI::root() . 'index.php?poweradmin=1&vsm_changeposition=1&tp=1&jsnpa_key=' . md5($secret), 'changePosition');
     $this->jsnrender = $jsnrender;
     parent::display($tpl);
 }
 /** Constructor function **/
 function __construct(&$subject, $config)
 {
     // Check if JSN Framework installed & enabled.
     $jsnframework = JPluginHelper::getPlugin('system', 'jsnframework');
     if (!$jsnframework || !file_exists(JPATH_ROOT . '/plugins/system/jsnframework')) {
         return;
     }
     JSNFactory::import('plugins.system.jsnframework.libraries.joomlashine.config.helper', 'site');
     JSNFactory::import('plugins.system.jsnframework.libraries.joomlashine.utils.xml', 'site');
     $this->_params = JSNConfigHelper::get('com_poweradmin');
     $this->_application = JFactory::getApplication();
     $this->_user = JFactory::getUser();
     $this->_session = JFactory::getSession();
     $this->_preview = new JSNPowerAdminBarPreview();
     $this->loadLanguage('plg_system_jsnpoweradmin');
     $this->_removeAdminBarPlugin();
     $app = JFactory::getApplication();
     $input = $app->input;
     $poweradmin = $input->getCmd('poweradmin', 0);
     $showTemplatePosition = $input->getCmd('tp', 0);
     if ($app->isAdmin()) {
         $user = JFactory::getUser();
         if ($input->getVar('view', '') == 'jsnrender' && $user->id == 0) {
             jimport('joomla.application.component.controller');
             JController::setRedirect(JSN_VISUALMODE_PAGE_URL);
             JController::redirect();
         }
     }
     if ($poweradmin == 1) {
         /**
          * Auto-enable Preview Module Positions of template setting
          */
         if ($showTemplatePosition == 1) {
             $PreviewModulePositionsIsEnabled = JComponentHelper::getParams('com_content')->get('template_positions_display', 0) == 1 ? true : false;
             if (!$PreviewModulePositionsIsEnabled) {
                 /**
                  * Get config class
                  */
                 JSNFactory::localimport('libraries.joomlashine.config');
                 JSNConfig::extension('com_templates', array('template_positions_display' => 1));
             }
         }
         /** load JSNPOWERADMIN template library **/
         $template = JSNFactory::getTemplate();
         $this->_templateAuthor = $template->getAuthor();
         /*if T3 Framework*/
         if ($this->_templateAuthor == 'joomlart') {
             //check folder jat3 exists
             $t3FrameworkFolder = JPATH_ROOT . 'plugins/system/jat3';
             if (is_dir($t3FrameworkFolder)) {
                 if (!class_exists('T3Common')) {
                     jimport('joomla.html.parameter');
                     JSNFactory::import('plugins.system.jat3.jat3.core.common', 'site');
                 }
                 if (!class_exists('T3Framework')) {
                     JSNFactory::import('plugins.system.jat3.jat3.core.framework', 'site');
                     $jt3Plg = JPluginHelper::getPlugin('system', 'jat3');
                     T3Framework::t3_init($jt3Plg->params);
                 }
                 JSNFactory::import('plugins.system.jsnpoweradmin.libraries.jsnjoomlart', 'site');
             }
         } else {
             if ($this->_templateAuthor == 'yootheme') {
                 return;
             } else {
                 if ($this->_templateAuthor == 'gavick') {
                     JSNFactory::import('libraries.joomla.environment.browser', 'site');
                     $browser = JBrowser::getInstance();
                     $browser->setBrowser('JSNPoweradmin');
                 } else {
                     if ($this->_templateAuthor == 'joomlaxtc') {
                         JSNFactory::import('plugins.system.jsnpoweradmin.libraries.jsnjoomlaxtc', 'site');
                     }
                 }
             }
         }
         $this->_helper = JSNPLGHelper::getInstance();
     }
     parent::__construct($subject, $config);
 }