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

Documentation is available at TIcon.php

  1. <?php
  2. namespace Adianti\Widget\Form;
  3.  
  4. use Adianti\Widget\Form\AdiantiWidgetInterface;
  5. use Adianti\Widget\Base\TElement;
  6. use Adianti\Widget\Base\TScript;
  7. use Adianti\Widget\Form\TEntry;
  8. use Adianti\Control\TAction;
  9.  
  10. /**
  11.  * Color Widget
  12.  *
  13.  * @version    7.4
  14.  * @package    widget
  15.  * @subpackage form
  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 TIcon extends TEntry implements AdiantiWidgetInterface
  21. {
  22.     protected $id;
  23.     protected $changeFunction;
  24.     protected $formName;
  25.     protected $name;
  26.     
  27.     /**
  28.      * Class Constructor
  29.      * @param $name Name of the widget
  30.      */
  31.     public function __construct($name)
  32.     {
  33.         parent::__construct($name);
  34.         $this->id = 'ticon_'.mt_rand(10000000001999999999);
  35.         $this->tag->{'autocomplete''off';
  36.     }
  37.     
  38.     /**
  39.      * Enable the field
  40.      * @param $form_name Form name
  41.      * @param $field Field name
  42.      */
  43.     public static function enableField($form_name$field)
  44.     {
  45.         TScript::create" ticon_enable_field('{$form_name}', '{$field}'); );
  46.     }
  47.     
  48.     /**
  49.      * Disable the field
  50.      * @param $form_name Form name
  51.      * @param $field Field name
  52.      */
  53.     public static function disableField($form_name$field)
  54.     {
  55.         TScript::create" ticon_disable_field('{$form_name}', '{$field}'); );
  56.     }
  57.     
  58.     /**
  59.      * Set change function
  60.      */
  61.     public function setChangeFunction($function)
  62.     {
  63.         $this->changeFunction $function;
  64.     }
  65.  
  66.     /**
  67.      * Shows the widget at the screen
  68.      */
  69.     public function show()
  70.     {
  71.         $wrapper new TElement('div');
  72.         $wrapper->{'class''input-group';
  73.         $span new TElement('span');
  74.         $span->{'class''input-group-addon';
  75.         
  76.         if (!empty($this->exitAction))
  77.         {
  78.             $this->setChangeFunction$this->changeFunction "; tform_fire_field_actions('{$this->formName}', '{$this->name}'); );
  79.         }
  80.         
  81.         $i new TElement('i');
  82.         $span->add($i);
  83.         
  84.         if (strstr((string) $this->size'%'!== FALSE)
  85.         {
  86.             $outer_size $this->size;
  87.             $this->size '100%';
  88.             $wrapper->{'style'"width: $outer_size";
  89.         }
  90.         
  91.         ob_start();
  92.         parent::show();
  93.         $child ob_get_contents();
  94.         ob_end_clean();
  95.         
  96.         $wrapper->add($child);
  97.         $wrapper->add($span);
  98.         $wrapper->show();
  99.         
  100.         if (parent::getEditable())
  101.         {
  102.             if($this->changeFunction)
  103.             {
  104.                 TScript::create(" ticon_start('{$this->id}',function(icon){ {$this->changeFunction} }); ");   
  105.             }
  106.             else
  107.             {
  108.                 TScript::create(" ticon_start('{$this->id}',false); ");
  109.             }
  110.         }
  111.     }
  112. }