示例#1
0
 /**
  * {@inheritdoc}
  */
 protected function layout() : Container
 {
     if (!$this->buttons) {
         return self::fieldTraitLayout();
     }
     $container = self::fieldTraitLayout();
     foreach ($this->buttons->getElements() as $button) {
         $container->first()->addFirst($button);
     }
     return $container;
 }
示例#2
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;
 }
示例#3
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();
 }
示例#4
0
文件: Group.php 项目: cawaphp/html
 /**
  * @return Container
  */
 protected function layout() : Container
 {
     $container = new Container();
     if ($this->label) {
         $container->add($this->label);
     }
     $container->add($this->container);
     return $container;
 }
示例#5
0
文件: Map.php 项目: cawaphp/widget
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $container = new Container();
     $container->add(new Element(parent::render()));
     $container->add($this->widgetOptions);
     return $container->render();
 }
示例#6
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;
     }
 }
 /**
  * @return string
  */
 public function render() : string
 {
     foreach ($this->module()->namespaces as $namespace) {
         $namespaceName = $namespace->getName();
         $version = $this->data['version'] ? $this->data['version'] : max($namespace->getVersions());
         $servicesList = [];
         foreach ($this->listServices($namespaceName, $version) as $serviceName => $currentService) {
             $link = self::uri('swagger/doc/' . ($this->data['version'] ? 'version' : '') . '/service', ['namespace' => $namespaceName, 'service' => $serviceName, 'version' => $version]);
             $methodsList = ['name' => $serviceName, 'link' => $link, 'active' => $namespaceName == $this->data['namespace'] && $serviceName == $this->data['service'], 'methods' => []];
             if ($serviceName == $this->data['service']) {
                 foreach ($currentService->getMethods() as $methodName) {
                     $link = self::uri('swagger/doc/' . ($this->data['version'] ? 'version' : '') . '/method', ['namespace' => $namespaceName, 'service' => $serviceName, 'method' => $methodName, 'version' => $version]);
                     $methodsList['methods'][] = ['link' => $link, 'active' => $namespaceName == $this->data['namespace'] && $serviceName == $this->data['service'] && $methodName == $this->data['method'], 'name' => $methodName];
                 }
             }
             $servicesList[$serviceName] = $methodsList;
         }
         $link = self::uri('swagger/doc/' . ($this->data['version'] ? 'version' : '') . '/namespace', ['namespace' => $namespaceName, 'version' => $version]);
         $this->data['namespaces'][] = ['name' => $namespaceName, 'link' => $link, 'active' => $namespaceName == $this->data['namespace'], 'versions' => $namespace->getVersions(), 'services' => $servicesList];
     }
     if ($this->data['namespace']) {
         foreach ($this->module()->namespaces[$this->data['namespace']]->getVersions() as $version) {
             $route = self::router()->current()->getName();
             if ($this->maxVersion($this->data['namespace']) == $version) {
                 $route = str_replace('version/', '', self::router()->current()->getName());
             }
             $this->data['versions'][$version] = (string) self::uri($route, ['namespace' => $this->data['namespace'], 'service' => $this->data['service'], 'method' => $this->data['method'], 'version' => $this->maxVersion($this->data['namespace']) != $version ? $version : null]);
         }
         $this->data['maxVersion'] = $this->maxVersion($this->data['namespace']);
     }
     $this->data['main'] = $this->main->render();
     $this->data['titleBadge'] = $this->titleBadge->render();
     $this->getBody()->setContent($this->phtmlRender());
     return parent::render();
 }