PrettyRecentChanges Action
This gentle rewrite of the RecentChanges which ships with WikkaWiki 1.1.6.4 was created for use in a translucent website, where I want to make it possible to show a short list of changed pages while hiding much of the wiki guts.
It creates short unordered lists for each day's changes, up to a total specified by the constant MAX_REVISION_NUMBER_PRETTY which is set (here) at 6. The days retain the essential formatting provided by the original code, including references to the same CSS formatting. Most of the work done here was with the delete key, and a little work to generate the unordered lists.
The other change is the addition of an uncamel function which splits up CamelCase into constituent words and numbers. I have many pages which are listed as Readings4June2008 which this code presents as Readings 4 June 2008.
Installation
Place the following code in the actions directory as prettyrecentchanges.php
prettyrecentchanges.php (line 1)
- <?php
- /**
- * Display a simple list of recently changed pages.
- *
- * @package Actions
- * @name PrettyRecentChanges
- *
- * @author {@link http://www.mornography.de/ Hendrik Mans} (wakka code)
- * @author {@link http://wikkawiki.org/DarTar Dario Taraborelli} (preliminary code cleanup)
- * @author {@link http://wikkawiki.org/RichardMartinNielsen Richard Martin-Nielsen} (slight modifications to simplify for easy inclusion in homepages)
- * @todo - make datetime format configurable;
- * - add configurable option for non-accessible pages {@link http://wush.net/trac/wikka/ticket/178 #178};
- * - added extensive logging of events such as page deletion, cloning, ACL change {@link http://wush.net/trac/wikka/ticket/143 #143};
- */
- //defaults
- //i18n
- //initialization
- $max = 0;
- $readable = 0;
- {
- function uncamel($intext)
- {
- // Following codes based on a blog posting by Trenton Davies
- // at http://ad.hominem.org/log/2004/12/camelcase.php
- // Following line breaks out numbers as separate words as well
- return "$text";
- }
- }
- if ($pages = $this->LoadRecentlyChanged())
- {
- $curday = '';
- $max = MAX_REVISION_NUMBER_PRETTY;
- foreach ($pages as $i => $page)
- {
- if (($i < $max) && $this->HasAccess('read', $page['tag']))
- {
- $readable++;
- // day header
- if ($day != $curday)
- {
- if ($curday)
- {
- echo '</ul></span>'."\n";
- }
- echo $dateformatted.':<br />'."\n".'<span class="recentchanges"><ul>'."\n";
- $curday = $day;
- }
- }
- }
- if ($readable == 0)
- {
- echo '<em class="error">'.NO_READABLE_RECENTLY_CHANGED_PAGES.'</em>';
- }
- echo '</ul></span>'."\n";
- //wikiping instructions
- $wikipingserver = $this->config['wikiping_server'];
- if (!$wikipingserver == '')
- {
- $wikipingserver_host = $wikipingserver_url_parsed['host'];
- }
- }
- else
- {
- echo '<em class="error">'.NO_RECENTLY_CHANGED_PAGES.'</em>';
- }
- ?>
Usage
This code was originally conceived to be used in a >> section. I apply a title by hand:>>**Latest News and Updates**{{PrettyRecentChanges}}>>
It needn't be used this way, of course.
Possible criticisms
This could have just been another option passed to recent changes. I'm building a site to be edited and updated by novice users. They would much prefer to be told to just type {{PrettyRecentChanges}} than to try to get a series of parameters correct.
CategoryUserContributions