19 include_once (
"FDL/Class.Doc.php");
20 include_once (
"FDL/Class.DocAttr.php");
21 include_once (
"FDL/Lib.Vault.php");
22 include_once (
"VAULT/Class.VaultFile.php");
50 $action->exitError(sprintf(_(
"Document %s in %s state not found") ,
$doc->title, _($state)));
64 if (
$doc->doctype ==
"C") {
65 $ovalue =
$doc->getParamValue($attrid);
66 if (!$ovalue) $ovalue =
$doc->getDefValue($attrid);
67 }
else $ovalue =
$doc->getValue($attrid);
68 if (($index !==
"") && ($index >= 0)) {
69 $tvalue = explode(
"\n", $ovalue);
70 $ovalue = $tvalue[$index];
72 $oa =
$doc->getAttribute($attrid);
73 if (!$oa)
$action->exitError(sprintf(_(
"attribute %s not found") , $attrid));
74 if ($oa->getOption(
"preventfilechange") ==
"yes") {
84 print (sprintf(_(
"no file referenced for %s document") ,
$doc->title));
87 if ($ovalue ==
"")
$action->exiterror(sprintf(_(
"no file referenced for %s document") ,
$doc->title));
108 $attr =
$doc->GetFirstFileAttributes();
109 if (!$attr)
$action->exiterror(_(
"no attribute file found"));
111 setHttpVar(
"attrid", $attr->id);
121 if (
$type ==
"pdf") {
124 if (
$err !=
"")
$err = sprintf(_(
"PDF conversion not found")) .
"\n$err";
129 if (substr($info->mime_s, 0, 5) ==
"image")
$type =
"original";
131 if (
$type ==
"png") {
135 $filecache = sprintf(
"%s/.img-resize/vid-%s-%d.png",
DEFAULT_PUBDIR, $info->id_file, $pngpage);
136 if (file_exists($filecache)) {
141 list($owidth, $oheight) = getimagesize(
$filename);
143 $newheight = $oheight * ($width / $owidth);
145 $thumb = imagecreatetruecolor($newwidth, $newheight);
148 imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $owidth, $oheight);
150 header(
'Content-type: image/png');
154 Http_DownloadFile($filecache, $info->name .
".png",
"image/png", $inline, $cache);
160 if (!$width) $width = 150;
166 $cmd = sprintf(
"convert -thumbnail %s -density %d %s[%d] %s", $width, $quality, $info->path, $pngpage,
$cible);
176 if (file_exists(
$cible)) {
179 include_once (
"FDL/insertfile.php");
184 list($owidth, $oheight) = getimagesize(
$filename);
186 $newheight = $oheight * ($width / $owidth);
188 $thumb = imagecreatetruecolor($newwidth, $newheight);
191 imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $owidth, $oheight);
193 header(
'Content-type: image/png');
201 }
else $err = sprintf(_(
"cannot get image transformation for %s") , $info->name) .
"\n$err";
205 if ($info)
$err = sprintf(_(
"conversion png not found for %s") , $info->name) .
"\n$err";
211 if ((substr($info->mime_s, 0, 5) ==
"image") && ($width > 0)) {
224 if ($info->mime_s)
$mimetype = $info->mime_s;
226 if ($isControled || ($info->public_access)) {
227 if ((
$mimetype !=
"image/jpeg") || ($width == 0)) {
228 if ($othername) $info->name = $othername;
233 if (!$inline) header(
"Content-Disposition: form-data;filename=$name");
236 $nav = $_SERVER[
'HTTP_USER_AGENT'];
237 $pos = strpos($nav,
"MSIE");
240 header(
"Content-Disposition: form-data;filename=\"$name\"");
246 header(
'Content-type: image/jpeg');
250 list($owidth, $oheight) = getimagesize(
$filename);
252 $newheight = $oheight * ($width / $owidth);
254 $thumb = imagecreatetruecolor($newwidth, $newheight);
255 $source = imagecreatefromjpeg(
$filename);
257 imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $owidth, $oheight);
262 if (!$info->public_access) AddlogMsg(sprintf(_(
"%s has be sended") , $info->name));
264 $action->exiterror(_(
"file must be controlled : read permission needed"));
279 if (
seems_utf8($text)) $text = utf8_decode($text);
280 $ts = explode(
"\n", $text);
282 foreach ($ts as $k => $string) {
283 $width = max($width, strlen($string));
286 $width = imagefontwidth($font_size) * $width;
288 $height = imagefontheight($font_size) * count($ts);
289 $el = imagefontheight($font_size);
290 $em = imagefontwidth($font_size);
292 $img = imagecreatetruecolor($width, $height);
294 $bg = imagecolorallocate(
$img, 0xAA, 0x00, 0x00);
296 imagefilledrectangle(
$img, 0, 0, $width, $height, $bg);
297 $color = imagecolorallocate(
$img, 255, 255, 255);
299 foreach ($ts as $k => $string) {
301 $len = strlen($string);
305 for ($i = 0; $i < $len; $i++) {
310 imagechar(
$img, $font_size, $xpos, $ypos, $string, $color);
312 $string = substr($string, 1);
316 header(
"Content-Type: image/png");
332 if (!file_exists(
$dest)) {
333 $cmd = sprintf(
"convert -thumbnail %d %s %s",
$size, escapeshellarg($source) , escapeshellarg(
$dest));