[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * This file contains a custom renderer class used by the forum module. 20 * 21 * @package mod_forum 22 * @copyright 2009 Sam Hemelryk 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 /** 27 * A custom renderer class that extends the plugin_renderer_base and 28 * is used by the forum module. 29 * 30 * @package mod_forum 31 * @copyright 2009 Sam Hemelryk 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 **/ 34 class mod_forum_renderer extends plugin_renderer_base { 35 36 /** 37 * Returns the navigation to the previous and next discussion. 38 * 39 * @param mixed $prev Previous discussion record, or false. 40 * @param mixed $next Next discussion record, or false. 41 * @return string The output. 42 */ 43 public function neighbouring_discussion_navigation($prev, $next) { 44 $html = ''; 45 if ($prev || $next) { 46 $html .= html_writer::start_tag('div', array('class' => 'discussion-nav clearfix')); 47 $html .= html_writer::start_tag('ul'); 48 if ($prev) { 49 $url = new moodle_url('/mod/forum/discuss.php', array('d' => $prev->id)); 50 $html .= html_writer::start_tag('li', array('class' => 'prev-discussion')); 51 $html .= html_writer::link($url, format_string($prev->name), 52 array('aria-label' => get_string('prevdiscussiona', 'mod_forum', format_string($prev->name)))); 53 $html .= html_writer::end_tag('li'); 54 } 55 if ($next) { 56 $url = new moodle_url('/mod/forum/discuss.php', array('d' => $next->id)); 57 $html .= html_writer::start_tag('li', array('class' => 'next-discussion')); 58 $html .= html_writer::link($url, format_string($next->name), 59 array('aria-label' => get_string('nextdiscussiona', 'mod_forum', format_string($next->name)))); 60 $html .= html_writer::end_tag('li'); 61 } 62 $html .= html_writer::end_tag('ul'); 63 $html .= html_writer::end_tag('div'); 64 } 65 return $html; 66 } 67 68 /** 69 * This method is used to generate HTML for a subscriber selection form that 70 * uses two user_selector controls 71 * 72 * @param user_selector_base $existinguc 73 * @param user_selector_base $potentialuc 74 * @return string 75 */ 76 public function subscriber_selection_form(user_selector_base $existinguc, user_selector_base $potentialuc) { 77 $output = ''; 78 $formattributes = array(); 79 $formattributes['id'] = 'subscriberform'; 80 $formattributes['action'] = ''; 81 $formattributes['method'] = 'post'; 82 $output .= html_writer::start_tag('form', $formattributes); 83 $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey())); 84 85 $existingcell = new html_table_cell(); 86 $existingcell->text = $existinguc->display(true); 87 $existingcell->attributes['class'] = 'existing'; 88 $actioncell = new html_table_cell(); 89 $actioncell->text = html_writer::start_tag('div', array()); 90 $actioncell->text .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'subscribe', 'value'=>$this->page->theme->larrow.' '.get_string('add'), 'class'=>'actionbutton')); 91 $actioncell->text .= html_writer::empty_tag('br', array()); 92 $actioncell->text .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'unsubscribe', 'value'=>$this->page->theme->rarrow.' '.get_string('remove'), 'class'=>'actionbutton')); 93 $actioncell->text .= html_writer::end_tag('div', array()); 94 $actioncell->attributes['class'] = 'actions'; 95 $potentialcell = new html_table_cell(); 96 $potentialcell->text = $potentialuc->display(true); 97 $potentialcell->attributes['class'] = 'potential'; 98 99 $table = new html_table(); 100 $table->attributes['class'] = 'subscribertable boxaligncenter'; 101 $table->data = array(new html_table_row(array($existingcell, $actioncell, $potentialcell))); 102 $output .= html_writer::table($table); 103 104 $output .= html_writer::end_tag('form'); 105 return $output; 106 } 107 108 /** 109 * This function generates HTML to display a subscriber overview, primarily used on 110 * the subscribers page if editing was turned off 111 * 112 * @param array $users 113 * @param object $forum 114 * @param object $course 115 * @return string 116 */ 117 public function subscriber_overview($users, $forum , $course) { 118 $output = ''; 119 $modinfo = get_fast_modinfo($course); 120 if (!$users || !is_array($users) || count($users)===0) { 121 $output .= $this->output->heading(get_string("nosubscribers", "forum")); 122 } else if (!isset($modinfo->instances['forum'][$forum->id])) { 123 $output .= $this->output->heading(get_string("invalidmodule", "error")); 124 } else { 125 $cm = $modinfo->instances['forum'][$forum->id]; 126 $canviewemail = in_array('email', get_extra_user_fields(context_module::instance($cm->id))); 127 $strparams = new stdclass(); 128 $strparams->name = format_string($forum->name); 129 $strparams->count = count($users); 130 $output .= $this->output->heading(get_string("subscriberstowithcount", "forum", $strparams)); 131 $table = new html_table(); 132 $table->cellpadding = 5; 133 $table->cellspacing = 5; 134 $table->tablealign = 'center'; 135 $table->data = array(); 136 foreach ($users as $user) { 137 $info = array($this->output->user_picture($user, array('courseid'=>$course->id)), fullname($user)); 138 if ($canviewemail) { 139 array_push($info, $user->email); 140 } 141 $table->data[] = $info; 142 } 143 $output .= html_writer::table($table); 144 } 145 return $output; 146 } 147 148 /** 149 * This is used to display a control containing all of the subscribed users so that 150 * it can be searched 151 * 152 * @param user_selector_base $existingusers 153 * @return string 154 */ 155 public function subscribed_users(user_selector_base $existingusers) { 156 $output = $this->output->box_start('subscriberdiv boxaligncenter'); 157 $output .= html_writer::tag('p', get_string('forcesubscribed', 'forum')); 158 $output .= $existingusers->display(true); 159 $output .= $this->output->box_end(); 160 return $output; 161 } 162 163 /** 164 * Generate the HTML for an icon to be displayed beside the subject of a timed discussion. 165 * 166 * @param object $discussion 167 * @param bool $visiblenow Indicicates that the discussion is currently 168 * visible to all users. 169 * @return string 170 */ 171 public function timed_discussion_tooltip($discussion, $visiblenow) { 172 $dates = array(); 173 if ($discussion->timestart) { 174 $dates[] = get_string('displaystart', 'mod_forum').': '.userdate($discussion->timestart); 175 } 176 if ($discussion->timeend) { 177 $dates[] = get_string('displayend', 'mod_forum').': '.userdate($discussion->timeend); 178 } 179 180 $str = $visiblenow ? 'timedvisible' : 'timedhidden'; 181 $dates[] = get_string($str, 'mod_forum'); 182 183 $tooltip = implode("\n", $dates); 184 return $this->pix_icon('i/calendar', $tooltip, 'moodle', array('class' => 'smallicon timedpost')); 185 } 186 187 /** 188 * Display a forum post in the relevant context. 189 * 190 * @param \mod_forum\output\forum_post $post The post to display. 191 * @return string 192 */ 193 public function render_forum_post_email(\mod_forum\output\forum_post_email $post) { 194 $data = $post->export_for_template($this, $this->target === RENDERER_TARGET_TEXTEMAIL); 195 return $this->render_from_template('mod_forum/' . $this->forum_post_template(), $data); 196 } 197 198 /** 199 * The template name for this renderer. 200 * 201 * @return string 202 */ 203 public function forum_post_template() { 204 return 'forum_post'; 205 } 206 }
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 |