/**
	 * Run job
	 *
	 * @return boolean success
	 */
	function run() {
		wfProfileIn( 'SMWRefreshJob::run (SMW)' );

		if ( !array_key_exists( 'spos', $this->params ) ) {
			wfProfileOut( 'SMWRefreshJob::run (SMW)' );
			return true;
		}

		$run = array_key_exists( 'run', $this->params ) ? $this->params['run']:1;
		$spos = $this->params['spos'];
		$namespaces = ( ( $this->params['rc'] > 1 ) && ( $run == 1 ) ) ? array( SMW_NS_PROPERTY, SMW_NS_TYPE ):false;
		$progress = smwfGetStore()->refreshData( $spos, 20, $namespaces );

		if ( $spos > 0 ) {
			$nextjob = new SMWRefreshJob( $this->title, array( 'spos' => $spos, 'prog' => $progress, 'rc' => $this->params['rc'], 'run' => $run ) );
			$nextjob->insert();
		} elseif ( $this->params['rc'] > $run ) { // do another run from the beginning
			$nextjob = new SMWRefreshJob( $this->title, array( 'spos' => 1, 'prog' => 0, 'rc' => $this->params['rc'], 'run' => $run + 1 ) );
			$nextjob->insert();
		}

		wfProfileOut( 'SMWRefreshJob::run (SMW)' );

		return true;
	}
Example #2
0
 function setTypeAndPossibleValues()
 {
     $proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
     if ($proptitle === null) {
         return;
     }
     $store = smwfGetStore();
     // this returns an array of objects
     $allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
     $label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
     $propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
     $this->mPropertyType = $propValue->findPropertyTypeID();
     foreach ($allowed_values as $allowed_value) {
         // HTML-unencode each value
         $this->mPossibleValues[] = html_entity_decode($allowed_value);
         if (count($label_formats) > 0) {
             $label_format = $label_formats[0];
             $prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
             $label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
             $label_value->setOutputFormat($label_format);
             $this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
         }
     }
     // HACK - if there were any possible values, set the property
     // type to be 'enumeration', regardless of what the actual type is
     if (count($this->mPossibleValues) > 0) {
         $this->mPropertyType = 'enumeration';
     }
 }
Example #3
0
 protected function getTypeProperties($typeLabel)
 {
     global $wgRequest, $smwgTypePagingLimit;
     if ($smwgTypePagingLimit <= 0) {
         return '';
     }
     // not too useful, but we comply to this request
     $from = $wgRequest->getVal('from');
     $until = $wgRequest->getVal('until');
     $typeValue = SMWDataValueFactory::newTypeIDValue('__typ', $typeLabel);
     $store = smwfGetStore();
     $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until);
     $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options);
     if (!$options->ascending) {
         $diWikiPages = array_reverse($diWikiPages);
     }
     $result = '';
     if (count($diWikiPages) > 0) {
         $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until);
         $title = $this->getTitleFor('Types', $typeLabel);
         $title->setFragment('#SMWResults');
         // Make navigation point to the result list.
         $navigation = $pageLister->getNavigationLinks($title);
         $resultNumber = min($smwgTypePagingLimit, count($diWikiPages));
         $typeName = $typeValue->getLongWikiText();
         $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMsg('smw_type_header', $typeName) . "</h2>\n<p>" . wfMsgExt('smw_typearticlecount', array('parsemag'), $resultNumber) . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>";
     }
     return $result;
 }
Example #4
0
 /**
  * Run job
  *
  * @return boolean success
  */
 function run()
 {
     wfProfileIn('SMWRefreshJob::run (SMW)');
     if (!array_key_exists('spos', $this->params)) {
         wfProfileOut('SMWRefreshJob::run (SMW)');
         return true;
     }
     $run = array_key_exists('run', $this->params) ? $this->params['run'] : 1;
     $spos = $this->params['spos'];
     $namespaces = $this->params['rc'] > 1 && $run == 1 ? array(SMW_NS_PROPERTY, SMW_NS_TYPE) : false;
     $progress = smwfGetStore()->refreshData($spos, 20, $namespaces);
     $jobParams = null;
     if ($spos > 0) {
         $jobParams = array('spos' => $spos, 'prog' => $progress, 'rc' => $this->params['rc'], 'run' => $run);
     } elseif ($this->params['rc'] > $run) {
         // do another run from the beginning
         $jobParams = array('spos' => 1, 'prog' => 0, 'rc' => $this->params['rc'], 'run' => $run + 1);
     }
     if (!empty($jobParams)) {
         // wikia change start - jobqueue migration
         $task = new \Wikia\Tasks\Tasks\JobWrapperTask();
         $task->call('SMWRefreshJob', $this->title, $jobParams);
         $task->queue();
         // wikia change end
     }
     wfProfileOut('SMWRefreshJob::run (SMW)');
     return true;
 }
Example #5
0
 public static function getAllPropertyNames()
 {
     $all_properties = array();
     // Set limit on results - we don't want a massive dropdown
     // of properties, if there are a lot of properties in this wiki.
     // getProperties() functions stop requiring a limit
     $options = new SMWRequestOptions();
     $options->limit = 500;
     $used_properties = smwfGetStore()->getPropertiesSpecial($options);
     foreach ($used_properties as $property) {
         if ($property[0] instanceof SMWDIProperty) {
             // SMW 1.6+
             $propName = $property[0]->getKey();
             if ($propName[0] != '_') {
                 $all_properties[] = str_replace('_', ' ', $propName);
             }
         } else {
             $all_properties[] = $property[0]->getWikiValue();
         }
     }
     $unused_properties = smwfGetStore()->getUnusedPropertiesSpecial($options);
     foreach ($unused_properties as $property) {
         if ($property instanceof SMWDIProperty) {
             // SMW 1.6+
             $all_properties[] = str_replace('_', ' ', $property->getKey());
         } else {
             $all_properties[] = $property->getWikiValue();
         }
     }
     // Sort properties list alphabetically.
     sort($all_properties);
     return $all_properties;
 }
