Hi Alex,
Sorry for posting top post, but I'm just reading up on some mails on my phone while waiting for the intermission to end.
Just an idea, while reading your description of how to use the transformation classes : why don't you provide a factory pattern to instantiate/create the classes. Everything like checking if the include file exists, including it and preparing/instantiating can be done in the factory.
Also consider creating an interface for every type of class (auth, export/import, transformation, ...) and implement it in every derived class (f.e. ExportSql, ExportXml could implement a ExportInterface)
Kind regards, Dieter Adriaenssens. Op 28 jun. 2012 18:08 schreef "Alex Marin" alex.ukf@gmail.com het volgende:
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
Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel