Example #1
0
 protected function getUniqueValues($array)
 {
     $ret = array();
     foreach ($array as $table => $cols) {
         foreach ($cols as $col) {
             $ret[$table][$col] = Model::getValues($col, $table);
         }
     }
     return $ret;
 }
Example #2
0
 public function getValues()
 {
     return array_merge(parent::getValues(), $this->_variable_values);
 }
Example #3
0
 protected function createComponentForm($name)
 {
     $form = new AppForm();
     //$form->getElementPrototype()->id('editform');
     $form->addText('title', 'Název', 50)->addRule(Form::FILLED, "Jméno je potřeba vyplnit");
     $items = dibi::query('SELECT
     authorId,
     CONCAT_WS(" ", name, surname,', Model::sqlClassName(Model::getSchoolYear()), ') as authorName
     FROM [authors]
     ORDER BY surname, class desc')->fetchPairs();
     $keys = array_keys($items);
     $form->addSelect('author', 'Autor', array("0" => 'Nový') + $items)->setValue($keys[0]);
     $form->addTextArea('text', 'Text')->getControlPrototype()->style = 'width: 100%';
     $form->addSelect('award', 'Ocenění', array("0" => 'Nové') + $this->setKeys(Model::getValues('award', 'works')));
     $form->addText('newAward', '');
     $form->addSelect('year', 'Ročník ChP', $this->generateYears())->setDefaultValue(Model::getSchoolYear());
     $form->addSelect('type', 'Typ', array("0" => 'Nový') + $this->setKeys(Model::getValues('type', 'works')));
     $form->addText('newType', '');
     if ($this->setId == '') {
         $form->addFile('file', "Soubor:");
     }
     $form['newAward']->addConditionOn($form['award'], Form::EQUAL, 0)->addRule(Form::FILLED, 'Pokud nevyberete ocenění, musíte zadat nové');
     $form['newType']->addConditionOn($form['type'], Form::EQUAL, 0)->addRule(Form::FILLED, 'Pokud nevyberete typ, musíte zadat nový');
     $form->addSubmit('ok', 'Přidat práci')->onClick[] = array($this, 'addClicked');
     $form->addHidden("authorId")->setValue('false');
     if ($this->setId != '') {
         $dataSource = dibi::query('SELECT * FROM [works] WHERE workId=%i', $this->setId)->fetch();
         $form->setDefaults($dataSource);
         $form['ok']->onClick = array(array($this, 'saveClicked'));
         $form['ok']->caption = "Uložit práci";
         $form->addHidden("workId")->setValue($this->setId);
     } else {
         $s = Environment::getSession('workform');
         if (isset($s->author) && array_search($s->author, $keys) === FALSE) {
             $s->author = $keys[0];
         }
         if (isset($s->author)) {
             $form->setDefaults($s);
         }
     }
     $this->addComponent($form, $name);
     $form->getRenderer()->wrappers['control']['container'] .= ' class="wide"';
     return;
 }