Changeset 1905 for trunk/system/libraries/Pagination.php
- Timestamp:
- 02/03/2008 02:00:03 AM (10 months ago)
- Files:
-
- 1 modified
-
trunk/system/libraries/Pagination.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/libraries/Pagination.php
r1537 r1905 11 11 12 12 // Config values 13 pr ivate$base_url = '';14 pr ivate$directory = 'pagination';15 pr ivate$style = 'classic';16 pr ivate$uri_segment = 3;13 protected $base_url = ''; 14 protected $directory = 'pagination'; 15 protected $style = 'classic'; 16 protected $uri_segment = 3; 17 17 protected $items_per_page = 10; 18 18 protected $total_items = 0; … … 28 28 protected $previous_page; 29 29 protected $next_page; 30 protected $sql_offset; 31 protected $sql_limit; 30 32 31 33 /** 32 * Constructor: __construct 33 * Sets up the config values. 34 * Constructs the Pagination object. 34 35 * 35 * Parameters:36 * config - custom configuration36 * @param array configuration 37 * @return void 37 38 */ 38 39 public function __construct($config = array()) … … 47 48 48 49 /** 49 * Method: initialize 50 * Sets or overwrites (some) config values. 50 * Sets or overwrites (some) config values. 51 51 * 52 * Parameters:53 * config - custom configuration52 * @param array configuration 53 * @return void 54 54 */ 55 55 public function initialize($config = array()) … … 103 103 $this->previous_page = ($this->current_page > 1) ? $this->current_page - 1 : FALSE; 104 104 $this->next_page = ($this->current_page < $this->total_pages) ? $this->current_page + 1 : FALSE; 105 106 // SQL values 107 $this->sql_offset = (int) ($this->current_page - 1) * $this->items_per_page; 108 $this->sql_limit = sprintf(' LIMIT %d OFFSET %d ', $this->items_per_page, $this->sql_offset); 105 109 } 106 110 107 111 /** 108 * Method: create_links 109 * Generates the HTML for the chosen pagination style. 112 * Generates the HTML for the chosen pagination style. 110 113 * 111 * Parameters: 112 * style - style of generated links 113 * 114 * Returns: 115 * Generated pagination HTML. 114 * @param string pagination style 115 * @return string pagination html 116 116 */ 117 117 public function create_links($style = NULL) … … 123 123 124 124 /** 125 * Method: __toString 126 * Magic method for converting an object to a string. 125 * Magically converts pagination object to string. 127 126 * 128 * Returns: 129 * The generated pagination HTML. 127 * @return string pagination html 130 128 */ 131 129 public function __toString() … … 135 133 136 134 /** 137 * Method: sql_offset 138 * Gets the SQL offset of the first row to return. 135 * Magically gets a pagination variable. 139 136 * 140 * Returns: 141 * SQL offset integer. 137 * @param string variable key 138 * @return mixed variable value if the key is found 139 * @return void if the key is not found 140 */ 141 public function __get($key) 142 { 143 if (isset($this->$key)) 144 return $this->$key; 145 } 146 147 /** 148 * Gets the SQL offset of the first row to return. Deprecated. 149 * 150 * @return integer sql offset 142 151 */ 143 152 public function sql_offset() 144 153 { 145 return (int) ($this->current_page - 1) * $this->items_per_page;154 return $this->sql_offset; 146 155 } 147 156 148 157 /** 149 * Method: sql_limit 150 * Generates the complete SQL LIMIT clause. 158 * Generates the complete SQL LIMIT clause. Deprecated. 151 159 * 152 * Returns: 153 * SQL LIMIT clause. 160 * @return string sql limit clause 154 161 */ 155 162 public function sql_limit() 156 163 { 157 return sprintf(' LIMIT %d OFFSET %d ', $this->items_per_page, $this->sql_offset());164 return $this->sql_limit; 158 165 } 159 166
