$params = array('id' => $cm->id, 'conversationid' => $record->conversationid, 'action' => 'edit'); $editlink = html_writer::link(new moodle_url('conversation.php', $params), get_string('edit'), array()); } else { $label = html_writer::tag('span', get_string('draftreply', 'dialogue'), array('class' => 'state-indicator state-draft')); $datattributes = array('data-redirect' => 'reply', 'data-action' => 'edit', 'data-conversationid' => $record->conversationid, 'data-messageid' => $record->id); $params = array('id' => $cm->id, 'conversationid' => $record->conversationid, 'messageid' => $record->id, 'action' => 'edit'); $editlink = html_writer::link(new moodle_url('reply.php', $params), get_string('edit'), array()); } $html .= html_writer::start_tag('tr', $datattributes); $html .= html_writer::tag('td', $label); $subject = empty($record->subject) ? get_string('nosubject', 'dialogue') : $record->subject; $subject = html_writer::tag('strong', $subject); $shortenedbody = dialogue_shorten_html($record->body, 60); $shortenedbody = html_writer::tag('span', $shortenedbody); $html .= html_writer::tag('td', $subject . ' - ' . $shortenedbody); $date = (object) dialogue_get_humanfriendly_dates($record->timemodified); if ($date->today) { $timemodified = $date->time; } else { if ($date->currentyear) { $timemodified = new lang_string('dateshortyear', 'dialogue', $date); } else { $timemodified = new lang_string('datefullyear', 'dialogue', $date); } } $html .= html_writer::tag('td', $timemodified, array('title' => userdate($record->timemodified))); $html .= html_writer::tag('td', $editlink, array('class' => 'nonjs-control')); $html .= html_writer::end_tag('tr'); } $html .= html_writer::end_tag('tbody'); //$html .= html_writer::tag('caption', '@todo');
/** * Render a reply related to conversation. * * @param dialogue_reply $reply * @return string */ public function render_reply(\mod_dialogue\reply $reply) { global $OUTPUT, $USER; $context = $reply->dialogue->context; // fetch context from parent dialogue $cm = $reply->dialogue->cm; // fetch course module from parent dialogue $conversation = $reply->conversation; // fetch parent conversation $today = strtotime("today"); $yearago = strtotime("-1 year"); $html = ''; $html .= html_writer::start_div('conversation'); $messageid = 'm' . $reply->messageid; $html .= html_writer::tag('a', '', array('id' => $messageid)); $avatar = $OUTPUT->user_picture($reply->author, array('size' => true, 'class' => 'userpicture img-rounded')); $html .= html_writer::div($avatar, 'conversation-object pull-left'); $html .= html_writer::start_div('conversation-body'); $datestrings = (object) dialogue_get_humanfriendly_dates($reply->timemodified); $datestrings->fullname = fullname($reply->author); //sneaky if ($reply->timemodified >= $today) { $repliedbyheader = get_string('repliedbytoday', 'dialogue', $datestrings); } else { if ($reply->timemodified >= $yearago) { $repliedbyheader = get_string('repliedbyshortyear', 'dialogue', $datestrings); } else { $repliedbyheader = get_string('repliedbyfullyear', 'dialogue', $datestrings); } } $html .= html_writer::start_div('reply-header'); $html .= html_writer::tag('span', $repliedbyheader, array('class' => 'reply-openedby pull-left')); $html .= html_writer::empty_tag('br'); $html .= html_writer::end_div(); $html .= html_writer::empty_tag('hr'); $html .= $reply->bodyhtml; $html .= $this->render_attachments($reply->attachments); $html .= html_writer::end_div(); $html .= html_writer::end_div(); return $html; }