本文整理汇总了PHP中smwfGetLinker函数的典型用法代码示例。如果您正苦于以下问题:PHP smwfGetLinker函数的具体用法?PHP smwfGetLinker怎么用?PHP smwfGetLinker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smwfGetLinker函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @since 2.1
*
* @param HtmlFormBuilder $htmlFormBuilder
* @param PageRequestOptions $pageRequestOptions
* @param QueryResultLookup $queryResultLookup
*/
public function __construct(HtmlFormBuilder $htmlFormBuilder, PageRequestOptions $pageRequestOptions, QueryResultLookup $queryResultLookup)
{
$this->htmlFormBuilder = $htmlFormBuilder;
$this->pageRequestOptions = $pageRequestOptions;
$this->queryResultLookup = $queryResultLookup;
$this->linker = smwfGetLinker();
}
示例2: uriProvider
public function uriProvider()
{
$linker = smwfGetLinker();
// FIXME MW 1.19*
$noFollowAttribute = version_compare($GLOBALS['wgVersion'], '1.20', '<') ? '' : ' rel="nofollow"';
// https://github.com/lanthaler/IRI/blob/master/Test/IriTest.php
$provider[] = array('http://example.org/aaa/bbb#ccc', false, null, array('wikiValue' => 'http://example.org/aaa/bbb#ccc', 'longHTMLText' => 'http://example.org/aaa/bbb#ccc', 'longWikiText' => 'http://example.org/aaa/bbb#ccc', 'shortHTMLText' => 'http://example.org/aaa/bbb#ccc', 'shortWikiText' => 'http://example.org/aaa/bbb#ccc'));
$provider[] = array('http://example.org/aaa/bbb#ccc', 'Foo', null, array('wikiValue' => 'http://example.org/aaa/bbb#ccc', 'longHTMLText' => 'http://example.org/aaa/bbb#ccc', 'longWikiText' => 'http://example.org/aaa/bbb#ccc', 'shortHTMLText' => 'Foo', 'shortWikiText' => 'Foo'));
$provider[] = array('http://example.org/aaa/bbb#ccc', false, $linker, array('wikiValue' => 'http://example.org/aaa/bbb#ccc', 'longHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/aaa/bbb#ccc">http://example.org/aaa/bbb#ccc</a>', 'longWikiText' => '[http://example.org/aaa/bbb#ccc http://example.org/aaa/bbb#ccc]', 'shortHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/aaa/bbb#ccc">http://example.org/aaa/bbb#ccc</a>', 'shortWikiText' => '[http://example.org/aaa/bbb#ccc http://example.org/aaa/bbb#ccc]'));
#3
$provider[] = array('http://example.org/aaa/bbb#ccc', 'Foo', $linker, array('wikiValue' => 'http://example.org/aaa/bbb#ccc', 'longHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/aaa/bbb#ccc">http://example.org/aaa/bbb#ccc</a>', 'longWikiText' => '[http://example.org/aaa/bbb#ccc http://example.org/aaa/bbb#ccc]', 'shortHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/aaa/bbb#ccc">Foo</a>', 'shortWikiText' => '[http://example.org/aaa/bbb#ccc Foo]'));
#4
$provider[] = array('http://example.org/aaa%2Fbbb#ccc', false, null, array('wikiValue' => 'http://example.org/aaa%2Fbbb#ccc', 'longHTMLText' => 'http://example.org/aaa%2Fbbb#ccc', 'longWikiText' => 'http://example.org/aaa%2Fbbb#ccc', 'shortHTMLText' => 'http://example.org/aaa%2Fbbb#ccc', 'shortWikiText' => 'http://example.org/aaa%2Fbbb#ccc'));
$provider[] = array('http://example.org/aaa%2Fbbb#ccc', 'Foo', null, array('wikiValue' => 'http://example.org/aaa%2Fbbb#ccc', 'longHTMLText' => 'http://example.org/aaa%2Fbbb#ccc', 'longWikiText' => 'http://example.org/aaa%2Fbbb#ccc', 'shortHTMLText' => 'Foo', 'shortWikiText' => 'Foo'));
#6
$provider[] = array('http://example.org/aaa%2Fbbb#ccc', false, $linker, array('wikiValue' => 'http://example.org/aaa%2Fbbb#ccc', 'longHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/aaa/bbb#ccc">http://example.org/aaa%2Fbbb#ccc</a>', 'longWikiText' => '[http://example.org/aaa/bbb#ccc http://example.org/aaa%2Fbbb#ccc]', 'shortHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/aaa/bbb#ccc">http://example.org/aaa%2Fbbb#ccc</a>', 'shortWikiText' => '[http://example.org/aaa/bbb#ccc http://example.org/aaa%2Fbbb#ccc]'));
$provider[] = array('http://example.org/aaa%2Fbbb#ccc', 'Foo', $linker, array('wikiValue' => 'http://example.org/aaa%2Fbbb#ccc', 'longHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/aaa/bbb#ccc">http://example.org/aaa%2Fbbb#ccc</a>', 'longWikiText' => '[http://example.org/aaa/bbb#ccc http://example.org/aaa%2Fbbb#ccc]', 'shortHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/aaa/bbb#ccc">Foo</a>', 'shortWikiText' => '[http://example.org/aaa/bbb#ccc Foo]'));
#8 UTF-8 encoded string
$provider[] = array('http://example.org/ようこそ--23-7B-7D', false, null, array('wikiValue' => 'http://example.org/ようこそ--23-7B-7D', 'longHTMLText' => 'http://example.org/ようこそ--23-7B-7D', 'longWikiText' => 'http://example.org/ようこそ--23-7B-7D', 'shortHTMLText' => 'http://example.org/ようこそ--23-7B-7D', 'shortWikiText' => 'http://example.org/ようこそ--23-7B-7D'));
#9
$provider[] = array('http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', false, null, array('wikiValue' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'longHTMLText' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'longWikiText' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'shortHTMLText' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'shortWikiText' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D'));
$provider[] = array('http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', '一二三', null, array('wikiValue' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'longHTMLText' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'longWikiText' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'shortHTMLText' => '一二三', 'shortWikiText' => '一二三'));
# 11
$provider[] = array('http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', false, $linker, array('wikiValue' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'longHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D">http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D</a>', 'longWikiText' => '[http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D]', 'shortHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D">http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D</a>', 'shortWikiText' => '[http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D]'));
$provider[] = array('http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', '一二三', $linker, array('wikiValue' => 'http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D', 'longHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D">http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D</a>', 'longWikiText' => '[http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D]', 'shortHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D">一二三</a>', 'shortWikiText' => '[http://example.org/%E3%82%88%E3%81%86%E3%81%93%E3%81%9D-23-7B-7D 一二三]'));
# 13
$provider[] = array('http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', false, null, array('wikiValue' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'longHTMLText' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'longWikiText' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'shortHTMLText' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'shortWikiText' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar'));
$provider[] = array('http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', '&!_:;@*#Foo', null, array('wikiValue' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'longHTMLText' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'longWikiText' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'shortHTMLText' => '&!_:;@*#Foo', 'shortWikiText' => '&!_:;@*#Foo'));
$provider[] = array('http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', false, $linker, array('wikiValue' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'longHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/api?query=%21_:%3B@%2A%20#Foo&=%20-3DBar">http://example.org/api?query=!_:;@* #Foo&=%20-3DBar</a>', 'longWikiText' => '[http://example.org/api?query=%21_:%3B@%2A%20#Foo&=%20-3DBar http://example.org/api?query=!_:;@* #Foo&=%20-3DBar]', 'shortHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/api?query=%21_:%3B@%2A%20#Foo&=%20-3DBar">http://example.org/api?query=!_:;@* #Foo&=%20-3DBar</a>', 'shortWikiText' => '[http://example.org/api?query=%21_:%3B@%2A%20#Foo&=%20-3DBar http://example.org/api?query=!_:;@* #Foo&=%20-3DBar]'));
$provider[] = array('http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', '&!_:;@* #Foo', $linker, array('wikiValue' => 'http://example.org/api?query=!_:;@* #Foo&=%20-3DBar', 'longHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/api?query=%21_:%3B@%2A%20#Foo&=%20-3DBar">http://example.org/api?query=!_:;@* #Foo&=%20-3DBar</a>', 'longWikiText' => '[http://example.org/api?query=%21_:%3B@%2A%20#Foo&=%20-3DBar http://example.org/api?query=!_:;@* #Foo&=%20-3DBar]', 'shortHTMLText' => '<a class="external"' . $noFollowAttribute . ' href="http://example.org/api?query=%21_:%3B@%2A%20#Foo&=%20-3DBar">&!_:;@* #Foo</a>', 'shortWikiText' => '[http://example.org/api?query=%21_:%3B@%2A%20#Foo&=%20-3DBar &!_:;@* #Foo]'));
return $provider;
}
示例3: formatResult
/**
* @param $skin
* @param array $result First item is SMWDIProperty, second item is int
*
* @return string
*/
function formatResult($skin, $result)
{
$linker = smwfGetLinker();
if ($result[0]->isUserDefined()) {
$proplink = $linker->makeLinkObj($result[0]->getDiWikiPage()->getTitle(), htmlspecialchars($result[0]->getLabel()), 'action=view');
} else {
$proplink = SMWDataValueFactory::newDataItemValue($result[0], new SMWDIProperty('_TYPE'))->getLongHTMLText($linker);
}
return wfMsgExt('smw_wantedproperty_template', array('parsemag'), $proplink, $result[1]);
}
示例4: formatPropertyItem
/**
* Produce a formatted string representation for showing a property and
* its usage count in the list of used properties.
*
* @since 1.8
*
* @param SMWDIProperty $property
* @param integer $useCount
* @return string
*/
protected function formatPropertyItem(SMWDIProperty $property, $useCount)
{
global $wgLang;
$linker = smwfGetLinker();
$errors = array();
$diWikiPage = $property->getDiWikiPage();
$title = !is_null($diWikiPage) ? $diWikiPage->getTitle() : null;
if ($property->isUserDefined() && is_null($title)) {
// Show even messed up property names.
$typestring = '';
$proplink = $property->getLabel();
$errors[] = wfMessage('smw_notitle', $property->getLabel())->escaped();
} elseif ($property->isUserDefined()) {
if ($useCount <= 5) {
$errors[] = wfMessage('smw_propertyhardlyused')->escaped();
}
// User defined types default to Page
global $smwgPDefaultType;
$typeDataValue = SMWTypesValue::newFromTypeId($smwgPDefaultType);
$typestring = $typeDataValue->getLongHTMLText($linker);
$label = htmlspecialchars($property->getLabel());
if ($title->exists()) {
$typeProperty = new SMWDIProperty('_TYPE');
$types = smwfGetStore()->getPropertyValues($diWikiPage, $typeProperty);
if (count($types) >= 1) {
$typeDataValue = SMWDataValueFactory::newDataItemValue(current($types), $typeProperty);
$typestring = $typeDataValue->getLongHTMLText($linker);
} else {
$errors[] = wfMessage('smw_propertylackstype')->rawParams($typestring)->escaped();
}
$proplink = $linker->link($title, $label);
} else {
$errors[] = wfMessage('smw_propertylackspage')->escaped();
$proplink = $linker->link($title, $label, array(), array('action' => 'view'));
}
} else {
// predefined property
$typeid = $property->findPropertyTypeID();
$typeDataValue = SMWTypesValue::newFromTypeId($typeid);
$typestring = $typeDataValue->getLongHTMLText($linker);
$propertyDataValue = SMWDataValueFactory::newDataItemValue($property, null);
$proplink = $propertyDataValue->getShortHtmlText($linker);
}
$warnings = smwfEncodeMessages($errors, 'warning', '', false);
$useCount = $wgLang->formatNum($useCount);
if ($typestring === '') {
// Builtins have no type
// @todo Should use numParams for $useCount?
return wfMessage('smw_property_template_notype')->rawParams($proplink)->params($useCount)->text() . ' ' . $warnings;
} else {
// @todo Should use numParams for $useCount?
return wfMessage('smw_property_template')->rawParams($proplink, $typestring)->params($useCount)->escaped() . ' ' . $warnings;
}
}
示例5: getTypesList
protected function getTypesList()
{
$html = '<p>' . wfMessage('smw_types_docu')->escaped() . "</p><br />\n";
$typeLabels = DataTypeRegistry::getInstance()->getKnownTypeLabels();
asort($typeLabels, SORT_STRING);
$html .= "<ul>\n";
foreach ($typeLabels as $typeId => $label) {
$typeValue = SMWTypesValue::newFromTypeId($typeId);
$html .= '<li>' . $typeValue->getLongHTMLText(smwfGetLinker()) . "</li>\n";
}
$html .= "</ul>\n";
return $html;
}
示例6: getTypesList
protected function getTypesList()
{
$html = '<p>' . htmlspecialchars(wfMsg('smw_types_docu')) . "</p><br />\n";
$typeLabels = SMWDataValueFactory::getKnownTypeLabels();
asort($typeLabels, SORT_STRING);
$html .= "<ul>\n";
foreach ($typeLabels as $typeId => $label) {
$typeValue = SMWTypesValue::newFromTypeId($typeId);
$html .= '<li>' . $typeValue->getLongHTMLText(smwfGetLinker()) . "</li>\n";
}
$html .= "</ul>\n";
return $html;
}
示例7: formatResult
function formatResult($skin, $result)
{
global $wgLang;
$linker = smwfGetLinker();
list($property, $useCount) = $result;
$errors = array();
$diWikiPage = $property->getDiWikiPage();
$title = !is_null($diWikiPage) ? $diWikiPage->getTitle() : null;
if ($property->isUserDefined()) {
if ($title === null) {
return '';
}
if ($useCount <= 5) {
$errors[] = wfMsgHtml('smw_propertyhardlyused');
}
// User defined types default to Page
global $smwgPDefaultType;
$typeDataValue = SMWTypesValue::newFromTypeId($smwgPDefaultType);
$typestring = $typeDataValue->getLongHTMLText($linker);
$label = htmlspecialchars($property->getLabel());
if ($title->exists()) {
$typeProperty = new SMWDIProperty('_TYPE');
$types = smwfGetStore()->getPropertyValues($diWikiPage, $typeProperty);
if (count($types) >= 1) {
$typeDataValue = SMWDataValueFactory::newDataItemValue(current($types), $typeProperty);
$typestring = $typeDataValue->getLongHTMLText($linker);
} else {
$errors[] = wfMsgHtml('smw_propertylackstype', $typestring);
}
$proplink = $linker->link($title, $label);
} else {
$errors[] = wfMsgHtml('smw_propertylackspage');
$proplink = $linker->link($title, $label, array(), array('action' => 'view'));
}
} else {
// predefined property
$typeid = $property->findPropertyTypeID();
$typeDataValue = SMWTypesValue::newFromTypeId($typeid);
$typestring = $typeDataValue->getLongHTMLText($linker);
$propertyDataValue = SMWDataValueFactory::newDataItemValue($property, null);
$proplink = $propertyDataValue->getShortHtmlText($linker);
}
$warnings = smwfEncodeMessages($errors, 'warning', '', false);
$useCount = $wgLang->formatNum($useCount);
if ($typestring === '') {
// Builtins have no type
return wfMsgHtml('smw_property_template_notype', $proplink, $useCount) . ' ' . $warnings;
} else {
return wfMsgHtml('smw_property_template', $proplink, $typestring, $useCount) . ' ' . $warnings;
}
}
示例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: getTypesList
protected function getTypesList()
{
$typeLabels = DataTypeRegistry::getInstance()->getKnownTypeLabels();
asort($typeLabels, SORT_STRING);
$mwCollaboratorFactory = ApplicationFactory::getInstance()->newMwCollaboratorFactory();
$htmlColumnListRenderer = $mwCollaboratorFactory->newHtmlColumnListRenderer();
foreach ($typeLabels as $typeId => $label) {
$typeValue = SMWTypesValue::newFromTypeId($typeId);
$startChar = $this->getLanguage()->convert($this->getLanguage()->firstChar($typeValue->getWikiValue()));
$contentsByIndex[] = $typeValue->getLongHTMLText(smwfGetLinker());
}
$htmlColumnListRenderer->setNumberOfColumns(2);
$htmlColumnListRenderer->addContentsByNoIndex($contentsByIndex);
$htmlColumnListRenderer->setColumnListClass('smw-sp-types-list');
$html = \Html::rawElement('p', array('class' => 'smw-sp-types-intro'), wfMessage('smw_types_docu')->parse()) . \Html::element('h2', array(), wfMessage('smw-sp-types-list')->escaped());
return $html . $htmlColumnListRenderer->getHtml();
}
示例10: formatPropertyItem
/**
* Produce a formatted string representation for showing a property in
* the list of unused properties.
*
* @since 1.8
*
* @param SMWDIProperty $property
* @return string
*/
protected function formatPropertyItem(SMWDIProperty $property)
{
$linker = smwfGetLinker();
$errors = array();
if ($property->isUserDefined()) {
$proplink = $linker->link($property->getDiWikiPage()->getTitle(), $property->getLabel());
$types = smwfGetStore()->getPropertyValues($property->getDiWikiPage(), new SMWDIProperty('_TYPE'));
if (count($types) >= 1) {
$typeDataValue = SMWDataValueFactory::newDataItemValue(current($types), new SMWDIProperty('_TYPE'));
} else {
$typeDataValue = SMWTypesValue::newFromTypeId('_wpg');
$errors[] = wfMessage('smw_propertylackstype', $typeDataValue->getLongHTMLText())->text();
}
$typeString = $typeDataValue->getLongHTMLText($linker);
} else {
$typeid = $property->findPropertyTypeID();
$typeDataValue = SMWTypesValue::newFromTypeId($typeid);
$typeString = $typeDataValue->getLongHTMLText($linker);
$propertyDataValue = SMWDataValueFactory::newDataItemValue($property, null);
$proplink = $propertyDataValue->getShortHtmlText($linker);
}
return wfMessage('smw_unusedproperty_template', $proplink, $typeString)->text() . ' ' . smwfEncodeMessages($errors);
}
示例11: getResultList
/**
* Creates the HTML for a bullet list with all the results of the set
* query. Values can be highlighted to show exact matches among nearby
* ones.
*
* @todo I18N: some parentheses hardcoded
*
* @since 1.8 (was private displayResults before)
* @param array $results (array of (array of one or two SMWDataValues))
* @param integer $number How many results should be displayed? -1 for all
* @param boolean $first If less results should be displayed than
* given, should they show the first $number results, or the last
* $number results?
* @param boolean $highlight Should the results be highlighted?
*
* @return string HTML with the bullet list, including header
*/
protected function getResultList($results, $number, $first, $highlight = false)
{
if ($number > 0) {
$results = $first ? array_slice($results, 0, $number) : array_slice($results, $number);
}
$html = '';
foreach ($results as $result) {
$listitem = $result[0]->getLongHTMLText(smwfGetLinker());
// Add browsing link for wikipage results
// Note: non-wikipage results are possible using inverse properties
if ($result[0]->getTypeID() == '_wpg') {
$listitem .= '  ' . SMWInfolink::newBrowsingLink('+', $result[0]->getLongWikiText())->getHTML(smwfGetLinker());
}
// Show value if not equal to the value that was searched
// or if the current results are to be highlighted:
if (array_key_exists(1, $result) && $result[1] instanceof SMWDataValue && (!$this->value->getDataItem()->equals($result[1]->getDataItem()) || $highlight)) {
// TODO i18n: Hardcoded parentheses
$listitem .= " <em><small>(" . $result[1]->getLongHTMLText(smwfGetLinker()) . ")</small></em>";
}
// Highlight values
if ($highlight) {
$listitem = "<strong>{$listitem}</strong>";
}
$html .= "<li>{$listitem}</li>\n";
}
return "<ul>\n{$html}</ul>\n";
}
示例12: displayHead
/**
* Displays the subject that is currently being browsed to.
*
* @return A string containing the HTML with the subject line
*/
private function displayHead() {
global $wgOut;
$wgOut->setHTMLTitle( $this->subject->getTitle() );
$html = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n" .
"<tr class=\"smwb-title\"><td colspan=\"2\">\n" .
$this->subject->getLongHTMLText( smwfGetLinker() ) . "\n" .
"</td></tr>\n</table>\n";
return $html;
}
示例13: execute
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 .= '     <b>' . wfMsg('smw_result_results') . ' ' . ($offset + 1) . '– ' . ($offset + min(count($results), $limit)) . '</b>    ';
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 .= '  ' . $browselink->getHTML($linker);
}
$html .= "</li> \n";
}
$html .= "</ul>\n";
}
$html .= $navigation;
}
// Display query form
$spectitle = $this->getTitle();
$html .= '<p> </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) . '" />' . "   \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!
}
示例14: displayResults
/**
* Creates the HTML for a bullet list with all the results of the set query.
*
* @param[in] $results array of array of SMWWikiPageValue, SMWDataValue The entity and its datavalue
* @param[in] $number int How many results should be displayed? -1 for all
* @param[in] $first bool If less results should be displayed than given, should they show the first $number results, or the last $number results?
* @param[in] $highlight bool Should the results be highlighted?
*
* @return string HTML with the bullet list and a header
*/
private function displayResults($results, $number = -1, $first = true, $highlight = false)
{
$html = "<ul>\n";
if (!$first && $number > 0) {
// TODO: why is this reversed?
// I (jeroendedauw) replaced a loop using array_shift by this, which is equivalent.
$results = array_slice(array_reverse($results), 0, $number);
}
while ($results && $number != 0) {
$result = array_shift($results);
$html .= '<li>' . $result[0]->getLongHTMLText(smwfGetLinker());
if ($result[0]->getTypeID() == '_wpg') {
$html .= '  ' . SMWInfolink::newBrowsingLink('+', $result[0]->getLongWikiText())->getHTML(smwfGetLinker());
}
if (array_key_exists(1, $result) && is_object($result[1]) && ($this->value != $result[1] || $highlight)) {
$html .= " <em><small>(" . $result[1]->getLongHTMLText(smwfGetLinker()) . ")</small></em>";
}
$html .= "</li>";
if ($highlight) {
$html = "<strong>" . $html . "</strong>";
}
$html .= "\n";
$number--;
}
$html .= "</ul>\n";
return $html;
}
示例15: linkForSpecialPage
/**
* Creates a link to a special page, using that page's top-level description as the link text.
*/
public static function linkForSpecialPage($specialPageName)
{
$specialPage = SpecialPage::getPage($specialPageName);
return smwfGetLinker()->link($specialPage->getTitle(), $specialPage->getDescription());
}