"MDL-17316, improve non-js file manager interface"
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -173,9 +173,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
|
||||
$str .= $repo_info['js'];
|
||||
$str .= <<<EOD
|
||||
<input value="$draftitemid" name="{$this->_attributes['name']}" type="hidden" />
|
||||
<div>
|
||||
<a href="{$CFG->httpswwwroot}/repository/filepicker.php?ctx_id={$context->id}&&itemid=$draftitemid" onclick="return callpicker('$id', '$client_id', '$draftitemid')" target="_blank">$straddfile</a>
|
||||
</div>
|
||||
<a href="#nonjsfp" class="btnaddfile" onclick="return callpicker('$id', '$client_id', '$draftitemid')">$straddfile</a>
|
||||
EOD;
|
||||
if (empty($CFG->filemanagerjsloaded)) {
|
||||
$str .= <<<EOD
|
||||
@@ -226,7 +224,11 @@ function callpicker(el_id, client_id, itemid) {
|
||||
//]]>
|
||||
</script>
|
||||
<noscript>
|
||||
<object type="text/html" data="{$CFG->httpswwwroot}/repository/filepicker.php?action=embedded&itemid={$draftitemid}&ctx_id=$context->id" height="160" width="600" style="border:1px solid #000">Error</object>
|
||||
<style type="text/css">
|
||||
.btnaddfile{display:none}
|
||||
</style>
|
||||
<a name="nonjsfp"></a>
|
||||
<object type="text/html" data="{$CFG->httpswwwroot}/repository/filepicker.php?action=embedded&itemid={$draftitemid}&ctx_id=$context->id" height="300" width="800" style="border:1px solid #000">Error</object>
|
||||
</noscript>
|
||||
EOD;
|
||||
$CFG->filemanagerjsloaded = true;
|
||||
|
||||
+37
-52
@@ -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
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
img{border:0}
|
||||
li{list-style-type:none;margin:0;padding:0}
|
||||
ul{margin:0;padding:0}
|
||||
</style>
|
||||
<meta http-equiv="Refresh" Content="3" />
|
||||
</head>
|
||||
<body>
|
||||
EOD;
|
||||
$fs = get_file_storage();
|
||||
$context = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$files = $fs->get_area_files($context->id, 'user_draft', $itemid);
|
||||
echo '<ul>';
|
||||
foreach ($files as $file) {
|
||||
if ($file->get_filename()!='.') {
|
||||
$url = $CFG->httpswwwroot.'/draftfile.php/'.$context->id.'/user_draft/'.$itemid.'/'.$file->get_filename();
|
||||
echo '<li><a href="'.$url.'">'.$file->get_filename().'</a> ';
|
||||
echo '<a href="'.$CFG->httpswwwroot.'/repository/filepicker.php?action=deletedraft&itemid='.$itemid.'&ctx_id='.$ctx_id.'&title='.$file->get_filename().'"><img src="'.$CFG->httpswwwroot.'/pix/t/delete.gif" class="iconsmall" /></a></li>';
|
||||
}
|
||||
}
|
||||
echo '</ul>';
|
||||
echo '</body></html>';
|
||||
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 "<div><a href='$CFG->httpswwwroot/repository/filepicker.php?action=embedded&itemid=$itemid&ctx_id=$ctx_id'>".get_string('back', 'repository')."</a></div>";
|
||||
if ($repo->check_login()) {
|
||||
$list = $repo->get_listing($req_path);
|
||||
$dynload = !empty($list['dynload'])?true:false;
|
||||
@@ -119,7 +88,7 @@ case 'sign':
|
||||
echo '<form method="post" style="display:inline">';
|
||||
echo '<label>'.$list['upload']['label'].'</label>';
|
||||
echo '<input type="file" name="repo_upload_file" /><br />';
|
||||
echo '<input type="submit" value="Upload" />';
|
||||
echo '<input type="submit" value="'.get_string('upload', 'repository').'" />';
|
||||
echo '</form>';
|
||||
} else {
|
||||
if (!empty($list['path'])) {
|
||||
@@ -129,7 +98,7 @@ case 'sign':
|
||||
echo '<input type="hidden" name="action" value="list"';
|
||||
echo '<input type="submit" value="'.$p['name'].'" />';
|
||||
echo '</form>';
|
||||
echo ' <strong>/</strong> ';
|
||||
echo '<strong> / </strong>';
|
||||
}
|
||||
}
|
||||
echo '<table>';
|
||||
@@ -150,12 +119,12 @@ case 'sign':
|
||||
echo '<input type="hidden" name="action" value="confirm"/>';
|
||||
echo '<input type="hidden" name="title" value="'.$item['title'].'"/>';
|
||||
echo '<input type="hidden" name="icon" value="'.$item['thumbnail'].'"/>';
|
||||
echo '<input type="submit" value="Download" />';
|
||||
echo '<input type="submit" value="'.get_string('select','repository').'" />';
|
||||
echo '</form>';
|
||||
} else {
|
||||
echo '<form method="post">';
|
||||
echo '<input type="hidden" name="p" value="'.$item['path'].'"/>';
|
||||
echo '<input type="submit" value="Enter" />';
|
||||
echo '<input type="submit" value="'.get_string('enter', 'repository').'" />';
|
||||
echo '</form>';
|
||||
}
|
||||
echo '</td>';
|
||||
@@ -207,7 +176,8 @@ case 'download':
|
||||
|
||||
break;
|
||||
case 'confirm':
|
||||
print_header(get_string('download', 'repository'), get_string('download', 'repository'));
|
||||
print_header();
|
||||
echo '<div><a href="'.me().'">'.get_string('back', 'repository').'</a></div>';
|
||||
echo '<img src="'.$icon.'" />';
|
||||
echo '<form method="post"><table>';
|
||||
echo '<tr>';
|
||||
@@ -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 '<h2>'.get_string('attachedfiles', 'repository').'</h2>';
|
||||
if (empty($files)) {
|
||||
echo get_string('nofilesattached', 'repository');
|
||||
} else {
|
||||
echo '<ul>';
|
||||
foreach ($files as $file) {
|
||||
if ($file->get_filename()!='.') {
|
||||
$drafturl = $CFG->httpswwwroot.'/draftfile.php/'.$context->id.'/user_draft/'.$itemid.'/'.$file->get_filename();
|
||||
echo '<li><a href="'.$drafturl.'">'.$file->get_filename().'</a> ';
|
||||
echo '<a href="'.$CFG->httpswwwroot.'/repository/filepicker.php?action=deletedraft&itemid='.$itemid.'&ctx_id='.$ctx_id.'&title='.$file->get_filename().'"><img src="'.$CFG->httpswwwroot.'/pix/t/delete.gif" class="iconsmall" /></a></li>';
|
||||
}
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '<h2>'.get_string('plugin', 'repository').'</h2>';
|
||||
echo '<div><ul>';
|
||||
foreach($repos as $repo) {
|
||||
$info = $repo->get_meta();
|
||||
|
||||
Reference in New Issue
Block a user