]> git.llucax.com Git - software/bife/bife-all.git/blobdiff - src/BIFE/Album.php
- Added HIT to UML diagram.
[software/bife/bife-all.git] / src / BIFE / Album.php
index 977949c4b927d1da76a3fdebe5385eccfded804a..90333897a6c4143afe5ff38220cb22a092b3a009 100644 (file)
@@ -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
 
@@ -104,45 +98,39 @@ 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'];
+        $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
 
@@ -172,9 +160,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/$file",
+                        'DESC'  => $name,
+                        'THUMB' => is_readable($thumb) ? $thumb : null,
                     );
                 }              
             }