本文整理汇总了PHP中File::scanFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP File::scanFiles方法的具体用法?PHP File::scanFiles怎么用?PHP File::scanFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::scanFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _scanClassDir
protected static function _scanClassDir($path, &$map, &$mapPackaged, $exceptPath, $packages, $packagesCfg)
{
$path = File::fillEndSep($path);
$items = File::scanFiles($path, array('.php'), false);
if (empty($items)) {
return;
}
foreach ($items as $item) {
if (File::getExt($item) === '.php') {
$parts = explode(DIRECTORY_SEPARATOR, str_replace($exceptPath, '', substr($item, 0, -4)));
$parts = array_map('ucfirst', $parts);
$class = implode('_', $parts);
$package = false;
if (isset($packages[$item]) && $packagesCfg['packages'][$packages[$item]]['active']) {
$package = $packagesCfg->get('path') . $packages[$item] . '.php';
} else {
$package = $item;
}
if (!isset($map[$class])) {
$map[$class] = $item;
}
if (!isset($mapPackaged[$class])) {
$mapPackaged[$class] = $package;
}
} else {
self::_scanClassDir($item, $map, $mapPackaged, $exceptPath, $packages, $packagesCfg);
}
}
}
示例2: controllersAction
/**
* Get list of available controllers
*/
public function controllersAction()
{
$appPath = $this->_configMain['application_path'];
$folders = File::scanFiles($this->_configMain->get('frontend_controllers'), false, true, File::Dirs_Only);
$data = array();
if (!empty($folders)) {
foreach ($folders as $item) {
$name = basename($item);
if (file_exists($item . '/Controller.php')) {
$name = str_replace($appPath, '', $item . '/Controller.php');
$name = Utils::classFromPath($name);
$data[] = array('id' => $name, 'title' => $name);
}
}
}
if ($this->_configMain->get('allow_externals')) {
$config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
$eExpert = new Externals_Expert($this->_configMain, $config);
$classes = $eExpert->getClasses();
$extControllers = $eExpert->getFrontendControllers();
if (!empty($extControllers)) {
$data = array_merge($data, array_values($extControllers));
}
}
Response::jsonSuccess($data);
}
示例3: getlogfilesAction
public function getlogfilesAction()
{
//$version = $this->_configMain['development_version'];
$logPath = $this->_configMain['orm_log_path'];
//$fileName = $logPath . 'default_'.$version . '_build_log.sql';
$files = File::scanFiles($logPath, array('.sql'), false);
$data = array();
foreach ($files as $file) {
$file = basename($file, '.sql');
$data[] = array('id' => $file);
}
Response::jsonSuccess($data);
}
示例4: getConnections
/**
* Get connections list
* @param integer $devType
* @throws Exception
* @return array
*/
public function getConnections($devType)
{
if (!$this->typeExists($devType)) {
throw new Exception('Backend_Orm_Connections_Manager :: getConnections undefined dev type ' . $devType);
}
$files = File::scanFiles($this->_config[$devType]['dir'], array('.php'), false, File::Files_Only);
$result = array();
if (!empty($files)) {
foreach ($files as $item) {
$result[substr(basename($item), 0, -4)] = Config::factory(Config::File_Array, $item);
}
}
return $result;
}
示例5: getRegisteredObjects
/**
* Get list of registered objects (names only)
* @return array
*/
public function getRegisteredObjects()
{
if (is_null(self::$_objects)) {
$paths = File::scanFiles(Db_Object_Config::getConfigPath(), array('.php'), false, File::Files_Only);
self::$_objects = array();
if (!empty($paths)) {
foreach ($paths as $path) {
self::$_objects[] = substr(basename($path), 0, -4);
}
}
/*
* Scan for External objects
*/
if (self::$_externalsExpert) {
$objects = self::$_externalsExpert->getObjects();
if (!empty($objects)) {
self::$_objects = array_merge(self::$_objects, array_keys($objects));
}
}
}
return self::$_objects;
}
示例6: getList
/**
* Get list of dictionaries
* return array
*/
public function getList()
{
if (!is_null(self::$_list)) {
return array_keys(self::$_list);
}
$files = File::scanFiles($this->_path, array('.php'), false, File::Files_Only);
$list = array();
if (!empty($files)) {
foreach ($files as $path) {
$name = substr(basename($path), 0, -4);
$list[$name] = $path;
}
}
$external = Dictionary::getExternal();
if (!empty($external)) {
$list = array_merge($list, $external);
}
self::$_list = $list;
if ($this->_cache) {
$this->_cache->save($list, self::CACHE_KEY_LIST);
}
return array_keys($list);
}
示例7: classlistAction
/**
* List defined Blocks
*/
public function classlistAction()
{
$blocksPath = $this->_configMain['blocks'];
$classesPath = $this->_configMain['application_path'];
$files = File::scanFiles($blocksPath, array('.php'), true, File::Files_Only);
foreach ($files as $k => $file) {
$class = Utils::classFromPath(str_replace($classesPath, '', $file));
if ($class != 'Block_Abstract') {
$data[] = array('id' => $class, 'title' => $class);
}
}
if ($this->_configMain->get('allow_externals')) {
$config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
$eExpert = new Externals_Expert($this->_configMain, $config);
$extBlocks = $eExpert->getBlocks();
if (!empty($extBlocks)) {
foreach ($extBlocks as $class => $path) {
$data[] = array('id' => $class, 'title' => $class);
}
}
}
Response::jsonSuccess($data);
}
示例8: listAction
public function listAction()
{
$modulesCfg = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php')->__toArray();
$vendors = File::scanFiles($this->_configMain->get('external_modules'), false, false, File::Dirs_Only);
if (!$this->_configMain->get('allow_externals') || empty($vendors)) {
Response::jsonSuccess(array());
}
foreach ($vendors as $path) {
$vendorName = basename($path);
$modules = File::scanFiles($path, false, false, File::Dirs_Only);
if (empty($modules)) {
continue;
}
foreach ($modules as $module) {
$moduleName = basename($module);
$uid = $vendorName . '/' . $moduleName;
if (!file_exists($module . '/config.ini')) {
continue;
}
$cfg = parse_ini_file($module . '/config.ini', true);
if (!isset($cfg['INFO'])) {
continue;
}
$info = $cfg['INFO'];
if (!isset($modulesCfg[$uid])) {
$modulesCfg[$uid] = array('active' => false);
}
$modulesCfg[$uid]['title'] = $info['title'];
$modulesCfg[$uid]['description'] = $info['description'];
$modulesCfg[$uid]['author'] = $info['author'];
$modulesCfg[$uid]['version'] = $info['version'];
$modulesCfg[$uid]['id'] = $uid;
}
}
Response::jsonSuccess(array_values($modulesCfg));
}
示例9: getSubPackages
/**
* Get language subpackages
* @param string $language - optional
* @return array
*/
public function getSubPackages($lang = false)
{
if (!$lang) {
$lang = $this->_indexLanguage;
}
$langDir = $this->_appConfig->get('lang_path') . $lang;
if (!is_dir($langDir)) {
return array();
}
$files = File::scanFiles($langDir, array('.php'), false, File::Files_Only);
$data = array();
foreach ($files as $file) {
// IIS fix
if (DIRECTORY_SEPARATOR !== '/') {
$file = str_replace(DIRECTORY_SEPARATOR, '/', $file);
}
$file = str_replace('//', '/', $file);
$lang = str_replace($langDir, '', substr($file, 0, -4));
if (basename($file) !== 'objects.php') {
$data[] = $lang;
}
}
return $data;
}
示例10: rmdirRecursive
/**
* Recursively remove files and dirs from given $pathname
* @param string $pathname
* @param bool $removeParentDir
* @return boolean
*/
public static function rmdirRecursive($pathname, $removeParentDir = false)
{
$filesDirs = File::scanFiles($pathname, false, true, File::Files_Dirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($filesDirs as $v) {
if (is_dir($v)) {
if (!rmdir($v)) {
return false;
}
} elseif (is_file($v) || is_link($v)) {
if (!unlink($v)) {
return false;
}
} else {
return false;
}
}
if ($removeParentDir) {
if (!rmdir($pathname)) {
return false;
}
}
return true;
}
示例11: fslistAction
/**
* Inerface projects list
*/
public function fslistAction()
{
$path = Request::post('node', 'string', '');
$config = $config = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php');
$dirPath = $config->get('configs');
$list = array();
if (!is_dir($dirPath)) {
Response::jsonArray(array());
}
if ($path === '') {
if ($this->_configMain->get('allow_externals')) {
$config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
$eExpert = new Externals_Expert($this->_configMain, $config);
$extProjects = $eExpert->getProjects();
if (!empty($extProjects)) {
foreach ($extProjects as $item) {
$list[] = $item;
}
}
}
$path = $dirPath . $path;
}
$files = File::scanFiles($path, array('.dat'), false, File::Files_Dirs);
/**
* This is hard fix for windows
*/
if (DIRECTORY_SEPARATOR == '\\') {
foreach ($files as &$v) {
$v = str_replace('\\', '/', $v);
$v = str_replace('//', '/', $v);
}
unset($v);
}
if (empty($files)) {
Response::jsonArray(array());
}
foreach ($files as $k => $fpath) {
$text = basename($fpath);
if ($text === '.svn') {
continue;
}
$obj = new stdClass();
$obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath);
$obj->text = $text;
if (is_dir($fpath)) {
$obj->expanded = false;
$obj->leaf = false;
} else {
$obj->leaf = true;
}
$list[] = $obj;
}
Response::jsonArray($list);
}
示例12: imglistAction
public function imglistAction()
{
$templates = $this->_config->get('templates');
$dirPath = $this->_configMain->get('docroot');
$dir = Request::post('dir', 'string', '');
if (!is_dir($dirPath . $dir)) {
Response::jsonArray(array());
}
$files = File::scanFiles($dirPath . $dir, array('.jpg', '.png', '.gif', '.jpeg'), false, File::Files_Only);
if (empty($files)) {
Response::jsonArray(array());
}
sort($files);
$list = array();
foreach ($files as $k => $fpath) {
// ms fix
$fpath = str_replace('\\', '/', $fpath);
$text = basename($fpath);
if ($text === '.svn') {
continue;
}
$list[] = array('name' => $text, 'url' => str_replace($dirPath . '/', $this->_configMain->get('wwwroot'), $fpath), 'path' => str_replace($dirPath . '/', $templates['wwwroot'], $fpath));
}
Response::jsonSuccess($list);
}
示例13: themeslistAction
/**
* Get themes list
*/
public function themeslistAction()
{
$themes = File::scanFiles($this->_configMain->get('themes'), false, false, File::Dirs_Only);
$result = array();
if (!empty($themes)) {
foreach ($themes as $name) {
$code = basename($name);
if ($code[0] != '.') {
$result[] = array('id' => $code, 'title' => $code);
}
}
}
if ($this->_configMain->get('allow_externals')) {
$config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
$eExpert = new Externals_Expert($this->_configMain, $config);
$themes = $eExpert->getThemes();
if (!empty($themes)) {
foreach ($themes as $k => $path) {
$result[] = array('id' => $k, 'title' => $k);
}
}
}
Response::jsonSuccess($result);
}
示例14: listadaptersAction
/**
* Get list of existing form field adapters
*/
public function listadaptersAction()
{
$data = array();
$autoloaderPaths = $this->_configMain['autoloader'];
$autoloaderPaths = $autoloaderPaths['paths'];
$files = File::scanFiles($this->_config->get('components') . '/Field', array('.php'), true, File::Files_Only);
if (!empty($files)) {
foreach ($files as $item) {
$class = Utils::classFromPath(str_replace($autoloaderPaths, '', $item));
$data[] = array('id' => $class, 'title' => str_replace($this->_config->get('components') . '/', '', substr($item, 0, -4)));
}
}
Response::jsonArray($data);
}
示例15: Application
* and save a reference for it (for convenience)
* @var Config_Simple $appConfig
*/
$appConfig = Config::factory(Config::Simple, 'main');
$appConfig->setData($config);
Registry::set('main', $appConfig, 'config');
/**
* Convert the data of main_config file
* in to the general form of configuration
* and save a reference for it (for convenience)
* @var Config_Simple $appConfig
*/
/*
* Starting the application
*/
$app = new Application($appConfig);
$app->setAutoloader($autoloader);
$app->init();
// build objects
$objectFiles = File::scanFiles($config['object_configs'], array('.php'), false, File::Files_Only);
foreach ($objectFiles as $file) {
$object = substr(basename($file), 0, -4);
echo 'build ' . $object . ' : ';
$builder = new Db_Object_Builder($object);
if ($builder->build()) {
echo 'OK';
} else {
echo 'Error! ' . strip_tags(implode(', ', $builder->getErrors()));
}
echo "\n";
}