function ouwiki_display_page_in_index($indexitem, $subwiki, $cm) { if ($startpage = is_null($indexitem->title)) { $title = get_string('startpage', 'ouwiki'); $output = '<div class="ouw_index_startpage">'; } else { $title = $indexitem->title; $output = ''; } $output .= '<a class="ouw_title" href="view.php?' . ouwiki_display_wiki_parameters($indexitem->title, $subwiki, $cm) . '">' . htmlspecialchars($title) . '</a>'; $lastchange = new StdClass(); $lastchange->userlink = ouwiki_display_user($indexitem, $cm->course); $lastchange->date = ouwiki_recent_span($indexitem->timecreated) . ouwiki_nice_date($indexitem->timecreated) . '</span>'; $output .= '<div class="ouw_indexinfo">'; $output .= ' <span class="ouw_lastchange">' . get_string('lastchange', 'ouwiki', $lastchange) . '</span>'; $output .= '</div>'; if ($startpage) { $output .= '</div>'; } return $output; }
/** * Print the table which list the comments by the user in this subwiki, * with the date of the comment and a link to the page * * @param unknown_type $subwiki the subwiki in question * @param unknown_type $cm * @param unknown_type $userid the id of the user * @param unknown_type $header the header text for the table */ function reportsuser_usercommentstable($subwiki, $cm, $userid, $header, $csv) { // get the user comments info $usercomments = ouwiki_get_usercomments($subwiki->id, $userid); if (count($usercomments) == 0) { return; } // Print the opening div and table tags as well as the header row if (!$csv) { print <<<EOF <div class="ouw_usercommentslist"> \t<h3>{$header->comments}</h3> \t<table> \t\t<tr> \t\t\t<th class='ouw_leftcol' scope="col">{$header->datetime}</th> \t\t\t<th class='ouw_rightcol' scope="col">{$header->pagename}</th>\t\t\t \t\t</tr>\t\t EOF; } else { print $csv->line() . $csv->quote($header->comments) . $csv->line() . $csv->quote($header->datetime) . $csv->sep() . $csv->quote($header->pagename) . $csv->line(); } // for each comment in this subwiki by the user foreach ($usercomments as $usercomment) { // get the date and time of the comment $datetime = ouwiki_nice_date($usercomment->timeposted); // get the page title of the page with the comment $title = $usercomment->title; // make it html safe $pagetitle = htmlspecialchars($title); // create html link to the page $pagelink = "<a href='view.php?" . ouwiki_display_wiki_parameters($title, $subwiki, $cm) . "'>{$pagetitle}</a>"; // if title is blank then must be subwiki start page - create link to there if ($title == '') { $pagelink = "<a href='view.php?" . ouwiki_display_wiki_parameters(null, $subwiki, $cm) . "'>" . get_string('startpage', 'ouwiki') . "</a>"; } // print the table row for date and time and page link for comments by user if (!$csv) { print <<<EOF \t\t<tr> \t\t\t<td class='ouw_leftcol'>{$datetime}</td> \t\t\t<td class='ouw_rightcol'>{$pagelink}</td>\t \t\t</tr>\t\t EOF; } else { if ($title == '') { $title = get_string('startpage', 'ouwiki'); } print $csv->quote($datetime) . $csv->sep() . $csv->quote($title) . $csv->line(); } } // close table and div tags if (!$csv) { print ' </table> </div>'; } }
// Check permission - Allow anyone with edit capability to revert to a previous version $canrevert = has_capability('mod/ouwiki:edit', $context); if (!$canrevert) { print_error('reverterrorcapability', 'ouwiki'); } // Check if reverting to previous version has been confirmed $confirmed = optional_param('confirm', null, PARAM_RAW); if ($confirmed) { // Lock something - but maybe this should be the current version list($lockok, $lock) = ouwiki_obtain_lock($ouwiki, $pageversion->pageid); // Revert to previous version ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $pagename, $pageversion->xhtml); // Unlock whatever we locked ouwiki_release_lock($pageversion->pageid); // Redirect to view what is now the current version redirect('view.php?' . ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_URL)); exit; } else { // Display confirm form $nav = get_string('revertversion', 'ouwiki'); ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context, array(array('name' => $nav, 'type' => 'ouwiki')), true, true); print_box_start(); $a = ouwiki_nice_date($pageversion->timecreated); print get_string('revertversionconfirm', 'ouwiki', $a); print '<form action="revert.php" method="post">'; print ouwiki_display_wiki_parameters($pagename, $subwiki, $cm, OUWIKI_PARAMS_FORM); print '<input type="hidden" name="version" value="' . $versionid . '" />' . '<input type="submit" name="confirm" value="' . get_string('revertversion', 'ouwiki') . '"/> ' . '<input type="submit" name="cancel" value="' . get_string('cancel') . '"/>'; print '</form>'; print_box_end(); ouwiki_print_footer($course, $cm, $subwiki, $pagename); }
<feed xmlns="http://www.w3.org/2005/Atom"> <link rel="self" href="' . $feedlink . '"/> <title>' . $feedtitle . '</title> <subtitle>' . $feeddescription . '</subtitle> <link href="http://example.org/"/> <updated>' . date('c', reset($changes)->timecreated) . '</updated> <author> <name>Wiki system</name> </author> <id>' . $id . '</id>'; } foreach ($changes as $change) { $pageparams = ouwiki_display_wiki_parameters($change->title, $subwiki, $cm); $a = new StdClass(); $a->name = htmlspecialchars(fullname($change)); $a->date = ouwiki_nice_date($change->timecreated); $itemtitle = $ouwiki->name . ' - ' . ($change->title === '' ? get_string('startpage', 'ouwiki') : htmlspecialchars($change->title)); $itemlink = $CFG->wwwroot . '/mod/ouwiki/view.php?' . $pageparams; if (!empty($change->previousversionid)) { $a->url = $CFG->wwwroot . '/mod/ouwiki/diff.php?' . $pageparams . '&v1=' . $change->previousversionid . '&v2=' . $change->versionid; $a->main = get_string('feedchange', 'ouwiki', $a); } else { $a->main = get_string('feednewpage', 'ouwiki', $a); } $itemdescription = get_string('feeditemdescriptiondate', 'ouwiki', $a); if ($rss) { // The 'permalink' guid just points to the wiki history page but with a unique-ifying versionid on end print ' <item> <title>' . $itemtitle . '</title> <link>' . $itemlink . '</link>
$wikiparams = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm); $tabhistparams = ouwiki_shared_url_params($pagename, $subwiki, $cm); echo $ouwikioutput->ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context, array(array('name' => get_string('tab_history', 'ouwiki'), 'link' => new moodle_url('/mod/ouwiki/history.php', $tabhistparams)), array('name' => get_string('oldversion', 'ouwiki'), 'link' => null)), true, true); // Information box if ($prevnext->prev) { $date = ouwiki_nice_date($prevnext->prev->timecreated); $prev = link_arrow_left(get_string('previousversion', 'ouwiki', $date), "viewold.php?{$wikiparams}&version={$prevnext->prev->versionid}"); } else { $prev = ''; } if ($prevnext->next) { if ($prevnext->next->versionid == $pageversion->currentversionid) { $date = get_string('currentversion', 'ouwiki'); $next = link_arrow_right(get_string('nextversion', 'ouwiki', $date), "view.php?{$wikiparams}"); } else { $date = ouwiki_nice_date($prevnext->next->timecreated); $next = link_arrow_right(get_string('nextversion', 'ouwiki', $date), "viewold.php?{$wikiparams}&version={$prevnext->next->versionid}"); } } else { $next = ''; } $date = userdate($pageversion->timecreated); $pageversion->id = $pageversion->userid; // To make it look like a user object $name = ouwiki_display_user($pageversion, $course->id); $savedby = get_string('savedby', 'ouwiki', $name); $stradvice = get_string('advice_viewold', 'ouwiki'); if (!empty($pageversion->deletedat)) { $stradvice = get_string('advice_viewdeleted', 'ouwiki'); } print "\n<div class='ouw_oldversion'>\n <h1>{$date} <span class='ouw_person'>({$savedby})</span></h1>\n <p>" . $stradvice . "</p>\n <div class='ouw_prev'>{$prev}</div>\n <div class='ouw_next'>{$next}</div>\n <div class='clearer'></div>\n</div>";
<updated>' . date('c', reset($changes)->timecreated) . '</updated> <author> <name>Wiki system</name> </author> <id>' . $id . '</id>'; } $pageparams = ouwiki_display_wiki_parameters($pagename, $subwiki, $cm); foreach ($changes as $change) { $a = new StdClass(); $a->name = htmlspecialchars(fullname($change)); if ($change->versionid == $pageversion->versionid) { $itemlink = $CFG->wwwroot . '/mod/ouwiki/view.php?' . $pageparams; } else { $itemlink = $CFG->wwwroot . '/mod/ouwiki/viewold.php?' . $pageparams . '&version=' . $change->versionid; } $itemtitle = $ouwiki->name . ' - ' . $pagetitle . ' (' . ouwiki_nice_date($change->timecreated) . ')'; $nextchange = next($changes); if ($nextchange) { $a->url = $CFG->wwwroot . '/mod/ouwiki/diff.php?' . $pageparams . '&v1=' . $nextchange->versionid . '&v2=' . $change->versionid; $a->main = get_string('feedchange', 'ouwiki', $a); } else { $a->main = get_string('feednewpage', 'ouwiki', $a); } $itemdescription = get_string('feeditemdescriptionnodate', 'ouwiki', $a); if ($rss) { // The 'permalink' guid just points to the wiki history page but with a unique-ifying versionid on end print ' <item> <title>' . $itemtitle . '</title> <link>' . $itemlink . '</link> <pubDate>' . date('r', $change->timecreated) . '</pubDate>
/** * Print the main page content * * @param object $subwiki For details of user/group and ID so that * we can make links * @param object $cm Course-module object (again for making links) * @param object $pageversion Data from page and version tables. * @param bool $hideannotations If true, adds extra class to hide annotations * @return string HTML content for page */ public function ouwiki_print_page($subwiki, $cm, $pageversion, $gewgaws = null, $page = 'history', $showwordcount = 0, $hideannotations = false) { $output = ''; $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); global $CFG, $ouwikiinternalre; require_once $CFG->libdir . '/filelib.php'; // Get annotations - only if using annotation system. prevents unnecessary db access if ($subwiki->annotation) { $annotations = ouwiki_get_annotations($pageversion); } else { $annotations = ''; } // Title $title = $pageversion->title === '' ? get_string('startpage', 'ouwiki') : htmlspecialchars($pageversion->title); // setup annotations according to the page we are on if ($page == 'view') { // create the annotations if ($subwiki->annotation && count($annotations)) { ouwiki_highlight_existing_annotations(&$pageversion->xhtml, $annotations, 'view'); } } else { if ($page == 'annotate') { // call function for the annotate page ouwiki_setup_annotation_markers(&$pageversion->xhtml); ouwiki_highlight_existing_annotations(&$pageversion->xhtml, $annotations, 'annotate'); } } // Must rewrite plugin urls AFTER doing annotations because they depend on byte // position in unmolested data from db $pageversion->xhtml = file_rewrite_pluginfile_urls($pageversion->xhtml, 'pluginfile.php', $modcontext->id, 'mod_ouwiki', 'content', $pageversion->versionid); // get files up here so we have them for the portfolio button addition as well $fs = get_file_storage(); $files = $fs->get_area_files($modcontext->id, 'mod_ouwiki', 'attachment', $pageversion->versionid, "timemodified", false); $output .= html_writer::start_tag('div', array('class' => 'ouwiki-content' . ($hideannotations ? ' ouwiki-hide-annotations' : ''))); $output .= html_writer::start_tag('div', array('class' => 'ouw_topheading')); $output .= html_writer::start_tag('div', array('class' => 'ouw_heading')); $output .= html_writer::tag('h1', format_string($title), array('class' => 'ouw_topheading')); if ($gewgaws) { $output .= $this->render_heading_bit(1, $pageversion->title, $subwiki, $cm, null, $annotations, $pageversion->locked, $files, $pageversion->pageid); } else { $output .= html_writer::end_tag('div'); } // List of recent changes if ($gewgaws && $pageversion->recentversions) { $output .= html_writer::start_tag('div', array('class' => 'ouw_recentchanges')); $output .= get_string('recentchanges', 'ouwiki') . ': '; $output .= html_writer::start_tag('span', array('class' => 'ouw_recentchanges_list')); $first = true; foreach ($pageversion->recentversions as $recentversion) { if ($first) { $first = false; } else { $output .= '; '; } $output .= ouwiki_recent_span($recentversion->timecreated); $output .= ouwiki_nice_date($recentversion->timecreated); $output .= html_writer::end_tag('span'); $output .= ' ('; $recentversion->id = $recentversion->userid; // so it looks like a user object $output .= ouwiki_display_user($recentversion, $cm->course, false); $output .= ')'; } $output .= '; '; $pagestr = ''; if (strtolower(trim($title)) !== strtolower(get_string('startpage', 'ouwiki'))) { $pagestr = '&page=' . $title; } $output .= html_writer::tag('a', get_string('seedetails', 'ouwiki'), array('href' => $CFG->wwwroot . '/mod/ouwiki/history.php?id=' . $cm->id . $pagestr)); $output .= html_writer::end_tag('span'); $output .= html_writer::end_tag('div'); } $output .= html_writer::end_tag('div'); $output .= html_writer::start_tag('div', array('class' => 'ouw_belowmainhead')); // spacer $output .= html_writer::start_tag('div', array('class' => 'ouw_topspacer')); $output .= html_writer::end_tag('div'); // Content of page $output .= ouwiki_convert_content($pageversion->xhtml, $subwiki, $cm, null, $pageversion->xhtmlformat); if ($gewgaws) { // Add in links/etc. around headings $ouwikiinternalre->pagename = $pageversion->title; $ouwikiinternalre->subwiki = $subwiki; $ouwikiinternalre->cm = $cm; $ouwikiinternalre->annotations = $annotations; $ouwikiinternalre->locked = $pageversion->locked; $ouwikiinternalre->pageversion = $pageversion; $ouwikiinternalre->files = $files; $output = preg_replace_callback('|<h([1-9]) id="ouw_s([0-9]+_[0-9]+)">(.*?)(<br\\s*/>)?</h[1-9]>|s', 'ouwiki_internal_re_heading', $output); } $output .= html_writer::start_tag('div', array('class' => 'clearer')); $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); // Render wordcount if ($showwordcount) { $output .= $this->ouwiki_render_wordcount($pageversion->wordcount); } $output .= html_writer::end_tag('div'); // attached files if ($files) { $output .= html_writer::start_tag('div', array('class' => 'ouwiki-post-attachments')); $output .= html_writer::tag('h3', get_string('attachments', 'ouwiki'), array('class' => 'ouw_topheading')); $output .= html_writer::start_tag('ul'); foreach ($files as $file) { $output .= html_writer::start_tag('li'); $filename = $file->get_filename(); $mimetype = $file->get_mimetype(); $iconimage = html_writer::empty_tag('img', array('src' => $this->output->pix_url(file_mimetype_icon($mimetype)), 'alt' => $mimetype, 'class' => 'icon')); $path = file_encode_url($CFG->wwwroot . '/pluginfile.php', '/' . $modcontext->id . '/mod_ouwiki/attachment/' . $pageversion->versionid . '/' . $filename); $output .= html_writer::tag('a', $iconimage, array('href' => $path)); $output .= html_writer::tag('a', s($filename), array('href' => $path)); $output .= html_writer::end_tag('li'); } $output .= html_writer::end_tag('ul'); $output .= html_writer::end_tag('div'); } // pages that link to this page if ($gewgaws) { $links = ouwiki_get_links_to($pageversion->pageid); if (count($links) > 0) { $output .= html_writer::start_tag('div', array('class' => 'ouw_linkedfrom')); $output .= html_writer::tag('h3', get_string(count($links) == 1 ? 'linkedfromsingle' : 'linkedfrom', 'ouwiki'), array('class' => 'ouw_topheading')); $output .= html_writer::start_tag('ul'); $first = true; foreach ($links as $link) { $output .= html_writer::start_tag('li'); if ($first) { $first = false; } else { $output .= '• '; } $linktitle = $link->title ? htmlspecialchars($link->title) : get_string('startpage', 'ouwiki'); $output .= html_writer::tag('a', $linktitle, array('href' => $CFG->wwwroot . '/mod/ouwiki/view.php?' . ouwiki_display_wiki_parameters($link->title, $subwiki, $cm, OUWIKI_PARAMS_URL))); $output .= html_writer::end_tag('li'); } $output .= html_writer::end_tag('ul'); $output .= html_writer::end_tag('div'); } } // disply the orphaned annotations if ($subwiki->annotation && $annotations && $page != 'history') { $orphaned = ''; foreach ($annotations as $annotation) { if ($annotation->orphaned) { $orphaned .= $this->ouwiki_print_hidden_annotation($annotation); } } if ($orphaned !== '') { $output .= html_writer::tag('h3', get_string('orphanedannotations', 'ouwiki')); $output .= $orphaned; } else { $output = $output; } } return array($output, $annotations); }
// Handle case where page is locked by someone else if (!$lockok) { // Print header etc echo $ouwikioutput->ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context); $lockholder = $DB->get_record('user', array('id' => $lock->userid)); $pagelockedtitle = get_string('pagelockedtitle', 'ouwiki'); $pagelockedtimeout = ''; $details = new StdClass(); $details->name = fullname($lockholder); $details->lockedat = ouwiki_nice_date($lock->lockedat); $details->seenat = ouwiki_nice_date($lock->seenat); if ($lock->seenat > time()) { // When the 'seen at' value is greater than current time, that means // their lock has been automatically confirmed in advance because they // don't have JavaScript support. $details->nojs = ouwiki_nice_date($lock->seenat + OUWIKI_LOCK_PERSISTENCE); $pagelockeddetails = get_string('pagelockeddetailsnojs', 'ouwiki', $details); } else { $pagelockeddetails = get_string('pagelockeddetails', 'ouwiki', $details); if ($lock->expiresat) { $pagelockedtimeout = get_string('pagelockedtimeout', 'ouwiki', userdate($lock->expiresat)); } } $canoverride = has_capability('mod/ouwiki:overridelock', $context); $pagelockedoverride = $canoverride ? '<p>' . get_string('pagelockedoverride', 'ouwiki') . '</p>' : ''; $overridelock = get_string('overridelock', 'ouwiki'); $overridebutton = $canoverride ? "\n<form class='ouwiki_overridelock' action='override.php' method='post'>\n <input type='hidden' name='redirpage' value='annotate' />\n {$wikiformfields}\n <input type='submit' value='{$overridelock}' />\n</form>\n" : ''; $cancel = get_string('cancel'); $tryagain = get_string('tryagain', 'ouwiki'); print "\n<div id='ouwiki_lockinfo'>\n <h2>{$pagelockedtitle}</h2>\n <p>{$pagelockeddetails} {$pagelockedtimeout}</p>\n {$pagelockedoverride}\n <div class='ouwiki_lockinfobuttons'>\n <form action='edit.php' method='get'>\n {$wikiformfields}\n <input type='submit' value='{$tryagain}' />\n </form>\n <form action='view.php' method='get'>\n {$wikiformfields}\n <input type='submit' value='{$cancel}' />\n </form>\n {$overridebutton}\n </div>\n </div><div>"; ouwiki_print_footer($course, $cm, $subwiki, $pagename);
/** * Print the main page content * * @param object $subwiki For details of user/group and ID so that * we can make links * @param object $cm Course-module object (again for making links) * @param object $pageversion Data from page and version tables. * @param bool $gewgaws A decorator indicator. * @param string $page Page type * @param int $showwordcount * @param bool $hideannotations If true, adds extra class to hide annotations * @return string HTML content for page */ public function ouwiki_print_page($subwiki, $cm, $pageversion, $gewgaws = null, $page = 'history', $showwordcount = 0, $hideannotations = false) { global $CFG, $ouwikiinternalre; require_once $CFG->libdir . '/filelib.php'; $output = ''; $modcontext = context_module::instance($cm->id); $title = $pageversion->title === '' ? get_string('startpage', 'ouwiki') : htmlspecialchars($pageversion->title); // Get annotations - only if using annotation system. Prevents unnecessary db access. if ($subwiki->annotation) { $annotations = ouwiki_get_annotations($pageversion); } else { $annotations = ''; } // Setup annotations according to the page we are on. if ($page == 'view') { if ($subwiki->annotation && count($annotations)) { $pageversion->xhtml = ouwiki_highlight_existing_annotations($pageversion->xhtml, $annotations, 'view'); } } else { if ($page == 'annotate') { $pageversion->xhtml = ouwiki_setup_annotation_markers($pageversion->xhtml); $pageversion->xhtml = ouwiki_highlight_existing_annotations($pageversion->xhtml, $annotations, 'annotate'); } } // Must rewrite plugin urls AFTER doing annotations because they depend on byte position. $pageversion->xhtml = file_rewrite_pluginfile_urls($pageversion->xhtml, 'pluginfile.php', $modcontext->id, 'mod_ouwiki', 'content', $pageversion->versionid); $pageversion->xhtml = ouwiki_convert_content($pageversion->xhtml, $subwiki, $cm, null, $pageversion->xhtmlformat); // Get files here so we have them for the portfolio button addition as well. $fs = get_file_storage(); $files = $fs->get_area_files($modcontext->id, 'mod_ouwiki', 'attachment', $pageversion->versionid, "timemodified", false); // Start gathering output. $output .= html_writer::start_tag('div', array('class' => 'ouwiki-content' . ($hideannotations ? ' ouwiki-hide-annotations' : ''))); $output .= $this->get_topheading_section($title, $gewgaws, $pageversion, $annotations, $files); // List of recent changes. if ($gewgaws && $pageversion->recentversions) { $output .= html_writer::start_tag('div', array('class' => 'ouw_recentchanges')); $output .= get_string('recentchanges', 'ouwiki') . ': '; $output .= html_writer::start_tag('span', array('class' => 'ouw_recentchanges_list')); $first = true; foreach ($pageversion->recentversions as $recentversion) { if ($first) { $first = false; } else { $output .= '; '; } $output .= ouwiki_recent_span($recentversion->timecreated); $output .= ouwiki_nice_date($recentversion->timecreated); $output .= html_writer::end_tag('span'); $output .= ' ('; $recentversion->id = $recentversion->userid; // So it looks like a user object. $output .= ouwiki_display_user($recentversion, $cm->course, false); $output .= ')'; } $output .= '; '; $pagestr = ''; if (strtolower(trim($title)) !== strtolower(get_string('startpage', 'ouwiki'))) { $pagestr = '&page=' . $title; } $output .= html_writer::tag('a', get_string('seedetails', 'ouwiki'), array('href' => $CFG->wwwroot . '/mod/ouwiki/history.php?id=' . $cm->id . $pagestr)); $output .= html_writer::end_tag('span'); $output .= html_writer::end_tag('div'); } $output .= $this->get_new_annotations_section($gewgaws, $pageversion, $annotations, $files); $output .= html_writer::end_tag('div'); // Main content of page. $output .= html_writer::start_tag('div', array('class' => 'ouw_belowmainhead')); $output .= html_writer::start_tag('div', array('class' => 'ouw_topspacer')); $output .= html_writer::end_tag('div'); $output .= $pageversion->xhtml; if ($gewgaws) { // Add in links around headings. $ouwikiinternalre = new stdClass(); $ouwikiinternalre->pagename = $pageversion->title; $ouwikiinternalre->subwiki = $subwiki; $ouwikiinternalre->cm = $cm; $ouwikiinternalre->annotations = $annotations; $ouwikiinternalre->locked = $pageversion->locked; $ouwikiinternalre->pageversion = $pageversion; $ouwikiinternalre->files = $files; $output = preg_replace_callback('|<h([1-9]) id="ouw_s([0-9]+_[0-9]+)">(.*?)(<br\\s*/>)?</h[1-9]>|s', 'ouwiki_internal_re_heading', $output); } $output .= html_writer::tag('div', '', array('class' => 'clearer')); $output .= html_writer::end_tag('div'); // End of ouw_belowmainhead. // Add wordcount. if ($showwordcount) { $output .= $this->ouwiki_render_wordcount($pageversion->wordcount); } $output .= html_writer::end_tag('div'); // End of ouwiki-content. // Add attached files. $output .= $this->get_attached_files($files, $modcontext, $pageversion); // Pages that link to this page. if ($gewgaws) { $links = ouwiki_get_links_to($pageversion->pageid); if (count($links) > 0) { $output .= $this->get_links_to($links); } } // Display the orphaned annotations. if ($subwiki->annotation && $annotations && $page != 'history') { $orphaned = ''; foreach ($annotations as $annotation) { if ($annotation->orphaned) { $orphaned .= $this->ouwiki_print_hidden_annotation($annotation); } } if ($orphaned !== '') { $output .= html_writer::start_div('ouw-orphaned-annotations'); $output .= html_writer::tag('h3', get_string('orphanedannotations', 'ouwiki')); $output .= $orphaned; $output .= html_writer::end_div(); } else { $output = $output; } } $output .= $this->get_new_buttons_section($gewgaws, $pageversion); return array($output, $annotations); }
/** * Displays an array of comments in the order of the array. * @param array $comments Array of comment objects * @param string $fromphp Page name i.e. 'view' or 'comments' * @param string $section Comment section (null for main page) * @param string $page Name of page (null for startpage) * @param object $subwiki Current subwiki object * @param object $cm Course-module object * @param bool $candelete If true, user gets delete option for everything not just * their own comments, also gets undelete * @return string XHTML for output */ function ouwiki_display_comments($comments, $section, $page, $subwiki, $cm, $showdelete = false, $candelete = false) { global $USER; $out = '<ul class="ouw_comments">'; $first = true; $strcommenter = get_string('access_commenter', 'ouwiki') . ': '; $strdate = get_string('date') . ': '; foreach ($comments as $comment) { $out .= '<li class="ouw_comment' . ($comment->deleted ? ' ouw_deletedcomment' : '') . ($first ? ' ouw_firstcomment' : '') . '">'; $first = false; $user = new StdClass(); $user->id = $comment->userid; $user->firstname = $comment->firstname; $user->lastname = $comment->lastname; $out .= '<div class="ouw_commentposter"><span class="accesshide">' . $strcommenter . '</span>' . ouwiki_display_user($user, $cm->course) . '</div>'; $out .= '<div class="ouw_commentdate"><span class="accesshide">' . $strdate . '</span>' . ouwiki_nice_date($comment->timeposted, false, true) . '</div>'; if ($comment->section != $section) { $out .= '<div class="ouw_commentsection">' . get_string('commentoriginalsection', 'ouwiki', $comment->sectiontitle) . '</div>'; } if ($comment->title !== null) { $out .= '<h3 class="ouw_commenttitle">' . htmlspecialchars($comment->title) . '</h3>'; } $out .= '<div class="ouw_commentxhtml">'; $out .= format_text($comment->xhtml); $out .= '</div>'; if ($showdelete && ($candelete || $USER->id == $comment->userid)) { $out .= '<form class="ouw_commentsubmit" action="deletecomment.php" method="post">'; $out .= ouwiki_display_wiki_parameters($page, $subwiki, $cm, OUWIKI_PARAMS_FORM); $out .= '<input type="hidden" name="section" value="' . $section . '" />'; $out .= '<input type="hidden" name="comment" value="' . $comment->id . '" />'; $out .= '<input type="hidden" name="delete" value="' . ($comment->deleted ? 0 : 1) . '" />'; $out .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; $out .= '<input type="submit" value="' . get_string($comment->deleted ? 'commentundelete' : 'commentdelete', 'ouwiki') . '" />'; $out .= '</form>'; } $out .= '</li>'; } $out .= '</ul>'; return $out; }
function ouwiki_display_wikiindex_page_in_index($indexitem, $subwiki, $cm) { global $ouwiki; if ($startpage = $indexitem->title === '') { $title = get_string('startpage', 'ouwiki'); $output = '<div class="ouw_index_startpage">'; } else { $title = $indexitem->title; $output = ''; } $output .= '<div class="ouw_title"><a class="ouw_title_link" href="view.php?' . ouwiki_display_wiki_parameters($indexitem->title, $subwiki, $cm) . '">' . htmlspecialchars($title) . '</a></div>'; $lastchange = new StdClass(); $lastchange->userlink = ouwiki_display_user($indexitem, $cm->course); $lastchange->date = ouwiki_recent_span($indexitem->timecreated) . ouwiki_nice_date($indexitem->timecreated) . '</span>'; $output .= '<div class="ouw_indexinfo">'; if ($ouwiki->enablewordcount) { $output .= '<span class="ouw_wordcount">' . get_string('numwords', 'ouwiki', $indexitem->wordcount) . '</span>'; $output .= '<div class="spacer"></div>'; } $output .= ' <span class="ouw_lastchange">' . get_string('lastchange', 'ouwiki', $lastchange) . '</span>'; $output .= '</div>'; if ($startpage) { $output .= '</div>'; } return $output; }