Beispiel #1
0
 function getPagination()
 {
     $pagination = parent::getPagination();
     $pagination->total = $this->total;
     if ($pagination->total % $pagination->limit > 0) {
         $nr_pages = intval($pagination->total / $pagination->limit) + 1;
     } else {
         $nr_pages = intval($pagination->total / $pagination->limit);
     }
     $pagination->set('pages.total', $nr_pages);
     $pagination->set('pages.stop', $nr_pages);
     return $pagination;
 }
Beispiel #2
0
 /**
  * Tests the getPagination method.
  *
  * @since   3.4
  *
  * @return  void
  *
  * @testdox getPagination() stores JPagination object in object cache
  */
 public function testGetPaginationSavesPaginationObjectInCache()
 {
     TestReflection::setValue($this->object, '__state_set', true);
     $this->object->getPagination();
     $this->assertArrayHasKey('0b072c19169b805b8ecca41340f0e20a', TestReflection::getValue($this->object, 'cache'));
 }
Beispiel #3
0
 public function getPagination()
 {
     return parent::getPagination();
 }
 /**
  * Method to get a JPagination object for the data set.
  *
  * @return  JPagination  A JPagination object for the data set.
  */
 public function getPagination()
 {
     if ($this->getState('list.limit', 20) == 0) {
         return;
     }
     $pagination = parent::getPagination();
     $pagination->prefix = 'slicomments';
     $url = ContentHelperRoute::getArticleRoute($this->getState('article.slug'), $this->getState('article.catid'));
     $uri = new JUri($url);
     $query = $uri->getQuery(true);
     foreach ($query as $key => $value) {
         $pagination->setAdditionalUrlParam($key, $value);
     }
     return $pagination;
 }
Beispiel #5
0
 /**
  * Method to get a list of newsletters.
  *
  * Overriden to inject convert the attribs field into a JParameter object.
  *
  * @return	mixed	An array of objects on success, false on failure.
  *
  * @since	1.0.1
  */
 public function getItems()
 {
     $items = parent::getItems();
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $guest = $user->get('guest');
     $groups = $user->getAuthorisedViewLevels();
     $this->_pagination = parent::getPagination();
     // Convert the parameter fields into objects.
     foreach ($items as &$item) {
         $item->params = clone $this->getState('params');
         // Get display date
         switch ($item->params->get('list_show_date')) {
             case 'modified_time':
                 $item->displayDate = $item->modified_time;
                 break;
             case 'published':
                 $item->displayDate = $item->publish_up == 0 ? $item->created_date : $item->publish_up;
                 break;
             case 'created_date':
                 $item->displayDate = $item->created_date;
                 break;
             default:
             case 'mailing_date':
                 $item->displayDate = $item->mailing_date;
                 break;
         }
         // Compute the asset access permissions.
         // Technically guest could edit an newsletter, but lets not check that to improve performance a little.
         if (!$guest) {
             $asset = 'com_bwpostman.newsletter.' . $item->id;
             // Check general edit permission first.
             if ($user->authorise('core.edit', $asset)) {
                 $item->params->set('access-edit', true);
             } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) {
                 // Check for a valid user and that they are the owner.
                 if ($userId == $item->created_by) {
                     $item->params->set('access-edit', true);
                 }
             }
         }
         $access = $this->getState('filter.access');
         if ($access) {
             // If the access filter has been set, we already have only the newsletters this user can view.
             $item->params->set('access-view', true);
         } else {
             // If no access filter is set, the layout takes some responsibility for display of limited information.
             $item->params->set('access-view', in_array($item->access, $groups));
         }
         // Get the tags
         $item->tags = new JHelperTags();
         $item->tags->getItemTags('com_bwpostman.newsletter', $item->id);
     }
     return $items;
 }
 /**
  * Method to get a JPagination object for the data set.
  *
  * @return  JPagination  A JPagination object for the data set.
  * @since       1.0.0
  */
 public function getPagination()
 {
     if ($this->getState('filter.extension_name')) {
         $page = parent::getPagination();
     } else {
         // Create the pagination object.
         jimport('joomla.html.pagination');
         $limit = (int) $this->getState('list.limit') - (int) $this->getState('list.links');
         $page = new JPagination(0, 0, $limit);
     }
     return $page;
 }