Example #6
0
 /**
  * Returns the HTML which is added to $wgOut after the article text.
  *
  * @return string
  */
 protected function getHtml()
 {
     wfProfileIn(__METHOD__ . ' (SMW)');
     if ($this->limit > 0) {
         // limit==0: configuration setting to disable this completely
         $store = smwfGetStore();
         $description = new SMWConceptDescription($this->getDataItem());
         $query = SMWPageLister::getQuery($description, $this->limit, $this->from, $this->until);
         $queryResult = $store->getQueryResult($query);
         $diWikiPages = $queryResult->getResults();
         if ($this->until !== '') {
             $diWikiPages = array_reverse($diWikiPages);
         }
         $errors = $queryResult->getErrors();
     } else {
         $diWikiPages = array();
         $errors = array();
     }
     $pageLister = new SMWPageLister($diWikiPages, null, $this->limit, $this->from, $this->until);
     $this->mTitle->setFragment('#SMWResults');
     // Make navigation point to the result list.
     $navigation = $pageLister->getNavigationLinks($this->mTitle);
     $titleText = htmlspecialchars($this->mTitle->getText());
     $resultNumber = min($this->limit, count($diWikiPages));
     $result = "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMsg('smw_concept_header', $titleText) . "</h2>\n" . wfMsgExt('smw_conceptarticlecount', array('parsemag'), $resultNumber) . smwfEncodeMessages($errors) . "\n" . $navigation . $pageLister->formatList() . $navigation . "</div>\n";
     wfProfileOut(__METHOD__ . ' (SMW)');
     return $result;
 }
Example #7
0
 /**
  * Run job
  * @return boolean success
  */
 function run()
 {
     wfProfileIn('SMWUpdateJob::run (SMW)');
     global $wgParser;
     LinkCache::singleton()->clear();
     if (is_null($this->title)) {
         $this->error = "SMWUpdateJob: Invalid title";
         wfProfileOut('SMWUpdateJob::run (SMW)');
         return false;
     } elseif (!$this->title->exists()) {
         smwfGetStore()->deleteSubject($this->title);
         // be sure to clear the data
         wfProfileOut('SMWUpdateJob::run (SMW)');
         return true;
     }
     $revision = Revision::newFromTitle($this->title);
     if (!$revision) {
         $this->error = 'SMWUpdateJob: Page exists but no revision was found for "' . $this->title->getPrefixedDBkey() . '"';
         wfProfileOut('SMWUpdateJob::run (SMW)');
         return false;
     }
     wfProfileIn(__METHOD__ . '-parse');
     $options = new ParserOptions();
     $output = $wgParser->parse($revision->getText(), $this->title, $options, true, true, $revision->getID());
     wfProfileOut(__METHOD__ . '-parse');
     wfProfileIn(__METHOD__ . '-update');
     SMWParseData::storeData($output, $this->title, false);
     wfProfileOut(__METHOD__ . '-update');
     wfProfileOut('SMWUpdateJob::run (SMW)');
     return true;
 }
Example #8
0
 function testCheckIfPropertyRenamed()
 {
     // do some checks
     $page = Title::newFromText("5 cylinder", NS_MAIN);
     $prop = SMWPropertyValue::makeUserProperty("Torsional moment");
     $values = smwfGetStore()->getPropertyValues($page, $prop);
     $this->assertTrue(count($values) > 0);
 }
Example #9
0
 /**
  * Helper function to get the SMW data store for different versions
  * of SMW.
  */
 public static function getSMWStore()
 {
     if (class_exists('\\SMW\\StoreFactory')) {
         // SMW 1.9+
         return \SMW\StoreFactory::getStore();
     } else {
         return smwfGetStore();
     }
 }
 function testGetInstanceAsTarget()
 {
     $exp_values = array("Kai");
     $domainRangeAnnotations = smwfGetStore()->getPropertyValues(Title::newFromText("Has Child", SMW_NS_PROPERTY), smwfGetSemanticStore()->domainRangeHintProp);
     $values = smwfGetAutoCompletionStore()->getInstanceAsTarget("K", $domainRangeAnnotations);
     foreach ($values as $v) {
         $this->assertContains($v->getText(), $exp_values, $v->getText() . " missing");
     }
 }
Example #11
0
 public function run($paramArray, $isAsync, $delay)
 {
     $this->cleanCompleteCache();
     global $smwgDefaultStore;
     if ($smwgDefaultStore == 'SMWTripleStore' || $smwgDefaultStore == 'SMWTripleStoreQuad') {
         define('SMWH_FORCE_TS_UPDATE', 'TRUE');
         smwfGetStore()->initialize(true);
     }
     return '';
 }
 public function execute($param)
 {
     global $wgOut, $wgLang;
     $wgOut->setPageTitle(wfMessage('semanticstatistics')->text());
     $semanticStatistics = smwfGetStore()->getStatistics();
     $dbr = wfGetDB(DB_SLAVE);
     $propertyPageAmount = $dbr->estimateRowCount('page', '*', array('page_namespace' => SMW_NS_PROPERTY));
     $out = wfMsgExt('smw_semstats_text', array('parse'), $wgLang->formatNum($semanticStatistics['PROPUSES']), $wgLang->formatNum($semanticStatistics['USEDPROPS']), $wgLang->formatNum($propertyPageAmount), $wgLang->formatNum($semanticStatistics['DECLPROPS']));
     $wgOut->addHTML($out);
 }
Example #13
0
function saclGetPermissionErrors($title, $user, $action, &$result)
{
    // Failsafe: Some users are exempt from Semantic ACLs
    if ($user->isAllowed('sacl-exempt')) {
        return true;
    }
    $store = smwfGetStore();
    $subject = SMWDIWikiPage::newFromTitle($title);
    // The prefix for the whitelisted group and user properties
    // Either ___VISIBLE or ___EDITABLE
    $prefix = '';
    if ($action == 'read') {
        $prefix = '___VISIBLE';
    } else {
        $type_property = 'Editable by';
        $prefix = '___EDITABLE';
    }
    $property = new SMWDIProperty($prefix);
    $aclTypes = $store->getPropertyValues($subject, $property);
    foreach ($aclTypes as $valueObj) {
        $value = strtolower($valueObj->getString());
        if ($value == 'users') {
            if ($user->isAnon()) {
                $result = false;
                return false;
            }
        } elseif ($value == 'whitelist') {
            $isWhitelisted = false;
            $groupProperty = new SMWDIProperty("{$prefix}_WL_GROUP");
            $userProperty = new SMWDIProperty("{$prefix}_WL_USER");
            $whitelistValues = $store->getPropertyValues($subject, $groupProperty);
            foreach ($whitelistValues as $whitelistValue) {
                $group = strtolower($whitelistValue->getString());
                if (in_array($group, $user->getEffectiveGroups())) {
                    $isWhitelisted = true;
                    break;
                }
            }
            $whitelistValues = $store->getPropertyValues($subject, $userProperty);
            foreach ($whitelistValues as $whitelistValue) {
                $title = $whitelistValue->getTitle();
                if ($title->equals($user->getUserPage())) {
                    $isWhitelisted = true;
                }
            }
            if (!$isWhitelisted) {
                $result = false;
                return false;
            }
        } elseif ($value == 'public') {
            return true;
        }
    }
    return true;
}
 /**
  * This method is called by the bot framework.
  */
 public function run($paramArray, $isAsync, $delay)
 {
     echo "...started!\n";
     $this->updateTermImports();
     global $smwgDefaultStore;
     if ($smwgDefaultStore == 'SMWTripleStore' || $smwgDefaultStore == 'SMWTripleStoreQuad') {
         define('SMWH_FORCE_TS_UPDATE', 'TRUE');
         smwfGetStore()->initialize(true);
     }
     return;
 }
