���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/field.class.php.tar
���ѧ٧ѧ�
home3/cpr76684/public_html/Aem/user/profile/field/menu/field.class.php 0000644 00000013302 15151265162 0021336 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/>. /** * Menu profile field. * * @package profilefield_menu * @copyright 2007 onwards Shane Elliot {@link http://pukunui.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Class profile_field_menu * * @copyright 2007 onwards Shane Elliot {@link http://pukunui.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class profile_field_menu extends profile_field_base { /** @var array $options */ public $options; /** @var int $datakey */ public $datakey; /** * Constructor method. * * Pulls out the options for the menu from the database and sets the the corresponding key for the data if it exists. * * @param int $fieldid * @param int $userid * @param object $fielddata */ public function __construct($fieldid = 0, $userid = 0, $fielddata = null) { // First call parent constructor. parent::__construct($fieldid, $userid, $fielddata); // Param 1 for menu type is the options. if (isset($this->field->param1)) { $options = explode("\n", $this->field->param1); } else { $options = array(); } $this->options = array(); if (!empty($this->field->required)) { $this->options[''] = get_string('choose').'...'; } foreach ($options as $key => $option) { // Multilang formatting with filters. $this->options[$option] = format_string($option, true, ['context' => context_system::instance()]); } // Set the data key. if ($this->data !== null) { $key = $this->data; if (isset($this->options[$key]) || ($key = array_search($key, $this->options)) !== false) { $this->data = $key; $this->datakey = $key; } } } /** * Create the code snippet for this field instance * Overwrites the base class method * @param moodleform $mform Moodle form instance */ public function edit_field_add($mform) { $mform->addElement('select', $this->inputname, format_string($this->field->name), $this->options); } /** * Set the default value for this field instance * Overwrites the base class method. * @param moodleform $mform Moodle form instance */ public function edit_field_set_default($mform) { $key = $this->field->defaultdata; if (isset($this->options[$key]) || ($key = array_search($key, $this->options)) !== false){ $defaultkey = $key; } else { $defaultkey = ''; } $mform->setDefault($this->inputname, $defaultkey); } /** * The data from the form returns the key. * * This should be converted to the respective option string to be saved in database * Overwrites base class accessor method. * * @param mixed $data The key returned from the select input in the form * @param stdClass $datarecord The object that will be used to save the record * @return mixed Data or null */ public function edit_save_data_preprocess($data, $datarecord) { return isset($this->options[$data]) ? $data : null; } /** * When passing the user object to the form class for the edit profile page * we should load the key for the saved data * * Overwrites the base class method. * * @param stdClass $user User object. */ public function edit_load_user_data($user) { $user->{$this->inputname} = $this->datakey; } /** * HardFreeze the field if locked. * @param moodleform $mform instance of the moodleform class */ public function edit_field_set_locked($mform) { if (!$mform->elementExists($this->inputname)) { return; } if ($this->is_locked() and !has_capability('moodle/user:update', context_system::instance())) { $mform->hardFreeze($this->inputname); $mform->setConstant($this->inputname, format_string($this->datakey)); } } /** * Convert external data (csv file) from value to key for processing later by edit_save_data_preprocess * * @param string $value one of the values in menu options. * @return int options key for the menu */ public function convert_external_data($value) { if (isset($this->options[$value])) { $retval = $value; } else { $retval = array_search($value, $this->options); } // If value is not found in options then return null, so that it can be handled // later by edit_save_data_preprocess. if ($retval === false) { $retval = null; } return $retval; } /** * Return the field type and null properties. * This will be used for validating the data submitted by a user. * * @return array the param type and null property * @since Moodle 3.2 */ public function get_field_properties() { return array(PARAM_TEXT, NULL_NOT_ALLOWED); } } home3/cpr76684/public_html/Aem/mod/data/field/picture/field.class.php 0000644 00000037232 15152126302 0021120 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/>. /** * Class picture field for database activity * * @package datafield_picture * @copyright 2005 Martin Dougiamas * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class data_field_picture extends data_field_base { var $type = 'picture'; var $previewwidth = 50; var $previewheight = 50; public function supports_preview(): bool { return true; } public function get_data_content_preview(int $recordid): stdClass { return (object)[ 'id' => 0, 'fieldid' => $this->field->id, 'recordid' => $recordid, 'content' => 'datafield_picture/preview', 'content1' => get_string('sample', 'datafield_picture'), 'content2' => null, 'content3' => null, 'content4' => null, ]; } function display_add_field($recordid = 0, $formdata = null) { global $CFG, $DB, $OUTPUT, $USER, $PAGE; // Necessary for the constants used in args. require_once($CFG->dirroot . '/repository/lib.php'); $file = false; $content = false; $alttext = ''; $itemid = null; $fs = get_file_storage(); if ($formdata) { $fieldname = 'field_' . $this->field->id . '_file'; $itemid = clean_param($formdata->$fieldname, PARAM_INT); $fieldname = 'field_' . $this->field->id . '_alttext'; if (isset($formdata->$fieldname)) { $alttext = $formdata->$fieldname; } } else if ($recordid) { if (!$content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid))) { // Quickly make one now! $content = new stdClass(); $content->fieldid = $this->field->id; $content->recordid = $recordid; $id = $DB->insert_record('data_content', $content); $content = $DB->get_record('data_content', array('id' => $id)); } file_prepare_draft_area($itemid, $this->context->id, 'mod_data', 'content', $content->id); if (!empty($content->content)) { if ($file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) { $usercontext = context_user::instance($USER->id); if ($thumbfile = $fs->get_file($usercontext->id, 'user', 'draft', $itemid, '/', 'thumb_'.$content->content)) { $thumbfile->delete(); } } } $alttext = $content->content1; } else { $itemid = file_get_unused_draft_itemid(); } $str = '<div title="' . s($this->field->description) . '">'; $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name; if ($this->field->required) { $str .= ' ' . get_string('requiredelement', 'form') . '</span></legend>'; $image = $OUTPUT->pix_icon('req', get_string('requiredelement', 'form')); $str .= html_writer::div($image, 'inline-req'); } else { $str .= '</span></legend>'; } $str .= '<noscript>'; if ($file) { $src = file_encode_url($CFG->wwwroot.'/pluginfile.php/', $this->context->id.'/mod_data/content/'.$content->id.'/'.$file->get_filename()); $str .= '<img width="'.s($this->previewwidth).'" height="'.s($this->previewheight).'" src="'.$src.'" alt="" />'; } $str .= '</noscript>'; $options = new stdClass(); $options->maxbytes = $this->field->param3; $options->maxfiles = 1; // Only one picture permitted. $options->itemid = $itemid; $options->accepted_types = array('web_image'); $options->return_types = FILE_INTERNAL; $options->context = $PAGE->context; if (!empty($file)) { $options->filename = $file->get_filename(); $options->filepath = '/'; } $fm = new form_filemanager($options); // Print out file manager. $output = $PAGE->get_renderer('core', 'files'); $str .= '<div class="mod-data-input">'; $str .= $output->render($fm); $str .= '<div class="mdl-left">'; $str .= '<input type="hidden" name="field_' . $this->field->id . '_file" value="' . s($itemid) . '" />'; $str .= '<label for="field_' . $this->field->id . '_alttext">' . get_string('alttext', 'data') . '</label> <input type="text" class="form-control" name="field_' . $this->field->id . '_alttext" id="field_' . $this->field->id . '_alttext" value="' . s($alttext) . '" />'; $str .= '</div>'; $str .= '</div>'; $str .= '</fieldset>'; $str .= '</div>'; return $str; } /** * Validate the image field type parameters. * * This will check for valid numeric values in the width and height fields. * * @param stdClass $fieldinput the field input data * @return array array of error messages if width or height parameters are not numeric * @throws coding_exception */ public function validate(stdClass $fieldinput): array { $errors = []; // These are the params we have to check if they are numeric, because they represent width and height of the image // in single and list view. $widthandheightparams = ['param1', 'param2', 'param4', 'param5']; foreach ($widthandheightparams as $param) { if (!empty($fieldinput->$param) && !is_numeric($fieldinput->$param)) { $errors[$param] = get_string('error_invalid' . $param, 'datafield_picture'); } } return $errors; } // TODO delete this function and instead subclass data_field_file - see MDL-16493 function get_file($recordid, $content=null) { global $DB; if (empty($content)) { if (!$content = $DB->get_record('data_content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))) { return null; } } $fs = get_file_storage(); if (!$file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) { return null; } return $file; } function display_search_field($value = '') { return '<label class="accesshide" for="f_' . $this->field->id . '">' . get_string('fieldname', 'data') . '</label>' . '<input type="text" size="16" id="f_' . $this->field->id . '" name="f_' . $this->field->id . '" ' . 'value="' . s($value) . '" class="form-control"/>'; } public function parse_search_field($defaults = null) { $param = 'f_'.$this->field->id; if (empty($defaults[$param])) { $defaults = array($param => ''); } return optional_param($param, $defaults[$param], PARAM_NOTAGS); } function generate_sql($tablealias, $value) { global $DB; static $i=0; $i++; $name = "df_picture_$i"; return array(" ({$tablealias}.fieldid = {$this->field->id} AND ".$DB->sql_like("{$tablealias}.content", ":$name", false).") ", array($name=>"%$value%")); } function display_browse_field($recordid, $template) { global $OUTPUT; $content = $this->get_data_content($recordid); if (!$content || empty($content->content)) { return ''; } $alt = $content->content1; $title = $alt; $width = $this->field->param1 ? ' width="' . s($this->field->param1) . '" ' : ' '; $height = $this->field->param2 ? ' height="' . s($this->field->param2) . '" ' : ' '; if ($this->preview) { $imgurl = $OUTPUT->image_url('sample', 'datafield_picture'); return '<img ' . $width . $height . ' src="' . $imgurl . '" alt="' . s($alt) . '" class="list_picture"/>'; } if ($template == 'listtemplate') { $filename = 'thumb_' . $content->content; // Thumbnails are already converted to the correct width and height. $width = ''; $height = ''; $url = new moodle_url('/mod/data/view.php', ['d' => $this->field->dataid, 'rid' => $recordid]); } else { $filename = $content->content; $url = null; } $imgurl = moodle_url::make_pluginfile_url($this->context->id, 'mod_data', 'content', $content->id, '/', $filename); if (!$url) { $url = $imgurl; } $img = '<img ' . $width . $height . ' src="' . $imgurl->out() . '" alt="' . s($alt) . '" title="' . s($title) . '" class="list_picture"/>'; return '<a class="data-field-link" href="' . $url->out() . '">' . $img . '</a>'; } function update_field() { global $DB, $OUTPUT; // Get the old field data so that we can check whether the thumbnail dimensions have changed $oldfield = $DB->get_record('data_fields', array('id'=>$this->field->id)); $DB->update_record('data_fields', $this->field); // Have the thumbnail dimensions changed? if ($oldfield && ($oldfield->param4 != $this->field->param4 || $oldfield->param5 != $this->field->param5)) { // Check through all existing records and update the thumbnail if ($contents = $DB->get_records('data_content', array('fieldid'=>$this->field->id))) { $fs = get_file_storage(); if (count($contents) > 20) { echo $OUTPUT->notification(get_string('resizingimages', 'data'), 'notifysuccess'); echo "\n\n"; // To make sure that ob_flush() has the desired effect ob_flush(); } foreach ($contents as $content) { if (!$file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) { continue; } if ($thumbfile = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', 'thumb_'.$content->content)) { $thumbfile->delete(); } core_php_time_limit::raise(300); // Might be slow! $this->update_thumbnail($content, $file); } } } return true; } function update_content($recordid, $value, $name='') { global $CFG, $DB, $USER; // Should always be available since it is set by display_add_field before initializing the draft area. $content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid)); if (!$content) { $content = (object)array('fieldid' => $this->field->id, 'recordid' => $recordid); $content->id = $DB->insert_record('data_content', $content); } $names = explode('_', $name); switch ($names[2]) { case 'file': $fs = get_file_storage(); file_save_draft_area_files($value, $this->context->id, 'mod_data', 'content', $content->id); $usercontext = context_user::instance($USER->id); $files = $fs->get_area_files( $this->context->id, 'mod_data', 'content', $content->id, 'itemid, filepath, filename', false); // We expect no or just one file (maxfiles = 1 option is set for the form_filemanager). if (count($files) == 0) { $content->content = null; } else { $file = array_values($files)[0]; if (count($files) > 1) { // This should not happen with a consistent database. Inform admins/developers about the inconsistency. debugging('more then one file found in mod_data instance {$this->data->id} picture field (field id: {$this->field->id}) area during update data record {$recordid} (content id: {$content->id})', DEBUG_NORMAL); } if ($file->get_imageinfo() === false) { $url = new moodle_url('/mod/data/edit.php', array('d' => $this->field->dataid)); redirect($url, get_string('invalidfiletype', 'error', $file->get_filename())); } $content->content = $file->get_filename(); $this->update_thumbnail($content, $file); } $DB->update_record('data_content', $content); break; case 'alttext': // only changing alt tag $content->content1 = clean_param($value, PARAM_NOTAGS); $DB->update_record('data_content', $content); break; default: break; } } function update_thumbnail($content, $file) { // (Re)generate thumbnail image according to the dimensions specified in the field settings. // If thumbnail width and height are BOTH not specified then no thumbnail is generated, and // additionally an attempted delete of the existing thumbnail takes place. $fs = get_file_storage(); $file_record = array('contextid'=>$file->get_contextid(), 'component'=>$file->get_component(), 'filearea'=>$file->get_filearea(), 'itemid'=>$file->get_itemid(), 'filepath'=>$file->get_filepath(), 'filename'=>'thumb_'.$file->get_filename(), 'userid'=>$file->get_userid()); try { // this may fail for various reasons $fs->convert_image($file_record, $file, (int) $this->field->param4, (int) $this->field->param5, true); return true; } catch (Exception $e) { debugging($e->getMessage()); return false; } } function text_export_supported() { return false; } function file_ok($path) { return true; } /** * Custom notempty function * * @param string $value * @param string $name * @return bool */ function notemptyfield($value, $name) { global $USER; $names = explode('_', $name); if ($names[2] == 'file') { $usercontext = context_user::instance($USER->id); $fs = get_file_storage(); $files = $fs->get_area_files($usercontext->id, 'user', 'draft', $value); return count($files) >= 2; } return false; } /** * Return the plugin configs for external functions. * * @return array the list of config parameters * @since Moodle 3.3 */ public function get_config_for_external() { // Return all the config parameters. $configs = []; for ($i = 1; $i <= 10; $i++) { $configs["param$i"] = $this->field->{"param$i"}; } return $configs; } } home3/cpr76684/public_html/Aem/user/profile/field/text/field.class.php 0000644 00000005316 15152220665 0021364 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/>. /** * Text profile field. * * @package profilefield_text * @copyright 2007 onwards Shane Elliot {@link http://pukunui.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Class profile_field_text * * @copyright 2007 onwards Shane Elliot {@link http://pukunui.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class profile_field_text extends profile_field_base { /** * Overwrite the base class to display the data for this field */ public function display_data() { // Default formatting. $data = format_string($this->data); // Are we creating a link? if (!empty($this->field->param4) && !empty($data)) { // Define the target. if (! empty($this->field->param5)) { $target = 'target="'.$this->field->param5.'"'; } else { $target = ''; } // Create the link. $data = '<a href="'.str_replace('$$', urlencode($data), $this->field->param4).'" '.$target.'>'.htmlspecialchars($data, ENT_COMPAT).'</a>'; } return $data; } /** * Add fields for editing a text profile field. * @param moodleform $mform */ public function edit_field_add($mform) { $size = $this->field->param1; $maxlength = $this->field->param2; $fieldtype = ($this->field->param3 == 1 ? 'password' : 'text'); // Create the form field. $mform->addElement($fieldtype, $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" '); $mform->setType($this->inputname, PARAM_TEXT); } /** * Return the field type and null properties. * This will be used for validating the data submitted by a user. * * @return array the param type and null property * @since Moodle 3.2 */ public function get_field_properties() { return array(PARAM_TEXT, NULL_NOT_ALLOWED); } } home3/cpr76684/public_html/Aem/mod/data/field/menu/field.class.php 0000644 00000015010 15152656154 0020414 0 ustar 00 <?php /////////////////////////////////////////////////////////////////////////// // // // NOTICE OF COPYRIGHT // // // // Moodle - Modular Object-Oriented Dynamic Learning Environment // // http://moodle.org // // // // Copyright (C) 1999-onwards Moodle Pty Ltd http://moodle.com // // // // This program 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 2 of the License, or // // (at your option) any later version. // // // // This program 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: // // // // http://www.gnu.org/copyleft/gpl.html // // // /////////////////////////////////////////////////////////////////////////// class data_field_menu extends data_field_base { var $type = 'menu'; /** * priority for globalsearch indexing * * @var int */ protected static $priority = self::HIGH_PRIORITY; public function supports_preview(): bool { return true; } public function get_data_content_preview(int $recordid): stdClass { $options = explode("\n", $this->field->param1); $options = array_map('trim', $options); $selected = $options[$recordid % count($options)]; return (object)[ 'id' => 0, 'fieldid' => $this->field->id, 'recordid' => $recordid, 'content' => $selected, 'content1' => null, 'content2' => null, 'content3' => null, 'content4' => null, ]; } function display_add_field($recordid = 0, $formdata = null) { global $DB, $OUTPUT; if ($formdata) { $fieldname = 'field_' . $this->field->id; $content = $formdata->$fieldname; } else if ($recordid) { $content = $DB->get_field('data_content', 'content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid)); $content = trim($content); } else { $content = ''; } $str = '<div title="' . s($this->field->description) . '">'; $options = array(); $rawoptions = explode("\n",$this->field->param1); foreach ($rawoptions as $option) { $option = trim($option); if (strlen($option) > 0) { $options[$option] = $option; } } $str .= '<label for="' . 'field_' . $this->field->id . '">'; $str .= html_writer::span($this->field->name, 'accesshide'); if ($this->field->required) { $image = $OUTPUT->pix_icon('req', get_string('requiredelement', 'form')); $str .= html_writer::div($image, 'inline-req'); } $str .= '</label>'; $str .= html_writer::select($options, 'field_'.$this->field->id, $content, array('' => get_string('menuchoose', 'data')), array('id' => 'field_'.$this->field->id, 'class' => 'mod-data-input custom-select')); $str .= '</div>'; return $str; } function display_search_field($content = '') { global $CFG, $DB; $varcharcontent = $DB->sql_compare_text('content', 255); $sql = "SELECT DISTINCT $varcharcontent AS content FROM {data_content} WHERE fieldid=? AND content IS NOT NULL"; $usedoptions = array(); if ($used = $DB->get_records_sql($sql, array($this->field->id))) { foreach ($used as $data) { $value = $data->content; if ($value === '') { continue; } $usedoptions[$value] = $value; } } $options = array(); foreach (explode("\n",$this->field->param1) as $option) { $option = trim($option); if (!isset($usedoptions[$option])) { continue; } $options[$option] = $option; } if (!$options) { // oh, nothing to search for return ''; } $return = html_writer::label(get_string('fieldtypelabel', "datafield_" . $this->type), 'menuf_' . $this->field->id, false, array('class' => 'accesshide')); $return .= html_writer::select($options, 'f_'.$this->field->id, $content, array('' => get_string('menuchoose', 'data')), array('class' => 'custom-select')); return $return; } public function parse_search_field($defaults = null) { $param = 'f_'.$this->field->id; if (empty($defaults[$param])) { $defaults = array($param => ''); } return optional_param($param, $defaults[$param], PARAM_NOTAGS); } function generate_sql($tablealias, $value) { global $DB; static $i=0; $i++; $name = "df_menu_$i"; $varcharcontent = $DB->sql_compare_text("{$tablealias}.content", 255); return array(" ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = :$name) ", array($name=>$value)); } /** * Check if a field from an add form is empty * * @param mixed $value * @param mixed $name * @return bool */ function notemptyfield($value, $name) { return strval($value) !== ''; } /** * Return the plugin configs for external functions. * * @return array the list of config parameters * @since Moodle 3.3 */ public function get_config_for_external() { // Return all the config parameters. $configs = []; for ($i = 1; $i <= 10; $i++) { $configs["param$i"] = $this->field->{"param$i"}; } return $configs; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