From 94e74dd4e317d5217ada7bd1c5adefc1c34efcb7 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sun, 6 Jul 2003 00:45:56 +0000 Subject: [PATCH] Base package is splited (again), so BIFE no longer depends on HTML_Template_HIT. A new structure in modules is tested. --- base/BIFE/Container.php | 97 +++++++ base/BIFE/Fallback.php | 86 ++++++ base/BIFE/Link.php | 126 ++++++++ base/BIFE/Parser.php | 305 ++++++++++++++++++++ base/BIFE/Translate.php | 77 +++++ base/BIFE/Widget.php | 96 ++++++ base/Doxyfile | 227 +++++++++++++++ base/Makefile | 65 +++++ base/README | 6 + base/ROADMAP | 21 ++ base/bife.xmi | 89 ++++++ base/build.xml | 52 ++++ base/core/HTML/Template/HIT.php | 265 +++++++++++++++++ base/core/Makefile | 62 ++++ base/examples/index.php | 48 +++ base/examples/index.xbf | 9 + base/examples/link.xbf | 5 + base/examples/templates/bife_link.tpl.html | 1 + base/examples/templates/bife_page.tpl.html | 9 + base/examples/templates/bife_title.tpl.html | 1 + base/package.xml | 44 +++ base/xmi2code.config | 47 +++ base/xmi2code.tpl.php | 27 ++ bife/bife.xmi | 62 +--- 24 files changed, 1775 insertions(+), 52 deletions(-) create mode 100644 base/BIFE/Container.php create mode 100644 base/BIFE/Fallback.php create mode 100644 base/BIFE/Link.php create mode 100644 base/BIFE/Parser.php create mode 100644 base/BIFE/Translate.php create mode 100644 base/BIFE/Widget.php create mode 100644 base/Doxyfile create mode 100644 base/Makefile create mode 100644 base/README create mode 100644 base/ROADMAP create mode 100644 base/bife.xmi create mode 100644 base/build.xml create mode 100644 base/core/HTML/Template/HIT.php create mode 100644 base/core/Makefile create mode 100644 base/examples/index.php create mode 100644 base/examples/index.xbf create mode 100644 base/examples/link.xbf create mode 100644 base/examples/templates/bife_link.tpl.html create mode 100644 base/examples/templates/bife_page.tpl.html create mode 100644 base/examples/templates/bife_title.tpl.html create mode 100644 base/package.xml create mode 100644 base/xmi2code.config create mode 100644 base/xmi2code.tpl.php diff --git a/base/BIFE/Container.php b/base/BIFE/Container.php new file mode 100644 index 0000000..2ddc24d --- /dev/null +++ b/base/BIFE/Container.php @@ -0,0 +1,97 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + +// +X2C includes +require_once 'BIFE/Widget.php'; +// ~X2C + +// +X2C Class 5 :Container +/** + * Base container widget class. + * + * @access public + * @abstract + */ +class BIFE_Container extends BIFE_Widget { + /** + * Widget contents. + * + * @var array $contents + * @access public + */ + var $contents = array(); + + // ~X2C + + // +X2C Operation 6 + /** + * Adds contents to the container. + * + * @param mixed &$contents Contents to add to the container. + * + * @return void + * @access public + */ + function addContents(&$contents) // ~X2C + { + if (is_object($contents)) { + $this->contents[] =& $contents; + } else { + $this->contents[] = $contents; + } + } + // -X2C + + // +X2C Operation 59 + /** + * Renders the widget using a template returning a string with the results. + * + * @param HTML_Template_HIT &$template Template object to render the widget. + * + * @return string + * @access public + */ + function renderContents(&$template) // ~X2C + { + $c = count($this->contents); + $o = ''; + for ($i = 0; $i < $c; $i++) { + if (is_object($this->contents[$i])) { + $o .= $this->contents[$i]->render($template); + } else { + $o .= $this->contents[$i]; + } + } + return $o; + } + // -X2C + + +} // -X2C Class :Container + +?> \ No newline at end of file diff --git a/base/BIFE/Fallback.php b/base/BIFE/Fallback.php new file mode 100644 index 0000000..04a11b1 --- /dev/null +++ b/base/BIFE/Fallback.php @@ -0,0 +1,86 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + +// +X2C includes +require_once 'BIFE/Container.php'; +// ~X2C + +// +X2C Class 61 :Fallback +/** + * Fallback widget to use when no specific widget is implemented. + * + * @access public + * @abstract + */ +class BIFE_Fallback extends BIFE_Container { + /** + * Name of the widget. + * + * @var string $name + * @access private + */ + var $name = ''; + + // ~X2C + + // +X2C Operation 62 + /** + * Constructor. + * + * @param string $name Name of the widget to draw. + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function BIFE_Fallback($name, $attrs) // ~X2C + { + $this->__construct($name, $attrs); + } + // -X2C + + // +X2C Operation 63 + /** + * Constructor. + * + * @param string $name Name of the widget. + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($name, $attrs) // ~X2C + { + parent::__construct($attrs); + $this->name = strtolower(strtr($name, ':', '_')); + } + // -X2C + +} // -X2C Class :Fallback + +?> \ No newline at end of file diff --git a/base/BIFE/Link.php b/base/BIFE/Link.php new file mode 100644 index 0000000..8204db0 --- /dev/null +++ b/base/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/base/BIFE/Parser.php b/base/BIFE/Parser.php new file mode 100644 index 0000000..76a5845 --- /dev/null +++ b/base/BIFE/Parser.php @@ -0,0 +1,305 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + +// +X2C Class 25 :Parser +/** + * This is the XML Parser. + * + * @access public + */ +class BIFE_Parser { + /** + * Top level widget. + * + * @var BIFE_Widget $root + * @access protected + */ + var $root = null; + + /** + * XML parser resource. + * + * @var resource $parser + * @access protected + */ + var $parser = null; + + /** + * BIFE widgets stack. + * + * @var array $stack + * @access protected + */ + var $stack = array(); + + /** + * Fallback class to use in case that a widget class is not found. + * + * @var string $fallback + * @access protected + */ + var $fallback = ''; + + /** + * XML cache directory. Empty if no cahching must be done (for current dir use '.'). + * + * @var string $cache + * @access protected + */ + var $cache = '/tmp'; + + /** + * Files required by the parsed XML file. + * + * @var array $requires + * @access protected + */ + var $requires = array(); + + // ~X2C + + // +X2C Operation 30 + /** + * Constructor. + * + * @param string $fallback Fallback class name (none if empty). + * @param string $cache XML cache directory. Empty is no caching will be done. + * + * @return void + * @access public + */ + function BIFE_Parser($fallback = '', $cache = '/tmp') // ~X2C + { + $this->__construct($fallback, $cache); + } + // -X2C + + // +X2C Operation 31 + /** + * Constructor. + * + * @param string $fallback Fallback class name (none if empty). + * @param string $cache XML cache directory. Empty is no caching will be done. + * + * @return void + * @access public + */ + function __construct($fallback = '', $cache = '/tmp') // ~X2C + { + $this->parser = xml_parser_create(); + $this->fallback = $fallback; + $this->cache = $cache; + xml_set_object($this->parser, $this); + xml_set_element_handler($this->parser, 'startElement', 'endElement'); + xml_set_character_data_handler($this->parser, 'characterData'); + } + // -X2C + + // +X2C Operation 32 + /** + * Destructor. + * + * @return void + * @access public + */ + function __destruct() // ~X2C + { + xml_parser_free($this->parser); + } + // -X2C + + // +X2C Operation 33 + /** + * XML parser start of element handler. + * + * @param resource $parser XML parser resource. + * @param string $name XML tag name. + * @param array $attrs XML tag attributes. + * + * @return void + * @access public + */ + function startElement($parser, $name, $attrs) // ~X2C + { + $class = 'bife_' . strtolower(strtr($name, ':', '_')); + if (!class_exists($class)) { + $inc = 'BIFE/' . + strtr(ucwords(strtr(strtolower($name), ':', ' ')), ' ', '/') . + '.php'; + if (@include_once $inc) { + $this->includes[] = $inc; + } + } + if (class_exists($class)) { + $obj =& new $class($attrs); + // XXX - Does this check make sense? + if (!is_a($obj, 'bife_widget')) { + trigger_error("Class '$class' is not a BIFE_Widget.", E_USER_WARNING); + } + $this->stack[] =& $obj; + } else { + if ($this->fallback) { + $class = $this->fallback; + $obj =& new $class($name, $attrs); + if (!is_a($obj, 'bife_fallback')) { + trigger_error("Class '$class' is not a BIFE_Fallback.", E_USER_WARNING); + } + $this->stack[] =& $obj; + } else { + trigger_error("Class not found '$class'.", E_USER_ERROR); + } + } + } + // -X2C + + // +X2C Operation 34 + /** + * XML parser end of element handler. + * + * @param resource $parser XML parser resource. + * @param string $name XML tag name. + * + * @return void + * @access public + */ + function endElement($parser, $name) // ~X2C + { + end($this->stack); + $current =& $this->stack[key($this->stack)]; + array_pop($this->stack); + end($this->stack); + $parent =& $this->stack[key($this->stack)]; + if ($parent) { + $parent->addContents($current); + } else { + $this->root =& $current; + } + } + // -X2C + + // +X2C Operation 35 + /** + * XML parser character data handler. + * + * @param resource $parser XML parser resource. + * @param string $data XML character data. + * + * @return void + * @access public + */ + function characterData($parser, $data) // ~X2C + { + end($this->stack); + $current =& $this->stack[key($this->stack)]; + $current->addContents($data); + } + // -X2C + + // +X2C Operation 36 + /** + * Parse a string with XML data. + * + * @param string $data XML string to parse. + * @param bool $final Indicates if is the last string to parse. + * + * @return void + * @access public + */ + function parse($data, $final = true) // ~X2C + { + if (!xml_parse($this->parser, $data, $final)) { + trigger_error( + sprintf('XML error: %s at line %d.', + xml_error_string(xml_get_error_code($this->parser)), + xml_get_current_line_number($this->parser) + ), + E_USER_WARNING + ); + } + } + // -X2C + + // +X2C Operation 37 + /** + * Parse a XML file with a complete and valid XML document. + * + * @param string $filename Filename to parse. + * + * @return &BIFE_Widget + * @access public + */ + function &parseFile($filename) // ~X2C + { + if ($this->cache) { + $cache = $this->cache . '/' . 'bife_parser_cache' . strtr(realpath($filename), '/', '_'); + if (@filemtime($cache) > @filemtime($filename)) { + $file = file($cache); + foreach(unserialize(trim(array_shift($file))) as $required) { + include_once $required; + } + return unserialize(join('', $file)); + } + } + if ($fp = @fopen($filename, 'r')) { + while ($data = fread($fp, 4096)) { + $this->parse($data, feof($fp)); + } + } else { + trigger_error("Could not open BIFE XML input file '$filename'.", + E_USER_WARNING); + } + fclose($fp); + if ($this->cache) { + $fp = fopen($cache, 'w'); + fputs($fp, serialize($this->includes) . "\n"); + fputs($fp, serialize($this->root)); + fclose($fp); + } + return $this->root; + } + // -X2C + + // +X2C Operation 74 + /** + * Parse a XML string with a complete and valid XML document. + * + * @param string $data XML data to parse. + * + * @return &BIFE_Widget + * @access public + */ + function &parseString($data) // ~X2C + { + $this->parse($data, true); + return $this->root; + } + // -X2C + +} // -X2C Class :Parser + +?> \ No newline at end of file diff --git a/base/BIFE/Translate.php b/base/BIFE/Translate.php new file mode 100644 index 0000000..4c1fe05 --- /dev/null +++ b/base/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/base/BIFE/Widget.php b/base/BIFE/Widget.php new file mode 100644 index 0000000..5e0ab11 --- /dev/null +++ b/base/BIFE/Widget.php @@ -0,0 +1,96 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + +// +X2C Class 3 :Widget +/** + * Base widget class. + * + * @access public + * @abstract + */ +class BIFE_Widget { + /** + * Attribute list. + * + * @var array $attrs + * @access protected + */ + var $attrs = array(); + + // ~X2C + + // +X2C Operation 126 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function BIFE_Widget($attrs) // ~X2C + { + $this->__construct($attrs); + } + // -X2C + + // +X2C Operation 127 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($attrs) // ~X2C + { + $this->attrs = $attrs; + } + // -X2C + + // +X2C Operation 4 + /** + * Renders the widget using a template returning a string with the results. + * + * @param HTML_Template_HIT &$template Template object to render the widget. + * + * @return string + * @access public + * @abstract + */ + function render(&$template) // ~X2C + { + trigger_error('Method not implemented '.get_class($this). + '::render().', E_USER_ERROR); + } + // -X2C + +} // -X2C Class :Widget + +?> \ No newline at end of file diff --git a/base/Doxyfile b/base/Doxyfile new file mode 100644 index 0000000..caed41f --- /dev/null +++ b/base/Doxyfile @@ -0,0 +1,227 @@ +# vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: +# +--------------------------------------------------------------------+ +# | BIFE - Buil It FastEr | +# +--------------------------------------------------------------------+ +# | This file is part of BIFE. | +# | | +# | BIFE is free software; you can redistribute it and/or modify it | +# | under the terms of the GNU General Public License as published by | +# | the Free Software Foundation; either version 2 of the License, or | +# | (at your option) any later version. | +# | | +# | BIFE is distributed in the hope that it will be useful, but | +# | WITHOUT ANY WARRANTY; without even the implied warranty of | +# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | +# | General Public License for more details. | +# | | +# | You should have received a copy of the GNU General Public License | +# | along with Hooks; if not, write to the Free Software Foundation, | +# | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | +# +--------------------------------------------------------------------+ +# | Created: Mon May 19 00:16:56 ART 2003 | +# | Authors: Leandro Lucarella | +# +--------------------------------------------------------------------+ +# +# $Id$ +# + +# Doxyfile 1.3-rc3 +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "BIFE - Build It FastEr" +PROJECT_NUMBER = 0.11 +OUTPUT_DIRECTORY = api +OUTPUT_LANGUAGE = English +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = YES +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +INTERNAL_DOCS = YES +CASE_SENSE_NAMES = YES +SHORT_NAMES = NO +HIDE_SCOPE_NAMES = NO +VERBATIM_HEADERS = YES +SHOW_INCLUDE_FILES = YES +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ALIASES = +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +SHOW_USED_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = doxygen.warn +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = +FILE_PATTERNS = *.php +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 200 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = YES +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = YES +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_SCHEMA = +XML_DTD = +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +TEMPLATE_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO +CGI_NAME = search.cgi +CGI_URL = +DOC_URL = +DOC_ABSPATH = +BIN_ABSPATH = /usr/local/bin/ +EXT_DOC_PATHS = diff --git a/base/Makefile b/base/Makefile new file mode 100644 index 0000000..4bfa3e5 --- /dev/null +++ b/base/Makefile @@ -0,0 +1,65 @@ +# vim: set noexpandtab tabstop=4 softtabstop=4 shiftwidth=4: +# +--------------------------------------------------------------------+ +# | BIFE - Buil It FastEr | +# +--------------------------------------------------------------------+ +# | This file is part of BIFE. | +# | | +# | BIFE is free software; you can redistribute it and/or modify it | +# | under the terms of the GNU General Public License as published by | +# | the Free Software Foundation; either version 2 of the License, or | +# | (at your option) any later version. | +# | | +# | BIFE is distributed in the hope that it will be useful, but | +# | WITHOUT ANY WARRANTY; without even the implied warranty of | +# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | +# | General Public License for more details. | +# | | +# | You should have received a copy of the GNU General Public License | +# | along with Hooks; if not, write to the Free Software Foundation, | +# | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | +# +--------------------------------------------------------------------+ +# | Created: Mon May 19 00:16:56 ART 2003 | +# | Authors: Leandro Lucarella | +# +--------------------------------------------------------------------+ +# +# $Id$ +# + +VERSION=0.11 +MODULE_FILE=BIFE.php +MODULE_NAME=Core +PHP_FILES=$(filter-out $(MODULE_FILE),$(subst ./,,$(shell find -name '*.php'))) +EXAMPLE_FILES=$(subst ./,,$(shell find examples -regex '.*\.svn.*')) +DOC_FILES=README ROADMAP +X2C_TEMPLATE=xmi2code.tpl.php + +package: package.xml $(PHP_FILES) $(EXAMPLE_FILES) $(DOC_FILES) + pear package + +code: bife.xmi xmi2code.config + @xmi2code + +code-clean: + @find -name '*.bak' | xargs rm -vf + +$(MODULE_FILE): code $(PHP_FILES) $(X2C_TEMPLATE) + @( \ + ( \ + cat $(X2C_TEMPLATE) | \ + grep -v '@@date' | \ + grep -v '$$Id' | \ + egrep -v '^//$$' \ + ); \ + echo '//'; \ + echo -n '// BIFE $(MODULE_NAME) (version $(VERSION)) - '; \ + date; \ + echo '//'; \ + ( \ + cat $(PHP_FILES) | \ + grep -v require_once | \ + grep -v '?>' | \ + grep -v '' \ + ) > $(MODULE_FILE) diff --git a/base/README b/base/README new file mode 100644 index 0000000..13737e0 --- /dev/null +++ b/base/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/base/ROADMAP b/base/ROADMAP new file mode 100644 index 0000000..801d858 --- /dev/null +++ b/base/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/base/bife.xmi b/base/bife.xmi new file mode 100644 index 0000000..bdf7124 --- /dev/null +++ b/base/bife.xmi @@ -0,0 +1,89 @@ + + + + + umbrello uml modeller http://uml.sf.net + 1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/base/build.xml b/base/build.xml new file mode 100644 index 0000000..5a6d0a5 --- /dev/null +++ b/base/build.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/base/core/HTML/Template/HIT.php b/base/core/HTML/Template/HIT.php new file mode 100644 index 0000000..2b635c9 --- /dev/null +++ b/base/core/HTML/Template/HIT.php @@ -0,0 +1,265 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + +// +X2C Class 130 :HIT +/** + * Hooks vs. IT (HIT) is a simple template implementation, based on hooks and IT template systems. + * + * @access public + */ +class HTML_Template_HIT { + /** + * Root directory where template files are. + * + * @var string $root + * @access public + */ + var $root = '.'; + + /** + * If it's true, it looks for template files in PHP's include_path. + * + * @var bool $useIncludePath + * @access public + */ + var $useIncludePath = false; + + /** + * Group of templates to use (a subdirectory in root). + * + * @var string $group + * @access protected + */ + var $group = ''; + + /** + * Templates cache. + * + * @var array $cache + * @access protected + */ + var $cache = array(); + + /** + * @var array $buffer + * @access protected + */ + var $buffer = array(); + + // ~X2C + + // +X2C Operation 136 + /** + * Constructor. + * + * @param string $root Root directory where template files are. + * @param bool $useIncludePath If it's true, it looks for template files in PHP's include_path. + * @param string $group Group of templates to use (a subdirectory in root). + * + * @return void + * @access public + */ + function HTML_Template_HIT($root = '.', $useIncludePath = false, $group = '') // ~X2C + { + $this->__construct($root, $useIncludePath, $group); + } + // -X2C + + // +X2C Operation 137 + /** + * Constructor. + * + * @param int $root Root directory where template files are. + * @param false $useIncludePath If it's true, it looks for template files in PHP's include_path. + * @param string $group Group of templates to use (a subdirectory in root). + * + * @return void + * @access public + */ + function __construct($root = '.', $useIncludePath = false, $group = '') // ~X2C + { + $this->root = $root; + $this->useIncludePath = $useIncludePath; + $this->pushGroup($group); + } + // -X2C + + // +X2C Operation 138 + /** + * Parse a template returning the results. +If $vars is an array, the {[keys]} are replaced with [values] ($val is ignored). If is a string, {$vars} is replaced with $val. + * + * @param string $name Name of template to parse. + * @param mixed $vars Variables to replace in the template. + * @param string $val If $vars is a string, the value to replace for $vars. + * @param mixed $group Group to use to parse this template. Null to use the current group. + * + * @return string + * @access public + */ + function parse($name, $vars = '', $val = '', $group = null) // ~X2C + { + $group = is_null($group) ? end($this->group) : $group; + if ($group) { + $file = "{$this->root}/$group/$name.tpl.html"; + } else { + $file = "{$this->root}/$name.tpl.html"; + } + if (!isset($this->cache[$file])) { + // FIXME - replace join(file()) with file_get_contents(). + $this->cache[$file] = join('', file($file, $this->useIncludePath)); + } + if ($vars) { + if (is_string($vars)) { + $vars = array($vars => $val); + } + foreach ($vars as $key => $val) { + $keys[] = '{' . $key . '}'; + $vals[] = $val; + } + return str_replace($keys, $vals, $this->cache[$file]); + } else { + return $this->cache[$file]; + } + } + // -X2C + + // +X2C Operation 144 + /** + * Parse a template buffering the results. +Parse a template appending the results to an internal buffer. If $vars is an array, the {[keys]} are replaced with [values] ($val is ignored). If is a string, {$vars} is replaced with $val. + * + * @param string $name Name of template to parse. + * @param mixed $vars Variables to replace in the template. + * @param string $val If $vars is a string, the value to replace for $vars. + * + * @return void + * @access public + */ + function parseBuffered($name, $vars = '', $val = '') // ~X2C + { + @$this->buffer["{$this->group}/$name"] .= $this->parse($name, $vars, $val); + } + // -X2C + + // +X2C Operation 145 + /** + * Gets a parsed buffer. + * + * @param string $name Name of the parsed template to get. + * + * @return string + * @access public + * @static + */ + function getBuffer($name) // ~X2C + { + return @$this->buffer["{$this->group}/$name"]; + } + // -X2C + + // +X2C Operation 146 + /** + * Gets a parsed buffer and removes it. + * + * @param string $name Name of the buffer to flush. + * + * @return void + * @access public + */ + function popBuffer($name) // ~X2C + { + $return = @$this->buffer["{$this->group}/$name"]; + unset($this->buffer["{$this->group}/$name"]); + return $return; + } + // -X2C + + // +X2C Operation 139 + /** + * Sets the group to use and add it to the groups stack. + * + * @param string $group Group to use. + * + * @return void + * @access public + */ + function pushGroup($group = '') // ~X2C + { + $this->group[] = $group; + } + // -X2C + + // +X2C Operation 140 + /** + * Removes the group from the groups stack and returns to the previous used group. + * + * @return string + * @access public + */ + function popGroup() // ~X2C + { + return array_pop($this->group); + } + // -X2C + + // +X2C Operation 159 + /** + * True if the template $name exists in $group (or the current group). + * + * @param string $name Name of the template. + * @param mixed $group Template's group. If it's null it uses the current group. + * + * @return bool + * @access public + */ + function exists($name, $group = null) // ~X2C + { + $group = is_null($group) ? end($this->group) : $group; + if ($group) { + $file = "{$this->root}/$group/$name.tpl.html"; + } else { + $file = "{$this->root}/$name.tpl.html"; + } + if (!$this->useIncludePath) { + return is_readable($file); + } else { + $include_path = array_unique(preg_split('/[:;]/', ini_get('include_path'))); + foreach ($include_path as $path) { + if (is_readable("$path/$file")) { + return true; + } + } + return false; + } + } + // -X2C + +} // -X2C Class :HIT + +?> \ No newline at end of file diff --git a/base/core/Makefile b/base/core/Makefile new file mode 100644 index 0000000..ed9979c --- /dev/null +++ b/base/core/Makefile @@ -0,0 +1,62 @@ +# vim: set noexpandtab tabstop=4 softtabstop=4 shiftwidth=4: +# +--------------------------------------------------------------------+ +# | BIFE - Buil It FastEr | +# +--------------------------------------------------------------------+ +# | This file is part of BIFE. | +# | | +# | BIFE is free software; you can redistribute it and/or modify it | +# | under the terms of the GNU General Public License as published by | +# | the Free Software Foundation; either version 2 of the License, or | +# | (at your option) any later version. | +# | | +# | BIFE is distributed in the hope that it will be useful, but | +# | WITHOUT ANY WARRANTY; without even the implied warranty of | +# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | +# | General Public License for more details. | +# | | +# | You should have received a copy of the GNU General Public License | +# | along with Hooks; if not, write to the Free Software Foundation, | +# | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | +# +--------------------------------------------------------------------+ +# | Created: Mon May 19 00:16:56 ART 2003 | +# | Authors: Leandro Lucarella | +# +--------------------------------------------------------------------+ +# +# $Id$ +# + +VERSION=0.10 +MODULE_FILE=BIFE.php +MODULE_NAME=Core +PHP_FILES=$(filter-out $(MODULE_FILE),$(subst ./,,$(shell find -name '*.php'))) +X2C_TEMPLATE=../xmi2code.tpl.php + +all: $(MODULE_FILE) + +code: bife.xmi xmi2code.config + @xmi2code + +code-clean: + @find -name '*.bak' | xargs rm -vf + +$(MODULE_FILE): code $(PHP_FILES) $(X2C_TEMPLATE) + @( \ + ( \ + cat $(X2C_TEMPLATE) | \ + grep -v '@@date' | \ + grep -v '$$Id' | \ + egrep -v '^//$$' \ + ); \ + echo '//'; \ + echo -n '// BIFE $(MODULE_NAME) (version $(VERSION)) - '; \ + date; \ + echo '//'; \ + ( \ + cat $(PHP_FILES) | \ + grep -v require_once | \ + grep -v '?>' | \ + grep -v '' \ + ) > $(MODULE_FILE) diff --git a/base/examples/index.php b/base/examples/index.php new file mode 100644 index 0000000..c38ac9c --- /dev/null +++ b/base/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/base/examples/index.xbf b/base/examples/index.xbf new file mode 100644 index 0000000..df29c36 --- /dev/null +++ b/base/examples/index.xbf @@ -0,0 +1,9 @@ + + + BIFE is working! +

