Wikipedia talk:Infobox/Specification

From Wikipedia, the free encyclopedia

Wikipedia's Infobox Class Specification

This is a suggested software specification, if you are unfamiliar with PHP/SQL or software programming feel free to ignore this page.

BEFORE YOU MAKE ANY CHANGES


Be sure to read the discussion on this page before you make any changes to the class specification.

If you do any modification to the PHP/SQL specification be sure to detail it in the specification historial.


See also: Infobox Class Implementation.

Contents

Suggested approaches

SQL tables

Here's a suggested definition of how an article's SQL table should be in order to handle Infoboxes. The new rows are the infobox and infoboxType rows.

articles
: id
: title
: context
: infobox <-- new row
: infoboxType <-- new row

Explanation:

  • infobox — stores the HTML context of the infobox
    • should be set to NULL if no Infobox is defined
  • infoboxType — stores the infobox's type
    • the infobox's type will be used to determine which Taxobox PHP Class will be used to print the article's infobox
    • should be set to a type or to NULL
    • a standard Infobox template stylesheet should be specified in the standard skin or on each custom skin in the case that an infobox with an unknown type is displayed

PHP definitions

Here is a suggested PHP base class specification for the Infobox standard. All other infobox types would extend from this class. In other words, plants' infobox would be defined as something like:

class PlantInfobox extends Infobox {
        /* blahblah */
}

For an in-depth explanation see Infobox Class Implementation.

class Infobox extends Article {

        var userPreference;
        /* stores the user's preference regarding if infoboxes should be displayed      */
        /* var type is BOOLEAN:                                                         */
        /*      TRUE if the option is set to SHOW INFOBOXES                             */
        /*      FALSE if the option is set to DO NOT SHOW INFOBOXES                     */

        var $context;
        /* stores the infobox's context                                                 */
        
        var $type;
        /* stores the infobox's type                                                    */

        var $tempContext;
        /* used when the user is editing the infobox                                    */
        /* stores the temporary context of the infobox (ie: the preview context)        */

        function getContext ( /*void*/ ) {
                GET article's infobox context
                /* in other words:                                                      */
                /*      (1) retreive the article's infobox context from the SQL         */
                /*          article's table                                             */
                /*          NOTE: be meticulous, excessive calls to SQL can be harmful  */
                /*      (2) assign the retreived information to $context                */
        }
        
        function getType ( /*void*/ ) {
                GET article's infobox type
                /* in other words:                                                      */
                /*      (1) retreive the article's infobox type from the SQL
                /*          article's table                                             */
                /*          NOTE: be meticulous, excessive calls to SQL can be harmful  */
                /*      (2) assign the retreived information to $type                   */
        }

        function getUserPreference ( /*void*/ ) {
                IF user is loggued in THEN
                        GET user's infobox display preference
                        /* in other words:                                              */
                        /*      (1) retreive the user's preference from the SQL users'  */
                        /*          preferences table                                   */
                        /*          NOTE: be meticulous, excessive calls to SQL can be  */
                        /*          harmful                                             */
                        /*      (2) assign the retreived information to $userPreference */
        }
        
        /* Constructor                                                                  */
        function Infobox ( /*void*/ ) {
                IF this article exists THEN
                        GET article's infobox context   /* $this->getContext();      */
                        GET article's infobox type      /* $this->getType();         */
                        GET user's preference           /* $this->getUserPreference();       */
                /* NOTE: the constructor is not used to create new infoboxes.           */
                /*       an article must exist before the user is allowed to create     */
                /*       its infobox. read this discussion page for an explanation of   */
                /*       the consequences that arise by this approach.                  */
        }

        function setContext ( $infoboxHTML = "NULL" ) {

                SET the article's infobox context to the $infoboxHTML provided
                /* no matter if it is empty/NULL or whatever                            */
                /* if the input is NULL, empty or ""  then the context must be set to */
                /* ""                                                                 */
        }

