Ejemplo n.º 1
0
 /**
  * Main entry point for Special Pages
  *
  * @param[in] $query string  Given by MediaWiki
  */
 public function execute($query)
 {
     global $wgRequest, $wgOut, $smwgBrowseShowAll;
     $this->setHeaders();
     // get the GET parameters
     $this->articletext = $wgRequest->getVal('article');
     // no GET parameters? Then try the URL
     if (is_null($this->articletext)) {
         $params = SMWInfolink::decodeParameters($query, false);
         reset($params);
         $this->articletext = current($params);
     }
     $this->subject = SMWDataValueFactory::newTypeIDValue('_wpg', $this->articletext);
     $offsettext = $wgRequest->getVal('offset');
     $this->offset = is_null($offsettext) ? 0 : intval($offsettext);
     $dir = $wgRequest->getVal('dir');
     if ($smwgBrowseShowAll) {
         $this->showoutgoing = true;
         $this->showincoming = true;
     }
     if ($dir === 'both' || $dir === 'in') {
         $this->showincoming = true;
     }
     if ($dir === 'in') {
         $this->showoutgoing = false;
     }
     if ($dir === 'out') {
         $this->showincoming = false;
     }
     $wgOut->addHTML($this->displayBrowse());
     SMWOutputs::commitToOutputPage($wgOut);
     // make sure locally collected output data is pushed to the output!
 }
Ejemplo n.º 2
0
 /**
  * Main entrypoint for the special page.
  *
  * @param string $p
  */
 public function execute($p)
 {
     global $wgOut, $wgRequest, $smwgQEnabled;
     $wgOut->addModules('ext.smw.style');
     $wgOut->addModules('ext.smw.ask');
     $wgOut->addModules('ext.smw.property');
     $this->setHeaders();
     if (!$smwgQEnabled) {
         $wgOut->addHTML('<br />' . wfMessage('smw_iq_disabled')->escaped());
     } else {
         if ($wgRequest->getCheck('showformatoptions')) {
             // handle Ajax action
             $format = $wgRequest->getVal('showformatoptions');
             $params = $wgRequest->getArray('params');
             $wgOut->disable();
             echo $this->showFormatOptions($format, $params);
         } else {
             $this->extractQueryParameters($p);
             $this->makeHTMLResult();
         }
     }
     $this->addExternalHelpLinkFor('smw_ask_doculink');
     SMWOutputs::commitToOutputPage($wgOut);
     // make sure locally collected output data is pushed to the output!
 }
	/**
	 * Method for handling the set_recurring_event parser function.
	 * 
	 * @since 1.5.3
	 * 
	 * @param Parser $parser
	 */
	public static function render( Parser &$parser ) {
		$params = func_get_args();
		array_shift( $params ); // We already know the $parser ...

		// Almost all of the work gets done by
		// getDatesForRecurringEvent().
		$results = self::getDatesForRecurringEvent( $params );
		if ( $results == null ) {
			return null;
		}

		list( $property_name, $all_date_strings, $unused_params ) = $results;

		// Do the actual saving of the data.
		foreach ( $all_date_strings as $date_str ) {
			SMWParseData::addProperty( $property_name, $date_str, false, $parser, true );
		}

		global $wgTitle;
		if ( !is_null( $wgTitle ) && $wgTitle->isSpecialPage() ) {
			global $wgOut;
			SMWOutputs::commitToOutputPage( $wgOut );
		}
		else {
			SMWOutputs::commitToParser( $parser );
		}	
	}
Ejemplo n.º 4
0
 /**
  * Main method for adding all additional HTML to the output stream.
  */
 protected function showList()
 {
     global $wgOut, $wgRequest;
     $this->from = $wgRequest->getVal('from', '');
     $this->until = $wgRequest->getVal('until', '');
     if ($this->initParameters()) {
         $wgOut->addHTML($this->getHtml());
         SMWOutputs::commitToOutputPage($wgOut);
     }
 }
 /**
  * Main entry point for the special page.
  *
  * @param string $query Given by MediaWiki
  */
 public function execute($query)
 {
     global $wgOut;
     $this->setHeaders();
     $this->processParameters($query);
     $wgOut->addHTML($this->displaySearchByProperty());
     $wgOut->addHTML($this->queryForm());
     // push locally collected output data to the output
     SMWOutputs::commitToOutputPage($wgOut);
 }
 public function execute($param)
 {
     wfProfileIn('smwfDoSpecialUnusedProperties (SMW)');
     global $wgOut;
     $wgOut->setPageTitle(wfMsg('unusedproperties'));
     $rep = new SMWUnusedPropertiesPage();
     list($limit, $offset) = wfCheckLimits();
     $rep->doQuery($offset, $limit);
     // Ensure locally collected output data is pushed to the output!
     SMWOutputs::commitToOutputPage($wgOut);
     wfProfileOut('smwfDoSpecialUnusedProperties (SMW)');
 }
Ejemplo n.º 7
0
 /**
  * Main method for adding all additional HTML to the output stream.
  */
 protected function showList()
 {
     global $wgOut, $wgRequest;
     wfProfileIn(__METHOD__ . ' (SMW)');
     $this->from = $wgRequest->getVal('from', '');
     $this->until = $wgRequest->getVal('until', '');
     if ($this->initParameters()) {
         $wgOut->addHTML("<br id=\"smwfootbr\"/>\n" . $this->getHtml());
         SMWOutputs::commitToOutputPage($wgOut);
     }
     wfProfileOut(__METHOD__ . ' (SMW)');
 }
Ejemplo n.º 8
0
 /**
  * Method for handling the declare parser function.
  * 
  * @since 1.5.3
  * 
  * @param Parser $parser
  * @param PPFrame $frame
  * @param array $args
  */
 public static function render(Parser &$parser, PPFrame $frame, array $args)
 {
     if ($frame->isTemplate()) {
         foreach ($args as $arg) {
             if (trim($arg) !== '') {
                 $expanded = trim($frame->expand($arg));
                 $parts = explode('=', $expanded, 2);
                 if (count($parts) == 1) {
                     $propertystring = $expanded;
                     $argumentname = $expanded;
                 } else {
                     $propertystring = $parts[0];
                     $argumentname = $parts[1];
                 }
                 $property = SMWPropertyValue::makeUserProperty($propertystring);
                 $argument = $frame->getArgument($argumentname);
                 $valuestring = $frame->expand($argument);
                 if ($property->isValid()) {
                     $type = $property->getPropertyTypeID();
                     if ($type == '_wpg') {
                         $matches = array();
                         preg_match_all('/\\[\\[([^\\[\\]]*)\\]\\]/u', $valuestring, $matches);
                         $objects = $matches[1];
                         if (count($objects) == 0) {
                             if (trim($valuestring) !== '') {
                                 SMWParseData::addProperty($propertystring, $valuestring, false, $parser, true);
                             }
                         } else {
                             foreach ($objects as $object) {
                                 SMWParseData::addProperty($propertystring, $object, false, $parser, true);
                             }
                         }
                     } elseif (trim($valuestring) !== '') {
                         SMWParseData::addProperty($propertystring, $valuestring, false, $parser, true);
                     }
                     // $value = SMWDataValueFactory::newPropertyObjectValue( $property->getDataItem(), $valuestring );
                     // if (!$value->isValid()) continue;
                 }
             }
         }
     } else {
         // @todo Save as metadata
     }
     global $wgTitle;
     if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($parser);
     }
     return '';
 }
Ejemplo n.º 9
0
 /**
  * Renders and returns the output.
  * @see ParserHook::render
  * 
  * @since 1.7
  * 
  * @param array $parameters
  * 
  * @return string
  */
 public function render(array $parameters)
 {
     /**
      * Non-escaping is safe bacause a user's message is passed through parser, which will
      * handle unsafe HTM elements.
      */
     $result = smwfEncodeMessages(array($parameters['message']), $parameters['icon'], ' <!--br-->', false);
     if (!is_null($this->parser->getTitle()) && $this->parser->getTitle()->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($this->parser);
     }
     return $result;
 }
