Esempio n. 1
0
 function onAfterRoute()
 {
     $app = JFactory::getApplication();
     if ($app->getName() != 'site') {
         return true;
     }
     $option = JFactory::getApplication()->input->get('option', '', 'get');
     $Itemid = JFactory::getApplication()->input->get('Itemid', 0, 'get', 'int');
     $view = JFactory::getApplication()->input->get('view', 0, 'get');
     $id = JFactory::getApplication()->input->get('id', 0, 'get', 'int');
     //$allGet=JFactory::getApplication()->input->get('get');
     $allGet = array('Itemid' => $Itemid, 'option' => $option, 'view' => $view, 'id' => $id);
     //echo '<pre>allGet1::'.print_r($allGet,true).'</pre>';
     //$allGet=JRequest::get('get');
     $u = JURI::getInstance();
     $currentLink = $u->toString(array('path'));
     $uir = $_SERVER['REQUEST_URI'];
     $defvalue = array();
     $defvalue[0] = array();
     $defvalue['com_content'] = array();
     $defvalue[0]["var_name"][0] = 'task';
     $defvalue[0]["var_value"][0] = 'save, edit, add, delete, apply';
     $defvalue[0]["var_name"][1] = 'format';
     $defvalue[0]["var_value"][1] = 'nohtml';
     $defvalue[0]["var_name"][2] = 'no_html';
     $defvalue[0]["var_value"][2] = '1';
     $defvalue[0]["var_name"][3] = 'tmpl';
     $defvalue[0]["var_value"][3] = 'component';
     $defvalue['com_content']["checkbox"] = 'on';
     $defvalue['com_content']["var_name"][0] = '';
     $defvalue['com_content']["var_value"][0] = '';
     $componentsvars = $this->params->get('componentsvars', $defvalue);
     if (is_object($componentsvars)) {
         $componentsvars_array = array();
         foreach ($componentsvars as $k => $val) {
             if (is_object($val)) {
                 $val_arr = array();
                 foreach ($val as $kk => $vv) {
                     $val_arr[$kk] = $vv;
                 }
                 $val = $val_arr;
             }
             $componentsvars_array[$k] = $val;
         }
         $componentsvars = $componentsvars_array;
     }
     if (!isset($componentsvars[$option]["checkbox"])) {
         self::$noRedirect = true;
         return;
     }
     $cur_components = array(0, $option);
     foreach ($cur_components as $comp) {
         if (isset($componentsvars[$comp])) {
             for ($i = 0; $i < sizeof($componentsvars[$comp]["var_name"]); $i++) {
                 $var_name = $componentsvars[$comp]["var_name"][$i];
                 if (trim($componentsvars[$comp]["var_value"][$i])) {
                     $var_values = array_map('trim', explode(',', $componentsvars[$comp]["var_value"][$i]));
                     foreach ($var_values as $vvalue) {
                         if (isset($allGet[trim($var_name)]) && $allGet[trim($var_name)] == trim($vvalue)) {
                             self::$noRedirect = true;
                             return;
                         }
                     }
                 } else {
                     if (isset($allGet[$var_name])) {
                         self::$noRedirect = true;
                         return;
                     }
                 }
             }
         }
     }
     if ($option && $option != "com_content") {
         $allGetArr = array();
         foreach ($allGet as $ag_name => $ag_value) {
             if ($ag_name && $ag_value) {
                 $allGetArr[] = $ag_name . '=' . $ag_value;
             }
         }
         if (!$Itemid) {
             $app = JFactory::getApplication();
             $menus = $app->getMenu();
             //$menus = &JApplication::getMenu('site', array());
             $component_menu = $menus->getItems('component', $option);
             $Itemid = $component_menu[0]->id;
             if ($Itemid) {
                 $allGetArr[] = 'Itemid=' . $Itemid;
             }
         }
         /*if (JRequest::getInt('start') > 0){
         			 $currentLink .= "?start=" . JRequest::getVar('start');
         		}		
         		if (JRequest::getInt('limitstart') > 0){
         			 $currentLink .= "?limitstart=" . JRequest::getVar('limitstart');
         		}*/
         $redirectLink = JRoute::_('index.php?' . implode('&', $allGetArr));
         if ($redirectLink != $currentLink) {
             $this->shRedirect($redirectLink);
         }
     } else {
         if ($option == "com_content") {
             //$view=JRequest::getVar('view', '', 'get');
             if ($view == 'category') {
                 include_once JPATH_SITE . '/components/com_content/helpers/route.php';
                 $catlink = JRoute::_(ContentHelperRoute::getCategoryRoute($allGet['id']));
                 //echo '<pre>allGet1::'.print_r($catlink,true).'</pre>';
                 if (JRequest::getInt('start') > 0) {
                     $catlink .= "?start=" . JRequest::getVar('start');
                     $currentLink .= "?start=" . JRequest::getVar('start');
                 }
                 if ($catlink != $currentLink) {
                     $this->shRedirect($catlink);
                 }
             }
         }
     }
     return true;
 }
