]> dev.renevier.net Git - syp.git/commitdiff
create thumbnails of photos
authorarno <arenevier@fdn.fr>
Wed, 5 Aug 2009 20:10:02 +0000 (22:10 +0200)
committerarno <arenevier@fdn.fr>
Fri, 7 Aug 2009 10:07:46 +0000 (12:07 +0200)
18 files changed:
README.txt
api.php
build.sh
inc/i10n/en/syp.php
inc/i10n/fr/syp.php
inc/i10n/updatelang.php
inc/settings.php
inc/templates_index.php
inc/templates_upgrade.php [new file with mode: 0644]
inc/templates_wizard.php
inc/utils.php
inc/version.php [new file with mode: 0644]
items.php
media/syp.css
news.php
upgrade.en.php [new symlink]
upgrade.fr.php [new symlink]
upgrade.php [new file with mode: 0644]

index d648c63be605ecaed667b69c37b4b2c243608c0d..33949386d2fa77c7fd290d08d66b81bb7cc51bc0 100644 (file)
@@ -14,10 +14,20 @@ Requirements
 
 Installation
 ------------
+upload syp to your webserver
 edit inc/settings.php
-open http://yoururl.com/wizard.php
+open http://yoururl.com/wizard.php with your web browser
 follow instructions
 
+Upgrade
+------------
+- make a copy of inc/settings.php
+- delete old version of syp from your server
+- upload now version
+- edit inc/settings.php again (copy old version of file may not be enough
+  because new settings may have appeared)
+- open http://yoururl.com/upgrade.php with your web browser
+
 server API
 ----------
 The way server side communicates with client side is described at
diff --git a/api.php b/api.php
index 39c6319ab5c749d857665830e0bb040f5dfe30e3..18c7179cd1b9306a1ab34acb4bc6c2ed43b5f4f6 100644 (file)
--- a/api.php
+++ b/api.php
@@ -20,7 +20,7 @@ function success_feature ($feature, $request) {
 
     $res .= "<imgurl>" .
              ($feature->imgpath ? 
-                    full_url_from_imgpath ($feature->imgpath)
+                    image_url_from_imgpath ($feature->imgpath)
                     : "") .
              "</imgurl>";
 
@@ -98,6 +98,19 @@ function save_uploaded_file ($file, $con) {
                 (!move_uploaded_file ($file ["tmp_name"], $dest))) {
             server_error ();
         }
+        $mini_dest = getthumbsdir () . "/mini_" . basename_safe ($dest);
+
+        try {
+            $thumbnail_ok = create_thumbnail ($dest, $mini_dest);
+        } catch (Exception $e) {
+            $thumbnail_ok = false;
+        }
+        if (!$thumbnail_ok) {
+            if (!copy ($dest, $mini_dest)) {
+                server_error ();
+            }
+        }
+
     }
     return basename_safe ($dest);
 }
@@ -120,14 +133,17 @@ function delete_image_if_unused ($imgpath, $con) {
         return;
     }
     if ($con->imgpath_exists ($imgpath)) {
-        return false;
+        return;
     }
+
     $path = UPLOADDIR . "/" . $imgpath;
-    if (file_exists($path)) {
+    if (file_exists ($path)) {
         unlink ($path);
-        return true;
-    } else {
-        return false;
+    }
+
+    $thumb_path = getthumbsdir () . "/mini_" . $imgpath;
+    if (file_exists ($thumb_path)) {
+        unlink ($thumb_path);
     }
 }
 
index d6c6a28138156a8b0e14fd6cd5071ad79877f132..764f1c6d708bf249107f78f7c4ff09020656f82c 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -15,7 +15,7 @@ mkdir -p $DESTDIR
 cp -RLp inc/ $DESTDIR/
 
 # other php files
-cp -p admin.*php index.*php wizard.*php news.php api.php items.php logout.php $DESTDIR/
+cp -p admin.*php index.*php upgrade.*php wizard.*php news.php api.php items.php logout.php $DESTDIR/
 
 # media
 cp -RLp media/ $DESTDIR/
