Skip to content
Browse files

wiki: Added a link to force reloading of the page (WR#515)

The link allows the page to be reloaded, which saves people from only seeing the cached copy. This is the equivalent of doing Shift+Reload in most
browsers.


Author: Luke Hudson <luke@catalyst.net.nz>
  • Loading branch information...
1 parent c1cda9d commit 51886e2fb40888e79ddf681e5893084d338ceba1 martinlanghoff committed Jul 31, 2006
Showing with 21 additions and 4 deletions.
  1. +2 −1 lang/en_utf8/wiki.php
  2. +19 −3 mod/wiki/view.php
View
3 lang/en_utf8/wiki.php
@@ -130,6 +130,8 @@
$string['preview'] = 'Preview';
$string['readonly'] = 'Read only page';
$string['refs'] = 'References';
+$string['reloadlinkdescription'] = 'Reloads the page, so that any new content is shown.';
+$string['reloadlinktext'] = 'Reload this page';
$string['removenotice'] = 'Note that only unreferenced pages will be listed here. And because the ewiki engine itself does only limited testing if a page is referenced it may miss some of them here.<br />If you however empty a page first, it will get listed here too. Various other database diagnostics are made as well.';
$string['removepagecheck'] = 'Are you sure that you want to delete these pages ?';
$string['removepages'] = 'Remove pages';
@@ -187,5 +189,4 @@
$string['withbinaries'] = 'Include binary content';
$string['withvirtualpages'] = 'Include Wiki-Links';
$string['wrongversionrange'] = '$a is not a correct range!';
-
?>
View
22 mod/wiki/view.php
@@ -16,12 +16,11 @@
$userid = optional_param('userid', 0, PARAM_INT); // User wiki.
$groupid = optional_param('groupid', 0, PARAM_INT); // Group wiki.
$canceledit = optional_param('canceledit','', PARAM_ALPHA); // Editing has been cancelled
+ $cacheme = optional_param('allowcache', 1, PARAM_INT); // Set this to 0 to try and disable page caching.
// Only want to add edit log entries if we have made some changes ie submitted a form
$editsave = optional_param('thankyou', '');
-
-
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
@@ -245,7 +244,7 @@
print_header_simple($ewiki_title?$ewiki_title:format_string($wiki->name), "",
"<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":""),
- "", "", true, update_module_button($cm->id, $course->id, $strwiki),
+ "", "", $cacheme, update_module_button($cm->id, $course->id, $strwiki),
navmenu($course, $cm));
@@ -346,7 +345,24 @@
print_tabs($tabrows, $currenttab);
}
+ /// Insert a link to force page refresh if new content isn't showing.
+ // build new URL + query string
+ $queries = preg_split('/[?&]/', me());
+ $nqueries = count($queries);
+ $me = $queries[0] . '?';
+ for($i=1; $i < $nqueries; $i++)
+ {
+ if( !strstr($queries[$i], 'allowcache') )
+ $me .= $queries[$i] . '&';
+ }
+ $me .= 'allowcache=0';
+
+ // Insert the link
+ $linkdesc = get_string('reloadlinkdescription', 'wiki');
+ $linktext = get_string('reloadlinktext', 'wiki');
+ echo "<div align='right' style='padding-bottom: 0.5em;'><a href='$me' title='$linkdesc'><input type='button' value='$linktext'></a></div>";
+
print_simple_box_start('center', '100%', '', '20');
/// Don't filter any pages containing wiki actions (except view). A wiki page containing

0 comments on commit 51886e2

Please sign in to comment.
Something went wrong with that request. Please try again.