本文整理汇总了PHP中Cake\Filesystem\Folder::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::read方法的具体用法?PHP Folder::read怎么用?PHP Folder::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Filesystem\Folder
的用法示例。
在下文中一共展示了Folder::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: includeCmsAdminAssets
/**
* Includes all necessary JS code for admin editing of CmsBlocks.
*
* @return void
*/
public function includeCmsAdminAssets()
{
$script = 'var Cms = {AdminWidgetControllers: {}};';
$this->Html->scriptBlock($script, ['block' => true]);
$this->Html->script('Cms.app/lib/AdminWidgetController.js', ['block' => true]);
$availableWidgets = WidgetManager::getAvailableWidgets();
$adminControllers = [];
$folder = new Folder();
foreach ($availableWidgets as $widgetIdentifier) {
$widget = WidgetFactory::identifierFactory($widgetIdentifier);
$webrootPath = $widget->getWebrootPath();
if (!is_dir($webrootPath)) {
continue;
}
$folder->cd($webrootPath . 'js/');
$jsFiles = $folder->read();
if (empty($jsFiles[1])) {
continue;
}
foreach ($jsFiles[1] as $filename) {
if (strpos($filename, 'AdminWidgetController.js') !== false) {
$adminControllers[] = '/cms/widget/' . $widgetIdentifier . '/js/' . $filename;
}
}
}
$this->Html->script($adminControllers, ['block' => true]);
}
示例2: _findTemplates
/**
* Find the paths to all the installed shell templates in the app.
*
* Bake templates are directories under `Template/Bake` path.
* They are listed in this order: app -> plugin -> default
*
* @return array Array of bake templates that are installed.
*/
protected function _findTemplates()
{
$paths = App::path('Template');
$plugins = Plugin::loaded();
foreach ($plugins as $plugin) {
$paths[] = Plugin::classPath($plugin) . 'Template' . DS;
}
$core = current(App::core('Template'));
$Folder = new Folder($core . 'Bake' . DS . 'default');
$contents = $Folder->read();
$templateFolders = $contents[0];
$paths[] = $core;
foreach ($paths as $i => $path) {
$paths[$i] = rtrim($path, DS) . DS;
}
$this->_io->verbose('Found the following bake templates:');
$templates = [];
foreach ($paths as $path) {
$Folder = new Folder($path . 'Bake', false);
$contents = $Folder->read();
$subDirs = $contents[0];
foreach ($subDirs as $dir) {
$Folder = new Folder($path . 'Bake' . DS . $dir);
$contents = $Folder->read();
$subDirs = $contents[0];
if (array_intersect($contents[0], $templateFolders)) {
$templateDir = $path . 'Bake' . DS . $dir . DS;
$templates[$dir] = $templateDir;
$this->_io->verbose(sprintf("- %s -> %s", $dir, $templateDir));
}
}
}
return $templates;
}
示例3: scanFolder
/**
* Scan folder by path.
*
* @param null $path
* @return void|\Cake\Network\Response
*/
public function scanFolder($path = null)
{
if (!$path) {
$path = WWW_ROOT;
}
$Folder = new Folder();
$_path = $this->request->query('path') ? $this->request->query('path') : $path;
if (!is_dir($_path)) {
$Folder->create($_path);
}
$_path = realpath($_path) . DS;
$regex = '/^' . preg_quote(realpath($path), '/') . '/';
if (preg_match($regex, $_path) == false) {
$this->_controller->Flash->error(__d('file_manager', 'Path {0} is restricted', $_path));
return $this->_controller->redirect(['action' => 'browse']);
}
$blacklist = ['.git', '.svn', '.CVS'];
$regex = '/(' . preg_quote(implode('|', $blacklist), '.') . ')/';
if (in_array(basename($_path), $blacklist) || preg_match($regex, $_path)) {
$this->_controller->Flash->error(__d('file_manager', 'Path %s is restricted', $_path));
return $this->_controller->redirect(['action' => 'browse']);
}
$Folder->path = $_path;
$content = $Folder->read();
$this->_controller->set('path', $_path);
$this->_controller->set('content', $content);
}
示例4: createFileAndDeleteTmp
private function createFileAndDeleteTmp($identifier, $filename)
{
$tmpFolder = new Folder($this->tmpChunkDir($identifier));
$chunkFiles = $tmpFolder->read(true, true, true)[1];
if ($this->createFileFromChunks($chunkFiles, $this->uploadFolder . DIRECTORY_SEPARATOR . $filename) && $this->deleteTmpFolder) {
$tmpFolder->delete();
}
}
示例5: loadThemes
/**
* Register all available themes in the composer classloader and load them as plugin.
*
* @return void
*/
public static function loadThemes()
{
$themesFolder = new Folder(ROOT . DS . 'themes');
$themes = $themesFolder->read()[0];
$loader = (require ROOT . DS . 'vendor' . DS . 'autoload.php');
foreach ($themes as $theme) {
$loader->addPsr4('WasabiTheme\\' . $theme . '\\', [$themesFolder->path . DS . $theme . DS . 'src']);
Plugin::load('WasabiTheme/' . $theme, ['path' => $themesFolder->path . DS . $theme . DS, 'bootstrap' => true, 'routes' => false]);
}
}
示例6: addTestDirectory
/**
* Adds all the files in a directory to the test suite. Does not recursive through directories.
*
* @param string $directory The directory to add tests from.
* @return void
*/
public function addTestDirectory($directory = '.')
{
$Folder = new Folder($directory);
list(, $files) = $Folder->read(true, true, true);
foreach ($files as $file) {
if (substr($file, -4) === '.php') {
$this->addTestFile($file);
}
}
}
示例7: init
/**
* Initialize all available modules.
*
* @return void
*/
public static function init()
{
foreach (self::$_modulePaths as $path) {
$folder = new Folder($path);
$modulePaths = $folder->read(true, false, true)[0];
foreach ($modulePaths as $modulePath) {
self::_initializeModule($modulePath);
}
}
self::$_initialized = true;
}
示例8: flagsList
/**
* Gets a list of counties flags suitable for select boxes.
*
* @return array
*/
public static function flagsList()
{
$flags = [];
$Folder = new Folder(Plugin::path('Locale') . 'webroot/img/flags/');
foreach ($Folder->read()[1] as $icon) {
$value = $icon;
$label = str_replace_last('.gif', '', $icon);
$flags[$value] = $label;
}
asort($flags);
return $flags;
}
示例9: getFilelistFromControllerFolderAndIdFolder
public function getFilelistFromControllerFolderAndIdFolder($controller, $id)
{
$filefolder = '../webroot' . DS . 'files';
$folder = new Folder($filefolder . DS . $controller . DS . $id);
$files = $folder->read();
$list = [];
$list[''] = '';
foreach ($files[1] as $f) {
$list[$f] = $f;
}
return $list;
}
示例10: _scanDir
/**
* Scan a directory for .php files and return the class names that
* should be within them.
*
* @param string $dir The directory to read.
* @return array The list of shell classnames based on conventions.
*/
protected function _scanDir($dir)
{
$dir = new Folder($dir);
$contents = $dir->read(true, true);
if (empty($contents[1])) {
return [];
}
$shells = [];
foreach ($contents[1] as $file) {
if (substr($file, -4) !== '.php') {
continue;
}
$shells[] = substr($file, 0, -4);
}
return $shells;
}
示例11: widgets
public static function widgets()
{
if (!empty(self::$_widgets)) {
return self::$_widgets;
}
foreach (self::paths() as $path) {
if (!is_dir($path)) {
continue;
}
$folder = new Folder($path);
list($widgets) = $folder->read();
foreach ($widgets as $widget) {
self::$_widgets[$widget] = $path . $widget . DS;
}
}
return self::$_widgets;
}
示例12: language
/**
* First step of the installation process.
*
* User must select the language they want to use for the installation process.
*
* @return void
*/
public function language()
{
$languages = ['en_US' => ['url' => '/installer/startup/requirements?locale=en_US', 'welcome' => 'Welcome to QuickAppsCMS', 'action' => 'Click here to install in English']];
$Folder = new Folder(Plugin::classPath('Installer') . 'Locale');
foreach ($Folder->read(false, true, true)[0] as $path) {
$code = basename($path);
$file = $path . '/installer.po';
if (is_readable($file)) {
I18n::locale($code);
// trick for __d()
$languages[$code] = ['url' => "/installer/startup/requirements?locale={$code}", 'welcome' => __d('installer', 'Welcome to QuickAppsCMS'), 'action' => __d('installer', 'Click here to install in English')];
}
}
I18n::locale('en_US');
$this->title('Welcome to QuickAppsCMS');
$this->set('languages', $languages);
$this->_step();
}
示例13: _attachListeners
/**
* Loads and registers plugin's namespace and loads its event listeners classes.
*
* This is used to allow plugins being installed to respond to events before
* they are integrated to the system. Events such as `beforeInstall`,
* `afterInstall`, etc.
*
* @param string $plugin Name of the plugin for which attach listeners
* @param string $path Path to plugin's root directory (which contains "src")
* @throws \Cake\Error\FatalErrorException On illegal usage of this method
*/
protected function _attachListeners($plugin, $path)
{
$path = normalizePath("{$path}/");
$eventsPath = normalizePath("{$path}/src/Event/");
if (is_readable($eventsPath) && is_dir($eventsPath)) {
$EventManager = EventManager::instance();
$eventsFolder = new Folder($eventsPath);
Plugin::load($plugin, ['autoload' => true, 'bootstrap' => false, 'routes' => false, 'path' => $path, 'classBase' => 'src', 'ignoreMissing' => true]);
foreach ($eventsFolder->read(false, false, true)[1] as $classPath) {
$className = preg_replace('/\\.php$/i', '', basename($classPath));
$fullClassName = implode('\\', [$plugin, 'Event', $className]);
if (class_exists($fullClassName)) {
$handler = new $fullClassName();
$this->_listeners[] = $handler;
$EventManager->on($handler);
}
}
}
}
示例14: read
public function read($path)
{
$dir = new Folder($path);
$read = $dir->read();
$result = [];
foreach ($read[0] as $folder) {
$info = new Folder($path . DS . $folder);
$reference = Router::fullBaseUrl() . '/' . $this->toRelative($path . '/' . $folder);
$data = ['name' => $folder, 'type' => 'folder', 'path' => $path . DS . $folder, 'reference' => $reference, 'extension' => 'folder', 'size' => $info->dirsize()];
$result[] = $data;
}
foreach ($read[1] as $file) {
$info = new File($path . DS . $file, false);
$reference = Router::fullBaseUrl() . '/' . $this->toRelative($path . '/' . $file);
$data = ['name' => $info->info()['basename'], 'type' => 'file', 'path' => $path, 'reference' => $reference, 'extension' => $info->info()['extension'], 'size' => $info->info()['filesize']];
$result[] = $data;
}
return $result;
}
示例15: _icons
protected function _icons()
{
$useCache = true;
if (!empty($this->request->params['named']['reset'])) {
$useCache = false;
}
if ($useCache && ($iconNames = Cache::read('country_icon_names')) !== false) {
$this->Flash->info('Cache Used');
return $iconNames;
}
$handle = new Folder($this->imageFolder);
$icons = $handle->read(true, true);
$iconNames = [];
foreach ($icons[1] as $icon) {
# only use files (not folders)
$iconNames[] = strtoupper(extractPathInfo('filename', $icon));
}
Cache::write('country_icon_names', $iconNames);
return $iconNames;
}