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);
 }
Example #2
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $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);
     $jsnrender = JSNPositionsRender::getInstance();
     $jsnrender->renderPage(JURI::root() . 'index.php?poweradmin=1&vsm_changeposition=1&tp=1', 'changePosition');
     $this->assignRef('jsnrender', $jsnrender);
     parent::display($tpl);
 }