Exemple #1
0
 protected function afterInit()
 {
     parent::afterInit();
     if (!$this->isValid()) {
         $this->cfg->classLine .= ' fileError';
     }
 }
Exemple #2
0
 /**
  * Initialize the list and group with a sql request if provided
  */
 protected function afterInit()
 {
     parent::afterInit();
     if (!$this->cfg->uniqValue) {
         $this->cfg->name .= '[]';
     }
     $dbList = $this->cfg->dbList;
     if (is_array($dbList) && $dbList['table']) {
         $list = $this->cfg->list;
         if (!$list) {
             $list = array();
         }
         $group = $this->cfg->group;
         if (!$group) {
             $group = array();
         }
         $db = db::getInstance();
         $values = $db->select(array_merge($dbList, array('result' => PDO::FETCH_ASSOC)));
         $tmp = null;
         foreach ($values as $v) {
             $key = array_shift($v);
             if ($dbList['nbFieldGr'] > 0) {
                 $arr = utils::cutArray($v, $dbList['nbFieldGr']);
                 $tmp2 = implode($dbList['sepGr'], $arr[0]);
                 if ($tmp != $tmp2) {
                     $group[$key] = $tmp2;
                     $tmp = $tmp2;
                 }
                 $v = $arr[1];
             }
             if (empty($v)) {
                 $v = array($key);
             }
             $list[$key] = implode($dbList['sep'], $v);
         }
         $this->cfg->group = utils::htmlOut($group);
         $this->cfg->list = utils::htmlOut($list);
     } else {
         if ($this->cfg->needOut) {
             $this->cfg->list = utils::htmlOut($this->cfg->list, true);
         }
     }
     if (is_array($this->cfg->list)) {
         $this->addRule('in', array_keys($this->cfg->list));
     }
 }
Exemple #3
0
 protected function afterInit()
 {
     parent::afterInit();
     $this->date = factory::getHelper('date', array('timestamp' => $this->cfg->value ? strtotime($this->cfg->value) : time(), 'defaultFormat' => array('type' => 'date', 'len' => 'mysql')));
 }