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


PHP SMWDIProperty::isInverse方法代码示例

本文整理汇总了PHP中SMWDIProperty::isInverse方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWDIProperty::isInverse方法的具体用法?PHP SMWDIProperty::isInverse怎么用?PHP SMWDIProperty::isInverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMWDIProperty的用法示例。


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

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

示例2: 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("SMWSQLStore2::getPropertySubjects (SMW)");
     if ($property->isInverse()) {
         // inverses are working differently
         $noninverse = new SMWDIProperty($property->getKey(), false);
         $result = $this->getPropertyValues($value, $noninverse, $requestoptions);
         wfProfileOut("SMWSQLStore2::getPropertySubjects (SMW)");
         return $result;
     }
     // First build $select, $from, and $where for the DB query
     $where = $from = '';
     $pid = $this->getSMWPropertyID($property);
     $tableid = self::findPropertyTableID($property);
     if ($pid == 0 || $tableid === '') {
         wfProfileOut("SMWSQLStore::getPropertySubjects (SMW)");
         return array();
     }
     $proptables = self::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->getSQLConditions($requestoptions, 'smw_sortkey', 'smw_sortkey', $where !== ''), 'SMW::getPropertySubjects', $this->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("SMWSQLStore2::getPropertySubjects (SMW)");
     return $result;
 }
开发者ID:nischayn22,项目名称:SemanticMediawiki,代码行数:61,代码来源:SMW_SQLStore2.php

