Hi Chanaka,
On Thu, Jun 28, 2012 at 5:04 AM, Chanaka Dharmarathna pe.chanaka.ck@gmail.com wrote:
I'm going to look into getting PMA_mimeDefaultFunction() function inside PMA_DisplayResults class. (currently it is under core.lib.php) I think it is possible to use this function inside that class, and call directly ($this->_mimeDefaultFunction()) instead of using additional string to store method name. (current way)
Then the default function for the mime transformation is inside a class. But the other existing transformations functions are still global functions. If that is not good (feels not good), those also should convert to classes.
I've seen that the PMA_mimeDefaultFunction is only currently used in DisplayResults.class.php, so I think it's a good idea to move it there.
And if other transformations converted to classes, in which way I can create objects of those classes. Should I need to use string to store the class name and then use it as belows.
$class_name = 'TestClass'; $ob = new $class_name($params);
It is very helpful for me if you can share your suggestions.
As general info, to use a transformation plugin, you have to include it and then instantiate it. For example, if you want to use Text_Plain_Sql: include_once 'libraries/plugins/transformations/Text_Plain_Sql.class.php'; $plugin_manager = null; // Still working on this, so you can use null for now $sql_transf = new Text_Plain_Sql($plugin_manager); Then, you can use the actual transformation by calling: $sql_transf->applyTransformation();
In DisplayResults.class.php, inside _getTableBody(), there is an init: [2158] $default_function = 'PMA_mimeDefaultFunction'; // default_function Then, this variable is passed as an argument to several functions along the way: _getDataCellForNumericColumns, _getDataCellForBlobColumns, _getDataCellForGeometryColumns, _getDataCellForNonNumericAndNonBlobColumns, _getRowData, _addClass _handleNonPrintableContents
Some of the functions only pass it further, while others use actually use it. I replaced the use of the PMA_transformation_[FILENAME]() with the use of $transformation_plugin->applyTransformation() and kept the same arguments. So I had to pass an instance of the transformation class as an argument ($transformation_plugin), but my problem was that in some cases I had to use the applyTransformations method, while in others, I had to use the default function ( PMA_mimeDefaultFunction() ). Therefore, where needed, I set the argument $transformation_plugin = $default_function, and, in the above mentioned methods I checked and used accordingly, something similar to: $result = ($transformation_plugin != $default_function ? $transformation_plugin->applyTransformation( $data, $transform_options, $meta ) : $default_function($data) )
Hope that helps. I will write some wikis for all of the plugins, but I thought I should first finish the whole system (the plugin managers).
-- Alex