Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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);
             }
         }
     }
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
    $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();
Esempio n. 6
0
 protected function getEmptyRiesitel($riesitel)
 {
     $result = \FlatArray::toArray($riesitel);
     $result['meskanie'] = 0;
     $result['bonus'] = 0;
     return $result;
 }