示例3: getPropertySubjects

 /**
  * @see SMWStore::getPropertySubjects
  *
  * @todo This method cannot retrieve subjects for sortkeys, i.e., for
  * property _SKEY. Only empty arrays will be returned there.
  *
  * @param SMWDIProperty $property
  * @param SMWDataItem|null $value
  * @param SMWRequestOptions|null $requestOptions
  *
  * @return array of DIWikiPage
  */
 public function getPropertySubjects(SMWDIProperty $property, SMWDataItem $value = null, SMWRequestOptions $requestOptions = null)
 {
     /// TODO: should we share code with #ask query computation here? Just use queries?
     if ($property->isInverse()) {
         // inverses are working differently
         $noninverse = new SMW\DIProperty($property->getKey(), false);
         $result = $this->getPropertyValues($value, $noninverse, $requestOptions);
         return $result;
     }
     // #1222, Filter those where types don't match (e.g property = _txt
     // and value = _wpg)
     if ($value !== null && DataTypeRegistry::getInstance()->getDataItemId($property->findPropertyTypeID()) !== $value->getDIType()) {
         return array();
     }
     // First build $select, $from, and $where for the DB query
     $where = $from = '';
     $pid = $this->store->smwIds->getSMWPropertyID($property);
     $tableid = $this->store->findPropertyTableID($property);
     if ($pid == 0 || $tableid === '') {
         return array();
     }
     $proptables = $this->store->getPropertyTables();
     $proptable = $proptables[$tableid];
     $db = $this->store->getConnection();
     if ($proptable->usesIdSubject()) {
         // join with ID table to get title data
         $from = $db->tableName(SMWSql3SmwIds::TABLE_NAME) . " INNER JOIN " . $db->tableName($proptable->getName()) . " AS t1 ON t1.s_id=smw_id";
         $select = 'smw_title, smw_namespace, smw_iw, smw_sortkey, smw_subobject';
     } else {
         // no join needed, title+namespace as given in proptable
         $from = $db->tableName($proptable->getName()) . " AS t1";
         $select = 's_title AS smw_title, s_namespace AS smw_namespace, \'\' AS smw_iw, s_title AS smw_sortkey, \'\' AS smw_subobject';
     }
     if (!$proptable->isFixedPropertyTable()) {
         $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();
     if (!$proptable->isFixedPropertyTable()) {
         if ($where !== '' && strpos(SMW_SQL3_SMWIW_OUTDATED, $where) === false) {
             $where .= " AND smw_iw!=" . $db->addQuotes(SMW_SQL3_SMWIW_OUTDATED) . " AND smw_iw!=" . $db->addQuotes(SMW_SQL3_SMWDELETEIW);
         } else {
             $where .= " smw_iw!=" . $db->addQuotes(SMW_SQL3_SMWIW_OUTDATED) . " AND smw_iw!=" . $db->addQuotes(SMW_SQL3_SMWDELETEIW);
         }
     }
     $res = $db->select($from, 'DISTINCT ' . $select, $where . $this->store->getSQLConditions($requestOptions, 'smw_sortkey', 'smw_sortkey', $where !== ''), __METHOD__, $this->store->getSQLOptions($requestOptions, 'smw_sortkey'));
     $diHandler = $this->store->getDataItemHandlerForDIType(SMWDataItem::TYPE_WIKIPAGE);
     foreach ($res as $row) {
         try {
             if ($row->smw_iw === '' || $row->smw_iw[0] != ':') {
                 // filter special objects
                 $result[] = $diHandler->dataItemFromDBKeys(array_values((array) $row));
             }
         } catch (DataItemHandlerException $e) {
             // silently drop data, should be extremely rare and will usually fix itself at next edit
         }
     }
     $db->freeResult($res);
     return $result;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:73,代码来源:SMW_SQLStore3_Readers.php

示例4: newPropertyObjectValue

 /**
  * Create a value for the given property, provided as an SMWDIProperty
  * object. If no value is given, an empty container is created, the
  * value of which can be set later on.
  *
  * @param $property SMWDIProperty property object for which this value is made
  * @param $valueString mixed user value string, or false if unknown
  * @param $caption mixed user-defined caption, or false if none given
  * @param $contextPage SMWDIWikiPage that provides a context for parsing the value string, or null
  *
  * @return SMWDataValue
  */
 public static function newPropertyObjectValue(SMWDIProperty $property, $valueString = false, $caption = false, $contextPage = null)
 {
     $typeId = $property->isInverse() ? '_wpg' : $property->findPropertyTypeID();
     return self::newTypeIdValue($typeId, $valueString, $caption, $property, $contextPage);
 }
开发者ID:yusufchang,项目名称:app,代码行数:17,代码来源:SMW_DataValueFactory.php

示例5: removePropertyObjectValue

 /**
  * Remove a value for a property identified by its SMWDataItem object.
  * This method removes a property-value specified by the property and
  * dataitem. If there are no more property-values for this property it
  * also removes the property from the mProperties.
  *
  * @note There is no check whether the type of the given data item
  * agrees with the type of the property. Since property types can
  * change, all parts of SMW are prepared to handle mismatched data item
  * types anyway.
  *
  * @param $property SMWDIProperty
  * @param $dataItem SMWDataItem
  *
  * @since 1.8
  */
 public function removePropertyObjectValue(SMWDIProperty $property, SMWDataItem $dataItem)
 {
     //delete associated subSemanticData
     if ($dataItem instanceof SMWDIContainer) {
         $this->removeSubSemanticData($dataItem->getSemanticData());
         $dataItem = $dataItem->getSemanticData()->getSubject();
     }
     if ($property->isInverse()) {
         // inverse properties cannot be used for annotation
         return;
     }
     if (!array_key_exists($property->getKey(), $this->mPropVals) || !array_key_exists($property->getKey(), $this->mProperties)) {
         return;
     }
     if ($this->mNoDuplicates) {
         //this didn't get checked for my tests, but should work
         unset($this->mPropVals[$property->getKey()][$dataItem->getHash()]);
     } else {
         foreach ($this->mPropVals[$property->getKey()] as $index => $di) {
             if ($di->equals($dataItem)) {
                 unset($this->mPropVals[$property->getKey()][$index]);
             }
         }
         $this->mPropVals[$property->getKey()] = array_values($this->mPropVals[$property->getKey()]);
     }
     if ($this->mPropVals[$property->getKey()] === array()) {
         unset($this->mProperties[$property->getKey()]);
         unset($this->mPropVals[$property->getKey()]);
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:46,代码来源:SMW_SemanticData.php

示例6: getPropertySubjects

 public function getPropertySubjects(SMWDIProperty $property, $value, $requestoptions = null)
 {
     wfProfileIn("SMWSQLStoreLight::getPropertySubjects (SMW)");
     if ($property->isInverse()) {
         // inverses are working differently
         $noninverse = clone $property;
         $noninverse->setInverse(false);
         $result = $this->getPropertyValues($value, $noninverse, $requestoptions);
         wfProfileOut("SMWSQLStoreLight::getPropertySubjects (SMW)");
         return $result;
     }
     // ***  First build $select, $from, and $where for the DB query  ***//
     $tablename = SMWSQLStoreLight::findPropertyTableName($property);
     $db = wfGetDB(DB_SLAVE);
     $from = $db->tableName('page') . " AS p INNER JOIN " . $db->tableName($tablename) . " AS t ON t.pageid=p.page_id";
     $where = 't.propname=' . $db->addQuotes($property->getDBkey());
     if ($value !== null) {
         $valuestring = $tablename == 'smwsimple_special' ? reset($value->getDBkeys()) : serialize($value->getDBkeys());
         $where .= ' AND t.value=' . $db->addQuotes($valuestring);
     }
     $select = array('p.page_title AS title', 'p.page_namespace AS namespace');
     // ***  Now execute the query and read the results  ***//
     $result = array();
     $res = $db->select($from, $select, $where . $this->getSQLConditions($requestoptions, 'p.page_title', 'p.page_title'), 'SMW::getPropertySubjects', $this->getSQLOptions($requestoptions, 'p.page_title') + array('DISTINCT'));
     foreach ($res as $row) {
         $result[] = SMWWikiPageValue::makePage($row->title, $row->namespace, $row->title);
     }
     $db->freeResult($res);
     wfProfileOut("SMWSQLStoreLight::getPropertySubjects (SMW)");
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:SMW_SQLStoreLight.php

示例7: addPropertyObjectValue

 /**
  * Store a value for a property identified by its SMWDataItem object.
  *
  * @note There is no check whether the type of the given data item
  * agrees with the type of the property. Since property types can
  * change, all parts of SMW are prepared to handle mismatched data item
  * types anyway.
  *
  * @param $property SMWDIProperty
  * @param $dataItem SMWDataItem
  */
 public function addPropertyObjectValue(SMWDIProperty $property, SMWDataItem $dataItem)
 {
     if ($property->isInverse()) {
         // inverse properties cannot be used for annotation
         return;
     }
     if (!array_key_exists($property->getKey(), $this->mPropVals)) {
         $this->mPropVals[$property->getKey()] = array();
         $this->mProperties[$property->getKey()] = $property;
     }
     if ($this->mNoDuplicates) {
         $this->mPropVals[$property->getKey()][$dataItem->getHash()] = $dataItem;
     } else {
         $this->mPropVals[$property->getKey()][] = $dataItem;
     }
     if (!$property->isUserDefined()) {
         if ($property->isShown()) {
             $this->mHasVisibleSpecs = true;
             $this->mHasVisibleProps = true;
         }
     } else {
         $this->mHasVisibleProps = true;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:SMW_SemanticData.php

示例8: addPropertyObjectChange

 /**
  * Store a value for a property identified by its SMWDataItem object.
  *
  * @note There is no check whether the type of the given data item
  * agrees with the type of the property. Since property types can
  * change, all parts of SMW are prepared to handle mismatched data item
  * types anyway.
  *
  * @param SMWDIProperty $property
  * @param SWLPropertyChange $change
  */
 public function addPropertyObjectChange(SMWDIProperty $property, SWLPropertyChange $change)
 {
     if ($property->isInverse()) {
         // inverse properties cannot be used for annotation
         return;
     }
     if (!array_key_exists($property->getKey(), $this->changes)) {
         $this->changes[$property->getKey()] = array();
         $this->properties[$property->getKey()] = $property;
     }
     $this->changes[$property->getKey()][] = $change;
     $this->hasChanges = true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:24,代码来源:SWL_PropertyChanges.php

示例9: getPropertyValues

 /**
  * Get the array of all stored values for some property.
  *
  * @since 1.8
  *
  * @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)) {
         // Not catching exception here; the
         $this->unstubProperty($property->getKey(), $property);
         $propertyTypeId = $property->findPropertyTypeID();
         $propertyDiId = SMWDataValueFactory::getDataItemId($propertyTypeId);
         foreach ($this->mStubPropVals[$property->getKey()] as $dbkeys) {
             try {
                 $diHandler = $this->store->getDataItemHandlerForDIType($propertyDiId);
                 $di = $diHandler->dataItemFromDBKeys($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,代码行数:37,代码来源:SMW_Sql3StubSemanticData.php


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