Пример #1
0
 public function __invoke(HtmlContainer $tr, array $data, Table $table)
 {
     if (isset($data['_rowheader']) && $data['_rowheader']) {
         $tr->addClass('rowheader');
     }
     return $tr;
 }
Пример #2
0
 /**
  * @param string|null $content
  * @param string|null $link
  */
 public function __construct(string $content = null, string $link = null)
 {
     parent::__construct('<a>', $content);
     if ($link) {
         $this->setHref($link);
     }
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function addFirst(ViewController ...$elements)
 {
     if ($this->isAdded) {
         throw new \LogicException("can't add element on fieldset when is already add on a form");
     }
     return parent::add(...$elements);
 }
Пример #4
0
 /**
  * @return string
  */
 public function render()
 {
     $timerEvent = new TimerEvent('router.htmlPage', ['elements' => sizeof($this->elements)]);
     $out = '<!DOCTYPE html lang="' . self::locale() . '">' . "\n";
     // default seo
     if (!$this->headTitle && ($title = self::trans('seo.default/title'))) {
         $this->setHeadTitle($title);
     }
     if (!$this->headDescription && ($description = self::trans('seo.default/description'))) {
         $this->setHeadDescription($description);
     }
     // add mandatory headers
     $language = new HtmlElement('<meta />');
     $language->addAttributes(['http-equiv' => 'Content-Language', 'content' => self::locale()]);
     $this->head->addFirst($language);
     $charset = new HtmlElement('<meta />');
     $charset->addAttribute('charset', 'utf-8');
     $this->head->addFirst($charset);
     $content = $this->body->getContent();
     if ($content) {
         $this->body->setContent($content . $this->footer->render());
     }
     $parent = parent::render();
     $out .= $parent;
     $timerEvent->addData(['size' => $this->getContent() ? strlen($this->getContent()) : strlen($parent)]);
     self::emit($timerEvent);
     return $out;
 }
Пример #5
0
 /**
  * @param array $keyValue
  */
 public function __construct(array $keyValue = [])
 {
     parent::__construct('<dl>');
     foreach ($keyValue as $key => $value) {
         $this->addDescription($key, $value);
     }
 }
Пример #6
0
 public function __invoke(HtmlContainer $tr, array $data)
 {
     if (isset($data['_deleted']) && $data['_deleted']) {
         $tr->addClass('deleted');
         /** @var HtmlElement $current */
         foreach ($tr->getElements() as $current) {
             if ($current->hasClass('row-action') && stripos($current->getContent(), 'fa-trash') !== false) {
                 if ($data['_deleted'] instanceof DateTime) {
                     $current->setContent('<i title="' . $data['_deleted']->display() . '" class="fa fa-info-circle" aria-hidden="true"></i>');
                 } else {
                     $current->setContent('');
                 }
             }
         }
     }
     return $tr;
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function addFirst(ViewController ...$elements)
 {
     foreach ($elements as $element) {
         /* @noinspection PhpParamsInspection */
         parent::add($this->beforeAdd($element));
     }
     return $this;
 }
Пример #8
0
 /**
  * @param string $class
  */
 public function __construct(string $class = null)
 {
     parent::__construct('<span>');
     $this->addClass('input-group-addon');
     $element = new HtmlElement('<i>');
     $element->addClass($class);
     $this->add($element);
 }
Пример #9
0
 /**
  * @param array $links
  *
  * @return $this|self
  */
 private function setOl(array $links = []) : self
 {
     $this->ol = new HtmlContainer('<ol>');
     $this->ol->addClass('breadcrumb');
     $last = null;
     foreach ($links as $uri => $link) {
         if (!$uri) {
             $last = $link;
         } else {
             $this->ol->add((new HtmlContainer('<li>'))->add(new Link($link, $uri)));
         }
     }
     if ($last) {
         $this->ol->add((new HtmlElement('<li>', $last))->addClass('active'));
     }
     $this->add($this->ol);
     return $this;
 }
Пример #10
0
 /**
  * @param string $size
  */
 public function __construct(string $size = null)
 {
     parent::__construct('<div>');
     $this->addClass('btn-group');
     $this->addAttribute('role', 'group');
     if ($size) {
         $this->addClass($size);
     }
 }
Пример #11
0
 public function render()
 {
     if ($this->badge) {
         if ($this->content) {
             $this->content = '<span class="badge">' . $this->badge . '</span> ' . $this->content;
         } else {
             $this->addFirst((new HtmlElement('<span>', $this->badge))->addClass('badge'));
         }
     }
     return parent::render();
 }
Пример #12
0
 /**
  * @return string
  */
 public function render()
 {
     if (sizeof($this->data)) {
         // append row actions
         foreach ($this->rowActions as $i => $rowAction) {
             $this->add((new Column('row_action_' . $i, ''))->addRenderer(new RowActionRenderer($rowAction))->addClass('row-action')->setHideable(false));
         }
         foreach ($this->data as $row) {
             $tr = new HtmlContainer('<tr>');
             if (sizeof($this->thead->elements)) {
                 /** @var Column $column */
                 foreach ($this->thead->elements as $column) {
                     if ($column->isVisible() && $column->isRenderable()) {
                         $td = new HtmlElement('<td>');
                         $td->addClass($column->getClasses());
                         $content = $row[$column->getId()] ?? '';
                         if ($column->getRenderer()) {
                             foreach ($column->getRenderer() as $renderer) {
                                 $content = $renderer($content, $column, $this->getPrimaryValues($row), $row);
                             }
                         }
                         $td->setContent((string) $content);
                         $tr->add($td);
                     }
                 }
             } else {
                 foreach ($row as $col) {
                     $tr->add(new HtmlElement('<td>', $col));
                 }
             }
             if ($this->rowRenderers) {
                 foreach ($this->rowRenderers as $callback) {
                     $tr = call_user_func($callback, $tr, $row, $this);
                 }
             }
             $this->tbody->add($tr);
         }
     } else {
         $this->tbody->add((new HtmlContainer('<tr>'))->add((new HtmlElement('<td>'))->addAttribute('colspan', (string) sizeof($this->getVisibleColumns()))->setContent(self::trans('html.table/noResult'))->addClass('text-center')));
     }
     $return = parent::render();
     return $return;
 }
Пример #13
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $this->ul->clear();
     $this->ul->add($this->getLi(max(1, $this->current - 1), '&laquo;')->addClass('prev'));
     $min = 1;
     $max = $this->page;
     if ($this->page > $this->maxItem) {
         $min = max(1, $this->current - $this->maxItem / 2);
         $max = min($this->page, $this->current + $this->maxItem / 2);
     }
     if ($min - 1 >= 1) {
         $this->ul->add($this->getLi($min + 1, '...'));
     }
     for ($i = $min; $i <= $max; $i++) {
         $this->ul->add($this->getLi($i));
     }
     if ($max + 1 < $this->page) {
         $this->ul->add($this->getLi($max + 1, '...'));
     }
     $this->ul->add($this->getLi(min($this->page, $this->current + 1), '&raquo;')->addClass('next'));
     $this->setContent($this->ul->render());
     return parent::render();
 }
Пример #14
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $container = new Container();
     $container->add(new Element(parent::render()));
     $container->add($this->widgetOptions);
     return $container->render();
 }
Пример #15
0
 /**
  * @param array|string $class
  */
 public function __construct($class = null)
 {
     parent::__construct('<div>');
     if ($class) {
         $this->addClass($class);
     }
 }
Пример #16
0
 /**
  * @return string
  */
 private function renderClone()
 {
     return parent::render();
 }
Пример #17
0
 /**
  * {@inheritdoc}
  */
 public function renderOuter() : array
 {
     $this->alterBeforeRender();
     return parent::renderOuter();
 }
Пример #18
0
 /**
  *
  */
 public function __construct()
 {
     parent::__construct('<div>');
     $this->addClass('row');
 }
Пример #19
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $this->content = $this->layout()->render();
     return parent::render();
 }
Пример #20
0
 /**
  * {@inheritdoc}
  */
 public function addFirst(ViewController ...$elements)
 {
     foreach ($elements as $element) {
         /* @noinspection PhpParamsInspection */
         parent::addFirst($this->handleDisplay($element, true));
     }
     return $this;
 }
Пример #21
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $deepcopy = new DeepCopy();
     /** @var MultipleGroup $clone */
     $clone = $deepcopy->copy($this);
     $fullRender = $clone->parentRender();
     $this->newContainer->getOptions()->addData('clone', $fullRender);
     return parent::render();
 }
