mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-82935 filter: Fix coding style in manage.php
This commit is contained in:
parent
056f473a6e
commit
327f06053b
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -26,18 +25,18 @@
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$contextid = required_param('contextid',PARAM_INT);
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$forfilter = optional_param('filter', '', PARAM_SAFEDIR);
|
||||
$returnto = optional_param('return', null, PARAM_ALPHANUMEXT);
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
/// Check login and permissions.
|
||||
// Check login and permissions.
|
||||
require_login($course, false, $cm);
|
||||
require_capability('moodle/filter:manage', $context);
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$args = array('contextid'=>$contextid);
|
||||
$args = ['contextid' => $contextid];
|
||||
$baseurl = new moodle_url('/filter/manage.php', $args);
|
||||
if (!empty($forfilter)) {
|
||||
$args['filter'] = $forfilter;
|
||||
@ -48,7 +47,7 @@ if ($returnto !== null) {
|
||||
}
|
||||
|
||||
// This is a policy decision, rather than something that would be impossible to implement.
|
||||
if (!in_array($context->contextlevel, array(CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_MODULE))) {
|
||||
if (!in_array($context->contextlevel, [CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_MODULE])) {
|
||||
throw new \moodle_exception('cannotcustomisefiltersblockuser', 'error');
|
||||
}
|
||||
|
||||
@ -65,13 +64,13 @@ if ($context->contextlevel == CONTEXT_COURSECAT) {
|
||||
$PAGE->set_heading($PAGE->activityrecord->name);
|
||||
}
|
||||
|
||||
/// Check login and permissions.
|
||||
// Check login and permissions.
|
||||
require_login($course, false, $cm);
|
||||
require_capability('moodle/filter:manage', $context);
|
||||
|
||||
$PAGE->set_context($context);
|
||||
|
||||
/// Get the list of available filters.
|
||||
// Get the list of available filters.
|
||||
$availablefilters = filter_get_available_in_context($context);
|
||||
if (!$isfrontpage && empty($availablefilters)) {
|
||||
throw new \moodle_exception('nofiltersenabled', 'error');
|
||||
@ -93,7 +92,7 @@ if ($forfilter) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Process any form submission.
|
||||
// Process any form submission.
|
||||
if ($forfilter == '' && optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
foreach ($availablefilters as $filter => $filterinfo) {
|
||||
$newstate = optional_param($filter, false, PARAM_INT);
|
||||
@ -104,7 +103,7 @@ if ($forfilter == '' && optional_param('savechanges', false, PARAM_BOOL) && conf
|
||||
redirect($baseurl, get_string('changessaved'), 1);
|
||||
}
|
||||
|
||||
/// Work out an appropriate page title.
|
||||
// Work out an appropriate page title.
|
||||
if ($forfilter) {
|
||||
$a = new stdClass;
|
||||
$a->filter = filter_get_name($forfilter);
|
||||
@ -122,7 +121,7 @@ $PAGE->set_pagelayout('admin');
|
||||
$PAGE->activityheader->disable();
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// Print heading.
|
||||
// Print heading.
|
||||
echo $OUTPUT->heading_with_help($title, 'filtersettings', 'filters');
|
||||
|
||||
if (empty($availablefilters)) {
|
||||
@ -144,33 +143,33 @@ if (empty($availablefilters)) {
|
||||
$stron = get_string('on', 'filters');
|
||||
$strdefaultoff = get_string('defaultx', 'filters', $stroff);
|
||||
$strdefaulton = get_string('defaultx', 'filters', $stron);
|
||||
$activechoices = array(
|
||||
$activechoices = [
|
||||
TEXTFILTER_INHERIT => '',
|
||||
TEXTFILTER_OFF => $stroff,
|
||||
TEXTFILTER_ON => $stron,
|
||||
);
|
||||
];
|
||||
|
||||
echo html_writer::start_tag('form', array('action'=>$baseurl->out_omit_querystring(), 'method'=>'post'));
|
||||
echo html_writer::start_tag('form', ['action' => $baseurl->out_omit_querystring(), 'method' => 'post']);
|
||||
echo html_writer::start_tag('div');
|
||||
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
|
||||
echo html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()]);
|
||||
foreach ($baseurl->params() as $key => $value) {
|
||||
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>$key, 'value'=>$value));
|
||||
echo html_writer::empty_tag('input', ['type' => 'hidden', 'name' => $key, 'value' => $value]);
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filter'), get_string('isactive', 'filters'));
|
||||
$table->colclasses = array('leftalign', 'leftalign');
|
||||
$table->head = [get_string('filter'), get_string('isactive', 'filters')];
|
||||
$table->colclasses = ['leftalign', 'leftalign'];
|
||||
if ($settingscol) {
|
||||
$table->head[] = $strsettings;
|
||||
$table->colclasses[] = 'leftalign';
|
||||
}
|
||||
$table->id = 'frontpagefiltersettings';
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->data = array();
|
||||
$table->data = [];
|
||||
|
||||
// iterate through filters adding to display table
|
||||
// Iterate through filters adding to display table.
|
||||
foreach ($availablefilters as $filter => $filterinfo) {
|
||||
$row = array();
|
||||
$row = [];
|
||||
|
||||
// Filter name.
|
||||
$row[] = filter_get_name($filter);
|
||||
@ -181,15 +180,15 @@ if (empty($availablefilters)) {
|
||||
} else {
|
||||
$activechoices[TEXTFILTER_INHERIT] = $strdefaultoff;
|
||||
}
|
||||
$select = html_writer::label($filterinfo->localstate, 'menu'. $filter, false, array('class' => 'accesshide'));
|
||||
$select = html_writer::label($filterinfo->localstate, 'menu'. $filter, false, ['class' => 'accesshide']);
|
||||
$select .= html_writer::select($activechoices, $filter, $filterinfo->localstate, false);
|
||||
$row[] = $select;
|
||||
|
||||
// Settings link, if required
|
||||
// Settings link, if required.
|
||||
if ($settingscol) {
|
||||
$settings = '';
|
||||
if ($filterinfo->hassettings) {
|
||||
$settings = '<a href="' . $baseurl->out(true, array('filter'=>$filter)). '">' . $strsettings . '</a>';
|
||||
$settings = '<a href="' . $baseurl->out(true, ['filter' => $filter]). '">' . $strsettings . '</a>';
|
||||
}
|
||||
$row[] = $settings;
|
||||
}
|
||||
@ -198,7 +197,7 @@ if (empty($availablefilters)) {
|
||||
}
|
||||
|
||||
echo html_writer::table($table);
|
||||
echo html_writer::start_tag('div', array('class'=>'buttons'));
|
||||
echo html_writer::start_tag('div', ['class' => 'buttons']);
|
||||
$submitattr = ['type' => 'submit', 'name' => 'savechanges', 'value' => get_string('savechanges'), 'class' => 'btn btn-primary'];
|
||||
echo html_writer::empty_tag('input', $submitattr);
|
||||
echo html_writer::end_tag('div');
|
||||
@ -206,19 +205,18 @@ if (empty($availablefilters)) {
|
||||
echo html_writer::end_tag('form');
|
||||
}
|
||||
|
||||
/// Appropriate back link.
|
||||
// Appropriate back link.
|
||||
if (!$isfrontpage) {
|
||||
|
||||
if ($context->contextlevel === CONTEXT_COURSECAT && $returnto === 'management') {
|
||||
$url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
|
||||
$url = new moodle_url('/course/management.php', ['categoryid' => $context->instanceid]);
|
||||
} else {
|
||||
$url = $context->get_url();
|
||||
}
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'backlink'));
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
|
||||
echo html_writer::start_tag('div', ['class' => 'backlink']);
|
||||
echo html_writer::tag('a', get_string('backto', '', $contextname), ['href' => $url]);
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user