jablonka.czprosek.czf

websvn

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

 

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);
68 
69// Cachename reflecting full path to and rev for rssfeed. Must end with xml to work
70$cachename = strtr(getFullURL($listurl), ":/\\?", "____");
71$cachename = $locwebsvnreal.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$cachename.$rev.'_rssfeed.xml';
72 
73$rss = new UniversalFeedCreator();
74$rss->useCached($feedformat, $cachename);
75$rss->title = $rep->getDisplayName();
76$rss->description = $lang['RSSFEEDTITLE'].' - '.$repname;
77$rss->link = htmlspecialchars(html_entity_decode(getFullURL($baseurl.$listurl)));
78$rss->syndicationURL = $rss->link;
79$rss->xslStyleSheet = ''; //required for UniversalFeedCreator since 1.7
80$rss->cssStyleSheet = ''; //required for UniversalFeedCreator since 1.7
81 
82if ($history && is_array($history->entries)) {
83 foreach ($history->entries as $r) {
84 $thisrev = $r->rev;
85 $changes = $r->mods;
86 $files = count($changes);
87 
88 // Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!)
89 $rpath = $r->path;
90 if ($isDir && $rpath{strlen($rpath) - 1} != '/') {
91 $rpath .= '/';
92 }
93 
94 // Find the parent path (or the whole path if it's already a directory)
95 $pos = strrpos($rpath, '/');
96 $parent = substr($rpath, 0, $pos + 1);
97 
98 $url = $config->getURL($rep, $parent, 'revision');
99 
100 $desc = $r->msg;
101 $item = new FeedItem();
102 
103 // For the title, we show the first 10 words of the description
104 $pos = 0;
105 $len = strlen($desc);
106 for ($i = 0; $i < 10; $i++) {
107 if ($pos >= $len) {
108 break;
109 }
110 
111 $pos = strpos($desc, ' ', $pos);
112 
113 if ($pos === false) {
114 break;
115 }
116 $pos++;
117 }
118 
119 if ($pos !== false) {
120 $desc = substr($desc, 0, $pos).'...';
121 }
122 
123 if ($desc == '') {
124 $desc = $lang['REV'].' '.$thisrev;
125 }
126 
127 $item->title = $desc;
128 $item->link = html_entity_decode(getFullURL($baseurl.$url.'rev='.$thisrev));
129 $item->description = '<div><strong>'.$lang['REV'].' '.$thisrev.' - '.$r->author.'</strong> ('.$files.' '.$lang['FILESMODIFIED'].')</div><div>'.nl2br(create_anchors($desc)).'</div>';
130 
131 if (true) {
132 usort($changes, 'SVNLogEntry_compare');
133 
134 foreach ($changes as $file) {
135 switch ($file->action) {
136 case 'A': $item->description .= '+ '; break;
137 case 'M': $item->description .= '~ '; break;
138 case 'D': $item->description .= '- '; break;
139 }
140 $item->description .= $file->path.'<br />';
141 }
142 }
143 
144 $item->date = $r->committime;
145 $item->author = $r->author;
146 $item->guid = $item->link;
147 
148 $rss->addItem($item);
149 }
150}
151 
152// Save the feed
153$rss->saveFeed($feedformat, $cachename, false);
154header('Content-Type: application/xml');
155echo $rss->createFeed($feedformat);

Powered by WebSVN 2.2.1