本文整理匯總了PHP中eZDir::path方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZDir::path方法的具體用法?PHP eZDir::path怎麽用?PHP eZDir::path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZDir
的用法示例。
在下文中一共展示了eZDir::path方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: eZMutex
function eZMutex($name)
{
$this->Name = md5($name);
$mutexPath = eZDir::path(array(eZSys::cacheDirectory(), 'ezmutex'));
eZDir::mkdir($mutexPath, false, true);
$this->FileName = eZDir::path(array($mutexPath, $this->Name));
$this->MetaFileName = eZDir::path(array($mutexPath, $this->Name . '_meta'));
}
示例2: getTmpDir
/**
* tmp dir for mail parser
* ezvardir / cjw_newsletter/tmp/
* @return string dirname
*/
public function getTmpDir($createDirIfNotExists = true)
{
$varDir = eZSys::varDirectory();
// $dir = $varDir . "/cjw_newsletter/tmp/";
$dir = eZDir::path(array($varDir, 'cjw_newsletter', 'tmp'));
$fileSep = eZSys::fileSeparator();
$filePath = $dir . $fileSep;
if ($createDirIfNotExists === true) {
if (!file_exists($filePath)) {
eZDir::mkdir($filePath, false, true);
}
}
return $filePath;
}
示例3: clearCache
public static function clearCache()
{
eZDebug::writeNotice("Clear calendar taxonomy cache", __METHOD__);
$ini = eZINI::instance();
if ($ini->hasVariable('SiteAccessSettings', 'RelatedSiteAccessList') && ($relatedSiteAccessList = $ini->variable('SiteAccessSettings', 'RelatedSiteAccessList'))) {
if (!is_array($relatedSiteAccessList)) {
$relatedSiteAccessList = array($relatedSiteAccessList);
}
$relatedSiteAccessList[] = $GLOBALS['eZCurrentAccess']['name'];
$siteAccesses = array_unique($relatedSiteAccessList);
} else {
$siteAccesses = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList');
}
$cacheBaseDir = eZDir::path(array(eZSys::cacheDirectory(), self::cacheDirectory()));
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileDeleteByDirList($siteAccesses, $cacheBaseDir, '');
$fileHandler = eZClusterFileHandler::instance($cacheBaseDir);
$fileHandler->purge();
}
示例4: gmapStaticImage
/**
*
* http://maps.googleapis.com/maps/api/staticmap?zoom=13&size=600x300&maptype=roadmap&markers=color:blue|{first_set( $attribute.content.latitude, '0.0')},{first_set( $attribute.content.longitude, '0.0')}
* @param array $parameters
* @param eZContentObjectAttribute $attribute
* @return string
*/
public static function gmapStaticImage(array $parameters, eZContentObjectAttribute $attribute, $extraCacheFileNameStrings = array())
{
$cacheParameters = array(serialize($parameters));
$cacheFile = $attribute->attribute('id') . implode('-', $extraCacheFileNameStrings) . '-' . md5(implode('-', $cacheParameters)) . '.cache';
$extraPath = eZDir::filenamePath($attribute->attribute('id'));
$cacheDir = eZDir::path(array(eZSys::cacheDirectory(), 'gmap_static', $extraPath));
// cacenllo altri file con il medesimo attributo
$fileList = array();
$deleteItems = eZDir::recursiveList($cacheDir, $cacheDir, $fileList);
foreach ($fileList as $file) {
if ($file['type'] == 'file' && $file['name'] !== $cacheFile) {
unlink($file['path'] . '/' . $file['name']);
}
}
$cachePath = eZDir::path(array($cacheDir, $cacheFile));
$args = compact('parameters', 'attribute');
$cacheFile = eZClusterFileHandler::instance($cachePath);
$result = $cacheFile->processCache(array('OCOperatorsCollectionsTools', 'gmapStaticImageRetrieve'), array('OCOperatorsCollectionsTools', 'gmapStaticImageGenerate'), null, null, $args);
return $result;
}
示例5: __construct
/**
* Constructs an empty CjwNewsletterLog instance
*
* This constructor is private as this class should be used as a
* singleton. Use the getInstance() method instead to get an ezcLog instance.
*
* @param boolean $isCliMode
* @return void
*/
protected function __construct($isCliMode = false)
{
if ($isCliMode === true) {
$this->isCliMode = true;
}
$this->reset();
$log = $this;
// "var/log"
$ini = eZINI::instance();
$varDir = eZSys::varDirectory();
$iniLogDir = $ini->variable('FileSettings', 'LogDir');
$permissions = octdec($ini->variable('FileSettings', 'LogFilePermissions'));
$logDir = eZDir::path(array($varDir, $iniLogDir));
$logNamePostfix = '';
// Debug enabled
$cjwNewsletterIni = eZINI::instance('cjw_newsletter.ini');
if ($cjwNewsletterIni->variable('DebugSettings', 'Debug') == 'enabled') {
$this->debug = true;
}
if ($isCliMode === true) {
$logNamePostfix = 'cli_';
}
// Create the writers
$generalFilename = "cjw_newsletter_" . $logNamePostfix . "general.log";
$errorFilename = "cjw_newsletter_" . $logNamePostfix . "error.log";
$writeAll = new ezcLogUnixFileWriter($logDir, $generalFilename);
$writeErrors = new ezcLogUnixFileWriter($logDir, $errorFilename);
// Check file permissions
foreach (array($generalFilename, $errorFilename) as $file) {
$path = eZDir::path(array($logDir, $file));
if (substr(decoct(fileperms($path)), 2) !== $permissions) {
@chmod($path, $permissions);
}
}
$errorFilter = new ezcLogFilter();
$errorFilter->severity = ezcLog::ERROR;
$log->getMapper()->appendRule(new ezcLogFilterRule($errorFilter, $writeErrors, true));
$log->getMapper()->appendRule(new ezcLogFilterRule(new ezcLogFilter(), $writeAll, true));
}
示例6: clusterFilePath
/**
* @param string $cluster
* @param string $path
* @param bool $clusterizedPath
* @return bool|string
*/
public static function clusterFilePath($cluster, $path, $clusterizedPath = true)
{
if (!$cluster)
{
$cluster = 'default';
}
$staticPath = eZDir::path(array(StaticData::directory(), $cluster, $path));
$fullPath = self::fileExists($staticPath);
if ($fullPath)
{
return $clusterizedPath ? $fullPath : $staticPath;
}
if ($cluster != 'default')
{
return self::clusterFilePath('default', $path);
}
return false;
}
示例7: clearStaticCache
/**
* Clears all static cache for a site
* Removers all static cache, but not the static cache directory itself.
*
* Currently, this function only supports 'combined_host_url'
*
*/
static function clearStaticCache()
{
$ini = eZINI::instance('staticcache.ini');
$storageDir = $ini->variable('CacheSettings', 'StaticStorageDir');
// Check that we have combined_host_url hostmatching
$siteIni = eZINI::instance();
$matchType = $siteIni->variable('SiteAccessSettings', 'MatchOrder');
if ($matchType !== 'combined_host_url') {
throw new Exception('combined_host_url required for this workflow');
}
global $eZCurrentAccess;
$siteAccess = $eZCurrentAccess['name'];
//Get hostname part from siteaccess name (exclude for instance _eng or _admin)
if (strpos($siteAccess, '_') === false) {
$hostName = $siteAccess;
} else {
$hostName = substr($siteAccess, 0, strpos($siteAccess, '_'));
}
$staticCacheDir = eZDir::path(array($storageDir, $hostName));
// Sanity checking, make sure we don't remove everyones static cache.
if ($staticCacheDir == $storageDir) {
throw new Exception("Failed to find correct static cache directory : {$staticCacheDir} \n");
}
$dirs = scandir($staticCacheDir);
foreach ($dirs as $dir) {
if ($dir !== '.' && $dir !== '..') {
$fullPath = eZDir::path(array($staticCacheDir, $dir));
if (is_dir($fullPath)) {
ezcBaseFile::removeRecursive($fullPath);
} else {
if (!unlink($fullPath)) {
throw new ezsfFileCouldNotRemoveException($fullPath);
}
}
}
}
}
示例8: eZSetupCheckExecutable
function eZSetupCheckExecutable($type)
{
$http = eZHTTPTool::instance();
$filesystemType = eZSys::filesystemType();
$envSeparator = eZSys::envSeparator();
$programs = eZSetupConfigVariableArray($type, $filesystemType . '_Executable');
$systemSearchPaths = explode($envSeparator, eZSys::path(true));
$additionalSearchPaths = eZSetupConfigVariableArray($type, $filesystemType . '_SearchPaths');
$excludePaths = eZSetupConfigVariableArray($type, $filesystemType . '_ExcludePaths');
$imageIniPath = eZSetupImageConfigVariableArray('ShellSettings', 'ConvertPath');
/*
We save once entered extra path in the persistent data list
to keep it within setup steps.
This trick is needed, for example, in "registration" step,
where user has no chance to enter extra path again
due to missing input field for this purpose.
*/
// compute extra path
$extraPath = array();
if ($http->hasPostVariable($type . '_ExtraPath')) {
$GLOBALS['eZSetupCheckExecutable_' . $type . '_ExtraPath'] = $http->postVariable($type . '_ExtraPath');
$extraPath = explode($envSeparator, $http->postVariable($type . '_ExtraPath'));
} else {
if (isset($GLOBALS['eZSetupCheckExecutable_' . $type . '_ExtraPath'])) {
$extraPath = explode($envSeparator, $GLOBALS['eZSetupCheckExecutable_' . $type . '_ExtraPath']);
}
}
// if extra path was given in any way
if ($extraPath) {
// remove program from path name if entered
foreach ($extraPath as $path) {
foreach ($programs as $program) {
if (strpos($path, $program) == strlen($path) - strlen($program)) {
$extraPath[] = substr($path, strpos($path, $program));
}
}
}
}
$searchPaths = array_merge($systemSearchPaths, $additionalSearchPaths, $extraPath, $imageIniPath);
$result = false;
$correctPath = false;
$correctProgram = false;
foreach ($programs as $program) {
foreach ($searchPaths as $path) {
$pathProgram = eZDir::path(array($path, $program));
if (file_exists($pathProgram)) {
if ($filesystemType == 'unix') {
$relativePath = $path;
if (preg_match("#^/(.+)\$#", $path, $matches)) {
$relativePath = $matches[1];
}
$relativePath = eZDir::cleanPath($relativePath);
} else {
$relativePath = $path;
if (preg_match("#^[a-zA-Z]:[/\\\\](.+)\$#", $path, $matches)) {
$relativePath = $matches[1];
}
$relativePath = eZDir::cleanPath($relativePath);
}
$exclude = false;
foreach ($excludePaths as $excludePath) {
$excludePath = strtolower($excludePath);
$match = strtolower($program . "@" . $relativePath);
if ($match == $excludePath) {
$exclude = true;
break;
} else {
if ($relativePath == $excludePath) {
$exclude = true;
break;
}
}
}
if ($exclude) {
continue;
}
if (function_exists("is_executable")) {
if (is_executable($pathProgram)) {
$result = true;
$correctPath = $path;
$correctProgram = $program;
break;
}
} else {
// Windows system
$result = true;
$correctPath = $path;
$correctProgram = $program;
break;
}
}
}
if ($result) {
break;
}
}
$extraPathAsString = implode($envSeparator, $extraPath);
return array('result' => $result, 'persistent_data' => array('path' => array('value' => $correctPath), 'program' => array('value' => $correctProgram), 'extra_path' => array('value' => $extraPathAsString, 'merge' => TRUE), 'result' => array('value' => $result)), 'env_separator' => $envSeparator, 'filesystem_type' => $filesystemType, 'extra_path' => $extraPath, 'correct_path' => $correctPath, 'system_search_path' => $systemSearchPaths, 'additional_search_path' => $additionalSearchPaths);
}
示例9: generatePHPCodeChildren
//.........這裏部分代碼省略.........
* don't have any fallback code. If we can
* generate the fallback code we make the
* included template compile on demand */
if (!$tmpResourceData['compiled-template'] and $resourceCanCache and $tpl->canCompileTemplate($tmpResourceData, $node[5]) and !$useFallbackCode) {
$generateStatus = $tpl->compileTemplate($tmpResourceData, $node[5]);
// Time limit #2:
/* We reset the time limit to 60 seconds to
* ensure that remaining template has
* enough time to compile. However if time
* limit is unlimited (0) we leave it be */
$maxExecutionTime = ini_get('max_execution_time');
if ($maxExecutionTime != 0 && $maxExecutionTime < 60) {
@set_time_limit(60);
}
if ($generateStatus) {
$tmpResourceData['compiled-template'] = true;
}
}
}
$GLOBALS['eZTemplateCompilerResourceCache'][$tmpResourceData['template-filename']] =& $tmpResourceData;
}
}
setlocale(LC_CTYPE, $savedLocale);
$textName = eZTemplateCompiler::currentTextName($parameters);
if ($tmpResourceData['compiled-template']) {
$hasCompiledCode = true;
// if ( !eZTemplateCompiler::isFallbackResourceCodeEnabled() )
// $useFallbackCode = false;
$keyData = $tmpResourceData['key-data'];
$templatePath = $tmpResourceData['template-name'];
$key = $resourceObject->cacheKey($keyData, $tmpResourceData, $templatePath, $node[5]);
$cacheFileName = eZTemplateCompiler::compilationFilename($key, $tmpResourceData);
$directory = eZTemplateCompiler::compilationDirectory();
$phpScript = eZDir::path(array($directory, $cacheFileName));
$phpScriptText = $php->thisVariableText($phpScript, 0, 0, false);
$resourceMap[$uriKey] = array('key' => $uriKey, 'uri' => $uri, 'phpscript' => $phpScript);
}
}
}
if ($useComments) {
$variablePlacement = $node[6];
if ($variablePlacement) {
$originalText = eZTemplateCompiler::fetchTemplatePiece($variablePlacement);
$php->addComment("Resource Acquisition:", true, true, array('spacing' => $spacing));
$php->addComment($originalText, true, true, array('spacing' => $spacing));
}
}
if ($hasCompiledCode) {
if ($resourceVariableName) {
$phpScriptText = '$phpScript';
$phpScriptArray = array();
foreach ($resourceMap as $resourceMapItem) {
$phpScriptArray[$resourceMapItem['key']] = $resourceMapItem['phpscript'];
}
if (!$resourceFilename) {
$php->addVariable("phpScriptArray", $phpScriptArray, eZPHPCreator::VARIABLE_ASSIGNMENT, array('spacing' => $spacing));
$resourceVariableNameText = "\${$resourceVariableName}";
$php->addCodePiece("\$phpScript = isset( \$phpScriptArray[{$resourceVariableNameText}] ) ? \$phpScriptArray[{$resourceVariableNameText}] : false;\n", array('spacing' => $spacing));
} else {
$php->addVariable("phpScript", $phpScriptArray[$node[10]], eZPHPCreator::VARIABLE_ASSIGNMENT, array('spacing' => $spacing));
}
// The default is to only check if it exists
$modificationCheckText = "file_exists( {$phpScriptText} )";
if (eZTemplateCompiler::isDevelopmentModeEnabled()) {
$modificationCheckText = "@filemtime( {$phpScriptText} ) > filemtime( {$uriText} )";
}
示例10: storeObjectAttribute
function storeObjectAttribute($attribute)
{
$ini = eZINI::instance();
// Delete compiled template
$siteINI = eZINI::instance();
if ($siteINI->hasVariable('FileSettings', 'CacheDir')) {
$cacheDir = $siteINI->variable('FileSettings', 'CacheDir');
if ($cacheDir[0] == "/") {
$cacheDir = eZDir::path(array($cacheDir));
} else {
if ($siteINI->hasVariable('FileSettings', 'VarDir')) {
$varDir = $siteINI->variable('FileSettings', 'VarDir');
$cacheDir = eZDir::path(array($varDir, $cacheDir));
}
}
} else {
if ($siteINI->hasVariable('FileSettings', 'VarDir')) {
$varDir = $siteINI->variable('FileSettings', 'VarDir');
$cacheDir = $ini->variable('FileSettings', 'CacheDir');
$cacheDir = eZDir::path(array($varDir, $cacheDir));
} else {
$cacheDir = eZSys::cacheDirectory();
}
}
$compiledTemplateDir = $cacheDir . "/template/compiled";
eZDir::unlinkWildcard($compiledTemplateDir . "/", "*pagelayout*.*");
// Expire template block cache
eZContentCacheManager::clearTemplateBlockCacheIfNeeded(false);
}
示例11: rootCacheDirectory
static function rootCacheDirectory()
{
$internalCharset = eZTextCodec::internalCharset();
$ini = eZINI::instance();
$translationRepository = $ini->variable('RegionalSettings', 'TranslationRepository');
$translationExtensions = $ini->variable('RegionalSettings', 'TranslationExtensions');
$uniqueParts = array($internalCharset, $translationRepository, implode(';', $translationExtensions));
$sharedTsCacheDir = $ini->hasVariable('RegionalSettings', 'SharedTranslationCacheDir') ? trim($ini->variable('RegionalSettings', 'SharedTranslationCacheDir')) : '';
if ($sharedTsCacheDir !== '') {
$rootCacheDirectory = eZDir::path(array($sharedTsCacheDir, md5(implode('-', $uniqueParts))));
} else {
$rootCacheDirectory = eZDir::path(array(eZSys::cacheDirectory(), 'translation', md5(implode('-', $uniqueParts))));
}
return $rootCacheDirectory;
}
示例12: generateViewCacheFile
static function generateViewCacheFile($user, $nodeID, $offset, $layout, $language, $viewMode, $viewParameters = false, $cachedViewPreferences = false, $viewCacheTweak = '')
{
$cacheNameExtra = '';
$ini = eZINI::instance();
if (!$language) {
$language = false;
}
if (!$viewCacheTweak && $ini->hasVariable('ContentSettings', 'ViewCacheTweaks')) {
$viewCacheTweaks = $ini->variable('ContentSettings', 'ViewCacheTweaks');
if (isset($viewCacheTweaks[$nodeID])) {
$viewCacheTweak = $viewCacheTweaks[$nodeID];
} else {
if (isset($viewCacheTweaks['global'])) {
$viewCacheTweak = $viewCacheTweaks['global'];
}
}
}
// should we use current siteaccess or let several siteaccesse share cache?
if (strpos($viewCacheTweak, 'ignore_siteaccess_name') === false) {
$currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
} else {
$currentSiteAccess = $ini->variable('SiteSettings', 'DefaultAccess');
}
$cacheHashArray = array($nodeID, $viewMode, $language, $offset, $layout);
// several user related cache tweaks
if (strpos($viewCacheTweak, 'ignore_userroles') === false) {
$cacheHashArray[] = implode('.', $user->roleIDList());
}
if (strpos($viewCacheTweak, 'ignore_userlimitedlist') === false) {
$cacheHashArray[] = implode('.', $user->limitValueList());
}
if (strpos($viewCacheTweak, 'ignore_discountlist') === false) {
$cacheHashArray[] = implode('.', eZUserDiscountRule::fetchIDListByUserID($user->attribute('contentobject_id')));
}
$cacheHashArray[] = eZSys::indexFile();
// Add access type to cache hash if current access is uri type (so uri and host doesn't share cache)
if (strpos($viewCacheTweak, 'ignore_siteaccess_type') === false && $GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI) {
$cacheHashArray[] = eZSiteAccess::TYPE_URI;
}
// Make the cache unique for every logged in user
if (strpos($viewCacheTweak, 'pr_user') !== false and !$user->isAnonymous()) {
$cacheNameExtra = $user->attribute('contentobject_id') . '-';
}
// Make the cache unique for every case of view parameters
if (strpos($viewCacheTweak, 'ignore_viewparameters') === false && $viewParameters) {
$vpString = '';
ksort($viewParameters);
foreach ($viewParameters as $key => $value) {
if (!$key || $key === '_custom') {
continue;
}
$vpString .= 'vp:' . $key . '=' . $value;
}
$cacheHashArray[] = $vpString;
}
// Make the cache unique for every case of the preferences
if ($cachedViewPreferences === false) {
$depPreferences = $ini->variable('ContentSettings', 'CachedViewPreferences');
} else {
$depPreferences = $cachedViewPreferences;
}
if (strpos($viewCacheTweak, 'ignore_userpreferences') === false && isset($depPreferences[$viewMode])) {
$depPreferences = explode(';', $depPreferences[$viewMode]);
$pString = '';
// Fetch preferences for the specified user
$preferences = eZPreferences::values($user);
foreach ($depPreferences as $pref) {
$pref = explode('=', $pref);
if (isset($pref[0])) {
if (isset($preferences[$pref[0]])) {
$pString .= 'p:' . $pref[0] . '=' . $preferences[$pref[0]] . ';';
} else {
if (isset($pref[1])) {
$pString .= 'p:' . $pref[0] . '=' . $pref[1] . ';';
}
}
}
}
$cacheHashArray[] = $pString;
}
$cacheFile = $nodeID . '-' . $cacheNameExtra . md5(implode('-', $cacheHashArray)) . '.cache';
$extraPath = eZDir::filenamePath($nodeID);
$cacheDir = eZDir::path(array(eZSys::cacheDirectory(), $ini->variable('ContentSettings', 'CacheDir'), $currentSiteAccess, $extraPath));
$cachePath = eZDir::path(array($cacheDir, $cacheFile));
return array('cache_path' => $cachePath, 'cache_dir' => $cacheDir, 'cache_file' => $cacheFile);
}
示例13: repositoryPath
static function repositoryPath()
{
$ini = eZINI::instance();
$packageIni = eZINI::instance('package.ini');
return eZDir::path(array('var', $ini->variable('FileSettings', 'StorageDir'), $packageIni->variable('RepositorySettings', 'RepositoryDirectory')));
}
示例14: cleanup
static function cleanup( $nodeList, $userId = false )
{
// The view-cache has a different storage structure than before:
// var/cache/content/<siteaccess>/<extra-path>/<nodeID>-<hash>.cache
// Also it uses the cluster file handler to delete files using a wildcard (glob style).
$ini = eZINI::instance();
$extraCacheName = '';
$cacheBaseDir = eZDir::path( array( eZSys::cacheDirectory(), $ini->variable( 'ContentSettings', 'CacheDir' ) ) );
$fileHandler = eZClusterFileHandler::instance();
if ( $userId !== false && is_numeric( $userId ) )
{
$extraCacheName = $userId . '-';
}
// Figure out the siteaccess which are related, first using the new
// INI setting RelatedSiteAccessList then the old existing one
// AvailableSiteAccessList
if ( $ini->hasVariable( 'SiteAccessSettings', 'RelatedSiteAccessList' ) &&
$relatedSiteAccessList = $ini->variable( 'SiteAccessSettings', 'RelatedSiteAccessList' ) )
{
if ( !is_array( $relatedSiteAccessList ) )
{
$relatedSiteAccessList = array( $relatedSiteAccessList );
}
$relatedSiteAccessList[] = $GLOBALS['eZCurrentAccess']['name'];
$siteAccesses = array_unique( $relatedSiteAccessList );
}
else
{
$siteAccesses = $ini->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' );
}
if ( !$siteAccesses )
{
return;
}
foreach ( $nodeList as $nodeID )
{
$extraPath = eZDir::filenamePath( $nodeID );
$fileHandler->fileDeleteByDirList( $siteAccesses, $cacheBaseDir, "$extraPath$nodeID-$extraCacheName" );
}
}
示例15: removeURL
/**
* Removes the static cache file (index.html) and its directory if it exists.
* The directory path is based upon the URL $url and the configured static storage dir.
*
* @param string $url The URL for the current item, e.g /news
*/
function removeURL( $url )
{
$dir = eZDir::path( array( $this->staticStorageDir, $url ) );
@unlink( $dir . "/index.html" );
@rmdir( $dir );
}