Пример #22
0
 /**
  * {@inheritdoc}
  */
 protected function layout() : Container
 {
     if ($this instanceof Group || $this instanceof Fieldset) {
         $this->applyContainerSize($this->container->elements);
     } else {
         $this->applySize($this);
     }
     if ($this->getGridSize()) {
         $container = new Container();
         // label
         if ($this->getLabel()) {
             $this->getLabel()->addClass('col-sm-' . $this->getGridSize())->addClass('control-label');
             $container->add($this->getLabel());
         }
         // field
         if ($this instanceof Group) {
             $fieldWrapper = $this->getContainer();
         } else {
             if (sizeof($this->inputGroups)) {
                 $fieldWrapper = new HtmlContainer('<div>');
                 $fieldWrapper->add($inputGroupWrapper = (new HtmlContainer('<div>'))->addClass('input-group'));
                 if (isset($this->inputGroups[true])) {
                     foreach ($this->inputGroups[true] as $inputGroup) {
                         $inputGroupWrapper->add($inputGroup);
                     }
                 }
                 $inputGroupWrapper->add($this->getField());
                 if (isset($this->inputGroups[false])) {
                     foreach ($this->inputGroups[false] as $inputGroup) {
                         $inputGroupWrapper->add($inputGroup);
                     }
                 }
             } else {
                 $fieldWrapper = new HtmlContainer('<div>');
                 $fieldWrapper->add($this->getField());
             }
         }
         if ($this instanceof MultipleGroup) {
             $fieldWrapper->getElement()->addClass('col-sm-' . (12 - $this->getGridSize()));
         } else {
             $fieldWrapper->addClass('col-sm-' . (12 - $this->getGridSize()));
         }
         // label
         if (!$this->getLabel()) {
             $fieldWrapper->addClass('col-sm-offset-' . $this->getGridSize());
         }
         // help wrap
         if ($this->helpText) {
             $fieldWrapper->add($this->helpText);
         }
         $container->add($fieldWrapper);
         return $container;
     } else {
         $container = parent::layout();
         if ($this->helpText) {
             $container->add($this->helpText);
         }
         return $container;
     }
 }
Пример #23
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     if ($this->title || $this->title) {
         $header = (new HtmlContainer('<div>'))->addClass('panel-heading');
         if ($this->buttonGroup) {
             $header->add($this->buttonGroup);
         }
         if ($this->title) {
             $header->add((new HtmlElement('<h3>', $this->title))->addClass('panel-title'));
         }
         parent::add($header);
     }
     if ($this->content) {
         parent::add((new HtmlElement('<div>', $this->content))->addClass('panel-body'));
     } else {
         $container = new Container();
         foreach ($this->container->getElements() as $element) {
             if ($element instanceof Table || $element instanceof Grid || $element instanceof ListGroup) {
                 if (sizeof($container->getElements()) > 0) {
                     parent::add((new HtmlContainer('<div>'))->addClass('panel-body')->add($container));
                     $container = new Container();
                 }
                 parent::add($element);
             } else {
                 $container->add($element);
             }
         }
         if (sizeof($container->getElements()) > 0) {
             parent::add((new HtmlContainer('<div>'))->addClass('panel-body')->add($container));
         }
     }
     if ($this->footer) {
         parent::add((new HtmlElement('<div>', $this->footer))->addClass('panel-footer'));
     }
     return parent::render();
 }
Пример #24
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     if ($this->visible) {
         return parent::render();
     } else {
         return '';
     }
 }
Пример #25
0
 /**
  * @return HtmlContainer
  */
 public function getHeader() : HtmlContainer
 {
     $title = ($this->icon ? (new HtmlElement('<i>'))->addClass($this->icon)->render() . ' ' : '') . $this->title;
     $link = new HtmlContainer('<a>', $title);
     if ($this->href && !$this->isDisabled()) {
         $link->addAttribute('href', $this->href);
     }
     if (substr($this->href, 0, 1) == '#' && !$this->isDisabled()) {
         $link->addAttribute('data-toggle', 'tab');
     }
     $li = (new HtmlContainer('<li>'))->addAttribute('role', 'presentation')->add($link);
     if ($this->isActive()) {
         $li->addClass('active');
     }
     if ($this->isDisabled()) {
         $li->addClass('disabled');
     }
     return $li;
 }
Пример #26
0
 /**
  * @return string
  */
 private function renderClone() : string
 {
     // add columns viksiblity dropdown
     $this->options->add($this->getColumnDropdown());
     if ($this->filtersForm) {
         $this->filtersForm->add(new Submit(self::trans('bootstrap.grid/filter')));
     }
     // add pagination
     if ($this->rowCount) {
         $this->options->add($this->getRowsPerPageDropdown());
         $pagination = new Pagination((int) ceil($this->rowCount / $this->getPageSize()), $this->argsCallback);
         $this->navbar->add($pagination, false);
     }
     return parent::render();
 }