Code Duplication    Length = 23-23 lines in 2 locations

view/SSTemplateParser.php 1 location

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

view/SSTemplateParser.php.inc 1 location

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