* @access public
*/
class BIFE_Album extends BIFE_Widget {
- /**
- * Attributes.
- *
- * @var array $attrs
- * @access public
- */
- var $attrs;
-
// ~X2C
// +X2C Operation 22
'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
*/
function render(&$template) // ~X2C
{
- $template->loadTemplateFile('bife_album.html');
- $template->addBlockFile('ITEMS', 'ITEM', 'bife_album_item.html');
- $root = $this->attrs['DIR'];
+ $template->group = 'album';
$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]) {
- $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->parse('ITEM');
+ $html_cell = $template->parse('item', $photo);
+ } else {
+ $html_cell = $template->parse('empty');
}
+ $html_cells .= $template->parse('cell', 'CONTENTS', $html_cell);
}
- $template->parse('FILA');
+ $html_rows .= $template->parse('row', 'CONTENTS', $html_cells);
}
- $template->setVariable('DESC', $this->getDescription());
- return $template->get();
+ return $template->parse(
+ 'body',
+ array('DESC' => $this->getDescription(), 'CONTENTS' => $html_rows));
}
// -X2C
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/$file",
+ 'DESC' => $name,
+ 'THUMB' => is_readable($thumb) ? $thumb : null,
);
}
}