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


PHP SMWDataValueFactory类代码示例

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


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

示例1: 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

示例2: getIncomingProperties

 /**
  * Gets the set of all properties that point to this page, anywhere
  * in the wiki.
  */
 static function getIncomingProperties($title)
 {
     $store = smwfGetStore();
     // SMW 1.6+
     if (class_exists('SMWDataItem')) {
         $value = SMWDIWikiPage::newFromTitle($title);
     } else {
         $title_text = SFUtils::titleString($title);
         $value = SMWDataValueFactory::newTypeIDValue('_wpg', $title_text);
     }
     $properties = $store->getInProperties($value);
     $propertyNames = array();
     foreach ($properties as $property) {
         // SMW 1.6+
         if ($property instanceof SMWDIProperty) {
             $property_name = $property->getKey();
         } else {
             $property_name = $property->getWikiValue();
         }
         if (!empty($property_name)) {
             $propertyNames[] = $property_name;
         }
     }
     return $propertyNames;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:29,代码来源:SF_FormLinker.php

示例3: getTypeProperties

 protected function getTypeProperties($typeLabel)
 {
     global $wgRequest, $smwgTypePagingLimit;
     if ($smwgTypePagingLimit <= 0) {
         return '';
     }
     // not too useful, but we comply to this request
     $from = $wgRequest->getVal('from');
     $until = $wgRequest->getVal('until');
     $typeValue = SMWDataValueFactory::newTypeIDValue('__typ', $typeLabel);
     $store = smwfGetStore();
     $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until);
     $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options);
     if (!$options->ascending) {
         $diWikiPages = array_reverse($diWikiPages);
     }
     $result = '';
     if (count($diWikiPages) > 0) {
         $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until);
         $title = $this->getTitleFor('Types', $typeLabel);
         $title->setFragment('#SMWResults');
         // Make navigation point to the result list.
         $navigation = $pageLister->getNavigationLinks($title);
         $resultNumber = min($smwgTypePagingLimit, count($diWikiPages));
         $typeName = $typeValue->getLongWikiText();
         $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMsg('smw_type_header', $typeName) . "</h2>\n<p>" . wfMsgExt('smw_typearticlecount', array('parsemag'), $resultNumber) . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>";
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:29,代码来源:SMW_SpecialTypes.php

示例4: 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

示例5: getPropertyValues

 /**
  * Get the array of all stored values for some property.
  *
  * @param $property SMWDIProperty
  * @return array of SMWDataItem
  */
 public function getPropertyValues(SMWDIProperty $property)
 {
     if ($property->isInverse()) {
         // we never have any data for inverses
         return array();
     }
     if (array_key_exists($property->getKey(), $this->mStubPropVals)) {
         $this->unstubProperty($property->getKey(), $property);
         $propertyTypeId = $property->findPropertyTypeID();
         $propertyDiId = SMWDataValueFactory::getDataItemId($propertyTypeId);
         foreach ($this->mStubPropVals[$property->getKey()] as $dbkeys) {
             try {
                 if ($propertyDiId == SMWDataItem::TYPE_CONTAINER) {
                     $diSubWikiPage = SMWCompatibilityHelpers::dataItemFromDBKeys('_wpg', $dbkeys);
                     $semanticData = new SMWContainerSemanticData($diSubWikiPage);
                     $semanticData->copyDataFrom(smwfGetStore()->getSemanticData($diSubWikiPage));
                     $di = new SMWDIContainer($semanticData);
                 } else {
                     $di = SMWCompatibilityHelpers::dataItemFromDBKeys($propertyTypeId, $dbkeys);
                 }
                 if ($this->mNoDuplicates) {
                     $this->mPropVals[$property->getKey()][$di->getHash()] = $di;
                 } else {
                     $this->mPropVals[$property->getKey()][] = $di;
                 }
             } catch (SMWDataItemException $e) {
                 // ignore data
             }
         }
         unset($this->mStubPropVals[$property->getKey()]);
     }
     return parent::getPropertyValues($property);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:39,代码来源:SMW_SqlStubSemanticData.php

示例6: getQueryString

	/**
	 * @see SMWDescription:getQueryString
	 * 
	 * @since 0.6
	 * 
	 * @param Boolean $asValue
	 */
	public function getQueryString( $asValue = false ) {
		if ( $this->getDataItem() !== null ) {
			$queryString = SMWDataValueFactory::newDataItemValue( $this->getDataItem(), $this->m_property )->getWikiValue();
			return $asValue ? $queryString : "[[$queryString]]";
		} else {
			return $asValue ? '+' : '';
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:SM_AreaValueDescription.php

示例7: 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

示例8: 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]);
 }
开发者ID:yusufchang,项目名称:app,代码行数:16,代码来源:SMW_SpecialWantedProperties.php

示例9: 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

