Lançado Adianti Framework 7.6!
Clique aqui para saber mais
menu

Adianti Solutions

API

Adianti, Framework, PHP, MVC, Active record, Front controller, IDE, RAD, Web, multiplataforma, geração de código, desenvolvimento rápido, relatórios, formulários, listagens, datagrids, gráficos, banco de dados, padrões de projeto, design patterns API do Adianti Framework.
API Docs
code
Selecione a classe

Source for file TPanelGroup.php

Documentation is available at TPanelGroup.php

  1. <?php
  2. namespace Adianti\Widget\Container;
  3.  
  4. use Adianti\Wrapper\BootstrapFormWrapper;
  5. use Adianti\Wrapper\BootstrapDatagridWrapper;
  6. use Adianti\Widget\Base\TElement;
  7. use Adianti\Control\TAction;
  8. use Adianti\Widget\Util\TActionLink;
  9.  
  10. /**
  11.  * Bootstrap native panel for Adianti Framework
  12.  *
  13.  * @version    7.4
  14.  * @package    widget
  15.  * @subpackage container
  16.  * @author     Pablo Dall'Oglio
  17.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  18.  * @license    http://www.adianti.com.br/framework-license
  19.  */
  20. class TPanelGroup extends TElement
  21. {
  22.     private $title;
  23.     private $head;
  24.     private $body;
  25.     private $footer;
  26.     private $actionsContainer;
  27.     
  28.     /**
  29.      * Static creator for panels
  30.      * @param $title Panel title
  31.      * @param $element Panel content
  32.      */
  33.     public static function pack($title$element$footer null)
  34.     {
  35.         $panel new self($title);
  36.         $panel->add($element);
  37.         
  38.         if ($footer)
  39.         {
  40.             $panel->addFooter($footer);
  41.         }
  42.         
  43.         return $panel;
  44.     }
  45.     
  46.     /**
  47.      * Constructor method
  48.      * @param $title  Panel Title
  49.      * @param $footer Panel Footer
  50.      */
  51.     public function __construct($title NULL$background NULL)
  52.     {
  53.         parent::__construct('div');
  54.         $this->{'class''card panel';
  55.         
  56.         $this->head new TElement('div');
  57.         $this->head->{'class''card-header panel-heading';
  58.         $this->head->{'style''display:none';
  59.         parent::add($this->head);
  60.         
  61.         $panel_title new TElement('div');
  62.         $panel_title->{'class''card-title panel-title';
  63.         $this->head->add($panel_title);
  64.         
  65.         $this->title new TElement('div');
  66.         $this->title->{'style''width: 100%';
  67.         $this->title->add($title);
  68.         $panel_title->add($this->title);
  69.         
  70.         if (!empty($background))
  71.         {
  72.             $this->head->{'style'.= ';background:'.$background;
  73.         }
  74.         
  75.         $this->actionsContainer new TElement('div');
  76.         $this->actionsContainer->{'style''margin-left: auto';
  77.         $this->head->add$this->actionsContainer );
  78.         
  79.         if (!empty($title))
  80.         {
  81.             $this->head->{'style'str_replace('display:none'''$this->head->{'style'});
  82.         }
  83.         
  84.         $this->body new TElement('div');
  85.         $this->body->{'class''card-body panel-body';
  86.         parent::add($this->body);
  87.         
  88.         $this->footer new TElement('div');
  89.         $this->footer->{'class''card-footer panel-footer';
  90.     }
  91.     
  92.     /**
  93.      * Set title
  94.      */
  95.     public function setTitle($title)
  96.     {
  97.         $this->title->clearChildren();
  98.         $this->title->add($title);
  99.     }
  100.     
  101.     /**
  102.      * Add a form header action
  103.      * @param $label Button label
  104.      * @param $action Button action
  105.      * @param $icon Button icon
  106.      */
  107.     public function addHeaderActionLink($labelTAction $action$icon 'fa:save')
  108.     {
  109.         $this->head->{'style'str_replace('display:none'''$this->head->{'style'});
  110.         
  111.         $this->title->{'style''display:inline-block;';
  112.         $label_info ($label instanceof TLabel$label->getValue($label;
  113.         $button new TActionLink($label_info$actionnullnullnull$icon);
  114.         $button->{'class''btn btn-sm btn-default';
  115.         
  116.         $this->actionsContainer->add($button);
  117.         
  118.         return $button;
  119.     }
  120.     
  121.     /**
  122.      * Add a form header widget
  123.      * @param $widget Widget
  124.      */
  125.     public function addHeaderWidget($widget)
  126.     {
  127.         $this->head->{'style'str_replace('display:none'''$this->head->{'style'});
  128.         $this->title->{'style''display:inline-block;';
  129.         
  130.         $this->actionsContainer->add($widget);
  131.         
  132.         return $widget;
  133.     }
  134.     
  135.     /**
  136.      * Add the panel content
  137.      */
  138.     public function add($content)
  139.     {
  140.         $this->body->add($content);
  141.         
  142.         if ($content instanceof BootstrapFormWrapper)
  143.         {
  144.             $buttons $content->detachActionButtons();
  145.             if ($buttons)
  146.             {
  147.                 foreach ($buttons as $button)
  148.                 {
  149.                     $this->footer->add$button );
  150.                 }
  151.                 parent::add($this->footer);
  152.             }
  153.         }
  154.         
  155.         return $this->body;
  156.     }
  157.     
  158.     /**
  159.      * Return panel header
  160.      */
  161.     public function getHeader()
  162.     {
  163.         return $this->head;
  164.     }
  165.     
  166.     /**
  167.      * Return panel body
  168.      */
  169.     public function getBody()
  170.     {
  171.         return $this->body;
  172.     }
  173.     
  174.     /**
  175.      * Return panel footer
  176.      */
  177.     public function getFooter()
  178.     {
  179.         return $this->footer;
  180.     }
  181.     
  182.     /**
  183.      * Add footer
  184.      */
  185.     public function addFooter($footer)
  186.     {
  187.         $this->footer->add$footer );
  188.         parent::add($this->footer);
  189.     }
  190. }