$this->config->seoArticles = $this->seoArticles;
}
- public function writeGrandVisionCart(){
+ public function writeGrandVisionCart()
+ {
$this->lessVariables['import-cart-styles'] = 'grandvision';
$this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js');
$file = $cdir . $this->book->parametres->basketReferences;
$this->config->basketReferences = wsUtil::excelToArrayKeyVars($file);
+ $odir = $cdir . '/opt/';
+ if (!file_exists($odir)) {
+ mkdir($odir, 0777, true);
+ }
+
+ $it = CubeIT_Files::getDirectoryIterator($cdir . '/raw/');
+ $exts = ['png', 'jpg', 'tif', 'mp4'];
+ foreach ($it as $file) {
+
+ /** @var $file SplFileInfo */
+ if ($file->isDir()) {
+ continue;
+ }
+ $ext = $file->getExtension();
+ if (!in_array($ext, $exts)) {
+ continue;
+ }
+
+ $e = explode('-', $file->getFilename());
+ $ean = $this->findEAN($e);
+ if (!$ean) {
+ continue;
+ }
+
+ $f = $file->getPathname();
+
+ if ($ext === 'mp4') {
+ $this->config->basketReferences[$ean]['360'] = true;
+ $opt = $odir . '/' . $ean . '-360.mp4';
+ if (!file_exists($opt) || !filesize($opt) || filemtime($opt) < filemtime($f)) {
+ // Optimize original video
+ `ffmpeg -i $f -filter:v scale=360:-2 -vcodec libx264 -an $opt`;
+ }
+ } else {
+ if (in_array('front', $e)) {
+ $type = 'front';
+ } else if (in_array('angle', $e)) {
+ $type = 'angle';
+ }
+ $this->config->basketReferences[$ean][$type] = true;
+ $opt = $odir . '/' . $ean . '-' . $type . '.jpg';
+ if (!file_exists($opt) || !filesize($opt) || filemtime($opt) < filemtime($f)) {
+ // Optimize original image
+ $convert = new CubeIT_Image_Resizer_ImageMagick();
+ $convert->loadImage($f);
+ $convert->resize(1080, null, 'ratio', false, 'C', 'M', 'ffffff');
+ $convert->output('jpg', $f, 75);
+ }
+ }
+
+
+ }
+
+ }
+
+ public function findEAN($array)
+ {
+ foreach ($array as $item) {
+ if (strlen($item) === 13 && preg_match('/^\d{13}$/', $item)) {
+ return $item;
+ }
+ }
+ return false;
}
public function writeMIFCart()
$ids = explode(',', $linkData['to']);
foreach ($ids as $id) {
$id = trim($id);
- if($id==='tabs'){
- $this->config->tabsHiddenAtStartup=true;
- }else {
+ if ($id === 'tabs') {
+ $this->config->tabsHiddenAtStartup = true;
+ } else {
$hiddenLinks[] = $id;
$hiddenLinks[] = 'i_' . $id;
}
} else {
$dim = [0 => 1024, 1 => 10];
}
- $res .= '<figure'.$dirattr.'><img src="data/articles/' . $file . '" alt="' . $legend . '" width="' . $dim[0] . '" height="' . $dim[1] . '">' . $caption . '</figure>';
+ $res .= '<figure' . $dirattr . '><img src="data/articles/' . $file . '" alt="' . $legend . '" width="' . $dim[0] . '" height="' . $dim[1] . '">' . $caption . '</figure>';
} else {
$c = trim($this->SimpleXMLElement_innerXML($child));
if (!$c) {