コード例 #1
0
ファイル: TypStudiaSource.php プロジェクト: hleumas/databaza
 public function getAll()
 {
     if (!$this->cachedAll) {
         $pairs = $this->_dbConnection->table(self::TABLE)->fetchPairs('id');
         $this->cache = FlatArray::toArray($pairs);
         $this->cachedAll = true;
     }
     return $this->cache;
 }
コード例 #2
0
ファイル: DisplayRenderer.php プロジェクト: hleumas/databaza
 public function render(\Nette\Forms\Form $form, $mode = null)
 {
     $content = Html::el('div class="details"');
     foreach ($form->getGroups() as $group) {
         if (!$group->getControls() || !$group->getOption('visual')) {
             continue;
         }
         $elgroup = $content->create('div class="viewGroup"');
         $grouplabel = $group->getOption('label');
         if (!is_string($grouplabel)) {
             $grouplabel = $grouplabel->getText();
         }
         $elgroup->create('h5', $grouplabel);
         $el = $elgroup->create('dl');
         foreach ($group->getControls() as $control) {
             if ($control instanceof \Nette\Forms\Controls\HiddenField || $control instanceof \Nette\Forms\Controls\Button) {
                 continue;
             }
             $label = $control->getLabel();
             if (!is_string($label)) {
                 $label = $label->getText();
             }
             $el->create('dt', $label);
             $value = $control->getValue();
             if ($control instanceof \Nette\Forms\Controls\Checkbox) {
                 if ($value) {
                     $el->create('dd')->create('span class="yes"');
                 } else {
                     $el->create('dd')->create('span class="no"');
                 }
             } elseif ($control instanceof \Nette\Forms\Controls\SelectBox) {
                 $items = FlatArray::getLeafs($control->getItems());
                 if (!isset($items[$value])) {
                     $el->create('dd class="na"', 'n/a');
                     continue;
                 }
                 $value = $items[$value];
                 if (!is_string($value)) {
                     $value = $value->getTitle();
                 }
                 $el->create('dd', $value);
             } else {
                 if ($value instanceof \Nette\DateTime) {
                     $value = $value->format('j.n.Y');
                 }
                 if ($value !== '') {
                     $el->create('dd', $value);
                 } else {
                     $el->create('dd class="na"', 'n/a');
                 }
             }
         }
         $elgroup->create('div style="{clear: both;}"');
     }
     return $content;
 }
コード例 #3
0
ファイル: Vysledkovka.php プロジェクト: hleumas/databaza
 private function addRiesitelia(&$data, $riesitelia, $serie)
 {
     foreach ($riesitelia as $riesitel) {
         $data[$riesitel['seria_id']][$riesitel['id']] = \FlatArray::toArray($riesitel);
         foreach ($serie as $seria) {
             if (!isset($data[$seria][$riesitel['id']])) {
                 $data[$seria][$riesitel['id']] = $this->getEmptyRiesitel($riesitel);
             }
         }
     }
 }
コード例 #4
0
ファイル: SkolyPresenter.php プロジェクト: hleumas/databaza
 public function onSubmit()
 {
     $form = $this['form'];
     $record = new \SkolaRecord(\FlatArray::inflate($form->getValues()));
     $record['adresa']['stat'] = 'SR';
     if (!empty($record['id'])) {
         $this->context->sources->skolaSource->update($record);
         $this['grid']->flashMessage("Zmenená škola {$record['nazov']}");
     } else {
         $this->context->sources->skolaSource->insert($record);
         $this['grid']->flashMessage("Pridaná škola {$record['nazov']}");
     }
     $this->redirect('this');
 }
コード例 #5
0
ファイル: CommonSource.php プロジェクト: hleumas/databaza
 /**
  * Get the record by id
  *
  * @param string $id
  *
  * @return array
  */
 public function getById($id)
 {
     $fetch = $this->whereId($id)->fetch();
     if ($fetch === false) {
         throw new InvalidIdException("Id {$id} was not found in database");
     }
     $data = FlatArray::toArray($fetch);
     foreach ($this->propertySource as $property => $source) {
         $property_id = "{$property}_id";
         if (!isset($data[$property_id]) || is_null($data[$property_id])) {
             continue;
         }
         $data[$property] = $source->getById($data[$property_id]);
         unset($data[$property_id]);
     }
     return $data;
 }
コード例 #6
0
 public function onSubmit()
 {
     $sources = $this->context->sources;
     $record = new \RiesitelRecord(\FlatArray::inflate($this['form']->values));
     if ($record['koresp_kam'] != \RiesitelRecord::KORESP_ELSE) {
         $record['koresp_adresa'] = null;
     } else {
         $record['koresp_adresa']['stat'] = 'SR';
     }
     $record['osoba']['adresa']['stat'] = 'SR';
     $record['typ_studia'] = $sources->typStudiaSource->getById($record['typ_studia']);
     $record['datum'] = new \Nette\DateTime();
     $osoba = $record['osoba'];
     if (!empty($record['id'])) {
         $sources->riesitelSource->update($record);
         $this['grid']->flashMessage("Zmenený riešiteľ {$osoba['meno']} {$osoba['priezvisko']}");
     } else {
         $sources->riesitelSource->insert($record);
         $this['grid']->flashMessage("Pridaný riešiteľ {$osoba['meno']} {$osoba['priezvisko']}");
     }
     $this->redirect('this');
 }
