File modules/template_engine/components/html/component_list/ListComponent.class.php

Last commit: Thu Mar 4 02:00:11 2021 +0100	Jan Dankert	New: Show all page filenames in info.
1 <?php 2 3 namespace template_engine\components\html\component_list; 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 $items; 14 15 public $extract = false; 16 17 public $key = 'list_key'; 18 19 public $value = 'list_value'; 20 21 public function createElement() 22 { 23 $list = new PHPBlockElement(); 24 25 if ( $this->items ) 26 $listValue = '['.implode(',',array_map( function($value){return "'".$value."'";},explode(',',$this->items))).']'; 27 else 28 $listValue = $list->value($this->list); 29 30 $list->beforeBlock = 'foreach((array)'.'@'.$listValue.' as $' . $this->key . '=>$' . $this->value . ')'; 31 32 if ($this->extract) 33 $list->inBlock = 'extract($' . $this->value . ');'; 34 35 return $list; 36 } 37 38 }
Download modules/template_engine/components/html/component_list/ListComponent.class.php
History Thu, 4 Mar 2021 02:00:11 +0100 Jan Dankert New: Show all page filenames in info. Mon, 8 Feb 2021 23:04:22 +0100 Jan Dankert New: A sidebar with sticky buttons as a shortcut to some methods. Wed, 14 Oct 2020 22:36:29 +0200 Jan Dankert Refactoring: Fixed the namespace in component classes, now the are able to be load by the standard autoloader. Wed, 14 Oct 2020 22:20:22 +0200 Jan Dankert Refactoring: Renamed component folders, because 'if' is no valid namespace fragment.