Esempio n. 1
0
 public function actionPreviewPage($id)
 {
     $file = FilesModel::getFile($id);
     if (!$file) {
         throw new BadRequestException("File not found", 404);
     }
     if (!$this->triggerEvent('allowFileDownload', $file)) {
         throw new BadRequestException("File download forbidden", 403);
     }
     $this->template->file = $file;
     $this->setLayout(false);
     //experimental for documentFile
     $xml = substr($file->info, 5);
     $sxml = simplexml_load_string($xml);
     //TODO proč nefunguje vždy?
     $pages = array();
     if ($sxml && $sxml->page) {
         foreach ($sxml->page as $p) {
             $page = array($p, array());
             foreach ($p->block as $b) {
                 foreach ($b->text as $t) {
                     $page[1][] = $t;
                 }
             }
             $pages[] = $page;
         }
     }
     $this->template->pdf2xml = $pages;
 }
Esempio n. 2
0
 public function editFileFormSubmitted(AppForm $form)
 {
     if (!$this->presenter->editAllowed()) {
         return;
     }
     $values = (array) $form->values;
     $values['id_page'] = $values['id_page_change'];
     //fix - after submitting changing $id_page
     unset($values['id_page_change']);
     $file = FilesModel::getFile($values['id']);
     $file->save($values);
     $this->presenter->flashMessage("Popis souboru #{$file->id} uložen");
     $this->invalidateControl('editform_filelist');
     //TODO (ask) zrušit submitted signál (jak redirect na action?)
     $this->handleEditFile($file->id);
     //fill form
     if (!$this->presenter->isAjax()) {
         $this->redirect('this#toc-files');
     }
 }
Esempio n. 3
0
 public function npMacroControlOptions($macro)
 {
     //TODO combine with Front_BasePresenter (extract to class NpMacros)
     if (preg_match('~^file-([0-9]+)(_.+)?$~', $macro[1], $m)) {
         return "#-file-{$m['1']}" . FilesModel::getFile($m[1])->getControlMacroOptions(isset($m[2]) ? $m[2] : NULL) . "-#";
     } else {
         return $macro[0];
     }
 }
Esempio n. 4
0
 function fileMacro($opts)
 {
     $opts = explode('_', $opts);
     $id = array_shift($opts);
     return FilesModel::getFile($id)->getControlHtml($opts);
 }