On Thu, Jan 30, 2003 at 12:15:00PM +0100, Garvin Hicking wrote:
I think the column name should not be used to define what type of transform is used, as that restricts the user a lot. Instead just base the transform off the specified mimetype.
Then I don't get the clue of how you want to add the mime-types. In your first mail I thought you want to use the column comments table for storing it. The column comments references the comments by the column name, currently like this:
db_name.table_name.column_name:comment
There I would just add new fields: mimetype, parameters.
You missed transformname, or whatever you want to call it, for when multiple transforms exist for the same data. (If you base this off the filename for the transform, it should be easy to manage...). The mime-type field should contain ONLY the offical mime-type values for portability reasons, no custom modifiying them.
On the browsepage I would use a function which gets all fields mimetype and parameters from the comments-database. In every field I would the check the mimetype of the column using an association by the column name.
Just SELECT the three data fields that you need from the columncomments table yes.
Which means exactly, I have an array like this: $transformation_map = array('id' => 'text/plain', 'image' => 'image/jpg_inline', 'image2' => 'image/jpg');
I had envisenged it more like this, but you are close enough anyway... $transformation_map = array( 'id' => array('mimetype'=>'text/plain','transform'=>'',parameters=>''), 'image' => array('mimetype'=>'image/jpg','transform'=>'inline',parameters=>'width=100,height=100'), 'image2' => array('mimetype'=>'image/jpg','transform'=>'',parameters=>''));
And after that, inside the loop for displaying the rows' values I query my array via $transformation_map[$pointer] -- if there is an entry, to the transformation stuff, otherwise use the standard htmlspecialchars()-Function.
(puesdo code) foreach($field of $data)... echo doTransform($row[$field],$transformation_map[$field]); I have it this way so that people can specify default transforms for all data in their database if they so desire...
What was your approach, could you please specify?
I think it was just a slight misunderstand, what you wrote in your previous email looked like you were basing it directly off the field names instead of using those as indexes into the tranformation mapping.
Oh, and once you write up the code for putting the mime-type in, I'll contribute a little bit of code that can auto-detect what mime-type a data field should be if there is data in the field but no mime-type specified. It's just a little bit of code I have kicking around my personal archives that I wouldn't mind putting to better use.
That'll be great. :-)
This is part of my reasoning behind wanting to stay with offical mime-types only in the one field.