mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Simple parse via parseTemplate added, small improvements
This commit is contained in:
@@ -17,8 +17,8 @@
|
|||||||
* @package e107
|
* @package e107
|
||||||
* @subpackage e107_handlers
|
* @subpackage e107_handlers
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*
|
*
|
||||||
* Text processing and parsing functions.
|
* Text processing and parsing functions.
|
||||||
* Simple parse data model.
|
* Simple parse data model.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -520,7 +520,7 @@ class e_parse
|
|||||||
{
|
{
|
||||||
$ret = str_replace(array("[php]", "[/php]"), array("[php]", "[/php]"), $ret);
|
$ret = str_replace(array("[php]", "[/php]"), array("[php]", "[/php]"), $ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,10 +568,10 @@ class e_parse
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function parseTemplate($text, $parseSCFiles = TRUE, $extraCodes = "")
|
function parseTemplate($text, $parseSCFiles = TRUE, $extraCodes = '', $eVars = null)
|
||||||
{
|
{
|
||||||
//$this->sch_load();
|
//$this->sch_load();
|
||||||
return $this->e_sc->parseCodes($text, $parseSCFiles, $extraCodes);
|
return $this->e_sc->parseCodes($text, $parseSCFiles, $extraCodes, $eVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
function simpleParse(&$template, &$vars, $replaceUnset=true)
|
function simpleParse(&$template, &$vars, $replaceUnset=true)
|
||||||
@@ -580,12 +580,12 @@ class e_parse
|
|||||||
$this->replaceUnset = $replaceUnset;
|
$this->replaceUnset = $replaceUnset;
|
||||||
return preg_replace_callback("#\{([a-zA-Z0-9_]+)\}#", array($this, 'simpleReplace'), $template);
|
return preg_replace_callback("#\{([a-zA-Z0-9_]+)\}#", array($this, 'simpleReplace'), $template);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function simpleReplace($tmp) {
|
protected function simpleReplace($tmp) {
|
||||||
$unset = ($this->replaceUnset !== false ? $this->replaceUnset : $tmp[0]);
|
$unset = ($this->replaceUnset !== false ? $this->replaceUnset : $tmp[0]);
|
||||||
return ($this->replaceVars->$tmp[1] !== null ? $this->replaceVars->$tmp[1] : $unset);
|
return ($this->replaceVars->$tmp[1] !== null ? $this->replaceVars->$tmp[1] : $unset);
|
||||||
}
|
}
|
||||||
|
|
||||||
function htmlwrap($str, $width, $break = "\n", $nobreak = "a", $nobr = "pre", $utf = FALSE)
|
function htmlwrap($str, $width, $break = "\n", $nobreak = "a", $nobr = "pre", $utf = FALSE)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -1903,7 +1903,7 @@ class e_parse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Data model for e_parse::simpleParse()
|
* Data model for e_parse::simpleParse()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class e_vars
|
class e_vars
|
||||||
{
|
{
|
||||||
@@ -1911,20 +1911,20 @@ class e_vars
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $vars;
|
private $vars;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param array $array [optional] initial data
|
* @param array $array [optional] initial data
|
||||||
*/
|
*/
|
||||||
public function __construct($array = array())
|
public function __construct($array = array())
|
||||||
{
|
{
|
||||||
$this->setVars($array);
|
$this->setVars($array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set array data
|
* Set array data
|
||||||
*
|
*
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @param boolean $empty true (default) override old data, false - merge with existing data
|
* @param boolean $empty true (default) override old data, false - merge with existing data
|
||||||
* @return e_vars
|
* @return e_vars
|
||||||
@@ -1940,22 +1940,22 @@ class e_vars
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add array data to the object (merge with existing)
|
* Add array data to the object (merge with existing)
|
||||||
* Convenient proxy to setVars methods
|
* Convenient proxy to setVars methods
|
||||||
*
|
*
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public function addVars(array $array)
|
public function addVars(array $array)
|
||||||
{
|
{
|
||||||
$this->setVars($array, false);
|
$this->setVars($array, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset object data
|
* Reset object data
|
||||||
*
|
*
|
||||||
* @return e_vars
|
* @return e_vars
|
||||||
*/
|
*/
|
||||||
public function emptyVars()
|
public function emptyVars()
|
||||||
@@ -1963,20 +1963,20 @@ class e_vars
|
|||||||
$this->vars = array();
|
$this->vars = array();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if there is data available
|
* Check if there is data available
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isEmpty()
|
public function isEmpty()
|
||||||
{
|
{
|
||||||
return empty($this->vars);
|
return empty($this->vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic setter
|
* Magic setter
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
@@ -1984,10 +1984,10 @@ class e_vars
|
|||||||
{
|
{
|
||||||
$this->vars[$key] = $value;
|
$this->vars[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic getter
|
* Magic getter
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return mixed value or null if key not found
|
* @return mixed value or null if key not found
|
||||||
*/
|
*/
|
||||||
@@ -1997,15 +1997,15 @@ class e_vars
|
|||||||
{
|
{
|
||||||
return $this->vars[$key];
|
return $this->vars[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic method to check if given data key is set.
|
* Magic method to check if given data key is set.
|
||||||
* Triggered on <code><?php isset($e_vars->myKey); </code>
|
* Triggered on <code><?php isset($e_vars->myKey); </code>
|
||||||
* NOTE: works on PHP 5.1.0+
|
* NOTE: works on PHP 5.1.0+
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@@ -2013,12 +2013,12 @@ class e_vars
|
|||||||
{
|
{
|
||||||
return isset($this->vars[$key]);
|
return isset($this->vars[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic method to unset given data key.
|
* Magic method to unset given data key.
|
||||||
* Triggered on <code><?php unset($e_vars->myKey); </code>
|
* Triggered on <code><?php unset($e_vars->myKey); </code>
|
||||||
* NOTE: works on PHP 5.1.0+
|
* NOTE: works on PHP 5.1.0+
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
*/
|
*/
|
||||||
public function __unset($key)
|
public function __unset($key)
|
||||||
|
@@ -340,11 +340,12 @@ class e_shortcode
|
|||||||
return in_array($code, $this->scOverride);
|
return in_array($code, $this->scOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCodes($text, $useSCFiles = true, $extraCodes = '', &$eVars='')
|
function parseCodes($text, $useSCFiles = true, $extraCodes = '', $eVars = null)
|
||||||
{
|
{
|
||||||
$saveParseSCFiles = $this->parseSCFiles; // In case of nested call
|
$saveParseSCFiles = $this->parseSCFiles; // In case of nested call
|
||||||
$this->parseSCFiles = $useSCFiles;
|
$this->parseSCFiles = $useSCFiles;
|
||||||
|
|
||||||
|
$this->eVars = null;
|
||||||
if(is_object($eVars)) {
|
if(is_object($eVars)) {
|
||||||
$this->eVars = $eVars;
|
$this->eVars = $eVars;
|
||||||
}
|
}
|
||||||
@@ -379,7 +380,7 @@ class e_shortcode
|
|||||||
{
|
{
|
||||||
global $pref, $e107cache, $menu_pref, $sc_style, $parm, $sql;
|
global $pref, $e107cache, $menu_pref, $sc_style, $parm, $sql;
|
||||||
|
|
||||||
if(is_object($this->eVars)) {
|
if($this->eVars) {
|
||||||
if($this->eVars->$matches[1]) {
|
if($this->eVars->$matches[1]) {
|
||||||
return $this->eVars->$matches[1];
|
return $this->eVars->$matches[1];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user