format = EDIT_FORMAT_FILE; global $conn; $this->conn = $conn; } function addJSFiles() { if($this->pageObject->pageType == PAGE_ADD || $this->pageObject->pageType == PAGE_EDIT || $this->pageObject->pageType == PAGE_REGISTER){ $this->pageObject->AddJSFile("include/mupload.js"); $this->pageObject->AddJSFile("include/zoombox/zoombox.js"); } } function addCSSFiles() { if($this->pageObject->pageType == PAGE_ADD || $this->pageObject->pageType == PAGE_EDIT || $this->pageObject->pageType == PAGE_REGISTER){ $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 = ""; $this->formStamp = generatePassword(15); $this->initUploadHandler(); $this->upload_handler->formStamp = $this->formStamp; $filesArray = my_json_decode($value); if(!is_array($filesArray) || count($filesArray) == 0) { if(!$value) $jsonValue = "[]"; else { $uploadedFile = $this->upload_handler->get_file_object($value); if(is_null($uploadedFile)) $filesArray = array(); else $filesArray = array(my_json_decode(my_json_encode($uploadedFile))); } } if($this->pageObject->pageType == PAGE_EDIT) { if(count($this->pageObject->keys) > 0) { $i = 1; foreach($this->pageObject->keys as $keyName => $keyValue) { $this->upload_handler->tkeys .= "&key".$i."=".rawurlencode($keyValue); $i++; } } } $_SESSION["mupload_".$this->formStamp] = array(); $userFilesArray = array(); if(is_array($filesArray)) { foreach ($filesArray as $file) { $sessionArray = array(); $sessionArray["file"] = $file; $sessionArray["fromDB"] = true; $sessionArray["deleted"] = false; $_SESSION["mupload_".$this->formStamp][$file["usrName"]] = $sessionArray; $userFile = $this->upload_handler->buildUserFile($file); if(!$userFile["isImg"]){ $userFile["isImg"] = true; $userFile["isIco"] = true; $userFile["thumbnail_url"] = $userFile["url"]."&icon=1"; } $userFilesArray[] = $userFile; } } $jsonValue = my_json_encode($userFilesArray); echo '
'; if(!isset($this->container->globalVals["muploadTemplateIncluded"])) { echo ' '; $this->container->globalVals["muploadTemplateIncluded"] = true; } $this->buildControlEnd($validate); } /** * Create CSS code for specifying control's width */ function makeWidthStyle($widthPx) { if(0 == $widthPx) return ""; return "min-width: ".$widthPx."px"; } function initUploadHandler() { if(is_null($this->upload_handler)) { require_once getabspath("classes/uploadhandler.php"); $this->upload_handler = new UploadHandler(getOptionsForMultiUpload($this->pageObject->pSet, $this->field)); $this->upload_handler->pSet = $this->pageObject->pSetEdit; $this->upload_handler->field = $this->field; $this->upload_handler->table = $this->pageObject->tName; $this->upload_handler->pageType = $this->pageObject->pageType; } } function readWebValue(&$avalues, &$blobfields, $strWhereClause, $oldValuesRead, &$filename_values) { $this->getPostValueAndType(); $this->formStamp = postvalue("formStamp_".$this->goodFieldName."_".$this->id); if (FieldSubmitted($this->goodFieldName."_".$this->id) && $this->formStamp != "") { $filesArray = my_json_decode($this->webValue); if(!is_array($filesArray) || count($filesArray) == 0) $this->webValue = ""; else { if(count($_SESSION["mupload_".$this->formStamp]) > 0) { foreach($_SESSION["mupload_".$this->formStamp] as $fileArray) $fileArray["deleted"] = true; } $result = array(); $uploadDir = $this->pageObject->pSetEdit->getLinkPrefix($this->field); $searchStr = ""; foreach ($filesArray as $file) { if(isset($_SESSION["mupload_".$this->formStamp][$file["name"]])) { $sessionFile = $_SESSION["mupload_".$this->formStamp][$file["name"]]["file"]; $searchStr .= $file["name"].",!"; $result[] = array("name" => $sessionFile["name"], "usrName" => $file["name"], "size" => $sessionFile["size"], "type" => $sessionFile["type"] ); if($this->pageObject->pSetEdit->getCreateThumbnail($this->field) && $sessionFile["thumbnail"] != "") { $lastIndex = count($result) - 1; $result[$lastIndex]["thumbnail"] = $sessionFile["thumbnail"]; $result[$lastIndex]["thumbnail_type"] = $sessionFile["thumbnail_type"]; $result[$lastIndex]["thumbnail_size"] = $sessionFile["thumbnail_size"]; } $_SESSION["mupload_".$this->formStamp][$file["name"]]["deleted"] = false; } } if(count($result) > 0) { $result[0]["searchStr"] = $searchStr.":sStrEnd"; $this->webValue = my_json_encode_unescaped_unicode($result); } else $this->webValue = ""; } } else $this->webValue = false; if(!($this->webValue===false)) { $avalues[$this->field] = $this->webValue; } } public function showDBValue($value, $keyLink) { $imageValue = ""; $this->initUploadHandler(); $this->upload_handler->tkeys = $keyLink; $filesArray = my_json_decode($value); if(!is_array($filesArray) || count($filesArray) == 0) { if($value == "") $filesArray = array(); else { $uploadedFile = $this->upload_handler->get_file_object($value); if(is_null($uploadedFile)) $filesArray = array(); else $filesArray = array($uploadedFile); } } foreach ($filesArray as $imageFile) { $userFile = $this->upload_handler->buildUserFile($imageFile); if($this->pageObject->pSetEdit->getViewFormat($this->field) == FORMAT_FILE) { $imageValue .= ($imageValue != "" ? "" : ""); $imageValue .= '' .runner_htmlspecialchars($imageFile["usrName"] != "" ? $imageFile["usrName"] : $imageFile["name"]).''; } else if(CheckImageExtension($imageFile["name"])) { $imageValue .= ($imageValue != "" ? "" : ""); if($this->pageObject->pSetEdit->showThumbnail($this->field)) { $thumbname = $userFile["thumbnail_url"]; $imageValue .= ""; $imageValue .= "