openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

List.class.php (570B)


      1 <?php
      2 
      3 namespace template_engine\components;
      4 
      5 use template_engine\components\html\Component;
      6 use template_engine\element\PHPBlockElement;
      7 
      8 class ListComponent extends Component
      9 {
     10 
     11 	public $list;
     12 
     13 	public $extract = false;
     14 
     15 	public $key = 'list_key';
     16 
     17 	public $value = 'list_value';
     18 
     19 	public function createElement()
     20 	{
     21 		$list = new PHPBlockElement();
     22 		$list->beforeBlock = 'foreach((array)'.$list->value($this->list).' as $' . $this->key . '=>$' . $this->value . ')';
     23 
     24 		if ($this->extract)
     25 			$list->inBlock = 'extract($' . $this->value . ');';
     26 
     27 		return $list;
     28 	}
     29 
     30 }