* $fm = new form_filemanager($options);
* $output = get_renderer('core', 'files');
* echo $output->render($fm);
*
*
* @param form_filemanager $fm File manager to render
* @return string HTML fragment
*/
public function render_form_filemanager($fm) {
$html = $this->fm_print_generallayout($fm);
$module = array(
'name'=>'form_filemanager',
'fullpath'=>'/lib/form/filemanager.js',
'requires' => array('moodle-core-notification-dialogue', 'core_filepicker', 'base', 'io-base', 'node', 'json', 'core_dndupload', 'panel', 'resize-plugin', 'dd-plugin'),
'strings' => array(
array('error', 'moodle'), array('info', 'moodle'), array('confirmdeletefile', 'repository'),
array('draftareanofiles', 'repository'), array('entername', 'repository'), array('enternewname', 'repository'),
array('invalidjson', 'repository'), array('popupblockeddownload', 'repository'),
array('unknownoriginal', 'repository'), array('confirmdeletefolder', 'repository'),
array('confirmdeletefilewithhref', 'repository'), array('confirmrenamefolder', 'repository'),
array('confirmrenamefile', 'repository'), array('newfolder', 'repository'), array('edit', 'moodle'),
array('originalextensionchange', 'repository'), array('originalextensionremove', 'repository'),
array('aliaseschange', 'repository'), ['nofilesselected', 'repository'],
['confirmdeleteselectedfile', 'repository'], ['selectall', 'moodle'], ['deselectall', 'moodle'],
['selectallornone', 'form'],
)
);
if ($this->page->requires->should_create_one_time_item_now('core_file_managertemplate')) {
$this->page->requires->js_init_call('M.form_filemanager.set_templates',
array($this->filemanager_js_templates()), true, $module);
}
$this->page->requires->js_call_amd('core/checkbox-toggleall', 'init');
$this->page->requires->js_init_call('M.form_filemanager.init', array($fm->options), true, $module);
// non javascript file manager
$html .= '';
return $html;
}
/**
* Returns html for displaying one file manager
*
* @param form_filemanager $fm
* @return string
*/
protected function fm_print_generallayout($fm) {
$context = [
'client_id' => $fm->options->client_id,
'helpicon' => $this->help_icon('setmainfile', 'repository'),
'restrictions' => $this->fm_print_restrictions($fm)
];
return $this->render_from_template('core/filemanager_page_generallayout', $context);
}
/**
* FileManager JS template for displaying one file in 'icon view' mode.
*
* Except for elements described in fp_js_template_iconfilename, this template may also
* contain element with class 'fp-contextmenu'. If context menu is available for this
* file, the top element will receive the additional class 'fp-hascontextmenu' and
* the element with class 'fp-contextmenu' will hold onclick event for displaying
* the context menu.
*
* @see fp_js_template_iconfilename()
* @return string
*/
protected function fm_js_template_iconfilename() {
$rv = '
';
return $rv;
}
/**
* FileManager JS template for displaying file name in 'table view' and 'tree view' modes.
*
* Except for elements described in fp_js_template_listfilename, this template may also
* contain element with class 'fp-contextmenu'. If context menu is available for this
* file, the top element will receive the additional class 'fp-hascontextmenu' and
* the element with class 'fp-contextmenu' will hold onclick event for displaying
* the context menu.
*
* @todo MDL-32736 remove onclick="return false;"
* @see fp_js_template_listfilename()
* @return string
*/
protected function fm_js_template_listfilename() {
$rv = '
';
return $rv;
}
/**
* FileManager JS template for displaying 'Make new folder' dialog.
*
* Must be wrapped in an element, CSS for this element must define width and height of the window;
*
* Must have one input element with type="text" (for users to enter the new folder name);
*
* content of element with class 'fp-dlg-curpath' will be replaced with current path where
* new folder is about to be created;
* elements with classes 'fp-dlg-butcreate' and 'fp-dlg-butcancel' will hold onclick events;
*
* @return string
*/
protected function fm_js_template_mkdir() {
$rv = '