X-Git-Url: https://git.llucax.com/software/bife/bife-all.git/blobdiff_plain/6b3b1dd0cad8c4342008f139922e1ed26924bf2a..f36ac20c1ad9e4d0987240a7fd2e0438f492be9b:/src/BIFE/Album.php?ds=inline diff --git a/src/BIFE/Album.php b/src/BIFE/Album.php index 1bbc1d6..977949c 100644 --- a/src/BIFE/Album.php +++ b/src/BIFE/Album.php @@ -29,12 +29,12 @@ // +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 */ @@ -60,17 +60,36 @@ class BIFE_Album extends BIFE_Widget { */ function BIFE_Album($attrs) // ~X2C { + $this->__construct($attrs); + } + // -X2C + + // +X2C Operation 57 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + 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', + 'EXTENSIONS' => 'png,jpg,jpeg,PNG,JPG,JPEG', 'SELECTED' => '', 'MAXROWS' => 0, 'COLUMNS' => 4, + // 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']); } // -X2C @@ -80,14 +99,184 @@ 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->loadTemplateFile('bife_album.html'); + $template->addBlockFile('ITEMS', 'ITEM', 'bife_album_item.html'); + $root = $this->attrs['DIR']; + $list = $this->getList(); + $tot = count($list); + $rows = ceil($tot / $this->attrs['COLUMNS']); + for ($row = 0; $row < $rows; $row++) { + 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']); + } + // 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; + } + $template->touchBlock('ITEM'); + $template->parse('ITEM'); + } + } + $template->parse('FILA'); + } + $template->setVariable('DESC', $this->getDescription()); + return $template->get(); + } + // -X2C + + // +X2C Operation 95 + /** + * Gets a list of photos with their descriptions and thumbnails. +Returns an array of associative arrays with this keys: +