From a49c17b42493e7b07ecbae0dbc35901cda87e239 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 16 Feb 2011 11:33:31 +0000 Subject: [PATCH] MDL-26425 tablelib rename constructors to PHP5 __construct and add depreacted functions with the old name so that legacy code does not break. --- lib/tablelib.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/tablelib.php b/lib/tablelib.php index 7c196ddf63d..bae9504c11c 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -119,7 +119,7 @@ class flexible_table { * @param int $uniqueid * @todo Document properly */ - function flexible_table($uniqueid) { + function __construct($uniqueid) { $this->uniqueid = $uniqueid; $this->request = array( TABLE_VAR_SORT => 'tsort', @@ -131,6 +131,17 @@ class flexible_table { ); } + /** + * Backwards-compatible constructor, so that legacy code subclassing + * flexible_table does not break. + * @deprecated since Moodle 2.0. Will be removed in Moodle 2.1. + */ + function flexible_table($uniqueid) { + debugging('Please update your code to user PHP5-style parent::__construct(...), ' . + 'not parent::flexible_table(...).'); + $this->__construct($uniqueid); + } + /** * Call this to pass the download type. Use : * $download = optional_param('download', '', PARAM_ALPHA); @@ -1244,13 +1255,24 @@ class table_sql extends flexible_table { * @param string $uniqueid a string identifying this table.Used as a key in * session vars. */ - function table_sql($uniqueid) { - parent::flexible_table($uniqueid); + function __construct($uniqueid) { + parent::__construct($uniqueid); // some sensible defaults $this->set_attribute('cellspacing', '0'); $this->set_attribute('class', 'generaltable generalbox'); } + /** + * Backwards-compatible constructor, so that legacy code subclassing + * table_sql does not break. + * @deprecated since Moodle 2.0. Will be removed in Moodle 2.1. + */ + function table_sql($uniqueid) { + debugging('Please update your code to user PHP5-style parent::__construct(...), ' . + 'not parent::table_sql(...).'); + $this->__construct($uniqueid); + } + /** * Take the data returned from the db_query and go through all the rows * processing each col using either col_{columnname} method or other_cols