openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit ab6e31ed01688af69ab6023b407f09e65a0c1e3b
parent 4bdd3bbde97e3f381e9d58f79b104798400a963c
Author: dankert <devnull@localhost>
Date:   Thu, 27 Jul 2006 22:32:39 +0200

Auswerten Datei *.el.php

Diffstat:
serviceClasses/TemplateEngine.class.php | 71++++++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/serviceClasses/TemplateEngine.class.php b/serviceClasses/TemplateEngine.class.php @@ -68,49 +68,53 @@ class TemplateEngine $raw = false; $openCmd = array(); -// echo "<pre>"; -// print_r($document); -// echo "</pre>"; - foreach( $document as $line ) { - if ( !isset($line['attributes']) ) - $line['attributes'] = array(); - - $line['attributes'] = $this->checkAttributes($line['tag'],$line['attributes']); + // Initialisieren der möglichen Element-Inhalte + $type = ''; + $attributes = array(); + $value = ''; + $tag = ''; + + + // Setzt: $tag, $attributes, $value, $type + extract( $line ); + + if ($type == 'complete' || $type == 'open') + $attributes = $this->checkAttributes($tag,$attributes); - if ( $line['tag'] == 'raw' ) - fwrite( $outFile,$line['value']."\n"); - elseif ( $line['type'] == 'open' ) - $this->copyFileContents( $line['tag'],$outFile,$line['attributes'] ); - elseif ( $line['type'] == 'complete' ) + if ( $tag == 'raw' ) + fwrite( $outFile,$value."\n"); + elseif ( $type == 'open' ) + $this->copyFileContents( $tag,$outFile,$attributes ); + elseif ( $type == 'complete' ) { - $this->copyFileContents( $line['tag'],$outFile,$line['attributes'] ); - $this->copyFileContents( $line['tag'].'-end',$outFile,array() ); + $this->copyFileContents( $tag,$outFile,$attributes ); + $this->copyFileContents( $tag.'-end',$outFile,array() ); } - elseif ( $line['type'] == 'close' ) - $this->copyFileContents( $line['tag'].'-end',$outFile,array() ); - } - - // Am Ende der Datei alle offenen Tags schließen - $openCmdCopy = $openCmd; - krsort($openCmdCopy); - foreach($openCmdCopy as $idx=>$ccmd) - { - $this->copyFileContents( $ccmd.'-end',$outFile,array() ); - unset($openCmd[$idx]); + elseif ( $type == 'close' ) + $this->copyFileContents( $tag.'-end',$outFile,array() ); } fclose($outFile); } + + function getElementValue( $elFilename,$attributes ) + { + extract($attributes); + require($elFilename); + return $value; + } + function copyFileContents( $infile,$outFileHandler,$attr ) { global $conf; // Logger::debug("Inserting template command: ".$infile); $inFileName = OR_THEMES_DIR.$conf['interface']['theme'].'/include/html/'.$infile.'.inc.'.PHP_EXT; + $elFileName = OR_THEMES_DIR.$conf['interface']['theme'].'/include/html/'.$infile.'.el.' .PHP_EXT; if ( !is_file($inFileName) ) if ( count($attr)==0 ) return; @@ -140,6 +144,11 @@ class TemplateEngine fwrite( $outFileHandler,'<?php unset($attr_'.$attrName.') ?>'); // foreach( $attr as $attrName=>$attrValue ) // fwrite( $outFileHandler,'<?php unset($'.$attrName.') ? >'); + + if ( is_file($elFileName) ) + { + fwrite( $outFileHandler, $this->getElementValue( $elFileName,$attr) ); + } } @@ -186,15 +195,7 @@ class TemplateEngine function loadDocument( $filename ) { -// echo $filename.':'; -// echo strrpos($filename,'.xml'); -// echo '---'; -// echo strlen($filename)-4; -// if ( strrpos('.xml',$filename) == strlen($filename)-3 ) -// echo" a"; -// else -// echo "b"; - if ( strrpos($filename,'.xml') == strlen($filename)-4 ) + if ( substr($filename,-4)=='.xml') return $this->loadXmlDocument( $filename ); else return $this->loadOrmlDocument( $filename );