Example #1
1
 /**
  *
  * Ajax render to store in session
  */
 public function ajaxGetRender()
 {
     /** load libraries for the system rener **/
     JSNFactory::localimport('libraries.joomlashine.mode.rawmode');
     JSNFactory::localimport('libraries.joomlashine.menu.menuitems');
     /** get url **/
     $render_url = JRequest::getVar('render_url', '');
     $urlRender = base64_decode($render_url);
     $session = JSession::getInstance('files', array('name' => 'jsnpoweradmin'));
     if ($render_url == '') {
         $urlRender = JSNDatabase::getDefaultPage()->link;
     }
     $currUri = new JURI($urlRender);
     if (!$currUri->hasVar('Itemid')) {
         $currUri->setVar('Itemid', JSNDatabase::getDefaultPage()->id);
     }
     $urlString = $currUri->toString();
     $session->set('rawmode_render_url', base64_encode($urlString));
     $parts = JString::parse_url($urlString);
     if (!empty($parts['query'])) {
         parse_str($parts['query'], $params);
     } else {
         $params = array();
     }
     $jsntemplate = JSNFactory::getTemplate();
     $jsnrawmode = JSNRawmode::getInstance($params);
     $jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions());
     $jsnrawmode->renderAll();
     $session = JSession::getInstance('files', array('name' => 'jsnajaxgetrender'));
     $session->set('component', $jsnrawmode->getHTML('component'));
     $session->set('jsondata', $jsnrawmode->getScript('positions', 'JSON'));
     jexit('success');
 }
 /**
  * 
  * Make array store all position in template
  */
 protected function makeArrayColumns()
 {
     //All position not defined in XML
     $this->_columns = array('user14', 'user15', 'user16', 'user17', 'user18', 'user19', 'user20', 'user21', 'user22', 'user23', 'user24', 'user25', 'user26', 'user27', 'bottom1', 'bottom2', 'bottom3', 'bottom4', 'bottom5');
     $template = JSNFactory::getTemplate();
     $positions = $template->loadXMLPositions();
     foreach ($positions as $position) {
         if (!in_array($position->name[0], $this->_columns)) {
             $this->_columns[] = (string) $position->name[0];
         }
     }
 }
 /**
  * Display function
  */
 public function display($tpl = null)
 {
     if (function_exists('error_reporting')) {
         error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT);
     }
     /** load libraries for the system rener **/
     JSNFactory::localimport('libraries.joomlashine.mode.rawmode');
     JSNFactory::localimport('libraries.joomlashine.menu.menuitems');
     /** Assignment variables **/
     $jsntemplate = JSNFactory::getTemplate();
     $jsnmenuitems = JSNMenuitems::getInstance();
     /** get url **/
     $render_url = JRequest::getVar('render_url', '');
     $session = JSession::getInstance('files', array('name' => 'jsnpoweradmin'));
     if ($render_url == '' && $session->get('rawmode_render_url')) {
         $render_url = $session->get('rawmode_render_url');
     }
     $urlRender = base64_decode($render_url);
     if ($render_url == '') {
         $urlRender = JSNDatabase::getDefaultPage()->link;
     }
     $currUri = new JURI($urlRender);
     if (!$currUri->hasVar('Itemid')) {
         $currUri->setVar('Itemid', JSNDatabase::getDefaultPage()->id);
     }
     $urlString = $currUri->toString();
     $session->set('rawmode_render_url', base64_encode($urlString));
     $parts = JString::parse_url($urlString);
     if (!empty($parts['query'])) {
         parse_str($parts['query'], $params);
     } else {
         $params = array();
     }
     $jsnrawmode = JSNRawmode::getInstance($params);
     $jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions());
     $jsnrawmode->renderAll();
     $this->assign('component', $jsnrawmode->getHTML('component'));
     $this->assign('modules', $jsnrawmode->getHTML('positions'));
     $this->assign('jsnmenuitems', $jsnmenuitems);
     $this->assign('urlRender', $urlRender);
     /** add toolbar buttons **/
     $this->addToolBar();
     /** add scripts and css **/
     //$this->addMedia( $currUri->getVar('Itemid'), $urlString, array());//$jsnrawmode->getScript('positions', 'Array'));
     $this->addMedia($currUri->getVar('Itemid'), $urlString, $jsnrawmode->getScript('positions', 'Array'));
     return parent::display();
 }
