Extension:SemanticTitle

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
SemanticTitle

Release status: beta

Implementation User interface, Parser function
Description Sets visible page title and link text to value of a page's semantic property.
Author(s) Van de Bugger, Cindy Cicalese
Latest version 1.3 (2014-07-25)
MediaWiki 1.18+
PHP 5.3+
Database changes No
License AGPLv3
Download
Parameters
  • $wgSemanticTitleProperties
  • $wgSemanticTitleHideSubtitle
Hooks used
BeforePageDisplay

LanguageGetMagic
LinkBegin
ParserFirstCallInit

Translate the SemanticTitle extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

The SemanticTitle extension sets visible page title to a value of semantic property.

For example, if page `Bug:32758' has semantic property `Title' with value `SMW handles timezones incorrectly', and SemanticTitle is properly installed and configured, visible page title will be `SMW handles timezones incorrectly', with subtitle `Bug:32758'.

Similarly, link to the page will be `SMW handles timezones incorrectly' with tooltip `Bug:32758'.

{{ #semantic-title: Bug:32758 }} returns `SMW handles timezones incorrectly' as plain text (not a link).

Rationale[edit | edit source]

Let us assume we are creating a bug tracking system based on MediaWiki. Semantic MediaWiki converts wiki into a database. Pages become objects or entities (e. g. bugs) with properties (e. g. title, submitter, severity, component, etc). We want every bug is identified by its number, assigned automatically. Semantic Forms allows it:

{{{info|page name=Bug:<unique number>}}}
{{{for template|Bug|...}}}
...

so every new bug receives unique identifier. Everything works, but bug page title will be `Bug:32758', links to this bug will also be `Bug:32758', while we want to see bug titles (set by user, not an id assigned by system) in page titles and links. This is the job for SemanticTitle extension.

Installation[edit | edit source]

Note Note: This extension requires Semantic MediaWiki to be installed first.


  • Download and extract the file(s) in a directory called SemanticTitle in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository using:
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/SemanticTitle.git
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/SemanticTitle/SemanticTitle.php";
  • Configure as required
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

Note Note: If this extension is used with the HidePrefix extension, SemanticTitle should be included before HidePrefix (SemanticTitle does not touch title if it was set to non-default value, e. g. processed by HidePrefix extension).

Configuration[edit | edit source]

In LocalSettings.php after including `SemanticTitle.php':

$wgSemanticTitleProperties = array( 
    NS1 => "Property name1",
    NS2 => "Property name2",
    ...
);

where:

  • NS# — Namespace index (not a namespace name!) (usually constant, like NS_USER). Only pages in specified namespaces are affected.
  • Property name# — Name of property to be used as title in the specified namespace.

You may also optionally set $wgSemanticTitleHideSubtitle to "true" to hide the subtitle that shows the "real" page title.

Upgrade Note: If you are upgrading from to version 1.0 from a previous version, you will need to replace $egSemanticTitle with $wgSemanticTitleProperties.

Usage[edit | edit source]

Being installed and configured, SemanticTitle handles page titles and links with no user intervention.

However, category listings may look ugly, because listings show semantic titles while pages are sorted in order of their actual titles. Use {{ DEFAULTSORT }} magic word to fix it, e. g.:

[[Title::title]]
{{ DEFAULTSORT: title }}

If you need semantic title of a page as plain text (not a link), use #semantic-title parser function:

{{ #semantic-title: Bug:32758 }}

Other extensions can call `SemanticTitle::getText( Title $title )' static function to get a semantic title by given title.

Release Notes[edit | edit source]

Version 1.3[edit | edit source]

  • Fixed bug that caused the page title not to be transformed on pages that use the LiquidThreads extension. This may also have affected other pages with title fragments.

Version 1.2[edit | edit source]

  • Added support for the SelfLinkBegin hook (Linker.php in MediaWiki core). This replaces self links on a page with the semantic title text as the link text.

Version 1.1.0[edit | edit source]

  • Remediated XSS vulnerability CVE-2014-2854.
  • Migrated to JSON i18n. Beginning with MediaWiki 1.23, translation strings are stored in JSON files, and the EXTENSION.i18n.php file only exists to provide compatibility with older releases of MediaWiki. For more information about this migration, see: https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format.

Caveats[edit | edit source]

  • SematicTitle overrides edit page title set by Semantic Forms (specified by `{{{info ...|edit title=...}}}' construct).

License[edit | edit source]

GNU Affero General Public License, version 3 or any later version. See AGPL-3.0.txt file for the full license text.

See also[edit | edit source]