public function showDBValue(&$data, $keylink) { if ($this->container->forExport) { return "LONG BINARY DATA - CANNOT BE DISPLAYED"; } $value = ""; if (@$data[$this->field] != NULL && $this->container->pageType != PAGE_PRINT) { $videoId = 'video_' . GoodFieldName(htmlspecialchars($this->field)) . '_'; $videoId .= $this->getContainer()->id . "_"; if ($this->getContainer()->pageType != PAGE_ADD) { $videoId .= $this->getContainer()->recId; } else { $videoId .= postvalue("id"); } $type = 'video/flv'; $fileName = 'file.flv'; $fileNameF = $this->getContainer()->pSet->getFilenameField($this->field); if ($fileNameF) { $fileName = $data[$fileNameF]; if (!$fileName) { $fileName = 'file.flv'; } else { $type = getContentTypeByExtension(substr($fileName, strrpos($fileName, '.'))); } } $href = "mfhandler.php?filename=" . $fileName . "&table=" . rawurlencode($this->getContainer()->pSet->_table) . "&field=" . rawurlencode($this->field) . "&pageType=" . $this->getContainer()->pageType . $keylink; if (isMobileIOS()) { $value = '<video width="' . $this->getContainer()->pSet->getVideoWidth($this->field) . '" height="' . $this->getContainer()->pSet->getVideoHeight($this->field) . '" controls="controls"> <source src="' . $href . '" type="' . $type . '" /> Your browser does not support the video tag. </video>'; } else { $vWidth = $this->getContainer()->pSet->getVideoWidth($this->field); $vHeight = $this->getContainer()->pSet->getVideoHeight($this->field); if ($vWidth == 0) { $vWidth = 300; } if ($vHeight == 0) { $vHeight = 200; } $value .= ' <div style="width:' . $vWidth . 'px; height:' . $vHeight . 'px;"> <video class="projekktor" width="' . $vWidth . '" height="' . $vHeight . '" id="' . $videoId . '" type="' . $type . '" src="' . $href . '" > </video></div>'; } if ($this->pageObject != null) { $this->pageObject->controlsMap['video'][] = $videoId; } } else { $fileNameF = $this->getContainer()->pSet->getFilenameField($this->field); if ($fileNameF) { $fileName = $data[$fileNameF]; if (!$fileName) { $value = $fileName; } } } return $value; }
public function showDBValue(&$data, $keylink) { $value = ""; if (@$data[$this->field] != NULL && $this->container->pageType != PAGE_PRINT) { $videoId = 'video_' . GoodFieldName(runner_htmlspecialchars($this->field)) . '_'; $videoId .= $this->getContainer()->id . "_"; if ($this->getContainer()->pageType != PAGE_ADD) { $videoId .= $this->getContainer()->recId; } else { $videoId .= postvalue("id"); } $type = 'video/mp4'; $fileName = 'file.mp4'; $fileNameF = $this->getContainer()->pSet->getFilenameField($this->field); if ($fileNameF) { $fileName = $data[$fileNameF]; if (!$fileName) { $fileName = 'file.mp4'; } else { $type = getContentTypeByExtension(substr($fileName, strrpos($fileName, '.'))); } } $href = GetTableLink("mfhandler", "", "filename=" . $fileName . "&table=" . rawurlencode($this->getContainer()->pSet->_table) . "&field=" . rawurlencode($this->field) . "&pageType=" . $this->getContainer()->pageType . $keylink); $vWidth = $this->getContainer()->pSet->getVideoWidth($this->field); $vHeight = $this->getContainer()->pSet->getVideoHeight($this->field); if ($vWidth == 0) { $vWidth = 300; } if ($vHeight == 0) { $vHeight = 200; } $value .= ' <div style="width:' . $vWidth . 'px; height:' . $vHeight . 'px;"> <video class="projekktor" width="' . $vWidth . '" height="' . $vHeight . '" id="' . $videoId . '" type="' . $type . '" src="' . $href . '" > </video></div>'; if ($this->pageObject != null) { $this->pageObject->controlsMap['video'][] = $videoId; } } else { $fileNameF = $this->getContainer()->pSet->getFilenameField($this->field); if ($fileNameF) { $fileName = $data[$fileNameF]; if (!$fileName) { $value = $fileName; } } } return $value; }
public function handle_file_upload($uploadedFile, $index) { $tmpName = $uploadedFile["tmp_name"]; $name = $uploadedFile["name"]; $size = $uploadedFile["size"]; $type = $uploadedFile["type"]; $error = $uploadedFile["error"]; $fileInfo = array("name" => $name, "size" => intval($size), "type" => $type, "isThumbnail" => false); $uploadDir = $this->pSet->getFinalUploadFolder($this->field, $fileInfo); $uploadDirRelative = $this->pSet->getUploadFolder($this->field, $fileInfo); $file = array(); $file["error"] = false; $file["name"] = trim_file_name($name, $type, $index, $this); $file["usrName"] = $file["name"]; $file["size"] = intval($size); switch ($type) { case "image/png": case "image/x-png": $file["type"] = "image/png"; break; case "image/jpeg": case "image/pjpeg": $file["type"] = "image/jpeg"; break; default: $file["type"] = $type; } $path_parts = $this->pathinfo_local($name); if ($file["type"] == "") { $file["type"] = getContentTypeByExtension($path_parts["extension"]); } $file["isImg"] = false; $file["thumbnail"] = ""; if ($this->pSet->isMakeDirectoryNeeded($this->field)) { if (!makeSurePathExists($uploadDir)) { $file["error"] = "Upload folder doesn't exist"; return $file; } } else { if (!is_dir($uploadDir)) { $file["error"] = "Upload folder doesn't exist"; return $file; } } if ($this->validate($uploadedFile, $file, $error, $size, $index, $uploadDir)) { $file["isImg"] = CheckImageExtension($tmpName) != false; $this->handle_form_data($file, $index); $file["name"] = $this->tempnam_sfx($uploadDir, $path_parts["filename"], $path_parts["extension"]); $file_path = $uploadDir . $file["name"]; clearstatcache(); upload_File($uploadedFile, $file_path); $file_size = filesize($file_path); if ($this->options["resizeOnUpload"]) { $tempOptions = array('max_width' => $this->options["max_width"], 'max_height' => $this->options["max_width"]); $new_file_name = $this->tempnam_sfx($uploadDir, $path_parts["filename"], $path_parts["extension"]); if ($this->create_scaled_image($uploadDir . $file["name"], $uploadDir, $new_file_name, $tempOptions, $file, false, $uploadDirRelative, $uploadedFile)) { unlink($file_path); $file["name"] = $new_file_name; $file_path = $uploadDir . $new_file_name; $file_size = filesize($file_path); } } if ($file_size === $file["size"]) { $file["url"] = $uploadDir . rawurlencode($file["name"]); foreach ($this->options['image_versions'] as $version => $options) { $fileInfoThimbnail = array("name" => $name, "size" => intval($size), "type" => $type, "isThumbnail" => true); $thumbUploadDir = $this->pSet->getFinalUploadFolder($this->field, $fileInfoThimbnail); $thumbUploadDirRelative = $this->pSet->getUploadFolder($this->field, $fileInfoThimbnail); if ($this->pSet->isMakeDirectoryNeeded($this->field)) { if (!makeSurePathExists($thumbUploadDir)) { continue; } } $thumbnail_name = $this->tempnam_sfx($thumbUploadDir, $options['thumbnailPrefix'] . $path_parts["filename"], $path_parts["extension"]); if ($this->create_scaled_image($uploadDir . $file["name"], $thumbUploadDir, $thumbnail_name, $options, $file, true, $thumbUploadDirRelative, $uploadedFile)) { clearstatcache(); $file_size = filesize($file_path); } } } else { unlink($file_path); $file["error"] = 'abort'; } $file["size"] = $file_size; $file["name"] = $uploadDirRelative . $file["name"]; $this->set_file_delete_url($file); } return $file; }
} } } } } $iconShowed = false; if ($isDBFile) { $ftype = ""; if ($pSet->getViewFormat($field) == FORMAT_DATABASE_IMAGE) { if (!$value) { $value = myfile_get_contents('images/no_image.gif'); } $ftype = SupposeImageType($value); } if (!$ftype) { $ftype = getContentTypeByExtension(substr($fileName, strrpos($fileName, '.'))); } $fsize = strlen_bin($value); } else { if ($sessionFile != null) { $isThumbnail = false; $isSRC = false; if ($isPDF) { $isThumbnail = isset($params["thumbnail"]); $isSRC = isset($params['src']); } else { $isThumbnail = postvalue("thumbnail") != ""; $isSRC = postvalue('src') == 1; } if (postvalue("icon") != "") { $fsFileName = "images/icons/" . getIconByFileType($sessionFile["type"], $sessionFile["name"]);
public function getFileIconByType($file_name, $fileType) { $fileName = "no_image.gif"; if ($fileType == "") { $fileType = getContentTypeByExtension(substr($file_name, strrpos($file_name, '.'))); } return getIconByFileType($fileType, $file_name); }