本文整理汇总了PHP中Menu::list_dirs方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::list_dirs方法的具体用法?PHP Menu::list_dirs怎么用?PHP Menu::list_dirs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::list_dirs方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Create upload page
*
* @author Thibaud Rohmer
*/
public function __construct()
{
/// Get all subdirs
$list_dirs = Menu::list_dirs(Settings::$photos_dir, true);
foreach ($list_dirs as $dir) {
$this->dirs[] = File::a2r($dir);
}
if (isset(CurrentUser::$path)) {
$this->selected_dir = File::a2r(CurrentUser::$path);
}
}
示例2: __construct
/**
* Board constructor
*
* @param string $path
* @author Thibaud Rohmer
*/
public function __construct($path = NULL)
{
if (!isset($path)) {
$path = CurrentUser::$path;
}
$this->analyzed = array();
$this->path = $path;
// If $path is a file, list directory containing the file
if (is_file($path)) {
$this->path = dirname($path);
}
$this->title = basename($this->path);
$this->header = new BoardHeader($this->title, $this->path);
$this->files = Menu::list_files($this->path);
$this->dirs = Menu::list_dirs($this->path);
$pageURL = Settings::$site_address . "/?f=" . urlencode(File::a2r($this->path));
// generate the header - opengraph metatags for facebook
$this->page_header = "<meta property=\"og:url\" content=\"" . $pageURL . "\"/>\n" . "<meta property=\"og:site_name\" content=\"" . Settings::$name . "\"/>\n" . "<meta property=\"og:type\" content=\"article\"/>\n" . "<meta property=\"og:title\" content=\"" . Settings::$name . ": " . File::a2r($this->path) . "\"/>\n";
if (Settings::$fbappid) {
$this->page_header .= "<meta property=\"fb:app_id\" content=\"" . Settings::$fbappid . "\"/>\n";
}
if (!empty($this->files)) {
$i = 0;
foreach ($this->files as $file) {
if ($i > 9) {
break;
}
if (Judge::is_public($file)) {
$this->page_header .= "<meta property=\"og:image\" content=\"" . Settings::$site_address . "/?t=Thb&f=" . urlencode(File::a2r($file)) . "\"/>\n";
$i++;
}
}
} else {
// No files in the directory, getting thumbnails from sub-directories
$i = 0;
foreach ($this->dirs as $d) {
if ($i > 9) {
break;
}
if (!Judge::view($d)) {
//Dir is not accessible (rights) - ignore it for better performance
continue;
}
$img = Judge::searchDir($d, true);
if ($img) {
$this->page_header .= "<meta property=\"og:image\" content=\"" . Settings::$site_address . "/?t=Thb&f=" . urlencode(File::a2r($img)) . "\"/>\n";
$i++;
}
}
}
$this->foldergrid();
}
示例3: Calculate
public function Calculate()
{
/// Calculate number of users, etc...
$this->stats['Users'] = sizeof(Account::findAll());
$this->stats['Groups'] = sizeof(Group::findAll());
$this->stats['Items'] = sizeof(Menu::list_files(Settings::$photos_dir, true));
$this->stats['Generated items'] = sizeof(Menu::list_files(Settings::$thumbs_dir, true));
$this->stats['Albums'] = sizeof(Menu::list_dirs(Settings::$photos_dir, true));
$this->accounts = array_reverse(Account::findAll());
$commentsfile = Settings::$conf_dir . "/comments.xml";
if (is_file($commentsfile)) {
$xml = simplexml_load_file($commentsfile);
$this->comments = $xml->children();
}
}
示例4: dir2div
public function dir2div($dir)
{
$subdirs = Menu::list_dirs($dir);
$res = "<li class=' ";
if (sizeof($subdirs) > 0) {
$res .= " has_sub ";
}
try {
File::a2r(CurrentUser::$path, $dir);
$res .= " selected ";
} catch (Exception $e) {
// Do nothing
}
$res .= " dir'>";
$res .= "\n\t\t<div class='title {$class}'>\t<span id='" . urlencode(File::a2r($dir)) . "' class='" . addslashes(htmlentities(File::a2r($dir), ENT_QUOTES, 'UTF-8')) . "'>" . htmlentities(basename($dir), ENT_QUOTES, 'UTF-8') . "</span></div>\n\t\t\t<ul class='subdirs'>\n\t\t\t";
foreach ($subdirs as $d) {
$res .= $this->dir2div($d);
}
$res .= "</ul></li>";
return $res;
}
示例5: list_dirs
/**
* List directories in $dir, omit hidden directories
*
* @param string $dir
* @return void
* @author Thibaud Rohmer
*/
public static function list_dirs($dir, $rec = false, $hidden = false)
{
/// Directories list
$list = array();
/// Check that $dir is a directory, or throw exception
if (!is_dir($dir)) {
throw new Exception("'" . $dir . "' is not a directory");
}
/// Directory content
$dir_content = scandir($dir);
if (empty($dir_content)) {
// Directory is empty or no right to read
return $list;
}
/// Check each content
foreach ($dir_content as $content) {
/// Content isn't hidden and is a directory
if (($content[0] != '.' || $hidden) && is_dir($path = $dir . "/" . $content)) {
/// Add content to list
$list[] = $path;
if ($rec) {
$list = array_merge($list, Menu::list_dirs($dir . "/" . $content, true));
}
}
}
/// Return directories list
return $list;
}
示例6: searchDir
/**
* Check if a file is viewable in a folder, and returns path to that file.
*/
public static function searchDir($dir, $public_search = false)
{
$rightsdir = File::r2a(File::a2r($dir), Settings::$thumbs_dir);
$rightsfiles = glob($rightsdir . "/.*ights.xml");
// Check files
foreach ($rightsfiles as $rf) {
$f = Judge::associated_file($rf);
if ($public_search and Judge::is_public($f) or !$public_search and Judge::view($f)) {
if (is_file($f)) {
return $f;
} else {
foreach (Menu::list_files($f, true) as $p) {
if ($public_search and Judge::is_public($p) or !$public_search and Judge::view($p)) {
return $p;
}
}
}
}
}
// Check subdirs
foreach (Menu::list_dirs($dir) as $d) {
if ($f = Judge::searchDir($d, $public_search)) {
return $f;
}
}
return false;
}
示例7: searchDir
/**
* Check recursively if a file is viewable in a folder, and returns path to that file.
*/
public static function searchDir($dir, $public_search = false)
{
foreach (Menu::list_files($dir) as $f) {
if (Judge::view($f)) {
return $f;
}
}
foreach (Menu::list_dirs($dir) as $d) {
if (($f = Judge::searchDir($d, $public_search)) != NULL) {
return $f;
}
}
return NULL;
}
示例8: rec_del
/**
* Reccursively delete all files in $dir
*
* @param string $dir
* @author Thibaud Rohmer
*/
public function rec_del($dir)
{
if (is_file($dir)) {
return unlink($dir);
}
$dirs = Menu::list_dirs($dir);
$files = Menu::list_files($dir, false, true);
foreach ($dirs as $d) {
AdminDelete::rec_del($d);
}
foreach ($files as $f) {
unlink($f);
}
return rmdir($dir);
}
示例9: rec_del
/**
* Reccursively delete all files in $dir
*
* @param string $dir
* @author Thibaud Rohmer
*/
public function rec_del($dir)
{
if ($dir == Settings::$photos_dir) {
return;
}
if (is_file($dir)) {
return unlink($dir);
}
$dirs = Menu::list_dirs($dir);
$files = Menu::list_files($dir, false, true);
foreach ($dirs as $d) {
Admin::rec_del($d);
}
foreach ($files as $f) {
unlink($f);
}
return rmdir($dir);
}
示例10: __construct
/**
* Create Settings page
*
*/
public function __construct()
{
$this->folders = Menu::list_dirs(Settings::$photos_dir, true);
}
示例11: list_dirs
/**
* List directories contained in $dir
*/
public static function list_dirs($key, $dir, $rec = false)
{
CurrentUser::keyin($key);
$res = array();
$m = Menu::list_dirs(File::r2a($dir), $rec);
if (sizeof($m) == 0) {
return $res;
}
foreach ($m as $i) {
if (Judge::view($i)) {
$res[] = File::a2r($i);
}
}
return $res;
}