Esempio n. 2
0
 public function onAfterRoute()
 {
     $app = JFactory::getApplication();
     if ($app->getName() != 'site' || self::$noRedirect) {
         return true;
     }
     $option = $app->input->getCmd('option', '');
     $Itemid = $app->input->getInt('Itemid', 0);
     $view = $app->input->getCmd('view', '');
     $id = $app->input->getString('id', 0);
     $task = $app->input->getCmd('task', '');
     $layout = $app->input->getCmd('layout', '');
     $lang = $app->input->getCmd('lang', '');
     $allGet = array('Itemid' => $Itemid, 'option' => $option, 'view' => $view, 'id' => $id, 'task' => $task, 'layout' => $layout, 'lang' => $lang);
     $u = JUri::getInstance();
     $currentLink = $u->toString(array('path'));
     $uir = $_SERVER['REQUEST_URI'];
     $defValue = array(array('var_name' => array('task', 'format', 'no_html', 'tmpl'), 'var_value' => array('save, edit, add, delete, apply', 'nohtml', '1', 'component')), 'com_content' => array('checkbox' => 'on', 'var_name' => array(''), 'var_value' => array('')));
     $componentsvars = $this->params->get('componentsvars', $defValue);
     if (is_object($componentsvars)) {
         $tmp = array();
         foreach ($componentsvars as $k => $val) {
             $tmp[$k] = (array) $val;
         }
         $componentsvars = $tmp;
         unset($tmp);
     }
     if (!isset($componentsvars[$option]["checkbox"])) {
         self::$noRedirect = true;
         return true;
     }
     if (isset($componentsvars[$option])) {
         for ($i = 0; $i < sizeof($componentsvars[$option]["var_name"]); $i++) {
             $var_name = $componentsvars[$option]["var_name"][$i];
             if (trim($componentsvars[$option]["var_value"][$i])) {
                 $var_values = array_map('trim', explode(',', $componentsvars[$option]["var_value"][$i]));
                 foreach ($var_values as $vvalue) {
                     if (isset($allGet[trim($var_name)]) && $allGet[trim($var_name)] == trim($vvalue)) {
                         self::$noRedirect = true;
                         return true;
                     }
                 }
             } else {
                 if (isset($allGet[$var_name])) {
                     self::$noRedirect = true;
                     return true;
                 }
             }
         }
     }
     $helperPath = JPATH_ROOT . '/plugins/system/jlnodoubles/helpers/' . $option . '.php';
     $return = true;
     if (is_file($helperPath) && ($option == 'com_content' || self::$isPro)) {
         require_once $helperPath;
         $class = 'JLNodoubles_' . $option . '_helper';
         if (class_exists($class)) {
             $this->params->set('isPro', self::$isPro);
             $helper = new $class($this->params);
             if (method_exists($helper, 'go')) {
                 $return = $helper->go($allGet);
             }
         }
     }
     if ($option && $return == false) {
         $allGetArr = array();
         foreach ($allGet as $ag_name => $ag_value) {
             if ($ag_name && $ag_value) {
                 $allGetArr[] = $ag_name . '=' . $ag_value;
             }
         }
         if (!$Itemid) {
             $app = JFactory::getApplication();
             $menus = $app->getMenu();
             //$menus = &JApplication::getMenu('site', array());
             $component_menu = $menus->getItems('component', $option);
             $Itemid = $component_menu[0]->id;
             if ($Itemid) {
                 $allGetArr[] = 'Itemid=' . $Itemid;
             }
         }
         $redirectLink = JRoute::_('index.php?' . implode('&', $allGetArr));
         if ($redirectLink != $currentLink) {
             JLNodoublesHelper::getInstance($this->params)->shRedirect($redirectLink);
         }
     }
     return true;
 }