当前位置: 首页>>代码示例>>PHP>>正文


PHP SMWQueryProcessor::getResultPrinter方法代码示例

本文整理汇总了PHP中SMWQueryProcessor::getResultPrinter方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryProcessor::getResultPrinter方法的具体用法?PHP SMWQueryProcessor::getResultPrinter怎么用?PHP SMWQueryProcessor::getResultPrinter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMWQueryProcessor的用法示例。


在下文中一共展示了SMWQueryProcessor::getResultPrinter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doManipulation

 /**
  * @see ItemParameterManipulation::doManipulation
  * 
  * @since 1.6.2
  */
 public function doManipulation(&$value, Parameter $parameter, array &$parameters)
 {
     // Make sure the format value is valid.
     $value = self::getValidFormatName($value);
     // Add the formats parameters to the parameter list.
     $queryPrinter = SMWQueryProcessor::getResultPrinter($value);
     $parameters = array_merge($parameters, $queryPrinter->getValidatorParameters());
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:SMW_ParamFormat.php

示例2: execute

 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)');
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:41,代码来源:SMW_AskTSC.php

示例3: getFormatParameters

 /**
  * Returns the definitions of all parameters supported by the specified format.
  *
  * @since 1.8
  *
  * @param string $format
  *
  * @return array of IParamDefinition
  */
 public static function getFormatParameters($format)
 {
     SMWParamFormat::resolveFormatAliases($format);
     if (array_key_exists($format, $GLOBALS['smwgResultFormats'])) {
         return ParamDefinition::getCleanDefinitions(SMWQueryProcessor::getResultPrinter($format)->getParamDefinitions(SMWQueryProcessor::getParameters()));
     } else {
         return array();
     }
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:18,代码来源:SMW_QueryProcessor.php

示例4: getHTMLResult

 /**
  * Returns the results in HTML, or in case of exports, a link to the
  * result.
  *
  * This method can only be called after execute() has been called.
  *
  * @return string of all the HTML generated
  */
 public function getHTMLResult()
 {
     $result = '';
     $res = $this->queryResult;
     $printer = SMWQueryProcessor::getResultPrinter($this->parameters['format'], SMWQueryProcessor::SPECIAL_PAGE);
     if ($res->getCount() > 0) {
         $queryResult = $printer->getResult($res, $this->params, SMW_OUTPUT_HTML);
         if (is_array($queryResult)) {
             $result .= $queryResult[0];
         } else {
             $result .= $queryResult;
         }
     } else {
         $result = wfMsg('smw_result_noresults');
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:SMW_QueryUIHelper.php

示例5: getFormatParameters

 /**
  * @param string $format
  *
  * @return array of IParamDefinition
  */
 protected function getFormatParameters($format)
 {
     if (array_key_exists($format, $GLOBALS['smwgResultFormats'])) {
         return ParamDefinition::getCleanDefinitions(SMWQueryProcessor::getResultPrinter($format)->getParamDefinitions(SMWQueryProcessor::getParameters()));
     } else {
         return array();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:SMW_SMWDoc.php

示例6: getFormatSelection

 /**
  * Build the format drop down
  *
  * @param array
  *
  * @return string
  */
 protected static function getFormatSelection($params)
 {
     $result = '';
     $printer = SMWQueryProcessor::getResultPrinter('broadtable', SMWQueryProcessor::SPECIAL_PAGE);
     $url = SpecialPage::getSafeTitleFor('Ask')->getLocalURL('showformatoptions=this.value');
     foreach ($params as $param => $value) {
         if ($param !== 'format') {
             $url .= '&params[' . rawurlencode($param) . ']=' . rawurlencode($value);
         }
     }
     $result .= '<br /><span style=vertical-align:middle;">' . wfMessage('smw_ask_format_as')->text() . ' <input type="hidden" name="eq" value="yes"/>' . "\n" . Html::openElement('select', array('id' => 'formatSelector', 'name' => 'p[format]', 'data-url' => $url)) . "\n" . '	<option value="broadtable"' . ($params['format'] == 'broadtable' ? ' selected' : '') . '>' . $printer->getName() . ' (' . wfMessage('smw_ask_defaultformat')->text() . ')</option>' . "\n";
     $formats = array();
     foreach (array_keys($GLOBALS['smwgResultFormats']) as $format) {
         // Special formats "count" and "debug" currently not supported.
         if ($format != 'broadtable' && $format != 'count' && $format != 'debug') {
             $printer = SMWQueryProcessor::getResultPrinter($format, SMWQueryProcessor::SPECIAL_PAGE);
             $formats[$format] = $printer->getName();
         }
     }
     natcasesort($formats);
     foreach ($formats as $format => $name) {
         $result .= '	<option value="' . $format . '"' . ($params['format'] == $format ? ' selected' : '') . '>' . $name . "</option>\n";
     }
     $result .= "</select></span>\n";
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:33,代码来源:SMW_SpecialAsk.php

示例7: notifyUsers

	public function notifyUsers() {
		global $wgSitename, $wgSMTP, $wgEmergencyContact, $wgEnotifyMeJob;
		$sStore = NMStorage::getDatabase();

		$nm_send_jobs = array();
		$id = 0;

		if ( count( $this->m_notifyHtmlMsgs ) > 0 ) {
			$notifications = $sStore->getNotifyMe( array_keys( $this->m_notifyHtmlMsgs ) );
		}
		$html_style = '';
		// <style>
		// table.smwtable{background-color: #EEEEFF;}
		// table.smwtable th{background-color: #EEEEFF;text-align: left;}
		// table.smwtable td{background-color: #FFFFFF;padding: 1px;padding-left: 5px;padding-right: 5px;text-align: left;vertical-align: top;}
		// table.smwtable tr.smwfooter td{font-size: 90%;line-height: 1;background-color: #EEEEFF;padding: 0px;padding-left: 5px;padding-right: 5px;text-align: right;vertical-align: top;}
		// </style>';
		$html_showall = array();
		foreach ( $this->m_notifyHtmlMsgs as $notify_id => $msg ) {
			$html_msg = $html_style;
			$showing_all = false;
			if ( isset( $notifications[$notify_id] ) && $notifications[$notify_id]['show_all'] ) {
				SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $notifications[$notify_id]['query'] ), $querystring, $params, $printouts );

				$format = 'auto';
				if ( array_key_exists( 'format', $params ) ) {
					$format = strtolower( trim( $params['format'] ) );
					global $smwgResultFormats;
					if ( !array_key_exists( $format, $smwgResultFormats ) ) {
						$format = 'auto';
					}
				}
				$query  = SMWQueryProcessor::createQuery( $querystring, $params, SMWQueryProcessor::INLINE_QUERY, $format, $printouts );
				$res = smwfGetStore()->getQueryResult( $query );
				$printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::INLINE_QUERY, $res );
				$result = $printer->getResult( $res, $params, SMW_OUTPUT_HTML );
				// FIXME: hardcode switch to full url
				global $wgScriptPath, $wgServer;
				$result = str_replace ( $wgScriptPath, $wgServer . $wgScriptPath, $result );
				$html_msg .= $result . '<br/>';
				$html_showall[$notify_id] = array ( 'name' => $notifications[$notify_id]['name'], 'html' => $result );

				$showing_all = true;
				$link = $res->getQueryLink()->getURL();
			}
			global $smwgNMHideDiffWhenShowAll;
			if ( !( $smwgNMHideDiffWhenShowAll && $showing_all ) ) {
				$html_msg .= wfMsg( 'smw_nm_hint_notification_html', $this->m_notifyHtmlMsgs[$notify_id] );
				if ( isset( $this->m_notifyHtmlPropMsgs[$notify_id] ) ) {
					$html_msg .= wfMsg( 'smw_nm_hint_nmtable_html', $this->m_notifyHtmlPropMsgs[$notify_id] );
				}
			}
			if ( $showing_all ) {
				$id = $sStore->addNotifyRSS( 'nid', $notify_id, "All current items, " . date( 'Y-m-d H:i:s', time() ), $this->applyStyle( $html_msg ), $link );
			} else {
				$id = $sStore->addNotifyRSS( 'nid', $notify_id, $this->m_title->getText(), $this->applyStyle( $html_msg ) );
			}
		}
		foreach ( $this->m_userMsgs as $user_id => $msg ) {
			// generate RSS items
			$html_msg = $html_style;
			foreach ( array_unique( $this->m_userNMs[$user_id] ) as $showall_nid ) {
				if ( isset( $html_showall[$showall_nid] ) ) {
					$html_msg .= wfMsg( 'smw_nm_hint_item_html', $html_showall[$showall_nid]['name'], $html_showall[$showall_nid]['html'] );
				}
			}

			$html_msg .= wfMsg( 'smw_nm_hint_notification_html', $this->m_userHtmlNMMsgs[$user_id] );
			if ( isset( $this->m_userHtmlPropMsgs[$user_id] ) ) {
				$html_msg .= wfMsg( 'smw_nm_hint_nmtable_html', $this->m_userHtmlPropMsgs[$user_id] );
			}

			global $wgNMReportModifier, $wgUser;
			if ( $wgNMReportModifier ) {
				$userText = $wgUser->getName();
				if ( $wgUser->getId() == 0 ) {
					$page = SpecialPage::getTitleFor( 'Contributions', $userText );
				} else {
					$page = Title::makeTitle( NS_USER, $userText );
				}
				$l = '<a href="' . $page->getFullUrl() . '">' . htmlspecialchars( $userText ) . '</a>';
				$html_msg .= wfMsg( 'smw_nm_hint_modifier_html', $l );
				$msg .= wfMsg( 'smw_nm_hint_modifier', $wgUser->getName() );
			}

			$id = $sStore->addNotifyRSS( 'uid', $user_id, $this->m_title->getText(), $this->applyStyle( $html_msg ) );

			if ( $wgEnotifyMeJob ) {
				// send notifications by mail
				$user_info = $sStore->getUserInfo( $user_id );
				$user = User::newFromRow( $user_info );
				if ( ( $user_info->user_email != '' ) && $user->getOption( 'enotifyme' ) ) {
					$name = ( ( $user_info->user_real_name == '' ) ? $user_info->user_name:$user_info->user_real_name );

					$params = array( 'to' => new MailAddress( $user_info->user_email, $name ),
						'from' => new MailAddress( $wgEmergencyContact, 'Admin' ),
						'subj' => wfMsg( 'smw_nm_hint_mail_title', $this->m_title->getText(), $wgSitename ),
						'body' => wfMsg( 'smw_nm_hint_mail_body', $name, $msg ),
						'replyto' => new MailAddress( $wgEmergencyContact, 'Admin' ) );

//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:SMW_NotifyProcessor.smw15.php

示例8: formatValue

 /**
  * Formats the parameter value to it's final result.
  *
  * @since 1.8
  *
  * @param mixed $value
  * @param IParam $param
  * @param IParamDefinition[] $definitions
  * @param IParam[] $params
  *
  * @return mixed
  */
 protected function formatValue($value, IParam $param, array &$definitions, array $params)
 {
     $value = parent::formatValue($value, $param, $definitions, $params);
     // Make sure the format value is valid.
     $value = self::getValidFormatName($value);
     // Add the formats parameters to the parameter list.
     $queryPrinter = SMWQueryProcessor::getResultPrinter($value);
     $definitions = $queryPrinter->getParamDefinitions($definitions);
     return $value;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:22,代码来源:SMW_ParamFormat.php

示例9: getFormatParameters

 protected function getFormatParameters($format)
 {
     if (array_key_exists($format, $GLOBALS['smwgResultFormats'])) {
         return SMWQueryProcessor::getResultPrinter($format)->getValidatorParameters();
     } else {
         return array();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:SMW_SMWDoc.php

示例10: makeHTMLResult

 protected function makeHTMLResult()
 {
     global $wgOut;
     $result = '';
     $result_mime = false;
     // output in MW Special page as usual
     // build parameter strings for URLs, based on current settings
     $urltail = '&q=' . urlencode($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;
         }
     }
     $urltail .= '&p=' . urlencode(SMWInfolink::encodeParameters($tmp_parray));
     $printoutstring = '';
     foreach ($this->m_printouts as $printout) {
         $printoutstring .= $printout->getSerialisation() . "\n";
     }
     if ('' != $printoutstring) {
         $urltail .= '&po=' . urlencode($printoutstring);
     }
     if ('' != $this->m_params['sort']) {
         $urltail .= '&sort=' . $this->m_params['sort'];
     }
     if ('' != $this->m_params['order']) {
         $urltail .= '&order=' . $this->m_params['order'];
     }
     if ($this->m_querystring != '') {
         $queryobj = SMWQueryProcessor::createQuery($this->m_querystring, $this->m_params, false, '', $this->m_printouts);
         $queryobj->querymode = SMWQuery::MODE_INSTANCES;
         ///TODO: Somewhat hacky (just as the query mode computation in SMWQueryProcessor::createQuery!)
         $res = smwfGetStore()->getQueryResult($queryobj);
         $printer = SMWQueryProcessor::getResultPrinter($this->m_params['format'], false, $res);
         $result_mime = $printer->getMimeType($res);
         if ($result_mime == false) {
             $navigation = $this->getNavigationBar($res, $urltail);
             $result = '<div style="text-align: center;">' . $navigation;
             $result .= '</div>' . $printer->getResult($res, $this->m_params, SMW_OUTPUT_HTML);
             $result .= '<div style="text-align: center;">' . $navigation . '</div>';
         } else {
             // make a stand-alone file
             $result = $printer->getResult($res, $this->m_params, SMW_OUTPUT_FILE);
         }
     }
     if ($result_mime == false) {
         if ($this->m_querystring) {
             $wgOut->setHTMLtitle($this->m_querystring);
         } else {
             $wgOut->setHTMLtitle(wfMsg('ask'));
         }
         $result = $this->getInputForm($printoutstring, 'offset=' . $this->m_params['offset'] . '&limit=' . $this->m_params['limit'] . $urltail) . $result;
         $wgOut->addHTML($result);
     } else {
         $wgOut->disable();
         header("Content-type: {$result_mime}; charset=UTF-8");
         print $result;
     }
 }
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:59,代码来源:MV_Status2.php

示例11: getFormatSelectBoxSep

    /**
     * Creates form elements for choosing the result-format and their
     * associated format.
     *
     * The drop-down list and the format options are returned seperately as
     * elements of an array.Use in conjunction with processFormatOptions() to
     * supply formats options using ajax. Also, use its complement
     * processFormatSelectBox() to decode form data sent by these elements.
     * UI's may overload these methods to change behaviour or form
     * parameters.
     *
     * @param string $defaultFormat The default format which remains selected in the form
     * @return array The first element contains the format selector, while the second contains the Format options
     */
    protected function getFormatSelectBoxSep($defaultFormat = 'broadtable')
    {
        global $smwgResultFormats;
        SMWOutputs::requireResource('jquery');
        // checking argument
        $defFormat = 'broadtable';
        if (array_key_exists($defaultFormat, $smwgResultFormats)) {
            $defFormat = $defaultFormat;
        }
        $printer = SMWQueryProcessor::getResultPrinter($defFormat, SMWQueryProcessor::SPECIAL_PAGE);
        $url = $this->getTitle()->getLocalURL("showformatoptions=' + this.value + '");
        foreach ($this->uiCore->getParameters() as $param => $value) {
            if ($param !== 'format') {
                $url .= '&params[' . Xml::escapeJsString($param) . ']=' . Xml::escapeJsString($value);
            }
        }
        // @todo FIXME: i18n: Hard coded parentheses.
        $result[0] = "\n" . '<select id="formatSelector" name="p[format]" onChange="JavaScript:updateOtherOptions(\'' . $url . '\')">' . "\n" . '<option value="' . $defFormat . '">' . $printer->getName() . ' (' . wfMessage('smw_ask_defaultformat')->text() . ')</option>' . "\n";
        $formats = array();
        foreach (array_keys($smwgResultFormats) as $format) {
            // Special formats "count" and "debug" currently not supported.
            if ($format != $defFormat && $format != 'count' && $format != 'debug') {
                $printer = SMWQueryProcessor::getResultPrinter($format, SMWQueryProcessor::SPECIAL_PAGE);
                $formats[$format] = $printer->getName();
            }
        }
        natcasesort($formats);
        $params = $this->uiCore->getParameters();
        foreach ($formats as $format => $name) {
            $result[0] .= '<option value="' . $format . '"' . ($params['format'] == $format ? ' selected' : '') . '>' . $name . "</option>\n";
        }
        $result[0] .= "</select>";
        $result[0] .= "\n";
        $result[] .= '<div id="other_options"> ' . $this->showFormatOptions($params['format'], $params) . ' </div>';
        // BEGIN: add javascript for updating formating options by ajax
        $javascript = <<<END
<script type="text/javascript">
function updateOtherOptions(strURL) {
\tjQuery.ajax({ url: strURL, context: document.body, success: function(data){
\t\tjQuery("#other_options").html(data);
\t}});
}
</script>
END;
        SMWOutputs::requireScript('smwUpdateOptionsQueryUI', $javascript);
        // END: add javascript for updating formating options by ajax
        return $result;
    }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:62,代码来源:SMW_QueryUI.php

示例12: outputResults

 /**
  * 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);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:71,代码来源:SD_BrowseData.php

示例13: formatWSResultWithSMWQPs

 private static function formatWSResultWithSMWQPs($wsResults, $configArgs, $wsParameters, $wsReturnValues, $smwQueryMode)
 {
     //do sorting
     $wsResults = self::sortWSResult($wsResults, $configArgs);
     //deal with limit and offset
     list($wsResults, $furtherResults) = self::formatWithLimitAndOffset($wsResults, $configArgs);
     $format = array_key_exists('format', $configArgs) ? $configArgs['format'] : '';
     //todo: create print requests array for constructor below
     $printRequests = array();
     $queryResults = array();
     $typeIds = array();
     //get Type ids
     $numTypeFormats = array('sum' => true, 'min' => true, 'max' => true, 'average' => true);
     foreach ($wsResults as $columnLabel => $values) {
         if (array_key_exists(strtolower($format), $numTypeFormats)) {
             $typeIds[$columnLabel] = '_num';
         } else {
             $typeIds[$columnLabel] = '_txt';
         }
     }
     //create print requests
     foreach ($wsReturnValues as $id => $label) {
         $id = ucfirst(substr($id, strpos($id, '.') + 1));
         if (!$label) {
             $label = $id;
         }
         $printRequests[$id] = new SMWPrintRequest(SMWPrintRequest::PRINT_THIS, $label, $id);
     }
     //transpose ws result
     foreach ($wsResults as $columnLabel => $values) {
         foreach ($values as $key => $value) {
             $queryResultColumnValues = array();
             $resultInstance = SMWDataValueFactory::newTypeIDValue('_wpg');
             $title = Title::newFromText(wfMsg('smw_ob_invalidtitle'), '');
             $resultInstance->setValues($title->getDBkey(), $title->getNamespace(), $title->getArticleID(), false, '', $title->getFragment());
             $dataValue = SMWDataValueFactory::newTypeIDValue($typeIds[$columnLabel]);
             $dataValue->setUserValue($value);
             $queryResultColumnValues[] = $dataValue;
             //this is necessary, because one can edit with the properties
             //parameter of the LDConnector additional columns
             if (!array_key_exists(ucfirst($columnLabel), $printRequests)) {
                 $printRequests[ucfirst($columnLabel)] = new SMWPrintRequest(SMWPrintRequest::PRINT_THIS, $columnLabel, ucfirst($columnLabel));
             }
             $queryResultColumnValues = new SMWWSResultArray($resultInstance, $printRequests[ucfirst($columnLabel)], $queryResultColumnValues);
             @($queryResults[$key][$columnLabel] = $queryResultColumnValues);
         }
     }
     //translate ws call to SMW ask query
     $queryParams = array();
     foreach ($wsParameters as $param => $value) {
         $queryParams['_' . $param] = $value;
     }
     foreach ($configArgs as $param => $value) {
         $queryParams[$param] = $value;
     }
     $queryParams['source'] = 'webservice';
     $queryParams['webservice'] = $configArgs['webservice'];
     //create query object
     $query = SMWQueryProcessor::createQuery('[[dummy]]', $queryParams, SMWQueryProcessor::INLINE_QUERY, $format, $printRequests);
     $query->params = $queryParams;
     //create query result object
     $queryResult = new SMWWSQueryResult($printRequests, $query, $queryResults, new SMWWSSMWStore(), $furtherResults);
     //deal with count mode
     if ($format == 'count') {
         return count($queryResults);
     }
     //return the query result object if this is called by special:ask
     if ($smwQueryMode) {
         return $queryResult;
     }
     $printer = SMWQueryProcessor::getResultPrinter($format, SMWQueryProcessor::INLINE_QUERY);
     $result = $printer->getResult($queryResult, $configArgs, SMW_OUTPUT_WIKI);
     return $result;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:74,代码来源:SMW_WebServiceUsage.php

示例14: showFormatOptions

	/**
	 * Display a form section showing the options for a given format,
	 * based on the getParameters() value for that format's query printer.
	 *
	 * @param string $format
	 * @param array $paramValues The current values for the parameters (name => value)
	 *
	 * @return string
	 */
	protected function showFormatOptions( $format, array $paramValues ) {
		$printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE );

		$params = SMWQueryProcessor::getParameters();

		if ( method_exists( $printer, 'getValidatorParameters' ) ) {
			$params = array_merge( $params, $printer->getValidatorParameters() );
		}

		$optionsHtml = array();

		foreach ( $params as $param ) {
			// Ignore the format parameter, as we got a special control in the GUI for it already.
			if ( $param->getName() == 'format' ) {
				continue;
			}

			$currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false;

			$optionsHtml[] =
				Html::rawElement(
					'div',
					array(
						'style' => 'width: 30%; padding: 5px; float: left;'
					),
					htmlspecialchars( $param->getName() ) . ': ' .
					$this->showFormatOption( $param, $currentValue ) .
					'<br />' .
					Html::element( 'em', array(), $param->getDescription() )
				);
		}

		for ( $i = 0, $n = count( $optionsHtml ); $i < $n; $i++ ) {
			if ( $i % 3 == 2 || $i == $n - 1 ) {
				$optionsHtml[$i] .= "<div style=\"clear: both\";></div>\n";
			}
		}

		$i = 0;
		$rowHtml = '';
		$resultHtml = '';

		while ( $option = array_shift( $optionsHtml ) ) {
			$rowHtml .= $option;
			$i++;

			$resultHtml .= Html::rawElement(
				'div',
				array(
					'style' => 'background: ' . ( $i % 6 == 0 ? 'white' : '#dddddd' ) . ';'
				),
				$rowHtml
			);

			$rowHtml = '';
		}

		return $resultHtml;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:68,代码来源:SMW_SpecialAsk.php

示例15: makeHTMLResult


//.........这里部分代码省略.........
                $tmp_parray[$key] = $value;
            }
        }
        $urltail .= '&p=' . urlencode(SMWInfolink::encodeParameters($tmp_parray));
        $printoutstring = '';
        foreach ($this->m_printouts as $printout) {
            $printoutstring .= $printout->getSerialisation() . "\n";
        }
        if ($printoutstring != '') {
            $urltail .= '&po=' . urlencode($printoutstring);
        }
        if (array_key_exists('sort', $this->m_params)) {
            $urltail .= '&sort=' . $this->m_params['sort'];
        }
        if (array_key_exists('order', $this->m_params)) {
            $urltail .= '&order=' . $this->m_params['order'];
        }
        if ($this->m_querystring != '') {
            $queryobj = SMWQueryProcessor::createQuery($this->m_querystring, $this->m_params, SMWQueryProcessor::SPECIAL_PAGE, $this->m_params['format'], $this->m_printouts);
            $queryobj->params = $this->m_params;
            $store = $this->getStore();
            $res = $store->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])) {
                    $dv = end(smwfGetStore()->getPropertyValues(SMWWikiPageValue::makePageFromTitle($concept), SMWPropertyValue::makeProperty('_CONC')));
                    if ($dv instanceof SMWConceptValue) {
                        $this->m_params[$desckey] = $dv->getDocu();
                    }
                }
            }
            $printer = SMWQueryProcessor::getResultPrinter($this->m_params['format'], SMWQueryProcessor::SPECIAL_PAGE);
            $result_mime = $printer->getMimeType($res);
            global $wgRequest;
            $hidequery = $wgRequest->getVal('eq') == 'no';
            // if it's an export format (like CSV, JSON, etc.),
            // don't actually export the data if 'eq' is set to
            // either 'yes' or 'no' in the query string - just
            // show the link instead
            if ($this->m_editquery || $hidequery) {
                $result_mime = false;
            }
            if ($result_mime == false) {
                if ($res->getCount() > 0) {
                    if ($this->m_editquery) {
                        $urltail .= '&eq=yes';
                    }
                    if ($hidequery) {
                        $urltail .= '&eq=no';
                    }
                    $navigation = $this->getNavigationBar($res, $urltail);
                    $result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
                    $query_result = $printer->getResult($res, $this->m_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;">' . 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'));
            }
            $result = $this->getInputForm($printoutstring, 'offset=' . $this->m_params['offset'] . '&limit=' . $this->m_params['limit'] . $urltail) . $result;
            $result = $this->postProcessHTML($result);
            $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;
        }
    }
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:SMW_WSSMWAskPage.php


注:本文中的SMWQueryProcessor::getResultPrinter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。