TableComponent.class.php (1249B)
1 <?php 2 3 namespace template_engine\components\html\component_table; 4 5 use template_engine\components\html\HtmlComponent; 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 class TableComponent extends HtmlComponent 12 { 13 public $filter = true; 14 15 public function createElement() 16 { 17 $tableWrapper = (new HtmlElement('div'))->addStyleClass('table-wrapper'); 18 19 if ( $this->filter) 20 { 21 $filterInput = (new CMSElement('input'))->addStyleClass(['input','table-filter-input'])->addAttribute('type','search')->addAttribute('name','filter')->addAttribute('placeholder',Value::createExpression(ValueExpression::TYPE_MESSAGE,'SEARCH_FILTER')); 22 $filter = (new HtmlElement('div'))->addStyleClass('table-filter')->addChild( $filterInput ); 23 $tableWrapper->addChild($filter); 24 } 25 26 $tableContent = (new HtmlElement('div'))->addStyleClass('table-area'); 27 28 $table = (new CMSElement('table'))->addStyleClass('table'); 29 30 $tableWrapper->addChild( $tableContent->addChild( $table) ); 31 32 if ( $this->class) 33 $table->addStyleClass($this->class); 34 35 $this->adoptiveElement = $table; 36 37 return $tableWrapper; 38 } 39 }