本文整理汇总了PHP中dir::read方法的典型用法代码示例。如果您正苦于以下问题:PHP dir::read方法的具体用法?PHP dir::read怎么用?PHP dir::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dir
的用法示例。
在下文中一共展示了dir::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($params = array())
{
$defaults = array('page' => page(), 'headline' => 'Mentions');
if (is_a($params, 'Page')) {
$params = array('page' => $params);
} else {
if (is_string($params)) {
$params = array('headline' => $params);
}
}
$this->options = array_merge($defaults, $params);
$this->page = $this->options['page'];
$this->root = $this->page->root() . DS . '.webmentions';
$this->headline = new Field($this->page, 'headline', $this->options['headline']);
if (!is_dir($this->root)) {
return;
}
$files = dir::read($this->root);
// flip direction
rsort($files);
foreach ($files as $file) {
// skip the pings cache
if ($file == 'pings.json') {
continue;
}
// register a new webmention
try {
$mention = new Mention($this->page, $this->root . DS . $file);
$this->append($mention->id(), $mention);
} catch (Exception $e) {
}
}
}
示例2: read
public function read($url = '', $recursive = false, $format = 'flat')
{
if (substr($url, -1) !== Application::DS) {
$url .= Application::DS;
}
if ($this->ignore('find', $url)) {
return array();
}
$list = array();
$cwd = getcwd();
chdir($url);
if ($handle = opendir($url)) {
while (false !== ($entry = readdir($handle))) {
$recursiveList = array();
if ($entry == '.' || $entry == '..') {
continue;
}
$file = new stdClass();
$file->url = $url . $entry;
if (is_dir($file->url)) {
$file->url .= Application::DS;
$file->type = 'dir';
}
if ($this->ignore('find', $file->url)) {
continue;
}
$file->name = $entry;
if (isset($file->type)) {
if (!empty($recursive)) {
$directory = new dir();
$directory->ignore('list', $this->ignore());
$recursiveList = $directory->read($file->url, $recursive, $format);
if ($format !== 'flat') {
$file->list = $recursiveList;
unset($recursiveList);
}
}
} else {
$file->type = 'file';
}
if (is_link($entry)) {
$file->link = true;
}
/* absolute url is_link wont work probably the targeting type
if(is_link($file->url)){
$file->link = true;
}
*/
$list[] = $file;
if (!empty($recursiveList)) {
foreach ($recursiveList as $recursive_nr => $recursive_file) {
$list[] = $recursive_file;
}
}
}
}
closedir($handle);
return $list;
}
示例3: custom
public function custom()
{
$kirby = kirby();
$root = $kirby->roots()->widgets();
foreach (dir::read($root) as $dir) {
$kirby->registry->set('widget', $dir, $root . DS . $dir, true);
}
}
示例4: testClean
public function testClean()
{
dir::make($this->tmpDir);
f::write($this->tmpDir . DS . 'testfile.txt', '');
$this->assertTrue(dir::clean($this->tmpDir));
$files = dir::read($this->tmpDir);
$this->assertEquals(0, count($files));
dir::remove($this->tmpDir);
}
示例5: runTests
public function runTests($result)
{
$root = TEST_ROOT_ETC . DS . 'kirbytext';
$dirs = dir::read($root);
foreach ($dirs as $dir) {
$testFile = $root . DS . $dir . DS . 'test.txt';
$expectedFile = $root . DS . $dir . DS . 'expected.html';
$this->assertEquals(f::read($expectedFile), $result(f::read($testFile)), 'test: ' . $dir);
}
}
示例6: custom
public function custom()
{
$root = kirby()->roots()->widgets();
foreach (dir::read($root) as $dir) {
// add missing widgets to the order array
if (!array_key_exists($dir, $this->order)) {
$this->order[$dir] = true;
}
$this->load($dir, $root . DS . $dir . DS . $dir . '.php');
}
}
示例7: __construct
public function __construct()
{
$root = kirby::instance()->roots()->accounts();
foreach (dir::read($root) as $file) {
// skip invalid account files
if (f::extension($file) != 'php') {
continue;
}
$user = new User(f::name($file));
$this->append($user->username(), $user);
}
}
示例8: find
public function find($type)
{
$root = form::$root[$type];
$dirs = dir::read($root);
foreach ($dirs as $dir) {
$name = strtolower($dir);
$file = $root . DS . $name . DS . $name . '.php';
if (file_exists($file)) {
$this->{$type}[$name . 'field'] = $file;
}
}
}
示例9: index
public function index()
{
$widgets = array();
$wroot = c::get('root.site') . DS . 'widgets';
$wdirs = dir::read($wroot);
foreach ($wdirs as $dir) {
$file = $wroot . DS . $dir . DS . $dir . '.php';
if (file_exists($file)) {
$widgets[$dir] = (require $file);
}
}
return view('dashboard/index', array('topbar' => new Snippet('pages/topbar', array('breadcrumb' => new Snippet('breadcrumb'), 'search' => purl('pages/search/'))), 'history' => history::get(), 'site' => site(), 'widgets' => $widgets, 'user' => site()->user()));
}
示例10: plugins
static function plugins()
{
$root = c::get('root.plugins');
$files = dir::read($root);
if (!is_array($files)) {
return false;
}
foreach ($files as $file) {
if (f::extension($file) != 'php') {
continue;
}
self::file($root . '/' . $file);
}
}
示例11: all
public static function all()
{
$files = dir::read(static::$root);
$result = array_keys(kirby()->get('blueprint'));
$home = kirby()->option('home', 'home');
$error = kirby()->option('error', 'error');
foreach ($files as $file) {
$name = f::name($file);
if ($name != 'site' and $name != $home and $name != $error) {
$result[] = $name;
}
}
return $result;
}
示例12: all
public static function all()
{
$files = dir::read(static::$root);
$result = array();
$home = site()->homePage()->uid();
$error = site()->errorPage()->uid();
foreach ($files as $file) {
$name = f::name($file);
if ($name != 'site' and $name != $home and $name != $error) {
$result[] = $name;
}
}
return $result;
}
示例13: index
public function index()
{
$site = site();
$widgets = array();
$wroot = kirby()->roots()->widgets();
$wdirs = dir::read($wroot);
// fetch all top-level pages in the right order
$blueprint = blueprint::find($site);
$pages = api::subpages($site->children(), $blueprint);
foreach ($wdirs as $dir) {
$file = $wroot . DS . $dir . DS . $dir . '.php';
if (file_exists($file)) {
$widgets[$dir] = (require $file);
}
}
return view('dashboard/index', array('topbar' => new Snippet('pages/topbar', array('breadcrumb' => new Snippet('breadcrumb'), 'search' => purl('pages/search/'))), 'history' => history::get(), 'site' => $site, 'pages' => $pages, 'addbutton' => !api::maxPages($site, $blueprint->pages()->max()), 'widgets' => $widgets, 'user' => site()->user(), 'license' => panel()->license()));
}
示例14: find
public function find()
{
$kirby = kirby();
// store all fields coming from plugins and load
// them between the default fields and the custom fields
$pluginfields = $kirby->get('field');
// load the default panel fields first, because they can be overwritten
foreach (dir::read(form::$root['default']) as $name) {
$kirby->set('field', $name, form::$root['default'] . DS . $name);
}
// load the plugin fields again. A bit hacky, but works
foreach ($pluginfields as $name => $field) {
$kirby->set('field', $name, $field->root());
}
// load all custom fields, which can overwrite all the others
foreach (dir::read(form::$root['custom']) as $name) {
$kirby->set('field', $name, form::$root['custom'] . DS . $name);
}
}
示例15: plugins
static function plugins($folder = false)
{
$root = c::get('root.plugins');
$folder = $folder ? $folder : $root;
$files = dir::read($folder);
if (!is_array($files)) {
return false;
}
foreach ($files as $file) {
if (is_dir($folder . '/' . $file) && $folder == $root) {
self::plugins($folder . '/' . $file);
continue;
}
if (f::extension($file) != 'php') {
continue;
}
self::file($folder . '/' . $file);
}
}