From: dongsheng Date: Thu, 18 Jun 2009 06:31:51 +0000 (+0000) Subject: "MDL-17316, fix upload form in non-js file picker" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ab9cdbb976aca5de13571f602f3bab4ab60674f8;p=moodle.git "MDL-17316, fix upload form in non-js file picker" --- diff --git a/lang/en_utf8/repository.php b/lang/en_utf8/repository.php index 983cbc3961..10d23c55d3 100644 --- a/lang/en_utf8/repository.php +++ b/lang/en_utf8/repository.php @@ -1,7 +1,7 @@ _attributes['name']}" type="hidden" /> -$straddfile + + EOD; if (empty($CFG->filemanagerjsloaded)) { $str .= << EOD; diff --git a/lib/form/filepicker.php b/lib/form/filepicker.php index a2d7d94014..5739b3b783 100644 --- a/lib/form/filepicker.php +++ b/lib/form/filepicker.php @@ -65,6 +65,8 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { return $this->getFrozenHtml(); } + $strsaved = get_string('filesaved', 'repository'); + $straddfile = get_string('openpicker', 'repository'); $currentfile = ''; $draftvalue = ''; if ($draftid = (int)$this->getValue()) { @@ -76,7 +78,6 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { $draftvalue = 'value="'.$draftid.'"'; } } - $strsaved = get_string('filesaved', 'repository'); if ($COURSE->id == SITEID) { $context = get_context_instance(CONTEXT_SYSTEM); } else { @@ -90,8 +91,11 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { $str = $this->_getTabs(); $str .= ''; + $str .= $repository_info['css'].$repository_info['js']; $str .= <<$straddfile +$currentfile + EOD; - $str .= ''.''.$currentfile.''.$repository_info['css'].$repository_info['js']; return $str; } diff --git a/repository/filepicker.php b/repository/filepicker.php index f748711eca..ff40fd22c4 100755 --- a/repository/filepicker.php +++ b/repository/filepicker.php @@ -62,6 +62,9 @@ if (file_exists($CFG->dirroot.'/repository/'.$type.'/repository.class.php')) { //$PAGE->set_course($context); switch ($action) { +case 'upload': + redirect($url, get_string('uploadsucc','repository')); + break; case 'deletedraft': if (!$context = get_context_instance(CONTEXT_USER, $USER->id)) { print_error('wrongcontextid', 'error'); @@ -85,9 +88,11 @@ case 'sign': $list = $repo->get_listing($req_path); $dynload = !empty($list['dynload'])?true:false; if (!empty($list['upload'])) { - echo '
'; - echo ''; + echo ''; + echo ''; echo '
'; + echo '
'; + echo '
'; echo ''; echo '
'; } else { @@ -194,6 +199,17 @@ case 'confirm': echo ''; print_footer('empty'); break; +case 'plugins': + $user_context = get_context_instance(CONTEXT_USER, $USER->id); + $repos = repository::get_instances(array($user_context, get_system_context()), null, true, null, '*', 'ref_id'); + print_header(); + echo '
    '; + foreach($repos as $repo) { + $info = $repo->get_meta(); + echo '
  • '.$info->name.'
  • '; + } + echo '
'; + break; 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'); @@ -201,7 +217,6 @@ default: $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 { @@ -215,13 +230,7 @@ default: } echo ''; } - echo '

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

'; - echo '
    '; - foreach($repos as $repo) { - $info = $repo->get_meta(); - echo '
  • '.$info->name.'
  • '; - } - echo '
'; + echo '
'.get_string('add', 'repository').'
'; print_footer('empty'); break; } diff --git a/repository/repository.src.js b/repository/repository.src.js index 0399ad2d82..d4d664b58e 100644 --- a/repository/repository.src.js +++ b/repository/repository.src.js @@ -571,7 +571,8 @@ repository_client.select_file = function(oldname, url, icon, client_id, repo_id) if (repository_client.files[client_id] == undefined) { repository_client.files[client_id] = 0; } - if (repository_client.files[client_id] >= repository_client.fp[client_id].maxfiles) + if (repository_client.files[client_id] >= repository_client.fp[client_id].maxfiles && + repository_client.fp[client_id].maxfiles != -1) { alert('Only '+repository_client.fp[client_id].maxfiles+' files are allowed!'); return false; diff --git a/repository/upload/repository.class.php b/repository/upload/repository.class.php index 78be689e48..cf2a52df6f 100755 --- a/repository/upload/repository.class.php +++ b/repository/upload/repository.class.php @@ -19,7 +19,7 @@ class repository_upload extends repository { * @param array $options */ public function __construct($repositoryid, $context = SITEID, $options = array()){ - global $SESSION, $action, $CFG; + global $_FILES, $SESSION, $action, $CFG; parent::__construct($repositoryid, $context, $options); $itemid = optional_param('itemid', '', PARAM_INT); if($action=='upload'){