/** * Initialises the page. Sets the property $uiCore to the appropriate * helper object. * * To create a custom UI, adding changes to makePage() is usually * enough, but one might want to overload this method to get better * handling of form parameters. * * @global OutputPage $wgOut * @global WebRequest $wgRequest * @global boolean $smwgQEnabled * @param string $p the sub-page string */ public function execute($p) { global $wgOut, $wgRequest, $smwgQEnabled, $wgFeedClasses; $this->setHeaders(); if (!$smwgQEnabled) { $wgOut->addHTML('<br />' . wfMessage('smw_iq_disabled')->escaped()); return; } // Check if this request is actually an AJAX request, and handle it accodingly: $ajaxMode = $this->processFormatOptions($wgRequest); // If not replying to AJAX, build the UI HTML as usual: if (!$ajaxMode) { // Checking if a query string has been sent by using the form: if ($this->processQueryFormBox($wgRequest) !== false) { $params = $this->processParams(); $this->uiCore = SMWQueryUIHelper::makeForUI($this->processQueryFormBox($wgRequest), $params, array(), false); if ($this->uiCore->getQueryString() !== '') { $this->uiCore->execute(); } } else { // Query not sent via form (though maybe from "further results" link: $this->uiCore = SMWQueryUIHelper::makeForInfoLink($p); } // Add RSS feed of results to the page head: if ($this->isSyndicated() && $this->uiCore->getQueryString() !== '' && method_exists($wgOut, 'addFeedlink') && array_key_exists('rss', $wgFeedClasses)) { $res = $this->uiCore->getResultObject(); $link = $res->getQueryLink(); $link->setParameter('rss', 'format'); $link->setParameter($this->uiCore->getLimit(), 'limit'); $wgOut->addFeedLink('rss', $link->getURl()); } $wgOut->addHTML($this->makePage($p)); } // Make sure locally collected output data is pushed to the output: SMWOutputs::commitToOutputPage($wgOut); }
/** * Constructs a new SMWQueryUIHelper object when the query is passed to * the UI in the Info-link format. This constructor should be used for * handling the "further results" links in wiki-pages that use #ask. If * your search UI handles form parameters only, then consider using * makeForUI(). * * If any errors do occur while parsing parameters, they may be accessed * from hasError() and getErrors(). * * @param string $p parameters of the query. * @param boolean $enableValidation * @return SMWQueryUIHelper * * @todo Handle validation for infolink parameters */ public static function makeForInfoLink($p, $enableValidation = false) { $result = new SMWQueryUIHelper(self::WIKI_LINK); $result->extractParameters($p); $result->execute(); return $result; }