Exemplo n.º 1
0
 public function action_manage_pages($id = 0)
 {
     if (!$id || !ctype_digit((string) $id)) {
         throw new NotFoundHttpException();
     }
     try {
         $release_bulk = $this->release_factory->getById($id);
     } catch (SeriesNotFoundException $e) {
         throw new NotFoundHttpException();
     }
     if ($this->getPost() && !$this->checkCsrfToken()) {
         $this->notices->set('warning', _i('The security token was not found. Please try again.'));
     } elseif ($this->getPost()) {
         var_dump($this->getRequest()->files->count());
         try {
             $this->page_factory->addFromFileArray($release_bulk, $this->getRequest()->files->all());
         } catch (PageUploadException $e) {
             $this->notices->set('warning', $e->getMessage());
         }
         if (isset($result['error'])) {
             $this->notices->set('warning', $result['error']);
         } else {
             $this->notices->set('success', _i('The pages were uploaded successfully'));
             return $this->redirect('admin/reader/manage_pages/' . $id);
         }
     }
     $this->page_factory->fillReleaseBulk($release_bulk);
     $this->param_manager->setParam('method_title', [_i('Manage pages')]);
     $this->builder->createPartial('body', 'reader/manage_pages')->getParamManager()->setParam('release_bulk', $release_bulk);
     return new Response($this->builder->build());
 }
Exemplo n.º 2
0
 /**
  * Returns the content of a release and the parent series
  *
  * @param int $id The ID of a series
  *
  * @return PageBulk The bulk object with the series data object inside
  * @throws PageNotFoundException If the ID doesn't correspond to a release
  */
 public function getById($id)
 {
     $dc = $this->dc;
     $result = $dc->qb()->select('*')->from($dc->p('pages'), 'p')->where('id = :id')->setParameter(':id', $id)->execute()->fetch();
     if (!$result) {
         throw new PageNotFoundException(_i('The page could not be found.'));
     }
     $release_bulk = $this->release_factory->getById($result['release_id']);
     $page_data = new PageData();
     $page_data->import($result);
     return PageBulk::forge($release_bulk->series, $release_bulk->release, $page_data);
 }