mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-16597, move print_filemanager to $OUTPUT->file_manager, now theme designers are able to costomize file manager.
This commit is contained in:
parent
bfe600c3e9
commit
4d2ee4c2c0
@ -21,7 +21,7 @@
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage repository
|
||||
* @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
|
||||
* @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@ -46,7 +46,7 @@ class block_private_files extends block_base {
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $USER, $PAGE;
|
||||
global $CFG, $USER, $PAGE, $OUTPUT;
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
@ -56,36 +56,19 @@ class block_private_files extends block_base {
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
if (isloggedin() && !isguestuser()) { // Show the block
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$client_id = uniqid();
|
||||
|
||||
$params = new stdclass;
|
||||
$params->accepted_types = '*';
|
||||
$params->return_types = FILE_INTERNAL;
|
||||
$params->context = $PAGE->context;
|
||||
$params->env = 'filemanager';
|
||||
|
||||
$filepicker_options = initialise_filepicker($params);
|
||||
|
||||
$fs = get_file_storage();
|
||||
$draftfiles = $fs->get_area_files($usercontext->id, 'user_private', 0, 'id', false);
|
||||
// the number of existing files in user private area
|
||||
$filecount = count($draftfiles);
|
||||
|
||||
// read existing user private files
|
||||
$options = file_get_user_area_files(0, '/', 'user_private');
|
||||
$options = new stdclass;
|
||||
$options->maxbytes = -1;
|
||||
$options->maxfiles = -1;
|
||||
$options->filearea = 'user_private';
|
||||
$options->client_id = $client_id;
|
||||
$options->filecount = $filecount;
|
||||
$options->itemid = 0;
|
||||
$options->subdirs = true;
|
||||
// store filepicker options
|
||||
$options->filepicker = $filepicker_options;
|
||||
$options->accepted_types = '*';
|
||||
$options->return_types = FILE_INTERNAL;
|
||||
$options->context = $PAGE->context;
|
||||
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = print_filemanager($options, true);
|
||||
$this->content->text = $OUTPUT->file_manager($options);
|
||||
;
|
||||
$this->content->footer = '';
|
||||
|
||||
|
@ -156,6 +156,7 @@ $string['upload'] = 'Upload this file';
|
||||
$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['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';
|
||||
|
@ -132,36 +132,26 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
|
||||
$draftitemid = $this->getValue();
|
||||
}
|
||||
|
||||
$draftareainfo = file_get_draft_area_info($draftitemid);
|
||||
$filecount = $draftareainfo['filecount'];
|
||||
$client_id = uniqid();
|
||||
|
||||
$params = new stdclass;
|
||||
$params->accepted_types = $accepted_types;
|
||||
$params->return_types = FILE_INTERNAL;
|
||||
$params->context = $PAGE->context;
|
||||
$params->env = 'filemanager';
|
||||
|
||||
// including the repository instances list
|
||||
$filepicker_options = initialise_filepicker($params);
|
||||
|
||||
// including draft files
|
||||
$options = file_get_user_area_files($draftitemid, '/', 'user_draft');
|
||||
// filemanager options
|
||||
$options->filepicker = $filepicker_options;
|
||||
$options = new stdclass;
|
||||
$options->mainfile = $this->_options['mainfile'];
|
||||
$options->filearea = 'user_draft';
|
||||
$options->maxbytes = $this->_options['maxbytes'];
|
||||
$options->maxfiles = $this->getMaxfiles();
|
||||
$options->client_id = $client_id;
|
||||
$options->filecount = $filecount;
|
||||
$options->itemid = $draftitemid;
|
||||
$options->subdirs = $this->_options['subdirs'];
|
||||
// store filepicker options
|
||||
$options->target = $id;
|
||||
$options->accepted_types = $accepted_types;
|
||||
$options->return_types = FILE_INTERNAL;
|
||||
$options->context = $PAGE->context;
|
||||
|
||||
$html = $this->_getTabs();
|
||||
$html .= $OUTPUT->file_manager($options);
|
||||
|
||||
$html .= '<input value="'.$draftitemid.'" name="'.$elname.'" type="hidden" />';
|
||||
$html .= print_filemanager($options, true);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
@ -35,6 +35,61 @@ interface renderable {
|
||||
// intentionally empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Data structure representing a file manager.
|
||||
*
|
||||
* @copyright 2010 Dongsheng Cai
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 2.0
|
||||
*/
|
||||
class file_manager implements renderable {
|
||||
public $options;
|
||||
public function __construct(stdClass $options) {
|
||||
global $CFG, $USER, $PAGE;
|
||||
require_once($CFG->dirroot. '/repository/lib.php');
|
||||
$defaults = array(
|
||||
'maxbytes'=>-1,
|
||||
'maxfiles'=>-1,
|
||||
'filearea'=>'user_draft',
|
||||
'itemid'=>0,
|
||||
'subdirs'=>0,
|
||||
'client_id'=>uniqid(),
|
||||
'accepted_types'=>'*',
|
||||
'return_types'=>FILE_INTERNAL,
|
||||
'context'=>$PAGE->context
|
||||
);
|
||||
foreach ($defaults as $key=>$value) {
|
||||
if (empty($options->$key)) {
|
||||
$options->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$fs = get_file_storage();
|
||||
|
||||
// initilise options, getting files in root path
|
||||
$this->options = file_get_user_area_files($options->itemid, '/', $options->filearea);
|
||||
|
||||
// calculate file count
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$files = $fs->get_area_files($usercontext->id, $options->filearea, $options->itemid, 'id', false);
|
||||
$filecount = count($files);
|
||||
$this->options->filecount = $filecount;
|
||||
|
||||
// copying other options
|
||||
foreach ($options as $name=>$value) {
|
||||
$this->options->$name = $value;
|
||||
}
|
||||
|
||||
// building file picker options
|
||||
$params = new stdclass;
|
||||
$params->accepted_types = $options->accepted_types;
|
||||
$params->return_types = $options->return_types;
|
||||
$params->context = $options->context;
|
||||
$params->env = 'filemanager';
|
||||
$filepicker_options = initialise_filepicker($params);
|
||||
$this->options->filepicker = $filepicker_options;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data structure representing a user picture.
|
||||
@ -2133,7 +2188,7 @@ class custom_menu extends custom_menu_item {
|
||||
* -Second level third item|http://www.moodle.com/development/
|
||||
* First level second item|http://www.moodle.com/feedback/
|
||||
* First level third item
|
||||
*
|
||||
*
|
||||
* @static
|
||||
* @param string $text
|
||||
* @return array
|
||||
@ -2217,4 +2272,4 @@ class custom_menu extends custom_menu_item {
|
||||
}
|
||||
return ($itema > $itemb) ? +1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -623,7 +623,7 @@ class core_renderer extends renderer_base {
|
||||
global $CFG, $DB;
|
||||
|
||||
$output = $this->container_end_all(true);
|
||||
|
||||
|
||||
$footer = $this->opencontainers->pop('header/footer');
|
||||
|
||||
if (debugging() and $DB and $DB->is_transaction_started()) {
|
||||
@ -739,7 +739,7 @@ class core_renderer extends renderer_base {
|
||||
$output = html_writer::tag('a', get_string('skipa', 'access', $skiptitle), array('href' => '#sb-' . $bc->skipid, 'class' => 'skip-block'));
|
||||
$skipdest = html_writer::tag('span', '', array('id' => 'sb-' . $bc->skipid, 'class' => 'skip-block-to'));
|
||||
}
|
||||
|
||||
|
||||
$output .= html_writer::start_tag('div', $bc->attributes);
|
||||
|
||||
$controlshtml = $this->block_controls($bc->controls);
|
||||
@ -1269,9 +1269,9 @@ class core_renderer extends renderer_base {
|
||||
$ratinghtml = ''; //the string we'll return
|
||||
|
||||
//permissions check - can they view the aggregate?
|
||||
if ( ($rating->itemuserid==$USER->id
|
||||
if ( ($rating->itemuserid==$USER->id
|
||||
&& $rating->settings->permissions->view && $rating->settings->pluginpermissions->view)
|
||||
|| ($rating->itemuserid!=$USER->id
|
||||
|| ($rating->itemuserid!=$USER->id
|
||||
&& $rating->settings->permissions->viewany && $rating->settings->pluginpermissions->viewany) ) {
|
||||
|
||||
$aggregatelabel = '';
|
||||
@ -1337,7 +1337,7 @@ class core_renderer extends renderer_base {
|
||||
&& $rating->settings->permissions->rate
|
||||
&& $rating->settings->pluginpermissions->rate
|
||||
&& $inassessablewindow) {
|
||||
|
||||
|
||||
//start the rating form
|
||||
$formstart = html_writer::start_tag('form',
|
||||
array('id'=>"postrating{$rating->itemid}", 'class'=>'postratingform', 'method'=>'post', 'action'=>"{$CFG->wwwroot}/rating/rate.php"));
|
||||
@ -1391,7 +1391,7 @@ class core_renderer extends renderer_base {
|
||||
$ratinghtml .= html_writer::select($scalearray, 'rating', $rating->rating, false, array('class'=>'postratingmenu ratinginput','id'=>'menurating'.$rating->itemid));
|
||||
|
||||
//output submit button
|
||||
|
||||
|
||||
$ratinghtml .= html_writer::start_tag('span', array('class'=>"ratingsubmit"));
|
||||
|
||||
$attributes = array('type'=>'submit', 'class'=>'postratingmenusubmit', 'id'=>'postratingsubmit'.$rating->itemid, 'value'=>s(get_string('rate', 'rating')));
|
||||
@ -1720,6 +1720,127 @@ class core_renderer extends renderer_base {
|
||||
return html_writer::tag('a', $output, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the file manager
|
||||
*
|
||||
* <pre>
|
||||
* $OUTPUT->file_manager($options);
|
||||
* </pre>
|
||||
*
|
||||
* @param array $options associative array with file manager options
|
||||
* options are:
|
||||
* maxbytes=>-1,
|
||||
* maxfiles=>-1,
|
||||
* filearea=>'user_draft',
|
||||
* itemid=>0,
|
||||
* subdirs=>false,
|
||||
* client_id=>uniqid(),
|
||||
* ccepted_types=>'*',
|
||||
* return_types=>FILE_INTERNAL,
|
||||
* context=>$PAGE->context
|
||||
* @return string HTML fragment
|
||||
*/
|
||||
public function file_manager($options) {
|
||||
$fm = new file_manager($options);
|
||||
return $this->render($fm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal implementation of file manager rendering.
|
||||
* @param file_manager $fm
|
||||
* @return string
|
||||
*/
|
||||
public function render_file_manager(file_manager $fm) {
|
||||
global $CFG, $OUTPUT;
|
||||
static $filemanagertemplateloaded;
|
||||
$html = '';
|
||||
$nonjsfilemanager = optional_param('usenonjsfilemanager', 0, PARAM_INT);
|
||||
$options = $fm->options;
|
||||
$straddfile = get_string('add', 'repository') . '...';
|
||||
$strmakedir = get_string('makeafolder', 'moodle');
|
||||
$strdownload = get_string('downloadfolder', 'repository');
|
||||
|
||||
$icon_add_file = $OUTPUT->pix_icon('t/addfile', $straddfile).'';
|
||||
$icon_add_folder = $OUTPUT->pix_icon('t/adddir', $strmakedir).'';
|
||||
$icon_download = $OUTPUT->pix_icon('t/download', $strdownload).'';
|
||||
|
||||
$client_id = $options->client_id;
|
||||
$itemid = $options->itemid;
|
||||
$filearea = $options->filearea;
|
||||
|
||||
if (empty($options->filecount)) {
|
||||
$extra = ' style="display:none"';
|
||||
} else {
|
||||
$extra = '';
|
||||
}
|
||||
|
||||
$html .= <<<FMHTML
|
||||
<div id="filemanager-wrapper-{$client_id}" style="display:none">
|
||||
<div class="fm-breadcrumb" id="fm-path-{$client_id}"></div>
|
||||
<div class="filemanager-toolbar">
|
||||
<button id="btnadd-{$client_id}" onclick="return false">{$icon_add_file} $straddfile</button>
|
||||
<button id="btncrt-{$client_id}" onclick="return false">{$icon_add_folder} $strmakedir</button>
|
||||
<button id="btndwn-{$client_id}" onclick="return false" {$extra}>{$icon_download} $strdownload</button>
|
||||
</div>
|
||||
<div class="filemanager-container" id="filemanager-{$client_id}">
|
||||
<ul id="draftfiles-{$client_id}" class="fm-filelist">
|
||||
<li>Loading...</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class='clearer'></div>
|
||||
FMHTML;
|
||||
if (empty($filemanagertemplateloaded)) {
|
||||
$filemanagertemplateloaded = true;
|
||||
$html .= <<<FMHTML
|
||||
<div id="fm-template" style="display:none"><div class="fm-file-menu">___action___</div> <div class="fm-file-name">___fullname___</div></div>
|
||||
FMHTML;
|
||||
}
|
||||
|
||||
$filemanagerurl = new moodle_url('/repository/filepicker.php', array(
|
||||
'filearea'=>$filearea,
|
||||
'env'=>'filemanager',
|
||||
'action'=>'embedded',
|
||||
'itemid'=>$itemid,
|
||||
'subdirs'=>'/',
|
||||
'maxbytes'=>$options->maxbytes,
|
||||
'ctx_id'=>$this->page->context->id,
|
||||
'course'=>$this->page->course->id,
|
||||
));
|
||||
|
||||
$module = array(
|
||||
'name'=>'form_filemanager',
|
||||
'fullpath'=>'/lib/form/filemanager.js',
|
||||
'requires' => array('core_filepicker', 'base', 'io', 'node', 'json', 'yui2-button', 'yui2-container', 'yui2-layout', 'yui2-menu', 'yui2-treeview'),
|
||||
'strings' => array(array('loading', 'repository'), array('nomorefiles', 'repository'), array('confirmdeletefile', 'repository'),
|
||||
array('add', 'repository'), array('accessiblefilepicker', 'repository'), array('move', 'moodle'),
|
||||
array('cancel', 'moodle'), array('download', 'moodle'), array('ok', 'moodle'),
|
||||
array('emptylist', 'repository'), array('entername', 'repository'), array('enternewname', 'repository'),
|
||||
array('zip', 'editor'), array('unzip', 'moodle'), array('rename', 'moodle'), array('delete', 'moodle'),
|
||||
array('setmainfile', 'resource'), array('cannotdeletefile', 'error'), array('confirmdeletefile', 'repository'),
|
||||
array('nopathselected', 'repository'), array('popupblockeddownload', 'repository'),
|
||||
array('draftareanofiles', 'repository'), array('path', 'moodle'), array('setmainfile', 'repository')
|
||||
)
|
||||
);
|
||||
$this->page->requires->js_module($module);
|
||||
$this->page->requires->js_init_call('M.form_filemanager.init', array($options), true, $module);
|
||||
|
||||
$url = new moodle_url($this->page->url, array('usenonjsfilemanager'=>1));
|
||||
|
||||
// non javascript file manager
|
||||
$html .= '<div id="nonjs-filemanager-'.$client_id.'">';
|
||||
if (!empty($nonjsfilemanager)) {
|
||||
$html .= <<<NONJS
|
||||
<object type="text/html" data="$url" height="160" width="600" style="border:1px solid #000">Error</object>
|
||||
NONJS;
|
||||
} else {
|
||||
$html .= html_writer::link($url, get_string('usenonjsfilemanager', 'repository'));
|
||||
}
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the 'Update this Modulename' button that appears on module pages.
|
||||
*
|
||||
@ -2213,7 +2334,7 @@ class core_renderer extends renderer_base {
|
||||
* A custom menu can be configured by browing to
|
||||
* Settings: Administration > Appearance > Themes > Theme settings
|
||||
* and then configuring the custommenu config setting as described.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function custom_menu() {
|
||||
|
@ -2722,102 +2722,6 @@ function print_maintenance_message() {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is used to print a filemanager
|
||||
*
|
||||
* @param $options array options to setup filemanager
|
||||
* @param $return bool If true output is returned rather than printed out
|
||||
* @return string
|
||||
*/
|
||||
function print_filemanager($options, $return = false) {
|
||||
global $PAGE, $CFG, $OUTPUT;
|
||||
// start to setup filemanager
|
||||
// loading filemanager language string
|
||||
$PAGE->requires->string_for_js('loading', 'repository');
|
||||
$PAGE->requires->string_for_js('nomorefiles', 'repository');
|
||||
$PAGE->requires->string_for_js('confirmdeletefile', 'repository');
|
||||
$PAGE->requires->string_for_js('add', 'repository');
|
||||
$PAGE->requires->string_for_js('accessiblefilepicker', 'repository');
|
||||
$PAGE->requires->string_for_js('move', 'moodle');
|
||||
$PAGE->requires->string_for_js('cancel', 'moodle');
|
||||
$PAGE->requires->string_for_js('download', 'moodle');
|
||||
$PAGE->requires->string_for_js('ok', 'moodle');
|
||||
$PAGE->requires->string_for_js('emptylist', 'repository');
|
||||
$PAGE->requires->string_for_js('entername', 'repository');
|
||||
$PAGE->requires->string_for_js('enternewname', 'repository');
|
||||
$PAGE->requires->string_for_js('zip', 'editor');
|
||||
$PAGE->requires->string_for_js('unzip', 'moodle');
|
||||
$PAGE->requires->string_for_js('rename', 'moodle');
|
||||
$PAGE->requires->string_for_js('delete', 'moodle');
|
||||
$PAGE->requires->string_for_js('setmainfile', 'resource');
|
||||
$PAGE->requires->string_for_js('cannotdeletefile', 'error');
|
||||
$PAGE->requires->string_for_js('confirmdeletefile', 'repository');
|
||||
$PAGE->requires->string_for_js('nopathselected', 'repository');
|
||||
$PAGE->requires->string_for_js('popupblockeddownload', 'repository');
|
||||
$PAGE->requires->string_for_js('draftareanofiles', 'repository');
|
||||
$PAGE->requires->string_for_js('path', 'moodle');
|
||||
$PAGE->requires->string_for_js('setmainfile', 'repository');
|
||||
// language strings
|
||||
$straddfile = get_string('add', 'repository') . '...';
|
||||
$strmakedir = get_string('makeafolder', 'moodle');
|
||||
$strdownload = get_string('downloadfolder', 'repository');
|
||||
|
||||
$client_id = $options->client_id;
|
||||
$itemid = $options->itemid;
|
||||
$filearea = !empty($options->filearea) ? $options->filearea : 'user_draft';
|
||||
|
||||
$html = '';
|
||||
if ($options->filecount == 0 || empty($options->filecount)) {
|
||||
$extra = ' style="display:none"';
|
||||
} else {
|
||||
$extra = '';
|
||||
}
|
||||
$icon_add_file = $OUTPUT->pix_icon('t/addfile', $straddfile).'';
|
||||
$icon_add_folder = $OUTPUT->pix_icon('t/adddir', $strmakedir).'';
|
||||
$icon_download = $OUTPUT->pix_icon('t/download', $strdownload).'';
|
||||
|
||||
$html .= <<<FMHTML
|
||||
<div id="filemanager-wrapper-{$client_id}" style="display:none">
|
||||
<div class="fm-breadcrumb" id="fm-path-{$client_id}"></div>
|
||||
<div class="filemanager-toolbar">
|
||||
<button id="btnadd-{$client_id}" onclick="return false">{$icon_add_file} $straddfile</button>
|
||||
<button id="btncrt-{$client_id}" onclick="return false">{$icon_add_folder} $strmakedir</button>
|
||||
<button id="btndwn-{$client_id}" onclick="return false" {$extra}>{$icon_download} $strdownload</button>
|
||||
</div>
|
||||
<div class="filemanager-container" id="filemanager-{$client_id}">
|
||||
<ul id="draftfiles-{$client_id}">
|
||||
<li>Loading...</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class='clearer'></div>
|
||||
FMHTML;
|
||||
// print out file entry template only one time
|
||||
if (empty($CFG->filemanagertemplateloaded)) {
|
||||
$CFG->filemanagertemplateloaded = true;
|
||||
$html .= <<<FMHTML
|
||||
<div id="fm-template" style="display:none"><div class="fm-file-menu">___action___</div> <div class="fm-file-name">___fullname___</div></div>
|
||||
FMHTML;
|
||||
}
|
||||
$filemanagerurl = "$CFG->wwwroot/repository/filepicker.php?filearea=$filearea&env=filemanager&action=embedded&itemid=$itemid&subdirs=/&maxbytes=$options->maxbytes&ctx_id=".$PAGE->context->id.'&course='.$PAGE->course->id;
|
||||
|
||||
$html .= <<<NONJS
|
||||
<div id="nonjs-filemanager-$client_id">
|
||||
<object type="text/html" data="$filemanagerurl" height="160" width="600" style="border:1px solid #000">Error</object>
|
||||
</div>
|
||||
NONJS;
|
||||
|
||||
$module = array('name'=>'form_filemanager', 'fullpath'=>'/lib/form/filemanager.js', 'requires' => array('core_filepicker', 'base', 'io', 'node', 'json', 'yui2-button', 'yui2-container', 'yui2-layout', 'yui2-menu', 'yui2-treeview'));
|
||||
$PAGE->requires->js_module($module);
|
||||
$PAGE->requires->js_init_call('M.form_filemanager.init', array($options), true, $module);
|
||||
|
||||
if ($return) {
|
||||
return $html;
|
||||
} else {
|
||||
echo $html;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust the list of allowed tags based on $CFG->allowobjectembed and user roles (admin)
|
||||
*
|
||||
|
@ -69,33 +69,6 @@ class data_field_file extends data_field_base {
|
||||
$itemid = file_get_unused_draft_itemid();
|
||||
}
|
||||
|
||||
$draftareainfo = file_get_draft_area_info($itemid);
|
||||
$filecount = $draftareainfo['filecount'];
|
||||
|
||||
|
||||
// create a unique id for filemanager
|
||||
$client_id = uniqid();
|
||||
|
||||
// parameters to filter repositories
|
||||
$params = new stdclass;
|
||||
$params->accepted_types = '*';
|
||||
$params->return_types = FILE_INTERNAL;
|
||||
$params->context = $PAGE->context;
|
||||
|
||||
// including repoisitory instances list
|
||||
$filepicker_options = initialise_filepicker($params);
|
||||
|
||||
// get existing files
|
||||
$filemanager_options = file_get_user_area_files($itemid);
|
||||
$filemanager_options->client_id = $client_id;
|
||||
$filemanager_options->filecount = $filecount;
|
||||
$filemanager_options->itemid = $itemid;
|
||||
$filemanager_options->subdirs = 0;
|
||||
$filemanager_options->maxbytes = $this->field->param3;
|
||||
$filemanager_options->maxfiles = 1;
|
||||
// store filepicker options
|
||||
$filemanager_options->filepicker = $filepicker_options;
|
||||
|
||||
$html = '';
|
||||
// database entry label
|
||||
$html .= '<div title="'.s($this->field->description).'">';
|
||||
@ -104,7 +77,16 @@ class data_field_file extends data_field_base {
|
||||
// itemid element
|
||||
$html .= '<input type="hidden" name="field_'.$this->field->id.'_file" value="'.$itemid.'" />';
|
||||
|
||||
$html .= print_filemanager($filemanager_options, true);
|
||||
$filemanager_options = new stdclass;
|
||||
$filemanager_options->maxbytes = $this->field->param3;
|
||||
$filemanager_options->maxfiles = 1;
|
||||
$filemanager_options->filearea = 'user_draft';
|
||||
$filemanager_options->itemid = $itemid;
|
||||
$filemanager_options->subdirs = 0;
|
||||
$filemanager_options->accepted_types = '*';
|
||||
$filemanager_options->return_types = FILE_INTERNAL;
|
||||
$filemanager_options->context = $PAGE->context;
|
||||
$html .= $OUTPUT->file_manager($filemanager_options);
|
||||
|
||||
$html .= '</fieldset>';
|
||||
$html .= '</div>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user