Changeset 726
- Timestamp:
- 08/19/2007 08:41:38 PM (3 years ago)
- Location:
- trunk/handlers
- Files:
-
- 2 modified
-
comments.xml/comments.xml.php (modified) (8 diffs)
-
recentchanges.xml/recentchanges.xml.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/handlers/comments.xml/comments.xml.php
r690 r726 14 14 * @access public 15 15 * @since 1.1.7 16 * 16 17 * @uses FeedCreator 17 18 * @uses Config::$base_url … … 22 23 * @uses Wakka::LoadRecentComments() 23 24 * @uses Wakka::StaticHref() 24 * 25 * 26 * @input string $f optional GET parameter: output format, can be any of the 27 * following: RSS0.91, RSS1.0, RSS2.0, ATOM1.0 28 * default: RSS2.0 29 * the default can be overridden by providing a URL parameter 'f'. 30 * @output feed for recent comments in the specified format. 25 31 * @todo move some defaults to wiki configuration files 26 32 * @todo add flexible filtering support … … 30 36 * @todo use stylesheet compatible with multiple feed formats 31 37 * @todo allow feed for one page only, e.g. Feed for comments on my userpage only. Perhaps by adding params in $_GET. 32 * 33 * @input string $f optional: output format, can be any of the following: 34 * RSS0.91, RSS1.0, RSS2.0, ATOM1.0 35 * default: RSS2.0 36 * the default format can be overridden by providing a URL parameter 'f'. 37 * @output feed for recently changed pages in the specified format. 38 * @todo replace htmlspecialchars() in FeedCreator with our secure version (!) 39 * @todo either do not escape a <link> in FeedCreator, or feed it a URL that 40 * does not already have '&' in a URL escaped (as Href() is doing!) 41 * because it gets "double-escaped" now; in fact, I think it should not 42 * be escaped at all in a feed, only in HTML 43 * @todo review whether page, or actual comment, should be used for the item 44 * 'source' attribute in RSS 1.0 45 * @todo replace current feed image 'images/wikka_logo.jpg' by a more 46 * appropriate smaller feed image 38 47 */ 39 48 … … 78 87 //get URL parameters 79 88 $formats = explode(",",FEED_VALID_FORMATS); 80 $f = (in_array($_GET['f'], $formats))? $_GET['f'] : FEED_DEFAULT_OUTPUT_FORMAT; 89 #$f = (in_array($_GET['f'], $formats))? $_GET['f'] : FEED_DEFAULT_OUTPUT_FORMAT; 90 $f = (isset($_GET['f']) && in_array($_GET['f'], $formats)) ? $_GET['f'] : FEED_DEFAULT_OUTPUT_FORMAT; 81 91 82 92 //create object … … 97 107 $rss->descriptionTruncSize = FEED_DESCRIPTION_TRUNCATE_SIZE; 98 108 $rss->descriptionHtmlSyndicated = FEED_DESCRIPTION_HTML; 99 $rss->link = $this->Href('', $this->GetConfigValue('root_page')); // just $this->Href() should do it!100 $rss->syndicationURL = $this->Href($this-> method,'','f='.$f);109 $rss->link = $this->Href('', $this->GetConfigValue('root_page')); 110 $rss->syndicationURL = $this->Href($this->handler,'','f='.$f); 101 111 102 112 //create feed image … … 105 115 $image->title = FEED_IMAGE_TITLE; 106 116 $image->url = FEED_IMAGE_URL; 107 $image->link = $this->Href('', $this->GetConfigValue('root_page')); // just $this->Href() should do it!117 $image->link = $this->Href('', $this->GetConfigValue('root_page')); 108 118 $image->description = FEED_IMAGE_DESCRIPTION; 109 119 $image->descriptionTruncSize = FEED_DESCRIPTION_TRUNCATE_SIZE; … … 114 124 $n = (int) $n; 115 125 // get feed items 116 // To optimize memory usage, we should load the minimum items. But, we must load 126 // To optimize memory usage, we should load the minimum items. But, we must load 117 127 // more than what we need, because we may have no rights on some items. 118 128 // Twice the number we need is just an arbitrary value!!! (2*$n) … … 131 141 $item->title = $comment['page_tag']; 132 142 $item->link = $this->Href('', $comment['page_tag'], 'show_comments=1').'#comment_'.$comment['id']; 143 // @@@ ^ uses &amp; in all formats - this is FC escaping the & that Href() outputs 144 // WARNING: the double escape comes from the use of htmlspecialchars() 145 // see also recentchanges.xml.php 133 146 $item->date = date('r', strtotime($comment['time'])); 134 147 $item->description = 'By '.$comment['user'].': '.$comment['comment']."\n"; 135 148 #$item->source = $this->GetConfigValue('base_url'); 136 $item->source = $this->base_url; // @@@ JW: should link to actual comment, I think 137 if ($f == 'ATOM1.0' || $f == 'RSS1.0') 149 #$item->source = $this->base_url; // home page 150 // @@@ ^ JW: should link to actual comment, or (maybe) the page that has the comment 151 /* 152 http://dublincore.org/documents/1999/07/02/dces/ 153 Element: Source 154 155 Name: Source 156 Identifier: Source 157 Definition: A Reference to a resource from which the present resource 158 is derived. 159 Comment: The present resource may be derived from the Source resource 160 in whole or in part. Recommended best practice is to reference 161 the resource by means of a string or number conforming to a 162 formal identification system. 163 */ 164 if ('RSS1.0' == $f) // dc:source used only here 165 { 166 $item->source = $this->Href('', $comment['page_tag']); // use page, rather than comment, for now 167 } 168 #if ($f == 'ATOM1.0' || $f == 'RSS1.0') 169 if (('ATOM1.0' == $f || 'RSS1.0' == $f) && $this->existsUser($comment['user'])) // check for existence of user 138 170 { 139 171 $item->author = $comment['user']; # RSS0.91 and RSS2.0 require authorEmail 140 172 } 141 $rss->addItem($item); 173 $rss->addItem($item); 174 142 175 if ($c == $n) // enough! 143 176 { -
trunk/handlers/recentchanges.xml/recentchanges.xml.php
r701 r726 7 7 * 8 8 * @package Handlers 9 * @author {@link http://wikkawiki.org/DarTar Dario Taraborelli} 9 * @author {@link http://wikkawiki.org/DarTar Dario Taraborelli} (rewrite using FeedCreator) 10 10 * @version $Id$ 11 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License11 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 12 12 * @filesource 13 13 * 14 14 * @access public 15 * @since 1.1.7 15 * @since 1.0.0 16 * 16 17 * @uses FeedCreator 17 18 * @uses Config::$base_url … … 33 34 * @todo use stylesheet compatible with multiple feed formats 34 35 * 35 * @input string $f optional : output format, can be any of the following:36 * RSS0.91, RSS1.0, RSS2.0, ATOM1.037 * default: RSS2.038 * the default format can be overridden by providing a URL parameter 'f'.36 * @input string $f optional GET parameter: output format, can be any of the 37 * following: RSS0.91, RSS1.0, RSS2.0, ATOM1.0 38 * default: RSS2.0 39 * the default can be overridden by providing a URL parameter 'f'. 39 40 * @output feed for recently changed pages in the specified format. 41 * @todo replace htmlspecialchars() in FeedCreator with our secure version (!) 42 * @todo either do not escape a <link> in FeedCreator, or feed it a URL that 43 * does not already have '&' in a URL escaped (as Href() is doing!) 44 * because it gets "double-escaped" now; in fact, I think it should not 45 * be escaped at all in a feed, only in HTML 46 * @todo replace current feed image 'images/wikka_logo.jpg' by a more 47 * appropriate smaller feed image 40 48 */ 41 49 … … 61 69 * Logo image to be used. 62 70 */ 63 if (!defined('FEED_IMAGE_ PATH')) define('FEED_IMAGE_PATH', $this->StaticHref('images/wikka_logo.jpg'));71 if (!defined('FEED_IMAGE_URL')) define('FEED_IMAGE_URL', $this->StaticHref('images/wikka_logo.jpg')); 64 72 65 73 /**#@+ … … 85 93 //get URL parameters 86 94 $formats = explode(',',FEED_VALID_FORMATS); 87 $f = (in_array($_GET['f'], $formats))? $_GET['f'] : FEED_DEFAULT_OUTPUT_FORMAT; 95 #$f = (in_array($_GET['f'], $formats))? $_GET['f'] : FEED_DEFAULT_OUTPUT_FORMAT; 96 $f = (isset($_GET['f']) && in_array($_GET['f'], $formats)) ? $_GET['f'] : FEED_DEFAULT_OUTPUT_FORMAT; 88 97 89 98 //create object … … 104 113 $rss->descriptionTruncSize = FEED_DESCRIPTION_TRUNCATE_SIZE; 105 114 $rss->descriptionHtmlSyndicated = FEED_DESCRIPTION_HTML; 106 $rss->link = $this->Href('', $this->GetConfigValue('root_page')); // just $this->Href() should do it!107 $rss->syndicationURL = $this->Href($this-> method,'','f='.$f);115 $rss->link = $this->Href('', $this->GetConfigValue('root_page')); 116 $rss->syndicationURL = $this->Href($this->handler,'','f='.$f); 108 117 109 118 //create feed image … … 111 120 $image = instantiate('FeedImage'); 112 121 $image->title = FEED_IMAGE_TITLE; 113 $image->url = $PHP_SELF.FEED_IMAGE_PATH;114 $image->link = $this->Href('', $this->GetConfigValue('root_page')); // just $this->Href() should do it!122 $image->url = FEED_IMAGE_URL; 123 $image->link = $this->Href('', $this->GetConfigValue('root_page')); 115 124 $image->description = FEED_IMAGE_DESCRIPTION; 116 125 $image->descriptionTruncSize = FEED_DESCRIPTION_TRUNCATE_SIZE; … … 130 139 #$item = new FeedItem(); 131 140 $item = instantiate('FeedItem'); 132 $item->title = $page['tag']; 133 $item->link = $this->Href('show', $page['tag'], 'time='.urlencode($page['time'])); 134 $item->date = date('r',strtotime($page['time'])); 141 $item->title = $page['tag']; 142 #$item->link = $this->Href('show', $page['tag'], 'time='.urlencode($page['time'])); 143 $item->link = $this->Href('', $page['tag'], 'time='.urlencode($page['time'])); 144 // @@@ ^ uses &amp; in all formats - this is FC escaping the & that Href() outputs 145 // WARNING: the double escape comes from the use of htmlspecialchars() 146 // 1. we need to replace this with our own secure version 147 // 2. we should NOT use it on already-escaped links -OR- feed it 148 // links that that have & not escaped (yet) 149 $item->date = date('r',strtotime($page['time'])); // RFC2822 135 150 $item->description = sprintf(FEED_ITEM_DESCRIPTION, $page['user']).($page['note'] ? ' ('.$page['note'].')' : '')."\n"; 136 151 #$item->source = $this->GetConfigValue('base_url'); 137 $item->source = $this->base_url; // home page // @@@ JW: should link to actual page, I think 138 #if (($f == 'ATOM1.0' || $f == 'RSS1.0') && $this->LoadUser($page['user']))// @@@ only check for existence of user here 139 if (($f == 'ATOM1.0' || $f == 'RSS1.0') && $this->existsUser($page['user']))// @@@ only check for existence of user here 152 #$item->source = $this->base_url; // home page 153 // @@@ JW: ^ should link to *actual* page not root 154 /* 155 http://dublincore.org/documents/1999/07/02/dces/ 156 Element: Source 157 158 Name: Source 159 Identifier: Source 160 Definition: A Reference to a resource from which the present resource 161 is derived. 162 Comment: The present resource may be derived from the Source resource 163 in whole or in part. Recommended best practice is to reference 164 the resource by means of a string or number conforming to a 165 formal identification system. 166 */ 167 if ('RSS1.0' == $f) // dc:source used only here 168 { 169 $item->source = $this->Href('', $page['tag']); // correct, I think, but actually redundant -- JW 170 } 171 #if (($f == 'ATOM1.0' || $f == 'RSS1.0') && $this->LoadUser($page['user'])) //only check for existence of user here 172 if (('ATOM1.0' == $f || 'RSS1.0' == $f) && $this->existsUser($page['user'])) // check for existence of user 140 173 { 141 174 $item->author = $page['user']; # RSS0.91 and RSS2.0 require authorEmail 142 175 } 143 $rss->addItem($item); 176 $rss->addItem($item); 144 177 } 145 178 } 146 } 179 } 147 180 148 181 //output feed