Example #15
0
 function testExcelQueryPrinter()
 {
     $params = array();
     $context = SMWQueryProcessor::INLINE_QUERY;
     $format = "exceltable";
     $extraprintouts = array();
     $querystring = "[[Category:Car]]";
     $query = SMWQueryProcessor::createQuery($querystring, $params, $context, $format, $extraprintouts);
     $res = smwfGetStore()->getQueryResult($query);
     $result = SMWQueryProcessor::getResultFromQuery($query, $params, $extraprintouts, SMW_OUTPUT_FILE, $context, $format);
     $this->assertFileContentsIgnoringWhitespaces("testcases/resources/excel_qp_result.dat", $result);
 }
 public function execute()
 {
     global $wgRequest, $wgOut, $smwgMessageBroker, $smwgWebserviceEndpoint, $wgUser, $smwgEnableObjectLogicRules;
     $wgOut->setPageTitle(wfMsg('tsa'));
     $html = "";
     if ($wgRequest->getVal('init') != NULL) {
         // after init
         smwfGetStore()->initialize(false);
         $html .= $wgUser->getSkin()->makeKnownLinkObj(Title::newFromText("TSA", NS_SPECIAL), wfMsg('smw_tsa_waitsoemtime'));
         $wgOut->addHTML($html);
         return;
     }
     $html .= "<div style=\"margin-bottom:10px;\">" . wfMsg('smw_tsa_welcome') . "</div>";
     global $smwgTripleStoreGraph;
     TSConnection::getConnector()->connect();
     try {
         $status = TSConnection::getConnector()->getStatus($smwgTripleStoreGraph);
     } catch (Exception $e) {
         // if no connection could be created
         $html .= "<div style=\"color:red;font-weight:bold;\">" . wfMsg('smw_tsa_couldnotconnect') . "</div>" . wfMsg('smw_tsa_addtoconfig') . "<pre>\$smwgMessageBroker  = &lt;IP of messagebroker&gt;\n" . "\$smwgWebserviceEndpoint = &lt;IP and port of SPARQL endpoint&gt;\n\nExample:\n\n\$smwgMessageBroker  = \"localhost\";\n" . "\$smwgWebserviceEndpoint = \"localhost:8080\";</pre>" . wfMsg('smw_tsa_addtoconfig2') . " <pre>enableSMWHalo('SMWHaloStore2', 'SMWTripleStore', 'http://mywiki');</pre>" . wfMsg('smw_tsa_addtoconfig3');
         $smwForumLink = '<a href="http://smwforum.ontoprise.com/smwforum/index.php/Help:Installing_the_Basic_Triplestore_manually">SMW-Forum</a>';
         $html .= "<br><b>" . wfMsg('smw_tsa_addtoconfig4', $smwForumLink) . "</b>";
         $wgOut->addHTML($html);
         return;
     }
     // normal
     $html .= "<h2>" . wfMsg('smw_tsa_driverinfo') . "</h2>" . $status['driverInfo'] . "";
     $html .= "<h2>" . wfMsg('smw_tsa_tscinfo') . "</h2>";
     $html .= wfMsg('smw_tsa_tscversion') . ": " . $status['tscversion'];
     // show warning when rule support is missing or defined although it is not available.
     if (in_array('RULES', $status['features']) && (!isset($smwgEnableObjectLogicRules) || $smwgEnableObjectLogicRules === false)) {
         $html .= "<div style=\"color:red;font-weight:bold;\">" . wfMsg('smw_tsa_rulesupport') . "</div>";
     }
     if (!in_array('RULES', $status['features']) && $smwgEnableObjectLogicRules === true) {
         $html .= "<div style=\"color:red;font-weight:bold;\">" . wfMsg('smw_tsa_norulesupport') . "</div>";
     }
     $html .= "<h2>" . wfMsg('smw_tsa_status') . "</h2>";
     if ($status['isInitialized'] == true) {
         $html .= "<div style=\"color:green;font-weight:bold;\">" . wfMsg('smw_tsa_wikiconfigured', is_array($smwgWebserviceEndpoint) ? implode(", ", $smwgWebserviceEndpoint) : $smwgWebserviceEndpoint) . "</div>";
         $tsaPage = Title::newFromText("TSA", NS_SPECIAL);
         $html .= "<br><form><input name=\"init\" type=\"submit\" value=\"" . wfMsg('smw_tsa_reinitialize') . "\"/><input name=\"title\" type=\"hidden\" value=\"" . $tsaPage->getPrefixedDBkey() . "\"/></form>";
     } else {
         $html .= "<div style=\"color:red;font-weight:bold;\">" . wfMsg('smw_tsa_notinitalized') . "</div>" . wfMsg('smw_tsa_pressthebutton');
         $tsaPage = Title::newFromText("TSA", NS_SPECIAL);
         $html .= "<br><form><input name=\"init\" type=\"submit\" value=\"" . wfMsg('smw_tsa_initialize') . "\"/><input name=\"title\" type=\"hidden\" value=\"" . $tsaPage->getPrefixedDBkey() . "\"/></form>";
     }
     $wgOut->addHTML($html);
 }
 public function __construct(LingoMessageLog &$messages = null)
 {
     parent::__construct($messages);
     // get the store
     $store = smwfGetStore();
     // Create query
     $desc = new SMWSomeProperty(new SMWDIProperty('___glt'), new SMWThingDescription());
     $desc->addPrintRequest(new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty('___glt')));
     $desc->addPrintRequest(new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty('___gld')));
     $desc->addPrintRequest(new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty('___gll')));
     $query = new SMWQuery($desc, false, false);
     $query->sort = true;
     $query->sortkeys['___glt'] = 'ASC';
     // get the query result
     $this->mQueryResult = $store->getQueryResult($query);
 }
