コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function initialize(ConfigInterface $objConfig, PanelElementInterface $objElement = null)
 {
     if (is_null($objElement)) {
         $objTempConfig = $this->getOtherConfig();
         $arrTotal = $this->getEnvironment()->getDataProvider()->fetchAll($objTempConfig->setIdOnly(true));
         $this->intTotal = $arrTotal ? count($arrTotal) : 0;
         $offset = 0;
         // TODO: we need to determine the perPage some better way.
         $amount = $GLOBALS['TL_CONFIG']['resultsPerPage'];
         $input = $this->getInputProvider();
         if ($this->getPanel()->getContainer()->updateValues() && $input->hasValue('tl_limit')) {
             $limit = explode(',', $input->getValue('tl_limit'));
             $offset = $limit[0];
             $amount = $limit[1];
             $this->setPersistent($offset, $amount);
         }
         $persistent = $this->getPersistent();
         if ($persistent) {
             $offset = $persistent['offset'];
             $amount = $persistent['amount'];
             // Hotfix the offset - we also might want to store it persistent.
             // Another way would be to always stick on the "last" page when we hit the upper limit.
             if ($offset > $this->intTotal) {
                 $offset = 0;
             }
         }
         if (!is_null($offset)) {
             $this->setOffset($offset);
             $this->setAmount($amount);
         }
     }
     $objConfig->setStart($this->getOffset());
     $objConfig->setAmount($this->getAmount());
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function initialize(ConfigInterface $objConfig, PanelElementInterface $objElement = null)
 {
     if ($objElement === null) {
         $this->calculateTotal();
         $offset = 0;
         $amount = $this->getItemsPerPage();
         $input = $this->getInputProvider();
         if ($this->getPanel()->getContainer()->updateValues() && $input->hasValue('tl_limit')) {
             $limit = explode(',', $input->getValue('tl_limit'));
             $offset = $limit[0];
             $amount = $limit[1];
             $this->setPersistent($offset, $amount);
         }
         $persistent = $this->getPersistent();
         if ($persistent) {
             $offset = $persistent['offset'];
             $amount = $persistent['amount'];
             // Hotfix the offset - we also might want to store it persistent.
             // Another way would be to always stick on the "last" page when we hit the upper limit.
             if ($offset > $this->intTotal) {
                 $offset = 0;
             }
         }
         if ($offset !== null) {
             $this->setOffset($offset);
             $this->setAmount($amount);
         }
     }
     $objConfig->setStart($this->getOffset());
     $objConfig->setAmount($this->getAmount());
 }