/**
  * Generate selected category book and save it
  * 
  * @var int $page Current page
  * @var int $id   Category ID
  * @var string $pageEormat передается пользрвателем либо A5 либо A4
  * @var string $print передается пользователем либо true либо false
  */
 public function bycategoryAction()
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         throw new Zend_Exception("Page not found", 404);
     }
     set_time_limit(3600);
     $this->_helper->layout->disableLayout();
     $page = $this->getRequest()->getParam("page");
     $categoryId = $this->getRequest()->getParam("id");
     $exceptionList = $this->getRequest()->getParam("except");
     $this->secondTime = (int) $this->getRequest()->getParam("second_time");
     $pageFormat = $this->getRequest()->getParam("pageFormat");
     $print = $this->getRequest()->getParam("print");
     $pdfBook = new Model_Static_PdfBook($pageFormat, $print);
     $categoriesModel = new Model_DbTable_Categories();
     $pdfBook->logger = new Zend_Log();
     $pdfBook->logWriter = new Zend_Log_Writer_Stream(APPLICATION_ROOT . '/book.log');
     $pdfBook->logger->addWriter($pdfBook->logWriter);
     $pdfBook->logger->log('get params', Zend_Log::INFO);
     $category = $categoriesModel->find($categoryId)->current();
     $pdfBook->logger->log('get oject category', Zend_Log::INFO);
     $pdfBook->exceptionProductList = $this->getRequest()->getParam("except_products");
     $pdfBook->logger->log('get params product', Zend_Log::INFO);
     //передаем id категории и запускаем процесс генерации данной категории
     $book = $pdfBook->byCategory($category, $page, $exceptionList, $this->secondTime);
     $pdfBook->logger->log('Return generated pdfBook', Zend_Log::INFO);
     $topParent = $category->findTopParent();
     $pdfBook->addCategoryToIndex($topParent->id, $page, 0);
     $pdfBook->addCategoryToIndex($category->parent_id, $page, 1);
     //завершение  генерации одной категории
     $this->view->nextpage = $book->end_pages;
     $this->view->endpage = $this->view->nextpage + count($book->pages);
     $saveFilename = str_repeat("0", 4 - strlen($this->view->nextpage)) . $this->view->nextpage . '-' . ($this->view->endpage - 1) . '.pdf';
     $pdfBook->logger->log('Saving pages', Zend_Log::INFO);
     if ($this->secondTime == 1) {
         $book->save(APPLICATION_ROOT . $this::PDFBOOK_DIR . '/' . $saveFilename);
     }
 }