Erweiterung:Semantic Rating

This page is a translated version of the page Extension:Semantic Rating and the translation is 100% complete.
MediaWiki-Erweiterungen
Semantic Rating
Freigabestatus: stabil
Einbindung Benutzer-Schnittstelle, Parser-Funktion
Beschreibung Adds three parser functions to display a star rating.
Autor(en) Cindy Cicalese (cindy.cicaleseDiskussion)
Letzte Version 4.0.1 (2019-04-19)
Kompatibilitätspolitik Der Master behält die Abwärtskompatibilität bei.
MediaWiki 1.25+
PHP 5.3+
Datenbankänderungen Nein
Lizenz MIT-Lizenz
Herunterladen

  • $wgSemanticRating_DefaultMax
  • $wgSemanticRating_CSSSelector
Übersetze die Semantic Rating-Erweiterung, wenn sie auf translatewiki.net verfügbar ist
Probleme Offene Aufgaben · Einen Fehler melden

Die Erweiterung Semantic Rating fügt drei Parser-Funktionen zur Anzeige einer Sternebewertung hinzu:

  • #rating - zeigt eine Bewertungszeile an
  • #ratingBeforeTitle - zeigt oben auf der Seite links neben dem Titel eine Bewertung an
  • #ratingAfterTitle - zeigt eine Bewertung rechts vom Titel oben auf der Seite an

Die Parserfunktionen sind in der Lage, leere (graue), volle (gelbe) und halbe Sterne darzustellen.

By default, the #ratingBeforeTitle and #ratingAfterTitle parser functions will insert the rating in the title at the top of a page for any skin that puts the title in an HTML element with id firstHeading such as the default Vector skin. This can be changed for other skins using the $wgSemanticRating_CSSSelector configuration variable. This approach can also be used to have the rating appear at other places in the page by using a <div> and appropriate choice of $wgSemanticRating_CSSSelector.

Special thanks to Bernadette Clemente for the original idea that inspired this extension and to Kelly Hatfield for an early implementation of this extension.

Installation

  • Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens SemanticRating im Ordner extensions/ ablegen.
    Entwickler und Code-Beitragende sollten stattdessen die Erweiterung von Git installieren, mit:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/SemanticRating
  • Folgenden Code am Ende deiner LocalSettings.php -Datei einfügen:
    wfLoadExtension( 'SemanticRating' );
    
  • Configure as required.
  •   Erledigt – Navigiere zu Special:Version in deinem Wiki, um zu überprüfen, ob die Erweiterung erfolgreich installiert wurde.

Konfiguration

Flag Default Description
$wgSemanticRating_DefaultMax 5 Holds the default value for the maximum value of a rating (that is, the total number of stars that will be displayed). If the maximum value is not explicitly set in the parser function invocation, SemanticRating_DefaultMax will be used.
$wgSemanticRating_CSSSelector "#firstHeading" Specifies the CSS selector that will be used to locate the page title. The Vector skin uses #firstHeading. The Foreground skin uses h2.title.

Beispiele

Anzeigen einer Bewertung

The following displays a 3 star rating inline using the default maximum number of stars:

{{#rating:3}}

If the default maximum is 5, it will display 3 yellow stars and 2 gray stars. If the default maximum is 10, it will display 3 yellow stars and 7 gray stars.

To explicitly set the maximum number of stars to 10, use the following:

{{#rating:3|10}}

To display the rating at the top of the page with the page title instead, use (again with an optional maximum value):

{{#ratingBeforeTitle:3}}

or

{{#ratingAfterTitle:3}}

Anzeige einer Zahl als Fünf-Sterne-Bewertung

 

Darstellung des Ergebnisses einer semantischen Abfrage als Fünf-Sterne-Bewertung

While SemanticRating does not require Semantic MediaWiki to be installed, the two extensions do work well togther. Semantic Rating also works well with Cargo. For example, below are several more advanced examples that illustrate how this extension can be used with Semantic MediaWiki.

Consider the case where users can review a wiki page. In this example, each review is itself a wiki page in category Reviews. Each review page has a property, Item, that is a link to the page being reviewed. Each review page also has a property, Rating, that has a value between 1 and 5 (with 0 being reserved for the case where no rating is assigned).

On the page being reviewed, the page's average rating can be displayed by the following query:

{{#rating: {{#ask: [[Category:Reviews]] [[Item::{{FULLPAGENAME}}]] |?Rating |format=average }} }}

Further, assume that each page being reviewed has a property, Author, pointing to a page for the author of the page being reviewed. On the author's page, using the ParserFunctions and Arrays extensions, the average rating for all pages authored by that author (an average of the average page ratings) can be displayed by the following:

 {{#arraydefine: ratings
   |{{#arraymap:
     {{#ask: [[Author::{{FULLPAGENAME}}]] [[Category:Items]] |link=none }}
     |,
     |@@@@
     |{{#ask: [[Item::@@@@]] [[Category:Reviews]] |?Rating |format=average }}
   }}
 }}
 {{#rating: {{#expr: {{#expr: {{#arrayprint: ratings |+ }} }} / {{#arraysize: ratings }} }} }}

Release Notes

Version 4.0.1
  • Added check that parser function parameter is numeric
Version 4.0
  • Removed form input, since it is now part of the Page Forms extension; this extension no longer requires Page Forms to be installed
Version 3.0
  • Removed use of inline JavaScript that caused issues in MediaWiki 1.26
  • Converted to new extension registration style
  • Removed support for old style i18n and extension registration
  • Renamed configuration variables with $wg prefix to support new extension registration format
Version 2.2.1
  • Minor changes: improved coding style, several internal tweaks, license to show on "Special:Version"
Version 2.2
  • Added $SemanticRating_CSSSelector and updated coding style.