SF.net SVN: phpwiki:[10737] trunk/lib/plugin/PhotoAlbum.php

vargenau--- via phpwiki-checkins <[email protected]>
Newsgroups gmane.comp.web.wiki.phpwiki.checkins
Message-ID <[email protected]>
Revision: 10737
          http://sourceforge.net/p/phpwiki/code/10737
Author:   vargenau
Date:     2021-12-06 16:13:44 +0000 (Mon, 06 Dec 2021)
Log Message:
-----------
PhotoAlbum plugin: replace class ImageTile by function image_tile to display tiles

Modified Paths:
--------------
    trunk/lib/plugin/PhotoAlbum.php

Modified: trunk/lib/plugin/PhotoAlbum.php
===================================================================
--- trunk/lib/plugin/PhotoAlbum.php	2021-12-06 15:33:23 UTC (rev 10736)
+++ trunk/lib/plugin/PhotoAlbum.php	2021-12-06 16:13:44 UTC (rev 10737)
@@ -62,38 +62,10 @@
  * TODO:
  * - specify picture(s) as parameter(s)
  * - limit amount of pictures on one page
- * - use PHP to really resize or greyscale images (only where GD library supports it)
- *   (quite done for resize with "ImageTile.php")
  *
- * KNOWN ISSUES:
- * - reading height and width from images with spaces in their names fails.
- *
  * Fixed album location idea by Philip J. Hollenback. Thanks!
  */
 
-class ImageTile extends HtmlElement
-{
-    // go away, hack!
-    static function image_tile( /*...*/)
-    {
-        $el = new HTML ('img');
-        $tag = func_get_args();
-        $path = DATA_PATH . "/ImageTile.php";
-        $params = "<img src=\"$path?url=" . $tag[0]['src'];
-        if (!@empty($tag[0]['width']))
-            $params .= "&width=" . $tag[0]['width'];
-        if (!@empty($tag[0]['height']))
-            $params .= "&height=" . $tag[0]['height'];
-        if (!@empty($tag[0]['width']))
-            $params .= '" width="' . $tag[0]['width'];
-        if (!@empty($tag[0]['height']))
-            $params .= '" height="' . $tag[0]['height'];
-
-        $params .= '" alt="' . $tag[0]['alt'] . '" />';
-        return $el->raw($params);
-    }
-}
-
 class WikiPlugin_PhotoAlbum
     extends WikiPlugin
 {
@@ -347,7 +319,7 @@
                     unset ($params['location'], $params['src_tile']);
                     $url_image = $link ? HTML::a(array("id" => basename($value["name"]),
                             "href" => "$url"),
-                        ImageTile::image_tile($params))
+                        $this->image_tile($params))
                         : HTML::img($params);
                     $params = $keep;
                     unset ($keep);
@@ -507,7 +479,7 @@
      * @param  mixed   $value   Either absolute no. or HTML percentage e.g. '50%'
      * @return integer New size in pixels
      */
-    function newSize($oldSize, $value)
+    private function newSize($oldSize, $value)
     {
         if (trim(substr($value, strlen($value) - 1)) != "%") {
             return $value;
@@ -524,7 +496,7 @@
      * @param array $photos
      * @return string Error if fixed location is not allowed
      */
-    function fromLocation($src, &$photos)
+    private function fromLocation($src, &$photos)
     {
         //FIXME!
         if (!IsSafeURL($src)) {
@@ -540,10 +512,10 @@
      *
      * @param  string $src    path to dir or textfile (local or remote)
      * @param  array  $photos
-     * @param string $webpath
+     * @param  string $webpath
      * @return string Error when bad URL or file couldn't be opened
      */
-    function fromFile($src, &$photos, $webpath = '')
+    private function fromFile($src, &$photos, $webpath = '')
     {
         $src_bak = $src;
         if (preg_match("/^Upload:(.*)$/", $src, $m)) {
@@ -565,7 +537,7 @@
             if (string_ends_with($src, "/"))
                 $src = substr($src, 0, -1);
         }
-        if (!file_exists($src) 
+        if (!file_exists($src)
             && defined('PHPWIKI_DIR')
             && file_exists(PHPWIKI_DIR . "/$src")) {
             $src = PHPWIKI_DIR . "/$src";
@@ -657,4 +629,16 @@
         }
         return '';
     }
+
+    private function image_tile($params)
+    {
+        if (array_key_exists('width', $params)) {
+            return HTML::img(array('src' => '/'.$params['src'],
+                                   'width' => $params['width'],
+                                   'alt' => $params['alt']));
+        } else {
+            return HTML::img(array('src' => '/'.$params['src'],
+                                   'alt' => $params['alt']));
+        }
+    }
 }

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.