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


PHP repository::prepare_listing方法代码示例

本文整理汇总了PHP中repository::prepare_listing方法的典型用法代码示例。如果您正苦于以下问题:PHP repository::prepare_listing方法的具体用法?PHP repository::prepare_listing怎么用?PHP repository::prepare_listing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在repository的用法示例。


在下文中一共展示了repository::prepare_listing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: optional_param

$filepath = optional_param('filepath', '/', PARAM_PATH);
$user_context = get_context_instance(CONTEXT_USER, $USER->id);
echo $OUTPUT->header();
// send headers
//
//NOTE TO ALL DEVELOPERS: this script must deal only with draft area of current user, it has to use only file_storage and no file_browser!!
//
switch ($action) {
    case 'dir':
        $data = new stdClass();
        file_get_drafarea_folders($draftid, $filepath, $data);
        echo json_encode($data);
        die;
    case 'list':
        $filepath = optional_param('filepath', '/', PARAM_PATH);
        $data = repository::prepare_listing(file_get_drafarea_files($draftid, $filepath));
        $info = file_get_draft_area_info($draftid);
        $data->filecount = $info['filecount'];
        $data->filesize = $info['filesize'];
        $data->tree = new stdClass();
        file_get_drafarea_folders($draftid, '/', $data->tree);
        echo json_encode($data);
        die;
    case 'mkdir':
        $filepath = required_param('filepath', PARAM_PATH);
        $newdirname = required_param('newdirname', PARAM_FILE);
        $fs = get_file_storage();
        $fs->create_directory($user_context->id, 'user', 'draft', $draftid, file_correct_filepath(file_correct_filepath($filepath) . $newdirname));
        $return = new stdClass();
        $return->filepath = $filepath;
        echo json_encode($return);
开发者ID:nmicha,项目名称:moodle,代码行数:31,代码来源:draftfiles_ajax.php

示例2: json_encode

     $listing['repo_id'] = $repo_id;
     echo json_encode($listing);
     break;
 case 'logout':
     $logout = $repo->logout();
     $logout['repo_id'] = $repo_id;
     echo json_encode($logout);
     break;
 case 'searchform':
     $search_form['repo_id'] = $repo_id;
     $search_form['form'] = $repo->print_search();
     $search_form['allowcaching'] = true;
     echo json_encode($search_form);
     break;
 case 'search':
     $search_result = repository::prepare_listing($repo->search($search_text, (int) $page));
     $search_result['repo_id'] = $repo_id;
     $search_result['issearchresult'] = true;
     echo json_encode($search_result);
     break;
 case 'download':
     // validate mimetype
     $mimetypes = array();
     if (is_array($accepted_types) and in_array('*', $accepted_types) or $accepted_types == '*') {
         $mimetypes = '*';
     } else {
         foreach ($accepted_types as $type) {
             $mimetypes[] = mimeinfo('type', $type);
         }
         if (!in_array(mimeinfo('type', $saveas_filename), $mimetypes)) {
             throw new moodle_exception('invalidfiletype', 'repository', '', get_mimetype_description(array('filename' => $saveas_filename)));
开发者ID:covex-nn,项目名称:moodle,代码行数:31,代码来源:repository_ajax.php

示例3: ajaxListFiles

 public static function ajaxListFiles()
 {
     $draftIDs = explode(',', $_POST['draftIDs']);
     $files = array();
     foreach ($draftIDs as $id) {
         $data = repository::prepare_listing(file_get_drafarea_files($id, '/'));
         if (!empty($data->list)) {
             foreach ($data->list as $f) {
                 $files[] = $f->filename;
             }
         }
     }
     $out = array('draftIDs' => $draftIDs, 'files' => $files);
     header('Content-type: application/json');
     echo json_encode($out);
     die;
 }
开发者ID:RyanNutt,项目名称:moodle-code-activity,代码行数:17,代码来源:codeactivity.php


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