Ejemplo n.º 10
0
 public function execute($param)
 {
     global $wgOut;
     $params = SMWInfolink::decodeParameters($param, false);
     $typeLabel = reset($params);
     if ($typeLabel == false) {
         $wgOut->setPageTitle(wfMessage('types')->text());
         $html = $this->getTypesList();
     } else {
         $typeName = str_replace('_', ' ', $typeLabel);
         $wgOut->setPageTitle($typeName);
         // Maybe add a better message for this
         $html = $this->getTypeProperties($typeLabel);
     }
     $wgOut->addHTML($html);
     SMWOutputs::commitToOutputPage($wgOut);
 }
Ejemplo n.º 11
0
 /**
  * Method for handling the ask concept function.
  * 
  * @todo The possible use of this in an HTML or Specal page context needs to be revisited. The code mentions it, but can this actually happen?
  * @todo The escaping of symbols in concept queries needs to be revisited.
  * 
  * @since 1.5.3
  * 
  * @param Parser $parser
  */
 public static function render(Parser &$parser)
 {
     global $wgContLang, $wgTitle;
     $title = $parser->getTitle();
     $pconc = new SMWDIProperty('_CONC');
     if ($title->getNamespace() != SMW_NS_CONCEPT) {
         $result = smwfEncodeMessages(array(wfMsgForContent('smw_no_concept_namespace')));
         SMWOutputs::commitToParser($parser);
         return $result;
     } elseif (count(SMWParseData::getSMWdata($parser)->getPropertyValues($pconc)) > 0) {
         $result = smwfEncodeMessages(array(wfMsgForContent('smw_multiple_concepts')));
         SMWOutputs::commitToParser($parser);
         return $result;
     }
     // process input:
     $params = func_get_args();
     array_shift($params);
     // We already know the $parser ...
     // Use first parameter as concept (query) string.
     $concept_input = str_replace(array('&gt;', '&lt;'), array('>', '<'), array_shift($params));
     // second parameter, if any, might be a description
     $concept_docu = array_shift($params);
     // NOTE: the str_replace above is required in MediaWiki 1.11, but not in MediaWiki 1.14
     $query = SMWQueryProcessor::createQuery($concept_input, SMWQueryProcessor::getProcessedParams(array('limit' => 20, 'format' => 'list')), SMWQueryProcessor::CONCEPT_DESC);
     $concept_text = $query->getDescription()->getQueryString();
     if (!is_null(SMWParseData::getSMWData($parser))) {
         $diConcept = new SMWDIConcept($concept_text, $concept_docu, $query->getDescription()->getQueryFeatures(), $query->getDescription()->getSize(), $query->getDescription()->getDepth());
         SMWParseData::getSMWData($parser)->addPropertyObjectValue($pconc, $diConcept);
     }
     // display concept box:
     $rdflink = SMWInfolink::newInternalLink(wfMsgForContent('smw_viewasrdf'), $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' . $title->getPrefixedText(), 'rdflink');
     SMWOutputs::requireResource('ext.smw.style');
     // TODO: escape output, preferably via Html or Xml class.
     $result = '<div class="smwfact"><span class="smwfactboxhead">' . wfMsgForContent('smw_concept_description', $title->getText()) . (count($query->getErrors()) > 0 ? ' ' . smwfEncodeMessages($query->getErrors()) : '') . '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<br />' . ($concept_docu ? "<p>{$concept_docu}</p>" : '') . '<pre>' . str_replace('[', '&#x005B;', $concept_text) . "</pre>\n</div>";
     if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($parser);
     }
     return $result;
 }
Ejemplo n.º 12
0
 /**
  * Method for handling the ask parser function.
  * 
  * @since 1.5.3
  * 
  * @param Parser $parser
  */
 public static function render(Parser &$parser)
 {
     global $smwgQEnabled, $smwgIQRunningNumber, $wgTitle;
     if ($smwgQEnabled) {
         $smwgIQRunningNumber++;
         $params = func_get_args();
         array_shift($params);
         // We already know the $parser ...
         $result = SMWQueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI);
     } else {
         $result = smwfEncodeMessages(array(wfMessage('smw_iq_disabled')->inContentLanguage()->text()));
     }
     if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($parser);
     }
     return $result;
 }
