Skip to content

Commit

Permalink
[update] Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mdn-thamtt committed Jul 21, 2024
1 parent 4060fc7 commit b921095
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 160 deletions.
33 changes: 18 additions & 15 deletions classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,32 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Settings code for the serlo theme
*
* @package theme_serlo
* @author Faisal Kaleem <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2024 Serlo (https://adornis.de)
*/
namespace theme_serlo\output;

use theme_boost\output\core_renderer as base_core_render;

defined('MOODLE_INTERNAL') || die;

/**
* Renderers to align Moodle's HTML with that expected by Bootstrap
*
* @package theme_boost
* @copyright 2012 Bas Brands, www.basbrands.nl
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_renderer extends base_core_render
{
public function firstview_fakeblocks(): bool
{
$first_view = parent::firstview_fakeblocks();
class core_renderer extends base_core_render {
/**
* Summary of firstview_fakeblocks
* @return bool
*/
public function firstview_fakeblocks(): bool {
$firstview = parent::firstview_fakeblocks();
if ($this->page->course->id != SITEID) {
$this->course_activitychooser(SITEID);
}
return $first_view;
return $firstview;
}

/**
Expand All @@ -44,13 +48,12 @@ public function firstview_fakeblocks(): bool
* @param int $courseid The course id to fetch modules for.
* @return string
*/
public function course_activitychooser($courseid)
{
public function course_activitychooser($courseid) {
if (!$this->page->requires->should_create_one_time_item_now('core_course_modchooser')) {
return '';
}

// Build an object of config settings that we can then hook into in the Activity Chooser.
// Build an object of config settings that we can then hook into in the Activity Chooser!
$chooserconfig = (object) [
'tabmode' => get_config('core', 'activitychoosertabmode'),
];
Expand Down
22 changes: 9 additions & 13 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Settings for Serlo theme
* Settings code for the serlo theme
*
* @package theme_serlo
* @copyright 2024 YOUR NAME <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package theme_serlo
* @author Faisal Kaleem <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2024 Serlo (https://adornis.de)
*/

// This line protects the file from being accessed by a URL directly.
defined('MOODLE_INTERNAL') || die();

// $THEME is defined before this page is included and we can define settings by adding properties to this global object.

// Variable $THEME is defined before this page is included and we can define settings by adding properties to this global object!
// The first setting we need is the name of the theme. This should be the last part of the component name, and the same
// as the directory name for our theme.
$THEME->name = 'serlo';
Expand All @@ -53,7 +53,7 @@

// This is an old setting used to load specific CSS for some YUI JS. We don't need it in Boost based themes because Boost
// provides default styling for the YUI modules that we use. It is not recommended to use this setting anymore.
$THEME->yuicssmodules = array();
$THEME->yuicssmodules = [];

// Most themes will use this rendererfactory as this is the one that allows the theme to override any other renderer.
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
Expand All @@ -63,12 +63,11 @@
// pages in Moodle. Boost does not require these blocks because it provides other ways to navigate built into the theme.
$THEME->requiredblocks = '';

// This is a feature that tells the blocks library not to use the "Add a block" block. We don't want this in boost based themes because
// This is a feature that tells the blocks library not to use the "Add a block" block.
// We don't want this in boost based themes because
// it forces a block region into the page when editing is enabled and it takes up too much room.
$THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_FLATNAV;

# $THEME->haseditswitch = true;


$THEME->scss = function ($theme) {
return theme_serlo_get_main_scss_content($theme);
Expand All @@ -78,6 +77,3 @@
$THEME->prescsscallback = 'theme_serlo_get_pre_scss';

$THEME->extrascsscallback = 'theme_serlo_get_extra_scss';


// $CFG->cachejs = false;
66 changes: 40 additions & 26 deletions lang/de/theme_serlo.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,56 @@
<?php
$string['choosereadme'] = 'Theme photo is a child theme of Boost. It add serlo specific controls.';
$string['pluginname'] = 'Serlo';
$string['secondbutton'] = 'Second Button';
$string['secondbutton_desc'] = 'This is a description for the second button.';
// 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/>.

$string['serlo'] = 'Serlo';
/**
* Language code for the serlo theme
*
* @package theme_serlo
* @author Faisal Kaleem <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2024 Serlo (https://adornis.de)
*/

$string['advancedsettings'] = 'Advanced settings';
// The brand colour setting.

$string['brandcolor'] = 'Brand colour';
// The brand colour setting description.

$string['brandcolor_desc'] = 'The accent colour.';
// A description shown in the admin theme selector.
// Name of the settings pages.

$string['choosereadme'] = 'Theme photo is a child theme of Boost. It add serlo specific controls.';
$string['configtitle'] = 'Photo settings';
// Name of the first settings tab.

$string['generalsettings'] = 'General settings';
// The name of our plugin.
// Preset files setting.
$string['presetfiles'] = 'Additional theme preset files';
// Preset files help text.
$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See <a href=https://docs.moodle.org/dev/Boost_Presets>Boost presets</a> for information on creating and sharing your own preset files, and see the <a href=http://moodle.net/boost>Presets repository</a> for presets that others have shared.';
// Preset setting.

$string['loginbackgroundimage'] = 'Login page background image';
$string['loginbackgroundimage_desc'] = 'An image that will be stretched to fill the background of the login page.';

$string['pluginname'] = 'Serlo';

$string['preset'] = 'Theme preset';
// Preset help text.
$string['preset_desc'] = 'Pick a preset to broadly change the look of the theme.';
// Raw SCSS setting.
$string['presetfiles'] = 'Additional theme preset files';
$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See <a href=https://docs.moodle.org/dev/Boost_Presets>Boost presets</a> for information on creating and sharing your own preset files, and see the <a href=http://moodle.net/boost>Presets repository</a> for presets that others have shared.';

$string['rawscss'] = 'Raw SCSS';
// Raw SCSS setting help text.
$string['rawscss_desc'] = 'Use this field to provide SCSS or CSS code which will be injected at the end of the style sheet.';
// Raw initial SCSS setting.
$string['rawscsspre'] = 'Raw initial SCSS';
// Raw initial SCSS setting help text.
$string['rawscsspre_desc'] = 'In this field you can provide initialising SCSS code, it will be injected before everything else. Most of the time you will use this setting to define variables.';
// We need to include a lang string for each block region.

$string['region-side-pre'] = 'Right';

// Background image for login page.
$string['loginbackgroundimage'] = 'Login page background image';
// Background image for login page.
$string['loginbackgroundimage_desc'] = 'An image that will be stretched to fill the background of the login page.';
$string['secondbutton'] = 'Second Button';
$string['secondbutton_desc'] = 'This is a description for the second button.';
$string['serlo'] = 'Serlo';
66 changes: 40 additions & 26 deletions lang/en/theme_serlo.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,56 @@
<?php
$string['choosereadme'] = 'Theme photo is a child theme of Boost. It add serlo specific controls.';
$string['pluginname'] = 'Serlo';
$string['secondbutton'] = 'Second Button';
$string['secondbutton_desc'] = 'This is a description for the second button.';
// 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/>.

$string['serlo'] = 'Serlo';
/**
* Language code for the serlo theme
*
* @package theme_serlo
* @author Faisal Kaleem <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2024 Serlo (https://adornis.de)
*/

$string['advancedsettings'] = 'Advanced settings';
// The brand colour setting.

$string['brandcolor'] = 'Brand colour';
// The brand colour setting description.

$string['brandcolor_desc'] = 'The accent colour.';
// A description shown in the admin theme selector.
// Name of the settings pages.

$string['choosereadme'] = 'Theme photo is a child theme of Boost. It add serlo specific controls.';
$string['configtitle'] = 'Photo settings';
// Name of the first settings tab.

$string['generalsettings'] = 'General settings';
// The name of our plugin.
// Preset files setting.
$string['presetfiles'] = 'Additional theme preset files';
// Preset files help text.
$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See <a href=https://docs.moodle.org/dev/Boost_Presets>Boost presets</a> for information on creating and sharing your own preset files, and see the <a href=http://moodle.net/boost>Presets repository</a> for presets that others have shared.';
// Preset setting.

$string['loginbackgroundimage'] = 'Login page background image';
$string['loginbackgroundimage_desc'] = 'An image that will be stretched to fill the background of the login page.';

$string['pluginname'] = 'Serlo';

$string['preset'] = 'Theme preset';
// Preset help text.
$string['preset_desc'] = 'Pick a preset to broadly change the look of the theme.';
// Raw SCSS setting.
$string['presetfiles'] = 'Additional theme preset files';
$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See <a href=https://docs.moodle.org/dev/Boost_Presets>Boost presets</a> for information on creating and sharing your own preset files, and see the <a href=http://moodle.net/boost>Presets repository</a> for presets that others have shared.';

$string['rawscss'] = 'Raw SCSS';
// Raw SCSS setting help text.
$string['rawscss_desc'] = 'Use this field to provide SCSS or CSS code which will be injected at the end of the style sheet.';
// Raw initial SCSS setting.
$string['rawscsspre'] = 'Raw initial SCSS';
// Raw initial SCSS setting help text.
$string['rawscsspre_desc'] = 'In this field you can provide initialising SCSS code, it will be injected before everything else. Most of the time you will use this setting to define variables.';
// We need to include a lang string for each block region.

$string['region-side-pre'] = 'Right';

// Background image for login page.
$string['loginbackgroundimage'] = 'Login page background image';
// Background image for login page.
$string['loginbackgroundimage_desc'] = 'An image that will be stretched to fill the background of the login page.';
$string['secondbutton'] = 'Second Button';
$string['secondbutton_desc'] = 'This is a description for the second button.';
$string['serlo'] = 'Serlo';
Loading

0 comments on commit b921095

Please sign in to comment.