1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
<?php
class Changes {
function Changes(&$page,&$search) {
$this->page = &$page;
$this->search = &$search;
}
function getpaths() {
$limit = get('limit',15);
$offset = get('offset',0);
$ago = get('ago',30); // number of days from today
$ago = time() - ($ago*60*60*24);
return $this->search->recentChanges($this->page,$offset,$limit,$ago);
}
function title() {
$rc = _("Recent Changes");
if (!$this->page->path and $sitename = $this->page->get('sitename'))
return "$rc: $sitename";
elseif ($title = $this->page->get('title'))
return "$rc: $title";
else
return $rc;
}
function results($pages,&$ps) {
$paths = $this->getpaths();
$changetitle = $this->title();
$str .= '<div id="changes">';
$str .= "<h2>$changetitle</h2>";
foreach ($paths as $path) {
$page = $ps->getPage($path);
$title = $page->get('title');
$description = $page->get('description');
$time = $page->get('mtime');
$date = date("Y-m-d", $time);
if ($title == '') $title = "Untitled";
$str .= "<p class=\"item\">\n<div class=\"title\">";
$str .= alink("$path/",$title);
$str .= "</div>\n";
$str .= $description;
$str .= "<div class=\"date\">$date</div>";
$str .= "</p>\n";
}
$str .= "</div>";
return $str;
}
function resultsRSS($pages,&$ps) {
global $root;
$paths = $this->getpaths();
$title = $this->title();
$link = http::absoluteUrl(preg_replace("/(\?.*)$/",'',$_SERVER['REQUEST_URI']));
$xml = '<?xml version="1.0"?>
<rss version="2.0">
<channel>
<language>en</language>
<description></description>
';
$xml .= "<link>$link</link>\n";
$xml .= "<title>$title</title>\n";
foreach ($paths as $path) {
$page = $ps->getPage($path);
$title = $page->get('title','Untitled');
$description = $page->get('description');
$time = $page->get('mtime');
$date = date("D M j G:i:s T Y",$time);
$xml .= "<item>\n";
$xml .= "<title>$title</title>\n";
$xml .= "<link>" . http::absoluteUrl("$root$path/") . "</link>\n";
$xml .= "<pubDate>$date</pubDate>\n";
$xml .= "<description>$description</description>\n";
$xml .= "</item>\n";
}
$xml .= "</channel>\n";
$xml .= "</rss>\n";
return $xml;
}
} // end class
return;
?>
|