Re: Bug in Smarty Compiler concerning constants?

Jan Rosier <[email protected]>
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
Just an idea. You could also change the test function you use in the { 
if } tags to detect that it got the constant as a string.

class Example
{

    /**
    * Example function
    *
    * @access   public
    *
    * @param    integer|string
    *
    * @return   boolean
    */
    function hasPerm($perm)
    {
        if (is_string($perm)) {
            $perm = constant($perm);
        }
        if (is_integer($perm)) {
            if (($this->getUserPermissies() & $perm) == $perm) {
                    return TRUE;
            }
        }
        return FALSE;
    }

}

Greetings, 
Jan Rosier

* Space and time are relative. - Albert Einstein *



Oliver Jones wrote:

>On Mon, 2005-03-07 at 23:04 -0800, boots wrote:
>  
>
>>It looks like there is an issue but I believe that Smarty should output
>>quoted text rather than a constant token, not? Especially since
>>constants are accessed from the $smarty reserved variable, ie:
>>$smarty.const.CONSTANT.
>>    
>>
>
>Erk.  No.  That would be annoying.  Sure I can understand using
>$smarty.const.CONSTANT etc when using the {$var} syntax as without a
>prefix there would be no way of differentiating between function calls
>and constants but that is just plain annoying (and unnecessary) in {if }
>tags.  Though understandable if you wanted a consistent API.
>
>Personally I'm not a huge fan of the whole
>$smarty.{section,const,capture} business.
>
>Regads
>--
>                   Oliver Jones » Roving Code Warrior
>   [email protected] » +64 (21) 41 2238 » www.deeperdesign.com 
>
>  
>

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.