moodle/mod/data/templates.php
Sara Arjona 61e8b806ec MDL-75289 mod_data: Implement prototyped tertiary nav
On the Database page:
- The List/single view is displayed in the right.
- The buttons Import entries, export entries and Export to portfolio
have been moved to the Actions menu.
- The List/Single view headings have been removed.
- The "Save settings" secondary button is hidden when advanced search
is enabled.
- The result (Found X out of Y entries, No records found) are not
displayed as notifications anymore.

On the Presets page:
- The buttons (Import, Export and Save as preset) have been moved to an
actions menu to the tertiary navigation. Some of these options have been
renamed.
- Remove the Action column heading from the table.

On the Presets preview page:
- Move the preset name to the heading in the tertiary navigation (Preview
of xxxxx), and remove the current preset name from the page.
- Align the List/single template to the right in the tertiary navigation.
- Make primary the "Use this preset" button.

On the Fields page:
- Remove the "Manage fields" menu.
- Remove the Export and Save as preset from the tertiary navigation.
- Align Create a field to the right in the tertiary navigation.
- Add a description at the top of the page.
- Remove the Action column heading from the table.
- Move field actions (Edit and Delete) to ellipsis.

On the Templates page:
- Move Export and Save as preset to the Actions menu.
- Move the templates list to a tertiary navigation selector and remove
the template heading.
- Reorder the templates list (Add entry template should be displayed
at the begining, instead of List template).
- Rename "Enable editor" to "Enable code editor".
2022-10-31 15:24:13 +01:00

113 lines
3.7 KiB
PHP

<?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 is part of the Database module for Moodle
*
* @copyright 2005 Martin Dougiamas http://dougiamas.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package mod_data
*/
use mod_data\manager;
require_once('../../config.php');
require_once('lib.php');
$id = optional_param('id', 0, PARAM_INT); // course module id
$d = optional_param('d', 0, PARAM_INT); // database id
$mode = optional_param('mode', 'addtemplate', PARAM_ALPHA);
$useeditor = optional_param('useeditor', null, PARAM_BOOL);
$url = new moodle_url('/mod/data/templates.php');
if ($id) {
list($course, $cm) = get_course_and_cm_from_cmid($id, manager::MODULE);
$manager = manager::create_from_coursemodule($cm);
$url->param('d', $cm->instance);
} else { // We must have $d.
$instance = $DB->get_record('data', ['id' => $d], '*', MUST_EXIST);
$manager = manager::create_from_instance($instance);
$cm = $manager->get_coursemodule();
$course = get_course($cm->course);
$url->param('d', $d);
}
$instance = $manager->get_instance();
$context = $manager->get_context();
$url->param('mode', $mode);
$PAGE->set_url($url);
require_login($course, false, $cm);
require_capability('mod/data:managetemplates', $context);
$manager->set_template_viewed();
if ($useeditor !== null) {
// The useeditor param was set. Update the value for this template.
data_set_config($instance, "editor_{$mode}", !!$useeditor);
}
$PAGE->requires->js('/mod/data/data.js');
$PAGE->set_title($instance->name);
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('admin');
$PAGE->force_settings_menu(true);
$PAGE->activityheader->disable();
$PAGE->add_body_class('mediumwidth');
echo $OUTPUT->header();
$renderer = $manager->get_renderer();
// Check if it is an empty database with no fields.
if (!$manager->has_fields()) {
echo $renderer->render_templates_zero_state($manager);
echo $OUTPUT->footer();
// Don't check the rest of the options. There is no field, there is nothing else to work with.
exit;
}
$actionbar = new \mod_data\output\action_bar($instance->id, $url);
echo $actionbar->get_templates_action_bar();
if (($formdata = data_submitted()) && confirm_sesskey()) {
$notificationstr = get_string('templatesaved', 'data');
if (!empty($formdata->defaultform)) {
// Reset the template to default.
$formdata->{$mode} = '';
if ($mode == 'listtemplate') {
$formdata->listtemplateheader = '';
$formdata->listtemplatefooter = '';
}
if ($mode == 'rsstemplate') {
$formdata->rsstitletemplate = '';
}
$notificationstr = get_string('templatereset', 'data');
}
if ($manager->update_templates($formdata)) {
// Reload instance.
$instance = $manager->get_instance();
echo $OUTPUT->notification($notificationstr, 'notifysuccess');
}
}
$templateeditor = new \mod_data\output\template_editor($manager, $mode);
echo $renderer->render($templateeditor);
/// Finish the page
echo $OUTPUT->footer();