本文整理汇总了PHP中getFiles函数的典型用法代码示例。如果您正苦于以下问题:PHP getFiles函数的具体用法?PHP getFiles怎么用?PHP getFiles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getFiles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFiles
function getFiles(&$rdi, $depth = 0)
{
if (!is_object($rdi)) {
return;
}
$files = array();
// order changes per machine
for ($rdi->rewind(); $rdi->valid(); $rdi->next()) {
if ($rdi->isDot()) {
continue;
}
if ($rdi->isDir() || $rdi->isFile()) {
$indent = '';
for ($i = 0; $i <= $depth; ++$i) {
$indent .= " ";
}
$files[] = $indent . $rdi->current() . "\n";
if ($rdi->hasChildren()) {
getFiles($rdi->getChildren(), 1 + $depth);
}
}
}
asort($files);
var_dump(array_values($files));
}
示例2: getFiles
function getFiles($dir, $ext, $exclude = array())
{
$returnList = array();
$nextDirs = array();
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
if (is_dir($file)) {
array_push($nextDirs, $file);
} else {
$info = pathinfo($dir . '/' . $file);
if ($info['extension'] == $ext) {
$dontInclude = false;
for ($l = 0; $l < count($exclude); ++$l) {
if (strtolower($file) == strtolower($exclude[$l])) {
$dontInclude = true;
}
}
if (!$dontInclude) {
array_push($returnList, $file);
}
}
}
}
}
closedir($dh);
}
for ($i = 0; $i < count($nextDirs); ++$i) {
$newFiles = getFiles($dir . '/' . $nextDirs[$i], $ext, $exclude);
for ($j = 0; $j < count($newFiles); ++$j) {
array_push($returnList, $nextDirs[$i] . '/' . $newFiles[$j]);
}
}
return $returnList;
}
示例3: buildCache
/**
* Builds the cache of Dashlets by scanning the system
*/
function buildCache()
{
global $beanList;
$dashletFiles = array();
$dashletFilesCustom = array();
getFiles($dashletFiles, 'modules', '/^.*\\/Dashlets\\/[^\\.]*\\.php$/');
getFiles($dashletFilesCustom, 'custom/modules', '/^.*\\/Dashlets\\/[^\\.]*\\.php$/');
$cacheDir = create_cache_directory('dashlets/');
$allDashlets = array_merge($dashletFiles, $dashletFilesCustom);
$dashletFiles = array();
foreach ($allDashlets as $num => $file) {
if (substr_count($file, '.meta') == 0) {
// ignore meta data files
$class = substr($file, strrpos($file, '/') + 1, -4);
$dashletFiles[$class] = array();
$dashletFiles[$class]['file'] = $file;
$dashletFiles[$class]['class'] = $class;
if (is_file(preg_replace('/(.*\\/.*)(\\.php)/Uis', '$1.meta$2', $file))) {
// is there an associated meta data file?
$dashletFiles[$class]['meta'] = preg_replace('/(.*\\/.*)(\\.php)/Uis', '$1.meta$2', $file);
require $dashletFiles[$class]['meta'];
if (isset($dashletMeta[$class]['module'])) {
$dashletFiles[$class]['module'] = $dashletMeta[$class]['module'];
}
}
$filesInDirectory = array();
getFiles($filesInDirectory, substr($file, 0, strrpos($file, '/')), '/^.*\\/Dashlets\\/[^\\.]*\\.icon\\.(jpg|jpeg|gif|png)$/i');
if (!empty($filesInDirectory)) {
$dashletFiles[$class]['icon'] = $filesInDirectory[0];
// take the first icon we see
}
}
}
write_array_to_file('dashletsFiles', $dashletFiles, $cacheDir . 'dashlets.php');
}
示例4: getFiles
function getFiles(&$modx, &$results, &$filesfound, $directory, $listing = array(), $count = 0)
{
$dummy = $count;
if (@($handle = opendir($directory))) {
while ($file = readdir($handle)) {
if ($file == '.' || $file == '..' || strpos($file, '.') === 0) {
continue;
} else {
if ($h = @opendir($directory . $file . "/")) {
closedir($h);
$count = -1;
$listing["{$file}"] = getFiles($modx, $results, $filesfound, $directory . $file . "/", array(), $count + 1);
} else {
$listing[$dummy] = $file;
$dummy = $dummy + 1;
$filesfound++;
}
}
}
} else {
$results .= $modx->lexicon('import_site_failed') . " Could not open '{$directory}'.<br />";
}
@closedir($handle);
return $listing;
}
示例5: getFiles
/**
* Get files under a directory recursive.
*
* @param string $dir
* @param array $exceptions
* @access private
* @return array
*/
function getFiles($dir, $exceptions = array())
{
static $files = array();
if (!is_dir($dir)) {
return $files;
}
$dir = realpath($dir) . '/';
$entries = scandir($dir);
foreach ($entries as $entry) {
if ($entry == '.' or $entry == '..' or $entry == '.svn' or $entry == 'db') {
continue;
}
if (in_array($entry, $exceptions)) {
continue;
}
$fullEntry = $dir . $entry;
if (is_file($fullEntry)) {
$files[] = $dir . $entry;
} else {
$nextDir = $dir . $entry;
getFiles($nextDir);
}
}
return $files;
}
示例6: getFiles
function getFiles($fileName, &$updateTime = 0, $url = '', $levels = 100, $types = array('jpg', 'png', 'gif', 'jpeg', 'css', 'js'))
{
if (empty($fileName) || !$levels) {
return false;
}
$files = array();
if (is_file($fileName)) {
$updateTime = getMax(filectime($fileName), $updateTime);
$files[] = $url;
} else {
if ($dir = @opendir($fileName)) {
while (($file = readdir($dir)) !== false) {
if (in_array($file, array('.', '..'))) {
continue;
}
if (is_dir($fileName . '/' . $file)) {
$files2 = getFiles($fileName . '/' . $file, $updateTime, $url . '/' . $file, $levels - 1);
if ($files2) {
$files = array_merge($files, $files2);
}
} else {
$updateTime = getMax(filectime($fileName . '/' . $file), $updateTime);
$type = end(explode(".", $file));
if (in_array($type, $types)) {
$files[] = $url . '/' . $file;
}
}
}
}
}
@closedir($dir);
// echo date("Y-m-d H:i:s",$updateTime).'<hr>';
return $files;
}
示例7: nm_get_languages
function nm_get_languages()
{
$languages = array();
$files = getFiles(NMLANGPATH);
foreach ($files as $file) {
if (isFile($file, NMLANGPATH, 'php')) {
$lang = basename($file, '.php');
$languages[$lang] = NMLANGPATH . $file;
}
}
ksort($languages);
return $languages;
}
示例8: generateSitemapWithoutPing
public static function generateSitemapWithoutPing()
{
global $SITEURL;
$filenames = getFiles(GSDATAPAGESPATH);
if (count($filenames)) {
foreach ($filenames as $file) {
if (isFile($file, GSDATAPAGESPATH, 'xml')) {
$data = getXML(GSDATAPAGESPATH . $file);
if ($data->url != '404' && $data->private != 'Y') {
$pagesArray[] = array('url' => (string) $data->url, 'parent' => (string) $data->parent, 'date' => (string) $data->pubDate, 'menuStatus' => (string) $data->menuStatus);
}
}
}
}
$pagesSorted = subval_sort($pagesArray, 'menuStatus');
$languages = return_i18n_available_languages();
$deflang = return_i18n_default_language();
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
$xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
if (count($pagesSorted)) {
foreach ($pagesSorted as $page) {
// set <loc>
if (count($languages) > 1) {
$pos = strrpos($page['url'], '_');
if ($pos !== false) {
$pageLoc = find_i18n_url(substr($page['url'], 0, $pos), $page['parent'], substr($page['url'], $pos + 1));
} else {
$pageLoc = find_i18n_url($page['url'], $page['parent'], $deflang);
}
} else {
$pageLoc = find_i18n_url($page['url'], $page['parent']);
}
// set <lastmod>
$pageLastMod = makeIso8601TimeStamp(date("Y-m-d H:i:s", strtotime($page['date'])));
// set <changefreq>
$pageChangeFreq = 'weekly';
// set <priority>
$pagePriority = $page['menuStatus'] == 'Y' ? '1.0' : '0.5';
//add to sitemap
$url_item = $xml->addChild('url');
$url_item->addChild('loc', htmlspecialchars($pageLoc));
$url_item->addChild('lastmod', $pageLastMod);
$url_item->addChild('changefreq', $pageChangeFreq);
$url_item->addChild('priority', $pagePriority);
}
}
//create xml file
$file = GSROOTPATH . 'sitemap.xml';
XMLsave($xml, $file);
}
示例9: loadModules
function loadModules()
{
global $ARI_ADMIN_MODULES;
global $ARI_DISABLED_MODULES;
global $loaded_modules;
$modules_path = "./modules";
if (is_dir($modules_path)) {
$filter = ".module";
$recursive_max = 1;
$recursive_count = 0;
$files = getFiles($modules_path, $filter, $recursive_max, $recursive_count);
foreach ($files as $key => $path) {
// build module object
include_once $path;
$path_parts = pathinfo($path);
list($name, $ext) = split("\\.", $path_parts['basename']);
// check for module and get rank
if (class_exists($name)) {
$module = new $name();
// check if admin module
$found = 0;
if ($ARI_ADMIN_MODULES) {
$admin_modules = split(',', $ARI_ADMIN_MODULES);
foreach ($admin_modules as $key => $value) {
if ($name == $value) {
$found = 1;
break;
}
}
}
// check if disabled module
$disabled = 0;
if ($ARI_DISABLED_MODULES) {
$disabled_modules = split(',', $ARI_DISABLED_MODULES);
foreach ($disabled_modules as $key => $value) {
if ($name == $value) {
$disabled = 1;
break;
}
}
}
// if not admin module or admin user add to module name to array
if (!$disabled && (!$found || $_SESSION['ari_user']['admin'])) {
$loaded_modules[$name] = $module;
}
}
}
} else {
$_SESSION['ari_error'] = _("{$path} not a directory or not readable");
}
}
示例10: getFiles
function getFiles($dir, $subfolder = '.')
{
$handle = opendir($dir);
$templates = array();
while ($file = readdir($handle)) {
if (is_file($dir . '/' . $file) and substr($file, -3) == 'tpl') {
$templates[] = $subfolder . '/' . $file;
} elseif (is_dir($dir . '/' . $file) and $file != '.' && $file != '..') {
$templates = array_merge($templates, getFiles($dir . '/' . $file, $subfolder . '/' . $file));
}
}
closedir($handle);
return $templates;
}
示例11: getFiles
/**
* Retrieves all file names from a directory
*
* @param string $dir_name Name of the directory from which to extract file names
* @return string[] $file_list
*/
function getFiles($dir_name)
{
$dir_files = scandir($dir_name);
$file_list = array();
foreach ($dir_files as $file_name) {
$file = "{$dir_name}/{$file_name}";
if (is_file($file)) {
$file_list[] = $file;
} elseif ($file_name[0] != '.' && is_dir($file)) {
$file_list = array_merge(getFiles($file), $file_list);
}
}
return $file_list;
}
示例12: __construct
public function __construct(SugarView &$view)
{
require_once 'include/utils/file_utils.php';
$files = array();
getFiles($files, 'custom/include/utils/DevToolKit', '/\\.php/');
foreach ($files as $file) {
preg_match("/\\/(\\w+)\\.php\$/", $file, $matches);
$class = $matches[1];
require_once $file;
$bean = new $class($view);
if ($bean->has_metadata()) {
$this->toolkits[] = $bean;
}
}
}
示例13: getFiles
function getFiles($dir, &$results = array(), $filename = 'template.html')
{
$files = scandir($dir);
foreach ($files as $key => $value) {
$path = realpath($dir . '/' . $value);
if (!is_dir($path)) {
if ($value == $filename) {
$results[] = $path;
}
} else {
if ($value != "." && $value != "..") {
getFiles($path, $results);
}
}
}
return $results;
}
示例14: getFiles
function getFiles($path, $base_path = null)
{
$path_files = array_diff(scandir($path), array('..', '.'));
$files = array();
foreach ($path_files as $file) {
$file_path = $path . '/' . $file;
if ($file[0] == '.') {
continue;
}
if (is_dir($file_path)) {
$files = array_merge($files, getFiles($file_path, $base_path ?: $path));
} else {
$files[] = $base_path ? str_replace($base_path . '/', '', $file_path) : $file_path;
}
}
return $files;
}
示例15: getFiles
function getFiles($i, $pref)
{
$output = array();
foreach ($i as $f) {
$f = $pref . '/' . $f;
if (is_dir($f)) {
$base = basename($f);
if ($base[0] !== '.') {
if ($base !== 'tests' and $base !== 'smarty' and $base !== 'tinymce' and $base !== 'smarty-plugins') {
$output = array_merge($output, getFiles(scandir($f), $f));
}
}
} else {
$output[] = $f;
}
}
return $output;
}