Example #18
0
 public function execute()
 {
     $params = $this->extractRequestParams();
     $requestedInfo = $params['info'];
     $resultInfo = array();
     if (in_array('proppagecount', $requestedInfo)) {
         $resultInfo['proppagecount'] = wfGetDB(DB_SLAVE)->estimateRowCount('page', '*', array('page_namespace' => SMW_NS_PROPERTY));
     }
     if (in_array('propcount', $requestedInfo) || in_array('usedpropcount', $requestedInfo) || in_array('declaredpropcount', $requestedInfo)) {
         $semanticStats = smwfGetStore()->getStatistics();
         $map = array('propcount' => 'PROPUSES', 'usedpropcount' => 'USEDPROPS', 'declaredpropcount' => 'DECLPROPS');
         foreach ($map as $apiName => $smwName) {
             if (in_array($apiName, $requestedInfo)) {
                 $resultInfo[$apiName] = $semanticStats[$smwName];
             }
         }
     }
     $this->getResult()->addValue(null, 'info', $resultInfo);
 }
Example #19
0
 /**
  *
  * Load all semantic properties of a page as a hash
  * @param String $pagename
  * @param Integer $namespace
  * @param Boolean $normalizeTitle
  * @return an associative array with the property name as key and property value as value.
  */
 public static function &loadSemanticProperties($pagename, $namespace = NS_MAIN, $normalizeTitle = true)
 {
     //-----normalize title
     $data = null;
     if ($normalizeTitle) {
         $title = MWUtil::normalizePageTitle($pagename, false);
         $di = SMWDIWikiPage::newFromTitle($title);
         $data = smwfGetStore()->getSemanticData($di);
     } else {
         $di = new SMWDIWikiPage($pagename, $namespace, '');
         $data = smwfGetStore()->getSemanticData($di);
     }
     $valuehash = array();
     $diProperties = $data->getProperties();
     foreach ($diProperties as $diProperty) {
         $dvProperty = SMWDataValueFactory::newDataItemValue($diProperty, null);
         $name = null;
         if ($dvProperty->isVisible()) {
             $name = $diProperty->getLabel();
         } elseif ($diProperty->getKey() == '_INST') {
             $name = 'Categories';
         } else {
             continue;
             // skip this line
         }
         if (!$name) {
             continue;
         }
         $values = $data->getPropertyValues($diProperty);
         $vs = array();
         foreach ($values as $di) {
             $dv = SMWDataValueFactory::newDataItemValue($di, $diProperty);
             $vs[] = $dv->getWikiValue();
         }
         if (count($vs) == 1) {
             $valuehash[$name] = $vs[0];
         } else {
             $valuehash[$name] = $vs;
         }
     }
     #error_log(print_r($valuehash, true));
     return $valuehash;
 }
Example #20
0
 function execute($p)
 {
     global $wgOut, $wgRequest, $smwgQEnabled, $smwgRSSEnabled, $smwgMW_1_14;
     wfProfileIn('doSpecialAskTSC (SMWHalo)');
     $this->extractQueryParameters($p);
     $format = $this->getResultFormat($this->m_params);
     $query = SMWSPARQLQueryProcessor::createQuery($this->m_querystring, $this->m_params, SMWQueryProcessor::SPECIAL_PAGE, $format, $this->m_printouts);
     $res = smwfGetStore()->getQueryResult($query);
     $printer = SMWQueryProcessor::getResultPrinter($format, SMWQueryProcessor::SPECIAL_PAGE, $res);
     $result_mime = $printer->getMimeType($res);
     if ($result_mime == false) {
         if ($res->getCount() > 0) {
             $result = '<div style="text-align: center;">';
             $result .= '</div>' . $printer->getResult($res, $this->m_params, SMW_OUTPUT_HTML);
             $result .= '<div style="text-align: center;"></div>';
         } else {
             $result = '<div style="text-align: center;">' . wfMsg('smw_result_noresults') . '</div>';
         }
     } else {
         // make a stand-alone file
         $result = $printer->getResult($res, $this->m_params, SMW_OUTPUT_FILE);
         $result_name = $printer->getFileName($res);
         // only fetch that after initialising the parameters
     }
     if ($result_mime == false) {
         if ($this->m_querystring) {
             $wgOut->setHTMLtitle($this->m_querystring);
         } else {
             $wgOut->setHTMLtitle(wfMsg('ask'));
         }
         $wgOut->addHTML($result);
     } else {
         $wgOut->disable();
         header("Content-type: {$result_mime}; charset=UTF-8");
         if ($result_name !== false) {
             header("Content-Disposition: attachment; filename={$result_name}");
         }
         print $result;
     }
     wfProfileOut('doSpecialAskTSC (SMWHalo)');
 }
Example #21
0
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if (!isset($this->paramWidth)) {
         $this->paramWidth = -1;
     }
     $this->isHTML = true;
     global $wgOut;
     $wgOut->addModules('ext.SemanticImageAnnotator.ResultFormat');
     $resultPages = $res->getResults();
     $store = smwfGetStore();
     $annotationArray = array();
     foreach ($resultPages as $page) {
         $namespace = $page->getNamespace();
         if ($namespace != 380) {
             continue;
         }
         $coords = "";
         $imgUrl = "";
         $pageName = $page->getDBkey();
         $propertyCoords = new SMWDIProperty("__SIA_RECTCOORDS");
         $propertyImgUrl = new SMWDIProperty("__SIA_IMG_URL");
         $coordValues = $store->getPropertyValues($page, $propertyCoords);
         $urlValues = $store->getPropertyValues($page, $propertyImgUrl);
         if (count($coordValues) == 1 && $coordValues[0] instanceof SMWDIString) {
             $coords = $coordValues[0]->getString();
         }
         if (count($urlValues) == 1 && $coordValues[0] instanceof SMWDIString) {
             $imgUrl = $urlValues[0]->getString();
         }
         if ($coords != "" && $imgUrl != "") {
             $annotationArray[$imgUrl][] = array($pageName, $coords);
         }
     }
     $returnString = "";
     foreach ($annotationArray as $image => $annotationData) {
         $returnString .= $this->createAnnotatedImg($image, $annotationData);
     }
     return $returnString;
 }
