Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
 /**
  * @param array $links
  *
  * @return $this|self
  */
 private function setSchema(array $links = []) : self
 {
     $this->schema = new HtmlContainer('<script>');
     $this->schema->addAttribute('type', 'application/ld+json');
     $content = ['@context' => 'http://schema.org', '@type' => 'BreadcrumbList', 'itemListElement' => []];
     $uri = clone self::request()->getUri();
     $count = 1;
     foreach ($links as $url => $link) {
         $content['itemListElement'][] = ['@type' => 'ListItem', 'position' => $count, 'item' => ['@id' => $uri->setPath($url)->get(false), 'name' => $link]];
         $count++;
     }
     $this->schema->setContent(json_encode($content));
     $this->add($this->schema);
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * @param HtmlElement|string $helpText
  *
  * @return $this|self
  */
 public function setHelpText($helpText) : self
 {
     if (!$helpText instanceof HtmlElement) {
         $helpText = new HtmlElement('<span>', $helpText);
     }
     $helpText->addClass('help-block');
     // @see http://getbootstrap.com/css/#forms-help-text
     if ($this->getField()) {
         if (!$helpText->getId()) {
             $helpText->generateId();
         }
         $this->getField()->addAttribute('aria-describedby', $helpText->getId());
     }
     $this->helpText = $helpText;
     return $this;
 }
Ejemplo n.º 4
0
 public function method(string $namespace, string $service, string $method, int $version = null)
 {
     $serviceObject = $this->listServices($namespace, $version, $service)[0];
     $authName = $serviceObject->getReflectionMethod($method)->getDefinition(Definition::AUTH)->getAuth();
     $auth = new HtmlElement('<span>', self::trans('swaggerserver.auth', [$authName]));
     $auth->addClass(['btn', 'btn-warning']);
     $this->masterpage->addTitleBadge($auth);
     $this->masterpage->addMain(new Method\Parameters($serviceObject, $method, $version));
     $this->masterpage->addMain(new Method\Responses($serviceObject, $method, $version));
     $this->masterpage->addMain(new Method\Models($serviceObject, $method, $version));
     $comment = $serviceObject->getReflectionMethod($method)->getDefinition(Definition::COMMENT)->getComment();
     if ($serviceObject->getReflectionMethod($method)->getDefinition(Definition::COMMENT_LONG)) {
         $comment .= '<br /><br />' . $serviceObject->getReflectionMethod($method)->getDefinition(Definition::COMMENT_LONG)->getComment();
     }
     $this->masterpage->setSubtitle($comment);
     return $this->masterpage->render();
 }
Ejemplo n.º 5
0
 /**
  * @param string $content
  * @param string $type
  * @param string $size
  */
 public function __construct(string $content, string $type = self::TYPE_DEFAULT, string $size = null)
 {
     if (!$this->tag) {
         $this->tag = '<button>';
     }
     parent::__construct(null, $content);
     $this->addClass(['btn', $type]);
     if ($size) {
         $this->addClass($size);
     }
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     if ($this->isDismissible()) {
         $content = $this->getContent();
         $this->setContent('<button type="button" class="close" data-dismiss="alert" aria-label="Close">' . '<span aria-hidden="true">&times;</span></button>' . $content);
     }
     $return = parent::render();
     if (isset($content)) {
         $this->setContent($content);
     }
     return $return;
 }
Ejemplo n.º 7
0
 /**
  * @param HtmlElement $element
  *
  * @return HtmlElement
  */
 private function beforeAdd(HtmlElement $element)
 {
     $element->addClass('list-group-item');
     return $element;
 }
Ejemplo n.º 8
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();
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     if (!isset($this->data['id'])) {
         $this->generateId();
     }
     $this->data['content'] = $this->elements->render();
     $phtml = $this->phtmlRender();
     if ($this->isStaticToTop()) {
         $phtml = (new HtmlElement('<div>'))->addClass('container')->setContent($phtml)->render();
     }
     $this->setContent($phtml);
     $return = parent::render();
     return $return;
 }
Ejemplo n.º 10
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;
 }
Ejemplo n.º 11
0
 /**
  * @param string $content
  * @param string $type
  */
 public function __construct(string $content, string $type = self::TYPE_DEFAULT)
 {
     parent::__construct('<span>', $content);
     $this->addAttributes(['class' => 'label']);
     $this->addClass($type);
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $this->addAttribute('src', $this->getUrl());
     return parent::render();
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $this->build();
     $this->setContent($this->header->render());
     return HtmlElement::render();
 }
Ejemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     if ($this->responsive) {
         $div = new HtmlElement('<div>');
         $div->addClass('table-responsive');
         $div->setContent(parent::render());
         return $div->render();
     } else {
         return parent::render();
     }
 }
Ejemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $this->build();
     $this->setContent($this->header->render() . $this->body->render());
     return parent::render();
 }
Ejemplo n.º 16
0
 /**
  * @param string $content
  */
 public function __construct(string $content = null)
 {
     parent::__construct('<label>');
     $this->setContent($content);
 }
Ejemplo n.º 17
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;
 }
Ejemplo n.º 18
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $this->content = $this->layout()->render();
     return parent::render();
 }
Ejemplo n.º 19
0
 /**
  * @return string
  */
 public function render()
 {
     $this->element->setContent(json_encode($this->data));
     return $this->element->render();
 }