|
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;
}
|