本文整理汇总了PHP中eZMimeType类的典型用法代码示例。如果您正苦于以下问题:PHP eZMimeType类的具体用法?PHP eZMimeType怎么用?PHP eZMimeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZMimeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyImagesToDB
function copyImagesToDB($remove)
{
global $cli, $fileHandler;
$db = eZDB::instance();
$cli->output("Importing images and imagealiases files to database:");
$rows = $db->arrayQuery('select filepath from ezimagefile');
foreach ($rows as $row) {
$filePath = $row['filepath'];
$cli->output("- " . $filePath);
$mimeData = eZMimeType::findByFileContents($filePath);
$fileHandler->fileStore($filePath, 'image', $remove, $mimeData['name']);
}
}
示例2: fetchNodeInfo
/**
* Gathers information about a given node specified as parameter.
*
* The format of the returned array is:
* <code>
* array( 'name' => node name (eg. 'Group picture'),
* 'size' => storage size of the_node in bytes (eg. 57123),
* 'mimetype' => mime type of the node (eg. 'image/jpeg'),
* 'ctime' => creation time as timestamp,
* 'mtime' => latest modification time as timestamp,
* 'href' => the path to the node (eg. '/plain_site_user/Content/Folder1/file1.jpg')
* </code>
*
* @param string $target Eg. '/plain_site_user/Content/Folder1/file1.jpg
* @param eZContentObject &$node The node corresponding to $target
* @return array(string=>mixed)
* @todo remove/replace .ini calls, eZContentUpload, eZMimeType, eZSys RequestURI
* @todo handle articles as files
*/
protected function fetchNodeInfo($target, &$node)
{
// When finished, we'll return an array of attributes/properties.
$entry = array();
$classIdentifier = $node->attribute('class_identifier');
$object = $node->attribute('object');
$urlAlias = $node->urlAlias();
// By default, everything is displayed as a folder:
// Trim the name of the node, it is in some cases whitespace in eZ Publish
$name = trim($node->attribute('name'));
// @as 2009-03-09: return node_id as displayname in case name is missing
// displayname is not actually used by WebDAV clients
$entry["name"] = $name !== '' && $name !== NULL ? $name : $node->attribute('node_id');
$entry["size"] = 0;
$entry["mimetype"] = self::DIRECTORY_MIMETYPE;
eZWebDAVContentBackend::appendLogEntry('FetchNodeInfo:' . $node->attribute('name') . '/' . $urlAlias);
// @todo handle articles as files
// if ( $classIdentifier === 'article' )
// {
// $entry["mimetype"] = 'application/ms-word';
// }
$entry["ctime"] = $object->attribute('published');
$entry["mtime"] = $object->attribute('modified');
$upload = new eZContentUpload();
$info = $upload->objectFileInfo($object);
$suffix = '';
$class = $object->contentClass();
$isObjectFolder = $this->isObjectFolder($object, $class);
if ($isObjectFolder) {
// We do nothing, the default is to see it as a folder
} else {
if ($info) {
$filePath = $info['filepath'];
$entry['filepath'] = $filePath;
$entry["mimetype"] = false;
$entry["size"] = false;
if (isset($info['filesize'])) {
$entry['size'] = $info['filesize'];
}
if (isset($info['mime_type'])) {
$entry['mimetype'] = $info['mime_type'];
}
// Fill in information from the actual file if they are missing.
$file = eZClusterFileHandler::instance($filePath);
if (!$entry['size'] and $file->exists()) {
$entry["size"] = $file->size();
}
if (!$entry['mimetype']) {
$mimeInfo = eZMimeType::findByURL($filePath);
$entry["mimetype"] = $mimeInfo['name'];
$suffix = $mimeInfo['suffix'];
if (strlen($suffix) > 0) {
$entry["name"] .= '.' . $suffix;
}
} else {
// eZMimeType returns first suffix in its list
// this could be another one than the original file extension
// so let's try to get the suffix from the file path first
$suffix = eZFile::suffix($filePath);
if (!$suffix) {
$mimeInfo = eZMimeType::findByName($entry['mimetype']);
$suffix = $mimeInfo['suffix'];
}
if (strlen($suffix) > 0) {
$entry["name"] .= '.' . $suffix;
}
}
if ($file->exists()) {
$entry["ctime"] = $file->mtime();
$entry["mtime"] = $file->mtime();
}
} else {
// Here we only show items as folders if they have
// is_container set to true, otherwise it's an unknown binary file
if (!$class->attribute('is_container')) {
$entry['mimetype'] = 'application/octet-stream';
}
}
}
$scriptURL = $target;
if (strlen($scriptURL) > 0 and $scriptURL[strlen($scriptURL) - 1] !== "/") {
//.........这里部分代码省略.........
示例3: fetchCollectionAttributeHTTPInput
function fetchCollectionAttributeHTTPInput($collection, $collectionAttribute, $http, $base, $contentObjectAttribute)
{
EnhancedeZBinaryFileType::checkFileUploads();
if (eZHTTPFile::canFetch($base . "_data_enhancedbinaryfilename_" . $contentObjectAttribute->attribute("id")) != eZHTTPFile::UPLOADEDFILE_OK) {
return false;
}
//Check allowed file type - must do it here,again - otherwise an illegal
//file will still be created in the storage directory
$binaryFile = eZHTTPFile::fetch($base . "_data_enhancedbinaryfilename_" . $contentObjectAttribute->attribute("id"));
if (!$binaryFile) {
return eZInputValidator::STATE_INVALID;
}
$moduleINI = eZINI::instance('module.ini.append.php', 'settings');
$allowed = $moduleINI->variable('AllowedFileTypes', 'AllowedFileTypeList');
// $binaryFile->attribute( 'mime_type_part' ) not always the extension
$extension = preg_replace('/.*\\.(.+?)$/', '\\1', $binaryFile->attribute("original_filename"));
if (!in_array(strtolower($extension), $allowed)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Failed to store file. Only the following file types are allowed: %1.'), implode(", ", $allowed));
return eZInputValidator::STATE_INVALID;
}
//$contentObjectAttribute->setContent( $binaryFile );
if ($binaryFile instanceof eZHTTPFile) {
//clean up older files.
$moduleINI = eZINI::instance('module.ini.append.php', 'settings');
$maxFiles = $moduleINI->variable('RemoveFiles', 'MaxFiles');
$downloadPath = $moduleINI->variable('RemoveFiles', 'DownloadPath');
$downloadPath = trim($downloadPath, "/");
if (!$downloadPath) {
$downloadPath = 'original/collected';
}
if ($maxFiles > 0) {
$Files = array();
$storageDir = eZSys::storageDirectory();
$fileCollection = eZDir::recursiveFindRelative($storageDir, $downloadPath, '.*');
if (count($fileCollection) >= $maxFiles) {
foreach ($fileCollection as $fileItem) {
$lastModified = filemtime($storageDir . '/' . $fileItem);
$Files[$fileItem] = filemtime($storageDir . '/' . $fileItem);
}
asort($Files, SORT_NUMERIC);
while (count($Files) >= $maxFiles) {
$removeFile = key($Files);
if (file_exists($storageDir . '/' . $removeFile)) {
if (!unlink($storageDir . '/' . $removeFile)) {
eZDebug::writeError("Failed to delete file: " . $storageDir . '/' . $removeFile, "EnhancedeZBinaryFileType");
return false;
}
}
array_shift($Files);
}
}
}
//end cleanup
// $contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
//$version = $contentObjectAttribute->attribute( "version" );
$mimeData = eZMimeType::findByFileContents($binaryFile->attribute("original_filename"));
//Nice name but it still uses the extension to set the mimetype and therefore can be bogus
$mime = $mimeData['name'];
if ($mime == '') {
$mime = $binaryFile->attribute("mime_type");
}
$extension = eZFile::suffix($binaryFile->attribute("original_filename"));
$binaryFile->setMimeType($mime);
if (!$binaryFile->store($downloadPath, $extension)) {
eZDebug::writeError("Failed to store http-file: " . $binaryFile->attribute("original_filename"), "EnhancedeZBinaryFileType");
return false;
}
//Adds xmltext to collection attribute with file info to data_text attribute
$doc = new DOMDocument('1.0', 'utf-8');
$root = $doc->createElement('binaryfile-info');
$binaryFileList = $doc->createElement('binaryfile-attributes');
foreach ($binaryFile as $key => $binaryFileItem) {
$binaryFileElement = $doc->createElement($key, $binaryFileItem);
$binaryFileList->appendChild($binaryFileElement);
}
$root->appendChild($binaryFileList);
$doc->appendChild($root);
$docText = EnhancedeZBinaryFileType::domString($doc);
$collectionAttribute->setAttribute('data_text', $docText);
}
return true;
}
示例4: imageAliasInfo
/**
* Image information for $aliasName. This is the information which normally
* would be provided during generation of aliasName. This so that requests
* not holding the lock will provide meaningful information.
*
* @param mixed $mimeData
* @param string $aliasName
* @return array
*/
function imageAliasInfo( $mimeData, $aliasName, $isAliasNew = false )
{
if ( is_string( $mimeData ) )
$mimeData = eZMimeType::findByFileContents( $mimeData );
$this->analyzeImage( $mimeData );
if ( $aliasName )
{
$aliasList = $this->aliasList();
if ( isset( $aliasList[$aliasName] ) )
{
$alias = $aliasList[$aliasName];
if ( $alias['mime_type'] )
{
eZMimeType::changeMIMEType( $mimeData, $alias['mime_type'] );
}
}
}
if ( $aliasName != 'original' )
{
$mimeData['filename'] = $mimeData['basename'] . '_' . $aliasName . '.' . $mimeData['suffix'];
$mimeData['url'] = $mimeData['dirpath'] . '/' . $mimeData['filename'];
}
// eZDebug::writeDebug( $mimeData, __METHOD__ );
return $mimeData;
}
示例5: validateObjectAttributeHTTPInput
/**
* Validate the object attribute input in http. If there is validation failure, there failure message will be put into $contentObjectAttribute->ValidationError
* @param $http: http object
* @param $base:
* @param $contentObjectAttribute: content object attribute being validated
* @return validation result- eZInputValidator::STATE_INVALID or eZInputValidator::STATE_ACCEPTED
*
* @see kernel/classes/eZDataType#validateObjectAttributeHTTPInput($http, $base, $objectAttribute)
*/
function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$classAttribute = $contentObjectAttribute->contentClassAttribute();
$httpFileName = $base . "_data_imagename_" . $contentObjectAttribute->attribute("id");
$maxSize = 1024 * 1024 * $classAttribute->attribute(self::FILESIZE_FIELD);
$mustUpload = false;
if ($contentObjectAttribute->validateIsRequired()) {
$tmpImgObj = $contentObjectAttribute->attribute('content');
$original = $tmpImgObj->attribute('original');
if (!$original['is_valid']) {
$mustUpload = true;
}
}
$canFetchResult = eZHTTPFile::canFetch($httpFileName, $maxSize);
if (isset($_FILES[$httpFileName]) and $_FILES[$httpFileName]["tmp_name"] != "") {
$imagefile = $_FILES[$httpFileName]['tmp_name'];
if (!$_FILES[$httpFileName]["size"]) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The image file must have non-zero size.'));
return eZInputValidator::STATE_INVALID;
}
if (function_exists('getimagesize')) {
$info = getimagesize($imagefile);
if (!$info) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'A valid image file is required.'));
return eZInputValidator::STATE_INVALID;
}
} else {
$mimeType = eZMimeType::findByURL($_FILES[$httpFileName]['name']);
$nameMimeType = $mimeType['name'];
$nameMimeTypes = explode("/", $nameMimeType);
if ($nameMimeTypes[0] != 'image') {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'A valid image file is required.'));
return eZInputValidator::STATE_INVALID;
}
}
}
if ($mustUpload && $canFetchResult == eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'A valid image file is required.'));
return eZInputValidator::STATE_INVALID;
}
if ($canFetchResult == eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The size of the uploaded image exceeds limit set by upload_max_filesize directive in php.ini. Please contact the site administrator.'));
return eZInputValidator::STATE_INVALID;
}
if ($canFetchResult == eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The size of the uploaded file exceeds the limit set for this site: %1 bytes.'), $maxSize);
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}
示例6: validateImageFiles
function validateImageFiles( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
{
// If we don't have an image we continue as normal
if ( !eZHTTPFile::canFetch( 'PackageImageFile' ) )
return true;
$file = eZHTTPFile::fetch( 'PackageImageFile' );
$result = true;
if ( $file )
{
$mimeData = eZMimeType::findByFileContents( $file->attribute( 'original_filename' ) );
$dir = eZSys::storageDirectory() . '/temp';
eZMimeType::changeDirectoryPath( $mimeData, $dir );
$file->store( false, false, $mimeData );
$persistentData['imagefiles'][] = $mimeData;
$result = false;
}
return $result;
}
示例7: callImage
/**
* Function for insert image
*/
function callImage($info)
{
$params = array();
$leftMargin = false;
$rightMargin = false;
eZPDFTable::extractParameters($info['p'], 0, $params, true);
$filename = rawurldecode($params['src']);
$mimetype = eZMimeType::findByFileContents($filename);
$this->transaction('start');
if (!isset($params['static'])) {
$params['static'] = false;
}
if ($this->yOffset() - $params['height'] < $this->ez['bottomMargin']) {
$this->ezNewPage();
}
if (isset($params['dpi'])) {
$newWidth = (int) ($params['width'] * ((int) $params['dpi'] / 72));
$newHeight = (int) ($params['height'] * ((int) $params['dpi'] / 72));
$newFilename = eZSys::cacheDirectory() . '/' . md5(mt_rand()) . '.jpg';
while (file_exists($newFilename)) {
$newFilename = eZSys::cacheDirectory() . '/' . md5(mt_rand()) . '.jpg';
}
$img = eZImageManager::factory();
$newImg = $img->convert($filename, $newFilename, false, array('filters' => array(array('name' => 'geometry/scaledownonly', 'data' => array($newWidth, $newHeight)))));
$filename = $newFilename['url'];
}
$drawableAreaWidth = $this->ez['pageWidth'] - $this->ez['leftMargin'] - $this->ez['rightMargin'];
switch ($params['align']) {
case 'right':
$xOffset = $this->ez['pageWidth'] - ($this->rightMargin() + $params['width']);
$rightMargin = $this->rightMargin() + $params['width'];
if ($rightMargin > $drawableAreaWidth + $this->rightMargin()) {
// the image is equal or larger then width of the page(of the drawable area) => no point
// to set $rightMargin and next object(text, image, ...) should be outputted below the image.
$rightMargin = false;
}
break;
case 'center':
$xOffset = ($this->ez['pageWidth'] - $this->rightMargin() - $this->leftMargin()) / 2 + $this->leftMargin() - $params['width'] / 2;
break;
case 'left':
default:
$xOffset = $this->leftMargin();
$leftMargin = $this->leftMargin() + $params['width'];
if ($leftMargin > $drawableAreaWidth + $this->leftMargin()) {
// the image is equal or larger then width of the page(of the drawable area) => no point
// to set $leftMargin and next object(text, image, ...) should be outputted below the image.
$leftMargin = false;
}
break;
}
if (isset($params['x'])) {
$xOffset = $params['x'];
$leftMargin = false;
$rightMargin = false;
}
$yOffset = $this->yOffset();
$whileCount = 0;
if ($params['width'] < $drawableAreaWidth) {
while ($this->leftMargin($yOffset) > $xOffset && ++$whileCount < 100) {
$yOffset -= 10;
}
}
$yOffset -= $params['height'];
$yOffset += $this->lineHeight() / 2;
if (isset($params['y'])) {
$yOffset = $params['y'];
}
if ($leftMargin !== false) {
$this->setLimitedLeftMargin($yOffset - 7, $yOffset + $params['height'] + 7, $leftMargin + 7);
}
if ($rightMargin !== false) {
$this->setLimitedRightMargin($yOffset - 7, $yOffset + $params['height'] + 7, $rightMargin + 7);
}
switch ($mimetype['name']) {
case 'image/gif':
$newFilename = eZSys::cacheDirectory() . '/' . md5(mt_rand()) . '.jpg';
while (file_exists($newFilename)) {
$newFilename = eZSys::cacheDirectory() . '/' . md5(mt_rand()) . '.jpg';
}
$newMimetype = eZMimeType::findByURL($newFilename);
$img = eZImageManager::factory();
$newImg = $img->convert($mimetype, $newMimetype, false, array());
$this->addJpegFromFile($newMimetype['url'], $xOffset, $yOffset, $params['width'], $params['height']);
break;
case 'image/jpeg':
$this->addJpegFromFile($filename, $xOffset, $yOffset, $params['width'], $params['height']);
break;
case 'image/png':
if ($this->addPngFromFile($filename, $xOffset, $yOffset, $params['width'], $params['height']) === false) {
$this->transaction('abort');
return;
}
break;
default:
eZDebug::writeError('Unsupported image file type, ' . $mimetype['name'], __METHOD__);
$this->transaction('abort');
//.........这里部分代码省略.........
示例8: fetch
static function fetch($http_name)
{
if (!isset($GLOBALS["eZHTTPFile-{$http_name}"]) || !$GLOBALS["eZHTTPFile-{$http_name}"] instanceof eZHTTPFile) {
$GLOBALS["eZHTTPFile-{$http_name}"] = null;
if (isset($_FILES[$http_name]) and $_FILES[$http_name]["name"] != "") {
$mimeType = eZMimeType::findByURL($_FILES[$http_name]['name']);
$_FILES[$http_name]['type'] = $mimeType['name'];
$GLOBALS["eZHTTPFile-{$http_name}"] = new eZHTTPFile($http_name, $_FILES[$http_name]);
} else {
eZDebug::writeError("Unknown file for post variable: {$http_name}", "eZHTTPFile");
}
}
return $GLOBALS["eZHTTPFile-{$http_name}"];
}
示例9: findByBuffer
static function findByBuffer($buffer, $length = false, $offset = false, $url = false, $returnDefault = true)
{
return eZMimeType::findByURL($url, $returnDefault);
}
示例10: getFileInfo
function getFileInfo($dir, $file)
{
append_to_log("inside getFileInfo, dir: {$dir}, file: {$file}");
$realPath = $dir . '/' . $file;
$fileInfo = array();
$fileInfo["name"] = $file;
// If the file is a directory:
if (is_dir($realPath)) {
$fileInfo["size"] = 0;
$fileInfo["mimetype"] = "httpd/unix-directory";
// Get the dir's creation & modification times.
$fileInfo["ctime"] = filectime($realPath . '/.');
$fileInfo["mtime"] = filemtime($realPath . '/.');
} else {
// Get the file's creation & modification times.
$fileInfo["ctime"] = filectime($realPath);
$fileInfo["mtime"] = filemtime($realPath);
// Get the file size (bytes).
$fileInfo["size"] = filesize($realPath);
// Check if the filename exists and is readable:
if (is_readable($realPath)) {
// Attempt to get & set the MIME type.
$mimeInfo = eZMimeType::findByURL($dir . '/' . $file);
$fileInfo['mimetype'] = $mimeInfo['name'];
} else {
$fileInfo["mimetype"] = "application/x-non-readable";
}
}
// Return the array (hopefully containing correct info).
return $fileInfo;
}
示例11: time
$newBaseName = $objectName;
}
if ($newFilePath != $filePath) {
if (!file_exists($newDirPath)) {
eZDir::mkdir($newDirPath, false, true);
}
eZFileHandler::copy($filePath, $newFilePath);
$filePath = $newFilePath;
$fileName = $newFileName;
$suffix = $newSuffix;
$dirPath = $newDirPath;
$baseName = $newBaseName;
}
}
}
$mimeData = eZMimeType::findByFileContents($fileName);
$imageManager->analyzeImage($mimeData);
$imageNode->setAttribute('serial_number', false);
$imageNode->setAttribute('is_valid', $isValid);
$imageNode->setAttribute('filename', $fileName);
$imageNode->setAttribute('suffix', $suffix);
$imageNode->setAttribute('basename', $baseName);
$imageNode->setAttribute('dirpath', $dirPath);
$imageNode->setAttribute('url', $filePath);
$imageNode->setAttribute('original_filename', $originalFileName);
$imageNode->setAttribute('mime_type', $mimeType);
$imageNode->setAttribute('width', $width);
$imageNode->setAttribute('height', $height);
$imageNode->setAttribute('alternative_text', $altText);
$imageNode->setAttribute('alias_key', $imageManager->createImageAliasKey($imageManager->alias('original')));
$imageNode->setAttribute('timestamp', time());
示例12: insertRegularFile
function insertRegularFile($object, $objectVersion, $objectLanguage, $objectAttribute, $filePath, &$result)
{
$result = array('errors' => array(), 'require_storage' => false);
$attributeID = $objectAttribute->attribute('id');
$media = eZMedia::fetch($attributeID, $objectVersion);
if ($media === null) {
$media = eZMedia::create($attributeID, $objectVersion);
}
$fileName = basename($filePath);
$mimeData = eZMimeType::findByFileContents($filePath);
$storageDir = eZSys::storageDirectory();
list($group, $type) = explode('/', $mimeData['name']);
$destination = $storageDir . '/original/' . $group;
if (!file_exists($destination)) {
if (!eZDir::mkdir($destination, false, true)) {
return false;
}
}
// create dest filename in the same manner as eZHTTPFile::store()
// grab file's suffix
$fileSuffix = eZFile::suffix($fileName);
// prepend dot
if ($fileSuffix) {
$fileSuffix = '.' . $fileSuffix;
}
// grab filename without suffix
$fileBaseName = basename($fileName, $fileSuffix);
// create dest filename
$destFileName = md5($fileBaseName . microtime() . mt_rand()) . $fileSuffix;
$destination = $destination . '/' . $destFileName;
copy($filePath, $destination);
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileStore($destination, 'mediafile', true, $mimeData['name']);
$classAttribute = $objectAttribute->contentClassAttribute();
$player = $classAttribute->attribute("data_text1");
$pluginPage = eZMediaType::pluginPage($player);
$media->setAttribute("contentobject_attribute_id", $attributeID);
$media->setAttribute("version", $objectVersion);
$media->setAttribute("filename", $destFileName);
$media->setAttribute("original_filename", $fileName);
$media->setAttribute("mime_type", $mimeData['name']);
// Setting width and height to zero means that the browser/player must find the size itself.
// In the future we will probably analyze the media file and find this information
$width = $height = 0;
// Quality is not known, so we don't set any
$quality = false;
// Not sure what this is for, set to false
$controls = false;
// We want to show controllers by default
$hasController = true;
// Don't play automatically
$isAutoplay = false;
// Don't loop movie
$isLoop = false;
$media->setAttribute("width", $width);
$media->setAttribute("height", $height);
$media->setAttribute("quality", $quality);
$media->setAttribute("controls", $controls);
$media->setAttribute("pluginspage", $pluginPage);
$media->setAttribute("is_autoplay", $isAutoplay);
$media->setAttribute("has_controller", $hasController);
$media->setAttribute("is_loop", $isLoop);
$media->store();
$objectAttribute->setContent($media);
return true;
}
示例13: passthrough
/**
* Outputs file contents prepending them with appropriate HTTP headers.
*
* \public
*/
function passthrough()
{
$path = $this->filePath;
eZDebugSetting::writeDebug('kernel-clustering', "fs::passthrough()", __METHOD__);
eZDebug::accumulatorStart('dbfile', false, 'dbfile');
$mimeData = eZMimeType::findByFileContents($path);
// $mimeType = $mimeData['name'];
$mimeType = 'application/octec-stream';
$contentLength = filesize($path);
header("Content-Length: {$contentLength}");
header("Content-Type: {$mimeType}");
header("Expires: " . gmdate('D, d M Y H:i:s', time() + 6000) . 'GMT');
header("Connection: close");
readfile($path);
eZDebug::accumulatorStop('dbfile');
}
示例14: fetchHTTPFile
function fetchHTTPFile($httpFileIdentifier, &$errors, &$file, &$mimeData)
{
if (!eZHTTPFile::canFetch($httpFileIdentifier)) {
$errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'A file is required for upload, no file were found.'));
return false;
}
$file = eZHTTPFile::fetch($httpFileIdentifier);
if (!$file instanceof eZHTTPFile) {
$errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'Expected a eZHTTPFile object but got nothing.'));
return false;
}
$mimeData = eZMimeType::findByFileContents($file->attribute("original_filename"));
return false;
}
示例15: initImage
/**
* Initializes image handler for the given application and applies selection rules
* (internal) fetches the good eZContentObjectAttribute containing the expected image and its image alias handler
*
* @return void
* @throws Exception
*/
public function initImage()
{
if ( !isset($this->_imageAttribute) )
{
$this->_imageAttribute = $this->fetchImageAttribute();
if ( $this->_imageAttribute !== true )
{
$handler = new eZImageAliasHandler($this->_imageAttribute);
$this->_aliasHandler = $handler->imageAlias($this->_aliasName);
}
else if ( $this->_isLocalImage )
{
$filePath = self::$_localImagePaths[$this->_localImage];
$mime = eZMimeType::findByURL($filePath);
$this->_aliasHandler = array(
'url' => $filePath,
'filesize' => filesize($filePath),
'mime_type' => $mime['name'],
);
}
else
throw new Exception('Image Attribute has no valid case');
}
}