Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialProperties.php |
— | — | @@ -67,30 +67,39 @@ |
68 | 68 | function formatResult( $skin, $result ) { |
69 | 69 | $typestring = ''; |
70 | 70 | $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 | + } |
71 | 77 | if ( $result[0]->isUserDefined() && ( $result[1] <= 5 ) ) { |
72 | 78 | $errors[] = wfMsg( 'smw_propertyhardlyused' ); |
73 | 79 | } |
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' ) ); |
76 | 82 | if ( count( $types ) >= 1 ) { |
77 | | - $typestring = current( $types )->getLongHTMLText( $skin ); |
| 83 | + $typeDataValue = SMWDataValueFactory::newDataItemValue( current( $types ) ); |
| 84 | + $typestring = $typeDataValue->getLongHTMLText( $skin ); |
78 | 85 | } |
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 ) ) { |
81 | 88 | $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' ); |
83 | 90 | } else { // predefined property |
84 | 91 | $type = $result[0]->getTypesValue(); |
85 | 92 | $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 |
87 | 94 | $proplink = $result[0]->getLongHTMLText( $skin ); |
88 | 95 | } |
89 | 96 | 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 ); |
95 | 104 | } |
96 | 105 | } |
97 | 106 | 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 @@ |
155 | 155 | * relates to this property, or null if no such page exists. The latter |
156 | 156 | * can happen for special properties without user-readable label, and |
157 | 157 | * for inverse properties. |
| 158 | + * |
| 159 | + * @return SMWDIWikiPage or null |
158 | 160 | */ |
159 | 161 | public function getDiWikiPage() { |
160 | 162 | if ( $this->m_inverse ) return null; |