Skip to content

Add a default settings global page #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions block_course_contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function specialization() {
if (!empty($this->config->blocktitle)) {
$this->title = $this->config->blocktitle;
} else {
$this->title = get_string('config_blocktitle_default', 'block_course_contents');
$this->title = get_config('course_contents', 'blocktitle_default');
}
}

Expand Down Expand Up @@ -124,7 +124,17 @@ public function get_content() {
$text .= html_writer::start_tag('li', array('class' => 'section-item r'.$odd));
}

if (empty($this->config) or !isset($this->config->enumerate) or is_null($this->config->enumerate) or !empty($this->config->enumerate)) {
if (
(
(
empty($this->config)
or !isset($this->config->enumerate)
or is_null($this->config->enumerate)
)
and get_config('course_contents', 'enumerate_default')
)
or !empty($this->config->enumerate)
) {
$title = html_writer::tag('span', $i.' ', array('class' => 'section-number')).
html_writer::tag('span', $title, array('class' => 'section-title'));
} else {
Expand Down Expand Up @@ -186,4 +196,8 @@ private function node_plain_text($node) {
}
return $t;
}

function has_config() {
return true;
}
}
6 changes: 5 additions & 1 deletion lang/en/block_course_contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
$string['config_blocktitle'] = 'Block title';
$string['config_blocktitle_default'] = 'Table of contents';
$string['config_blocktitle_help'] = 'Leave this field empty to use the default block title. If you define a title here, it will be used instead of the default one.';
$string['config_blocktitle_default_help'] = 'You can define the default block title here.';
$string['config_enumerate'] = 'Enumerate section titles';
$string['config_enumerate_label'] = 'If enabled, the section number is displayed before the section title';
$string['course_contents:addinstance'] = 'Add a new course contents block';
$string['notusingsections'] = 'This course format does not use sections.';
$string['pluginname'] = 'Course contents';
$string['pluginname'] = 'Course contents';

$string['defaults_header'] = 'Default Settings';
$string['defaults_desc'] = 'These settings will be used as defaults, but will not override the user\'s choices.';
31 changes: 31 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* course_contents global settings.
*
* @package block_course_contents
* @copyright 2012 David Mudrak <david@moodle.com>
* @copyright 2016 COMETE (Paris Ouest University)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

$settings->add(new admin_setting_heading(
'defaults',
get_string('defaults_header', 'block_course_contents'),
get_string('defaults_desc', 'block_course_contents')
));

$settings->add(new admin_setting_configcheckbox(
'course_contents/enumerate_default',
get_string('config_enumerate', 'block_course_contents'),
get_string('config_enumerate_label', 'block_course_contents'),
'1'
));

$settings->add(new admin_setting_configtext(
'course_contents/blocktitle_default',
get_string('config_blocktitle', 'block_course_contents'),
get_string('config_blocktitle_default_help', 'block_course_contents'),
get_string('config_blocktitle_default', 'block_course_contents')
));