Re: [Formsess-devel] smarty-vars/functions in fs-tags
Status: Beta
Brought to you by:
mrkatana
|
From: David <da...@df...> - 2003-12-10 10:16:08
|
On Wed, 10 Dec 2003 09:22:40 +0100
Katana <ka...@ka...> wrote:
> glueAttributes just returns a string with arguments ready to be used
> in a smarty function call. If another smarty function call (capture)
> is inserted in that string, we will probably end up with a parse error
>
> won't we ?
You're right.. I should have looked a little closer to the context..
> {fs_input_text name="foo" {capture ...
> We probably need to
> - keep in a property the list of captures
> - return from glueAttributes with a string containing the capture
> names when needed
Yes, what do you think about that:
adding another property 'captures' to FormsessTag
var $captures;
initialising it onthe constructor:
$this->captures = array();
and accessing it via glueAttributes:
===
function glueAttributes() {
$string = '';
$atts = getAllAttributes();
foreach ($atts as $name => $value) {
if (!$value or ($value == 'false')) {
$format = ' %s=%s';
} elseif ($this->_fs_filter->_isSmartyVar($value)) {
//we can use a single var directly
$value = $this->smartyVariableRemoveDelimiters($value);
$format = '%s=%s';
} elseif (strpos($value, $this->_fs_filter->smarty_ldelim) !== false) {
//we need to capture the value
$value = 'fs_capture_' . count($this->captures);
$this->captures[] = $value;
$format = '%s=%s';
} else {
//value is a simple string
$format = ' %s="%s"';
}
$string .= sprintf(' %s="%s"', $name, $value);
}
return $string;
}
===
> - prepend the captured captures (ahaha.. ahem, right) to the tag
> string before it is returned.
I'm not sure how to accomplish that.
One solution is building a function adCaptures($string) that simply adds
the capture-tags to the given smarty-function and is called by the
extending function at the very end.
like
function addCaptures($string) {
$tmp = '';
foreach($this->captures)
//add capturetag tp $tmp
return $tmp . $string;
}
And in the extending functions for example:
return addCaptures($this->smartyEmbed('fs_html_select_date' . $this->glueAttributes()));
I'm not very happy with that, maybe you have a better idea..
Another thing: the input.class.php does that:
$string = 'fs_input_' . $this->getAttributeValue('type') . ' name="' . $this->getAttributeValue('name') . '"';
$this->deleteAttribute('type'); $this->deleteAttribute('value');
Which prevents the name and type attribute from beeing captured.
Is there any reason not to handle them like the other attributes?
David
|