Mwjames has uploaded a new change for review.
https://gerrit.wikimedia.org/r/67609
Change subject: Be more helpful and display an introductory text for predefined
properties
......................................................................
Be more helpful and display an introductory text for predefined properties
This is for users who barely know SMW (and for all others as well). It
will display an introductory text for all predefined properties and
links to smw.org allowing for easier access to available online resources.
It is also possible to maintain an individual text compenent for each
predefined property using the following message key
'smw-pa-property-predefined' + <internal property key> schema.
## Example
'smw-pa-property-predefined' + '_asksi' = smw-pa-property-predefined_asksi'
Change-Id: I029716a67302962e1b6e2d9a769c150b63d7da74
---
M SemanticMediaWiki.hooks.php
M includes/Setup.php
M includes/articlepages/ConceptPage.php
M includes/articlepages/SMW_OrderedListPage.php
M includes/articlepages/SMW_PropertyPage.php
M languages/SMW_Messages.php
6 files changed, 72 insertions(+), 3 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki
refs/changes/09/67609/1
diff --git a/SemanticMediaWiki.hooks.php b/SemanticMediaWiki.hooks.php
index 168a3e7..20675d3 100644
--- a/SemanticMediaWiki.hooks.php
+++ b/SemanticMediaWiki.hooks.php
@@ -122,6 +122,28 @@
}
/**
+ * Hook: Before displaying noarticletext or noarticletext-nopermission
messages.
+ *
+ * @see
http://www.mediawiki.org/wiki/Manual:Hooks/BeforeDisplayNoArticleText
+ *
+ * @since 1.9
+ *
+ * @param $article Article
+ *
+ * @return boolean
+ */
+ public static function onBeforeDisplayNoArticleText( $article ) {
+
+ // Avoid having "noarticletext" info being generated for
predefined
+ // properties as we are going to display an introductory text
+ if ( $article->getTitle()->getNamespace() === SMW_NS_PROPERTY )
{
+ return SMWDIProperty::newFromUserLabel(
$article->getTitle()->getText() )->isUserDefined();
+ }
+
+ return true;
+ }
+
+ /**
* This hook registers parser functions and hooks to the given parser.
It is
* called during SMW initialisation. Note that parser hooks are
something different
* than MW hooks in general, which explains the two-level registration.
diff --git a/includes/Setup.php b/includes/Setup.php
index 49ef38d..c535527 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -98,6 +98,7 @@
// Add changes to the output page
$wgHooks['BeforePageDisplay'][] = 'SMWHooks::onBeforePageDisplay';
+ $wgHooks['BeforeDisplayNoArticleText'][] =
'SMWHooks::onBeforeDisplayNoArticleText';
// ResourceLoader
$wgHooks['ResourceLoaderGetConfigVars'][] =
'SMWHooks::onResourceLoaderGetConfigVars';
diff --git a/includes/articlepages/ConceptPage.php
b/includes/articlepages/ConceptPage.php
index 407ddc4..42ca2d2 100644
--- a/includes/articlepages/ConceptPage.php
+++ b/includes/articlepages/ConceptPage.php
@@ -105,7 +105,7 @@
wfProfileOut( __METHOD__ . ' (SMW)' );
- return Html::element( 'a', array( 'name' => 'SMWResults' ) ,
null ) .
+ return Html::element( 'br', array( 'id' => 'smwfootbr' ) ) .
Html::element( 'a', array( 'name' => 'SMWResults' ) , null ) .
Html::rawElement( 'div', array( 'id' => 'mw-pages'),
Html::rawElement( 'h2', array(),
$this->getContext()->msg( 'smw_concept_header', $titleText )->text() ) .
Html::element( 'span', array(),
$this->getContext()->msg( 'smw_conceptarticlecount', $resultNumber )->parse() )
.
diff --git a/includes/articlepages/SMW_OrderedListPage.php
b/includes/articlepages/SMW_OrderedListPage.php
index 789a7a3..9e6e49e 100644
--- a/includes/articlepages/SMW_OrderedListPage.php
+++ b/includes/articlepages/SMW_OrderedListPage.php
@@ -80,7 +80,7 @@
$this->until = $wgRequest->getVal( 'until', '' );
if ( $this->initParameters() ) {
- $wgOut->addHTML( "<br id=\"smwfootbr\"/>\n" .
$this->getHtml() );
+ $wgOut->addHTML( $this->getHtml() );
SMWOutputs::commitToOutputPage( $wgOut );
}
diff --git a/includes/articlepages/SMW_PropertyPage.php
b/includes/articlepages/SMW_PropertyPage.php
index 0e15adc..4a73539 100644
--- a/includes/articlepages/SMW_PropertyPage.php
+++ b/includes/articlepages/SMW_PropertyPage.php
@@ -31,12 +31,43 @@
protected function getHtml() {
wfProfileIn( __METHOD__ . ' (SMW)' );
- $result = $this->getSubpropertyList() .
$this->getPropertyValueList();
+ $list = $this->getSubpropertyList() .
$this->getPropertyValueList();
+ $result = $this->getPredefinedPropertyIntro() . ( $list !== ''
? Html::element( 'br', array( 'id' => 'smwfootbr' ) ) . $list : '' );
wfProfileOut( __METHOD__ . ' (SMW)' );
return $result;
}
+
+ /**
+ * Returns an introductory text for a predefined property
+ *
+ * @note In order to enable a more detailed description for a specific
+ * predefined property a concatenated message key can be used (e.g
+ * 'smw-pa-property-predefined' + <internal property key> => '_asksi' )
+ *
+ * @since 1.9
+ *
+ * @return string
+ */
+ protected function getPredefinedPropertyIntro() {
+
+ if ( !$this->mProperty->isUserDefined() ) {
+
+ $propertyName = htmlspecialchars(
$this->mTitle->getText() );
+ $propertyKey = 'smw-pa-property-predefined' .
strtolower( $this->mProperty->getKey() );
+ $propertyText = wfMessage( $propertyKey )->exists() ? '
' . wfMessage( $propertyKey )->text() : '';
+
+ return Html::rawElement(
+ 'div',
+ array( 'class' =>
'smw-pa-property-predefined-intro' ),
+ wfMessage( 'smw-pa-property-predefined-intro',
$propertyName, $propertyText )->parse()
+ );
+ }
+
+ return '';
+ }
+
/**
* Get the HTML for displaying subproperties of this property. This list
* is usually short and we implement no additional navigation.
diff --git a/languages/SMW_Messages.php b/languages/SMW_Messages.php
index 2a6e08a..72b3fcb 100644
--- a/languages/SMW_Messages.php
+++ b/languages/SMW_Messages.php
@@ -442,6 +442,11 @@
// Query printer messages
'smw-qp-aggregatable-empty-data' => 'Requested aggregatable data could
not be displayed due to some insufficient selection criteria.',
+
+ // Property pages (Predefined properties)
+ 'smw-pa-property-predefined-intro' => '$1 is a predefined property
(also known as [https://www.semantic-mediawiki.org/wiki/Help:Special_properties
special property])$2. It is a built-in property that comes with additional
administrative privileges but can be used just like any other
[https://www.semantic-mediawiki.org/wiki/Property user-defined property].',
+ 'smw-pa-property-predefined_ask' => 'which links to the meta data
[https://www.semantic-mediawiki.org/wiki/Subobject subobject] of a query',
+ 'smw-pa-property-predefined_asksi' => 'which collects the number of
conditions used in a query'
);
/** Message documentation (Message documentation)
@@ -970,6 +975,16 @@
'smw_conceptarticlecount' => 'This is the introductory message below
the header on pages in namespace "Concept". Parameters:
* $1 holds the number of pages displayed in the current view.',
'smw-qp-aggregatable-empty-data' => 'An error message shown for
insufficient data.',
+
+ 'smw-pa-property-predefined-intro' => 'An introductory text for
predefined properties.
+
+Parameters:
+* $1 - Name of the invoked property
+* $2 - Additional text component for a detailed property description',
+
+ 'smw-pa-property-predefined_ask' => 'Additional text component which
describes a predefined property.',
+ 'smw-pa-property-predefined_asksi' => 'Additional text component which
describes a predefined property.',
+
);
/** Afrikaans (Afrikaans)
--
To view, visit https://gerrit.wikimedia.org/r/67609
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I029716a67302962e1b6e2d9a769c150b63d7da74
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits