From 80cd655e2ca89e6d96aaa12623fac448569c6ac7 Mon Sep 17 00:00:00 2001 From: Pim Snel Date: Mon, 20 Sep 2004 20:40:50 +0000 Subject: [PATCH] - made UploadImage finally working - integrated with egroupware using appsession vars - added max sizes when uploading - added this CHANGELOG - added the README for developer instructions - checked copyrights - changed icon --- .../js/htmlarea/plugins/UploadImage/CHANGELOG | 9 + .../js/htmlarea/plugins/UploadImage/README | 48 + .../plugins/UploadImage/img/up_image.gif | Bin 148 -> 181 bytes .../plugins/UploadImage/img/up_image.xcf | Bin 0 -> 1664 bytes .../popups/ImageManager/config.inc.php | 119 +- .../popups/ImageManager/images.php | 1129 +++++++++-------- .../popups/ImageManager/std_functions.inc.php | 25 + .../popups/ImageManager/thumbs.php | 130 +- .../UploadImage/popups/insert_image.php | 72 +- .../plugins/UploadImage/upload-image.js | 34 +- 10 files changed, 872 insertions(+), 694 deletions(-) create mode 100644 phpgwapi/js/htmlarea/plugins/UploadImage/CHANGELOG create mode 100644 phpgwapi/js/htmlarea/plugins/UploadImage/README create mode 100644 phpgwapi/js/htmlarea/plugins/UploadImage/img/up_image.xcf create mode 100644 phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/std_functions.inc.php diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/CHANGELOG b/phpgwapi/js/htmlarea/plugins/UploadImage/CHANGELOG new file mode 100644 index 0000000000..a20e7f788c --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/CHANGELOG @@ -0,0 +1,9 @@ +Mon Sep 20 22:23:52 CEST 2004 +----------------------------- +- made UploadImage finally working +- integrated with egroupware using appsession vars +- added max sizes when uploading +- added this CHANGELOG +- added the README for developer instructions +- checked copyrights +- changed icon diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/README b/phpgwapi/js/htmlarea/plugins/UploadImage/README new file mode 100644 index 0000000000..11da02155b --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/README @@ -0,0 +1,48 @@ +UploadImage for HtmlArea in eGroupWare +----------------------------------------------------------- +Original Author: Xiang Wei ZHUO +Author for eGW: Pim Snel +Last Updated: Mon Sep 20 19:55:03 CEST 2004 +Requirements: eGroupWare 1.x, htmlArea 3rc or higher +Note: UploadImage only works as plugin for htmlArea in eGroupWare. +----------------------------------------------------------- + +UploadImage adds an image_upload-icon in the htmlArea-toolbar. When the icon is clicked +the user can Select an image from the Upload Directory or upload an Image to the directory +the upload directory eGW-developer has specified. After insertion the image is shown in the +htmlarea. Future features will be: resizing images, cropping images, rotating images etc .... + +To use the plugin you have to do the following: + +// thirst setup the sessionvariables UploadImage Need +$sessdata = array( + 'UploadImageBaseDir' => /path/to/eg/egw/images , // absolute path to the base directory + 'UploadImageBaseURL' => http://yourhost/egw/images, // the complete URL to the base images directory + 'UploadImageMaxWidth' => 500, // max, image width in pixels + 'UploadImageMaxHeight' => 500 // max. image height in pixels + ); + +$GLOBALS['phpgw']->session->appsession('UploadImage','phpgwapi',$sessdata); + + +// then init the html class and call the htmlarea class-method with the UploadPlugin as argument +if (!is_object($GLOBALS['phpgw']->html)) +{ + $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); +} + +$htmlarea = $GLOBALS['phpgw']->html->htmlarea($field_name, $value,$style,false,'UploadImage',$custom_toolbar); + +----------------------------------------------------------- +SECURITY WARNING!!! +----------------------------------------------------------- +When you are implementing the UploadImage plugin make sure +your UploadImageBaseDir is set correctly because else it +might give access to other directories apache has access to. + + +----------------------------------------------------------- +Known issues: +- Create directory doesn't work +- In some cases the OK and cancel buttons won't work anymore (javascript issue) + diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/img/up_image.gif b/phpgwapi/js/htmlarea/plugins/UploadImage/img/up_image.gif index 9d2bff131cfa0741a7eff54a054c272bbdd834bb..b20f66837767ed358495776adf85af71ab2832e0 100755 GIT binary patch literal 181 zcmZ?wbhEHb6k-r!c+9~71`Q2Bs(}GWH30E{AOI5}20Bpu$->CMz`>vc(g-qxfh9@c zr043r5lx47KW7N#V9A`8VIj)$VBdxXUdb5>-xn&cy>ZXsh@+CQXg=$lP1}DdPLgrn zv_nfRvr&EWwOw}14`yAAW|+PG7Nb*c-uZb=jWv043nJAo&0N*E_l&-za9UHVkRXFK E0KP|1s{jB1 literal 148 zcmZ?wbhEHb6k-r!Sj5i2&;W!C4M4J?;s1XI1`q}k{}q3-FfuT(Gw1-hK$Sua49t-g zyYBo8nCZBBXMu5Onm%C*sub7uF&%L9k=tI=u%$|uwf^2*{Vcow8}BEuFjxZsptv^# diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/img/up_image.xcf b/phpgwapi/js/htmlarea/plugins/UploadImage/img/up_image.xcf new file mode 100644 index 0000000000000000000000000000000000000000..8cc3ce9b72f0f76715b6dc11793db049215a3bfe GIT binary patch literal 1664 zcmcIk&2G~`5T0EpcA6ic{N(HdNXa26y>daS;Kq$7NL|NR(>u`UpMQ6YAcF_bVK_%on35oh9Lss|9ei5470eY?c-v zAAN|K^>RKQ=W($k$kBg7C2}{E=V6byAd=smh1)HF=h=QcT@>~Mr<3o7< z8q%;jE;^{_&5GWt=N4~a-;|pK;{w^jXw$JGsZ8be0 zsXJ8DE%J36I@?aVbS~bMjy^m3aP;Bm!_jBk2^{|=8>%{5JjTQ0QS>p%=4Z3hus59M zeWtZ<;u*rObw?c0fe!iltE0tv1+ZA7%;y!sG z;wS}5I{yx}w4|=Cw(tW*D}Sa^3kf!gNC!L4XgAQp;Y_2_A{sLE@j#H&*Btv7`X;yJ z61F4Pfm9pL!3|)1s&-3Vs4L4-kPYA04W_~5?PVN2w7e;K8M~&jqKa*M;odNd`#KS7 zjn!~-Yg|mbrtCP_s2c;@;svOBxgM~n6LwS*a%x~8EJ9%s)Y0BfFgUY66Cu xvP75{Y^i@)8)Zrdcrq&+fR79|J`jAQNaG=c#E;xVq@=*yCV-*a(k;C1(r<|F#S{Pl literal 0 HcmV?d00001 diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/config.inc.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/config.inc.php index ea23fa1aa7..0045788e5e 100755 --- a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/config.inc.php +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/config.inc.php @@ -1,64 +1,87 @@ - * + * Modified for eGW by and (c) by Pim Snel * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; version 2 of the License. * + \**************************************************************************/ -//************************** BEGIN CONFIGURATION *****************************// + /* $id$ */ -//example, this is the actual file system path -//of the web server document root. e.g. -// Filesystem == /home/web/www.yourdomain.com -$BASE_DIR = $GLOBALS[UploadImageBaseDir]; -$BASE_URL = $GLOBALS[UploadImageBaseURL]; -$BASE_ROOT = $GLOBALS[UploadImageRelativePath]; + // FIXME: remove imageMagick shit, we only use gdlib + // FIXME: autodetect safe_mode + // FIXME set current app to the calling app + // FIXME include header nicer -var_dump($BASE_DIR); -var_dump($BASE_URL); -var_dump($BASE_ROOT); + $phpgw_flags = Array( + 'currentapp' => 'jinn', + 'noheader' => True, + 'nonavbar' => True, + 'noappheader' => True, + 'noappfooter' => True, + 'nofooter' => True + ); -//$BASE_DIR = $_SERVER['DOCUMENT_ROOT']; -//$BASE_DIR = '/home/www'; + $GLOBALS['phpgw_info']['flags'] = $phpgw_flags; -//the path where the browser sees the document root (i.e. http://www.yourdomain.com/) -//$BASE_URL = 'https://192.168.0.2/'; + if(@include('../../../../../../header.inc.php')) + { + // I know this is very ugly + } + else + { + @include('../../../../../../../header.inc.php'); + } -//this is where the images will be stored relative to the $BASE_DIR (and $BASE_URL) -//this directory MUST be readable AND writable by the web server. -//$BASE_ROOT = ''; + define('IMAGE_CLASS', 'GD'); -//The image manipulation library to use, either GD or ImageMagick or NetPBM -//valid definitions are 'GD' or 'IM' or 'NetPBM'. -define('IMAGE_CLASS', 'GD'); // + //In safe mode, directory creation is not permitted. + $SAFE_MODE = false; -//After defining which library to use, if it is NetPBM or IM, you need to -//specify where the binary for the selected library are. And of course -//your server and PHP must be able to execute them (i.e. safe mode is OFF). -//If you have safe mode ON, or don't have the binaries, your choice is -//GD only. GD does not require the following definition. -define('IMAGE_TRANSFORM_LIB_PATH', '/usr/bin/netpbm/'); -//define('IMAGE_TRANSFORM_LIB_PATH', '"D:\\Program Files\\ImageMagick\\'); + $sessdata = $GLOBALS['phpgw']->session->appsession('UploadImage','phpgwapi'); + + $BASE_DIR = $sessdata[UploadImageBaseDir]; + $BASE_URL = $sessdata[UploadImageBaseURL]; + $MAX_HEIGHT = $sessdata[UploadImageMaxHeight]; + $MAX_WIDTH = $sessdata[UploadImageMaxWidth]; + + if(!$MAX_HEIGHT) $MAX_HEIGHT = 10000; + if(!$MAX_WIDTH) $MAX_WIDTH = 10000; +// _debug_array($sessdata); + //die(); -//In safe mode, directory creation is not permitted. -$SAFE_MODE = false; + //After defining which library to use, if it is NetPBM or IM, you need to + //specify where the binary for the selected library are. And of course + //your server and PHP must be able to execute them (i.e. safe mode is OFF). + //If you have safe mode ON, or don't have the binaries, your choice is + //GD only. GD does not require the following definition. + //define('IMAGE_TRANSFORM_LIB_PATH', '/usr/bin/netpbm/'); + //define('IMAGE_TRANSFORM_LIB_PATH', '"D:\\Program Files\\ImageMagick\\'); -//************************** END CONFIGURATION *****************************// + $BASE_ROOT = ''; + $IMG_ROOT = $BASE_ROOT; -$IMG_ROOT = $BASE_ROOT; + if(strrpos($BASE_DIR, '/')!= strlen($BASE_DIR)-1) + $BASE_DIR .= '/'; -if(strrpos($BASE_DIR, '/')!= strlen($BASE_DIR)-1) - $BASE_DIR .= '/'; + if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1) + $BASE_URL .= '/'; -if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1) -$BASE_URL .= '/'; - -//Built in function of dirname is faulty -//It assumes that the directory nane can not contain a . (period) -function dir_name($dir) -{ - $lastSlash = intval(strrpos($dir, '/')); - if($lastSlash == strlen($dir)-1){ - return substr($dir, 0, $lastSlash); - } - else - return dirname($dir); -} + //Built in function of dirname is faulty + //It assumes that the directory nane can not contain a . (period) + function dir_name($dir) + { + $lastSlash = intval(strrpos($dir, '/')); + if($lastSlash == strlen($dir)-1){ + return substr($dir, 0, $lastSlash); + } + else + return dirname($dir); + } ?> diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/images.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/images.php index 59fb1e3188..414262063e 100755 --- a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/images.php +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/images.php @@ -1,296 +1,355 @@ - -** Filename......: images.php -** Last changed..: 8 Mar 2003 -** Notes.........: Configuration in config.inc.php + * + * Modified for eGW by and (c) by Pim Snel * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; version 2 of the License. * + * -------------------------------------------- * + * Title.........: Image Manager, draws the thumbnails and directies * + * Version.......: 1.01 * + * Author........: Xiang Wei ZHUO * + * Notes.........: Configuration in config.inc.php * + * * + * Functions * + * - create a new folder, * + * - delete folder, * + * - upload new image * + * - use cached thumbnail views * + \**************************************************************************/ - Functions - - create a new folder, - - delete folder, - - upload new image - - use cached thumbnail views + /* $id */ -***********************************************************************/ + // FIXME move all php functions to a main file + // FIXME better directory-structure -include 'config.inc.php'; + include 'config.inc.php'; + require_once 'std_functions.inc.php'; + require_once '../ImageEditor/Transform.php'; -if(isset($_GET['dir'])) { - $dirParam = $_GET['dir']; + if(isset($_GET['dir'])) { + $dirParam = $_GET['dir']; - if(strlen($dirParam) > 0) - { - if(substr($dirParam,0,1)=='/') - $IMG_ROOT .= $dirParam; - else - $IMG_ROOT = $dirParam; - } -} + if(strlen($dirParam) > 0) + { + if(substr($dirParam,0,1)=='/') + $IMG_ROOT .= $dirParam; + else + $IMG_ROOT = $dirParam; + } + } -$refresh_dirs = false; -$clearUploads = false; + $refresh_dirs = false; + $clearUploads = false; -if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) - $IMG_ROOT .= '/'; + if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) + $IMG_ROOT .= '/'; + if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false) + { + create_folder(); + } -if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false) -{ - create_folder(); -} + if(isset($_GET['delFile']) && isset($_GET['dir'])) + { + delete_file($_GET['delFile']); + } -if(isset($_GET['delFile']) && isset($_GET['dir'])) -{ - delete_file($_GET['delFile']); -} + if(isset($_GET['delFolder']) && isset($_GET['dir'])) + { + delete_folder($_GET['delFolder']); + } -if(isset($_GET['delFolder']) && isset($_GET['dir'])) -{ - delete_folder($_GET['delFolder']); -} + if(isset($_FILES['upload']) && is_array($_FILES['upload']) && isset($_POST['dirPath'])) + { + $dirPathPost = $_POST['dirPath']; -if(isset($_FILES['upload']) && is_array($_FILES['upload']) && isset($_POST['dirPath'])) -{ + if(strlen($dirPathPost) > 0) + { + if(substr($dirPathPost,0,1)=='/') + $IMG_ROOT .= $dirPathPost; + else + $IMG_ROOT = $dirPathPost; + } - $dirPathPost = $_POST['dirPath']; + if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) + $IMG_ROOT .= '/'; - if(strlen($dirPathPost) > 0) - { - if(substr($dirPathPost,0,1)=='/') - $IMG_ROOT .= $dirPathPost; - else - $IMG_ROOT = $dirPathPost; - } + // do_upload($_FILES['upload'], $BASE_DIR.$BASE_ROOT.$dirPathPost.'/'); + do_upload($_FILES['upload'], $BASE_DIR.$dirPathPost.'/'); + } - if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) - $IMG_ROOT .= '/'; + function do_upload($file, $dest_dir) + { + global $clearUploads,$MAX_WIDTH,$MAX_HEIGHT; - do_upload($_FILES['upload'], $BASE_DIR.$BASE_ROOT.$dirPathPost.'/'); -} + if(is_file($file['tmp_name'])) + { + $img_info = getimagesize($file['tmp_name']); -function do_upload($file, $dest_dir) -{ - global $clearUploads; + //_debug_array($img_info); + + if(is_array($img_info)) + { + $w = $img_info[0]; + $h = $img_info[1]; - if(is_file($file['tmp_name'])) - { - //var_dump($file); echo "DIR:$dest_dir"; - move_uploaded_file($file['tmp_name'], $dest_dir.$file['name']); - chmod($dest_dir.$file['name'], 0666); - } + if( $w > $MAX_WIDTH || $h > $MAX_HEIGHT ) + { + adapt_size($file['tmp_name'],$dest_dir.$file['name']); + } + else + { + move_uploaded_file($file['tmp_name'], $dest_dir.$file['name']); + } + chmod($dest_dir.$file['name'], 0666); + } + } + $clearUploads = true; + } + + function adapt_size($img,$dest_file) + { + global $BASE_DIR, $BASE_URL,$MAX_WIDTH,$MAX_HEIGHT; - $clearUploads = true; -} + $path_info = pathinfo($img); + $path = $path_info['dirname']."/"; + $img_file = $path_info['basename']; -function delete_folder($folder) -{ - global $BASE_DIR, $refresh_dirs; - //var_dump($BASE_DIR); - $del_folder = dir_name($BASE_DIR).$folder; - //echo $del_folder; - if(is_dir($del_folder) && num_files($del_folder) <= 0) { - //echo $del_folder.'
'; - rm_all_dir($del_folder); - $refresh_dirs = true; - } -} + $img_info = getimagesize($path.$img_file); + $w = $img_info[0]; $h = $img_info[1]; -function rm_all_dir($dir) -{ - //$dir = dir_name($dir); - //echo "OPEN:".$dir.'
'; - if(is_dir($dir)) - { - $d = @dir($dir); - - while (false !== ($entry = $d->read())) - { + $nw = $MAX_WIDTH; $nh = $MAX_HEIGHT; + + $img_resize = Image_Transform::factory(IMAGE_CLASS); + $img_resize->load($path.$img_file); + + if ($w > $h) + $nh = unpercent(percent($nw, $w), $h); + else if ($h > $w) + $nw = unpercent(percent($nh, $h), $w); + + $img_resize->resize($nw, $nh); + + $img_resize->save($dest_file); + $img_resize->free(); + + chmod($dest_file, 0666); + } + + + + function delete_folder($folder) + { + global $BASE_DIR, $refresh_dirs; + + $del_folder = dir_name($BASE_DIR).$folder; + + if(is_dir($del_folder) && num_files($del_folder) <= 0) + { + rm_all_dir($del_folder); + $refresh_dirs = true; + } + } + + function rm_all_dir($dir) + { + //$dir = dir_name($dir); + //echo "OPEN:".$dir.'
'; + if(is_dir($dir)) + { + $d = @dir($dir); + + while (false !== ($entry = $d->read())) + { //echo "#".$entry.'
'; if($entry != '.' && $entry != '..') { - $node = $dir.'/'.$entry; - //echo "NODE:".$node; - if(is_file($node)) { - //echo " - is file
"; - unlink($node); - } - else if(is_dir($node)) { - //echo " - is Dir
"; - rm_all_dir($node); - } + $node = $dir.'/'.$entry; + //echo "NODE:".$node; + if(is_file($node)) { + //echo " - is file
"; + unlink($node); + } + else if(is_dir($node)) { + //echo " - is Dir
"; + rm_all_dir($node); + } } - } - $d->close(); + } + $d->close(); - rmdir($dir); - } - //echo "RM: $dir
"; -} + rmdir($dir); + } + //echo "RM: $dir
"; + } -function delete_file($file) -{ - global $BASE_DIR; - - $del_image = dir_name($BASE_DIR).$file; + function delete_file($file) + { + global $BASE_DIR,$IMG_ROOT; - $del_thumb = dir_name($del_image).'.'.basename($del_image); + $del_image = dir_name($BASE_DIR).$IMG_ROOT.$file; + $del_thumb = dir_name($BASE_DIR).$IMG_ROOT.$file; - if(is_file($del_image)) { - unlink($del_image); - } + if(is_file($del_image)) + { + unlink($del_image); + } - if(is_file($del_thumb)) { - unlink($del_thumb); - } -} + if(is_file($del_thumb)) + { + unlink($del_thumb); + } + } -function create_folder() -{ - global $BASE_DIR, $IMG_ROOT, $refresh_dirs; - - $folder_name = $_GET['foldername']; + function create_folder() + { + global $BASE_DIR, $IMG_ROOT, $refresh_dirs; - if(strlen($folder_name) >0) - { - $folder = $BASE_DIR.$IMG_ROOT.$folder_name; + $folder_name = $_GET['foldername']; - if(!is_dir($folder) && !is_file($folder)) - { + if(strlen($folder_name) >0) + { + $folder = $BASE_DIR.$IMG_ROOT.$folder_name; + + if(!is_dir($folder) && !is_file($folder)) + { mkdir($folder,0777); chmod($folder,0777); $refresh_dirs = true; - } - } -} + } + } + } -function num_files($dir) -{ - $total = 0; + function num_files($dir) + { + $total = 0; - if(is_dir($dir)) - { - $d = @dir($dir); + if(is_dir($dir)) + { + $d = @dir($dir); - while (false !== ($entry = $d->read())) - { + while (false !== ($entry = $d->read())) + { //echo $entry."
"; if(substr($entry,0,1) != '.') { - $total++; + $total++; } - } - $d->close(); - } - return $total; -} + } + $d->close(); + } + return $total; + } -function dirs($dir,$abs_path) -{ - $d = dir($dir); - //echo "Handle: ".$d->handle."
\n"; - //echo "Path: ".$d->path."
\n"; - $dirs = array(); - while (false !== ($entry = $d->read())) { - if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.') - { - //dirs($dir.'/'.$entry, $prefix.$prefix); - //echo $prefix.$entry."
\n"; - $path['path'] = $dir.'/'.$entry; - $path['name'] = $entry; - $dirs[$entry] = $path; - } - } - $d->close(); - - ksort($dirs); - for($i=0; $ihandle."
\n"; + //echo "Path: ".$d->path."
\n"; + $dirs = array(); + while (false !== ($entry = $d->read())) { + if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.') + { + //dirs($dir.'/'.$entry, $prefix.$prefix); + //echo $prefix.$entry."
\n"; + $path['path'] = $dir.'/'.$entry; + $path['name'] = $entry; + $dirs[$entry] = $path; + } + } + $d->close(); -function parse_size($size) -{ - if($size < 1024) - return $size.' btyes'; - else if($size >= 1024 && $size < 1024*1024) - { - return sprintf('%01.2f',$size/1024.0).' Kb'; - } - else - { - return sprintf('%01.2f',$size/(1024.0*1024)).' Mb'; - } -} + ksort($dirs); + for($i=0; $i= 1024 && $size < 1024*1024) + { + return sprintf('%01.2f',$size/1024.0).' Kb'; + } + else + { + return sprintf('%01.2f',$size/(1024.0*1024)).' Mb'; + } + } - $img_path = dir_name($img); - $img_file = basename($img); + function show_image($img, $file, $info, $size) + { + global $BASE_DIR, $BASE_URL, $newPath; - $thumb_image = 'thumbs.php?img='.urlencode($img); + $img_path = dir_name($img); + $img_file = basename($img); - $img_url = $BASE_URL.$img_path.'/'.$img_file; + $thumb_image = 'thumbs.php?img='.urlencode($img); - $filesize = parse_size($size); + $img_url = $BASE_URL.$img_path.'/'.$img_file; -?> - - - - - - - - -
- <? echo $file; ?> - <? echo $filesize; ?>
- - - - - -
- -
- - + + + + + + + + +
+ <? echo $file; ?> - <? echo $filesize; ?>
+ + + + + +
+ +
+ + - - - - - - - -
- - <? echo $dir; ?> - -
- - - - -
-
+ + + + + + + +
+ + <? echo $dir; ?> + +
+ + + + +
+
- - - + + +
No Images Found
No Images Found
- - - + + +
Configuration Problem: "" does not exist.
Configuration Problem: "" does not exist.
'; - echo ''; -} + echo ''; + echo ''; + } -function draw_table_footer() -{ - echo ''; - echo '
'; + function draw_table_footer() + { + echo ''; + echo ''; } ?> - -Image Browser - - - + + 0) - { - $upDirPath .= $path.'/'; - } - } + $paths = explode('/', $dirPath); + $upDirPath = '/'; + for($i=0; $i 0) + { + $upDirPath .= $path.'/'; + } + } - $slashIndex = strlen($dirPath); - $newPath = $dirPath; - if($slashIndex > 1 && substr($dirPath, $slashIndex-1, $slashIndex) == '/') - { - $newPath = substr($dirPath, 0,$slashIndex-1); - } -?> - - - - - + function MM_showHideLayers() { //v6.0 + var i,p,v,obj,args=MM_showHideLayers.arguments; + for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i],window.top.document))!=null) { v=args[i+2]; + if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } + obj.visibility=v; } + } -'; -$d = @dir($BASE_DIR.$IMG_ROOT); + function changeLoadingStatus(state) + { + var statusText = null; + if(state == 'load') { + statusText = 'Loading Images'; + } + else if(state == 'upload') { + statusText = 'Uploading Files'; + } + if(statusText != null) { + var obj = MM_findObj('loadingStatus', window.top.document); + //alert(obj.innerHTML); + if (obj != null && obj.innerHTML != null) + obj.innerHTML = statusText; + MM_showHideLayers('loading','','show') + } + } -if($d) -{ - //var_dump($d); - $images = array(); - $folders = array(); - while (false !== ($entry = $d->read())) - { - $img_file = $IMG_ROOT.$entry; + //--> + + + - if(is_file($BASE_DIR.$img_file) && substr($entry,0,1) != '.') - { - $image_info = @getimagesize($BASE_DIR.$img_file); - if(is_array($image_info)) - { - $file_details['file'] = $img_file; - $file_details['img_info'] = $image_info; - $file_details['size'] = filesize($BASE_DIR.$img_file); - $images[$entry] = $file_details; - //show_image($img_file, $entry, $image_info); - } - } - else if(is_dir($BASE_DIR.$img_file) && substr($entry,0,1) != '.') - { - $folders[$entry] = $img_file; - //show_dir($img_file, $entry); - } - } - $d->close(); - - if(count($images) > 0 || count($folders) > 0) - { - //now sort the folders and images by name. - ksort($images); - ksort($folders); + '; + $d = @dir($BASE_DIR.$IMG_ROOT); - draw_table_header(); + if($d) + { + //var_dump($d); + $images = array(); + $folders = array(); + while (false !== ($entry = $d->read())) + { + $img_file = $IMG_ROOT.$entry; - for($i=0; $iclose(); -?> - - - + if(count($images) > 0 || count($folders) > 0) + { + //now sort the folders and images by name. + ksort($images); + ksort($folders); + + draw_table_header(); + + for($i=0; $i + + + diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/std_functions.inc.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/std_functions.inc.php new file mode 100644 index 0000000000..8a0e696ec4 --- /dev/null +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/std_functions.inc.php @@ -0,0 +1,25 @@ + * + * Modified for eGW by and (c) by Pim Snel * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; version 2 of the License. * + \**************************************************************************/ + + function percent($p, $w) + { + return (real)(100 * ($p / $w)); + } + + function unpercent($percent, $whole) + { + return (real)(($percent * $whole) / 100); + } + + + +?> diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/thumbs.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/thumbs.php index 7fd8c3ae78..c0ed2e9a2f 100755 --- a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/thumbs.php +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/thumbs.php @@ -1,91 +1,87 @@ -** Filename......: thumbs.php -** Last changed..: 1 Mar 2003 -** Notes.........: Configuration in config.inc.php + /**************************************************************************\ + * eGroupWare - UploadImage-plugin for htmlArea * + * http://www.eGroupWare.org * + * Written and (c) by Xiang Wei ZHUO * + * Modified for eGW by and (c) by Pim Snel * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; version 2 of the License. * + * -------------------------------------------- * + * Title.........: Thumbnail generator, with cache. * + * Version.......: 1.01 * + * Author........: Xiang Wei ZHUO * + * Notes.........: Configuration in config.inc.php * + * * + * Functions * + * - if the thumbnail does not exists or the source file is newer, create a * + * new thumbnail. * + \**************************************************************************/ - - if the thumbnail does not exists or the source - file is newer, create a new thumbnail. + /* $id */ -***********************************************************************/ + require_once 'config.inc.php'; + require_once 'std_functions.inc.php'; + require_once '../ImageEditor/Transform.php'; + $img = $BASE_DIR.urldecode($_GET['img']); -include 'config.inc.php'; -require_once '../ImageEditor/Transform.php'; + if(is_file($img)) { + make_thumbs(urldecode($_GET['img'])); + } -$img = $BASE_DIR.urldecode($_GET['img']); + function make_thumbs($img) + { + global $BASE_DIR, $BASE_URL; -if(is_file($img)) { - make_thumbs(urldecode($_GET['img'])); -} + $path_info = pathinfo($img); + $path = $path_info['dirname']."/"; + $img_file = $path_info['basename']; + $thumb = $path.'.'.$img_file; -function make_thumbs($img) -{ - global $BASE_DIR, $BASE_URL; + $img_info = getimagesize($BASE_DIR.$path.$img_file); + $w = $img_info[0]; $h = $img_info[1]; + $nw = 96; $nh = 96; - $path_info = pathinfo($img); - $path = $path_info['dirname']."/"; - $img_file = $path_info['basename']; + if($w <= $nw && $h <= $nh) { + header('Location: '.$BASE_URL.$path.$img_file); + exit(); + } - $thumb = $path.'.'.$img_file; + if(is_file($BASE_DIR.$thumb)) { - $img_info = getimagesize($BASE_DIR.$path.$img_file); - $w = $img_info[0]; $h = $img_info[1]; - - $nw = 96; $nh = 96; + $t_mtime = filemtime($BASE_DIR.$thumb); + $o_mtime = filemtime($BASE_DIR.$img); - if($w <= $nw && $h <= $nh) { - header('Location: '.$BASE_URL.$path.$img_file); - exit(); - } - - if(is_file($BASE_DIR.$thumb)) { - - $t_mtime = filemtime($BASE_DIR.$thumb); - $o_mtime = filemtime($BASE_DIR.$img); - - if($t_mtime > $o_mtime) { + if($t_mtime > $o_mtime) { //echo $BASE_URL.$path.'.'.$img_file; header('Location: '.$BASE_URL.$path.'.'.$img_file); exit(); - } - } + } + } - $img_thumbs = Image_Transform::factory(IMAGE_CLASS); - $img_thumbs->load($BASE_DIR.$path.$img_file); + $img_thumbs = Image_Transform::factory(IMAGE_CLASS); + $img_thumbs->load($BASE_DIR.$path.$img_file); + if ($w > $h) + $nh = unpercent(percent($nw, $w), $h); + else if ($h > $w) + $nw = unpercent(percent($nh, $h), $w); - if ($w > $h) - $nh = unpercent(percent($nw, $w), $h); - else if ($h > $w) - $nw = unpercent(percent($nh, $h), $w); + $img_thumbs->resize($nw, $nh); - $img_thumbs->resize($nw, $nh); + $img_thumbs->save($BASE_DIR.$thumb); + $img_thumbs->free(); - $img_thumbs->save($BASE_DIR.$thumb); - $img_thumbs->free(); + chmod($BASE_DIR.$thumb, 0666); - chmod($BASE_DIR.$thumb, 0666); + if(is_file($BASE_DIR.$thumb)) { + header('Location: '.$BASE_URL.$path.'.'.$img_file); + exit(); + } + } - if(is_file($BASE_DIR.$thumb)) { - //echo "Made:".$BASE_URL.$path.'.'.$img_file; - header('Location: '.$BASE_URL.$path.'.'.$img_file); - exit(); - } -} -function percent($p, $w) - { - return (real)(100 * ($p / $w)); - } - -function unpercent($percent, $whole) - { - return (real)(($percent * $whole) / 100); - } - -?> \ No newline at end of file +?> diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/insert_image.php b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/insert_image.php index a918b3e87f..7270c62ba5 100755 --- a/phpgwapi/js/htmlarea/plugins/UploadImage/popups/insert_image.php +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/popups/insert_image.php @@ -7,15 +7,49 @@ ** Last changed..: 8 Mar 2003 ** Notes.........: Configuration in config.inc.php - - Only compatible with IE 5.5+ + - FIXME Only compatible with IE 5.5+ ***********************************************************************/ + /* $id */ + include 'ImageManager/config.inc.php'; $no_dir = false; - if(!is_dir($BASE_DIR.$BASE_ROOT)) { + if(!is_dir($BASE_DIR)) { $no_dir = true; } + +// _debug_array($_GET); +// die(); + function dirs($dir,$abs_path) + { + $d = dir($dir); + $dirs = array(); + while (false !== ($entry = $d->read())) + { + if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.') + { + $path['path'] = $dir.'/'.$entry; + $path['name'] = $entry; + $dirs[$entry] = $path; + } + } + $d->close(); + + ksort($dirs); + for($i=0; $i$current_dir\n"; + dirs($dirs[$name]['path'],$current_dir); + next($dirs); + } + } + + + + ?> @@ -326,38 +360,12 @@ function toggleConstrains(constrains) diff --git a/phpgwapi/js/htmlarea/plugins/UploadImage/upload-image.js b/phpgwapi/js/htmlarea/plugins/UploadImage/upload-image.js index 757ef7de5e..61af0b06cd 100755 --- a/phpgwapi/js/htmlarea/plugins/UploadImage/upload-image.js +++ b/phpgwapi/js/htmlarea/plugins/UploadImage/upload-image.js @@ -1,16 +1,18 @@ -// UploadImage Plugin for HTMLArea-3.0 -// Implementation by Mihai Bazon. Sponsored by http://thycotic.com -// -// htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc. -// This notice MUST stay intact for use (see license.txt). -// -// A free WYSIWYG editor replacement for