New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add property count to property pages #1313
Comments
@@ -1,9 +1,11 @@
<?php
use SMW\ApplicationFactory;
use SMW\DataValueFactory;
+use SMW\RequestOptions;
+use SMW\StringCondition;
@@ -54,23 +56,36 @@ class SMWPropertyPage extends SMWOrderedListPage {
*
* @return string
*/
protected function getTopText() {
+ $propertyName = htmlspecialchars( $this->mTitle->getText() );
+ $usageCount = '';
+
+ $requestOptions = new RequestOptions();
+ $requestOptions->limit = 1;
+ $requestOptions->addStringCondition( $propertyName, StringCondition::STRCOND_PRE );
+ $cachedLookupList = $this->store->getPropertiesSpecial( $requestOptions );
+ $usageList = $cachedLookupList->fetchList();
+
+ if ( $usageList && $usageList !== array() ) {
+ $usage = end( $usageList );
+ $usageCount = wfMessage( 'smw-pa-property-usage', $propertyName, $usage[1], $this->getContext()->getLanguage()->timeanddate( $cachedLookupList->getTimestamp() ) )->parse();
+ }
+
if ( !$this->mProperty->isUserDefined() ) {
- $propertyName = htmlspecialchars( $this->mTitle->getText() );
$propertyKey = 'smw-pa-property-predefined' . strtolower( $this->mProperty->getKey() );
$messageKey = wfMessage( $propertyKey )->exists() ? $propertyKey : 'smw-pa-property-predefined-default';
return Html::rawElement(
'div',
array( 'class' => 'smw-pa-property-predefined-intro' ),
- wfMessage( $messageKey, $propertyName )->parse() . ' ' . wfMessage( 'smw-pa-property-predefined-common' )->parse()
+ wfMessage( $messageKey, $propertyName )->parse() . ' ' . wfMessage( 'smw-pa-property-predefined-common' )->parse() . ' ' . $usageCount
);
}
- return '';
+ return $usageCount; + "smw-pa-property-usage": "\"$1\" is registered with an approximate [https://www.semantic-mediawiki.org/wiki/Help:Property_usage_count usage count] of '''$2''' ($3)." and you get |
References issue #1313 Code changes mainly provided by James Hong Kong. Thanks!
Not to forget: Kudos and thanks for helping on this one! |
@mwjames I know that the appearance of this was change in a subsequent pull plus the enhancement to show if it is defined by the software or the user (cannot find the pull). Is this behind a configuration setting since it does not show up on smw.o which is on 2.4? sandbox is fine |
We rely on [0] to be available with [1] checking if it is available. [0] https://www.mediawiki.org/wiki/Help:Page_status_indicators |
Ah, got it. Thanks! I have added this information. Also found the follow up commit. |
So far one has to add
{{#ask: [[{{PAGENAME}}::+]] |format= count }}
to property pages to see how many pages store values that are set for a specific property. If one wants to know how many values are stored for the property one has to proceed to "Special:Properties". I will perhaps be nice to have a system message not only showing the number of pages but also extending this to display the number of values set: Something like "A total of x values are set on a total of x pages for this property. This information was last recalculated on x at y.". Admittedly this is kinda gimmick.The text was updated successfully, but these errors were encountered: