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
+114
View File
@@ -0,0 +1,114 @@
<?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/>.
/**
* core_customfield field value renderable.
*
* @package core_customfield
* @copyright 2018 Daniel Neis Araujo <danielneis@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_customfield\output;
use core_customfield\data_controller;
defined('MOODLE_INTERNAL') || die;
/**
* core_customfield field value renderable class.
*
* @package core_customfield
* @copyright 2018 Daniel Neis Araujo <danielneis@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class field_data implements \renderable, \templatable {
/** @var \core_customfield\data_controller */
protected $data;
/**
* Renderable constructor.
*
* @param \core_customfield\data_controller $data
*/
public function __construct(\core_customfield\data_controller $data) {
$this->data = $data;
}
/**
* Returns the data value formatted for the output
*
* @return mixed|null
*/
public function get_value() {
return $this->data->export_value();
}
/**
* Returns the field type (checkbox, date, text, ...)
*
* @return string
*/
public function get_type(): string {
return $this->data->get_field()->get('type');
}
/**
* Returns the field short name
*
* @return string
*/
public function get_shortname(): string {
return $this->data->get_field()->get('shortname');
}
/**
* Returns the field name formatted for the output
*
* @return string
*/
public function get_name(): string {
return $this->data->get_field()->get_formatted_name();
}
/**
* Returns the data controller used to create this object if additional attributes are needed
*
* @return data_controller
*/
public function get_data_controller(): data_controller {
return $this->data;
}
/**
* Export data for using as template context.
*
* @param \renderer_base $output
* @return \stdClass
*/
public function export_for_template(\renderer_base $output) {
$value = $this->get_value();
return (object)[
'value' => $value,
'type' => $this->get_type(),
'shortname' => $this->get_shortname(),
'name' => $this->get_name(),
'hasvalue' => ($value !== null),
'instanceid' => $this->data->get('instanceid')
];
}
}
+126
View File
@@ -0,0 +1,126 @@
<?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/>.
/**
* Customfield component output.
*
* @package core_customfield
* @copyright 2018 David Matamoros <davidmc@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_customfield\output;
use core_customfield\api;
use core_customfield\handler;
use renderable;
use templatable;
defined('MOODLE_INTERNAL') || die;
/**
* Class management
*
* @package core_customfield
* @copyright 2018 David Matamoros <davidmc@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class management implements renderable, templatable {
/**
* @var handler
*/
protected $handler;
/**
* @var
*/
protected $categoryid;
/**
* management constructor.
*
* @param \core_customfield\handler $handler
*/
public function __construct(\core_customfield\handler $handler) {
$this->handler = $handler;
}
/**
* Export for template
*
* @param \renderer_base $output
* @return array|object|\stdClass
*/
public function export_for_template(\renderer_base $output) {
$data = new \stdClass();
$fieldtypes = $this->handler->get_available_field_types();
$data->component = $this->handler->get_component();
$data->area = $this->handler->get_area();
$data->itemid = $this->handler->get_itemid();
$data->usescategories = $this->handler->uses_categories();
$categories = $this->handler->get_categories_with_fields();
$categoriesarray = array();
foreach ($categories as $category) {
$categoryarray = array();
$categoryarray['id'] = $category->get('id');
$categoryarray['nameeditable'] = $output->render(api::get_category_inplace_editable($category, true));
$categoryarray['movetitle'] = get_string('movecategory', 'core_customfield',
$category->get_formatted_name());
$categoryarray['fields'] = array();
foreach ($category->get_fields() as $field) {
$fieldname = $field->get_formatted_name();
$fieldarray['type'] = $fieldtypes[$field->get('type')];
$fieldarray['id'] = $field->get('id');
$fieldarray['name'] = $fieldname;
$fieldarray['shortname'] = $field->get('shortname');
$fieldarray['movetitle'] = get_string('movefield', 'core_customfield', $fieldname);
$categoryarray['fields'][] = $fieldarray;
}
$menu = new \action_menu();
$menu->set_menu_trigger(get_string('createnewcustomfield', 'core_customfield'));
foreach ($fieldtypes as $type => $fieldname) {
$action = new \action_menu_link_secondary(new \moodle_url('#'), null, $fieldname,
['data-role' => 'addfield', 'data-categoryid' => $category->get('id'), 'data-type' => $type,
'data-typename' => $fieldname]);
$menu->add($action);
}
$menu->attributes['class'] .= ' float-left mr-1';
$categoryarray['addfieldmenu'] = $output->render($menu);
$categoriesarray[] = $categoryarray;
}
$data->categories = $categoriesarray;
if (empty($data->categories)) {
$data->nocategories = get_string('nocategories', 'core_customfield');
}
return $data;
}
}
+62
View File
@@ -0,0 +1,62 @@
<?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/>.
/**
* Renderer.
*
* @package core_customfield
* @copyright 2018 David Matamoros <davidmc@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_customfield\output;
defined('MOODLE_INTERNAL') || die();
use plugin_renderer_base;
/**
* Renderer class.
*
* @package core_customfield
* @copyright 2018 David Matamoros <davidmc@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renderer extends plugin_renderer_base {
/**
* Render custom field management interface.
*
* @param \core_customfield\output\management $list
* @return string HTML
*/
protected function render_management(\core_customfield\output\management $list) {
$context = $list->export_for_template($this);
return $this->render_from_template('core_customfield/list', $context);
}
/**
* Render single custom field value
*
* @param \core_customfield\output\field_data $field
* @return string HTML
*/
protected function render_field_data(\core_customfield\output\field_data $field) {
$context = $field->export_for_template($this);
return $this->render_from_template('core_customfield/field_data', $context);
}
}