protected $out;
protected $in;
protected $html;
+ protected $mf;
protected $uncompressed;
protected $log;
protected $common_log_pointer;
$this->out = wsDocument::getDir($this->document_id);
$this->log = $this->out . '/logs/';
$this->html = $this->out . '/html/';
+ $this->mf = $this->out . '/mf/';
$this->in = $this->out . 'original.pdf';
$this->uncompressed = $this->out . 'uncompressed.pdf';
$this->infos = $this->out . 'infos.txt';
if (!file_exists($this->html)) {
mkdir($this->html, 0755);
}
+ if (!file_exists($this->mf)) {
+ mkdir($this->mf, 0777);
+ }
+
$this->cropped = $this->out . 'crop.pdf';
$this->pages_log_pointers = array();
- if (is_null($this->conversionInfos)) {
+ if ($this->conversionInfos === null) {
$this->conversionInfos = new wsDocumentConversionInfos();
}
}
$this->addToLog('Processing page #' . $page);
$this->makeMiniShot($page);
$this->makeSWFFiles($page);
- $this->makeHTML5Files($page);
}
}
return sqrt($a4surface / $docSurface);
}
+ public function getMobileFirstRatio()
+ {
+ return 0.48 * (620 / $this->generalInfos['size'][0]);
+ }
+
public function makeMiniShot($page)
{
$this->makeShotFixedWidth($page, 'p', 500, 65, 4, 'PNM');
public function makeShot($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'PNM', $in = null)
{
$error = false;
- if (is_null($in)) {
+ if ($in === null) {
$in = $this->getCroppedPDF();
}
// Delete all old files
$this->makeSVGFile($page);
}
+ public function makeMobileFirstFiles($page)
+ {
+ // Then make HD background shots
+ $resolutions = array(300 => 85, 150 => 85, 36 => 85);
+ $rratio = $this->getMobileFirstRatio();
+ foreach ($resolutions as $r => $q) {
+ $this->makeShotPNM($page, 'mf/h' . $r . '-', $r * $rratio, $q, 4, null, false);
+ $this->makeShotPNM($page, 'mf/t' . $r . '-', $r * $rratio, $q, 4, null, true);
+ }
+ }
+
public function makeSVGFile($page)
{
$svgFile = $this->out . '/html/fp' . $page . '.svg';
self::$_docsDir[$id] = $new;
return $new;
}
+
+ public static function makeHTML5FilesIfNotExists($document_id, $document_page)
+ {
+ global $core;
+
+ $path = self::getDir($document_id) . '/html/h150-' . $document_page . '.jpg';
+ if (!file_exists($path)) {
+ $dao = new wsDAODocument($core->con);
+ $doc = $dao->selectById($document_id);
+ $doc->makeHTML5Files($document_page);
+ }
+ }
+
+ public static function makeMobileFirstFilesIfNotExists($document_id, $document_page)
+ {
+ global $core;
+
+ $path = self::getDir($document_id) . '/mf/h150-' . $document_page . '.jpg';
+ if (!file_exists($path)) {
+ $dao = new wsDAODocument($core->con);
+ $doc = $dao->selectById($document_id);
+ $doc->makeMobileFirstFiles($document_page);
+ }
+ }
}
\ No newline at end of file
$this->width = round($size[0], 3);
$this->height = round($size[1], 3);
- $imagesize = CubeIT_Image::getimagesize(wsDocument::getDir($this->pages[1]['document_id']) . 'html/h150-' . $this->pages[1]['document_page'] . '.jpg');
+ wsDocument::makeHTML5FilesIfNotExists($this->pages[1]['document_id'], $this->pages[1]['document_page']);
+ $firstJpeg = wsDocument::getDir($this->pages[1]['document_id']) . 'html/h150-' . $this->pages[1]['document_page'] . '.jpg';
+
+ $imagesize = CubeIT_Image::getimagesize($firstJpeg);
$this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 3);
$this->cssScale = $this->z * min($this->optimalWidth / $this->width, $this->optimalHeight / $this->height);
$rasterizePages = $this->config->rasterizePages;
$this->config->pagesDimensions = [];
+ if ($this->book->parametres->mobileNavigationType === 'mobilefirst') {
+ $makeFunction = 'makeMobileFirstFilesIfNotExists';
+ $imdir = 'mf';
+ } else {
+ $makeFunction = 'makeHTML5FilesIfNotExists';
+ $imdir = 'html';
+ }
+
$thumbs = array();
foreach ($this->pages as $page => $infos) {
$docdir = wsDocument::getDir($infos['document_id']);
$thisimagesvg = !$thisrasterize && $this->svg;
$thisbackgroundPrefix = $thisrasterize ? ['t'] : $this->backgroundsPrefix;
+ wsDocument::$makeFunction($infos['document_id'], $infos['document_page']);
+
foreach ($this->getResolutions() as $r) {
foreach ($thisbackgroundPrefix as $backgroundsPrefix) {
$srcPrefix = $backgroundsPrefix;
- if ($backgroundsPrefix == 'p') {
+ if ($backgroundsPrefix === 'p') {
$srcPrefix = 'h';
}
- $source = $docdir . 'html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg';
- if (!file_exists($source)) {
- if (!isset($doc) || $doc->document_id != $infos['document_id']) {
- $dao = new wsDAODocument($core->con);
- $doc = $dao->selectById($infos['document_id']);
- }
- $doc->makeHTML5Files($infos['document_page']);
- }
+ $source = $docdir . $imdir . '/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg';
if ($r == 150 && file_exists($source)) {
$d = getimagesize($source);
$this->config->pagesDimensions[$page] = array($this->cssWidth, $d[1] * ($this->cssWidth / $d[0]));