本文整理汇总了PHP中smwfEncodeMessages函数的典型用法代码示例。如果您正苦于以下问题:PHP smwfEncodeMessages函数的具体用法?PHP smwfEncodeMessages怎么用?PHP smwfEncodeMessages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smwfEncodeMessages函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHtml
/**
* Returns the HTML which is added to $wgOut after the article text.
*
* @return string
*/
protected function getHtml()
{
if ($this->limit > 0) {
// limit==0: configuration setting to disable this completely
$store = StoreFactory::getStore();
$concept = $store->getConceptCacheStatus($this->getDataItem());
$description = new ConceptDescription($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));
// Concept cache information
if ($concept instanceof DIConcept && $concept->getCacheStatus() === 'full') {
$cacheInformation = Html::element('span', array('class' => 'smw-concept-cache-information'), ' ' . $this->getContext()->msg('smw-concept-cache-text', $this->getContext()->getLanguage()->formatNum($concept->getCacheCount()), $this->getContext()->getLanguage()->date($concept->getCacheDate()), $this->getContext()->getLanguage()->time($concept->getCacheDate()))->text());
} else {
$cacheInformation = '';
}
return Html::element('br', array('id' => 'smwfootbr')) . Html::element('a', array('name' => 'SMWResults'), null) . Html::rawElement('div', array('id' => 'mw-pages'), Html::rawElement('h2', array(), $this->getContext()->msg('smw_concept_header', $titleText)->text()) . Html::element('span', array(), $this->getContext()->msg('smw_conceptarticlecount', $resultNumber)->parse()) . smwfEncodeMessages($errors) . ' ' . $navigation . $cacheInformation . $pageLister->formatList());
}
示例2: render
/**
* Method for handling the subobject parser function.
*
* @since 1.7
*
* @param Parser $parser
*/
public static function render(Parser &$parser)
{
self::$m_errors = array();
$params = func_get_args();
array_shift($params);
// We already know the $parser ...
$subobjectName = str_replace(' ', '_', trim(array_shift($params)));
$mainSemanticData = SMWParseData::getSMWData($parser);
$subject = $mainSemanticData->getSubject();
$diSubWikiPage = new SMWDIWikiPage($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $subobjectName);
$semanticData = new SMWContainerSemanticData($diSubWikiPage);
foreach ($params as $param) {
$parts = explode('=', trim($param), 2);
// Only add the property when there is both a name
// and a non-empty value.
if (count($parts) == 2 && $parts[1] != '') {
self::addPropertyValueToSemanticData($parts[0], $parts[1], $semanticData);
} else {
//self::$m_errors[] = wfMsgForContent( 'smw_noinvannot' );
}
}
$propertyDi = new SMWDIProperty('_SOBJ');
$subObjectDi = new SMWDIContainer($semanticData);
SMWParseData::getSMWData($parser)->addPropertyObjectValue($propertyDi, $subObjectDi);
return smwfEncodeMessages(self::$m_errors);
}
示例3: getHtml
/**
* 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;
}
示例4: render
/**
* Method for handling the subobject parser function.
*
* @since 1.7
*
* @param Parser $parser
*/
public static function render(Parser &$parser)
{
self::$m_errors = array();
$params = func_get_args();
array_shift($params);
// We already know the $parser ...
$subobjectName = str_replace(' ', '_', trim(array_shift($params)));
// For objects that don't come with there own idenifier, use a value
// dependant md4 hash key
if ($subobjectName === '' || $subobjectName === '-') {
$subobjectName = '_' . hash('md4', implode('|', $params), false);
}
$mainSemanticData = SMWParseData::getSMWData($parser);
$subject = $mainSemanticData->getSubject();
$diSubWikiPage = new SMWDIWikiPage($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $subobjectName);
$semanticData = new SMWContainerSemanticData($diSubWikiPage);
$previousPropertyDi = null;
foreach ($params as $param) {
$parts = explode('=', trim($param), 2);
// Only add the property when there is both a name
// and a non-empty value.
if (count($parts) == 2 && $parts[1] != '') {
$previousPropertyDi = self::addPropertyValueToSemanticData($parts[0], $parts[1], $semanticData);
} elseif (count($parts) == 1 && !is_null($previousPropertyDi)) {
self::addPropertyDiValueToSemanticData($previousPropertyDi, $parts[0], $semanticData);
} else {
//self::$m_errors[] = wfMessage( 'smw_noinvannot' )->inContentLanguage()->text();
}
}
$propertyDi = new SMWDIProperty('_SOBJ');
$subObjectDi = new SMWDIContainer($semanticData);
SMWParseData::getSMWData($parser)->addPropertyObjectValue($propertyDi, $subObjectDi);
return smwfEncodeMessages(self::$m_errors);
}
示例5: getHtml
/**
* Returns the HTML which is added to $wgOut after the article text.
*
* @return string
*/
protected function getHtml()
{
global $smwgConceptPagingLimit, $wgRequest;
if ($this->limit > 0) {
// limit==0: configuration setting to disable this completely
$description = new ConceptDescription($this->getDataItem());
$query = SMWPageLister::getQuery($description, $this->limit, $this->from, $this->until);
$query->setLimit($wgRequest->getVal('limit', $smwgConceptPagingLimit));
$query->setOffset($wgRequest->getVal('offset', '0'));
$queryResult = ApplicationFactory::getInstance()->getStore()->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.
$titleText = htmlspecialchars($this->mTitle->getText());
return Html::element('br', array('id' => 'smwfootbr')) . Html::element('a', array('name' => 'SMWResults'), null) . Html::rawElement('div', array('id' => 'mw-pages'), $this->getCacheInformation() . Html::rawElement('h2', array(), $this->getContext()->msg('smw_concept_header', $titleText)->text()) . $this->getNavigationLinks('smw_conceptarticlecount', $diWikiPages, $smwgConceptPagingLimit) . smwfEncodeMessages($errors) . ' ' . $this->getFormattedColumns($diWikiPages));
}
示例6: testSmwfEncodeMessages
/**
* @covers ::smwfEncodeMessages
* @test smwfEncodeMessages
* @dataProvider getEncodeMessagesDataProvider
*
* @param $message
* @param $type
* @param $separator
* @param $escape
*/
public function testSmwfEncodeMessages($message, $type, $separator, $escape)
{
$results = smwfEncodeMessages($message);
$this->assertFalse(is_null($results));
$this->assertTrue(is_string($results));
$results = smwfEncodeMessages($message, $type);
$this->assertFalse(is_null($results));
$this->assertTrue(is_string($results));
$results = smwfEncodeMessages($message, $type, $separator);
$this->assertFalse(is_null($results));
$this->assertTrue(is_string($results));
$results = smwfEncodeMessages($message, $type, $separator, $escape);
$this->assertFalse(is_null($results));
$this->assertTrue(is_string($results));
}
示例7: render
/**
* 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;
}
示例8: formatResult
function formatResult($skin, $result)
{
$linker = smwfGetLinker();
$proplink = $linker->link($result->getDiWikiPage()->getTitle(), $result->getLabel());
$types = smwfGetStore()->getPropertyValues($result->getDiWikiPage(), new SMWDIProperty('_TYPE'));
$errors = array();
if (count($types) >= 1) {
$typestring = SMWDataValueFactory::newDataItemValue(current($types), new SMWDIProperty('_TYPE'))->getLongHTMLText($linker);
} else {
$type = SMWTypesValue::newFromTypeId('_wpg');
$typestring = $type->getLongHTMLText($linker);
$errors[] = wfMsg('smw_propertylackstype', $type->getLongHTMLText());
}
return wfMsg('smw_unusedproperty_template', $proplink, $typestring) . ' ' . smwfEncodeMessages($errors);
}
示例9: handle
/**
* @param Parser $parser
* @param ProcessingResult $result
*
* @return mixed
*/
public function handle(Parser $parser, ProcessingResult $result)
{
$parameters = $result->getParameters();
/**
* Non-escaping is safe bacause a user's message is passed through parser, which will
* handle unsafe HTM elements.
*/
$result = smwfEncodeMessages(array($parameters['message']->getValue()), $parameters['icon']->getValue(), ' <!--br-->', false);
if (!is_null($parser->getTitle()) && $parser->getTitle()->isSpecialPage()) {
global $wgOut;
SMWOutputs::commitToOutputPage($wgOut);
} else {
SMWOutputs::commitToParser($parser);
}
return $result;
}
示例10: doCompoundQuery
/**
* Handler for the #compound_query parser function.
*
* @param Parser $parser
*
* @return string
*/
public static function doCompoundQuery(Parser &$parser)
{
global $smwgQEnabled, $smwgIQRunningNumber;
if (!$smwgQEnabled) {
return smwfEncodeMessages(array(wfMsgForContent('smw_iq_disabled')));
}
$smwgIQRunningNumber++;
$params = func_get_args();
array_shift($params);
// We already know the $parser.
$other_params = array();
$results = array();
$printRequests = array();
$queryParams = array();
foreach ($params as $param) {
// Very primitive heuristic - if the parameter
// includes a square bracket, then it's a
// sub-query; otherwise it's a regular parameter.
if (strpos($param, '[') !== false) {
$queryParams[] = $param;
} else {
$parts = explode('=', $param, 2);
if (count($parts) >= 2) {
$other_params[strtolower(trim($parts[0]))] = $parts[1];
// don't trim here, some params care for " "
}
}
}
foreach ($queryParams as $param) {
$subQueryParams = self::getSubParams($param);
if (array_key_exists('format', $other_params) && !array_key_exists('format', $subQueryParams)) {
$subQueryParams['format'] = $other_params['format'];
}
$next_result = self::getQueryResultFromFunctionParams($subQueryParams, SMW_OUTPUT_WIKI);
$results = self::mergeSMWQueryResults($results, $next_result->getResults());
$printRequests = self::mergeSMWPrintRequests($printRequests, $next_result->getPrintRequests());
}
// Sort results so that they'll show up by page name
uasort($results, array('SCQQueryProcessor', 'compareQueryResults'));
$query_result = new SCQQueryResult($printRequests, new SMWQuery(), $results, smwfGetStore());
if (version_compare(SMW_VERSION, '1.6.1', '>')) {
SMWQueryProcessor::addThisPrintout($printRequests, $other_params);
$other_params = parent::getProcessedParams($other_params, $printRequests);
}
return self::getResultFromQueryResult($query_result, $other_params, SMW_OUTPUT_WIKI);
}
示例11: render
/**
* 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('>', '<'), 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('[', '[', $concept_text) . "</pre>\n</div>";
if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
global $wgOut;
SMWOutputs::commitToOutputPage($wgOut);
} else {
SMWOutputs::commitToParser($parser);
}
return $result;
}
示例12: render
/**
* 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;
}
示例13: render
/**
* 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;
}
示例14: materializePF_render
function materializePF_render(&$parser)
{
$parameters = materializePF_getParameters(func_get_args());
if ($parser->OutputType() == 2) {
if (!($parameters["update"] === "false" && $parameters["materialized"] != null || $parameters["update"] === "both")) {
$parameters["materialized"] = $parser->replaceVariables("{{subst:" . substr($parameters["call"], 2));
}
if ($parameters["update"] != "final") {
$parameters["call"] = str_replace("{", "##mcoll##", $parameters["call"]);
$parameters["call"] = str_replace("}", "##mcolr##", $parameters["call"]);
$parameters["call"] = str_replace("|", "##pipe##", $parameters["call"]);
$output = "{{#materialize:" . $parameters["call"] . "\n";
$output .= "| update = " . $parameters["update"] . "\n";
$output .= "| materialized = \n" . $parameters["materialized"];
$output .= "\n}}";
} else {
$output = $parameters["materialized"];
}
} else {
global $wgsmwRememberedMaterializations;
$dbAccess = SMWMaterializationStorageAccess::getInstance();
$db = $dbAccess->getDatabase();
$pageId = $parser->getTitle()->getArticleID();
$callHash = SMWHashProcessor::generateHashValue($parameters["call"]);
$materialized = null;
$sourceHash = $db->getMaterializationHash($pageId, $callHash);
if ($sourceHash == null) {
$materialized = trim($parser->replaceVariables($parameters["call"]));
$materializationHash = SMWHashProcessor::generateHashValue($materialized);
$db->addMaterializationHash($pageId, $callHash, $materializationHash);
} else {
if ($parameters["update"] == "true") {
$materialized = trim($parser->replaceVariables($parameters["call"]));
$materializationHash = SMWHashProcessor::generateHashValue($materialized);
$db->deleteMaterializationHash($pageId, $callHash);
$db->addMaterializationHash($pageId, $callHash, $materializationHash);
}
}
$wgsmwRememberedMaterializations[$callHash] = null;
$output = $parameters["materialized"];
if ($parameters["update"] == "both") {
if ($sourceHash) {
$materialized = trim($parser->replaceVariables($parameters["call"]));
if (!SMWHashProcessor::isHashValueEqual(SMWHashProcessor::generateHashValue($materialized), $sourceHash)) {
$output .= "<br/>" . $materialized;
}
}
} else {
if ($parameters["update"] == "false") {
$output = $parameters["materialized"];
if ($sourceHash) {
$materialized = trim($parser->replaceVariables($parameters["call"]));
if (!SMWHashProcessor::isHashValueEqual(SMWHashProcessor::generateHashValue($materialized), $sourceHash)) {
$output .= smwfEncodeMessages(array(wfMsg('smw_wwsm_update_msg')));
}
}
}
}
}
return $output;
}
示例15: getErrorString
/**
* Provides a simple formatted string of all the error messages that occurred.
* Can be used if not specific error formatting is desired. Compatible with HTML
* and Wiki.
*
* @param SMWQueryResult $res
*
* @return string
*/
protected function getErrorString(SMWQueryResult $res)
{
return $this->mShowErrors ? smwfEncodeMessages(array_merge($this->mErrors, $res->getErrors())) : '';
}