From: dongsheng Date: Thu, 11 Jun 2009 08:08:33 +0000 (+0000) Subject: "MDL-17316, improve non-js file manager interface" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b6fd5aee62c452c97bba350c135a2e3ebd176eb5;p=moodle.git "MDL-17316, improve non-js file manager interface" --- diff --git a/lang/en_utf8/repository.php b/lang/en_utf8/repository.php index eae8f43e63..28c7d8010c 100644 --- a/lang/en_utf8/repository.php +++ b/lang/en_utf8/repository.php @@ -12,11 +12,13 @@ $string['areauserdraft'] = 'Drafts'; $string['areauserpersonal'] = 'Personal'; $string['areauserprofile'] = 'Profile'; $string['attachment'] = 'Attachment'; +$string['attachedfiles'] = 'Attached files'; $string['back'] = '< Back'; $string['cacheexpire'] = 'Cache expire'; $string['cachecleared'] = 'Cached files are removed'; -$string['cannotinitplugin'] = 'Call plugin_init failed'; +$string['cannotdelete'] = 'Cannot delete this file.'; $string['cannotdownload'] = 'Cannot download this file'; +$string['cannotinitplugin'] = 'Call plugin_init failed'; $string['clicktohide'] = 'Click here to hide'; $string['clicktoshow'] = 'Click here to show'; $string['close'] = 'Close'; @@ -40,6 +42,7 @@ $string['editrepositoryinstance'] = 'Edit repository instance'; $string['emptytype'] = 'Cannot create repository type: type name is empty'; $string['enablecourseinstances'] = 'Allow teachers to add a repository instance into the file picker'; $string['enableuserinstances'] = 'Allow users to add a repository instance into the file picker'; +$string['enter'] = 'Enter'; $string['error'] = 'An unknown error occurred!'; $string['existingrepository'] = 'This repository already exists'; $string['filename'] = 'Filename'; @@ -64,14 +67,16 @@ $string['loading'] = 'Loading...'; $string['manage'] = 'Manage repositories'; $string['manageurl'] = 'Manage'; $string['manageuserrepository'] = 'Manage individual repository'; -$string['nopermissiontoaccess'] = 'No permission to access this repository'; $string['noenter'] = 'Nothing entered'; +$string['nofilesattached'] = 'No files attached'; +$string['nopermissiontoaccess'] = 'No permission to access this repository'; $string['notyourinstances'] = 'You can not view/edit repository instances of another user'; $string['noresult'] = 'No search result'; $string['operation'] = 'Operation'; $string['openpicker'] = 'Choose a file...'; $string['personalrepositories'] = 'Personal repositories'; $string['plugin'] = 'Repository plug-ins'; +$string['pluginerror'] = 'Errors in repository plugin.'; $string['preview'] = 'Preview'; $string['popup'] = 'Click "Login" button to login'; $string['readonlyinstance'] = 'You cannot edit/delete a read-only instance'; @@ -88,6 +93,7 @@ $string['settings'] = 'Settings'; $string['setupdefaultplugins'] = 'Setting up default repository plugins'; $string['search'] = 'Search '; $string['searching'] = 'Search in '; +$string['select'] = 'Select'; $string['siteinstances'] = 'Repositories instances of the site'; $string['size'] = 'Size'; $string['submit'] = 'Submit'; diff --git a/lib/form/filemanager.php b/lib/form/filemanager.php index a85a93358a..93283a34e2 100644 --- a/lib/form/filemanager.php +++ b/lib/form/filemanager.php @@ -173,9 +173,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element { $str .= $repo_info['js']; $str .= << -
- $straddfile -
+$straddfile EOD; if (empty($CFG->filemanagerjsloaded)) { $str .= << EOD; $CFG->filemanagerjsloaded = true; diff --git a/repository/filepicker.php b/repository/filepicker.php index f0b79fd6ff..f748711eca 100755 --- a/repository/filepicker.php +++ b/repository/filepicker.php @@ -18,6 +18,10 @@ require_once('../config.php'); require_once($CFG->libdir.'/filelib.php'); require_once('lib.php'); +/// Wait as long as it takes for this script to finish +set_time_limit(0); + +require_login(); $page = optional_param('page', '', PARAM_RAW); // page $client_id = optional_param('client_id', SITEID, PARAM_RAW); // client ID @@ -37,8 +41,7 @@ $search_text = optional_param('s', '', PARAM_CLEANHTML); $sql = 'SELECT i.name, i.typeid, r.type FROM {repository} r, {repository_instances} i '. 'WHERE i.id=? AND i.typeid=r.id'; if (!$repository = $DB->get_record_sql($sql, array($repo_id))) { - $err->e = get_string('invalidrepositoryid', 'repository'); - die(json_encode($err)); + print_error('invalidrepositoryid', 'repository'); } else { $type = $repository->type; } @@ -50,47 +53,18 @@ if (file_exists($CFG->dirroot.'/repository/'.$type.'/repository.class.php')) { try { $repo = new $classname($repo_id, $ctx_id, array('ajax'=>false, 'name'=>$repository->name, 'client_id'=>$client_id)); } catch (repository_exception $e){ - $err->e = $e->getMessage(); - die(json_encode($err)); + print_error('pluginerror', 'repository'); } } else { - $err->e = get_string('invalidplugin', 'repository', $type); - die(json_encode($err)); + print_error('invalidplugin', 'repository'); } //$context = get_context_instance_by_id($ctx_id); //$PAGE->set_course($context); + switch ($action) { -case 'embedded': - echo << - - - - - -EOD; - $fs = get_file_storage(); - $context = get_context_instance(CONTEXT_USER, $USER->id); - $files = $fs->get_area_files($context->id, 'user_draft', $itemid); - echo '
    '; - foreach ($files as $file) { - if ($file->get_filename()!='.') { - $url = $CFG->httpswwwroot.'/draftfile.php/'.$context->id.'/user_draft/'.$itemid.'/'.$file->get_filename(); - echo '
  • '.$file->get_filename().' '; - echo '
  • '; - } - } - echo '
'; - echo ''; - exit; - break; case 'deletedraft': if (!$context = get_context_instance(CONTEXT_USER, $USER->id)) { - echo 'non exist'; + print_error('wrongcontextid', 'error'); } $contextid = $context->id; $fs = get_file_storage(); @@ -98,20 +72,15 @@ case 'deletedraft': if($result = $file->delete()) { header("Location: $CFG->httpswwwroot/repository/filepicker.php?action=embedded&itemid=$itemid&ctx_id=$ctx_id"); } else { - echo 'not deleteed'; + print_error('cannotdelete', 'repository'); } } exit; break; case 'list': case 'sign': - - $navlinks = array(); - $navlinks[] = array('name' => 'filepicker', 'link' => $url, 'type' => 'activityinstance'); - $navlinks[] = array('name' => $repo->get_name()); - - $navigation = build_navigation($navlinks); - print_header(get_string('accessiblefilepicker', 'repository'), get_string('accessiblefilepicker', 'repository'), $navigation); + print_header(); + echo "
".get_string('back', 'repository')."
"; if ($repo->check_login()) { $list = $repo->get_listing($req_path); $dynload = !empty($list['dynload'])?true:false; @@ -119,7 +88,7 @@ case 'sign': echo '
'; echo ''; echo '
'; - echo ''; + echo ''; echo '
'; } else { if (!empty($list['path'])) { @@ -129,7 +98,7 @@ case 'sign': echo ''; echo ''; - echo ' / '; + echo ' / '; } } echo ''; @@ -150,12 +119,12 @@ case 'sign': echo ''; echo ''; echo ''; - echo ''; + echo ''; echo ''; } else { echo ''; echo ''; - echo ''; + echo ''; echo ''; } echo ''; @@ -207,7 +176,8 @@ case 'download': break; case 'confirm': - print_header(get_string('download', 'repository'), get_string('download', 'repository')); + print_header(); + echo '
'.get_string('back', 'repository').'
'; echo ''; echo '
'; echo ''; @@ -227,10 +197,25 @@ case 'confirm': default: $user_context = get_context_instance(CONTEXT_USER, $USER->id); $repos = repository::get_instances(array($user_context, get_system_context()), null, true, null, '*', 'ref_id'); - $navlinks = array(); - $navlinks[] = array('name' => get_string('accessiblefilepicker', 'repository'), 'link' => $url, 'type' => 'activityinstance'); - $navigation = build_navigation($navlinks); - print_header(get_string('accessiblefilepicker', 'repository'), get_string('accessiblefilepicker', 'repository'), $navigation); + print_header(); + $fs = get_file_storage(); + $context = get_context_instance(CONTEXT_USER, $USER->id); + $files = $fs->get_area_files($context->id, 'user_draft', $itemid); + echo '

'.get_string('attachedfiles', 'repository').'

'; + if (empty($files)) { + echo get_string('nofilesattached', 'repository'); + } else { + echo '
    '; + foreach ($files as $file) { + if ($file->get_filename()!='.') { + $drafturl = $CFG->httpswwwroot.'/draftfile.php/'.$context->id.'/user_draft/'.$itemid.'/'.$file->get_filename(); + echo '
  • '.$file->get_filename().' '; + echo '
  • '; + } + } + echo '
'; + } + echo '

'.get_string('plugin', 'repository').'

'; echo '
    '; foreach($repos as $repo) { $info = $repo->get_meta();