本文整理汇总了PHP中eZDir::recursiveFindRelative方法的典型用法代码示例。如果您正苦于以下问题:PHP eZDir::recursiveFindRelative方法的具体用法?PHP eZDir::recursiveFindRelative怎么用?PHP eZDir::recursiveFindRelative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZDir
的用法示例。
在下文中一共展示了eZDir::recursiveFindRelative方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSettings
public function getSettings()
{
// Copied from settings/view
$rootDir = 'settings';
$iniFiles = eZDir::recursiveFindRelative($rootDir, '', '.ini');
// find all .ini files in active extensions
// Note: is this the same algorithm used by ezini? mmm...
foreach (eZINI::globalOverrideDirs() as $iniDataSet) {
$iniPath = $iniDataSet[1] ? $iniDataSet[0] : 'settings/' . $iniDataSet[0];
$iniFiles = array_merge($iniFiles, eZDir::recursiveFindRelative($iniPath, '', '.ini'));
$iniFiles = array_merge($iniFiles, eZDir::recursiveFindRelative($iniPath, '', '.ini.append.php'));
}
// extract all .ini files without path
$iniFiles = preg_replace('%.*/%', '', $iniFiles);
// remove *.ini[.append.php] from file name
$iniFiles = preg_replace('%\\.ini.*%', '.ini', $iniFiles);
$iniFiles = array_unique($iniFiles);
sort($iniFiles);
$siteIni = null;
foreach ($iniFiles as $key => $ini) {
if ($this->currentSiteAccess != '' && $GLOBALS['eZCurrentAccess']['name'] !== $this->currentSiteAccess) {
// create a site ini instance using $useLocalOverrides
if ($siteIni === null) {
$siteIni = eZSiteAccess::getIni($this->currentSiteAccess, 'site.ini');
}
// load settings file with $useLocalOverrides = true
$iniFile = new eZINI($ini, 'settings', null, false, true, false, false, false);
$iniFile->setOverrideDirs($siteIni->overrideDirs(false));
$iniFile->load();
} else {
$iniFile = new eZINI($ini);
}
$iniFiles[$ini] = $iniFile->groups();
unset($iniFiles[$key]);
}
return $iniFiles;
}
示例2: foreach
{
$tpl->setVariable( 'settings', false );
$tpl->setVariable( 'block_count', false );
$tpl->setVariable( 'setting_count', false );
$tpl->setVariable( 'ini_file', false );
}
$rootDir = 'settings';
$iniFiles = eZDir::recursiveFindRelative( $rootDir, '', '.ini' );
// find all .ini files in active extensions
foreach ( eZINI::globalOverrideDirs() as $iniDataSet )
{
$iniPath = $iniDataSet[1] ? $iniDataSet[0] : 'settings/' . $iniDataSet[0];
$iniFiles = array_merge( $iniFiles, eZDir::recursiveFindRelative( $iniPath, '', '.ini' ) );
$iniFiles = array_merge( $iniFiles, eZDir::recursiveFindRelative( $iniPath, '', '.ini.append.php' ) );
}
// extract all .ini files without path
$iniFiles = preg_replace('%.*/%', '', $iniFiles );
// remove *.ini[.append.php] from file name
$iniFiles = preg_replace('%\.ini.*%', '.ini', $iniFiles );
sort( $iniFiles );
$tpl->setVariable( 'ini_files', array_unique( $iniFiles ) );
$tpl->setVariable( 'siteaccess_list', $siteAccessList );
$tpl->setVariable( 'current_siteaccess', $currentSiteAccess );
$Result = array();
$Result['content'] = $tpl->fetch( 'design:settings/view.tpl' );
$Result['path'] = array( array( 'text' => ezpI18n::tr( 'settings/view', 'Settings' ),
示例3: overrideArray
/**
* Get an array of all the current templates and overrides for them.
* The current siteaccess is used if none is specified.
*
* @static
* @return array
*/
static function overrideArray($siteAccess = false)
{
if ($siteAccess === false and self::$overrideArrayCache !== null) {
return self::$overrideArrayCache;
}
$bases = eZTemplateDesignResource::allDesignBases($siteAccess);
// fetch the override array from a specific siteacces
if ($siteAccess) {
$overrideINI = eZSiteAccess::getIni($siteAccess, 'override.ini');
} else {
$overrideINI = eZINI::instance('override.ini');
}
$designStartPath = eZTemplateDesignResource::designStartPath();
// Generate match cache for all templates
// Build arrays of available files, start with standard design and end with most prefered design
$matchFileArray = array();
$reverseBases = array_reverse($bases);
foreach ($reverseBases as $base) {
$templateResource = $base . '/templates';
$sourceFileArray = eZDir::recursiveFindRelative($templateResource, "", "tpl");
foreach ($sourceFileArray as $source) {
$matchFileArray[$source]['base_dir'] = $templateResource;
$matchFileArray[$source]['template'] = $source;
}
}
// Load override templates
$overrideSettingGroups = $overrideINI->groups();
if (isset($GLOBALS['eZDesignOverrides'])) {
$overrideSettingGroups = array_merge($overrideSettingGroups, $GLOBALS['eZDesignOverrides']);
}
foreach ($overrideSettingGroups as $overrideName => $overrideSetting) {
if (!isset($overrideSetting['Source'])) {
continue;
}
$overrideSource = "/" . $overrideSetting['Source'];
$overrideMatchFile = $overrideSetting['MatchFile'];
// Find the matching file in the available resources
$triedFiles = array();
$fileInfo = eZTemplateDesignResource::fileMatch($bases, 'override/templates', $overrideMatchFile, $triedFiles);
$resourceInUse = is_array($fileInfo) ? $fileInfo['resource'] : false;
$overrideMatchFilePath = is_array($fileInfo) ? $fileInfo['path'] : false;
// if the override template is not found
// then we probably shouldn't use it
// there should be added a check around the following code
// if ( $overrideMatchFilePath )
// {
$customMatchArray = array();
$customMatchArray['conditions'] = isset($overrideSetting['Match']) ? $overrideSetting['Match'] : null;
$customMatchArray['match_file'] = $overrideMatchFilePath;
$customMatchArray['override_name'] = $overrideName;
$matchFileArray[$overrideSource]['custom_match'][] = $customMatchArray;
// }
// if overriding a non-existing template
// then we use the override template as main template
// this code should probably be removed
// because we should not allow an override if the main template is missing
if ($resourceInUse && !isset($matchFileArray[$overrideSource]['base_dir'])) {
$matchFileArray[$overrideSource]['base_dir'] = $resourceInUse;
$matchFileArray[$overrideSource]['template'] = $overrideSource;
}
if (!$overrideMatchFilePath) {
eZDebug::writeError("Custom match file: path '{$overrideMatchFile}' not found in any resource. Check the template settings in settings/override.ini", __METHOD__);
eZDebug::writeError(implode(', ', $triedFiles), __METHOD__ . ' tried files');
}
}
if ($siteAccess === false) {
self::$overrideArrayCache = $matchFileArray;
}
return $matchFileArray;
}
示例4: array_merge
}
}
} else {
$ini = eZINI::instance();
$standardDesign = $ini->variable("DesignSettings", "StandardDesign");
$siteDesign = $ini->variable("DesignSettings", "SiteDesign");
$additionalSiteDesignList = $ini->variable("DesignSettings", "AdditionalSiteDesignList");
$designList = array_merge(array($standardDesign), $additionalSiteDesignList, array($siteDesign));
$tpl = eZTemplate::factory();
$script->setIterationData('.', '~');
$script->setShowVerboseOutput(true);
foreach ($designList as $design) {
$cli->output("Validating in design " . $cli->stylize('emphasize', $design));
$baseDir = 'design/' . $design;
$files = eZDir::recursiveFindRelative($baseDir, 'templates', "\\.tpl");
$files = array_merge($files, eZDir::recursiveFindRelative($baseDir, 'override/templates', "\\.tpl"));
$script->resetIteration(count($files));
foreach ($files as $fileRelative) {
$file = $baseDir . '/' . $fileRelative;
$status = $tpl->validateTemplateFile($file);
$text = false;
if ($status) {
$text = "Template file valid: " . $cli->stylize('file', $file);
} else {
$text = "Template file invalid: " . $cli->stylize('file', $file);
}
if (!$status) {
$result = false;
}
$script->iterate($cli, $status, $text);
}
示例5: recursiveFindRelative
static function recursiveFindRelative( $baseDir, $subDir, $suffix )
{
$dir = $baseDir;
if ( $subDir != "" )
{
if ( $dir != '' )
$dir .= "/" . $subDir;
else
$dir .= $subDir;
}
if ( !is_dir( $dir ) )
{
return array();
}
$returnFiles = array();
if ( $handle = @opendir( $dir ) )
{
while ( ( $file = readdir( $handle ) ) !== false )
{
if ( ( $file == "." ) || ( $file == ".." ) )
{
continue;
}
if ( is_dir( $dir . '/' . $file ) )
{
if ( $file[0] != "." )
{
$files = eZDir::recursiveFindRelative( $baseDir, $subDir . '/' . $file, $suffix );
$returnFiles = array_merge( $files, $returnFiles );
}
}
else
{
if ( preg_match( "/$suffix$/", $file ) )
$returnFiles[] = $subDir . '/' . $file;
}
}
@closedir( $handle );
}
return $returnFiles;
}
示例6: array
if ($options['no-print']) {
$print = false;
}
$ini = eZINI::instance();
$pathList = $options['arguments'];
$error = false;
$badFiles = array();
$shellTag = '#!';
$startTag = '<?php';
$shortStartTag = '<?';
$endTag = '?>';
$endNewlineTag = "?>\n";
foreach ($pathList as $path) {
$files = array();
if (is_dir($path)) {
$files = eZDir::recursiveFindRelative(false, $path, '.php');
} else {
if (is_file($path)) {
$files[] = $path;
} else {
if (!file_exists($path)) {
if ($print) {
$cli->output($cli->stylize('file', $path) . ": file does not exist");
}
}
}
}
foreach ($files as $file) {
$fd = fopen($file, 'r');
if ($fd) {
$startText = fread($fd, 5);
示例7: foreach
$extensionDirectory = eZExtension::baseDirectory();
$designINI = eZINI::instance( 'design.ini' );
$extensions = $designINI->variable( 'ExtensionSettings', 'DesignExtensions' );
foreach ( $designList as $design )
{
$cli->output( "Compiling in design " . $cli->stylize( 'emphasize', $design ) );
$baseDir = 'design/' . $design;
$files = eZDir::recursiveFindRelative( '', "$baseDir/templates", "\.tpl" );
$files = array_merge( $files, eZDir::recursiveFindRelative( '', "$baseDir/override/templates", "\.tpl" ) );
foreach( $extensions as $extension )
{
$files = array_merge( $files, eZDir::recursiveFindRelative( '', "$extensionDirectory/$extension/$baseDir/templates", "\.tpl" ) );
$files = array_merge( $files, eZDir::recursiveFindRelative( '', "$extensionDirectory/$extension/$baseDir/override/templates", "\.tpl" ) );
}
$script->resetIteration( count( $files ) );
foreach ( $files as $file )
{
$status = $tpl->compileTemplateFile( $file );
$text = false;
if ( $status )
$text = "Compiled template file: " . $cli->stylize( 'file', $file );
else
$text = "Compilation failed: " . $cli->stylize( 'file', $file );
$script->iterate( $cli, $status, $text );
}
}
}
示例8: getMIBTree
/**
* Builds the mib tree, either for a single oid or for full settings.
* Contrary to parents version, we store value too
* NB: we do not cache this, as in pass_persist mode settings might change
* over time (be added/removed, etc...)
* @return array A nested array:
* [ 1-n => [ 'name' => filename, 'children' => [ 1-n => [ 'name' => groupname, 'children' => [ 1-n => [ 'name' => settingname, 'value' => value, 'syntax' => asn-type, 'access' => rw/ro ] ] ] ] ] ]
* @see eZMIBTree
*/
function getMIBTree($oid = null)
{
if ($oid != null) {
$oid = explode('.', $oid);
if (count($oid) != 3) {
return 0;
}
}
// nb: should try to avoid caching these settings, since the script can
// be running for a long time
$rootDir = 'settings';
$iniFiles = eZDir::recursiveFindRelative($rootDir, '', '.ini');
sort($iniFiles);
$out = array();
foreach ($iniFiles as $key => $file) {
$file = str_replace('/', '', $file);
if ($oid == null || $key == $oid[0] - 1) {
$ini = ezINI::instance($file);
$outgroups = array();
$j = 1;
$groups = $ini->groups();
ksort($groups);
foreach ($groups as $group => $settings) {
if ($oid == null || $j == $oid[1]) {
$i = 1;
$values = array();
ksort($settings);
foreach ($settings as $setting => $val) {
if ($oid == null || $i == $oid[2]) {
if (is_numeric($val)) {
$type = 'INTEGER';
} else {
if ($val == 'true' || $val == 'enabled') {
$type = 'Boolean';
$val = 1;
} else {
if ($val == 'false' || $val == 'disabled') {
$type = 'Boolean';
$val = 2;
} else {
$type = 'DisplayString';
}
}
}
$values[$i] = array('name' => $setting . ucfirst($group) . ucfirst(str_replace('.ini', '', $file)), 'value' => $val, 'syntax' => $type, 'access' => eZMIBTree::access_read_only, 'description' => $file . ' / ' . $group . ' / ' . $setting);
}
$i++;
}
$outgroups[$j] = array('name' => $group . ucfirst(str_replace('.ini', '', $file)), 'children' => $values);
}
$j++;
}
// we do not remove.ini here to avoid clashes with identifier 'shop', 'ldap', etc...
$out[$key + 1] = array('name' => $file, 'children' => $outgroups);
}
}
if ($oid == null) {
$out = array('name' => 'eZPublish', 'children' => array(1 => array('name' => 'settings', 'children' => array(1 => array('name' => 'currentSASettings', 'children' => $out)))));
}
return $out;
}
示例9: fetchCollectionAttributeHTTPInput
function fetchCollectionAttributeHTTPInput($collection, $collectionAttribute, $http, $base, $contentObjectAttribute)
{
EnhancedeZBinaryFileType::checkFileUploads();
if (eZHTTPFile::canFetch($base . "_data_enhancedbinaryfilename_" . $contentObjectAttribute->attribute("id")) != eZHTTPFile::UPLOADEDFILE_OK) {
return false;
}
//Check allowed file type - must do it here,again - otherwise an illegal
//file will still be created in the storage directory
$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;
}
//$contentObjectAttribute->setContent( $binaryFile );
if ($binaryFile instanceof eZHTTPFile) {
//clean up older files.
$moduleINI = eZINI::instance('module.ini.append.php', 'settings');
$maxFiles = $moduleINI->variable('RemoveFiles', 'MaxFiles');
$downloadPath = $moduleINI->variable('RemoveFiles', 'DownloadPath');
$downloadPath = trim($downloadPath, "/");
if (!$downloadPath) {
$downloadPath = 'original/collected';
}
if ($maxFiles > 0) {
$Files = array();
$storageDir = eZSys::storageDirectory();
$fileCollection = eZDir::recursiveFindRelative($storageDir, $downloadPath, '.*');
if (count($fileCollection) >= $maxFiles) {
foreach ($fileCollection as $fileItem) {
$lastModified = filemtime($storageDir . '/' . $fileItem);
$Files[$fileItem] = filemtime($storageDir . '/' . $fileItem);
}
asort($Files, SORT_NUMERIC);
while (count($Files) >= $maxFiles) {
$removeFile = key($Files);
if (file_exists($storageDir . '/' . $removeFile)) {
if (!unlink($storageDir . '/' . $removeFile)) {
eZDebug::writeError("Failed to delete file: " . $storageDir . '/' . $removeFile, "EnhancedeZBinaryFileType");
return false;
}
}
array_shift($Files);
}
}
}
//end cleanup
// $contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
//$version = $contentObjectAttribute->attribute( "version" );
$mimeData = eZMimeType::findByFileContents($binaryFile->attribute("original_filename"));
//Nice name but it still uses the extension to set the mimetype and therefore can be bogus
$mime = $mimeData['name'];
if ($mime == '') {
$mime = $binaryFile->attribute("mime_type");
}
$extension = eZFile::suffix($binaryFile->attribute("original_filename"));
$binaryFile->setMimeType($mime);
if (!$binaryFile->store($downloadPath, $extension)) {
eZDebug::writeError("Failed to store http-file: " . $binaryFile->attribute("original_filename"), "EnhancedeZBinaryFileType");
return false;
}
//Adds xmltext to collection attribute with file info to data_text attribute
$doc = new DOMDocument('1.0', 'utf-8');
$root = $doc->createElement('binaryfile-info');
$binaryFileList = $doc->createElement('binaryfile-attributes');
foreach ($binaryFile as $key => $binaryFileItem) {
$binaryFileElement = $doc->createElement($key, $binaryFileItem);
$binaryFileList->appendChild($binaryFileElement);
}
$root->appendChild($binaryFileList);
$doc->appendChild($root);
$docText = EnhancedeZBinaryFileType::domString($doc);
$collectionAttribute->setAttribute('data_text', $docText);
}
return true;
}