本文整理汇总了PHP中eZHTTPFile::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZHTTPFile::fetch方法的具体用法?PHP eZHTTPFile::fetch怎么用?PHP eZHTTPFile::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZHTTPFile
的用法示例。
在下文中一共展示了eZHTTPFile::fetch方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version 2013.11
* @package kernel
*/
$module = $Params['Module'];
if (!eZPackage::canUsePolicyFunction('import')) {
return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
$package = false;
$installElements = false;
$errorList = array();
if ($module->isCurrentAction('UploadPackage')) {
if (eZHTTPFile::canFetch('PackageBinaryFile')) {
$file = eZHTTPFile::fetch('PackageBinaryFile');
if ($file) {
$packageFilename = $file->attribute('filename');
$package = eZPackage::import($packageFilename, $packageName);
if ($package instanceof eZPackage) {
if ($package->attribute('install_type') != 'install' or !$package->attribute('can_install')) {
return $module->redirectToView('view', array('full', $package->attribute('name')));
} else {
if ($package->attribute('install_type') == 'install') {
return $module->redirectToView('install', array($package->attribute('name')));
}
}
} else {
if ($package == eZPackage::STATUS_ALREADY_EXISTS) {
$errorList[] = array('description' => ezpI18n::tr('kernel/package', 'Package %packagename already exists, cannot import the package', false, array('%packagename' => $packageName)));
} else {
示例2: fetchObjectAttributeHTTPInput
/**
* Fetch object attribute http input, override the ezDataType method
* This method is triggered when submiting a http form which includes Image class
* Image is stored into file system every time there is a file input and validation result is valid.
* @param $http http object
* @param $base
* @param $contentObjectAttribute : the content object attribute being handled
* @return true if content object is not null, false if content object is null
*/
function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$result = false;
$imageAltText = false;
$hasImageAltText = false;
if ($http->hasPostVariable($base . "_data_imagealttext_" . $contentObjectAttribute->attribute("id"))) {
$imageAltText = $http->postVariable($base . "_data_imagealttext_" . $contentObjectAttribute->attribute("id"));
$hasImageAltText = true;
}
$content = $contentObjectAttribute->attribute('content');
$httpFileName = $base . "_data_imagename_" . $contentObjectAttribute->attribute("id");
if (eZHTTPFile::canFetch($httpFileName)) {
$httpFile = eZHTTPFile::fetch($httpFileName);
if ($httpFile) {
if ($content) {
$content->setHTTPFile($httpFile);
$result = true;
}
}
}
if ($content) {
if ($hasImageAltText) {
$content->setAttribute('alternative_text', $imageAltText);
}
$result = true;
}
return $result;
}
示例3: uploadPackage
/**
* Upload local package.
*
* \private
*/
function uploadPackage()
{
if (!eZHTTPFile::canFetch('PackageBinaryFile')) {
$this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'No package selected for upload') . '.';
return;
}
$file = eZHTTPFile::fetch('PackageBinaryFile');
if (!$file) {
$this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'Failed fetching upload package file');
return;
}
$packageFilename = $file->attribute('filename');
$packageName = $file->attribute('original_filename');
if (preg_match("#^(.+)-[0-9](\\.[0-9]+)-[0-9].ezpkg\$#", $packageName, $matches)) {
$packageName = $matches[1];
}
$packageName = preg_replace(array("#[^a-zA-Z0-9]+#", "#_+#", "#(^_)|(_\$)#"), array('_', '_', ''), $packageName);
$package = eZPackage::import($packageFilename, $packageName, false);
if (is_object($package)) {
// package successfully imported
return;
} elseif ($package == eZPackage::STATUS_ALREADY_EXISTS) {
eZDebug::writeWarning("Package '{$packageName}' already exists.");
} else {
$this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'Uploaded file is not an eZ Publish package');
}
}
示例4: 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;
}
示例5: fetchObjectAttributeHTTPInput
function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
{
eZBinaryFileType::checkFileUploads();
if ( $this->isDeletingFile( $http, $contentObjectAttribute ) )
{
return false;
}
if ( !eZHTTPFile::canFetch( $base . "_data_binaryfilename_" . $contentObjectAttribute->attribute( "id" ) ) )
return false;
$binaryFile = eZHTTPFile::fetch( $base . "_data_binaryfilename_" . $contentObjectAttribute->attribute( "id" ) );
$contentObjectAttribute->setContent( $binaryFile );
if ( $binaryFile instanceof eZHTTPFile )
{
$contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
$version = $contentObjectAttribute->attribute( "version" );
/*
$mimeObj = new eZMimeType();
$mimeData = $mimeObj->findByURL( $binaryFile->attribute( "original_filename" ), true );
$mime = $mimeData['name'];
*/
$mimeData = eZMimeType::findByFileContents( $binaryFile->attribute( "original_filename" ) );
$mime = $mimeData['name'];
if ( $mime == '' )
{
$mime = $binaryFile->attribute( "mime_type" );
}
$extension = eZFile::suffix( $binaryFile->attribute( "original_filename" ) );
$binaryFile->setMimeType( $mime );
if ( !$binaryFile->store( "original", $extension ) )
{
eZDebug::writeError( "Failed to store http-file: " . $binaryFile->attribute( "original_filename" ),
"eZBinaryFileType" );
return false;
}
$binary = eZBinaryFile::fetch( $contentObjectAttributeID, $version );
if ( $binary === null )
$binary = eZBinaryFile::create( $contentObjectAttributeID, $version );
$orig_dir = $binaryFile->storageDir( "original" );
$binary->setAttribute( "contentobject_attribute_id", $contentObjectAttributeID );
$binary->setAttribute( "version", $version );
$binary->setAttribute( "filename", basename( $binaryFile->attribute( "filename" ) ) );
$binary->setAttribute( "original_filename", $binaryFile->attribute( "original_filename" ) );
$binary->setAttribute( "mime_type", $mime );
$binary->store();
$filePath = $binaryFile->attribute( 'filename' );
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileStore( $filePath, 'binaryfile', true, $mime );
$contentObjectAttribute->setContent( $binary );
}
return true;
}
示例6: fetchHTTPFile
/**
* Fetches the HTTP-File into $file and fills in MIME-Type information into $mimeData.
*
* @return bool false if something went wrong.
*/
function fetchHTTPFile($httpFileIdentifier, &$errors, &$file, &$mimeData)
{
$returnCode = eZHTTPFile::canFetch($httpFileIdentifier, 0);
if ($returnCode !== eZHTTPFile::UPLOADEDFILE_OK && $returnCode !== true) {
switch ($returnCode) {
case eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST:
$errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'A file is required for upload, no file were found.'));
break;
case eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT:
case eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE:
$errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'The uploaded file size is above the maximum limit.'));
break;
case eZHTTPFile::UPLOADEDFILE_MISSING_TMP_DIR:
case eZHTTPFile::UPLOADEDFILE_CANT_WRITE:
case eZHTTPFile::UPLOADEDFILE_UNKNOWN_ERROR:
$errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'A system error occured while writing the uploaded file.'));
break;
}
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 true;
}
示例7: fetchObjectAttributeHTTPInput
function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
eZMediaType::checkFileUploads();
$classAttribute = $contentObjectAttribute->contentClassAttribute();
$player = $classAttribute->attribute("data_text1");
$pluginPage = eZMediaType::pluginPage($player);
$contentObjectAttributeID = $contentObjectAttribute->attribute("id");
$version = $contentObjectAttribute->attribute("version");
$width = $http->postVariable($base . "_data_media_width_" . $contentObjectAttribute->attribute("id"));
$height = $http->postVariable($base . "_data_media_height_" . $contentObjectAttribute->attribute("id"));
$quality = $http->hasPostVariable($base . "_data_media_quality_" . $contentObjectAttribute->attribute("id")) ? $http->postVariable($base . "_data_media_quality_" . $contentObjectAttribute->attribute("id")) : null;
if ($http->hasPostVariable($base . "_data_media_controls_" . $contentObjectAttribute->attribute("id"))) {
$controls = $http->postVariable($base . "_data_media_controls_" . $contentObjectAttribute->attribute("id"));
} else {
$controls = null;
}
$media = eZMedia::fetch($contentObjectAttributeID, $version);
if ($media == null) {
$media = eZMedia::create($contentObjectAttributeID, $version);
}
$media->setAttribute("contentobject_attribute_id", $contentObjectAttributeID);
$media->setAttribute("version", $version);
$media->setAttribute("width", $width);
$media->setAttribute("height", $height);
$media->setAttribute("quality", $quality);
$media->setAttribute("controls", $controls);
$media->setAttribute("pluginspage", $pluginPage);
if ($http->hasPostVariable($base . "_data_media_is_autoplay_" . $contentObjectAttribute->attribute("id"))) {
$media->setAttribute("is_autoplay", true);
} else {
$media->setAttribute("is_autoplay", false);
}
if ($http->hasPostVariable($base . "_data_media_has_controller_" . $contentObjectAttribute->attribute("id"))) {
$media->setAttribute("has_controller", true);
} else {
$media->setAttribute("has_controller", false);
}
if ($http->hasPostVariable($base . "_data_media_is_loop_" . $contentObjectAttribute->attribute("id"))) {
$media->setAttribute("is_loop", true);
} else {
$media->setAttribute("is_loop", false);
}
$mediaFilePostVarName = $base . "_data_mediafilename_" . $contentObjectAttribute->attribute("id");
if (eZHTTPFile::canFetch($mediaFilePostVarName)) {
$mediaFile = eZHTTPFile::fetch($mediaFilePostVarName);
} else {
$mediaFile = null;
}
if ($mediaFile instanceof eZHTTPFile) {
$mimeData = eZMimeType::findByFileContents($mediaFile->attribute("original_filename"));
$mime = $mimeData['name'];
if ($mime == '') {
$mime = $mediaFile->attribute("mime_type");
}
$extension = eZFile::suffix($mediaFile->attribute("original_filename"));
$mediaFile->setMimeType($mime);
if (!$mediaFile->store("original", $extension)) {
eZDebug::writeError("Failed to store http-file: " . $mediaFile->attribute("original_filename"), "eZMediaType");
return false;
}
$orig_dir = $mediaFile->storageDir("original");
eZDebug::writeNotice("dir={$orig_dir}");
$media->setAttribute("filename", basename($mediaFile->attribute("filename")));
$media->setAttribute("original_filename", $mediaFile->attribute("original_filename"));
$media->setAttribute("mime_type", $mime);
$filePath = $mediaFile->attribute('filename');
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileStore($filePath, 'media', true, $mime);
} else {
if ($media->attribute('filename') == '') {
$media->remove();
return false;
}
}
$media->store();
$contentObjectAttribute->setContent($media);
return true;
}
示例8: date
if ($access['accessWord'] == 'yes') {
$importCsvFile = true;
} else {
return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
}
// upload csv and store data
if (eZHTTPFile::canFetch('UploadCsvFile') && $importId == 0) {
$importType = 'cjwnl_csv';
$dataText = '';
$remoteId = false;
//$remoteId = 'csv:' . md5( $csvFilePath );
// create new Import Object
$importObject = CjwNewsletterImport::create($listContentObjectId, $importType, $note, $dataText, $remoteId);
$importObject->store();
$binaryFile = eZHTTPFile::fetch('UploadCsvFile');
$filePathUpload = $binaryFile->attribute('filename');
$fileSep = eZSys::fileSeparator();
// $fileSize = filesize( $filePathUpload );
//$siteDir = eZSys::siteDir();
$dir = eZSys::varDirectory() . $fileSep . 'cjw_newsletter' . $fileSep . 'csvimport';
$importId = $importObject->attribute('id');
$fileName = $importId . '-' . date("Ymd-His", $importObject->attribute('created')) . '-' . $binaryFile->attribute('original_filename');
$csvFilePath = $dir . $fileSep . $fileName;
$importObject->setAttribute('data_text', $csvFilePath);
$importObject->setAttribute('note', $note);
// create dir
eZDir::mkdir($dir, false, true);
$createResult = copy($filePathUpload, $csvFilePath);
$importObject->store();
// after import object is created redirect to view with import_id
示例9: makeErrorArray
else
{
eZDebug::writeError( "Cannot import document, supplied placement nodeID is not valid." );
$tpl->setVariable( 'error', makeErrorArray( eZOOImport::ERROR_PLACEMENTINVALID,
ezpI18n::tr( 'extension/ezodf/import/error', "Cannot import document, supplied placement nodeID is not valid." ) ) );
}
// $tpl->setVariable( 'oo_mode', 'imported' );
}
else
{
$tpl->setVariable( 'oo_mode', 'browse' );
if( eZHTTPFile::canFetch( "oo_file" ) )
{
$file = eZHTTPFile::fetch( "oo_file" );
if ( $file )
{
if ( $file->store() )
{
$fileName = $file->attribute( 'filename' );
$originalFileName = $file->attribute( 'original_filename' );
// If we have the NodeID do the import/replace directly
if ( $http->sessionVariable( 'oo_direct_import_node' ) )
{
$nodeID = $http->sessionVariable( 'oo_direct_import_node' );
$importType = $http->sessionVariable( 'oo_import_type' );
if ( $importType != "replace" )
示例10: print
// User authentication
$user = eZUser::loginUser( $username, $password );
if ( $user == false )
{
print( 'problem:Authentication failed' );
eZExecution::cleanExit();
}
if ( !eZHTTPFile::canFetch( 'File' ) )
{
print( 'problem:Can\'t fetch HTTP file.' );
eZExecution::cleanExit();
}
$file = eZHTTPFile::fetch('File');
$fileName = $file->attribute( 'filename' );
$originalFilename = $file->attribute('original_filename');
$content = base64_decode( file_get_contents( $fileName ) );
$fd = fopen( $fileName, 'w' );
fwrite( $fd, $content );
fclose( $fd );
// Conversion of the stored file
$import = new eZOOImport();
$importResult = $import->import( $fileName, $nodeID, $originalFilename, $importType );
// Verification : conversion OK ?
示例11: 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;
}
示例12: validateFileHTTPInput
function validateFileHTTPInput($base, $contentObjectAttribute, $classAttribute)
{
//Check allowed file type
//Have to do it here again, otherwise no error message
$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;
}
//Check size
$mustUpload = false;
$maxSize = 1024 * 1024 * $classAttribute->attribute(self::MAX_FILESIZE_FIELD);
/* Since it is not an ezbinary file this can never be true
unfortunately, this is where the check would be to not upload the file
multiple times in the event the form fails somewhere. Unfortunately it
can't be a binary file since it is a collection object and not a content
object.
if ( $contentObjectAttribute->validateIsRequired() )
{
$contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
$version = $contentObjectAttribute->attribute( "version" );
$binary = eZBinaryFile::fetch( $contentObjectAttributeID, $version );
if ( $binary === null )
{
$mustUpload = true;
}
}
*/
$canFetchResult = EnhancedeZBinaryFileType::canFetch($base . "_data_enhancedbinaryfilename_" . $contentObjectAttribute->attribute("id"), $maxSize);
//$binaryfile doesn't have an attribute(http_name)
if ($mustUpload && $canFetchResult === eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'A valid 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 file exceeds the limit set by the upload_max_filesize directive in php.ini.'));
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 maximum upload size: %1 bytes.'), $maxSize);
return eZInputValidator::STATE_INVALID;
}
//Dropped all the way through with no error
return eZInputValidator::STATE_ACCEPTED;
}
示例13: fileupload
/**
* Saves a file for import option
* @param array $args First value: handler id, second value: option id
* @return string saved file name
* @throws SQLIImportRuntimeException
*/
public static function fileupload($args)
{
if (count($args) !== 2) {
throw new SQLIImportRuntimeException('Invalid arguments');
}
$handler = $args[0];
$option = $args[1];
$importINI = eZINI::instance('sqliimport.ini');
$handlerSection = $handler . '-HandlerSettings';
if (!$importINI->hasSection($handlerSection)) {
throw new SQLIImportRuntimeException('No config for handler ' . $handler);
}
$options = $importINI->variable($handlerSection, 'Options');
if (!in_array($option, $options)) {
throw new SQLIImportRuntimeException('Invalid option ' . $option);
}
$returnCode = eZHTTPFile::canFetch('Filedata', 0);
if ($returnCode !== eZHTTPFile::UPLOADEDFILE_OK && $returnCode !== true) {
throw new SQLIImportRuntimeException('Invalid uploaded file');
}
$file = eZHTTPFile::fetch('Filedata');
if (!$file instanceof eZHTTPFile) {
throw new SQLIImportRuntimeException('Invalid uploaded file');
}
if (self::checkFileFormat($handler, $option, $file)) {
$dir = $importINI->variable('OptionsGUISettings', 'UploadedFilesDir') . DIRECTORY_SEPARATOR . $handler . DIRECTORY_SEPARATOR . $option;
//temporarily store uploaded file before clusterizing it
$file->store($dir);
eZClusterFileHandler::instance()->fileStore($file->attribute('filename'), false, true);
return $file->attribute('filename');
}
}