Date index for Apr 2004


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [achievo] Problem with atkFileAttribute::db2value()



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

(this discussion should move to the developers dot 
cc-ing this. If you are subscribed to the development list too, please
reply there).

Bjørn Langfors wrote:

> function db2value($rec)
> {
>     return Array("tmpfile"=>$this->m_dir.$rec[$this->fieldName()],
>
>
"orgfilename"=>$rec[$this->fieldName()],"filename"=>$rec[$this->fieldName()],"filesize"=>"?");
>
> }
> Any ideas on how to make the edit view display the filename correctly as
> well?

The fault is that ATK doesn't use the proper display() methods to render
the descriptor_def templates. It assumes the array contains 'raw' values.

I've filed this as http://www.achievo.org/bug/286

There are 2 workarounds:

1. You can use the dot-notation in the descriptor def to render elements
of an array:

function descriptor_def()
{
  return "[name] ([filename.filename], [filename.filesize]Kb)";
}

But, since you said in normal (view/admin view) it works ok, I suspect
that this workaround would break that.

2. Instead of descriptor_def(), You can override the descriptor()
method, like this:

function descriptor($record, $mode)
{
  return $record["filename"]." - ".$record["name"];
}

This is more flexible than a template. You'll get the record, and you
can do whatever you need with it.

The $record that is passed to this function does not contain all fields
by default. You would have to implement this:

function descriptorFields()
{
  return array("filename", "name");
}

to tell ATK that these are the fields that you want to have preloaded in
the record that is passed to descriptor().

Greetings,
Ivo

- --
Ivo Jansch <ivo dot 
ibuildings.nl BV - information technology
http://www.ibuildings.nl

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFAfSbG95NUnGFZm9cRAhUoAJ9DPlGoDAO2Bjh3vKRL3mGhKvpVkgCfTekG
Brc9iR+LCr/Jd4L6C3e+Ck4=
=1XSj
-----END PGP SIGNATURE-----

http://www.achievo.org/lists achievo.org - ©1999-2002 ibuildings.nl BV