class wsDAOBook extends commonDAO {
+ public static $pagesOfBookCache = array();
+
/**
* wsDAOBook::singleton()
*
$c->update('WHERE book_id=\'' . $this->con->escape($data['book_id']) . '\'');
}
+ if (isset(self::$pagesOfBookCache[$book_id])) {
+ unset(self::$pagesOfBookCache[$book_id]);
+ }
+
return $this->selectById($book_id);
}
}
public function getPagesOfBook($book_id, $conversion = true) {
- $pages = array();
+ if (!isset(self::$pagesOfBookCache[$book_id])) {
- $sql = 'SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages,d.version AS version FROM book_pages b JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page';
- $r = $this->con->select($sql);
- while ($r->fetch()) {
- $n = explode(',', $r->num);
+ $pages = array();
- if (isset($n[$r->document_page - 1])) {
- $num = $n[$r->document_page - 1];
- } else {
- $num = '';
- }
- $pages[$r->book_page] = array('document_id' => $r->document_id,
- 'document_page' => $r->document_page,
- 'version' => $r->version,
- 'defaultNum' => $num,
- 'nb_pages' => $r->doc_pages
- );
-
- if ($conversion) {
- if ($r->conversion != '') {
- $c = unserialize($r->conversion);
- $c = $c->pages[$r->document_page];
+ $sql = 'SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages,d.version AS version FROM book_pages b JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page';
+
+ $r = $this->con->select($sql);
+ while ($r->fetch()) {
+ $n = explode(',', $r->num);
+
+ if (isset($n[$r->document_page - 1])) {
+ $num = $n[$r->document_page - 1];
+ } else {
+ $num = '';
}
- $qp = array('resolution', 'method', 'quality', 'objects');
- foreach ($qp as $p) {
- if (isset($c) && isset($c->$p)) {
- $pages[$r->book_page][$p] = $c->$p;
+ $pages[$r->book_page] = array('document_id' => $r->document_id,
+ 'document_page' => $r->document_page,
+ 'version' => $r->version,
+ 'defaultNum' => $num,
+ 'nb_pages' => $r->doc_pages
+ );
+
+ if ($conversion) {
+ if ($r->conversion != '') {
+ $c = unserialize($r->conversion);
+ $c = $c->pages[$r->document_page];
+ }
+ $qp = array('resolution', 'method', 'quality', 'objects');
+ foreach ($qp as $p) {
+ if (isset($c) && isset($c->$p)) {
+ $pages[$r->book_page][$p] = $c->$p;
+ }
}
}
}
+
+ self::$pagesOfBookCache[$book_id] = $pages;
}
- return $pages;
+ return self::$pagesOfBookCache[$book_id];
}
public function appendDocument($book_id, $document_id) {
public function getURL() {
- switch($this->video_service) {
- case 1: // Dailymotion
- return '#/webvideo/dailymotion/' . $this->to;
- break;
- case 2: // Vimeo
- return '#/webvideo/vimeo/' . $this->to;
- break;
- default:
- return '#/video/' . $this->to;
- }
+ switch ($this->video_service) {
+ case 1: // Dailymotion
+ return '#/webvideo/dailymotion/' . $this->to;
+ break;
+ case 2: // Vimeo
+ return '#/webvideo/vimeo/' . $this->to;
+ break;
+ default:
+ return '#/video/' . $this->to;
+ }
}
public function getAdditionnalContent() {
}
public function generateImage() {
+ $this->compiler->log('Before generating image');
+
$left = CubeIT_Files::tempnam();
$p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page);
+ $this->compiler->log('Got document page');
$pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf';
-
+ $this->compiler->log('Got pdf original');
$leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
$p['document_page'],
array('x' => $this->left, 'y' => $this->top, 'width' => $this->width, 'height' => $this->height),
$left, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/');
+ $this->compiler->log('Left file generated');
+
$bookwidth = $this->compiler->book->parametres->width;
if (($this->left + $this->width) > $bookwidth) {
array('x' => 0, 'y' => $this->top, 'width' => $diff, 'height' => $this->height),
$right, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/');
+ $this->compiler->log('Left file generated');
+
$both = CubeIT_Files::tempnam() . '.jpg';
CubeIT_CommandLine_Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
+
+ $this->compiler->log('Both files assembled');
} else {
$both = $leftfile;
}
$this->compiler->simpleCopyLinkFile($both, 'data/links/zoom_' . $this->id . '.jpg');
+ $this->compiler->log('Files copied');
// Perform tidy up and delete temporary files if they exist
$files_to_delete = ['left', 'leftfile', 'right', 'rightfile', 'both'];
unlink($$file);
}
}
+ $this->compiler->log('Files cleaned up');
}