Esempio n. 1
0
 /**
  * This function creates wiki text suitable for rendering a Factbox based on the
  * information found in a given ParserOutput object. If the required custom data
  * is not found in the given ParserOutput, then semantic data for the provided Title
  * object is retreived from the store.
  * 
  * @param ParserOutput $parseroutput
  * @param Title $title
  * 
  * @return string
  */
 public static function getFactboxTextFromOutput(ParserOutput $parseroutput, Title $title)
 {
     global $wgRequest, $smwgShowFactboxEdit, $smwgShowFactbox;
     $mws = isset($parseroutput->mSMWMagicWords) ? $parseroutput->mSMWMagicWords : array();
     if (in_array('SMW_SHOWFACTBOX', $mws)) {
         $showfactbox = SMW_FACTBOX_NONEMPTY;
     } elseif (in_array('SMW_NOFACTBOX', $mws)) {
         $showfactbox = SMW_FACTBOX_HIDDEN;
     } elseif ($wgRequest->getCheck('wpPreview')) {
         $showfactbox = $smwgShowFactboxEdit;
     } else {
         $showfactbox = $smwgShowFactbox;
     }
     if ($showfactbox == SMW_FACTBOX_HIDDEN) {
         // use shortcut
         return '';
     }
     // Deal with complete dataset only if needed:
     $smwData = SMWParseData::getSMWDataFromParserOutput($parseroutput);
     if ($smwData === null || $smwData->stubObject) {
         $smwData = smwfGetStore()->getSemanticData(SMWDIWikiPage::newFromTitle($title));
     }
     return SMWFactbox::getFactboxText($smwData, $showfactbox);
 }