[ Index ] |
PHP Cross Reference of moodle-2.8 |
[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 * Settings block 19 * 20 * @package block_settings 21 * @copyright 2010 Sam Hemelryk 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 class block_settings_renderer extends plugin_renderer_base { 26 27 public function settings_tree(settings_navigation $navigation) { 28 $count = 0; 29 foreach ($navigation->children as &$child) { 30 $child->preceedwithhr = ($count!==0); 31 $count++; 32 } 33 $content = $this->navigation_node($navigation, array('class'=>'block_tree list')); 34 if (isset($navigation->id) && !is_numeric($navigation->id) && !empty($content)) { 35 $content = $this->output->box($content, 'block_tree_box', $navigation->id); 36 } 37 return $content; 38 } 39 40 protected function navigation_node(navigation_node $node, $attrs=array()) { 41 $items = $node->children; 42 43 // exit if empty, we don't want an empty ul element 44 if ($items->count()==0) { 45 return ''; 46 } 47 48 // array of nested li elements 49 $lis = array(); 50 foreach ($items as $item) { 51 if (!$item->display) { 52 continue; 53 } 54 55 $isbranch = ($item->children->count()>0 || $item->nodetype==navigation_node::NODETYPE_BRANCH); 56 $hasicon = (!$isbranch && $item->icon instanceof renderable); 57 58 if ($isbranch) { 59 $item->hideicon = true; 60 } 61 $content = $this->output->render($item); 62 63 // this applies to the li item which contains all child lists too 64 $liclasses = array($item->get_css_type()); 65 $liexpandable = array(); 66 if (!$item->forceopen || (!$item->forceopen && $item->collapse) || ($item->children->count()==0 && $item->nodetype==navigation_node::NODETYPE_BRANCH)) { 67 $liclasses[] = 'collapsed'; 68 } 69 if ($isbranch) { 70 $liclasses[] = 'contains_branch'; 71 $liexpandable = array('aria-expanded' => in_array('collapsed', $liclasses) ? "false" : "true"); 72 } else if ($hasicon) { 73 $liclasses[] = 'item_with_icon'; 74 } 75 if ($item->isactive === true) { 76 $liclasses[] = 'current_branch'; 77 } 78 $liattr = array('class' => join(' ',$liclasses)) + $liexpandable; 79 // class attribute on the div item which only contains the item content 80 $divclasses = array('tree_item'); 81 if ($isbranch) { 82 $divclasses[] = 'branch'; 83 } else { 84 $divclasses[] = 'leaf'; 85 } 86 if (!empty($item->classes) && count($item->classes)>0) { 87 $divclasses[] = join(' ', $item->classes); 88 } 89 $divattr = array('class'=>join(' ', $divclasses)); 90 if (!empty($item->id)) { 91 $divattr['id'] = $item->id; 92 } 93 $content = html_writer::tag('p', $content, $divattr) . $this->navigation_node($item); 94 if (!empty($item->preceedwithhr) && $item->preceedwithhr===true) { 95 $content = html_writer::empty_tag('hr') . $content; 96 } 97 $content = html_writer::tag('li', $content, $liattr); 98 $lis[] = $content; 99 } 100 101 if (count($lis)) { 102 return html_writer::tag('ul', implode("\n", $lis), $attrs); 103 } else { 104 return ''; 105 } 106 } 107 108 public function search_form(moodle_url $formtarget, $searchvalue) { 109 $content = html_writer::start_tag('form', array('class'=>'adminsearchform', 'method'=>'get', 'action'=>$formtarget, 'role' => 'search')); 110 $content .= html_writer::start_tag('div'); 111 $content .= html_writer::tag('label', s(get_string('searchinsettings', 'admin')), array('for'=>'adminsearchquery', 'class'=>'accesshide')); 112 $content .= html_writer::empty_tag('input', array('id'=>'adminsearchquery', 'type'=>'text', 'name'=>'query', 'value'=>s($searchvalue))); 113 $content .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>s(get_string('search')))); 114 $content .= html_writer::end_tag('div'); 115 $content .= html_writer::end_tag('form'); 116 return $content; 117 } 118 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |