Example #1
0
 /**
  * @param String fieldValue
  * @return String
  */
 function getFieldValueCopy($fieldValue)
 {
     $this->initUploadHandler();
     $uploadFolder = $this->pageObject->pSetEdit->getUploadFolder($this->field);
     $absoluteUploadDirPath = $this->pageObject->pSetEdit->getFinalUploadFolder($this->field);
     $filesData = my_json_decode($fieldValue);
     if (!is_array($filesData) || count($filesData) == 0) {
         return $fieldValue;
     }
     foreach ($filesData as $idx => $fileData) {
         $info = $this->upload_handler->pathinfo_local($fileData["usrName"]);
         $newFieldName = $this->upload_handler->tempnam_sfx($absoluteUploadDirPath, $info['filename'], $info['extension']);
         runner_copy_file(getabspath($fileData["name"]), $absoluteUploadDirPath . $newFieldName);
         $filesData[$idx]["name"] = $uploadFolder . $newFieldName;
         if ($this->pageObject->pSetEdit->getCreateThumbnail($this->field)) {
             $thumbnailPrefix = $this->pageObject->pSetEdit->getStrThumbnail($this->field);
             $newThumbName = $this->upload_handler->tempnam_sfx($absoluteUploadDirPath, $thumbnailPrefix . $info['filename'], $info['extension']);
             runner_copy_file(getabspath($fileData["thumbnail"]), $absoluteUploadDirPath . $newThumbName);
             $filesData[$idx]["thumbnail"] = $uploadFolder . $newThumbName;
         }
     }
     return my_json_encode($filesData);
 }