        function setType ( $infoboxType = "NULL" ) {
                SET the article's infobox type to the $infoboxType provided
                /* no matter if it is empty/NULL or whatever                            */
                /* if the input is NULL, empty or "" then the type must be set to ""        */
        }

        function save ( $infoboxHTML = "NULL", $infoboxType = "NULL" ) {
                SET $context to $infoboxHTML    /* setContext( $infoboxHTML );          */
                SET $type to $infoboxType       /* setType( $infoboxHTML );             */

                SET the article's infobox and infoboxType row to the $context and $type
                respectively
                /* Read this discussion page for an explanation of the consequences     */
                /* that arise by this approach.                                         */
                /* NOTE: if $context is equal to "" then the row must be set to NULL  */
                /*       if $type is equal to "" then the row must be set to NULL     */              
        }

        function setTempContext ( $tempHTML = "NULL" ) {
                SET $tempContext to the temporary HTML provided
                /* no matter if it is empty/NULL or whatever                            */
                /* if the input is NULL then tempContext must be set to ""            */
        }
        
        /* variant function name of setTempContext()                                    */      
        function setPreview ( $tempHTML = "NULL" ) {
                SET $tempContext to the temporary HTML provided
                /* ie: setTempContext( $tempHTML );                                     */
        }

        function printTempContext ( /*void*/ ) {
                PRINT $tempContext
                /* ie: print $this->$tempContext;                                    */
                /* this implementation provides 1 function for displaying the preview   */
                /* context in both HTML format and inside a textbox:                    */
                /*                                                                      */
                /* -->       for displaying a preview HTML, the developer would call         */
                /*      printTempContext() in the HTML code                             */
                /*                                                                      */
                /* -->       for displaying a preview HTML code, the developer would call    */
                /*      printTempContext() inside the textarea preview                  */
                /*      ie: <textarea><? printTempContext(); ?></textarea>               */
        }
        
        function print ( /*void*/ ) {
                IF $userPreference is set to TRUE THEN
                /* ie: user wants infoboxes to be printed                               */
                                
                        /* displaying the EDIT link for infoboxes                       */
                        IF the user invoking the article has the
                           "Enable section editing via [edit] links" preference set to
                           true THEN
                                DISPLAY an [edit infobox] link
                        
                        /* displaying the infobox finally                               */
                        DISPLAY the infobox
                        /* > this display should include the div HTML tags and $context      */
                        /*   printed inside them                                        */
                        /* > the div HTML tag should include a stylesheet id parameter       */
                        /* > the id should be the stylesheet id used for infoboxes   */
                        /*   which is retreived from another file                       */
                        /*   for example: " id=\"#$infobox_id\"\n"                  */
                        /*                could result in id="#infobox_US_Presidents" */
                        /* > this implementation allows each skin to have an appropiate */
                        /*   infobox stylesheet definition. as a rule, all skins        */
                        /*   should inherit the standard skin in the case that the      */
                        /*   custom skin doesn't have a stylesheet definition for       */
                        /*   infoboxes                                                  */
                        
                ELSE no else should be defined
                /* if $userPreference is set to FALSE then nothing should be            */
                /* done/printed                                                         */
        }

}

Other aproaches

Infoboxes SQL tables for each type of infobox?

We could have different SQL tables for infoboxes. That way, each infobox's information is stored separately. Allowing us to give a different Edit-GUI for each type of infoboxes.

Suggested main SQL table:

infoboxes
: article_id
: infoboxType

Where infoboxType points to the infobox's type SQL table

Example of an infobox's type SQL table:

infoboxes_People
: article_id
: name
: nicknames
: date_of_birth
: place_of_birth
: education
: occupation

Cons: nasty SQL configuration because of the enormous size of tables (one for each type), more server load.

Pros: user-friendliness (each edit environment is different for each type of infobox), separation of infoboxes from articles' context. Although it is more server load, only 1 enormous SQL query is needed to retrieve all the article's information (including the main context and the infobox).

--Maio 21:47, Feb 7, 2004 (UTC)


Discussion

Please locate all discussion below this category. If you are posting a new message remember to subject it by typing ===Subject===.