Re: HTML_Template_Flexy private vars in controller
| From: | Didier Galland | Date: | Sat, 05 Jul 2003 23:48:12 +0000 |
| Subject: | Re: HTML_Template_Flexy private vars in controller | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-6499@lists.php.net to get a copy of this message | ||
Thanks a lot for your help.
You're right, this is not really related to flexy api/code. It was only an
idea based on a feature of flexy.
Regards,
Didier
"Alan Knowles" <alan@akbkhome.com> a écrit dans le message de news:
3F064A1A.9090307@akbkhome.com...
> Didier Galland wrote:
> > I'll try to be more clear (my english is not very good). The goal is to
> > hide internal stuff from outside (esp. designers) : private vars are
> > impossible to output, phpdocumenter won't parse them, flexy will ignore
> > them, etc.
> > You ask me for an example :
> > I've wrote this method in my parent class controller :
> > function set_tags($object)//param $object is a data object
> > {
> > foreach(get_object_vars($this) as $tag_name => $default_value) {
> if ($tag_name{0} == '_') {
> continue;
> }
>
>
> > if (!is_array($this->$tag_name)) {
> > $tag_value = $object->get($tag_name);
> > if (!empty($tag_value)) {
> > $this->$tag_name = $tag_value;
> > } elseif (!empty($default_value)) {
> > $this->$tag_name = $default_value;//value in
declaration
> > of var
> > }
> continue;
> }
> if (is_array($this->$tag_name) && method_exists($this,'set_' .
> $tag_name)) {
>
>
> > //used for lists of other objects, $products in a
category
> > page e.g.
> > $method = 'set_' . $tag_name;//name of the method that
set
> > the array of objects
> > $this->$method($object->get('id'));
> > }
> > }
> > }
> > So, in sub-classes controller (in the constructor), I call
> > $this->set_vars($_page_object) and all my declared vars are set
> > automatically.
> >
> > The downside of this is that even $vars that are not intended to be
output
> > ($_template, $_modulename of sub-controller, etc.) are set by this
method.
> > Indeed, get_object_vars considers all vars, included private ones,
useless
> > parsing can then occurs. So if private vars are ignored by flexy, I save
> > some parsing (?? I'm not sure, and I don't know performance effects).
> >
> flexy ignores these variables at compile time, by ignoring {_a} or
> {someobject._a}
>
> the above skip should stop your private variables being loaded. - but I
> dont think it really related to flexy's API/code..
>
>
> > btw:
> > {t:r} triggers a
> > "Warning: htmlspecialchars() expects parameter 1 to be string, object
given"
>
> I've got quite a few patches and things queued up for changes on flexy
> at the moment, and I'll see if I can get this added in.
>
> Regards
> Alan
>
>
>
>
>
> > Regards,
> >
> > Didier
> >
> >
> > "Alan Knowles" <alan@akbkhome.com> a écrit dans le message de news:
> > 3F02278E.5020402@akbkhome.com...
> >
> >>Didier Galland wrote:
> >>
> >>>Is Flexy skipping private vars in the controller and doesn't output
them
> >
> > ? I
> >
> >>>mean vars that begins by an underscore. So if $_test in the controller
> >
> > and
> >
> >>>{_test} in the template, {_test} is outputed without modification
> >
> > ({test}
> >
> >>>from $test is outputed normally).
> >>>
> >>>I would like to know if this is an intended feature
> >>
> >>It was.
> >>and if this feature will
> >>
> >>>remains in future versions of flexy.
> >>
> >>I'm open to ideas on this.
> >>
> >>It is (would be ?) a nice feature, when
> >>
> >>>setting vars to output automatically (with get_object_vars($this)
e.g.),
> >>
> >>the old version did do something like that, if you have not disabled php
> >>in code, at present you can do
> >><script language="php">
> >>print_r($t);
> >></script>
> >>
> >>from what I remember, I did add it as a modifier in early versions -
> >>eg:
> >>{t:r}
> >>but have no made any decisisons on modifiers for the current version.
> >>
> >>
> >>
> >>>also providing a mean to set a nice api / doc for designers (hiding
> >
> > private
> >
> >>>vars).
> >>
> >>Not quite sure what you are getting at here - have you got an example?
> >>
> >>Regards
> >>Alan
> >>
> >>>Regards,
> >>>
> >>>Didier
> >>>
> >>>
> >>
> >
> >
> >
>
>
> --
> Can you help out?
> Need Consulting Services or Know of a Job?
> http://www.akbkhome.com
>