当前位置: 首页>>代码示例>>PHP>>正文


PHP eZClusterFileHandler::instance方法代码示例

本文整理汇总了PHP中eZClusterFileHandler::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZClusterFileHandler::instance方法的具体用法?PHP eZClusterFileHandler::instance怎么用?PHP eZClusterFileHandler::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZClusterFileHandler的用法示例。


在下文中一共展示了eZClusterFileHandler::instance方法的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;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:32,代码来源:ezfilepassthroughhandler.php

示例2: 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));
                }
            }
        }
    }
}
开发者ID:rantoniazzi,项目名称:xrowmetadata,代码行数:34,代码来源:index.php

示例3: 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;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:7,代码来源:eznodeviewfunctions.php

示例4: 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;
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:34,代码来源:staticData.php

示例5: __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();
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:33,代码来源:image_pre_action.php

示例6: 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 ) );
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:29,代码来源:eztemplatecacheblock.php

示例7: 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;
 }
开发者ID:gggeek,项目名称:ezdbintegrity,代码行数:33,代码来源:ezdbiezbinaryfilechecker.php

示例8: __construct

 /**
  * Constructor
  */
 function __construct()
 {
     $this->Timestamps = array();
     $this->IsModified = false;
     $cacheDirectory = eZSys::cacheDirectory();
     $this->CacheFile = eZClusterFileHandler::instance($cacheDirectory . '/' . 'expiry.php');
     $this->restore();
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:11,代码来源:ezexpiryhandler.php

示例9: 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();
     }
 }
开发者ID:netbliss,项目名称:ezie,代码行数:15,代码来源:image_analyzer.php

示例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);
 }
开发者ID:radca,项目名称:ezpublish,代码行数:14,代码来源:ezfs2filehandler_test.php

示例11: fileSize

 function fileSize()
 {
     $fileInfo = $this->storedFileInfo();
     $file = eZClusterFileHandler::instance($fileInfo['filepath']);
     if ($file->exists()) {
         return $file->size();
     }
     return 0;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:9,代码来源:ezmedia.php

示例12: 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;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:53,代码来源:ezfilepassthroughhandler.php

示例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;
 }
开发者ID:Nick-lion-22,项目名称:parsing,代码行数:12,代码来源:follow.php

示例14: 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();
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:22,代码来源:ezcontentlanguage_regression.php

示例15: initialize

 /**
  * Main method called to configure/initialize handler.
  * Here you may read your data to import
  */
 public function initialize()
 {
     if (!$this->options->file) {
         throw new SQLIImportConfigException('No file to import!');
     }
     $clusterFilePath = eZClusterFileHandler::instance()->fileFetch($this->options->file);
     if (!$clusterFilePath) {
         throw new SQLIImportConfigException($this->options->file . ' could not be found');
     }
     $this->validateFile('file', $clusterFilePath);
     $this->csv = new SQLICSVDoc(new SQLICSVOptions(array('csv_path' => $clusterFilePath)));
     $this->csv->parse();
 }
开发者ID:heliopsis,项目名称:SQLIImport,代码行数:17,代码来源:sqliusersimporthandler.php


注:本文中的eZClusterFileHandler::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。