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. $this->setIcon($icon);
  30. $this->setTitle($title);
  31. $this->setValue($value);
  32. $this->setBackground($background);
  33. }
  34. /**
  35. * Define the box icon
  36. * @param $icon Icon
  37. */
  38. public function setIcon($icon)
  39. {
  40. $this->icon = $icon;
  41. }
  42. /**
  43. * Define the content title
  44. * @param $title Title
  45. */
  46. public function setTitle($title)
  47. {
  48. $this->title = $title;
  49. }
  50. /**
  51. * Define the content value
  52. * @param $value Value
  53. */
  54. public function setValue($value)
  55. {
  56. $this->value = $value;
  57. }
  58. /**
  59. * Define the icon background color
  60. * @param $background Background color class
  61. */
  62. public function setBackground($background)
  63. {
  64. $this->background = $background;
  65. }
  66. /**
  67. * Render infobox icon
  68. */
  69. public function renderBoxIcon()
  70. {
  71. $icon = new TImage($this->icon);
  72. $icon->{'aria-hidden'} = 'true';
  73. $span = new TElement('span');
  74. $span->{'class'} = 'info-box-icon';
  75. if(isset($this->background))
  76. {
  77. $span->{'class'} .= ' bg-'.$this->background;
  78. }
  79. $span->add($icon);
  80. return $span;
  81. }
  82. /**
  83. * Render infobox content
  84. */
  85. public function renderBoxContent()
  86. {
  87. if(isset($this->title))
  88. {
  89. $title = new TElement('span');
  90. $title->{'class'} = 'info-box-text';
  91. $title->add($this->title);
  92. }
  93. if(isset($this->value))
  94. {
  95. $value = new TELement('span');
  96. $value->{'class'} = 'info-box-number';
  97. $value->add($this->value);
  98. }
  99. $content = new TElement('div');
  100. $content->{'class'} = 'info-box-content';
  101. $content->add($title);
  102. $content->add($value);
  103. return $content;
  104. }
  105. /**
  106. * Show
  107. */
  108. public function show()
  109. {
  110. parent::add( $this->renderBoxIcon() );
  111. parent::add( $this->renderBoxContent() );
  112. parent::show();
  113. }
  114. }
  115. 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. public function __construct()
  12. {
  13. parent::__construct();
  14. $container = new TElement('div');
  15. $container->class = 'col-sm-12';
  16. $container->add(new TInfoBox('fa:user','teste',"12323",'green'));
  17. $container->add(new TInfoBox('fa:user','teste',"-4984",'red'));
  18. // wrap the page content using vertical box
  19. $vbox = new TVBox;
  20. $vbox->style = 'width: 100%';
  21. $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  22. $vbox->add($container);
  23. parent::add($vbox);
  24. }
  25. }

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework 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