r85428 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85427‎ | r85428 | r85429 >
Date:08:03, 5 April 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
SMWTypesValue now uses SMWWikiPageValue directly, with the same dataitem. Storage backends can still store DBkeys only for property types on their own behalf, but the new design will not hardwire this in the datamodel. In particular, types in RDF stores should rather be URIs than strings.

SMWSimpleWikiPagevalue is obsolete and will vanish before SMW 1.6.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_SimpleWikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Types.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_SimpleWikiPage.php
@@ -13,6 +13,8 @@
1414 * advantage of the reduction of data is that these important values can be
1515 * stored in smaller tables that allow for faster direct access than general
1616 * page type values.
 17+ *
 18+ * @deprecated This auxiliary class will vanish in SMW 1.6
1719 *
1820 * @author Markus Krötzsch
1921 * @ingroup SMWDataValues
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php
@@ -6,7 +6,13 @@
77
88 /**
99 * This datavalue implements special processing suitable for defining
10 - * wikipages as values of properties. In contrast to most other types
 10+ * wikipages as values of properties.
 11+ *
 12+ * The class can support general wiki pages, or pages of a fixed
 13+ * namespace, Whether a namespace is fixed is decided based on the
 14+ * type ID when the object is constructed.
 15+ *
 16+ * In contrast to most other types
1117 * of values, wiki pages are determined by multiple components, as
1218 * retruned by their getDBkeys() method: DBkey, namespace, interwiki
1319 * prefix and sortkey. The last of those has a somewhat nonstandard
@@ -155,12 +161,12 @@
156162 }
157163
158164 protected function parseDBkeys( $args ) {
159 - if ( count( $args ) != 4 ) {
 165+ if ( count( $args ) < 3 ) {
160166 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
161167 $this->addError( wfMsgForContent( 'smw_notitle', $this->getPrefixedText() ) );
162168 $this->m_dataitem = new SMWDIWikiPage( 'ERROR', NS_MAIN, '', $this->m_typeid );
163169 } else {
164 - $this->m_dataitem = new SMWDIWikiPage( $args[0], floatval( $args[1] ), $args[2], $args[3], $this->m_typeid );
 170+ $this->m_dataitem = new SMWDIWikiPage( $args[0], floatval( $args[1] ), $args[2], $this->m_typeid );
165171 $this->m_textform = str_replace( '_', ' ', $this->m_dataitem->getDBkey() );
166172 $this->m_id = -1;
167173 $this->m_title = null;
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Types.php
@@ -6,7 +6,7 @@
77
88 /**
99 * This datavalue implements special processing suitable for defining types of
10 - * properties. Types behave largely like values of type SMWSimpleWikiPageValue
 10+ * properties. Types behave largely like values of type SMWWikiPageValue
1111 * with three main differences. First, they actively check if a value is an
1212 * alias for another type, modifying the internal representation accordingly.
1313 * Second, they have a modified display for emphasizing if some type is defined
@@ -16,7 +16,7 @@
1717 * @author Markus Krötzsch
1818 * @ingroup SMWDataValues
1919 */
20 -class SMWTypesValue extends SMWSimpleWikiPageValue {
 20+class SMWTypesValue extends SMWWikiPageValue {
2121
2222 private $m_isalias; // record whether this is an alias to another type, used to avoid duplicates when listing page types
2323 protected $m_reallabel;
@@ -28,7 +28,8 @@
2929 }
3030
3131 protected function parseDBkeys( $args ) {
32 - parent::parseDBkeys( array( str_replace( ' ', '_', SMWDataValueFactory::findTypeLabel( $args[0] ) ) ) );
 32+ $pagedbkey = str_replace( ' ', '_', SMWDataValueFactory::findTypeLabel( $args[0] ) );
 33+ parent::parseDBkeys( array( $pagedbkey, $this->m_fixNamespace, '', $this->m_typeid ) );
3334 $this->m_reallabel = $this->m_textform;
3435 $this->m_isalias = false;
3536 }
@@ -87,18 +88,20 @@
8889 }
8990
9091 public function getWikiValue() {
91 - return implode( '; ', $this->getTypeLabels() );
 92+ $this->unstub();
 93+ return $this->m_reallabel;
9294 }
9395
9496 public function getHash() {
95 - return implode( "\t", $this->getTypeLabels() );
 97+ $this->unstub();
 98+ return $this->m_reallabel;
9699 }
97100
98101 /**
99102 * This class uses type ids as DB keys.
100103 */
101104 public function getDBkey() {
102 - return ( $this->isValid() ) ? SMWDataValueFactory::findTypeID( $this->m_reallabel ):'';
 105+ return ( $this->isValid() ) ? SMWDataValueFactory::findTypeID( $this->m_reallabel ) : '';
103106 }
104107
105108 /**
@@ -107,7 +110,7 @@
108111 */
109112 public function isBuiltIn() {
110113 $v = $this->getDBkey();
111 - return ( ( $this->isUnary() ) && ( $v { 0 } == '_' ) );
 114+ return ( $v { 0 } == '_' );
112115 }
113116
114117 /**
@@ -119,38 +122,5 @@
120123 return $this->m_isalias;
121124 }
122125
123 - /**
124 - * Retrieve type labels if needed. Can be done lazily.
125 - */
126 - public function getTypeLabels() {
127 - $this->unstub();
128 - return array( $this->m_reallabel );
129 - }
130 -
131 - /**
132 - * Retrieve type captions if needed. Can be done lazily. The captions
133 - * are different from the labels if type aliases are used.
134 - */
135 - public function getTypeCaptions() {
136 - $this->unstub();
137 - return array( $this->m_textform );
138 - }
139 -
140 - /**
141 - * Retrieve type values.
142 - * @deprecated This method is no longer meaningful and will vanish before SMW 1.6
143 - */
144 - public function getTypeValues() {
145 - return array( $this );
146 - }
147 -
148 - /**
149 - * Is this a simple unary type or some composed n-ary type?
150 - * @deprecated This method is no longer meaningful and will vanish before SMW 1.6
151 - */
152 - public function isUnary() {
153 - return true;
154 - }
155 -
156126 }
157127

Status & tagging log