1
<?PHP // $Id: view.php,v 1.15.2.9 2004/09/09 15:57:17 moodler Exp $
2
/// Extended by Michael Schneider
3
/// This page prints a particular instance of wiki
7
require_once("../../config.php");
8
require_once("lib.php");
9
# require_once("$CFG->dirroot/course/lib.php"); // For side-blocks
11
optional_variable($ewiki_action,""); // Action on Wiki-Page
12
optional_variable($id); // Course Module ID, or
13
optional_variable($wid); // Wiki ID
14
optional_variable($wikipage, false); // Wiki Page Name
15
optional_variable($q,""); // Search Context
16
optional_variable($userid); // User wiki.
17
optional_variable($groupid); // Group wiki.
18
optional_variable($canceledit,""); // Editing has been cancelled
24
if (! $cm = get_record("course_modules", "id", $id)) {
25
error("Course Module ID was incorrect");
28
if (! $course = get_record("course", "id", $cm->course)) {
29
error("Course is misconfigured");
32
if (! $wiki = get_record("wiki", "id", $cm->instance)) {
33
error("Course module is incorrect");
37
if (! $wiki = get_record("wiki", "id", $wid)) {
38
error("Course module is incorrect");
40
if (! $course = get_record("course", "id", $wiki->course)) {
41
error("Course is misconfigured");
43
if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) {
44
error("Course Module ID was incorrect");
47
$_REQUEST["id"] = $id;
50
if ($course->category or !empty($CFG->forcelogin)) {
51
require_login($course->id);
54
/// Add the course module 'groupmode' to the wiki object, for easy access.
55
$wiki->groupmode = $cm->groupmode;
58
$moodle_format=FORMAT_MOODLE;
60
### SAVE ID from Moodle
61
$moodleID=@$_REQUEST["id"];
63
/// Globally disable CamelCase, if the option is selected for this wiki.
64
$moodle_disable_camel_case = ($wiki->disablecamelcase == 1);
66
if (($wiki_entry = wiki_get_default_entry($wiki, $course, $userid, $groupid))) {
68
/// ################# EWIKI Part ###########################
69
/// The wiki_entry->pagename is set to the specified value of the wiki,
70
/// or the default value in the 'lang' file if the specified value was empty.
71
define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
73
/// If the page has a ' in it, it may have slashes added to it. Remove them if it does.
74
$wikipage = ($wikipage === false) ? stripslashes(EWIKI_PAGE_INDEX) : stripslashes($wikipage);
76
/// ### Prevent ewiki getting id as PageID...
77
unset($_REQUEST["id"]);
81
unset($_SERVER["QUERY_STRING"]);
82
unset($HTTP_GET_VARS["id"]);
83
unset($HTTP_POST_VARS["id"]);
86
/// #-- predefine some of the configuration constants
89
/// EWIKI_NAME is defined in ewikimoodlelibs, so that also admin.php can use this
90
#define("EWIKI_NAME", $wiki_entry->pagename);
93
if($ewiki_title=="SearchPages") {
94
$qArgument="&q=".urlencode($q);
97
/// Build the ewsiki script constant
98
/// ewbase will also be needed by EWIKI_SCRIPT_BINARY
99
$ewbase = $ME.'?id='.$moodleID;
100
if (isset($userid)) $ewbase .= '&userid='.$userid;
101
if (isset($groupid)) $ewbase .= '&groupid='.$groupid;
102
$ewscript = $ewbase.'&wikipage=';
103
define("EWIKI_SCRIPT", $ewscript);
104
define("EWIKI_SCRIPT_URL", $ewscript);
106
/// # Settings for this specific Wiki
107
define("EWIKI_PRINT_TITLE", $wiki->ewikiprinttitle);
109
define("EWIKI_INIT_PAGES", wiki_content_dir($wiki));
111
/// # fix broken PHP setup
112
if (!function_exists("get_magic_quotes_gpc") || get_magic_quotes_gpc()) {
113
include($CFG->dirroot."/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php");
115
if (ini_get("register_globals")) {
116
# include($CFG->dirroot."/mod/wiki/ewiki/fragments/strike_register_globals.php");
120
include_once($CFG->dirroot."/mod/wiki/ewikimoodlelib.php");
122
//include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/email_protect.php");
123
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/patchsaving.php");
124
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/notify.php");
125
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/feature/imgresize_gd.php");
126
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_highlight.php");
127
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/f_fixhtml.php");
128
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/sitemap.php");
129
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php");
130
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/aview/backlinks.php");
131
#include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/markup/css.php");
132
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/markup/footnotes.php");
133
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/diff.php");
134
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/page/pageindex.php");
135
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/page/orphanedpages.php");
136
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/wantedpages.php");
139
if($wiki->ewikiacceptbinary) {
140
define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
141
define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
142
define("EWIKI_ALLOW_BINARY",1);
143
define("EWIKI_IMAGE_CACHING",1);
144
#define("EWIKI_AUTOVIEW",1);
145
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/lib/mime_magic.php");
146
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/aview/downloads.php");
147
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/downloads.php");
148
#include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/db/binary_store.php");
149
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php");
151
define("EWIKI_SCRIPT_BINARY", 0);
152
define("EWIKI_ALLOW_BINARY",0);
155
# The mighty Wiki itself
156
include_once($CFG->dirroot."/mod/wiki/ewiki/ewiki.php");
158
# Language-stuff: eWiki gets language from Browser. Lets correct it. Empty arrayelements do no harm
159
$ewiki_t["languages"]=array(current_language(), $course->lang, $CFG->lang,"en","c");
161
# Check Access Rights
162
$canedit = wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course);
165
unset($ewiki_plugins["action"]["edit"]);
166
unset($ewiki_plugins["action"]["info"]);
171
if($wiki->htmlmode == 0) {
173
$ewiki_config["htmlentities"]=array(); // HTML is managed by moodle
174
$moodle_format=FORMAT_TEXT;
176
if($wiki->htmlmode == 1) {
178
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_rescue_html.php");
179
$moodle_format=FORMAT_HTML;
181
if($wiki->htmlmode == 2) {
183
$moodle_format=FORMAT_HTML;
185
$ewiki_config["htmlentities"]=array(); // HTML is allowed
186
$ewiki_config["wiki_link_regex"] = "\007 [!~]?(
187
\#?\[[^<>\[\]\n]+\] |
188
\^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} |
189
\b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* |
190
\w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x";
193
global $ewiki_author, $USER;
194
$ewiki_author=fullname($USER);
195
$content=ewiki_page($wikipage);
198
### RESTORE ID from Moodle
199
$_REQUEST["id"]=$moodleID;
201
/// ################# EWIKI Part ###########################
205
$content2 = '<div align="center">'.get_string('nowikicreated', 'wiki').'</div>';
209
# Group wiki, ...: No wikipage and no ewiki_title
210
if(!isset($ewiki_title)) {
215
add_to_log($course->id, "wiki", $ewiki_action, "view.php?id=$cm->id&groupid=$groupid&userid=$userid&wikipage=$wikipage", $wiki->name." ".$ewiki_title);
218
/// Print the page header
220
$strwikis = get_string("modulenameplural", "wiki");
221
$strwiki = get_string("modulename", "wiki");
223
print_header_simple(($ewiki_title?$ewiki_title:$wiki->name), "",
224
"<A HREF=\"index.php?id=$course->id\">$strwikis</A> -> <A HREF=\"view.php?id=$moodleID\">$wiki->name</a>".($ewiki_title?" -> $ewiki_title":""),
225
"", "", true, update_module_button($cm->id, $course->id, $strwiki),
226
navmenu($course, $cm));
231
/// The top row contains links to other wikis, if applicable.
232
if ($wiki_list = wiki_get_other_wikis($wiki, $USER, $course, $wiki_entry->id)) {
234
if (isset($wiki_list['selected'])) {
235
$selected = $wiki_list['selected'];
236
unset($wiki_list['selected']);
238
echo '<tr><td colspan="2">';
240
echo '<form name="otherwikis" action="'.$CFG->wwwroot.'/mod/wiki/view.php">';
241
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>';
242
echo '<td class="sideblockheading" bgcolor="'.$THEME->cellheading.'"> '
243
.$WIKI_TYPES[$wiki->wtype].' '
244
.get_string('modulename', 'wiki')." ".get_string('for',"wiki")." "
245
.wiki_get_owner($wiki_entry).':</td>';
247
echo '<td class="sideblockheading" bgcolor="'.$THEME->cellheading.'" align="right">'
248
.get_string('otherwikis', 'wiki').': ';
249
$script = 'self.location=document.otherwikis.wikiselect.options[document.otherwikis.wikiselect.selectedIndex].value';
250
choose_from_menu($wiki_list, "wikiselect", $selected, "choose", $script);
252
echo '</tr></table>';
260
$specialpages=array("WikiExport", "SiteMap", "SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
262
echo '<table border="0" width="100%">';
266
echo '<td align="center">';
267
wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
270
/// Internal Wikilinks
271
echo '<td align="center">';
272
wiki_print_wikilinks_block($cm->id, $wiki->ewikiacceptbinary);
275
/// Administrative Links
277
echo '<td align="center">';
278
wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $ewiki_title, $wiki->htmlmode!=2, $course);
283
echo '<td align="right">';
284
helpbutton('howtowiki', get_string('howtowiki', 'wiki'), 'wiki');
287
echo '</tr></table>';
290
if($ewiki_title==$wiki_entry->pagename && !empty($wiki->summary)) {
291
if (trim(strip_tags($wiki->summary))) {
293
print_simple_box(format_text($wiki->summary, FORMAT_MOODLE), "center");
300
if (!empty($canedit)) { /// Print tabs with commands for this page
301
$tabstyle = ' style="padding-left: 5px;padding-right: 5px" ';
303
echo '<table border="0">';
305
$tabs = array('view', 'edit','links','info');
306
if ($wiki->ewikiacceptbinary) {
307
$tabs[] = 'attachments';
309
foreach ($tabs as $tab) {
310
$tabname = get_string("tab$tab", 'wiki');
311
if ($ewiki_action != "$tab" && !in_array($wikipage, $specialpages)) {
312
echo '<td class="generaltab" '.$tabstyle.' bgcolor="'.$THEME->cellheading.'">';
313
echo '<a href="'.$ewbase.'&wikipage='.$tab.'/'.$ewiki_id.'">'.$tabname.'</a>';
316
echo '<td class="generaltabselected" '.$tabstyle.' bgcolor="'.$THEME->cellcontent.'">'.$tabname.'</td>';
322
print_simple_box_start( "right", "100%", "$THEME->cellcontent", "20");
323
/// Don't filter any pages containing wiki actions (except view). A wiki page containing
324
/// actions will have the form [action]/[pagename]. If the '/' isn't there, or the action
325
/// is 'view', filter it. Also, if the page doesn't exist, it will default to 'edit'.
326
$actions = explode('/', $wikipage);
327
// if ($ewiki_action == "edit" || ($actions !== false && count($actions) > 1 && $actions[0] != 'view') ||
328
// (count($actions) == 1 && !record_exists('wiki_pages', 'pagename', $wikipage, 'wiki', $wiki_entry->id))) {
332
// print(format_text($content, $moodle_format)); /// DISABLED UNTIL IT CAN BE FIXED
336
print_simple_box_end();
337
echo "<br clear=all />";
340
print_footer($course);