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($page, false); // Wiki Page Name
15 optional_variable($q,""); // Search Context
16 optional_variable($userid, 0); // User wiki.
17 optional_variable($groupid, 0); // Group wiki.
18 optional_variable($canceledit,""); // Editing has been cancelled
20 /// Only want to add edit log entries if we have made some changes ie submitted a form
21 $editsave = optional_param('thankyou');
26 if (! $cm = get_record("course_modules", "id", $id)) {
27 error("Course Module ID was incorrect");
30 if (! $course = get_record("course", "id", $cm->course
)) {
31 error("Course is misconfigured");
34 if (! $wiki = get_record("wiki", "id", $cm->instance
)) {
35 error("Course module is incorrect");
39 if (! $wiki = get_record("wiki", "id", $wid)) {
40 error("Course module is incorrect");
42 if (! $course = get_record("course", "id", $wiki->course
)) {
43 error("Course is misconfigured");
45 if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id
, $course->id
)) {
46 error("Course Module ID was incorrect");
49 $_REQUEST["id"] = $id;
52 require_course_login($course, true, $cm);
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 $page = ($page === false) ?
stripslashes(EWIKI_PAGE_INDEX
) : stripslashes($page);
76 /// # Prevent ewiki getting id as PageID...
77 unset($_REQUEST["id"]);
81 unset($_SERVER["QUERY_STRING"]);
82 if (isset($HTTP_GET_VARS)) {
83 unset($HTTP_GET_VARS["id"]);
85 if (isset($HTTP_POST_VARS)) {
86 unset($HTTP_POST_VARS["id"]);
90 /// #-- predefine some of the configuration constants
93 /// EWIKI_NAME is defined in ewikimoodlelibs, so that also admin.php can use this
94 #define("EWIKI_NAME", $wiki_entry->pagename);
97 if($ewiki_title=="SearchPages") {
98 $qArgument="&q=".urlencode($q);
101 /// Build the ewsiki script constant
102 /// ewbase will also be needed by EWIKI_SCRIPT_BINARY
103 $ewbase = 'view.php?id='.$moodleID;
104 if (isset($userid) && $userid!=0) $ewbase .= '&userid='.$userid;
105 if (isset($groupid) && $groupid!=0) $ewbase .= '&groupid='.$groupid;
106 $ewscript = $ewbase.'&page=';
107 define("EWIKI_SCRIPT", $ewscript);
108 define("EWIKI_SCRIPT_URL", $ewscript);
110 /// # Settings for this specific Wiki
111 define("EWIKI_PRINT_TITLE", $wiki->ewikiprinttitle
);
113 define("EWIKI_INIT_PAGES", wiki_content_dir($wiki));
115 /// # fix broken PHP setup
116 if (!function_exists("get_magic_quotes_gpc") ||
get_magic_quotes_gpc()) {
117 include($CFG->dirroot
."/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php");
119 if (ini_get("register_globals")) {
120 # include($CFG->dirroot."/mod/wiki/ewiki/fragments/strike_register_globals.php");
124 include_once($CFG->dirroot
."/mod/wiki/ewikimoodlelib.php");
126 //include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/email_protect.php");
127 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/patchsaving.php");
128 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/notify.php");
129 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/feature/imgresize_gd.php");
130 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/moodle_highlight.php");
131 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/f_fixhtml.php");
132 #include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/wikinews.php");
133 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/sitemap.php");
134 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php");
135 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/aview/backlinks.php");
136 #include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/markup/css.php");
137 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/markup/footnotes.php");
138 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/diff.php");
139 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/page/pageindex.php");
140 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/page/orphanedpages.php");
141 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/wantedpages.php");
144 if($wiki->ewikiacceptbinary
) {
145 define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
146 define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
147 define("EWIKI_ALLOW_BINARY",1);
148 define("EWIKI_IMAGE_CACHING",1);
149 #define("EWIKI_AUTOVIEW",1);
150 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/lib/mime_magic.php");
151 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/aview/downloads.php");
152 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/downloads.php");
153 #include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/db/binary_store.php");
154 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php");
156 define("EWIKI_SCRIPT_BINARY", 0);
157 define("EWIKI_ALLOW_BINARY",0);
160 # The mighty Wiki itself
161 include_once($CFG->dirroot
."/mod/wiki/ewiki/ewiki.php");
164 if ($delim = strpos($page, EWIKI_ACTION_SEP_CHAR
)) {
165 @$page = substr($page, $delim +
1);
170 # Language-stuff: eWiki gets language from Browser. Lets correct it. Empty arrayelements do no harm
171 $ewiki_t["languages"]=array(current_language(), $course->lang
, $CFG->lang
,"en","c");
173 # Check Access Rights
174 $canedit = wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course);
177 unset($ewiki_plugins["action"]["edit"]);
178 unset($ewiki_plugins["action"]["info"]);
183 if($wiki->htmlmode
== 0) {
185 $ewiki_config["htmlentities"]=array(); // HTML is managed by moodle
186 $moodle_format=FORMAT_TEXT
;
188 if($wiki->htmlmode
== 1) {
190 include_once($CFG->dirroot
."/mod/wiki/ewiki/plugins/moodle/moodle_rescue_html.php");
191 $moodle_format=FORMAT_HTML
;
193 if($wiki->htmlmode
== 2) {
195 $moodle_format=FORMAT_HTML
;
197 $ewiki_config["htmlentities"]=array(); // HTML is allowed
198 $ewiki_config["wiki_link_regex"] = "\007 [!~]?(
199 \#?\[[^<>\[\]\n]+\] |
200 \^[-".EWIKI_CHARS_U
.EWIKI_CHARS_L
."]{3,} |
201 \b([\w]{3,}:)*([".EWIKI_CHARS_U
."]+[".EWIKI_CHARS_L
."]+){2,}\#?[\w\d]* |
202 \w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x";
205 global $ewiki_author, $USER;
206 $ewiki_author=fullname($USER);
207 $content=ewiki_page($page);
210 ### RESTORE ID from Moodle
211 $_REQUEST["id"]=$moodleID;
213 /// ################# EWIKI Part ###########################
217 $content2 = '<div align="center">'.get_string('nowikicreated', 'wiki').'</div>';
220 # Group wiki, ...: No page and no ewiki_title
221 if(!isset($ewiki_title)) {
227 if ($editsave != NULL) { /// We've submitted an edit and have been redirected back here
228 add_to_log($course->id
, "wiki", 'edit',
229 addslashes("view.php?id=$cm->id&groupid=$groupid&userid=$userid&page=$ewiki_title"),
230 format_string($wiki->name
,true).": ".$ewiki_title, $cm->id
, $userid);
231 } else if ($ewiki_action != 'edit') {
232 add_to_log($course->id
, "wiki", $ewiki_action,
233 addslashes("view.php?id=$cm->id&groupid=$groupid&userid=$userid&page=$ewiki_title"),
234 format_string($wiki->name
,true).": ".$ewiki_title, $cm->id
, $userid);
238 /// Print the page header
240 $strwikis = get_string("modulenameplural", "wiki");
241 $strwiki = get_string("modulename", "wiki");
244 print_header_simple($ewiki_title?
$ewiki_title:format_string($wiki->name
), "",
245 "<a href=\"index.php?id=$course->id\">$strwikis</a> -> <a href=\"view.php?id=$moodleID\">".format_string($wiki->name
,true)."</a>".($ewiki_title?
" -> $ewiki_title":""),
246 "", "", true, update_module_button($cm->id
, $course->id
, $strwiki),
247 navmenu($course, $cm));
251 echo ' <div id="wikiPageActions">
254 /// The top row contains links to other wikis, if applicable.
255 if ($wiki_list = wiki_get_other_wikis($wiki, $USER, $course, $wiki_entry->id
)) {
257 if (isset($wiki_list['selected'])) {
258 $selected = $wiki_list['selected'];
259 unset($wiki_list['selected']);
261 echo '<tr><td colspan="2">';
263 echo '<form name="otherwikis" action="'.$CFG->wwwroot
.'/mod/wiki/view.php">';
264 echo '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>';
265 echo '<td class="sideblockheading"> '
266 .$WIKI_TYPES[$wiki->wtype
].' '
267 .get_string('modulename', 'wiki')." ".get_string('for',"wiki")." "
268 .wiki_get_owner($wiki_entry).':</td>';
270 echo '<td class="sideblockheading" align="right">'
271 .get_string('otherwikis', 'wiki').': ';
272 $script = 'self.location=document.otherwikis.wikiselect.options[document.otherwikis.wikiselect.selectedIndex].value';
273 choose_from_menu($wiki_list, "wikiselect", $selected, "choose", $script);
275 echo '</tr></table>';
283 $specialpages=array("WikiExport", "SiteMap", "SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
285 echo '<table border="0" width="100%">';
289 echo '<td align="center">';
290 wiki_print_search_form($cm->id
, $q, $userid, $groupid, false);
293 /// Internal Wikilinks
294 echo '<td align="center">';
295 wiki_print_wikilinks_block($cm->id
, $wiki->ewikiacceptbinary
);
298 /// Administrative Links
300 echo '<td align="center">';
301 wiki_print_administration_actions($wiki, $cm->id
, $userid, $groupid, $ewiki_title, $wiki->htmlmode
!=2, $course);
306 echo '<td align="right">';
307 helpbutton('howtowiki', get_string('howtowiki', 'wiki'), 'wiki');
310 echo '</tr></table>';
314 <div id="wiki-view" class="mwiki">
317 if($ewiki_title==$wiki_entry->pagename
&& !empty($wiki->summary
)) {
318 if (trim(strip_tags($wiki->summary
))) {
319 print_simple_box(format_text($wiki->summary
, FORMAT_MOODLE
), 'center', '70%', '', 5, 'generalbox', 'intro');
325 if (!empty($canedit)) { /// Print tabs with commands for this page
326 $tabs = array('view', 'edit','links','info');
327 if ($wiki->ewikiacceptbinary
) {
328 $tabs[] = 'attachments';
334 foreach ($tabs as $tab) {
335 $tabname = get_string("tab$tab", 'wiki');
336 $row[] = new tabobject($tabname, $ewbase.'&page='.$tab.'/'.$ewiki_id, $tabname);
337 if ($ewiki_action == "$tab" or in_array($page, $specialpages)) {
338 $currenttab = $tabname;
343 print_tabs($tabrows, $currenttab);
347 print_simple_box_start('center', '100%', '', '20');
349 /// Don't filter any pages containing wiki actions (except view). A wiki page containing
350 /// actions will have the form [action]/[pagename]. If the '/' isn't there, or the action
351 /// is 'view', filter it. Also, if the page doesn't exist, it will default to 'edit'.
352 $actions = explode('/', $page);
353 if ($ewiki_action == "edit" ||
($actions !== false && count($actions) > 1 && $actions[0] != 'view') ||
354 (count($actions) == 1 && !record_exists('wiki_pages', 'pagename', addslashes($page), 'wiki', $wiki_entry->id
))) {
358 print(format_text($content, $moodle_format)); /// DISABLED UNTIL IT CAN BE FIXED
361 print_simple_box_end();
362 echo "<br clear=\"all\" />";
369 print_footer($course);