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

Documentation is available at TDBCheckList.php

  1. <?php
  2. namespace Adianti\Widget\Wrapper;
  3.  
  4. use Adianti\Core\AdiantiCoreTranslator;
  5. use Adianti\Widget\Form\TCheckList;
  6. use Adianti\Database\TTransaction;
  7. use Adianti\Database\TRepository;
  8. use Adianti\Database\TCriteria;
  9.  
  10. use Exception;
  11.  
  12. /**
  13.  * Database Checklist
  14.  *
  15.  * @version    7.4
  16.  * @package    widget
  17.  * @subpackage form
  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 TDBCheckList extends TCheckList
  23. {
  24.     protected $items// array containing the combobox options
  25.     protected $keyColumn;
  26.     protected $valueColumn;
  27.     
  28.     use AdiantiDatabaseWidgetTrait;
  29.     
  30.     /**
  31.      * Class Constructor
  32.      * @param  $name     widget's name
  33.      * @param  $database database name
  34.      * @param  $model    model class name
  35.      * @param  $key      table field to be used as key in the combo
  36.      * @param  $value    table field to be listed in the combo
  37.      * @param  $ordercolumn column to order the fields (optional)
  38.      * @param  $criteria criteria (TCriteria object) to filter the model (optional)
  39.      */
  40.     public function __construct($name$database$model$key$value$ordercolumn NULLTCriteria $criteria NULL)
  41.     {
  42.         // executes the parent class constructor
  43.         parent::__construct($name);
  44.         
  45.         // define the ID column por set/get values from component
  46.         parent::setIdColumn($key);
  47.         
  48.         // value column
  49.         $this->valueColumn = parent::addColumn($value,  '',    'left',  '100%');
  50.         
  51.         // get objects
  52.         $collection $this->getObjectsFromModel($database$model$key$ordercolumn$criteria) );
  53.         
  54.         if (strpos($value'{'!== FALSE)
  55.         {
  56.             // iterate objects to render the value when needed
  57.             TTransaction::open($database);
  58.             if ($collection)
  59.             {
  60.                 foreach ($collection as $key => $object)
  61.                 {
  62.                     if (!isset($object->$value))
  63.                     {
  64.                         $collection[$key]->$value $object->render($value);
  65.                     }
  66.                 }
  67.             }
  68.             TTransaction::close();
  69.         }
  70.         
  71.         parent::addItems($collection);
  72.         
  73.         $head parent::getHead();
  74.         $head->{'style''display:none';
  75.     }
  76. }