X-Git-Url: https://git.llucax.com/software/bife/bife-all.git/blobdiff_plain/6b3b1dd0cad8c4342008f139922e1ed26924bf2a..2ca13aad316873633c3fd9ba59ee2f5579d90272:/src/BIFE/Album.php diff --git a/src/BIFE/Album.php b/src/BIFE/Album.php index 1bbc1d6..ff08c40 100644 --- a/src/BIFE/Album.php +++ b/src/BIFE/Album.php @@ -29,27 +29,34 @@ // +X2C includes require_once 'BIFE/Widget.php'; // ~X2C -require_once 'Album.php'; + +require_once 'Image/Transform.php'; // +X2C Class 20 :Album /** - * Photo album widget. -[TODO: Make a better explanation] + * Photo album widget. [TODO: Make a better explanation] * * @access public */ class BIFE_Album extends BIFE_Widget { + // ~X2C + + // +X2C Operation 22 /** - * Attributes. + * Constructor. + * + * @param array $attrs Attributes. * - * @var array $attrs + * @return void * @access public */ - var $attrs; - - // ~X2C + function BIFE_Album($attrs) // ~X2C + { + $this->__construct($attrs); + } + // -X2C - // +X2C Operation 22 + // +X2C Operation 57 /** * Constructor. * @@ -58,19 +65,25 @@ class BIFE_Album extends BIFE_Widget { * @return void * @access public */ - function BIFE_Album($attrs) // ~X2C + function __construct($attrs) // ~X2C { + // TODO - get defaults from an INI file. $defaults = array( 'DIR' => '.', 'RECURSIVE' => true, 'THUMBSFORMAT' => 'jpeg', 'THUMBSDIR' => '.thumbs', - 'EXTENSIONS' => 'png,jpg,jpeg,gif', - 'SELECTED' => '', + 'EXTENSIONS' => 'png,jpg,jpeg,PNG,JPG,JPEG', '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); + $attrs = array_merge($defaults, $attrs); + $attrs['EXTENSIONS'] = explode(',', $attrs['EXTENSIONS']); + parent::__construct($attrs); } // -X2C @@ -80,14 +93,179 @@ class BIFE_Album extends BIFE_Widget { * * @param HTML_Template_Sigma &$template Template to use to render the widget. * - * @return void + * @return string * @access public */ function render(&$template) // ~X2C { - extract($this->attrs, EXTR_SKIP); - $album =& new Hook_Album($DIR, $RECURSIVE, $THUMBSFORMAT, $THUMBSDIR, $EXTENSIONS); - return $album->album($template, $SELECTED, $MAXROWS, $COLUMNS); + $template->group = 'album'; + $root = $this->attrs['DIR']; + $list = $this->getList(); + $tot = count($list); + $rows = ceil($tot / $this->attrs['COLUMNS']); + $html_rows = ''; + for ($row = 0; $row < $rows; $row++) { + $html_cells = ''; + for ($col = 0; $col < $this->attrs['COLUMNS']; $col++) { + $cur = $row * $this->attrs['COLUMNS'] + $col; + if ($photo = @$list[$cur]) { + 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). + $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']); + } + $html_cell = $template->parse('item', $photo); + } else { + $html_cell = $template->parse('empty'); + } + $html_cells .= $template->parse('cell', 'CONTENTS', $html_cell); + } + $html_rows .= $template->parse('row', 'CONTENTS', $html_cells); + } + return $template->parse( + 'body', + array('DESC' => $this->getDescription(), 'CONTENTS' => $html_rows)); + } + // -X2C + + // +X2C Operation 95 + /** + * Gets a list of photos with their descriptions and thumbnails. +Returns an array of associative arrays with this keys: +