first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,89 @@
<?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/>.
/**
* Privacy Subsystem implementation for datafield_picture.
*
* @package datafield_picture
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace datafield_picture\privacy;
use core_privacy\local\request\writer;
use mod_data\privacy\datafield_provider;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for datafield_picture implementing null_provider.
*
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider,
datafield_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
/**
* Exports data about one record in {data_content} table.
*
* @param \context_module $context
* @param \stdClass $recordobj record from DB table {data_records}
* @param \stdClass $fieldobj record from DB table {data_fields}
* @param \stdClass $contentobj record from DB table {data_content}
* @param \stdClass $defaultvalue pre-populated default value that most of plugins will use
*/
public static function export_data_content($context, $recordobj, $fieldobj, $contentobj, $defaultvalue) {
if ($fieldobj->param1) {
$defaultvalue->field['width'] = $fieldobj->param1;
}
if ($fieldobj->param2) {
$defaultvalue->field['height'] = $fieldobj->param2;
}
if ($fieldobj->param3) {
$defaultvalue->field['maxbytes'] = $fieldobj->param3;
}
// Change file name to file path.
$defaultvalue->file = writer::with_context($context)
->rewrite_pluginfile_urls([$recordobj->id, $contentobj->id], 'mod_data', 'content', $contentobj->id,
'@@PLUGINFILE@@/' . $defaultvalue->content);
if (isset($defaultvalue->content1)) {
$defaultvalue->alttext = $defaultvalue->content1;
}
unset($defaultvalue->content);
unset($defaultvalue->content1);
writer::with_context($context)->export_data([$recordobj->id, $contentobj->id], $defaultvalue);
}
/**
* Allows plugins to delete locally stored data.
*
* @param \context_module $context
* @param \stdClass $recordobj record from DB table {data_records}
* @param \stdClass $fieldobj record from DB table {data_fields}
* @param \stdClass $contentobj record from DB table {data_content}
*/
public static function delete_data_content($context, $recordobj, $fieldobj, $contentobj) {
}
}
+473
View File
@@ -0,0 +1,473 @@
<?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">'.s($this->field->name);
if ($this->field->required) {
$str .= '&nbsp;' . 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>&nbsp;<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();
$filerecord = [
'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.
$newwidth = isset($this->field->param4) ? (int) $this->field->param4 : null;
$newheight = isset($this->field->param5) ? (int) $this->field->param5 : null;
$fs->convert_image($filerecord, $file, $newwidth, $newheight, true);
return true;
} catch (Exception $e) {
debugging($e->getMessage());
return false;
}
}
/**
* Here we export the text value of a picture field which is the filename of the exported picture.
*
* @param stdClass $record the record which is being exported
* @return string the value which will be stored in the exported file for this field
*/
public function export_text_value(stdClass $record): string {
return !empty($record->content) ? $record->content : '';
}
/**
* Specifies that this field type supports the export of files.
*
* @return bool true which means that file export is being supported by this field type
*/
public function file_export_supported(): bool {
return true;
}
/**
* Exports the file content for file export.
*
* @param stdClass $record the data content record the file belongs to
* @return null|string The file content of the stored file or null if no file should be exported for this record
*/
public function export_file_value(stdClass $record): null|string {
$file = $this->get_file($record->id);
return $file ? $file->get_content() : null;
}
/**
* Specifies that this field type supports the import of files.
*
* @return bool true which means that file import is being supported by this field type
*/
public function file_import_supported(): bool {
return true;
}
/**
* Provides the necessary code for importing a file when importing the content of a mod_data instance.
*
* @param int $contentid the id of the mod_data content record
* @param string $filecontent the content of the file to import as string
* @param string $filename the filename the imported file should get
* @return void
*/
public function import_file_value(int $contentid, string $filecontent, string $filename): void {
$filerecord = [
'contextid' => $this->context->id,
'component' => 'mod_data',
'filearea' => 'content',
'itemid' => $contentid,
'filepath' => '/',
'filename' => $filename,
];
$fs = get_file_storage();
$file = $fs->create_file_from_string($filerecord, $filecontent);
$this->update_thumbnail(null, $file);
}
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;
}
public function get_field_params(): array {
global $DB, $CFG;
$data = parent::get_field_params();
$course = $DB->get_record('course', ['id' => $this->data->course]);
$filesizes = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes, 0, $this->field->param3);
foreach ($filesizes as $value => $name) {
if (!((isset($this->field->param3) && $value == $this->field->param3))) {
$data['options'][] = ['name' => $name, 'value' => $value, 'selected' => 0];
} else {
$data['options'][] = ['name' => $name, 'value' => $value, 'selected' => 1];
}
}
return $data;
}
}
@@ -0,0 +1,34 @@
<?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/>.
/**
* Strings for component 'datafield_picture', language 'en', branch 'master'
*
* @package datafield
* @subpackage picture
* @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Image';
$string['fieldtypelabel'] = 'Image';
$string['error_invalidparam1'] = 'Width in single view needs to be a numeric value.';
$string['error_invalidparam2'] = 'Height in single view needs to be a numeric value.';
$string['error_invalidparam4'] = 'Width in list view needs to be a numeric value.';
$string['error_invalidparam5'] = 'Height in list view needs to be a numeric value.';
$string['privacy:metadata'] = 'The Image field component doesn\'t store any personal data; it uses tables defined in mod_data.';
$string['sample'] = 'Image description placeholder';
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

+42
View File
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg8"
version="1.1"
viewBox="0 0 105.83334 71.4375"
height="71.4375mm"
width="105.83334mm" preserveAspectRatio="xMinYMid meet">
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(276.67856,-129.93452)"
id="layer1">
<rect
y="129.93452"
x="-276.67856"
height="71.4375"
width="105.83334"
id="rect864"
style="opacity:1;vector-effect:none;fill:#e9eef1;fill-opacity:1;stroke:none;stroke-width:3.30729175;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<path
id="rect826"
d="m -239.31599,150.5547 c -1.81012,0 -3.32227,1.50707 -3.32227,3.31918 v 23.55955 c 0,1.8121 1.51215,3.3184 3.32227,3.3184 h 31.10818 c 1.81012,0 3.32228,-1.5063 3.32228,-3.3184 v -23.55955 c 0,-1.81211 -1.51216,-3.31918 -3.32228,-3.31918 z m -0.004,2.43655 h 31.1149 c 0.46886,0 0.8462,0.3776 0.8462,0.84646 v 23.63112 c 0,0.46886 -0.37734,0.84646 -0.8462,0.84646 h -31.1149 c -0.46886,0 -0.8462,-0.3776 -0.8462,-0.84646 v -23.63112 c 0,-0.46886 0.37734,-0.84646 0.8462,-0.84646 z m 5.40122,2.67271 a 3.7417735,3.7417735 0 0 0 -3.74163,3.74189 3.7417735,3.7417735 0 0 0 3.74163,3.74163 3.7417735,3.7417735 0 0 0 3.74189,-3.74163 3.7417735,3.7417735 0 0 0 -3.74189,-3.74189 z m 15.8024,3.17526 -10.0273,10.02703 -3.24063,-3.24063 -6.27636,6.27636 v 3.7406 h 27.79598 v -8.55141 z"
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#babec1;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3.30072331;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

@@ -0,0 +1,97 @@
{{!
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/>.
}}
{{!
@template datafield_picture/picture
The purpose of this template is to enable the user to define a picture field.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* name string The field's name.
* description string The field's description.
* required bool The field's requiredness.
* param1 int The fields width in single view value.
* param2 int The fields height in single view value.
* param3 int The file's maximum size.
* param4 int The fields width in list view value.
* param5 int The fields height in list view value.
* filesizes array The field's file sizes.
Example context (json):
{
"name": "A name",
"description": "A description",
"required": true,
"param1": 100,
"param2": 200,
"param3": 67108864,
"param4": 300,
"param5": 400,
"options": [ { "name": "Site upload limit (64MB)", "value": "0", "selected": true },
{ "name": "64MB", "value": "67108864", "selected": false } ]
}
}}
<fieldset>
{{> mod_data/fields/basicfields }}
{{> mod_data/fields/requiredfield }}
<div class="form-group row fitem">
<div class="col-md-3">
<label for="param1">{{#str}}fieldwidthsingleview, data{{/str}}</label>
</div>
<div class="col-md-9 form-inline align-items-start felement">
<input class="picturefieldsize form-control" type="text" name="param1" id="param1" value="{{param1}}">
</div>
</div>
<div class="form-group row fitem">
<div class="col-md-3"><label for="param2">{{#str}}fieldheightsingleview, data{{/str}}</label>
</div>
<div class="col-md-9 form-inline align-items-start felement">
<input class="picturefieldsize form-control" type="text" name="param2" id="param2" value="{{param2}}">
</div>
</div>
<div class="form-group row fitem">
<div class="col-md-3"><label for="param4">{{#str}}fieldwidthlistview, data{{/str}}</label>
</div>
<div class="col-md-9 form-inline align-items-start felement">
<input class="picturefieldsize form-control" type="text" name="param4" id="param4" value="{{param4}}">
</div>
</div>
<div class="form-group row fitem">
<div class="col-md-3"><label for="param5">{{#str}}fieldheightlistview, data{{/str}}</label>
</div>
<div class="col-md-9 form-inline align-items-start felement">
<input class="picturefieldsize form-control" type="text" name="param5" id="param5" value="{{param5}}">
</div>
</div>
<div class="form-group row fitem">
<div class="col-md-3"><label for="param3" class="mb-0">
{{#str}}maxsize, data{{/str}}</label></div>
<div class="col-md-9 form-inline align-items-start felement">
<select id="param3" class="select custom-select form-control" name="param3">
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/options}}
</select>
</div>
</div>
</fieldset>
+28
View File
@@ -0,0 +1,28 @@
<?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/>.
/**
* @package datafield
* @subpackage picture
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2024041600; // Requires this Moodle version.
$plugin->component = 'datafield_picture'; // Full name of the plugin (used for diagnostics)