Extension:TableEdit/Details

From MediaWiki.org
Jump to navigation Jump to search

Execution Syntax/ Usage[edit]

To Create a New Table...[edit]

...using a template[edit]

<newTableEdit>Template:PageName</newTableEdit>
  • The name of the template should be put in-between the tags, including the Template: prefix. See the section below for defining a template.

...without a template[edit]

<newTableEdit>
Heading1
Heading2
Heading3
So Forth...
</newTableEdit>
  • Put the headings for the row/columns you want to create in-between the tags. You must specify a heading for a column.

Specifications[edit]

Template Definitions[edit]

TableEdit is extensively template-driven. Most of the tables on EcoliWiki.net are managed by templates, meaning all the information about the table is defined in a wikipage in the Template namespace. This includes all the headings, the heading-styles, if the table is horizontal or vertically oriented, and other variables.

Exhaustive List of Variables[edit]

<table_style></table_style>

Style to apply to table as a whole. For example:

TableEdit template text
<table_style>style="margin: 1em 1em 1em 0;" width='30%'</table_style>
~ equivalent standard MediaWiki markup
{| style="margin: 1em 1em 1em 0;" width='30%'
<headings></headings>

A newline (carriage-return) delimited list of the headings.

TableEdit template text
<headings>
Standard name
Mnemonic
Synonyms
</headings>
~ equivalent standard MediaWiki markup (in a vertical table - see type below)
|-
! Standard Name
! Mnemonic
! Synonyms
|-
<heading_style></heading_style>

Sets the default style for the headings. For example:

TableEdit template text
<heading_style>align='left' bgcolor='#CCCCFF'</heading_style>
~ equivalent standard MediaWiki markup (at the front of every header element)
! align='left' bgcolor='#CCCCFF' |
<type></type>
  • 0 indicates a vertical-type table -- with the headings going across the page left to right. This is the defualt.
  • 1 indicates a horizontal-type table -- with the headings running down the left side of the table.
<datatable></datatable>
As of TableEdit-v1.0 there is a directive to add the class datatable to a table. This allows custom Javascript to be bound to a set of tables, or a specific table on a page. See the code in js/init_datatables.js for an example. Also there is some information in the READMEs.


You can also display text in specific situations when displaying and editing a table. This text can use any MediaWiki markup.

<help1></help1>
This text shows up above the box view on the general view and when you edit a row.
<help2></help2>
Above the table on the general view when you are editing a table.
<help3></help3>
Below the table on the general edit view.
<help4></help4>
On the very right hand side when you edit a row.
<above></above>
Goes right above the table in the wiki page.
<below></below>
This is the counterpart to <above> tag. The text in this field gets put right below the table in the wiki page.

Example[edit]

  • Here is the Template:Gene_nomenclature_table from EcoliWiki.
<headings>Standard name
Mnemonic
Synonyms</headings>
<heading_style>{{table_heading_style}}</heading_style>
<type>1</type>
  • Here is a more complicated example that makes use of column rules. This comes from Template:GO_table_product in EcoliWiki. Long lines have been broken and have a backslash to indicate an inserted line-break.
<headings>
Qualifier||qualifier|select| |NOT|Contributes to|Colocalizes with|Obsolete GO term|Under review
GO ID||go_id|text
Reference(s)||refs
Evidence Code||evidence|select| |IC: Inferred by Curator|IDA: Inferred from Direct Assay \
|IEA: Inferred from Electronic Annotation|IEP: Inferred from Expression Pattern \
|IGC: Inferred from Genomic Context|IGI: Inferred from Genetic Interaction \
|IMP: Inferred from Mutant Phenotype|IPI: Inferred from Physical Interaction \
|ISS: Inferred from Sequence or Structural Similarity|ISO: Inferred from Sequence Orthology \
|ISA: Inferred from Sequence Alignment|ISM: Inferred from Sequence Model \
|IGC: Inferred from Genomic Context|RCA: inferred from Reviewed Computational Analysis \
|TAS: Traceable Author Statement|NAS: Non-traceable Author Statement \
|ND: No biological Data available|NR: Not Recorded
with/from||with|text
Notes||Notes
Status||status|calc|reqcomplete|go_id|refs|go_term|evidence
</headings>
<heading_style>{{table_heading_style}}</heading_style>
[[Category:Table templates|GO table product]]

Column Rules[edit]

By default, TableEdit will accept any text in table cells. Column rules allow you more control over what can be placed in a given column. Column rules are included in the <headings> section of TableEdit templates. They are defined on the same line as the column they apply to.

The basic syntax for a creating a column rule is

Column Heading||column_id|column_rule_type|...

Where

Column Heading The name of the column to display in the table. For example, Street Address.
column_id Identifier for this column within TableEdit. This ID can be used in column rules in other columns. The ID may not contain spaces.
column_rule_type Is the column rule to use with this column. See below for a list of column rule types.
... The remainder of the line is dependent on the column rule used. See below.

These are defined in TableEdit::apply_column_rules() in SpecialTableEdit.body.php.

select[edit]

The select column rule specifies a pull down menu of values that the column can have. The format is:

Column Heading||column_id|select|Default Option|Other Option 1|Other Option 2|...

The default option will be preselected when a new row is created. If you don't want a default option, then insert a space here. The default may not be empty.

For example, this gives editors a pulldown menu listing 4 years, with a default of blank.

Year||year|select| |2010|2011|2012|2013

And this gives editors a pulldown menu listing 5 choices, with a default of "Before 2010":

Year||year|select|Before 2010|2010|2011|2012|2013

The pull-down menu is only shown when the table is being edited. Once the table is saved, only the selected option is shown.

checkbox[edit]

The checkbox column rule allows editors to select multiple values. lumn rule specifies a pull down menu of values that the column can have. The format is:

Column Heading||column_id|checkbox|Item 1|Item 2|Item 3|... 

For example, to allow an editor to select 0, 1, or many favorite vegetables:

Favorite vegetables||fav_veg|checkbox|Corn|Green beans|Broccoli|Lettuce|Celery 

When editing a row, this would show all 5 choices, with a checkbox to the right of each. Editors could 0, 1, some or all choices. Once the table is saved, the choices are displayed as a space separated list.

text[edit]

The text column rule creates a text box one line high, 40 characters wide, and with a maximum length of 255 characters. The format is:

Column Heading||column_id|text 

When editing, the edit window is 40 characters wide. After saving the edits, the full-length value will be shown.

calc[edit]

timestamp[edit]

The timestamp column rule automatically populates the column with the date the row was last updated. The date is in the format YYYY-MM-DD. The format is:

Column Heading||column_id|timestamp 

When editing, the date of the previous update is shown. After saving any edits, the date of the newly saved edits is shown.

foreign[edit]

The foreign table type allows you to show data from another table/row in a table. This was originally created for the Quickview Tables on EcoliWiki. We needed a way to mirror the data from the Gene and Product pages on the Quickview page dynamically, so the user wouldn't have to edit the same information in two different places. The syntax is:

Column Heading||column_id|foreign|foreign_page|foreign_table_template|foreign_heading

Anything in italics should be changed. For gene pages we needed a way to tell the table to look on the corresponding gene/product page, so we added the {{{SIBLING}}} magic word. For example, the following line would pull information from the nomenclature table on the corresponding Gene page. (If this was used on the lacZ:Quickview page, it would pull from the lacZ:Gene page.)

Gene Synonym(s)||syns|foreign|{{{SIBLING}}}:Gene|Gene_nomenclature_table|Synonyms

The code executes in the following manner:

  1. sets a row property specifying this is a foreign row
  2. breaks the definition (coming from the template) into variables
  3. does {{{SIBLING}}} magic word processing
  4. uses variables to search the database for the corresponding foreign row/box
  5. creates a box object from the returned database info
  6. crawls through the box, and when the right row is found, it saves the foreign row_data to this row_data
  7. looks for any existing relations in the db
  8. if none are found, it creates a relation in the db
  9. creates display version & raw version to be shown in the view
  10. returns view string

Object Classes[edit]

TableEdit has undergone major changes trying to make it more like the MVC model. This cannot always be accomplished due to programmer style and historical reasons, but where possible we've tried to seperate the three.

wikiBox
A wikiBox object consists of a series of attributes that control the behavior and appearance of the table and a collection of row objects that hold the actual data. The wikiBox also has methods to manipulate rows, serialize and unserialize its contents, and for interacting with the MySQL database that controls the tables. Most of the manipulation of the tables can be done through this method. It (not so transparently) handles the wikiBoxRow objects (see below.)
wikiBoxRow
A wikiBoxRow object holds the actual data. This is also defined in class.wikiBox.php. The wikiBoxRow has methods for loading and saving etc. This class also carries methods that cannot/are not called from class wikiBox, such as the methods dealing with the relations database table (ext_TableEdit_relations.)
TableEdit
Class TableEdit is defined in SpecialTableEdit.body.php and is an extension of the SpecialPage class. However, it can be invoked without generating a special page to handle interactions between wikiBoxes and Article objects in MediaWiki.
wikiBoxMetadata, wikiBoxRowMetadata, tableEditMetadata====
These classes are defined in class.wikiBox.php and handle the saving and retreiving of metadata from their respective database tables.
TableEdit_Loader
Defined in class.loader.php, this class is devoted to loading data into pre-existing tables. There is a whole page devoted to the loader, with all the options and usage explained there.

Semantics[edit]

Don't know what people are talking about? Brush up on the TableEdit lingo and impress your friends.

table[edit]

  1. The table as displayed when you first visit a wiki page.
  2. A table in the database that stores data. (Ex. ext_TableEdit_box or ext_TableEdit_relations.)

box/box object[edit]

  1. The complex data structure representing the table. This consists of an object with sub-objects/arrays, etc.
  2. Sometimes used in place of "table."



Notes[edit]

The Conflict Detector[edit]

Sessions[edit]

List of Hooks[edit]