From: Leandro Lucarella Date: Tue, 17 Jun 2003 04:14:53 +0000 (+0000) Subject: - Moved some Generic functionality to Widget (attrs property). X-Git-Tag: svn_import~46 X-Git-Url: https://git.llucax.com/software/bife/bife-all.git/commitdiff_plain/3658b126d4873c96dd3b08af6619795790e23ac2?ds=sidebyside - Moved some Generic functionality to Widget (attrs property). - Moved some Copy functionality to Fallback (name property). - Moved QUERY to URL in Link. - Improved Album (now it uses just one template). - Added Menu (not implemented yet). - Updated UML diagram. --- diff --git a/doc/bife.xmi b/doc/bife.xmi index f587167..7a89f99 100644 --- a/doc/bife.xmi +++ b/doc/bife.xmi @@ -5,16 +5,23 @@ umbrello uml modeller http://uml.sf.net 1.1 - + - + + + + + + + + @@ -40,7 +47,6 @@ - @@ -55,7 +61,6 @@ - @@ -95,7 +100,6 @@ Returns an array of associative arrays with this keys: - @@ -142,6 +146,7 @@ Returns an array of associative arrays with this keys: + @@ -155,8 +160,6 @@ Returns an array of associative arrays with this keys: - - @@ -176,8 +179,6 @@ Returns an array of associative arrays with this keys: - - @@ -187,123 +188,255 @@ Returns an array of associative arrays with this keys: + + + + + + + + + + + - + - - - - - - - - - - - + + + + + - - + + - + - - + + - + - - + + - + + + + - - + + - + + + + + + + + + + + + + + + + - - + + - + - - + + - + - - + + - - + + - + - - + + - + + + + + + + - - + + - + - - + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + - @@ -311,37 +444,24 @@ Returns an array of associative arrays with this keys: + - - - - - - - - - - + + + - - - - - - - @@ -352,21 +472,62 @@ Returns an array of associative arrays with this keys: - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/index.php b/examples/index.php index dfff49c..33b14e1 100644 --- a/examples/index.php +++ b/examples/index.php @@ -42,7 +42,7 @@ require_once 'BIFE/Link.php'; $file = isset($_REQUEST['BIFE']) ? $_REQUEST['BIFE'] : 'index.xbf'; $template =& new HTML_Template_Sigma('templates', 'compiled_templates'); -$template->setErrorHandling(PEAR_ERROR_PRINT); +$template->setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_ERROR); $parser =& new BIFE_Parser('BIFE_Copy'); $page =& $parser->parseFile($file); diff --git a/examples/templates/bife_album.html b/examples/templates/bife_album.html index 2510de9..749e1d0 100644 --- a/examples/templates/bife_album.html +++ b/examples/templates/bife_album.html @@ -2,11 +2,20 @@
- + - {ITEMS} + + + + + + - +
+ {DESC} + + VACÍO +
diff --git a/examples/templates/bife_album_emptyitem.html b/examples/templates/bife_album_emptyitem.html deleted file mode 100644 index ca79251..0000000 --- a/examples/templates/bife_album_emptyitem.html +++ /dev/null @@ -1 +0,0 @@ -VACIO diff --git a/examples/templates/bife_album_item.html b/examples/templates/bife_album_item.html deleted file mode 100644 index 5523de6..0000000 --- a/examples/templates/bife_album_item.html +++ /dev/null @@ -1,4 +0,0 @@ - - {DESC} - diff --git a/examples/templates/bife_albumphoto.html b/examples/templates/bife_albumphoto.html index 34c901f..901274f 100644 --- a/examples/templates/bife_albumphoto.html +++ b/examples/templates/bife_albumphoto.html @@ -1,2 +1,2 @@ -{DESC} -
{DESC}
+

{DESC}

