Пример #1
0
 /**
  *
  * Get config instanced
  */
 public static function getConfig()
 {
     JSNFactory::localimport('libraries.joomlashine.config');
     if (!isset(self::$config)) {
         self::$config = JSNConfig::getInstance();
     }
     return self::$config;
 }
Пример #2
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);
 }
Пример #4
0
 /**
  * Get featured items
  * 
  */
 public function getData($pk)
 {
     JSNFactory::localimport('libraries.joomlashine.config');
     $params = JSNConfig::getMenuParams($pk['Itemid']);
     JSNConfig::megreGlobalParams('com_content', $params);
     $this->setState('params', $params);
     $data = new stdClass();
     $data->params = $params;
     $activeAllParams = new JRegistry();
     if ($params instanceof JRegistry) {
         foreach ($params->toArray() as $key => $val) {
             if (strpos($key, 'show_') !== false && (int) $params->get($key) == 0) {
                 $activeAllParams->set($key, 1);
             } else {
                 $activeAllParams->set($key, $val);
             }
         }
     }
     $limit = (int) $params->def('num_leading_articles', 1) + (int) $params->get('num_intro_articles', 4) + (int) $params->def('num_links', 4);
     $this->setState('params', $activeAllParams);
     $this->setState('filter.published', 1);
     $this->setState('filter.access', '');
     $this->setState('list.start', 0);
     $this->setState('list.limit', $limit);
     $this->setState('list.direction', '');
     $this->setState('list.filter', '');
     // filter.subcategories indicates whether to include articles from subcategories in the list or blog
     $this->setState('list.links', $activeAllParams->get('num_links'));
     if ($activeAllParams->get('featured_categories') && implode(',', $activeAllParams->get('featured_categories')) == true) {
         $this->setState('filter.frontpage.categories', $activeAllParams->get('featured_categories'));
     }
     $this->setState('filter.frontpage', 1);
     $items = parent::getItems();
     // PREPARE THE DATA
     // Get the metrics for the structural page layout.
     $numLeading = $params->def('num_leading_articles', 1);
     $numIntro = $params->def('num_intro_articles', 4);
     $numLinks = $params->def('num_links', 4);
     // Compute the article slugs and prepare introtext (runs content plugins).
     foreach ($items as $i => &$item) {
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         // Ignore content plugins on links.
         if ($i < $numLeading + $numIntro) {
             $item->introtext = JHtml::_('content.prepare', $item->introtext);
         }
     }
     // Preprocess the breakdown of leading, intro and linked articles.
     // This makes it much easier for the designer to just interogate the arrays.
     $max = count($items);
     // The first group is the leading articles.
     $limit = $numLeading;
     for ($i = 0; $i < $limit && $i < $max; $i++) {
         $data->lead_items[$i] =& $items[$i];
     }
     // The second group is the intro articles.
     $limit = $numLeading + $numIntro;
     // Order articles across, then down (or single column mode)
     for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
         $data->intro_items[$i] =& $items[$i];
     }
     $data->columns = max(1, $params->def('num_columns', 1));
     $order = $params->def('multi_column_order', 1);
     if ($order == 0 && $data->columns > 1) {
         // call order down helper
         $data->intro_items = ContentHelperQuery::orderDownColumns($data->intro_items, $data->columns);
     }
     // The remainder are the links.
     for ($i = $numLeading + $numIntro; $i < $max; $i++) {
         $data->link_items[$i] =& $items[$i];
     }
     $data->pagination = $this->getPagination();
     //Escape strings for HTML output
     $data->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     return $data;
 }