Ejemplo n.º 13
0
 /**
  * Method for handling the show parser function.
  *
  * @since 1.5.3
  *
  * @param Parser $parser
  */
 public static function render(Parser &$parser)
 {
     global $smwgQEnabled, $smwgIQRunningNumber, $wgTitle;
     if ($smwgQEnabled) {
         $smwgIQRunningNumber++;
         $rawParams = func_get_args();
         array_shift($rawParams);
         // We already know the $parser ...
         list($query, $params) = SMWQueryProcessor::getQueryAndParamsFromFunctionParams($rawParams, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY, true);
         $result = SMWQueryProcessor::getResultFromQuery($query, $params, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY);
         $queryKey = hash('md4', implode('|', $rawParams), false);
         SMWAsk::addQueryData($queryKey, $query, $params, $parser);
     } else {
         $result = smwfEncodeMessages(array(wfMessage('smw_iq_disabled')->inContentLanguage()->text()));
     }
     if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($parser);
     }
     return $result;
 }
Ejemplo n.º 14
0
 /**
  * Main entrypoint for the special page.
  *
  * @param string $p
  */
 public function execute($p)
 {
     global $wgOut, $wgRequest, $smwgQEnabled;
     $this->setHeaders();
     wfProfileIn('doSpecialAsk (SMW)');
     if (!$smwgQEnabled) {
         $wgOut->addHTML('<br />' . wfMessage('smw_iq_disabled')->text());
     } else {
         if ($wgRequest->getCheck('showformatoptions')) {
             // handle Ajax action
             $format = $wgRequest->getVal('showformatoptions');
             $params = $wgRequest->getArray('params');
             $wgOut->disable();
             echo $this->showFormatOptions($format, $params);
         } else {
             $this->extractQueryParameters($p);
             $this->makeHTMLResult();
         }
     }
     SMWOutputs::commitToOutputPage($wgOut);
     // make sure locally collected output data is pushed to the output!
     wfProfileOut('doSpecialAsk (SMW)');
 }
