From: andi <bin...@li...> - 2001-09-25 22:51:56
|
andi Tue Sep 25 15:51:51 2001 EDT Modified files: /r2/binarycloud/base/mod/bcc BccModuleCompiler.php Log: BccModuleCompiler works now with SML Syntax !! Index: r2/binarycloud/base/mod/bcc/BccModuleCompiler.php diff -u r2/binarycloud/base/mod/bcc/BccModuleCompiler.php:1.1 r2/binarycloud/base/mod/bcc/BccModuleCompiler.php:1.2 --- r2/binarycloud/base/mod/bcc/BccModuleCompiler.php:1.1 Sat Sep 22 12:58:15 2001 +++ r2/binarycloud/base/mod/bcc/BccModuleCompiler.php Tue Sep 25 15:51:51 2001 @@ -1,7 +1,7 @@ <?php // Header {{{ /* - * -File $Id: BccModuleCompiler.php,v 1.1 2001/09/22 19:58:15 andi Exp $ + * -File $Id: BccModuleCompiler.php,v 1.2 2001/09/25 22:51:51 andi Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, Andreas Aderhold * -Authors Andreas Aderhold, <an...@bi...> @@ -13,38 +13,49 @@ // {{{ BccModuleCompiler class BccModuleCompiler { - var $output = false; // echo output or return - var $data = ""; // will contain the tag to compile + /* config var, echo output? */ + var $output = false; + + /* config var, tagdata to compile */ + var $data = ""; + + /* internal buffer */ + var $compiled =""; // compiled data buffer + + + /** */ function BccModuleCompiler($_params) { extract_params($this, $_params); - // compile tag in $this->data + import('ext.metabase.xml_parser'); + import('binarycloud.lib.XMLUtils'); + + $trees = XMLUtils::XMLStr2XML($this->data); + $xmlTree = $trees[0]; + $phpTree = XMLUtils::XML2PHP($xmlTree); + $txtTree = XMLUtils::PHP2PHPArr($phpTree, false); + $this->compiled = str_replace(');',')', $txtTree); + return true; } + /** */ function Output() { - $strBuffer = "Module Compiler Output"; - if ($this->output != true) { - return $strBuffer; + $strFormat = "<? global \$Page;\n\$Page->BuildStaticModule(".$this->compiled.");\n?>"; + if (!$this->error) { + if ($this->output != true) { + return $strFormat; + } else { + echo $strFormat; + } } else { - echo $strBuffer; + echo $this->error; + return false; } } } -/* -function BCCompileModuleTag($_tags) { - // translating xml to php by using XMLUtils - // this seems not to work for tag attributes - - $trees = XMLUtils::XMLStr2XML($_tags); - $xmlTree = $trees[0]; - $phpTree = XMLUtils::XML2PHP($xmlTree); - $txtTree = XMLUtils::PHP2PHPArr($phpTree,false); - return $txtTree; -} -*/ // }}} /* * Local Variables: |
From: andi <bin...@li...> - 2001-10-02 13:12:40
|
andi Tue Oct 2 06:12:34 2001 EDT Modified files: /r2/binarycloud/base/mod/bcc BccModuleCompiler.php Log: Staticmodule, GroupOutput and ModuleOutput syntax works now Index: r2/binarycloud/base/mod/bcc/BccModuleCompiler.php diff -u r2/binarycloud/base/mod/bcc/BccModuleCompiler.php:1.2 r2/binarycloud/base/mod/bcc/BccModuleCompiler.php:1.3 --- r2/binarycloud/base/mod/bcc/BccModuleCompiler.php:1.2 Tue Sep 25 15:51:51 2001 +++ r2/binarycloud/base/mod/bcc/BccModuleCompiler.php Tue Oct 2 06:12:34 2001 @@ -1,7 +1,7 @@ <?php // Header {{{ /* - * -File $Id: BccModuleCompiler.php,v 1.2 2001/09/25 22:51:51 andi Exp $ + * -File $Id: BccModuleCompiler.php,v 1.3 2001/10/02 13:12:34 andi Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, Andreas Aderhold * -Authors Andreas Aderhold, <an...@bi...> @@ -14,42 +14,75 @@ class BccModuleCompiler { - /* config var, echo output? */ - var $output = false; + /** config var, echo output? */ + var $output = false; - /* config var, tagdata to compile */ + /** strip newlines, tabs, whitespaces from output */ + var $compact = false; + + /** config var, tagdata to compile */ var $data = ""; - /* internal buffer */ + /** internal buffer */ var $compiled =""; // compiled data buffer + /** format templates for the tags */ + var $tmplModuleOutput = "<?global \$Page?>\n<?=\$Page->output['%s']['%s'];?>"; + var $tmplGroupOutput = "<?global \$Page?>\n<?=\$Page->output['%s'];?>"; + var $tmplStaticOutput = "<?global \$Page?>\n<?=\$Page->BuildStaticModule(%s);?>"; /** */ function BccModuleCompiler($_params) { + + /* extract module parameters to class namespace */ extract_params($this, $_params); - import('ext.metabase.xml_parser'); + + /* import the xml utils */ import('binarycloud.lib.XMLUtils'); + /* generate php array from xml data */ $trees = XMLUtils::XMLStr2XML($this->data); $xmlTree = $trees[0]; $phpTree = XMLUtils::XML2PHP($xmlTree); - $txtTree = XMLUtils::PHP2PHPArr($phpTree, false); - $this->compiled = str_replace(');',')', $txtTree); - return true; + /* look what tag type occured and apply format */ + if (isset($phpTree['group'])) { + /* we have a module output tag */ + if (isset($phpTree['index'])) { + $this->compiled = sprintf($this->tmplModuleOutput, $phpTree['group'], $phpTree['index']); + return true; + } else { + /* we have a group output tag */ + $this->compiled = sprintf($this->tmplGroupOutput, $phpTree['group']); + return true; + } + } else { + /* we have a static module tag */ + $txtTree = XMLUtils::PHP2PHPArr($phpTree, false); + $strArray = str_replace(');',')', $txtTree); + $this->compiled = sprintf($this->tmplStaticOutput, $strArray); + return true; + } } /** */ function Output() { + + /* look if we want formated output or strip whitespace, tabs, etc */ + if ($this->compact != false) { + $this->compiled=preg_replace ("/([\r\n\t])[\s]+/", "", $this->compiled); + } - $strFormat = "<? global \$Page;\n\$Page->BuildStaticModule(".$this->compiled.");\n?>"; + /* check if error occured */ if (!$this->error) { + /* all done, check if compiled tag to be echoed or returned */ if ($this->output != true) { - return $strFormat; + return $this->compiled; } else { - echo $strFormat; + echo $this->compiled; } } else { + /* display error, return false to bcc */ echo $this->error; return false; } |
From: jason <ja...@gr...> - 2001-09-26 00:39:56
|
Curious.. How are these commit logs being broadcasted to the list? Is there any automation here or do we just paste a diff? jason |