Translate Fallback is working too!

+

This is a very bad use for BIFE, because I'm writing HTML :-P

+ A little of 'real' use +

Here's a link to another BIFE file

+
+
diff --git a/base/examples/link.xbf b/base/examples/link.xbf new file mode 100644 index 0000000..1eaa4a9 --- /dev/null +++ b/base/examples/link.xbf @@ -0,0 +1,5 @@ + + + BIFE Links are working too! +

Go back.

+
diff --git a/base/examples/templates/bife_link.tpl.html b/base/examples/templates/bife_link.tpl.html new file mode 100644 index 0000000..873ba85 --- /dev/null +++ b/base/examples/templates/bife_link.tpl.html @@ -0,0 +1 @@ +{CONTENTS} diff --git a/base/examples/templates/bife_page.tpl.html b/base/examples/templates/bife_page.tpl.html new file mode 100644 index 0000000..ea824f4 --- /dev/null +++ b/base/examples/templates/bife_page.tpl.html @@ -0,0 +1,9 @@ + + + {TITLE} + + +

{TITLE}

+ {CONTENTS} + + diff --git a/base/examples/templates/bife_title.tpl.html b/base/examples/templates/bife_title.tpl.html new file mode 100644 index 0000000..3590da3 --- /dev/null +++ b/base/examples/templates/bife_title.tpl.html @@ -0,0 +1 @@ +

{CONTENTS}

diff --git a/base/package.xml b/base/package.xml new file mode 100644 index 0000000..3cfff25 --- /dev/null +++ b/base/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/base/xmi2code.config b/base/xmi2code.config new file mode 100644 index 0000000..7540819 --- /dev/null +++ b/base/xmi2code.config @@ -0,0 +1,47 @@ + + + + + diff --git a/base/xmi2code.tpl.php b/base/xmi2code.tpl.php new file mode 100644 index 0000000..ce8775b --- /dev/null +++ b/base/xmi2code.tpl.php @@ -0,0 +1,27 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// diff --git a/bife/bife.xmi b/bife/bife.xmi index 13594f0..dd94c30 100644 --- a/bife/bife.xmi +++ b/bife/bife.xmi @@ -5,7 +5,7 @@ umbrello uml modeller http://uml.sf.net 1.1 - + @@ -83,60 +83,27 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - + + - + - - - - - - - - - - - - - - + + @@ -157,12 +124,6 @@ - - - - - - @@ -180,9 +141,6 @@ - - - -- 2.43.0