Extension:Attribute

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Attribute Extension

Release status: unknown

Implementation Tag, Special page
Description Add attribute tag
Author(s) Xypron
Version 0.4 (10th February, 2007)
MediaWiki 1.8, 1.7.1, 1.5.8
Download http://xywattributeext.sourceforge.net



Contents

[edit] Why is this extension necessary?

Currently MediaWiki only allows the use of categories as attributes. These can only hold binary values:

  • 0: does not belong to category
  • 1: does belong to category

Real live attributes of articles can have arbitrary values:

  • authors: Meyer, Smith, Hu
  • comment: This is neat.
  • date of expiry: 2008-12-31

Furthermore data not only occurs as single values but also as datasets:

Example:

Mean average temperature [°C]
month= "1", value= "5.7"
month= "2", value= "5.8"
month= "3", value= "7.8"
month= "4", value="11.0"
month= "5", value="14.7"
month= "6", value="17.7"
month= "7", value="19.3"
month= "8", value="19.2"
month= "9", value="17.2"
month="10", value="14.0"
month="11", value="10.3"
month="12", value= "7.3"

A method to enter such data into MediaWiki in a retrievable way is needed.

[edit] What this extension does

[edit] Editing

A new tag attribute is defined.

<attribute comment="This is neat." />
<attribute author="Meyer" /><attribute author="Smith" /><attribute author="Hu" />
<attribute property="mean monthly temperature" month="11" value="10.3" unit="degC" />

The icon Image:attribute.png is added to the editor to create attribute tags.

Input of attributes in the editor

When saving changes the attribute values are written to a database table allowing SQL queries to

[edit] Attribute Tab

An attribute tab is added to the article page showing all attributes.

The attributes can be seen on the attributes tab.

[edit] Attribute query page

  • A special page for attribute queries is provided.
Form to specify query
Results for the query

[edit] Installation

[edit] Install files

require_once( "$IP/extensions/xyAttribute/xyAttribute.php");
$xyAttributePng = "/extensions/xyAttribute/attribute.png";
$xyAttributeMultipleValues = true;
  • Adjust pathes as necessary.

When $xyAttributeMultipleValues = true an attribute can have multiple values like:

<attribute author="Meyer" /><attribute author="Smith" /><attribute author="Hu" />

$xyAttributeMultipleValues = false signifies that only the last value shall be used.

[edit] Create table

In your MediaWiki site you will now find an "Attributes" tab on each page. The installation procedure will commence by simply hitting it.

[edit] Tested environments

The extension has been successfully tested in the following environments:

[edit] MediaWiki 1.8

  • Windows 2000 prof
    • MediaWiki 1.8 alpha rev. 15483
    • Apache 2.0.49
    • PHP Version 5.1.1
    • MySQL - 5.0.23-community-nt

[edit] MediaWiki 1.7

  • Windows 2000 prof
    • MediaWiki 1.7.1
    • Apache 2.0.49
    • PHP Version 5.1.1
    • MySQL - 5.0.23-community-nt

[edit] MediaWiki 1.5

The following setups needed patching

  • Windows 2000 prof
    • MediaWiki 1.5.8, rev. 16026
    • Apache 2.0.49
    • PHP Version 5.1.1
    • MySQL - 5.0.23-community-nt
  • Linux (RedHat)
    • MediaWiki 1.5.8, rev. 16026
    • Apache 2.0.49
    • PHP 4.3.8
    • MySQL 3.23.58

For adding the tab "attributes" in version 1.5 the following patch is needed:

Index: includes/SkinTemplate.php
===================================================================
--- includes/SkinTemplate.php   (revision 16026)
+++ includes/SkinTemplate.php   (working copy)
@@ -695,6 +695,7 @@
                                        }
                                }
                        }
+                       wfRunHooks( 'SkinTemplateTabs', array( &$this , &$content_actions ) )   ;
                } else {
                        /* show special page tab */
 

The extra editor button can be made visible with this patch in mediawiki 1.5:

Index: EditPage.php
===================================================================
--- includes/EditPage.php       (revision 16026)
+++ includes/EditPage.php       (working copy)
@@ -1010,6 +1010,7 @@
         */
        function getEditToolbar() {
                global $wgStylePath, $wgContLang, $wgMimeType, $wgJsMimeType;
+               global $xyAttributePng;
 
                /**
                 * toolarray an array of arrays which each include the filename of
@@ -1124,6 +1125,7 @@
 
                $toolbar.="addInfobox('" . wfEscapeJsString( wfMsg( "infobox" ) ) .
                        "','" . wfEscapeJsString( wfMsg( "infobox_alert" ) ) . "');\n";
+               $toolbar.="addButton('$xyAttributePng','".wfMsg('xyattribute')."','<'+'attribute name=\"','\" />','value');\n";
                $toolbar.="document.writeln(\"</div>\");\n";
 
                $toolbar.="/*]]>*/\n</script>";

[edit] To do

[edit] Evaluation

A special page for querying the database for attribute values is needed.

[edit] Alternatives

[edit] Project Homepage

The homepage of the project on Sourceforge is http://xywattributeext.sourceforge.net

Personal tools