Extension:TableEdit

Rationale and Features
Wiki markup can be challenging. Tables are one of the harder things for new users. TableEdit provides a simple table creation and editing system.

TableEdit replaces &lt;newTableEdit/> tags in wikitext with a "Create Table Here" link. Following this link goes to a Special page that creates HTML comment-delimited tables The content is controlled by an external mysql database, but the tables are saved back to the wiki in normal wikitext surrounded by HTML comments with the id number of the table in the database. Users can
 * Insert rows
 * Append columns
 * Change styles for tables, heading rows, and rows
 * Use template-defined lists of column headings

See EcoliWiki for more about the TableEdit features and how to use them.

Status
So far, TableEdit 0.5 has been tested with MediaWiki 1.8.3, MediaWiki 1.9.3, and MediaWiki 1.10.0 on MacOSX. Help testing this extension on other versions will be appreciated!

Changes in Version 0.6

 * Special page now displays template expansions, e.g if the heading style is determined by a wiki template, then it gets used
 * Added hook and extension, TableEditCreationLinks.php to alter the "Create Table Here" text, depending on the template used
 * changed how box_uid is done. Wasn't unique enough before
 * changed SpecialTableEdit.body.php organization to be more useful for maintenance scripts
 * more misc bug fixes.
 * Inactivate headings edit link when templates are in use.

-I can't get this work. I'm sorry for posting this here, but I'm not getting any response in the discussion area. I'd like to use MediaWiki to deliver content to my users, and I'd like to have this TabbleEdit extension functional before I start transferring all my information. It looks like a great solution to my needs, maybe even better than what I need.

I'm using the monobox skin. I've changed all the database commands to match the name of the database I created (my host requests a default format). I've followed all the other instructions to the best of my interpretation. When I put  code in the text, it just shows up as I've typed it.

Thanks, and again, sorry for putting this here. It just looks like a great extension for my needs. -- Jim R.

Changes in Version 0.5
TableEdit.php was incorrectly getting the page id. Fixed SpecialTableEdit.body.php was doing some odd things when editing headings. Blank headings at the end of the list now must be a space, not just a return.

Changes in Version 0.4

 * modified INSERT statements to use null for autoincrement
 * changed TableEdit.php to respect nowiki.

Changes in Version 0.3
Lots of changes in version 0.3, including a schema change. Be sure to use the new one in the distribution Syntax: Heading||column_name|rule rule syntax text                   to use input type=text instead of textarea select|1|2|etc         make a pulldown menu with choices 1, 2, etc lookup|sql|field       sql statement|name of field to return sql statements use in place of specific fields example: Aspect||aspect|lookup|SELECT namespace from go_archive.term WHERE go_id = '' ORDER BY term_update DESC LIMIT 1|namespace currently available calcs split                split|delimiter|x|y|z where x,y, and z are integers indicating which parts of the split to join into the result
 * Changed how boxes are identified to handle imports and page moves better
 * misc. bug fixes
 * Tables are now saved into the wiki in a less compressed form. This was necessary to allow content that breaks over more than one line, and to support bulleted lists as data.
 * Template handling changed. There are now two ways to represent a table template
 * The old way, a return-delimited list is assumed to be a list of headings.
 * XML style. Attributes for the table are wrapped in XML-like tags.
 * for headings
 * for heading style
 * for horizontal (default) or vertical (1) orientation
 * Added support for special kinds of editable cells in the Template-defined headings. This should work with either the old or XML-style templates

reqcomplete          reqcomplete|column_name|column_name|column_name...                              where column names are required fields. returns \"complete\" or \"required field needed\"
 * Started moving message text to the i18n file. Needs more work!
 * Added a hook to allow other extensions to do things to the table before it is saved back to the wiki page. Example included in the distribution.

Changes in Version 0.2

 * Persistence now changed to use $_SESSION variable
 * Rudimentary edit conflict detection and resolution
 * Ability to rotate tables so headings are on the left instead of on the top
 * With MW 1.9.3, tables with headings on top can be sorted using the sortable.js javascript library in MediaWiki/Common.js

