[pmwiki-users] please feedback/help on/with some code
EuGeNe
eugene at boardkulture.com
Fri Feb 10 17:25:45 CST 2006
Hi,
A few days ago I posted a question regarding the generation of a list of
the most recent changes to be displayed in a side bar ... which didn't
inspire anyone. I figured I'll try to find a solution myself and learn a
bit more about PmWiki in the process.
In the code bellow I defined a new markup (:mru grp:), where mru stands
for most recent updates and grp can be any group name.
What I really wanted to do is pass something looking like group=Site
count=10 to mru i.e. (:mur group=Site count=10:) which is why it is a 2
step process, function mru parse the arguments and mostRecentUpdates
return the final result.
But for some reason with the markup the way it is defined it doesn't
work, the program crash, nothing is displayed and I can't figure out
why, I think it comes from my Markup definition but....?
Can anyone help?
Thanks a lot,
EuGeNe
----
<?
Markup(
'mru',
'directives',
'/\\(:mru(\\s+.*?)?:\\)/ei',
"mru($1)"
);
function mru($args){
//$args=ParseArgs($args);
$Group=$args;
return mostRecentUpdates($Group);
}
function mostRecentUpdates($Group="Site",$count=5) {
global $WorkDir;
if ($Group!="Site"){
$Page="RecentChanges";
} else {
$Page="AllRecentChanges";
}
$path="$WorkDir/$Group.$Page";
$file=file($path,"r");
foreach($file as $line) {
$pos=strpos($line,"text=");
if ($pos===false or $pos>0) {
continue;
}
$text=$line;
}
preg_match_all("/\[\[([^\]]*)\]\]/",$text,$pages);
$i=0;
$return="";
foreach($pages[0] as $page){
$return.= $page."<br/>";
$i++;
if ($i>=$count) break;
}
return $return;
}
?>
More information about the pmwiki-users
mailing list