+{DESC} diff --git a/examples/templates/bife_link.html b/examples/templates/bife_link.html index f8e2148..873ba85 100644 --- a/examples/templates/bife_link.html +++ b/examples/templates/bife_link.html @@ -1 +1 @@ -{CONTENTS} +{CONTENTS} diff --git a/src/BIFE/Album.php b/src/BIFE/Album.php index 1d9fa2b..b3fd409 100644 --- a/src/BIFE/Album.php +++ b/src/BIFE/Album.php @@ -39,14 +39,6 @@ require_once 'Image/Transform.php'; * @access public */ class BIFE_Album extends BIFE_Widget { - /** - * Attributes. - * - * @var array $attrs - * @access public - */ - var $attrs; - // ~X2C // +X2C Operation 22 @@ -82,14 +74,16 @@ class BIFE_Album extends BIFE_Widget { 'THUMBSFORMAT' => 'jpeg', 'THUMBSDIR' => '.thumbs', 'EXTENSIONS' => 'png,jpg,jpeg,PNG,JPG,JPEG', - 'SELECTED' => '', 'MAXROWS' => 0, 'COLUMNS' => 4, + 'LINK-BIFE' => 'photo.xbf', + 'LINK-URL' => '', // TODO - agregar atributo para el LINK, ver de hacer el // widget de un link. ); - $this->attrs = array_merge($defaults, $attrs); - $this->attrs['EXTENSIONS'] = explode(',', $this->attrs['EXTENSIONS']); + $attrs = array_merge($defaults, $attrs); + $attrs['EXTENSIONS'] = explode(',', $attrs['EXTENSIONS']); + parent::__construct($attrs); } // -X2C @@ -105,7 +99,6 @@ class BIFE_Album extends BIFE_Widget { function render(&$template) // ~X2C { $template->loadTemplateFile('bife_album.html'); - $template->addBlockFile('ITEMS', 'ITEM', 'bife_album_item.html'); $root = $this->attrs['DIR']; $list = $this->getList(); $tot = count($list); @@ -114,32 +107,25 @@ class BIFE_Album extends BIFE_Widget { for ($col = 0; $col < $this->attrs['COLUMNS']; $col++) { $cur = $row * $this->attrs['COLUMNS'] + $col; if ($photo = @$list[$cur]) { - $selected = ($photo['file'] === $this->attrs['SELECTED']); - if (is_null($photo['thumb'])) { - $photo['thumb'] = $this->makeThumb($photo['file']); + if (is_null($photo['THUMB'])) { + $photo['THUMB'] = $this->makeThumb($photo['FILE']); } // FIXME - Si no se pudo crear el thumb, devuelve null // (ver si se agrega otro template para indicar error // o algo asi). - $template->setVariable( - array( - 'PHOTO' => $photo['file'], - 'DESC' => $photo['desc'], - 'THUMB' => $photo['thumb'], - ) - ); - $template->parse('ITEM'); - } else { - if (!@$empty) { - $template->replaceBlockFile('ITEM', - 'bife_album_emptyitem.html', true); - $empty = true; + $photo['URL'] = $this->attrs['LINK-URL'] . '?BIFE_ALBUM_FILE=' . + urlencode($photo['FILE']); + if ($this->attrs['LINK-BIFE']) { + $photo['URL'] .= '&BIFE=' . urlencode($this->attrs['LINK-BIFE']); } - $template->touchBlock('ITEM'); + $template->setVariable($photo); $template->parse('ITEM'); + } else { + $template->touchBlock('EMPTY'); + $template->parse('EMPTY'); } } - $template->parse('FILA'); + $template->parse('ROW'); } $template->setVariable('DESC', $this->getDescription()); return $template->get(); @@ -172,9 +158,9 @@ Returns an array of associative arrays with this keys: if (is_readable("$root/$file") and in_array($ext, $exts)) { $thumb = $this->getThumbFilename("$root/$file"); $return[] = array( - 'file' => "$root/$name", - 'desc' => $name, - 'thumb' => is_readable($thumb) ? $thumb : null, + 'FILE' => "$root/$name", + 'DESC' => $name, + 'THUMB' => is_readable($thumb) ? $thumb : null, ); } } @@ -282,4 +268,4 @@ Returns an array of associative arrays with this keys: } // -X2C Class :Album -?> \ No newline at end of file +?> diff --git a/src/BIFE/AlbumPhoto.php b/src/BIFE/AlbumPhoto.php index 6a34876..ab4cc53 100644 --- a/src/BIFE/AlbumPhoto.php +++ b/src/BIFE/AlbumPhoto.php @@ -37,22 +37,6 @@ require_once 'BIFE/Widget.php'; * @access public */ class BIFE_AlbumPhoto extends BIFE_Widget { - /** - * Photo filename. - * - * @var string $file - * @access protected - */ - var $file; - - /** - * Photo Description. - * - * @var string $desc - * @access protected - */ - var $desc; - // ~X2C // +X2C Operation 106 @@ -81,8 +65,9 @@ class BIFE_AlbumPhoto extends BIFE_Widget { */ function __construct($attrs) // ~X2C { - $this->file = @$attrs['FILE'] ? $attrs['FILE'] : @$_REQUEST['BIFE_ALBUMPHOTO_FILE']; - $this->desc = @$attrs['DESC'] ? $attrs['DESC'] : basename($this->file); + $new_attrs['FILE'] = @$attrs['FILE'] ? $attrs['FILE'] : @$_REQUEST['BIFE_ALBUM_FILE']; + $new_attrs['DESC'] = @$attrs['DESC'] ? $attrs['DESC'] : basename($new_attrs['FILE']); + parent::__construct($new_attrs); } // -X2C @@ -98,12 +83,7 @@ class BIFE_AlbumPhoto extends BIFE_Widget { function render(&$template) // ~X2C { $template->loadTemplateFile('bife_albumphoto.html'); - $template->setVariable( - array( - 'FILE' => $this->file, - 'DESC' => $this->desc, - ) - ); + $template->setVariable($this->attrs); return $template->get(); } // -X2C diff --git a/src/BIFE/Copy.php b/src/BIFE/Copy.php index c26fada..f660e04 100644 --- a/src/BIFE/Copy.php +++ b/src/BIFE/Copy.php @@ -37,22 +37,6 @@ require_once 'BIFE/Fallback.php'; * @access public */ class BIFE_Copy extends BIFE_Fallback { - /** - * Widget name. - * - * @var string $name - * @access protected - */ - var $name; - - /** - * Attributes. - * - * @var array $attrs - * @access protected - */ - var $attrs; - // ~X2C // +X2C Operation 79 @@ -83,8 +67,7 @@ class BIFE_Copy extends BIFE_Fallback { */ function __construct($name, $attrs) // ~X2C { - $this->name = $name; - $this->attrs = $attrs; + parent::__construct($name, $attrs); } // -X2C @@ -116,4 +99,4 @@ class BIFE_Copy extends BIFE_Fallback { } // -X2C Class :Copy -?> \ No newline at end of file +?> diff --git a/src/BIFE/Fallback.php b/src/BIFE/Fallback.php index ed6ebdd..60ac5f8 100644 --- a/src/BIFE/Fallback.php +++ b/src/BIFE/Fallback.php @@ -26,8 +26,6 @@ // $Id$ // - - // +X2C includes require_once 'BIFE/Container.php'; // ~X2C @@ -40,6 +38,12 @@ require_once 'BIFE/Container.php'; * @abstract */ class BIFE_Fallback extends BIFE_Container { + /** + * @var string $name + * @access public + */ + var $name; + // ~X2C // +X2C Operation 62 @@ -54,7 +58,7 @@ class BIFE_Fallback extends BIFE_Container { */ function BIFE_Fallback($name, $attrs) // ~X2C { - trigger_error('Not implemented!', E_USER_WARNING); + $this->__construct($name, $attrs); } // -X2C @@ -70,9 +74,11 @@ class BIFE_Fallback extends BIFE_Container { */ function __construct($name, $attrs) // ~X2C { - trigger_error('Not implemented!', E_USER_WARNING); + parent::__construct($attrs); + $this->name = $name; } // -X2C } // -X2C Class :Fallback -?> \ No newline at end of file + +?> diff --git a/src/BIFE/Generic.php b/src/BIFE/Generic.php index c98bc49..e31d813 100644 --- a/src/BIFE/Generic.php +++ b/src/BIFE/Generic.php @@ -38,14 +38,6 @@ require_once 'BIFE/Container.php'; * @abstract */ class BIFE_Generic extends BIFE_Container { - /** - * Attribute list. - * - * @var array $attrs - * @access protected - */ - var $attrs; - // ~X2C // +X2C Operation 10 @@ -74,8 +66,7 @@ class BIFE_Generic extends BIFE_Container { */ function __construct($attrs) // ~X2C { - parent::__construct(); - $this->attrs = $attrs; + parent::__construct($attrs); } // -X2C @@ -120,4 +111,4 @@ class BIFE_Generic extends BIFE_Container { } // -X2C Class :Generic -?> \ No newline at end of file +?> diff --git a/src/BIFE/Link.php b/src/BIFE/Link.php index ab21616..7d4d7b6 100644 --- a/src/BIFE/Link.php +++ b/src/BIFE/Link.php @@ -65,14 +65,12 @@ class BIFE_Link extends BIFE_Generic { */ function __construct($attrs) // ~X2C { - if (isset($attrs['URL'])) { - $this->attrs['URL'] = $attrs['URL']; - unset($attrs['URL']); - } else { - $this->attrs['URL'] = ''; - } + $link_attrs['URL'] = @$attrs['URL']; + unset($attrs['URL']); + $link_attrs['DESC'] = @$attrs['DESC']; + unset($attrs['DESC']); if (isset($attrs['BIFE'])) { - $this->attrs['BIFE'] = $attrs['BIFE']; + $link_attrs['BIFE'] = $attrs['BIFE']; $attrs['DATA-BIFE'] = $attrs['BIFE']; unset($attrs['BIFE']); } @@ -85,10 +83,9 @@ class BIFE_Link extends BIFE_Generic { } } if ($query) { - $this->attrs['QUERY'] = '?' . join('&', $query); - } else { - $this->attrs['QUERY'] = ''; + $link_attrs['URL'] .= '?' . join('&', $query); } + parent::__construct($link_attrs); } // -X2C diff --git a/src/BIFE/Menu.php b/src/BIFE/Menu.php new file mode 100644 index 0000000..49923d2 --- /dev/null +++ b/src/BIFE/Menu.php @@ -0,0 +1,90 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + + + +// +X2C includes +require_once 'BIFE/Widget.php'; +// ~X2C + +// +X2C Class 115 :Menu +/** + * Dynamic Menu. + * + * @access public + */ +class BIFE_Menu extends BIFE_Widget { + // ~X2C + + // +X2C Operation 117 + /** + * Renders the widget using a template returning a string with the results. + * + * @param HTML_Template_Sigma &$template Template to use to render the widget. + * + * @return string + * @access public + */ + function render(&$template) // ~X2C + { + trigger_error('Not implemented!', E_USER_WARNING); + } + // -X2C + + // +X2C Operation 121 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function BIFE_Menu($attrs) // ~X2C + { + trigger_error('Not implemented!', E_USER_WARNING); + } + // -X2C + + // +X2C Operation 122 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($attrs) // ~X2C + { + trigger_error('Not implemented!', E_USER_WARNING); + } + // -X2C + +} // -X2C Class :Menu +?> \ No newline at end of file diff --git a/src/BIFE/Page.php b/src/BIFE/Page.php index 7f8fa30..d1ce348 100644 --- a/src/BIFE/Page.php +++ b/src/BIFE/Page.php @@ -37,14 +37,6 @@ require_once 'BIFE/Root.php'; * @access public */ class BIFE_Page extends BIFE_Root { - /** - * Attributes. - * - * @var array $attrs - * @access protected - */ - var $attrs; - // ~X2C // +X2C Operation 15 @@ -74,7 +66,6 @@ class BIFE_Page extends BIFE_Root { function __construct($attrs) // ~X2C { parent::__construct($attrs); - $this->attrs = $attrs; } // -X2C @@ -119,4 +110,4 @@ class BIFE_Page extends BIFE_Root { } // -X2C Class :Page -?> \ No newline at end of file +?> diff --git a/src/BIFE/Widget.php b/src/BIFE/Widget.php index 96ecdd4..35e18ba 100644 --- a/src/BIFE/Widget.php +++ b/src/BIFE/Widget.php @@ -34,8 +34,46 @@ * @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. @@ -55,4 +93,4 @@ class BIFE_Widget { } // -X2C Class :Widget -?> \ No newline at end of file +?>