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

Documentation is available at TDBEntry.php

  1. <?php
  2. namespace Adianti\Widget\Wrapper;
  3.  
  4. use Adianti\Core\AdiantiCoreTranslator;
  5. use Adianti\Widget\Base\TElement;
  6. use Adianti\Widget\Base\TScript;
  7. use Adianti\Widget\Form\TEntry;
  8. use Adianti\Database\TCriteria;
  9.  
  10. use Exception;
  11.  
  12. /**
  13.  * Database Entry Widget
  14.  *
  15.  * @version    7.4
  16.  * @package    widget
  17.  * @subpackage wrapper
  18.  * @author     Pablo Dall'Oglio
  19.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  20.  * @license    http://www.adianti.com.br/framework-license
  21.  */
  22. class TDBEntry extends TEntry
  23. {
  24.     protected $minLength;
  25.     protected $service;
  26.     protected $displayMask;
  27.     private $database;
  28.     private $model;
  29.     private $column;
  30.     private $operator;
  31.     private $orderColumn;
  32.     private $criteria;
  33.     
  34.     /**
  35.      * Class Constructor
  36.      * @param  $name     widget's name
  37.      * @param  $database database name
  38.      * @param  $model    model class name
  39.      * @param  $value    table field to be listed in the combo
  40.      * @param  $ordercolumn column to order the fields (optional)
  41.      * @param  $criteria criteria (TCriteria object) to filter the model (optional)
  42.      */
  43.     public function __construct($name$database$model$value$orderColumn NULLTCriteria $criteria NULL)
  44.     {
  45.         // executes the parent class constructor
  46.         parent::__construct($name);
  47.         
  48.         $value trim($value);
  49.         
  50.         if (empty($database))
  51.         {
  52.             throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required''database'__CLASS__));
  53.         }
  54.         
  55.         if (empty($model))
  56.         {
  57.             throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required''model'__CLASS__));
  58.         }
  59.         
  60.         if (empty($value))
  61.         {
  62.             throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required''value'__CLASS__));
  63.         }
  64.         
  65.         $this->minLength = 1;
  66.         $this->database $database;
  67.         $this->model $model;
  68.         $this->column $value;
  69.         $this->displayMask = '{'.$value.'}';
  70.         $this->operator null;
  71.         $this->orderColumn = isset($orderColumn$orderColumn NULL;
  72.         $this->criteria $criteria;
  73.         $this->service = 'AdiantiAutocompleteService';
  74.     }
  75.     
  76.     /**
  77.      * Define the display mask
  78.      * @param $mask Show mask
  79.      */
  80.     public function setDisplayMask($mask)
  81.     {
  82.         $this->displayMask = $mask;
  83.     }
  84.     
  85.     /**
  86.      * Define the search service
  87.      * @param $service Search service
  88.      */
  89.     public function setService($service)
  90.     {
  91.         $this->service = $service;
  92.     }
  93.     
  94.     /**
  95.      * Define the minimum length for search
  96.      */
  97.     public function setMinLength($length)
  98.     {
  99.         $this->minLength = $length;
  100.     }
  101.     
  102.     /**
  103.      * Define the search operator
  104.      * @param $operator Search operator
  105.      */
  106.     public function setOperator($operator)
  107.     {
  108.         $this->operator $operator;
  109.     }
  110.     
  111.     /**
  112.      * Shows the widget
  113.      */
  114.     public function show()
  115.     {
  116.         parent::show();
  117.         
  118.         $min $this->minLength;
  119.         $orderColumn = isset($this->orderColumn$this->orderColumn $this->column;
  120.         $criteria '';
  121.         if ($this->criteria)
  122.         {
  123.             $criteria base64_encode(serialize($this->criteria));
  124.         }
  125.         
  126.         $seed APPLICATION_NAME.'s8dkld83kf73kf094';
  127.         $hash md5("{$seed}{$this->database}{$this->column}{$this->model}");
  128.         $length = $this->minLength;
  129.         
  130.         $class $this->service;
  131.         $callback array($class'onSearch');
  132.         $method $callback[1];
  133.         $url "engine.php?class={$class}&method={$method}&static=1&database={$this->database}&column={$this->column}&model={$this->model}&orderColumn={$orderColumn}&criteria={$criteria}&operator={$this->operator}&hash={$hash}&mask={$this->displayMask}";
  134.         
  135.         TScript::create(" tdbentry_start( '{$this->name}', '{$url}', '{$min}' );");
  136.     }