summaryrefslogtreecommitdiffstats
path: root/system/libraries/Parser.php
diff options
context:
space:
mode:
authorBrennan Thompson <brenjt@gmail.com>2014-02-14 20:03:57 +0100
committerBrennan Thompson <brenjt@gmail.com>2014-02-14 20:03:57 +0100
commit6949f95f6e21980f36095490bf38fc8a172dbc0f (patch)
treeb3141f390acd0051396cda6a3da51c1f98384cca /system/libraries/Parser.php
parent68a02a01a086bbb1b8128ea2744439de84873d11 (diff)
parent81f036753272391360ba5b64e6dd93c4101a8733 (diff)
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts: system/helpers/form_helper.php
Diffstat (limited to 'system/libraries/Parser.php')
-rw-r--r--system/libraries/Parser.php32
1 files changed, 20 insertions, 12 deletions
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index c1f1ad73b..d23a53423 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -18,7 +18,7 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 1.0
@@ -187,26 +187,34 @@ class CI_Parser {
*/
protected function _parse_pair($variable, $data, $string)
{
- if (FALSE === ($match = $this->_match_pair($string, $variable)))
+ if (FALSE === ($matches = $this->_match_pair($string, $variable)))
{
return $string;
}
$str = '';
- foreach ($data as $row)
+ $search = $replace = array();
+ foreach ($matches as $match)
{
- $temp = $match[1];
- foreach ($row as $key => $val)
+ $str = '';
+ foreach ($data as $row)
{
- $temp = is_array($val)
+ $temp = $match[1];
+ foreach ($row as $key => $val)
+ {
+ $temp = is_array($val)
? $this->_parse_pair($key, $val, $temp)
: $this->_parse_single($key, $val, $temp);
+ }
+
+ $str .= $temp;
}
- $str .= $temp;
+ $search[] = $match[0];
+ $replace[] = $str;
}
- return str_replace($match[0], $str, $string);
+ return str_replace($search, $replace, $string);
}
// --------------------------------------------------------------------
@@ -214,14 +222,14 @@ class CI_Parser {
/**
* Matches a variable pair
*
- * @param string
- * @param string
+ * @param string $string
+ * @param string $variable
* @return mixed
*/
protected function _match_pair($string, $variable)
{
- return preg_match('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s',
- $string, $match)
+ return preg_match_all('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s',
+ $string, $match, PREG_SET_ORDER)
? $match : FALSE;
}