当前位置: 首页>>代码示例>>PHP>>正文


PHP get_directory_list函数代码示例

本文整理汇总了PHP中get_directory_list函数的典型用法代码示例。如果您正苦于以下问题:PHP get_directory_list函数的具体用法?PHP get_directory_list怎么用?PHP get_directory_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_directory_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的get_directory_list函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。