<?php //$Id$
$string['accessiblefilepicker']='Accessible file picker';
$string['activerepository'] = 'Active repository plugins';
-$string['add'] = 'Add';
+$string['add'] = 'Add...';
$string['addplugin'] = 'Add a repository plugin';
$string['activaterep'] = 'Active repositories';
$string['areabackup'] = 'Backups';
$string['updown'] = 'Display order';
$string['upload'] = 'Upload this file';
$string['uploading'] = 'Uploading...';
+$string['uploadsucc'] = 'The file has been uploaded 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';
$str .= $repo_info['js'];
$str .= <<<EOD
<input value="$draftitemid" name="{$this->_attributes['name']}" type="hidden" />
-<a href="#nonjsfp" class="btnaddfile" onclick="return callpicker('$id', '$client_id', '$draftitemid')">$straddfile</a>
+<a href="###" id="btnadd-{$client_id}" style="display:none" class="btnaddfile" onclick="return callpicker('$id', '$client_id', '$draftitemid')">$straddfile</a>
+<script type="text/javascript">
+//<![CDATA[
+document.getElementById('btnadd-{$client_id}').style.display="inline";
+//]]>
+</script>
EOD;
if (empty($CFG->filemanagerjsloaded)) {
$str .= <<<EOD
//]]>
</script>
<noscript>
-<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;
return $this->getFrozenHtml();
}
+ $strsaved = get_string('filesaved', 'repository');
+ $straddfile = get_string('openpicker', 'repository');
$currentfile = '';
$draftvalue = '';
if ($draftid = (int)$this->getValue()) {
$draftvalue = 'value="'.$draftid.'"';
}
}
- $strsaved = get_string('filesaved', 'repository');
if ($COURSE->id == SITEID) {
$context = get_context_instance(CONTEXT_SYSTEM);
} else {
$str = $this->_getTabs();
$str .= '<input type="hidden" name="'.$elname.'" id="'.$id.'" '.$draftvalue.' />';
+ $str .= $repository_info['css'].$repository_info['js'];
$str .= <<<EOD
+<a href="#nonjsfp" class="btnaddfile" onclick="return callpicker('$client_id', '$id', '$draftvalue')">$straddfile</a>
+<span id="repo_info_{$client_id}" class="notifysuccess">$currentfile</span>
<script type="text/javascript">
function updatefile(client_id, obj) {
document.getElementById('repo_info_'+client_id).innerHTML = obj['file'];
var el=document.getElementById(id);
var params = {};
params.env = 'filepicker';
+ params.itemid = itemid;
params.maxbytes = $this->_options['maxbytes'];
params.maxfiles = $this->_options['maxfiles'];
params.target = el;
params.callback = updatefile;
open_filepicker(client_id, params);
+ return false;
}
</script>
+<noscript>
+<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;
- $str .= '<input value="'.get_string('openpicker', 'repository').'" type="button" onclick="callpicker(\''.$client_id.'\', \''.$id.'\')" />'.'<span id="repo_info_'.$client_id.'" class="notifysuccess">'.$currentfile.'</span>'.$repository_info['css'].$repository_info['js'];
return $str;
}
//$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');
$list = $repo->get_listing($req_path);
$dynload = !empty($list['dynload'])?true:false;
if (!empty($list['upload'])) {
- echo '<form method="post" style="display:inline">';
- echo '<label>'.$list['upload']['label'].'</label>';
+ echo '<form action="'.$url.'" method="post" enctype="multipart/form-data" style="display:inline">';
+ echo '<label>'.$list['upload']['label'].': </label>';
echo '<input type="file" name="repo_upload_file" /><br />';
+ echo '<input type="hidden" name="action" value="upload" /><br />';
+ echo '<input type="hidden" name="repo_id" value="'.$repo_id.'" /><br />';
echo '<input type="submit" value="'.get_string('upload', 'repository').'" />';
echo '</form>';
} else {
echo '</form>';
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 '<div><ul>';
+ foreach($repos as $repo) {
+ $info = $repo->get_meta();
+ echo '<li><img src="'.$info->icon.'" width="16px" height="16px"/> <a href="'.$url.'&action=list&repo_id='.$info->id.'">'.$info->name.'</a></li>';
+ }
+ echo '</ul></div>';
+ 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');
$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>';
}
- echo '<h2>'.get_string('plugin', 'repository').'</h2>';
- echo '<div><ul>';
- foreach($repos as $repo) {
- $info = $repo->get_meta();
- echo '<li><img src="'.$info->icon.'" width="16px" height="16px"/> <a href="'.$url.'&action=list&repo_id='.$info->id.'">'.$info->name.'</a></li>';
- }
- echo '</ul></div>';
+ echo '<div><a href="'.$url.'&action=plugins">'.get_string('add', 'repository').'</a></div>';
print_footer('empty');
break;
}
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;
* @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'){