Code Duplication    Length = 32-32 lines in 2 locations

view/SSTemplateParser.php 1 location

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

view/SSTemplateParser.php.inc 1 location

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