/** * check the archive */ function execute() { global $lang, $errors; $archfolder = $_SESSION["archivefolder"]; if ($archfolder != "") { $d = dir($archfolder); $this->counter = 0; while (false !== ($f = $d->read())) { if (is_file($d->path . '/' . $f)) { $info = pathinfo($d->path . '/' . $f); $ext2 = strtoupper($info["extension"]); if ($ext2 == "JPG" || $ext2 == "JPEG" || $ext2 == "PNG" || $ext2 == "GIF") { createImageFromFile($d->path . '/' . $f, "", "", 1, value("folder", "NUMERIC", 1)); $this->counter++; } } } $d->close(); } nxRMDir($d->path); $_SESSION["archivefolder"] = ""; $this->add(new WZLabel($lang->get("nofi", "Number of files imported:") . $this->counter)); $this->forbidBack = true; }
/** * Takes care of images. The Images are not really rendered within this function! By default * it will simply return [IMAGE]! If you want to output the real image, you will have to * provide a userfunction. You can pass the userfunction's name by the general TS configuration * of this extension. * * Example: * userFunctions.renderImage = tx_rlmpofficeimport_pi1->renderImage * * @param [array] $iArray: subtags for the image section * @return [string] [IMAGE] */ function renderImage($binDataConf) { global $c; $pathinformation = pathinfo($binDataConf['attributes']['W:NAME']); $baseName = $pathinformation['basename']; $extension = strtolower($pathinformation['extension']); $binary = $binDataConf['value']; if (strstr('gif,jpeg,jpg,png', $extension)) { mt_srand((double) microtime() * 1000000); $fileName = $c["path"] . "cache/" . md5(uniqid(mt_rand())) . "." . $extension; if (!@is_file($fileName)) { if ($fd = fopen($fileName, 'wb')) { fwrite($fd, base64_decode($binary)); fclose($fd); } } } $imageId = createImageFromFile($fileName); unlink($fileName); return "{NX:IMAGE ID=\"{$imageId}\"}"; }
flush(); foreach ($images as $k => $image) { $image = $link->getImageLink($productObj->link_rewrite, $image['id_image'], 'thickbox'); $image = (int) preg_replace('/\\D/', '', $image); $str = str_split($image); $filepath = "/var/www/indusdiva.com/img/p/"; $filepath = $filepath . implode("/", $str) . "/" . $image . "-thickbox.jpg"; $new_filename = "{$id_product}_{$count}.jpg"; $new_filename = "/var/www/indusdiva.com/gosf-images/" . $new_filename; $source_gd_image = createImageFromFile($filepath); $new_width = 483; $new_height = 660; $dest_gd_image = scaleImageToHeight($source_gd_image, $new_height); $background = createImage(990, 660); $background = mergeImages($background, $dest_gd_image, Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::GRAVITY_CENTER); $background->setImageFormat('jpg'); $background->writeImage($new_filename); $source_gd_image->destroy(); $dest_gd_image->destroy(); $background->destroy(); $count++; } } //LOGO $filepath = "/home/venu/Logo.jpg"; $source_gd_image = createImageFromFile($filepath); $dest_gd_image = scaleImageToWidth($source_gd_image, 990); $background = createImage(990, 660); $background = mergeImages($background, $dest_gd_image, Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::GRAVITY_CENTER); $background->setImageFormat('jpg'); $background->writeImage('/var/www/indusdiva.com/gosf-images/logo.jpg');
$image_size = getimagesize($filename); $pinfo = pathinfo($file["name"]); $ftype = $pinfo['extension']; $destination = $pathpre . $destination_folder . date("YmdHis", time()) . $authnum . "." . $ftype; if (file_exists($destination) && $overwrite != true) { echo "<script language=javascript>alert('同名文件已经存在了!');history.go(-1);</script>"; exit; } if (!move_uploaded_file($filename, $destination)) { echo "<script language=javascript>alert('移动文件出错!');history.go(-1);</script>"; exit; } //如何宽度大于470px,长度大于370px,对图片进行缩略 list($width, $height, $type) = getimagesize($destination); if ($width > 450 || $height > 370) { $src = createImageFromFile($destination); //设置缩略图的宽度和高度 $ret = setWidthAndHeight($width, $height); $dst = imagecreatetruecolor($ret[0], $ret[1]); //创建输出图像 imagecopyresampled($dst, $src, 0, 0, 0, 0, $ret[0], $ret[1], $width, $height); //拷贝图像 save($destination, $type, $dst); } $pinfo = pathinfo($destination); $fname = $pinfo[basename]; //路径问题 $destination_folder = str_replace("\\", "/", $destination_folder); $turepath = $config->app_root . '/app'; $turepath = str_replace('\\', '/', $turepath); $destination_folder = str_replace($turepath, '', $destination_folder);
/** * This processed the content inside a paragraph or header. * * @param [type] $v: ... * @return [type] ... */ function getParagraphContent($v) { $content = ''; $content .= $this->pValue($v['value']); if (is_array($v['subTags'])) { $v['subTags'] = $this->indentSubTags($v['subTags']); reset($v['subTags']); while (list(, $subV) = each($v['subTags'])) { switch ($subV['tag']) { // Paragraph/Headers case 'TEXT:P': case 'TEXT:H': // Fields: // Fields: case 'TEXT:AUTHOR-NAME': case 'TEXT:TITLE': case 'TEXT:USER-DEFINED': if (strstr(',complete,cdata,', ',' . $subV['type'] . ',')) { $content .= $this->pValue($subV['value']); } else { $this->noProcessing($subV); } break; case 'TEXT:S': // Extra SPACE! if ($subV['attributes']['TEXT:C'] > 1 && $subV['attributes']['TEXT:C'] < 2000000000) { $cc = $subV['attributes']['TEXT:C']; } else { $cc = 1; } for ($a = 0; $a < $cc; $a++) { $content .= ' '; } break; case 'TEXT:TAB-STOP': $content .= $this->chr10BR ? chr(9) : ' '; break; case 'TEXT:LINE-BREAK': $content .= $this->chr10BR ? chr(10) : '<br />'; break; case 'TEXT:SPAN': if (strstr(',complete,cdata,', ',' . $subV['type'] . ',')) { $content .= $this->spanFormat($this->getParagraphContent($subV), $subV['attributes']['TEXT:STYLE-NAME']); } else { $this->noProcessing($subV); } break; case 'TEXT:A': if (strstr(',complete,cdata,', ',' . $subV['type'] . ',')) { $content .= '<a href="' . $subV['attributes']['XLINK:HREF'] . '">' . $this->getParagraphContent($subV) . '</a>'; } else { $this->noProcessing($subV); } break; case 'DRAW:IMAGE': if ($subV['attributes']['XLINK:HREF']) { $fI = pathinfo($subV['attributes']['XLINK:HREF']); $imageId = createImageFromFile($this->tmpFolder . "/Pictures/" . $fI["basename"]); $content .= "{NX:IMAGE ID=\"{$imageId}\"}"; } break; case 'DRAW:TEXT-BOX': $content .= '<table border="0" cellpadding="0" cellspacing="0"><tr><td>' . implode('', $this->renderOOBody($this->indentSubTags($subV['subTags']))) . '</td></tr></table>'; break; // Nothing happens: // Nothing happens: case 'TEXT:SEQUENCE': case 'OFFICE:ANNOTATION': break; default: $this->noProcessing($subV); break; } } } if (!strcmp(trim(strip_tags($content, '<img>')), '')) { $content = ' '; } return $content; }