本文整理汇总了PHP中file_prepare_standard_filemanager函数的典型用法代码示例。如果您正苦于以下问题:PHP file_prepare_standard_filemanager函数的具体用法?PHP file_prepare_standard_filemanager怎么用?PHP file_prepare_standard_filemanager使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_prepare_standard_filemanager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
/**
* Define this form - called by the parent constructor
*/
public function definition()
{
global $COURSE, $USER;
$mform = $this->_form;
$params = $this->_customdata;
$mform->addElement('header', 'batchuploadfilesforusers', get_string('batchuploadfilesforusers', 'setaskfeedback_file', count($params['users'])));
$mform->addElement('static', 'userslist', get_string('selectedusers', 'setaskfeedback_file'), $params['usershtml']);
$data = new stdClass();
$fileoptions = array('subdirs' => 1, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
$data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $params['context'], 'setaskfeedback_file', ASSIGNFEEDBACK_FILE_BATCH_FILEAREA, $USER->id);
$mform->addElement('filemanager', 'files_filemanager', '', null, $fileoptions);
$this->set_data($data);
$mform->addElement('hidden', 'id', $params['cm']);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'operation', 'plugingradingbatchoperation_file_uploadfiles');
$mform->setType('operation', PARAM_ALPHAEXT);
$mform->addElement('hidden', 'action', 'viewpluginpage');
$mform->setType('action', PARAM_ALPHA);
$mform->addElement('hidden', 'pluginaction', 'uploadfiles');
$mform->setType('pluginaction', PARAM_ALPHA);
$mform->addElement('hidden', 'plugin', 'file');
$mform->setType('plugin', PARAM_PLUGIN);
$mform->addElement('hidden', 'pluginsubtype', 'setaskfeedback');
$mform->setType('pluginsubtype', PARAM_PLUGIN);
$mform->addElement('hidden', 'selectedusers', implode(',', $params['users']));
$mform->setType('selectedusers', PARAM_SEQUENCE);
$this->add_action_buttons(true, get_string('uploadfiles', 'setaskfeedback_file'));
}
示例2: get_form_elements
/**
* Get form elements for grading form
*
* @param stdClass $grade
* @param MoodleQuickForm $mform
* @param stdClass $data
* @return bool true if elements were added to the form
*/
public function get_form_elements($grade, MoodleQuickForm $mform, stdClass $data)
{
$fileoptions = $this->get_file_options();
$gradeid = $grade ? $grade->id : 0;
$data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $this->assignment->get_context(), 'assignfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $gradeid);
$mform->addElement('filemanager', 'files_filemanager', '', null, $fileoptions);
return true;
}
示例3: get_string
}
$title = get_string('editfiles', 'wiki');
$struser = get_string('user');
$url = new moodle_url('/mod/wiki/filesedit.php', array('subwiki' => $subwiki->id, 'pageid' => $pageid));
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_title($title);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(format_string(get_string('wikifiles', 'wiki')), $CFG->wwwroot . '/mod/wiki/files.php?pageid=' . $pageid);
$PAGE->navbar->add(format_string($title));
$data = new stdClass();
$data->returnurl = $returnurl;
$data->subwikiid = $subwiki->id;
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
$options = array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => -1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL | FILE_REFERENCE);
file_prepare_standard_filemanager($data, 'files', $options, $context, 'mod_wiki', 'attachments', $subwiki->id);
$mform = new mod_wiki_filesedit_form(null, array('data' => $data, 'options' => $options));
if ($mform->is_cancelled()) {
redirect($returnurl);
} else {
if ($formdata = $mform->get_data()) {
$formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_wiki', 'attachments', $subwiki->id);
redirect($returnurl);
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($wiki->name));
echo $OUTPUT->box(format_module_intro('wiki', $wiki, $PAGE->cm->id), 'generalbox', 'intro');
echo $OUTPUT->box_start('generalbox');
$mform->display();
echo $OUTPUT->box_end();
示例4: require_capability
}
} else {
// new entry
require_capability('mod/glossary:write', $context);
// note: guest user does not have any write capability
$entry = new stdClass();
$entry->id = null;
}
$maxfiles = 99;
// TODO: add some setting
$maxbytes = $course->maxbytes;
// TODO: add some setting
$definitionoptions = array('trusttext' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $context, 'subdirs' => file_area_contains_subdirs($context, 'mod_glossary', 'entry', $entry->id));
$attachmentoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
$entry = file_prepare_standard_editor($entry, 'definition', $definitionoptions, $context, 'mod_glossary', 'entry', $entry->id);
$entry = file_prepare_standard_filemanager($entry, 'attachment', $attachmentoptions, $context, 'mod_glossary', 'attachment', $entry->id);
$entry->cmid = $cm->id;
// create form and set initial data
$mform = new mod_glossary_entry_form(null, array('current' => $entry, 'cm' => $cm, 'glossary' => $glossary, 'definitionoptions' => $definitionoptions, 'attachmentoptions' => $attachmentoptions));
if ($mform->is_cancelled()) {
if ($id) {
redirect("view.php?id={$cm->id}&mode=entry&hook={$id}");
} else {
redirect("view.php?id={$cm->id}");
}
} else {
if ($entry = $mform->get_data()) {
$timenow = time();
$categories = empty($entry->categories) ? array() : $entry->categories;
unset($entry->categories);
$aliases = trim($entry->aliases);
示例5: file_prepare_standard_filemanager
file_prepare_standard_filemanager($course, 'overviewfiles', $overviewfilesoptions, $coursecontext, 'course', 'overviewfiles', 0);
}
// Inject current aliases.
$aliases = $DB->get_records('role_names', array('contextid' => $coursecontext->id));
foreach ($aliases as $alias) {
$course->{'role_' . $alias->roleid} = $alias->name;
}
// Populate course tags.
$course->tags = core_tag_tag::get_item_tags_array('core', 'course', $course->id);
} else {
// Editor should respect category context if course context is not set.
$editoroptions['context'] = $catcontext;
$editoroptions['subdirs'] = 0;
$course = file_prepare_standard_editor($course, 'summary', $editoroptions, null, 'course', 'summary', null);
if ($overviewfilesoptions) {
file_prepare_standard_filemanager($course, 'overviewfiles', $overviewfilesoptions, null, 'course', 'overviewfiles', 0);
}
}
// First create the form.
$args = array('course' => $course, 'category' => $category, 'editoroptions' => $editoroptions, 'returnto' => $returnto, 'returnurl' => $returnurl);
$editform = new course_edit_form(null, $args);
if ($editform->is_cancelled()) {
// The form has been cancelled, take them back to what ever the return to is.
redirect($returnurl);
} else {
if ($data = $editform->get_data()) {
// Process data if submitted.
if (empty($course->id)) {
// In creating the course.
$course = create_course($data, $editoroptions);
// Get the context of the newly created course.
示例6: redirect
echo $output->header();
echo $output->box(get_string('assessmentreferenceconflict', 'workshopplus'));
echo $output->continue_button($workshopplus->view_url());
echo $output->footer();
die;
}
redirect($workshopplus->exassess_url($asid));
}
if ($edit and $canmanage) {
require_once dirname(__FILE__) . '/submission_form.php';
$maxfiles = $workshopplus->nattachments;
$maxbytes = $workshopplus->maxbytes;
$contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $workshopplus->context);
$attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
$example = file_prepare_standard_editor($example, 'content', $contentopts, $workshopplus->context, 'mod_workshopplus', 'submission_content', $example->id);
$example = file_prepare_standard_filemanager($example, 'attachment', $attachmentopts, $workshopplus->context, 'mod_workshopplus', 'submission_attachment', $example->id);
$mform = new workshopplus_submission_form($PAGE->url, array('current' => $example, 'workshopplus' => $workshopplus, 'contentopts' => $contentopts, 'attachmentopts' => $attachmentopts));
if ($mform->is_cancelled()) {
redirect($workshopplus->view_url());
} elseif ($canmanage and $formdata = $mform->get_data()) {
if ($formdata->example == 1) {
// this was used just for validation, it must be set to one when dealing with example submissions
unset($formdata->example);
} else {
throw new coding_exception('Invalid submission form data value: example');
}
$timenow = time();
if (is_null($example->id)) {
$formdata->workshopplusid = $workshopplus->id;
$formdata->example = 1;
$formdata->authorid = $USER->id;
示例7: strip_tags
$PAGE->set_context($context);
$title = strip_tags($course->fullname . ': ' . get_string('modulename', 'assignment') . ': ' . format_string($assignment->name, true));
$PAGE->set_title($title);
$PAGE->set_heading($title);
$instance = new assignment_onlinejudge($cm->id, $assignment, $cm, $course);
$submission = $instance->get_submission($formdata->userid, true);
$filemanager_options = array('subdirs' => 1, 'maxbytes' => $assignment->maxbytes, 'maxfiles' => $assignment->var1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
$mform = new mod_assignment_upload_form(null, array('contextid' => $contextid, 'userid' => $formdata->userid, 'options' => $filemanager_options));
if ($mform->is_cancelled()) {
redirect(new moodle_url('/mod/assignment/view.php', array('id' => $cm->id)));
} else {
if ($formdata = $mform->get_data()) {
$instance->upload($mform, $filemanager_options);
die;
}
}
echo $OUTPUT->header();
echo $OUTPUT->box_start('generalbox');
if ($instance->can_upload_file($submission) && $id == null) {
$data = new stdClass();
// move submission files to user draft area
$data = file_prepare_standard_filemanager($data, 'files', $filemanager_options, $context, 'mod_assignment', 'submission', $submission->id);
// set file manager itemid, so it will find the files in draft area
$mform->set_data($data);
$mform->display();
} else {
echo $OUTPUT->notification(get_string('uploaderror', 'assignment'));
echo $OUTPUT->continue_button(new moodle_url('/mod/assignment/view.php', array('id' => $cm->id)));
}
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
示例8: redirect
}
if ($asid == workshop::ALLOCATION_EXISTS) {
// the training assessment of the example was not found but the allocation already
// exists. this probably means that the user is the author of the reference assessment.
echo $output->header();
echo $output->box(get_string('assessmentreferenceconflict', 'workshop'));
echo $output->continue_button($workshop->view_url());
echo $output->footer();
die;
}
redirect($workshop->exassess_url($asid));
}
if ($edit and $canmanage) {
require_once dirname(__FILE__) . '/submission_form.php';
$example = file_prepare_standard_editor($example, 'content', $workshop->submission_content_options(), $workshop->context, 'mod_workshop', 'submission_content', $example->id);
$example = file_prepare_standard_filemanager($example, 'attachment', $workshop->submission_attachment_options(), $workshop->context, 'mod_workshop', 'submission_attachment', $example->id);
$mform = new workshop_submission_form($PAGE->url, array('current' => $example, 'workshop' => $workshop, 'contentopts' => $workshop->submission_content_options(), 'attachmentopts' => $workshop->submission_attachment_options()));
if ($mform->is_cancelled()) {
redirect($workshop->view_url());
} elseif ($canmanage and $formdata = $mform->get_data()) {
if ($formdata->example == 1) {
// this was used just for validation, it must be set to one when dealing with example submissions
unset($formdata->example);
} else {
throw new coding_exception('Invalid submission form data value: example');
}
$timenow = time();
if (is_null($example->id)) {
$formdata->workshopid = $workshop->id;
$formdata->example = 1;
$formdata->authorid = $USER->id;
示例9: edit_load_user_data
/**
* during editing this prepares the file manager with the correct file reference
* @param object instance of the userdata for this form (course edit form)
*/
function edit_load_user_data(&$user)
{
global $DB;
//, $FILEPICKER_OPTIONS;
$options = filepicker_options();
//$dataid = $this->data;
//if (!empty($dataid)) {
if ($dataid = $DB->get_field('course_meta_info_data', 'id', array('courseid' => $this->courseid, 'fieldid' => $this->fieldid))) {
$user->{$this->inputname} = file_prepare_standard_filemanager($user, $this->inputname, $options, $options['context'], 'course_meta_customfield', 'course_meta_filemanager', $dataid);
}
}
示例10: get_form_elements_for_user
/**
* Get form elements for grading form.
*
* @param stdClass $grade
* @param MoodleQuickForm $mform
* @param stdClass $data
* @param int $userid The userid we are currently grading
* @return bool true if elements were added to the form
*/
public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdClass $data, $userid)
{
$fileoptions = $this->get_file_options();
$gradeid = $grade ? $grade->id : 0;
$elementname = 'files_' . $userid;
$data = file_prepare_standard_filemanager($data, $elementname, $fileoptions, $this->seplment->get_context(), 'seplfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $gradeid);
$mform->addElement('filemanager', $elementname . '_filemanager', $this->get_name(), null, $fileoptions);
return true;
}
示例11: get_form_elements_for_user
/**
* Get form elements for grading form.
*
* @param stdClass $grade
* @param MoodleQuickForm $mform
* @param stdClass $data
* @param int $userid The userid we are currently grading
* @return bool true if elements were added to the form
*/
public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdClass $data, $userid) {
$fileoptions = $this->get_file_options();
$gradeid = $grade ? $grade->id : 0;
$elementname = 'files_' . $userid;
$data = file_prepare_standard_filemanager($data,
$elementname,
$fileoptions,
$this->assignment->get_context(),
'assignfeedback_file',
ASSIGNFEEDBACK_FILE_FILEAREA,
$gradeid);
$mform->addElement('filemanager', $elementname . '_filemanager', html_writer::tag('span', $this->get_name(),
array('class' => 'accesshide')), null, $fileoptions);
return true;
}
示例12: get_form_elements
/**
* Add elements to submission form
*
* @param mixed $submission stdClass|null
* @param MoodleQuickForm $mform
* @param stdClass $data
* @return bool
*/
public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data)
{
global $DB;
if ($this->get_config('maxfilesubmissions') <= 0) {
return false;
}
$fileoptions = $this->get_file_options();
$submissionid = $submission ? $submission->id : 0;
$context = $this->assignment->get_context();
$fs = get_file_storage();
$coversheetfiles = $fs->get_area_files($context->id, 'assignsubmission_pdf', ASSIGNSUBMISSION_PDF_FA_COVERSHEET, false, '', false);
if ($coversheetfiles) {
$file = reset($coversheetfiles);
$fileurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename());
$filelink = html_writer::link($fileurl, $file->get_filename(), array('target' => '_blank'));
$mform->addElement('static', 'pdf_coversheet', '', get_string('coversheetnotice', 'assignsubmission_pdf') . ': ' . $filelink);
}
file_prepare_standard_filemanager($data, 'pdfs', $fileoptions, $this->assignment->get_context(), 'assignsubmission_pdf', ASSIGNSUBMISSION_PDF_FA_DRAFT, $submissionid);
$label = html_writer::tag('span', get_string('pdfsubmissions', 'assignsubmission_pdf'), array('class' => 'accesshide'));
$mform->addElement('filemanager', 'pdfs_filemanager', $label, null, $fileoptions);
if ($coversheetfiles) {
if ($templateid = $this->get_config('templateid')) {
$templateitems = $DB->get_records('assignsubmission_pdf_tmplit', array('templateid' => $templateid));
$templatedata = array();
if ($submissionid) {
if ($templatedata = $DB->get_field('assignsubmission_pdf', 'templatedata', array('submission' => $submissionid))) {
$templatedata = unserialize($templatedata);
}
}
foreach ($templateitems as $item) {
$elname = "pdf_template[{$item->id}]";
if ($item->type == 'shorttext') {
$mform->addElement('text', $elname, s($item->setting));
} else {
if ($item->type == 'text') {
$mform->addElement('textarea', $elname, s($item->setting));
} else {
continue;
}
}
$mform->setType($elname, PARAM_TEXT);
$mform->addRule($elname, null, 'required', null, 'client');
if (isset($templatedata[$item->id])) {
$mform->setDefault($elname, $templatedata[$item->id]);
}
}
}
}
return true;
}
示例13: redirect
echo $output->header();
echo $output->box(get_string('assessmentreferenceconflict', 'teamwork'));
echo $output->continue_button($teamwork->view_url());
echo $output->footer();
die;
}
redirect($teamwork->exassess_url($asid));
}
if ($edit and $canmanage) {
require_once dirname(__FILE__) . '/submission_form.php';
$maxfiles = $teamwork->nattachments;
$maxbytes = $teamwork->maxbytes;
$contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $teamwork->context);
$attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
$example = file_prepare_standard_editor($example, 'content', $contentopts, $teamwork->context, 'mod_teamwork', 'submission_content', $example->id);
$example = file_prepare_standard_filemanager($example, 'attachment', $attachmentopts, $teamwork->context, 'mod_teamwork', 'submission_attachment', $example->id);
$mform = new teamwork_submission_form($PAGE->url, array('current' => $example, 'teamwork' => $teamwork, 'contentopts' => $contentopts, 'attachmentopts' => $attachmentopts));
if ($mform->is_cancelled()) {
redirect($teamwork->view_url());
} elseif ($canmanage and $formdata = $mform->get_data()) {
if ($formdata->example == 1) {
// this was used just for validation, it must be set to one when dealing with example submissions
unset($formdata->example);
} else {
throw new coding_exception('Invalid submission form data value: example');
}
$timenow = time();
if (is_null($example->id)) {
$formdata->teamworkid = $teamwork->id;
$formdata->example = 1;
$formdata->authorid = $USER->id;
示例14: get_form_elements
/**
* Add elements to submission form
*
* @param mixed $submission stdClass|null
* @param MoodleQuickForm $mform
* @param stdClass $data
* @return bool
*/
public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data)
{
if ($this->get_config('maxfilesubmissions') <= 0) {
return false;
}
$fileoptions = $this->get_file_options();
$submissionid = $submission ? $submission->id : 0;
$data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $this->setaskment->get_context(), 'setasksubmission_file', ASSIGNSUBMISSION_FILE_FILEAREA, $submissionid);
$mform->addElement('filemanager', 'files_filemanager', $this->get_name(), null, $fileoptions);
return true;
}
示例15: array
$chapter = $DB->get_record('giportfolio_userchapters', array('id' => $chapterid, 'giportfolioid' => $giportfolio->id, 'iduser' => $USER->id), '*', MUST_EXIST);
}
// Chapter is hidden for students.
if ($chapter->hidden) {
require_capability('mod/giportfolio:viewhiddenchapters', $context);
}
giportfolio_add_fake_block($chapters, $chapter, $giportfolio, $cm, 0, 0);
// Add TOC.
$editoroptions = array('noclean' => true, 'subdirs' => true, 'maxfiles' => -1, 'maxbytes' => 0, 'context' => $context);
$attachmentoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
$contribution = null;
if ($contributionid) {
$contribution = $DB->get_record('giportfolio_contributions', array('id' => $contributionid, 'chapterid' => $chapterid, 'userid' => $USER->id), '*', MUST_EXIST);
$formdata = clone $contribution;
$formdata = file_prepare_standard_editor($formdata, 'content', $editoroptions, $context, 'mod_giportfolio', 'contribution', $formdata->id);
$formdata = file_prepare_standard_filemanager($formdata, 'attachment', $attachmentoptions, $context, 'mod_giportfolio', 'attachment', $formdata->id);
$formdata->contributionid = $formdata->id;
} else {
$formdata = new stdClass();
}
$formdata->id = $cm->id;
$formdata->chapterid = $chapter->id;
// Header and strings.
$PAGE->set_title(format_string($giportfolio->name));
$PAGE->add_body_class('mod_giportfolio');
$PAGE->set_heading(format_string($course->fullname));
$redir = new moodle_url('/mod/giportfolio/viewgiportfolio.php', array('id' => $cm->id, 'chapterid' => $chapter->id));
// Handle delete / show / hide actions.
if ($action) {
if (!$contribution) {
print_error('invalidcontributionid', 'giportfolio');