X-Git-Url: https://git.llucax.com/software/bife/bife-all.git/blobdiff_plain/090eddcda4bf543db3463012f7a552a744364cd5..3658b126d4873c96dd3b08af6619795790e23ac2:/src/BIFE/Album.php 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 +?>