load plugins, and added getThumbTarget function, overloaded by viewer plugin
authorMarc MAURICE <dooblempub@positon.org>
Sun, 12 Dec 2010 22:35:15 +0000 (23:35 +0100)
committerMarc MAURICE <dooblempub@positon.org>
Sun, 12 Dec 2010 22:35:15 +0000 (23:35 +0100)
index.php
plugins/viewer/functions.php [new file with mode: 0644]

index 61f5579..b464e04 100644 (file)
--- a/index.php
+++ b/index.php
 
 require 'config.php';
 
+// load plugins
+$plugins = scandir("plugins");
+array_shift($plugins); array_shift($plugins); // remove . and ..
+foreach ($plugins as $p) if (is_file("plugins/$p/functions.php"))
+       require "plugins/$p/functions.php";
+
+if (! function_exists('getThumbTarget')) {
+function getThumbTarget($imageSimplePath)
+{
+       return dirname($_SERVER["SCRIPT_NAME"]).'/'.IMAGES_DIR.$imageSimplePath;
+}
+}
+
 function getPreview($imgFile, $maxSize = THUMB_SIZE)
 {
        # example: data/myalbum/100.mypic.jpg
@@ -120,6 +133,7 @@ foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..')
                $ext = strtolower(substr($file, -4));
                if ($ext == ".jpg" or $ext == ".png") {
                                $link = dirname($scriptUrlPath)."/$realDir/$file";
+                               $link = getThumbTarget("$shortPath/$file");
 
                        $imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => $link );
 
diff --git a/plugins/viewer/functions.php b/plugins/viewer/functions.php
new file mode 100644 (file)
index 0000000..3d14508
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+function getThumbTarget($imageSimplePath)
+{
+       return dirname($_SERVER["SCRIPT_NAME"])."/plugins/viewer/view.php$imageSimplePath";
+}
+?>