Skip to content

Commit

Permalink
Code checker
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Oct 7, 2023
1 parent b89f95b commit 866b2ce
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 47 deletions.
45 changes: 22 additions & 23 deletions block_theme_selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @author G J Barnard - {@link http://moodle.org/user/profile.php?id=442195}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;

/**
* Theme selector block class.
Expand Down Expand Up @@ -76,16 +75,16 @@ public function get_content() {
if (((has_capability('moodle/site:config', $coursecontext)) && ($CFG->block_theme_selector_urlswitch == 1)) ||
(($CFG->block_theme_selector_urlswitch == 2) && ($allowthemechangeonurl))) {

$selectdataarray = array('data-sesskey' => sesskey(), 'data-device' => 'default',
'data-urlswitch' => $CFG->block_theme_selector_urlswitch);
$selectdataarray = ['data-sesskey' => sesskey(), 'data-device' => 'default',
'data-urlswitch' => $CFG->block_theme_selector_urlswitch, ];
if ($CFG->block_theme_selector_urlswitch == 2) {
$pageurl = $this->page->url->out(false);
$selectdataarray['data-url'] = $pageurl;
$selectdataarray['data-urlparams'] = (strpos($pageurl, '?') === false) ? 1 : 2;
}
$selectdataarray['aria-labelledby'] = 'themeselectorselectlabel';
$selectdataarray['id'] = 'themeselectorselect';
$this->page->requires->js_call_amd('block_theme_selector/block_theme_selector', 'init', array());
$this->page->requires->js_call_amd('block_theme_selector/block_theme_selector', 'init', []);

// Add a dropdown to switch themes.
if (!empty($CFG->block_theme_selector_excludedthemes)) {
Expand All @@ -94,7 +93,7 @@ public function get_content() {
$excludedthemes = [];
}
$themes = core_component::get_plugin_list('theme');
$options = array();
$options = [];
foreach ($themes as $theme => $themedir) {
if (in_array($theme, $excludedthemes)) {
continue;
Expand All @@ -112,41 +111,41 @@ public function get_content() {
unset($options['bootstrapbase']);
$current = $this->page->theme->name;
}
$this->content->text .= html_writer::start_tag('form', array('class' => 'themeselectorselect'));
$this->content->text .= html_writer::start_tag('form', ['class' => 'themeselectorselect']);
$this->content->text .= html_writer::tag('label', get_string('changetheme', 'block_theme_selector'),
array('id' => 'themeselectorselectlabel', 'for' => 'themeselectorselect'));
['id' => 'themeselectorselectlabel', 'for' => 'themeselectorselect']);
$this->content->text .= html_writer::select($options, 'choose', $current, false, $selectdataarray);
$this->content->text .= html_writer::end_tag('form');

if (has_capability('moodle/site:config', $coursecontext)) {
// Add a button to reset theme caches.
$this->content->text .= html_writer::start_tag('form', array('action' => new moodle_url('/theme/index.php'),
'method' => 'post', 'class' => 'themeselectorreset'));
$this->content->text .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey',
'value' => sesskey()));
$this->content->text .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'reset',
'value' => '1'));
$this->content->text .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'device',
'value' => 'default'));
$this->content->text .= html_writer::start_tag('form', ['action' => new moodle_url('/theme/index.php'),
'method' => 'post', 'class' => 'themeselectorreset', ]);
$this->content->text .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey',
'value' => sesskey(), ]);
$this->content->text .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'reset',
'value' => '1', ]);
$this->content->text .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'device',
'value' => 'default', ]);
$this->content->text .= html_writer::tag('button', get_string('resetthemecache', 'block_theme_selector'),
array('type' => 'submit'));
['type' => 'submit']);
$this->content->text .= html_writer::end_tag('form');
}
if ($CFG->block_theme_selector_window == 2) {
$this->content->text .= html_writer::start_tag('form', array('class' => 'themeselectorwindow'));
$this->content->text .= html_writer::start_tag('form', ['class' => 'themeselectorwindow']);
$this->content->text .= html_writer::tag('label', get_string('windowsize', 'block_theme_selector'),
array('id' => 'themeselectorwindowlabel', 'for' => 'themeselectorwindowwidth'));
$this->content->text .= html_writer::empty_tag('input', array('type' => 'number',
['id' => 'themeselectorwindowlabel', 'for' => 'themeselectorwindowwidth']);
$this->content->text .= html_writer::empty_tag('input', ['type' => 'number',
'id' => 'themeselectorwindowwidth', 'name' => 'themeselectorwindowwidth',
'aria-labelledby' => 'themeselectorwindowlabel',
'min' => '1', 'max' => '9999'));
'min' => '1', 'max' => '9999', ]);
$this->content->text .= html_writer::tag('span', get_string('by', 'block_theme_selector'));
$this->content->text .= html_writer::empty_tag('input', array('type' => 'number',
$this->content->text .= html_writer::empty_tag('input', ['type' => 'number',
'id' => 'themeselectorwindowheight', 'name' => 'themeselectorwindowheight',
'aria-labelledby' => 'themeselectorwindowlabel',
'min' => '1', 'max' => '9999'));
'min' => '1', 'max' => '9999', ]);
$this->content->text .= html_writer::tag('button', get_string('createwindow', 'block_theme_selector'),
array('id' => 'themeselectorcreatewindow'));
['id' => 'themeselectorcreatewindow']);
$this->content->text .= html_writer::end_tag('form');
}
} else if ($CFG->block_theme_selector_urlswitch == 1) {
Expand Down
28 changes: 14 additions & 14 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@

defined('MOODLE_INTERNAL') || die();

$capabilities = array(
$capabilities = [

'block/theme_selector:myaddinstance' => array(
'block/theme_selector:myaddinstance' => [
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
),
'archetypes' => [
'user' => CAP_ALLOW,
],

'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'clonepermissionsfrom' => 'moodle/my:manageblocks',
],

'block/theme_selector:addinstance' => array(
'block/theme_selector:addinstance' => [
'riskbitmask' => RISK_SPAM | RISK_XSS,

'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'manager' => CAP_ALLOW,
],

'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
'clonepermissionsfrom' => 'moodle/site:manageblocks',
],
];
2 changes: 0 additions & 2 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

/**
* Upgrade code for the theme selector block.
*
Expand Down
14 changes: 7 additions & 7 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@
$title = get_string('urlswitch', 'block_theme_selector');
$description = get_string('urlswitch_desc', 'block_theme_selector');
$default = 2;
$choices = array(
$choices = [
1 => new lang_string('no'), // No.
2 => new lang_string('yes') // Yes.
);
2 => new lang_string('yes'), // Yes.
];
$settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices));

/* Inner window information - 1 = no, 2 = yes. */
$name = 'block_theme_selector_window';
$title = get_string('windowinformation', 'block_theme_selector');
$description = get_string('windowinformation_desc', 'block_theme_selector');
$default = 1;
$choices = array(
$choices = [
1 => new lang_string('no'), // No.
2 => new lang_string('yes') // Yes.
);
2 => new lang_string('yes'), // Yes.
];
$settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices));

$themes = core_component::get_plugin_list('theme');
$options = array();
$options = [];
foreach ($themes as $theme => $themedir) {
$options[$theme] = ucfirst(get_string('pluginname', 'theme_' . $theme));
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@

$plugin->release = '2.9.1.5';
$plugin->version = 2015082107;
$plugin->requires = 2015051100.00; // 2.9 (Build: 20150511).
$plugin->requires = 2015051100.00; // M2.9 (Build: 20150511).
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'block_theme_selector';

0 comments on commit 866b2ce

Please sign in to comment.