jablonka.czprosek.czf

websvn

Subversion Repositories:
[/] [rss.php] - Blame information for rev 4

 

Line No. Rev Author Line
11simandl<?php
2// WebSVN - Subversion repository viewing via the web using PHP
3// Copyright (C) 2004-2006 Tim Armes
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18//
19// --
20//
21// rss.php
22//
23// Creates an rss feed for the given repository number
24 
25include('lib/feedcreator.class.php');
26 
27require_once('include/setup.php');
28require_once('include/svnlook.php');
29require_once('include/utils.php');
30require_once('include/template.php');
31 
32$isDir = @$_REQUEST['isdir'] == 1;
33 
34$maxmessages = 20;
35 
36// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), MBOX, OPML, ATOM, ATOM0.3, HTML, JS
37$feedformat = 'RSS2.0';
38 
39// Find the base URL name
40if ($config->multiViews) {
41 $baseurl = '';
42} else {
43 $baseurl = dirname($_SERVER['PHP_SELF']);
44 if ($baseurl != '' && $baseurl != DIRECTORY_SEPARATOR && $baseurl != "\\" && $baseurl != '/') {
45 $baseurl .= '/';
46 } else {
47 $baseurl = '/';
48 }
49}
50 
51$svnrep = new SVNRepository($rep);
52 
53if ($path == '' || $path{0} != '/') {
54 $ppath = '/'.$path;
55} else {
56 $ppath = $path;
57}
58 
59// Make sure that the user has full access to the specified directory
60if (!$rep->hasReadAccess($path, false)) {
61 exit;
62}
63 
64$listurl = $config->getURL($rep, $path, 'dir');
65 
66// If there's no revision info, go to the lastest revision for this path
67$history = $svnrep->getLog($path, $rev, '', false, $maxmessages);
683simandlif (is_string($history)) {
69 echo $history;
70 exit;
71}
721simandl 
73// Cachename reflecting full path to and rev for rssfeed. Must end with xml to work
74$cachename = strtr(getFullURL($listurl), ":/\\?", "____");
75$cachename = $locwebsvnreal.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cachename.$rev.'_rssfeed.xml';
76 
77$rss = new UniversalFeedCreator();
78$rss->useCached($feedformat, $cachename);
79$rss->title = $rep->getDisplayName();
80$rss->description = $lang['RSSFEEDTITLE'].' - '.$repname;
81$rss->link = htmlspecialchars(html_entity_decode(getFullURL($baseurl.$listurl)));
82$rss->syndicationURL = $rss->link;
83$rss->xslStyleSheet = ''; //required for UniversalFeedCreator since 1.7
84$rss->cssStyleSheet = ''; //required for UniversalFeedCreator since 1.7
85 
86if ($history && is_array($history->entries)) {
87 foreach ($history->entries as $r) {
88 $thisrev = $r->rev;
89 $changes = $r->mods;
90 $files = count($changes);
91 
92 // Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!)
93 $rpath = $r->path;
94 if ($isDir && $rpath{strlen($rpath) - 1} != '/') {
95 $rpath .= '/';
96 }
97 
98 // Find the parent path (or the whole path if it's already a directory)
99 $pos = strrpos($rpath, '/');
100 $parent = substr($rpath, 0, $pos + 1);
101 
102 $url = $config->getURL($rep, $parent, 'revision');
103 
104 $desc = $r->msg;
105 $item = new FeedItem();
106 
107 // For the title, we show the first 10 words of the description
108 $pos = 0;
109 $len = strlen($desc);
110 for ($i = 0; $i < 10; $i++) {
111 if ($pos >= $len) {
112 break;
113 }
114 
115 $pos = strpos($desc, ' ', $pos);
116 
117 if ($pos === false) {
118 break;
119 }
120 $pos++;
121 }
122 
123 if ($pos !== false) {
124 $desc = substr($desc, 0, $pos).'...';
125 }
126 
127 if ($desc == '') {
128 $desc = $lang['REV'].' '.$thisrev;
129 }
130 
131 $item->title = $desc;
132 $item->link = html_entity_decode(getFullURL($baseurl.$url.'rev='.$thisrev));
1333simandl $item->description = '<div><strong>'.$lang['REV'].' '.$thisrev.' - '.$r->author.'</strong> ('.$files.' '.$lang['FILESMODIFIED'].')</div><div>'.nl2br(create_anchors($r->msg)).'</div>';
1341simandl 
135 if (true) {
136 usort($changes, 'SVNLogEntry_compare');
137 
138 foreach ($changes as $file) {
139 switch ($file->action) {
140 case 'A': $item->description .= '+ '; break;
141 case 'M': $item->description .= '~ '; break;
142 case 'D': $item->description .= '- '; break;
143 }
144 $item->description .= $file->path.'<br />';
145 }
146 }
147 
148 $item->date = $r->committime;
149 $item->author = $r->author;
150 $item->guid = $item->link;
151 
152 $rss->addItem($item);
153 }
154}
155 
156// Save the feed
1573simandl@$rss->saveFeed($feedformat, $cachename, false);
1581simandlheader('Content-Type: application/xml');
1593simandlecho @$rss->createFeed($feedformat);

Powered by WebSVN 2.2.1