Example #4
0
 /**
  * Add jquery files
  * @return: Array
  */
 protected function addScripts()
 {
     $JSNMedia = JSNFactory::getMedia();
     $template = JSNFactory::getTemplate();
     $template_js_positions = $template->loadArrayJavascriptTemplatePositions(true);
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jquery-baseencode64.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.mousecheck.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.autodragdrop.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.submenu.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.visualmode.draganddrop.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.visualmode.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.showblock.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jstorage.js');
     $currentUrlInos = $this->jsnpwrender->getCurrentUrlInfos();
     $showTemplatePosition = $currentUrlInos->showTemplatePosition ? 'true' : 'false';
     $customscripts = "\n\t\t\t" . $template_js_positions . "\n\t\t\tvar jsnpoweradmin = true;\n\t\t\tvar baseUrl       = '" . JURI::root() . "';\n\t\t\tvar lang          = '" . $JSNMedia->getLang() . "';\n\t\t\tvar currItemid    = '" . $this->jsnpwrender->getCurrentItemid() . "';\n\n\t\t\t(function(\$){\n\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\tif (" . $showTemplatePosition . "){\n\t\t\t\t\t\t\$('.poweradmin-module-item').each(function(){\n\t\t\t\t\t\t\tvar el = \$(this);\n\t\t\t\t\t\t\tif ( el.attr('id').split('-')[0] == '0'){\n\t\t\t\t\t\t\t\tif (el.parent().find('.poweradmin-module-item').length == 1){\n\t\t\t\t\t\t\t\t\tel.parent().addClass('inactive-position');\n\t\t\t\t\t\t\t\t\tel.parent().html('<label class=\"jsn-position-name\">'+el.parent().attr('id').replace('-jsnposition', '')+'</label><a class=\"add-new-module\" title=\"Add new module to this position.\" href=\"javascript:;\"></a>');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tel.remove();\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tif (el.find('.mod-preview-wrapper').length > 0){\n\t\t\t\t\t\t\t\t\tvar moduleContent = \$('.mod-preview-wrapper', el).html();\n\t\t\t\t\t\t\t\t\tel.children().html( moduleContent );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof window.parent !== undefined){\n\t\t\t\t\t\tif (typeof window.parent.jQuery._visualmode.changeToolbar == 'function' ){\n\t\t\t\t\t\t\twindow.parent.jQuery._visualmode.changeToolbar('" . $currentUrlInos->urlString . "');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof window.parent.jQuery._visualmode.jsnRenderReady == 'function' ){\n\t\t\t\t\t\t\twindow.parent.jQuery._visualmode.jsnRenderReady();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\$.jsnmouse.init();\n\t\t\t\t\t//no show browser context menu\n\t    \t\t\t\$('body')[0].oncontextmenu = function() {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t })(JoomlaShine.jQuery);";
     $JSNMedia->addScriptDeclaration($customscripts);
     $this->assign('JSNMedia', $JSNMedia);
 }
 /**
  *
  * Add Scripts and StyleSheets for this view
  */
 protected function addMedia()
 {
     $JSNMedia = JSNFactory::getMedia();
     /* require jsnpwTemplate class */
     $template = JSNFactory::getTemplate();
     $template_js_positions = $template->loadArrayJavascriptTemplatePositions(true);
     $JSNMedia->addStyleDeclaration(JSN_POWERADMIN_LIB_JSUILAYOUT_URI, 'layout-default-latest.css');
     $JSNMedia->addStyleDeclaration(JSN_POWERADMIN_STYLE_URI, 'styles.css');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSUILAYOUT_URI . 'jquery.layout-latest.js');
     JSNHtmlAsset::addScript(JSN_FRAMEWORK_ASSETS . '/3rd-party/jquery-hotkeys/jquery.hotkeys.js');
     JSNHtmlAsset::addScript(JSN_FRAMEWORK_ASSETS . '/3rd-party/jquery-jstree/jquery.jstree.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jquery.topzindex.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jquery-baseencode64.js');
     JSNHtmlAsset::addScript(JSN_FRAMEWORK_ASSETS . '/3rd-party/jquery-jstorage/jquery.jstorage.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.menuitems.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.visualmode.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.submenu.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.mousecheck.js');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.functions.js');
     //check sef on/off
     $sef = JFactory::getConfig()->get('sef');
     $customScript = "\n\t\t" . $template_js_positions . "\n\t\tvar lang    = '" . $JSNMedia->getLang() . "';\n\t\tvar baseUrl = '" . JURI::root() . "';\n\t\tvar sef     = " . $sef . ";\n\n\t\t(function(\$){\n\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\$._visualmode.showLoading(true);\n\t\t\t\t\t\$( '.jsn-toolbar-button' ).buttonset();\n\t\t\t\t\t\$._visualmode.initLayout();\n\t\t\t\t\t\$.jsnmouse.init();\n\t\t\t\t\t\$._menuitems.init();\n\t\t\t\t\t\$._menuitems.layoutResize();\n\t\t\t\t\t\$._visualmode.init();\n                    \$(window).resize(function(){\n                    \t\$._visualmode.initLayout();\n                    });\n                    \$._visualmode.calculatorRate();\n\t\t\t\t\t//init status value and set it in to browser cookie\n\t\t\t\t\tvar index = \$.jStorage.index();\n\t\t\t\t\tif (!\$.inArray('module_highlight', index)){\n\t\t\t\t\t\t\$.jStorage.set('module_hightlight', false);\n\t\t\t\t\t\t\$.jStorage.set('inactive_position', false);\n\t\t\t\t\t\t\$.jStorage.set('unpublish_module', false);\n\t\t\t\t\t\t\$.jStorage.set('add_new_module', false);\n\t\t\t\t\t\t\$.jStorage.set('render_url', '');\n\t\t\t\t\t}\n\t\t\t\t\t/**\n\t\t\t\t\t * Support call to iframe page\n\t\t\t\t\t */\n\t\t\t\t\t\$.autoDragDrop = function(_ops){\n\t\t\t\t\t\twindow.frames.jsnrender.jQuery.autoDragDrop(_ops);\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t})(JoomlaShine.jQuery);\n\t\t";
     $JSNMedia->addScriptDeclaration($customScript);
 }
 /**
  * load current template
  *
  * @return: Add script to validate before submit form
  */
 public function getTemplate()
 {
     $this->_template = JSNFactory::getTemplate();
 }
 /** 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);
 }
Example #8
0
 /**
  * 
  * Get all modules assigned/unassign not default position
  * 
  * @param Array $defaultPositions
  * @param Number $Itemid
  * @return: Array 
  */
 public static function getModulesNotDefaultPosition($Itemid)
 {
     $instances = JSNModules::getInstance();
     $jsntemplate = JSNFactory::getTemplate();
     $positions = $jsntemplate->loadXMLPositions();
     $defaultPositions = "";
     foreach ($positions as $position) {
         $defaultPositions .= "'" . (string) $position->name . "',";
     }
     if (strlen($defaultPositions)) {
         $defaultPositions .= "''";
     }
     $app = JFactory::getApplication();
     $lang = JFactory::getLanguage()->getTag();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('id, title, module, position, content, showtitle, params, published, checked_out');
     $query->from('#__modules AS m');
     $query->where(' ( m.position NOT IN (' . $defaultPositions . ') OR m.position IS NULL OR m.position = "" ) ');
     $query->where('m.published <> -2');
     $date = JFactory::getDate();
     $nullDate = $db->getNullDate();
     $query->where('(m.publish_up = ' . $db->Quote($nullDate) . ' OR m.publish_up <= ' . $db->Quote($date) . ')');
     $query->where('(m.publish_down = ' . $db->Quote($nullDate) . ' OR m.publish_down >= ' . $db->Quote($date) . ')');
     $query->where('m.client_id = 0');
     // Filter by language
     if ($app->isSite() && $app->getLanguageFilter()) {
         $query->where('m.language IN (' . $db->Quote($lang) . ',' . $db->Quote('*') . ')');
     }
     $query->order('m.ordering ASC, m.title DESC, m.id DESC');
     // Set the query
     $db->setQuery($query);
     if (!($modules = @$db->loadObjectList())) {
         return;
     }
     // Apply negative selections and eliminate duplicates
     $clean = array();
     for ($i = 0, $n = count($modules); $i < $n; $i++) {
         $module =& $modules[$i];
         // Only accept modules without explicit exclusions.
         if (!isset($clean[$module->id])) {
             //determine if this is a custom module
             $file = $module->module;
             $custom = substr($file, 0, 4) == 'mod_' ? 0 : 1;
             $module->user = $custom;
             // Custom module name is given by the title field, otherwise strip off "com_"
             $module->name = $custom ? $module->title : substr($file, 4);
             $module->style = null;
             $module->position = strtolower($module->position);
             $module->assignment = $instances->getItemAssignmentType($module->id, $Itemid);
             $module->moduletype = $instances->getModuleType($module->id);
             $clean[$module->id] = $module;
         }
     }
     unset($dupes);
     // Return to simple indexing that matches the query order.
     $clean = array_values($clean);
     return $clean;
 }