108 lines
3.0 KiB
PHP
108 lines
3.0 KiB
PHP
<?php
|
|
// This file is part of the Studyplan plugin for Moodle
|
|
//
|
|
// 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 <https://www.gnu.org/licenses/>.
|
|
/**
|
|
* Main block code
|
|
*
|
|
* @package block_bibleblock
|
|
* @copyright 2023 P.M. Kuipers
|
|
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
|
|
|
|
/**
|
|
* MyTreestudyplan block base code
|
|
*/
|
|
class block_bibleblock extends \block_base {
|
|
|
|
/**
|
|
* Plugin initialization (before $this->config and $this->page are loaded)
|
|
*/
|
|
public function init() {
|
|
}
|
|
|
|
/**
|
|
* Plugin specialization (directly called after $this->config and $this->page are ready)
|
|
*/
|
|
public function specialization() {
|
|
global $CFG;
|
|
$this->title = get_string('title', 'block_bibleblock');
|
|
|
|
// Load CSS files from treestudyplan.
|
|
try {
|
|
// Include javascript and run studyplan renderer when page loading is complete.
|
|
$this->page->requires->js_call_amd('block_bibleblock/block_bibleblock',
|
|
'init',
|
|
[]);
|
|
} catch (Exception $x) {
|
|
// On some occasions (Plugin management), the plugin is loaded after HEAD has been printed.
|
|
// In those cases we don't want to show the block anyway, so ignore the error that gets inevitably thrown.
|
|
$off = 0; // Empty statement to satisfy code checker.
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Publish the pages this block can be shown on
|
|
*/
|
|
public function applicable_formats() {
|
|
// Limit this block to the site index and the dashboard (my) pages.
|
|
return [
|
|
'admin' => false,
|
|
'site-index' => true,
|
|
'course-view' => true,
|
|
'mod' => true,
|
|
'my' => true
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Render block content
|
|
*/
|
|
public function get_content() {
|
|
global $OUTPUT;
|
|
|
|
if ($this->content !== null) {
|
|
return $this->content;
|
|
}
|
|
|
|
$data = [];
|
|
$this->content = new \stdClass;
|
|
$this->content->text = $OUTPUT->render_from_template("block_bibleblock/block", $data);
|
|
|
|
return $this->content;
|
|
}
|
|
|
|
/**
|
|
* Whether to hide the header or not
|
|
*/
|
|
public function hide_header() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Whether this block has config or not
|
|
*/
|
|
public function has_config() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Return true to avoid broken self-test message
|
|
*/
|
|
function _self_test() {
|
|
return true;
|
|
}
|
|
}
|