[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Admin Bookmarks Block page. 19 * 20 * @package block_admin_bookmarks 21 * @copyright 2011 Moodle 22 * @author 2006 vinkmar 23 * 2011 Rossiani Wijaya (updated) 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 /** 28 * The admin bookmarks block class 29 */ 30 class block_admin_bookmarks extends block_base { 31 32 /** @var string */ 33 public $blockname = null; 34 35 /** @var bool */ 36 protected $contentgenerated = false; 37 38 /** @var bool|null */ 39 protected $docked = null; 40 41 /** 42 * Set the initial properties for the block 43 */ 44 function init() { 45 $this->blockname = get_class($this); 46 $this->title = get_string('pluginname', $this->blockname); 47 } 48 49 /** 50 * All multiple instances of this block 51 * @return bool Returns false 52 */ 53 function instance_allow_multiple() { 54 return false; 55 } 56 57 /** 58 * Set the applicable formats for this block to all 59 * @return array 60 */ 61 function applicable_formats() { 62 if (has_capability('moodle/site:config', context_system::instance())) { 63 return array('all' => true); 64 } else { 65 return array('site' => true); 66 } 67 } 68 69 /** 70 * Gets the content for this block 71 */ 72 function get_content() { 73 74 global $CFG; 75 76 // First check if we have already generated, don't waste cycles 77 if ($this->contentgenerated === true) { 78 return $this->content; 79 } 80 $this->content = new stdClass(); 81 82 if (get_user_preferences('admin_bookmarks')) { 83 require_once($CFG->libdir.'/adminlib.php'); 84 $adminroot = admin_get_root(false, false); // settings not required - only pages 85 86 $bookmarks = explode(',', get_user_preferences('admin_bookmarks')); 87 /// Accessibility: markup as a list. 88 $contents = array(); 89 foreach($bookmarks as $bookmark) { 90 $temp = $adminroot->locate($bookmark); 91 if ($temp instanceof admin_settingpage) { 92 $contenturl = new moodle_url('/admin/settings.php', array('section'=>$bookmark)); 93 $contentlink = html_writer::link($contenturl, $temp->visiblename); 94 $contents[] = html_writer::tag('li', $contentlink); 95 } else if ($temp instanceof admin_externalpage) { 96 $contenturl = new moodle_url($temp->url); 97 $contentlink = html_writer::link($contenturl, $temp->visiblename); 98 $contents[] = html_writer::tag('li', $contentlink); 99 } 100 } 101 $this->content->text = html_writer::tag('ol', implode('', $contents), array('class' => 'list')); 102 } else { 103 $bookmarks = array(); 104 } 105 106 $this->content->footer = ''; 107 $this->page->settingsnav->initialise(); 108 $node = $this->page->settingsnav->get('root', navigation_node::TYPE_SITE_ADMIN); 109 if (!$node || !$node->contains_active_node()) { 110 return $this->content; 111 } 112 $section = $node->find_active_node()->key; 113 114 if ($section == 'search' || empty($section)){ 115 // the search page can't be properly bookmarked at present 116 $this->content->footer = ''; 117 } else if (in_array($section, $bookmarks)) { 118 $deleteurl = new moodle_url('/blocks/admin_bookmarks/delete.php', array('section'=>$section, 'sesskey'=>sesskey())); 119 $this->content->footer = html_writer::link($deleteurl, get_string('unbookmarkthispage','admin')); 120 } else { 121 $createurl = new moodle_url('/blocks/admin_bookmarks/create.php', array('section'=>$section, 'sesskey'=>sesskey())); 122 $this->content->footer = html_writer::link($createurl, get_string('bookmarkthispage','admin')); 123 } 124 125 return $this->content; 126 } 127 128 /** 129 * Returns the role that best describes the admin bookmarks block. 130 * 131 * @return string 132 */ 133 public function get_aria_role() { 134 return 'navigation'; 135 } 136 } 137 138
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |