[Chameleon-dev] [Bug 502] New: [Chameleon] Recursive preprocessing enhancement

bugzilla-daemon at www.maptools.org bugzilla-daemon at www.maptools.org
Wed Jul 7 13:57:29 EDT 2004


http://www.maptools.org/bugzilla/show_bug.cgi?id=502

           Summary: [Chameleon] Recursive preprocessing enhancement
           Product: Chameleon
           Version: 2.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Core
        AssignedTo: chameleon-dev at lists.maptools.org
        ReportedBy: jlacroix at dmsolutions.ca


Currently, Chameleon preprocessor do the parsing of [##] tags and then [$$]
tags. So you can't include [$$] tags in [##].

pxniw from the list suggest a patch that will do [$$], [##] and again [$$]:

// Start ADDED by PXNIW (Wanted to parse $$ tags
before ## tags
// replace all [$something$] to the correct url var
value
// This is duplicate code from below so $$ parses
before ##
        $nPos = strpos($this->mszTemplate, "[$");
        while($nPos !== false)
        {
            $nEndPos = strpos($this->mszTemplate,
"$]", $nPos);
            $szTag = substr($this->mszTemplate, $nPos,
$nEndPos-$nPos+2);

            if
(isset($oApp->moHttpFormVars->maszVars[strtoupper(substr($szTag,
2, -2))]))
                $this->mszTemplate =&
str_replace($szTag, 
                       
$oApp->moHttpFormVars->maszVars[strtoupper(substr($szTag,
2, -2))],
                        $this->mszTemplate);
            $nPos = strpos($this->mszTemplate, "[$",
$nPos+2);
        }
// END ADDED by PXNIW

        // First, include all files to include.
        $nPos = strpos($this->mszTemplate, "[#");
        while ($nPos !== false)
        {
            $nEndPos = strpos($this->mszTemplate,
"#]");

            if ($nEndPos === false)
                break;

            $szTemplateName =
substr($this->mszTemplate, $nPos+2, $nEndPos-$nPos-2);

            // Make a copy of the current teplate
            $szTemplate = $this->mszTemplate;

            $oApp->CWCLoadTemplate($szTemplateName);

            $this->mszTemplate =&
str_replace("[#$szTemplateName#]", $oApp->mszTemplate,
$szTemplate);

            $nPos = strpos($this->mszTemplate, "[#");
        }

        // Then, replace all [$something$] to the
correct url var value
        $nPos = strpos($this->mszTemplate, "[$");
        while($nPos !== false)
        {
            $nEndPos = strpos($this->mszTemplate,
"$]", $nPos);
            $szTag = substr($this->mszTemplate, $nPos,
$nEndPos-$nPos+2);

            if
(isset($oApp->moHttpFormVars->maszVars[strtoupper(substr($szTag,
2, -2))]))
                $this->mszTemplate =&
str_replace($szTag, 
                       
$oApp->moHttpFormVars->maszVars[strtoupper(substr($szTag,
2, -2))],
                        $this->mszTemplate);
            $nPos = strpos($this->mszTemplate, "[$",
$nPos+2);
        }

        if (strlen($this->mszTemplate) == 0)
            return 0;

        $this->maszElements = array();
        $this->maszPlaceholders = array();

        $this->mszTemplate = preg_replace_callback(
$this->mszPattern,
                    array( &$this, "ParseCallback" ),
$this->mszTemplate );

        return $this->NumElements();
    }



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


More information about the Chameleon-dev mailing list