r37118 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37117‎ | r37118 | r37119 >
Date:16:59, 5 July 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
if RSS or iCal queries use concepts, but give no description or title, take the data from the concept by default
(this allows for much shorter RSS/iCalendar URLs, esp. in non-ASCII alphabets)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -158,6 +158,27 @@
159159 $queryobj = SMWQueryProcessor::createQuery($this->m_querystring, $this->m_params, false, '', $this->m_printouts);
160160 $queryobj->querymode = SMWQuery::MODE_INSTANCES; ///TODO: Somewhat hacky (just as the query mode computation in SMWQueryProcessor::createQuery!)
161161 $res = smwfGetStore()->getQueryResult($queryobj);
 162+ // try to be smart for rss/ical if no description/title is given and we have a concept query:
 163+ if ($this->m_params['format'] == 'rss') {
 164+ $desckey = 'rssdescription';
 165+ $titlekey = 'rsstitle';
 166+ } elseif ($this->m_params['format'] == 'icalendar') {
 167+ $desckey = 'icalendardescription';
 168+ $titlekey = 'icalendartitle';
 169+ } else { $desckey = false; }
 170+ if ( ($desckey) && ($queryobj->getDescription() instanceof SMWConceptDescription) &&
 171+ (!isset($this->m_params[$desckey]) || !isset($this->m_params[$titlekey])) ) {
 172+ $concept = $queryobj->getDescription()->getConcept();
 173+ if ( !isset($this->m_params[$titlekey]) ) {
 174+ $this->m_params[$titlekey] = $concept->getText();
 175+ }
 176+ if ( !isset($this->m_params[$desckey]) ) {
 177+ $dv = end(smwfGetStore()->getSpecialValues($concept, SMW_SP_CONCEPT_DESC));
 178+ if ($dv instanceof SMWConceptValue) {
 179+ $this->m_params[$desckey] = $dv->getDocu();
 180+ }
 181+ }
 182+ }
162183 $printer = SMWQueryProcessor::getResultPrinter($this->m_params['format'], SMWQueryProcessor::SPECIAL_PAGE, $res);
163184 $result_mime = $printer->getMimeType($res);
164185 if ($result_mime == false) {

Status & tagging log