Ejemplo n.º 15
0
 /**
  * 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);
 }
 /**
  * Main entry point for Special Pages
  *
  * @param[in] $query string  Given by MediaWiki
  */
 public function execute($query)
 {
     global $wgRequest, $wgOut, $smwgBrowseShowAll;
     $this->setHeaders();
     // get the GET parameters
     $this->articletext = $wgRequest->getVal('article');
     // @see SMWInfolink::encodeParameters
     if ($query === null && $this->getRequest()->getCheck('x')) {
         $query = $this->getRequest()->getVal('x');
     }
     // no GET parameters? Then try the URL
     if (is_null($this->articletext)) {
         $this->articletext = UrlEncoder::decode($query);
     }
     $this->subject = \SMW\DataValueFactory::getInstance()->newTypeIDValue('_wpg', $this->articletext);
     $offsettext = $wgRequest->getVal('offset');
     $this->offset = is_null($offsettext) ? 0 : intval($offsettext);
     $dir = $wgRequest->getVal('dir');
     if ($smwgBrowseShowAll) {
         $this->showoutgoing = true;
         $this->showincoming = true;
     }
     if ($dir === 'both' || $dir === 'in') {
         $this->showincoming = true;
     }
     if ($dir === 'in') {
         $this->showoutgoing = false;
     }
     if ($dir === 'out') {
         $this->showincoming = false;
     }
     $wgOut->addHTML($this->displayBrowse());
     $this->addExternalHelpLinkFor('smw-specials-browse-helplink');
     SMWOutputs::commitToOutputPage($wgOut);
     // make sure locally collected output data is pushed to the output!
 }
 /**
  * Main entry point for Special Pages. Gets all required parameters.
  *
  * @param[in] $query string  Given by MediaWiki
  */
 public function execute($query)
 {
     global $wgRequest, $wgOut;
     $this->setHeaders();
     // get the GET parameters
     $this->propertystring = $wgRequest->getText('property');
     $this->valuestring = $wgRequest->getText('value');
     $params = SMWInfolink::decodeParameters($query, false);
     reset($params);
     // no GET parameters? Then try the URL
     if ($this->propertystring === '') {
         $this->propertystring = current($params);
     }
     if ($this->valuestring === '') {
         $this->valuestring = next($params);
     }
     $this->valuestring = str_replace('&nbsp;', ' ', $this->valuestring);
     $this->valuestring = str_replace('&#160;', ' ', $this->valuestring);
     $this->property = SMWPropertyValue::makeUserProperty($this->propertystring);
     if (!$this->property->isValid()) {
         $this->propertystring = '';
     } else {
         $this->propertystring = $this->property->getWikiValue();
         $this->value = SMWDataValueFactory::newPropertyObjectValue($this->property->getDataItem(), $this->valuestring);
         if ($this->value->isValid()) {
             $this->valuestring = $this->value->getWikiValue();
         } else {
             $this->value = null;
         }
     }
     $limitstring = $wgRequest->getVal('limit');
     if (is_numeric($limitstring)) {
         $this->limit = intval($limitstring);
     }
     $offsetstring = $wgRequest->getVal('offset');
     if (is_numeric($offsetstring)) {
         $this->offset = intval($offsetstring);
     }
     $wgOut->addHTML($this->displaySearchByProperty());
     $wgOut->addHTML($this->queryForm());
     SMWOutputs::commitToOutputPage($wgOut);
     // make sure locally collected output data is pushed to the output!
 }
	/**
	 * Main entry point for Special Pages
	 *
	 * @param[in] $query string  Given by MediaWiki
	 */
	public function execute( $query ) {
		global $wgRequest, $wgOut, $smwgBrowseShowAll, $wgContLang;
		$this->setHeaders();

		// get the GET parameters
		$this->articletext = $wgRequest->getVal( 'article' );
        $this->title = $wgOut->getTitle();          
		// no GET parameters? Then try the URL
		if ( $this->articletext == '' ) {
			$params = SMWInfolink::decodeParameters( $query, false );
			reset( $params );
			$this->articletext = current( $params );
		}
		$offsettext = $wgRequest->getVal( 'offset' );
		$this->offset = ( $offsettext == '' ) ? 0:intval( $offsettext );
		$dir = $wgRequest->getVal( 'dir' );

		if ( $smwgBrowseShowAll ) {
			$this->showoutgoing = true;
			$this->showincoming = true;
		}
		if ( ( $dir == 'both' ) || ( $dir == 'in' ) ) $this->showincoming = true;
		if ( $dir == 'in' ) $this->showoutgoing = false;
		if ( $dir == 'out' ) $this->showincoming = false;

	   // print OutputPage
	   
		$wgOut->addHTML( $this->displayBrowse() );
		SMWOutputs::commitToOutputPage( $wgOut ); // make sure locally collected output data is pushed to the output!

	}
