r92530 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92529‎ | r92530 | r92531 >
Date:13:16, 19 July 2011
Author:devayon
Status:deferred
Tags:
Comment:
Adding syndication to the head of results
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -50,7 +50,7 @@
5151 * @todo: using processXXXBox() methods here goes against the general architecture.
5252 */
5353 public function execute( $p ) {
54 - global $wgOut, $wgRequest, $smwgQEnabled;
 54+ global $wgOut, $wgRequest, $smwgQEnabled, $wgFeedClasses;
5555
5656 $this->setHeaders();
5757
@@ -83,6 +83,16 @@
8484 // or no query has been set
8585 $this->uiCore = SMWQueryUIHelper::makeForInfoLink( $p );
8686 }
 87+ // adding rss feed of results to the page head
 88+ if(($this->uiCore->getQueryString()!=='')
 89+ and ($this->isSyndicated())
 90+ and (method_exists($wgOut, 'addFeedlink')) //remove this line after MW 1.5 is no longer supported by SMW
 91+ and (array_key_exists('rss', $wgFeedClasses))){
 92+ $res=$this->uiCore->getResultObject();
 93+ $href=$res->getQueryLink()->getURl().'/format%3Drss/limit%3D'. $this->uiCore->getLimit();
 94+ $wgOut->addFeedLink('rss', $href);
 95+ }
 96+
8797 $this->makepage( $p );
8898 }
8999 }
@@ -91,6 +101,15 @@
92102 }
93103
94104 /**
 105+ * To enable/disable syndicated feeds of results to appear in the UI header
 106+ *
 107+ * @return boolean
 108+ */
 109+ public function isSyndicated(){
 110+ return true;
 111+ }
 112+
 113+ /**
95114 * The main entrypoint for your UI. Call the various methods of SMWQueryUI
96115 * and SMWQueryUIHelper to build ui elements and to process them.
97116 */
@@ -736,7 +755,6 @@
737756 $default_format = $defaultformat;
738757 }
739758
740 - $result = '';
741759 $printer = SMWQueryProcessor::getResultPrinter( $default_format, SMWQueryProcessor::SPECIAL_PAGE );
742760 $url = $this->getTitle()->getLocalURL( "showformatoptions=' + this.value + '" );
743761
@@ -746,7 +764,7 @@
747765 }
748766 }
749767
750 - $result .= "\n<p>" . wfMsg( 'smw_ask_format_as' ) . "\n" .
 768+ $result = "\n<p>" . wfMsg( 'smw_ask_format_as' ) . "\n" .
751769 '<select id="formatSelector" name="p[format]" onChange="JavaScript:updateOtherOptions(\'' . $url . '\')">' . "\n" .
752770 '<option value="' . $default_format . '">' . $printer->getName() .
753771 ' (' . wfMsg( 'smw_ask_defaultformat' ) . ')</option>' . "\n";

Follow-up revisions

RevisionCommit summaryAuthorDate
r93814Follow up: r92530devayon11:21, 3 August 2011
r93815Follow up: r92530devayon11:23, 3 August 2011