mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-73532 navigation: Modify methods that extend the setting nav
Introduces some changes to the exising _extend_settings_navigation() methods that utilize the global $PAGE object. In order to accomodate the changes done for the secondary navigation for single activity courses, the methods that extend the settings navigation can no longer rely on the $PAGE object, instead the more reliabe way to obtain this infomation is through the get_page() method from settings_navigation class.
This commit is contained in:
parent
bf27303955
commit
4a9c83ac9e
19 changed files with 132 additions and 145 deletions
|
@ -328,7 +328,7 @@ function book_supports($feature) {
|
|||
* @return void
|
||||
*/
|
||||
function book_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode) {
|
||||
global $USER, $PAGE, $OUTPUT;
|
||||
global $USER, $OUTPUT;
|
||||
|
||||
if ($booknode->children->count() > 0) {
|
||||
$firstkey = $booknode->children->get_key_list()[0];
|
||||
|
@ -336,10 +336,10 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
|
|||
$firstkey = null;
|
||||
}
|
||||
|
||||
$params = $PAGE->url->params();
|
||||
$params = $settingsnav->get_page()->url->params();
|
||||
|
||||
if ($PAGE->cm->modname === 'book' and !empty($params['id']) and !empty($params['chapterid'])
|
||||
and has_capability('mod/book:edit', $PAGE->cm->context)) {
|
||||
if ($settingsnav->get_page()->cm->modname === 'book' and !empty($params['id']) and !empty($params['chapterid'])
|
||||
and has_capability('mod/book:edit', $settingsnav->get_page()->cm->context)) {
|
||||
if (!empty($USER->editing)) {
|
||||
$string = get_string("turneditingoff");
|
||||
$edit = '0';
|
||||
|
@ -351,8 +351,8 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
|
|||
$editnode = navigation_node::create($string, $url, navigation_node::TYPE_SETTING);
|
||||
$editnode->set_show_in_secondary_navigation(false);
|
||||
$booknode->add_node($editnode, $firstkey);
|
||||
if (!$PAGE->theme->haseditswitch) {
|
||||
$PAGE->set_button($OUTPUT->single_button($url, $string));
|
||||
if (!$settingsnav->get_page()->theme->haseditswitch) {
|
||||
$settingsnav->get_page()->set_button($OUTPUT->single_button($url, $string));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,8 @@ defined('MOODLE_INTERNAL') || die;
|
|||
* @param navigation_node $node The node to add module settings to
|
||||
*/
|
||||
function booktool_exportimscp_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('booktool/exportimscp:export', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/book/tool/exportimscp/index.php', array('id'=>$PAGE->cm->id));
|
||||
if (has_capability('booktool/exportimscp:export', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/book/tool/exportimscp/index.php', array('id' => $settings->get_page()->cm->id));
|
||||
$icon = new pix_icon('generate', '', 'booktool_exportimscp', array('class'=>'icon'));
|
||||
$umscpnode = $node->add(get_string('generateimscp', 'booktool_exportimscp'), $url,
|
||||
navigation_node::TYPE_SETTING, null, null, $icon);
|
||||
|
|
|
@ -31,10 +31,8 @@ defined('MOODLE_INTERNAL') || die;
|
|||
* @param navigation_node $node The node to add module settings to
|
||||
*/
|
||||
function booktool_importhtml_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('booktool/importhtml:import', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/book/tool/importhtml/index.php', array('id'=>$PAGE->cm->id));
|
||||
if (has_capability('booktool/importhtml:import', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/book/tool/importhtml/index.php', array('id' => $settings->get_page()->cm->id));
|
||||
$node->add(get_string('import', 'booktool_importhtml'), $url, navigation_node::TYPE_SETTING, null, 'importchapter', null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,14 +31,12 @@ defined('MOODLE_INTERNAL') || die;
|
|||
* @param navigation_node $node The node to add module settings to
|
||||
*/
|
||||
function booktool_print_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
|
||||
global $USER, $PAGE, $CFG, $DB, $OUTPUT;
|
||||
|
||||
$params = $PAGE->url->params();
|
||||
$params = $settings->get_page()->url->params();
|
||||
if (empty($params['id']) or empty($params['chapterid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (has_capability('booktool/print:print', $PAGE->cm->context)) {
|
||||
if (has_capability('booktool/print:print', $settings->get_page()->cm->context)) {
|
||||
$url1 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id']));
|
||||
$url2 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid']));
|
||||
$action = new action_link($url1, get_string('printbook', 'booktool_print'), new popup_action('click', $url1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue