• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP SMWDataValueFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __construct

	public function __construct( $property, $value, $caption = '' ) {
		parent::__construct( WOM_TYPE_PROPERTY );

		if ( !defined( 'SMW_VERSION' ) ) {
			// MW hook will catch this exception
			throw new MWException( __METHOD__ . ": Property model is invalid. Please install 'SemanticMediaWiki extension' first." );
		}

		$user_property = SMWPropertyValue::makeUserProperty( $property );
		if ( count ( $user_property->getErrors() ) > 0 ) {
			$user_property = SMWPropertyValue::makeUserProperty( '///NA///' );
		} else {
			$property = '';
		}
		$smwdatavalue = null;
		// FIXME: property should be collection object according to templates
		// if template/field used
		if ( preg_match ( '/\{\{.+\}\}/s', $value . $caption ) ) {
			$value = $value . ( $caption == '' ? '' : "|{$caption}" );
			$caption = '';
		} else {
			if ( version_compare ( SMW_VERSION, '1.6', '>=' ) ) {
				$smwdatavalue = SMWDataValueFactory::newPropertyObjectValue( $user_property->getDataItem(), $value, $caption );
			} else {
				$smwdatavalue = SMWDataValueFactory::newPropertyObjectValue( $user_property, $value, $caption );
			}
			if ( count ( $smwdatavalue->getErrors() ) > 0 ) {
				$smwdatavalue = null;
			}
		}

		$this->m_user_property = $user_property;
		$this->m_smwdatavalue = $smwdatavalue;
		$this->m_property = $property;
		$this->m_value = $value;
		$this->m_caption = $caption;
		$this->m_visible = !preg_match( '/^\s+$/', $caption );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:38,代码来源:WOM_OM_Property.php


示例17: getPropertyHTML

 /**
  * Creates and returns the HTML representatation of the property and it's changes.
  * 
  * @since 0.1
  * 
  * @param SMWDIProperty $property
  * @param array $changes
  * 
  * @return string
  */
 protected static function getPropertyHTML(SMWDIProperty $property, array $changes)
 {
     $insertions = array();
     $deletions = array();
     // Convert the changes into a list of insertions and a list of deletions.
     foreach ($changes as $change) {
         if (!is_null($change->getOldValue())) {
             $deletions[] = SMWDataValueFactory::newDataItemValue($change->getOldValue(), $property)->getShortHTMLText();
         }
         if (!is_null($change->getNewValue())) {
             $insertions[] = SMWDataValueFactory::newDataItemValue($change->getNewValue(), $property)->getShortHTMLText();
         }
     }
     $lines = array();
     if (count($insertions) > 0) {
         $lines[] = Html::element('span', array(), wfMsg('swl-watchlist-insertions')) . ' ' . implode(', ', $insertions);
     }
     if (count($deletions) > 0) {
         $lines[] = Html::element('span', array(), wfMsg('swl-watchlist-deletions')) . ' ' . implode(', ', $deletions);
     }
     $html = Html::element('b', array(), $property->getLabel());
     $html .= Html::rawElement('div', array('class' => 'swl-prop-div'), implode('<br />', $lines));
     return $html;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:SWL_Emailer.php


示例18: execute

 public function execute()
 {
     global $wgDBtype;
     if ($this->hasOption('setup')) {
         $store = new SMWSQLStore3();
         // Lets do a drop to ensure the user doesn't has any Store3 tables already (happens when running this script twice)
         $tables = array('smw_stats');
         foreach (SMWSQLStore3::getPropertyTables() as $proptable) {
             $tables[] = $proptable->name;
         }
         $dbw = wfGetDB(DB_MASTER);
         foreach ($tables as $table) {
             $name = $dbw->tableName($table);
             $dbw->query('DROP TABLE ' . ($wgDBtype == 'postgres' ? '' : 'IF EXISTS ') . $name, 'SMWMigrate::drop');
         }
         $store->setup();
         //enter user defined properties into smw_stats (internal ones are handled by setup already )
         $query = 'Replace into ' . $dbw->tableName('smw_stats') . ' (pid,usage_count) Select smw_id,0 from ' . $dbw->tableName('smw_ids') . ' where smw_namespace = ' . SMW_NS_PROPERTY . ' and smw_iw = "" ';
         $dbw->query($query, 'SMWMigrate:commandLine');
     } elseif ($this->hasOption('migrate')) {
         $options = array();
         if ($this->hasArg(0)) {
             if ($this->hasArg(1)) {
                 $options['LIMIT'] = $this->getArg(0);
                 $options['OFFSET'] = $this->getArg(1);
             }
         }
         $dbw = wfGetDB(DB_MASTER);
         $oldStore = new SMWSQLStore2();
         $newStore = new SMWSQLStore3();
         $proptables = SMWSQLStore3::getPropertyTables();
         //get properties
         $res = $dbw->select('smw_ids', array('smw_id', 'smw_title', 'smw_namespace'), array('smw_namespace' => SMW_NS_PROPERTY), __METHOD__, $options);
         foreach ($res as $row) {
             $property = new SMWDIProperty($row->smw_title);
             echo 'Now migrating data for Property ' . $property->getLabel() . " into Store3 \n";
             //get the table
             $tableId = SMWSQLStore3::findPropertyTableID($property);
             $proptable = $proptables[$tableId];
             //get the DIHandler
             $dataItemId = SMWDataValueFactory::getDataItemId($property->findPropertyTypeId());
             $diHandler = $newStore->getDataItemHandlerForDIType($dataItemId);
             $subjects = $oldStore->getPropertySubjects($property, null);
             $insertions = array();
             foreach ($subjects as $subject) {
                 $sid = $newStore->makeSMWPageID($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $subject->getSubobjectName(), true, str_replace('_', ' ', $subject->getDBkey()) . $subject->getSubobjectName());
                 //now prepare udpates
                 $propvals = $oldStore->getPropertyValues($subject, $property);
                 $uvals = $proptable->idsubject ? array('s_id' => $sid) : array('s_title' => $subject->getDBkey(), 's_namespace' => $subject->getNamespace());
                 if ($proptable->fixedproperty == false) {
                     $uvals['p_id'] = $newStore->makeSMWPropertyID($property);
                 }
                 foreach ($propvals as $propval) {
                     $uvals = array_merge($uvals, $diHandler->getInsertValues($propval));
                     $insertions[] = $uvals;
                 }
             }
             // now write to the DB for all subjects (is this too much?)
             $dbw->insert($proptable->name, $insertions, "SMW::migrate{$proptable->name}");
         }
         $dbw->freeResult($res);
     } else {
         echo "Sorry I refuse to work without any options currently";
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:65,代码来源:SMW_migration.php


示例19: findAllDiTypeTableIds

 /**
  * Find the id of all property tables where data items of the given
  * type could possibly be stored.
  *
  * @param $dataItemId integer
  * @return array of string
  */
 public static function findAllDiTypeTableIds($dataItemId)
 {
     $result = array(self::findDiTypeTableId($dataItemId));
     foreach (self::$special_tables as $specialTableId) {
         if ($dataItemId == SMWDataValueFactory::getDataItemId($dataItemId)) {
             $result[] = $specialTableId;
         }
     }
     return $result;
 }
开发者ID:nischayn22,项目名称:SemanticMediawiki,代码行数:17,代码来源:SMW_SQLStore2.php


示例20: 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 .= '&#160;&#160;&#160;&#160; <b>' . wfMsg('smw_result_results') . ' ' . ($offset + 1) . '– ' . ($offset + min(count($results), $limit)) . '</b>&#160;&#160;&#160;&#160;';
             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 .= ' &#160;' . $browselink->getHTML($linker);
                 }
                 $html .= "</li> \n";
             }
             $html .= "</ul>\n";
         }
         $html .= $navigation;
     }
     // Display query form
     $spectitle = $this->getTitle();
     $html .= '<p>&#160;</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) . '" />' . "&#160;&#160;&#160;\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!
 }
开发者ID:yusufchang,项目名称:app,代码行数:96,代码来源:SMW_SpecialPageProperty.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP SMWExporter类代码示例发布时间:2022-05-23
下一篇:
PHP SMWDataItem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap