示例#1
0
 /**
  * Return the first limit we can find
  * @param   array
  * @param   int
  * @return  int
  */
 public function getFirstLimitForModules(array $arrIds, $intDefault = 0)
 {
     if (null !== $this->arrLimits) {
         foreach ($arrIds as $id) {
             if (isset($this->arrLimits[$id])) {
                 return $this->arrLimits[$id];
             }
         }
     }
     return Limit::to($intDefault);
 }
 /**
  * Generate a limit form
  */
 protected function generateLimit()
 {
     $this->Template->hasLimit = false;
     if ($this->iso_enableLimit) {
         $arrOptions = array();
         $arrLimit = array_map('intval', trimsplit(',', $this->iso_perPage));
         $objLimit = Isotope::getRequestCache()->getFirstLimitForModules(array($this->id));
         $arrLimit = array_unique($arrLimit);
         sort($arrLimit);
         if ($this->blnUpdateCache && in_array(\Input::post('limit'), $arrLimit)) {
             // Cache new request value
             Isotope::getRequestCache()->setLimitForModule(Limit::to(\Input::post('limit')), $this->id);
         } elseif ($objLimit->notIn($arrLimit)) {
             // Request cache contains wrong value, delete it!
             $this->blnUpdateCache = true;
             Isotope::getRequestCache()->setLimitForModule(Limit::to($arrLimit[0]), $this->id);
             RequestCache::deleteById(\Input::get('isorc'));
         } elseif (!$this->blnUpdateCache) {
             // No need to generate options if we reload anyway
             foreach ($arrLimit as $limit) {
                 $arrOptions[] = array('label' => $limit, 'value' => $limit, 'default' => $objLimit->equals($limit) ? '1' : '');
             }
             $this->Template->hasLimit = true;
             $this->Template->limitLabel = $GLOBALS['TL_LANG']['MSC']['perPageLabel'];
             $this->Template->limitOptions = $arrOptions;
         }
     }
 }