summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-13 13:49:55 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-13 13:49:55 +0100
commitaef63e532bcede1d455bc27f0fc6f369ab74f203 (patch)
treecb45c347ce82f8fd2b4b898f591050293ee84267
parent0bd390c660290b7dc478955da6a8a7fbb3ca9fd6 (diff)
Add language translation support to CI_Pagination (#1589)
-rw-r--r--system/libraries/Pagination.php21
-rw-r--r--user_guide_src/source/changelog.rst5
-rw-r--r--user_guide_src/source/libraries/pagination.rst8
3 files changed, 25 insertions, 9 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index da4b89232..2f1bcfbad 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -304,6 +304,16 @@ class CI_Pagination {
*/
public function __construct($params = array())
{
+ $CI =& get_instance();
+ $CI->load->language('paginaton');
+ foreach (array('first_link', 'next_link', 'prev_link', 'last_link') as $key)
+ {
+ if (($val = $CI->lang->line('pagination_'.$key)) !== FALSE)
+ {
+ $this->$key = $val;
+ }
+ }
+
$this->initialize($params);
log_message('debug', 'Pagination Class Initialized');
}
@@ -316,7 +326,7 @@ class CI_Pagination {
* @param array $params Initialization parameters
* @return CI_Pagination
*/
- public function initialize($params = array())
+ public function initialize(array $params = array())
{
if (isset($params['attributes']) && is_array($params['attributes']))
{
@@ -332,14 +342,11 @@ class CI_Pagination {
unset($params['anchor_class']);
}
- if (count($params) > 0)
+ foreach ($params as $key => $val)
{
- foreach ($params as $key => $val)
+ if (property_exists($this, $this->$key))
{
- if (isset($this->$key))
- {
- $this->$key = $val;
- }
+ $this->$key = $val;
}
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 029bf61cb..3bb88a779 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -367,11 +367,12 @@ Release Date: Not Released
- :doc:`Pagination Library <libraries/pagination>` changes include:
+ - Deprecated usage of the "anchor_class" setting (use the new "attributes" setting instead).
- Added method chaining support to ``initialize()`` method.
- Added support for the anchor "rel" attribute.
- Added support for setting custom attributes.
- - Deprecated usage of the "anchor_class" setting (use the new "attributes" setting instead).
- - Added $config['reuse_query_string'] to allow automatic repopulation of query string arguments, combined with normal URI segments.
+ - Added support for language translations of the *first_link*, *next_link*, *prev_link* and *last_link* values.
+ - Added ``$config['reuse_query_string']`` to allow automatic repopulation of query string arguments, combined with normal URI segments.
- Removed the default ``&nbsp;`` from a number of the configuration variables.
- :doc:`Profiler Library <general/profiling>` changes include:
diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst
index ee12d9e6f..d8d31f8c5 100644
--- a/user_guide_src/source/libraries/pagination.rst
+++ b/user_guide_src/source/libraries/pagination.rst
@@ -165,6 +165,8 @@ $config['first_link'] = 'First';
The text you would like shown in the "first" link on the left. If you do
not want this link rendered, you can set its value to FALSE.
+.. note:: This value can also be translated via a language file.
+
$config['first_tag_open'] = '<div>';
====================================
@@ -185,6 +187,8 @@ $config['last_link'] = 'Last';
The text you would like shown in the "last" link on the right. If you do
not want this link rendered, you can set its value to FALSE.
+.. note:: This value can also be translated via a language file.
+
$config['last_tag_open'] = '<div>';
===================================
@@ -205,6 +209,8 @@ $config['next_link'] = '&gt;';
The text you would like shown in the "next" page link. If you do not
want this link rendered, you can set its value to FALSE.
+.. note:: This value can also be translated via a language file.
+
$config['next_tag_open'] = '<div>';
===================================
@@ -225,6 +231,8 @@ $config['prev_link'] = '&lt;';
The text you would like shown in the "previous" page link. If you do not
want this link rendered, you can set its value to FALSE.
+.. note:: This value can also be translated via a language file.
+
$config['prev_tag_open'] = '<div>';
===================================