@@ -61,8 +61,8 @@ done
 cp -p license.txt README.txt COPYING.txt $DESTDIR/
 
 # creates upload directory
-mkdir $DESTDIR/upload
-chmod a+wx $DESTDIR/upload
+mkdir -p $DESTDIR/upload/_thumbs
+chmod -R a+wx $DESTDIR/upload
 
 # generate sources
 cd $BUILDDIR
index 4d965ea29a9ea746a6fbb0ff1cb953ed9ef4e8b3..3bf57b9f1f6b593a15cb89f4cf1e7d50825518df 100644 (file)
         "SYP wizard"
           => "",
 
+        "exist but is not a directory"
+          => "",
+
+        "could not create directory"
+          => "",
+
+        "directory created"
+          => "",
+
+        "could not write in directory"
+          => "",
+
         "You need at least PHP version 5"
           => "",
 
         "Data table created."
           => "",
 
-        "exist but is not a directory"
+        "It looks like GD extension is not installed."
           => "",
 
-        "could not create directory"
+        "SYP is installed. You can now go to <a href=\"admin.en.php\">admin area</a>"
           => "",
 
-        "directory created"
+        "SYP upgrade"
           => "",
 
-        "could not write in directory"
+        "Thumbnails successfully created."
           => "",
 
-        "SYP is installed. You can now go to <a href=\"admin.en.php\">admin area</a>"
+        "Error when creating thumbnails."
+          => "",
+
+        "SYP upgrade went smoothly. You can now go to <a href=\"admin.en.php\">admin area</a>"
           => "",
 
         "SYP needs javascript. Please activate scripts in your browser."
index 9b1f815d304f3ccff88efeb725b18cb0d7c7039b..0ebe330f6e4aea6f9a84b37c1d02e5b5e3aee52e 100644 (file)
         "Assistant d'installation de SYP"
           ,
 
+        "exist but is not a directory"
+          =>
+        "existe mais n'est pas un répertoire"
+          ,
+
+        "could not create directory"
+          =>
+        "Impossible de créer le répertoire"
+          ,
+
+        "directory created"
+          =>
+        "Répertoire créé"
+          ,
+
+        "could not write in directory"
+          =>
+        "Impossible d'écrire dans le répertoire"
+          ,
+
         "You need at least PHP version 5"
           =>
         "Vous devez utiliser une version de PHP au moins égale à la version 5"
         "Table des données créée."
           ,
 
-        "exist but is not a directory"
+        "It looks like GD extension is not installed."
           =>
-        "existe mais n'est pas un répertoire"
+        "L'extension GD ne semble pas être installée."
           ,
 
-        "could not create directory"
+        "SYP is installed. You can now go to <a href=\"admin.en.php\">admin area</a>"
           =>
-        "Impossible de créer le répertoire"
+        "SYP est installé. Vous pouvez maintenant vous rendre dans <a href=\"admin.fr.php\">la partie administration.</a>"
           ,
 
-        "directory created"
+        "SYP upgrade"
           =>
-        "Répertoire créé"
+        "mise à jour de SYP"
           ,
 
-        "could not write in directory"
+        "Thumbnails successfully created."
           =>
-        "Impossible d'écrire dans le répertoire"
+        "Miniatures crées avec succès."
           ,
 
-        "SYP is installed. You can now go to <a href=\"admin.en.php\">admin area</a>"
+        "Error when creating thumbnails."
           =>
-        "SYP est installé. Vous pouvez maintenant vous rendre dans <a href=\"admin.fr.php\">la partie administration.</a>"
+        "Erreur lors de la création des miniatures."
+          ,
+
+        "SYP upgrade went smoothly. You can now go to <a href=\"admin.en.php\">admin area</a>"
+          =>
+        "La mise à jour de SYP s'est déroulée avec succès. Vous pouvez maintenant vous rendre dans <a href=\"admin.fr.php\">la partie administration.</a>"
           ,
 
         "SYP needs javascript. Please activate scripts in your browser."
           ,
 
     )
