@@ -28,13 +28,13 @@ interface i18nEntityProvider {
* foreach($this->stat('my_static_array) as $key => $value) {
* $entities["MyTestClass.my_static_array_{$key}"] = array(
* $value,
- *
+ *
* 'My context description'
* );
* }
* return $entities;
* }
- *
+ *
* public static function my_static_array() {
* $t_my_static_array = array();
* foreach(self::$my_static_array as $k => $v) {
@@ -44,9 +44,9 @@ interface i18nEntityProvider {
* }
* }
*
- *
+ *
* Example usage in {@link DataObject->provideI18nEntities()}.
- *
+ *
* 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:
*
@@ -55,7 +55,7 @@ interface i18nEntityProvider {
* $entities = array();
* $entities["MyOtherModuleClass.MYENTITY"] = array(
* $value,
- *
+ *
* 'My context description',
* 'myothermodule'
* );
@@ -63,7 +63,7 @@ interface i18nEntityProvider {
* return $entities;
* }
*
- *
+ *
* @return array All entites in an associative array, with
* entity name as the key, and a numerical array of pseudo-arguments
* for _t() as a value.
diff --git a/logging/DebugViewFriendlyErrorFormatter.php b/logging/DebugViewFriendlyErrorFormatter.php
index 9172fbc5d..55d0b7a43 100644
--- a/logging/DebugViewFriendlyErrorFormatter.php
+++ b/logging/DebugViewFriendlyErrorFormatter.php
@@ -51,7 +51,7 @@ class DebugViewFriendlyErrorFormatter implements FormatterInterface
}
public function output() {
- // TODO: Refactor into a content-type option
+ // TODO: Refactor into a content-type option
if(\Director::is_ajax()) {
return $this->friendlyErrorMessage;
diff --git a/logging/HTTPOutputHandler.php b/logging/HTTPOutputHandler.php
index 87ccd0e2b..97f090ab0 100644
--- a/logging/HTTPOutputHandler.php
+++ b/logging/HTTPOutputHandler.php
@@ -47,7 +47,7 @@ class HTTPOutputHandler extends AbstractProcessingHandler
protected function write(array $record) {
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
if(\Controller::has_curr()) {
$response = \Controller::curr()->getResponse();
diff --git a/parsers/ShortcodeParser.php b/parsers/ShortcodeParser.php
index 3b1319422..d83af5ca2 100644
--- a/parsers/ShortcodeParser.php
+++ b/parsers/ShortcodeParser.php
@@ -4,27 +4,27 @@
* 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
* [Wordpress implementation](http://codex.wordpress.org/Shortcode_API) of shortcodes.
- *
+ *
* @see http://doc.silverstripe.org/framework/en/reference/shortcodes
* @package framework
* @subpackage misc
*/
class ShortcodeParser extends Object {
-
+
public function img_shortcode($attrs) {
return "";
}
-
+
protected static $instances = array();
-
+
protected static $active_instance = 'default';
-
+
// --------------------------------------------------------------------------------------------------------------
-
+
protected $shortcodes = array();
-
+
// --------------------------------------------------------------------------------------------------------------
-
+
/**
* 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)) {
self::$instances[$identifier] = static::create();
}
-
+
return self::$instances[$identifier];
}
-
+
/**
* Get the currently active/default {@link ShortcodeParser} instance.
*
@@ -47,7 +47,7 @@ class ShortcodeParser extends Object {
public static function get_active() {
return static::get(self::$active_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) {
self::$active_instance = (string) $identifier;
}
-
+
// --------------------------------------------------------------------------------------------------------------
-
+
/**
* Register a shortcode, and attach it to a PHP callback.
*
@@ -76,7 +76,7 @@ class ShortcodeParser extends Object {
public function register($shortcode, $callback) {
if(is_callable($callback)) $this->shortcodes[$shortcode] = $callback;
}
-
+
/**
* Check if a shortcode has been registered.
*
@@ -86,7 +86,7 @@ class ShortcodeParser extends Object {
public function registered($shortcode) {
return array_key_exists($shortcode, $this->shortcodes);
}
-
+
/**
* Remove a specific registered shortcode.
*
@@ -95,14 +95,14 @@ class ShortcodeParser extends Object {
public function unregister($shortcode) {
if($this->registered($shortcode)) unset($this->shortcodes[$shortcode]);
}
-
+
/**
* Remove all registered shortcodes.
*/
public function clear() {
$this->shortcodes = array();
}
-
+
/**
* Call a shortcode and return its replacement text
* Returns false if the shortcode isn't registered
@@ -111,7 +111,7 @@ class ShortcodeParser extends Object {
if (!$tag || !isset($this->shortcodes[$tag])) return false;
return call_user_func($this->shortcodes[$tag], $attributes, $content, $this, $tag, $extra);
}
-
+
/**
* 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.
@@ -145,14 +145,14 @@ class ShortcodeParser extends Object {
}
// --------------------------------------------------------------------------------------------------------------
-
+
protected function removeNode($node) {
$node->parentNode->removeChild($node);
}
-
+
protected function insertAfter($new, $after) {
$parent = $after->parentNode; $next = $after->nextSibling;
-
+
if ($next) {
$parent->insertBefore($new, $next);
}
@@ -160,7 +160,7 @@ class ShortcodeParser extends Object {
$parent->appendChild($new);
}
}
-
+
protected function insertListAfter($new, $after) {
$doc = $after->ownerDocument; $parent = $after->parentNode; $next = $after->nextSibling;
@@ -168,8 +168,8 @@ class ShortcodeParser extends Object {
$imported = $doc->importNode($new->item($i), true);
if ($next) {
- $parent->insertBefore($imported, $next);
- }
+ $parent->insertBefore($imported, $next);
+ }
else {
$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',
'pre', 'section', 'table', 'ul'
);
-
+
protected static $attrrx = '
- ([^\s\/\'"=,]+) # Name
+ ([^\s\/\'"=,]+) # Name
\s* = \s*
(?:
(?:\'([^\']+)\') | # Value surrounded by \'
@@ -193,7 +193,7 @@ class ShortcodeParser extends Object {
([^\s,\]]+) # Bare value
)
';
-
+
protected static function attrrx() {
return '/'.self::$attrrx.'/xS';
}
@@ -201,21 +201,21 @@ class ShortcodeParser extends Object {
protected static $tagrx = '
# HTML Tag
<(?AB
AB
CD
- * + * * For shortcodes inserted INLINE, no modification is needed (but in that case the shortcode handler needs to * generate only inline blocks) * @@ -494,7 +494,7 @@ class ShortcodeParser extends Object { if(in_array(strtolower($node->tagName), self::$block_level_elements)) { user_error( 'Requested to insert block tag '.$node->tagName. - ' inline - probably this will break HTML compliance', + ' inline - probably this will break HTML compliance', 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 * shortcode handler & replace the marker with the actual content - * + * * @param DOMElement $node * @param array $tag */ protected function replaceMarkerWithContent($node, $tag) { $content = $this->getShortcodeReplacementText($tag); - + if ($content) { $parsed = Injector::inst()->create('HTMLValue', $content); $body = $parsed->getBody(); if ($body) $this->insertListAfter($body->childNodes, $node); } - + $this->removeNode($node); } @@ -565,11 +565,11 @@ class ShortcodeParser extends Object { foreach($shortcodes as $shortcode) { $tag = $tags[$shortcode->getAttribute('data-tagid')]; $parent = $parents[$shortcode->getAttribute('data-parentid')]; - + $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']; - + $location = self::INLINE; if($class == 'left' || $class == 'right') $location = self::BEFORE; if($class == 'center' || $class == 'leftALone') $location = self::SPLIT; diff --git a/search/filters/ExactMatchFilter.php b/search/filters/ExactMatchFilter.php index 45d0ea216..5f7016cf6 100644 --- a/search/filters/ExactMatchFilter.php +++ b/search/filters/ExactMatchFilter.php @@ -53,13 +53,13 @@ class ExactMatchFilter extends SearchFilter { $this->model = $query->applyRelation($this->relation); $field = $this->getDbName(); $value = $this->getValue(); - + // Null comparison check if($value === null) { $where = DB::get_conn()->nullCheckClause($field, $inclusive); return $query->where($where); } - + // Value comparison check $where = DB::get_conn()->comparisonClause( $field, @@ -107,7 +107,7 @@ class ExactMatchFilter extends SearchFilter { protected function manyFilter(DataQuery $query, $inclusive) { $this->model = $query->applyRelation($this->relation); $caseSensitive = $this->getCaseSensitive(); - + // Check values for null $field = $this->getDbName(); $values = $this->getValue(); diff --git a/search/filters/SearchFilter.php b/search/filters/SearchFilter.php index 238994e18..da5bea6ce 100644 --- a/search/filters/SearchFilter.php +++ b/search/filters/SearchFilter.php @@ -172,7 +172,7 @@ abstract class SearchFilter extends Object { } $candidateClass = ClassInfo::table_for_object_field( - $this->model, + $this->model, $this->name ); diff --git a/view/SSTemplateParser.php b/view/SSTemplateParser.php index fdae5ccfc..d81c361d3 100644 --- a/view/SSTemplateParser.php +++ b/view/SSTemplateParser.php @@ -25,46 +25,46 @@ else { * @subpackage view */ class SSTemplateParseException extends Exception { - + function __construct($message, $parser) { $prior = substr($parser->string, 0, $parser->pos); - + preg_match_all('/\r\n|\r|\n/', $prior, $matches); $line = count($matches[0])+1; - + 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 * to match that string against the language structure, building up the PHP code to execute that structure as it * parses - * + * * 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 * template tree. - * + * * Some match rules generate alternate php, or other variations, so check the per-match documentation too. - * + * * Terms used: - * + * * 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") - * + * * 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 %> - * + * * 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. - * + * * 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) - * + * * 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 * 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 - * + * * This method will delete any existing closed blocks, please use addClosedBlock if you don't * want to overwrite * @param array $closedBlocks @@ -195,7 +195,7 @@ class SSTemplateParser extends Parser implements TemplateParser { ); } } - + /* Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | OpenBlock | MalformedBlock | Injection | Text)+ */ protected $match_Template_typestack = array('Template'); @@ -450,7 +450,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function Template_STR(&$res, $sub) { $res['php'] .= $sub['php'] . PHP_EOL ; } - + /* Word: / [A-Za-z_] [A-Za-z0-9_]* / */ protected $match_Word_typestack = array('Word'); 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 * strings to numbers when needed. */ function CallArguments_Argument(&$res, $sub) { 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']); } @@ -727,22 +727,22 @@ class SSTemplateParser extends Parser implements TemplateParser { - + function Lookup__construct(&$res) { $res['php'] = '$scope->locally()'; $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) * depending on the context the lookup is used in. */ function Lookup_AddLookupStep(&$res, $sub, $method) { $res['LookupSteps'][] = $sub; - + $property = $sub['Call']['Method']['text']; - + if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) { $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); $_142 = NULL; do { - $stack[] = $result; $result = $this->construct( $matchrule, "q" ); + $stack[] = $result; $result = $this->construct( $matchrule, "q" ); if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) { $result["text"] .= $subres; $subres = $result; $result = array_pop($stack); @@ -1093,7 +1093,7 @@ class SSTemplateParser extends Parser implements TemplateParser { $result = array_pop($stack); $_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) { $result["text"] .= $subres; $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 * 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: * - 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) * - 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 * 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 */ - + function Argument_DollarMarkedLookup(&$res, $sub) { $res['ArgumentMode'] = 'lookup'; $res['php'] = $sub['Lookup']['php']; @@ -1263,12 +1263,12 @@ class SSTemplateParser extends Parser implements TemplateParser { $res['php'] = $sub['php']; } } - + function Argument_FreeString(&$res, $sub) { $res['ArgumentMode'] = 'string'; $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'"; } - + /* ComparisonOperator: "!=" | "==" | ">=" | ">" | "<=" | "<" | "=" */ protected $match_ComparisonOperator_typestack = array('ComparisonOperator'); function match_ComparisonOperator ($stack = array()) { @@ -1413,7 +1413,7 @@ class SSTemplateParser extends Parser implements TemplateParser { if ($sub['ArgumentMode'] == 'default') { 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['php']); } @@ -1433,7 +1433,7 @@ class SSTemplateParser extends Parser implements TemplateParser { $pos_199 = $this->pos; $_198 = NULL; do { - $stack[] = $result; $result = $this->construct( $matchrule, "Not" ); + $stack[] = $result; $result = $this->construct( $matchrule, "Not" ); if (( $subres = $this->literal( 'not' ) ) !== FALSE) { $result["text"] .= $subres; $subres = $result; $result = array_pop($stack); @@ -1469,7 +1469,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function PresenceCheck_Not(&$res, $sub) { $res['php'] = '!'; } - + function PresenceCheck_Argument(&$res, $sub) { if ($sub['ArgumentMode'] == 'string') { $res['php'] .= '((bool)'.$sub['php'].')'; @@ -1780,22 +1780,22 @@ class SSTemplateParser extends Parser implements TemplateParser { function If_IfPart(&$res, $sub) { - $res['php'] = + $res['php'] = 'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL . (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . '}'; - } + } function If_ElseIfPart(&$res, $sub) { - $res['php'] .= + $res['php'] .= 'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL . (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . '}'; } function If_ElsePart(&$res, $sub) { - $res['php'] .= - 'else { ' . PHP_EOL . + $res['php'] .= + 'else { ' . PHP_EOL . (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . '}'; } @@ -1813,7 +1813,7 @@ class SSTemplateParser extends Parser implements TemplateParser { else { $_274 = FALSE; break; } if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } else { $_274 = FALSE; break; } - $stack[] = $result; $result = $this->construct( $matchrule, "Call" ); + $stack[] = $result; $result = $this->construct( $matchrule, "Call" ); $_270 = NULL; do { $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'].');'; } - + /* CacheBlockArgument: !( "if " | "unless " ) - ( + ( :DollarMarkedLookup | :QuotedString | :Lookup @@ -1976,15 +1976,15 @@ class SSTemplateParser extends Parser implements TemplateParser { function CacheBlockArgument_DollarMarkedLookup(&$res, $sub) { $res['php'] = $sub['Lookup']['php']; } - + function CacheBlockArgument_QuotedString(&$res, $sub) { $res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'"; } - + function CacheBlockArgument_Lookup(&$res, $sub) { $res['php'] = $sub['php']; } - + /* CacheBlockArguments: CacheBlockArgument ( < "," < CacheBlockArgument )* */ protected $match_CacheBlockArguments_typestack = array('CacheBlockArguments'); function match_CacheBlockArguments ($stack = array()) { @@ -2034,10 +2034,10 @@ class SSTemplateParser extends Parser implements TemplateParser { function CacheBlockArguments_CacheBlockArgument(&$res, $sub) { if (!empty($res['php'])) $res['php'] .= ".'_'."; else $res['php'] = ''; - + $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']); } - + /* CacheBlockTemplate: (Comment | Translate | If | Require | OldI18NTag | Include | ClosedBlock | OpenBlock | MalformedBlock | Injection | Text)+ */ 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 )? > '%>' Template:$TemplateMatcher? '<%' < 'end_' ("uncached"|"cached"|"cacheblock") > '%>' */ @@ -2285,7 +2285,7 @@ class SSTemplateParser extends Parser implements TemplateParser { $_363 = NULL; do { if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } - $stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); + $stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); $_359 = NULL; do { $_357 = NULL; @@ -2413,7 +2413,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function UncachedBlock_Template(&$res, $sub){ $res['php'] = $sub['php']; } - + /* CacheRestrictedTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | OpenBlock | MalformedBlock | Injection | Text)+ */ 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 ' . '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 ' . 'that are within cache blocks', $this); } - - /* CacheBlock: + + /* CacheBlock: '<%' < CacheTag:("cached"|"cacheblock") < (CacheBlockArguments)? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>' (CacheBlock | UncachedBlock | CacheBlockTemplate)* @@ -2688,7 +2688,7 @@ class SSTemplateParser extends Parser implements TemplateParser { if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } else { $_491 = FALSE; break; } if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } - $stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" ); + $stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" ); $_444 = NULL; do { $_442 = NULL; @@ -2745,7 +2745,7 @@ class SSTemplateParser extends Parser implements TemplateParser { $_460 = NULL; do { if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } - $stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); + $stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); $_456 = NULL; do { $_454 = NULL; @@ -2918,23 +2918,23 @@ class SSTemplateParser extends Parser implements TemplateParser { function CacheBlock__construct(&$res){ $res['subblocks'] = 0; } - + function CacheBlock_CacheBlockArguments(&$res, $sub){ $res['key'] = !empty($sub['php']) ? $sub['php'] : ''; } - + function CacheBlock_Condition(&$res, $sub){ $res['condition'] = ($res['Conditional']['text'] == 'if' ? '(' : '!(') . $sub['php'] . ') && '; } - + function CacheBlock_CacheBlock(&$res, $sub){ $res['php'] .= $sub['php']; } - + function CacheBlock_UncachedBlock(&$res, $sub){ $res['php'] .= $sub['php']; } - + function CacheBlock_CacheBlockTemplate(&$res, $sub){ // Get the block counter $block = ++$res['subblocks']; @@ -2959,14 +2959,14 @@ class SSTemplateParser extends Parser implements TemplateParser { . ".'_$block'"; // block index // Get any condition $condition = isset($res['condition']) ? $res['condition'] : ''; - + $res['php'] .= 'if ('.$condition.'($partial = $cache->load('.$key.'))) $val .= $partial;' . PHP_EOL; $res['php'] .= 'else { $oldval = $val; $val = "";' . PHP_EOL; $res['php'] .= $sub['php'] . PHP_EOL; $res['php'] .= $condition . ' $cache->save($val); $val = $oldval . $val;' . PHP_EOL; $res['php'] .= '}'; } - + /* OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")? */ protected $match_OldTPart_typestack = array('OldTPart'); function match_OldTPart ($stack = array()) { @@ -3077,7 +3077,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function OldTPart__construct(&$res) { $res['php'] = "_t("; } - + function OldTPart_QuotedString(&$res, $sub) { $entity = $sub['String']['text']; if (strpos($entity, '.') === false) { @@ -3087,7 +3087,7 @@ class SSTemplateParser extends Parser implements TemplateParser { $res['php'] .= "'$entity'"; } } - + function OldTPart_CallArguments(&$res, $sub) { $res['php'] .= ',' . $sub['php']; } @@ -3095,7 +3095,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function OldTPart__finalise(&$res) { $res['php'] .= ')'; } - + /* OldTTag: "<%" < OldTPart > "%>" */ protected $match_OldTTag_typestack = array('OldTTag'); function match_OldTTag ($stack = array()) { @@ -3179,7 +3179,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function OldSprintfTag__construct(&$res) { $res['php'] = "sprintf("; } - + function OldSprintfTag_OldTPart(&$res, $sub) { $res['php'] .= $sub['php']; } @@ -3187,7 +3187,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function OldSprintfTag_CallArguments(&$res, $sub) { $res['php'] .= ',' . $sub['php'] . ')'; } - + /* OldI18NTag: OldSprintfTag | OldTTag */ protected $match_OldI18NTag_typestack = array('OldI18NTag'); function match_OldI18NTag ($stack = array()) { @@ -3370,7 +3370,7 @@ class SSTemplateParser extends Parser implements TemplateParser { $template = $res['template']; $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"; 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' > '%>' */ protected $match_ClosedBlock_typestack = array('ClosedBlock'); function match_ClosedBlock ($stack = array()) { @@ -3638,7 +3638,7 @@ class SSTemplateParser extends Parser implements TemplateParser { unset( $pos_621 ); } 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) { $result["text"] .= $subres; $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 * 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 * 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). - * + * * 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. */ - + function ClosedBlock__construct(&$res) { $res['ArgumentCount'] = 0; } - + function ClosedBlock_BlockArguments(&$res, $sub) { if (isset($sub['Argument']['ArgumentMode'])) { $res['Arguments'] = array($sub['Argument']); @@ -3741,7 +3741,7 @@ class SSTemplateParser extends Parser implements TemplateParser { if ($arg['ArgumentMode'] == 'string') { 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']); } @@ -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 ' . 'argument only.', $this); } - + $arg = $res['Arguments'][0]; if ($arg['ArgumentMode'] == 'string') { throw new SSTemplateParseException('Control block cant take string as argument.', $this); } - + $on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']); - return + return $on . '; $scope->pushScope();' . PHP_EOL . $res['Template']['php'] . PHP_EOL . '; $scope->popScope(); '; } - + /* OpenBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > '%>' */ protected $match_OpenBlock_typestack = array('OpenBlock'); function match_OpenBlock ($stack = array()) { @@ -3839,7 +3839,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function OpenBlock__construct(&$res) { $res['ArgumentCount'] = 0; } - + function OpenBlock_BlockArguments(&$res, $sub) { if (isset($sub['Argument']['ArgumentMode'])) { $res['Arguments'] = array($sub['Argument']); @@ -3872,9 +3872,9 @@ class SSTemplateParser extends Parser implements TemplateParser { if ($res['ArgumentCount'] == 0) return '$scope->debug();'; else if ($res['ArgumentCount'] == 1) { $arg = $res['Arguments'][0]; - + if ($arg['ArgumentMode'] == 'string') return 'Debug::show('.$arg['php'].');'; - + $php = ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['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); return '$val .= $_SERVER[SCRIPT_URL];'; } - + /* MismatchedEndBlock: '<%' < 'end_' :Word > '%>' */ protected $match_MismatchedEndBlock_typestack = array('MismatchedEndBlock'); function match_MismatchedEndBlock ($stack = array()) { @@ -3930,7 +3930,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function MismatchedEndBlock__finalise(&$res) { $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); } @@ -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?" , $this); } - + /* MalformedCloseTag: '<%' < Tag:('end_' :Word ) !( > '%>' ) */ protected $match_MalformedCloseTag_typestack = array('MalformedCloseTag'); function match_MalformedCloseTag ($stack = array()) { @@ -4029,7 +4029,7 @@ class SSTemplateParser extends Parser implements TemplateParser { if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } else { $_679 = FALSE; break; } if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } - $stack[] = $result; $result = $this->construct( $matchrule, "Tag" ); + $stack[] = $result; $result = $this->construct( $matchrule, "Tag" ); $_673 = NULL; do { 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 " . "argument to one?", $this); } - + /* MalformedBlock: MalformedOpenTag | MalformedCloseTag */ protected $match_MalformedBlock_typestack = array('MalformedBlock'); function match_MalformedBlock ($stack = array()) { @@ -4175,7 +4175,7 @@ class SSTemplateParser extends Parser implements TemplateParser { function Comment__construct(&$res) { $res['php'] = ''; } - + /* TopTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | OpenBlock | MalformedBlock | MismatchedEndBlock | Injection | Text)+ */ 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 */ @@ -4659,13 +4659,13 @@ class SSTemplateParser extends Parser implements TemplateParser { - + /** - * We convert text + * We convert text */ function Text__finalise(&$res) { $text = $res['text']; - + // Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes $text = stripslashes($text); $text = addcslashes($text, '\'\\'); @@ -4682,14 +4682,14 @@ class SSTemplateParser extends Parser implements TemplateParser { $res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL; } - + /****************** * 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. - * + * * @throws SSTemplateParseException * @param $string The source of the template * @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 { parent::__construct($string); - + $this->includeDebuggingComments = $includeDebuggingComments; - + // Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF // (and other encodings) properly if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $this->pos = 3; - + // Match the source against the parser if ($topTemplate) { $result = $this->match_TopTemplate(); @@ -4717,7 +4717,7 @@ class SSTemplateParser extends Parser implements TemplateParser { $result = $this->match_Template(); } if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $this); - + // Get the result $code = $result['php']; } @@ -4725,8 +4725,8 @@ class SSTemplateParser extends Parser implements TemplateParser { // Include top level debugging comments if desired if($includeDebuggingComments && $templateName && stripos($code, "includeDebuggingComments($code, $templateName); - } - + } + return $code; } @@ -4762,11 +4762,11 @@ class SSTemplateParser extends Parser implements TemplateParser { } return $code; } - + /** * Compiles some file that contains template source code, and returns the php code that will execute as per that * source - * + * * @static * @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 diff --git a/view/SSViewer.php b/view/SSViewer.php index 8969e7c3d..0daa824a5 100644 --- a/view/SSViewer.php +++ b/view/SSViewer.php @@ -443,7 +443,7 @@ class SSViewer_DataPresenter extends SSViewer_Scope { /** * Get the injected value - * + * * @param string $property Name of property * @param array $params * @param bool $cast If true, an object is always returned even if not an object. diff --git a/view/ViewableData.php b/view/ViewableData.php index 09d52aebb..d2126ce66 100644 --- a/view/ViewableData.php +++ b/view/ViewableData.php @@ -188,7 +188,7 @@ class ViewableData extends Object implements IteratorAggregate { /** * Method to facilitate deprecation of underscore-prefixed methods automatically being cached. - * + * * @param string $field * @param array $arguments * @param string $identifier an optional custom cache identifier