format = EDIT_FORMAT_FILE;
}
/**
* addJSFiles
* Add control JS files to page object
*/
function addJSFiles()
{
$this->pageObject->AddJSFile("include/zoombox/zoombox.js");
}
/**
* addCSSFiles
* Add control CSS files to page object
*/
function addCSSFiles()
{
$this->pageObject->AddCSSFile("include/zoombox/zoombox.css");
}
function buildControl($value, $mode, $fieldNum, $validate, $additionalCtrlParams, $data)
{
parent::buildControl($value, $mode, $fieldNum, $validate, $additionalCtrlParams, $data);
if( $this->pageObject->pageType == PAGE_SEARCH || $this->pageObject->pageType == PAGE_LIST )
{
echo 'inputStyle.' type="text" '
.($mode == MODE_SEARCH ? 'autocomplete="off" ' : '')
.(($mode==MODE_INLINE_EDIT || $mode==MODE_INLINE_ADD) && $this->is508==true ? 'alt="'.$this->strLabel.'" ' : '')
.'name="'.$this->cfield.'" '.$this->pageObject->pSetEdit->getEditParams($this->field).' value="'
.runner_htmlspecialchars($value).'">';
$this->buildControlEnd($validate);
return;
}
if( $mode == MODE_SEARCH )
$this->format = "";
$disp = "";
$strfilename = "";
$filename_size = 30;
if( $this->pageObject->pSetEdit->isUseTimestamp( $this->field ) )
$filename_size = 50;
if( $mode == MODE_EDIT || $mode == MODE_INLINE_EDIT )
{
// show current file
$newUploaderFilesData = my_json_decode($value);
$newUploaderWasUsed = is_array($newUploaderFilesData) && count($newUploaderFilesData) > 0;
$fileData = $newUploaderWasUsed ? $newUploaderFilesData[0] : array();
$fileName = $newUploaderWasUsed ? $fileData["usrName"] : $value;
$viewFormat = $this->pageObject->pSetEdit->getViewFormat( $this->field );
if( $viewFormat == FORMAT_FILE || $viewFormat == FORMAT_FILE_IMAGE )
$disp = $this->getFileOrImageMarkup( $value, $fileName, $newUploaderWasUsed, $fileData )."
";
// filename edit
$strfilename = '
'
.mlang_message("FILENAME")
.' ';
$strtype = '
'.mlang_message("KEEP");
if( (strlen($value) || $mode == MODE_INLINE_EDIT) && !$this->pageObject->pSetEdit->isRequired($this->field) )
{
$strtype .= ''.mlang_message("DELETE");
}
$strtype .= ''.mlang_message("UPDATE");
}
else
{
// if Adding record
$strtype = '';
$strfilename = '
'.mlang_message("FILENAME")
.' ';
}
echo $disp.$strtype;
if( $mode == MODE_EDIT || $mode == MODE_INLINE_EDIT )
echo '
';
echo 'is508 == true ? 'alt="'.$this->strLabel.'" ' : '')
.' name="'.$this->cfield.'" >'.$strfilename;
echo '';
$this->buildControlEnd($validate);
}
/**
* Get the image or file link markup
* @param String value
* @param String fileName
* @param Boolean newUploaderWasUsed
* @param Array fileData
* @return String
*/
function getFileOrImageMarkup( $value, $fileName, $newUploaderWasUsed, $fileData )
{
$cachedValue = $value;
if( $newUploaderWasUsed )
$finalFilePath = $filePath = $fileData["name"];
else
{
$uploadFolder = $this->pageObject->pSetEdit->getUploadFolder( $this->field );
$filePath = $uploadFolder.$value;
$finalUploadFolder = $this->pageObject->pSetEdit->getFinalUploadFolder( $this->field );
$finalFilePath = $finalUploadFolder.$value;
}
if( !CheckImageExtension($fileName) )
{
return ""
.runner_htmlspecialchars($fileName)."";
}
$altAttr = $this->is508 ? " alt=\"".runner_htmlspecialchars( $fileName )."\"" : "";
if( !myfile_exists(getabspath( $finalFilePath ) ) )
$filePath = "images/no_image.gif";
if( $this->pageObject->pSetEdit->showThumbnail( $this->field ) )
{
if( $newUploaderWasUsed )
$finalThumbPath = $thumbPath = $fileData["thumbnail"];
else
{
$thumbprefix = $this->pageObject->pSetEdit->getStrThumbnail( $this->field );
$thumbPath = $uploadFolder.$thumbprefix.$fileName;
$finalThumbPath = $finalUploadFolder.$thumbprefix.$fileName;
}
if( substr($thumbPath, 0, 7) != "http://" )
{
if( !myfile_exists(getabspath( $finalThumbPath )) )
$thumbPath = $filePath;
}
// show thumbnail
return ""
."
";
}
$imageValue = $filePath;
if( $filePath != "images/no_image.gif" && !$newUploaderWasUsed )
{
if( filesize($finalUploadFolder.$fileName) > 51200 )
$imageValue = "images/icons/jpg.png";
}
$disp = '
';
if( $imageValue != "images/no_image.gif" )
$disp = "".$disp."";
return $disp;
}
/**
*
*/
function readWebValue(&$avalues, &$blobfields, $legacy1, $legacy2, &$filename_values)
{
$this->getPostValueAndType();
if( FieldSubmitted( $this->goodFieldName."_".$this->id ) )
{
$fileNameForPrepareFunc = securityCheckFileName( postvalue("filename_".$this->goodFieldName."_".$this->id) );
if( $this->pageObject->pageType != PAGE_EDIT )
{
$this->webValue = prepare_upload($this->field, "upload2", $fileNameForPrepareFunc, $fileNameForPrepareFunc, ""
, $this->id, $this->pageObject);
}
else
{
if(substr($this->webType, 0, 4) == "file")
{
$prepearedFile = prepare_file($this->webValue, $this->field, $this->webType, $fileNameForPrepareFunc, $this->id);
if($prepearedFile !== false)
{
$this->webValue = $prepearedFile["value"];
$filename = $prepearedFile["filename"];
}
else
$this->webValue = false;
}
else if(substr($this->webType, 0, 6) == "upload")
{
if($fileNameForPrepareFunc)
$this->webValue = $fileNameForPrepareFunc;
if($this->webType == "upload1")
{
// file deletion, read filename from the database
$oldValues = $this->pageObject->getOldRecordData();
$fileNameForPrepareFunc = $oldValues[$this->field];
}
$this->webValue = prepare_upload($this->field, $this->webType, $fileNameForPrepareFunc, $this->webValue, "", $this->id, $this->pageObject);
}
}
}
else
$this->webValue = false;
if(!($this->webValue === false))
{
if( $this->webValue && $this->pageObject->pSetEdit->getCreateThumbnail($this->field) )
{
$contents = GetUploadedFileContents("value_".$this->goodFieldName."_".$this->id);
$ext = CheckImageExtension( GetUploadedFileName("value_".$this->goodFieldName."_".$this->id) );
$thumb = CreateThumbnail($contents, $this->pageObject->pSetEdit->getThumbnailSize($this->field), $ext);
$this->pageObject->filesToSave[] = new SaveFile($thumb, $this->pageObject->pSetEdit->GetStrThumbnail($this->field)
.$this->webValue, $this->pageObject->pSetEdit->getUploadFolder($this->field), $this->pageObject->pSetEdit->isAbsolute($this->field));
}
$avalues[ $this->field ] = $this->webValue;
}
}
function makeWidthStyle($widthPx)
{
if(0 == $widthPx)
return "";
return "min-width: ".$widthPx."px";
}
}
?>