Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_RSSlink.php |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | class SMWRSSResultPrinter extends SMWResultPrinter { |
15 | 15 | protected $title = ''; |
16 | 16 | protected $description = ''; |
| 17 | + protected $rsslinktitle; // just a cache |
17 | 18 | |
18 | 19 | protected function readParameters($params,$outputmode) { |
19 | 20 | SMWResultPrinter::readParameters($params,$outputmode); |
— | — | @@ -22,6 +23,7 @@ |
23 | 24 | if (array_key_exists('rssdescription', $this->m_params)) { |
24 | 25 | $this->description = $this->m_params['rssdescription']; |
25 | 26 | } |
| 27 | + $this->rsslinktitle = ''; |
26 | 28 | } |
27 | 29 | |
28 | 30 | public function getResult($results, $params, $outputmode) { // skip all checks, the result is never populated |
— | — | @@ -38,7 +40,10 @@ |
39 | 41 | $label = wfMsgForContent('smw_rss_link'); |
40 | 42 | } |
41 | 43 | $result .= $this->getRSSLink($outputmode, $res, $label); |
42 | | - smwfRequireHeadItem('rss' . $smwgIQRunningNumber, '<link rel="alternate" type="application/rss+xml" title="' . $this->title . '" href="' . $this->getRSSURL($res) . '" />'); |
| 44 | + $rurl = $this->getRSSURL($res); |
| 45 | + if ($rurl != false) { |
| 46 | + smwfRequireHeadItem('rss' . $smwgIQRunningNumber, '<link rel="alternate" type="application/rss+xml" title="' . $this->title . '" href="' . $rurl . '" />'); |
| 47 | + } |
43 | 48 | return $result; |
44 | 49 | } |
45 | 50 | |
— | — | @@ -51,11 +56,15 @@ |
52 | 57 | |
53 | 58 | protected function getRSSURL($res) { |
54 | 59 | $title = Title::newFromText( $this->getRSSTitle($res) ); |
| 60 | + if ($title === NULL) return false; // this should not happen, but there can always be unexpected problems in user input strings |
55 | 61 | return $title->getFullURL(); |
56 | 62 | } |
57 | 63 | |
58 | 64 | protected function getRSSTitle($res) { |
59 | | - $result = $res->getQueryTitle(); |
| 65 | + if ($this->rsslinktitle != '') { |
| 66 | + return $this->rsslinktitle; |
| 67 | + } |
| 68 | + $this->rsslinktitle = $res->getQueryTitle(); |
60 | 69 | $params = array('rss=1'); |
61 | 70 | if (array_key_exists('limit', $this->m_params)) { |
62 | 71 | $params[] = 'limit=' . $this->m_params['limit']; |
— | — | @@ -68,9 +77,9 @@ |
69 | 78 | } |
70 | 79 | foreach ($params as $p) { |
71 | 80 | $p = str_replace(array('/','=','-','%'),array('-2F','-3D','-2D','-'), rawurlencode($p)); |
72 | | - $result .= '/' . $p; |
| 81 | + $this->rsslinktitle .= '/' . $p; |
73 | 82 | } |
74 | | - return $result; |
| 83 | + return $this->rsslinktitle; |
75 | 84 | } |
76 | 85 | |
77 | 86 | } |