All pastes #468335 Raw Edit

k4st

public php v1 · immutable
·published 2007-05-03 01:26 UTC
rendered paste body
<?phpfunction guid(){	static $guid;		if($guid === NULL)		$guid = 0;		return $guid++;}class ForNode extends ClosingNode{	private $var_name,			$guid;		public function parseOpen($args = array())	{		$this->var_name = $args['var'];		$this->guid = guid();						return '<?php for($i'.$this->guid.'='. (int)$args['start'] .'; $i'.$this->guid.'<='. (int)$args['end'] .';$i'.$this->guid.'+='. (int)$args['increment'] .'): $scope->pushVar("'. $args['var'] .'",$i'.$this->guid.'); ?>';	}	public function parseClose()	{			return '<?php endfor; $scope->popVar("'. $this->var_name .'"); ?>';	}}class ForeachNode extends ClosingNode{	private $key_name,			$val_name,			$guid;		public function parseOpen($args = array())	{		$this->key_name = $args['key'];		$this->val_name = $args['val'];		$this->guid = guid();				return '<?php foreach($scope->pullVar('. $args['var'] .') as $k'.$this->guid.' => $v'.$this->guid.'): $scope->pushVar("'. $args['val'] .'", $k'.$this->guid.');$scope->pushVar("",$v'.$this->guid.'); ?>';	}	public function parseClose()	{			return '<?php endforeach; $scope->popVar("'. $this->key_name .'"); $scope->popVar("'. $this->val_name .'"); ?>';	}}class PrintNode extends ClosingNode{		public function parseOpen($args = array())	{		return '<?php echo ';	}	public function parseClose()	{			return '; ?>';	}}?>