���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/forms.php.tar
���ѧ٧ѧ�
home3/cpr76684/public_html/Aem/lib/portfolio/forms.php 0000644 00000030173 15152003716 0016414 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/>. /** * This file contains all the form definitions used by the portfolio code. * * @package core_portfolio * @copyright 2008 Penny Leach <penny@catalyst.net.nz>, * Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); // make sure we include moodleform first! require_once ($CFG->libdir.'/formslib.php'); /** * During-export config form. * * This is the form that is actually used while exporting. * Plugins and callers don't get to define their own class * as we have to handle form elements from both places * See the docs here for more information: * http://docs.moodle.org/dev/Writing_a_Portfolio_Plugin#has_export_config * http://docs.moodle.org/dev/Adding_a_Portfolio_Button_to_a_page#has_export_config * * @package core_portfolio * @category portfolio * @copyright 2008 Penny Leach <penny@catalyst.net.nz> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ final class portfolio_export_form extends moodleform { /** * prepare form */ public function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'stage', PORTFOLIO_STAGE_CONFIG); $mform->addElement('hidden', 'id', $this->_customdata['id']); $mform->addElement('hidden', 'instance', $this->_customdata['instance']->get('id')); $mform->setType('instance', PARAM_INT); $mform->setType('stage', PARAM_INT); $mform->setType('id', PARAM_INT); if (array_key_exists('formats', $this->_customdata) && is_array($this->_customdata['formats'])) { if (count($this->_customdata['formats']) > 1) { $options = array(); foreach ($this->_customdata['formats'] as $key) { $options[$key] = get_string('format_' . $key, 'portfolio'); } $mform->addElement('select', 'format', get_string('availableformats', 'portfolio'), $options); } else { $f = array_shift($this->_customdata['formats']); $mform->addElement('hidden', 'format', $f); $mform->setType('format', PARAM_RAW); } } // only display the option to wait or not if it's applicable if (array_key_exists('expectedtime', $this->_customdata) && $this->_customdata['expectedtime'] != PORTFOLIO_TIME_LOW && $this->_customdata['expectedtime'] != PORTFOLIO_TIME_FORCEQUEUE) { $radioarray = array(); $radioarray[] = $mform->createElement('radio', 'wait', '', get_string('wait', 'portfolio'), 1); $radioarray[] = $mform->createElement('radio', 'wait', '', get_string('dontwait', 'portfolio'), 0); $mform->addGroup($radioarray, 'radioar', get_string('wanttowait_' . $this->_customdata['expectedtime'], 'portfolio') , array(' '), false); $mform->setDefault('wait', 0); } else { if ($this->_customdata['expectedtime'] == PORTFOLIO_TIME_LOW) { $mform->addElement('hidden', 'wait', 1); } else { $mform->addElement('hidden', 'wait', 0); } $mform->setType('wait', PARAM_INT); } if (array_key_exists('plugin', $this->_customdata) && is_object($this->_customdata['plugin'])) { $this->_customdata['plugin']->export_config_form($mform, $this->_customdata['userid']); } if (array_key_exists('caller', $this->_customdata) && is_object($this->_customdata['caller'])) { $this->_customdata['caller']->export_config_form($mform, $this->_customdata['instance'], $this->_customdata['userid']); } $this->add_action_buttons(true, get_string('next')); } /** * Validate portfolio export form * * @param stdClass $data portfolio information from form data * @return array */ public function validation($data, $files) { $errors = array(); if (array_key_exists('plugin', $this->_customdata) && is_object($this->_customdata['plugin'])) { $pluginerrors = $this->_customdata['plugin']->export_config_validation($data); if (is_array($pluginerrors)) { $errors = $pluginerrors; } } if (array_key_exists('caller', $this->_customdata) && is_object($this->_customdata['caller'])) { $callererrors = $this->_customdata['caller']->export_config_validation($data); if (is_array($callererrors)) { $errors = array_merge($errors, $callererrors); } } return $errors; } } /** * Admin config form. * * This form is extendable by plugins who want the admin to be able to configure more than just the name of the instance. * This is NOT done by subclassing this class, see the docs for portfolio_plugin_base for more information: * {@link http://docs.moodle.org/dev/Writing_a_Portfolio_Plugin#has_admin_config} * * @package core_portfolio * @category portfolio * @copyright 2008 Penny Leach <penny@catalyst.net.nz> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ final class portfolio_admin_form extends moodleform { /** @var object to hold porfolio instance configuration */ protected $instance; /** @var string plugin name*/ protected $plugin; /** @var string portfolio plugin name*/ protected $portfolio; /** @var string plugin availability*/ protected $action; /** @var int portfolio plugin visibility*/ protected $visible; /** * prepare form */ public function definition() { global $CFG; $this->plugin = $this->_customdata['plugin']; $this->instance = (isset($this->_customdata['instance']) && is_subclass_of($this->_customdata['instance'], 'portfolio_plugin_base')) ? $this->_customdata['instance'] : null; $this->portfolio = $this->_customdata['portfolio']; $this->action = $this->_customdata['action']; $this->visible = $this->_customdata['visible']; $mform =& $this->_form; $strrequired = get_string('required'); $mform->addElement('hidden', 'pf', $this->portfolio); $mform->setType('pf', PARAM_ALPHA); $mform->addElement('hidden', 'action', $this->action); $mform->setType('action', PARAM_ALPHA); $mform->addElement('hidden', 'visible', $this->visible); $mform->setType('visible', PARAM_INT); $mform->addElement('hidden', 'plugin', $this->plugin); $mform->setType('plugin', PARAM_PLUGIN); if (!$this->instance) { $insane = portfolio_instance_sanity_check($this->instance); } else { $insane = portfolio_plugin_sanity_check($this->plugin); } if (isset($insane) && is_array($insane)) { $insane = array_shift($insane); } if (isset($insane) && is_string($insane)) { // something went wrong, warn... $mform->addElement('warning', 'insane', null, get_string($insane, 'portfolio_' . $this->plugin)); } $mform->addElement('text', 'name', get_string('name'), 'maxlength="100" size="30"'); $mform->addRule('name', $strrequired, 'required', null, 'client'); $mform->setType('name', PARAM_TEXT); // let the plugin add the fields they want (either statically or not) if (portfolio_static_function($this->plugin, 'has_admin_config')) { require_once($CFG->libdir . '/portfolio/plugin.php'); require_once($CFG->dirroot . '/portfolio/' . $this->plugin . '/lib.php'); $classname = 'portfolio_plugin_' . $this->plugin; $classname::admin_config_form($mform); } // and set the data if we have some. if ($this->instance) { $data = array('name' => $this->instance->get('name')); foreach ($this->instance->get_allowed_config() as $config) { $data[$config] = $this->instance->get_config($config); } $this->set_data($data); } else { $this->set_data(array('name' => portfolio_static_function($this->plugin, 'get_name'))); } $this->add_action_buttons(true, get_string('save', 'portfolio')); } /** * Validate admin config form * * @param stdObject $data form data * @return array */ public function validation($data, $files) { global $DB; $errors = array(); if ($DB->count_records('portfolio_instance', array('name' => $data['name'], 'plugin' => $data['plugin'])) > 1) { $errors = array('name' => get_string('err_uniquename', 'portfolio')); } $pluginerrors = array(); $pluginerrors = portfolio_static_function($this->plugin, 'admin_config_validation', $data); if (is_array($pluginerrors)) { $errors = array_merge($errors, $pluginerrors); } return $errors; } } /** * User config form. * * This is the form for letting the user configure an instance of a plugin. * In order to extend this, you don't subclass this in the plugin.. * see the docs in portfolio_plugin_base for more information: * {@link http://docs.moodle.org/dev/Writing_a_Portfolio_Plugin#has_user_config} * * @package core_portfolio * @category portfolio * @copyright 2008 Penny Leach <penny@catalyst.net.nz> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ final class portfolio_user_form extends moodleform { /** @var object user porfolio instance */ protected $instance; /** @var int hold user id */ protected $userid; /** * prepare form */ public function definition() { $this->instance = $this->_customdata['instance']; $this->userid = $this->_customdata['userid']; $this->_form->addElement('hidden', 'config', $this->instance->get('id')); $this->_form->setType('config', PARAM_INT); $this->instance->user_config_form($this->_form, $this->userid); $data = array(); foreach ($this->instance->get_allowed_user_config() as $config) { $data[$config] = $this->instance->get_user_config($config, $this->userid); } $this->set_data($data); $this->add_action_buttons(true, get_string('save', 'portfolio')); } /** * User user config form. * * @param stdClass $data form data */ public function validation($data, $files) { $errors = $this->instance->user_config_validation($data); } } /** * Form that just contains the dropdown menu of available instances. * * This is not used by portfolio_add_button, but on the first step of the export, * if the plugin instance has not yet been selected. * * @package core_portfolio * @category portfolio * @copyright 2008 Penny Leach <penny@catalyst.net.nz> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class portfolio_instance_select extends moodleform { /** @var portfolio_caller_base plugin instance */ private $caller; /** * The required basic elements to the form. */ function definition() { $this->caller = $this->_customdata['caller']; $options = $this->_customdata['options']; $mform =& $this->_form; $mform->addElement('select', 'instance', get_string('selectplugin', 'portfolio'), $options); $mform->addElement('hidden', 'id', $this->_customdata['id']); $mform->setType('id', PARAM_INT); $this->add_action_buttons(true, get_string('next')); } } home3/cpr76684/public_html/Aem/cache/forms.php 0000644 00000032667 15152356277 0014723 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/>. /** * Forms used for the administration and managemement of the cache setup. * * This file is part of Moodle's cache API, affectionately called MUC. * * @package core * @category cache * @copyright 2012 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/lib/formslib.php'); /** * Add store instance form. * * @package core * @category cache * @copyright 2012 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class cachestore_addinstance_form extends moodleform { /** * The definition of the add instance form */ protected final function definition() { $form = $this->_form; $store = $this->_customdata['store']; $plugin = $this->_customdata['plugin']; $locks = $this->_customdata['locks']; $form->addElement('hidden', 'plugin', $plugin); $form->setType('plugin', PARAM_PLUGIN); $form->addElement('hidden', 'editing', !empty($this->_customdata['store'])); $form->setType('editing', PARAM_BOOL); if (!$store) { $form->addElement('text', 'name', get_string('storename', 'cache')); $form->addHelpButton('name', 'storename', 'cache'); $form->addRule('name', get_string('required'), 'required'); $form->setType('name', PARAM_NOTAGS); } else { $form->addElement('hidden', 'name', $store); $form->addElement('static', 'name-value', get_string('storename', 'cache'), $store); $form->setType('name', PARAM_NOTAGS); } if (is_array($locks)) { $form->addElement('select', 'lock', get_string('locking', 'cache'), $locks); $form->addHelpButton('lock', 'locking', 'cache'); $form->setType('lock', PARAM_ALPHANUMEXT); } else { $form->addElement('hidden', 'lock', ''); $form->setType('lock', PARAM_ALPHANUMEXT); $form->addElement('static', 'lock-value', get_string('locking', 'cache'), '<em>'.get_string('nativelocking', 'cache').'</em>'); } if (method_exists($this, 'configuration_definition')) { $form->addElement('header', 'storeconfiguration', get_string('storeconfiguration', 'cache')); $this->configuration_definition(); } $this->add_action_buttons(); } /** * Validates the add instance form data * * @param array $data * @param array $files * @return array */ public function validation($data, $files) { $errors = parent::validation($data, $files); if (!array_key_exists('name', $errors)) { if (!preg_match('#^[a-zA-Z0-9\-_ ]+$#', $data['name'])) { $errors['name'] = get_string('storenameinvalid', 'cache'); } else if (empty($this->_customdata['store'])) { $stores = core_cache\administration_helper::get_store_instance_summaries(); if (array_key_exists($data['name'], $stores)) { $errors['name'] = get_string('storenamealreadyused', 'cache'); } } } if (method_exists($this, 'configuration_validation')) { $newerrors = $this->configuration_validation($data, $files, $errors); // We need to selectiviliy merge here foreach ($newerrors as $element => $error) { if (!array_key_exists($element, $errors)) { $errors[$element] = $error; } } } return $errors; } } /** * Form to set definition mappings * * @package core * @category cache * @copyright 2012 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class cache_definition_mappings_form extends moodleform { /** * The definition of the form */ protected final function definition() { global $OUTPUT; $definition = $this->_customdata['definition']; $form = $this->_form; list($component, $area) = explode('/', $definition, 2); list($currentstores, $storeoptions, $defaults) = core_cache\administration_helper::get_definition_store_options($component, $area); $storedata = core_cache\administration_helper::get_definition_summaries(); if ($storedata[$definition]['mode'] != cache_store::MODE_REQUEST) { if (isset($storedata[$definition]['canuselocalstore']) && $storedata[$definition]['canuselocalstore']) { $form->addElement('html', $OUTPUT->notification(get_string('localstorenotification', 'cache'), 'notifymessage')); } else { $form->addElement('html', $OUTPUT->notification(get_string('sharedstorenotification', 'cache'), 'notifymessage')); } } $form->addElement('hidden', 'definition', $definition); $form->setType('definition', PARAM_SAFEPATH); $form->addElement('hidden', 'action', 'editdefinitionmapping'); $form->setType('action', PARAM_ALPHA); $requiredoptions = max(3, count($currentstores)+1); $requiredoptions = min($requiredoptions, count($storeoptions)); $options = array('' => get_string('none')); foreach ($storeoptions as $option => $def) { $options[$option] = $option; if ($def['default']) { $options[$option] .= ' '.get_string('mappingdefault', 'cache'); } } for ($i = 0; $i < $requiredoptions; $i++) { $title = '...'; if ($i === 0) { $title = get_string('mappingprimary', 'cache'); } else if ($i === $requiredoptions-1) { $title = get_string('mappingfinal', 'cache'); } $form->addElement('select', 'mappings['.$i.']', $title, $options); } $i = 0; foreach ($currentstores as $store => $def) { $form->setDefault('mappings['.$i.']', $store); $i++; } if (!empty($defaults)) { $form->addElement('static', 'defaults', get_string('defaultmappings', 'cache'), html_writer::tag('strong', join(', ', $defaults))); $form->addHelpButton('defaults', 'defaultmappings', 'cache'); } $this->add_action_buttons(); } } /** * Form to set definition sharing option * * @package core * @category cache * @copyright 2013 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class cache_definition_sharing_form extends moodleform { /** * The definition of the form */ protected final function definition() { $definition = $this->_customdata['definition']; $sharingoptions = $this->_customdata['sharingoptions']; $form = $this->_form; $form->addElement('hidden', 'definition', $definition); $form->setType('definition', PARAM_SAFEPATH); $form->addElement('hidden', 'action', 'editdefinitionsharing'); $form->setType('action', PARAM_ALPHA); // We use a group here for validation. $count = 0; $group = array(); foreach ($sharingoptions as $value => $text) { $count++; $group[] = $form->createElement('checkbox', $value, null, $text); } $form->addGroup($group, 'sharing', get_string('sharing', 'cache'), '<br />'); $form->setType('sharing', PARAM_INT); $form->addElement('text', 'userinputsharingkey', get_string('userinputsharingkey', 'cache')); $form->addHelpButton('userinputsharingkey', 'userinputsharingkey', 'cache'); $form->disabledIf('userinputsharingkey', 'sharing['.cache_definition::SHARING_INPUT.']', 'notchecked'); $form->setType('userinputsharingkey', PARAM_ALPHANUMEXT); $values = array_keys($sharingoptions); if (in_array(cache_definition::SHARING_ALL, $values)) { // If you share with all thenthe other options don't really make sense. foreach ($values as $value) { $form->disabledIf('sharing['.$value.']', 'sharing['.cache_definition::SHARING_ALL.']', 'checked'); } $form->disabledIf('userinputsharingkey', 'sharing['.cache_definition::SHARING_ALL.']', 'checked'); } $this->add_action_buttons(); } /** * Sets the data for this form. * * @param array $data */ public function set_data($data) { if (!isset($data['sharing'])) { // Set the default value here. mforms doesn't handle defaults very nicely. $data['sharing'] = core_cache\administration_helper::get_definition_sharing_options(cache_definition::SHARING_DEFAULT); } parent::set_data($data); } /** * Validates this form * * @param array $data * @param array $files * @return array */ public function validation($data, $files) { $errors = parent::validation($data, $files); if (count($errors) === 0 && !isset($data['sharing'])) { // They must select at least one sharing option. $errors['sharing'] = get_string('sharingrequired', 'cache'); } return $errors; } } /** * Form to set the mappings for a mode. * * @package core * @category cache * @copyright 2012 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class cache_mode_mappings_form extends moodleform { /** * The definition of the form */ protected function definition() { $form = $this->_form; $stores = $this->_customdata; $options = array( cache_store::MODE_APPLICATION => array(), cache_store::MODE_SESSION => array(), cache_store::MODE_REQUEST => array() ); foreach ($stores as $storename => $store) { foreach ($store['modes'] as $mode => $enabled) { if ($enabled && ($mode !== cache_store::MODE_SESSION || $store['supports']['searchable'])) { if (empty($store['default'])) { $options[$mode][$storename] = $store['name']; } else { $options[$mode][$storename] = get_string('store_'.$store['name'], 'cache'); } } } } $form->addElement('hidden', 'action', 'editmodemappings'); $form->setType('action', PARAM_ALPHA); foreach ($options as $mode => $optionset) { $form->addElement('select', 'mode_'.$mode, get_string('mode_'.$mode, 'cache'), $optionset); } $this->add_action_buttons(); } } /** * Form to add a cache lock instance. * * All cache lock plugins that wish to have custom configuration should override * this form, and more explicitly the plugin_definition and plugin_validation methods. * * @package core * @category cache * @copyright 2013 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class cache_lock_form extends moodleform { /** * Defines this form. */ final public function definition() { $plugin = $this->_customdata['lock']; $this->_form->addElement('hidden', 'action', 'newlockinstance'); $this->_form->setType('action', PARAM_ALPHANUMEXT); $this->_form->addElement('hidden', 'lock', $plugin); $this->_form->setType('lock', PARAM_COMPONENT); $this->_form->addElement('text', 'name', get_string('lockname', 'cache')); $this->_form->setType('name', PARAM_ALPHANUMEXT); $this->_form->addRule('name', get_string('required'), 'required'); $this->_form->addElement('static', 'namedesc', '', get_string('locknamedesc', 'cache')); $this->plugin_definition(); $this->add_action_buttons(); } /** * Validates this form. * * @param array $data * @param array $files * @return array */ final public function validation($data, $files) { $errors = parent::validation($data, $files); if (!isset($errors['name'])) { $config = cache_config::instance(); if (in_array($data['name'], array_keys($config->get_locks()))) { $errors['name'] = get_string('locknamenotunique', 'cache'); } } $errors = $this->plugin_validation($data, $files, $errors); return $errors; } /** * Plugin specific definition. */ public function plugin_definition() { // No custom validation going on here. } /** * Plugin specific validation. * * @param array $data * @param array $files * @param array $errors * @return array */ public function plugin_validation($data, $files, array $errors) { return $errors; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