Permalink
Browse files

Merged branch 's7_MDL-26105_block_settings_master' git://github.com/a…

…ndyjdavis/moodle.git with changes
  • Loading branch information...
2 parents 379f39e + 35d7256 commit 46d3b9be73585100a72c6ec830871721071b4097 Sam Hemelryk committed Jun 13, 2011
Showing with 614 additions and 38 deletions.
  1. +59 −23 blocks/edit_form.php
  2. +15 −0 blog/lib.php
  3. +3 −1 course/format/topics/lang/en/format_topics.php
  4. +2 −0 course/format/weeks/lang/en/format_weeks.php
  5. +20 −0 course/lib.php
  6. +8 −3 lang/en/block.php
  7. +3 −0 lang/en/blog.php
  8. +1 −0 lang/en/message.php
  9. +2 −0 lang/en/notes.php
  10. +2 −6 lang/en/pagetype.php
  11. +5 −0 lang/en/question.php
  12. +5 −0 lang/en/tag.php
  13. +173 −3 lib/blocklib.php
  14. +23 −0 lib/questionlib.php
  15. +10 −0 message/lib.php
  16. +3 −0 mod/assignment/lang/en/assignment.php
  17. +14 −0 mod/assignment/lib.php
  18. +1 −0 mod/chat/lang/en/chat.php
  19. +11 −0 mod/chat/lib.php
  20. +1 −0 mod/choice/lang/en/choice.php
  21. +11 −0 mod/choice/lib.php
  22. +1 −0 mod/data/lang/en/data.php
  23. +11 −0 mod/data/lib.php
  24. +1 −0 mod/feedback/lang/en/feedback.php
  25. +11 −0 mod/feedback/lib.php
  26. +2 −0 mod/folder/lang/en/folder.php
  27. +11 −0 mod/folder/lib.php
  28. +3 −0 mod/forum/lang/en/forum.php
  29. +15 −0 mod/forum/lib.php
  30. +3 −0 mod/forum/view.php
  31. +1 −0 mod/glossary/lang/en/glossary.php
  32. +11 −0 mod/glossary/lib.php
  33. +1 −0 mod/imscp/lang/en/imscp.php
  34. +11 −0 mod/imscp/lib.php
  35. +1 −0 mod/lesson/lang/en/lesson.php
  36. +12 −0 mod/lesson/lib.php
  37. +1 −0 mod/page/lang/en/page.php
  38. +11 −0 mod/page/lib.php
  39. +1 −0 mod/quiz/lang/en/quiz.php
  40. +11 −0 mod/quiz/lib.php
  41. +1 −0 mod/resource/lang/en/resource.php
  42. +11 −0 mod/resource/lib.php
  43. +1 −0 mod/scorm/lang/en/scorm.php
  44. +11 −0 mod/scorm/lib.php
  45. +1 −0 mod/survey/lang/en/survey.php
  46. +11 −0 mod/survey/lib.php
  47. +1 −0 mod/url/lang/en/url.php
  48. +12 −1 mod/url/lib.php
  49. +5 −0 mod/wiki/lang/en/wiki.php
  50. +17 −0 mod/wiki/lib.php
  51. +1 −0 mod/workshop/lang/en/workshop.php
  52. +11 −0 mod/workshop/lib.php
  53. +10 −0 notes/lib.php
  54. +16 −0 tag/lib.php
  55. +1 −1 user/index.php
  56. +13 −0 user/lib.php
View
@@ -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;
}
View
@@ -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')
+ );
+}
@@ -25,4 +25,6 @@
$string['sectionname'] = 'Topic';
$string['pluginname'] = 'Topics format';
-$string['section0name'] = 'General';
+$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';
@@ -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';
View
@@ -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')
+ );
+ }
+}
View
@@ -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'] = 'The original location where the block was created. Block settings may cause it to appear in other locations (contexts) within the original location. For example, a block created on a course page could be displayed in activities within that course. A block created on the front page can 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';
View
@@ -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';
View
@@ -104,6 +104,7 @@
$string['outputnotconfigured'] = 'Not configured';
$string['pagerefreshes'] = 'This page refreshes automatically every {$a} seconds';
$string['permitted'] = 'Permitted';
+$string['page-message-x'] = 'Any message pages';
$string['private_config'] = 'Popup message window';
$string['processortag'] = 'Destination';
$string['providers_config'] = 'Configure notification methods for incoming messages';
View
@@ -48,6 +48,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';
View
@@ -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';
View
@@ -205,6 +205,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';
View
@@ -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';
Oops, something went wrong.

0 comments on commit 46d3b9b

Please sign in to comment.