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 TImage.php

Documentation is available at TImage.php

  1. <?php
  2. namespace Adianti\Widget\Util;
  3.  
  4. use Adianti\Widget\Base\TElement;
  5.  
  6. /**
  7.  * Image Widget
  8.  *
  9.  * @version    7.4
  10.  * @package    widget
  11.  * @subpackage util
  12.  * @author     Pablo Dall'Oglio
  13.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  14.  * @license    http://www.adianti.com.br/framework-license
  15.  */
  16. class TImage extends TElement
  17. {
  18.     private $source// image path
  19.     
  20.     /**
  21.      * Class Constructor
  22.      * @param $source Image path, of bs:bs-glyphicon, fab:font-awesome
  23.      */
  24.     public function __construct($source)
  25.     {
  26.         if (substr($source,0,3== 'fa:')
  27.         {
  28.             parent::__construct('i');
  29.             
  30.             $fa_class substr($source,3);
  31.             if (strstr($source'#'!== FALSE)
  32.             {
  33.                 $parts explode('#'$fa_class);
  34.                 $fa_color   substr($parts[1],0,7);
  35.                 $fa_bgcolor !empty($parts[2]substr($parts[2],0,7null;
  36.                 $fa_class   str_replace['#'.$fa_color'#'.$fa_bgcolor]['''']$fa_class);
  37.             }
  38.             
  39.             $this->{'class''fa fa-'.$fa_class;
  40.             if (!empty($fa_color))
  41.             {
  42.                 $this->{'style'.= "; color: #{$fa_color};";
  43.             }
  44.             
  45.             if (!empty($fa_bgcolor))
  46.             {
  47.                 $this->{'style'.= "; background-color: #{$fa_bgcolor};";
  48.             }
  49.             parent::add('');
  50.         }
  51.         else if ( ( substr($source,0,4== 'far:'|| (substr($source,0,4== 'fas:'|| (substr($source,0,4== 'fab:'|| (substr($source,0,4== 'fal:'|| (substr($source,0,4== 'fad:'))
  52.         {
  53.             parent::__construct('i');
  54.             
  55.             $fa_class substr($source,4);
  56.             if (strstr($source'#'!== FALSE)
  57.             {
  58.                 $parts explode('#'$fa_class);
  59.                 $fa_color   substr($parts[1],0,7);
  60.                 $fa_bgcolor !empty($parts[2]substr($parts[2],0,7null;
  61.                 $fa_class   str_replace['#'.$fa_color'#'.$fa_bgcolor]['''']$fa_class);
  62.             }
  63.             
  64.             $this->{'class'substr($source,0,3' fa-'.$fa_class;
  65.             
  66.             if (!empty($fa_color))
  67.             {
  68.                 $this->{'style'.= "; color: #{$fa_color};";
  69.             }
  70.             
  71.             if (!empty($fa_bgcolor))
  72.             {
  73.                 $this->{'style'.= "; background-color: #{$fa_bgcolor};";
  74.             }
  75.             parent::add('');
  76.         }
  77.         else if (substr($source,0,3== 'mi:')
  78.         {
  79.             parent::__construct('i');
  80.             
  81.             $mi_class substr($source,3);
  82.             if (strstr($source'#'!== FALSE)
  83.             {
  84.                 $pieces explode('#'$mi_class);
  85.                 $mi_class $pieces[0];
  86.                 $mi_color $pieces[1];
  87.             }
  88.             $this->{'class''material-icons';
  89.             
  90.             $pieces explode(' '$mi_class);
  91.             
  92.             if (count($pieces)>1)
  93.             {
  94.                 $mi_class array_shift($pieces);
  95.                 $this->{'class''material-icons ' implode(' '$pieces);
  96.             }
  97.             
  98.             if (isset($mi_color))
  99.             {
  100.                 $this->{'style'"color: #{$mi_color};";
  101.             }
  102.             parent::add($mi_class);
  103.         }
  104.         else if (substr($source,0,4== 'http')
  105.         {
  106.             parent::__construct('img');
  107.             // assign the image path
  108.             $this->{'src'$source;
  109.             $this->{'border'0;
  110.         }
  111.         else if (file_exists($source))
  112.         {
  113.             parent::__construct('img');
  114.             // assign the image path
  115.             $this->{'src'$source;
  116.             $this->{'border'0;
  117.         }
  118.         else if (substr($source,0,12== 'download.php')
  119.         {
  120.             parent::__construct('img');
  121.             // assign the image path
  122.             $this->{'src'$source;
  123.             $this->{'border'0;
  124.         }
  125.         else if (file_exists("app/images/{$source}"))
  126.         {
  127.             parent::__construct('img');
  128.             // assign the image path
  129.             $this->{'src'"app/images/{$source}";
  130.             $this->{'border'0;
  131.         }
  132.         else if (file_exists("lib/adianti/images/{$source}"))
  133.         {
  134.             parent::__construct('img');
  135.             // assign the image path
  136.             $this->{'src'"lib/adianti/images/{$source}";
  137.             $this->{'border'0;
  138.         }
  139.         else
  140.         {
  141.             parent::__construct('i');
  142.         }
  143.     }
  144. }