Source for file DBMS_FIELD_IMAGE.phpclass
Documentation is available at DBMS_FIELD_IMAGE.phpclass
* Class file DBMS_FIELD_IMAGE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: DBMS_FIELD_IMAGE.phpclass,v 1.19 2008/11/11 07:04:42 pitlinz Exp $
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version pk-07-09-12 changed parent class from DBMS_FIELD to DBMS_FIELD_FILESELECTLIST
* @version $Id: DBMS_FIELD_IMAGE.phpclass,v 1.19 2008/11/11 07:04:42 pitlinz Exp $
* attributes ------------------------------------------------------------------
* source file of the class
* @var string $classSrcFile
// ------------------------------------------------------------------------------
* @var boolean $resizeOnUpload
* @var int $listMaxHeight
* @var boolean $hideInputField
// ###########################################################
// OBJECT SETTINGS METHODS
// ###########################################################
* convert old object vars to DBMS_FIELD_DBLOOKUPSELECTLIST
* and then calls the parent method
foreach($varArr as $str_name =>
$m_val)
$varArr['allow_overwrite']=
$m_val;
unset
($varArr['allowOverwrite']);
$varArr['allow_mkdir']=
$m_val;
unset
($varArr['allowMkDir']);
$varArr['allow_upload']=
$m_val;
unset
($varArr['allowUpload']);
if ($m_val==
"DOCUMENT_ROOT")
$varArr['useDocRoot']=
TRUE;
$varArr['useDocRoot']=
FALSE;
unset
($varArr['dirPrefix']);
parent::setObjectVars($varArr,$debug);
* returns if the upload is to resize
* returns the value of the uploaded file
* @param array $uplFile ($_FILE[fld])
* @return string value to set or Null on error
if (isset
($uplFile['error']) &&
!empty($uplFile['error']))
$obj_image =
new OCSP_IMAGE($uplFile['tmp_name']);
if ($obj_image->isImage())
$this->setErrorMsg($uplFile['name'] .
" is to wide " .
$obj_image->getWidth() .
" instead of " .
$this->getMaxWidth(),True);
$this->setErrorMsg($uplFile['name'] .
" is to heigh " .
$obj_image->getHeight() .
" instead of " .
$this->getMaxHeight(),True);
//echo "L: " . __LINE__ . "\n$path\n$str_curDir\n$str_path";
$arr_name=
explode(".",$str_fileName,2);
$str_fileName =
$arr_name[0].
'_'.
sprintf("%03d",$int_idx++
).
".".
$arr_name[1];
if ($int_type=
$obj_image->res_saveAs($str_file))
//echo "\nL: " . __LINE__ . ": ".$str_file;
$this->setErrorMsg($uplFile['name'].
" is not an image");
$this->setErrorMsg('You are not allowed to upload an image',True);
// ###########################################################
// FIELD DEFINITION DATA METHODS
// ###########################################################
* returns an array of field to bie shown in the edit form
* by using editTbl_echoForm
unset
($a_ret['LAYOUT']['FLD_INPUTADD']);
unset
($a_ret['LAYOUT']['FLD_SIZE']);
unset
($a_ret['LAYOUT']['FLD_SELSIZE']);
unset
($a_ret['FILESELECT']['FLD_DOWNL']);
unset
($a_ret['FILESELECT']['FLD_EDITORURL']);
unset
($a_ret['FILESELECT']['FLD_UPLOADURL']);
* save the filed definition form
* @returns bool return TRUE
function save($debug=
FALSE) {
$this->maxWidth =
(isset
($_POST['maxWidth']) ?
intval($_POST['maxWidth']) :
0);
$this->maxHeight =
(isset
($_POST['maxWidth']) ?
intval($_POST['maxHeight']) :
0);
$this->listMaxWidth =
(isset
($_POST['listMaxWidth']) ?
intval($_POST['listMaxWidth']) :
0);
// ###########################################################
// OBJECT HTML FORM METHODS
// ###########################################################
* returns the html <img src= value >
* @param int $mode since pk-06-08-15
* @global array $OCSP_CONF
* @requires pcf_md5.phpinc
* @version pk-06-10-06 // different db-versions one with $rootDir and one without
* @version pk-06-12-06 // check for html urls
* @version pk-07-02-14 // SEC_REQ['PUBLIC']
* @version pk-07-09-12 // compleate rewrite
* @version $Id: DBMS_FIELD_IMAGE.phpclass,v 1.19 2008/11/11 07:04:42 pitlinz Exp $
$str_showUrl =
OCSP_OBJ::getConf('SYSTEMURL').
"tools/imageSource.php?imgSrc=";
* returns the img preview tag with link to the image browser
$str_imgSrc=
$this->getImgSrc($aValue,$debug);
$str_imgSrc.=
"&w=$i_maxWidth&h=$i_maxHeight";
if (obj_form = jOCSP.getFormByHash('" .
$this->myControll->jOCSP_getfrmHash() .
"'))
if (obj_field = obj_form.getFieldByDomId('" .
$this->getDOMId() .
"'))
$str_style.=
"float: left;width:".
($i_maxWidth+
2).
"px;height:".
($i_maxHeight+
2).
"px;";
$str_style.=
"margin: 2px;border: dashed 2px #C0C0C0;padding: 2px;";
$str_style.=
"background-image: url('".
$str_imgSrc.
"');";
$str_style.=
"background-repeat: no-repeat;";
$str_style.=
"background-position: left center;";
<div id=\"preview_".
$this->getDOMId().
"\" $str_onClick $str_style>
if ($debug) $str_tag.=
"<p><a href=\"" .
$str_imgSrc .
"\">" .
$aValue .
"</a></p>";
* @param string $aValue (image path)
* @param string $arrName (overwrites $this->myDataArrName if not empty)
* @global ${$this->myDataArrName}
function getInputTag($aValue,$arrName=
"DBVAL",$debug=
FALSE)
global $
{$this->myDataArrName};
$str_ret.=
"<div id=\"imgdiv_".
$this->getDOMId().
"\">";
<div style=\"float:left\">
alt=\"cancel\" title=\"Bild entfernen\" class=\"button\"
document.getElementById('" .
$this->getDOMId() .
"').value='';
document.getElementById('preview_".
$this->getDOMId().
"').style.backgroundImage='url(" .
OCSP_OBJ::getConf('SYSIMGURL') .
"icons-64x64/unknown.png)';
<input type=\"{$str_type}\" name=\"" .
$this->myDataArrName .
"[" .
$this->getName() .
"]\" id=\"" .
$this->getDOMId() .
"\" value=\"" .
$aValue .
"\" />
return (($aValue) &&
(file_exists($_SERVER['DOCUMENT_ROOT'].
$aValue)));
* returns the screen representation
* here a img tag is returned
if ($debug) echo
"<p><b>DBMS_FIELD_IMAGE::getScreenValue($aValue,$arrName,..)</b> (".
get_class($this).
")</p>";
$str_ret=
"<img src=\"$src\" alt=\"".
basename($aValue).
"\" border=\"0\">";
if ($debug) $str_ret.=
"<a href=\"$src\">+</a>";
* returns the list representation
* here an img tag is returned
function getListValue($aValue=
NULL,$arrName=
"DBVAL",$debug=
FALSE) {
return "<img src=\"$src\" border=\"0\">";
} else if (!empty($aValue)) {
* gets a htmltag for the value
* for images only the src url is returned
* as this is often used with: <img src="$*img$">
* @version pk-06-12-06 check for http?: in the url
function getHtmlTag($aValue,$arrName=
"DBVAL",$debug=
FALSE) {
if ($debug) echo
"<p><b>DMBS_FIELD::getHtmlTag($aValue,$arrName ...)</b> (".
get_class($this).
")</p>";
$ret=
trim($this->getDirPrefixUri()).
trim($aValue);
switch($this->dirPrefix) {
// --------------------------------------------------------
// --------------------------------------------------------
* returns an array of jOCSP/jQuery Modules which are required
* $arr_ret[]="script url";
if ($debug) echoDebugMethod(__FILE__
,get_classe($this),"DBMS_FIELD::jOCSP_getRequiredModules()");
$arr_ret =
parent::jOCSP_getRequiredModules($debug);
'CLASS' =>
'jOCSP.FLDOBJ_Image',
'SRC' =>
OCSP_OBJ::getConf('SYSTEMURL').
"jOCSP/formFields/jOCSP_FLDOBJ_Image.js"
* returns additional object elements of the field object
* array definition: [elemName] = value
* NOTE: do not js_escapte value this is done when building the json object
$arr_ret =
parent::jOCSP_getAdditonalFieldObjElems($debug);
$arr_ret['fldClass'] =
"'FLDOBJ_Image'";
//$arr_ret['debug'] = True;
$str_url =
OCSP_OBJ::getConf('SYSTEMURL') .
"forms/filemanager/imagebrowser2/index.php";
'E' =>
$this->allow_edit,
'U' =>
$this->allow_upload,
'O' =>
$this->allow_overwrite
'COMMANDS' =>
$arr_allow,
$str_url.=
"?fldDOM=" .
$this->getDOMId();
if (obj_form = jOCSP.getFormByHash('" .
$this->myControll->jOCSP_getfrmHash() .
"'))
if (obj_field = obj_form.getFieldByDomId('" .
$this->getDOMId() .
"'))
obj_field.rootDir = '" .
$this->getRootDir() .
"';
document.getElementById('" .
$this->getDOMId() .
"').ocspForm = obj_form;
document.getElementById('" .
$this->getDOMId() .
"').ocspField = obj_field;
if (wnd=openWindow('imgBrowser','".
$str_url.
"',700,500))
$str_onClick="onclick=\"\n";
$str_onClick.="openWindow('imgBrowser','".$this->getImgBrowserUrl($aValue,$debug)."',700,500);\n";
$str_onClick.="this.innerHTML='";
$str_onClick.="<img src=\\'" . OCSP_OBJ::getConf('SYSIMGURL') ."jquery/loading.gif\\' />";
* @global array ${$this->myDataArrName};
if (isset
($request['value']))
* @global array ${$this->myDataArrName};
if ($arr_upload =
$_FILES[$this->getDOMId() .
'_upload'])
if (isset
($arr_upload['error']) &&
!empty($arr_upload['error']))
if ($debug) pcf_js_alert("value: " .
$str_value .
"\ncurDir: " .
$str_curDir .
"\npath: " .
$str_path);
$arr_name=
explode(".",$str_fileName,2);
$str_fileName =
$arr_name[0].
'_'.
sprintf("%03d",$int_idx++
).
".".
$arr_name[1];
if (dom_field = parent.document.getElementById('" .
$this->getDOMId() .
"'))
dom_field.options[dom_field.options.length]=new Option('" .
basename($str_val) .
"','" .
$str_val .
"',true,true);
dom_field.value='" .
$str_val .
"';
obj_field = dom_field.jOCSPFldObj
obj_domForm = obj_field.myForm.getDomObj();
obj_domForm.target=obj_field.uploadOri.target;
obj_domForm.action=obj_field.uploadOri.action;
if (obj_field.uploadOri.encoding)
obj_domForm.encoding = obj_field.uploadOri.encoding;
obj_domForm.enctype = obj_field.uploadOri.enctype;
parent.document.getElementById('" .
$this->getDOMId() .
"_upload').value='';
alert('" .
basename(__FILE__
) .
" L: " . __LINE__ .
": ' + dom_field.id + '\\n' + e );
alert('Feld nicht gefunden');
} // end class DBMS_FIELD_PASSWORD
Documentation generated on Thu, 08 Jan 2009 17:42:00 +0100 by phpDocumentor 1.4.0a2