[Chameleon] Server side include?

Julien-Samuel Lacroix jlacroix at dmsolutions.ca
Wed Jul 7 14:31:47 EDT 2004


Thanks pxniw,
:)

I open a enhancement bug about this in the Chameleon bugzilla.
http://www.maptools.org/bugzilla/show_bug.cgi?id=502

You can add yourself in CC if you wan to see the evolution of the bug.

Julien


pxniw pxniw wrote:
> Ok here is the code:
> (No performance hit noted btw)
> and works great. ;)
> 
> Start Code
> 
> // 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();
>     }
> 
> End Code
> 
> 
> 
> 


-- 
------------------------------------------------------------
Julien-Samuel Lacroix            jlacroix at dmsolutions.ca
DM Solutions Group               http://www.dmsolutions.ca/
------------------------------------------------------------


More information about the Chameleon mailing list