Installation
Table.php installation requires an additional mysql database.
 * Download tableEdit.0.5.tgz
 * Place the TableEdit directory into your extensions directory. Set appropriate permissions for these files.  Files included:
 * TableEdit.php - the extension to catch &lt;newTableEdit/> tags, and load the other files.
 * SpecialTableEdit.php - setup for the special page
 * SpecialTableEdit.body.php - the special page that provides the editing interface and displays the help file
 * SpecialTableEdit.docs.php - help info
 * SpecialTableEdit.i18n.php - internationalization (needs lots of work)
 * Create the mysql database wikibox_db and grant appropriate permissions (Don't forget to FLUSH PRIVILEGES!). See EcoliWiki for the SQL to create the database. NOTE: The schema has been extensively modified for version 0.3. An SQL document for the schema is included in the distribution.
 * mysql> create database wikibox_db;
 * mysql> grant SELECT,INSERT,DELETE,UPDATE on wikibox_db.* to wikiuser;
 * mysql> use wikibox_db;
 * mysql> source wikibox_db.sql


 * add
 * require_once(" /TableEdit/TableEdit.php");
 * to LocalSettings.php.

Alternatives

 * PropertyTable

Known Issues

 * Can't get the content back if the table is edited directly in the wiki. This can be prevented by combining TableEdit with ProtectSection
 * Can't sort
 * Can't insert columns in the middle

Dumps
While tables will be preserved when importing a dump from a wiki that uses TableEdit, when a user tries to click on the Edit link, bad things are likely to happen. In the best case, the recipient wiki will not have TableEdit installed and there will just be a 404 error. If TableEdit is installed, the most likely outcome is that the box_id and pagename will not match what is stored in the database and TableEdit will refuse to do the edit on the imported page. Suggestions for how to solve this are welcomed!

Patch for record insertion
Some MySQL installations don't like "" instead of null as an insert value for an autoincremented field. This means two lines should be changed (and will be in the next version) In TableEdit.php change line 126 to $sql = "INSERT INTO wikibox_db.box VALUES (null,'$template','$page_name','$page_uid','$box_uid','$type','$headings','','$prettytable','".time."')"; In class.wikibox.php change lines 244-252 to $sql = "INSERT INTO wikibox_db.row VALUES(     null,     '$this->box_id',     '$this->owner_uid',     '$this->row_data',     '$this->row_style',     '$this->row_sort_order',     '".time."'     )";

1.10 problem
I tested it with MW 1.10 (tabledefinition below), and after click on 'Create Table Here' the Special page appears (inkl. ID for the Table) but no editor!.

 Überschrift 1 Überschrift 2 

The  - Tag will alawys be ignored! --nope 15.5.07

Problems with 0.2 distribution
- The 0.1 distribution install instructions for database setup are broken. Need to not create the 'xxx' column!

Bug on Ubuntu?
-By André Tavares (Hasgassa@hotmail.com), on MediaWiki 1.7.1, ubuntu (linux) appear:

"Page&ns=&type=0 Create Table Here" and table was not created. 1. TableEdit.php && SpecialTableEdit.body.php:
 * I needed to make 2 changes to could edit normally:

[/wiki/index.php/Special:TableEdit?id=$box_id&page=&ns= Create Table Here]
 * to

[/wiki/index.php/Special:TableEdit?id=$box_id&page=&ns= Create Table Here]

2. LocalSettings.php require_once("Cite/TableEdit.php"); to require_once("$IP/extensions/TableEdit.php"); Note: TableEdit extension files on /my/wiki/folder/extensions/


 * I still have an error. While adding a row the following error appears:
 * Warning: array_shift [function.array-shift]: The argument should be an array in /var/www/service/extensions/TableEdit/SpecialTableEdit.body.php on line 326
 * Still working on solution

Problems with 0.1 distribution

 * Doesn't work on Mediawiki 1.9.3, PHP 5.1.6, MySQL 4.1.21; Muirhejs 02:07, 28 March 2007 (UTC)
 * Installed into wiki/extensions/TableEdit/
 * LocalSettings.php line: require_once("extensions/TableEdit/TableEdit.php");
 * Created tables as described at EcoliWiki with prefix mw_; modified the scripts with command perl -p -i -e 's/wikibox_db\./mw_/g' * to account for this
 * Part of the problem may have be in SpecialTableEdit.php. I changed the line
 * $wgExtensionFunctions[] = 'tableeditsetup'; to $wgExtensionFunctions[] = 'specialtableeditsetup';

Warning: call_user_func(tableeditsetup) [function.call-user-func]: First argument is expected to be a  valid callback in /home/ /public_html/wiki/includes/Setup.php on line 219
 * The extension seems to go straight to the help page instead of going to the editor; it seems that the extension is properly changing the .

FIXED: in TableEdit.php, changed line: [/wiki/index.php/Special:TableEdit?id=$box_id&page=&ns= Create Table Here]
 * to

[/wiki/index.php/Special:TableEdit?id=$box_id&page=&ns= Create Table Here]


 * Since this does work in our setup, please provide more information about the conditions under which it gave this error. JimHu 01:57, 28 March 2007 (UTC)