Skip to content

Commit

Permalink
MDL-23065, fix non js filepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsheng Cai committed Aug 4, 2010
1 parent 9b8b9b7 commit 563d041
Show file tree
Hide file tree
Showing 7 changed files with 463 additions and 366 deletions.
5 changes: 4 additions & 1 deletion lang/en/repository.php
Expand Up @@ -47,6 +47,7 @@
$string['attachment'] = 'Attachment';
$string['author'] = 'Author';
$string['back'] = '« Back';
$string['backtodraftfiles'] = '« Back to draft files manager';
$string['cachecleared'] = 'Cached files are removed';
$string['cacheexpire'] = 'Cache expire';
$string['cannotaccessparentwin'] = 'If parent window is on HTTPS, then we are not allowed to access window.opener object, so we cannot refresh the repository for you automatically, but we already got your session, just go back to file picker and select the repository again, it should work now.';
Expand Down Expand Up @@ -165,7 +166,9 @@
$string['uploading'] = 'Uploading...';
$string['uploadsucc'] = 'The file has been uploaded successfully';
$string['usercontextrepositorydisabled'] = 'You cannot edit this repository in user context';
$string['usenonjsfilemanager'] = 'Use non javascript file manager';
$string['usenonjsfilemanager'] = 'Open file manager in new window';
$string['usenonjsfilepicker'] = 'Open file picker in new window';
$string['unzipped'] = 'Unzipped successfully';
$string['wrongcontext'] = 'You cannot access to this context';
$string['xhtmlerror'] = 'You are probably using XHTML strict header, some YUI Component doesn\'t work in this mode, please turn it off in moodle';
$string['ziped'] = 'Compress folder successfully';
14 changes: 8 additions & 6 deletions lib/form/editor.php
Expand Up @@ -222,20 +222,22 @@ function toHtml() {
if (!during_initial_install() && empty($CFG->adminsetuppending)) {
// 0 means no files, -1 unlimited
if ($maxfiles != 0 ) {
$str .= '<div><input type="hidden" name="'.$elname.'[itemid]" value="'.$draftitemid.'" /></div>';
$str .= '<div id="'.$id.'_filemanager">';
$editorurl = new moodle_url("$CFG->wwwroot/repository/filepicker.php", array(
$str .= '<input type="hidden" name="'.$elname.'[itemid]" value="'.$draftitemid.'" />';

// used by non js editor only
$editorurl = new moodle_url("$CFG->wwwroot/repository/draftfiles_manager.php", array(
'action'=>'browse',
'env'=>'editor',
'itemid'=>$draftitemid,
'subdirs'=>$subdirs,
'maxbytes'=>$maxbytes,
'maxfiles'=>$maxfiles,
'ctx_id'=>$ctx->id,
'course'=>$PAGE->course->id
));
$str .= html_writer::link($editorurl->out(false), get_string('manageeditorfiles'), array('target'=>'_blank'));
//$str .= '<object type="text/html" data="'.$editorurl.'" height="160" width="600" style="border:1px solid #000">Error</object>';
$str .= '</div>';
$str .= '<noscript>';
$str .= "<object type='text/html' data='$editorurl' height='160' width='600' style='border:1px solid #000'></object>";
$str .= '</noscript>';
}
}

Expand Down
38 changes: 14 additions & 24 deletions lib/form/filemanager.php
Expand Up @@ -245,9 +245,7 @@ function form_filemanager_render($options) {
static $filemanagertemplateloaded;

$html = '';
$nonjsfilemanager = optional_param('usenonjsfilemanager', 0, PARAM_INT);
$options = $fm->options;
$options->usenonjs = $nonjsfilemanager;
$straddfile = get_string('add', 'repository') . '...';
$strmakedir = get_string('makeafolder', 'moodle');
$strdownload = get_string('downloadfolder', 'repository');
Expand Down Expand Up @@ -293,16 +291,6 @@ function form_filemanager_render($options) {
FMHTML;
}

$filemanagerurl = new moodle_url('/repository/filepicker.php', array(
'env'=>'filemanager',
'action'=>'embedded',
'itemid'=>$itemid,
'subdirs'=>'/',
'maxbytes'=>$options->maxbytes,
'ctx_id'=>$PAGE->context->id,
'course'=>$PAGE->course->id,
));

$module = array(
'name'=>'form_filemanager',
'fullpath'=>'/lib/form/filemanager.js',
Expand All @@ -321,18 +309,20 @@ function form_filemanager_render($options) {
$PAGE->requires->js_init_call('M.form_filemanager.init', array($options), true, $module);

// non javascript file manager
if (!empty($nonjsfilemanager)) {
$html = '<div id="nonjs-filemanager-'.$client_id.'">';
$html .= <<<NONJS
<object type="text/html" data="$filemanagerurl" height="160" width="600" style="border:1px solid #000">Error</object>
NONJS;
$html .= '</div>';
} else {
$url = new moodle_url($PAGE->url, array('usenonjsfilemanager'=>1));
$html .= '<div id="nonjs-filemanager-'.$client_id.'" class="mdl-align">';
$html .= html_writer::link($url, get_string('usenonjsfilemanager', 'repository'));
$html .= '</div>';
}
$filemanagerurl = new moodle_url('/repository/draftfiles_manager.php', array(
'env'=>'filemanager',
'action'=>'browse',
'itemid'=>$itemid,
'subdirs'=>$options->subdirs,
'maxbytes'=>$options->maxbytes,
'maxfiles'=>$options->maxfiles,
'ctx_id'=>$PAGE->context->id,
'course'=>$PAGE->course->id,
));

$html .= '<noscript>';
$html .= "<object type='text/html' data='$filemanagerurl' height='160' width='600' style='border:1px solid #000'></object>";
$html .= '</noscript>';


return $html;
Expand Down
16 changes: 16 additions & 0 deletions lib/form/filepicker.php
Expand Up @@ -87,6 +87,22 @@ function toHtml() {
$module = array('name'=>'form_filepicker', 'fullpath'=>'/lib/form/filepicker.js', 'requires'=>array('core_filepicker'));
$PAGE->requires->js_init_call('M.form_filepicker.init', array($fp->options), true, $module);

$nonjsfilepicker = new moodle_url('/repository/draftfiles_manager.php', array(
'env'=>'filepicker',
'action'=>'browse',
'itemid'=>$draftitemid,
'subdirs'=>0,
'maxbytes'=>$options->maxbytes,
'maxfiles'=>1,
'ctx_id'=>$PAGE->context->id,
'course'=>$PAGE->course->id,
));

// non js file picker
$html .= '<noscript>';
$html .= "<object type='text/html' data='$nonjsfilepicker' height='160' width='600' style='border:1px solid #000'></object>";
$html .= '</noscript>';

return $html;
}

Expand Down

0 comments on commit 563d041

Please sign in to comment.