Code Duplication    Length = 23-23 lines in 2 locations

view/SSTemplateParser.php 1 location

@@ 3742-3764 (lines=23) @@
3739
	/**
3740
	 * This is an example of a block handler function. This one handles the loop tag.
3741
	 */
3742
	function ClosedBlock_Handle_Loop(&$res) {
3743
		if ($res['ArgumentCount'] > 1) {
3744
			throw new SSTemplateParseException('Either no or too many arguments in control block. Must be one ' .
3745
				'argument only.', $this);
3746
		}
3747
3748
		//loop without arguments loops on the current scope
3749
		if ($res['ArgumentCount'] == 0) {
3750
			$on = '$scope->obj(\'Up\', null, true)->obj(\'Foo\', null, true)';
3751
		} else {    //loop in the normal way
3752
			$arg = $res['Arguments'][0];
3753
			if ($arg['ArgumentMode'] == 'string') {
3754
				throw new SSTemplateParseException('Control block cant take string as argument.', $this);
3755
			}
3756
			$on = str_replace('$$FINAL', 'obj', 
3757
				($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
3758
		}
3759
3760
		return
3761
			$on . '; $scope->pushScope(); while (($key = $scope->next()) !== false) {' . PHP_EOL .
3762
				$res['Template']['php'] . PHP_EOL .
3763
			'}; $scope->popScope(); ';
3764
	}
3765
3766
	/**
3767
	 * The closed block handler for with blocks

view/SSTemplateParser.php.inc 1 location

@@ 911-933 (lines=23) @@
908
	/**
909
	 * This is an example of a block handler function. This one handles the loop tag.
910
	 */
911
	function ClosedBlock_Handle_Loop(&$res) {
912
		if ($res['ArgumentCount'] > 1) {
913
			throw new SSTemplateParseException('Either no or too many arguments in control block. Must be one ' .
914
				'argument only.', $this);
915
		}
916
917
		//loop without arguments loops on the current scope
918
		if ($res['ArgumentCount'] == 0) {
919
			$on = '$scope->obj(\'Up\', null, true)->obj(\'Foo\', null, true)';
920
		} else {    //loop in the normal way
921
			$arg = $res['Arguments'][0];
922
			if ($arg['ArgumentMode'] == 'string') {
923
				throw new SSTemplateParseException('Control block cant take string as argument.', $this);
924
			}
925
			$on = str_replace('$$FINAL', 'obj', 
926
				($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
927
		}
928
929
		return
930
			$on . '; $scope->pushScope(); while (($key = $scope->next()) !== false) {' . PHP_EOL .
931
				$res['Template']['php'] . PHP_EOL .
932
			'}; $scope->popScope(); ';
933
	}
934
935
	/**
936
	 * The closed block handler for with blocks