[ 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 * Exporting a comment area. 19 * 20 * A comment area is the set of information about a defined comments area. 21 * 22 * @package core_competency 23 * @copyright 2015 Frédéric Massart - FMCorz.net 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 namespace core_competency\external; 27 require_once($CFG->dirroot . '/comment/lib.php'); 28 29 // TODO MDL-52243 Move this to core. 30 defined('MOODLE_INTERNAL') || die(); 31 32 use comment; 33 use renderer_base; 34 use stdClass; 35 36 /** 37 * Class for exporting a comment area. 38 * 39 * @package core_competency 40 * @copyright 2015 Frédéric Massart - FMCorz.net 41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 42 */ 43 class comment_area_exporter extends exporter { 44 45 /** @var comment The comment instance. */ 46 protected $comment = null; 47 48 public function __construct(comment $comment, $related = array()) { 49 $this->comment = $comment; 50 $data = new stdClass(); 51 $data->component = $comment->get_component(); 52 $data->commentarea = $comment->get_commentarea(); 53 $data->itemid = $comment->get_itemid(); 54 $data->courseid = $comment->get_courseid(); 55 $data->contextid = $comment->get_context()->id; 56 $data->cid = $comment->get_cid(); 57 58 parent::__construct($data, $related); 59 } 60 61 protected static function define_properties() { 62 return array( 63 'component' => array( 64 'type' => PARAM_COMPONENT, 65 ), 66 'commentarea' => array( 67 'type' => PARAM_AREA, 68 ), 69 'itemid' => array( 70 'type' => PARAM_INT, 71 ), 72 'courseid' => array( 73 'type' => PARAM_INT, 74 ), 75 'contextid' => array( 76 'type' => PARAM_INT, 77 ), 78 'cid' => array( 79 'type' => PARAM_ALPHANUMEXT, 80 ), 81 ); 82 } 83 84 protected static function define_other_properties() { 85 return array( 86 'autostart' => array( 87 'type' => PARAM_BOOL, 88 ), 89 'canpost' => array( 90 'type' => PARAM_BOOL, 91 ), 92 'canview' => array( 93 'type' => PARAM_BOOL, 94 ), 95 'count' => array( 96 'type' => PARAM_INT, 97 ), 98 'collapsediconurl' => array( 99 'type' => PARAM_URL, 100 ), 101 'displaytotalcount' => array( 102 'type' => PARAM_BOOL, 103 ), 104 'displaycancel' => array( 105 'type' => PARAM_BOOL, 106 ), 107 'fullwidth' => array( 108 'type' => PARAM_BOOL, 109 ), 110 'linktext' => array( 111 'type' => PARAM_RAW, 112 ), 113 'notoggle' => array( 114 'type' => PARAM_BOOL, 115 ), 116 'template' => array( 117 'type' => PARAM_RAW, 118 ), 119 'canpostorhascomments' => array( 120 'type' => PARAM_BOOL 121 ) 122 ); 123 } 124 125 public function get_other_values(renderer_base $output) { 126 $values = array(); 127 $values['autostart'] = $this->comment->get_autostart(); 128 $values['canpost'] = $this->comment->can_post(); 129 $values['canview'] = $this->comment->can_view(); 130 $values['collapsediconurl'] = $output->pix_url(right_to_left() ? 't/collapsed_rtl' : 't/collapsed')->out(false); 131 $values['count'] = $this->comment->count(); 132 $values['displaycancel'] = $this->comment->get_displaycancel(); 133 $values['displaytotalcount'] = $this->comment->get_displaytotalcount(); 134 $values['fullwidth'] = $this->comment->get_fullwidth(); 135 $values['linktext'] = $this->comment->get_linktext(); 136 $values['notoggle'] = $this->comment->get_notoggle(); 137 $values['template'] = $this->comment->get_template(); 138 $values['canpostorhascomments'] = $values['canpost'] || ($values['canview'] && $values['count'] > 0); 139 return $values; 140 } 141 }
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 |