Ejemplo n.º 19
0
 /**
  * This hook copies SMW's custom data from the given ParserOutput object to
  * the given OutputPage object, since otherwise it is not possible to access
  * it later on to build a Factbox.
  * 
  * @param OutputPage $outputpage
  * @param ParserOutput $parseroutput
  * 
  * @return true
  */
 public static function onOutputPageParserOutput(OutputPage $outputpage, ParserOutput $parseroutput)
 {
     global $wgParser;
     $factbox = SMWFactbox::getFactboxTextFromOutput($parseroutput, $outputpage->getTitle());
     if ($factbox !== '') {
         $popts = new ParserOptions();
         $po = $wgParser->parse($factbox, $outputpage->getTitle(), $popts);
         $outputpage->mSMWFactboxText = $po->getText();
         // do not forget to grab the outputs header items
         SMWOutputs::requireFromParserOutput($po);
         SMWOutputs::commitToOutputPage($outputpage);
     }
     // else: nothing shown, don't even set any text
     return true;
 }
	/**
	 * Displays the watchlist.
	 * 
	 * @since 0.1
	 * 
	 * @param array of SWLChangeSet $sets
	 */
	protected function displayWatchlist( array $sets ) {
		global $wgOut, $wgLang;
		
		$changeSetsHTML = array();
		
		foreach ( $sets as /* SWLChangeSet */ $set ) {
			$dayKey = substr( $set->getEdit()->getTime(), 0, 8 ); // Get the YYYYMMDD part.
			
			if ( !array_key_exists( $dayKey, $changeSetsHTML ) ) {
				$changeSetsHTML[$dayKey] = array();
			}
			
			$changeSetsHTML[$dayKey][] = $this->getChangeSetHTML( $set );
		}
		
		krsort( $changeSetsHTML );
		
		foreach ( $changeSetsHTML as $dayKey => $daySets ) {
			$wgOut->addHTML( Html::element(
				'h4',
				array(),
				$wgLang->date( str_pad( $dayKey, 14, '0' ) )
			) );
			
			$wgOut->addHTML( '<ul>' );
			
			foreach ( $daySets as $setHTML ) {
				$wgOut->addHTML( $setHTML );
			}
			
			$wgOut->addHTML( '</ul>' );
		}
		
		SMWOutputs::commitToOutputPage( $wgOut );
		
		$wgOut->addModules( 'ext.swl.watchlist' );
	}
Ejemplo n.º 21
0
 /**
  * Format and output report results using the given information plus
  * OutputPage
  *
  * @param OutputPage $out OutputPage to print to
  * @param Skin $skin User skin to use
  * @param Database $dbr Database (read) connection to use
  * @param int $res Result pointer
  * @param int $num Number of available result rows
  * @param int $offset Paging offset
  */
 protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
 {
     global $wgContLang;
     $all_display_params = SDUtils::getDisplayParamsForCategory($this->category);
     $querystring = null;
     $printouts = $params = array();
     // only one set of params is handled for now
     if (count($all_display_params) > 0) {
         $display_params = array_map('trim', $all_display_params[0]);
         SMWQueryProcessor::processFunctionParams($display_params, $querystring, $params, $printouts);
     }
     if (!empty($querystring)) {
         $query = SMWQueryProcessor::createQuery($querystring, $params);
     } else {
         $query = new SMWQuery();
     }
     if (!array_key_exists('format', $params)) {
         $params['format'] = 'category';
     }
     if (array_key_exists('mainlabel', $params)) {
         $mainlabel = $params['mainlabel'];
     } else {
         $mainlabel = '';
     }
     $r = $this->addSemanticResultWrapper($dbr, $res, $num, $query, $mainlabel, $printouts);
     $printer = SMWQueryProcessor::getResultPrinter($params['format'], SMWQueryProcessor::SPECIAL_PAGE, $r);
     if (version_compare(SMW_VERSION, '1.6.1', '>')) {
         SMWQueryProcessor::addThisPrintout($printouts, $params);
         $params = SMWQueryProcessor::getProcessedParams($params, $printouts);
     }
     $prresult = $printer->getResult($r, $params, SMW_OUTPUT_HTML);
     $prtext = is_array($prresult) ? $prresult[0] : $prresult;
     SMWOutputs::commitToOutputPage($out);
     // Crappy hack to get the contents of SMWOutputs::$mHeadItems,
     // which may have been set in the result printer, and dump into
     // headItems of $out.
     // How else can we do this?
     global $wgParser;
     SMWOutputs::commitToParser($wgParser);
     if (!is_null($wgParser->mOutput)) {
         // getHeadItems() was added in MW 1.16
         if (method_exists($wgParser->getOutput(), 'getHeadItems')) {
             $headItems = $wgParser->getOutput()->getHeadItems();
         } else {
             $headItems = $wgParser->getOutput()->mHeadItems;
         }
         foreach ($headItems as $key => $item) {
             $out->addHeadItem($key, $item);
         }
         // Force one more parser function, so links appear.
         $wgParser->replaceLinkHolders($prtext);
     }
     $html = array();
     $html[] = $prtext;
     if (!$this->listoutput) {
         $html[] = $this->closeList();
     }
     $html = $this->listoutput ? $wgContLang->listToText($html) : implode('', $html);
     $out->addHTML($html);
 }
