Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialProperties.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | parent::__construct( 'Properties' ); |
19 | 19 | } |
20 | 20 | |
21 | | - public function execute( $param ) { |
| 21 | + public function execute( $param ) { |
22 | 22 | wfProfileIn( 'smwfDoSpecialProperties (SMW)' ); |
23 | 23 | |
24 | 24 | global $wgOut; |
— | — | @@ -55,50 +55,64 @@ |
56 | 56 | } |
57 | 57 | |
58 | 58 | function formatResult( $skin, $result ) { |
| 59 | + global $wgLang; |
59 | 60 | $linker = smwfGetLinker(); |
| 61 | + list ( $property, $useCount ) = $result; |
60 | 62 | |
61 | 63 | $typestring = ''; |
62 | 64 | $errors = array(); |
63 | 65 | |
64 | | - $diWikiPage = $result[0]->getDiWikiPage(); |
| 66 | + $diWikiPage = $property->getDiWikiPage(); |
65 | 67 | $title = !is_null( $diWikiPage ) ? $diWikiPage->getTitle() : null; |
66 | 68 | |
67 | | - if ( $result[0]->isUserDefined() && ( $result[1] <= 5 ) ) { |
68 | | - $errors[] = wfMsg( 'smw_propertyhardlyused' ); |
69 | | - } |
| 69 | + if ( $property->isUserDefined() ) { |
70 | 70 | |
71 | | - if ( $result[0]->isUserDefined() && !is_null( $title ) && $title->exists() ) { |
72 | | - $typeProperty = new SMWDIProperty( '_TYPE' ); |
73 | | - $types = smwfGetStore()->getPropertyValues( $diWikiPage, $typeProperty ); |
74 | | - if ( count( $types ) >= 1 ) { |
75 | | - $typeDataValue = SMWDataValueFactory::newDataItemValue( current( $types ), $typeProperty ); |
76 | | - $typestring = $typeDataValue->getLongHTMLText( $linker ); |
| 71 | + if ( $title === null ) { |
| 72 | + continue; |
77 | 73 | } |
78 | | - $proplink = $linker->link( $title, $result[0]->getLabel() ); |
79 | | - } elseif ( $result[0]->isUserDefined() && !is_null( $title ) ) { |
80 | | - $errors[] = wfMsg( 'smw_propertylackspage' ); |
81 | | - $proplink = $linker->makeBrokenLinkObj( $title, $result[0]->getLabel(), 'action=view' ); |
82 | | - } else { // predefined property |
83 | | - $typeid = $result[0]->findPropertyTypeID(); |
84 | | - $typeDataValue = SMWTypesValue::newFromTypeId( $typeid ); |
85 | | - $propertyDataValue = SMWDataValueFactory::newDataItemValue( $result[0], null ); |
86 | | - $typestring = $typeDataValue->getLongHTMLText( $linker ); |
87 | | - if ( $typestring === '' ) $typestring = '–'; /// FIXME some types of builtin props have no name, and another message should be used then |
88 | | - $proplink = $propertyDataValue->getLongHTMLText( $linker ); |
89 | | - } |
90 | 74 | |
91 | | - if ( $typestring === '' ) { |
| 75 | + if ( $useCount <= 5 ) { |
| 76 | + $errors[] = wfMsgHtml( 'smw_propertyhardlyused' ); |
| 77 | + } |
| 78 | + |
| 79 | + // User defined types default to Page |
92 | 80 | global $smwgPDefaultType; |
93 | | - |
94 | 81 | $typeDataValue = SMWTypesValue::newFromTypeId( $smwgPDefaultType ); |
95 | 82 | $typestring = $typeDataValue->getLongHTMLText( $linker ); |
96 | | - |
97 | | - if ( !is_null( $title ) && $title->exists() ) { // print only when we did not print a "nopage" warning yet |
98 | | - $errors[] = wfMsg( 'smw_propertylackstype', $typestring ); |
| 83 | + |
| 84 | + $label = htmlspecialchars( $property->getLabel() ); |
| 85 | + if ( $title->exists() ) { |
| 86 | + $typeProperty = new SMWDIProperty( '_TYPE' ); |
| 87 | + $types = smwfGetStore()->getPropertyValues( $diWikiPage, $typeProperty ); |
| 88 | + if ( count( $types ) >= 1 ) { |
| 89 | + $typeDataValue = SMWDataValueFactory::newDataItemValue( current( $types ), $typeProperty ); |
| 90 | + $typestring = $typeDataValue->getLongHTMLText( $linker ); |
| 91 | + } else { |
| 92 | + $errors[] = wfMsgHtml( 'smw_propertylackstype', $typestring ); |
| 93 | + } |
| 94 | + |
| 95 | + $proplink = $linker->link( $title, $label ); |
| 96 | + } else { |
| 97 | + $errors[] = wfMsgHtml( 'smw_propertylackspage' ); |
| 98 | + $proplink = $linker->link( $title, $label, array(), array( 'action' => 'view' ) ); |
99 | 99 | } |
| 100 | + |
| 101 | + } else { // predefined property |
| 102 | + $typeid = $property->findPropertyTypeID(); |
| 103 | + $typeDataValue = SMWTypesValue::newFromTypeId( $typeid ); |
| 104 | + $typestring = $typeDataValue->getLongHTMLText( $linker ); |
| 105 | + $propertyDataValue = SMWDataValueFactory::newDataItemValue( $property, null ); |
| 106 | + $proplink = $propertyDataValue->getShortHtmlText( $linker ); |
100 | 107 | } |
101 | 108 | |
102 | | - return wfMsg( 'smw_property_template', $proplink, $typestring, $result[1] ) . ' ' . smwfEncodeMessages( $errors, 'warning', ' <!--br-->', false ); |
| 109 | + $warnings = smwfEncodeMessages( $errors, 'warning', '', false ); |
| 110 | + |
| 111 | + $useCount = $wgLang->formatNum( $useCount ); |
| 112 | + if ( $typestring === '' ) { // Builtins have no type |
| 113 | + return wfMsgHtml( 'smw_property_template_notype', $proplink, $useCount ) . ' ' . $warnings; |
| 114 | + } else { |
| 115 | + return wfMsgHtml( 'smw_property_template', $proplink, $typestring, $useCount ) . ' ' . $warnings; |
| 116 | + } |
103 | 117 | } |
104 | 118 | |
105 | 119 | function getResults( $requestoptions ) { |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Types.php |
— | — | @@ -92,9 +92,9 @@ |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | | - public function getShortWikiText( $linked = null ) { |
| 96 | + public function getShortWikiText( $linker = null ) { |
97 | 97 | global $wgContLang; |
98 | | - if ( is_null( $linked ) || ( $linked === false ) || ( $this->m_outformat == '-' ) || ( $this->m_caption === '' ) ) { |
| 98 | + if ( !$linker || $this->m_outformat === '-' || $this->m_caption === '' ) { |
99 | 99 | return $this->m_caption; |
100 | 100 | } else { |
101 | 101 | $titleText = $this->getSpecialPageTitleText(); |
— | — | @@ -103,18 +103,18 @@ |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | | - public function getShortHTMLText( $linked = null ) { |
108 | | - if ( is_null( $linked ) || ( $linked === false ) || ( $this->m_outformat == '-' ) || ( $this->m_caption === '' ) ) { |
| 107 | + public function getShortHTMLText( $linker = null ) { |
| 108 | + if ( !$linker || $this->m_outformat === '-' || $this->m_caption === '' ) { |
109 | 109 | return htmlspecialchars( $this->m_caption ); |
110 | 110 | } else { |
111 | 111 | $title = Title::makeTitle( NS_SPECIAL, $this->getSpecialPageTitleText() ); |
112 | | - return $linked->makeLinkObj( $title, htmlspecialchars( $this->m_caption ) ); |
| 112 | + return $linker->link( $title, htmlspecialchars( $this->m_caption ) ); |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | | - public function getLongWikiText( $linked = null ) { |
| 116 | + public function getLongWikiText( $linker = null ) { |
117 | 117 | global $wgContLang; |
118 | | - if ( is_null( $linked ) || ( $linked === false ) ) { |
| 118 | + if ( !$linker || $this->m_realLabel === '' ) { |
119 | 119 | return $this->m_realLabel; |
120 | 120 | } else { |
121 | 121 | $titleText = $this->getSpecialPageTitleText(); |
— | — | @@ -124,11 +124,11 @@ |
125 | 125 | } |
126 | 126 | |
127 | 127 | public function getLongHTMLText( $linker = null ) { |
128 | | - if ( is_null( $linker ) || ( $linker === false ) ) { |
| 128 | + if ( !$linker || $this->m_realLabel === '' ) { |
129 | 129 | return htmlspecialchars( $this->m_realLabel ); |
130 | 130 | } else { |
131 | 131 | $title = Title::makeTitle( NS_SPECIAL, $this->getSpecialPageTitleText() ); |
132 | | - return $linker->makeLinkObj( $title, htmlspecialchars( $this->m_realLabel ) ); |
| 132 | + return $linker->link( $title, htmlspecialchars( $this->m_realLabel ) ); |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php |
— | — | @@ -187,6 +187,7 @@ |
188 | 188 | 'properties' => 'Properties', |
189 | 189 | 'smw_properties_docu' => 'The following properties are used in the wiki.', |
190 | 190 | 'smw_property_template' => '$1 of type $2 ($3)', // <propname> of type <type> (<count>) |
| 191 | + 'smw_property_template_notype' => '$1 ($2)', // <propname> (<count>) |
191 | 192 | 'smw_propertylackspage' => 'All properties should be described by a page!', |
192 | 193 | 'smw_propertylackstype' => 'No type was specified for this property (assuming type $1 for now).', |
193 | 194 | 'smw_propertyhardlyused' => 'This property is hardly used within the wiki!', |
— | — | @@ -506,6 +507,14 @@ |
507 | 508 | 'smw_smwadmin_announcedocu' => 'Do not alter or translate link targets', |
508 | 509 | 'smw-info-par-message' => 'Short description of the message parameter behaviour.', |
509 | 510 | 'smw-info-par-icon' => 'Short description of the icon parameter behaviour.', |
| 511 | + 'smw_property_template' => 'Used on [[Special:Properties]] |
| 512 | +* $1 link to Property page |
| 513 | +* $2 link to Type page |
| 514 | +* $3 Number of times the property is used', |
| 515 | + 'smw_property_template_notype' => 'Used on [[Special:Properties]] |
| 516 | +* $1 link to Property page |
| 517 | +* $2 Number of times the property is used', |
| 518 | + |
510 | 519 | ); |
511 | 520 | |
512 | 521 | /** Niuean (ko e vagahau Niuē) |