From b1627a92e52a7dbd67cc64383def143010f509a7 Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Thu, 28 Apr 2011 11:20:30 +0800 Subject: [PATCH] MDL-26105 Block settings should contains less options, and be more user friendly AMOS BEGIN MOV [page-blog-index, pagetype], [page-blog-index, blog] MOV [page-blog-x, pagetype], [page-blog-x, blog] MOV [page-tag-x, pagetype], [page-tag-x, tag] MOV [page-course-view-weeks, pagetype], [page-course-view-weeks, format_weeks] MOV [page-course-view-weeks-x, pagetype], [page-course-view-weeks-x, format_weeks] MOV [page-course-view-topics, pagetype], [page-course-view-topics, format_topics] MOV [page-course-view-topics-x, pagetype], [page-course-view-topics-x, format_topics] AMOS END --- blocks/edit_form.php | 82 +++++++--- blog/lib.php | 15 ++ .../format/topics/lang/en/format_topics.php | 4 +- course/format/weeks/lang/en/format_weeks.php | 2 + course/lib.php | 20 +++ lang/en/block.php | 11 +- lang/en/blog.php | 3 + lang/en/notes.php | 2 + lang/en/pagetype.php | 8 +- lang/en/question.php | 5 + lang/en/tag.php | 5 + lib/blocklib.php | 143 +++++++++++++++++- lib/questionlib.php | 23 +++ mod/assignment/lang/en/assignment.php | 3 + mod/assignment/lib.php | 14 ++ mod/chat/lang/en/chat.php | 1 + mod/chat/lib.php | 11 ++ mod/choice/lang/en/choice.php | 1 + mod/choice/lib.php | 11 ++ mod/data/lang/en/data.php | 1 + mod/data/lib.php | 11 ++ mod/feedback/lang/en/feedback.php | 1 + mod/feedback/lib.php | 11 ++ mod/folder/lang/en/folder.php | 2 + mod/folder/lib.php | 11 ++ mod/forum/lang/en/forum.php | 3 + mod/forum/lib.php | 15 ++ mod/forum/view.php | 3 + mod/glossary/lang/en/glossary.php | 1 + mod/glossary/lib.php | 11 ++ mod/imscp/lang/en/imscp.php | 1 + mod/imscp/lib.php | 11 ++ mod/lesson/lang/en/lesson.php | 1 + mod/lesson/lib.php | 12 ++ mod/page/lang/en/page.php | 1 + mod/page/lib.php | 11 ++ mod/quiz/lang/en/quiz.php | 1 + mod/quiz/lib.php | 11 ++ mod/resource/lang/en/resource.php | 1 + mod/resource/lib.php | 11 ++ mod/scorm/lang/en/scorm.php | 1 + mod/scorm/lib.php | 11 ++ mod/survey/lang/en/survey.php | 1 + mod/survey/lib.php | 11 ++ mod/url/lang/en/url.php | 1 + mod/url/lib.php | 13 +- mod/wiki/lang/en/wiki.php | 5 + mod/wiki/lib.php | 17 +++ mod/workshop/lang/en/workshop.php | 1 + mod/workshop/lib.php | 11 ++ notes/lib.php | 10 ++ tag/lib.php | 16 ++ user/index.php | 2 +- user/lib.php | 13 ++ 54 files changed, 570 insertions(+), 38 deletions(-) diff --git a/blocks/edit_form.php b/blocks/edit_form.php index b0ad9755d9..3e5a9e03a2 100644 --- a/blocks/edit_form.php +++ b/blocks/edit_form.php @@ -32,6 +32,7 @@ } require_once($CFG->libdir . '/formslib.php'); +require_once($CFG->libdir . '/blocklib.php'); /** * The base class form used by blocks/edit.php to edit block instance configuration. @@ -89,40 +90,73 @@ function definition() { $parentcontext = get_context_instance_by_id($this->block->instance->parentcontextid); $mform->addElement('hidden', 'bui_parentcontextid', $parentcontext->id); + $mform->addElement('static', 'bui_homecontext', get_string('createdat', 'block'), print_context_name($parentcontext)); + $mform->addHelpButton('bui_homecontext', 'createdat', 'block'); + + // parse pagetype patterns + $bits = explode('-', $this->page->pagetype); + $contextoptions = array(); if ( ($parentcontext->contextlevel == CONTEXT_COURSE && $parentcontext->instanceid == SITEID) || - ($parentcontext->contextlevel == CONTEXT_SYSTEM)) { // Home page - $contextoptions[0] = get_string('showonfrontpageonly', 'block'); - $contextoptions[1] = get_string('showonfrontpageandsubs', 'block'); - $contextoptions[2] = get_string('showonentiresite', 'block'); + ($parentcontext->contextlevel == CONTEXT_SYSTEM)) { // Home page + if ($bits[0] == 'tag') { + // tag always use system context, the contexts options don't make differences, so we use + // page type patterns only + $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_ENTIRE_SITE); + } else { + $contextoptions[BUI_CONTEXTS_FRONTPAGE_ONLY] = get_string('showonfrontpageonly', 'block'); + $contextoptions[BUI_CONTEXTS_FRONTPAGE_SUBS] = get_string('showonfrontpageandsubs', 'block'); + $contextoptions[BUI_CONTEXTS_ENTIRE_SITE] = get_string('showonentiresite', 'block'); + $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); + $mform->addHelpButton('bui_contexts', 'contexts', 'block'); + } + } else if ($parentcontext->contextlevel == CONTEXT_COURSE) { + // 0 means display on current context only, not child contexts + // but if course managers select mod-* as pagetype patterns, block system will overwrite this option + // to 1 (display on current context and child contexts) + $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_CURRENT); + } else if ($parentcontext->contextlevel == CONTEXT_MODULE or $parentcontext->contextlevel == CONTEXT_USER) { + // module context doesn't have child contexts, so display in current context only + $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_CURRENT); } else { $parentcontextname = print_context_name($parentcontext); - $contextoptions[0] = get_string('showoncontextonly', 'block', $parentcontextname); - $contextoptions[1] = get_string('showoncontextandsubs', 'block', $parentcontextname); + $contextoptions[BUI_CONTEXTS_CURRENT] = get_string('showoncontextonly', 'block', $parentcontextname); + $contextoptions[BUI_CONTEXTS_CURRENT_SUBS] = get_string('showoncontextandsubs', 'block', $parentcontextname); + $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); } - $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); if ($this->page->pagetype == 'site-index') { // No need for pagetype list on home page - $pagetypelist = array('*'); + $pagetypelist = array('*'=>get_string('page-x', 'pagetype')); } else { - $pagetypelist = matching_page_type_patterns($this->page->pagetype); - } - $pagetypeoptions = array(); - foreach ($pagetypelist as $pagetype) { // Find human-readable names for the pagetypes - $pagetypeoptions[$pagetype] = $pagetype; - $pagetypestringname = 'page-'.str_replace('*', 'x',$pagetype); // Better names MDL-21375 - if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) { - $pagetypeoptions[$pagetype] .= ' (' . get_string($pagetypestringname, 'pagetype') . ')'; + // Generate pagetype patterns by callbacks + $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context); + if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) { + // Pushing block's existing page type pattern + $pagetypestringname = 'page-'.str_replace('*', 'x', $this->block->instance->pagetypepattern); + if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) { + $pagetyelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype'); + } } } - $mform->addElement('select', 'bui_pagetypepattern', get_string('restrictpagetypes', 'block'), $pagetypeoptions); + + // hide page type pattern select box if there is only one choice + if (count($pagetypelist) > 1) { + $mform->addElement('select', 'bui_pagetypepattern', get_string('restrictpagetypes', 'block'), $pagetypelist); + } else { + $value = array_pop(array_keys($pagetypelist)); + $mform->addElement('hidden', 'bui_pagetypepattern', $value); + } if ($this->page->subpage) { - $subpageoptions = array( - '%@NULL@%' => get_string('anypagematchingtheabove', 'block'), - $this->page->subpage => get_string('thisspecificpage', 'block', $this->page->subpage), - ); - $mform->addElement('select', 'bui_subpagepattern', get_string('subpages', 'block'), $subpageoptions); + if ($parentcontext->contextlevel == CONTEXT_USER) { + $mform->addElement('hidden', 'bui_subpagepattern', '%@NULL@%'); + } else { + $subpageoptions = array( + '%@NULL@%' => get_string('anypagematchingtheabove', 'block'), + $this->page->subpage => get_string('thisspecificpage', 'block', $this->page->subpage), + ); + $mform->addElement('select', 'bui_subpagepattern', get_string('subpages', 'block'), $subpageoptions); + } } $defaultregionoptions = $regionoptions; @@ -131,8 +165,10 @@ function definition() { $defaultregionoptions[$defaultregion] = $defaultregion; } $mform->addElement('select', 'bui_defaultregion', get_string('defaultregion', 'block'), $defaultregionoptions); + $mform->addHelpButton('bui_defaultregion', 'defaultregion', 'block'); $mform->addElement('select', 'bui_defaultweight', get_string('defaultweight', 'block'), $weightoptions); + $mform->addHelpButton('bui_defaultweight', 'defaultweight', 'block'); // Where this block is positioned on this page. $mform->addElement('header', 'whereheader', get_string('onthispage', 'block')); @@ -182,7 +218,7 @@ function set_data($defaults) { $systemcontext = get_context_instance(CONTEXT_SYSTEM); if ($defaults->parentcontextid == $systemcontext->id) { - $defaults->bui_contexts = 2; // System-wide and sticky + $defaults->bui_contexts = BUI_CONTEXTS_ENTIRE_SITE; // System-wide and sticky } else { $defaults->bui_contexts = $defaults->bui_showinsubcontexts; } diff --git a/blog/lib.php b/blog/lib.php index c7882484a9..0f25fb4b92 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -1028,3 +1028,18 @@ function blog_comment_validate($comment_param) { } return true; } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function blog_pagetypelist($pagetype, $parentcontext, $currentcontext) { + return array( + '*'=>get_string('page-x', 'pagetype'), + 'blog-*'=>get_string('page-blog-x', 'blog'), + 'blog-index'=>get_string('page-blog-index', 'blog'), + 'blog-edit'=>get_string('page-blog-edit', 'blog') + ); +} diff --git a/course/format/topics/lang/en/format_topics.php b/course/format/topics/lang/en/format_topics.php index 48941682ee..fed2cefc9c 100644 --- a/course/format/topics/lang/en/format_topics.php +++ b/course/format/topics/lang/en/format_topics.php @@ -25,4 +25,6 @@ $string['sectionname'] = 'Topic'; $string['pluginname'] = 'Topics format'; -$string['section0name'] = 'General'; \ No newline at end of file +$string['section0name'] = 'General'; +$string['page-course-view-topics'] = 'Any course main page in topics format'; +$string['page-course-view-topics-x'] = 'Any course page in topics format'; diff --git a/course/format/weeks/lang/en/format_weeks.php b/course/format/weeks/lang/en/format_weeks.php index 55d63a5baf..87c52aa9c4 100644 --- a/course/format/weeks/lang/en/format_weeks.php +++ b/course/format/weeks/lang/en/format_weeks.php @@ -26,3 +26,5 @@ $string['sectionname'] = 'Week'; $string['pluginname'] = 'Weekly format'; $string['section0name'] = 'General'; +$string['page-course-view-weeks'] = 'Any course main page in weeks format'; +$string['page-course-view-weeks-x'] = 'Any course page in weeks format'; diff --git a/course/lib.php b/course/lib.php index fa948b1d6b..1a9dbd9c39 100644 --- a/course/lib.php +++ b/course/lib.php @@ -4211,3 +4211,23 @@ protected function notify($touser, $fromuser, $name='courserequested', $subject, message_send($eventdata); } } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function course_pagetypelist($pagetype, $parentcontext, $currentcontext) { + // if above course context ,display all course fomats + list($currentcontext, $course, $cm) = get_context_info_array($currentcontext->id); + if ($course->id == SITEID) { + return array('*'=>get_string('page-x', 'pagetype')); + } else { + return array('*'=>get_string('page-x', 'pagetype'), + 'course-*'=>get_string('page-course-x', 'pagetype'), + 'course-view-*'=>get_string('page-course-view-x', 'pagetype'), + 'mod-*'=>get_string('page-mod-x', 'pagetype') + ); + } +} diff --git a/lang/en/block.php b/lang/en/block.php index b05cb12396..8ee7aa67fa 100644 --- a/lang/en/block.php +++ b/lang/en/block.php @@ -30,8 +30,13 @@ $string['bracketfirst'] = '{$a} (first)'; $string['bracketlast'] = '{$a} (last)'; $string['contexts'] = 'Page contexts'; +$string['contexts_help'] = 'Contexts are more specific types of pages where this block can be displayed within the original block location. You will have different options here depending on the original block location and your current location. For example, you can restrict a block to only appearing on forum pages in a course by adding the block to the course (making it appear on all sub-pages), then going into a forum and editing the block settings again to restrict display to just forum pages.'; +$string['createdat'] = 'Original block location'; +$string['createdat_help'] = 'This is the original location where the block was created, even though other block settings may cause it to appear in other locations (contexts) within this original location. For example, a block created in a course could be displayed on one or more pages within that course only. A block created on the front page, however, could be displayed throughout the site.'; $string['defaultregion'] = 'Default region'; +$string['defaultregion_help'] = 'Themes may define one or more named block regions where blocks are displayed. This setting defines which of these you want this block to appear in by default. The region may be overridden on specific pages if required.'; $string['defaultweight'] = 'Default weight'; +$string['defaultweight_help'] = 'The default weight allows you to choose roughly where you want the block to appear in the chosen region, either at the top or the bottom. The final location is calculated from all the blocks in that region (for example, only one block can actually be at the top). This value can be overridden on specific pages if required.'; $string['moveblockhere'] = 'Move block here'; $string['movingthisblockcancel'] = 'Moving this block ({$a})'; $string['onthispage'] = 'On this page'; @@ -43,9 +48,9 @@ $string['showonfrontpageandsubs'] = 'Display on the front page and any pages added to the front page'; $string['showonfrontpageonly'] = 'Display on the front page only'; $string['site-*'] = 'Any top-level site page'; -$string['subpages'] = 'Specific sub-page'; -$string['restrictpagetypes'] = 'Restrict to these page types'; -$string['thisspecificpage'] = 'This specific page (page {$a})'; +$string['subpages'] = 'Select pages'; +$string['restrictpagetypes'] = 'Display on page types'; +$string['thisspecificpage'] = 'This specific page'; $string['undockall'] = 'Undock all'; $string['undockitem'] = 'Undock this item'; $string['visible'] = 'Visible'; diff --git a/lang/en/blog.php b/lang/en/blog.php index c812e81d20..ab7c6b453b 100644 --- a/lang/en/blog.php +++ b/lang/en/blog.php @@ -176,3 +176,6 @@ $string['viewuserentries'] = 'View all entries by {$a}'; $string['worldblogs'] = 'The world can read entries set to be world-accessible'; $string['wrongpostid'] = 'Wrong blog post id'; +$string['page-blog-edit'] = 'Blog editing pages'; +$string['page-blog-index'] = 'Blog listing pages'; +$string['page-blog-x'] = 'All blog pages'; diff --git a/lang/en/notes.php b/lang/en/notes.php index f8520faf9c..b31019e693 100644 --- a/lang/en/notes.php +++ b/lang/en/notes.php @@ -46,6 +46,8 @@ $string['notesdisabled'] = 'Notes are disabled, sorry.'; $string['notesnotvisible'] = 'You are not allowed to view the notes.'; $string['nouser'] = 'You must select a user'; +$string['page-notes-x'] = 'Any note pages'; +$string['page-notes-index'] = 'Notes main page'; $string['personal'] = 'personal'; $string['personalnotes'] = 'Personal notes'; $string['publishstate'] = 'Context'; diff --git a/lang/en/pagetype.php b/lang/en/pagetype.php index 986426e21b..bc540f05bf 100644 --- a/lang/en/pagetype.php +++ b/lang/en/pagetype.php @@ -23,18 +23,14 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['page-blog-index'] = 'Blog listing pages'; -$string['page-blog-x'] = 'All blog pages'; -$string['page-course-view-topics'] = 'Any course main page in topics format'; -$string['page-course-view-weeks'] = 'Any course main page in weeks format'; $string['page-course-view-x'] = 'Any type of course main page'; $string['page-course-x'] = 'Any course page'; $string['page-mod-x'] = 'Any activity module page'; $string['page-mod-x-view'] = 'Any main activity module page'; -$string['page-my-index'] = 'Users\' My home page'; +$string['page-my-index'] = 'My home page'; $string['page-site-index'] = 'The front page only'; $string['page-site-x'] = 'Any top-level site page'; -$string['page-tag-x'] = 'All tag pages'; $string['page-user-view'] = 'Only user profile pages'; +$string['page-user-profile'] = 'Only user profile pages'; $string['page-user-x'] = 'All user pages'; $string['page-x'] = 'Any page'; diff --git a/lang/en/question.php b/lang/en/question.php index e262ae3cc5..17992c2bac 100644 --- a/lang/en/question.php +++ b/lang/en/question.php @@ -186,6 +186,11 @@ $string['notenoughdatatomovequestions'] = 'You need to provide the question ids of questions you want to move.'; $string['notflagged'] = 'Not flagged'; $string['novirtualquestiontype'] = 'No virtual question type for question type {$a}'; +$string['page-question-x'] = 'Any question page'; +$string['page-question-edit'] = 'Question editing page'; +$string['page-question-category'] = 'Question category page'; +$string['page-question-import'] = 'Question import page'; +$string['page-question-export'] = 'Question export page'; $string['parentcategory'] = 'Parent category'; $string['parentcategory_help'] = 'The parent category is the one in which the new category will be placed. "Top" means that this category is not contained in any other category. Category contexts are shown in bold type. There must be at least one category in each context.'; $string['parentcategory_link'] = 'question/category'; diff --git a/lang/en/tag.php b/lang/en/tag.php index af731c4403..e981881921 100644 --- a/lang/en/tag.php +++ b/lang/en/tag.php @@ -26,6 +26,7 @@ $string['addedotag'] = '"{$a}" was added as an official tag.'; $string['addotags'] = 'Add official tags'; $string['addtagtomyinterests'] = 'Add "{$a}" to my interests'; +$string['alltagpages'] = 'All tag pages'; $string['count'] = 'Count'; $string['delete'] = 'Delete'; $string['deleted'] = 'Deleted'; @@ -82,3 +83,7 @@ $string['updated'] = 'Updated'; $string['updatetag'] = 'Update'; $string['withselectedtags'] = 'With selected tags...'; +$string['page-tag-x'] = 'All tag pages'; +$string['page-tag-index'] = 'Single tag page'; +$string['page-tag-search'] = 'Tag search page'; +$string['page-tag-manage'] = 'Tag manage page'; diff --git a/lib/blocklib.php b/lib/blocklib.php index 9e3c729edd..fba166ddf2 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -53,6 +53,13 @@ define('BLOCKS_PINNED_BOTH',2); /**#@-*/ +define('BUI_CONTEXTS_FRONTPAGE_ONLY', 0); +define('BUI_CONTEXTS_FRONTPAGE_SUBS', 1); +define('BUI_CONTEXTS_ENTIRE_SITE', 2); + +define('BUI_CONTEXTS_CURRENT', 0); +define('BUI_CONTEXTS_CURRENT_SUBS', 1); + /** * Exception thrown when someone tried to do something with a block that does * not exist on a page. @@ -1152,7 +1159,8 @@ public function process_url_edit() { $editpage = new moodle_page(); $editpage->set_pagelayout('admin'); $editpage->set_course($this->page->course); - $editpage->set_context($block->context); + //$editpage->set_context($block->context); + $editpage->set_context($this->page->context); if ($this->page->cm) { $editpage->set_cm($this->page->cm); } @@ -1204,8 +1212,9 @@ public function process_url_edit() { $bi->showinsubcontexts = (int)(!empty($data->bui_contexts)); // If the block wants to be system-wide, then explicitly set that - if ($data->bui_contexts == 2) { // Only possible on a frontpage or system page + if ($data->bui_contexts == BUI_CONTEXTS_ENTIRE_SITE) { // Only possible on a frontpage or system page $bi->parentcontextid = $systemcontext->id; + $bi->showinsubcontexts = 1; } else { // The block doesn't want to be system-wide, so let's ensure that if ($parentcontext->id == $systemcontext->id) { // We need to move it to the front page @@ -1216,6 +1225,25 @@ public function process_url_edit() { } } + $bits = explode('-', $bi->pagetypepattern); + // hacks for some contexts + if (($parentcontext->contextlevel == CONTEXT_COURSE) && ($parentcontext->instanceid != SITEID)) { + // For course context + // is page type pattern is mod-*, change showinsubcontext to 1 + if ($bits[0] == 'mod' || $bi->pagetypepattern == '*') { + $bi->showinsubcontexts = 1; + } else { + $bi->showinsubcontexts = 0; + } + } else if ($parentcontext->contextlevel == CONTEXT_USER) { + // for user context + // subpagepattern should be null + if ($bits[0] == 'user' or $bits[0] == 'my') { + // we don't need subpagepattern in usercontext + $bi->subpagepattern = null; + } + } + $bi->defaultregion = $data->bui_defaultregion; $bi->defaultweight = $data->bui_defaultweight; $DB->update_record('block_instances', $bi); @@ -1266,7 +1294,18 @@ public function process_url_edit() { $strheading = get_string('blockconfiga', 'moodle', $block->get_title()); $editpage->set_title($strheading); $editpage->set_heading($strheading); - $editpage->navbar->add($strheading); + $bits = explode('-', $this->page->pagetype); + if ($bits[0] == 'tag' && !empty($this->page->subpage)) { + // better navbar for tag pages + $editpage->navbar->add(get_string('tags'), new moodle_url('/tag/')); + $tag = tag_get('id', $this->page->subpage, '*'); + // tag search page doesn't have subpageid + if ($tag) { + $editpage->navbar->add($tag->name, new moodle_url('/tag/index.php', array('id'=>$tag->id))); + } + } + $editpage->navbar->add($block->get_title()); + $editpage->navbar->add(get_string('configuration')); $output = $editpage->get_renderer('core'); echo $output->header(); echo $output->heading($strheading, 2); @@ -1508,6 +1547,104 @@ function matching_page_type_patterns($pagetype) { return $patterns; } +/** + * Given a specific page type, parent context and currect context, return all the page type patterns + * that might be used by this block. + * + * @param string $pagetype for example 'course-view-weeks' or 'mod-quiz-view'. + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + * @return array an array of all the page type patterns that might match this page type. + */ +function generate_page_type_patterns($pagetype, $parentcontext = null, $currentcontext = null) { + global $CFG; + // always includes current page type: $PAGE->pagetype + // if plugin callbacks defined, it will be overwriten by a property description + $patterns = array($pagetype=>$pagetype); + $bits = explode('-', $pagetype); + switch ($bits[0]) { + case 'mod': + // for modules + $modname = $bits[1]; + require_once("$CFG->dirroot/mod/$modname/lib.php"); + $listfunction = $modname . '_pagetypelist'; + if (function_exists($listfunction)) { + $module_pagetype = $listfunction($pagetype, $parentcontext, $currentcontext); + if ($parentcontext->contextlevel == CONTEXT_COURSE) { + // including course page type + require_once("$CFG->dirroot/course/lib.php"); + return array_merge(course_pagetypelist($pagetype, $parentcontext, $currentcontext), $module_pagetype); + } else { + return $module_pagetype; + } + } else { + // if modules don't have callbacks + // generate two default page type patterns for modules only + if ($bits[2] == 'view') { + $patterns['mod-*-view'] = get_string('page-mod-x-view', 'pagetype'); + } else if ($bits[2] == 'index') { + $patterns['mod-*-index'] = get_string('page-mod-x-index', 'pagetype'); + } + } + break; + + case 'my': + case 'user': + require_once("$CFG->dirroot/user/lib.php"); + return user_pagetypelist($pagetype, $parentcontext, $currentcontext); + break; + + case 'course': + require_once("$CFG->dirroot/course/lib.php"); + return course_pagetypelist($pagetype, $parentcontext, $currentcontext); + break; + + case 'tag': + require_once("$CFG->dirroot/tag/lib.php"); + return tag_pagetypelist($pagetype, $parentcontext, $currentcontext); + break; + + case 'blog': + require_once("$CFG->dirroot/blog/lib.php"); + return blog_pagetypelist($pagetype, $parentcontext, $currentcontext); + break; + + case 'note': + require_once("$CFG->dirroot/notes/lib.php"); + return note_pagetypelist($pagetype, $parentcontext, $currentcontext); + break; + + case 'question': + require_once("$CFG->libdir/questionlib.php"); + return question_pagetypelist($pagetype, $parentcontext, $currentcontext); + break; + + case 'local': + require_once("$CFG->dirroot/local/{$bits[1]}/lib.php"); + $functionname = 'local_' . $bits[1] . '_pagetypelist'; + if (function_exists($functionname)) { + return $functionname($pagetype, $parentcontext, $currentcontext); + } + break; + } + + // Generate page type patterns based on current page type if + // callbacks haven't been defined + while (count($bits) > 0) { + $pattern = implode('-', $bits) . '-*'; + $pagetypestringname = 'page-'.str_replace('*', 'x', $pattern); + // guessing page type description + if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) { + $patterns[$pattern] = get_string($pagetypestringname, 'pagetype'); + } else { + $patterns[$pattern] = $pattern; + } + array_pop($bits); + } + $patterns['*'] = get_string('page-x', 'pagetype'); + return $patterns; +} + /// Functions update the blocks if required by the request parameters ========== /** diff --git a/lib/questionlib.php b/lib/questionlib.php index dc3805ff8f..6daf415c46 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -3264,3 +3264,26 @@ function question_make_export_url($contextid, $categoryid, $format, $withcategor $urlbase = "$CFG->httpswwwroot/pluginfile.php"; return moodle_url::make_file_url($urlbase, "/$contextid/question/export/{$categoryid}/{$format}/{$withcategories}/{$withcontexts}/{$filename}", true); } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function question_pagetypelist($pagetype, $parentcontext, $currentcontext) { + global $CFG; + $types = array( + 'question-*'=>get_string('page-question-x', 'question'), + 'question-edit'=>get_string('page-question-edit', 'question'), + 'question-category'=>get_string('page-question-category', 'question'), + 'question-export'=>get_string('page-question-export', 'question'), + 'question-import'=>get_string('page-question-import', 'question') + ); + if ($currentcontext->contextlevel == CONTEXT_COURSE) { + require_once($CFG->dirroot . '/course/lib.php'); + return array_merge(course_pagetypelist($pagetype, $parentcontext, $currentcontext), $types); + } else { + return $types; + } +} diff --git a/mod/assignment/lang/en/assignment.php b/mod/assignment/lang/en/assignment.php index 9540c4d6a0..aec18b6f94 100644 --- a/mod/assignment/lang/en/assignment.php +++ b/mod/assignment/lang/en/assignment.php @@ -156,6 +156,9 @@ $string['operation'] = 'Operation'; $string['optionalsettings'] = 'Optional settings'; $string['overwritewarning'] = 'Warning: uploading again will REPLACE your current submission'; +$string['page-mod-assignment-x'] = 'Any assignment module page'; +$string['page-mod-assignment-view'] = 'Assignment module main page'; +$string['page-mod-assignment-submissions'] = 'Assignment module submission page'; $string['pagesize'] = 'Submissions shown per page'; $string['popupinnewwindow'] = 'Open in a popup window'; $string['pluginadministration'] = 'Assignment administration'; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index eed4da0065..165302ae50 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -3716,3 +3716,17 @@ function assignment_get_file_areas($course, $cm, $context) { return $areas; } +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function assignment_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array( + 'mod-assignment-*'=>get_string('page-mod-assignment-x', 'assignment'), + 'mod-assignment-view'=>get_string('page-mod-assignment-view', 'assignment'), + 'mod-assignment-submissions'=>get_string('page-mod-assignment-submissions', 'assignment') + ); + return $module_pagetype; +} diff --git a/mod/chat/lang/en/chat.php b/mod/chat/lang/en/chat.php index 602089fcdb..5a0254400a 100644 --- a/mod/chat/lang/en/chat.php +++ b/mod/chat/lang/en/chat.php @@ -90,6 +90,7 @@ $string['notlogged'] = 'You are not logged in!'; $string['nopermissiontoseethechatlog'] = 'You don\'t have permission to see the chat logs.'; $string['oldping'] = 'Disconnect timeout'; +$string['page-mod-chat-x'] = 'Any chat module page'; $string['pastchats'] = 'Past chat sessions'; $string['pluginadministration'] = 'Chat administration'; $string['pluginname'] = 'Chat'; diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 88bed4f916..c40b833bc7 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -1305,3 +1305,14 @@ function chat_user_logout($user) { global $DB; $DB->delete_records('chat_users', array('userid'=>$user->id)); } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function chat_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-chat-*'=>get_string('page-mod-chat-x', 'chat')); + return $module_pagetype; +} diff --git a/mod/choice/lang/en/choice.php b/mod/choice/lang/en/choice.php index 209adc6218..938742261a 100644 --- a/mod/choice/lang/en/choice.php +++ b/mod/choice/lang/en/choice.php @@ -65,6 +65,7 @@ $string['notenrolledchoose'] = 'Sorry, only enrolled users are allowed to make choices.'; $string['notopenyet'] = 'Sorry, this activity is not available until {$a}'; $string['option'] = 'Option'; +$string['page-mod-choice-x'] = 'Any choice module page'; $string['pluginadministration'] = 'Choice administration'; $string['pluginname'] = 'Choice'; $string['privacy'] = 'Privacy of results'; diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 6667305e76..b9b1fa0315 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -856,3 +856,14 @@ function choice_get_completion_state($course, $cm, $userid, $type) { return $type; } } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function choice_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-choice-*'=>get_string('page-mod-choice-x', 'choice')); + return $module_pagetype; +} diff --git a/mod/data/lang/en/data.php b/mod/data/lang/en/data.php index 0a3f1df4c3..5c3194eb79 100644 --- a/mod/data/lang/en/data.php +++ b/mod/data/lang/en/data.php @@ -252,6 +252,7 @@ $string['overwrite'] = 'Overwrite'; $string['overrwritedesc'] = 'Overwrite the preset if it already exists'; $string['overwritesettings'] = 'Overwrite current settings'; +$string['page-mod-data-x'] = 'Any data module page'; $string['pagesize'] = 'Entries per page'; $string['participants'] = 'Participants'; $string['picture'] = 'Picture'; diff --git a/mod/data/lib.php b/mod/data/lib.php index 8eb820a0db..671a795c86 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -3337,3 +3337,14 @@ function data_comment_validate($comment_param) { } return true; } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function data_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-data-*'=>get_string('page-mod-data-x', 'data')); + return $module_pagetype; +} diff --git a/mod/feedback/lang/en/feedback.php b/mod/feedback/lang/en/feedback.php index b4cd5454dc..2cff937908 100644 --- a/mod/feedback/lang/en/feedback.php +++ b/mod/feedback/lang/en/feedback.php @@ -201,6 +201,7 @@ $string['only_one_captcha_allowed'] = 'Only one captcha is allowed in a feedback'; $string['overview'] = 'Overview'; $string['page'] = 'Page'; +$string['page-mod-feedback-x'] = 'Any feedback module page'; $string['page_after_submit'] = 'Page after submit'; $string['pagebreak'] = 'Page break'; $string['parameters_missing'] = 'Parameters missing from'; diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index bc297e546f..b777e7e98f 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -2781,3 +2781,14 @@ function feedback_init_feedback_session() { } } } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function feedback_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-feedback-*'=>get_string('page-mod-feedback-x', 'feedback')); + return $module_pagetype; +} diff --git a/mod/folder/lang/en/folder.php b/mod/folder/lang/en/folder.php index 67020a0809..790d7b5ef4 100644 --- a/mod/folder/lang/en/folder.php +++ b/mod/folder/lang/en/folder.php @@ -31,5 +31,7 @@ $string['modulename'] = 'Folder'; $string['modulenameplural'] = 'Folders'; $string['neverseen'] = 'Never seen'; +$string['page-mod-folder-x'] = 'Any folder module page'; +$string['page-mod-folder-view'] = 'Folder module main page'; $string['pluginadministration'] = 'Folder administration'; $string['pluginname'] = 'Folder'; diff --git a/mod/folder/lib.php b/mod/folder/lib.php index 49c1bba336..20775d5355 100644 --- a/mod/folder/lib.php +++ b/mod/folder/lib.php @@ -336,3 +336,14 @@ function folder_extend_navigation($navigation, $course, $module, $cm) { */ $navigation->nodetype = navigation_node::NODETYPE_LEAF; } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function folder_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-folder-*'=>get_string('page-mod-folder-x', 'folder')); + return $module_pagetype; +} diff --git a/mod/forum/lang/en/forum.php b/mod/forum/lang/en/forum.php index ad6051adde..5db053b45e 100644 --- a/mod/forum/lang/en/forum.php +++ b/mod/forum/lang/en/forum.php @@ -273,6 +273,9 @@ $string['openmode2'] = 'Discussions and replies are allowed'; $string['overviewnumpostssince'] = 'posts since last login'; $string['overviewnumunread'] = 'total unread'; +$string['page-mod-forum-x'] = 'Any forum module page'; +$string['page-mod-forum-view'] = 'Forum module main page'; +$string['page-mod-forum-discuss'] = 'Forum module discuss page'; $string['parent'] = 'Show parent'; $string['parentofthispost'] = 'Parent of this post'; $string['pluginadministration'] = 'Forum administration'; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index b43997b440..6331f6c003 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -7954,3 +7954,18 @@ function forum_cm_info_view(cm_info $cm) { } } } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function forum_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $forum_pagetype = array( + 'mod-forum-*'=>get_string('page-mod-forum-x', 'forum'), + 'mod-forum-view'=>get_string('page-mod-forum-view', 'forum'), + 'mod-forum-discuss'=>get_string('page-mod-forum-discuss', 'forum') + ); + return $forum_pagetype; +} diff --git a/mod/forum/view.php b/mod/forum/view.php index d3c93cd8c8..5403cfbbd2 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -57,6 +57,9 @@ if (! $forum = $DB->get_record("forum", array("id" => $cm->instance))) { print_error('invalidforumid', 'forum'); } + if ($forum->type == 'single') { + $PAGE->set_pagetype('mod-forum-discuss'); + } // move require_course_login here to use forced language for course // fix for MDL-6926 require_course_login($course, true, $cm); diff --git a/mod/glossary/lang/en/glossary.php b/mod/glossary/lang/en/glossary.php index 0cb92660d0..77282a0928 100644 --- a/mod/glossary/lang/en/glossary.php +++ b/mod/glossary/lang/en/glossary.php @@ -219,6 +219,7 @@ $string['notapproved'] = 'glossary entry is not approved yet.'; $string['numberofentries'] = 'Number of entries'; $string['onebyline'] = '(one per line)'; +$string['page-mod-glossary-x'] = 'Any glossary module page'; $string['pluginadministration'] = 'Glossary administration'; $string['pluginname'] = 'Glossary'; $string['popupformat'] = 'Popup format'; diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index e1cb20e4d5..19848ae20f 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -2856,3 +2856,14 @@ function glossary_comment_validate($comment_param) { } return true; } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function glossary_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-glossary-*'=>get_string('page-mod-glossary-x', 'glossary')); + return $module_pagetype; +} diff --git a/mod/imscp/lang/en/imscp.php b/mod/imscp/lang/en/imscp.php index 8a6571e555..8c74f0acb8 100644 --- a/mod/imscp/lang/en/imscp.php +++ b/mod/imscp/lang/en/imscp.php @@ -35,6 +35,7 @@ $string['modulename_help'] = 'An IMS content package allows for packages created according to the IMS Content Packaging specification to be displayed in the course.'; $string['modulenameplural'] = 'IMS content packages'; $string['navigation'] = 'Navigation'; +$string['page-mod-imscp-x'] = 'Any imscp module page'; $string['packagefile'] = 'Package file'; $string['pluginadministration'] = 'IMSCP administration'; $string['pluginname'] = 'IMS content package'; diff --git a/mod/imscp/lib.php b/mod/imscp/lib.php index 5662730d68..697c293472 100644 --- a/mod/imscp/lib.php +++ b/mod/imscp/lib.php @@ -400,3 +400,14 @@ function imscp_extend_navigation($navigation, $course, $module, $cm) { */ $navigation->nodetype = navigation_node::NODETYPE_LEAF; } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function imscp_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-imscp-*'=>get_string('page-mod-imscp-x', 'imscp')); + return $module_pagetype; +} diff --git a/mod/lesson/lang/en/lesson.php b/mod/lesson/lang/en/lesson.php index 0ec7cbf93e..4a2a3b1803 100644 --- a/mod/lesson/lang/en/lesson.php +++ b/mod/lesson/lang/en/lesson.php @@ -307,6 +307,7 @@ $string['overview'] = 'Overview'; $string['overview_help'] = 'A lesson is made up of a number of pages and optionally content pages. A page contains some content and usually ends with a question. Associated with each answer to the question is a jump. The jump can be relative, such as this page or next page, or absolute, specifying any one of the pages in the lesson. A content page is a page containing a set of links to other pages in the lesson, for example a Table of Contents.'; $string['page'] = 'Page: {$a}'; +$string['page-mod-lesson-x'] = 'Any lesson module page'; $string['pagecontents'] = 'Page contents'; $string['pages'] = 'Pages'; $string['pagetitle'] = 'Page title'; diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index efaec0f1bc..58226d4b9a 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -988,3 +988,15 @@ function lesson_get_file_info($browser, $areas, $course, $cm, $context, $fileare } return new file_info_stored($browser, $context, $storedfile, $urlbase, $filearea, $itemid, true, true, false); } + + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function lesson_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-lesson-*'=>get_string('page-mod-lesson-x', 'lesson')); + return $module_pagetype; +} diff --git a/mod/page/lang/en/page.php b/mod/page/lang/en/page.php index 341a8ae5d7..e24dd4e23d 100644 --- a/mod/page/lang/en/page.php +++ b/mod/page/lang/en/page.php @@ -37,6 +37,7 @@ $string['modulenameplural'] = 'Pages'; $string['neverseen'] = 'Never seen'; $string['optionsheader'] = 'Options'; +$string['page-mod-page-x'] = 'Any page module page'; $string['page:view'] = 'View page content'; $string['pluginadministration'] = 'Page module administration'; $string['pluginname'] = 'Page'; diff --git a/mod/page/lib.php b/mod/page/lib.php index b94116ecb3..300051b0de 100644 --- a/mod/page/lib.php +++ b/mod/page/lib.php @@ -404,3 +404,14 @@ function page_extend_navigation($navigation, $course, $module, $cm) { */ $navigation->nodetype = navigation_node::NODETYPE_LEAF; } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function page_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-page-*'=>get_string('page-mod-page-x', 'page')); + return $module_pagetype; +} diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index a57bb93a02..70a231e03f 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -574,6 +574,7 @@ $string['overrides'] = 'Overrides'; $string['overrideuser'] = 'Override user'; $string['overrideusereventname'] = '{$a->quiz} - Override'; +$string['page-mod-quiz-x'] = 'Any quiz module page'; $string['pagesize'] = 'Attempts shown per page:'; $string['paragraphquestion'] = 'Paragraph question not supported at line {$a}. The question will be ignored.'; $string['parent'] = 'Parent'; diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 5524773b4a..056c9fad03 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -1816,3 +1816,14 @@ function quiz_question_pluginfile($course, $context, $component, send_stored_file($file, 0, 0, $forcedownload); } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function quiz_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-quiz-*'=>get_string('page-mod-quiz-x', 'quiz')); + return $module_pagetype; +} diff --git a/mod/resource/lang/en/resource.php b/mod/resource/lang/en/resource.php index 125bb289ef..601d3b6bc0 100644 --- a/mod/resource/lang/en/resource.php +++ b/mod/resource/lang/en/resource.php @@ -68,6 +68,7 @@ $string['neverseen'] = 'Never seen'; $string['notmigrated'] = 'This legacy resource type ({$a}) was not yet migrated, sorry.'; $string['optionsheader'] = 'Options'; +$string['page-mod-resource-x'] = 'Any resource module page'; $string['pluginadministration'] = 'File module administration'; $string['pluginname'] = 'File'; $string['popupheight'] = 'Popup height (in pixels)'; diff --git a/mod/resource/lib.php b/mod/resource/lib.php index 79091f5018..803c89b7a8 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -429,3 +429,14 @@ function resource_pluginfile($course, $cm, $context, $filearea, $args, $forcedow // finally send the file send_stored_file($file, 86400, $filter, $forcedownload); } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function resource_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-resource-*'=>get_string('page-mod-resource-x', 'resource')); + return $module_pagetype; +} diff --git a/mod/scorm/lang/en/scorm.php b/mod/scorm/lang/en/scorm.php index 46d027ac6d..1fac78ed7d 100644 --- a/mod/scorm/lang/en/scorm.php +++ b/mod/scorm/lang/en/scorm.php @@ -186,6 +186,7 @@ $string['organizations'] = 'Organizations'; $string['othersettings'] = 'Additional settings'; $string['othertracks'] = 'Other tracks'; +$string['page-mod-scorm-x'] = 'Any scorm module page'; $string['pagesize'] = 'Page size'; $string['package'] = 'Package file'; $string['package_help'] = 'The package file is a zip (or pif) file containing SCORM/AICC course definition files.'; diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 80b8c7ddd3..1db51a9d03 100644 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -1068,3 +1068,14 @@ function scorm_print_overview($courses, &$htmlarray) { } } } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function scorm_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-scorm-*'=>get_string('page-mod-scorm-x', 'scorm')); + return $module_pagetype; +} diff --git a/mod/survey/lang/en/survey.php b/mod/survey/lang/en/survey.php index 960e0c43b9..9c61c5869a 100644 --- a/mod/survey/lang/en/survey.php +++ b/mod/survey/lang/en/survey.php @@ -214,6 +214,7 @@ $string['notdone'] = 'Not done yet'; $string['notes'] = 'Your private analysis and notes'; $string['othercomments'] = 'Do you have any other comments?'; +$string['page-mod-survey-x'] = 'Any survey module page'; $string['peoplecompleted'] = '{$a} people have completed this survey so far'; $string['pluginadministration'] = 'Survey administration'; $string['pluginname'] = 'Survey'; diff --git a/mod/survey/lib.php b/mod/survey/lib.php index 2537066dab..9c3d3805bd 100644 --- a/mod/survey/lib.php +++ b/mod/survey/lib.php @@ -864,3 +864,14 @@ function survey_extend_settings_navigation($settings, $surveynode) { } } } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function survey_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-survey-*'=>get_string('page-mod-survey-x', 'survey')); + return $module_pagetype; +} diff --git a/mod/url/lang/en/url.php b/mod/url/lang/en/url.php index 5dc4f4cc6e..f75f6cbe91 100644 --- a/mod/url/lang/en/url.php +++ b/mod/url/lang/en/url.php @@ -49,6 +49,7 @@ $string['modulenameplural'] = 'URLs'; $string['neverseen'] = 'Never seen'; $string['optionsheader'] = 'Options'; +$string['page-mod-url-x'] = 'Any url module page'; $string['parameterinfo'] = 'parameter=variable'; $string['parametersheader'] = 'Parameters'; $string['pluginadministration'] = 'URL module administration'; diff --git a/mod/url/lib.php b/mod/url/lib.php index 39b10d44ff..9e43a41aa5 100644 --- a/mod/url/lib.php +++ b/mod/url/lib.php @@ -310,4 +310,15 @@ function url_extend_navigation($navigation, $course, $module, $cm) { * you content. */ $navigation->nodetype = navigation_node::NODETYPE_LEAF; -} \ No newline at end of file +} + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function url_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-url-*'=>get_string('page-mod-url-x', 'url')); + return $module_pagetype; +} diff --git a/mod/wiki/lang/en/wiki.php b/mod/wiki/lang/en/wiki.php index 5a2069cae2..5468c08089 100644 --- a/mod/wiki/lang/en/wiki.php +++ b/mod/wiki/lang/en/wiki.php @@ -131,6 +131,11 @@ $string['orphaned_help'] = 'List of pages that are not linked from other page.'; $string['overridelocks'] = 'Override locks'; $string['overridinglocks'] = 'Overriding locks...'; +$string['page-mod-wiki-x'] = 'Any wiki module page'; +$string['page-mod-wiki-view'] = 'Wiki module main page'; +$string['page-mod-wiki-comments'] = 'Wiki module comments page'; +$string['page-mod-wiki-history'] = 'Wiki history page'; +$string['page-mod-wiki-map'] = 'Wiki map page'; $string['pageexists'] = 'This page already exists. Redirecting to it.'; $string['pageindex'] = 'Page Index'; $string['pageindex_help'] = 'This wiki\'s page tree'; diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php index 230e7bd729..c2d0533102 100644 --- a/mod/wiki/lib.php +++ b/mod/wiki/lib.php @@ -639,3 +639,20 @@ function wiki_comment_validate($comment_param) { } return true; } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function wiki_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array( + 'mod-wiki-*'=>get_string('page-mod-wiki-x', 'wiki'), + 'mod-wiki-view'=>get_string('page-mod-wiki-view', 'wiki'), + 'mod-wiki-comments'=>get_string('page-mod-wiki-comments', 'wiki'), + 'mod-wiki-history'=>get_string('page-mod-wiki-history', 'wiki'), + 'mod-wiki-map'=>get_string('page-mod-wiki-map', 'wiki') + ); + return $module_pagetype; +} diff --git a/mod/workshop/lang/en/workshop.php b/mod/workshop/lang/en/workshop.php index 200d0605a7..cf405efc47 100644 --- a/mod/workshop/lang/en/workshop.php +++ b/mod/workshop/lang/en/workshop.php @@ -162,6 +162,7 @@ $string['noworkshops'] = 'There are no workshops in this course'; $string['noyoursubmission'] = 'You have not submitted your work yet'; $string['nullgrade'] = '-'; +$string['page-mod-workshop-x'] = 'Any workshop module page'; $string['participant'] = 'Participant'; $string['participantrevierof'] = 'Participant is reviewer of'; $string['participantreviewedby'] = 'Participant is reviewed by'; diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index f586dec17f..f147b97fdb 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -1342,3 +1342,14 @@ function workshop_extend_settings_navigation(settings_navigation $settingsnav, n $workshopnode->add(get_string('allocate', 'workshop'), $url, settings_navigation::TYPE_SETTING); } } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function workshop_pagetypelist($pagetype, $parentcontext, $currentcontext) { + $module_pagetype = array('mod-workshop-*'=>get_string('page-mod-workshop-x', 'workshop')); + return $module_pagetype; +} diff --git a/notes/lib.php b/notes/lib.php index 51df2397a7..f01d8700d7 100644 --- a/notes/lib.php +++ b/notes/lib.php @@ -277,3 +277,13 @@ function note_delete_all($courseid) { return $DB->delete_records('post', array('module'=>'notes', 'courseid'=>$courseid)); } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function note_pagetypelist($pagetype, $parentcontext, $currentcontext) { + return array('notes-*'=>get_string('page-notes-x', 'notes')); +} diff --git a/tag/lib.php b/tag/lib.php index 47c8c003c5..00806bf6e3 100644 --- a/tag/lib.php +++ b/tag/lib.php @@ -1093,3 +1093,19 @@ function tag_unset_flag($tagids) { $timemodified = time(); return $DB->execute("UPDATE {tag} SET flag = 0, timemodified = ? WHERE id IN ($tagids)", array($timemodified)); } + + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function tag_pagetypelist($pagetype, $parentcontext, $currentcontext) { + return array( + 'tag-*'=>get_string('page-tag-x', 'tag'), + 'tag-index'=>get_string('page-tag-index', 'tag'), + 'tag-search'=>get_string('page-tag-search', 'tag'), + 'tag-manage'=>get_string('page-tag-manage', 'tag') + ); +} diff --git a/user/index.php b/user/index.php index bb2a853a4c..007987784e 100644 --- a/user/index.php +++ b/user/index.php @@ -40,7 +40,7 @@ } $course = $DB->get_record('course', array('id'=>$context->instanceid), '*', MUST_EXIST); } else { - $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); + $course = $DB->get_record('course', array('id'=>SITEID), '*', MUST_EXIST); $context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST); } // not needed anymore diff --git a/user/lib.php b/user/lib.php index 92ffdf7c2a..b5df18c170 100644 --- a/user/lib.php +++ b/user/lib.php @@ -95,3 +95,16 @@ function user_get_users_by_id($userids) { global $DB; return $DB->get_records_list('user', 'id', $userids); } + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function user_pagetypelist($pagetype, $parentcontext, $currentcontext) { + return array( + 'user-profile'=>get_string('page-user-profile', 'pagetype'), + 'my-index'=>get_string('page-my-index', 'pagetype') + ); +}