Example #22
0
 public function execute()
 {
     global $smwgDefaultStore;
     $alternativestore = $this->getArg('backend', false);
     $alternativestore = $alternativestore !== false && $alternativestore !== $smwgDefaultStore;
     if ($alternativestore !== false) {
         $smwgDefaultStore = $this->getArg('backend', false);
         print "\nSelected storage " . $smwgDefaultStore . " for update!\n\n";
     }
     global $smwgIP;
     if (!isset($smwgIP)) {
         $smwgIP = dirname(__FILE__) . '/../';
     }
     require_once $smwgIP . 'includes/SMW_GlobalFunctions.php';
     if ($this->hasOption('delete')) {
         print "\n  Deleting all stored data for {$smwgDefaultStore} completely!\n  \n\n";
         if ($alternativestore) {
             print "  This store is currently not used by SMW. Deleting it\n  should not cause problems in the wiki.\n\n";
             $delay = 5;
         } else {
             print "  WARNING: This store is currently used by SMW! Deleting it\n           will cause problems in the wiki if SMW is enabled.\n\n";
             $delay = 20;
         }
         print "Abort with CTRL-C in the next {$delay} seconds ...  ";
         wfCountDown($delay);
         smwfGetStore()->drop(true);
         wfRunHooks('smwDropTables');
         print "\n";
         while (ob_get_level() > 0) {
             // be sure to have some buffer, otherwise some PHPs complain
             ob_end_flush();
         }
         echo "\n  All storage structures for {$smwgDefaultStore} have been deleted.\n  You can recreate them with this script, and then use\n  SMW_refreshData.php to rebuild their contents.";
     } else {
         smwfGetStore()->setup();
         wfRunHooks('smwInitializeTables');
     }
 }
 /**
  * Return all the children as PersonPageValues
  *
  * @return array
  */
 public function getChildren()
 {
     if ($this->children !== null) {
         return $this->children;
     }
     $this->children = array();
     $storage = smwfGetStore();
     $properties = SemanticGenealogy::getProperties();
     if ($properties['father'] instanceof SMWDIProperty) {
         $childrenPage = $storage->getPropertySubjects($properties['father'], $this->page);
         foreach ($childrenPage as $page) {
             $this->children[] = new PersonPageValues($page);
         }
     }
     if ($properties['mother'] instanceof SMWDIProperty) {
         $childrenPage = $storage->getPropertySubjects($properties['mother'], $this->page);
         foreach ($childrenPage as $page) {
             $this->children[] = new PersonPageValues($page);
         }
     }
     usort($this->children, array("PersonPageValues", "comparePeopleByBirthDate"));
     return $this->children;
 }
Example #24
0
function getAnnotations($annotatedImage)
{
    global $wgExtensionCredits;
    $new = false;
    foreach ($wgExtensionCredits['semantic'] as $elem) {
        if ($elem['name'] == 'Semantic MediaWiki') {
            $vers = $elem['version'];
            $new = version_compare($vers, '1.7', '>=');
        }
    }
    $returnString = '{"shapes":[';
    $queryString = '[[SIAannotatedImage::' . $annotatedImage . ']]';
    $params = array();
    $params['link'] = 'none';
    $params['mainlabel'] = 'result';
    #$params = ['order'];
    #$params = ['sort'];
    if ($new) {
        $params['order'] = array('asc');
        $params['sort'] = array('SIAannotatedImage');
    } else {
        $params['order'] = 'asc';
        $params['sort'] = 'SIAannotatedImage';
    }
    //Generate all the extra printouts, eg all properties to retrieve:
    $printmode = SMWPrintRequest::PRINT_PROP;
    $customPrintouts = array('coordinates' => 'SIArectangleCoordinates', 'text' => 'ImageAnnotationText');
    $extraprintouts = array();
    foreach ($customPrintouts as $label => $property) {
        $extraprintouts[] = new SMWPrintRequest($printmode, $label, SMWPropertyValue::makeUserProperty($property));
    }
    $format = 'table';
    $context = SMWQueryProcessor::INLINE_QUERY;
    $query = SMWQueryProcessor::createQuery($queryString, $params, $context, $format, $extraprintouts);
    $store = smwfGetStore();
    // default store
    $res = $store->getQueryResult($query);
    $shapeCounter = 0;
    while (($resArrayArray = $res->getNext()) != false) {
        //Array of SMWResultArray Objects, eg. all retrieved Pages
        $shapeCounter++;
        if ($shapeCounter > 1) {
            $returnString .= ',';
        }
        $returnString .= '{';
        foreach ($resArrayArray as $resArray) {
            //SMWResultArray-Object, column of resulttable (pagename or propertyvalue)
            $currentPrintRequestLabel = $resArray->getPrintRequest()->getLabel();
            //The label as defined in the above array
            if ($currentPrintRequestLabel == 'coordinates') {
                $currentResultPage = $resArray->getResultSubject();
                $currentID = $currentResultPage->getTitle()->getFullText();
                $currentCoords = $resArray->getNextDataItem()->getSerialization();
                $returnString .= '"coords":"' . $currentCoords . '","id":"' . $currentID . '"';
            }
        }
        $returnString .= '}';
    }
    $returnString .= ']}';
    return $returnString;
}
	function get_ask_feed() {
		global $wgSitename, $wgTitle, $wgRequest;
		// check for semantic wiki:
		if ( !defined( 'SMW_VERSION' ) ) {
			return false;
		}
		// bootstrap off of SMWAskPage:
		$SMWAskPage = new SMWAskPage();
		$SMWAskPage->extractQueryParameters( $wgRequest->getVal( 'q' ) );

		// print 'query string: ' . $SMWAskPage->m_querystring . "\n<br />";
		// print 'm_params: ' . print_r($SMWAskPage->m_params) . "\n<br />";
		// print 'print outs: ' .print_r($SMWAskPage->m_printouts) . "\n<br />";
		// set up the feed:
		$this->feed = new mvRSSFeed(
		$wgSitename . ' - ' . wfMsg( 'mediasearch' ) . ' : ' . strip_tags( $SMWAskPage->m_querystring ), // title
		strip_tags( $SMWAskPage->m_querystring ), // description
		$wgTitle->getFullUrl() // link
		);
		$this->feed->outHeader();

		$queryobj = SMWQueryProcessor::createQuery( $SMWAskPage->m_querystring, $SMWAskPage->m_params, false, '', $SMWAskPage->m_printouts );
		$res = smwfGetStore()->getQueryResult( $queryobj );
		$row = $res->getNext();
		while ( $row !== false ) {
			$wikititle = $row[0]->getNextObject();
			$this->feed->outPutItem( $wikititle->getTitle() );
			$row = $res->getNext();
		}
		$this->feed->outFooter();
	}
 public function execute($query)
 {
     global $wgRequest, $wgOut;
     $linker = smwfGetLinker();
     $this->setHeaders();
     // Get parameters
     $pagename = $wgRequest->getVal('from');
     $propname = $wgRequest->getVal('type');
     $limit = $wgRequest->getVal('limit');
     $offset = $wgRequest->getVal('offset');
     if ($limit === '') {
         $limit = 20;
     }
     if ($offset === '') {
         $offset = 0;
     }
     if ($propname === '') {
         // No GET parameters? Try the URL:
         $queryparts = explode('::', $query);
         $propname = $query;
         if (count($queryparts) > 1) {
             $pagename = $queryparts[0];
             $propname = implode('::', array_slice($queryparts, 1));
         }
     }
     $subject = SMWDataValueFactory::newTypeIDValue('_wpg', $pagename);
     $pagename = $subject->isValid() ? $subject->getPrefixedText() : '';
     $property = SMWPropertyValue::makeUserProperty($propname);
     $propname = $property->isValid() ? $property->getWikiValue() : '';
     // Produce output
     $html = '';
     if ($propname === '') {
         // no property given, show a message
         $html .= wfMsg('smw_pp_docu') . "\n";
     } else {
         // property given, find and display results
         // FIXME: very ugly, needs i18n
         $wgOut->setPagetitle(($pagename !== '' ? $pagename . ' ' : '') . $property->getWikiValue());
         // get results (get one more, to see if we have to add a link to more)
         $options = new SMWRequestOptions();
         $options->limit = $limit + 1;
         $options->offset = $offset;
         $options->sort = true;
         $results = smwfGetStore()->getPropertyValues($pagename !== '' ? $subject->getDataItem() : null, $property->getDataItem(), $options);
         // prepare navigation bar if needed
         if ($offset > 0 || count($results) > $limit) {
             if ($offset > 0) {
                 $navigation = Html::element('a', array('href' => $this->getTitle()->getLocalURL(array('offset' => max(0, $offset - $limit), 'limit' => $limit, 'type' => $propname, 'from' => $pagename))), wfMsg('smw_result_prev'));
             } else {
                 $navigation = wfMsg('smw_result_prev');
             }
             $navigation .= '&#160;&#160;&#160;&#160; <b>' . wfMsg('smw_result_results') . ' ' . ($offset + 1) . '– ' . ($offset + min(count($results), $limit)) . '</b>&#160;&#160;&#160;&#160;';
             if (count($results) == $limit + 1) {
                 $navigation = Html::element('a', array('href' => $this->getTitle()->getLocalURL(array('offset' => $offset + $limit, 'limit' => $limit, 'type' => $propname, 'from' => $pagename))), wfMsg('smw_result_next'));
             } else {
                 $navigation .= wfMsg('smw_result_next');
             }
         } else {
             $navigation = '';
         }
         // display results
         $html .= '<br />' . $navigation;
         if (count($results) == 0) {
             $html .= wfMsg('smw_result_noresults');
         } else {
             $html .= "<ul>\n";
             $count = $limit + 1;
             foreach ($results as $di) {
                 $count--;
                 if ($count < 1) {
                     continue;
                 }
                 $dv = SMWDataValueFactory::newDataItemValue($di, $property->getDataItem());
                 $html .= '<li>' . $dv->getLongHTMLText($linker);
                 // do not show infolinks, the magnifier "+" is ambiguous with the browsing '+' for '_wpg' (see below)
                 if ($property->getDataItem()->findPropertyTypeID() == '_wpg') {
                     $browselink = SMWInfolink::newBrowsingLink('+', $dv->getLongWikiText());
                     $html .= ' &#160;' . $browselink->getHTML($linker);
                 }
                 $html .= "</li> \n";
             }
             $html .= "</ul>\n";
         }
         $html .= $navigation;
     }
     // Display query form
     $spectitle = $this->getTitle();
     $html .= '<p>&#160;</p>';
     $html .= '<form name="pageproperty" action="' . htmlspecialchars($spectitle->getLocalURL()) . '" method="get">' . "\n" . '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>';
     $html .= wfMsg('smw_pp_from') . ' <input type="text" name="from" value="' . htmlspecialchars($pagename) . '" />' . "&#160;&#160;&#160;\n";
     $html .= wfMsg('smw_pp_type') . ' <input type="text" name="type" value="' . htmlspecialchars($propname) . '" />' . "\n";
     $html .= '<input type="submit" value="' . wfMsg('smw_pp_submit') . "\"/>\n</form>\n";
     $wgOut->addHTML($html);
     SMWOutputs::commitToOutputPage($wgOut);
     // make sure locally collected output data is pushed to the output!
 }
Example #27
0
 /**
  * Find the property's type ID, either by looking up its predefined ID
  * (if any) or by retrieving the relevant information from the store.
  * If no type is stored for a user defined property, the global default
  * type will be used.
  *
  * @return string type ID
  */
 public function findPropertyTypeID()
 {
     global $smwgPDefaultType;
     if (!isset($this->m_proptypeid)) {
         if ($this->isUserDefined()) {
             // normal property
             $diWikiPage = new SMWDIWikiPage($this->getKey(), SMW_NS_PROPERTY, '');
             $typearray = smwfGetStore()->getPropertyValues($diWikiPage, new SMWDIProperty('_TYPE'));
             if (count($typearray) >= 1) {
                 // some types given, pick one (hopefully unique)
                 $typeDataItem = reset($typearray);
                 if ($typeDataItem instanceof SMWDIUri) {
                     $this->m_proptypeid = $typeDataItem->getFragment();
                 } else {
                     $this->m_proptypeid = $smwgPDefaultType;
                     // This is important. If a page has an invalid assignment to "has type", no
                     // value will be stored, so the elseif case below occurs. But if the value
                     // is retrieved within the same run, then the error value for "has type" is
                     // cached and thus this case occurs. This is why it is important to tolerate
                     // this case -- it is not necessarily a DB error.
                 }
             } elseif (count($typearray) == 0) {
                 // no type given
                 $this->m_proptypeid = $smwgPDefaultType;
             }
         } else {
             // pre-defined property
             $this->m_proptypeid = self::getPredefinedPropertyTypeId($this->m_key);
         }
     }
     return $this->m_proptypeid;
 }
Example #28
0
 /**
  * Executes the query.
  *
  * This method can be called once $queryString, $parameters, $printOuts
  * are set either by using the setQueryString(), setParams() and
  * setPrintOuts() followed by extractParameters(), or one of the static
  * factory methods such as makeForInfoLink() or makeForUI().
  *
  * Errors, if any can be accessed from hasError() and getErrors().
  */
 public function execute()
 {
     $errors = array();
     if ($this->queryString !== '') {
         // FIXME: this is a hack
         SMWQueryProcessor::addThisPrintout($this->printOuts, $this->parameters);
         $params = SMWQueryProcessor::getProcessedParams($this->parameters, $this->printOuts);
         $this->parameters['format'] = $params['format'];
         $this->params = $params;
         $query = SMWQueryProcessor::createQuery($this->queryString, $params, SMWQueryProcessor::SPECIAL_PAGE, $this->parameters['format'], $this->printOuts);
         $res = smwfGetStore()->getQueryResult($query);
         $this->queryResult = $res;
         $errors = array_merge($errors, $res->getErrors());
         if (!empty($errors)) {
             $this->errorsOccured = true;
             $this->errors = array_merge($errors, $this->errors);
         }
         // BEGIN: Try to be smart for rss/ical if no description/title is given and we have a concept query
         if ($this->parameters['format'] == 'rss') {
             $descKey = 'rssdescription';
             $titleKey = 'rsstitle';
         } elseif ($this->parameters['format'] == 'icalendar') {
             $descKey = 'icalendardescription';
             $titleKey = 'icalendartitle';
         } else {
             $descKey = false;
         }
         if ($descKey && $query->getDescription() instanceof SMWConceptDescription && (!isset($this->parameters[$descKey]) || !isset($this->parameters[$titleKey]))) {
             $concept = $query->getDescription()->getConcept();
             if (!isset($this->parameters[$titleKey])) {
                 $this->parameters[$titleKey] = $concept->getText();
             }
             if (!isset($this->parameters[$descKey])) {
                 // / @bug The current SMWStore will never return SMWConceptValue (an SMWDataValue) here; it might return SMWDIConcept (an SMWDataItem)
                 $dv = end(smwfGetStore()->getPropertyValues(SMWWikiPageValue::makePageFromTitle($concept), new SMWDIProperty('_CONC')));
                 if ($dv instanceof SMWConceptValue) {
                     $this->parameters[$descKey] = $dv->getDocu();
                 }
             }
         }
         // END: Try to be smart for rss/ical if no description/title is given and we have a concept query
         /*
          * If parameters have been passed in the infolink-style and the
          * mimie-type of format is defined, generate the export, instead of
          * showing more html.
          */
         $printer = SMWQueryProcessor::getResultPrinter($this->parameters['format'], SMWQueryProcessor::SPECIAL_PAGE);
         $resultMime = $printer->getMimeType($res);
         if ($this->context == self::WIKI_LINK && $resultMime != false) {
             global $wgOut;
             $result = $printer->getResult($res, $this->parameters, SMW_OUTPUT_FILE);
             $resultName = $printer->getFileName($res);
             $wgOut->disable();
             header("Content-type: {$resultMime}; charset=UTF-8");
             if ($resultName !== false) {
                 header("content-disposition: attachment; filename={$resultName}");
             }
             echo $result;
         }
     }
 }
