本文整理汇总了PHP中eZClusterFileHandler类的典型用法代码示例。如果您正苦于以下问题:PHP eZClusterFileHandler类的具体用法?PHP eZClusterFileHandler怎么用?PHP eZClusterFileHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZClusterFileHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleFileDownload
function handleFileDownload($contentObject, $contentObjectAttribute, $type, $fileInfo)
{
$fileName = $fileInfo['filepath'];
$file = eZClusterFileHandler::instance($fileName);
if ($fileName != "" and $file->exists()) {
$fileSize = $file->size();
if (isset($_SERVER['HTTP_RANGE']) && preg_match("/^bytes=(\\d+)-(\\d+)?\$/", trim($_SERVER['HTTP_RANGE']), $matches)) {
$fileOffset = $matches[1];
$contentLength = isset($matches[2]) ? $matches[2] - $matches[1] + 1 : $fileSize - $matches[1];
} else {
$fileOffset = 0;
$contentLength = $fileSize;
}
// Figure out the time of last modification of the file right way to get the file mtime ... the
$fileModificationTime = $file->mtime();
// stop output buffering, and stop the session so that browsing can be continued while downloading
eZSession::stop();
ob_end_clean();
eZFile::downloadHeaders($fileName, self::dispositionType($fileInfo['mime_type']) === 'attachment', false, $fileOffset, $contentLength, $fileSize);
try {
$file->passthrough($fileOffset, $contentLength);
} catch (eZClusterFileHandlerNotFoundException $e) {
eZDebug::writeError($e->getMessage, __METHOD__);
header($_SERVER["SERVER_PROTOCOL"] . ' 500 Internal Server Error');
} catch (eZClusterFileHandlerGeneralException $e) {
eZDebug::writeError($e->getMessage, __METHOD__);
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}
eZExecution::cleanExit();
}
return eZBinaryFileHandler::RESULT_UNAVAILABLE;
}
示例2: generateNodeView
static function generateNodeView($tpl, $node, $object, $languageCode, $viewMode, $offset, $cacheDir, $cachePath, $viewCacheEnabled, $viewParameters = array('offset' => 0, 'year' => false, 'month' => false, 'day' => false), $collectionAttributes = false, $validation = false)
{
$cacheFile = eZClusterFileHandler::instance($cachePath);
$args = compact("tpl", "node", "object", "languageCode", "viewMode", "offset", "viewCacheEnabled", "viewParameters", "collectionAttributes", "validation");
$Result = $cacheFile->processCache(null, array('eZNodeviewfunctions', 'generateCallback'), null, null, $args);
return $Result;
}
示例3: addFiles
function addFiles(&$index, $dirname, $dirArray)
{
try {
$dir = new eZClusterDirectoryIterator($dirname);
} catch (Exception $e) {
if ($e instanceof UnexpectedValueException) {
eZDebug::writeDebug("Cannot add {$dirname} to the sitemaps index because it does not exist");
return;
}
}
foreach ($dir as $file) {
$f = eZClusterFileHandler::instance($file->name());
if ($f->exists()) {
$exists = true;
break;
}
}
if (false != $exists) {
foreach ($dir as $file) {
if (in_array($file->name(), $dirArray)) {
continue;
}
if ($file->size() > 50) {
$date = new xrowSitemapItemModified();
$date->date = new DateTime("@" . $file->mtime());
$loc = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $file->name();
if (!in_array($loc, $GLOBALS['loc'])) {
$GLOBALS['loc'][] = $loc;
$index->add($loc, array($date));
}
}
}
}
}
示例4: checkObjectAttribute
/**
* (called for each obj attribute)
*/
public function checkObjectAttribute(array $contentObjectAttribute)
{
// we adopt the ez api instead of acting on raw data
$contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
$binaryFile = $contentObjectAttribute->attribute('content');
$warnings = array();
// do not check attributes which do not even contain images
if ($binaryFile) {
// get path to original file
$filePath = $binaryFile->attribute('filepath');
// check if it is on fs (remember, images are clusterized)
$file = eZClusterFileHandler::instance($filePath);
if (!$file->exists()) {
$warnings[] = "Binary file not found: {$filePath}" . $this->postfixErrorMsg($contentObjectAttribute);
} else {
// if it is, check its size as well
if ($this->maxSize > 0) {
$maxSize = $this->maxSize * 1024 * 1024;
if ($file->size() > $maxSize) {
$warnings[] = "Binary file larger than {$maxSize} bytes : " . $file->size() . $this->postfixErrorMsg($contentObjectAttribute);
}
}
}
} else {
if (!$this->nullable) {
$warnings[] = "Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute);
}
}
return $warnings;
}
示例5: tearDown
public function tearDown()
{
ezpINIHelper::restoreINISettings();
eZClusterFileHandler::resetHandler();
parent::tearDown();
}
示例6: __construct
/**
* Constructor
*/
public function __construct()
{
$http = eZHTTPTool::instance();
// @todo change hasVariable to hasPostVariable
if (!$http->hasVariable('key') || !$http->hasVariable('image_id') || !$http->hasVariable('image_version') || !$http->hasVariable('history_version')) {
// @todo manage errors
return;
}
$this->key = $http->variable('key');
$this->image_id = $http->variable('image_id');
$this->image_version = $http->variable('image_version');
$this->history_version = $http->variable('history_version');
// retieve the attribute image
$this->original_image = eZContentObjectAttribute::fetch($this->image_id, $this->image_version)->attribute('content');
if ($this->original_image === null) {
// @todo manage error (the image_id does not match any existing image)
return;
}
// we could store the images in var/xxx/cache/public
$this->working_folder = eZSys::cacheDirectory() . "/public/ezie/" . $this->key;
$this->image_path = $this->working_folder . "/" . $this->history_version . "-" . $this->original_image->attributeFromOriginal('filename');
// check if file exists (that will mean the data sent is correct)
$absolute_image_path = eZSys::rootDir() . "/" . $this->image_path;
$handler = eZClusterFileHandler::instance();
if (!$handler->fileExists($this->image_path)) {
// @todo manage error
return;
}
$this->prepare_region();
}
示例7: fileExists
/**
* @param string $path
* @return bool|string
*/
private static function fileExists($path)
{
$fileUtils = eZClusterFileHandler::instance($path);
if ($fileUtils->requiresClusterizing())
{
if (!self::$dfsBackend)
{
self::$dfsBackend = new eZDFSFileHandlerDFSBackend();
}
$mountPoint = self::$dfsBackend->getMountPoint();
$path = eZDir::path(array($mountPoint, $path));
if (file_exists($path))
{
return $path;
}
}
else
{
if (file_exists($path))
{
return $path;
}
}
return false;
}
示例8: handle
static function handle( $cachePath, $nodeID, $ttl, $useGlobalExpiry = true )
{
$globalExpiryTime = -1;
eZExpiryHandler::registerShutdownFunction();
if ( $useGlobalExpiry )
{
$globalExpiryTime = eZExpiryHandler::getTimestamp( 'template-block-cache', -1 );
}
$cacheHandler = eZClusterFileHandler::instance( $cachePath );
$subtreeExpiry = -1;
// Perform an extra check if the DB handler is in use,
// get the modified_subnode value from the specified node ($nodeID)
// and use it as an extra expiry value.
if ( $cacheHandler instanceof eZDBFileHandler or $cacheHandler instanceof eZDFSFileHandler )
{
$subtreeExpiry = eZTemplateCacheBlock::getSubtreeModification( $nodeID );
}
$globalExpiryTime = max( eZExpiryHandler::getTimestamp( 'global-template-block-cache', -1 ), // This expiry value is the true global expiry for cache-blocks
$globalExpiryTime,
$subtreeExpiry );
if ( $ttl == 0 )
$ttl = -1;
return array( &$cacheHandler,
$cacheHandler->processCache( array( 'eZTemplateCacheBlock', 'retrieveContent' ), null,
$ttl, $globalExpiryTime ) );
}
示例9: __construct
/**
* Constructor
*/
function __construct()
{
$this->Timestamps = array();
$this->IsModified = false;
$cacheDirectory = eZSys::cacheDirectory();
$this->CacheFile = eZClusterFileHandler::instance($cacheDirectory . '/' . 'expiry.php');
$this->restore();
}
示例10: testFetchUnique
/**
* Test for the fetchUnique() method
*
* Doesn't do much with eZFS. Nothing, actually.
*/
public function testFetchUnique()
{
$testFile = 'var/tests/' . __FUNCTION__ . '/file.txt';
$this->createFile($testFile, "contents");
$clusterHandler = eZClusterFileHandler::instance($testFile);
$fetchedFile = $clusterHandler->fetchUnique();
self::assertSame($testFile, $fetchedFile, "A unique name should have been returned");
self::deleteLocalFiles($testFile, $fetchedFile);
}
示例11: fileSize
function fileSize()
{
$fileInfo = $this->storedFileInfo();
$file = eZClusterFileHandler::instance($fileInfo['filepath']);
if ($file->exists()) {
return $file->size();
}
return 0;
}
示例12: analyzeImage
/**
* Overload of ezcImageAnalyzer::analyzeImage()
* Creates a temporary local copy of the image file so that it can be analyzed
*
* @return void
*/
public function analyzeImage()
{
$clusterHandler = eZClusterFileHandler::instance($this->filePath);
$clusterHandler->fetch();
parent::analyzeImage();
if ($this->deleteLocal) {
$clusterHandler->deleteLocal();
}
}
示例13: save_token
public static function save_token($SettingsBlock, $Token, $TokenSuffix = false)
{
$ngpush_cache = eZSys::cacheDirectory() . (self::ngpush_cache_dir ? '/' . self::ngpush_cache_dir : '');
$token_file = $ngpush_cache . '/' . (self::token_prefix ? '_' . self::token_prefix : '') . $SettingsBlock . ($TokenSuffix ? '_' . $TokenSuffix : '') . '.txt';
$fileHandler = eZClusterFileHandler::instance($token_file);
$fileHandler->storeContents($Token);
$storedToken = $fileHandler->fetchContents();
if ($storedToken !== false) {
return true;
}
return false;
}
示例14: handleFileDownload
function handleFileDownload($contentObject, $contentObjectAttribute, $type, $fileInfo)
{
$fileName = $fileInfo['filepath'];
$file = eZClusterFileHandler::instance($fileName);
if ($fileName != "" and $file->exists()) {
$file->fetch(true);
$fileSize = $file->size();
$mimeType = $fileInfo['mime_type'];
$contentLength = $fileSize;
$fileOffset = false;
$fileLength = false;
if (isset($_SERVER['HTTP_RANGE'])) {
$httpRange = trim($_SERVER['HTTP_RANGE']);
if (preg_match("/^bytes=(\\d+)-(\\d+)?\$/", $httpRange, $matches)) {
$fileOffset = $matches[1];
if (isset($matches[2])) {
$fileLength = $matches[2] - $matches[1] + 1;
$lastPos = $matches[2];
} else {
$fileLength = $fileSize - $matches[1];
$lastPos = $fileSize - 1;
}
header("Content-Range: bytes {$matches['1']}-" . $lastPos . "/{$fileSize}");
header("HTTP/1.1 206 Partial Content");
$contentLength = $fileLength;
}
}
// Figure out the time of last modification of the file right way to get the file mtime ... the
$fileModificationTime = filemtime($fileName);
ob_clean();
header("Pragma: ");
header("Cache-Control: ");
/* Set cache time out to 10 minutes, this should be good enough to work around an IE bug */
header("Expires: " . gmdate('D, d M Y H:i:s', time() + 600) . ' GMT');
header("Last-Modified: " . gmdate('D, d M Y H:i:s', $fileModificationTime) . ' GMT');
header("Content-Length: {$contentLength}");
header("Content-Type: {$mimeType}");
header("X-Powered-By: eZ Publish");
header("Content-Disposition: " . self::dispositionType($mimeType));
header("Content-Transfer-Encoding: binary");
header("Accept-Ranges: bytes");
$fh = fopen("{$fileName}", "rb");
if ($fileOffset !== false && $fileLength !== false) {
echo stream_get_contents($fh, $contentLength, $fileOffset);
} else {
ob_end_clean();
fpassthru($fh);
}
fclose($fh);
eZExecution::cleanExit();
}
return eZBinaryFileHandler::RESULT_UNAVAILABLE;
}
示例15: testFetchListWithBlankCacheFile
/**
* Regression test for issue #18613 :
* Empty ezcontentlanguage_cache.php not being regenerated.
* This cache file should always exist, but if for some reason it's empty (lost sync with cluster for instance),
* it should be at least properly regenerated
*
* @link http://issues.ez.no/18613
* @group issue18613
*/
public function testFetchListWithBlankCacheFile()
{
// First simulate a problem generating the language cache file (make it blank)
$cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php';
$clusterFileHandler = eZClusterFileHandler::instance($cachePath);
$clusterFileHandler->storeContents('', 'content', 'php');
unset($GLOBALS['eZContentLanguageList']);
// Language list should never be empty
self::assertNotEmpty(eZContentLanguage::fetchList());
// Remove the test language cache file
$clusterFileHandler->delete();
$clusterFileHandler->purge();
}