adding some strings
[moodle-linuxchix.git] / blocks / admin_bookmarks / block_admin_bookmarks.php
blob9d709ea3c58d5205116d871ff972ff748322c4f6
1 <?php // $Id$
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('adminbookmarks');
11 $this->version = 2006090300;
14 function applicable_formats() {
15 if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
16 return array('all' => true);
17 } else {
18 return array('site' => true);
22 function preferred_width() {
23 return 210;
26 function create_item($visiblename,$link,$icon) {
27 $this->tempcontent .= '<a href="' . $link . '"><img src="' . $icon . '" alt="" /> ' . $visiblename . '</a><br />' . "\n";
30 function get_content() {
32 global $CFG, $USER, $PAGE;
34 require_once($CFG->libdir.'/adminlib.php');
35 $adminroot = admin_get_root();
37 if ($this->content !== NULL) {
38 return $this->content;
41 $this->content = new stdClass;
42 $this->content->text = '';
43 if (get_user_preferences('admin_bookmarks')) {
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 (is_a($temp, '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 (is_a($temp, '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($PAGE->section) and $PAGE->section == 'search'){
65 // the search page can't be properly bookmarked at present
66 $this->content->footer = '';
67 } else if (($section = (isset($PAGE->section) ? $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($PAGE->section) ? $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;