本文整理汇总了PHP中get_directory_list函数的典型用法代码示例。如果您正苦于以下问题:PHP get_directory_list函数的具体用法?PHP get_directory_list怎么用?PHP get_directory_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_directory_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: backup_delete_old_dirs
function backup_delete_old_dirs($delete_from)
{
global $CFG;
$status = true;
//Get files and directories in the temp backup dir witout descend
$list = get_directory_list($CFG->dataroot . "/temp/backup", "", false, true, true);
foreach ($list as $file) {
$file_path = $CFG->dataroot . "/temp/backup/" . $file;
$moddate = filemtime($file_path);
if ($status && $moddate < $delete_from) {
//If directory, recurse
if (is_dir($file_path)) {
$status = delete_dir_contents($file_path);
//There is nothing, delete the directory itself
if ($status) {
$status = rmdir($file_path);
}
//If file
} else {
unlink("{$file_path}");
}
}
}
return $status;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:25,代码来源:lib.php
示例2: definition
/**
* Define this form - called from the parent constructor.
*/
public function definition()
{
global $CFG;
global $USER;
global $DB;
$tablename = "block_eexcess_citation";
$citfolder = $CFG->dirroot . "/blocks/eexcess/citationStyles";
$filearr = get_directory_list($citfolder);
$citarr = array();
$userid = $USER->id;
$usersetting = $DB->get_record($tablename, array("userid" => $userid), $fields = '*');
$i = 0;
foreach ($filearr as $value) {
$filepath = $citfolder . "/" . $value;
$filecontent = file_get_contents($filepath);
$simplexml = simplexml_load_string($filecontent);
$name = (string) $simplexml->info->title;
$citarr["{$i}"] = $name;
$i++;
}
$citarr["lnk"] = get_string('link', 'block_eexcess');
$mform =& $this->_form;
$sel = $mform->addElement('select', 'changecit', get_string('changecit', 'block_eexcess'), $citarr);
if ($usersetting !== false) {
$sel->setSelected($usersetting->citation);
}
$this->add_action_buttons(true, get_string('savechanges'));
}
开发者ID:EEXCESS,项目名称:moodle-block_eexcess,代码行数:31,代码来源:user_setting_citation_form.php
示例3: get_student_answer
/**
* Returns the HTML to display the file submitted by the student
* (adapted from mod/assignment/lib.php)
*
* @param int $attemptid attempt id
* @param int $questionid question id
* @return string string to print to display file list
*/
function get_student_answer($attemptid, $questionid)
{
global $CFG;
$filearea = quiz_file_area_name($attemptid, $questionid);
$output = '';
if ($basedir = quiz_file_area($filearea)) {
if ($files = get_directory_list($basedir)) {
if (count($files) == 0) {
return false;
}
foreach ($files as $key => $file) {
require_once $CFG->libdir . '/filelib.php';
$icon = mimeinfo('icon', $file);
// remove "questionattempt", the first dir in the path, from the URL
$filearealist = explode('/', $filearea);
$fileareaurl = implode('/', array_slice($filearealist, 1));
if ($CFG->slasharguments) {
$ffurl = "{$CFG->wwwroot}/question/file.php/{$fileareaurl}/{$file}";
} else {
$ffurl = "{$CFG->wwwroot}/question/file.php?file=/{$fileareaurl}/{$file}";
}
$output .= '<img align="middle" src="' . $CFG->pixpath . '/f/' . $icon . '" class="icon" alt="' . $icon . '" />' . '<a href="' . $ffurl . '" >' . $file . '</a><br />';
}
}
}
// (Is this desired for theme reasons?)
//$output = '<div class="files">'.$output.'</div>';
return $output;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:37,代码来源:locallib.php
示例4: __construct
public function __construct($path = SEARCH_INDEX_PATH)
{
global $CFG, $db;
$this->path = $path;
//test to see if there is a valid index on disk, at the specified path
try {
$test_index = new Zend_Search_Lucene($this->path, false);
$validindex = true;
} catch (Exception $e) {
$validindex = false;
}
//retrieve file system info about the index if it is valid
if ($validindex) {
$this->size = display_size(get_directory_size($this->path));
$index_dir = get_directory_list($this->path, '', false, false);
$this->filecount = count($index_dir);
$this->indexcount = $test_index->count();
} else {
$this->size = 0;
$this->filecount = 0;
$this->indexcount = 0;
}
$db_exists = false;
//for now
//get all the current tables in moodle
$admin_tables = $db->MetaTables();
//TODO: use new IndexDBControl class for database checks?
//check if our search table exists
if (in_array($CFG->prefix . SEARCH_DATABASE_TABLE, $admin_tables)) {
//retrieve database information if it does
$db_exists = true;
//total documents
$this->dbcount = count_records(SEARCH_DATABASE_TABLE);
//individual document types
// $types = search_get_document_types();
$types = search_collect_searchables(true, false);
sort($types);
foreach ($types as $type) {
$c = count_records(SEARCH_DATABASE_TABLE, 'doctype', $type);
$this->types[$type] = (int) $c;
}
} else {
$this->dbcount = 0;
$this->types = array();
}
//check if the busy flag is set
if (isset($CFG->search_indexer_busy) && $CFG->search_indexer_busy == '1') {
$this->complete = false;
} else {
$this->complete = true;
}
//get the last run date for the indexer
if ($this->valid() && $CFG->search_indexer_run_date) {
$this->time = $CFG->search_indexer_run_date;
} else {
$this->time = 0;
}
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:58,代码来源:indexlib.php
示例5: get_course_directories
function get_course_directories()
{
global $CFG, $COURSE;
$dirs = get_directory_list($CFG->dataroot . '/' . $COURSE->id, array($CFG->moddata, 'backupdata', '_thumb'), true, true, false);
$result = array('' => get_string('maindirectory', 'resource'));
foreach ($dirs as $dir) {
$result[$dir] = $dir;
}
return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:10,代码来源:mod_form.php
示例6: observers
/**
* Returns notification observers for all Dataform events.
*
* @return array
*/
public static function observers()
{
global $CFG;
$observers = array();
foreach (get_directory_list("{$CFG->dirroot}/mod/dataform/classes/event") as $filename) {
if (strpos($filename, '_base.php') !== false) {
continue;
}
$name = basename($filename, '.php');
$observers[] = array('eventname' => "\\mod_dataform\\event\\{$name}", 'callback' => '\\mod_dataform\\observer\\notification::notify');
}
return $observers;
}
开发者ID:parksandwildlife,项目名称:learning,代码行数:18,代码来源:notification.php
示例7: observers
/**
* Returns list of dataform observers.
*
* @return array
*/
public static function observers()
{
global $CFG;
$observers = array();
foreach (get_directory_list("{$CFG->dirroot}/mod/dataform/classes/observer") as $filename) {
$basename = basename($filename, '.php');
if ($basename == 'manager') {
continue;
}
$observer = '\\mod_dataform\\observer\\' . $basename;
$observers = array_merge($observers, $observer::observers());
}
return $observers;
}
开发者ID:parksandwildlife,项目名称:learning,代码行数:19,代码来源:manager.php
示例8: recursive_get_files
function recursive_get_files($path)
{
global $CFG;
$items = get_directory_list($path, array($CFG->moddata, 'backupdata'), false, true, true);
$return_array = array();
foreach ($items as $item) {
if (is_dir("{$path}/{$item}")) {
$return_array[$item] = recursive_get_files("{$path}/{$item}");
} else {
$return_array[$item] = filesize("{$path}/{$item}");
}
}
return $return_array;
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:14,代码来源:lib.php
示例9: get_course_media_files
/**
* gets a list of all the media files for the given course
*
* @param int courseid
* @return array containing filenames
* @calledfrom type/<typename>/editquestion.php
* @package questionbank
* @subpackage importexport
*/
function get_course_media_files($courseid)
{
// this code lifted from mod/quiz/question.php and modified
global $CFG;
$images = null;
make_upload_directory("{$course->id}");
// Just in case
$coursefiles = get_directory_list("{$CFG->dataroot}/{$courseid}", $CFG->moddata);
foreach ($coursefiles as $filename) {
if (is_media_by_extension($filename)) {
$images["{$filename}"] = $filename;
}
}
return $images;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:24,代码来源:qt_common.php
示例10: capabilities
/**
* Returns a list of dataform capabilities.
*
* @return array
*/
public static function capabilities()
{
global $CFG;
// First collate the dataform core capabilities.
$capabilities = array_merge(self::dataform(), self::dataform_view(), self::dataform_entry(), self::dataform_entry_early(), self::dataform_entry_late(), self::dataform_entry_own(), self::dataform_entry_group(), self::dataform_entry_any(), self::dataform_entry_anonymous(), self::dataform_preset(), self::dataform_deprecated());
// Now add pluggable capabilities if any.
foreach (get_directory_list("{$CFG->dirroot}/mod/dataform/classes/capability") as $filename) {
$basename = basename($filename, '.php');
if ($basename == 'manager') {
continue;
}
$capability = '\\mod_dataform\\capability\\' . $basename;
$capabilities = array_merge($capabilities, $capability::capabilities());
}
return $capabilities;
}
开发者ID:vaenda,项目名称:moodle-mod_dataform,代码行数:21,代码来源:manager.php
示例11: wiki_upload_file
function wiki_upload_file($file, &$WS)
{
global $_FILES;
if (file_exists($WS->dfdir->name . '/' . $_FILES[$file]['name'])) {
//file already existst in the server
$WS->dfdir->error[] = get_string('fileexisterror', 'wiki');
} else {
//save file
$upd = new upload_manager('dfformfile');
$upd->preprocess_files();
if (!$upd->save_files($WS->dfdir->name)) {
//error uploading
$WS->dfdir->error[] = get_string('fileuploaderror', 'wiki');
}
}
$WS->dfdir->content = get_directory_list($WS->dfdir->name);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:17,代码来源:uploadlib.php
示例12: get_locks
/**
* Get all lock type instances
*
* @return array
**/
public static function get_locks()
{
global $CFG;
static $locks = false;
if ($locks === false) {
$locks = array();
$files = get_directory_list($CFG->dirroot . '/course/format/page/plugin/lock');
foreach ($files as $file) {
require_once "{$CFG->dirroot}/course/format/page/plugin/lock/{$file}";
$name = pathinfo($file, PATHINFO_FILENAME);
$classname = 'format_page_lock_' . $name;
if (!class_exists($classname)) {
error('Lock classname does not exist');
}
$locks[$name] = new $classname();
}
}
return $locks;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:24,代码来源:lock.php
示例13: definition
function definition()
{
global $CFG;
global $COURSE;
$mform =& $this->_form;
//-- General --------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
/// name
$mform->addElement('text', 'name', get_string('name'), array('size' => '60'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
/// text (description)
$mform->addElement('htmleditor', 'text', get_string('description'));
$mform->setType('text', PARAM_RAW);
//$mform->addRule('text', get_string('required'), 'required', null, 'client');
$mform->setHelpButton('text', array('writing', 'richtext'), false, 'editorhelpbutton');
/// introformat
$mform->addElement('format', 'introformat', get_string('format'));
//-- Stamp Collection------------------------------------------------------------
$mform->addElement('header', 'stampcollection', get_string('modulename', 'stampcoll'));
/// stampimage
make_upload_directory("{$COURSE->id}");
// Just in case
$images = array();
$coursefiles = get_directory_list("{$CFG->dataroot}/{$COURSE->id}", $CFG->moddata);
foreach ($coursefiles as $filename) {
if (mimeinfo("icon", $filename) == "image.gif") {
$images["{$filename}"] = $filename;
}
}
$mform->addElement('select', 'image', get_string('stampimage', 'stampcoll'), array_merge(array('' => get_string('default')), $images), 'a', 'b', 'c', 'd');
$mform->addElement('static', 'stampimageinfo', '', get_string('stampimageinfo', 'stampcoll'));
/// displayzero
$mform->addElement('selectyesno', 'displayzero', get_string('displayzero', 'stampcoll'));
$mform->setDefault('displayzero', 0);
//-------------------------------------------------------------------------------
// add standard elements, common to all modules
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// add standard buttons, common to all modules
$this->add_action_buttons();
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:42,代码来源:mod_form.php
示例14: print_student_answer
function print_student_answer($userid, $return = false)
{
global $CFG, $USER;
$filearea = $this->file_area_name($userid);
$output = '';
if ($basedir = $this->file_area($userid)) {
if ($files = get_directory_list($basedir)) {
require_once $CFG->libdir . '/filelib.php';
foreach ($files as $key => $file) {
$icon = mimeinfo('icon', $file);
$ffurl = get_file_url("{$filearea}/{$file}");
//died right here
//require_once($ffurl);
$output = '<img align="middle" src="' . $CFG->pixpath . '/f/' . $icon . '" class="icon" alt="' . $icon . '" />' . '<a href="' . $ffurl . '" >' . $file . '</a><br />';
}
}
}
$output = '<div class="files">' . $output . '</div>';
return $output;
}
开发者ID:veritech,项目名称:pare-project,代码行数:20,代码来源:assignment.class.php
示例15: get_submission_file_content
function get_submission_file_content($userid)
{
if ($basedir = $this->file_area($userid)) {
if ($files = get_directory_list($basedir)) {
foreach ($files as $key => $file) {
return mb_convert_encoding(file_get_contents($basedir . '/' . $file), 'UTF-8', 'UTF-8, GBK');
}
}
}
return false;
}
开发者ID:hit-moodle,项目名称:onlinejudge,代码行数:11,代码来源:assignment.class.php
示例16: main_upgrade
//.........这里部分代码省略.........
$new->mtable = "user";
$new->field = "CONCAT(firstname,\" \",lastname)";
insert_record("log_display", $new);
delete_records("log_display", "module", "course");
$new->module = "course";
$new->action = "view";
$new->mtable = "course";
$new->field = "fullname";
insert_record("log_display", $new);
$new->action = "update";
insert_record("log_display", $new);
$new->action = "enrol";
insert_record("log_display", $new);
}
if ($oldversion < 2003012200) {
// execute_sql(" ALTER TABLE `log_display` CHANGE `module` `module` VARCHAR( 20 ) NOT NULL ");
// Commented out - see below where it's done properly
}
if ($oldversion < 2003032500) {
modify_database("", "CREATE TABLE `prefix_user_coursecreators` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `userid` int(10) unsigned NOT NULL default '0',\n PRIMARY KEY (`id`),\n UNIQUE KEY `id` (`id`)\n ) TYPE=MyISAM COMMENT='One record per course creator';");
}
if ($oldversion < 2003032602) {
// Redoing it because of no prefix last time
execute_sql(" ALTER TABLE `{$CFG->prefix}log_display` CHANGE `module` `module` VARCHAR( 20 ) NOT NULL ");
// Add some indexes for speed
execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(course) ");
execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(userid) ");
}
if ($oldversion < 2003041400) {
table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
}
if ($oldversion < 2003042104) {
// Try to update permissions of all files
if ($files = get_directory_list($CFG->dataroot)) {
echo "Attempting to update permissions for all files... ignore any errors.";
foreach ($files as $file) {
echo "{$CFG->dataroot}/{$file}<br />";
@chmod("{$CFG->dataroot}/{$file}", $CFG->directorypermissions);
}
}
}
if ($oldversion < 2003042400) {
// Rebuild all course caches, because of changes to do with visible variable
if ($courses = get_records_sql("SELECT * FROM {$CFG->prefix}course")) {
require_once "{$CFG->dirroot}/course/lib.php";
foreach ($courses as $course) {
$modinfo = serialize(get_array_of_activities($course->id));
if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
notify("Could not cache module information for course '" . format_string($course->fullname) . "'!");
}
}
}
}
if ($oldversion < 2003042500) {
// Convert all usernames to lowercase.
$users = get_records_sql("SELECT id, username FROM {$CFG->prefix}user");
$cerrors = "";
$rarray = array();
foreach ($users as $user) {
// Check for possible conflicts
$lcname = trim(moodle_strtolower($user->username));
if (in_array($lcname, $rarray)) {
$cerrors .= $user->id . "->" . $lcname . '<br/>';
} else {
array_push($rarray, $lcname);
}
开发者ID:veritech,项目名称:pare-project,代码行数:67,代码来源:mysql.php
示例17: forum_rss_feed_posts
function forum_rss_feed_posts($forum, $newsince = 0)
{
global $CFG, $DB;
$items = array();
if ($newsince) {
$newsince = " AND p.modified > '{$newsince}'";
} else {
$newsince = "";
}
if ($recs = $DB->get_records_sql("SELECT p.id AS postid,\n d.id AS discussionid,\n d.name AS discussionname,\n u.id AS userid,\n u.firstname AS userfirstname,\n u.lastname AS userlastname,\n p.subject AS postsubject,\n p.message AS postmessage,\n p.created AS postcreated,\n p.messageformat AS postformat,\n p.messagetrust AS posttrust\n FROM {forum_discussions} d,\n {forum_posts} p,\n {user} u\n WHERE d.forum = ? AND\n p.discussion = d.id AND\n u.id = p.userid ?\n ORDER BY p.created desc", array($forum->id, $newsince), 0, $forum->rssarticles)) {
$item = NULL;
$user = NULL;
$formatoptions = new object();
$formatoptions->trusted = $rec->posttrust;
foreach ($recs as $rec) {
unset($item);
unset($user);
$item->category = $rec->discussionname;
$item->title = $rec->postsubject;
$user->firstname = $rec->userfirstname;
$user->lastname = $rec->userlastname;
$item->author = fullname($user);
$item->pubdate = $rec->postcreated;
$item->link = $CFG->wwwroot . "/mod/forum/discuss.php?d=" . $rec->discussionid . "&parent=" . $rec->postid;
$item->description = format_text($rec->postmessage, $rec->postformat, $formatoptions, $forum->course);
$post_file_area_name = str_replace('//', '/', "{$forum->course}/{$CFG->moddata}/forum/{$forum->id}/{$rec->postid}");
$post_files = get_directory_list("{$CFG->dataroot}/{$post_file_area_name}");
if (!empty($post_files)) {
$item->attachments = array();
//TODO: rewrite attachment handling
}
$items[] = $item;
}
}
return $items;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:36,代码来源:rsslib.php
示例18: get_directory_list
/**
* Returns an array with all the filenames in all subdirectories, relative to the given rootdir.
*
* If excludefiles is defined, then that file/directory is ignored
* If getdirs is true, then (sub)directories are included in the output
* If getfiles is true, then files are included in the output
* (at least one of these must be true!)
*
* @todo Finish documenting this function. Add examples of $excludefile usage.
*
* @param string $rootdir A given root directory to start from
* @param string|array $excludefiles If defined then the specified file/directory is ignored
* @param bool $descend If true then subdirectories are recursed as well
* @param bool $getdirs If true then (sub)directories are included in the output
* @param bool $getfiles If true then files are included in the output
* @return array An array with all the filenames in all subdirectories, relative to the given rootdir
*/
function get_directory_list($rootdir, $excludefiles = '', $descend = true, $getdirs = false, $getfiles = true)
{
$dirs = array();
if (!$getdirs and !$getfiles) {
// Nothing to show.
return $dirs;
}
if (!is_dir($rootdir)) {
// Must be a directory.
return $dirs;
}
if (!($dir = opendir($rootdir))) {
// Can't open it for some reason.
return $dirs;
}
if (!is_array($excludefiles)) {
$excludefiles = array($excludefiles);
}
while (false !== ($file = readdir($dir))) {
$firstchar = substr($file, 0, 1);
if ($firstchar == '.' or $file == 'CVS' or in_array($file, $excludefiles)) {
continue;
}
$fullfile = $rootdir . '/' . $file;
if (filetype($fullfile) == 'dir') {
if ($getdirs) {
$dirs[] = $file;
}
if ($descend) {
$subdirs = get_directory_list($fullfile, $excludefiles, $descend, $getdirs, $getfiles);
foreach ($subdirs as $subdir) {
$dirs[] = $file . '/' . $subdir;
}
}
} else {
if ($getfiles) {
$dirs[] = $file;
}
}
}
closedir($dir);
asort($dirs);
return $dirs;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:61,代码来源:moodlelib.php
示例19: _getfontfiles
/**
* Get the .php files for the fonts
*/
function _getfontfiles($fontdir)
{
$dirlist = get_directory_list($fontdir);
$fontfiles = array();
foreach ($dirlist as $file) {
if (substr($file, -4) == '.php') {
array_push($fontfiles, $file);
}
}
return $fontfiles;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:14,代码来源:pdflib.php
示例20: define_execution
protected function define_execution()
{
// Get basepath
$basepath = $this->get_basepath();
// Get the list of files in directory
$filestemp = get_directory_list($basepath, '', false, true, true);
$files = array();
foreach ($filestemp as $file) {
// Add zip paths and fs paths to all them
$files[$file] = $basepath . '/' . $file;
}
// Calculate the zip fullpath (in OS temp area it's always backup.mbz)
$zipfile = $basepath . '/backup.imscc';
// Get the zip packer
$zippacker = get_file_packer('application/zip');
// Zip files
$zippacker->archive_to_pathname($files, $zipfile);
}
开发者ID:nickread,项目名称:moodle,代码行数:18,代码来源:backuplib.php
注:本文中的get_directory_list函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论