From: Leandro Lucarella Date: Sun, 6 Jul 2003 00:45:56 +0000 (+0000) Subject: Base package is splited (again), so BIFE no longer depends on X-Git-Tag: 0.11~4 X-Git-Url: https://git.llucax.com/software/bife/base.git/commitdiff_plain/edb616c88535d349477e652c16b13d8c79e01266 Base package is splited (again), so BIFE no longer depends on HTML_Template_HIT. A new structure in modules is tested. --- edb616c88535d349477e652c16b13d8c79e01266 diff --git a/BIFE/Link.php b/BIFE/Link.php new file mode 100644 index 0000000..8204db0 --- /dev/null +++ b/BIFE/Link.php @@ -0,0 +1,126 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + +// +X2C includes +require_once 'BIFE/Container.php'; +// ~X2C + +// +X2C Class 110 :Link +/** + * Link to another page. + * + * @package BIFE + * @access public + */ +class BIFE_Link extends BIFE_Container { + // ~X2C + + // +X2C Operation 111 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function BIFE_Link($attrs) // ~X2C + { + $this->__construct($attrs); + } + // -X2C + + // +X2C Operation 112 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($attrs) // ~X2C + { + $link_attrs['URL'] = $this->getURL($attrs); + $link_attrs['DESC'] = @$attrs['DESC']; + $link_attrs['TARGET'] = @$attrs['TARGET']; + parent::__construct($link_attrs); + } + // -X2C + + // +X2C Operation 142 + /** + * Gets a URL string based on Link attributes. + * + * @param array $attrs Link attributes. + * + * @return string + * @access public + */ + function getURL($attrs) // ~X2C + { + $url = @$attrs['URL']; + unset($attrs['URL']); + if (isset($attrs['BIFE'])) { + $attrs['DATA-BIFE'] = $attrs['BIFE']; + unset($attrs['BIFE']); + } + $query = array(); + foreach($attrs as $name => $value) { + if (substr($name, 0, 5) === 'DATA-') { + if ($name = substr($name, 5)) { + $query[] = urlencode($name) . '=' . urlencode($value); + } + } + } + if ($query) { + $url .= '?' . join('&', $query); + } + return $url; + } + // -X2C + + // +X2C Operation 157 + /** + * Renders the widget. + * + * @param HTML_Template_HIT &$template Template to use to render the widget. + * + * @return string + * @access public + */ + function render(&$template) // ~X2C + { + $this->attrs['CONTENTS'] = $this->renderContents($template); + return $template->parse('bife_link', $this->attrs, '', ''); + } + // -X2C + +} // -X2C Class :Link + +?> \ No newline at end of file diff --git a/BIFE/Translate.php b/BIFE/Translate.php new file mode 100644 index 0000000..4c1fe05 --- /dev/null +++ b/BIFE/Translate.php @@ -0,0 +1,77 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + +// +X2C includes +require_once 'BIFE/Fallback.php'; +// ~X2C + +// +X2C Class 7 :Translate +/** + * This is a generic and simple (but very usefull) BIFE_Fallback implementation. Translate widgets using a template with it's name, prepended with 'bife_'. If not template is found, it copy the XML to the output. + * + * @package BIFE + * @access public + */ +class BIFE_Translate extends BIFE_Fallback { + // ~X2C + + // +X2C Operation 12 + /** + * Renders the widget. + * + * @param HTML_Template_HIT &$template Template to use to render the widget. + * + * @return string + * @access public + */ + function render(&$template) // ~X2C + { + $name = "bife_{$this->name}"; + if ($template->exists($name, '')) { + $this->attrs['CONTENTS'] = $this->renderContents($template); + $out = $template->parse($name, $this->attrs, '', ''); + } else { + $name = $this->name; + $out = "<$name"; + foreach ($this->attrs as $attr => $val) { + $out .= sprintf(' %s="%s"', $attr, $val); + } + $contents = $this->renderContents($template); + if ($contents !== '') { + $out .= ">$contents"; + } else { + $out .= "/>"; + } + } + return $out; + } + // -X2C + +} // -X2C Class :Translate + +?> \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..13737e0 --- /dev/null +++ b/README @@ -0,0 +1,6 @@ +$Id$ + +This is a basic implementation of BIFE to make a simple website or to use it +to make more complex widgets. + +There's a tentative roadmap in ROADMAP. diff --git a/ROADMAP b/ROADMAP new file mode 100644 index 0000000..801d858 --- /dev/null +++ b/ROADMAP @@ -0,0 +1,21 @@ +$Id$ + + +Version 0.12 +============ + + - Look if using $_SERVER['PATH_INFO'] in Link is viable. + + +Version 0.13 +============ + + - Start using config file for default widgets attributes. + +... + +Version 0.x +============ + - Make a way to put all classes in a package together in a single file to + avoid overhead in require_once calls (to be reviewed). + diff --git a/bife.xmi b/bife.xmi new file mode 100644 index 0000000..bdf7124 --- /dev/null +++ b/bife.xmi @@ -0,0 +1,89 @@ + + + + + umbrello uml modeller http://uml.sf.net + 1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/index.php b/examples/index.php new file mode 100644 index 0000000..c38ac9c --- /dev/null +++ b/examples/index.php @@ -0,0 +1,48 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + +$tmp = ini_get('include_path'); +ini_set('include_path', "..:$tmp"); +unset($tmp); +umask('002'); + +require_once 'HTML/Template/HIT.php'; +require_once 'BIFE/Parser.php'; +require_once 'BIFE/Translate.php'; + +$file = isset($_REQUEST['BIFE']) ? $_REQUEST['BIFE'] : 'index.xbf'; +#$file = isset($_SERVER['PATH_INFO']) ? ".{$_SERVER['PATH_INFO']}" : 'index.xbf'; + +$template =& new HTML_Template_HIT('templates'); + +$parser =& new BIFE_Parser('BIFE_Translate'); +$page =& $parser->parseFile($file); +$parser->__destruct(); +echo $page->render($template); + +?> diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..3cfff25 --- /dev/null +++ b/package.xml @@ -0,0 +1,44 @@ + + + + BIFE_Base + BIFE's basic implementation to make a simple website + BIFE Base (tbd) + + GPL + + + luca + Leandro Lucarella + luca@lugmen.org.ar + lead + + + + + 1.0.0beta1 + 2003-06-29 + beta + Check http://bife.llucax.hn.org/ for details. + + + + + BIFE/Link.php + BIFE/Translate.php + + README + ROADMAP + examples/index.php + examples/index.xbf + examples/templates/bife_page.tpl.html + examples/templates/bife_title.tpl.html + examples/templates/bife_link.tpl.html + + + + 4.2.3 + BIFE + HTML_Template_HIT + + diff --git a/xmi2code.config b/xmi2code.config new file mode 100644 index 0000000..7540819 --- /dev/null +++ b/xmi2code.config @@ -0,0 +1,47 @@ + + + + +