コード例 #7
0
ファイル: SeriaSelector.php プロジェクト: hleumas/databaza
 public function createComponentForm()
 {
     $form = new Form();
     $form->setMethod('get')->setAction($this->parent->link('this'));
     $semestre = FlatArray::toArray($this->semesterSource->getAll());
     $serie = $this->seriaSource->getAll();
     $items = array();
     foreach ($semestre as &$sem) {
         $sem['serie'] = array();
     }
     foreach ($serie as $seria) {
         $semestre[$seria['semester']]['serie'][] = $seria;
     }
     foreach ($semestre as $semester) {
         $name = "{$semester['rok']} " . ($semester['cast'] == 1 ? 'leto' : 'zima');
         $items[$name] = array();
         foreach ($semester['serie'] as $seria) {
             $items[$name][$seria['id']] = "{$seria['cislo']}. séria";
         }
     }
     $form->addSelect('seria', 'Séria:', $items)->setValue($this->selected);
     $form->addSubmit('submit', 'Načítaj');
     return $form;
 }
コード例 #8
0
ファイル: UdajePresenter.php プロジェクト: hleumas/databaza
 public function createRiesitelRecord($udajeForm)
 {
     $sources = $this->context->sources;
     $record = new \RiesitelRecord(\FlatArray::inflate($udajeForm->values));
     if ($record['koresp_kam'] != \RiesitelRecord::KORESP_ELSE) {
         $record['koresp_adresa'] = null;
     } else {
         $record['koresp_adresa']['stat'] = 'SR';
     }
     $record['osoba']['adresa']['stat'] = 'SR';
     $record['typ_studia'] = $sources->typStudiaSource->getById($record['typ_studia']);
     $record['datum'] = new \Nette\DateTime();
     return $record;
 }
コード例 #9
0
 public function submitOboduj()
 {
     $this['grid']->flashMessage('Nahodené body');
     $form = $this['obodujForm'];
     $values = \FlatArray::inflate($form->values);
     foreach ($values['riesitel'] as $id => $body) {
         if ($body === '') {
             $body = null;
         }
         $this->context->sources->riesitelSeriaSource->setPrikladById($id, $values['priklad'], $body);
     }
     $this->redirect('default');
 }
コード例 #10
0
ファイル: bootstrap.php プロジェクト: hleumas/databaza
    $s->params['database'] = $cont->database;
    return $s;
});
$configurator->container->addService('authenticator', function ($cont) {
    return new \Authenticator($cont->database);
});
$routes = $configurator->container->params['routes'];
// Configure application
$application = $configurator->container->application;
$application->errorPresenter = 'Error';
//$application->catchExceptions = TRUE;
// Setup router
$application->onStartup[] = function () use($application, $routes) {
    $router = $application->getRouter();
    foreach ($routes as $route) {
        $metadata = \FlatArray::toArray($route['metadata']);
        $router[] = new Route("//{$route['prefix']}/index.php", $metadata, Route::ONE_WAY);
        $mask = "//{$route['prefix']}/<presenter>/<action>[/<id>]";
        if ($route['secured']) {
            $router[] = new Route($mask, $metadata, Route::SECURED);
        } else {
            $router[] = new Route($mask, $metadata);
        }
    }
};
Nette\Forms\Container::extensionMethod('addDatePicker', function ($container, $name, $label = NULL) {
    return $container[$name] = new Forms\Controls\DatePicker($label);
});
// Run the application!
if (!$configurator->container->params['consoleMode']) {
    $application->run();
コード例 #11
0
ファイル: FKSVysledkovka.php プロジェクト: hleumas/databaza
 protected function getEmptyRiesitel($riesitel)
 {
     $result = \FlatArray::toArray($riesitel);
     $result['meskanie'] = 0;
     $result['bonus'] = 0;
     return $result;
 }
コード例 #12
0
 public function onSubmit()
 {
     $riesitelSource = $this->context->sources->riesitelSeriaSource;
     $data = \FlatArray::inflate($this['form']->getValues());
     $record = new \RiesitelSeriaRecord($data);
     foreach ($data['priklad'] as $key => $priklad) {
         if ($priklad) {
             $record[$key] = null;
         }
     }
     $this->context->sources->riesitelSeriaSource->insert($record);
     $this['grid']->flashMessage('Odobálkovaný riešiteľ');
     $this->redirect('this');
 }
コード例 #13
0
ファイル: FlatArrayTest.php プロジェクト: hleumas/databaza
 /**
  * @dataProvider flatProvider
  */
 public function testInflate($flat, $inflat)
 {
     $this->assertEquals(FlatArray::inflate($flat), $inflat);
 }