97
101
function __construct($wiki, $subwiki, $cm) {
98
102
global $PAGE, $CFG;
99
103
$this->subwiki = $subwiki;
100
$this->modcontext = context_module::instance($PAGE->cm->id);
105
$this->modcontext = context_module::instance($this->cm->id);
102
107
// initialise wiki renderer
103
108
$this->wikioutput = $PAGE->get_renderer('mod_wiki');
105
110
$PAGE->set_cm($cm);
106
111
$PAGE->set_activity_record($wiki);
107
112
// the search box
108
$PAGE->set_button(wiki_search_form($cm));
113
if (!empty($subwiki->id)) {
114
$search = optional_param('searchstring', null, PARAM_ALPHANUMEXT);
115
$PAGE->set_button(wiki_search_form($cm, $search, $subwiki));
114
122
function print_header() {
115
123
global $OUTPUT, $PAGE, $CFG, $USER, $SESSION;
117
$PAGE->set_heading(format_string($PAGE->course->fullname));
125
$PAGE->set_heading($PAGE->course->fullname);
119
127
$this->set_url();
146
$html .= $OUTPUT->container_start();
147
$html .= $OUTPUT->heading(format_string($this->title), 2, 'wiki_headingtitle');
156
$html .= $OUTPUT->container_start('wiki_headingtitle');
157
$html .= $OUTPUT->heading(format_string($this->title), 3);
148
158
$html .= $OUTPUT->container_end();
156
166
protected function setup_tabs($options = array()) {
157
167
global $CFG, $PAGE;
158
$groupmode = groups_get_activity_groupmode($PAGE->cm);
168
$groupmode = groups_get_activity_groupmode($this->cm);
160
170
if (empty($CFG->usecomments) || !has_capability('mod/wiki:viewcomment', $PAGE->context)){
161
171
unset($this->tabs['comments']);
168
178
if ($groupmode and $groupmode == VISIBLEGROUPS) {
169
$currentgroup = groups_get_activity_group($PAGE->cm);
170
$manage = has_capability('mod/wiki:managewiki', $PAGE->cm->context);
179
$currentgroup = groups_get_activity_group($this->cm);
180
$manage = has_capability('mod/wiki:managewiki', $this->modcontext);
171
181
$edit = has_capability('mod/wiki:editpage', $PAGE->context);
172
182
if (!$manage and !($edit and groups_is_member($currentgroup))) {
173
183
unset($this->tabs['edit']);
329
335
global $PAGE, $CFG;
330
336
$params = array();
332
if (isset($this->coursemodule)) {
333
$params['id'] = $this->coursemodule;
338
if (isset($this->cm->id)) {
339
$params['id'] = $this->cm->id;
334
340
} else if (!empty($this->page) and $this->page != null) {
335
341
$params['pageid'] = $this->page->id;
336
342
} else if (!empty($this->gid)) {
337
$params['wid'] = $PAGE->cm->instance;
343
$params['wid'] = $this->cm->instance;
338
344
$params['group'] = $this->gid;
339
345
} else if (!empty($this->title)) {
340
346
$params['swid'] = $this->subwiki->id;
343
349
print_error(get_string('invalidparameters', 'wiki'));
346
351
$PAGE->set_url(new moodle_url($CFG->wwwroot . '/mod/wiki/view.php', $params));
349
function set_coursemodule($id) {
350
$this->coursemodule = $id;
353
354
protected function create_navbar() {
391
392
if (isset($this->section)) {
392
393
$title .= ' : ' . $this->section;
394
echo $OUTPUT->container_start('wiki_clear');
395
echo $OUTPUT->heading(format_string($title), 2, 'wiki_headingtitle');
395
echo $OUTPUT->container_start('wiki_clear wiki_headingtitle');
396
echo $OUTPUT->heading(format_string($title), 3);
396
397
echo $OUTPUT->container_end();
564
565
$params['filearea'] = 'attachments';
567
if (!empty($CFG->usetags)) {
568
$params['tags'] = tag_get_tags_csv('wiki_pages', $this->page->id, TAG_RETURN_TEXT);
571
568
$form = new mod_wiki_edit_form($url, $params);
573
570
if ($formdata = $form->get_data()) {
623
620
$format = $version->contentformat;
625
622
if (empty($comments)) {
626
echo $OUTPUT->heading(get_string('nocomments', 'wiki'));
623
echo html_writer::tag('p', get_string('nocomments', 'wiki'), array('class' => 'bold'));
629
626
foreach ($comments as $comment) {
834
831
global $PAGE, $CFG;
835
832
$PAGE->set_url($CFG->wwwroot . '/mod/wiki/search.php');
835
function print_header() {
838
parent::print_header();
840
$wiki = $PAGE->activityrecord;
841
$page = (object)array('title' => $wiki->firstpagetitle);
842
$this->wikioutput->wiki_print_subwiki_selector($wiki, $this->subwiki, $page, 'search');
837
845
function print_content() {
1052
1060
$parseroutput = wiki_parse_content($data->contentformat, $text, $options);
1053
1061
$this->set_newcontent($text);
1054
echo $OUTPUT->notification(get_string('previewwarning', 'wiki'), 'notifyproblem wiki_info');
1062
echo $OUTPUT->notification(get_string('previewwarning', 'wiki'), 'notifyproblem');
1055
1063
$content = format_text($parseroutput['parsed_text'], FORMAT_HTML, array('overflowdiv'=>true, 'filter'=>false));
1056
1064
echo $OUTPUT->box($content, 'generalbox wiki_previewbox');
1057
1065
$content = $this->newcontent;
1082
1090
$vstring = new stdClass();
1083
1091
$vstring->old = $this->compare;
1084
1092
$vstring->new = $this->comparewith;
1085
echo $OUTPUT->heading(get_string('comparewith', 'wiki', $vstring));
1093
echo html_writer::tag('div', get_string('comparewith', 'wiki', $vstring), array('class' => 'wiki_headingtitle'));
1189
1197
global $OUTPUT;
1192
$html .= $OUTPUT->container_start();
1193
$html .= $OUTPUT->heading_with_help(format_string($this->title), 'history', 'wiki');
1200
$html .= $OUTPUT->container_start('wiki_headingtitle');
1201
$html .= $OUTPUT->heading_with_help(format_string($this->title), 'history', 'wiki', '', '', 3);
1194
1202
$html .= $OUTPUT->container_end();
1255
1263
$a = new StdClass;
1256
1264
$a->date = userdate($this->page->timecreated, get_string('strftimedaydatetime', 'langconfig'));
1257
1265
$a->username = fullname($creator);
1258
echo $OUTPUT->heading(get_string('createddate', 'wiki', $a), 4, 'wiki_headingtime');
1266
echo html_writer::tag ('div', get_string('createddate', 'wiki', $a), array('class' => 'wiki_headingtime'));
1259
1267
if ($vcount > 0) {
1261
1269
/// If there is only one version, we don't need radios nor forms
1269
1277
$time = userdate($row->timecreated, get_string('strftimetime', 'langconfig'));
1270
1278
$versionid = wiki_get_version($row->id);
1271
1279
$versionlink = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
1272
$userlink = new moodle_url('/user/view.php', array('id' => $username->id, 'course' => $PAGE->cm->course));
1280
$userlink = new moodle_url('/user/view.php', array('id' => $username->id, 'course' => $this->cm->course));
1273
1281
$contents[] = array('', html_writer::link($versionlink->out(false), $row->version), $picture . html_writer::link($userlink->out(false), fullname($username)), $time, $OUTPUT->container($date, 'wiki_histdate'));
1275
1283
$table = new html_table();
1298
1306
$viewlink = $version->version;
1300
$userlink = new moodle_url('/user/view.php', array('id' => $version->userid, 'course' => $PAGE->cm->course));
1308
$userlink = new moodle_url('/user/view.php', array('id' => $version->userid, 'course' => $this->cm->course));
1301
1309
$contents[] = array($this->choose_from_radio(array($version->version => null), 'compare', 'M.mod_wiki.history()', $checked - 1, true) . $this->choose_from_radio(array($version->version => null), 'comparewith', 'M.mod_wiki.history()', $checked, true), $viewlink, $picture . html_writer::link($userlink->out(false), fullname($user)), $time, $OUTPUT->container($date, 'wiki_histdate'));
1431
1439
echo $this->wikioutput->menu_map($this->page->id, $this->view);
1432
1440
$this->print_index_content();
1435
echo $this->wikioutput->menu_map($this->page->id, $this->view);
1436
$this->print_page_list_content();
1439
1443
echo $this->wikioutput->menu_map($this->page->id, $this->view);
1440
1444
$this->print_updated_content();
1443
1448
echo $this->wikioutput->menu_map($this->page->id, $this->view);
1444
1449
$this->print_page_list_content();
1628
1633
foreach ($pages as $page) {
1629
1634
// We need to format the title here to account for any filtering
1630
1635
$letter = format_string($page->title, true, array('context' => $this->modcontext));
1631
$letter = textlib::substr($letter, 0, 1);
1636
$letter = core_text::substr($letter, 0, 1);
1632
1637
if (preg_match('/^[a-zA-Z]$/', $letter)) {
1633
$letter = textlib::strtoupper($letter);
1638
$letter = core_text::strtoupper($letter);
1634
1639
$stdaux->{$letter}[] = wiki_parser_link($page);
1636
1641
$stdaux->{$strspecial}[] = wiki_parser_link($page);
1842
1847
function print_content() {
1845
require_capability('mod/wiki:managewiki', $this->modcontext, NULL, true, 'nomanagewikipermission', 'wiki');
1847
$this->print_restoreversion();
1850
$wiki = $PAGE->activityrecord;
1851
if (wiki_user_can_edit($this->subwiki, $wiki)) {
1852
$this->print_restoreversion();
1854
echo get_string('cannoteditpage', 'wiki');
1850
1859
function set_url() {
1886
1895
$restoreurl = new moodle_url('/mod/wiki/restoreversion.php', $optionsyes);
1887
1896
$return = new moodle_url('/mod/wiki/viewversion.php', array('pageid'=>$this->page->id, 'versionid'=>$version->id));
1889
echo $OUTPUT->heading(get_string('restoreconfirm', 'wiki', $version->version), 2);
1890
print_container_start(false, 'wiki_restoreform');
1898
echo $OUTPUT->container_start('wiki-form-center');
1899
echo html_writer::tag('div', get_string('restoreconfirm', 'wiki', $version->version));
1900
echo $OUTPUT->container_start(false, 'wiki_restoreform');
1891
1901
echo '<form class="wiki_restore_yes" action="' . $restoreurl . '" method="post" id="restoreversion">';
1892
1902
echo '<div><input type="submit" name="confirm" value="' . get_string('yes') . '" /></div>';
1893
1903
echo '</form>';
1894
1904
echo '<form class="wiki_restore_no" action="' . $return . '" method="post">';
1895
1905
echo '<div><input type="submit" name="norestore" value="' . get_string('no') . '" /></div>';
1896
1906
echo '</form>';
1897
print_container_end();
1907
echo $OUTPUT->container_end();
1908
echo $OUTPUT->container_end();
1954
1965
$deleteurl = new moodle_url('/mod/wiki/instancecomments.php', $optionsyes);
1955
1966
$return = new moodle_url('/mod/wiki/comments.php', array('pageid'=>$this->page->id));
1957
echo $OUTPUT->heading($strdeletecheckfull);
1958
print_container_start(false, 'wiki_deletecommentform');
1968
echo $OUTPUT->container_start('wiki-form-center');
1969
echo html_writer::tag('p', $strdeletecheckfull);
1970
echo $OUTPUT->container_start(false, 'wiki_deletecommentform');
1959
1971
echo '<form class="wiki_deletecomment_yes" action="' . $deleteurl . '" method="post" id="deletecomment">';
1960
1972
echo '<div><input type="submit" name="confirmdeletecomment" value="' . get_string('yes') . '" /></div>';
1961
1973
echo '</form>';
1962
1974
echo '<form class="wiki_deletecomment_no" action="' . $return . '" method="post">';
1963
1975
echo '<div><input type="submit" name="norestore" value="' . get_string('no') . '" /></div>';
1964
1976
echo '</form>';
1965
print_container_end();
1977
echo $OUTPUT->container_end();
1978
echo $OUTPUT->container_end();
1981
1994
function print_content() {
1984
$context = context_module::instance($PAGE->cm->id);
1997
$context = context_module::instance($this->cm->id);
1985
1998
require_capability('mod/wiki:editpage', $context, NULL, true, 'noeditpermission', 'wiki');
1987
2000
$this->print_save();
2120
2133
if ($pageversion) {
2121
2134
$restorelink = new moodle_url('/mod/wiki/restoreversion.php', array('pageid' => $this->page->id, 'versionid' => $this->version->id));
2122
echo $OUTPUT->heading(get_string('viewversion', 'wiki', $pageversion->version) . '<br />' . html_writer::link($restorelink->out(false), '(' . get_string('restorethis', 'wiki') . ')', array('class' => 'wiki_restore')) . ' ', 4);
2135
echo html_writer::tag('div', get_string('viewversion', 'wiki', $pageversion->version) . '<br />' .
2136
html_writer::link($restorelink->out(false), '(' . get_string('restorethis', 'wiki') .
2137
')', array('class' => 'wiki_restore')) . ' ', array('class' => 'wiki_headingtitle'));
2123
2138
$userinfo = wiki_get_user_info($pageversion->userid);
2124
2139
$heading = '<p><strong>' . get_string('modified', 'wiki') . ':</strong> ' . userdate($pageversion->timecreated, get_string('strftimedatetime', 'langconfig'));
2125
2140
$viewlink = new moodle_url('/user/view.php', array('id' => $userinfo->id));
2126
2141
$heading .= ' <strong>' . get_string('user') . ':</strong> ' . html_writer::link($viewlink->out(false), fullname($userinfo));
2127
2142
$heading .= ' → ' . $OUTPUT->user_picture(wiki_get_user_info($pageversion->userid), array('popup' => true)) . '</p>';
2128
print_container($heading, false, 'mdl-align wiki_modifieduser wiki_headingtime');
2143
echo $OUTPUT->container($heading, 'wiki_headingtime', 'mdl-align wiki_modifieduser');
2129
2144
$options = array('swid' => $this->subwiki->id, 'pretty_print' => true, 'pageid' => $this->page->id);
2131
2146
$pageversion->content = file_rewrite_pluginfile_urls($pageversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id);
2133
2148
$parseroutput = wiki_parse_content($pageversion->contentformat, $pageversion->content, $options);
2134
$content = print_container(format_text($parseroutput['parsed_text'], FORMAT_HTML, array('overflowdiv'=>true)), false, '', '', true);
2149
$content = $OUTPUT->container(format_text($parseroutput['parsed_text'], FORMAT_HTML, array('overflowdiv'=>true)), false, '', '', true);
2135
2150
echo $OUTPUT->box($content, 'generalbox wiki_contentbox');
2149
2164
$PAGE->set_url($CFG->wwwroot . '/mod/wiki/viewversion.php', array('pageid' => $this->page->id, 'versionid' => $this->version->id));
2167
function print_header() {
2152
2171
function print_content() {
2153
2172
global $CFG, $PAGE;
2155
require_capability('mod/wiki:managewiki', $this->modcontext, NULL, true, 'nomanagewikipermission', 'wiki');
2157
2174
$version = wiki_get_version($this->version->id);
2158
if (wiki_restore_page($this->page, $version->content, $version->userid)) {
2175
$wiki = $PAGE->activityrecord;
2176
if (wiki_user_can_edit($this->subwiki, $wiki) &&
2177
wiki_restore_page($this->page, $version->content, $version->userid)) {
2159
2178
redirect($CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $this->page->id, get_string('restoring', 'wiki', $version->version), 3);
2161
2180
print_error('restoreerror', 'wiki', $version->version);
2180
2199
$this->set_url();
2182
2201
echo $OUTPUT->header();
2183
echo '<h1 id="wiki_printable_title">' . format_string($this->title) . '</h1>';
2202
// Print dialog link.
2203
$printtext = get_string('print', 'wiki');
2204
$printlinkatt = array('onclick' => 'window.print();return false;', 'class' => 'printicon');
2205
$printiconlink = html_writer::link('#', $printtext, $printlinkatt);
2206
echo html_writer::tag('div', $printiconlink, array('class' => 'displayprinticon'));
2207
echo html_writer::tag('h1', format_string($this->title), array('id' => 'wiki_printable_title'));
2186
2210
function print_content() {
2582
2606
$a = new stdClass();
2583
2607
$a->date = userdate($this->page->timecreated, get_string('strftimedaydatetime', 'langconfig'));
2584
2608
$a->username = fullname($creator);
2585
echo $OUTPUT->heading(get_string('createddate', 'wiki', $a), 4, 'wiki_headingtime');
2609
echo $OUTPUT->heading(get_string('createddate', 'wiki', $a), 4);
2586
2610
if ($versioncount > 0) {
2587
2611
/// If there is only one version, we don't need radios nor forms
2588
2612
if (count($versions) == 1) {
2593
2617
$time = userdate($row->timecreated, get_string('strftimetime', 'langconfig'));
2594
2618
$versionid = wiki_get_version($row->id);
2595
2619
$versionlink = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
2596
$userlink = new moodle_url('/user/view.php', array('id' => $username->id, 'course' => $PAGE->cm->course));
2620
$userlink = new moodle_url('/user/view.php', array('id' => $username->id, 'course' => $this->cm->course));
2597
2621
$picturelink = $picture . html_writer::link($userlink->out(false), fullname($username));
2598
2622
$historydate = $OUTPUT->container($date, 'wiki_histdate');
2599
2623
$contents[] = array('', html_writer::link($versionlink->out(false), $row->version), $picturelink, $time, $historydate);
2630
2654
$viewlink = $version->version;
2633
$userlink = new moodle_url('/user/view.php', array('id' => $version->userid, 'course' => $PAGE->cm->course));
2657
$userlink = new moodle_url('/user/view.php', array('id' => $version->userid, 'course' => $this->cm->course));
2634
2658
$picturelink = $picture . html_writer::link($userlink->out(false), fullname($user));
2635
2659
$historydate = $OUTPUT->container($date, 'wiki_histdate');
2636
2660
$radiofromelement = $this->choose_from_radio(array($version->version => null), 'fromversion', 'M.mod_wiki.deleteversion()', $versioncount, true);