From 25b51b3a4242e18abf172dc2807d3a057e7aafdd Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 10 Jul 2003 04:32:32 +0000 Subject: [PATCH 1/1] - Uses new BIFE_Link methods to get the correct paths of files (but not really in a good way). - Added an example in a directory to test this. - Smooth the path for a migration to an external lib that does the real work. - Bugfixes. --- album/examples/dir/index.xbf | 9 ++++++++ album/examples/index.xbf | 2 +- album/package.xml | 2 +- album/src/BIFE/Album/Thumbs.php | 40 ++++++++++++++++----------------- 4 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 album/examples/dir/index.xbf diff --git a/album/examples/dir/index.xbf b/album/examples/dir/index.xbf new file mode 100644 index 0000000..fbaf7c7 --- /dev/null +++ b/album/examples/dir/index.xbf @@ -0,0 +1,9 @@ + + + Datos! +

Photo album

+ +
+ View BIFE (xbf) source | + View PHP source +
diff --git a/album/examples/index.xbf b/album/examples/index.xbf index 99fe909..d1795c8 100644 --- a/album/examples/index.xbf +++ b/album/examples/index.xbf @@ -2,7 +2,7 @@ Datos!

Photo album

- +
View BIFE (xbf) source | View PHP source diff --git a/album/package.xml b/album/package.xml index 7bb7d92..f9a9904 100644 --- a/album/package.xml +++ b/album/package.xml @@ -56,6 +56,6 @@ 4.2.3 HTML_Template_HIT BIFE - BIFE_Basic + BIFE_Basic diff --git a/album/src/BIFE/Album/Thumbs.php b/album/src/BIFE/Album/Thumbs.php index 293b092..c968c06 100644 --- a/album/src/BIFE/Album/Thumbs.php +++ b/album/src/BIFE/Album/Thumbs.php @@ -78,8 +78,7 @@ class BIFE_Album_Thumbs extends BIFE_Widget { 'EXTENSIONS' => 'png,jpg,jpeg,PNG,JPG,JPEG', 'MAXROWS' => 0, 'COLUMNS' => 4, - 'LINK-BIFE' => 'photo.xbf', - 'LINK-URL' => '', + 'LINK' => 'photo.xbf', ); $attrs = array_merge($defaults, $attrs); $attrs['EXTENSIONS'] = explode(',', $attrs['EXTENSIONS']); @@ -99,7 +98,9 @@ class BIFE_Album_Thumbs extends BIFE_Widget { function render(&$template) // ~X2C { $template->pushGroup('album'); - $list = $this->getList(); + $list = $this->getList(BIFE_Link::getFsPath() . $this->attrs['DIR'], + $this->attrs['EXTENSIONS'], $this->attrs['THUMBSFORMAT'], + $this->attrs['THUMBSDIR']); $tot = count($list); $rows = ceil($tot / $this->attrs['COLUMNS']); for ($row = 0; $row < $rows; $row++) { @@ -107,13 +108,18 @@ class BIFE_Album_Thumbs extends BIFE_Widget { $cur = $row * $this->attrs['COLUMNS'] + $col; if ($photo = @$list[$cur]) { if (is_null($photo['THUMB'])) { - $photo['THUMB'] = $this->makeThumb($photo['FILE']); + $photo['THUMB'] = $this->makeThumb( + BIFE_Link::getFsPath() . $photo['FILE'], + $this->attrs['THUMBSFORMAT'], + $this->attrs['THUMBSDIR']); } + $photo['THUMB'] = BIFE_Link::getWebPath() + . $this->attrs['DIR'] . '/' . $photo['THUMB']; $photo['URL'] = BIFE_Link::getURL( array( - 'BIFE' => $this->attrs['LINK-BIFE'], - 'URL' => $this->attrs['LINK-URL'], - 'DATA-BIFE_ALBUM_FILE' => $photo['FILE'], + 'URL' => $this->attrs['LINK'], + 'DATA-BIFE_ALBUM_FILE' => BIFE_Link::getWebPath() + . $this->attrs['DIR'] . '/' . $photo['FILE'], ) ); $cell = $template->parse('item', $photo); @@ -148,20 +154,18 @@ Returns an array of associative arrays with this keys: */ function getList() // ~X2C { - $root = $this->attrs['DIR']; - $exts = $this->attrs['EXTENSIONS']; - $format = $this->attrs['THUMBSFORMAT']; $return = array(); $d = dir($root); if ($d) { while (($file = $d->read()) !== false) { list($path, $name, $ext) = $this->splitFilename("$root/$file"); if (is_readable("$root/$file") and in_array($ext, $exts)) { - $thumb = $this->getThumbFilename("$root/$file"); + $thumb = $this->getThumbFilename($file, $format, + $thumbsdir); $return[] = array( - 'FILE' => "$root/$file", + 'FILE' => $file, 'DESC' => $name, - 'THUMB' => is_readable($thumb) ? $thumb : null, + 'THUMB' => $thumb, ); } } @@ -183,8 +187,7 @@ Returns an array of associative arrays with this keys: */ function makeThumb($filename, $size = 100) // ~X2C { - $format = $this->attrs['THUMBSFORMAT']; - $thumb = $this->getThumbFilename($filename); + $thumb = $this->getThumbFilename($filename, $format, $thumbsdir); list($path, $name, $ext) = $this->splitFilename($thumb); $img =& Image_Transform::factory('GD'); $img->load($filename); @@ -218,13 +221,8 @@ Returns an array of associative arrays with this keys: */ function getThumbFilename($filename) // ~X2C { - $root = $this->attrs['DIR']; - $format = $this->attrs['THUMBSFORMAT']; - $thumbsdir = $this->attrs['THUMBSDIR']; - list($path, $name, $ext) = $this->splitFilename($filename); - - return "$root/$thumbsdir/$name.$format"; + return "$thumbsdir/$name.$format"; } // -X2C -- 2.43.0