3 class XHTMLCompiler_DOMFilter_RSSFromSVN
extends XHTMLCompiler_DOMFilter
6 protected $name = 'RSSFromSVN';
9 protected $description = 'Subversion changelog for %s';
11 // xc:rss-from-svn="yes" on meta element to activate this feature
13 public function process(DOMDocument
$dom, $page, $manager) {
15 $xc = XHTMLCompiler
::getInstance();
16 $viewvc_url = $xc->getConf('viewvc_url');
18 // grab the document's links to RSS feeds
19 // link must be marked with xc:rss-from-svn
21 $link = $this->query('//html:link[@xc:rss-from-svn]')->item(0);
23 if (!$link) return; // nothing to do
25 if (!function_exists('svn_log')) {
26 throw new Exception('RSSFromSVN requires the svn extension');
29 $trigger = $this->confiscateAttr($link, $this->ns
, 'rss-from-svn');
30 if ($trigger != 'yes') return;
32 $path = $page->getWebPath();
34 $rss = new XHTMLCompiler_RSSFeed(
35 $link->getAttribute('title'),
37 str_replace('%s', $page->getCachePath(), $this->description
),
38 $dom->documentElement
->getAttribute('xml:lang')
41 $url = $page->getSVNHeadURL();
43 // file is not versioned, fail silently: it might work later
47 $logs = svn_log_limit($url, $this->limit
, $page);
49 $page_link = $page->getWebPath();
51 date_default_timezone_set('UTC');
52 foreach ($logs as $log) {
53 // link to ViewVC snapshot if possible
55 $item_link = $viewvc_url . '/' . $page->getSourcePath() .
56 '?revision=' . $log['rev'] . '&view=markup';
58 $item_link = $page_link . '#svn_r' . $log['rev'];
60 // generate short message (first line) for title
61 $lines = explode("\n", wordwrap($log['msg'], 40));
62 $short_msg = $lines[0];
66 'Revision ' . $log['rev'] . ': ' . htmlspecialchars($short_msg),
67 $d = gmdate('r', strtotime($log['date'])),
68 htmlspecialchars($log['msg'])
74 $link->getAttribute('href')