r86217 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86216‎ | r86217 | r86218 >
Date:16:53, 16 April 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
fixed special properties to use new data item system
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Property.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialProperties.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialProperties.php
@@ -67,30 +67,39 @@
6868 function formatResult( $skin, $result ) {
6969 $typestring = '';
7070 $errors = array();
 71+ $diWikiPage = $result[0]->getDiWikiPage();
 72+ if ( $diWikiPage !== null ) {
 73+ $title = Title::makeTitle( $diWikiPage->getNamespace(), $diWikiPage->getDBkey() );
 74+ } else {
 75+ $title = null;
 76+ }
7177 if ( $result[0]->isUserDefined() && ( $result[1] <= 5 ) ) {
7278 $errors[] = wfMsg( 'smw_propertyhardlyused' );
7379 }
74 - if ( $result[0]->isUserDefined() && $result[0]->getWikiPageValue()->getTitle()->exists() ) { // FIXME: this bypasses SMWDataValueFactory; ungood
75 - $types = smwfGetStore()->getPropertyValues( $result[0]->getDiWikiPage(), new SMWDIProperty( '_TYPE' ) );
 80+ if ( $result[0]->isUserDefined() && ( $title !== null ) && $title->exists() ) { // FIXME: this bypasses SMWDataValueFactory; ungood
 81+ $types = smwfGetStore()->getPropertyValues( $diWikiPage, new SMWDIProperty( '_TYPE' ) );
7682 if ( count( $types ) >= 1 ) {
77 - $typestring = current( $types )->getLongHTMLText( $skin );
 83+ $typeDataValue = SMWDataValueFactory::newDataItemValue( current( $types ) );
 84+ $typestring = $typeDataValue->getLongHTMLText( $skin );
7885 }
79 - $proplink = $skin->makeKnownLinkObj( $result[0]->getWikiPageValue()->getTitle(), $result[0]->getWikiValue() );
80 - } elseif ( $result[0]->isUserDefined() ) {
 86+ $proplink = $skin->makeKnownLinkObj( $title, $result[0]->getLabel() );
 87+ } elseif ( $result[0]->isUserDefined() && ( $title !== null ) ) {
8188 $errors[] = wfMsg( 'smw_propertylackspage' );
82 - $proplink = $skin->makeBrokenLinkObj( $result[0]->getWikiPageValue()->getTitle(), $result[0]->getWikiValue(), 'action=view' );
 89+ $proplink = $skin->makeBrokenLinkObj( $title, $result[0]->getLabel(), 'action=view' );
8390 } else { // predefined property
8491 $type = $result[0]->getTypesValue();
8592 $typestring = $type->getLongHTMLText( $skin );
86 - if ( $typestring == '' ) $typestring = '–'; /// FIXME some types o fbuiltin props have no name, and another message should be used then
 93+ if ( $typestring == '' ) $typestring = '–'; /// FIXME some types of builtin props have no name, and another message should be used then
8794 $proplink = $result[0]->getLongHTMLText( $skin );
8895 }
8996 if ( $typestring == '' ) {
90 - $type = SMWDataValueFactory::newPropertyObjectValue( new SMWDIProperty( '_TYPE' ) );
91 - $type->setDBkeys( array( '_wpg' ) );
92 - $typestring = $type->getLongHTMLText( $skin );
93 - if ( $result[0]->getWikiPageValue()->getTitle()->exists() ) { // print only when we did not print a "nopage" warning yet
94 - $errors[] = wfMsg( 'smw_propertylackstype', $type->getLongHTMLText() );
 97+ global $smwgPDefaultType;
 98+ $typepagedbkey = str_replace( ' ', '_', SMWDataValueFactory::findTypeLabel( $smwgPDefaultType ) );
 99+ $diTypePage = new SMWDIWikiPage( $typepagedbkey, SMW_NS_TYPE, '', '__typ' );
 100+ $dvTypePage = SMWDataValueFactory::newDataItemValue( $diTypePage );
 101+ $typestring = $dvTypePage->getLongHTMLText( $skin );
 102+ if ( ( $title !== null ) && ( $title->exists() ) ) { // print only when we did not print a "nopage" warning yet
 103+ $errors[] = wfMsg( 'smw_propertylackstype', $typestring );
95104 }
96105 }
97106 return wfMsg( 'smw_property_template', $proplink, $typestring, $result[1] ) . ' ' . smwfEncodeMessages( $errors );
Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Property.php
@@ -154,6 +154,8 @@
155155 * relates to this property, or null if no such page exists. The latter
156156 * can happen for special properties without user-readable label, and
157157 * for inverse properties.
 158+ *
 159+ * @return SMWDIWikiPage or null
158160 */
159161 public function getDiWikiPage() {
160162 if ( $this->m_inverse ) return null;

Status & tagging log