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


PHP SMWPropertyValue类代码示例

本文整理汇总了PHP中SMWPropertyValue的典型用法代码示例。如果您正苦于以下问题:PHP SMWPropertyValue类的具体用法?PHP SMWPropertyValue怎么用?PHP SMWPropertyValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: makeProperty

 /**
  * Static function for creating a new property object from a property
  * identifier (string) as it might be used internally. This might be
  * the DB key version of some property title text or the id of a
  * predefined property (such as '_TYPE').
  * @note This function strictly requires an internal identifier, i.e.
  * predefined properties must be referred to by their ID, and '-' is
  * not supported for indicating inverses.
  * @note The resulting property object might be invalid if
  * the provided name is not allowed. An object is returned
  * in any case.
  */
 public static function makeProperty($propertyid)
 {
     $diProperty = new SMWDIProperty($propertyid);
     $dvProperty = new SMWPropertyValue('__pro');
     $dvProperty->setDataItem($diProperty);
     return $dvProperty;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:19,代码来源:SMW_DV_Property.php

示例2: 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");
     if (class_exists('SMWDIProperty')) {
         // SMW 1.6+
         $propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
         $this->mPropertyType = $propValue->findPropertyTypeID();
     } else {
         $propValue = SMWPropertyValue::makeUserProperty($this->mSemanticProperty);
         $this->mPropertyType = $propValue->getPropertyTypeID();
     }
     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:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:SF_TemplateField.php

示例3: printoutFromString

	public static function printoutFromString( $printout ) {
		return new SMWPrintRequest(
			SMWPrintRequest::PRINT_PROP,
			$printout,
			SMWPropertyValue::makeUserProperty( $printout )
		);
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:ApiAskArgs.php

示例4: addPropertyValueToSemanticData

 protected static function addPropertyValueToSemanticData($propertyName, $valueString, $semanticData)
 {
     $propertyDv = SMWPropertyValue::makeUserProperty($propertyName);
     $propertyDi = $propertyDv->getDataItem();
     self::addPropertyDiValueToSemanticData($propertyDi, $valueString, $semanticData);
     return $propertyDi;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:SMW_Subobject.php

示例5: processParameters

 /**
  * Read and interpret the given parameters.
  *
  * @since 1.8
  * @param string $query from the web request as given by MW
  */
 protected function processParameters($query)
 {
     global $wgRequest;
     // get the GET parameters
     $params = SMWInfolink::decodeParameters($query, false);
     reset($params);
     $inputPropertyString = $wgRequest->getText('property', current($params));
     $inputValueString = $wgRequest->getText('value', next($params));
     $inputValueString = str_replace(' ', ' ', $inputValueString);
     $inputValueString = str_replace(' ', ' ', $inputValueString);
     $this->property = SMWPropertyValue::makeUserProperty($inputPropertyString);
     if (!$this->property->isValid()) {
         $this->propertystring = $inputPropertyString;
         $this->value = null;
         $this->valuestring = $inputValueString;
     } else {
         $this->propertystring = $this->property->getWikiValue();
         $this->value = SMWDataValueFactory::newPropertyObjectValue($this->property->getDataItem(), $inputValueString);
         $this->valuestring = $this->value->isValid() ? $this->value->getWikiValue() : $inputValueString;
     }
     $limitString = $wgRequest->getVal('limit');
     if (is_numeric($limitString)) {
         $this->limit = intval($limitString);
     } else {
         $this->limit = 20;
     }
     $offsetString = $wgRequest->getVal('offset');
     if (is_numeric($offsetString)) {
         $this->offset = intval($offsetString);
     } else {
         $this->offset = 0;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:39,代码来源:SMW_SpecialSearchByProperty.php

示例6: testCheckIfPropertyRenamed

 function testCheckIfPropertyRenamed()
 {
     // do some checks
     $page = Title::newFromText("5 cylinder", NS_MAIN);
     $prop = SMWPropertyValue::makeUserProperty("Torsional moment");
     $values = smwfGetStore()->getPropertyValues($page, $prop);
     $this->assertTrue(count($values) > 0);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:8,代码来源:TestWikiJobResults.php

示例7: registerSpecialProperties

 /**
  * Registers all special properties of this extension in Semantic Media Wiki.
  *
  * The language files of the ExtTab extension contain a mapping from special
  * property constants to their string representation. These mappings are
  * added to the mapping defined by Semantic Media Wiki.
  */
 function registerSpecialProperties()
 {
     global $smwgContLang;
     foreach ($this->smwSpecialProperties as $key => $prop) {
         list($typeid, $label) = $prop;
         SMWPropertyValue::registerProperty($key, $typeid, $label, true);
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:ET_Language.php

示例8: setXMLAttribute

	public function setXMLAttribute( $key, $value ) {
		if ( $value == '' ) throw new MWException( __METHOD__ . ": value cannot be empty" );

		if ( $key == 'name' ) {
			$property = SMWPropertyValue::makeUserProperty( $value );
		} else {
			throw new MWException( __METHOD__ . ": invalid key/value pair: name=property_name" );
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:9,代码来源:WOM_OM_NestProperty.php

示例9: render

 /**
  * Method for handling the declare parser function.
  * 
  * @since 1.5.3
  * 
  * @param Parser $parser
  * @param PPFrame $frame
  * @param array $args
  */
 public static function render(Parser &$parser, PPFrame $frame, array $args)
 {
     if ($frame->isTemplate()) {
         foreach ($args as $arg) {
             if (trim($arg) !== '') {
                 $expanded = trim($frame->expand($arg));
                 $parts = explode('=', $expanded, 2);
                 if (count($parts) == 1) {
                     $propertystring = $expanded;
                     $argumentname = $expanded;
                 } else {
                     $propertystring = $parts[0];
                     $argumentname = $parts[1];
                 }
                 $property = SMWPropertyValue::makeUserProperty($propertystring);
                 $argument = $frame->getArgument($argumentname);
                 $valuestring = $frame->expand($argument);
                 if ($property->isValid()) {
                     $type = $property->getPropertyTypeID();
                     if ($type == '_wpg') {
                         $matches = array();
                         preg_match_all('/\\[\\[([^\\[\\]]*)\\]\\]/u', $valuestring, $matches);
                         $objects = $matches[1];
                         if (count($objects) == 0) {
                             if (trim($valuestring) !== '') {
                                 SMWParseData::addProperty($propertystring, $valuestring, false, $parser, true);
                             }
                         } else {
                             foreach ($objects as $object) {
                                 SMWParseData::addProperty($propertystring, $object, false, $parser, true);
                             }
                         }
                     } elseif (trim($valuestring) !== '') {
                         SMWParseData::addProperty($propertystring, $valuestring, false, $parser, true);
                     }
                     // $value = SMWDataValueFactory::newPropertyObjectValue( $property->getDataItem(), $valuestring );
                     // if (!$value->isValid()) continue;
                 }
             }
         }
     } else {
         // @todo Save as metadata
     }
     global $wgTitle;
     if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($parser);
     }
     return '';
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:61,代码来源:SMW_Declare.php

示例10: newPropertyPrintRequest

 /**
  * @since 2.1
  *
  * @param DIProperty $property
  *
  * @return PrintRequest
  */
 public function newPropertyPrintRequest(DIProperty $property)
 {
     $propertyValue = new PropertyValue('__pro');
     $propertyValue->setDataItem($property);
     $instance = new PrintRequest(PrintRequest::PRINT_PROP, $propertyValue->getWikiValue(), $propertyValue);
     return $instance;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:14,代码来源:PrintRequestFactory.php

示例11: searchForResultsThatCompareEqualToClassOf

 private function searchForResultsThatCompareEqualToClassOf($categoryName)
 {
     $propertyValue = new PropertyValue('__pro');
     $propertyValue->setDataItem(new DIProperty('_INST'));
     $description = new ClassDescription(new DIWikiPage($categoryName, NS_CATEGORY, ''));
     $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
     $query = new Query($description, false, false);
     $query->querymode = Query::MODE_INSTANCES;
     return $this->getStore()->getQueryResult($query);
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:10,代码来源:CategoryClassQueryDBIntegrationTest.php

示例12: searchForResultsThatCompareEqualToOnlySingularPropertyOf

 private function searchForResultsThatCompareEqualToOnlySingularPropertyOf(DIProperty $property)
 {
     $propertyValue = new PropertyValue('__pro');
     $propertyValue->setDataItem($property);
     $description = new SomeProperty($property, new ThingDescription());
     $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
     $query = new Query($description);
     $query->querymode = Query::MODE_INSTANCES;
     return $this->getStore()->getQueryResult($query);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:10,代码来源:GeneralQueryDBIntegrationTest.php

示例13: testSetLabel

 public function testSetLabel()
 {
     $propertyValue = new PropertyValue('__pro');
     $propertyValue->setDataItem(new DIProperty('Foo'));
     $instance = new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue);
     $this->assertEquals(null, $instance->getLabel());
     $this->assertEquals(null, $instance->getWikiText());
     $instance->setLabel('Bar');
     $this->assertEquals('Bar', $instance->getLabel());
     $this->assertEquals('Bar', $instance->getWikiText());
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:11,代码来源:PrintRequestTest.php

示例14: getValue

 private function getValue($value, $escaped)
 {
     $this->value = DataValueFactory::getInstance()->newDataValueByProperty($this->property->getDataItem());
     $value = $this->unescape($value, $escaped);
     $this->value->setUserValue($value);
     return $this->value->isValid() ? $this->value->getWikiValue() : $value;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:7,代码来源:PageRequestOptions.php

示例15: testUserDefinedBlobProperty

 public function testUserDefinedBlobProperty()
 {
     $property = new DIProperty('SomeBlobProperty');
     $property->setPropertyTypeId('_txt');
     $dataItem = new DIBlob('SomePropertyBlobValue');
     $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
     $semanticData->addDataValue($this->dataValueFactory->newDataItemValue($dataItem, $property));
     $this->getStore()->updateData($semanticData);
     $this->assertArrayHasKey($property->getKey(), $this->getStore()->getSemanticData($semanticData->getSubject())->getProperties());
     $propertyValue = new PropertyValue('__pro');
     $propertyValue->setDataItem($property);
     $description = new SomeProperty($property, new ThingDescription());
     $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
     $query = new Query($description, false, false);
     $query->querymode = Query::MODE_INSTANCES;
     $queryResult = $this->getStore()->getQueryResult($query);
     $this->queryResultValidator->assertThatQueryResultContains($dataItem, $queryResult);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:18,代码来源:BlobPropertyValueQueryDBIntegrationTest.php


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