Example #29
0
 /**
  *	This method renders the result set provided by SMW according to the printer
  * 
  *  @param res				SMWQueryResult, result set of the ask query provided by SMW
  *  @param outputmode		?
  *  @return				String, rendered HTML output of this printer for the ask-query
  *
  */
 protected function getResultText($res, $outputmode)
 {
     global $wgContLang;
     // content language object
     $result = '';
     $m_outlineLevel = 0;
     $hasChildren = array();
     $m_outlineLevel++;
     $m_seedCategory = "";
     $m_seedName = "";
     $m_categories = $this->m_projectmanagementclass->getCategories();
     $m_properties = $this->m_projectmanagementclass->getProperties();
     if ($outputmode == SMW_OUTPUT_FILE) {
         $queryparts = preg_split("/]]/", $res->getQueryString());
         $taskname = str_replace("[[", "", $queryparts[0]);
         if (strpos($taskname, "Category:") === false) {
             //case: [[{{PAGENAME}}]]
             if ($res->getCount() == 1) {
                 $m_seedName = trim(str_replace("[[", "", str_replace("]]", "", $res->getQueryString())));
                 $firstQuery = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[' . $m_seedName . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
                 //$firstQuery = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[Part of::'.$m_seedName.']]',array(),SMWQueryProcessor::INLINE_QUERY,'',$res->getPrintRequests()));
             } else {
                 return "<html><body>ERROR: Query: " . $res->getQueryString() . "is invalid! Valid formats: [[Category:SampleCategory]] or: [[{{PAGENAME}}]]</body></html>";
             }
         } else {
             $m_seedCategory = trim(str_replace("Category:", "", $taskname));
             if (in_array($m_seedCategory, $m_categories)) {
                 $firstQuery = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[Category:' . $m_seedCategory . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
             } else {
                 return "<html><body>ERROR: Category: " . $m_seedCategory . " has not been defined on Special:SemanticProjectManagement </body></html>";
             }
         }
         $this->m_projectmanagementclass->setName("ProjectManagementClass");
         //	echo "First Query: ".$firstQuery->getQueryString()."<br/>";
         //generate seed task
         $task = $this->m_projectmanagementclass->makeTask("seed", 0);
         $task->addWBS(0, 0);
         $task->setUid(0);
         $hasChildren = $this->m_projectmanagementclass->getTaskResults($firstQuery, $outputmode, $m_outlineLevel, $task);
         $processedChildren = array();
         $hasChild = true;
         while ($hasChild) {
             $hasChild = false;
             $allTempChildren = array();
             $m_outlineLevel++;
             foreach ($hasChildren as $child) {
                 if (in_array($child, $processedChildren)) {
                 } else {
                     if (isset($m_properties[$child->getLevel()]) && isset($m_categories[$child->getLevel()])) {
                         //build new Query
                         if ($child->getLevel() != 0) {
                             $res2 = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[Category:' . $m_categories[$child->getLevel()] . ']] [[' . $m_properties[$child->getLevel()] . '::' . $child->getPage() . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
                         } else {
                             if (isset($m_properties[1])) {
                                 $res2 = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[Category:' . $m_categories[0] . ']] [[' . $m_properties[1] . '::' . $child->getPage() . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
                             } else {
                                 $res2 = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[' . $child->getPage() . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
                             }
                         }
                         //	echo "Next Query: ".$res2->getQueryString()." Level: ".$m_outlineLevel."<br/>";
                         $queryresults = $this->m_projectmanagementclass->getTaskResults($res2, $outputmode, $m_outlineLevel, $child);
                         $processedChildren[] = $child;
                         foreach ($queryresults as $temp) {
                             $allTempChildren[] = $temp;
                         }
                     }
                 }
             }
             $hasChildren = $allTempChildren;
             if (count($hasChildren) > 0) {
                 $hasChild = true;
             }
         }
         $task->addWBS(1, 0);
         $result .= $this->m_projectmanagementclass->getXML();
     } else {
         // just make xml file
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             $label = wfMsgForContent('spm_wbs_link');
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('wbs', 'format');
         if ($this->getSearchLabel(SMW_OUTPUT_WIKI) != '') {
             $link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
         }
         if (array_key_exists('limit', $this->m_params)) {
             $link->setParameter($this->m_params['limit'], 'limit');
         } else {
             // use a reasonable default limit
             $link->setParameter(500, 'limit');
         }
         $result .= $link->getText($outputmode, $this->mLinker);
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
         // make xml file
     }
     return $result;
 }
Example #30
0
 /**
  * TODO: document
  */
 protected function makeHTMLResult()
 {
     global $wgOut;
     // TODO: hold into account $smwgAutocompleteInSpecialAsk
     $wgOut->addModules('ext.smw.ask');
     $result = '';
     $result_mime = false;
     // output in MW Special page as usual
     // build parameter strings for URLs, based on current settings
     $urlArgs['q'] = $this->m_querystring;
     $tmp_parray = array();
     foreach ($this->m_params as $key => $value) {
         if (!in_array($key, array('sort', 'order', 'limit', 'offset', 'title'))) {
             $tmp_parray[$key] = $value;
         }
     }
     $urlArgs['p'] = SMWInfolink::encodeParameters($tmp_parray);
     $printoutstring = '';
     /**
      * @var SMWPrintRequest $printout
      */
     foreach ($this->m_printouts as $printout) {
         $printoutstring .= $printout->getSerialisation() . "\n";
     }
     if ($printoutstring !== '') {
         $urlArgs['po'] = $printoutstring;
     }
     if (array_key_exists('sort', $this->m_params)) {
         $urlArgs['sort'] = $this->m_params['sort'];
     }
     if (array_key_exists('order', $this->m_params)) {
         $urlArgs['order'] = $this->m_params['order'];
     }
     if ($this->m_querystring !== '') {
         // FIXME: this is a hack
         SMWQueryProcessor::addThisPrintout($this->m_printouts, $this->m_params);
         $params = SMWQueryProcessor::getProcessedParams($this->m_params, $this->m_printouts);
         $this->m_params['format'] = $params['format']->getValue();
         $this->params = $params;
         $queryobj = SMWQueryProcessor::createQuery($this->m_querystring, $params, SMWQueryProcessor::SPECIAL_PAGE, $this->m_params['format'], $this->m_printouts);
         /**
          * @var SMWQueryResult $res
          */
         // Determine query results
         $res = $params['source']->getValue()->getQueryResult($queryobj);
         // Try to be smart for rss/ical if no description/title is given and we have a concept query:
         if ($this->m_params['format'] == 'rss') {
             $desckey = 'rssdescription';
             $titlekey = 'rsstitle';
         } elseif ($this->m_params['format'] == 'icalendar') {
             $desckey = 'icalendardescription';
             $titlekey = 'icalendartitle';
         } else {
             $desckey = false;
         }
         if ($desckey && $queryobj->getDescription() instanceof SMWConceptDescription && (!isset($this->m_params[$desckey]) || !isset($this->m_params[$titlekey]))) {
             $concept = $queryobj->getDescription()->getConcept();
             if (!isset($this->m_params[$titlekey])) {
                 $this->m_params[$titlekey] = $concept->getText();
             }
             if (!isset($this->m_params[$desckey])) {
                 // / @bug The current SMWStore will never return SMWConceptValue (an SMWDataValue) here; it might return SMWDIConcept (an SMWDataItem)
                 $dv = end(smwfGetStore()->getPropertyValues(SMWWikiPageValue::makePageFromTitle($concept), new SMWDIProperty('_CONC')));
                 if ($dv instanceof SMWConceptValue) {
                     $this->m_params[$desckey] = $dv->getDocu();
                 }
             }
         }
         $printer = SMWQueryProcessor::getResultPrinter($this->m_params['format'], SMWQueryProcessor::SPECIAL_PAGE);
         global $wgRequest;
         $hidequery = $wgRequest->getVal('eq') == 'no';
         if (!$printer->isExportFormat()) {
             if ($res->getCount() > 0) {
                 if ($this->m_editquery) {
                     $urlArgs['eq'] = 'yes';
                 } elseif ($hidequery) {
                     $urlArgs['eq'] = 'no';
                 }
                 $navigation = $this->getNavigationBar($res, $urlArgs);
                 $result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
                 $query_result = $printer->getResult($res, $params, SMW_OUTPUT_HTML);
                 if (is_array($query_result)) {
                     $result .= $query_result[0];
                 } else {
                     $result .= $query_result;
                 }
                 $result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
             } else {
                 $result = '<div style="text-align: center;">' . wfMessage('smw_result_noresults')->escaped() . '</div>';
             }
         }
     }
     if (isset($printer) && $printer->isExportFormat()) {
         $wgOut->disable();
         /**
          * @var SMWIExportPrinter $printer
          */
         $printer->outputAsFile($res, $params);
     } else {
         if ($this->m_querystring) {
             $wgOut->setHTMLtitle($this->m_querystring);
         } else {
             $wgOut->setHTMLtitle(wfMessage('ask')->text());
         }
         $urlArgs['offset'] = $this->m_params['offset'];
         $urlArgs['limit'] = $this->m_params['limit'];
         $result = $this->getInputForm($printoutstring, wfArrayToCGI($urlArgs)) . $result;
         $wgOut->addHTML($result);
     }
 }