summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Barnes <eric@ericlbarnes.com>2011-12-24 07:34:27 +0100
committerEric Barnes <eric@ericlbarnes.com>2011-12-24 07:34:27 +0100
commitaf1a9bf2907754f7ab6af1b182c89b63ce7f8d25 (patch)
tree9e37ce2360c0c74286afca80f60944cee73dc6ef
parent320d6db867508db9f0e82a2818932383ec5a2c2f (diff)
parentee3bc29f39819cf6cabcc593162982e95c6e08dd (diff)
Merge pull request #815 from narfbg/develop-parser
Improve the Parser library
-rw-r--r--system/libraries/Parser.php40
1 files changed, 20 insertions, 20 deletions
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 0e6ab63d8..39aa61e45 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -38,9 +38,10 @@
*/
class CI_Parser {
- var $l_delim = '{';
- var $r_delim = '}';
- var $object;
+ public $l_delim = '{';
+ public $r_delim = '}';
+ public $object;
+ private $CI;
/**
* Parse a template
@@ -56,8 +57,8 @@ class CI_Parser {
*/
public function parse($template, $data, $return = FALSE)
{
- $CI =& get_instance();
- $template = $CI->load->view($template, $data, TRUE);
+ $this->CI =& get_instance();
+ $template = $this->CI->load->view($template, $data, TRUE);
return $this->_parse($template, $data, $return);
}
@@ -76,7 +77,7 @@ class CI_Parser {
* @param bool
* @return string
*/
- function parse_string($template, $data, $return = FALSE)
+ public function parse_string($template, $data, $return = FALSE)
{
return $this->_parse($template, $data, $return);
}
@@ -89,13 +90,13 @@ class CI_Parser {
* Parses pseudo-variables contained in the specified template,
* replacing them with the data in the second param
*
- * @access public
+ * @access private
* @param string
* @param array
* @param bool
* @return string
*/
- function _parse($template, $data, $return = FALSE)
+ private function _parse($template, $data, $return = FALSE)
{
if ($template == '')
{
@@ -116,8 +117,7 @@ class CI_Parser {
if ($return == FALSE)
{
- $CI =& get_instance();
- $CI->output->append_output($template);
+ $this->CI->output->append_output($template);
}
return $template;
@@ -133,7 +133,7 @@ class CI_Parser {
* @param string
* @return void
*/
- function set_delimiters($l = '{', $r = '}')
+ public function set_delimiters($l = '{', $r = '}')
{
$this->l_delim = $l;
$this->r_delim = $r;
@@ -150,9 +150,9 @@ class CI_Parser {
* @param string
* @return string
*/
- function _parse_single($key, $val, $string)
+ private function _parse_single($key, $val, $string)
{
- return str_replace($this->l_delim.$key.$this->r_delim, $val, $string);
+ return str_replace($this->l_delim.$key.$this->r_delim, (string) $val, $string);
}
// --------------------------------------------------------------------
@@ -168,7 +168,7 @@ class CI_Parser {
* @param string
* @return string
*/
- function _parse_pair($variable, $data, $string)
+ private function _parse_pair($variable, $data, $string)
{
if (FALSE === ($match = $this->_match_pair($string, $variable)))
{
@@ -178,7 +178,7 @@ class CI_Parser {
$str = '';
foreach ($data as $row)
{
- $temp = $match['1'];
+ $temp = $match[1];
foreach ($row as $key => $val)
{
if ( ! is_array($val))
@@ -194,7 +194,7 @@ class CI_Parser {
$str .= $temp;
}
- return str_replace($match['0'], $str, $string);
+ return str_replace($match[0], $str, $string);
}
// --------------------------------------------------------------------
@@ -207,7 +207,7 @@ class CI_Parser {
* @param string
* @return mixed
*/
- function _match_pair($string, $variable)
+ private function _match_pair($string, $variable)
{
if ( ! 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))
{