本文整理汇总了PHP中eZDir类的典型用法代码示例。如果您正苦于以下问题:PHP eZDir类的具体用法?PHP eZDir怎么用?PHP eZDir使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZDir类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArchiveFileName
public function getArchiveFileName( $path, $seeds, $prefix = null, $realm = null )
{
$dirElements = array();
$dirElements[] = $this->ArchiveDir;
if ( isset( $realm ) )
{
$dirElements[]= $realm;
}
$seed = implode ( '', $seeds );
$hash = hash( $this->hashAlgorithm, $seed );
$multiLevelDir = eZDir::createMultiLevelPath( substr( $hash, 0 , $this->ArchiveDirLevels ), $this->ArchiveDirLevels );
$dirElements[] = $multiLevelDir;
$fileDirectory = implode( '/', $dirElements );
if ( !file_exists( $fileDirectory ) )
{
eZDir::mkdir( $fileDirectory, false, true );
}
$archiveFileName = $fileDirectory . '/';
if ( isset( $prefix ) )
{
$archiveFileName .= $prefix . '-';
}
$archiveFileName .= $hash;
return $archiveFileName;
}
示例2: getContributors
function getContributors( $pathToDir )
{
$contribFiles = eZDir::recursiveFind( $pathToDir, "php" );
$contributors = array();
if ( count( $contribFiles ) )
{
foreach ( $contribFiles as $contribFile )
{
include_once( $contribFile );
if ( !isset( $contributorSettings ) )
continue;
$tmpFiles = explode( ',', $contributorSettings['files'] );
$updatedFiles = array();
foreach ( $tmpFiles as $file )
{
if ( trim( $file ) )
$updatedFiles[] = trim( $file,"\n\r" );
}
$files = implode( ', ', $updatedFiles );
$contributorSettings['files'] = $files;
$contributors[] = $contributorSettings;
}
}
return $contributors;
}
示例3: checkRecurrenceCondition
function checkRecurrenceCondition($newsletter)
{
if (!$newsletter->attribute('recurrence_condition')) {
return true;
}
if (0 < count($this->conditionExtensions)) {
foreach ($this->conditionExtensions as $conditionExtension) {
// TODO: Extend to ask multiple condition extensions to allow more complex checks
$siteINI = eZINI::instance();
$siteINI->loadCache();
$extensionDirectory = $siteINI->variable('ExtensionSettings', 'ExtensionDirectory');
$extensionDirectories = eZDir::findSubItems($extensionDirectory);
$directoryList = eZExtension::expandedPathList($extensionDirectories, 'condition_handler');
foreach ($directoryList as $directory) {
$handlerFile = $directory . '/' . strtolower($conditionExtension) . 'handler.php';
// we only check one extension for now
if ($conditionExtension === $newsletter->attribute('recurrence_condition') && file_exists($handlerFile)) {
include_once $handlerFile;
$className = $conditionExtension . 'Handler';
if (class_exists($className)) {
$impl = new $className();
// Ask if condition is fullfilled
return $impl->checkCondition($newsletter);
} else {
eZDebug::writeError("Class {$className} not found. Unable to verify recurrence condition. Blocked recurrence.");
return false;
}
}
}
}
}
// If we have a condition but no match we prevent the sendout
eZDebug::writeError("Newsletter recurrence condition '" . $newsletter->attribute('recurrence_condition') . "' extension not found ");
return false;
}
示例4: moveIfNeeded
function moveIfNeeded($oldPath, $newPath) {
global $fileToRemove;
$success = true;
$cli = eZCLI::instance();
if (!file_exists($newPath)) {
if (!file_exists($oldPath)) {
$cli->warning('Source file not exist : ' . $oldPath);
return false;
}
eZDir::mkdir( dirname( $newPath ), false, true );
$success = copy($oldPath, $newPath);
$cli = eZCLI::instance();
if ($success) {
$fileToRemove[] = $oldPath;
$cli->notice('Move ' . $oldPath . ' => ' . $newPath);
} else {
$cli->warning('Fail to move ' . $oldPath . ' => ' . $newPath);
}
} else {
$fileToRemove[] = $oldPath;
}
return $success;
}
示例5: create
static function create($filename, $directory = false, $data = false, $atomic = false)
{
$filepath = $filename;
if ($directory) {
if (!file_exists($directory)) {
eZDir::mkdir($directory, false, true);
// eZDebugSetting::writeNotice( 'ezfile-create', "Created directory $directory", 'eZFile::create' );
}
$filepath = $directory . '/' . $filename;
}
// If atomic creation is needed we will use a temporary
// file when writing the data, then rename it to the correct path.
if ($atomic) {
$realpath = $filepath;
$dirname = dirname($filepath);
if (strlen($dirname) != 0) {
$dirname .= "/";
}
$filepath = $dirname . "ezfile-tmp." . md5($filepath . getmypid() . mt_rand());
}
$file = fopen($filepath, 'wb');
if ($file) {
// eZDebugSetting::writeNotice( 'ezfile-create', "Created file $filepath", 'eZFile::create' );
if ($data) {
fwrite($file, $data);
}
fclose($file);
if ($atomic) {
eZFile::rename($filepath, $realpath);
}
return true;
}
// eZDebugSetting::writeNotice( 'ezfile-create', "Failed creating file $filepath", 'eZFile::create' );
return false;
}
示例6: 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'));
}
示例7: cleanupEmptyDirectories
/**
* Goes trough the directory path and removes empty directories, starting at
* the leaf and deleting down until a non empty directory is reached.
* If the path is not a directory, nothing will happen.
*
* @param string $path
*/
public static function cleanupEmptyDirectories($path)
{
$dirpath = eZDir::dirpath($path);
eZDebugSetting::writeDebug('kernel-clustering', "eZClusterFileHandler::cleanupEmptyDirectories( '{$dirpath}' )");
if (is_dir($dirpath)) {
eZDir::cleanupEmptyDirectories($dirpath);
}
}
示例8: __construct
/**
* Constructs a new CjwNewsletterTransportFile
*
* @param string $mailDir
* @return void
*/
public function __construct($mailDir = 'var/log/mail')
{
// $this->mailDir = eZSys::siteDir().eZSys::varDirectory().'/log/mail';
if (is_dir($mailDir) or eZDir::mkdir($mailDir, false, true)) {
$this->mailDir = $mailDir;
} else {
// TODO Fehlerbehandlung wenn verzeichnis nicht angelegt werden kann
}
}
示例9: copyDir
function copyDir( $source, $destination )
{
// Attempt to create destination dir.
$status = eZDir::mkdir( $destination );
// If no success: bail out.
if ( !$status )
{
return false;
}
// Get the contents of the directory.
$entries = getDirEntries( $source );
// Bail if contents is unavailable.
if ( $entries == false )
{
return false;
}
// Else: contents is OK:
else
{
// Copy each and every entry:
foreach ( $entries as $entry )
{
if ( $entry )
{
$from = "$source/$entry";
$to = "$destination/$entry";
// Is this a directory? -> special case.
if ( is_dir( $from ) )
{
$status = copyDir( $from, $to );
if (!$status)
{
return false;
}
}
// Else: simple file case.
else
{
$status = copy( $from, $to );
if (!$status)
{
return false;
}
}
}
}
}
// Phew: if we got this far then everything is OK.
return true;
}
示例10: __construct
/**
* Creates a new cache storage for a given location through eZ Publish cluster mechanism
* Options can contain the 'ttl' ( Time-To-Life ). This is per default set
* to 1 day.
*
* @param string $location Path to the cache location inside the cluster
* @param array(string=>string) $options Options for the cache.
*/
public function __construct($location, $options = array())
{
$path = eZSys::cacheDirectory() . '/rest/' . $location;
if (!file_exists($path)) {
if (!eZDir::mkdir($path, false, true)) {
throw new ezcBaseFilePermissionException($path, ezcBaseFileException::WRITE, 'Cache location is not writeable.');
}
}
parent::__construct($path);
$this->properties['options'] = new ezpCacheStorageClusterOptions($options);
}
示例11: nameFromPath
/**
* eZExtension::nameFromPath( __FILE__ ) executed in any file of an extension
* can help you to find the path to additional resources
*
* @param $path Path to check.
* @return Name of the extension a path belongs to.
* @deprecated Since 4.3, use {@link eZExtension::nameFromPath()} instead
*/
function nameFromPath($path)
{
$path = eZDir::cleanPath($path);
$base = eZExtension::baseDirectory() . '/';
$base = preg_quote($base, '/');
$pattern = '/' . $base . '([^\\/]+)/';
if (preg_match($pattern, $path, $matches)) {
return $matches[1];
} else {
false;
}
}
示例12: store
function store($sub_dir = false, $suffix = false, $mimeData = false)
{
if (!$this->IsTemporary) {
eZDebug::writeError("Cannot store non temporary file: " . $this->Filename, "eZHTTPFile");
return false;
}
$this->IsTemporary = false;
$ini = eZINI::instance();
// $storage_dir = $ini->variable( "FileSettings", "VarDir" ) . '/' . $ini->variable( "FileSettings", "StorageDir" );
$storage_dir = eZSys::storageDirectory();
if ($sub_dir !== false) {
$dir = $storage_dir . "/{$sub_dir}/";
} else {
$dir = $storage_dir . "/";
}
if ($mimeData) {
$dir = $mimeData['dirpath'];
}
if (!$mimeData) {
$dir .= $this->MimeCategory;
}
if (!file_exists($dir)) {
if (!eZDir::mkdir($dir, false, true)) {
return false;
}
}
$suffixString = false;
if ($suffix != false) {
$suffixString = ".{$suffix}";
}
if ($mimeData) {
$dest_name = $mimeData['url'];
} else {
$dest_name = $dir . "/" . md5(basename($this->Filename) . microtime() . mt_rand()) . $suffixString;
}
if (!move_uploaded_file($this->Filename, $dest_name)) {
eZDebug::writeError("Failed moving uploaded file " . $this->Filename . " to destination {$dest_name}");
unlink($dest_name);
$ret = false;
} else {
$ret = true;
$this->Filename = $dest_name;
$perm = $ini->variable("FileSettings", "StorageFilePermissions");
$oldumask = umask(0);
chmod($dest_name, octdec($perm));
umask($oldumask);
// Write log message to storage.log
$storageDir = $dir . "/";
eZLog::writeStorageLog(basename($this->Filename), $storageDir);
}
return $ret;
}
示例13: getCssFilePath
/**
* @return mixed
*/
public function getCssFilePath()
{
if ( is_null($this->_cssFilePath) )
{
$cssDirectory = eZSys::cacheDirectory() . '/css';
$this->_cssFilePath = $cssDirectory .'/' . md5( $this->getLessFilePath() ) . '.css';
if ( !file_exists( $cssDirectory ))
{
eZDir::mkdir( $cssDirectory );
}
}
return $this->_cssFilePath;
}
示例14: tearDown
public function tearDown()
{
// restore the previous file handler
if ($this->previousFileHandler !== null) {
$fileINI = eZINI::instance('file.ini');
$fileINI->setVariable('ClusteringSettings', 'FileHandler', $this->previousFileHandler);
$this->previousFileHandler = null;
eZClusterFileHandler::resetHandler();
}
if ($this->haveToRemoveDFSPath) {
eZDir::recursiveDelete($this->DFSPath);
}
parent::tearDown();
}
示例15: 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;
}