That was my point :)
Whatever the nature of the uploaded file is, we might want to act on
it differently based on the functionality required by that precise
upload operation. That functionality is probably already out there, be
it creating a thumbnail, zipping a file or whatever. It is just that I
don't really like the idea of extending the class just for a simple
function call to operate on the file. But, anyhow, it is the most
flexible and sensitive approach given that there is more functionality
to cover than just applying a function to the file when it is
uploaded. Go for it! ;)
Now, for an extreme example, lets take a music publisher that wants to
put their records online using the best framework out there ;) An
album has multiple photos, a cover, videos, lyrics, audio tracks...
some of them would probably better be models themselves, but just for
the porpouse of the example the $actsAs array could look something
like this:
var $actsAs = array (
'imageUpload' => array (
'photos' => array (
'dir' => 'files/images',
'max_size' => 200000,
'thumbs' => array (
'small' => array('width' => 320, 'height' => 200),
'medium' => array('width' => 640, 'height' => 400)
)
),
'cover' => array (
'dir' => 'files/images/covers',
'max_size' => 200000,
'filters' => array (
'tint' => array('color' => '#FF9900'),
'resize' => array('width' => 400, 'height' => 400)
)
)
),
'videoUpload' => array (
'videos' => array (
'dir' => 'files/video',
'max_size' => 3000000,
'preview' => array('width' => 100, 'height' => 100),
'encode' => array('format' => 'flv', 'sound' => 'mono',
'fps' => 25)
)
),
'docIndexerUpload' => array (
'lyrics' => array (
'dir' => 'files/docs/lyrics',
'max_size' => 200000
),
'intro' => array (
'dir' => 'files/docs/intros'
)
),
'audioUpload' => array(
...
),
...
);
Different behaviors (hint!) for different fields of the model, but
still the could all be referenced by the same DB table, name it
'files', associated to the model through the behavior. Thus, an album
might look like:
[Album] => Array (
[id] => 5,
[title] => 'Innuendo',
[group] => 'Queen',
[genre] => Array ([0] => 'pop', [1] => 'rock'),
...
[videos] => Array (
[0] => Array (
[dir] => 'files/videos',
[name] => 'delilah.flv',
...),
[1] => Array (
[dir] => 'files/videos',
[name] => 'all_gods_people.flv',
...),
...),
[photos] => Array (...),
[cover] => Array ([dir] => 'files/images/covers', [name] =>
'innuendo.jpg', ...)
....
)
Sorry for the lengthy post, you get the idea :)
On 13 jul, 13:38, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> On 7/13/07, Gorka <[EMAIL PROTECTED]> wrote:
>
>
>
> > imageUpload, videoUpload, docUpload, spreadsheetUpload, ... classes.
> > Thoughts?
>
> IME most often the functions which act on the file at the time of upload are
> also needed in, to coin a phrase, non upload situations. To give an example
> you create thumbnails while uploading but you could also want to re-create
> different sized thumbnails some other time - if your resize code was
> contained in a behavior it will not be much help.
>
> So after making a generic upload class it can be left to users to extend it
> to suit their needs using - vendor classes, stand-alone code, components or
> chicken entrails - Of course everyone loves examples though :)
>
> Tarique
>
> --
> =============================================================
> Cheesecake-Photoblog:http://cheesecake-photoblog.org
> PHP for E-Biz:http://sanisoft.com
> =============================================================
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---