示例10: addPropertyDiValueToSemanticData

 protected static function addPropertyDiValueToSemanticData($propertyDi, $valueString, $semanticData)
 {
     if (!$propertyDi->isInverse()) {
         $valueDv = SMWDataValueFactory::newPropertyObjectValue($propertyDi, $valueString, false, $semanticData->getSubject());
         $semanticData->addPropertyObjectValue($propertyDi, $valueDv->getDataItem());
         // Take note of the error for storage (do this here and not in storage, thus avoiding duplicates).
         if (!$valueDv->isValid()) {
             $semanticData->addPropertyObjectValue(new SMWDIProperty('_ERRP'), $propertyDi->getDiWikiPage());
             self::$m_errors = array_merge(self::$m_errors, $valueDv->getErrors());
         }
     } else {
         self::$m_errors[] = wfMessage('smw_noinvannot')->inContentLanguage()->text();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:SMW_Subobject.php

示例11: 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);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:SMW_SpecialUnusedProperties.php

示例12: 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

示例13: storeQueryMetadata

 public function storeQueryMetadata($title, $query)
 {
     global $wgParser;
     // initialize a new semdata object and append it to parser output if this was not yet done.
     // the semdata object will then be stored to the db by smw at the end of the parse process
     if (!isset($wgParser->getOutput()->mSMWData)) {
         $wgParser->getOutput()->mSMWData = new SMWSemanticData(SMWWikiPageValue::makePageFromTitle($title));
     }
     $semanticData = $wgParser->getOutput()->mSMWData;
     $propertyValue = SMWPropertyValue::makeProperty('___QRC_UQC');
     $dataValue = SMWDataValueFactory::newTypeIDValue('_qcm');
     $dataValue->setQueryId($this->getQueryId($query));
     $dataValue->setQueryString($query->getQueryString());
     if ($query->getLimit()) {
         $dataValue->setQueryLimit($query->getLimit());
     }
     if ($query->getOffset()) {
         $dataValue->setQueryOffset($query->getOffset());
     }
     if ($query instanceof SMWSPARQLQuery) {
         $prProperties = $this->getPrintRequestsProperties($query->getExtraPrintouts());
         $dataValue->setExtraPropertyPrintouts(implode(';', array_keys($prProperties)));
         $dataValue->setExtraCategoryPrintouts($this->isCategoryRequestedInPrintRequests($query->getExtraPrintouts()));
         $dataValue->setIsSPQRQLQuery(true);
     } else {
         $dataValue->setIsSPQRQLQuery(false);
     }
     $properties = array();
     $categories = array();
     if ($query instanceof SMWSPARQLQuery) {
         list($properties, $categories) = $this->getSPARQLQueryParts($query);
     } else {
         if ($query instanceof SMWQuery) {
             list($properties, $categories) = $this->getQueryParts($query->getDescription());
         }
     }
     foreach ($properties as $p => $dontCare) {
         $dataValue->addPropertyDependency($p);
     }
     foreach ($categories as $c => $dontCare) {
         $dataValue->addCategoryDependency($c);
     }
     $semanticData->addPropertyObjectValue($propertyValue, $dataValue);
     $wgParser->getOutput()->mSMWData = $semanticData;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:45,代码来源:SMW_QRC_QueryManagementHandler.php

示例14: getResultText

 /**
  * (non-PHPdoc)
  * @see SMWResultPrinter::getResultText()
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $dataItems = $this->getSortKeys($res);
     if (empty($dataItems)) {
         return $this->params['default'];
     }
     $sortKeys = array_keys($dataItems);
     switch ($this->mFormat) {
         case 'latest':
             $result = max($sortKeys);
             break;
         case 'earliest':
             $result = min($sortKeys);
             break;
     }
     $dataValue = SMWDataValueFactory::newDataItemValue($dataItems[$result], null);
     return $dataValue->getLongHTMLText();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:SRF_Time.php

示例15: smwfGetStore

 /**
  *
  * Load all semantic properties of a page as a hash
  * @param String $pagename
  * @param Integer $namespace
  * @param Boolean $normalizeTitle
  * @return an associative array with the property name as key and property value as value.
  */
 public static function &loadSemanticProperties($pagename, $namespace = NS_MAIN, $normalizeTitle = true)
 {
     //-----normalize title
     $data = null;
     if ($normalizeTitle) {
         $title = MWUtil::normalizePageTitle($pagename, false);
         $di = SMWDIWikiPage::newFromTitle($title);
         $data = smwfGetStore()->getSemanticData($di);
     } else {
         $di = new SMWDIWikiPage($pagename, $namespace, '');
         $data = smwfGetStore()->getSemanticData($di);
     }
     $valuehash = array();
     $diProperties = $data->getProperties();
     foreach ($diProperties as $diProperty) {
         $dvProperty = SMWDataValueFactory::newDataItemValue($diProperty, null);
         $name = null;
         if ($dvProperty->isVisible()) {
             $name = $diProperty->getLabel();
         } elseif ($diProperty->getKey() == '_INST') {
             $name = 'Categories';
         } else {
             continue;
             // skip this line
         }
         if (!$name) {
             continue;
         }
         $values = $data->getPropertyValues($diProperty);
         $vs = array();
         foreach ($values as $di) {
             $dv = SMWDataValueFactory::newDataItemValue($di, $diProperty);
             $vs[] = $dv->getWikiValue();
         }
         if (count($vs) == 1) {
             $valuehash[$name] = $vs[0];
         } else {
             $valuehash[$name] = $vs;
         }
     }
     #error_log(print_r($valuehash, true));
     return $valuehash;
 }
开发者ID:kghbln,项目名称:semanticaccesscontrol,代码行数:51,代码来源:SMWUtil.php


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