/
FieldTypeImageThumb.class.php
68 lines (62 loc) · 3.47 KB
/
FieldTypeImageThumb.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
// Copyright 2002 - 2007 SQLFusion LLC, Author: Philippe Lewicki info@sqlfusion.com
// For licensing, reuse, modification and distribution see pagebuilder_license.txt
/**
* Class FieldTypeImageThumb RegistryField class
*
* In the Form context Display a input type File and trigger the EventAction: mydb.formatPictureField that will process the uploaded file.
* In the Disp context if the file is an image display it in an image tag, otherwize in a link to download it.
* @package PASClass
*/
Class FieldTypeImageThumb extends RegistryFieldBase {
function default_Disp($field_value="") {
$file_path = trim($this->rdata['picture']);
if (!ereg("/$", $file_path)) {
$file_path .= "/";
}
if (!$this->getRdata('execute')) {
$field_value = $this->no_PhpCode($field_value);
}
if ($this->getRData('showpicture')=="1" && !empty($field_value)) {
$fval="<img border=\"0\" src=\"".$file_path.$field_value."\">";
} else {
//$fval = $file_path.$field_value;
//$fval = "<a href=\"".$fval."\">".$fval."</a>" ;
}
$this->processed .= $fval;
}
function default_Form($field_value="") {
if (!$this->rdata['hidden'] && !$this->rdata['readonly']) {
if (!$this->getRdata('execute')) {
$field_value = $this->no_PhpCode($field_value);
}
$overwrite = strtolower($this->getRData('overwrite'));
$max_width = $this->getRData("max_width") ;
$max_height = $this->getRData("max_height") ;
$thumb_max_width = $this->getRData("thumb_max_width");
$thumb_max_height = $this->getRData("thumb_max_height") ;
$filedir = $this->rdata['picture'];
$filethumbdir = $this->rdata['thumb_folder'];
$fval .= "<input type=\"hidden\" name=\"mydb_events[5]\" value=\"pagebuilder.FieldImageUpload\"/>" ;
if ($overwrite == "no") {
$fval .= "<input type=\"hidden\" name=\"fileoverwrite[]\" value=\"no\"/>" ;
}
if ($max_width > 0 || $max_height > 0) {
$fval .= "<input type=\"hidden\" name=\"mydb_events[23]\" value=\"pagebuilder.ImageFieldResizeWithThumb\"/>" ;
$fval .= "<input type=\"hidden\" name=\"maxwidth[".$this->getFieldName()."]\" value=\"".$max_width."\"/>" ;
$fval .= "<input type=\"hidden\" name=\"maxheight[".$this->getFieldName()."]\" value=\"".$max_height."\"/>" ;
$fval .= "<input type=\"hidden\" name=\"thumb_maxwidth[".$this->getFieldName()."]\" value=\"".$thumb_max_width."\"/>" ;
$fval .= "<input type=\"hidden\" name=\"thumb_maxheight[".$this->getFieldName()."]\" value=\"".$thumb_max_height."\"/>" ;
}
$fval .= "<input type=\"hidden\" name=\"filedirectoryuploaded[]\" value=\"$filedir\"/>" ;
$fval .= "<input type=\"hidden\" name=\"filedirectorythumbuploaded[]\" value=\"$filethumbdir\"/>" ;
$fval .= "<input type=\"hidden\" name=\"filefield[]\" value=\"".$this->getFieldName()."\"/>";
$fval .= "<input type=\"hidden\" name=\"fields[".$this->getFieldName()."]\" value=\"".$field_value."\"/>";
$fval .= "<input class=\"adformfield\" name=\"userfile[]\" type=\"file\"/>";
//if($field_value!="") $fval .= "(".$field_value.")";
$this->default_Disp($field_value);
$this->processed .= $fval;
}
}
}
?>