[pmwiki-users] Recipe Update Notification was:pmwiki.org seems slow today btw
Sebastian Siedentopf
schlaefer at macnews.de
Wed Feb 8 18:39:31 CST 2006
Am 08.02.2006 um 22:27 schrieb Sebastian Siedentopf:
>
> No, I mean a real update information system. So that I on my private
> lokal wiki have a site like Site.AvailableUpdates that shows me all
> my installed recipes and the versions available on pmwiki.org:
Here's a little code snippet to show what I had in mind.
A recipe registers itself in some way:
if (file_exists("$FarmD/cookbook/pmwikiautoupdate.php")){
include_once("$FarmD/cookbook/pmwikiautoupdate.php");
PmWikiAutoUpdateRegisterReceipe("myrecipe", "2.0", 'http://
somehost/');
}
The "source" should provide a version information:
PmWikiAutoUpdateRegisterReceipe("myrecipe", "2.0", 'http://
somehost/', true);
----
The script:
<?php
Markup('pmwikiautoupdate', '<split', "/\\(:pmwikiautoupdate:\\)/e",
"PmWikiAutoUpdateList()");
function PmWikiAutoUpdateList(){
global $PmWikiAutoUpdate;
$recipes = $PmWikiAutoUpdate['recipes'];
$out[] = "|| border=1";
$out[] = "||!Recipe||!Intalled Version||!Source||!New Version
Available||";
foreach ($recipes as $recipe) {
$data = "";
$fp = fopen ($PmWikiAutoUpdate[$recipe]['url']."?
action=pmwikiautoupdate&rname=$recipe", "r");
while (!feof($fp))
$data .= fgets($fp, 256);
fclose($fp);
if (!$data) continue;
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $data, $values, $index);
xml_parser_free($xml_parser);
$version = trim($values[$index['VERSION'][0]]['value']);
if ($PmWikiAutoUpdate[$recipe]['version'] != $version)
$out[] = "||".$recipe."||".$PmWikiAutoUpdate[$recipe]
['version']."||".$PmWikiAutoUpdate[$recipe]['url']."||$version||";
}
return implode("\n", $out);
}
function PmWikiAutoUpdateRegisterReceipe($rname, $rversion, $rurl,
$rsource = false) {
global $PmWikiAutoUpdate;
$PmWikiAutoUpdate['recipes'][] = $rname;
$PmWikiAutoUpdate[$rname]['version'] = $rversion;
$PmWikiAutoUpdate[$rname]['url'] = $rurl;
$PmWikiAutoUpdate[$rname]['source'] = $rsource;
}
$HandleActions['pmwikiautoupdate'] = 'HandlePmWikiAutoUpdate';
function HandlePmWikiAutoUpdate($pagename) {
global $PmWikiAutoUpdate;
$rname = $_GET['rname'];
if ($PmWikiAutoUpdate[$rname]['source'] == true){
header ('Content-type: text/xml; charset="UTF-8"');
echo "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<pmwikiautoupdate>
<name>
$rname
</name>
<version>
{$PmWikiAutoUpdate[$rname]['version']}
</version>
<url>
{$PmWikiAutoUpdate[$rname]['url']}
</url>
</pmwikiautoupdate>
";
}
}
?>
----
I believe I read in the mailing list about page vars set on a page
itself with something like "parameter:value". But I can't find the
thread at the moment. So we possibly could also subscribe to a
particular update page with "version:x.y" on it.
Sebastian
More information about the pmwiki-users
mailing list