芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/www/cepali/user/classes/output/myprofile/renderer.php
. /** * myprofile renderer. * * @package core_user * @copyright 2015 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core_user\output\myprofile; defined('MOODLE_INTERNAL') || die; /** * Report log renderer's for printing reports. * * @since Moodle 2.9 * @package core_user * @copyright 2015 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class renderer extends \plugin_renderer_base { /** * Render the whole tree. * * @param tree $tree * * @return string */ public function render_tree(tree $tree) { $return = \html_writer::start_tag('div', array('class' => 'profile_tree')); $categories = $tree->categories; foreach ($categories as $category) { $return .= $this->render($category); } $return .= \html_writer::end_tag('div'); return $return; } /** * Render a category. * * @param category $category * * @return string */ public function render_category(category $category) { $classes = $category->classes; if (empty($classes)) { $return = \html_writer::start_tag('section', array('class' => 'node_category')); } else { $return = \html_writer::start_tag('section', array('class' => 'node_category ' . $classes)); } $return .= \html_writer::tag('h3', $category->title); $nodes = $category->nodes; if (empty($nodes)) { // No nodes, nothing to render. return ''; } $return .= \html_writer::start_tag('ul'); foreach ($nodes as $node) { $return .= $this->render($node); } $return .= \html_writer::end_tag('ul'); $return .= \html_writer::end_tag('section'); return $return; } /** * Render a node. * * @param node $node * * @return string */ public function render_node(node $node) { $return = ''; if (is_object($node->url)) { $header = \html_writer::link($node->url, $node->title); } else { $header = $node->title; } $icon = $node->icon; if (!empty($icon)) { $header .= $this->render($icon); } $content = $node->content; $classes = $node->classes; if (!empty($content)) { if ($header) { // There is some content to display below this make this a header. $return = \html_writer::tag('dt', $header); $return .= \html_writer::tag('dd', $content); $return = \html_writer::tag('dl', $return); } else { $return = \html_writer::span($content); } if ($classes) { $return = \html_writer::tag('li', $return, array('class' => 'contentnode ' . $classes)); } else { $return = \html_writer::tag('li', $return, array('class' => 'contentnode')); } } else { $return = \html_writer::span($header); $return = \html_writer::tag('li', $return, array('class' => $classes)); } return $return; } }