Source for file pagination.php

Documentation is available at pagination.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Pagination
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Pagination Class. Provides a common interface for content pagination for the Joomla! CMS.
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  Pagination
  17.  * @since       1.5
  18.  */
  19. {
  20.     /**
  21.      * @var    integer  The record number to start displaying from.
  22.      * @since  1.5
  23.      */
  24.     public $limitstart = null;
  25.  
  26.     /**
  27.      * @var    integer  Number of rows to display per page.
  28.      * @since  1.5
  29.      */
  30.     public $limit = null;
  31.  
  32.     /**
  33.      * @var    integer  Total number of rows.
  34.      * @since  1.5
  35.      */
  36.     public $total = null;
  37.  
  38.     /**
  39.      * @var    integer  Prefix used for request variables.
  40.      * @since  1.6
  41.      */
  42.     public $prefix = null;
  43.  
  44.     /**
  45.      * @var    integer  Value pagination object begins at
  46.      * @since  3.0
  47.      */
  48.     public $pagesStart;
  49.  
  50.     /**
  51.      * @var    integer  Value pagination object ends at
  52.      * @since  3.0
  53.      */
  54.     public $pagesStop;
  55.  
  56.     /**
  57.      * @var    integer  Current page
  58.      * @since  3.0
  59.      */
  60.     public $pagesCurrent;
  61.  
  62.     /**
  63.      * @var    integer  Total number of pages
  64.      * @since  3.0
  65.      */
  66.     public $pagesTotal;
  67.  
  68.     /**
  69.      * @var    boolean  View all flag
  70.      * @since  3.0
  71.      */
  72.     protected $viewall = false;
  73.  
  74.     /**
  75.      * Additional URL parameters to be added to the pagination URLs generated by the class.  These
  76.      * may be useful for filters and extra values when dealing with lists and GET requests.
  77.      *
  78.      * @var    array 
  79.      * @since  3.0
  80.      */
  81.     protected $additionalUrlParams = array();
  82.  
  83.     /**
  84.      * Constructor.
  85.      *
  86.      * @param   integer  $total       The total number of items.
  87.      * @param   integer  $limitstart  The offset of the item to start at.
  88.      * @param   integer  $limit       The number of items to display per page.
  89.      * @param   string   $prefix      The prefix used for request variables.
  90.      *
  91.      * @since   1.5
  92.      */
  93.     public function __construct($total$limitstart$limit$prefix '')
  94.     {
  95.         // Value/type checking.
  96.         $this->total = (int) $total;
  97.         $this->limitstart = (int) max($limitstart0);
  98.         $this->limit = (int) max($limit0);
  99.         $this->prefix = $prefix;
  100.  
  101.         if ($this->limit > $this->total)
  102.         {
  103.             $this->limitstart = 0;
  104.         }
  105.  
  106.         if (!$this->limit)
  107.         {
  108.             $this->limit = $total;
  109.             $this->limitstart = 0;
  110.         }
  111.  
  112.         /*
  113.          * If limitstart is greater than total (i.e. we are asked to display records that don't exist)
  114.          * then set limitstart to display the last natural page of results
  115.          */
  116.         if ($this->limitstart > $this->total - $this->limit)
  117.         {
  118.             $this->limitstart = max(0(int) (ceil($this->total / $this->limit1$this->limit);
  119.         }
  120.  
  121.         // Set the total pages and current page values.
  122.         if ($this->limit > 0)
  123.         {
  124.             $this->pagesTotal = ceil($this->total / $this->limit);
  125.             $this->pagesCurrent = ceil(($this->limitstart + 1$this->limit);
  126.         }
  127.  
  128.         // Set the pagination iteration loop values.
  129.         $displayedPages 10;
  130.         $this->pagesStart = $this->pagesCurrent - ($displayedPages 2);
  131.  
  132.         if ($this->pagesStart < 1)
  133.         {
  134.             $this->pagesStart = 1;
  135.         }
  136.  
  137.         if ($this->pagesStart + $displayedPages $this->pagesTotal)
  138.         {
  139.             $this->pagesStop = $this->pagesTotal;
  140.  
  141.             if ($this->pagesTotal < $displayedPages)
  142.             {
  143.                 $this->pagesStart = 1;
  144.             }
  145.             else
  146.             {
  147.                 $this->pagesStart = $this->pagesTotal - $displayedPages 1;
  148.             }
  149.         }
  150.         else
  151.         {
  152.             $this->pagesStop = $this->pagesStart + $displayedPages 1;
  153.         }
  154.  
  155.         // If we are viewing all records set the view all flag to true.
  156.         if ($limit == 0)
  157.         {
  158.             $this->viewall = true;
  159.         }
  160.     }
  161.  
  162.     /**
  163.      * Method to set an additional URL parameter to be added to all pagination class generated
  164.      * links.
  165.      *
  166.      * @param   string  $key    The name of the URL parameter for which to set a value.
  167.      * @param   mixed   $value  The value to set for the URL parameter.
  168.      *
  169.      * @return  mixed  The old value for the parameter.
  170.      *
  171.      * @since   1.6
  172.      */
  173.     public function setAdditionalUrlParam($key$value)
  174.     {
  175.         // Get the old value to return and set the new one for the URL parameter.
  176.         $result = isset($this->additionalUrlParams[$key]$this->additionalUrlParams[$keynull;
  177.  
  178.         // If the passed parameter value is null unset the parameter, otherwise set it to the given value.
  179.         if ($value === null)
  180.         {
  181.             unset($this->additionalUrlParams[$key]);
  182.         }
  183.         else
  184.         {
  185.             $this->additionalUrlParams[$key$value;
  186.         }
  187.  
  188.         return $result;
  189.     }
  190.  
  191.     /**
  192.      * Method to get an additional URL parameter (if it exists) to be added to
  193.      * all pagination class generated links.
  194.      *
  195.      * @param   string  $key  The name of the URL parameter for which to get the value.
  196.      *
  197.      * @return  mixed  The value if it exists or null if it does not.
  198.      *
  199.      * @since   1.6
  200.      */
  201.     public function getAdditionalUrlParam($key)
  202.     {
  203.         $result = isset($this->additionalUrlParams[$key]$this->additionalUrlParams[$keynull;
  204.  
  205.         return $result;
  206.     }
  207.  
  208.     /**
  209.      * Return the rationalised offset for a row with a given index.
  210.      *
  211.      * @param   integer  $index  The row index
  212.      *
  213.      * @return  integer  Rationalised offset for a row with a given index.
  214.      *
  215.      * @since   1.5
  216.      */
  217.     public function getRowOffset($index)
  218.     {
  219.         return $index $this->limitstart;
  220.     }
  221.  
  222.     /**
  223.      * Return the pagination data object, only creating it if it doesn't already exist.
  224.      *
  225.      * @return  object   Pagination data object.
  226.      *
  227.      * @since   1.5
  228.      */
  229.     public function getData()
  230.     {
  231.         static $data;
  232.  
  233.         if (!is_object($data))
  234.         {
  235.             $data $this->_buildDataObject();
  236.         }
  237.  
  238.         return $data;
  239.     }
  240.  
  241.     /**
  242.      * Create and return the pagination pages counter string, ie. Page 2 of 4.
  243.      *
  244.      * @return  string   Pagination pages counter string.
  245.      *
  246.      * @since   1.5
  247.      */
  248.     public function getPagesCounter()
  249.     {
  250.         $html null;
  251.  
  252.         if ($this->pagesTotal > 1)
  253.         {
  254.             $html .= JText::sprintf('JLIB_HTML_PAGE_CURRENT_OF_TOTAL'$this->pagesCurrent$this->pagesTotal);
  255.         }
  256.  
  257.         return $html;
  258.     }
  259.  
  260.     /**
  261.      * Create and return the pagination result set counter string, e.g. Results 1-10 of 42
  262.      *
  263.      * @return  string   Pagination result set counter string.
  264.      *
  265.      * @since   1.5
  266.      */
  267.     public function getResultsCounter()
  268.     {
  269.         $html null;
  270.         $fromResult $this->limitstart + 1;
  271.  
  272.         // If the limit is reached before the end of the list.
  273.         if ($this->limitstart + $this->limit < $this->total)
  274.         {
  275.             $toResult $this->limitstart + $this->limit;
  276.         }
  277.         else
  278.         {
  279.             $toResult $this->total;
  280.         }
  281.  
  282.         // If there are results found.
  283.         if ($this->total > 0)
  284.         {
  285.             $msg JText::sprintf('JLIB_HTML_RESULTS_OF'$fromResult$toResult$this->total);
  286.             $html .= "\n" $msg;
  287.         }
  288.         else
  289.         {
  290.             $html .= "\n" JText::_('JLIB_HTML_NO_RECORDS_FOUND');
  291.         }
  292.  
  293.         return $html;
  294.     }
  295.  
  296.     /**
  297.      * Create and return the pagination page list string, ie. Previous, Next, 1 2 3 ... x.
  298.      *
  299.      * @return  string  Pagination page list string.
  300.      *
  301.      * @since   1.5
  302.      */
  303.     public function getPagesLinks()
  304.     {
  305.         $app JFactory::getApplication();
  306.  
  307.         // Build the page navigation list.
  308.         $data $this->_buildDataObject();
  309.  
  310.         $list array();
  311.         $list['prefix'$this->prefix;
  312.  
  313.         $itemOverride false;
  314.         $listOverride false;
  315.  
  316.         $chromePath JPATH_THEMES '/' $app->getTemplate('/html/pagination.php';
  317.  
  318.         if (file_exists($chromePath))
  319.         {
  320.             include_once $chromePath;
  321.  
  322.             if (function_exists('pagination_item_active'&& function_exists('pagination_item_inactive'))
  323.             {
  324.                 $itemOverride true;
  325.             }
  326.  
  327.             if (function_exists('pagination_list_render'))
  328.             {
  329.                 $listOverride true;
  330.             }
  331.         }
  332.  
  333.         // Build the select list
  334.         if ($data->all->base !== null)
  335.         {
  336.             $list['all']['active'true;
  337.             $list['all']['data'($itemOverridepagination_item_active($data->all$this->_item_active($data->all);
  338.         }
  339.         else
  340.         {
  341.             $list['all']['active'false;
  342.             $list['all']['data'($itemOverridepagination_item_inactive($data->all$this->_item_inactive($data->all);
  343.         }
  344.  
  345.         if ($data->start->base !== null)
  346.         {
  347.             $list['start']['active'true;
  348.             $list['start']['data'($itemOverridepagination_item_active($data->start$this->_item_active($data->start);
  349.         }
  350.         else
  351.         {
  352.             $list['start']['active'false;
  353.             $list['start']['data'($itemOverridepagination_item_inactive($data->start$this->_item_inactive($data->start);
  354.         }
  355.  
  356.         if ($data->previous->base !== null)
  357.         {
  358.             $list['previous']['active'true;
  359.             $list['previous']['data'($itemOverridepagination_item_active($data->previous$this->_item_active($data->previous);
  360.         }
  361.         else
  362.         {
  363.             $list['previous']['active'false;
  364.             $list['previous']['data'($itemOverridepagination_item_inactive($data->previous$this->_item_inactive($data->previous);
  365.         }
  366.  
  367.         // Make sure it exists
  368.         $list['pages'array();
  369.  
  370.         foreach ($data->pages as $i => $page)
  371.         {
  372.             if ($page->base !== null)
  373.             {
  374.                 $list['pages'][$i]['active'true;
  375.                 $list['pages'][$i]['data'($itemOverridepagination_item_active($page$this->_item_active($page);
  376.             }
  377.             else
  378.             {
  379.                 $list['pages'][$i]['active'false;
  380.                 $list['pages'][$i]['data'($itemOverridepagination_item_inactive($page$this->_item_inactive($page);
  381.             }
  382.         }
  383.  
  384.         if ($data->next->base !== null)
  385.         {
  386.             $list['next']['active'true;
  387.             $list['next']['data'($itemOverridepagination_item_active($data->next$this->_item_active($data->next);
  388.         }
  389.         else
  390.         {
  391.             $list['next']['active'false;
  392.             $list['next']['data'($itemOverridepagination_item_inactive($data->next$this->_item_inactive($data->next);
  393.         }
  394.  
  395.         if ($data->end->base !== null)
  396.         {
  397.             $list['end']['active'true;
  398.             $list['end']['data'($itemOverridepagination_item_active($data->end$this->_item_active($data->end);
  399.         }
  400.         else
  401.         {
  402.             $list['end']['active'false;
  403.             $list['end']['data'($itemOverridepagination_item_inactive($data->end$this->_item_inactive($data->end);
  404.         }
  405.  
  406.         if ($this->total > $this->limit)
  407.         {
  408.             return ($listOverridepagination_list_render($list$this->_list_render($list);
  409.         }
  410.         else
  411.         {
  412.             return '';
  413.         }
  414.     }
  415.  
  416.     /**
  417.      * Return the pagination footer.
  418.      *
  419.      * @return  string  Pagination footer.
  420.      *
  421.      * @since   1.5
  422.      */
  423.     public function getListFooter()
  424.     {
  425.         $app JFactory::getApplication();
  426.  
  427.         $list array();
  428.         $list['prefix'$this->prefix;
  429.         $list['limit'$this->limit;
  430.         $list['limitstart'$this->limitstart;
  431.         $list['total'$this->total;
  432.         $list['limitfield'$this->getLimitBox();
  433.         $list['pagescounter'$this->getPagesCounter();
  434.         $list['pageslinks'$this->getPagesLinks();
  435.  
  436.         $chromePath JPATH_THEMES '/' $app->getTemplate('/html/pagination.php';
  437.  
  438.         if (file_exists($chromePath))
  439.         {
  440.             include_once $chromePath;
  441.  
  442.             if (function_exists('pagination_list_footer'))
  443.             {
  444.                 return pagination_list_footer($list);
  445.             }
  446.         }
  447.  
  448.         return $this->_list_footer($list);
  449.     }
  450.  
  451.     /**
  452.      * Creates a dropdown box for selecting how many records to show per page.
  453.      *
  454.      * @return  string  The HTML for the limit # input box.
  455.      *
  456.      * @since   1.5
  457.      */
  458.     public function getLimitBox()
  459.     {
  460.         $app JFactory::getApplication();
  461.         $limits array();
  462.  
  463.         // Make the option list.
  464.         for ($i 5$i <= 30$i += 5)
  465.         {
  466.             $limits[JHtml::_('select.option'"$i");
  467.         }
  468.  
  469.         $limits[JHtml::_('select.option''50'JText::_('J50'));
  470.         $limits[JHtml::_('select.option''100'JText::_('J100'));
  471.         $limits[JHtml::_('select.option''0'JText::_('JALL'));
  472.  
  473.         $selected $this->viewall ? $this->limit;
  474.  
  475.         // Build the select list.
  476.         if ($app->isAdmin())
  477.         {
  478.             $html JHtml::_(
  479.                 'select.genericlist',
  480.                 $limits,
  481.                 $this->prefix . 'limit',
  482.                 'class="inputbox input-mini" size="1" onchange="Joomla.submitform();"',
  483.                 'value',
  484.                 'text',
  485.                 $selected
  486.             );
  487.         }
  488.         else
  489.         {
  490.             $html JHtml::_(
  491.                 'select.genericlist',
  492.                 $limits,
  493.                 $this->prefix . 'limit',
  494.                 'class="inputbox input-mini" size="1" onchange="this.form.submit()"',
  495.                 'value',
  496.                 'text',
  497.                 $selected
  498.             );
  499.         }
  500.  
  501.         return $html;
  502.     }
  503.  
  504.     /**
  505.      * Return the icon to move an item UP.
  506.      *
  507.      * @param   integer  $i          The row index.
  508.      * @param   boolean  $condition  True to show the icon.
  509.      * @param   string   $task       The task to fire.
  510.      * @param   string   $alt        The image alternative text string.
  511.      * @param   boolean  $enabled    An optional setting for access control on the action.
  512.      * @param   string   $checkbox   An optional prefix for checkboxes.
  513.      *
  514.      * @return  string   Either the icon to move an item up or a space.
  515.      *
  516.      * @since   1.5
  517.      */
  518.     public function orderUpIcon($i$condition true$task 'orderup'$alt 'JLIB_HTML_MOVE_UP'$enabled true$checkbox 'cb')
  519.     {
  520.         if (($i || ($i $this->limitstart > 0)) && $condition)
  521.         {
  522.             return JHtml::_('jgrid.orderUp'$i$task''$alt$enabled$checkbox);
  523.         }
  524.         else
  525.         {
  526.             return '&#160;';
  527.         }
  528.     }
  529.  
  530.     /**
  531.      * Return the icon to move an item DOWN.
  532.      *
  533.      * @param   integer  $i          The row index.
  534.      * @param   integer  $n          The number of items in the list.
  535.      * @param   boolean  $condition  True to show the icon.
  536.      * @param   string   $task       The task to fire.
  537.      * @param   string   $alt        The image alternative text string.
  538.      * @param   boolean  $enabled    An optional setting for access control on the action.
  539.      * @param   string   $checkbox   An optional prefix for checkboxes.
  540.      *
  541.      * @return  string   Either the icon to move an item down or a space.
  542.      *
  543.      * @since   1.5
  544.      */
  545.     public function orderDownIcon($i$n$condition true$task 'orderdown'$alt 'JLIB_HTML_MOVE_DOWN'$enabled true$checkbox 'cb')
  546.     {
  547.         if (($i $n || $i $this->limitstart < $this->total - 1&& $condition)
  548.         {
  549.             return JHtml::_('jgrid.orderDown'$i$task''$alt$enabled$checkbox);
  550.         }
  551.         else
  552.         {
  553.             return '&#160;';
  554.         }
  555.     }
  556.  
  557.     /**
  558.      * Create the HTML for a list footer
  559.      *
  560.      * @param   array  $list  Pagination list data structure.
  561.      *
  562.      * @return  string  HTML for a list footer
  563.      *
  564.      * @since   1.5
  565.      */
  566.     protected function _list_footer($list)
  567.     {
  568.         $html "<div class=\"list-footer\">\n";
  569.  
  570.         $html .= "\n<div class=\"limit\">" JText::_('JGLOBAL_DISPLAY_NUM'$list['limitfield'"</div>";
  571.         $html .= $list['pageslinks'];
  572.         $html .= "\n<div class=\"counter\">" $list['pagescounter'"</div>";
  573.  
  574.         $html .= "\n<input type=\"hidden\" name=\"" $list['prefix'"limitstart\" value=\"" $list['limitstart'"\" />";
  575.         $html .= "\n</div>";
  576.  
  577.         return $html;
  578.     }
  579.  
  580.     /**
  581.      * Create the html for a list footer
  582.      *
  583.      * @param   array  $list  Pagination list data structure.
  584.      *
  585.      * @return  string  HTML for a list start, previous, next,end
  586.      *
  587.      * @since   1.5
  588.      */
  589.     protected function _list_render($list)
  590.     {
  591.         // Reverse output rendering for right-to-left display.
  592.         $html '<ul>';
  593.         $html .= '<li class="pagination-start">' $list['start']['data''</li>';
  594.         $html .= '<li class="pagination-prev">' $list['previous']['data''</li>';
  595.  
  596.         foreach ($list['pages'as $page)
  597.         {
  598.             $html .= '<li>' $page['data''</li>';
  599.         }
  600.  
  601.         $html .= '<li class="pagination-next">' $list['next']['data''</li>';
  602.         $html .= '<li class="pagination-end">' $list['end']['data''</li>';
  603.         $html .= '</ul>';
  604.  
  605.         return $html;
  606.     }
  607.  
  608.     /**
  609.      * Method to create an active pagination link to the item
  610.      *
  611.      * @param   JPaginationObject  $item  The object with which to make an active link.
  612.      *
  613.      * @return  string  HTML link
  614.      *
  615.      * @since   1.5
  616.      */
  617.     protected function _item_active(JPaginationObject $item)
  618.     {
  619.         $app JFactory::getApplication();
  620.  
  621.         $title '';
  622.         $class '';
  623.  
  624.         if (!is_numeric($item->text))
  625.         {
  626.             JHtml::_('bootstrap.tooltip');
  627.             $title ' title="' $item->text '"';
  628.             $class 'hasTooltip ';
  629.         }
  630.  
  631.         if ($app->isAdmin())
  632.         {
  633.             return '<a' $title ' href="#" onclick="document.adminForm.' $this->prefix
  634.             . 'limitstart.value=' ($item->base $item->base '0''; Joomla.submitform();return false;">' $item->text '</a>';
  635.         }
  636.         else
  637.         {
  638.             return '<a' $title ' href="' $item->link '" class="' $class 'pagenav">' $item->text '</a>';
  639.         }
  640.     }
  641.  
  642.     /**
  643.      * Method to create an inactive pagination string
  644.      *
  645.      * @param   JPaginationObject  $item  The item to be processed
  646.      *
  647.      * @return  string 
  648.      *
  649.      * @since   1.5
  650.      */
  651.     protected function _item_inactive(JPaginationObject $item)
  652.     {
  653.         $app JFactory::getApplication();
  654.  
  655.         if ($app->isAdmin())
  656.         {
  657.             return '<span>' $item->text '</span>';
  658.         }
  659.         else
  660.         {
  661.             return '<span class="pagenav">' $item->text '</span>';
  662.         }
  663.     }
  664.  
  665.     /**
  666.      * Create and return the pagination data object.
  667.      *
  668.      * @return  object  Pagination data object.
  669.      *
  670.      * @since   1.5
  671.      */
  672.     protected function _buildDataObject()
  673.     {
  674.         $data new stdClass;
  675.  
  676.         // Build the additional URL parameters string.
  677.         $params '';
  678.  
  679.         if (!empty($this->additionalUrlParams))
  680.         {
  681.             foreach ($this->additionalUrlParams as $key => $value)
  682.             {
  683.                 $params .= '&' $key '=' $value;
  684.             }
  685.         }
  686.  
  687.         $data->all new JPaginationObject(JText::_('JLIB_HTML_VIEW_ALL')$this->prefix);
  688.  
  689.         if (!$this->viewall)
  690.         {
  691.             $data->all->base '0';
  692.             $data->all->link JRoute::_($params '&' $this->prefix . 'limitstart=');
  693.         }
  694.  
  695.         // Set the start and previous data objects.
  696.         $data->start new JPaginationObject(JText::_('JLIB_HTML_START')$this->prefix);
  697.         $data->previous new JPaginationObject(JText::_('JPREV')$this->prefix);
  698.  
  699.         if ($this->pagesCurrent > 1)
  700.         {
  701.             $page ($this->pagesCurrent - 2$this->limit;
  702.  
  703.             // Set the empty for removal from route
  704.             // @todo remove code: $page = $page == 0 ? '' : $page;
  705.  
  706.             $data->start->base '0';
  707.             $data->start->link JRoute::_($params '&' $this->prefix . 'limitstart=0');
  708.             $data->previous->base $page;
  709.             $data->previous->link JRoute::_($params '&' $this->prefix . 'limitstart=' $page);
  710.         }
  711.  
  712.         // Set the next and end data objects.
  713.         $data->next new JPaginationObject(JText::_('JNEXT')$this->prefix);
  714.         $data->end new JPaginationObject(JText::_('JLIB_HTML_END')$this->prefix);
  715.  
  716.         if ($this->pagesCurrent < $this->pagesTotal)
  717.         {
  718.             $next $this->pagesCurrent * $this->limit;
  719.             $end ($this->pagesTotal - 1$this->limit;
  720.  
  721.             $data->next->base $next;
  722.             $data->next->link JRoute::_($params '&' $this->prefix . 'limitstart=' $next);
  723.             $data->end->base $end;
  724.             $data->end->link JRoute::_($params '&' $this->prefix . 'limitstart=' $end);
  725.         }
  726.  
  727.         $data->pages array();
  728.         $stop $this->pagesStop;
  729.  
  730.         for ($i $this->pagesStart$i <= $stop$i++)
  731.         {
  732.             $offset ($i 1$this->limit;
  733.  
  734.             $data->pages[$inew JPaginationObject($i$this->prefix);
  735.  
  736.             if ($i != $this->pagesCurrent || $this->viewall)
  737.             {
  738.                 $data->pages[$i]->base $offset;
  739.                 $data->pages[$i]->link JRoute::_($params '&' $this->prefix . 'limitstart=' $offset);
  740.             }
  741.             else
  742.             {
  743.                 $data->pages[$i]->active true;
  744.             }
  745.         }
  746.  
  747.         return $data;
  748.     }
  749.  
  750.     /**
  751.      * Modifies a property of the object, creating it if it does not already exist.
  752.      *
  753.      * @param   string  $property  The name of the property.
  754.      * @param   mixed   $value     The value of the property to set.
  755.      *
  756.      * @return  void 
  757.      *
  758.      * @since   3.0
  759.      * @deprecated  4.0  Access the properties directly.
  760.      */
  761.     public function set($property$value null)
  762.     {
  763.         JLog::add('JPagination::set() is deprecated. Access the properties directly.'JLog::WARNING'deprecated');
  764.  
  765.         if (strpos($property'.'))
  766.         {
  767.             $prop explode('.'$property);
  768.             $prop[1ucfirst($prop[1]);
  769.             $property implode($prop);
  770.         }
  771.  
  772.         $this->$property $value;
  773.     }
  774.  
  775.     /**
  776.      * Returns a property of the object or the default value if the property is not set.
  777.      *
  778.      * @param   string  $property  The name of the property.
  779.      * @param   mixed   $default   The default value.
  780.      *
  781.      * @return  mixed    The value of the property.
  782.      *
  783.      * @since   3.0
  784.      * @deprecated  4.0  Access the properties directly.
  785.      */
  786.     public function get($property$default null)
  787.     {
  788.         JLog::add('JPagination::get() is deprecated. Access the properties directly.'JLog::WARNING'deprecated');
  789.  
  790.         if (strpos($property'.'))
  791.         {
  792.             $prop explode('.'$property);
  793.             $prop[1ucfirst($prop[1]);
  794.             $property implode($prop);
  795.         }
  796.  
  797.         if (isset($this->$property))
  798.         {
  799.             return $this->$property;
  800.         }
  801.  
  802.         return $default;
  803.     }
  804. }

Documentation generated on Tue, 19 Nov 2013 15:10:08 +0100 by phpDocumentor 1.4.3