本文整理汇总了PHP中SMWDIProperty类的典型用法代码示例。如果您正苦于以下问题:PHP SMWDIProperty类的具体用法?PHP SMWDIProperty怎么用?PHP SMWDIProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMWDIProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: parseUserValue
protected function parseUserValue($value)
{
global $wgContLang;
$this->m_diProperties = array();
$stringValue = '';
$valueList = preg_split('/[\\s]*;[\\s]*/u', trim($value));
foreach ($valueList as $propertyName) {
$propertyNameParts = explode(':', $propertyName, 2);
if (count($propertyNameParts) > 1) {
$namespace = smwfNormalTitleText($propertyNameParts[0]);
$propertyName = $propertyNameParts[1];
$propertyNamespace = $wgContLang->getNsText(SMW_NS_PROPERTY);
if ($namespace != $propertyNamespace) {
$this->addError(wfMessage('smw_wrong_namespace', $propertyNamespace)->inContentLanguage()->text());
}
}
$propertyName = smwfNormalTitleText($propertyName);
try {
$diProperty = SMWDIProperty::newFromUserLabel($propertyName);
} catch (SMWDataItemException $e) {
$diProperty = new SMWDIProperty('Error');
$this->addError(wfMessage('smw_noproperty', $propertyName)->inContentLanguage()->text());
}
$this->m_diProperties[] = $diProperty;
$stringValue .= ($stringValue ? ';' : '') . $diProperty->getKey();
}
$this->m_dataitem = new SMWDIBlob($stringValue);
}
开发者ID:Rikuforever,项目名称:wiki,代码行数:28,代码来源:SMW_DV_PropertyList.php
示例2: newFromSerialization
/**
* Creates and returns a new SWLPropertyChange instance from a serialization.
*
* @param string|null $oldValue
* @param string|null $newValue
*
* @return SWLPropertyChange
*/
public static function newFromSerialization(SMWDIProperty $property, $oldValue, $newValue)
{
$diType = SMWDataValueFactory::getDataItemId($property->findPropertyTypeID());
//var_dump($property);
//if($diType!=7) {throw new Exception();exit;}
return new self(is_null($oldValue) ? null : SMWDataItem::newFromSerialization($diType, $oldValue), is_null($newValue) ? null : SMWDataItem::newFromSerialization($diType, $newValue));
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:SWL_PropertyChange.php
示例3: newFromSerialization
/**
* Creates and returns a new SWLPropertyChange instance from a serialization.
*
* @param string|null $oldValue
* @param string|null $newValue
*
* @return SWLPropertyChange
*/
public static function newFromSerialization( SMWDIProperty $property, $oldValue, $newValue ) {
$diType = SMWDataValueFactory::getDataItemId( $property->findPropertyTypeID() );
return new self(
is_null( $oldValue ) ? null : SMWDataItem::newFromSerialization( $diType, $oldValue ),
is_null( $newValue ) ? null : SMWDataItem::newFromSerialization( $diType, $newValue )
);
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:16,代码来源:SWL_PropertyChange.php
示例4: getPropertyCustomText
/**
* Returns an array of CustomTexts set by the admin in WatchlistConditions
* for this group and property.
*
* @since 0.2
*
* @param SMWDIProperty $property
* @param String $newValue
*
* @return String or false
*/
public function getPropertyCustomText(SMWDIProperty $property, $newValue)
{
$this->initCustomTexts();
if (array_key_exists($property->getLabel(), $this->customTexts) && array_key_exists($newValue, $this->customTexts[$property->getLabel()])) {
return $this->customTexts[$property->getLabel()][$newValue];
} else {
return false;
}
}
开发者ID:nischayn22,项目名称:mediawiki-extensions-SemanticWatchlist,代码行数:20,代码来源:SWL_CustomTexts.php
示例5: SemanticGlossaryRegisterPropertyAliases
function SemanticGlossaryRegisterPropertyAliases()
{
SMWDIProperty::registerPropertyAlias('___glt', wfMsg('semanticglossary-prop-glt'));
SMWDIProperty::registerPropertyAlias('___gld', wfMsg('semanticglossary-prop-gld'));
SMWDIProperty::registerPropertyAlias('___gll', wfMsg('semanticglossary-prop-gll'));
return true;
}
开发者ID:yusufchang,项目名称:app,代码行数:7,代码来源:SemanticGlossary.php
示例6: checkAllowedValues
/**
* Check if property is range restricted and, if so, whether the current value is allowed.
* Creates an error if the value is illegal.
*/
protected function checkAllowedValues()
{
if (!is_null($this->m_property)) {
$propertyDiWikiPage = $this->m_property->getDiWikiPage();
}
if (is_null($this->m_property) || is_null($propertyDiWikiPage) || !isset($this->m_dataitem)) {
return;
// no property known, or no data to check
}
$allowedvalues = \SMW\StoreFactory::getStore()->getPropertyValues($propertyDiWikiPage, new SMWDIProperty('_PVAL'));
if (count($allowedvalues) == 0) {
return;
}
$hash = $this->m_dataitem->getHash();
$testdv = DataValueFactory::getInstance()->newTypeIDValue($this->getTypeID());
$accept = false;
$valuestring = '';
foreach ($allowedvalues as $di) {
if ($di instanceof SMWDIBlob) {
$testdv->setUserValue($di->getString());
if ($hash === $testdv->getDataItem()->getHash()) {
$accept = true;
break;
} else {
if ($valuestring !== '') {
$valuestring .= ', ';
}
$valuestring .= $di->getString();
}
}
}
if (!$accept) {
$this->addError(wfMessage('smw_notinenum', $this->getWikiValue(), $valuestring)->inContentLanguage()->text());
}
}
开发者ID:ReachingOut,项目名称:SemanticMediaWiki,代码行数:39,代码来源:SMW_DataValue.php
示例7: initParameters
/**
* @see SMWOrderedListPage::initParameters()
* @note We use a smaller limit here; property pages might become large.
*/
protected function initParameters()
{
global $smwgPropertyPagingLimit;
$this->limit = $smwgPropertyPagingLimit;
$this->mProperty = SMWDIProperty::newFromUserLabel($this->mTitle->getText());
return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:SMW_PropertyPage.php
示例8: setTypeAndPossibleValues
function setTypeAndPossibleValues()
{
// The presence of "-" at the beginning of a property name
// (which happens if SF tries to parse an inverse query)
// leads to an error in SMW - just exit if that's the case.
if (strpos($this->mSemanticProperty, '-') === 0) {
return;
}
$proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
if ($proptitle === null) {
return;
}
$store = SFUtils::getSMWStore();
// this returns an array of objects
$allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
$label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
$propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
$this->mPropertyType = $propValue->findPropertyTypeID();
foreach ($allowed_values as $allowed_value) {
// HTML-unencode each value
$this->mPossibleValues[] = html_entity_decode($allowed_value);
if (count($label_formats) > 0) {
$label_format = $label_formats[0];
$prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
$label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
$label_value->setOutputFormat($label_format);
$this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
}
}
// HACK - if there were any possible values, set the property
// type to be 'enumeration', regardless of what the actual type is
if (count($this->mPossibleValues) > 0) {
$this->mPropertyType = 'enumeration';
}
}
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:35,代码来源:SF_TemplateField.php
示例9: setTypeAndPossibleValues
function setTypeAndPossibleValues()
{
$proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
if ($proptitle === null) {
return;
}
$store = smwfGetStore();
// this returns an array of objects
$allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
$label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
$propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
$this->mPropertyType = $propValue->findPropertyTypeID();
foreach ($allowed_values as $allowed_value) {
// HTML-unencode each value
$this->mPossibleValues[] = html_entity_decode($allowed_value);
if (count($label_formats) > 0) {
$label_format = $label_formats[0];
$prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
$label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
$label_value->setOutputFormat($label_format);
$this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
}
}
// HACK - if there were any possible values, set the property
// type to be 'enumeration', regardless of what the actual type is
if (count($this->mPossibleValues) > 0) {
$this->mPropertyType = 'enumeration';
}
}
开发者ID:seedbank,项目名称:old-repo,代码行数:29,代码来源:SF_TemplateField.php
示例10: initParameters
/**
* @see SMWOrderedListPage::initParameters()
* @note We use a smaller limit here; property pages might become large.
*/
protected function initParameters()
{
global $smwgPropertyPagingLimit;
$this->limit = $smwgPropertyPagingLimit;
$this->mProperty = SMWDIProperty::newFromUserLabel($this->mTitle->getText());
$this->store = ApplicationFactory::getInstance()->getStore();
return true;
}
开发者ID:jdforrester,项目名称:SemanticMediaWiki,代码行数:12,代码来源:SMW_PropertyPage.php
示例11: 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;
}
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:64,代码来源:SMW_SpecialProperties.php
示例12: addPropertyAndValue
public function addPropertyAndValue( $propName, $value ) {
// SMW 1.6+
if ( class_exists( 'SMWDIProperty' ) ) {
$property = SMWDIProperty::newFromUserLabel( $propName );
} else {
$property = SMWPropertyValue::makeUserProperty( $propName );
}
$dataValue = SMWDataValueFactory::newPropertyObjectValue( $property, $value );
if ( $dataValue->isValid() ) {
$this->mPropertyValuePairs[] = array( $property, $dataValue );
} // else - show an error message?
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:13,代码来源:SemanticInternalObjects_body.php
示例13: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
*
* @param $dataitem SMWDataItem
*
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if (!$dataItem instanceof SMWDIBlob) {
return false;
}
$this->m_dataitem = $dataItem;
$this->m_diProperties = array();
foreach (explode(';', $dataItem->getString()) as $propertyKey) {
$property = null;
try {
$property = new SMWDIProperty($propertyKey);
} catch (SMWDataItemException $e) {
$property = new SMWDIProperty('Error');
$this->addError(wfMessage('smw_parseerror')->inContentLanguage()->text());
}
if ($property instanceof SMWDIProperty) {
// Find a possible redirect
$this->m_diProperties[] = $property->getRedirectTarget();
}
}
$this->m_caption = false;
return true;
}
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:30,代码来源:SMW_DV_PropertyList.php
示例14: initProperties
function initProperties()
{
if (class_exists('SMWDIProperty')) {
SMWDIProperty::registerProperty("__SIA_RECTCOORDS", '_str', "SIArectangleCoordinates", true);
SMWDIProperty::registerProperty("__SIA_IMG_URL", '_str', "SIAimageURL", true);
SMWDIProperty::registerProperty("__SIA_ANNOTATED", '_str', "SIAannotatedImage", true);
SMWDIProperty::registerProperty("__SIA_CREATED_BY", '_str', "SIAcreatedBy", true);
} else {
SMWPropertyValue::registerProperty("__SIA_RECTCOORDS", '_str', "SIArectangleCoordinates", true);
SMWPropertyValue::registerProperty("__SIA_IMG_URL", '_str', "SIAimageURL", true);
SMWPropertyValue::registerProperty("__SIA_ANNOTATED", '_str', "SIAannotatedImage", true);
SMWPropertyValue::registerProperty("__SIA_CREATED_BY", '_str', "SIAcreatedBy", true);
}
return true;
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:15,代码来源:SemanticImageAnnotator.php
示例15: writeOrDeleteDataToWiki
/**
* Write (or delte, if $delete is set to true) the data in the object
* variables, to the wiki page corresponding to this page handler
* @param boolean $delete
*/
public function writeOrDeleteDataToWiki( $delete = false ) {
if ( $delete ) {
if ( $this->checkWikiPageExists() ) {
$this->initSMWWriter( $delete = true );
} else {
return;
}
} else {
$this->ensureWikiPageExists();
$this->initSMWWriter();
}
$properties = $this->m_properties;
foreach ( $properties as $cur_prop ) {
$propertystring = $cur_prop['p'];
// TODO: Remove old code:
// $property = SMWPropertyValue::makeUserProperty( $propertystring );
$property_di = SMWDIProperty::newFromUserLabel($propertystring);
$valuestring = RDFIOUtils::sanitizeSMWValue( $cur_prop['v'] );
$value = SMWDataValueFactory::newPropertyObjectValue( $property_di, $valuestring );
$propertyErrorText = $property->getErrorText();
$propertyHasError = ( $propertyErrorText != '' );
if ( $propertyHasError ) {
$this->addError( "<p>In RDFIOPageHandler::writeOrDeleteDataToWiki(): " . $property->getErrorText() . "</p>" );
}
$valueErrorText = $value->getErrorText();
$valueHasError = ( $valueErrorText != '' );
if ( $valueHasError ) {
$this->addError( "<p>Error creating property value object in RDFIOPageHandler::writeOrDeleteDataToWiki():</p><p>" . $value->getErrorText() . "</p>" );
}
if ( $delete ) {
$this->m_smwwriter_remove->addPropertyObjectValue( $property, $value );
$editmessage = "Deleting properties. Last property delete: " . $propertystring . " : " . $valuestring;
} else {
$this->m_smwwriter_add->addPropertyObjectValue( $property, $value );
$editmessage = "Importing properties. Last property added: " . $propertystring . " : " . $valuestring;
}
}
$this->m_smwwriter->update( $this->m_smwwriter_remove, $this->m_smwwriter_add, $editmessage );
$smwWriterError = $this->m_smwwriter->getError();
$smwWriterHasError = ( $smwWriterError != '' );
if ( $smwWriterHasError ) {
$this->addError( "<p>SMWWriter Error: " . $smwWriterError . "</p>" );
}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:53,代码来源:PageHandler.php
示例16: saclInitProperties
function saclInitProperties()
{
// Read restriction properties
SMWDIProperty::registerProperty('___VISIBLE', '_str', wfMsgForContent('sacl-property-visibility'));
SMWDIProperty::registerProperty('___VISIBLE_WL_GROUP', '_str', wfMsgForContent('sacl-property-visibility-wl-group'));
SMWDIProperty::registerProperty('___VISIBLE_WL_USER', '_wpg', wfMsgForContent('sacl-property-visibility-wl-user'));
SMWDIProperty::registerPropertyAlias('___VISIBLE', 'Visible to');
SMWDIProperty::registerPropertyAlias('___VISIBLE_WL_GROUP', 'Visible to group');
SMWDIProperty::registerPropertyAlias('___VISIBLE_WL_USER', 'Visible to user');
// Write restriction properties
SMWDIProperty::registerProperty('___EDITABLE', '_str', wfMsgForContent('sacl-property-editable'));
SMWDIProperty::registerProperty('___EDITABLE_WL_GROUP', '_str', wfMsgForContent('sacl-property-editable-wl-group'));
SMWDIProperty::registerProperty('___EDITABLE_WL_USER', '_wpg', wfMsgForContent('sacl-property-editable-wl-user'));
SMWDIProperty::registerPropertyAlias('___EDITABLE_BY', 'Editable by');
SMWDIProperty::registerPropertyAlias('___EDITABLE_WL_GROUP', 'Editable by group');
SMWDIProperty::registerPropertyAlias('___EDITABLE_WL_USER', 'Editable by user');
return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:18,代码来源:SemanticACL.php
示例17: getProperties
/**
* Get an array key => value of genealogical properties as SMWDIProperty
* @throws MWException
*/
public static function getProperties()
{
static $properties;
if ($properties !== null) {
return $properties;
}
global $wgGenealogicalProperties, $wgOut;
$properties = array();
if (!is_array($wgGenealogicalProperties)) {
throw new MWException('Configuration variable $wgGenealogicalProperties must be an array !');
}
foreach ($wgGenealogicalProperties as $key => $value) {
if ($value) {
$properties[$key] = SMWDIProperty::newFromUserLabel($value);
}
}
return $properties;
}
开发者ID:Wilkins,项目名称:mediawiki-extensions-SemanticGenealogy,代码行数:22,代码来源:SemanticGenealogy.body.php
示例18: sespInitProperties
/**
* @brief Initializes all properties, hooks into smwInitProperties.
*
* @return true
*/
public static function sespInitProperties()
{
// Page author
SMWDIProperty::registerProperty('___EUSER', '_wpg', wfMsgForContent('sesp-property-author'));
SMWDIProperty::registerPropertyAlias('___EUSER', 'Page author');
// Page creator
SMWDIProperty::registerProperty('___CUSER', '_wpg', wfMsgForContent('sesp-property-first-author'));
SMWDIProperty::registerPropertyAlias('___CUSER', 'Page creator');
// Revision ID
SMWDIProperty::registerProperty('___REVID', '_num', wfMsgForContent('sesp-property-revision-id'));
SMWDIProperty::registerPropertyAlias('___REVID', 'Revision ID');
//View count
SMWDIProperty::registerProperty('___VIEWS', '_num', wfMsgForContent('sesp-property-view-count'));
SMWDIProperty::registerPropertyAlias('___VIEWS', 'Number of page views');
//Sub pages
SMWDIProperty::registerProperty('___SUBP', '_wpg', wfMsgForContent('sesp-property-subpages'));
SMWDIProperty::registerPropertyAlias('___SUBP', 'Subpage');
//Number of revisions
SMWDIProperty::registerProperty('___NREV', '_num', wfMsgForContent('sesp-property-revisions'));
SMWDIProperty::registerPropertyAlias('___NREV', 'Number of revisions');
//Number of talk page revisions
SMWDIProperty::registerProperty('___NTREV', '_num', wfMsgForContent('sesp-property-talk-revisions'));
SMWDIProperty::registerPropertyAlias('___NTREV', 'Number of talk page revisions');
// MIME type
SMWDIProperty::registerProperty('___MIMETYPE', '_str', wfMsgForContent('sesp-property-mimetype'));
SMWDIProperty::registerPropertyAlias('___MIMETYPE', 'MIME type');
// MIME type
SMWDIProperty::registerProperty('___MEDIATYPE', '_str', wfMsgForContent('sesp-property-mediatype'));
SMWDIProperty::registerPropertyAlias('___MEDIATYPE', 'Media type');
// SHORTURL type
SMWDIProperty::registerProperty('___SHORTURL', '_uri', wfMsgForContent('sesp-property-shorturl'));
SMWDIProperty::registerPropertyAlias('___SHORTURL', 'Short URL');
// METADATA types
SMWDIProperty::registerProperty('___EXIFDATETIME', '_dat', wfMsgForContent('exif-datetimeoriginal'));
SMWDIProperty::registerPropertyAlias('___EXIFDATETIME', 'Exposure date');
SMWDIProperty::registerProperty('___EXIFSOFTWARE', '_str', wfMsgForContent('exif-software'));
SMWDIProperty::registerPropertyAlias('___EXIFSOFTWARE', 'Software');
return true;
}
开发者ID:nischayn22,项目名称:Semantic-Extra-Special-Properties,代码行数:44,代码来源:SemanticExtraSpecialProperties.hooks.php
示例19: getPropertyTables
/**
* Return the array of predefined property table declarations, initialising
* it if necessary. The result is an array of SMWSQLStore3Table objects
* indexed by table ids.
*
* It is ensured that the keys of the returned array agree with the name of
* the table that they refer to.
*
* @since 1.8
* @return SMWSQLStore3Table[]
*/
public static function getPropertyTables()
{
if (isset(self::$prop_tables)) {
return self::$prop_tables;
// Don't initialise twice.
}
/**
* @var SMWSQLStore3Table[] $propertyTables
*/
$propertyTables = array();
//tables for each DI type
foreach (self::$di_type_tables as $tableDIType => $tableName) {
$propertyTables[$tableName] = new SMWSQLStore3Table($tableDIType, $tableName);
}
//tables for special properties
foreach (self::$special_tables as $propertyKey) {
$typeId = SMWDIProperty::getPredefinedPropertyTypeId($propertyKey);
$diType = SMWDataValueFactory::getDataItemId($typeId);
$tableName = 'smw_fpt' . strtolower($propertyKey);
$propertyTables[$tableName] = new SMWSQLStore3Table($diType, $tableName, $propertyKey);
}
// Redirect table uses another subject scheme for historic reasons
// TODO This should be changed if possible
$propertyTables['smw_fpt_redi']->setUsesIdSubject(false);
// Get all the tables for the properties that are declared as fixed
// (overly used and thus having separate tables)
foreach (self::$fixedProperties as $propertyKey => $tableDIType) {
$tableName = 'smw_fpt_' . md5($propertyKey);
$propertyTables[$tableName] = new SMWSQLStore3Table($tableDIType, $tableName, $propertyKey);
}
wfRunHooks('SMWPropertyTables', array(&$propertyTables));
self::$prop_tables = $propertyTables;
// Build index for finding property tables
self::$fixedPropertyTableIds = array();
foreach (self::$prop_tables as $tid => $propTable) {
if ($propTable->isFixedPropertyTable()) {
self::$fixedPropertyTableIds[$propTable->getFixedProperty()] = $tid;
}
}
// Specifically set properties that must not be stored in any
// property table to null here. Any function that hits this
// null unprepared is doing something wrong anyway.
self::$fixedPropertyTableIds['_SKEY'] = null;
return self::$prop_tables;
}
开发者ID:seedbank,项目名称:old-repo,代码行数:56,代码来源:SMW_SQLStore3.php
示例20: getPropertySubjects
/**
* @see SMWStore::getPropertySubjects
*
* @param SMWDIProperty $property
* @param mixed $value SMWDataItem or null
* @param SMWRequestOptions $requestoptions
*
* @return array of SMWDIWikiPage
*/
public function getPropertySubjects(SMWDIProperty $property, $value, $requestoptions = null)
{
/// TODO: should we share code with #ask query computation here? Just use queries?
wfProfileIn("SMWSQLStore3::getPropertySubjects (SMW)");
if ($property->isInverse()) {
// inverses are working differently
$noninverse = new SMWDIProperty($property->getKey(), false);
$result = $this->getPropertyValues($value, $noninverse, $requestoptions);
wfProfileOut("SMWSQLStore3::getPropertySubjects (SMW)");
return $result;
}
// First build $select, $from, and $where for the DB query
$where = $from = '';
$pid = $this->store->smwIds->getSMWPropertyID($property);
$tableid = SMWSQLStore3::findPropertyTableID($property);
if ($pid == 0 || $tableid === '') {
wfProfileOut("SMWSQLStoreLight::getPropertySubjects (SMW)");
return array();
}
$proptables = SMWSQLStore3::getPropertyTables();
$proptable = $proptables[$tableid];
$db = wfGetDB(DB_SLAVE);
if ($proptable->idsubject) {
// join in smw_ids to get title data
$from = $db->tableName('smw_ids') . " INNER JOIN " . $db->tableName($proptable->name) . " AS t1 ON t1.s_id=smw_id";
$select = 'smw_title, smw_namespace, smw_sortkey, smw_iw, smw_subobject';
} else {
// no join needed, title+namespace as given in proptable
$from = $db->tableName($proptable->name) . " AS t1";
$select = 's_title AS smw_title, s_namespace AS smw_namespace, s_title AS smw_sortkey, \'\' AS smw_iw, \'\' AS smw_subobject';
}
if ($proptable->fixedproperty == false) {
$where .= ($where ? ' AND ' : '') . "t1.p_id=" . $db->addQuotes($pid);
}
$this->prepareValueQuery($from, $where, $proptable, $value, 1);
// *** Now execute the query and read the results ***//
$result = array();
$res = $db->select($from, 'DISTINCT ' . $select, $where . $this->store->getSQLConditions($requestoptions, 'smw_sortkey', 'smw_sortkey', $where !== ''), 'SMW::getPropertySubjects', $this->store->getSQLOptions($requestoptions, 'smw_sortkey'));
foreach ($res as $row) {
try {
if ($row->smw_iw === '' || $row->smw_iw[0] != ':') {
// filter special objects
$result[] = new SMWDIWikiPage($row->smw_title, $row->smw_namespace, $row->smw_iw, $row->smw_subobject);
}
} catch (SMWDataItemException $e) {
// silently drop data, should be extremely rare and will usually fix itself at next edit
}
}
$db->freeResult($res);
wfProfileOut("SMWSQLStore3::getPropertySubjects (SMW)");
return $result;
}
开发者ID:nischayn22,项目名称:SemanticMediawiki,代码行数:61,代码来源:SMW_SQLStore3_Readers.php
注:本文中的SMWDIProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论