SelectorComponent.class.php (1705B)
1 <?php 2 3 namespace template_engine\components\html\component_selector; 4 5 use template_engine\components\html\Component; 6 use template_engine\element\CMSElement; 7 use template_engine\element\HtmlElement; 8 use template_engine\element\Value; 9 use template_engine\element\ValueExpression; 10 11 /** 12 * A selector for selecting a node object. 13 * 14 * @package template_engine\components\html\component_selector 15 */ 16 class SelectorComponent extends Component 17 { 18 19 public $types; 20 21 public $name; 22 23 public $id; 24 25 public $folderid; 26 27 public $default; 28 29 public $param; 30 31 public function createElement() { 32 return (new HtmlElement('div'))->addStyleClass(['selector','droppable-selector'])->addChild( 33 (new HtmlElement('input'))->addAttribute('type','hidden')->addStyleClass('selector-link-value')->addAttribute('name',$this->param)->addAttribute('value',$this->default?:Value::createExpression(ValueExpression::TYPE_DATA_VAR,$this->param)) 34 )->addChild( 35 (new HtmlElement('input'))->addAttribute('type','text')->addStyleClass(['input','selector-link-name','act-selector-search'])->addAttribute('name',$this->param.'_text')->addAttribute('placeholder',$this->name)->addAttribute('value',$this->name) 36 )->addChild( 37 (new HtmlElement('i'))->addStyleClass( ['image-icon','image-icon--menu-tree','act-selector-tree-button' ]) 38 )->addChild( 39 (new HtmlElement('div'))->addStyleClass('dropdown')->addStyleClass('act-selector-search-results') 40 )->addChild( 41 (new HtmlElement('div'))->addAttribute('type','hidden')->addStyleClass(['navtree','selector-tree','act-load-selector-tree'])->addAttribute('data-types',$this->types)->addAttribute('data-init-id',$this->id)->addAttribute('data-init-folderid',$this->folderid) 42 ); 43 } 44 45 }