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; }
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; }
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); }
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(); }
/** * Return an SMWTypesValue object representing the datatype of this * property. * @deprecated Types values are not a good way to exchange SMW type information. They are for input only. Use getPropertyTypeID() if you want the type id. This method will vanish in SMW 1.7. */ public function getTypesValue() { $result = SMWTypesValue::newFromTypeId($this->getPropertyTypeID()); if (!$this->isValid()) { $result->addError($this->getErrors()); } return $result; }
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[] = 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; } }
/** * 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); }