Пример #1
0
 /**
  * Override
  *
  * @see VmModel::setPaginationLimits()
  */
 public function setPaginationLimits()
 {
     $app = JFactory::getApplication();
     $view = vRequest::getCmd('view', 'virtuemart');
     $cateid = vRequest::getInt('virtuemart_category_id', -1);
     $manid = vRequest::getInt('virtuemart_manufacturer_id', 0);
     $limitString = 'com_virtuemart.' . $view . 'c' . $cateid . '.limit';
     $limit = (int) $app->getUserStateFromRequest($limitString, 'limit');
     $limitStartString = 'com_virtuemart.' . $view . '.limitstart';
     if ($app->isSite() and ($cateid != -1 or $manid != 0)) {
         //vmdebug('setPaginationLimits is site and $cateid,$manid ',$cateid,$manid);
         $lastCatId = ShopFunctionsf::getLastVisitedCategoryId();
         $lastManId = ShopFunctionsf::getLastVisitedManuId();
         if (!empty($cateid) and $cateid != -1) {
             $gCatId = $cateid;
         } else {
             if (!empty($lastCatId)) {
                 $gCatId = $lastCatId;
             }
         }
         if (!empty($gCatId)) {
             $catModel = VmModel::getModel('category');
             $category = $catModel->getCategory($gCatId);
         } else {
             $category = new stdClass();
         }
         if (!empty($lastCatId) and $lastCatId != $cateid or !empty($manid) and $lastManId != $manid) {
             //We are in a new category or another manufacturer, so we start at page 1
             $limitStart = vRequest::getInt('limitstart', 0, 'GET');
         } else {
             //We were already in the category/manufacturer, so we take the value stored in the session
             $limitStartString = 'com_virtuemart.' . $view . 'c' . $cateid . 'm' . $manid . '.limitstart';
             $limitStart = $app->getUserStateFromRequest($limitStartString, 'limitstart', vRequest::getInt('limitstart', 0, 'GET'), 'int');
         }
         if (empty($limit) and !empty($category->limit_list_initial)) {
             $suglimit = $category->limit_list_initial;
         } else {
             if (!empty($limit)) {
                 $suglimit = $limit;
             } else {
                 $suglimit = VmConfig::get('llimit_init_FE', 24);
             }
         }
         if (empty($category->products_per_row)) {
             $category->products_per_row = VmConfig::get('products_per_row', 3);
         }
         $rest = $suglimit % $category->products_per_row;
         $limit = $suglimit - $rest;
         if (!empty($category->limit_list_step)) {
             $prod_per_page = explode(",", $category->limit_list_step);
         } else {
             //fix by hjet
             $prod_per_page = explode(",", VmConfig::get('pagseq_' . $category->products_per_row));
         }
         if ($limit <= $prod_per_page['0'] && array_key_exists('0', $prod_per_page)) {
             $limit = $prod_per_page['0'];
         }
         //vmdebug('Calculated $limit  ',$limit,$suglimit);
     } else {
         $limitStart = $app->getUserStateFromRequest('com_virtuemart.' . $view . '.limitstart', 'limitstart', vRequest::getInt('limitstart', 0, 'GET'), 'int');
     }
     if (empty($limit)) {
         if ($app->isSite()) {
             $limit = VmConfig::get('llimit_init_FE', 24);
         } else {
             $limit = VmConfig::get('llimit_init_BE', 30);
         }
         if (empty($limit)) {
             $limit = 30;
         }
     }
     $this->setState('limit', $limit);
     $this->setState($limitString, $limit);
     $this->_limit = $limit;
     //There is a strange error in the frontend giving back 9 instead of 10, or 24 instead of 25
     //This functions assures that the steps of limitstart fit with the limit
     $limitStart = ceil((double) $limitStart / (double) $limit) * $limit;
     $this->setState('limitstart', $limitStart);
     $this->setState($limitStartString, $limitStart);
     $this->_limitStart = $limitStart;
     return array($this->_limitStart, $this->_limit);
 }
Пример #2
0
 /**
  * Override
  *
  * @see VmModel::setPaginationLimits()
  */
 public function setPaginationLimits()
 {
     $app = JFactory::getApplication();
     $view = JRequest::getWord('view');
     $cateid = JRequest::getInt('virtuemart_category_id', 0);
     $limit = (int) $app->getUserStateFromRequest('com_virtuemart.' . $view . $cateid . '.limit', 'limit');
     if ($app->isSite() and $cateid != 0) {
         $lastCatId = ShopFunctionsf::getLastVisitedCategoryId();
         if ($lastCatId != $cateid) {
             $limitStart = 0;
         } else {
             $limitStart = $app->getUserStateFromRequest('com_virtuemart.' . $view . '.limitstart', 'limitstart', JRequest::getInt('limitstart', 0), 'int');
         }
         $catModel = VmModel::getModel('category');
         $category = $catModel->getCategory();
         if (empty($limit)) {
             if (!empty($category->limit_list_initial)) {
                 $suglimit = $category->limit_list_initial;
             } else {
                 if (empty($category->limit_list_step)) {
                     $suglimit = VmConfig::get('list_limit', 20);
                 } else {
                     $suglimit = $category->limit_list_step;
                 }
             }
             if (empty($category->products_per_row)) {
                 $category->products_per_row = VmConfig::get('products_per_row', 3);
             }
             $rest = $suglimit % $category->products_per_row;
             $limit = $suglimit - $rest;
         }
         //vmdebug('my cat',$category);
         //vmdebug('Looks like the category lastCatId '.$lastCatId.' actual id '.$cateid );
     } else {
         $limitStart = $app->getUserStateFromRequest('com_virtuemart.' . $view . '.limitstart', 'limitstart', JRequest::getInt('limitstart', 0), 'int');
     }
     if (empty($limit)) {
         $limit = VmConfig::get('list_limit', 20);
     }
     $this->setState('limit', $limit);
     $this->setState('com_virtuemart.' . $view . $cateid . '.limit', $limit);
     $this->_limit = $limit;
     //There is a strange error in the frontend giving back 9 instead of 10, or 24 instead of 25
     //This functions assures that the steps of limitstart fit with the limit
     $limitStart = ceil((double) $limitStart / (double) $limit) * $limit;
     $this->setState('limitstart', $limitStart);
     $this->setState('com_virtuemart.' . $view . $cateid . '.limitstart', $limitStart);
     $this->_limitStart = $limitStart;
     return array($this->_limitStart, $this->_limit);
 }