MDL-22624 help string thanks to Davo Smith for suggested wording
[moodle.git] / blocks / admin_bookmarks / block_admin_bookmarks.php
blob0b3b039ec25cdca6ebe9d153c5973959aa1892c5
1 <?php
3 // seems to work...
4 // maybe I should add some pretty icons?
5 // or possibly add the ability to custom-name things?
7 class block_admin_bookmarks extends block_base {
9 function init() {
10 $this->title = get_string('pluginname', 'block_admin_bookmarks');
13 function applicable_formats() {
14 if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
15 return array('all' => true);
16 } else {
17 return array('site' => true);
21 function preferred_width() {
22 return 210;
25 function create_item($visiblename,$link,$icon) {
26 $this->tempcontent .= '<a href="' . $link . '"><img src="' . $icon . '" alt="" /> ' . $visiblename . '</a><br />' . "\n";
29 function get_content() {
31 global $CFG, $USER;
33 if ($this->content !== NULL) {
34 return $this->content;
37 $this->content = new stdClass;
38 $this->content->text = '';
39 if (get_user_preferences('admin_bookmarks')) {
40 // this is expensive! Only require when bookmakrs exist..
41 require_once($CFG->libdir.'/adminlib.php');
42 $adminroot = admin_get_root(false, false); // settings not required - only pages
44 $bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
45 // hmm... just a liiitle (potentially) processor-intensive
46 // (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here
48 /// Accessibility: markup as a list.
49 $this->content->text .= '<ol class="list">'."\n";
51 foreach($bookmarks as $bookmark) {
52 $temp = $adminroot->locate($bookmark);
53 if ($temp instanceof admin_settingpage) {
54 $this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n";
55 } else if ($temp instanceof admin_externalpage) {
56 $this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n";
59 $this->content->text .= "</ol>\n";
60 } else {
61 $bookmarks = array();
64 if (isset($this->page->section) and $this->page->section == 'search'){
65 // the search page can't be properly bookmarked at present
66 $this->content->footer = '';
67 } else if (($section = (isset($this->page->section) ? $this->page->section : '')) && (in_array($section, $bookmarks))) {
68 $this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/delete.php?section=' . $section . '&amp;sesskey='.sesskey().'">' . get_string('unbookmarkthispage','admin') . '</a>';
69 } else if ($section = (isset($this->page->section) ? $this->page->section : '')) {
70 $this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/create.php?section=' . $section . '&amp;sesskey='.sesskey().'">' . get_string('bookmarkthispage','admin') . '</a>';
71 } else {
72 $this->content->footer = '';
75 return $this->content;