From 9540d2e3496805939bdc216504d9f7060607dfe9 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Tue, 9 May 2023 18:29:31 +0100 Subject: [PATCH] Code checker. --- classes/admin_setting_configselect.php | 4 ++-- classes/output/core_renderer_toolbox.php | 16 ++++++++-------- classes/the_config.php | 2 +- lang/en/theme_foundation.php | 2 +- logout.php | 2 ++ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/classes/admin_setting_configselect.php b/classes/admin_setting_configselect.php index f420ca58..19633a37 100644 --- a/classes/admin_setting_configselect.php +++ b/classes/admin_setting_configselect.php @@ -41,7 +41,7 @@ class admin_setting_configselect extends \admin_setting_configselect { * @return string XHTML field and wrapping div */ public function output_html($data, $query='') { - if (!$this->load_choices() or empty($this->choices)) { + if (!$this->load_choices() || empty($this->choices)) { return ''; } @@ -49,7 +49,7 @@ public function output_html($data, $query='') { if (is_null($current)) { // First run. $default = $this->get_defaultsetting(); - if ((!is_null($default)) and (empty($data))) { + if ((!is_null($default)) && (empty($data))) { $data = $default; } } diff --git a/classes/output/core_renderer_toolbox.php b/classes/output/core_renderer_toolbox.php index 8e7fb9a2..2548abe5 100644 --- a/classes/output/core_renderer_toolbox.php +++ b/classes/output/core_renderer_toolbox.php @@ -64,7 +64,7 @@ public function render_page() { if (!empty($this->page->theme->layouts[$this->page->pagelayout]['regions'])) { if (in_array('drawer', $this->page->theme->layouts[$this->page->pagelayout]['regions'])) { $drawerblockshtml = $this->blocks('drawer'); - $hasdrawerblocks = ((strpos($drawerblockshtml, 'data-block=') !== false) or ($this->page->user_is_editing())); + $hasdrawerblocks = ((strpos($drawerblockshtml, 'data-block=') !== false) || ($this->page->user_is_editing())); $data->drawerblocks = $drawerblockshtml; $data->hasdrawerblocks = $hasdrawerblocks; @@ -80,7 +80,7 @@ public function render_page() { if (in_array('poster', $this->page->theme->layouts[$this->page->pagelayout]['regions'])) { $posterblockshtml = $this->blocks('poster'); - $hasposterblocks = ((strpos($posterblockshtml, 'data-block=') !== false) or ($this->page->user_is_editing())); + $hasposterblocks = ((strpos($posterblockshtml, 'data-block=') !== false) || ($this->page->user_is_editing())); $data->posterblocks = $posterblockshtml; $data->hasposterblocks = $hasposterblocks; @@ -88,7 +88,7 @@ public function render_page() { if (in_array('marketing', $this->page->theme->layouts[$this->page->pagelayout]['regions'])) { $hblockshtml = $this->hblocks('marketing'); - $hashblocks = ((strpos($hblockshtml, 'data-block=') !== false) or ($this->page->user_is_editing())); + $hashblocks = ((strpos($hblockshtml, 'data-block=') !== false) || ($this->page->user_is_editing())); $data->hblocks = $hblockshtml; $data->hashblocks = $hashblocks; @@ -96,7 +96,7 @@ public function render_page() { if (in_array('side-pre', $this->page->theme->layouts[$this->page->pagelayout]['regions'])) { $preblockshtml = $this->blocks('side-pre'); - $haspreblocks = ((strpos($preblockshtml, 'data-block=') !== false) or ($this->page->user_is_editing())); + $haspreblocks = ((strpos($preblockshtml, 'data-block=') !== false) || ($this->page->user_is_editing())); $data->sidepreblocks = $preblockshtml; $data->haspreblocks = $haspreblocks; @@ -104,7 +104,7 @@ public function render_page() { if (in_array('side-post', $this->page->theme->layouts[$this->page->pagelayout]['regions'])) { $postblockshtml = $this->blocks('side-post'); - $haspostblocks = ((strpos($postblockshtml, 'data-block=') !== false) or ($this->page->user_is_editing())); + $haspostblocks = ((strpos($postblockshtml, 'data-block=') !== false) || ($this->page->user_is_editing())); $data->sidepostblocks = $postblockshtml; $data->haspostblocks = $haspostblocks; @@ -112,7 +112,7 @@ public function render_page() { if (in_array('courseend', $this->page->theme->layouts[$this->page->pagelayout]['regions'])) { $ceblockshtml = $this->hblocks('courseend'); - $hasceblocks = ((strpos($ceblockshtml, 'data-block=') !== false) or ($this->page->user_is_editing())); + $hasceblocks = ((strpos($ceblockshtml, 'data-block=') !== false) || ($this->page->user_is_editing())); $data->ceblocks = $ceblockshtml; $data->hasceblocks = $hasceblocks; @@ -958,7 +958,7 @@ public function render_lang_menu() { return ''; } - if ($this->page->course != SITEID and !empty($this->page->course->lang)) { + if ($this->page->course != SITEID && !empty($this->page->course->lang)) { // Do not show lang menu if language forced. return ''; } @@ -1004,7 +1004,7 @@ public function primary_menu() { $fav = $toolbox->get_setting('fav'); $nodisplaymycourses = ($toolbox->get_setting('displaymycourses') < 2); - // See lib/classes/navigation/output/primary.php + // See lib/classes/navigation/output/primary.php. $menudata = []; foreach ($this->page->primarynav->children as $node) { switch ($node->key) { diff --git a/classes/the_config.php b/classes/the_config.php index a055f7c0..84dca63c 100644 --- a/classes/the_config.php +++ b/classes/the_config.php @@ -158,7 +158,7 @@ private static function find_theme_location($themename) { if (file_exists("$CFG->dirroot/theme/$themename/config.php")) { $dir = "$CFG->dirroot/theme/$themename"; - } else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$themename/config.php")) { + } else if (!empty($CFG->themedir) && file_exists("$CFG->themedir/$themename/config.php")) { $dir = "$CFG->themedir/$themename"; } else { throw new \coding_exception('Unable to find the \''.$themename.'\' theme!'); diff --git a/lang/en/theme_foundation.php b/lang/en/theme_foundation.php index 1377bee0..4af40f5c 100644 --- a/lang/en/theme_foundation.php +++ b/lang/en/theme_foundation.php @@ -65,7 +65,7 @@ $string['backtotop'] = 'Back to top'; // Settings. -// Information +// Information. $string['informationheading'] = 'Information'; $string['themechanges'] = 'Changes'; diff --git a/logout.php b/logout.php index 8159797c..4cde4e1e 100644 --- a/logout.php +++ b/logout.php @@ -29,6 +29,8 @@ * Only works when Foundaion is not installed in $CFG->themedir. */ +defined('MOODLE_INTERNAL') || die; + require_once('../../config.php'); $PAGE->set_url('/theme/foundation/logout.php');