-?>
+?>
\ No newline at end of file
index 0d1498f73e1143c04d1f15823b217185c96bdcd5..023797f8e17cdc16b386788467ee75ff016773ac 100755 (executable)
@@ -10,7 +10,7 @@ if (!(isset ($argc)) || !(isset ($argv))) {
 
 $ROOTDIR = "../../";
 // scripts in rootdir we need to link to
-$SCRIPTS = array ("admin", "index", "wizard");
+$SCRIPTS = array ("admin", "index", "upgrade", "wizard");
 
 function usage() {
     global $argv;
index 3f3a3581d5eeb0e38960c055cfa0963c9ba9d13e..50797f0eafc9e932324834ae7dcf33c158ab6547 100644 (file)
@@ -21,6 +21,10 @@ define ("DBPREFIX", "syp_");
 // to be writeable by SYP.
 define ("UPLOADDIR", "upload");
 
+// directory where generated thumbnails are stored. That directory needs to be
+// writeable by SYP.
+define ("THUMBSDIR", "upload/_thumbs");
+
 // title of your website
 define ("SITETITLE", "SYP");
 
@@ -32,4 +36,14 @@ define ("WEBMASTERMAIL", "");
 // different between syp admin and images directory. Or if protocol is
 // different (for example, if syp admin is https and images directory is http)
 define ("IMGSDIRURL", "");
+
+// url of tumbnails directory. If empty, syp will try to guess it from syp
+// location and THUMBSDIR. So, you need to set that variable if host is
+// different between syp admin and images directory. Or if protocol is
+// different (for example, if syp admin is https and images directory is http)
+define ("THUMBSDIRURL", "");
+
+// max size (either width or height) of thumbnails. If one dimension of
+// uploaded image is bigger, images will be resized.
+define ("THUMBSMAXSIZE", 400);
 ?>
index 7fd2bb457744ecb3005e9446aa90760070a13bfa..3b70e7c7ddd40f9c95b6c56ff51b2eecb2062b92 100644 (file)
@@ -11,6 +11,11 @@ try {
 }
 
 $bbox = $connection->mbr ();
+if (defined ("THUMBSMAXSIZE") && (THUMBSMAXSIZE > 0)) {
+    $thumbsmaxsize = THUMBSMAXSIZE;
+} else {
+    $thumbsmaxsize = 400; // default value;
+}
 ?>
 <html>
 <head>
@@ -19,6 +24,21 @@ $bbox = $connection->mbr ();
     <link rel="alternate" type="application/atom+xml" title="Atom 1.0" href="news.php">
     <link rel="stylesheet" href="./openlayers/theme/default/style.css" type="text/css">
     <link rel="stylesheet" href="./media/syp.css" type="text/css">
+    <style type="text/css">
+        .olPopup p {
+            <?php printf("width: %dpx;\n", $thumbsmaxsize)?>
+        }
+        .olPopup img {
+            <?php printf("max-height: %dpx;\n", $thumbsmaxsize)?>
+            <?php printf("max-width: %dpx;\n", $thumbsmaxsize)?>
+
+            /* for IE (does not understand max-heigth max-width) */
+            <?php printf("_height: expression((this.scrollHeight>this.scrollWidth) ? 
+                 Math.min(parseInt(this.scrollHeight), %d ) + 'px' : 'auto');\n", $thumbsmaxsize)?>
+            <?php printf("_width: expression((this.scrollWidth>this.scrollHeight) ? 
+                 Math.min(parseInt(this.scrollWidth), %d ) + 'px' : 'auto');\n", $thumbsmaxsize)?>
+        }
+    </style>
 
     <script type="text/javascript">
         var SypStrings = {
diff --git a/inc/templates_upgrade.php b/inc/templates_upgrade.php
new file mode 100644 (file)
index 0000000..410790a
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
+   license. */
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+       "http://www.w3.org/TR/html4/loose.dtd">  
+<html>
+<head>
+      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
+      <link rel="stylesheet" href="./media/common.css" type="text/css" />
+      <title><?php ptrans ('SYP upgrade')?></title>
+</head>
+<body>
+<?php
+    function create_all_thumbs($con) {
+        $features = $con->listfeatures ();
+        foreach ($features as $feature) {
+            if ($feature->imgpath) {
+                $imgfilename = UPLOADDIR . "/" . $feature->imgpath;
+                $thumbfilename = getthumbsdir () .  "/mini_" . $feature->imgpath;
+                if ((file_exists ($imgfilename)) && 
+                    (!(file_exists ($thumbfilename)))) {
+                    try {
+                        create_thumbnail ($imgfilename, $thumbfilename);
+                    } catch (Exception $e) {
+                        return false;
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    require_once ("./inc/settings.php");
+    require_once ("./inc/db/mysql.php");
+    require_once ("./inc/utils.php");
+
+    $error = false;
+    try {
+        $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
+        $usrtblexists = $connection->users_table_exists ();
+        $itemstblexists = $connection->items_table_exists ();
+    } catch (Exception $e) {
+        $error = true;
+    }
+    if (!$usrtblexists || !$itemstblexists) {
+        $error = true;
+    }
+    if ($error) {
+       die(sprintf('<p class="error center">%s</p>', trans('SYP is not correctly installed. Please follow README.txt instructions
+       and go to <a href="wizard.en.php">wizard</a>.')));
+    }
+
+    safe_create_writable_dir (getthumbsdir ());
+    if (create_all_thumbs ($connection)) {
+        par_success (trans('Thumbnails successfully created.'));
+    } else {
+        par_error (trans('Error when creating thumbnails.'));
+    }
+
+    par_success (trans ('SYP upgrade went smoothly. You can now go to <a href="admin.en.php">admin area</a>'));
+
+?>
+</body>
+</html>
index defbf3f5fe4c7a6b97a6ba755e1aadc6ca1cf913..313a6a7610d69d4eb17164d7e53403d1abe89cd3 100644 (file)
 <body onload="init()">
 
 <?php
-    function leave () {
-        exit ("\n</body></html>");
-    }
-    function wiz_success ($message) {
-        printf ("<p class=\"success center\">%s</p>", $message);
-    }
-    function wiz_error ($message) {
-        printf ("<p class=\"error center\">%s</p>", $message);
-        leave ();
-    }
-    function wiz_warn ($message) {
-        printf ("<p class=\"warn center\">%s</p>", $message);
-    }
 
     if (version_compare (PHP_VERSION, '5.0.0', '<')) {
-        wiz_error (trans ("You need at least PHP version 5"));
+        par_error (trans ("You need at least PHP version 5"));
     }
 
     require_once ("./inc/settings.php");
     require_once ("./inc/db/mysql.php");
+    require_once ("./inc/utils.php");
 
     try {
         $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
     } catch (Exception $e) {
         switch ($e->getMessage ()) {
             case anydbConnection::err_driver_unavailable:
-                wiz_error ($connection->getdbname() . ': ' . trans ('not supported'));
+                par_error ($connection->getdbname() . ': ' . trans ('not supported'));
             case anydbConnection::err_connection:
-                wiz_error (trans ('Could not connect to database.'));
+                par_error (trans ('Could not connect to database.'));
             case anydbConnection::err_unknown_database:
-                wiz_error (trans ('Database does not exist.'));
+                par_error (trans ('Database does not exist.'));
             default:
-                wiz_error (trans ('Unknown error when connecting to database.'));
+                par_error (trans ('Unknown error when connecting to database.'));
         }
     }
     try {
         $users_table_exists = $connection->users_table_exists ();
     } catch(Exception $e) {
-        wiz_error (trans ('Unknown error when checking user table.'));
+        par_error (trans ('Unknown error when checking user table.'));
     }
 
     if ($users_table_exists) {
-        wiz_success (trans ('Found user table.'));
+        par_success (trans ('Found user table.'));
     } else {
         if (isset($_POST ["password"])) {
             try {
                 $connection->create_users_table (true);
             } catch (Exception $e) {
-                wiz_error (trans ('Error when creating user table.'));
+                par_error (trans ('Error when creating user table.'));
             }
-            wiz_success (trans ('User table created.'));
+            par_success (trans ('User table created.'));
             try {
                 $connection->setpwd ("admin", $_POST ["password"]);
             } catch (Exception $e) {
-                wiz_error (trans ('Error when initializing password.'));
+                par_error (trans ('Error when initializing password.'));
             }
-            wiz_success (trans ('Admin password initialized.'));
+            par_success (trans ('Admin password initialized.'));
 
         } else {
             print ('<form class="center" method="post" action="">
     try {
         $items_table_exists = $connection->items_table_exists ();
     } catch (Exception $e) {
-        wiz_error (trans ('Unknown error when checking data table.'));
+        par_error (trans ('Unknown error when checking data table.'));
     }
     if ($items_table_exists) {
-        wiz_success (trans ('Found data table.'));
+        par_success (trans ('Found data table.'));
     } else {
         try {
             $connection->create_items_table (true);
         } catch (Exception $e) {
-            wiz_error (trans ('Error when creating data table.'));
+            par_error (trans ('Error when creating data table.'));
         }
-        wiz_success (trans ('Data table created.'));
+        par_success (trans ('Data table created.'));
     }
-    if (!is_dir (UPLOADDIR)) {
-        if (file_exists (UPLOADDIR)) {
-            wiz_error (UPLOADDIR . ": " . trans ('exist but is not a directory'));
-        }
-        if (!mkdir (UPLOADDIR)) {
-            wiz_error (UPLOADDIR . ": " . trans ('could not create directory'));
-        } else {
-            wiz_success (UPLOADDIR . ": " . trans ('directory created'));
-        }
-    }
-    if (!is_writeable (UPLOADDIR) || !is_executable (UPLOADDIR)) {
-        wiz_error (UPLOADDIR . ": " . trans ('could not write in directory'));
+
+    safe_create_writable_dir (UPLOADDIR);
+    safe_create_writable_dir (getthumbsdir ());
+
+    if (!function_exists ("gd_info")) {
+        par_warn (trans ('It looks like GD extension is not installed.'));
     }
-    wiz_success (trans ('SYP is installed. You can now go to <a href="admin.en.php">admin area</a>'));
+
+    par_success (trans ('SYP is installed. You can now go to <a href="admin.en.php">admin area</a>'));
 ?>
 
 </body>
index cee9d9a2a2d7e26650f144e351a214366f7396fc..12c85c673dfd321a9b1d1a955103aa93f5895d2c 100644 (file)
@@ -4,7 +4,16 @@
 
 require_once ("inc/settings.php");
 
-function gethost() {
+function getthumbsdir () {
+    if (THUMBSDIR) {
+        return rtrim (THUMBSDIR, "/");
+    } else {
+        $uploaddir = rtrim (UPLOADDIR, "/");
+        return $uploaddir . "/" . "_thumbs";
+    }
+}
+
+function gethost () {
     $host = $_SERVER ["HTTP_HOST"];
     $colpos = strpos ($host, ':');
     // some web clients add port informations in Host header
@@ -14,6 +23,11 @@ function gethost() {
     return $host;
 }
 
+function ext_safe ($path) {
+    $basename = basename_safe ($path);
+    return end (explode (".", $basename)); 
+}
+
 function basename_safe ($path) {
     return end (explode ("/", $path)); 
 }
@@ -29,13 +43,18 @@ function unquote($gpc_str) {
    }
 }
 
-function full_url_from_imgpath ($filename) {
+function thumb_url_from_imgpath ($filename) {
+    if (defined ("THUMBSDIRURL") && (strlen (THUMBSDIRURL) != 0)) {
+        return rtrim (THUMBSDIRURL, '/') . "/_mini" . rawurlencode ($filename);
+    }
+    return full_url_from_path (getthumbsdir () . "/mini_" . rawurlencode ($filename));
+}
+
+function image_url_from_imgpath ($filename) {
     if (defined ("IMGSDIRURL") && (strlen (IMGSDIRURL) != 0)) {
         return rtrim (IMGSDIRURL, '/') . "/" . rawurlencode ($filename);
     }
 
-    $rel_path = UPLOADDIR . "/" . rawurlencode ($filename);
-
     return full_url_from_path (UPLOADDIR . "/" . rawurlencode ($filename));
 }
 
@@ -81,4 +100,101 @@ function full_url_from_path ($path) {
 
     return "$proto://$host$port$path";
 }
+
+function create_thumbnail ($filename, $destfile) {
+    $ext = strtolower (ext_safe ($filename));
+    if ($ext == "jpg" || $ext == "jpeg") {
+        $image = imagecreatefromjpeg ($filename);
+    } else if ($ext == "png") {
+        $image = imagecreatefrompng ($filename);
+    } else {
+        return false;
+    }
+
+    if ($image === false) {
+        return false;
+    }
+
+    if (defined (THUMBSMAXSIZE) && (THUMBSMAXSIZE > 0)) {
+        $thumbsmaxsize = THUMBSMAXSIZE;
+    } else {
+        $thumbsmaxsize = 400; // default value;
+    }
+
+    $width = imageSX ($image);
+    $height = imageSY ($image);
+    if (($width  <= $thumbsmaxsize) || ($height <= $thumbsmaxsize)) {
+        return false;
+    }
+
+    if ($width > $height) {
+        $thumb_width = $thumbsmaxsize;
+        $thumb_height = $height * ($thumbsmaxsize / $width);
+    } else if ($width  < $height) {
+        $thumb_width = $width * ($thumbsmaxsize / $height);
+        $thumb_height = $thumbsmaxsize;
+    } else if ($width  == $height) {
+        $thumb_width = $thumbsmaxsize;
+        $thumb_height = $thumbsmaxsize;
+    }
+
+    $thumb_image = ImageCreateTrueColor ($thumb_width, $thumb_height);
+    if ($thumb_image === false) {
+        return false;
+    }
+    if (!imagecopyresampled ($thumb_image, $image, 0, 0, 0, 0,
+                        $thumb_width, $thumb_height, $width, $height)) {
+        return false;
+    }
+
+    if ($ext == "jpg" || $ext == "jpeg") {
+        if (!imagejpeg ($thumb_image, $destfile, 100)) {
+            return false;
+        }
+    } else if ($ext == "png") {
+        if (!imagepng ($thumb_image, $destfile)) {
+            return false;
+        }
+    }
+
+    imagedestroy ($image); 
+    imagedestroy ($thumb_image); 
+
+    return true;
+}
+
+function safe_create_dir ($dirname) {
+    if (is_dir ($dirname)) {
+        return;
+    }
+    if (file_exists ($dirname)) {
+        par_error ($dirname . ": " . trans ('exist but is not a directory'));
+    }
+    if (!mkdir ($dirname)) {
+        par_error ($dirname . ": " . trans ('could not create directory'));
+    } else {
+        par_success ($dirname . ": " . trans ('directory created'));
+    }
+}
+
+function safe_create_writable_dir ($dirname) {
+    safe_create_dir ($dirname);
+    if (!is_writeable ($dirname) || !is_executable ($dirname)) {
+        par_error ($dirname . ": " . trans ('could not write in directory'));
+    }
+}
+
+function leave () {
+    exit ("\n</body></html>");
+}
+function par_success ($message) {
+    printf ("<p class=\"success center\">%s</p>", $message);
+}
+function par_error ($message) {
+    printf ("<p class=\"error center\">%s</p>", $message);
+    leave ();
+}
+function par_warn ($message) {
+    printf ("<p class=\"warn center\">%s</p>", $message);
+}
 ?>
diff --git a/inc/version.php b/inc/version.php
new file mode 100644 (file)
index 0000000..e69de29
index 2ce7c41bac98dcdb213c9cf14a421f7b1f4b38d2..c36318379964d0790564a47587ccf7b4416ef27a 100644 (file)
--- a/items.php
+++ b/items.php
@@ -23,7 +23,10 @@ function main ($features) {
         $title = htmlspecialchars ($feature->title, ENT_QUOTES);
         $description = htmlspecialchars ($feature->description, ENT_QUOTES);
         $imgurl = ($feature->imgpath ? 
-                    full_url_from_imgpath ($feature->imgpath)
+                    image_url_from_imgpath ($feature->imgpath)
+                    : "");
+        $thumburl = ($feature->imgpath ? 
+                    thumb_url_from_imgpath ($feature->imgpath)
                     : "");
         $lon = $feature->lon;
         $lat = $feature->lat;
@@ -32,7 +35,7 @@ function main ($features) {
                     $title;
 
         if ($imgurl) {
-            $imgurlHTML = sprintf ('<img alt="%s" src="%s">', $alt, $imgurl);
+            $imgurlHTML = sprintf ('<a href="%s"><img alt="%s" src="%s"></a>', $imgurl, $alt, $thumburl);
         } else {
             $imgurlHTML = "";
         }
index 3cee0d2d23bd32538f3d35e9079227cee9a94e9f..25be854d3ef2b7bc43f3c4f32c705c9366141aa1 100644 (file)
     width: 50%;
 }
 
-.olPopup p {
-    width: 400px;
-}
-.olPopup img {
-    margin: 20px;
-    max-height: 400px;
-    max-width: 400px;
-
-    /* for IE (does not understand max-heigth max-width) */
-    _height: expression((this.offsetHeight>this.offsetWidth) ? 
-             Math.min(parseInt(this.offsetHeight), 400 ) : true);
-    _width: expression((this.offsetWidth>=this.offsetHeight) ? 
-            Math.min(parseInt(this.offsetWidth), 400 ) : true); 
-}
 .olPopup {
     text-align: center;
     border: 3px double black;
     background-color: white;
 }
+.olPopup img {
+    margin: 20px;
+}
+
 /* for IE (does not understand double borders */
 #popup_contentDiv {
     _border: 2px solid black;
index 9bdefd18cc54da0821569ad5a97956d75804b080..b729bb7f046f955844ea7100302214d29f8b406b 100644 (file)
--- a/news.php
+++ b/news.php
@@ -87,6 +87,17 @@ function main ($features) {
             $contentHTML = sprintf ("<p>%s</p>", htmlspecialchars ($feature->title, ENT_QUOTES));
         }
 
+        // FIXME: we consider thumbnail are correctly sized if gd library is
+        // installed. That may not always be true. For example if gd was installed
+        // after images were initially uploaded.
+        if (function_exists ("imagecreatefromjpeg")) { 
+            if ($feature->imgpath) {
+                $imgurl = image_url_from_imgpath ($feature->imgpath);
+                $thumburl = thumb_url_from_imgpath ($feature->imgpath);
+                $contentHTML .= sprintf ('<a href="%s"><img alt="%s" src="%s"></a>', $imgurl, $alt, $thumburl);
+            }
+        }
+
         if (strlen ($contentHTML) != 0) {
             printf ("       <content type=\"html\">
                 %s
diff --git a/upgrade.en.php b/upgrade.en.php
new file mode 120000 (symlink)
index 0000000..2e231bc
--- /dev/null
@@ -0,0 +1 @@
+upgrade.php
\ No newline at end of file
diff --git a/upgrade.fr.php b/upgrade.fr.php
new file mode 120000 (symlink)
index 0000000..2e231bc
--- /dev/null
@@ -0,0 +1 @@
+upgrade.php
\ No newline at end of file
diff --git a/upgrade.php b/upgrade.php
new file mode 100644 (file)
index 0000000..a29bfb3
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
+   license. */
+
+    require ('inc/langutils.php');
+    require ('inc/templates_upgrade.php');
+?>