RM
TInfoBox 1.0.0
Componente utilizado para criar um elemento InfoBox:
- <?php
- use Adianti\Widget\Base\TElement;
- use Adianti\Widget\Util\TImage;
- /**
- * TInfoBox
- *
- * @version 1.0
- * @package widget
- * @author Rodrigo Pires Meira
- */
- class TInfoBox extends TElement
- {
- private $icon;
- private $title;
- private $value;
- private $background;
- /**
- * Class Constructor
- * @param $icon text Icon name
- * @param $title text Title text
- * @param $value text Value text
- * @param $background text Background color class
- */
- public function __construct($icon = null, $title = null, $value = null, $background = null)
- {
- parent::__construct('div');
- $this->id = 'tinfobox_' . uniqid();
- $this->{'class'} = 'info-box';
- $this->setIcon($icon);
- $this->setTitle($title);
- $this->setValue($value);
- $this->setBackground($background);
- }
- /**
- * Define the box icon
- * @param $icon Icon
- */
- public function setIcon($icon)
- {
- $this->icon = $icon;
- }
- /**
- * Define the content title
- * @param $title Title
- */
- public function setTitle($title)
- {
- $this->title = $title;
- }
- /**
- * Define the content value
- * @param $value Value
- */
- public function setValue($value)
- {
- $this->value = $value;
- }
- /**
- * Define the icon background color
- * @param $background Background color class
- */
- public function setBackground($background)
- {
- $this->background = $background;
- }
- /**
- * Render infobox icon
- */
- public function renderBoxIcon()
- {
- $icon = new TImage($this->icon);
- $icon->{'aria-hidden'} = 'true';
- $span = new TElement('span');
- $span->{'class'} = 'info-box-icon';
- if(isset($this->background))
- {
- $span->{'class'} .= ' bg-'.$this->background;
- }
- $span->add($icon);
- return $span;
- }
- /**
- * Render infobox content
- */
- public function renderBoxContent()
- {
- if(isset($this->title))
- {
- $title = new TElement('span');
- $title->{'class'} = 'info-box-text';
- $title->add($this->title);
- }
- if(isset($this->value))
- {
- $value = new TELement('span');
- $value->{'class'} = 'info-box-number';
- $value->add($this->value);
- }
- $content = new TElement('div');
- $content->{'class'} = 'info-box-content';
- $content->add($title);
- $content->add($value);
- return $content;
- }
- /**
- * Show
- */
- public function show()
- {
- parent::add( $this->renderBoxIcon() );
- parent::add( $this->renderBoxContent() );
- parent::show();
- }
- }
- Para utilizar o elemento basta criar uma classe que instancie o elemento e adicione na página:
- <?php
- /**
- * TInfoBoxView
- *
- * @version 1.0
- * @author Rodrigo Pires Meira
- */
- class TInfoBoxView extends TPage
- {
- private $form;
- public function __construct()
- {
- parent::__construct();
- $container = new TElement('div');
- $container->class = 'col-sm-12';
- $container->add(new TInfoBox('fa:user','teste',"12323",'green'));
- $container->add(new TInfoBox('fa:user','teste',"-4984",'red'));
- // wrap the page content using vertical box
- $vbox = new TVBox;
- $vbox->style = 'width: 100%';
- $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
- $vbox->add($container);
- parent::add($vbox);
- }
- }
I am interested in this Because I have done developing work but now I left the work. Gustavo Woltmann