/** * @return Nette\Application\UI\Form */ protected function createComponentServerProps() { $form = new Form(); $form->addTextArea('props', '', 70, 36); $form->addSubmit('submit', 'Nastavit')->setAttribute('class', 'ajax'); try { $value = $this->fileModel->open($this->filePath, FALSE); $form->setValues(array('props' => implode('', $value))); } catch (\Nette\FileNotFoundException $e) { $form->setValues(array('props' => 'Soubor ještě nebyl vytvořen!')); $form['submit']->setDisabled(); } if (!$this->allowedToEdit) { $form['submit']->setDisabled(); } $form->onSuccess[] = $this->serverPropsFormSubmitted; return $form; }
/** * @param string $path * @return array suitable for json */ private function readOpsFromFile($path, $file) { try { $opsFile = $this->fileModel->open($path . $file, FALSE); $json = json_decode(implode('', $opsFile)); $ops = array(); if ($json != NULL) { foreach ($json as $record) { $ops[] = array('uuid' => $record->uuid, 'name' => $record->name, 'level' => $record->level); } return $ops; } else { return array(); } } catch (\Nette\FileNotFoundException $ex) { return array(); } }