Lançado Adianti Framework 7.6!
Clique aqui para saber mais
TInfoBox 1.0.0 Componente utilizado para criar um elemento InfoBox: ...
RM
TInfoBox 1.0.0  
Componente utilizado para criar um elemento InfoBox:

  1. <?php
  2. use Adianti\Widget\Base\TElement;
  3. use Adianti\Widget\Util\TImage;
  4. /**
  5.  * TInfoBox
  6.  *
  7.  * @version    1.0
  8.  * @package    widget
  9.  * @author     Rodrigo Pires Meira
  10.  */
  11. class TInfoBox extends TElement
  12. {
  13.     private $icon;
  14.     private $title;
  15.     private $value;
  16.     private $background;
  17.     /**
  18.      * Class Constructor
  19.      * @param $icon text Icon name
  20.      * @param $title text Title text
  21.      * @param $value text Value text
  22.      * @param $background text Background color class
  23.      */
  24.     public function __construct($icon null$title null$value null$background null)
  25.     {
  26.         parent::__construct('div');
  27.         $this->id 'tinfobox_' uniqid();
  28.         $this->{'class'} = 'info-box';
  29.         
  30.         $this->setIcon($icon);
  31.         $this->setTitle($title);
  32.         $this->setValue($value);
  33.         $this->setBackground($background);
  34.     }
  35.     /**
  36.      * Define the box icon
  37.      * @param  $icon Icon
  38.      */
  39.     public function setIcon($icon)
  40.     {
  41.         $this->icon $icon;
  42.     }
  43.     /**
  44.      * Define the content title
  45.      * @param  $title Title
  46.      */
  47.     public function setTitle($title)
  48.     {
  49.         $this->title $title;
  50.     }
  51.     /**
  52.      * Define the content value
  53.      * @param  $value Value
  54.      */
  55.     public function setValue($value)
  56.     {
  57.         $this->value $value;
  58.     }
  59.     /**
  60.      * Define the icon background color
  61.      * @param  $background Background color class
  62.      */
  63.     public function setBackground($background)
  64.     {
  65.         $this->background $background;
  66.     }
  67.     
  68.     /**
  69.      * Render infobox icon
  70.      */
  71.     public function renderBoxIcon()
  72.     {
  73.         
  74.         $icon = new TImage($this->icon);
  75.         $icon->{'aria-hidden'} = 'true';
  76.         
  77.         $span = new TElement('span');
  78.         $span->{'class'} = 'info-box-icon';
  79.         if(isset($this->background))
  80.         {
  81.            $span->{'class'} .= ' bg-'.$this->background;
  82.         }
  83.         $span->add($icon);
  84.         
  85.         return $span;
  86.     }
  87.     
  88.     /**
  89.      * Render infobox content
  90.      */
  91.     public function renderBoxContent()
  92.     {
  93.         if(isset($this->title))
  94.         {
  95.             $title = new TElement('span');
  96.             $title->{'class'} = 'info-box-text';
  97.             $title->add($this->title);
  98.         }
  99.         if(isset($this->value))
  100.         {
  101.             $value = new TELement('span');
  102.             $value->{'class'} = 'info-box-number';
  103.             $value->add($this->value);
  104.         }
  105.         
  106.         $content = new TElement('div');
  107.         $content->{'class'} = 'info-box-content';
  108.         $content->add($title);
  109.         $content->add($value);
  110.         
  111.         return $content;
  112.     }
  113.     
  114.     /**
  115.      * Show
  116.      */
  117.     public function show()
  118.     {
  119.         parent::add$this->renderBoxIcon() );
  120.         parent::add$this->renderBoxContent() );
  121.                 
  122.         parent::show();
  123.     }
  124.     
  125. }
  126. Para utilizar o elemento basta criar uma classe que instancie o elemento e adicione na página:
  1. <?php
  2. /**
  3.  * TInfoBoxView
  4.  *
  5.  * @version    1.0
  6.  * @author     Rodrigo Pires Meira
  7.  */
  8. class TInfoBoxView extends TPage
  9. {
  10.     private $form;
  11.     
  12.     public function __construct()
  13.     {
  14.         parent::__construct();
  15.         
  16.         $container = new TElement('div');
  17.         $container->class 'col-sm-12';
  18.         
  19.         $container->add(new TInfoBox('fa:user','teste',"12323",'green'));
  20.         $container->add(new TInfoBox('fa:user','teste',"-4984",'red'));
  21.         
  22.         // wrap the page content using vertical box
  23.         $vbox = new TVBox;
  24.         $vbox->style 'width: 100%';
  25.         $vbox->add(new TXMLBreadCrumb('menu.xml'__CLASS__));
  26.         $vbox->add($container);
  27.         parent::add($vbox);
  28.     }
  29.     
  30. }

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 Quero me inscrever agora!

Comentários (1)


GW

I am interested in this Because I have done developing work but now I left the work. Gustavo Woltmann