andi Sun Oct 7 08:29:02 2001 EDT Modified files: /r2/binarycloud/make bcc.php /r2/binarycloud/base/mod/bcc BccImgCompiler.php /r2/binarycloud/user/conf ImageRepository.php.xml /r2/binarycloud/user/htdocs compilertest.html Log: BccImageCompiler works now Index: r2/binarycloud/make/bcc.php diff -u r2/binarycloud/make/bcc.php:1.1 r2/binarycloud/make/bcc.php:1.2 --- r2/binarycloud/make/bcc.php:1.1 Wed Oct 3 16:41:19 2001 +++ r2/binarycloud/make/bcc.php Sun Oct 7 08:29:02 2001 @@ -2,7 +2,7 @@ <?php // {{{ Header /* - * -File $Id: bcc.php,v 1.1 2001/10/03 23:41:19 alex Exp $ + * -File $Id: bcc.php,v 1.2 2001/10/07 15:29:02 andi Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, Intacct Corp. * -Author odysseas tsatalos, ody...@ya... @@ -25,6 +25,8 @@ /* this is the constant for lang/htdocs */ define('BC_PATH_RESOURCES', '/'.$bcLang); + define('BC_LANG', strtolower($bcLang)); + // define('BC_PATH', $bcBuildPath); include_once($bcBuildPath. '/prepend.php'); Index: r2/binarycloud/base/mod/bcc/BccImgCompiler.php diff -u r2/binarycloud/base/mod/bcc/BccImgCompiler.php:1.1 r2/binarycloud/base/mod/bcc/BccImgCompiler.php:1.2 --- r2/binarycloud/base/mod/bcc/BccImgCompiler.php:1.1 Sat Sep 22 12:58:15 2001 +++ r2/binarycloud/base/mod/bcc/BccImgCompiler.php Sun Oct 7 08:29:02 2001 @@ -1,7 +1,7 @@ <?php // Header {{{ /* - * -File $Id: BccImgCompiler.php,v 1.1 2001/09/22 19:58:15 andi Exp $ + * -File $Id: BccImgCompiler.php,v 1.2 2001/10/07 15:29:02 andi Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, Andreas Aderhold * -Authors Andreas Aderhold, <an...@bi...> @@ -13,23 +13,134 @@ // {{{ BccImgCompiler class BccImgCompiler { - var $output = false; // echo output or return - var $data = ""; // will contain the tag to compile + /** echo or return compiled tag */ + var $output = false; + + /** the tag to be compiled */ + var $data = ""; + + /** the compiled tag */ + var $compiled =""; + + /** generate xhtml output */ + var $xhtml = true; + + /** do we have gd library? */ + var $haveGd = false; + + function BccImgCompiler($_params) { + + global $ImageRepository; + + /* extract module parameters to class namespace */ extract_params($this, $_params); - // compile tag in $this->data + + /* import the xml utils */ + import('binarycloud.lib.XMLUtils'); + + /* import the repository and reference it to classvar*/ + import('user.conf.ImageRepository'); + $this->images =& $ImageRepository; + + /* check if gd is available */ + + if (extension_loaded("gd")) { + $this->haveGd = true; + } + + /* generate php array from xml data */ + $trees = XMLUtils::XMLStr2XML($this->data); + $xmlTree = $trees[0]; + $phpTree = XMLUtils::XML2PHP($xmlTree); + + $imgId =& $phpTree['id']; + + for($i=0;$i<count($this->images);$i++) { + if ($this->images[$i]['id'] === $imgId) { + $this->compiled = $this->ImageToHtml($this->images[$i]); + break; + } + } + return true; } function Output() { - $strBuffer = "Img Compiler Output"; if ($this->output != true) { - return $strBuffer; + return $this->compiled; + } else { + echo $this->compiled; + } + } + + + /** + * converts a image repository entry to a valid html tag + */ + function ImageToHtml(&$_image) { + + $html = "<img"; + + if (isset($_image['src'])) { + $html .= ' src="'.BC_PATH_RESOURCES.$_image['src'].'"'; + } else { + return false; + } + if (isset($_image['name'])) { + $html .= ' name="'.$_image['name'].'"'; + } + if (isset($_image['alt']) && $_image['alt'] != false) { + if (isset($_image['alt'][BC_LANG])) { + $html .= ' alt="'.$_image['alt'][BC_LANG].'"'; + } + } + if (isset($_image['align']) && $_image['align'] != false) { + $html .= ' align="'.$_image['align'].'"'; + } + + /* if gd is available and the size parameters are set to false, + we determine the image size automatically, else it's left to + the browser */ + if ($this->haveGd != false && $_image['hspace'] === false && $_image['vspace'] === false) { + + $size = GetImageSize (BC_PATH.'/en/htdocs/'.$_image['src']); + $html .= $size[3]; + + } else { + + if (isset($_image['hspace']) && $_image['hspace'] != false) { + $html .= ' hspace="'.$_image['hspace'].'"'; + } + if (isset($_image['vspace']) && $_image['vspace'] != false) { + $html .= ' vspace="'.$_image['vspace'].'"'; + } + } + + if (isset($_image['border']) && $_image['border'] != false) { + $html .= ' border="'.$_image['border'].'"'; + } else { + $html .= ' border="0"'; + } + if (isset($_image['usemap']) && $_image['usemap'] != false) { + $html .= ' usemap="'.$_image['usemap'].'"'; + } + if (isset($_image['width']) && $_image['width'] != false) { + $html .= ' width="'.$_image['width'].'"'; + } + if (isset($_image['height']) && $_image['height'] != false) { + $html .= ' height="'.$_image['height'].'"'; + } + + /* xhtml closing or ordinary html ? */ + if ($this->xhtml != false) { + $html .= " />"; } else { - echo $strBuffer; + $html .= ">"; } + return $html; } } Index: r2/binarycloud/user/conf/ImageRepository.php.xml diff -u r2/binarycloud/user/conf/ImageRepository.php.xml:1.1 r2/binarycloud/user/conf/ImageRepository.php.xml:1.2 --- r2/binarycloud/user/conf/ImageRepository.php.xml:1.1 Sun Oct 7 07:06:42 2001 +++ r2/binarycloud/user/conf/ImageRepository.php.xml Sun Oct 7 08:29:02 2001 @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- Header {{{ ******************************************************************************* -** -File $Id: ImageRepository.php.xml,v 1.1 2001/10/07 14:06:42 andi Exp $ +** -File $Id: ImageRepository.php.xml,v 1.2 2001/10/07 15:29:02 andi Exp $ ** -License LGPL (http://www.gnu.org/copyleft/lesser.html) ** -Copyright 2001, The Turing Studio, Inc. ** -Author alex black, en...@tu... @@ -11,23 +11,23 @@ <images> <image> <id>bcFire</id> - <src>resources/images/binarycloud/tmpl/fire.jpg</src> + <src>/resources/images/binarycloud/tmpl/fire.jpg</src> <name>ImageName</name> <alt> <en>binarycloud fire</en> <de>binarycloud Feuer</de> </alt> <align>left</align> - <hspace>10</hspace> - <vspace>10</vspace> + <hspace>false</hspace> + <vspace>false</vspace> <border>0</border> <usemap>#moo</usemap> - <width>400</width> - <height>20</height> + <width>false</width> + <height>false</height> </image> <image> <id>StormHeader</id> - <src>resources/images/binarycloud/strom/storm_header.gif</src> + <src>/resources/images/binarycloud/strom/storm_header.gif</src> <name>stromHeader</name> <alt> <en>Storm Header</en> @@ -36,9 +36,9 @@ <align>left</align> <hspace>false</hspace> <vspace>false</vspace> - <border>0</border> + <border>false</border> <usemap>false</usemap> - <width>auto</width> - <height>auto</height> + <width>false</width> + <height>false</height> </image> </images> Index: r2/binarycloud/user/htdocs/compilertest.html diff -u r2/binarycloud/user/htdocs/compilertest.html:1.6 r2/binarycloud/user/htdocs/compilertest.html:1.7 --- r2/binarycloud/user/htdocs/compilertest.html:1.6 Tue Oct 2 23:51:05 2001 +++ r2/binarycloud/user/htdocs/compilertest.html Sun Oct 7 08:29:02 2001 @@ -1,7 +1,7 @@ <?php // {{{ Header /* - * -File $Id: compilertest.html,v 1.6 2001/10/03 06:51:05 alex Exp $ + * -File $Id: compilertest.html,v 1.7 2001/10/07 15:29:02 andi Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, The Turing Studio, Inc. * -Author alex black, en...@tu... @@ -33,11 +33,6 @@ ); $Init->Startup(); ?> -<!-- a binarycloud system tag --> -<bc:global> - <page>true</page> -</bc:global> -<!-- a binarycloud system tag --> <html> <head> <title>Test</title> @@ -80,7 +75,13 @@ <!-- a binarycloud image tag --> <bc:img> - <id>abcimg</id> + <id>bcFire</id> +</bc:img> +<!-- /binarycloud image tag --> +<br /> +<!-- a binarycloud image tag --> +<bc:img> + <id>StormHeader</id> </bc:img> <!-- /binarycloud image tag --> |