Ejemplo n.º 22
0
 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!
 }
Ejemplo n.º 23
0
	/**
	 * Includes the necessary Javascript and CSS files for the form
	 * to display and work correctly.
	 *
	 * Accepts an optional Parser instance, or uses $wgOut if omitted.
	 */
	public static function addJavascriptAndCSS( $parser = null ) {
		global $wgOut;

		if ( !$parser ) {
			$wgOut->addMeta( 'robots', 'noindex,nofollow' );
		}

		self::addJavascriptFiles( $parser );

		// MW 1.17 +
		if ( class_exists( 'ResourceLoader' ) ) {
			self::loadJavascriptAndCSS( $parser );
			return;
		}
		global $sfgScriptPath, $smwgScriptPath, $wgJsMimeType, $sfgUseFormEditPage;
		global $smwgJQueryIncluded, $smwgJQUIAutoIncluded;
		// jQuery and jQuery UI are used so often in forms, we might as
		// well assume they'll always be used, and include them in
		// every form
		$smwgJQueryIncluded = true;
		$smwgJQUIAutoIncluded = true;

		$css_files = array(
			"$smwgScriptPath/skins/SMW_custom.css",
			"$sfgScriptPath/skins/jquery-ui/base/jquery.ui.all.css",
			"$sfgScriptPath/skins/SemanticForms.css",
			"$sfgScriptPath/skins/SF_submit.css",
			"$sfgScriptPath/skins/jquery.fancybox.css"
		);
		foreach ( $css_files as $css_file ) {
			$link = array(
				'rel' => 'stylesheet',
				'type' => 'text/css',
				'media' => "screen",
				'href' => $css_file
			);
			if ( !is_null( $parser ) ) {
				$parser->getOutput()->addHeadItem( Html::element( 'link', $link ) );
			} else {
				$wgOut->addLink( $link );
			}
		}

		$scripts = array();
		if ( !$sfgUseFormEditPage )
			$scripts[] = "$sfgScriptPath/libs/SF_ajax_form_preview.js";
		$realFunction = array( 'SMWOutputs', 'requireHeadItem' );
		if ( is_callable( $realFunction ) ) {
			SMWOutputs::requireHeadItem( SMW_HEADER_TOOLTIP );
			SMWOutputs::requireHeadItem( SMW_HEADER_SORTTABLE );
			// TODO - should this be called directly here, or is
			// there a "smarter" (in some way) place to put it?
			SMWOutputs::commitToOutputPage( $wgOut );
		} else {
			$scripts[] = "$smwgScriptPath/skins/SMW_tooltip.js";
			$scripts[] = "$smwgScriptPath/skins/SMW_sorttable.js";
		}
		$realFunction = array( 'OutputPage', 'includeJQuery' );
		if ( is_callable( $realFunction ) ) {
			$wgOut->includeJQuery();
		} else {
			$scripts[] = "$sfgScriptPath/libs/jquery-1.4.2.min.js";
		}
		$scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.core.min.js";
		$scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.widget.min.js";
		$scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.button.min.js";
		$scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.position.min.js";
		$scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.autocomplete.min.js";
		$scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.mouse.min.js";
		$scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.sortable.min.js";
		$scripts[] = "$sfgScriptPath/libs/jquery.fancybox.js";
		$scripts[] = "$sfgScriptPath/libs/SF_imagePreview.js";
		$scripts[] = "$sfgScriptPath/libs/SF_autogrow.js";
		$scripts[] = "$sfgScriptPath/libs/SF_submit.js";
		$scripts[] = "$sfgScriptPath/libs/SemanticForms.js";

		global $wgOut;
		foreach ( $scripts as $js ) {
			if ( $parser ) {
				$script = "<script type=\"$wgJsMimeType\" src=\"$js\"></script>\n";
				$parser->getOutput()->addHeadItem( $script );
			} else {
				$wgOut->addScriptFile( $js );
			}
		}
	}