|
Cookbook /
NewsListSummary: Insert a list of recently changed/updated wikipages in a short form.
Version: 29.11.05: Initial release
Prerequisites: Requires at least PmWiki version: pmwiki-2.1.beta5; last tested on PmWiki version: pmwiki-2.1.beta5.
Status:
Maintainer:
Questions answered by this recipeHow can I insert a list of recently changed/updated wikipages in a short form that can be used in the sidebar, for example? AnswerInclude this in your php files: Markup('news','fulltext','/\(:news\s*(.*?):\\)/e',"newsList('$1')");
function newsList ($arg) {
global $WorkDir;
$args = explode(" ",$arg);
$reg = array();
$max = 500;
$exclude = false;
$grps=array();
foreach ($args as $i=>$val) {
if (preg_match("/(\d+)/",$val,$max)) {
$max = $max[1];
continue;
}
if ($val=='not') {
$exclude = true;
}
$grps[$val] = true;
}
$reg = "/^(.+?)\.[^,]+$/";
$dir = opendir($WorkDir);
$out = array();
$files = array();
while ($file = readdir ($dir)) {
if (!preg_match($reg,$file,$grp)||preg_match("/.(All)*RecentChanges/",$file)) continue;
$grp = $grp[1];
if ($grps[$grp] xor $exclude)
$files[filemtime("$WorkDir/$file")] = $file;
}
krsort($files);
foreach($files as $i => $val)
if ($max--<=0) break;
else $out[]="*[[".str_replace(".","/",$val)."]] [--(".date("d.m.y",$i).")--]";
closedir($dir);
return implode("\n",$out);
}
This will create a indexlist sorted by date. It will skip the AllRecentChanges and RecentChanges pages and it only looks into specified groups, so this will need some administration from your side. Since I needed this script for a CMS like website, I didn't want to list the Site etc. groups. You can specify a maximum of listet changes by adding a number. Use it like this: (:news Main Cookbook 8:) This will list the eight most recent changes (depending on the filechange dates in your (:news not Site:) CommentsSee AlsoContributors
|