mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #4658 from spekulatius/remove-trailing-spaces
remove trailing spaces in the codebase
This commit is contained in:
commit
254c5297d0
@ -378,7 +378,7 @@ class HTTP {
|
|||||||
// (http://support.microsoft.com/kb/323308)
|
// (http://support.microsoft.com/kb/323308)
|
||||||
// Note: this is also fixable by ticking "Do not save encrypted pages to disk" in advanced options.
|
// Note: this is also fixable by ticking "Do not save encrypted pages to disk" in advanced options.
|
||||||
$cacheControlHeaders['max-age'] = 3;
|
$cacheControlHeaders['max-age'] = 3;
|
||||||
|
|
||||||
// Set empty pragma to avoid PHP's session_cache_limiter adding conflicting caching information,
|
// Set empty pragma to avoid PHP's session_cache_limiter adding conflicting caching information,
|
||||||
// defaulting to "nocache" on most PHP configurations (see http://php.net/session_cache_limiter).
|
// defaulting to "nocache" on most PHP configurations (see http://php.net/session_cache_limiter).
|
||||||
// Since it's a deprecated HTTP 1.0 option, all modern HTTP clients and proxies should
|
// Since it's a deprecated HTTP 1.0 option, all modern HTTP clients and proxies should
|
||||||
|
@ -9,16 +9,16 @@
|
|||||||
* of your values.
|
* of your values.
|
||||||
* For any statics containing natural language, never use the static directly -
|
* For any statics containing natural language, never use the static directly -
|
||||||
* always wrap it in a getter.
|
* always wrap it in a getter.
|
||||||
*
|
*
|
||||||
* Classes must be able to be constructed without mandatory arguments, otherwise
|
* Classes must be able to be constructed without mandatory arguments, otherwise
|
||||||
* this interface will have no effect.
|
* this interface will have no effect.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage i18n
|
* @subpackage i18n
|
||||||
* @uses i18nTextCollector->collectFromEntityProviders()
|
* @uses i18nTextCollector->collectFromEntityProviders()
|
||||||
*/
|
*/
|
||||||
interface i18nEntityProvider {
|
interface i18nEntityProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example usage:
|
* Example usage:
|
||||||
* <code>
|
* <code>
|
||||||
@ -28,13 +28,13 @@ interface i18nEntityProvider {
|
|||||||
* foreach($this->stat('my_static_array) as $key => $value) {
|
* foreach($this->stat('my_static_array) as $key => $value) {
|
||||||
* $entities["MyTestClass.my_static_array_{$key}"] = array(
|
* $entities["MyTestClass.my_static_array_{$key}"] = array(
|
||||||
* $value,
|
* $value,
|
||||||
*
|
*
|
||||||
* 'My context description'
|
* 'My context description'
|
||||||
* );
|
* );
|
||||||
* }
|
* }
|
||||||
* return $entities;
|
* return $entities;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* public static function my_static_array() {
|
* public static function my_static_array() {
|
||||||
* $t_my_static_array = array();
|
* $t_my_static_array = array();
|
||||||
* foreach(self::$my_static_array as $k => $v) {
|
* foreach(self::$my_static_array as $k => $v) {
|
||||||
@ -44,9 +44,9 @@ interface i18nEntityProvider {
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* Example usage in {@link DataObject->provideI18nEntities()}.
|
* Example usage in {@link DataObject->provideI18nEntities()}.
|
||||||
*
|
*
|
||||||
* You can ask textcollector to add the provided entity to a different module
|
* You can ask textcollector to add the provided entity to a different module
|
||||||
* than the class is contained in by adding a 4th argument to the array:
|
* than the class is contained in by adding a 4th argument to the array:
|
||||||
* <code>
|
* <code>
|
||||||
@ -55,7 +55,7 @@ interface i18nEntityProvider {
|
|||||||
* $entities = array();
|
* $entities = array();
|
||||||
* $entities["MyOtherModuleClass.MYENTITY"] = array(
|
* $entities["MyOtherModuleClass.MYENTITY"] = array(
|
||||||
* $value,
|
* $value,
|
||||||
*
|
*
|
||||||
* 'My context description',
|
* 'My context description',
|
||||||
* 'myothermodule'
|
* 'myothermodule'
|
||||||
* );
|
* );
|
||||||
@ -63,7 +63,7 @@ interface i18nEntityProvider {
|
|||||||
* return $entities;
|
* return $entities;
|
||||||
* }
|
* }
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @return array All entites in an associative array, with
|
* @return array All entites in an associative array, with
|
||||||
* entity name as the key, and a numerical array of pseudo-arguments
|
* entity name as the key, and a numerical array of pseudo-arguments
|
||||||
* for _t() as a value.
|
* for _t() as a value.
|
||||||
|
@ -51,7 +51,7 @@ class DebugViewFriendlyErrorFormatter implements FormatterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function output() {
|
public function output() {
|
||||||
// TODO: Refactor into a content-type option
|
// TODO: Refactor into a content-type option
|
||||||
if(\Director::is_ajax()) {
|
if(\Director::is_ajax()) {
|
||||||
return $this->friendlyErrorMessage;
|
return $this->friendlyErrorMessage;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class HTTPOutputHandler extends AbstractProcessingHandler
|
|||||||
protected function write(array $record) {
|
protected function write(array $record) {
|
||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
|
|
||||||
// TODO: This coupling isn't ideal
|
// TODO: This coupling isn't ideal
|
||||||
// See https://github.com/silverstripe/silverstripe-framework/issues/4484
|
// See https://github.com/silverstripe/silverstripe-framework/issues/4484
|
||||||
if(\Controller::has_curr()) {
|
if(\Controller::has_curr()) {
|
||||||
$response = \Controller::curr()->getResponse();
|
$response = \Controller::curr()->getResponse();
|
||||||
|
@ -4,27 +4,27 @@
|
|||||||
* It is a simple regex based parser that allows you to replace simple bbcode-like tags
|
* It is a simple regex based parser that allows you to replace simple bbcode-like tags
|
||||||
* within a HTMLText or HTMLVarchar field when rendered into a template. The API is inspired by and very similar to the
|
* within a HTMLText or HTMLVarchar field when rendered into a template. The API is inspired by and very similar to the
|
||||||
* [Wordpress implementation](http://codex.wordpress.org/Shortcode_API) of shortcodes.
|
* [Wordpress implementation](http://codex.wordpress.org/Shortcode_API) of shortcodes.
|
||||||
*
|
*
|
||||||
* @see http://doc.silverstripe.org/framework/en/reference/shortcodes
|
* @see http://doc.silverstripe.org/framework/en/reference/shortcodes
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage misc
|
* @subpackage misc
|
||||||
*/
|
*/
|
||||||
class ShortcodeParser extends Object {
|
class ShortcodeParser extends Object {
|
||||||
|
|
||||||
public function img_shortcode($attrs) {
|
public function img_shortcode($attrs) {
|
||||||
return "<img src='".$attrs['src']."'>";
|
return "<img src='".$attrs['src']."'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static $instances = array();
|
protected static $instances = array();
|
||||||
|
|
||||||
protected static $active_instance = 'default';
|
protected static $active_instance = 'default';
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
protected $shortcodes = array();
|
protected $shortcodes = array();
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link ShortcodeParser} instance that is attached to a particular identifier.
|
* Get the {@link ShortcodeParser} instance that is attached to a particular identifier.
|
||||||
*
|
*
|
||||||
@ -35,10 +35,10 @@ class ShortcodeParser extends Object {
|
|||||||
if(!array_key_exists($identifier, self::$instances)) {
|
if(!array_key_exists($identifier, self::$instances)) {
|
||||||
self::$instances[$identifier] = static::create();
|
self::$instances[$identifier] = static::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instances[$identifier];
|
return self::$instances[$identifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the currently active/default {@link ShortcodeParser} instance.
|
* Get the currently active/default {@link ShortcodeParser} instance.
|
||||||
*
|
*
|
||||||
@ -47,7 +47,7 @@ class ShortcodeParser extends Object {
|
|||||||
public static function get_active() {
|
public static function get_active() {
|
||||||
return static::get(self::$active_instance);
|
return static::get(self::$active_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the identifier to use for the current active/default {@link ShortcodeParser} instance.
|
* Set the identifier to use for the current active/default {@link ShortcodeParser} instance.
|
||||||
*
|
*
|
||||||
@ -56,9 +56,9 @@ class ShortcodeParser extends Object {
|
|||||||
public static function set_active($identifier) {
|
public static function set_active($identifier) {
|
||||||
self::$active_instance = (string) $identifier;
|
self::$active_instance = (string) $identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a shortcode, and attach it to a PHP callback.
|
* Register a shortcode, and attach it to a PHP callback.
|
||||||
*
|
*
|
||||||
@ -76,7 +76,7 @@ class ShortcodeParser extends Object {
|
|||||||
public function register($shortcode, $callback) {
|
public function register($shortcode, $callback) {
|
||||||
if(is_callable($callback)) $this->shortcodes[$shortcode] = $callback;
|
if(is_callable($callback)) $this->shortcodes[$shortcode] = $callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a shortcode has been registered.
|
* Check if a shortcode has been registered.
|
||||||
*
|
*
|
||||||
@ -86,7 +86,7 @@ class ShortcodeParser extends Object {
|
|||||||
public function registered($shortcode) {
|
public function registered($shortcode) {
|
||||||
return array_key_exists($shortcode, $this->shortcodes);
|
return array_key_exists($shortcode, $this->shortcodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a specific registered shortcode.
|
* Remove a specific registered shortcode.
|
||||||
*
|
*
|
||||||
@ -95,14 +95,14 @@ class ShortcodeParser extends Object {
|
|||||||
public function unregister($shortcode) {
|
public function unregister($shortcode) {
|
||||||
if($this->registered($shortcode)) unset($this->shortcodes[$shortcode]);
|
if($this->registered($shortcode)) unset($this->shortcodes[$shortcode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all registered shortcodes.
|
* Remove all registered shortcodes.
|
||||||
*/
|
*/
|
||||||
public function clear() {
|
public function clear() {
|
||||||
$this->shortcodes = array();
|
$this->shortcodes = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call a shortcode and return its replacement text
|
* Call a shortcode and return its replacement text
|
||||||
* Returns false if the shortcode isn't registered
|
* Returns false if the shortcode isn't registered
|
||||||
@ -111,7 +111,7 @@ class ShortcodeParser extends Object {
|
|||||||
if (!$tag || !isset($this->shortcodes[$tag])) return false;
|
if (!$tag || !isset($this->shortcodes[$tag])) return false;
|
||||||
return call_user_func($this->shortcodes[$tag], $attributes, $content, $this, $tag, $extra);
|
return call_user_func($this->shortcodes[$tag], $attributes, $content, $this, $tag, $extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the text to insert in place of a shoprtcode.
|
* Return the text to insert in place of a shoprtcode.
|
||||||
* Behaviour in the case of missing shortcodes depends on the setting of ShortcodeParser::$error_behavior.
|
* Behaviour in the case of missing shortcodes depends on the setting of ShortcodeParser::$error_behavior.
|
||||||
@ -145,14 +145,14 @@ class ShortcodeParser extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
protected function removeNode($node) {
|
protected function removeNode($node) {
|
||||||
$node->parentNode->removeChild($node);
|
$node->parentNode->removeChild($node);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function insertAfter($new, $after) {
|
protected function insertAfter($new, $after) {
|
||||||
$parent = $after->parentNode; $next = $after->nextSibling;
|
$parent = $after->parentNode; $next = $after->nextSibling;
|
||||||
|
|
||||||
if ($next) {
|
if ($next) {
|
||||||
$parent->insertBefore($new, $next);
|
$parent->insertBefore($new, $next);
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ class ShortcodeParser extends Object {
|
|||||||
$parent->appendChild($new);
|
$parent->appendChild($new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function insertListAfter($new, $after) {
|
protected function insertListAfter($new, $after) {
|
||||||
$doc = $after->ownerDocument; $parent = $after->parentNode; $next = $after->nextSibling;
|
$doc = $after->ownerDocument; $parent = $after->parentNode; $next = $after->nextSibling;
|
||||||
|
|
||||||
@ -168,8 +168,8 @@ class ShortcodeParser extends Object {
|
|||||||
$imported = $doc->importNode($new->item($i), true);
|
$imported = $doc->importNode($new->item($i), true);
|
||||||
|
|
||||||
if ($next) {
|
if ($next) {
|
||||||
$parent->insertBefore($imported, $next);
|
$parent->insertBefore($imported, $next);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$parent->appendChild($imported);
|
$parent->appendChild($imported);
|
||||||
}
|
}
|
||||||
@ -183,9 +183,9 @@ class ShortcodeParser extends Object {
|
|||||||
'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'ol', 'output', 'p',
|
'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'ol', 'output', 'p',
|
||||||
'pre', 'section', 'table', 'ul'
|
'pre', 'section', 'table', 'ul'
|
||||||
);
|
);
|
||||||
|
|
||||||
protected static $attrrx = '
|
protected static $attrrx = '
|
||||||
([^\s\/\'"=,]+) # Name
|
([^\s\/\'"=,]+) # Name
|
||||||
\s* = \s*
|
\s* = \s*
|
||||||
(?:
|
(?:
|
||||||
(?:\'([^\']+)\') | # Value surrounded by \'
|
(?:\'([^\']+)\') | # Value surrounded by \'
|
||||||
@ -193,7 +193,7 @@ class ShortcodeParser extends Object {
|
|||||||
([^\s,\]]+) # Bare value
|
([^\s,\]]+) # Bare value
|
||||||
)
|
)
|
||||||
';
|
';
|
||||||
|
|
||||||
protected static function attrrx() {
|
protected static function attrrx() {
|
||||||
return '/'.self::$attrrx.'/xS';
|
return '/'.self::$attrrx.'/xS';
|
||||||
}
|
}
|
||||||
@ -201,21 +201,21 @@ class ShortcodeParser extends Object {
|
|||||||
protected static $tagrx = '
|
protected static $tagrx = '
|
||||||
# HTML Tag
|
# HTML Tag
|
||||||
<(?<element>(?:"[^"]*"[\'"]*|\'[^\']*\'[\'"]*|[^\'">])+)>
|
<(?<element>(?:"[^"]*"[\'"]*|\'[^\']*\'[\'"]*|[^\'">])+)>
|
||||||
|
|
||||||
| # Opening tag
|
| # Opening tag
|
||||||
(?<oesc>\[?)
|
(?<oesc>\[?)
|
||||||
\[
|
\[
|
||||||
(?<open>\w+)
|
(?<open>\w+)
|
||||||
[\s,]*
|
[\s,]*
|
||||||
(?<attrs> (?: %s [\s,]*)* )
|
(?<attrs> (?: %s [\s,]*)* )
|
||||||
\/?\]
|
\/?\]
|
||||||
(?<cesc1>\]?)
|
(?<cesc1>\]?)
|
||||||
|
|
||||||
| # Closing tag
|
| # Closing tag
|
||||||
\[\/
|
\[\/
|
||||||
(?<close>\w+)
|
(?<close>\w+)
|
||||||
\]
|
\]
|
||||||
(?<cesc2>\]?)
|
(?<cesc2>\]?)
|
||||||
';
|
';
|
||||||
|
|
||||||
protected static function tagrx() {
|
protected static function tagrx() {
|
||||||
@ -235,14 +235,14 @@ class ShortcodeParser extends Object {
|
|||||||
* of those tags
|
* of those tags
|
||||||
*
|
*
|
||||||
* Doesn't support nested shortcode tags
|
* Doesn't support nested shortcode tags
|
||||||
*
|
*
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @return array - The list of tags found. When using an open/close pair, only one item will be in the array,
|
* @return array - The list of tags found. When using an open/close pair, only one item will be in the array,
|
||||||
* with "content" set to the text between the tags
|
* with "content" set to the text between the tags
|
||||||
*/
|
*/
|
||||||
public function extractTags($content) {
|
public function extractTags($content) {
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
|
||||||
// Step 1: perform basic regex scan of individual tags
|
// Step 1: perform basic regex scan of individual tags
|
||||||
if(preg_match_all(static::tagrx(), $content, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
|
if(preg_match_all(static::tagrx(), $content, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
|
||||||
foreach($matches as $match) {
|
foreach($matches as $match) {
|
||||||
@ -251,7 +251,7 @@ class ShortcodeParser extends Object {
|
|||||||
|
|
||||||
// Pull the attributes out into a key/value hash
|
// Pull the attributes out into a key/value hash
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
|
|
||||||
if (!empty($match['attrs'][0])) {
|
if (!empty($match['attrs'][0])) {
|
||||||
preg_match_all(static::attrrx(), $match['attrs'][0], $attrmatches, PREG_SET_ORDER);
|
preg_match_all(static::attrrx(), $match['attrs'][0], $attrmatches, PREG_SET_ORDER);
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ class ShortcodeParser extends Object {
|
|||||||
$attrs[$name] = $value;
|
$attrs[$name] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// And store the indexes, tag details, etc
|
// And store the indexes, tag details, etc
|
||||||
$tags[] = array(
|
$tags[] = array(
|
||||||
'text' => $match[0][0],
|
'text' => $match[0][0],
|
||||||
@ -281,7 +281,7 @@ class ShortcodeParser extends Object {
|
|||||||
if(!empty($tags[$i]['close'])) {
|
if(!empty($tags[$i]['close'])) {
|
||||||
// If the tag just before this one isn't the related opening tag, throw an error
|
// If the tag just before this one isn't the related opening tag, throw an error
|
||||||
$err = null;
|
$err = null;
|
||||||
|
|
||||||
if ($i == 0) {
|
if ($i == 0) {
|
||||||
$err = 'Close tag "'.$tags[$i]['close'].'" is the first found tag, so has no related open tag';
|
$err = 'Close tag "'.$tags[$i]['close'].'" is the first found tag, so has no related open tag';
|
||||||
}
|
}
|
||||||
@ -293,10 +293,10 @@ class ShortcodeParser extends Object {
|
|||||||
$err = 'Close tag "'.$tags[$i]['close'].'" doesn\'t match preceding open tag "'.
|
$err = 'Close tag "'.$tags[$i]['close'].'" doesn\'t match preceding open tag "'.
|
||||||
$tags[$i-1]['open'].'"';
|
$tags[$i-1]['open'].'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($err) {
|
if($err) {
|
||||||
if(self::$error_behavior == self::ERROR) user_error($err, E_USER_ERRROR);
|
if(self::$error_behavior == self::ERROR) user_error($err, E_USER_ERRROR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($tags[$i]['escaped']) {
|
if ($tags[$i]['escaped']) {
|
||||||
if (!$tags[$i-1]['escaped']) {
|
if (!$tags[$i-1]['escaped']) {
|
||||||
@ -310,12 +310,12 @@ class ShortcodeParser extends Object {
|
|||||||
$tags[$i-1]['escaped'] = false;
|
$tags[$i-1]['escaped'] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, grab content between tags, save in opening tag & delete the closing one
|
// Otherwise, grab content between tags, save in opening tag & delete the closing one
|
||||||
$tags[$i-1]['text'] = substr($content, $tags[$i-1]['s'], $tags[$i]['e'] - $tags[$i-1]['s']);
|
$tags[$i-1]['text'] = substr($content, $tags[$i-1]['s'], $tags[$i]['e'] - $tags[$i-1]['s']);
|
||||||
$tags[$i-1]['content'] = substr($content, $tags[$i-1]['e'], $tags[$i]['s'] - $tags[$i-1]['e']);
|
$tags[$i-1]['content'] = substr($content, $tags[$i-1]['e'], $tags[$i]['s'] - $tags[$i-1]['e']);
|
||||||
$tags[$i-1]['e'] = $tags[$i]['e'];
|
$tags[$i-1]['e'] = $tags[$i]['e'];
|
||||||
|
|
||||||
unset($tags[$i]);
|
unset($tags[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ class ShortcodeParser extends Object {
|
|||||||
else {
|
else {
|
||||||
$str = $generator($i, $tags[$i]) . $tail . $str;
|
$str = $generator($i, $tags[$i]) . $tail . $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
$li = $tags[$i]['s'];
|
$li = $tags[$i]['s'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ class ShortcodeParser extends Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace the element-scoped tags with markers
|
* Replace the element-scoped tags with markers
|
||||||
*
|
*
|
||||||
@ -404,18 +404,18 @@ class ShortcodeParser extends Object {
|
|||||||
|
|
||||||
if($tags) {
|
if($tags) {
|
||||||
$markerClass = self::$marker_class;
|
$markerClass = self::$marker_class;
|
||||||
|
|
||||||
$content = $this->replaceTagsWithText($content, $tags, function($idx, $tag) use ($markerClass) {
|
$content = $this->replaceTagsWithText($content, $tags, function($idx, $tag) use ($markerClass) {
|
||||||
return '<img class="'.$markerClass.'" data-tagid="'.$idx.'" />';
|
return '<img class="'.$markerClass.'" data-tagid="'.$idx.'" />';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($content, $tags);
|
return array($content, $tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function findParentsForMarkers($nodes) {
|
protected function findParentsForMarkers($nodes) {
|
||||||
$parents = array();
|
$parents = array();
|
||||||
|
|
||||||
foreach($nodes as $node) {
|
foreach($nodes as $node) {
|
||||||
$parent = $node;
|
$parent = $node;
|
||||||
|
|
||||||
@ -428,34 +428,34 @@ class ShortcodeParser extends Object {
|
|||||||
$node->setAttribute('data-parentid', count($parents));
|
$node->setAttribute('data-parentid', count($parents));
|
||||||
$parents[] = $parent;
|
$parents[] = $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $parents;
|
return $parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BEFORE = 'before';
|
const BEFORE = 'before';
|
||||||
const AFTER = 'after';
|
const AFTER = 'after';
|
||||||
const SPLIT = 'split';
|
const SPLIT = 'split';
|
||||||
const INLINE = 'inline';
|
const INLINE = 'inline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a node with represents a shortcode marker and a location string, mutates the DOM to put the
|
* Given a node with represents a shortcode marker and a location string, mutates the DOM to put the
|
||||||
* marker in the compliant location
|
* marker in the compliant location
|
||||||
*
|
*
|
||||||
* For shortcodes inserted BEFORE, that location is just before the block container that
|
* For shortcodes inserted BEFORE, that location is just before the block container that
|
||||||
* the marker is in
|
* the marker is in
|
||||||
*
|
*
|
||||||
* For shortcodes inserted AFTER, that location is just after the block container that
|
* For shortcodes inserted AFTER, that location is just after the block container that
|
||||||
* the marker is in
|
* the marker is in
|
||||||
*
|
*
|
||||||
* For shortcodes inserted SPLIT, that location is where the marker is, but the DOM
|
* For shortcodes inserted SPLIT, that location is where the marker is, but the DOM
|
||||||
* is split around it up to the block container the marker is in - for instance,
|
* is split around it up to the block container the marker is in - for instance,
|
||||||
*
|
*
|
||||||
* <p>A<span>B<marker />C</span>D</p>
|
* <p>A<span>B<marker />C</span>D</p>
|
||||||
*
|
*
|
||||||
* becomes
|
* becomes
|
||||||
*
|
*
|
||||||
* <p>A<span>B</span></p><marker /><p><span>C</span>D</p>
|
* <p>A<span>B</span></p><marker /><p><span>C</span>D</p>
|
||||||
*
|
*
|
||||||
* For shortcodes inserted INLINE, no modification is needed (but in that case the shortcode handler needs to
|
* For shortcodes inserted INLINE, no modification is needed (but in that case the shortcode handler needs to
|
||||||
* generate only inline blocks)
|
* generate only inline blocks)
|
||||||
*
|
*
|
||||||
@ -494,7 +494,7 @@ class ShortcodeParser extends Object {
|
|||||||
if(in_array(strtolower($node->tagName), self::$block_level_elements)) {
|
if(in_array(strtolower($node->tagName), self::$block_level_elements)) {
|
||||||
user_error(
|
user_error(
|
||||||
'Requested to insert block tag '.$node->tagName.
|
'Requested to insert block tag '.$node->tagName.
|
||||||
' inline - probably this will break HTML compliance',
|
' inline - probably this will break HTML compliance',
|
||||||
E_USER_WARNING
|
E_USER_WARNING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -508,19 +508,19 @@ class ShortcodeParser extends Object {
|
|||||||
/**
|
/**
|
||||||
* Given a node with represents a shortcode marker and some information about the shortcode, call the
|
* Given a node with represents a shortcode marker and some information about the shortcode, call the
|
||||||
* shortcode handler & replace the marker with the actual content
|
* shortcode handler & replace the marker with the actual content
|
||||||
*
|
*
|
||||||
* @param DOMElement $node
|
* @param DOMElement $node
|
||||||
* @param array $tag
|
* @param array $tag
|
||||||
*/
|
*/
|
||||||
protected function replaceMarkerWithContent($node, $tag) {
|
protected function replaceMarkerWithContent($node, $tag) {
|
||||||
$content = $this->getShortcodeReplacementText($tag);
|
$content = $this->getShortcodeReplacementText($tag);
|
||||||
|
|
||||||
if ($content) {
|
if ($content) {
|
||||||
$parsed = Injector::inst()->create('HTMLValue', $content);
|
$parsed = Injector::inst()->create('HTMLValue', $content);
|
||||||
$body = $parsed->getBody();
|
$body = $parsed->getBody();
|
||||||
if ($body) $this->insertListAfter($body->childNodes, $node);
|
if ($body) $this->insertListAfter($body->childNodes, $node);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->removeNode($node);
|
$this->removeNode($node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,11 +565,11 @@ class ShortcodeParser extends Object {
|
|||||||
foreach($shortcodes as $shortcode) {
|
foreach($shortcodes as $shortcode) {
|
||||||
$tag = $tags[$shortcode->getAttribute('data-tagid')];
|
$tag = $tags[$shortcode->getAttribute('data-tagid')];
|
||||||
$parent = $parents[$shortcode->getAttribute('data-parentid')];
|
$parent = $parents[$shortcode->getAttribute('data-parentid')];
|
||||||
|
|
||||||
$class = null;
|
$class = null;
|
||||||
if(!empty($tag['attrs']['location'])) $class = $tag['attrs']['location'];
|
if(!empty($tag['attrs']['location'])) $class = $tag['attrs']['location'];
|
||||||
else if(!empty($tag['attrs']['class'])) $class = $tag['attrs']['class'];
|
else if(!empty($tag['attrs']['class'])) $class = $tag['attrs']['class'];
|
||||||
|
|
||||||
$location = self::INLINE;
|
$location = self::INLINE;
|
||||||
if($class == 'left' || $class == 'right') $location = self::BEFORE;
|
if($class == 'left' || $class == 'right') $location = self::BEFORE;
|
||||||
if($class == 'center' || $class == 'leftALone') $location = self::SPLIT;
|
if($class == 'center' || $class == 'leftALone') $location = self::SPLIT;
|
||||||
|
@ -53,13 +53,13 @@ class ExactMatchFilter extends SearchFilter {
|
|||||||
$this->model = $query->applyRelation($this->relation);
|
$this->model = $query->applyRelation($this->relation);
|
||||||
$field = $this->getDbName();
|
$field = $this->getDbName();
|
||||||
$value = $this->getValue();
|
$value = $this->getValue();
|
||||||
|
|
||||||
// Null comparison check
|
// Null comparison check
|
||||||
if($value === null) {
|
if($value === null) {
|
||||||
$where = DB::get_conn()->nullCheckClause($field, $inclusive);
|
$where = DB::get_conn()->nullCheckClause($field, $inclusive);
|
||||||
return $query->where($where);
|
return $query->where($where);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value comparison check
|
// Value comparison check
|
||||||
$where = DB::get_conn()->comparisonClause(
|
$where = DB::get_conn()->comparisonClause(
|
||||||
$field,
|
$field,
|
||||||
@ -107,7 +107,7 @@ class ExactMatchFilter extends SearchFilter {
|
|||||||
protected function manyFilter(DataQuery $query, $inclusive) {
|
protected function manyFilter(DataQuery $query, $inclusive) {
|
||||||
$this->model = $query->applyRelation($this->relation);
|
$this->model = $query->applyRelation($this->relation);
|
||||||
$caseSensitive = $this->getCaseSensitive();
|
$caseSensitive = $this->getCaseSensitive();
|
||||||
|
|
||||||
// Check values for null
|
// Check values for null
|
||||||
$field = $this->getDbName();
|
$field = $this->getDbName();
|
||||||
$values = $this->getValue();
|
$values = $this->getValue();
|
||||||
|
@ -172,7 +172,7 @@ abstract class SearchFilter extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$candidateClass = ClassInfo::table_for_object_field(
|
$candidateClass = ClassInfo::table_for_object_field(
|
||||||
$this->model,
|
$this->model,
|
||||||
$this->name
|
$this->name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -25,46 +25,46 @@ else {
|
|||||||
* @subpackage view
|
* @subpackage view
|
||||||
*/
|
*/
|
||||||
class SSTemplateParseException extends Exception {
|
class SSTemplateParseException extends Exception {
|
||||||
|
|
||||||
function __construct($message, $parser) {
|
function __construct($message, $parser) {
|
||||||
$prior = substr($parser->string, 0, $parser->pos);
|
$prior = substr($parser->string, 0, $parser->pos);
|
||||||
|
|
||||||
preg_match_all('/\r\n|\r|\n/', $prior, $matches);
|
preg_match_all('/\r\n|\r|\n/', $prior, $matches);
|
||||||
$line = count($matches[0])+1;
|
$line = count($matches[0])+1;
|
||||||
|
|
||||||
parent::__construct("Parse error in template on line $line. Error was: $message");
|
parent::__construct("Parse error in template on line $line. Error was: $message");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the parser for the SilverStripe template language. It gets called on a string and uses a php-peg parser
|
* This is the parser for the SilverStripe template language. It gets called on a string and uses a php-peg parser
|
||||||
* to match that string against the language structure, building up the PHP code to execute that structure as it
|
* to match that string against the language structure, building up the PHP code to execute that structure as it
|
||||||
* parses
|
* parses
|
||||||
*
|
*
|
||||||
* The $result array that is built up as part of the parsing (see thirdparty/php-peg/README.md for more on how
|
* The $result array that is built up as part of the parsing (see thirdparty/php-peg/README.md for more on how
|
||||||
* parsers build results) has one special member, 'php', which contains the php equivalent of that part of the
|
* parsers build results) has one special member, 'php', which contains the php equivalent of that part of the
|
||||||
* template tree.
|
* template tree.
|
||||||
*
|
*
|
||||||
* Some match rules generate alternate php, or other variations, so check the per-match documentation too.
|
* Some match rules generate alternate php, or other variations, so check the per-match documentation too.
|
||||||
*
|
*
|
||||||
* Terms used:
|
* Terms used:
|
||||||
*
|
*
|
||||||
* Marked: A string or lookup in the template that has been explictly marked as such - lookups by prepending with
|
* Marked: A string or lookup in the template that has been explictly marked as such - lookups by prepending with
|
||||||
* "$" (like $Foo.Bar), strings by wrapping with single or double quotes ('Foo' or "Foo")
|
* "$" (like $Foo.Bar), strings by wrapping with single or double quotes ('Foo' or "Foo")
|
||||||
*
|
*
|
||||||
* Bare: The opposite of marked. An argument that has to has it's type inferred by usage and 2.4 defaults.
|
* Bare: The opposite of marked. An argument that has to has it's type inferred by usage and 2.4 defaults.
|
||||||
*
|
*
|
||||||
* Example of using a bare argument for a loop block: <% loop Foo %>
|
* Example of using a bare argument for a loop block: <% loop Foo %>
|
||||||
*
|
*
|
||||||
* Block: One of two SS template structures. The special characters "<%" and "%>" are used to wrap the opening and
|
* Block: One of two SS template structures. The special characters "<%" and "%>" are used to wrap the opening and
|
||||||
* (required or forbidden depending on which block exactly) closing block marks.
|
* (required or forbidden depending on which block exactly) closing block marks.
|
||||||
*
|
*
|
||||||
* Open Block: An SS template block that doesn't wrap any content or have a closing end tag (in fact, a closing end
|
* Open Block: An SS template block that doesn't wrap any content or have a closing end tag (in fact, a closing end
|
||||||
* tag is forbidden)
|
* tag is forbidden)
|
||||||
*
|
*
|
||||||
* Closed Block: An SS template block that wraps content, and requires a counterpart <% end_blockname %> tag
|
* Closed Block: An SS template block that wraps content, and requires a counterpart <% end_blockname %> tag
|
||||||
*
|
*
|
||||||
* Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements
|
* Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements
|
||||||
* N: eats white space including newlines (using in legacy _t support)
|
* N: eats white space including newlines (using in legacy _t support)
|
||||||
*
|
*
|
||||||
@ -120,7 +120,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the closed blocks that the template parser should use
|
* Set the closed blocks that the template parser should use
|
||||||
*
|
*
|
||||||
* This method will delete any existing closed blocks, please use addClosedBlock if you don't
|
* This method will delete any existing closed blocks, please use addClosedBlock if you don't
|
||||||
* want to overwrite
|
* want to overwrite
|
||||||
* @param array $closedBlocks
|
* @param array $closedBlocks
|
||||||
@ -195,7 +195,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
|
/* Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
|
||||||
OpenBlock | MalformedBlock | Injection | Text)+ */
|
OpenBlock | MalformedBlock | Injection | Text)+ */
|
||||||
protected $match_Template_typestack = array('Template');
|
protected $match_Template_typestack = array('Template');
|
||||||
@ -450,7 +450,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function Template_STR(&$res, $sub) {
|
function Template_STR(&$res, $sub) {
|
||||||
$res['php'] .= $sub['php'] . PHP_EOL ;
|
$res['php'] .= $sub['php'] . PHP_EOL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Word: / [A-Za-z_] [A-Za-z0-9_]* / */
|
/* Word: / [A-Za-z_] [A-Za-z0-9_]* / */
|
||||||
protected $match_Word_typestack = array('Word');
|
protected $match_Word_typestack = array('Word');
|
||||||
function match_Word ($stack = array()) {
|
function match_Word ($stack = array()) {
|
||||||
@ -538,14 +538,14 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert
|
* Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert
|
||||||
* strings to numbers when needed.
|
* strings to numbers when needed.
|
||||||
*/
|
*/
|
||||||
function CallArguments_Argument(&$res, $sub) {
|
function CallArguments_Argument(&$res, $sub) {
|
||||||
if (!empty($res['php'])) $res['php'] .= ', ';
|
if (!empty($res['php'])) $res['php'] .= ', ';
|
||||||
|
|
||||||
$res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] :
|
$res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] :
|
||||||
str_replace('$$FINAL', 'XML_val', $sub['php']);
|
str_replace('$$FINAL', 'XML_val', $sub['php']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,22 +727,22 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Lookup__construct(&$res) {
|
function Lookup__construct(&$res) {
|
||||||
$res['php'] = '$scope->locally()';
|
$res['php'] = '$scope->locally()';
|
||||||
$res['LookupSteps'] = array();
|
$res['LookupSteps'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to
|
* The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to
|
||||||
* get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
|
* get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
|
||||||
* depending on the context the lookup is used in.
|
* depending on the context the lookup is used in.
|
||||||
*/
|
*/
|
||||||
function Lookup_AddLookupStep(&$res, $sub, $method) {
|
function Lookup_AddLookupStep(&$res, $sub, $method) {
|
||||||
$res['LookupSteps'][] = $sub;
|
$res['LookupSteps'][] = $sub;
|
||||||
|
|
||||||
$property = $sub['Call']['Method']['text'];
|
$property = $sub['Call']['Method']['text'];
|
||||||
|
|
||||||
if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) {
|
if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) {
|
||||||
$res['php'] .= "->$method('$property', array($arguments), true)";
|
$res['php'] .= "->$method('$property', array($arguments), true)";
|
||||||
}
|
}
|
||||||
@ -1083,7 +1083,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$matchrule = "QuotedString"; $result = $this->construct($matchrule, $matchrule, null);
|
$matchrule = "QuotedString"; $result = $this->construct($matchrule, $matchrule, null);
|
||||||
$_142 = NULL;
|
$_142 = NULL;
|
||||||
do {
|
do {
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "q" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "q" );
|
||||||
if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) {
|
if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) {
|
||||||
$result["text"] .= $subres;
|
$result["text"] .= $subres;
|
||||||
$subres = $result; $result = array_pop($stack);
|
$subres = $result; $result = array_pop($stack);
|
||||||
@ -1093,7 +1093,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$result = array_pop($stack);
|
$result = array_pop($stack);
|
||||||
$_142 = FALSE; break;
|
$_142 = FALSE; break;
|
||||||
}
|
}
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "String" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "String" );
|
||||||
if (( $subres = $this->rx( '/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /' ) ) !== FALSE) {
|
if (( $subres = $this->rx( '/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /' ) ) !== FALSE) {
|
||||||
$result["text"] .= $subres;
|
$result["text"] .= $subres;
|
||||||
$subres = $result; $result = array_pop($stack);
|
$subres = $result; $result = array_pop($stack);
|
||||||
@ -1227,21 +1227,21 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we get a bare value, we don't know enough to determine exactly what php would be the translation, because
|
* If we get a bare value, we don't know enough to determine exactly what php would be the translation, because
|
||||||
* we don't know if the position of use indicates a lookup or a string argument.
|
* we don't know if the position of use indicates a lookup or a string argument.
|
||||||
*
|
*
|
||||||
* Instead, we record 'ArgumentMode' as a member of this matches results node, which can be:
|
* Instead, we record 'ArgumentMode' as a member of this matches results node, which can be:
|
||||||
* - lookup if this argument was unambiguously a lookup (marked as such)
|
* - lookup if this argument was unambiguously a lookup (marked as such)
|
||||||
* - string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup)
|
* - string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup)
|
||||||
* - default if this argument needs to be handled as per 2.4
|
* - default if this argument needs to be handled as per 2.4
|
||||||
*
|
*
|
||||||
* In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which
|
* In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which
|
||||||
* should be used by the parent if the context indicates a lookup, and 'string_php' which should be used
|
* should be used by the parent if the context indicates a lookup, and 'string_php' which should be used
|
||||||
* if the context indicates a string
|
* if the context indicates a string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function Argument_DollarMarkedLookup(&$res, $sub) {
|
function Argument_DollarMarkedLookup(&$res, $sub) {
|
||||||
$res['ArgumentMode'] = 'lookup';
|
$res['ArgumentMode'] = 'lookup';
|
||||||
$res['php'] = $sub['Lookup']['php'];
|
$res['php'] = $sub['Lookup']['php'];
|
||||||
@ -1263,12 +1263,12 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$res['php'] = $sub['php'];
|
$res['php'] = $sub['php'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Argument_FreeString(&$res, $sub) {
|
function Argument_FreeString(&$res, $sub) {
|
||||||
$res['ArgumentMode'] = 'string';
|
$res['ArgumentMode'] = 'string';
|
||||||
$res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'";
|
$res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ComparisonOperator: "!=" | "==" | ">=" | ">" | "<=" | "<" | "=" */
|
/* ComparisonOperator: "!=" | "==" | ">=" | ">" | "<=" | "<" | "=" */
|
||||||
protected $match_ComparisonOperator_typestack = array('ComparisonOperator');
|
protected $match_ComparisonOperator_typestack = array('ComparisonOperator');
|
||||||
function match_ComparisonOperator ($stack = array()) {
|
function match_ComparisonOperator ($stack = array()) {
|
||||||
@ -1413,7 +1413,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
if ($sub['ArgumentMode'] == 'default') {
|
if ($sub['ArgumentMode'] == 'default') {
|
||||||
if (!empty($res['php'])) $res['php'] .= $sub['string_php'];
|
if (!empty($res['php'])) $res['php'] .= $sub['string_php'];
|
||||||
else $res['php'] = str_replace('$$FINAL', 'XML_val', $sub['lookup_php']);
|
else $res['php'] = str_replace('$$FINAL', 'XML_val', $sub['lookup_php']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
|
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
|
||||||
}
|
}
|
||||||
@ -1433,7 +1433,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$pos_199 = $this->pos;
|
$pos_199 = $this->pos;
|
||||||
$_198 = NULL;
|
$_198 = NULL;
|
||||||
do {
|
do {
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "Not" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "Not" );
|
||||||
if (( $subres = $this->literal( 'not' ) ) !== FALSE) {
|
if (( $subres = $this->literal( 'not' ) ) !== FALSE) {
|
||||||
$result["text"] .= $subres;
|
$result["text"] .= $subres;
|
||||||
$subres = $result; $result = array_pop($stack);
|
$subres = $result; $result = array_pop($stack);
|
||||||
@ -1469,7 +1469,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function PresenceCheck_Not(&$res, $sub) {
|
function PresenceCheck_Not(&$res, $sub) {
|
||||||
$res['php'] = '!';
|
$res['php'] = '!';
|
||||||
}
|
}
|
||||||
|
|
||||||
function PresenceCheck_Argument(&$res, $sub) {
|
function PresenceCheck_Argument(&$res, $sub) {
|
||||||
if ($sub['ArgumentMode'] == 'string') {
|
if ($sub['ArgumentMode'] == 'string') {
|
||||||
$res['php'] .= '((bool)'.$sub['php'].')';
|
$res['php'] .= '((bool)'.$sub['php'].')';
|
||||||
@ -1780,22 +1780,22 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
function If_IfPart(&$res, $sub) {
|
function If_IfPart(&$res, $sub) {
|
||||||
$res['php'] =
|
$res['php'] =
|
||||||
'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
|
'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
|
||||||
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
function If_ElseIfPart(&$res, $sub) {
|
function If_ElseIfPart(&$res, $sub) {
|
||||||
$res['php'] .=
|
$res['php'] .=
|
||||||
'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
|
'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
|
||||||
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
function If_ElsePart(&$res, $sub) {
|
function If_ElsePart(&$res, $sub) {
|
||||||
$res['php'] .=
|
$res['php'] .=
|
||||||
'else { ' . PHP_EOL .
|
'else { ' . PHP_EOL .
|
||||||
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
@ -1813,7 +1813,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
else { $_274 = FALSE; break; }
|
else { $_274 = FALSE; break; }
|
||||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
else { $_274 = FALSE; break; }
|
else { $_274 = FALSE; break; }
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "Call" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "Call" );
|
||||||
$_270 = NULL;
|
$_270 = NULL;
|
||||||
do {
|
do {
|
||||||
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
|
||||||
@ -1867,10 +1867,10 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$res['php'] = "Requirements::".$sub['Method']['text'].'('.$sub['CallArguments']['php'].');';
|
$res['php'] = "Requirements::".$sub['Method']['text'].'('.$sub['CallArguments']['php'].');';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* CacheBlockArgument:
|
/* CacheBlockArgument:
|
||||||
!( "if " | "unless " )
|
!( "if " | "unless " )
|
||||||
(
|
(
|
||||||
:DollarMarkedLookup |
|
:DollarMarkedLookup |
|
||||||
:QuotedString |
|
:QuotedString |
|
||||||
:Lookup
|
:Lookup
|
||||||
@ -1976,15 +1976,15 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function CacheBlockArgument_DollarMarkedLookup(&$res, $sub) {
|
function CacheBlockArgument_DollarMarkedLookup(&$res, $sub) {
|
||||||
$res['php'] = $sub['Lookup']['php'];
|
$res['php'] = $sub['Lookup']['php'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function CacheBlockArgument_QuotedString(&$res, $sub) {
|
function CacheBlockArgument_QuotedString(&$res, $sub) {
|
||||||
$res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'";
|
$res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
function CacheBlockArgument_Lookup(&$res, $sub) {
|
function CacheBlockArgument_Lookup(&$res, $sub) {
|
||||||
$res['php'] = $sub['php'];
|
$res['php'] = $sub['php'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CacheBlockArguments: CacheBlockArgument ( < "," < CacheBlockArgument )* */
|
/* CacheBlockArguments: CacheBlockArgument ( < "," < CacheBlockArgument )* */
|
||||||
protected $match_CacheBlockArguments_typestack = array('CacheBlockArguments');
|
protected $match_CacheBlockArguments_typestack = array('CacheBlockArguments');
|
||||||
function match_CacheBlockArguments ($stack = array()) {
|
function match_CacheBlockArguments ($stack = array()) {
|
||||||
@ -2034,10 +2034,10 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function CacheBlockArguments_CacheBlockArgument(&$res, $sub) {
|
function CacheBlockArguments_CacheBlockArgument(&$res, $sub) {
|
||||||
if (!empty($res['php'])) $res['php'] .= ".'_'.";
|
if (!empty($res['php'])) $res['php'] .= ".'_'.";
|
||||||
else $res['php'] = '';
|
else $res['php'] = '';
|
||||||
|
|
||||||
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
|
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CacheBlockTemplate: (Comment | Translate | If | Require | OldI18NTag | Include | ClosedBlock |
|
/* CacheBlockTemplate: (Comment | Translate | If | Require | OldI18NTag | Include | ClosedBlock |
|
||||||
OpenBlock | MalformedBlock | Injection | Text)+ */
|
OpenBlock | MalformedBlock | Injection | Text)+ */
|
||||||
protected $match_CacheBlockTemplate_typestack = array('CacheBlockTemplate','Template');
|
protected $match_CacheBlockTemplate_typestack = array('CacheBlockTemplate','Template');
|
||||||
@ -2253,8 +2253,8 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* UncachedBlock:
|
/* UncachedBlock:
|
||||||
'<%' < "uncached" < CacheBlockArguments? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>'
|
'<%' < "uncached" < CacheBlockArguments? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>'
|
||||||
Template:$TemplateMatcher?
|
Template:$TemplateMatcher?
|
||||||
'<%' < 'end_' ("uncached"|"cached"|"cacheblock") > '%>' */
|
'<%' < 'end_' ("uncached"|"cached"|"cacheblock") > '%>' */
|
||||||
@ -2285,7 +2285,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$_363 = NULL;
|
$_363 = NULL;
|
||||||
do {
|
do {
|
||||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
|
||||||
$_359 = NULL;
|
$_359 = NULL;
|
||||||
do {
|
do {
|
||||||
$_357 = NULL;
|
$_357 = NULL;
|
||||||
@ -2413,7 +2413,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function UncachedBlock_Template(&$res, $sub){
|
function UncachedBlock_Template(&$res, $sub){
|
||||||
$res['php'] = $sub['php'];
|
$res['php'] = $sub['php'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CacheRestrictedTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
|
/* CacheRestrictedTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
|
||||||
OpenBlock | MalformedBlock | Injection | Text)+ */
|
OpenBlock | MalformedBlock | Injection | Text)+ */
|
||||||
protected $match_CacheRestrictedTemplate_typestack = array('CacheRestrictedTemplate','Template');
|
protected $match_CacheRestrictedTemplate_typestack = array('CacheRestrictedTemplate','Template');
|
||||||
@ -2665,17 +2665,17 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function CacheRestrictedTemplate_CacheBlock(&$res, $sub) {
|
function CacheRestrictedTemplate_CacheBlock(&$res, $sub) {
|
||||||
throw new SSTemplateParseException('You cant have cache blocks nested within with, loop or control blocks ' .
|
throw new SSTemplateParseException('You cant have cache blocks nested within with, loop or control blocks ' .
|
||||||
'that are within cache blocks', $this);
|
'that are within cache blocks', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CacheRestrictedTemplate_UncachedBlock(&$res, $sub) {
|
function CacheRestrictedTemplate_UncachedBlock(&$res, $sub) {
|
||||||
throw new SSTemplateParseException('You cant have uncache blocks nested within with, loop or control blocks ' .
|
throw new SSTemplateParseException('You cant have uncache blocks nested within with, loop or control blocks ' .
|
||||||
'that are within cache blocks', $this);
|
'that are within cache blocks', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CacheBlock:
|
/* CacheBlock:
|
||||||
'<%' < CacheTag:("cached"|"cacheblock") < (CacheBlockArguments)? ( < Conditional:("if"|"unless") >
|
'<%' < CacheTag:("cached"|"cacheblock") < (CacheBlockArguments)? ( < Conditional:("if"|"unless") >
|
||||||
Condition:IfArgument )? > '%>'
|
Condition:IfArgument )? > '%>'
|
||||||
(CacheBlock | UncachedBlock | CacheBlockTemplate)*
|
(CacheBlock | UncachedBlock | CacheBlockTemplate)*
|
||||||
@ -2688,7 +2688,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
else { $_491 = FALSE; break; }
|
else { $_491 = FALSE; break; }
|
||||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" );
|
||||||
$_444 = NULL;
|
$_444 = NULL;
|
||||||
do {
|
do {
|
||||||
$_442 = NULL;
|
$_442 = NULL;
|
||||||
@ -2745,7 +2745,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$_460 = NULL;
|
$_460 = NULL;
|
||||||
do {
|
do {
|
||||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
|
||||||
$_456 = NULL;
|
$_456 = NULL;
|
||||||
do {
|
do {
|
||||||
$_454 = NULL;
|
$_454 = NULL;
|
||||||
@ -2918,23 +2918,23 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function CacheBlock__construct(&$res){
|
function CacheBlock__construct(&$res){
|
||||||
$res['subblocks'] = 0;
|
$res['subblocks'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CacheBlock_CacheBlockArguments(&$res, $sub){
|
function CacheBlock_CacheBlockArguments(&$res, $sub){
|
||||||
$res['key'] = !empty($sub['php']) ? $sub['php'] : '';
|
$res['key'] = !empty($sub['php']) ? $sub['php'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function CacheBlock_Condition(&$res, $sub){
|
function CacheBlock_Condition(&$res, $sub){
|
||||||
$res['condition'] = ($res['Conditional']['text'] == 'if' ? '(' : '!(') . $sub['php'] . ') && ';
|
$res['condition'] = ($res['Conditional']['text'] == 'if' ? '(' : '!(') . $sub['php'] . ') && ';
|
||||||
}
|
}
|
||||||
|
|
||||||
function CacheBlock_CacheBlock(&$res, $sub){
|
function CacheBlock_CacheBlock(&$res, $sub){
|
||||||
$res['php'] .= $sub['php'];
|
$res['php'] .= $sub['php'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function CacheBlock_UncachedBlock(&$res, $sub){
|
function CacheBlock_UncachedBlock(&$res, $sub){
|
||||||
$res['php'] .= $sub['php'];
|
$res['php'] .= $sub['php'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function CacheBlock_CacheBlockTemplate(&$res, $sub){
|
function CacheBlock_CacheBlockTemplate(&$res, $sub){
|
||||||
// Get the block counter
|
// Get the block counter
|
||||||
$block = ++$res['subblocks'];
|
$block = ++$res['subblocks'];
|
||||||
@ -2959,14 +2959,14 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
. ".'_$block'"; // block index
|
. ".'_$block'"; // block index
|
||||||
// Get any condition
|
// Get any condition
|
||||||
$condition = isset($res['condition']) ? $res['condition'] : '';
|
$condition = isset($res['condition']) ? $res['condition'] : '';
|
||||||
|
|
||||||
$res['php'] .= 'if ('.$condition.'($partial = $cache->load('.$key.'))) $val .= $partial;' . PHP_EOL;
|
$res['php'] .= 'if ('.$condition.'($partial = $cache->load('.$key.'))) $val .= $partial;' . PHP_EOL;
|
||||||
$res['php'] .= 'else { $oldval = $val; $val = "";' . PHP_EOL;
|
$res['php'] .= 'else { $oldval = $val; $val = "";' . PHP_EOL;
|
||||||
$res['php'] .= $sub['php'] . PHP_EOL;
|
$res['php'] .= $sub['php'] . PHP_EOL;
|
||||||
$res['php'] .= $condition . ' $cache->save($val); $val = $oldval . $val;' . PHP_EOL;
|
$res['php'] .= $condition . ' $cache->save($val); $val = $oldval . $val;' . PHP_EOL;
|
||||||
$res['php'] .= '}';
|
$res['php'] .= '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")? */
|
/* OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")? */
|
||||||
protected $match_OldTPart_typestack = array('OldTPart');
|
protected $match_OldTPart_typestack = array('OldTPart');
|
||||||
function match_OldTPart ($stack = array()) {
|
function match_OldTPart ($stack = array()) {
|
||||||
@ -3077,7 +3077,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function OldTPart__construct(&$res) {
|
function OldTPart__construct(&$res) {
|
||||||
$res['php'] = "_t(";
|
$res['php'] = "_t(";
|
||||||
}
|
}
|
||||||
|
|
||||||
function OldTPart_QuotedString(&$res, $sub) {
|
function OldTPart_QuotedString(&$res, $sub) {
|
||||||
$entity = $sub['String']['text'];
|
$entity = $sub['String']['text'];
|
||||||
if (strpos($entity, '.') === false) {
|
if (strpos($entity, '.') === false) {
|
||||||
@ -3087,7 +3087,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$res['php'] .= "'$entity'";
|
$res['php'] .= "'$entity'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function OldTPart_CallArguments(&$res, $sub) {
|
function OldTPart_CallArguments(&$res, $sub) {
|
||||||
$res['php'] .= ',' . $sub['php'];
|
$res['php'] .= ',' . $sub['php'];
|
||||||
}
|
}
|
||||||
@ -3095,7 +3095,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function OldTPart__finalise(&$res) {
|
function OldTPart__finalise(&$res) {
|
||||||
$res['php'] .= ')';
|
$res['php'] .= ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OldTTag: "<%" < OldTPart > "%>" */
|
/* OldTTag: "<%" < OldTPart > "%>" */
|
||||||
protected $match_OldTTag_typestack = array('OldTTag');
|
protected $match_OldTTag_typestack = array('OldTTag');
|
||||||
function match_OldTTag ($stack = array()) {
|
function match_OldTTag ($stack = array()) {
|
||||||
@ -3179,7 +3179,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function OldSprintfTag__construct(&$res) {
|
function OldSprintfTag__construct(&$res) {
|
||||||
$res['php'] = "sprintf(";
|
$res['php'] = "sprintf(";
|
||||||
}
|
}
|
||||||
|
|
||||||
function OldSprintfTag_OldTPart(&$res, $sub) {
|
function OldSprintfTag_OldTPart(&$res, $sub) {
|
||||||
$res['php'] .= $sub['php'];
|
$res['php'] .= $sub['php'];
|
||||||
}
|
}
|
||||||
@ -3187,7 +3187,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function OldSprintfTag_CallArguments(&$res, $sub) {
|
function OldSprintfTag_CallArguments(&$res, $sub) {
|
||||||
$res['php'] .= ',' . $sub['php'] . ')';
|
$res['php'] .= ',' . $sub['php'] . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OldI18NTag: OldSprintfTag | OldTTag */
|
/* OldI18NTag: OldSprintfTag | OldTTag */
|
||||||
protected $match_OldI18NTag_typestack = array('OldI18NTag');
|
protected $match_OldI18NTag_typestack = array('OldI18NTag');
|
||||||
function match_OldI18NTag ($stack = array()) {
|
function match_OldI18NTag ($stack = array()) {
|
||||||
@ -3370,7 +3370,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$template = $res['template'];
|
$template = $res['template'];
|
||||||
$arguments = $res['arguments'];
|
$arguments = $res['arguments'];
|
||||||
|
|
||||||
$res['php'] = '$val .= SSViewer::execute_template('.$template.', $scope->getItem(), array(' .
|
$res['php'] = '$val .= SSViewer::execute_template('.$template.', $scope->getItem(), array(' .
|
||||||
implode(',', $arguments)."), \$scope);\n";
|
implode(',', $arguments)."), \$scope);\n";
|
||||||
|
|
||||||
if($this->includeDebuggingComments) { // Add include filename comments on dev sites
|
if($this->includeDebuggingComments) { // Add include filename comments on dev sites
|
||||||
@ -3584,7 +3584,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ClosedBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > Zap:'%>' Template:$TemplateMatcher?
|
/* ClosedBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > Zap:'%>' Template:$TemplateMatcher?
|
||||||
'<%' < 'end_' '$BlockName' > '%>' */
|
'<%' < 'end_' '$BlockName' > '%>' */
|
||||||
protected $match_ClosedBlock_typestack = array('ClosedBlock');
|
protected $match_ClosedBlock_typestack = array('ClosedBlock');
|
||||||
function match_ClosedBlock ($stack = array()) {
|
function match_ClosedBlock ($stack = array()) {
|
||||||
@ -3638,7 +3638,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
unset( $pos_621 );
|
unset( $pos_621 );
|
||||||
}
|
}
|
||||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "Zap" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "Zap" );
|
||||||
if (( $subres = $this->literal( '%>' ) ) !== FALSE) {
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) {
|
||||||
$result["text"] .= $subres;
|
$result["text"] .= $subres;
|
||||||
$subres = $result; $result = array_pop($stack);
|
$subres = $result; $result = array_pop($stack);
|
||||||
@ -3680,7 +3680,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule
|
* As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule
|
||||||
* builds up two important elements in the match result array:
|
* builds up two important elements in the match result array:
|
||||||
@ -3690,15 +3690,15 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
* Once a block has successfully been matched against, it will then look for the actual handler, which should
|
* Once a block has successfully been matched against, it will then look for the actual handler, which should
|
||||||
* be on this class (either defined or extended on) as ClosedBlock_Handler_Name(&$res), where Name is the
|
* be on this class (either defined or extended on) as ClosedBlock_Handler_Name(&$res), where Name is the
|
||||||
* tag name, first letter captialized (i.e Control, Loop, With, etc).
|
* tag name, first letter captialized (i.e Control, Loop, With, etc).
|
||||||
*
|
*
|
||||||
* This function will be called with the match rule result array as it's first argument. It should return
|
* This function will be called with the match rule result array as it's first argument. It should return
|
||||||
* the php result of this block as it's return value, or throw an error if incorrect arguments were passed.
|
* the php result of this block as it's return value, or throw an error if incorrect arguments were passed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function ClosedBlock__construct(&$res) {
|
function ClosedBlock__construct(&$res) {
|
||||||
$res['ArgumentCount'] = 0;
|
$res['ArgumentCount'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ClosedBlock_BlockArguments(&$res, $sub) {
|
function ClosedBlock_BlockArguments(&$res, $sub) {
|
||||||
if (isset($sub['Argument']['ArgumentMode'])) {
|
if (isset($sub['Argument']['ArgumentMode'])) {
|
||||||
$res['Arguments'] = array($sub['Argument']);
|
$res['Arguments'] = array($sub['Argument']);
|
||||||
@ -3741,7 +3741,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
if ($arg['ArgumentMode'] == 'string') {
|
if ($arg['ArgumentMode'] == 'string') {
|
||||||
throw new SSTemplateParseException('Control block cant take string as argument.', $this);
|
throw new SSTemplateParseException('Control block cant take string as argument.', $this);
|
||||||
}
|
}
|
||||||
$on = str_replace('$$FINAL', 'obj',
|
$on = str_replace('$$FINAL', 'obj',
|
||||||
($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
|
($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3759,19 +3759,19 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
throw new SSTemplateParseException('Either no or too many arguments in with block. Must be one ' .
|
throw new SSTemplateParseException('Either no or too many arguments in with block. Must be one ' .
|
||||||
'argument only.', $this);
|
'argument only.', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$arg = $res['Arguments'][0];
|
$arg = $res['Arguments'][0];
|
||||||
if ($arg['ArgumentMode'] == 'string') {
|
if ($arg['ArgumentMode'] == 'string') {
|
||||||
throw new SSTemplateParseException('Control block cant take string as argument.', $this);
|
throw new SSTemplateParseException('Control block cant take string as argument.', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
|
$on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
|
||||||
return
|
return
|
||||||
$on . '; $scope->pushScope();' . PHP_EOL .
|
$on . '; $scope->pushScope();' . PHP_EOL .
|
||||||
$res['Template']['php'] . PHP_EOL .
|
$res['Template']['php'] . PHP_EOL .
|
||||||
'; $scope->popScope(); ';
|
'; $scope->popScope(); ';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OpenBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > '%>' */
|
/* OpenBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > '%>' */
|
||||||
protected $match_OpenBlock_typestack = array('OpenBlock');
|
protected $match_OpenBlock_typestack = array('OpenBlock');
|
||||||
function match_OpenBlock ($stack = array()) {
|
function match_OpenBlock ($stack = array()) {
|
||||||
@ -3839,7 +3839,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function OpenBlock__construct(&$res) {
|
function OpenBlock__construct(&$res) {
|
||||||
$res['ArgumentCount'] = 0;
|
$res['ArgumentCount'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function OpenBlock_BlockArguments(&$res, $sub) {
|
function OpenBlock_BlockArguments(&$res, $sub) {
|
||||||
if (isset($sub['Argument']['ArgumentMode'])) {
|
if (isset($sub['Argument']['ArgumentMode'])) {
|
||||||
$res['Arguments'] = array($sub['Argument']);
|
$res['Arguments'] = array($sub['Argument']);
|
||||||
@ -3872,9 +3872,9 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
if ($res['ArgumentCount'] == 0) return '$scope->debug();';
|
if ($res['ArgumentCount'] == 0) return '$scope->debug();';
|
||||||
else if ($res['ArgumentCount'] == 1) {
|
else if ($res['ArgumentCount'] == 1) {
|
||||||
$arg = $res['Arguments'][0];
|
$arg = $res['Arguments'][0];
|
||||||
|
|
||||||
if ($arg['ArgumentMode'] == 'string') return 'Debug::show('.$arg['php'].');';
|
if ($arg['ArgumentMode'] == 'string') return 'Debug::show('.$arg['php'].');';
|
||||||
|
|
||||||
$php = ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php'];
|
$php = ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php'];
|
||||||
return '$val .= Debug::show('.str_replace('FINALGET!', 'cachedCall', $php).');';
|
return '$val .= Debug::show('.str_replace('FINALGET!', 'cachedCall', $php).');';
|
||||||
}
|
}
|
||||||
@ -3898,7 +3898,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
if ($res['ArgumentCount'] != 0) throw new SSTemplateParseException('Current_page takes no arguments', $this);
|
if ($res['ArgumentCount'] != 0) throw new SSTemplateParseException('Current_page takes no arguments', $this);
|
||||||
return '$val .= $_SERVER[SCRIPT_URL];';
|
return '$val .= $_SERVER[SCRIPT_URL];';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MismatchedEndBlock: '<%' < 'end_' :Word > '%>' */
|
/* MismatchedEndBlock: '<%' < 'end_' :Word > '%>' */
|
||||||
protected $match_MismatchedEndBlock_typestack = array('MismatchedEndBlock');
|
protected $match_MismatchedEndBlock_typestack = array('MismatchedEndBlock');
|
||||||
function match_MismatchedEndBlock ($stack = array()) {
|
function match_MismatchedEndBlock ($stack = array()) {
|
||||||
@ -3930,7 +3930,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
function MismatchedEndBlock__finalise(&$res) {
|
function MismatchedEndBlock__finalise(&$res) {
|
||||||
$blockname = $res['Word']['text'];
|
$blockname = $res['Word']['text'];
|
||||||
throw new SSTemplateParseException('Unexpected close tag end_' . $blockname .
|
throw new SSTemplateParseException('Unexpected close tag end_' . $blockname .
|
||||||
' encountered. Perhaps you have mis-nested blocks, or have mis-spelled a tag?', $this);
|
' encountered. Perhaps you have mis-nested blocks, or have mis-spelled a tag?', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4019,7 +4019,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
throw new SSTemplateParseException("Malformed opening block tag $tag. Perhaps you have tried to use operators?"
|
throw new SSTemplateParseException("Malformed opening block tag $tag. Perhaps you have tried to use operators?"
|
||||||
, $this);
|
, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MalformedCloseTag: '<%' < Tag:('end_' :Word ) !( > '%>' ) */
|
/* MalformedCloseTag: '<%' < Tag:('end_' :Word ) !( > '%>' ) */
|
||||||
protected $match_MalformedCloseTag_typestack = array('MalformedCloseTag');
|
protected $match_MalformedCloseTag_typestack = array('MalformedCloseTag');
|
||||||
function match_MalformedCloseTag ($stack = array()) {
|
function match_MalformedCloseTag ($stack = array()) {
|
||||||
@ -4029,7 +4029,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
else { $_679 = FALSE; break; }
|
else { $_679 = FALSE; break; }
|
||||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
$stack[] = $result; $result = $this->construct( $matchrule, "Tag" );
|
$stack[] = $result; $result = $this->construct( $matchrule, "Tag" );
|
||||||
$_673 = NULL;
|
$_673 = NULL;
|
||||||
do {
|
do {
|
||||||
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; }
|
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||||
@ -4084,7 +4084,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
throw new SSTemplateParseException("Malformed closing block tag $tag. Perhaps you have tried to pass an " .
|
throw new SSTemplateParseException("Malformed closing block tag $tag. Perhaps you have tried to pass an " .
|
||||||
"argument to one?", $this);
|
"argument to one?", $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MalformedBlock: MalformedOpenTag | MalformedCloseTag */
|
/* MalformedBlock: MalformedOpenTag | MalformedCloseTag */
|
||||||
protected $match_MalformedBlock_typestack = array('MalformedBlock');
|
protected $match_MalformedBlock_typestack = array('MalformedBlock');
|
||||||
function match_MalformedBlock ($stack = array()) {
|
function match_MalformedBlock ($stack = array()) {
|
||||||
@ -4175,7 +4175,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
function Comment__construct(&$res) {
|
function Comment__construct(&$res) {
|
||||||
$res['php'] = '';
|
$res['php'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TopTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
|
/* TopTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
|
||||||
OpenBlock | MalformedBlock | MismatchedEndBlock | Injection | Text)+ */
|
OpenBlock | MalformedBlock | MismatchedEndBlock | Injection | Text)+ */
|
||||||
protected $match_TopTemplate_typestack = array('TopTemplate','Template');
|
protected $match_TopTemplate_typestack = array('TopTemplate','Template');
|
||||||
@ -4445,7 +4445,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TopTemplate also includes the opening stanza to start off the template
|
* The TopTemplate also includes the opening stanza to start off the template
|
||||||
*/
|
*/
|
||||||
@ -4659,13 +4659,13 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We convert text
|
* We convert text
|
||||||
*/
|
*/
|
||||||
function Text__finalise(&$res) {
|
function Text__finalise(&$res) {
|
||||||
$text = $res['text'];
|
$text = $res['text'];
|
||||||
|
|
||||||
// Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes
|
// Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes
|
||||||
$text = stripslashes($text);
|
$text = stripslashes($text);
|
||||||
$text = addcslashes($text, '\'\\');
|
$text = addcslashes($text, '\'\\');
|
||||||
@ -4682,14 +4682,14 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
|
|
||||||
$res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL;
|
$res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
* Here ends the parser itself. Below are utility methods to use the parser
|
* Here ends the parser itself. Below are utility methods to use the parser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles some passed template source code into the php code that will execute as per the template source.
|
* Compiles some passed template source code into the php code that will execute as per the template source.
|
||||||
*
|
*
|
||||||
* @throws SSTemplateParseException
|
* @throws SSTemplateParseException
|
||||||
* @param $string The source of the template
|
* @param $string The source of the template
|
||||||
* @param string $templateName The name of the template, normally the filename the template source was loaded from
|
* @param string $templateName The name of the template, normally the filename the template source was loaded from
|
||||||
@ -4703,13 +4703,13 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parent::__construct($string);
|
parent::__construct($string);
|
||||||
|
|
||||||
$this->includeDebuggingComments = $includeDebuggingComments;
|
$this->includeDebuggingComments = $includeDebuggingComments;
|
||||||
|
|
||||||
// Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF
|
// Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF
|
||||||
// (and other encodings) properly
|
// (and other encodings) properly
|
||||||
if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $this->pos = 3;
|
if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $this->pos = 3;
|
||||||
|
|
||||||
// Match the source against the parser
|
// Match the source against the parser
|
||||||
if ($topTemplate) {
|
if ($topTemplate) {
|
||||||
$result = $this->match_TopTemplate();
|
$result = $this->match_TopTemplate();
|
||||||
@ -4717,7 +4717,7 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
$result = $this->match_Template();
|
$result = $this->match_Template();
|
||||||
}
|
}
|
||||||
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $this);
|
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $this);
|
||||||
|
|
||||||
// Get the result
|
// Get the result
|
||||||
$code = $result['php'];
|
$code = $result['php'];
|
||||||
}
|
}
|
||||||
@ -4725,8 +4725,8 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
// Include top level debugging comments if desired
|
// Include top level debugging comments if desired
|
||||||
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
|
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
|
||||||
$code = $this->includeDebuggingComments($code, $templateName);
|
$code = $this->includeDebuggingComments($code, $templateName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4762,11 +4762,11 @@ class SSTemplateParser extends Parser implements TemplateParser {
|
|||||||
}
|
}
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles some file that contains template source code, and returns the php code that will execute as per that
|
* Compiles some file that contains template source code, and returns the php code that will execute as per that
|
||||||
* source
|
* source
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @param $template - A file path that contains template source code
|
* @param $template - A file path that contains template source code
|
||||||
* @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source
|
* @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source
|
||||||
|
@ -443,7 +443,7 @@ class SSViewer_DataPresenter extends SSViewer_Scope {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the injected value
|
* Get the injected value
|
||||||
*
|
*
|
||||||
* @param string $property Name of property
|
* @param string $property Name of property
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @param bool $cast If true, an object is always returned even if not an object.
|
* @param bool $cast If true, an object is always returned even if not an object.
|
||||||
|
@ -188,7 +188,7 @@ class ViewableData extends Object implements IteratorAggregate {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to facilitate deprecation of underscore-prefixed methods automatically being cached.
|
* Method to facilitate deprecation of underscore-prefixed methods automatically being cached.
|
||||||
*
|
*
|
||||||
* @param string $field
|
* @param string $field
|
||||||
* @param array $arguments
|
* @param array $arguments
|
||||||
* @param string $identifier an optional custom cache identifier
|
* @param string $identifier an optional custom cache identifier
|
||||||
|
Loading…
x
Reference in New Issue
Block a user