Code Duplication    Length = 32-32 lines in 2 locations

view/SSTemplateParser.php 1 location

@@ 4713-4744 (lines=32) @@
4710
	 * @param bool $topTemplate True if this is a top template, false if it's just a template
4711
	 * @return mixed|string The php that, when executed (via include or exec) will behave as per the template source
4712
	 */
4713
	public function compileString($string, $templateName = "", $includeDebuggingComments=false, $topTemplate = true) {
4714
		if (!trim($string)) {
4715
			$code = '';
4716
		}
4717
		else {
4718
			parent::__construct($string);
4719
4720
			$this->includeDebuggingComments = $includeDebuggingComments;
4721
4722
			// Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF
4723
			// (and other encodings) properly
4724
			if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $this->pos = 3;
4725
4726
			// Match the source against the parser
4727
			if ($topTemplate) {
4728
				$result = $this->match_TopTemplate();
4729
			} else {
4730
				$result = $this->match_Template();
4731
			}
4732
			if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $this);
4733
4734
			// Get the result
4735
			$code = $result['php'];
4736
		}
4737
4738
		// Include top level debugging comments if desired
4739
		if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
4740
			$code = $this->includeDebuggingComments($code, $templateName);
4741
		}
4742
4743
		return $code;
4744
	}
4745
4746
	/**
4747
	 * @param string $code

view/SSTemplateParser.php.inc 1 location

@@ 1167-1198 (lines=32) @@
1164
	 * @param bool $topTemplate True if this is a top template, false if it's just a template
1165
	 * @return mixed|string The php that, when executed (via include or exec) will behave as per the template source
1166
	 */
1167
	public function compileString($string, $templateName = "", $includeDebuggingComments=false, $topTemplate = true) {
1168
		if (!trim($string)) {
1169
			$code = '';
1170
		}
1171
		else {
1172
			parent::__construct($string);
1173
1174
			$this->includeDebuggingComments = $includeDebuggingComments;
1175
1176
			// Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF
1177
			// (and other encodings) properly
1178
			if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $this->pos = 3;
1179
1180
			// Match the source against the parser
1181
			if ($topTemplate) {
1182
				$result = $this->match_TopTemplate();
1183
			} else {
1184
				$result = $this->match_Template();
1185
			}
1186
			if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $this);
1187
1188
			// Get the result
1189
			$code = $result['php'];
1190
		}
1191
1192
		// Include top level debugging comments if desired
1193
		if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
1194
			$code = $this->includeDebuggingComments($code, $templateName);
1195
		}
1196
1197
		return $code;
1198
	}
1199
1200
	/**
1201
	 * @param string $code