| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: block_admin_bookmarks.php,v 1.20.2.3 2008/03/03 11:41:01 moodler Exp $ 2 3 // seems to work... 4 // maybe I should add some pretty icons? 5 // or possibly add the ability to custom-name things? 6 7 class block_admin_bookmarks extends block_base { 8 9 function init() { 10 $this->title = get_string('adminbookmarks'); 11 $this->version = 2007101509; 12 } 13 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); 19 } 20 } 21 22 function preferred_width() { 23 return 210; 24 } 25 26 function create_item($visiblename,$link,$icon) { 27 $this->tempcontent .= '<a href="' . $link . '"><img src="' . $icon . '" alt="" /> ' . $visiblename . '</a><br />' . "\n"; 28 } 29 30 function get_content() { 31 32 global $CFG, $USER, $PAGE; 33 34 if ($this->content !== NULL) { 35 return $this->content; 36 } 37 38 $this->content = new stdClass; 39 $this->content->text = ''; 40 if (get_user_preferences('admin_bookmarks')) { 41 // this is expensive! Only require when bookmakrs exist.. 42 require_once($CFG->libdir.'/adminlib.php'); 43 $adminroot =& admin_get_root(false, false); // settings not required - only pages 44 45 $bookmarks = explode(',', get_user_preferences('admin_bookmarks')); 46 // hmm... just a liiitle (potentially) processor-intensive 47 // (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here 48 49 /// Accessibility: markup as a list. 50 $this->content->text .= '<ol class="list">'."\n"; 51 52 foreach($bookmarks as $bookmark) { 53 $temp = $adminroot->locate($bookmark); 54 if (is_a($temp, 'admin_settingpage')) { 55 $this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n"; 56 } else if (is_a($temp, 'admin_externalpage')) { 57 $this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n"; 58 } 59 } 60 $this->content->text .= "</ol>\n"; 61 } else { 62 $bookmarks = array(); 63 } 64 65 if (isset($PAGE->section) and $PAGE->section == 'search'){ 66 // the search page can't be properly bookmarked at present 67 $this->content->footer = ''; 68 } else if (($section = (isset($PAGE->section) ? $PAGE->section : '')) && (in_array($section, $bookmarks))) { 69 $this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/delete.php?section=' . $section . '&sesskey='.sesskey().'">' . get_string('unbookmarkthispage','admin') . '</a>'; 70 } else if ($section = (isset($PAGE->section) ? $PAGE->section : '')) { 71 $this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/create.php?section=' . $section . '&sesskey='.sesskey().'">' . get_string('bookmarkthispage','admin') . '</a>'; 72 } else { 73 $this->content->footer = ''; 74 } 75 76 return $this->content; 77 } 78 } 79 80 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |