[dev] Re: [cvs] commit: framework/Data/Data csv.php tsv.php
Jason M. Felice
jfelice at cronosys.com
Sat Feb 14 09:06:11 PST 2004
On Sat, Feb 14, 2004 at 01:05:42PM +0100, Jan Schneider wrote:
> Zitat von Jason Felice <jfelice at cronosys.com>:
>
> >eraserhd 2004/02/13 21:34:11 PST
> >
> > Modified files:
> > Data/Data csv.php tsv.php
> > Log:
> > * Remove unused $delimiter parameter (first step in formalizing export
> > interface).
>
> Wouldn't it make more sense to actually *use* the delimiter instead of
> removing it completely?
I'm trying to avoid having completely different parameters to the
*::exportData() method for each file type. There's no point to using
*::factory() if all your code has to be specific to the driver.
I'm going to add back a way to set the delimiter that is flexible enough
for all the drivers. I'm reworking it now so that you will do something like
this to export:
$data = &Horde_Data::singleton($format);
// optional, replaces $header flag and drivers which don't
// support it can ignore it.
$data->setFieldNames(array('column_1' => _("Column 1"), _("Column 2")));
$data->setData($data);
then:
$foo = $data->exportToString()
or:
$data->exportToBrowser($filename)
Right now, I'm thinking of adding the following:
// returns a key => value array of the current settings here.
$options = $data->getExportOptions();
// sets the options.
$data->setExportOptions($options);
I haven't decided on how have it provide the UI for setting the options.
I think the easiest way would be.
$form = &Horde_Form::singleton();
$data->addExportVariablesToForm($form);
and on the receiving end:
$form = &Horde_Form::singleton();
if ($form->isValid()) {
$form->getInfo($vars, $info);
$data->readExportOptionsFromForm($info);
}
Eventually, I'd like the option for the application to build the data,
perhaps set it in the session, then redirect to a Horde-standard page
which knows about all the export formats, allows you to remap fields,
specify date formats, newline and delimiters, quoting characters, how to
escape quotes in quotes, all that jazz, and produce the file. I'd like
the user to be able to specify a name for the export settings and save
the name and all the settings in the user's preferences.
--
Jason M. Felice
Cronosys, LLC <http://www.cronosys.com/>
216.221.4600 x302
More information about the dev
mailing list