From: andi <bin...@li...> - 2001-10-09 17:26:53
|
andi Tue Oct 9 10:26:48 2001 EDT Added files: /r2/binarycloud/base/mod/bcc BccHrefCompiler.php Log: Very early HREF compiler. Does not work now, so don't register this one to bcc! Index: r2/binarycloud/base/mod/bcc/BccHrefCompiler.php +++ r2/binarycloud/base/mod/bcc/BccHrefCompiler.php <?php // Header {{{ /* * -File $Id: BccHrefCompiler.php,v 1.1 2001/10/09 17:26:48 andi Exp $ * -License LGPL (http://www.gnu.org/copyleft/lesser.html) * -Copyright 2001, Andreas Aderhold * -Authors Andreas Aderhold, <an...@bi...> */ $PACKAGE='binarycloud.mod.bcc'; // }}} // {{{ BccHrefCompiler class BccHrefCompiler { /** 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; function BccHrefCompiler($_params) { global $UrlRepository; /* extract module parameters to class namespace */ extract_params($this, $_params); /* import the xml utils */ import('binarycloud.lib.XMLUtils'); /* import the repository and reference it to classvar*/ import('user.conf.UrlRepository'); $this->urls =& $UrlRepository; /* generate php array from xml data */ $trees = XMLUtils::XMLStr2XML($this->data); $xmlTree = $trees[0]; $phpTree = XMLUtils::XML2PHP($xmlTree); $urlId =& $phpTree['id']; if (isset($urlId)) { /* we have a repository lookup */ for($i=0;$i<count($this->urls);$i++) { if ($this->urls[$i]['id'] === $urlId) { $this->compiled = $this->UrlToHtml($this->urls[$i]); break; } } } else { /* we have a direct entry */ $this->compiled = $this->UrlToHtml($phpTree); } return true; } function Output() { if ($this->output != true) { return $this->compiled; } else { echo $this->compiled; } } /** * converts a url tag entry to a valid html tag */ function UrlToHtml(&$_url) { $html = "<a"; foreach($_url as $tag => $value) { switch ($tag) { case 'href': $html .= ' href="'; if (isset($_url['usedocroot']) && $_url['usedocroot'] != false) { $html .= BC_LANG.'/'.$value; } else { $html .=$value; } $html .= '"'; break; /* convert 1:1 */ case 'attributes': foreach ($_url['attributes'] as $attName => $attValue) { $html .= ' '.$attName.'="'.$attValue.'"'; } break; } } /* xhtml closing or ordinary html ? */ if ($this->xhtml != false) { $html .= "</a>"; } else { $html .= "</a>"; } return $html; } } // }}} /* * Local Variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * End: */ ?> |