/** * Kunena Component * @package Kunena.Framework * @subpackage Forum * * @copyright (C) 2008 - 2016 Kunena Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @link https://www.kunena.org **/ defined ( '_JEXEC' ) or die (); /** * class KunenaForum * * Main class for Kunena Forum which is always present if Kunena framework has been installed. * * This class can be used to detect and initialize Kunena framework and to make sure that your extension * is compatible with the current version. */ abstract class KunenaForum { protected static $version = false; protected static $version_major = false; protected static $version_date = false; protected static $version_name = false; const PUBLISHED = 0; const UNAPPROVED = 1; const DELETED = 2; const TOPIC_DELETED = 3; const TOPIC_CREATION = 4; const MODERATOR = 1; const ADMINISTRATOR = 2; /** * Check if Kunena Forum is safe to be used. * * If installer is running, it's unsafe to use our framework. Files may be currently replaced with * new ones and the database structure might be inconsistent. Using forum during installation will * likely cause fatal errors and data corruption if you attempt to update objects in the database. * * Always detect Kunena in your code before you start using the framework: * * * // Check if Kunena Forum has been installed and compatible with your code * if (class_exists('KunenaForum') && KunenaForum::installed() && KunenaForum::isCompatible('2.0.0')) { * // Initialize the framework (new in 2.0.0) * KunenaForum::setup(); * // Start using the framework * } * * * @see KunenaForum::enabled() * @see KunenaForum::isCompatible() * @see KunenaForum::setup() * * @return boolean True if Kunena has been fully installed. */ public static function installed() { return !is_file(KPATH_ADMIN . '/install.php') || self::isDev(); } /** * Checks if Kunena Forum is safe to be used and online. * * It is a good practice to check if Kunena Forum is online before displaying * forum content to the user. It's even more important if you allow user to post * or manipulate forum! By following this practice administrator can have single * point which he can use to be sure that nobody has access to any data inside * his forum. * * Use case: Administrator is upgrading his forum to the next major version and wants * to be sure that everything works before putting forum back to online. He logs in * and can see everything. For everyone else no forum related information is shown. * * * // Check if Kunena Forum has been installed, online and compatible with your code * if (class_exists('KunenaForum') && KunenaForum::enabled() && KunenaForum::isCompatible('2.0.0')) { * // Initialize the framework (new in 2.0.0) * KunenaForum::setup(); * // It's now safe to display something or to save Kunena objects *} * * * @see KunenaForum::installed() * @see KunenaForum::isCompatible() * @see KunenaForum::setup() * * @param boolean $checkAdmin True if administrator is considered as a special case. * @return boolean True if online. */ public static function enabled($checkAdmin = true) { if (!JComponentHelper::isEnabled('com_kunena', true)) { return false; } $config = KunenaFactory::getConfig(); return !$config->board_offline || ($checkAdmin && self::installed() && KunenaUserHelper::getMyself()->isAdmin()); } /** * Initialize Kunena Framework. * * This function initializes Kunena Framework. Main purpose of this * function right now is to make sure all the translations have been loaded, * but later it may contain other initialization tasks. * * Following code gives an example how to create backwards compatible code. * Normally I wouldn't bother supporting deprecated unstable releases. * * * // We have already checked that Kunena 2.0+ has been installed and is online * * if (KunenaForum::isCompatible('2.0.0')) { * KunenaForum::setup(); * } else { * KunenaFactory::loadLanguage(); * } * * * @see KunenaForum::installed() * * Alternatively you could use method_exists() to check that the new API is in there. * * @since 2.0.0-BETA2 */ public static function setup() { $config = KunenaFactory::getConfig(); // Load language file for libraries. KunenaFactory::loadLanguage('com_kunena.libraries', 'admin'); // Setup output caching. $cache = JFactory::getCache('com_kunena', 'output'); if (!$config->get('cache')) { $cache->setCaching(0); } $cache->setLifeTime($config->get('cache_time', 60)); // Setup error logging. jimport('joomla.error.log'); $options = array('logger'=>'w3c', 'text_file'=>'kunena.php'); $categories = array('kunena'); $levels = JDEBUG || $config->debug ? JLog::ALL : JLog::EMERGENCY | JLog::ALERT | JLog::CRITICAL | JLog::ERROR; JLog::addLogger($options, $levels, $categories); } /** * Check if Kunena Forum is compatible with your code. * * This function can be used to make sure that user has installed Kunena version * that has been tested to work with your extension. All existing functions should * be backwards compatible, but each release can add some new functionality, which * you may want to use. * * * if (KunenaForum::isCompatible('2.0.1')) { * // We can do it in the new way * } else { * // Use the old code instead * } * * * @see KunenaForum::installed() * * @param string $version Minimum required version. * * @return boolean Yes, if it is safe to use Kunena Framework. */ public static function isCompatible($version) { // If requested version is smaller than 2.0, it's not compatible if (version_compare($version, '2.0', '<')) { return false; } // Development version support. if ($version == '4.0') { return true; } // Check if future version is needed (remove GIT and DEVn from the current version) if (version_compare($version, preg_replace('/(-DEV\d*)?(-GIT)?/i', '', self::version()), '>')) { return false; } return true; } /** * Check if Kunena Forum is running from a Git repository. * * Developers tend to do their work directly in the Git repositories instead of * creating and installing new builds after every change. This function can be * used to check the condition and make sure we do not break users repository * by replacing files during upgrade. * * @return boolean True if Git repository is detected. */ public static function isDev() { if ('4.0.10' == '@' . 'kunenaversion' . '@') { return true; } return false; } /** * Returns the exact version from Kunena Forum. * * @return string Version number. */ public static function version() { if (self::$version === false) { self::buildVersion(); } return self::$version; } /** * Returns major version number (2.0, 3.0, 3.1 and so on). * * @return string Major version in xxx.yyy format. */ public static function versionMajor() { if (self::$version_major === false) { self::buildVersion(); } return self::$version_major; } /** * Returns build date from Kunena Forum (for Git today). * * @return string Date in yyyy-mm-dd format. */ public static function versionDate() { if (self::$version_date === false) { self::buildVersion(); } return self::$version_date; } /** * Returns codename from Kunena release. * * @return string Codename. */ public static function versionName() { if (self::$version_name === false) { self::buildVersion(); } return self::$version_name; } /** * Returns all version information together. * * @return object stdClass containing (version, major, date, name). */ public static function getVersionInfo() { $version = new stdClass(); $version->version = self::version(); $version->major = self::versionMajor(); // New in K2.0.0-BETA2 $version->date = self::versionDate(); $version->name = self::versionName(); return $version; } /** * Displays Kunena Forum view/layout inside your extension. * * * * * * @param string $viewName Name of the view. * @param string $layout Name of the layout. * @param null|string $template Name of the template file. * @param array|JRegistry $params Extra parameters to control the model. */ public static function display($viewName, $layout='default', $template=null, $params = array()) { // Filter input $viewName = preg_replace( '/[^A-Z0-9_]/i', '', $viewName ); $layout = preg_replace( '/[^A-Z0-9_]/i', '', $layout ); $template = preg_replace( '/[^A-Z0-9_]/i', '', $template ); $template = $template ? $template : null; $view = "KunenaView{$viewName}"; $model = "KunenaModel{$viewName}"; // Load potentially needed language files KunenaFactory::loadLanguage(); KunenaFactory::loadLanguage('com_kunena.model'); KunenaFactory::loadLanguage('com_kunena.view'); require_once KPATH_SITE . '/views/common/view.html.php'; require_once KPATH_SITE . '/models/common.php'; if ( !class_exists( $view ) ) { $vpath = KPATH_SITE . '/views/'.$viewName.'/view.html.php'; if (!is_file($vpath)) { return; } require_once $vpath; } if ( $viewName != 'common' && !class_exists( $model ) ) { $mpath = KPATH_SITE . '/models/'.$viewName.'.php'; if (!is_file($mpath)) { return; } require_once $mpath; } $view = new $view ( array ('base_path' => KPATH_SITE ) ); /** @var KunenaView $view */ if ($params instanceof JRegistry) { // Do nothing } else { $params = new JRegistry($params); } $params->set('layout', $layout); // Push the model into the view (as default). $model = new $model(); /** @var KunenaModel $model */ $model->initialize($params); $view->setModel ( $model, true ); // Add template path if ($params->get('templatepath')) { $view->addTemplatePath($params->get('templatepath')); } if ($viewName != 'common') { $view->common = new KunenaViewCommon ( array ('base_path' => KPATH_SITE ) ); $view->common->embedded = true; } // Flag view as being embedded $view->embedded = true; // Flag view as being teaser $view->teaser = $params->get('teaser',0); // Render the view. $view->displayLayout ($layout, $template); } // Internal functions protected static function buildVersion() { if ('4.0.10' == '@' . 'kunenaversion' . '@') { $file = JPATH_MANIFESTS . '/packages/pkg_kunena.xml'; $manifest = simplexml_load_file($file); self::$version = (string) $manifest->version . '-GIT'; } else { self::$version = strtoupper ( '4.0.10' ); } self::$version_major = substr(self::$version, 0, 3); self::$version_date = ('2016-02-18' == '@' . 'kunenaversiondate' . '@') ? JFactory::getDate()->format('Y-m-d') : '2016-02-18'; self::$version_name = ('Villavicencio' == '@' . 'kunenaversionname' . '@') ? 'Git Repository' : 'Villavicencio'; } } /** * @package Joomla.Libraries * @subpackage Pagination * * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Pagination Class. Provides a common interface for content pagination for the Joomla! CMS. * * @since 1.5 */ class JPagination { /** * @var integer The record number to start displaying from. * @since 1.5 */ public $limitstart = null; /** * @var integer Number of rows to display per page. * @since 1.5 */ public $limit = null; /** * @var integer Total number of rows. * @since 1.5 */ public $total = null; /** * @var integer Prefix used for request variables. * @since 1.6 */ public $prefix = null; /** * @var integer Value pagination object begins at * @since 3.0 */ public $pagesStart; /** * @var integer Value pagination object ends at * @since 3.0 */ public $pagesStop; /** * @var integer Current page * @since 3.0 */ public $pagesCurrent; /** * @var integer Total number of pages * @since 3.0 */ public $pagesTotal; /** * @var boolean View all flag * @since 3.0 */ protected $viewall = false; /** * Additional URL parameters to be added to the pagination URLs generated by the class. These * may be useful for filters and extra values when dealing with lists and GET requests. * * @var array * @since 3.0 */ protected $additionalUrlParams = array(); /** * @var JApplicationCms The application object * @since 3.4 */ protected $app = null; /** * Pagination data object * * @var object * @since 3.4 */ protected $data; /** * Constructor. * * @param integer $total The total number of items. * @param integer $limitstart The offset of the item to start at. * @param integer $limit The number of items to display per page. * @param string $prefix The prefix used for request variables. * @param JApplicationCms $app The application object * * @since 1.5 */ public function __construct($total, $limitstart, $limit, $prefix = '', JApplicationCms $app = null) { // Value/type checking. $this->total = (int) $total; $this->limitstart = (int) max($limitstart, 0); $this->limit = (int) max($limit, 0); $this->prefix = $prefix; $this->app = $app ? $app : JFactory::getApplication(); if ($this->limit > $this->total) { $this->limitstart = 0; } if (!$this->limit) { $this->limit = $total; $this->limitstart = 0; } /* * If limitstart is greater than total (i.e. we are asked to display records that don't exist) * then set limitstart to display the last natural page of results */ if ($this->limitstart > $this->total - $this->limit) { $this->limitstart = max(0, (int) (ceil($this->total / $this->limit) - 1) * $this->limit); } // Set the total pages and current page values. if ($this->limit > 0) { $this->pagesTotal = ceil($this->total / $this->limit); $this->pagesCurrent = ceil(($this->limitstart + 1) / $this->limit); } // Set the pagination iteration loop values. $displayedPages = 10; $this->pagesStart = $this->pagesCurrent - ($displayedPages / 2); if ($this->pagesStart < 1) { $this->pagesStart = 1; } if ($this->pagesStart + $displayedPages > $this->pagesTotal) { $this->pagesStop = $this->pagesTotal; if ($this->pagesTotal < $displayedPages) { $this->pagesStart = 1; } else { $this->pagesStart = $this->pagesTotal - $displayedPages + 1; } } else { $this->pagesStop = $this->pagesStart + $displayedPages - 1; } // If we are viewing all records set the view all flag to true. if ($limit == 0) { $this->viewall = true; } } /** * Method to set an additional URL parameter to be added to all pagination class generated * links. * * @param string $key The name of the URL parameter for which to set a value. * @param mixed $value The value to set for the URL parameter. * * @return mixed The old value for the parameter. * * @since 1.6 */ public function setAdditionalUrlParam($key, $value) { // Get the old value to return and set the new one for the URL parameter. $result = isset($this->additionalUrlParams[$key]) ? $this->additionalUrlParams[$key] : null; // If the passed parameter value is null unset the parameter, otherwise set it to the given value. if ($value === null) { unset($this->additionalUrlParams[$key]); } else { $this->additionalUrlParams[$key] = $value; } return $result; } /** * Method to get an additional URL parameter (if it exists) to be added to * all pagination class generated links. * * @param string $key The name of the URL parameter for which to get the value. * * @return mixed The value if it exists or null if it does not. * * @since 1.6 */ public function getAdditionalUrlParam($key) { $result = isset($this->additionalUrlParams[$key]) ? $this->additionalUrlParams[$key] : null; return $result; } /** * Return the rationalised offset for a row with a given index. * * @param integer $index The row index * * @return integer Rationalised offset for a row with a given index. * * @since 1.5 */ public function getRowOffset($index) { return $index + 1 + $this->limitstart; } /** * Return the pagination data object, only creating it if it doesn't already exist. * * @return object Pagination data object. * * @since 1.5 */ public function getData() { if (!$this->data) { $this->data = $this->_buildDataObject(); } return $this->data; } /** * Create and return the pagination pages counter string, ie. Page 2 of 4. * * @return string Pagination pages counter string. * * @since 1.5 */ public function getPagesCounter() { $html = null; if ($this->pagesTotal > 1) { $html .= JText::sprintf('JLIB_HTML_PAGE_CURRENT_OF_TOTAL', $this->pagesCurrent, $this->pagesTotal); } return $html; } /** * Create and return the pagination result set counter string, e.g. Results 1-10 of 42 * * @return string Pagination result set counter string. * * @since 1.5 */ public function getResultsCounter() { $html = null; $fromResult = $this->limitstart + 1; // If the limit is reached before the end of the list. if ($this->limitstart + $this->limit < $this->total) { $toResult = $this->limitstart + $this->limit; } else { $toResult = $this->total; } // If there are results found. if ($this->total > 0) { $msg = JText::sprintf('JLIB_HTML_RESULTS_OF', $fromResult, $toResult, $this->total); $html .= "\n" . $msg; } else { $html .= "\n" . JText::_('JLIB_HTML_NO_RECORDS_FOUND'); } return $html; } /** * Create and return the pagination page list string, ie. Previous, Next, 1 2 3 ... x. * * @return string Pagination page list string. * * @since 1.5 */ public function getPagesLinks() { // Build the page navigation list. $data = $this->_buildDataObject(); $list = array(); $list['prefix'] = $this->prefix; $itemOverride = false; $listOverride = false; $chromePath = JPATH_THEMES . '/' . $this->app->getTemplate() . '/html/pagination.php'; if (file_exists($chromePath)) { include_once $chromePath; if (function_exists('pagination_item_active') && function_exists('pagination_item_inactive')) { $itemOverride = true; } if (function_exists('pagination_list_render')) { $listOverride = true; } } // Build the select list if ($data->all->base !== null) { $list['all']['active'] = true; $list['all']['data'] = ($itemOverride) ? pagination_item_active($data->all) : $this->_item_active($data->all); } else { $list['all']['active'] = false; $list['all']['data'] = ($itemOverride) ? pagination_item_inactive($data->all) : $this->_item_inactive($data->all); } if ($data->start->base !== null) { $list['start']['active'] = true; $list['start']['data'] = ($itemOverride) ? pagination_item_active($data->start) : $this->_item_active($data->start); } else { $list['start']['active'] = false; $list['start']['data'] = ($itemOverride) ? pagination_item_inactive($data->start) : $this->_item_inactive($data->start); } if ($data->previous->base !== null) { $list['previous']['active'] = true; $list['previous']['data'] = ($itemOverride) ? pagination_item_active($data->previous) : $this->_item_active($data->previous); } else { $list['previous']['active'] = false; $list['previous']['data'] = ($itemOverride) ? pagination_item_inactive($data->previous) : $this->_item_inactive($data->previous); } // Make sure it exists $list['pages'] = array(); foreach ($data->pages as $i => $page) { if ($page->base !== null) { $list['pages'][$i]['active'] = true; $list['pages'][$i]['data'] = ($itemOverride) ? pagination_item_active($page) : $this->_item_active($page); } else { $list['pages'][$i]['active'] = false; $list['pages'][$i]['data'] = ($itemOverride) ? pagination_item_inactive($page) : $this->_item_inactive($page); } } if ($data->next->base !== null) { $list['next']['active'] = true; $list['next']['data'] = ($itemOverride) ? pagination_item_active($data->next) : $this->_item_active($data->next); } else { $list['next']['active'] = false; $list['next']['data'] = ($itemOverride) ? pagination_item_inactive($data->next) : $this->_item_inactive($data->next); } if ($data->end->base !== null) { $list['end']['active'] = true; $list['end']['data'] = ($itemOverride) ? pagination_item_active($data->end) : $this->_item_active($data->end); } else { $list['end']['active'] = false; $list['end']['data'] = ($itemOverride) ? pagination_item_inactive($data->end) : $this->_item_inactive($data->end); } if ($this->total > $this->limit) { return ($listOverride) ? pagination_list_render($list) : $this->_list_render($list); } else { return ''; } } /** * Get the pagination links * * @param string $layoutId Layout to render the links * @param array $options Optional array with settings for the layout * * @return string Pagination links. * * @since 3.3 */ public function getPaginationLinks($layoutId = 'joomla.pagination.links', $options = array()) { // Allow to receive a null layout $layoutId = (null === $layoutId) ? 'joomla.pagination.links' : $layoutId; $list = array( 'prefix' => $this->prefix, 'limit' => $this->limit, 'limitstart' => $this->limitstart, 'total' => $this->total, 'limitfield' => $this->getLimitBox(), 'pagescounter' => $this->getPagesCounter(), 'pages' => $this->getPaginationPages() ); return JLayoutHelper::render($layoutId, array('list' => $list, 'options' => $options)); } /** * Create and return the pagination pages list, ie. Previous, Next, 1 2 3 ... x. * * @return array Pagination pages list. * * @since 3.3 */ public function getPaginationPages() { $list = array(); if ($this->total > $this->limit) { // Build the page navigation list. $data = $this->_buildDataObject(); // All $list['all']['active'] = (null !== $data->all->base); $list['all']['data'] = $data->all; // Start $list['start']['active'] = (null !== $data->start->base); $list['start']['data'] = $data->start; // Previous link $list['previous']['active'] = (null !== $data->previous->base); $list['previous']['data'] = $data->previous; // Make sure it exists $list['pages'] = array(); foreach ($data->pages as $i => $page) { $list['pages'][$i]['active'] = (null !== $page->base); $list['pages'][$i]['data'] = $page; } $list['next']['active'] = (null !== $data->next->base); $list['next']['data'] = $data->next; $list['end']['active'] = (null !== $data->end->base); $list['end']['data'] = $data->end; } return $list; } /** * Return the pagination footer. * * @return string Pagination footer. * * @since 1.5 */ public function getListFooter() { // Keep B/C for overrides done with chromes $chromePath = JPATH_THEMES . '/' . $this->app->getTemplate() . '/html/pagination.php'; if (file_exists($chromePath)) { $list = array(); $list['prefix'] = $this->prefix; $list['limit'] = $this->limit; $list['limitstart'] = $this->limitstart; $list['total'] = $this->total; $list['limitfield'] = $this->getLimitBox(); $list['pagescounter'] = $this->getPagesCounter(); $list['pageslinks'] = $this->getPagesLinks(); include_once $chromePath; if (function_exists('pagination_list_footer')) { return pagination_list_footer($list); } } return $this->getPaginationLinks(); } /** * Creates a dropdown box for selecting how many records to show per page. * * @return string The HTML for the limit # input box. * * @since 1.5 */ public function getLimitBox() { $limits = array(); // Make the option list. for ($i = 5; $i <= 30; $i += 5) { $limits[] = JHtml::_('select.option', "$i"); } $limits[] = JHtml::_('select.option', '50', JText::_('J50')); $limits[] = JHtml::_('select.option', '100', JText::_('J100')); $limits[] = JHtml::_('select.option', '0', JText::_('JALL')); $selected = $this->viewall ? 0 : $this->limit; // Build the select list. if ($this->app->isAdmin()) { $html = JHtml::_( 'select.genericlist', $limits, $this->prefix . 'limit', 'class="inputbox input-mini" size="1" onchange="Joomla.submitform();"', 'value', 'text', $selected ); } else { $html = JHtml::_( 'select.genericlist', $limits, $this->prefix . 'limit', 'class="inputbox input-mini" size="1" onchange="this.form.submit()"', 'value', 'text', $selected ); } return $html; } /** * Return the icon to move an item UP. * * @param integer $i The row index. * @param boolean $condition True to show the icon. * @param string $task The task to fire. * @param string $alt The image alternative text string. * @param boolean $enabled An optional setting for access control on the action. * @param string $checkbox An optional prefix for checkboxes. * * @return string Either the icon to move an item up or a space. * * @since 1.5 */ public function orderUpIcon($i, $condition = true, $task = 'orderup', $alt = 'JLIB_HTML_MOVE_UP', $enabled = true, $checkbox = 'cb') { if (($i > 0 || ($i + $this->limitstart > 0)) && $condition) { return JHtml::_('jgrid.orderUp', $i, $task, '', $alt, $enabled, $checkbox); } else { return ' '; } } /** * Return the icon to move an item DOWN. * * @param integer $i The row index. * @param integer $n The number of items in the list. * @param boolean $condition True to show the icon. * @param string $task The task to fire. * @param string $alt The image alternative text string. * @param boolean $enabled An optional setting for access control on the action. * @param string $checkbox An optional prefix for checkboxes. * * @return string Either the icon to move an item down or a space. * * @since 1.5 */ public function orderDownIcon($i, $n, $condition = true, $task = 'orderdown', $alt = 'JLIB_HTML_MOVE_DOWN', $enabled = true, $checkbox = 'cb') { if (($i < $n - 1 || $i + $this->limitstart < $this->total - 1) && $condition) { return JHtml::_('jgrid.orderDown', $i, $task, '', $alt, $enabled, $checkbox); } else { return ' '; } } /** * Create the HTML for a list footer * * @param array $list Pagination list data structure. * * @return string HTML for a list footer * * @since 1.5 */ protected function _list_footer($list) { $html = "
\n"; $html .= "\n
" . JText::_('JGLOBAL_DISPLAY_NUM') . $list['limitfield'] . "
"; $html .= $list['pageslinks']; $html .= "\n
" . $list['pagescounter'] . "
"; $html .= "\n"; $html .= "\n
"; return $html; } /** * Create the html for a list footer * * @param array $list Pagination list data structure. * * @return string HTML for a list start, previous, next,end * * @since 1.5 */ protected function _list_render($list) { // Reverse output rendering for right-to-left display. $html = ''; return $html; } /** * Method to create an active pagination link to the item * * @param JPaginationObject $item The object with which to make an active link. * * @return string HTML link * * @since 1.5 */ protected function _item_active(JPaginationObject $item) { $title = ''; $class = ''; if (!is_numeric($item->text)) { JHtml::_('bootstrap.tooltip'); $title = ' title="' . $item->text . '"'; $class = 'hasTooltip '; } if ($this->app->isAdmin()) { return '' . $item->text . ''; } else { return '' . $item->text . ''; } } /** * Method to create an inactive pagination string * * @param JPaginationObject $item The item to be processed * * @return string * * @since 1.5 */ protected function _item_inactive(JPaginationObject $item) { if ($this->app->isAdmin()) { return '' . $item->text . ''; } else { return '' . $item->text . ''; } } /** * Create and return the pagination data object. * * @return object Pagination data object. * * @since 1.5 */ protected function _buildDataObject() { $data = new stdClass; // Build the additional URL parameters string. $params = ''; if (!empty($this->additionalUrlParams)) { foreach ($this->additionalUrlParams as $key => $value) { $params .= '&' . $key . '=' . $value; } } $data->all = new JPaginationObject(JText::_('JLIB_HTML_VIEW_ALL'), $this->prefix); if (!$this->viewall) { $data->all->base = '0'; $data->all->link = JRoute::_($params . '&' . $this->prefix . 'limitstart='); } // Set the start and previous data objects. $data->start = new JPaginationObject(JText::_('JLIB_HTML_START'), $this->prefix); $data->previous = new JPaginationObject(JText::_('JPREV'), $this->prefix); if ($this->pagesCurrent > 1) { $page = ($this->pagesCurrent - 2) * $this->limit; // Set the empty for removal from route // @todo remove code: $page = $page == 0 ? '' : $page; $data->start->base = '0'; $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0'); $data->previous->base = $page; $data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page); } // Set the next and end data objects. $data->next = new JPaginationObject(JText::_('JNEXT'), $this->prefix); $data->end = new JPaginationObject(JText::_('JLIB_HTML_END'), $this->prefix); if ($this->pagesCurrent < $this->pagesTotal) { $next = $this->pagesCurrent * $this->limit; $end = ($this->pagesTotal - 1) * $this->limit; $data->next->base = $next; $data->next->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $next); $data->end->base = $end; $data->end->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end); } $data->pages = array(); $stop = $this->pagesStop; for ($i = $this->pagesStart; $i <= $stop; $i++) { $offset = ($i - 1) * $this->limit; $data->pages[$i] = new JPaginationObject($i, $this->prefix); if ($i != $this->pagesCurrent || $this->viewall) { $data->pages[$i]->base = $offset; $data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset); } else { $data->pages[$i]->active = true; } } return $data; } /** * Modifies a property of the object, creating it if it does not already exist. * * @param string $property The name of the property. * @param mixed $value The value of the property to set. * * @return void * * @since 3.0 * @deprecated 4.0 Access the properties directly. */ public function set($property, $value = null) { JLog::add('JPagination::set() is deprecated. Access the properties directly.', JLog::WARNING, 'deprecated'); if (strpos($property, '.')) { $prop = explode('.', $property); $prop[1] = ucfirst($prop[1]); $property = implode($prop); } $this->$property = $value; } /** * Returns a property of the object or the default value if the property is not set. * * @param string $property The name of the property. * @param mixed $default The default value. * * @return mixed The value of the property. * * @since 3.0 * @deprecated 4.0 Access the properties directly. */ public function get($property, $default = null) { JLog::add('JPagination::get() is deprecated. Access the properties directly.', JLog::WARNING, 'deprecated'); if (strpos($property, '.')) { $prop = explode('.', $property); $prop[1] = ucfirst($prop[1]); $property = implode($prop); } if (isset($this->$property)) { return $this->$property; } return $default; } }