Exemplo n.º 1
0
 public static function getParams($reload = false)
 {
     if (!self::$params || $reload == true) {
         $app = JFactory::getApplication();
         // our params
         $params = new JRegistry();
         // component's global params
         $cparams = JComponentHelper::getParams('com_djcatalog2');
         // current params - all
         $aparams = $app->getParams();
         // curent params - djc2 only
         $mparams = $app->getParams('com_djcatalog2');
         // first let's use all current params
         $params->merge($aparams);
         // then override them with djc2 global settings - in case some other extension share's the same parameter name
         $params->merge($cparams);
         // finally, override settings with current params, but only related to djc2.
         $params->merge($mparams);
         // ...and then, override with category specific params
         $option = $app->input->get('option');
         $view = $app->input->get('view');
         if ($option = 'com_djcatalog2' && ($view = 'item' || ($view = 'items' || ($view = 'archived')))) {
             $user = JFactory::getUser();
             $groups = $user->getAuthorisedViewLevels();
             $categories = Djc2Categories::getInstance(array('state' => '1', 'access' => $groups));
             $category = $categories->get((int) $app->input->get('cid', 0, 'int'));
             if (!empty($category)) {
                 $catpath = array_reverse($category->getPath());
                 foreach ($catpath as $k => $v) {
                     $parentCat = $categories->get((int) $v);
                     if (!empty($parentCat) && !empty($category->params)) {
                         $catparams = new JRegistry($parentCat->params);
                         $params->merge($catparams);
                     }
                 }
             }
         }
         $listLayout = $app->input->get('l', $app->getUserState('com_djcatalog2.list_layout', null), 'cmd');
         if ($listLayout == 'items') {
             $app->setUserState('com_djcatalog2.list_layout', 'items');
             $params->set('list_layout', 'items');
         } else {
             if ($listLayout == 'table') {
                 $app->setUserState('com_djcatalog2.list_layout', 'table');
                 $params->set('list_layout', 'table');
             }
         }
         $catalogMode = $app->input->get('cm', null, 'int');
         $indexSearch = $app->input->get('ind', null, 'string');
         $globalSearch = urldecode($app->input->get('search', '', 'string'));
         $globalSearch = trim(JString::strtolower($globalSearch));
         if (substr($globalSearch, 0, 1) == '"' && substr($globalSearch, -1) == '"') {
             $globalSearch = substr($globalSearch, 1, -1);
         }
         if (strlen($globalSearch) > 0 && strlen($globalSearch) < 3 || strlen($globalSearch) > 20) {
             $globalSearch = null;
         }
         if ($catalogMode === 0 || $globalSearch || $indexSearch) {
             $params->set('product_catalogue', '0');
             // set 'filtering' variable in REQUEST
             // so we could hide for example sub-categories
             // when searching/filtering is performed
             $app->input->set('filtering', true);
         }
         self::$params = $params;
     }
     return self::$params;
 }