示例#1
0
文件: Tag.php 项目: dez-php/dez-html
 /**
  * @param array $header
  * @param array $rows
  * @return TableElement
  */
 public static function table(array $header = [], array $rows = [])
 {
     $table = new TableElement();
     if (count($header) > 0) {
         $thead = new TableHeadElement();
         $headRow = new TableRowElement();
         $thead->appendContent($headRow);
         foreach ($header as $headerCell) {
             $headRow->appendContent(new TableHeadCellElement(new BoldElement($headerCell)));
         }
         $table->appendContent($thead);
     }
     if (count($rows) > 0) {
         $tbody = new TableBodyElement();
         foreach ($rows as $items) {
             $tableRow = new TableRowElement();
             $tbody->appendContent($tableRow);
             foreach ($items as $item) {
                 $tableRow->cell($item);
             }
         }
         $table->appendContent($tbody);
     }
     return $table;
 }
示例#2
0
}
//    die(var_dump($table));
echo $table;
$text = new H1Element(new ItalicElement('Hello world', ['data-inner-html' => new BoldElement('test', ['id' => 'click-me'])]));
$input = new InputTextElement('email', 'none');
$password = new InputPasswordElement('passwd', '123qwe');
$div = (new DivElement($input))->appendContent($password);
$div->addClass('test-class')->addClass('lol-class')->addClass('ok');
$button = new ButtonElement('do', new ItalicElement(new BoldElement('search...')));
$div->appendContent($button);
echo $text, $input, $password, $button, $div;
echo '<hr>';
$form = new FormElement('/app/save_element.php', 'post', true, new InputSubmitElement('save!', null));
$form->addClass('form-component')->id(md5(time()))->prependContent($div->removeClass('ok'))->prependContent($text);
echo $form;
$tableForm = new TableElement();
$tableForm->row('Test Form!!!')->cell($form);
echo '<hr>';
echo Tag::a('test', 'click me!')->addClass('col-md-12')->id('dezdezdez')->addClass('c');
echo '<hr>';
echo Tag::img('http://fox-fan.ru/news/269_1.jpg', 250, -1, 'rounded');
$select = new SelectElement('geo_list', ['Ukraine' => 'ua', 'Ukraine Regions' => ['Kiev' => 'ua-kyiv', '4e' => 'ua-4e'], 'Japan' => 'jp'], rand(0, 9));
echo $select;
$optgroup = new OptgroupElement();
$optgroup->setAttribute('label', 'Test');
for ($i = 0; $i < 10; $i++) {
    $optgroup->appendContent((new OptionElement("Item {$i}"))->id("id-{$i}")->setAttribute('value', $i));
}
$select->prependContent($optgroup);
echo $select, (new ScriptElement('js/jquery.js'))->async(true);
echo new InputCheckboxElement('test', 'asd');