$this->fields['OAMChromeFactor'] = ['type' => 'float', 'default' => '1', 'editable' => true, 'label' => __('Facteur OAM Chrome')];
$this->fields['OAMIEFactor'] = ['type' => 'float', 'default' => '1', 'editable' => true, 'label' => __('Facteur OAM IE11')];
$this->forms['multimedia'] = array('label' => __('Liens et multimédia'),
- 'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'linkBlinkRepetition', '|', 'customLinkClass', 'ignoreLinksTypes', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix', '|', 'linkMultimediaPerformanceMode', 'linkMultimediaQuality', '|', 'inlineSlideshowTransitionDuration', 'inlineSlideshowDuration', '|', 'videoReset', 'videoBigPlay', '|', 'brightcovePlayerId', 'brightcovePlayerSecret', '|', 'textPopupStylesheet', 'textPopupWidth', '|', 'iframePopupMaxWidth','|','OAMChromeFactor','OAMIEFactor'));
+ 'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'linkBlinkRepetition', '|', 'customLinkClass', 'ignoreLinksTypes', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix', '|', 'linkMultimediaPerformanceMode', 'linkMultimediaQuality', '|', 'inlineSlideshowTransitionDuration', 'inlineSlideshowDuration', '|', 'videoReset', 'videoBigPlay', '|', 'brightcovePlayerId', 'brightcovePlayerSecret', '|', 'textPopupStylesheet', 'textPopupWidth', '|', 'iframePopupMaxWidth', '|', 'OAMChromeFactor', 'OAMIEFactor'));
//.
+ $this->fields['downloadPortionPDF'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => 'PDF utilisé pour le téléchargement des extraits'];
+ $this->fields['downloadPortionZoom'] = ['type' => 'integer', 'default' => 8, 'editable' => false, 'editable' => true, 'label' => __('Zoom des images extraites')];
+ $this->forms['downloadportion'] = array('label' => __('Téléchargement d\'extraits'),
+ 'fieldsnames' => ['downloadPortionPDF', 'downloadPortionZoom']);
+
$this->fields['product_zoom_references'] = array('type' => 'freefile', 'default' => '', 'editable' => true,
'label' => __('Références produits'), 'grade' => 3, 'fileFilter' => $basketFilter, 'hint' => __('Fichier contenant les références produits'), 'dir' => 'commerce');
case 36:
return new articleLink($id, $init, $compiler);
break;
+ case 37:
+ return new downloadPortionLink($id, $init, $compiler);
default:
return null;
}
}
+class downloadPortionLink extends fileLink
+{
+ public function getURL()
+ {
+ zoomLink::generateImage($this->getZoomAttributes(), $this->compiler, 'downloadportion', 'downloadportion');
+ return 'data/links/downloadportion_' . $this->id . '.jpg';
+ }
+
+ public function getZoomAttributes()
+ {
+ return [
+ 'id' => $this->id,
+ 'page' => $this->page,
+ 'maxzoom' => $this->compiler->book->parametres->downloadPortionZoom,
+ 'group' => '',
+ 'group-count' => 0,
+ 'width' => round($this->width),
+ 'height' => round($this->height),
+ 'x' => round($this->left),
+ 'y' => round($this->top)
+ ];
+ }
+
+
+ public function getAdditionnalContent()
+ {
+ $file = $this->to;
+ if (!$file) {
+ $file = 'p' . $this->page;
+ }
+ if (!preg_match('/\.jpe?g$/', $file, $matches)) {
+ $file .= '.jpg';
+ }
+ $file = htmlspecialchars($file);
+
+ return parent::getAdditionnalContent() . ' download="' . $file . '" ';
+ }
+
+ public function getDefaultTooltip()
+ {
+ return 'click to download the image';
+ }
+}
+
class facebookLikeLink extends wsHTML5Link
{
public function getHTMLContent()
$res .= ' data-' . $key . '="' . htmlspecialchars($val, ENT_QUOTES) . '"';
}
- $this->generateImage();
+ self::generateImage($this->getZoomAttributes(), $this->compiler, 'zoomarea', 'zoom');
return $res;
}
public function getZoomAttributes()
{
return [
+ 'id' => $this->id,
+ 'page' => $this->page,
'maxzoom' => empty($this->to) ? $this->maxzoom_default : $this->to,
'group' => implode(',', $this->getGroups()),
'group-count' => empty($this->group) ? 0 : count($this->getGroups()),
];
}
- public function generateImage()
+ public static function generateImage($attributes, $compiler, $cachedir, $save)
{
- $maxzoom = $this->getZoomAttributes()['maxzoom']; // Max zoom level might not always be set in the link editor
+ $maxzoom = $attributes['maxzoom']; // Max zoom level might not always be set in the link editor
$maxzoom = max(2, min($maxzoom, 4.166666667));
if (!$maxzoom) {
$maxzoom = 2;
// Round all link co-ordinates because there seems to be a problem with the the Workshop link editor
// where link "left" values (and maybe others) change fractionally upon saves. This causes problems later when
// extracting the zoom images from the PDF because it causes a cache-miss and the images are regenerated again.
- $x = round($this->left);
- $y = round($this->top);
- $w = round($this->width);
- $h = round($this->height);
- $bookwidth = round($this->compiler->book->parametres->width);
+ $x = $attributes['x'];
+ $y = $attributes['y'];
+ $w = $attributes['width'];
+ $h = $attributes['height'];
+ $bookwidth = round($compiler->book->parametres->width);
//error_log("--- Book Width: $bookwidth ---");
- $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page);
+ $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page']);
$pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
$left = CubeIT_Files::tempnam();
$leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
1,
array('x' => $x, 'y' => $y, 'width' => $w, 'height' => $h),
- $left, $extractOptions, WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/');
+ $left, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');
if (($x + $w) > $bookwidth) {
- $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page + 1);
+ $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page'] + 1);
$pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
$diff = ($w + $x) - $bookwidth;
$right = CubeIT_Files::tempnam();
$rightfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
1,
array('x' => 0, 'y' => $y, 'width' => $diff, 'height' => $h),
- $right, $extractOptions, WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/');
+ $right, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');
$both = CubeIT_Files::tempnam() . '.jpg';
CubeIT_CommandLine_Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
$both = $leftfile;
}
- $this->compiler->simpleCopyLinkFile($both, 'data/links/zoom_' . $this->id . '.jpg');
+ $compiler->simpleCopyLinkFile($both, 'data/links/' . $save . '_' . $attributes['id'] . '.jpg');
// Perform tidy up and delete temporary files if they exist
$files_to_delete = ['left', 'leftfile', 'right', 'rightfile', 'both'];
foreach ($files_to_delete as $file) {
if (isset($$file)) {
- $this->compiler->vdir->addTemp($$file);
+ $compiler->vdir->addTemp($$file);
}
}
}