���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/edit_form.php.tar
���ѧ٧ѧ�
home3/cpr76684/public_html/Aem/blocks/tag_youtube/edit_form.php 0000644 00000005270 15152014770 0020261 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Form for editing tag_youtube block instances. * * @package block_tag_youtube * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Form for editing tag_youtube block instances. * * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_tag_youtube_edit_form extends block_edit_form { protected function specific_definition($mform) { global $OUTPUT; $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); $mform->addElement('text', 'config_title', get_string('configtitle', 'block_tag_youtube')); $mform->setType('config_title', PARAM_TEXT); $mform->addElement('text', 'config_numberofvideos', get_string('numberofvideos', 'block_tag_youtube'), array('size' => 5)); $mform->setType('config_numberofvideos', PARAM_INT); // Category setting. $categorychoices = ['0' => get_string('anycategory', 'block_tag_youtube')]; $hascategoryerror = false; $categoryerror = ''; try { // Get all video categories through an API call and add them to the category list. $categorychoices += $this->block->get_categories(); } catch (Exception $e) { $hascategoryerror = true; $categoryerror = $e->getMessage(); } $mform->addElement('select', 'config_category', get_string('category', 'block_tag_youtube'), $categorychoices); $mform->setDefault('config_category', 0); if ($hascategoryerror) { $notification = $OUTPUT->notification(get_string('categoryerror', 'block_tag_youtube', $categoryerror), 'error'); $mform->addElement('static', 'config_category_error', '', $notification); } $mform->addElement('text', 'config_playlist', get_string('includeonlyvideosfromplaylist', 'block_tag_youtube')); $mform->setType('config_playlist', PARAM_ALPHANUM); } } home3/cpr76684/public_html/Aem/blog/edit_form.php 0000644 00000017751 15152076137 0015414 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); // It must be included from a Moodle page. } require_once($CFG->libdir.'/formslib.php'); class blog_edit_form extends moodleform { public $modnames = array(); /** * Blog form definition. */ public function definition() { global $CFG, $DB; $mform =& $this->_form; $entry = $this->_customdata['entry']; $courseid = $this->_customdata['courseid']; $modid = $this->_customdata['modid']; $summaryoptions = $this->_customdata['summaryoptions']; $attachmentoptions = $this->_customdata['attachmentoptions']; $sitecontext = $this->_customdata['sitecontext']; $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'subject', get_string('entrytitle', 'blog'), array('size' => 60, 'maxlength' => 128)); $mform->addElement('editor', 'summary_editor', get_string('entrybody', 'blog'), null, $summaryoptions); $mform->setType('subject', PARAM_TEXT); $mform->addRule('subject', get_string('emptytitle', 'blog'), 'required', null, 'client'); $mform->addRule('subject', get_string('maximumchars', '', 128), 'maxlength', 128, 'client'); $mform->setType('summary_editor', PARAM_RAW); $mform->addRule('summary_editor', get_string('emptybody', 'blog'), 'required', null, 'client'); $mform->addElement('filemanager', 'attachment_filemanager', get_string('attachment', 'forum'), null, $attachmentoptions); // Disable publishstate options that are not allowed. $publishstates = array(); $i = 0; foreach (blog_entry::get_applicable_publish_states() as $state => $desc) { $publishstates[$state] = $desc; // No maximum was set. $i++; } $mform->addElement('select', 'publishstate', get_string('publishto', 'blog'), $publishstates); $mform->addHelpButton('publishstate', 'publishto', 'blog'); $mform->setDefault('publishstate', 'site'); if (core_tag_tag::is_enabled('core', 'post')) { $mform->addElement('header', 'tagshdr', get_string('tags', 'tag')); } $mform->addElement('tags', 'tags', get_string('tags'), array('itemtype' => 'post', 'component' => 'core')); $allmodnames = array(); if (!empty($CFG->useblogassociations)) { if ((!empty($entry->courseassoc) || (!empty($courseid) && empty($modid)))) { if (!empty($courseid)) { $course = $DB->get_record('course', array('id' => $courseid)); $context = context_course::instance($courseid); $a = new stdClass(); $a->coursename = format_string($course->fullname, true, array('context' => $context)); $contextid = $context->id; } else { $context = context::instance_by_id($entry->courseassoc); $sql = 'SELECT fullname FROM {course} cr LEFT JOIN {context} ct ON ct.instanceid = cr.id WHERE ct.id = ?'; $a = new stdClass(); $a->coursename = $DB->get_field_sql($sql, array($entry->courseassoc)); $contextid = $entry->courseassoc; } $mform->addElement('header', 'assochdr', get_string('associations', 'blog')); $mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid)); $mform->setDefault('courseassoc', $contextid); } else if ((!empty($entry->modassoc) || !empty($modid))) { if (!empty($modid)) { $mod = get_coursemodule_from_id(false, $modid); $a = new stdClass(); $a->modtype = get_string('modulename', $mod->modname); $a->modname = $mod->name; $context = context_module::instance($modid); } else { $context = context::instance_by_id($entry->modassoc); $cm = $DB->get_record('course_modules', array('id' => $context->instanceid)); $a = new stdClass(); $a->modtype = $DB->get_field('modules', 'name', array('id' => $cm->module)); $a->modname = $DB->get_field($a->modtype, 'name', array('id' => $cm->instance)); $modid = $context->instanceid; } $mform->addElement('header', 'assochdr', get_string('associations', 'blog')); $mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id)); $mform->setDefault('modassoc', $context->id); } } $this->add_action_buttons(); $mform->addElement('hidden', 'action'); $mform->setType('action', PARAM_ALPHANUMEXT); $mform->setDefault('action', ''); $mform->addElement('hidden', 'entryid'); $mform->setType('entryid', PARAM_INT); $mform->setDefault('entryid', $entry->id); $mform->addElement('hidden', 'modid'); $mform->setType('modid', PARAM_INT); $mform->setDefault('modid', $modid); $mform->addElement('hidden', 'courseid'); $mform->setType('courseid', PARAM_INT); $mform->setDefault('courseid', $courseid); } /** * Validate the blog form data. * @param array $data Data to be validated * @param array $files unused * @return array|bool */ public function validation($data, $files) { global $CFG, $DB, $USER; $errors = parent::validation($data, $files); // Validate course association. if (!empty($data['courseassoc'])) { $coursecontext = context::instance_by_id($data['courseassoc']); if ($coursecontext->contextlevel != CONTEXT_COURSE) { $errors['courseassoc'] = get_string('error'); } } // Validate mod association. if (!empty($data['modassoc'])) { $modcontextid = $data['modassoc']; $modcontext = context::instance_by_id($modcontextid); if ($modcontext->contextlevel == CONTEXT_MODULE) { // Get context of the mod's course. $coursecontext = $modcontext->get_course_context(true); // Ensure only one course is associated. if (!empty($data['courseassoc'])) { if ($data['courseassoc'] != $coursecontext->id) { $errors['modassoc'] = get_string('onlyassociateonecourse', 'blog'); } } else { $data['courseassoc'] = $coursecontext->id; } } else { $errors['modassoc'] = get_string('error'); } } if ($errors) { return $errors; } return true; } } home3/cpr76684/public_html/Aem/mod/book/edit_form.php 0000644 00000006727 15152114103 0016165 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Chapter edit form * * @package mod_book * @copyright 2004-2010 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir.'/formslib.php'); class book_chapter_edit_form extends moodleform { function definition() { global $CFG; $chapter = $this->_customdata['chapter']; $options = $this->_customdata['options']; // Disabled subchapter option when editing first node. $disabledmsg = null; if ($chapter->pagenum == 1) { $disabledmsg = get_string('subchapternotice', 'book'); } $mform = $this->_form; if (!empty($chapter->id)) { $mform->addElement('header', 'general', get_string('editingchapter', 'mod_book')); } else { $mform->addElement('header', 'general', get_string('addafter', 'mod_book')); } if (isset($chapter->currentchaptertitle)) { $mform->addElement('static', 'details', get_string('previouschapter', 'mod_book'), trim(format_string($chapter->currentchaptertitle, true)) ); } $mform->addElement('text', 'title', get_string('chaptertitle', 'mod_book'), ['size' => '30', 'maxlength' => '255']); $mform->setType('title', PARAM_RAW); $mform->addRule('title', null, 'required', null, 'client'); $mform->addRule('title', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addElement('advcheckbox', 'subchapter', get_string('subchapter', 'mod_book'), $disabledmsg); $mform->addElement('editor', 'content_editor', get_string('content', 'mod_book'), null, $options); $mform->setType('content_editor', PARAM_RAW); $mform->addRule('content_editor', get_string('required'), 'required', null, 'client'); if (core_tag_tag::is_enabled('mod_book', 'book_chapters')) { $mform->addElement('header', 'tagshdr', get_string('tags', 'tag')); } $mform->addElement('tags', 'tags', get_string('tags'), array('itemtype' => 'book_chapters', 'component' => 'mod_book')); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'cmid'); $mform->setType('cmid', PARAM_INT); $mform->addElement('hidden', 'pagenum'); $mform->setType('pagenum', PARAM_INT); $this->add_action_buttons(true); // set the defaults $this->set_data($chapter); } function definition_after_data(){ $mform = $this->_form; $pagenum = $mform->getElement('pagenum'); if ($pagenum->getValue() == 1) { $mform->hardFreeze('subchapter'); } } } home3/cpr76684/public_html/Aem/course/edit_form.php 0000644 00000060155 15152170176 0015763 0 ustar 00 <?php defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir.'/formslib.php'); require_once($CFG->libdir.'/completionlib.php'); /** * The form for handling editing a course. */ class course_edit_form extends moodleform { protected $course; protected $context; /** * Form definition. */ function definition() { global $CFG, $PAGE; $mform = $this->_form; $PAGE->requires->js_call_amd('core_course/formatchooser', 'init'); $course = $this->_customdata['course']; // this contains the data of this form $category = $this->_customdata['category']; $editoroptions = $this->_customdata['editoroptions']; $returnto = $this->_customdata['returnto']; $returnurl = $this->_customdata['returnurl']; $systemcontext = context_system::instance(); $categorycontext = context_coursecat::instance($category->id); if (!empty($course->id)) { $coursecontext = context_course::instance($course->id); $context = $coursecontext; } else { $coursecontext = null; $context = $categorycontext; } $courseconfig = get_config('moodlecourse'); $this->course = $course; $this->context = $context; // Form definition with new course defaults. $mform->addElement('header','general', get_string('general', 'form')); $mform->addElement('hidden', 'returnto', null); $mform->setType('returnto', PARAM_ALPHANUM); $mform->setConstant('returnto', $returnto); $mform->addElement('hidden', 'returnurl', null); $mform->setType('returnurl', PARAM_LOCALURL); $mform->setConstant('returnurl', $returnurl); $mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="50"'); $mform->addHelpButton('fullname', 'fullnamecourse'); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_TEXT); if (!empty($course->id) and !has_capability('moodle/course:changefullname', $coursecontext)) { $mform->hardFreeze('fullname'); $mform->setConstant('fullname', $course->fullname); } $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"'); $mform->addHelpButton('shortname', 'shortnamecourse'); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_TEXT); if (!empty($course->id) and !has_capability('moodle/course:changeshortname', $coursecontext)) { $mform->hardFreeze('shortname'); $mform->setConstant('shortname', $course->shortname); } // Verify permissions to change course category or keep current. if (empty($course->id)) { if (has_capability('moodle/course:create', $categorycontext)) { $displaylist = core_course_category::make_categories_list('moodle/course:create'); $mform->addElement('autocomplete', 'category', get_string('coursecategory'), $displaylist); $mform->addRule('category', null, 'required', null, 'client'); $mform->addHelpButton('category', 'coursecategory'); $mform->setDefault('category', $category->id); } else { $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $category->id); } } else { if (has_capability('moodle/course:changecategory', $coursecontext)) { $displaylist = core_course_category::make_categories_list('moodle/course:changecategory'); if (!isset($displaylist[$course->category])) { //always keep current $displaylist[$course->category] = core_course_category::get($course->category, MUST_EXIST, true) ->get_formatted_name(); } $mform->addElement('autocomplete', 'category', get_string('coursecategory'), $displaylist); $mform->addRule('category', null, 'required', null, 'client'); $mform->addHelpButton('category', 'coursecategory'); } else { //keep current $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $course->category); } } $choices = array(); $choices['0'] = get_string('hide'); $choices['1'] = get_string('show'); $mform->addElement('select', 'visible', get_string('coursevisibility'), $choices); $mform->addHelpButton('visible', 'coursevisibility'); $mform->setDefault('visible', $courseconfig->visible); if (!empty($course->id)) { if (!has_capability('moodle/course:visibility', $coursecontext)) { $mform->hardFreeze('visible'); $mform->setConstant('visible', $course->visible); } } else { if (!guess_if_creator_will_have_course_capability('moodle/course:visibility', $categorycontext)) { $mform->hardFreeze('visible'); $mform->setConstant('visible', $courseconfig->visible); } } // Download course content. if ($CFG->downloadcoursecontentallowed) { $downloadchoices = [ DOWNLOAD_COURSE_CONTENT_DISABLED => get_string('no'), DOWNLOAD_COURSE_CONTENT_ENABLED => get_string('yes'), ]; $sitedefaultstring = $downloadchoices[$courseconfig->downloadcontentsitedefault]; $downloadchoices[DOWNLOAD_COURSE_CONTENT_SITE_DEFAULT] = get_string('sitedefaultspecified', '', $sitedefaultstring); $downloadselectdefault = $courseconfig->downloadcontent ?? DOWNLOAD_COURSE_CONTENT_SITE_DEFAULT; $mform->addElement('select', 'downloadcontent', get_string('enabledownloadcoursecontent', 'course'), $downloadchoices); $mform->addHelpButton('downloadcontent', 'downloadcoursecontent', 'course'); $mform->setDefault('downloadcontent', $downloadselectdefault); if ((!empty($course->id) && !has_capability('moodle/course:configuredownloadcontent', $coursecontext)) || (empty($course->id) && !guess_if_creator_will_have_course_capability('moodle/course:configuredownloadcontent', $categorycontext))) { $mform->hardFreeze('downloadcontent'); $mform->setConstant('downloadcontent', $downloadselectdefault); } } $mform->addElement('date_time_selector', 'startdate', get_string('startdate')); $mform->addHelpButton('startdate', 'startdate'); $date = (new DateTime())->setTimestamp(usergetmidnight(time())); $date->modify('+1 day'); $mform->setDefault('startdate', $date->getTimestamp()); $mform->addElement('date_time_selector', 'enddate', get_string('enddate'), array('optional' => true)); $mform->addHelpButton('enddate', 'enddate'); if (!empty($CFG->enablecourserelativedates)) { $attributes = [ 'aria-describedby' => 'relativedatesmode_warning' ]; if (!empty($course->id)) { $attributes['disabled'] = true; } $relativeoptions = [ 0 => get_string('no'), 1 => get_string('yes'), ]; $relativedatesmodegroup = []; $relativedatesmodegroup[] = $mform->createElement('select', 'relativedatesmode', get_string('relativedatesmode'), $relativeoptions, $attributes); $relativedatesmodegroup[] = $mform->createElement('html', html_writer::span(get_string('relativedatesmode_warning'), '', ['id' => 'relativedatesmode_warning'])); $mform->addGroup($relativedatesmodegroup, 'relativedatesmodegroup', get_string('relativedatesmode'), null, false); $mform->addHelpButton('relativedatesmodegroup', 'relativedatesmode'); } $mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100" size="10"'); $mform->addHelpButton('idnumber', 'idnumbercourse'); $mform->setType('idnumber', PARAM_RAW); if (!empty($course->id) and !has_capability('moodle/course:changeidnumber', $coursecontext)) { $mform->hardFreeze('idnumber'); $mform->setConstants('idnumber', $course->idnumber); } // Description. $mform->addElement('header', 'descriptionhdr', get_string('description')); $mform->setExpanded('descriptionhdr'); $mform->addElement('editor','summary_editor', get_string('coursesummary'), null, $editoroptions); $mform->addHelpButton('summary_editor', 'coursesummary'); $mform->setType('summary_editor', PARAM_RAW); $summaryfields = 'summary_editor'; if ($overviewfilesoptions = course_overviewfiles_options($course)) { $mform->addElement('filemanager', 'overviewfiles_filemanager', get_string('courseoverviewfiles'), null, $overviewfilesoptions); $mform->addHelpButton('overviewfiles_filemanager', 'courseoverviewfiles'); $summaryfields .= ',overviewfiles_filemanager'; } if (!empty($course->id) and !has_capability('moodle/course:changesummary', $coursecontext)) { // Remove the description header it does not contain anything any more. $mform->removeElement('descriptionhdr'); $mform->hardFreeze($summaryfields); } // Course format. $mform->addElement('header', 'courseformathdr', get_string('type_format', 'plugin')); $courseformats = get_sorted_course_formats(true); $formcourseformats = array(); foreach ($courseformats as $courseformat) { $formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat"); } if (isset($course->format)) { $course->format = course_get_format($course)->get_format(); // replace with default if not found if (!in_array($course->format, $courseformats)) { // this format is disabled. Still display it in the dropdown $formcourseformats[$course->format] = get_string('withdisablednote', 'moodle', get_string('pluginname', 'format_'.$course->format)); } } $mform->addElement('select', 'format', get_string('format'), $formcourseformats, [ 'data-formatchooser-field' => 'selector', ]); $mform->addHelpButton('format', 'format'); $mform->setDefault('format', $courseconfig->format); // Button to update format-specific options on format change (will be hidden by JavaScript). $mform->registerNoSubmitButton('updatecourseformat'); $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'), [ 'data-formatchooser-field' => 'updateButton', 'class' => 'd-none', ]); // Just a placeholder for the course format options. $mform->addElement('hidden', 'addcourseformatoptionshere'); $mform->setType('addcourseformatoptionshere', PARAM_BOOL); // Appearance. $mform->addElement('header', 'appearancehdr', get_string('appearance')); if (!empty($CFG->allowcoursethemes)) { $themeobjects = get_list_of_themes(); $themes=array(); $themes[''] = get_string('forceno'); foreach ($themeobjects as $key=>$theme) { if (empty($theme->hidefromselector)) { $themes[$key] = get_string('pluginname', 'theme_'.$theme->name); } } $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } if ((empty($course->id) && guess_if_creator_will_have_course_capability('moodle/course:setforcedlanguage', $categorycontext)) || (!empty($course->id) && has_capability('moodle/course:setforcedlanguage', $coursecontext))) { $languages = ['' => get_string('forceno')]; $languages += get_string_manager()->get_list_of_translations(); $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages); $mform->setDefault('lang', $courseconfig->lang); } // Multi-Calendar Support - see MDL-18375. $calendartypes = \core_calendar\type_factory::get_list_of_calendar_types(); // We do not want to show this option unless there is more than one calendar type to display. if (count($calendartypes) > 1) { $calendars = array(); $calendars[''] = get_string('forceno'); $calendars += $calendartypes; $mform->addElement('select', 'calendartype', get_string('forcecalendartype', 'calendar'), $calendars); } $options = range(0, 10); $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options); $courseconfig = get_config('moodlecourse'); $mform->setDefault('newsitems', $courseconfig->newsitems); $mform->addHelpButton('newsitems', 'newsitemsnumber'); $mform->addElement('selectyesno', 'showgrades', get_string('showgrades')); $mform->addHelpButton('showgrades', 'showgrades'); $mform->setDefault('showgrades', $courseconfig->showgrades); $mform->addElement('selectyesno', 'showreports', get_string('showreports')); $mform->addHelpButton('showreports', 'showreports'); $mform->setDefault('showreports', $courseconfig->showreports); // Show activity dates. $mform->addElement('selectyesno', 'showactivitydates', get_string('showactivitydates')); $mform->addHelpButton('showactivitydates', 'showactivitydates'); $mform->setDefault('showactivitydates', $courseconfig->showactivitydates); // Files and uploads. $mform->addElement('header', 'filehdr', get_string('filesanduploads')); if (!empty($course->legacyfiles) or !empty($CFG->legacyfilesinnewcourses)) { if (empty($course->legacyfiles)) { //0 or missing means no legacy files ever used in this course - new course or nobody turned on legacy files yet $choices = array('0'=>get_string('no'), '2'=>get_string('yes')); } else { $choices = array('1'=>get_string('no'), '2'=>get_string('yes')); } $mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices); $mform->addHelpButton('legacyfiles', 'courselegacyfiles'); if (!isset($courseconfig->legacyfiles)) { // in case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses $courseconfig->legacyfiles = 0; } $mform->setDefault('legacyfiles', $courseconfig->legacyfiles); } // Handle non-existing $course->maxbytes on course creation. $coursemaxbytes = !isset($course->maxbytes) ? null : $course->maxbytes; // Let's prepare the maxbytes popup. $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $coursemaxbytes); $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices); $mform->addHelpButton('maxbytes', 'maximumupload'); $mform->setDefault('maxbytes', $courseconfig->maxbytes); // Completion tracking. if (completion_info::is_enabled_for_site()) { $mform->addElement('header', 'completionhdr', get_string('completion', 'completion')); $mform->addElement('selectyesno', 'enablecompletion', get_string('enablecompletion', 'completion')); $mform->setDefault('enablecompletion', $courseconfig->enablecompletion); $mform->addHelpButton('enablecompletion', 'enablecompletion', 'completion'); $showcompletionconditions = $courseconfig->showcompletionconditions ?? COMPLETION_SHOW_CONDITIONS; $mform->addElement('selectyesno', 'showcompletionconditions', get_string('showcompletionconditions', 'completion')); $mform->addHelpButton('showcompletionconditions', 'showcompletionconditions', 'completion'); $mform->setDefault('showcompletionconditions', $showcompletionconditions); $mform->hideIf('showcompletionconditions', 'enablecompletion', 'eq', COMPLETION_DISABLED); } else { $mform->addElement('hidden', 'enablecompletion'); $mform->setType('enablecompletion', PARAM_INT); $mform->setDefault('enablecompletion', 0); } enrol_course_edit_form($mform, $course, $context); $mform->addElement('header','groups', get_string('groupsettingsheader', 'group')); $choices = array(); $choices[NOGROUPS] = get_string('groupsnone', 'group'); $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group'); $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group'); $mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $choices); $mform->addHelpButton('groupmode', 'groupmode', 'group'); $mform->setDefault('groupmode', $courseconfig->groupmode); $mform->addElement('selectyesno', 'groupmodeforce', get_string('groupmodeforce', 'group')); $mform->addHelpButton('groupmodeforce', 'groupmodeforce', 'group'); $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce); //default groupings selector $options = array(); $options[0] = get_string('none'); $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options); if ((empty($course->id) && guess_if_creator_will_have_course_capability('moodle/course:renameroles', $categorycontext)) || (!empty($course->id) && has_capability('moodle/course:renameroles', $coursecontext))) { // Customizable role names in this course. $mform->addElement('header', 'rolerenaming', get_string('rolerenaming')); $mform->addHelpButton('rolerenaming', 'rolerenaming'); if ($roles = get_all_roles()) { $roles = role_fix_names($roles, null, ROLENAME_ORIGINAL); $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE); foreach ($roles as $role) { $mform->addElement('text', 'role_' . $role->id, get_string('yourwordforx', '', $role->localname)); $mform->setType('role_' . $role->id, PARAM_TEXT); } } } if (core_tag_tag::is_enabled('core', 'course') && ((empty($course->id) && guess_if_creator_will_have_course_capability('moodle/course:tag', $categorycontext)) || (!empty($course->id) && has_capability('moodle/course:tag', $coursecontext)))) { $mform->addElement('header', 'tagshdr', get_string('tags', 'tag')); $mform->addElement('tags', 'tags', get_string('tags'), array('itemtype' => 'course', 'component' => 'core')); } // Add custom fields to the form. $handler = core_course\customfield\course_handler::create(); $handler->set_parent_context($categorycontext); // For course handler only. $handler->instance_form_definition($mform, empty($course->id) ? 0 : $course->id); // When two elements we need a group. $buttonarray = array(); $classarray = array('class' => 'form-submit'); if ($returnto !== 0) { $buttonarray[] = &$mform->createElement('submit', 'saveandreturn', get_string('savechangesandreturn'), $classarray); } $buttonarray[] = &$mform->createElement('submit', 'saveanddisplay', get_string('savechangesanddisplay'), $classarray); $buttonarray[] = &$mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); $mform->addElement('hidden', 'id', null); $mform->setType('id', PARAM_INT); // Prepare custom fields data. $handler->instance_form_before_set_data($course); // Finally set the current form data $this->set_data($course); } /** * Fill in the current page data for this course. */ function definition_after_data() { global $DB; $mform = $this->_form; // add available groupings $courseid = $mform->getElementValue('id'); if ($courseid and $mform->elementExists('defaultgroupingid')) { $options = array(); if ($groupings = $DB->get_records('groupings', array('courseid'=>$courseid))) { foreach ($groupings as $grouping) { $options[$grouping->id] = format_string($grouping->name); } } core_collator::asort($options); $gr_el =& $mform->getElement('defaultgroupingid'); $gr_el->load($options); } // add course format options $formatvalue = $mform->getElementValue('format'); if (is_array($formatvalue) && !empty($formatvalue)) { $params = array('format' => $formatvalue[0]); // Load the course as well if it is available, course formats may need it to work out // they preferred course end date. if ($courseid) { $params['id'] = $courseid; } $courseformat = course_get_format((object)$params); $elements = $courseformat->create_edit_form_elements($mform); for ($i = 0; $i < count($elements); $i++) { $mform->insertElementBefore($mform->removeElement($elements[$i]->getName(), false), 'addcourseformatoptionshere'); } // Remove newsitems element if format does not support news. if (!$courseformat->supports_news()) { $mform->removeElement('newsitems'); } } // Tweak the form with values provided by custom fields in use. $handler = core_course\customfield\course_handler::create(); $handler->instance_form_definition_after_data($mform, empty($courseid) ? 0 : $courseid); } /** * Validation. * * @param array $data * @param array $files * @return array the errors that were found */ function validation($data, $files) { global $DB; $errors = parent::validation($data, $files); // Add field validation check for duplicate shortname. if ($course = $DB->get_record('course', array('shortname' => $data['shortname']), '*', IGNORE_MULTIPLE)) { if (empty($data['id']) || $course->id != $data['id']) { $errors['shortname'] = get_string('shortnametaken', '', $course->fullname); } } // Add field validation check for duplicate idnumber. if (!empty($data['idnumber']) && (empty($data['id']) || $this->course->idnumber != $data['idnumber'])) { if ($course = $DB->get_record('course', array('idnumber' => $data['idnumber']), '*', IGNORE_MULTIPLE)) { if (empty($data['id']) || $course->id != $data['id']) { $errors['idnumber'] = get_string('courseidnumbertaken', 'error', $course->fullname); } } } if ($errorcode = course_validate_dates($data)) { $errors['enddate'] = get_string($errorcode, 'error'); } $errors = array_merge($errors, enrol_course_edit_validation($data, $this->context)); $courseformat = course_get_format((object)array('format' => $data['format'])); $formaterrors = $courseformat->edit_form_validation($data, $files, $errors); if (!empty($formaterrors) && is_array($formaterrors)) { $errors = array_merge($errors, $formaterrors); } // Add the custom fields validation. $handler = core_course\customfield\course_handler::create(); $errors = array_merge($errors, $handler->instance_form_validation($data, $files)); return $errors; } } home3/cpr76684/public_html/Aem/blocks/html/edit_form.php 0000644 00000007527 15152204737 0016711 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Form for editing HTML block instances. * * @package block_html * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Form for editing HTML block instances. * * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_html_edit_form extends block_edit_form { protected function specific_definition($mform) { global $CFG; // Fields for editing HTML block title and contents. $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); $mform->addElement('text', 'config_title', get_string('configtitle', 'block_html')); $mform->setType('config_title', PARAM_TEXT); $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean'=>true, 'context'=>$this->block->context); $mform->addElement('editor', 'config_text', get_string('configcontent', 'block_html'), null, $editoroptions); $mform->addRule('config_text', null, 'required', null, 'client'); $mform->setType('config_text', PARAM_RAW); // XSS is prevented when printing the block contents and serving files if (!empty($CFG->block_html_allowcssclasses)) { $mform->addElement('text', 'config_classes', get_string('configclasses', 'block_html')); $mform->setType('config_classes', PARAM_TEXT); $mform->addHelpButton('config_classes', 'configclasses', 'block_html'); } } function set_data($defaults) { if (!empty($this->block->config) && !empty($this->block->config->text)) { $text = $this->block->config->text; $draftid_editor = file_get_submitted_draft_itemid('config_text'); if (empty($text)) { $currenttext = ''; } else { $currenttext = $text; } $defaults->config_text['text'] = file_prepare_draft_area($draftid_editor, $this->block->context->id, 'block_html', 'content', 0, array('subdirs'=>true), $currenttext); $defaults->config_text['itemid'] = $draftid_editor; $defaults->config_text['format'] = $this->block->config->format ?? FORMAT_MOODLE; } else { $text = ''; } if (!$this->block->user_can_edit() && !empty($this->block->config->title)) { // If a title has been set but the user cannot edit it format it nicely $title = $this->block->config->title; $defaults->config_title = format_string($title, true, $this->page->context); // Remove the title from the config so that parent::set_data doesn't set it. unset($this->block->config->title); } // have to delete text here, otherwise parent::set_data will empty content // of editor unset($this->block->config->text); parent::set_data($defaults); // restore $text if (!isset($this->block->config)) { $this->block->config = new stdClass(); } $this->block->config->text = $text; if (isset($title)) { // Reset the preserved title $this->block->config->title = $title; } } } home3/cpr76684/public_html/Aem/blocks/edit_form.php 0000644 00000034421 15152220145 0015725 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Defines the base class form used by blocks/edit.php to edit block instance configuration. * * It works with the {@link block_edit_form} class, or rather the particular * subclass defined by this block, to do the editing. * * @package core_block * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page } require_once($CFG->libdir . '/formslib.php'); require_once($CFG->libdir . '/blocklib.php'); /** * The base class form used by blocks/edit.php to edit block instance configuration. * * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_edit_form extends moodleform { /** * The block instance we are editing. * @var block_base */ public $block; /** * The page we are editing this block in association with. * @var moodle_page */ public $page; /** * Defaults set in set_data() that need to be returned in get_data() if form elements were not created * @var array */ protected $defaults = []; function __construct($actionurl, $block, $page) { global $CFG; $this->block = $block; $this->page = $page; parent::__construct($actionurl); } function definition() { $mform =& $this->_form; // First show fields specific to this type of block. $this->specific_definition($mform); // Then show the fields about where this block appears. $mform->addElement('header', 'whereheader', get_string('wherethisblockappears', 'block')); // If the current weight of the block is out-of-range, add that option in. $blockweight = $this->block->instance->weight; $weightoptions = array(); if ($blockweight < -block_manager::MAX_WEIGHT) { $weightoptions[$blockweight] = $blockweight; } for ($i = -block_manager::MAX_WEIGHT; $i <= block_manager::MAX_WEIGHT; $i++) { $weightoptions[$i] = $i; } if ($blockweight > block_manager::MAX_WEIGHT) { $weightoptions[$blockweight] = $blockweight; } $first = reset($weightoptions); $weightoptions[$first] = get_string('bracketfirst', 'block', $first); $last = end($weightoptions); $weightoptions[$last] = get_string('bracketlast', 'block', $last); $regionoptions = $this->page->theme->get_all_block_regions(); foreach ($this->page->blocks->get_regions() as $region) { // Make sure to add all custom regions of this particular page too. if (!isset($regionoptions[$region])) { $regionoptions[$region] = $region; } } $parentcontext = context::instance_by_id($this->block->instance->parentcontextid); $mform->addElement('static', 'bui_homecontext', get_string('createdat', 'block'), $parentcontext->get_context_name()); $mform->addHelpButton('bui_homecontext', 'createdat', 'block'); // For pre-calculated (fixed) pagetype lists $pagetypelist = array(); // parse pagetype patterns $bits = explode('-', $this->page->pagetype); // First of all, check if we are editing blocks @ front-page or no and // make some dark magic if so (MDL-30340) because each page context // implies one (and only one) harcoded page-type that will be set later // when processing the form data at {@link block_manager::process_url_edit()} // Front page, show the page-contexts element and set $pagetypelist to 'any page' (*) // as unique option. Processign the form will do any change if needed if ($this->is_editing_the_frontpage()) { $contextoptions = array(); $contextoptions[BUI_CONTEXTS_FRONTPAGE_ONLY] = get_string('showonfrontpageonly', 'block'); $contextoptions[BUI_CONTEXTS_FRONTPAGE_SUBS] = get_string('showonfrontpageandsubs', 'block'); $contextoptions[BUI_CONTEXTS_ENTIRE_SITE] = get_string('showonentiresite', 'block'); $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); $mform->addHelpButton('bui_contexts', 'contexts', 'block'); $pagetypelist['*'] = '*'; // This is not going to be shown ever, it's an unique option // Any other system context block, hide the page-contexts element, // it's always system-wide BUI_CONTEXTS_ENTIRE_SITE } else if ($parentcontext->contextlevel == CONTEXT_SYSTEM) { } else if ($parentcontext->contextlevel == CONTEXT_COURSE) { // 0 means display on current context only, not child contexts // but if course managers select mod-* as pagetype patterns, block system will overwrite this option // to 1 (display on current context and child contexts) } else if ($parentcontext->contextlevel == CONTEXT_MODULE or $parentcontext->contextlevel == CONTEXT_USER) { // module context doesn't have child contexts, so display in current context only } else { $parentcontextname = $parentcontext->get_context_name(); $contextoptions[BUI_CONTEXTS_CURRENT] = get_string('showoncontextonly', 'block', $parentcontextname); $contextoptions[BUI_CONTEXTS_CURRENT_SUBS] = get_string('showoncontextandsubs', 'block', $parentcontextname); $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); } $mform->setType('bui_contexts', PARAM_INT); // Generate pagetype patterns by callbacks if necessary (has not been set specifically) if (empty($pagetypelist)) { $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context); $displaypagetypewarning = false; if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) { // Pushing block's existing page type pattern $pagetypestringname = 'page-'.str_replace('*', 'x', $this->block->instance->pagetypepattern); if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) { $pagetypelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype'); } else { //as a last resort we could put the page type pattern in the select box //however this causes mod-data-view to be added if the only option available is mod-data-* // so we are just showing a warning to users about their prev setting being reset $displaypagetypewarning = true; } } } // hide page type pattern select box if there is only one choice if (count($pagetypelist) > 1) { if ($displaypagetypewarning) { $mform->addElement('static', 'pagetypewarning', '', get_string('pagetypewarning','block')); } $mform->addElement('select', 'bui_pagetypepattern', get_string('restrictpagetypes', 'block'), $pagetypelist); } else { $values = array_keys($pagetypelist); $value = array_pop($values); // Now we are really hiding a lot (both page-contexts and page-type-patterns), // specially in some systemcontext pages having only one option (my/user...) // so, until it's decided if we are going to add the 'bring-back' pattern to // all those pages or no (see MDL-30574), we are going to show the unique // element statically // TODO: Revisit this once MDL-30574 has been decided and implemented, although // perhaps it's not bad to always show this statically when only one pattern is // available. if (!$this->is_editing_the_frontpage()) { // Try to beautify it $strvalue = $value; $strkey = 'page-'.str_replace('*', 'x', $strvalue); if (get_string_manager()->string_exists($strkey, 'pagetype')) { $strvalue = get_string($strkey, 'pagetype'); } // Show as static (hidden has been set already) $mform->addElement('static', 'bui_staticpagetypepattern', get_string('restrictpagetypes','block'), $strvalue); } } if ($this->page->subpage) { if ($parentcontext->contextlevel != CONTEXT_USER) { $subpageoptions = array( '%@NULL@%' => get_string('anypagematchingtheabove', 'block'), $this->page->subpage => get_string('thisspecificpage', 'block', $this->page->subpage), ); $mform->addElement('select', 'bui_subpagepattern', get_string('subpages', 'block'), $subpageoptions); } } $defaultregionoptions = $regionoptions; $defaultregion = $this->block->instance->defaultregion; if (!array_key_exists($defaultregion, $defaultregionoptions)) { $defaultregionoptions[$defaultregion] = $defaultregion; } $mform->addElement('select', 'bui_defaultregion', get_string('defaultregion', 'block'), $defaultregionoptions); $mform->addHelpButton('bui_defaultregion', 'defaultregion', 'block'); $mform->addElement('select', 'bui_defaultweight', get_string('defaultweight', 'block'), $weightoptions); $mform->addHelpButton('bui_defaultweight', 'defaultweight', 'block'); // Where this block is positioned on this page. $mform->addElement('header', 'onthispage', get_string('onthispage', 'block')); $mform->addElement('selectyesno', 'bui_visible', get_string('visible', 'block')); $blockregion = $this->block->instance->region; if (!array_key_exists($blockregion, $regionoptions)) { $regionoptions[$blockregion] = $blockregion; } $mform->addElement('select', 'bui_region', get_string('region', 'block'), $regionoptions); $mform->addElement('select', 'bui_weight', get_string('weight', 'block'), $weightoptions); $pagefields = array('bui_visible', 'bui_region', 'bui_weight'); if (!$this->block->user_can_edit()) { $mform->hardFreezeAllVisibleExcept($pagefields); } if (!$this->page->user_can_edit_blocks()) { $mform->hardFreeze($pagefields); } $this->add_action_buttons(); } /** * Returns true if the user is editing a frontpage. * @return bool */ public function is_editing_the_frontpage() { // There are some conditions to check related to contexts. $ctxconditions = $this->page->context->contextlevel == CONTEXT_COURSE && $this->page->context->instanceid == get_site()->id; $issiteindex = (strpos($this->page->pagetype, 'site-index') === 0); // So now we can be 100% sure if edition is happening at frontpage. return ($ctxconditions && $issiteindex); } function set_data($defaults) { // Prefix bui_ on all the core field names. $blockfields = array('showinsubcontexts', 'pagetypepattern', 'subpagepattern', 'parentcontextid', 'defaultregion', 'defaultweight', 'visible', 'region', 'weight'); foreach ($blockfields as $field) { $newname = 'bui_' . $field; $defaults->$newname = $defaults->$field; } // Copy block config into config_ fields. if (!empty($this->block->config)) { foreach ($this->block->config as $field => $value) { $configfield = 'config_' . $field; $defaults->$configfield = $value; } } // Munge ->subpagepattern becuase HTML selects don't play nicely with NULLs. if (empty($defaults->bui_subpagepattern)) { $defaults->bui_subpagepattern = '%@NULL@%'; } $systemcontext = context_system::instance(); if ($defaults->parentcontextid == $systemcontext->id) { $defaults->bui_contexts = BUI_CONTEXTS_ENTIRE_SITE; // System-wide and sticky } else { $defaults->bui_contexts = $defaults->bui_showinsubcontexts; } // Some fields may not be editable, remember the values here so we can return them in get_data(). $this->defaults = [ 'bui_parentcontextid' => $defaults->bui_parentcontextid, 'bui_contexts' => $defaults->bui_contexts, 'bui_pagetypepattern' => $defaults->bui_pagetypepattern, 'bui_subpagepattern' => $defaults->bui_subpagepattern, ]; parent::set_data($defaults); } /** * Override this to create any form fields specific to this type of block. * @param object $mform the form being built. */ protected function specific_definition($mform) { // By default, do nothing. } /** * Return submitted data if properly submitted or returns NULL if validation fails or * if there is no submitted data. * * @return object submitted data; NULL if not valid or not submitted or cancelled */ public function get_data() { if ($data = parent::get_data()) { // Blocklib expects 'bui_editingatfrontpage' property to be returned from this form. $data->bui_editingatfrontpage = $this->is_editing_the_frontpage(); // Some fields are non-editable and we need to populate them with the values from set_data(). return (object)((array)$data + $this->defaults); } return $data; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