]> git.llucax.com Git - software/bife/bife-all.git/commitdiff
- Uses new BIFE_Link methods to get the correct paths of files (but not really
authorLeandro Lucarella <llucax@gmail.com>
Thu, 10 Jul 2003 04:32:32 +0000 (04:32 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Thu, 10 Jul 2003 04:32:32 +0000 (04:32 +0000)
  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 [new file with mode: 0644]
album/examples/index.xbf
album/package.xml
album/src/BIFE/Album/Thumbs.php

diff --git a/album/examples/dir/index.xbf b/album/examples/dir/index.xbf
new file mode 100644 (file)
index 0000000..fbaf7c7
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Page title="Hola mundo!" menu="true">
+    <Title>Datos!</Title>
+    <H3>Photo album</H3>
+    <Album:Thumbs dir="../images" columns="8"/>
+    <HR noshade="noshade" size="2"/>
+    <Link data-s="1" data-b="1">View BIFE (xbf) source</Link> |
+    <Link data-s="1">View PHP source</Link>
+</Page>
index 99fe90980458cc93465187e0a492b9c1c15af9b6..d1795c833710d2716ab324e56859c99a7c9e7354 100644 (file)
@@ -2,7 +2,7 @@
 <Page title="Hola mundo!" menu="true">
     <Title>Datos!</Title>
     <H3>Photo album</H3>
-    <Album:Thumbs dir="../../.." columns="8"/>
+    <Album:Thumbs dir="images" columns="8"/>
     <HR noshade="noshade" size="2"/>
     <Link data-s="1" data-b="1">View BIFE (xbf) source</Link> |
     <Link data-s="1">View PHP source</Link>
index 7bb7d92c484b49558333b2f75c2e4f0371ffd630..f9a99045b63795855740557e06fab519e747d2f8 100644 (file)
@@ -56,6 +56,6 @@
         <dep type="php" rel="ge">4.2.3</dep>
         <dep type="pkg" rel="ge" version="1.0.0beta1">HTML_Template_HIT</dep>
         <dep type="pkg" rel="ge" version="1.0.0beta1">BIFE</dep>
-        <dep type="pkg" rel="ge" version="1.0.0beta1">BIFE_Basic</dep>
+        <dep type="pkg" rel="ge" version="1.0.0beta3">BIFE_Basic</dep>
     </deps>
 </package>
index 293b0922d07cb30275263786950851a31f528495..c968c061f410da2dc089a24547dc2b4e58f5dbc0 100644 (file)
@@ -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