Thread: [Linpha-cvs] SF.net SVN: linpha: [4556] trunk/linpha2 (Page 4)
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-07-16 16:29:41
|
Revision: 4556 Author: fangehrn Date: 2006-07-16 09:29:17 -0700 (Sun, 16 Jul 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4556&view=rev Log Message: ----------- updated docu Modified Paths: -------------- trunk/linpha2/get_image.php trunk/linpha2/get_thumb.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/linpha2.specs.txt Added Paths: ----------- trunk/linpha2/docs/dev/important stuff.txt Added: trunk/linpha2/docs/dev/important stuff.txt =================================================================== --- trunk/linpha2/docs/dev/important stuff.txt (rev 0) +++ trunk/linpha2/docs/dev/important stuff.txt 2006-07-16 16:29:17 UTC (rev 4556) @@ -0,0 +1,15 @@ +- if we use exec($str, $array_output=array(), $return_value=''); + it will always return empty $array_output and $return_value + + you have to initialize $array_output and $return_value before! + + $array_output = array(); $return_value = ''; + exec($str, $array_output, $return_value); + + + +- filesize($tmp_file) may return zero if clearstatcache() is not executed! + + clearstatcache(); + $handle = fopen($tmp_file, "rb"); + $file_data = fread($handle, filesize($tmp_file)); \ No newline at end of file Modified: trunk/linpha2/get_image.php =================================================================== --- trunk/linpha2/get_image.php 2006-07-15 17:01:25 UTC (rev 4555) +++ trunk/linpha2/get_image.php 2006-07-16 16:29:17 UTC (rev 4556) @@ -50,7 +50,7 @@ $linpha->sql->startSession(); $image = new LinImage(); - if( ! $image->createImage($_GET['id'],$overrideSettings) ) + if( ! $image->createImage($_GET['id'],$overrideSettings) ) // returns false if no permission { throw new Exception("Error while creating image!<br />Error: ".$image->error_msg); } Modified: trunk/linpha2/get_thumb.php =================================================================== --- trunk/linpha2/get_thumb.php 2006-07-15 17:01:25 UTC (rev 4555) +++ trunk/linpha2/get_thumb.php 2006-07-16 16:29:17 UTC (rev 4556) @@ -40,7 +40,7 @@ $linpha->sql->startSession(); $thumbnail = new LinImage(); - if( ! $thumbnail->createThumbnail($_GET['id']) ) + if( ! $thumbnail->createThumbnail($_GET['id']) ) // returns false if no permission { throw new Exception("Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg); } Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-07-15 17:01:25 UTC (rev 4555) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-07-16 16:29:17 UTC (rev 4556) @@ -279,6 +279,8 @@ /** * thumbnail functions + * + * @return true on success, false on failure (checks for valid id, valid image, valid permission!) */ function createThumbnail($photo_id) { Modified: trunk/linpha2/linpha2.specs.txt =================================================================== --- trunk/linpha2/linpha2.specs.txt 2006-07-15 17:01:25 UTC (rev 4555) +++ trunk/linpha2/linpha2.specs.txt 2006-07-16 16:29:17 UTC (rev 4556) @@ -54,10 +54,10 @@ - smart_htmlspecialchars() from phpmeta used several times in forms in linpha1 ? - ? -- users have to use firefox - will hang me up on adapting css to internet explorer - (who finds sarcasm may keep it..) - ;-) +- php session + limit the session cookie not only to domain, but also to full url path + we cannot use the same session in localhost/linpha1.0 and localhost/linpha2.0 + -> session_set_cookie_params() Part 4: External Libs ============================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-08-25 21:30:09
|
Revision: 4557 Author: fangehrn Date: 2006-08-25 14:29:33 -0700 (Fri, 25 Aug 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4557&view=rev Log Message: ----------- 2006-08-25 flo * add exif autorotate support - db fields time_exif and rotate are saved during import - createThumbnail() and createImage() read this value and rotate automatically if necessary with this feature we should also be able to rotate images manually without having write permission to the file @todo what should happen if we later turn off autorot? @todo why does it not work with gdlib?! Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/settings_all.php trunk/linpha2/get_image.php trunk/linpha2/get_thumb.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/install/sql/sql.mysql.php trunk/linpha2/install/sql/sql.oci8po.php trunk/linpha2/install/sql/sql.postgres.php trunk/linpha2/install/sql/sql.sqlite.php trunk/linpha2/lib/classes/image/gdlib/image.php trunk/linpha2/lib/classes/image/gdlib/thumbnail.php trunk/linpha2/lib/classes/image/imagemagick/image.php trunk/linpha2/lib/classes/image/imagemagick/thumbnail.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/include/basket_build_zip.php trunk/linpha2/templates/default/view_thumb.html.php trunk/linpha2/templates/default_old/index.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/ChangeLog 2006-08-25 21:29:33 UTC (rev 4557) @@ -1,3 +1,12 @@ +2006-08-25 flo + * add exif autorotate support + - db fields time_exif and rotate are saved during import + - createThumbnail() and createImage() read this value and rotate automatically if necessary + with this feature we should also be able to rotate images manually without having write permission + to the file + @todo what should happen if we later turn off autorot? + @todo why does it not work with gdlib?! + 2006-07-15 flo * fixed bracket support detection during installation if we use exec($str, $array_output=array(), $return_value=''); Modified: trunk/linpha2/admin/settings_all.php =================================================================== --- trunk/linpha2/admin/settings_all.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/admin/settings_all.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -7,7 +7,11 @@ 'sys_im_imagemagick_path', 'sys_im_use_imagemagick', 'sys_im_video_thumbnail', + 'sys_import_autoimport', + 'sys_import_exif', + 'sys_import_exif_autorot', + 'sys_image_exif', 'sys_image_iptc', 'sys_image_xmp', @@ -46,6 +50,8 @@ 'sys_im_use_imagemagick', 'sys_im_video_thumbnail', 'sys_import_autoimport', + 'sys_import_exif', + 'sys_import_exif_autorot', 'sys_image_exif', 'sys_image_iptc', 'sys_image_xmp', Modified: trunk/linpha2/get_image.php =================================================================== --- trunk/linpha2/get_image.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/get_image.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -41,10 +41,15 @@ $overrideSettings = Array(); if(isset($_GET['width']) && isset($_GET['height'])) { - $overrideSettings['max_width'] = $_GET['width']; - $overrideSettings['max_height'] = $_GET['height']; + $overrideSettings['max_width'] = intval($_GET['width']); + $overrideSettings['max_height'] = intval($_GET['height']); } + if(isset($_GET['rotate'])) + { + $overrideSettings['rotate'] = intval($_GET['rotate']); + } + include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); $linpha = new linpha(); $linpha->sql->startSession(); Modified: trunk/linpha2/get_thumb.php =================================================================== --- trunk/linpha2/get_thumb.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/get_thumb.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -40,7 +40,14 @@ $linpha->sql->startSession(); $thumbnail = new LinImage(); - if( ! $thumbnail->createThumbnail($_GET['id']) ) // returns false if no permission + + /** + * set necessary infos to display image if exists + * create thumbnail if not exists + * + * returns false if no permission + */ + if( ! $thumbnail->createThumbnail($_GET['id']) ) { throw new Exception("Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg); } Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/install/sql/sql.data.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -31,7 +31,11 @@ 'sys_im_imagemagick_path' => $_SESSION['sys_im_convert_path'], 'sys_im_use_imagemagick' => $_SESSION['sys_im_use_convert'], 'sys_im_video_thumbnail' => '1', + 'sys_import_autoimport' => '1', + 'sys_import_exif' => '1', + 'sys_import_exif_autorot' => '1', + 'sys_image_exif' => '1', 'sys_image_iptc' => '0', 'sys_image_xmp' => '0', Modified: trunk/linpha2/install/sql/sql.mysql.php =================================================================== --- trunk/linpha2/install/sql/sql.mysql.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/install/sql/sql.mysql.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -67,6 +67,7 @@ "time_add INT NOT NULL default '0', " . "time_mod INT NOT NULL default '0', " . "time_exif INT NOT NULL default '0', " . + "rotate INT NOT NULL default '0', " . "stats_numbers INT NOT NULL default '0', " . "stats_views INT NOT NULL default '0', " . "stats_downloads INT NOT NULL default '0', " . Modified: trunk/linpha2/install/sql/sql.oci8po.php =================================================================== --- trunk/linpha2/install/sql/sql.oci8po.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/install/sql/sql.oci8po.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -62,6 +62,7 @@ "time_add NUMBER(12) DEFAULT '0', " . "time_mod NUMBER(12) DEFAULT '0', " . "time_exif NUMBER(12) DEFAULT '0', " . + "rotate NUMBER(12) DEFAULT '0', " . "stats_numbers NUMBER(10) DEFAULT '0', " . "stats_views NUMBER(10) DEFAULT '0', " . "stats_downloads NUMBER(10) DEFAULT '0'" . Modified: trunk/linpha2/install/sql/sql.postgres.php =================================================================== --- trunk/linpha2/install/sql/sql.postgres.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/install/sql/sql.postgres.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -62,6 +62,7 @@ "time_add INT NOT NULL default '0', " . "time_mod INT NOT NULL default '0', " . "time_exif INT NOT NULL default '0', " . + "rotate INT NOT NULL default '0', " . "stats_numbers INT NOT NULL default '0', " . "stats_views INT NOT NULL default '0', " . "stats_downloads INT NOT NULL default '0' " . Modified: trunk/linpha2/install/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/install/sql/sql.sqlite.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/install/sql/sql.sqlite.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -62,6 +62,7 @@ "time_add INTEGER NOT NULL default '0', " . "time_mod INTEGER NOT NULL default '0', " . "time_exif INTEGER NOT NULL default '0', " . + "rotate INTEGER NOT NULL default '0', " . "stats_numbers INTEGER NOT NULL default '0', " . "stats_views INTEGER NOT NULL default '0', " . "stats_downloads INTEGER NOT NULL default '0' " . Modified: trunk/linpha2/lib/classes/image/gdlib/image.php =================================================================== --- trunk/linpha2/lib/classes/image/gdlib/image.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/classes/image/gdlib/image.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -54,6 +54,15 @@ imagedestroy($src_image); /** + * rotate image + * @todo why does this not work?! + */ + if(function_exists('imagerotate') AND $this->rotate != "0") + { + imagerotate($scaled_image,$this->rotate,0); + } + +/** * save image */ imagejpeg($scaled_image,$this->output_file,$this->img_quality); Modified: trunk/linpha2/lib/classes/image/gdlib/thumbnail.php =================================================================== --- trunk/linpha2/lib/classes/image/gdlib/thumbnail.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/classes/image/gdlib/thumbnail.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -58,13 +58,14 @@ /** * create image resources */ - switch($image_type) + switch($this->img_type) { case 1: $src_image = imagecreatefromgif($this->src_file); break; case 2: $src_image = imagecreatefromjpeg($this->src_file); break; case 3: $src_image = imagecreatefrompng($this->src_file); break; default: return false;; } + $scaled_image = imagecreatetruecolor($this->img_thumbsize, $this->img_thumbsize); /** @@ -84,6 +85,15 @@ imagedestroy($src_image); /** + * rotate image + * @todo why does this not work?! + */ + if(function_exists('imagerotate') AND $this->rotate != "0") + { + imagerotate($scaled_image,$this->rotate,0); + } + +/** * save image */ imagejpeg($scaled_image,$this->output_file,$this->img_quality); Modified: trunk/linpha2/lib/classes/image/imagemagick/image.php =================================================================== --- trunk/linpha2/lib/classes/image/imagemagick/image.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/classes/image/imagemagick/image.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -27,15 +27,14 @@ $convert_str = $this->imagemagick_path.'convert'. - ' -quality '.$this->img_quality. - ' -size "'.$this->img_width.'x'.$this->img_height.'"'. // new size ' '.linEscapeString($this->src_file).'[0]'. // [0] -> take only first frame!!! ' -resize "'.$this->img_width.'x'.$this->img_height.'"'. // new size + ' -quality '.$this->img_quality. ' +profile "*"'. // delete all profiles ' -colorspace RGB'. // change colorspace always to RGB because all browsers only can display RGB images + ' -rotate '.$this->rotate. ' '.linEscapeString($this->output_file); LinFilesys::linExec( $convert_str ); - ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/image/imagemagick/thumbnail.php =================================================================== --- trunk/linpha2/lib/classes/image/imagemagick/thumbnail.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/classes/image/imagemagick/thumbnail.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -58,12 +58,12 @@ } $convert_str = $this->imagemagick_path.'convert'. + ' '.linEscapeString( $this->src_file ).'[0]'. // [0] -> take only first frame!!! + ' -thumbnail "'.$w.'x'.$h.'"'. // new size and delete profiles, no need anymore for ' +profile "*"'. // delete all profiles ' -quality '.$this->img_quality. - ' -size '.$w.'x'.$h. // new size ' -crop '.$this->img_thumbsize.'x'.$this->img_thumbsize.'+'.$x.'+'.$y. // crop - ' '.linEscapeString( $this->src_file ).'[0]'. // [0] -> take only first frame!!! - ' -thumbnail "'.$w.'x'.$h.'"'. // new size and delete profiles, no need anymore for ' +profile "*"'. // delete all profiles ' -colorspace RGB'. // change colorspace always to RGB because all browsers only can display RGB images + ' -rotate '.$this->rotate. ' '.linEscapeString( $this->output_file ); LinFilesys::linExec( $convert_str ); Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -79,16 +79,13 @@ } /** - * rotate (printing, ...) + * update rotate (printing, ...) if applicable (no else() !! ) + * the rotate value from the database is read earlier */ if(isset($this->overrideSettings['rotate'])) { $this->rotate = $this->overrideSettings['rotate']; } - else - { - $this->rotate = 0; - } /** * watermark @@ -175,26 +172,27 @@ { /** * check for valid id + * and get img_type and rotate informations */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type " . + $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type, rotate " . "FROM ".PREFIX."photos " . "WHERE id = '".LinSql::linAddslashes( $this->photo_id )."'"); - if( $query->EOF ) // not a sigle value returned + if( $query->EOF ) // not a single value returned { $this->error_msg = "wrong id supplied!"; return false; } - $data = $query->FetchRow(ADODB_FETCH_NUM); + $data = $query->FetchRow(); - if( ! LinSql::photoIsAllowed( $data['0'] ) ) + if( ! LinSql::photoIsAllowed( $data['id'] ) ) { $this->error_msg = "not permitted!"; return false; } - if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['1'] ) ) + if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['img_type'] ) ) { $this->error_msg = "only images possible!"; return false; @@ -209,7 +207,11 @@ $this->force = false; } - $this->img_type = $data['1']; + /** + * set additional informations + */ + $this->rotate = $data['rotate']; + $this->img_type = $data['img_type']; $this->setCachedInfos(); /** @@ -304,7 +306,6 @@ */ if( LinIdentify::isSupportedImage( $this->img_type ) ) { - $this->createThumbnailImage(); } /** @@ -325,7 +326,6 @@ $this->createThumbnailVideo(); } - if( ! file_exists( $this->output_file ) ) { return false; @@ -342,7 +342,7 @@ */ $this->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; $this->img_quality = 75; - + include(LINPHA_DIR.'/lib/classes/image/'.$this->image_tool.'/thumbnail.php'); } @@ -401,12 +401,12 @@ $this->overrideSettings = $overrideSettings; - if( ! $this->setFileInformation() ) + if( ! $this->setFileInformation() ) // will also do setCachedInfos() and setSourceFileInformation() { return false; } - if( ! $this->isCached ) + if( ! $this->isCached OR $this->force ) { /** * include the create image script Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -167,12 +167,12 @@ linSysLog(i18n("New").': '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES).'<br />'); - list($md5sum,$file_type,$stats_number) = LinImport::getFileInformation($dirname,$filename); + list($md5sum,$file_type,$stats_number,$time_exif,$rotate) = LinImport::getFileInformation($dirname,$filename); $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."photos ( " . - "parent_id , name, img_type , md5sum , time_add , time_mod , stats_numbers ) " . + "parent_id, name, img_type, md5sum, time_add, time_mod, time_exif, rotate, stats_numbers ) " . "VALUES ( '".$parent_id."' , '".$GLOBALS['linpha']->sql->linAddslashes($filename)."', " . - "'".$file_type."' , '".$md5sum."', '".time()."', '".time()."', '".$stats_number."' )"); + "'".$file_type."' , '".$md5sum."', '".time()."', '".filemtime($dirname.'/'.$filename)."', '".$time_exif."', '".$rotate."', '".$stats_number."' )"); /** * delete thumbnail if one exists with the same id @@ -271,7 +271,7 @@ */ function updateEntry( $id , $dirname , $filename ) { - list($md5sum,$file_type,$stats_number) = LinImport::getFileInformation($dirname,$filename); + list($md5sum,$file_type,$stats_number,$time_exif,$rotate) = LinImport::getFileInformation($dirname,$filename); $data = $GLOBALS['linpha']->db->GetRow("SELECT img_type, md5sum " . "FROM ".PREFIX."photos WHERE id = '".$id."'"); @@ -344,8 +344,14 @@ */ function getFileInformation($dirname,$filename) { + /** + * initial settings + * will be overwritten if necessary + */ $md5sum = ''; $stats_number = 0; + $time_exif = ""; + $rotate = "0"; $ext = LinFilesys::getFileExtFromPath($filename); if($filename{0} == '.') @@ -403,6 +409,31 @@ { $md5sum = md5_file($dirname.'/'.$filename); $stats_number = 1; + + /** + * exif date and exif rotate stuff + * globally turn off using 'sys_import_exif' if having problems with phpmeta + */ + if( $GLOBALS['linpha']->sql->config->value['sys_import_exif'] ) + { + include_once( LINPHA_DIR.'/lib/classes/phpmeta/EXIF.php' ); + $meta = get_EXIF_JPEG($dirname.'/'.$filename); + include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); + + /** + * get date + */ + $time_exif = MetaData::convertExifDateToUnix( $meta[0][34665]['Data'][0][36867]['Data'][0] ); + + /** + * get rotate information + * turn off exif autorotate using 'sys_import_exif_autorot' + */ + if( $GLOBALS['linpha']->sql->config->value['sys_import_exif_autorot'] ) + { + $rotate = MetaData::getRotationByExifTag( $meta[0][274]['Data'][0] ); + } + } } } else @@ -410,7 +441,7 @@ linSysLog('Error: what am i? '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES).'<br />'); } - return array($md5sum,$file_type,$stats_number); + return array($md5sum,$file_type,$stats_number,$time_exif,$rotate); } /** Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -881,7 +881,96 @@ } return $str; } + + /** + * Autorotate Images via EXIF tag + * Most Images contain an orientation tag which shows if and how to rotate + * the images + * @param int exif rotation tag + * @return degrees to rotate + * @author bzrudi + */ + function getRotationByExifTag($rotation) + { + if(is_numeric($rotation)) + { + switch($rotation) + { + //No Rotation, No Flip Row 0 is at the visual top of the + //image, and column 0 is the visual left-hand side + case "1": + $rotate = "0"; + break; + //No Rotation, Flipped Horizontally Row 0 is at the visual + //top of the image,and column 0 is the visual right-hand side + case "2": + $rotate = "0"; + break; + //Rotated 180 degrees, No Flip Row 0 is at the visual + //bottom of the image, and column 0 is the visual right-hand side + case "3": + $rotate = "180"; + break; + //No Rotation, Flipped Vertically Row 0 is at the visual + //bottom of the image, and column 0 is the visual left-hand side + case "4": + $rotate = "0"; + break; + //Flipped Horizontally, Rotated 90 degrees counter clockwise + //Row 0 is at the visual left-hand side of of the image, + //and column 0 is the visual top + case "5": + $rotate = "0"; + break; + //No Flip, Rotated 90 degrees clockwise Row 0 is at the visual + //right-hand side of of the image, and column 0 is the visual top + case "6": + $rotate = "90"; + break; + //Flipped Horizontally, Rotated 90 degrees clockwise Row 0 is + //at the visual right-hand side of of the image, and + //column 0 is the visual bottom + case "7": + $rotate = "0"; + break; + //No Flip, Rotated 90 degrees counter clockwise Row 0 is at + //the visual left-hand side of of the image, and column 0 is + //the visual bottom + case "8": + $rotate = "-90"; + break; + default: + $rotate = "0"; + break; + } + } + else // no rotation data is found, default to "0" + { + $rotate = "0"; + } + return $rotate; + } // end function getRotationByExifTag() + + /** + * converts a exif date to a unix timestamp + * example: 2004:02:14 18:24:19 -> 11167594589 + * + * @author flo + * @param string $date + * @return int unix timestamp + */ + function convertExifDateToUnix( $date ) + { + $year=substr($date,0,4); + $month=substr($date,5,2); + $day=substr($date,8,2); + $hour=substr($date,11,2); + $min=substr($date,14,2); + $sec=substr($date,17,2); + return mktime($hour,$min,$sec,$month,$day,$year); + } + } // end class metadata Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -646,7 +646,7 @@ } else { - $num = 1 + substr_count(TOP_DIR, '/'); + $num = 1 + substr_count(LINPHA_DIR, '/'); } /** Modified: trunk/linpha2/lib/include/basket_build_zip.php =================================================================== --- trunk/linpha2/lib/include/basket_build_zip.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/lib/include/basket_build_zip.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -47,7 +47,7 @@ $archive->startDownload(); /** - * no TOP_DIR because we've done a chdir(TOP_DIR)! + * no LINPHA_DIR because we've done a chdir(LINPHA_DIR)! */ /* * @todo Modified: trunk/linpha2/templates/default/view_thumb.html.php =================================================================== --- trunk/linpha2/templates/default/view_thumb.html.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/templates/default/view_thumb.html.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -62,9 +62,7 @@ ?> <div style="<?php echo $str_clear; ?>" class="imgdiv"> <?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['before']; ?> - <a href="<?php echo LINPHA_DIR.'/?cat=alb&id='.$value['id']; ?>"> - <img height="<?php echo ($GLOBALS['def_tn_size']-20); ?>" src="<?php echo LINPHA_DIR.'/get_thumb.php?id='.$value['id']; ?>" title="<?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['title']; ?>" class="img_thumbnail" /> - </a> + <a href="<?php echo LINPHA_DIR.'/?cat=alb&id='.$value['id']; ?>"><img height="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>" src="<?php echo LINPHA_DIR.'/get_thumb.php?id='.$value['id']; ?>" title="<?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['title']; ?>" class="img_thumbnail" /></a> <?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['after']; ?> </div> <?php Modified: trunk/linpha2/templates/default_old/index.php =================================================================== --- trunk/linpha2/templates/default_old/index.php 2006-07-16 16:29:17 UTC (rev 4556) +++ trunk/linpha2/templates/default_old/index.php 2006-08-25 21:29:33 UTC (rev 4557) @@ -49,7 +49,7 @@ <div><a href="">Guestbook</a></div> </li> <li class="button"> - <div><a href=""><img src="<?php echo TOP_DIR.'/templates/default_old/images/slideshow.png'?>" alt="slideshow" /></a></div> + <div><a href=""><img src="<?php echo LINPHA_DIR.'/templates/default_old/images/slideshow.png'?>" alt="slideshow" /></a></div> </li> <li class="button"> <div><a href=""><img src="<?php echo LINPHA_DIR.'/templates/default_old/images/download.png'?>" alt="download" /></a></div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2006-08-26 12:30:08
|
Revision: 4558 Author: bzrudi Date: 2006-08-26 05:28:52 -0700 (Sat, 26 Aug 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4558&view=rev Log Message: ----------- * fixed broken installation for postgres * replaced all PO_Inserted_ID (does not work with postgres) * update to latest adodb Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/step11_finish.php trunk/linpha2/install/step8_testing.php trunk/linpha2/lib/adodb/adodb-active-record.inc.php trunk/linpha2/lib/adodb/adodb-csvlib.inc.php trunk/linpha2/lib/adodb/adodb-datadict.inc.php trunk/linpha2/lib/adodb/adodb-error.inc.php trunk/linpha2/lib/adodb/adodb-errorhandler.inc.php trunk/linpha2/lib/adodb/adodb-errorpear.inc.php trunk/linpha2/lib/adodb/adodb-exceptions.inc.php trunk/linpha2/lib/adodb/adodb-iterator.inc.php trunk/linpha2/lib/adodb/adodb-lib.inc.php trunk/linpha2/lib/adodb/adodb-pager.inc.php trunk/linpha2/lib/adodb/adodb-pear.inc.php trunk/linpha2/lib/adodb/adodb-perf.inc.php trunk/linpha2/lib/adodb/adodb-php4.inc.php trunk/linpha2/lib/adodb/adodb-time.inc.php trunk/linpha2/lib/adodb/adodb-xmlschema03.inc.php trunk/linpha2/lib/adodb/adodb.inc.php trunk/linpha2/lib/adodb/drivers/adodb-access.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ado.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ado5.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ado_access.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ado_mssql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-borland_ibase.inc.php trunk/linpha2/lib/adodb/drivers/adodb-csv.inc.php trunk/linpha2/lib/adodb/drivers/adodb-db2.inc.php trunk/linpha2/lib/adodb/drivers/adodb-fbsql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-firebird.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ibase.inc.php trunk/linpha2/lib/adodb/drivers/adodb-informix.inc.php trunk/linpha2/lib/adodb/drivers/adodb-informix72.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ldap.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mssql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mssqlpo.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mysql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mysqli.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mysqlt.inc.php trunk/linpha2/lib/adodb/drivers/adodb-netezza.inc.php trunk/linpha2/lib/adodb/drivers/adodb-oci8.inc.php trunk/linpha2/lib/adodb/drivers/adodb-oci805.inc.php trunk/linpha2/lib/adodb/drivers/adodb-oci8po.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbc.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbc_db2.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbc_mssql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbc_oracle.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbtp.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbtp_unicode.inc.php trunk/linpha2/lib/adodb/drivers/adodb-oracle.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo_mssql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo_mysql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo_oci.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo_pgsql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-postgres.inc.php trunk/linpha2/lib/adodb/drivers/adodb-postgres64.inc.php trunk/linpha2/lib/adodb/drivers/adodb-postgres7.inc.php trunk/linpha2/lib/adodb/drivers/adodb-postgres8.inc.php trunk/linpha2/lib/adodb/drivers/adodb-proxy.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sapdb.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sqlanywhere.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sqlite.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sqlitepo.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sybase.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sybase_ase.inc.php trunk/linpha2/lib/adodb/drivers/adodb-vfp.inc.php trunk/linpha2/lib/adodb/lang/adodb-ar.inc.php trunk/linpha2/lib/adodb/pivottable.inc.php trunk/linpha2/lib/adodb/rsfilter.inc.php trunk/linpha2/lib/adodb/server.php trunk/linpha2/lib/adodb/toexport.inc.php trunk/linpha2/lib/adodb/tohtml.inc.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.import.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/ChangeLog 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,3 +1,8 @@ +2006-08-26 bzrudi + * fixed broken installation for postgres + * replaced all PO_Inserted_ID (does not work with postgres) + * update to latest adodb + 2006-08-25 flo * add exif autorotate support - db fields time_exif and rotate are saved during import Modified: trunk/linpha2/install/step11_finish.php =================================================================== --- trunk/linpha2/install/step11_finish.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/install/step11_finish.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -63,13 +63,18 @@ { echo failed_msg(); } else { - $userid = $GLOBALS['linpha']->db->PO_Insert_ID(PREFIX."users", "id"); + $userid = $GLOBALS['linpha']->db->GetOne("SELECT MAX(id) FROM ".PREFIX."users "); /** + * fails for pg + */ + //$userid = $GLOBALS['linpha']->db->PO_Insert_ID(PREFIX."users", "id"); + + /** * adding user to group 'admin' */ $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."groups WHERE group_name = 'admin'"); - $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."user_group (user_id, group_id) VALUES ('".$userid."','".$data['id']."')"); + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."user_group (user_id, group_id) VALUES ('".$userid['id']."','".$data['id']."')"); echo success_msg(); } Modified: trunk/linpha2/install/step8_testing.php =================================================================== --- trunk/linpha2/install/step8_testing.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/install/step8_testing.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -30,7 +30,7 @@ /** * prevent php notices, as sqlite doesn't know about ports' */ -if(false == isset($_SESSION['sql_port'])) +if(!isset($_SESSION['sql_dbport'])) { $_SESSION['sql_dbport'] = "0"; } Modified: trunk/linpha2/lib/adodb/adodb-active-record.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-active-record.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-active-record.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,7 +1,7 @@ <?php /* -@version V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. +@version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Latest version is available at http://adodb.sourceforge.net Released under both BSD license and Lesser GPL library license. @@ -10,10 +10,14 @@ Active Record implementation. Superset of Zend Framework's. - Version 0.02 + Version 0.04 + + See http://www-128.ibm.com/developerworks/java/library/j-cb03076/?ca=dgr-lnxw01ActiveRecord + for info on Ruby on Rails Active Record implementation */ global $_ADODB_ACTIVE_DBS; +global $ADODB_ACTIVE_CACHESECS; // set to true to enable caching of metadata such as field info // array of ADODB_Active_DB's, indexed by ADODB_Active_Record->_dbat $_ADODB_ACTIVE_DBS = array(); @@ -28,6 +32,7 @@ var $name; // table name var $flds; // assoc array of adofieldobjs, indexed by fieldname var $keys; // assoc array of primary keys, indexed by fieldname + var $_created; // only used when stored as a cached file } // returns index into $_ADODB_ACTIVE_DBS @@ -48,13 +53,15 @@ return sizeof($_ADODB_ACTIVE_DBS)-1; } + class ADODB_Active_Record { var $_dbat; // associative index pointing to ADODB_Active_DB eg. $ADODB_Active_DBS[_dbat] - var $_table; // tablename + var $_table; // tablename, if set in class definition then use it as table name var $_tableat; // associative index pointing to ADODB_Active_Table, eg $ADODB_Active_DBS[_dbat]->tables[$this->_tableat] var $_where; // where clause set in Load() var $_saved = false; // indicates whether data is already inserted. var $_lasterr = false; // last error message + var $_original = false; // the original values loaded or inserted, refreshed on update // should be static function SetDatabaseAdapter(&$db) @@ -78,8 +85,10 @@ $pkeyarr = false; } - if (!$table) $table = $this->_pluralize(get_class($this)); - + if (!$table) { + if (!empty($this->_table)) $table = $this->_table; + else $table = $this->_pluralize(get_class($this)); + } if ($db) { $this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db); } else @@ -119,7 +128,7 @@ // update metadata function UpdateActiveTable($pkeys=false,$forceUpdate=false) { - global $ADODB_ASSOC_CASE,$_ADODB_ACTIVE_DBS; + global $ADODB_ASSOC_CASE,$_ADODB_ACTIVE_DBS , $ADODB_CACHE_DIR, $ADODB_ACTIVE_CACHESECS; $activedb =& $_ADODB_ACTIVE_DBS[$this->_dbat]; @@ -133,10 +142,27 @@ return; } + $db =& $activedb->db; + $fname = $ADODB_CACHE_DIR . '/adodb_' . $db->databaseType . '_active_'. $table . '.cache'; + if (!$forceUpdate && $ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR && file_exists($fname)) { + $fp = fopen($fname,'r'); + @flock($fp, LOCK_SH); + $acttab = unserialize(fread($fp,100000)); + fclose($fp); + if ($acttab->_created + $ADODB_ACTIVE_CACHESECS - (abs(rand()) % 16) > time()) { + // abs(rand()) randomizes deletion, reducing contention to delete/refresh file + // ideally, you should cache at least 32 secs + $activedb->tables[$table] = $acttab; + + //if ($db->debug) ADOConnection::outp("Reading cached active record file: $fname"); + return; + } else if ($db->debug) { + ADOConnection::outp("Refreshing cached active record file: $fname"); + } + } $activetab = new ADODB_Active_Table(); $activetab->name = $table; - $db =& $activedb->db; $cols = $db->MetaColumns($table); if (!$cols) { @@ -198,6 +224,13 @@ $activetab->keys = $keys; $activetab->flds = $attr; + + if ($ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR) { + $activetab->_created = time(); + $s = serialize($activetab); + if (!function_exists('adodb_write_file')) include(ADODB_DIR.'/adodb-csvlib.inc.php'); + adodb_write_file($fname,$s); + } $activedb->tables[$table] = $activetab; } @@ -289,7 +322,7 @@ $this->$name = $row[$cnt]; $cnt += 1; } - #$this->_original =& $row; + $this->_original = $row; return true; } @@ -375,23 +408,29 @@ $db =& $this->DB(); if (!$db) return false; $cnt = 0; $table =& $this->TableInfo(); + + $valarr = array(); + $names = array(); + $valstr = array(); foreach($table->flds as $name=>$fld) { $val = $this->$name; - /* - if (is_null($val)) { - if (isset($fld->not_null) && $fld->not_null) { - if (isset($fld->default_value) && strlen($fld->default_value)) continue; - else $this->Error("Cannot insert null into $name","Insert"); - } - }*/ - - $valarr[] = $val; - $names[] = $name; - $valstr[] = $db->Param($cnt); - $cnt += 1; + if(!is_null($val) || !array_key_exists($name, $table->keys)) { + $valarr[] = $val; + $names[] = $name; + $valstr[] = $db->Param($cnt); + $cnt += 1; + } } + if (empty($names)){ + foreach($table->flds as $name=>$fld) { + $valarr[] = null; + $names[] = $name; + $valstr[] = $db->Param($cnt); + $cnt += 1; + } + } $sql = 'INSERT INTO '.$this->_table."(".implode(',',$names).') VALUES ('.implode(',',$valstr).')'; $ok = $db->Execute($sql,$valarr); @@ -410,7 +449,7 @@ } } - #$this->_original =& $valarr; + $this->_original = $valarr; return !empty($ok); } @@ -421,9 +460,18 @@ $where = $this->GenWhere($db,$table); $sql = 'DELETE FROM '.$this->_table.' WHERE '.$where; - $db->Execute($sql); + $ok = $db->Execute($sql); + + return $ok ? true : false; } + // returns an array of active record objects + function &Find($whereOrderBy,$bindarr=false,$pkeysArr=false) + { + $db =& $this->DB(); if (!$db || empty($this->_table)) return false; + $arr =& $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr); + return $arr; + } // returns 0 on error, 1 on update, 2 on insert function Replace() @@ -447,6 +495,9 @@ } } }*/ + if (is_null($val) && !empty($fld->auto_increment)) { + continue; + } $t = $db->MetaType($fld->type); $arr[$name] = $this->doquote($db,$val,$t); $valarr[] = $val; @@ -479,12 +530,12 @@ } } - #$this->_original =& $valarr; + $this->_original =& $valarr; } return $ok; } - // returns false on error + // returns 0 on error, 1 on update, -1 if no change in data (no update) function Update() { $db =& $this->DB(); if (!$db) return false; @@ -496,12 +547,20 @@ $this->error("Where missing for table $table", "Update"); return false; } + $valarr = array(); + $neworig = array(); + $pairs = array(); + $i = -1; $cnt = 0; foreach($table->flds as $name=>$fld) { - if (isset($table->keys[$name])) continue; - + $i += 1; $val = $this->$name; + $neworig[] = $val; + if (isset($table->keys[$name])) { + continue; + } + if (is_null($val)) { if (isset($fld->not_null) && $fld->not_null) { if (isset($fld->default_value) && strlen($fld->default_value)) continue; @@ -511,17 +570,24 @@ } } } + + if (isset($this->_original[$i]) && $val == $this->_original[$i]) { + continue; + } $valarr[] = $val; $pairs[] = $name.'='.$db->Param($cnt); $cnt += 1; } - #$this->_original =& $valarr; + if (!$cnt) return -1; $sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." WHERE ".$where; $ok = $db->Execute($sql,$valarr); - - return !empty($ok); + if ($ok) { + $this->_original =& $neworig; + return 1; + } + return 0; } function GetAttributeNames() Modified: trunk/linpha2/lib/adodb/adodb-csvlib.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-csvlib.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-csvlib.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -8,7 +8,7 @@ /* - V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt. Modified: trunk/linpha2/lib/adodb/adodb-datadict.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-datadict.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-datadict.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,7 +1,7 @@ <?php /** - V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-error.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-error.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-error.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /** - * @version V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, * the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-errorhandler.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-errorhandler.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-errorhandler.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /** - * @version V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, * the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-errorpear.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-errorpear.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-errorpear.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /** - * @version V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-exceptions.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-exceptions.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-exceptions.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,7 +1,7 @@ <?php /** - * @version V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, * the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-iterator.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-iterator.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-iterator.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,7 +1,7 @@ <?php /* - V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-lib.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-lib.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-lib.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -7,7 +7,7 @@ $ADODB_INCLUDED_LIB = 1; /* - @version V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jlim\@natsoft.com.my). All rights reserved. + @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim\@natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt. @@ -156,7 +156,7 @@ if ($fieldsize > 2) { $group = rtrim($zthis->fields[2]); } - +/* if ($optgroup != $group) { $optgroup = $group; if ($firstgroup) { @@ -167,7 +167,7 @@ $s .="\n<optgroup label='". htmlspecialchars($group) ."'>"; } } - +*/ if ($hasvalue) $value = " value='".htmlspecialchars($zval2)."'"; @@ -325,6 +325,8 @@ $rewritesql = preg_replace( '/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql); + + // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails // with mssql, access and postgresql. Also a good speedup optimization - skips sorting! // also see http://phplens.com/lens/lensforum/msgs.php?id=12752 @@ -332,10 +334,13 @@ $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$rewritesql); else $rewritesql = preg_replace('/(\sORDER\s+BY\s[^)]*)/is','',$rewritesql); - } + + if (isset($rewritesql) && $rewritesql != $sql) { + if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[1]; + if ($secs2cache) { // we only use half the time of secs2cache because the count can quickly // become inaccurate if new records are added @@ -354,6 +359,8 @@ if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql; else $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); + if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; + $rstest = &$zthis->Execute($rewritesql,$inputarr); if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr); @@ -1017,5 +1024,47 @@ return $s; } +/* +function _adodb_find_from($sql) +{ + $sql = str_replace(array("\n","\r"), ' ', $sql); + $charCount = strlen($sql); + + $inString = false; + $quote = ''; + $parentheseCount = 0; + $prevChars = ''; + $nextChars = ''; + + + for($i = 0; $i < $charCount; $i++) { + + $char = substr($sql,$i,1); + $prevChars = substr($sql,0,$i); + $nextChars = substr($sql,$i+1); + + if((($char == "'" || $char == '"' || $char == '`') && substr($prevChars,-1,1) != '\\') && $inString === false) { + $quote = $char; + $inString = true; + } + + elseif((($char == "'" || $char == '"' || $char == '`') && substr($prevChars,-1,1) != '\\') && $inString === true && $quote == $char) { + $quote = ""; + $inString = false; + } + + elseif($char == "(" && $inString === false) + $parentheseCount++; + + elseif($char == ")" && $inString === false && $parentheseCount > 0) + $parentheseCount--; + + elseif($parentheseCount <= 0 && $inString === false && $char == " " && strtoupper(substr($prevChars,-5,5)) == " FROM") + return $i; + + } +} +*/ + ?> \ No newline at end of file Modified: trunk/linpha2/lib/adodb/adodb-pager.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-pager.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-pager.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,7 +1,7 @@ <?php /* - V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-pear.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-pear.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-pear.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /** - * @version V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, * the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-perf.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-perf.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-perf.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /* -V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. +V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt. @@ -71,7 +71,7 @@ $rs =& $conn->Execute($sql,$inputarr); $t1 = microtime(); - if (!empty($conn->_logsql)) { + if (!empty($conn->_logsql) && (empty($conn->_logsqlErrors) || !$rs)) { $conn->_logsql = false; // disable logsql error simulation $dbT = $conn->databaseType; @@ -149,6 +149,7 @@ if ($dbT == 'informix') $isql = str_replace(chr(10),' ',$isql); $arr = false; } else { + if ($dbT == 'db2') $arr['f'] = (float) $arr['f']; $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)"; } @@ -860,8 +861,10 @@ { if (!$this->createTableSQL) return false; + $table = $this->table(); + $sql = str_replace('adodb_logsql',$table,$this->createTableSQL); $savelog = $this->conn->LogSQL(false); - $ok = $this->conn->Execute($this->createTableSQL); + $ok = $this->conn->Execute($sql); $this->conn->LogSQL($savelog); return ($ok) ? true : false; } Modified: trunk/linpha2/lib/adodb/adodb-php4.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-php4.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-php4.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,7 +1,7 @@ <?php /* - V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. + V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-time.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-time.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-time.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -241,6 +241,9 @@ CHANGELOG +- 19 March 2006 0.24 +Changed strftime() locale detection, because some locales prepend the day of week to the date when %c is used. + - 10 Feb 2006 0.23 PHP5 compat: when we detect PHP5, the RFC2822 format for gmt 0000hrs is changed from -0000 to +0000. In PHP4, we will still use -0000 for 100% compat with PHP4. @@ -365,7 +368,7 @@ /* Version Number */ -define('ADODB_DATE_VERSION',0.23); +define('ADODB_DATE_VERSION',0.24); /* This code was originally for windows. But apparently this problem happens @@ -1239,9 +1242,16 @@ } if (empty($ADODB_DATE_LOCALE)) { + /* $tstr = strtoupper(gmstrftime('%c',31366800)); // 30 Dec 1970, 1 am $sep = substr($tstr,2,1); $hasAM = strrpos($tstr,'M') !== false; + */ + # see http://phplens.com/lens/lensforum/msgs.php?id=14865 for reasoning, and changelog for version 0.24 + $dstr = gmstrftime('%x',31366800); // 30 Dec 1970, 1 am + $sep = substr($dstr,2,1); + $tstr = strtoupper(gmstrftime('%X',31366800)); // 30 Dec 1970, 1 am + $hasAM = strrpos($tstr,'M') !== false; $ADODB_DATE_LOCALE = array(); $ADODB_DATE_LOCALE[] = strncmp($tstr,'30',2) == 0 ? 'd'.$sep.'m'.$sep.'y' : 'm'.$sep.'d'.$sep.'y'; Modified: trunk/linpha2/lib/adodb/adodb-xmlschema03.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-xmlschema03.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb-xmlschema03.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -2092,16 +2092,20 @@ * in the schema. * * @param boolean $data Include data in schema dump + * @indent string indentation to use + * @prefix string extract only tables with given prefix + * @stripprefix strip prefix string when storing in XML schema * @return string Generated XML schema */ - function ExtractSchema( $data = FALSE, $indent = ' ' ) { + function ExtractSchema( $data = FALSE, $indent = ' ', $prefix = '' , $stripprefix=false) { $old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM ); $schema = '<?xml version="1.0"?>' . "\n" . '<schema version="' . $this->schemaVersion . '">' . "\n"; - if( is_array( $tables = $this->db->MetaTables( 'TABLES' ) ) ) { + if( is_array( $tables = $this->db->MetaTables( 'TABLES' , ($prefix) ? $prefix.'%' : '') ) ) { foreach( $tables as $table ) { + if ($stripprefix) $table = str_replace(str_replace('\\_', '_', $pfx ), '', $table); $schema .= $indent . '<table name="' . htmlentities( $table ) . '">' . "\n"; // grab details from database Modified: trunk/linpha2/lib/adodb/adodb.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/adodb.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -14,7 +14,7 @@ /** \mainpage - @version V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. You can choose which license you prefer. @@ -171,7 +171,7 @@ /** * ADODB version as a string. */ - $ADODB_vers = 'V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; + $ADODB_vers = 'V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; /** * Determines whether recordset->RecordCount() is used. @@ -314,6 +314,7 @@ var $_evalAll = false; var $_affected = false; var $_logsql = false; + var $_transmode = ''; // transaction mode /** * Constructor @@ -553,6 +554,7 @@ function q(&$s) { + #if (!empty($this->qNull)) if ($s == 'null') return $s; $s = $this->qstr($s,false); } @@ -822,7 +824,10 @@ $sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1 else if ($typ == 'boolean') $sql .= $v ? $this->true : $this->false; - else if ($v === null) + else if ($typ == 'object') { + if (method_exists($v, '__toString')) $sql .= $this->qstr($v->__toString()); + else $sql .= $this->qstr((string) $v); + } else if ($v === null) $sql .= 'NULL'; else $sql .= $v; @@ -864,7 +869,7 @@ { if ($this->debug) { global $ADODB_INCLUDED_LIB; - if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); $this->_queryID = _adodb_debug_execute($this, $sql,$inputarr); } else { $this->_queryID = @$this->_query($sql,$inputarr); @@ -1110,7 +1115,7 @@ $sql = preg_replace( '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql); - if ($secs2cache>0) { + if ($secs2cache >= 0) { $ret =& $this->CacheExecute($secs2cache, $sql,$inputarr); } else { $ret =& $this->Execute($sql,$inputarr); @@ -1143,10 +1148,10 @@ $ADODB_COUNTRECS = false; if ($offset>0){ - if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); + if ($secs2cache >= 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); else $rs = &$this->Execute($sql,$inputarr); } else { - if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); + if ($secs2cache >= 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); else $rs = &$this->Execute($sql,$inputarr); } $ADODB_COUNTRECS = $savec; @@ -1343,7 +1348,6 @@ return '('.$date.'+'.$dayFraction.')'; } - /** * * @param sql SQL statement @@ -1461,7 +1465,7 @@ function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) { global $ADODB_INCLUDED_LIB; - if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_replace($this, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc); } @@ -1528,7 +1532,7 @@ } global $ADODB_INCLUDED_CSV; - if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php'); + if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); $f = $this->_gencachename($sql.serialize($inputarr),false); adodb_write_file($f,''); // is adodb_write_file needed? @@ -1580,7 +1584,7 @@ } global $ADODB_INCLUDED_CSV; - if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php'); + if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); $f = $this->_gencachename($sql.serialize($inputarr),false); adodb_write_file($f,''); // is adodb_write_file needed? @@ -1655,7 +1659,7 @@ $sqlparam = $sql; global $ADODB_INCLUDED_CSV; - if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php'); + if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); $md5file = $this->_gencachename($sql.serialize($inputarr),true); $err = ''; @@ -1731,15 +1735,16 @@ */ function& AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false) { + $false = false; $sql = 'SELECT * FROM '.$table; if ($where!==FALSE) $sql .= ' WHERE '.$where; else if ($mode == 'UPDATE' || $mode == 2 /* DB_AUTOQUERY_UPDATE */) { ADOConnection::outp('AutoExecute: Illegal mode=UPDATE with empty WHERE clause'); - return false; + return $false; } $rs =& $this->SelectLimit($sql,1); - if (!$rs) return false; // table does not exist + if (!$rs) return $false; // table does not exist $rs->tableName = $table; switch((string) $mode) { @@ -1753,7 +1758,7 @@ break; default: ADOConnection::outp("AutoExecute: Unknown mode=$mode"); - return false; + return $false; } $ret = false; if ($sql) $ret = $this->Execute($sql); @@ -1786,7 +1791,7 @@ } //********************************************************// - if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$force); } @@ -1806,7 +1811,7 @@ $force = $ADODB_FORCE_TYPE; } - if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$force); } @@ -1973,7 +1978,7 @@ if (!isset($_ADODB_ACTIVE_DBS)) { - include_once(ADODB_DIR.'/adodb-active-record.inc.php'); + include(ADODB_DIR.'/adodb-active-record.inc.php'); } if (!class_exists($class)) { ADOConnection::outp("Unknown class $class in GetActiveRcordsClass()"); @@ -2016,6 +2021,57 @@ */ function BeginTrans() {return false;} + /* set transaction mode */ + function SetTransactionMode( $transaction_mode ) + { + $transaction_mode = $this->MetaTransaction($transaction_mode, $this->dataProvider); + $this->_transmode = $transaction_mode; + } +/* +http://msdn2.microsoft.com/en-US/ms173763.aspx +http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-isolation.html +http://www.postgresql.org/docs/8.1/interactive/sql-set-transaction.html +http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_10005.htm +*/ + function MetaTransaction($mode,$db) + { + $mode = strtoupper($mode); + $mode = str_replace('ISOLATION LEVEL ','',$mode); + + switch($mode) { + + case 'READ UNCOMMITTED': + switch($db) { + case 'oci8': + case 'oracle': + return 'ISOLATION LEVEL READ COMMITTED'; + default: + return 'ISOLATION LEVEL READ UNCOMMITTED'; + } + break; + + case 'READ COMMITTED': + return 'ISOLATION LEVEL READ COMMITTED'; + break; + + case 'REPEATABLE READ': + switch($db) { + case 'oci8': + case 'oracle': + return 'ISOLATION LEVEL SERIALIZABLE'; + default: + return 'ISOLATION LEVEL REPEATABLE READ'; + } + break; + + case 'SERIALIZABLE': + return 'ISOLATION LEVEL SERIALIZABLE'; + break; + + default: + return $mode; + } + } /** * If database does not support transactions, always return true as data always commited @@ -2207,7 +2263,7 @@ * * @return array of column names for current table. */ - function &MetaColumnNames($table, $numIndexes=false) + function &MetaColumnNames($table, $numIndexes=false,$useattnum=false /* only for postgres */) { $objarr =& $this->MetaColumns($table); if (!is_array($objarr)) { @@ -2217,7 +2273,12 @@ $arr = array(); if ($numIndexes) { $i = 0; - foreach($objarr as $v) $arr[$i++] = $v->name; + if ($useattnum) { + foreach($objarr as $v) + $arr[$v->attnum] = $v->name; + + } else + foreach($objarr as $v) $arr[$i++] = $v->name; } else foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name; @@ -2261,7 +2322,23 @@ return adodb_date($this->fmtDate,$d); } + function BindDate($d) + { + $d = $this->DBDate($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + function BindTimeStamp($d) + { + $d = $this->DBTimeStamp($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + /** * Converts a timestamp "ts" to a string that the database can understand. * @@ -2446,7 +2523,7 @@ /** * Will select the supplied $page number from a recordset, given that it is paginated in pages of * $nrows rows per page. It also saves two boolean values saying if the given page is the first - * and/or last one of the recordset. Added by Iv\xE1n Oliva to provide recordset pagination. + * and/or last one of the recordset. Added by Iv�n Oliva to provide recordset pagination. * * See readme.htm#ex8 for an example of usage. * @@ -2463,7 +2540,7 @@ function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) { global $ADODB_INCLUDED_LIB; - if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache); else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache); return $rs; @@ -2473,7 +2550,7 @@ /** * Will select the supplied $page number from a recordset, given that it is paginated in pages of * $nrows rows per page. It also saves two boolean values saying if the given page is the first - * and/or last one of the recordset. Added by Iv\xE1n Oliva to provide recordset pagination. + * and/or last one of the recordset. Added by Iv�n Oliva to provide recordset pagination. * * @param secs2cache seconds to cache data, set to 0 to force query * @param sql @@ -2535,7 +2612,7 @@ //============================================================================================== // DATE AND TIME FUNCTIONS //============================================================================================== - include_once(ADODB_DIR.'/adodb-time.inc.php'); + if (!defined('ADODB_DATE_VERSION')) include(ADODB_DIR.'/adodb-time.inc.php'); //============================================================================================== // CLASS ADORecordSet @@ -2581,9 +2658,9 @@ var $_obj; /** Used by FetchObj */ var $_names; /** Used by FetchObj */ - var $_currentPage = -1; /** Added by Iv\xE1n Oliva to implement recordset pagination */ - var $_atFirstPage = false; /** Added by Iv\xE1n Oliva to implement recordset pagination */ - var $_atLastPage = false; /** Added by Iv\xE1n Oliva to implement recordset pagination */ + var $_currentPage = -1; /** Added by Iv�n Oliva to implement recordset pagination */ + var $_atFirstPage = false; /** Added by Iv�n Oliva to implement recordset pagination */ + var $_atLastPage = false; /** Added by Iv�n Oliva to implement recordset pagination */ var $_lastPageNo = -1; var $_maxRecordCount = 0; var $datetime = false; @@ -2646,7 +2723,7 @@ $size=0, $selectAttr='',$compareFields0=true) { global $ADODB_INCLUDED_LIB; - if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple, $size, $selectAttr,$compareFields0); } @@ -2673,7 +2750,7 @@ $size=0, $selectAttr='') { global $ADODB_INCLUDED_LIB; - if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getmenu_gp($this, $name,$defstr,$blank1stItem,$multiple, $size, $selectAttr,false); } @@ -2790,7 +2867,17 @@ if ($ADODB_EXTENSION) { if ($numIndex) { while (!$this->EOF) { - $results[trim($this->fields[0])] = array_slice($this->fields, 1); + // $results[trim($this->fields[0])] = array_slice($this->fields, 1); + // Fix for array_slice re-numbering numeric associative keys in PHP5 + $keys = array_slice(array_keys($this->fields), 1); + $sliced_array = array(); + + foreach($keys as $key) { + $sliced_array[$key] = $this->fields[$key]; + } + + $results[trim(reset($this->fields))] = $sliced_array; + adodb_movenext($this); } } else { @@ -2802,7 +2889,16 @@ } else { if ($numIndex) { while (!$this->EOF) { - $results[trim($this->fields[0])] = array_slice($this->fields, 1); + //$results[trim($this->fields[0])] = array_slice($this->fields, 1); + // Fix for array_slice re-numbering numeric associative keys in PHP5 + $keys = array_slice(array_keys($this->fields), 1); + $sliced_array = array(); + + foreach($keys as $key) { + $sliced_array[$key] = $this->fields[$key]; + } + + $results[trim(reset($this->fields))] = $sliced_array; $this->MoveNext(); } } else { @@ -3360,6 +3456,7 @@ 'BPCHAR' => 'C', 'CHARACTER' => 'C', 'INTERVAL' => 'C', # Postgres + 'MACADDR' => 'C', # postgres ## 'LONGCHAR' => 'X', 'TEXT' => 'X', @@ -3386,6 +3483,7 @@ 'DATETIME' => 'T', 'TIMESTAMPTZ' => 'T', 'T' => 'T', + 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql ## 'BOOL' => 'L', 'BOOLEAN' => 'L', @@ -3952,7 +4050,7 @@ $path = ADODB_DIR."/datadict/datadict-$drivername.inc.php"; if (!file_exists($path)) { - ADOConnection::outp("Database driver '$path' not available"); + ADOConnection::outp("Dictionary driver '$path' not available"); return $false; } include_once($path); @@ -3998,7 +4096,7 @@ function adodb_backtrace($printOrArr=true,$levels=9999) { global $ADODB_INCLUDED_LIB; - if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_backtrace($printOrArr,$levels); } Modified: trunk/linpha2/lib/adodb/drivers/adodb-access.inc.php =================================================================== --- trunk/linpha2/lib/adodb/drivers/adodb-access.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/drivers/adodb-access.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /* -V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. +V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt. Modified: trunk/linpha2/lib/adodb/drivers/adodb-ado.inc.php =================================================================== --- trunk/linpha2/lib/adodb/drivers/adodb-ado.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/drivers/adodb-ado.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /* -V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. +V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -263,6 +263,7 @@ $this->transCnt += 1; return true; } + function CommitTrans($ok=true) { if (!$ok) return $this->RollbackTrans(); @@ -283,7 +284,9 @@ function ErrorMsg() { + if (!$this->_connectionID) return "No connection established"; $errc = $this->_connectionID->Errors; + if (!$errc) return "No Errors object found"; if ($errc->Count == 0) return ''; $err = $errc->Item($errc->Count-1); return $err->Description; Modified: trunk/linpha2/lib/adodb/drivers/adodb-ado5.inc.php =================================================================== --- trunk/linpha2/lib/adodb/drivers/adodb-ado5.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/drivers/adodb-ado5.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /* -V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. +V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -58,8 +58,22 @@ // you can also pass a connection string like this: // // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB'); - function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL') + function _connect($argHostname, $argUsername, $argPassword,$argDBorProvider, $argProvider= '') { + // two modes + // - if $argProvider is empty, we assume that $argDBorProvider holds provider -- this is for backward compat + // - if $argProvider is not empty, then $argDBorProvider holds db + + + if ($argProvider) { + $argDatabasename = $argDBorProvider; + } else { + $argDatabasename = ''; + if ($argDBorProvider) $argProvider = $argDBorProvider; + else $argProvider = 'MSDASQL'; + } + + try { $u = 'UID'; $p = 'PWD'; @@ -86,7 +100,11 @@ $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider if ($argProvider) $dbc->Provider = $argProvider; + + if ($argProvider) $argHostname = "PROVIDER=$argProvider;DRIVER={SQL Server};SERVER=$argHostname"; + + if ($argDatabasename) $argHostname .= ";DATABASE=$argDatabasename"; if ($argUsername) $argHostname .= ";$u=$argUsername"; if ($argPassword)$argHostname .= ";$p=$argPassword"; @@ -205,9 +223,6 @@ return $arr; } - - - /* returns queryID or false */ function &_query($sql,$inputarr=false) { @@ -216,6 +231,9 @@ $dbc = $this->_connectionID; // return rs + + $false = false; + if ($inputarr) { if (!empty($this->charPage)) @@ -236,22 +254,25 @@ $p = false; $rs = $oCmd->Execute(); $e = $dbc->Errors; - if ($dbc->Errors->Count > 0) return false; + if ($dbc->Errors->Count > 0) return $false; return $rs; } $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option); - if ($dbc->Errors->Count > 0) return false; - if (! $rs) return false; + if ($dbc->Errors->Count > 0) return $false; + if (! $rs) return $false; - if ($rs->State == 0) return true; // 0 = adStateClosed means no records returned + if ($rs->State == 0) { + $true = true; + return $true; // 0 = adStateClosed means no records returned + } return $rs; } catch (exception $e) { } - return false; + return $false; } @@ -290,10 +311,18 @@ function ErrorMsg() { - $errc = $this->_connectionID->Errors; - if ($errc->Count == 0) return ''; - $err = $errc->Item($errc->Count-1); - return $err->Description; + if (!$this->_connectionID) return "No connection established"; + $errmsg = ''; + + try { + $errc = $this->_connectionID->Errors; + if (!$errc) return "No Errors object found"; + if ($errc->Count == 0) return ''; + $err = $errc->Item($errc->Count-1); + $errmsg = $err->Description; + }catch(exception $e) { + } + return $errmsg; } function ErrorNo() Modified: trunk/linpha2/lib/adodb/drivers/adodb-ado_access.inc.php =================================================================== --- trunk/linpha2/lib/adodb/drivers/adodb-ado_access.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/drivers/adodb-ado_access.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /* -V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. +V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt. Modified: trunk/linpha2/lib/adodb/drivers/adodb-ado_mssql.inc.php =================================================================== --- trunk/linpha2/lib/adodb/drivers/adodb-ado_mssql.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/drivers/adodb-ado_mssql.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /* -V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. +V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -11,8 +11,8 @@ Microsoft SQL Server ADO data driver. Requires ADO and MSSQL client. Works only on MS Windows. - It is normally better to use the mssql driver directly because it is much faster. - This file is only a technology demonstration and for test purposes. + Warning: Some versions of PHP (esp PHP4) leak memory when ADO/COM is used. + Please check http://bugs.php.net/ for more info. */ // security - hide paths @@ -53,6 +53,17 @@ return $this->GetOne('select @@rowcount'); } + function SetTransactionMode( $transaction_mode ) + { + $this->_transmode = $transaction_mode; + if (empty($transaction_mode)) { + $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); + return; + } + if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; + $this->Execute("SET TRANSACTION ".$transaction_mode); + } + function MetaColumns($table) { $table = strtoupper($table); @@ -84,6 +95,44 @@ return empty($arr) ? $false : $arr; } + function CreateSequence($seq='adodbseq',$start=1) + { + + $this->Execute('BEGIN TRANSACTION adodbseq'); + $start -= 1; + $this->Execute("create table $seq (id float(53))"); + $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); + if (!$ok) { + $this->Execute('ROLLBACK TRANSACTION adodbseq'); + return false; + } + $this->Execute('COMMIT TRANSACTION adodbseq'); + return true; + } + + function GenID($seq='adodbseq',$start=1) + { + //$this->debug=1; + $this->Execute('BEGIN TRANSACTION adodbseq'); + $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); + if (!$ok) { + $this->Execute("create table $seq (id float(53))"); + $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); + if (!$ok) { + $this->Execute('ROLLBACK TRANSACTION adodbseq'); + return false; + } + $this->Execute('COMMIT TRANSACTION adodbseq'); + return $start; + } + $num = $this->GetOne("select id from $seq"); + $this->Execute('COMMIT TRANSACTION adodbseq'); + return $num; + + // in old implementation, pre 1.90, we returned GUID... + //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); + } + } // end class class ADORecordSet_ado_mssql extends ADORecordSet_ado { Modified: trunk/linpha2/lib/adodb/drivers/adodb-borland_ibase.inc.php =================================================================== --- trunk/linpha2/lib/adodb/drivers/adodb-borland_ibase.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/drivers/adodb-borland_ibase.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /* -V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. +V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/drivers/adodb-csv.inc.php =================================================================== --- trunk/linpha2/lib/adodb/drivers/adodb-csv.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/drivers/adodb-csv.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,6 +1,6 @@ <?php /* -V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jl...@na...). All rights reserved. +V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/drivers/adodb-db2.inc.php =================================================================== --- trunk/linpha2/lib/adodb/drivers/adodb-db2.inc.php 2006-08-25 21:29:33 UTC (rev 4557) +++ trunk/linpha2/lib/adodb/drivers/adodb-db2.inc.php 2006-08-26 12:28:52 UTC (rev 4558) @@ -1,13 +1,15 @@ <?php /* - V4.80 8 Mar 2006 (c) 2006 John Lim (jl...@na...). All rights reserved. + V4.91 2 Aug 2006 (c) 2006 John Lim (jlim#natsoft.com.my). All rights reserved. -This is a version of the ADODB driver for DB2. It uses the 'ibm_db2' PECL extension for PHP - (http://pecl.php.net/package/ibm_db2), which in turn requires DB2 V8.2.2. + This is a version of the ADODB driver for DB2. It uses the 'ibm_db2' PECL extension + for PHP (http://pecl.php.net/package/ibm_db2), which in turn requires DB2 V8.2.2 or + higher. - Tested with PHP 5.1.1 and Apache 2.0.55 on Windows XP SP2. + Originally tested with PHP 5.1.1 and Apache 2.0.55 on Windows XP SP2. + More recently tested with PHP 5.1.2 and Apache 2.0.55 on Windows XP SP2. - This file was ported from "adodb-odbc.inc.php" by Larry Menard, "lar...@ro...". + This file was ported from "adodb-odbc.inc.php" by Larry Menard, "larry.menard#rogers.com". I ripped out what I believed to be a lot of redundant or obsolete code, but there are probably still some remnants of the ODBC support in this file; I'm relying on reviewers of this code to point out any other things that can be removed. @@ -25,7 +27,13 @@ class ADODB_db2 extends ADOConnection { var $databaseType = "db2"; var $fmtDate = "'Y-m-d'"; - var $fmtTimeStamp = "'Y-m-d, h:i:sA'"; + var $concat_operator = '||'; + + var $sysTime = 'CURRENT TIME'; + var $sysDate = 'CURRENT DATE'; + var $sysTimeStamp = 'CURRENT TIMESTAMP'; + + var $fmtTimeStamp = "'Y-m-d-H.i.s'"; var $replaceQuote = "''"; // string to use to replace quotes var $dataProvider = "db2"; var $hasAffectedRows = true; @@ -35,12 +43,20 @@ var $useFetchArray = false; // setting this to true will make array elements in FETCH_ASSOC mode case-sensitive // breaking backward-compat var $_bindInputArray = false; - var $_genSeqSQL = "create table %s (id integer)"; + var $_genIDSQL = "VALUES NEXTVAL FOR %s"; + var $_genSeqSQL = "CREATE SEQUENCE %s START WITH 1 NO MAXVALUE NO CYCLE"; + var $_dropSeqSQL = "DROP SEQUENCE %s"; var $_autocommit = true; var $_haserrorfunctions = true; var $_lastAffectedRows = 0; var $uCaseTables = true; // for meta* functions, uppercase table names + var $hasInsertID = true; + function _insertid() + { + return ADOConnection::GetOne('VALUES IDENTITY_VAL_LOCAL()'); + } + function ADODB_db2() { $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050; @@ -69,7 +85,8 @@ // For db2_connect(), there is an optional 4th arg. If present, it must be // an array of valid options. So far, we don't use them. - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + $this->_errorMsg = @db2_conn_errormsg(); + if (isset($this->connectStmt)) $this->Execute($this->connectStmt); return $this->_connectionID != false; @@ -96,7 +113,7 @@ } if (isset($php_errormsg)) $php_errormsg = ''; - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + $this->_errorMsg = @db2_conn_errormsg(); if ($this->_connectionID && $this->autoRollback) @db2_rollback($this->_connectionID); if (isset($this->connectStmt)) $this->Execute($this->connectStmt); @@ -104,6 +121,61 @@ } + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + // use right() and replace() ? + if (!$col) $col = $this->sysDate; + $s = ''; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + if ($s) $s .= $this->concat_operator; + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= "char(year($col))"; + break; + case 'M': + $s .= "substr(monthname($col),1,3)"; + break; + case 'm': + $s .= "right(digits(month($col)),2)"; + break; + case 'D': + case 'd': + $s .= "right(digits(day($col)),2)"; + break; + case 'H': + case 'h': + if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)"; + else $s .= "''"; + break; + case 'i': + case 'I': + if ($col != $this->sysDate) + $s .= "right(digits(minute($col)),2)"; + else $s .= "''"; + break; + case 'S': + case 's': + if ($col != $this->sysDate) + $s .= "right(digits(second($col)),2)"; + else $s .= "''"; + break; + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + $s .= $this->qstr($ch); + } + } + return $s; + } + + function ServerInfo() { @@ -139,11 +211,9 @@ if (empty($this->_genSeqSQL)) return false; $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); if (!$ok) return false; - $start -= 1; - return $this->Execute("insert into $seqname values($start)"); + return true; } - var $_dropSeqSQL = 'drop table %s'; function DropSequence($seqname) { if (empty($this->_dropSeqSQL)) return false; @@ -160,37 +230,17 @@ { // if you have to modify the parameter below, your database is overloaded, // or you need to implement generation of id's yourself! - $MAXLOOPS = 100; - while (--$MAXLOOPS>=0) { - $num = $this->GetOne("select id from $seq"); - if ($num === false) { - $this->Execute(sprintf($this->_genSeqSQL ,$seq)); - $start -= 1; - $num = '0'; - $ok = $this->Execute("insert into $seq values($start)"); - if (!$ok) return false; - } - $this->Execute("update $seq set id=id+1 where id=$num"); - - if ($this->affected_rows() > 0) { - $num += 1; - $this->genID = $num; + $num = $this->GetOne("VALUES NEXTVAL FOR $seq"); return $num; } - } - if ($fn = $this->raiseErrorFn) { - $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num); - } - return false; - } function ErrorMsg() { if ($this->_haserrorfunctions) { if ($this->_errorMsg !== false) return $this->_errorMsg; - if (empty($this->_connectionID)) return @db2_errormsg(); - return @db2_errormsg($this->_connectionID); + if (empty($this->_connectionID)) return @db2_co... [truncated message content] |
From: <fan...@us...> - 2006-08-27 13:14:22
|
Revision: 4559 Author: fangehrn Date: 2006-08-27 06:14:05 -0700 (Sun, 27 Aug 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4559&view=rev Log Message: ----------- * fixed image rotate with gdlib Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/image/gdlib/image.php trunk/linpha2/lib/classes/image/gdlib/thumbnail.php trunk/linpha2/lib/classes/linpha.image.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-08-26 12:28:52 UTC (rev 4558) +++ trunk/linpha2/ChangeLog 2006-08-27 13:14:05 UTC (rev 4559) @@ -1,3 +1,6 @@ +2006-08-25 flo + * fixed image rotate with gdlib + 2006-08-26 bzrudi * fixed broken installation for postgres * replaced all PO_Inserted_ID (does not work with postgres) @@ -10,7 +13,6 @@ with this feature we should also be able to rotate images manually without having write permission to the file @todo what should happen if we later turn off autorot? - @todo why does it not work with gdlib?! 2006-07-15 flo * fixed bracket support detection during installation @@ -22,7 +24,6 @@ $array_output = array(); $return_value = ''; exec($str, $array_output, $return_value); - 2006-07-09 bzrudi * install: fixed bug in sqlite install - $_SESSION vars not inited and initial directories (sql/tmp/cache) under /var not created. Moved some functions to Modified: trunk/linpha2/lib/classes/image/gdlib/image.php =================================================================== --- trunk/linpha2/lib/classes/image/gdlib/image.php 2006-08-26 12:28:52 UTC (rev 4558) +++ trunk/linpha2/lib/classes/image/gdlib/image.php 2006-08-27 13:14:05 UTC (rev 4559) @@ -55,12 +55,8 @@ /** * rotate image - * @todo why does this not work?! */ - if(function_exists('imagerotate') AND $this->rotate != "0") - { - imagerotate($scaled_image,$this->rotate,0); - } + LinImage::imageRotateGd($scaled_image,$this->rotate); /** * save image Modified: trunk/linpha2/lib/classes/image/gdlib/thumbnail.php =================================================================== --- trunk/linpha2/lib/classes/image/gdlib/thumbnail.php 2006-08-26 12:28:52 UTC (rev 4558) +++ trunk/linpha2/lib/classes/image/gdlib/thumbnail.php 2006-08-27 13:14:05 UTC (rev 4559) @@ -86,12 +86,8 @@ /** * rotate image - * @todo why does this not work?! */ - if(function_exists('imagerotate') AND $this->rotate != "0") - { - imagerotate($scaled_image,$this->rotate,0); - } + LinImage::imageRotateGd($scaled_image,$this->rotate); /** * save image Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-08-26 12:28:52 UTC (rev 4558) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-08-27 13:14:05 UTC (rev 4559) @@ -576,6 +576,28 @@ readfile( $this->output_file ); } +/** + * rotates an image with a given angle using GDLib + * do nothing if imagerotate() doesn't exists + * + * + * @param imageressource $src_img pointer to the source image + * @param int $angle angle to rotate + * @author flo + * @todo maybe we should use linpha_log if imagerotate() doesn't exists + */ +function imageRotateGd(& $src_img, $angle) +{ + if(function_exists('imagerotate') && $angle != "0") + { + /** + * flip $angle, because with this function, left means right, and right means left :-) + */ + $angle = 360 - $angle; + $angle = $angle % 360; + $src_img = imagerotate($src_img,$angle,0); + } +} } // end class linImage ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-08-27 22:16:53
|
Revision: 4561 Author: fangehrn Date: 2006-08-27 15:16:12 -0700 (Sun, 27 Aug 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4561&view=rev Log Message: ----------- 2006-08-27 flo * fixed image rotate with gdlib * implemented user settings - change username, display name, email, password - the table linpha_config contains now two more columns: override and user_id all settings with override == 1 apear in the user settings and the user will be able to change themself the config array $linpha->sql->config->value[] will contain the real settings (system config + the configs the user made) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/image_fields.php trunk/linpha2/admin/image_fields_define.php trunk/linpha2/admin/image_fields_select.php trunk/linpha2/admin/index.php trunk/linpha2/admin/permissions.php trunk/linpha2/admin/permissions_groups.php trunk/linpha2/admin/permissions_others.php trunk/linpha2/admin/permissions_readwrite.php trunk/linpha2/admin/permissions_users.php trunk/linpha2/admin/settings.php trunk/linpha2/admin/settings_all.php trunk/linpha2/admin/settings_features.php trunk/linpha2/admin/settings_layout.php trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/docs/dev/important stuff.txt trunk/linpha2/index.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.filemanager.php trunk/linpha2/linpha2.specs.txt trunk/linpha2/templates/default/global.html.php Added Paths: ----------- trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/modules/module.settings.php trunk/linpha2/templates/default/settings.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/ChangeLog 2006-08-27 22:16:12 UTC (rev 4561) @@ -1,5 +1,10 @@ -2006-08-25 flo +2006-08-27 flo * fixed image rotate with gdlib + * implemented user settings + - change username, display name, email, password + - the table linpha_config contains now two more columns: override and user_id + all settings with override == 1 apear in the user settings and the user will be able to change themself + the config array $linpha->sql->config->value[] will contain the real settings (system config + the configs the user made) 2006-08-26 bzrudi * fixed broken installation for postgres Modified: trunk/linpha2/admin/image_fields.php =================================================================== --- trunk/linpha2/admin/image_fields.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/image_fields.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -11,7 +11,7 @@ 'define' => Array('name' => 'Define image fields', 'link' => 'imagefields_define') ); -print_admin_menu($array_menu,$cat2); +LinAdmin::printAdminMenu($array_menu,$cat2); switch($cat2) { Modified: trunk/linpha2/admin/image_fields_define.php =================================================================== --- trunk/linpha2/admin/image_fields_define.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/image_fields_define.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -24,7 +24,7 @@ 'iptc' => Array('name' => 'Iptc fields', 'link' => 'imagefields_define_iptc') ); - print_admin_menu($array_menu,$cat3); + LinAdmin::printAdminMenu($array_menu,$cat3); /** * parse POST data Modified: trunk/linpha2/admin/image_fields_select.php =================================================================== --- trunk/linpha2/admin/image_fields_select.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/image_fields_select.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -13,7 +13,7 @@ 'album' => Array('name' => 'Album', 'link' => 'imagefields_select_album') ); -print_admin_menu($array_menu,$cat3); +LinAdmin::printAdminMenu($array_menu,$cat3); switch($cat3) { Modified: trunk/linpha2/admin/index.php =================================================================== --- trunk/linpha2/admin/index.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/index.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -6,6 +6,8 @@ */ include_once(LINPHA_DIR.'/lib/include/common.php'); include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); + include_once(LINPHA_DIR.'/lib/classes/linpha.admin.class.php'); + $linpha = new linpha(); $linpha->sql->startSession(); @@ -14,6 +16,7 @@ echo i18n("Only Admin Has Access To This Area"); exit(1); } + /** * @todo admin permission check */ @@ -61,7 +64,7 @@ 'imagefields' => Array('name' => 'Image fields', 'link' => 'imagefields'), ); -print_admin_menu($array_menu,$cat1); +LinAdmin::printAdminMenu($array_menu,$cat1); switch($cat1) { @@ -94,114 +97,4 @@ <?php } ?> </body> -</html> - -<?php - -function print_admin_menu($array_menu,$active) -{ - ?> - <ul class="navlist"> - <?php - foreach($array_menu AS $key=>$value) - { - if($value['link']=='linpha_home') - { - echo '<li><a href="../">'.i18n($value['name']).'</a></li>'; - } - else - { - if($active==$key) - { - echo '<li class="active"><a href="./?cat='.$value['link'].'" class="current">'.i18n($value['name']).'</a></li>'; - } - else - { - echo '<li><a href="./?cat='.$value['link'].'">'.i18n($value['name']).'</a></li>'; - } - } - } - ?> - </ul> - <?php -} - -function printAdminConfig($type,$text,$id,$options=array()) -{ - ?> - <div style="width: 600px; border: 1px solid black; padding: 5px; margin-bottom: 5px;"> - <div align="left" style="float: left;"> - <?php - switch($type) - { - case 'radio': - if($GLOBALS['linpha']->sql->config->value[$id]) - { - $str_enabled = ' checked="checked"'; - $str_disabled = ''; - } - else - { - $str_enabled = ''; - $str_disabled = ' checked="checked"'; - } - echo $text; - ?> - </div> - <div align="right"> - <input type="radio" id="<?php echo $id; ?>01" name="<?php echo $id; ?>" value="1"<?php echo $str_enabled; ?> /><label for="<?php echo $id; ?>01"><?php echo i18n("Enable"); ?></label> - <input type="radio" id="<?php echo $id; ?>02" name="<?php echo $id; ?>" value="0"<?php echo $str_disabled; ?>/><label for="<?php echo $id; ?>02"><?php echo i18n("Disable"); ?></label> - <?php - break; - case 'text': - echo $text; - ?> - </div> - <div align="right"> - <input type="text" name="<?php echo $id; ?>" value="<?php echo $GLOBALS['linpha']->sql->config->value[$id]; ?>" maxlength="255"/> - <?php - - break; - case 'select': - echo $text; - ?> - </div> - <div align="right"> - <select name="<?php echo $id; ?>" size="1"> - <?php - foreach($options AS $key=>$value) - { - if($key == $GLOBALS['linpha']->sql->config->value[$id]) - { - $selected = ' selected="selected"'; - } - else - { - $selected = ''; - } - echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>'; - } - ?> - </select> - <?php - break; - } - ?> - </div> - </div> - <?php -} - -function saveConfig($array) -{ - foreach($array AS $value) - { - if(isset($GLOBALS['linpha']->sql->config->value[$value]) && - isset($_POST[$value])) - { - $GLOBALS['linpha']->sql->config->updateConfig($value,$_POST[$value]); - } - } - $GLOBALS['linpha']->sql->config->reloadConfig(); -} -?> \ No newline at end of file +</html> \ No newline at end of file Modified: trunk/linpha2/admin/permissions.php =================================================================== --- trunk/linpha2/admin/permissions.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -17,7 +17,7 @@ 'others' => Array('name' => 'Others', 'link' => 'permissions_others'), ); -print_admin_menu($array_menu,$cat2); +LinAdmin::printAdminMenu($array_menu,$cat2); switch($cat2) { Modified: trunk/linpha2/admin/permissions_groups.php =================================================================== --- trunk/linpha2/admin/permissions_groups.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions_groups.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -6,11 +6,10 @@ */ if(isset($_POST['cmd'])) { + try + { + /** - * @todo use something like htmlspecialchars() ? - */ - - /** * prevent changes on admin group */ switch($_POST['cmd']) @@ -21,51 +20,62 @@ $admingroup_id = $data['id']; if($_POST['id'] == $admingroup_id) { - linSysLog(i18n("Error").' trying to edit admin, something went wrong!'); - $error = 1; + throw new Exception(i18n("Trying to edit the admin group, something went wrong!")); } break; } - /** - * check if group already exists - */ switch($_POST['cmd']) { case 'ren_group': case 'new_group': + /** + * check if group is empty + */ + if(empty($_POST['group_name'])) + { + throw new Exception(i18n("The group name may not be empty.")); + } + + /** + * check if group already exists + */ $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."groups " . "WHERE group_name = '".LinSql::linAddslashes($_POST['group_name'])."'"); if(isset($data['id'])) { - linSysLog(i18n("Error: Group Already Exists")); - $error = 2; + throw new Exception(i18n("A group with the same name already exists.")); } break; } - if(!isset($error)) - { + /** + * update data + */ switch($_POST['cmd']) { case 'ren_group': $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."groups " . "SET group_name='".LinSql::linAddslashes($_POST['group_name'])."' " . "WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); - linSysLog("Group Renamed"); + linSysLog(i18n("Group Renamed")); break; case 'del_group': $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."groups ". "WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); - linSysLog("Group Deleted"); + linSysLog(i18n("Group Deleted")); break; case 'new_group': $GLOBALS['linpha']->db->Execute("INSERT INTO ".PREFIX."groups (group_name) ". "VALUES ('".LinSql::linAddslashes($_POST['group_name'])."')"); - linSysLog("Group Created"); + linSysLog(i18n("Group Created")); break; } } + catch(Exception $error) + { + linSysLog("Error: ".$error -> getMessage()); + } } ?> <table border="1"> @@ -81,7 +91,7 @@ <tr> <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_groups'; ?>"> <td> - <input style="width: 200;" type="text" name="group_name" value="<?php echo $data['group_name']; ?>" maxsize="255"> + <input style="width: 200;" type="text" name="group_name" value="<?php echo htmlspecialchars($data['group_name'],ENT_QUOTES); ?>" maxsize="255"> </td> <td> Modified: trunk/linpha2/admin/permissions_others.php =================================================================== --- trunk/linpha2/admin/permissions_others.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions_others.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -31,7 +31,7 @@ break; } -print_admin_menu($array_menu,$cat3); +LinAdmin::printAdminMenu($array_menu,$cat3); if(!empty($cat3)) { Modified: trunk/linpha2/admin/permissions_readwrite.php =================================================================== --- trunk/linpha2/admin/permissions_readwrite.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions_readwrite.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -15,7 +15,7 @@ <?php if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - saveConfig( + LinAdmin::saveConfig( Array( 'plugins_filemanager_enable' ) @@ -23,7 +23,7 @@ } - printAdminConfig('radio',i18n("Enable Filemanager For Non-Admin Users"),'plugins_filemanager_enable'); + LinAdmin::printAdminConfig('radio',i18n("Enable Filemanager For Non-Admin Users"),'plugins_filemanager_enable'); ?> <input type="hidden" name="cmd" value="saveconfig" /> Modified: trunk/linpha2/admin/permissions_users.php =================================================================== --- trunk/linpha2/admin/permissions_users.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions_users.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -3,36 +3,63 @@ /** * save data - * @todo create new user: check if name does not already exists - * @todo rename user: check if name does not already exists - * -> will not be easy - * @todo check if username and password not empty */ if(isset($_POST['cmd'])) { - /** - * @todo use something like htmlspecialchars() ? - */ + try + { + switch($_POST['cmd']) { case 'mod_user': + /** + * check if username is empty + */ + if( empty($_POST['mod_user_name']) ) + { + throw new Exception(i18n("The username may not be empty.")); + } + + /** + * check if username already exists + * (only if it will be changed) + */ + if( $_POST['old_user_name'] != $_POST['mod_user_name'] ) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT username FROM ".PREFIX."users " . + "WHERE username = '".LinSql::linAddslashes($_POST['mod_user_name'])."'"); + if( ! $query->EOF ) + { + throw new Exception(i18n("A user with the same username already exists.")); + } + } + + /** + * check length of new password + * (if strlen() == 0, the password isn't updated at all) + */ + if( strlen($_POST['mod_user_pass'])>0 && strlen($_POST['mod_user_pass'])<3 ) + { + throw new Exception(i18n("Password To Short")); + } + /** * update password * only if it is not empty */ if(empty($_POST['mod_user_pass'])) { - $new_password = ""; + $sql_str_new_password = ""; } else { $md5_pass = md5($_POST['mod_user_pass']); - $new_password = "password='".$md5_pass."', "; + $sql_str_new_password = "password='".$md5_pass."', "; } $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."users SET ". "username='".LinSql::linAddslashes($_POST['mod_user_name'])."', ". "display_name='".LinSql::linAddslashes($_POST['mod_user_fullname'])."', ". - $new_password. + $sql_str_new_password. "user_email='".LinSql::linAddslashes($_POST['mod_user_mail'])."' ". "WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); @@ -60,6 +87,33 @@ $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."users WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); break; case 'new_user': + + /** + * check if username is empty + */ + if( empty($_POST['new_user_name']) ) + { + throw new Exception(i18n("The username may not be empty.")); + } + + /** + * check if username already exists + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT username FROM ".PREFIX."users " . + "WHERE username = '".LinSql::linAddslashes($_POST['new_user_name'])."'"); + if( ! $query->EOF ) + { + throw new Exception(i18n("A user with the same username already exists.")); + } + + /** + * check length of new password + */ + if( strlen($_POST['new_user_pass'])<3 ) + { + throw new Exception(i18n("Password To Short")); + } + $GLOBALS['linpha']->db->Execute("INSERT INTO ".PREFIX."users " . "(username, password, user_email, display_name) ". "VALUES " . @@ -67,16 +121,12 @@ "'".LinSql::linAddslashes($_POST['new_user_mail'])."', '".LinSql::linAddslashes($_POST['new_user_fullname'])."')"); break; } + } + catch(Exception $error) + { + linSysLog("Error: ".$error -> getMessage()); + } } - -/** - * @todo !! - */ -function smart_htmlspecialchars($str) -{ - return $str; -} - ?> <table border="1"> <tr> @@ -97,10 +147,10 @@ <tr> <form name="mod_user" method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_users'; ?>"> <td> - <input type="text" name="mod_user_name" size="20" maxlength="255" value="<?php echo smart_htmlspecialchars($data['username'], ENT_QUOTES); ?>"> + <input type="text" name="mod_user_name" size="20" maxlength="255" value="<?php echo htmlspecialchars($data['username'], ENT_QUOTES); ?>"> </td> <td> - <input type="text" name="mod_user_fullname" size="20" maxlength="255" value="<?php echo smart_htmlspecialchars($data['display_name'], ENT_QUOTES); ?>"> + <input type="text" name="mod_user_fullname" size="20" maxlength="255" value="<?php echo htmlspecialchars($data['display_name'], ENT_QUOTES); ?>"> </td> <td> <input type="password" name="mod_user_pass" size="20" maxlength="255"> @@ -110,7 +160,7 @@ </td> <td> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> - <input type="hidden" name="old_user_name" value="<?php echo smart_htmlspecialchars($data['username'], ENT_QUOTES); ?>"> + <input type="hidden" name="old_user_name" value="<?php echo htmlspecialchars($data['username'], ENT_QUOTES); ?>"> <input type="hidden" name="cmd" value="mod_user"> <input type="submit" value="<?php echo i18n("Modify User"); ?>" style="float: left;"> </form> Modified: trunk/linpha2/admin/settings.php =================================================================== --- trunk/linpha2/admin/settings.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/settings.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -13,8 +13,18 @@ 'all' => Array('name' => 'All', 'link' => 'settings_all') ); -print_admin_menu($array_menu,$cat2); +LinAdmin::printAdminMenu($array_menu,$cat2); +/** + * get system option names and values + */ +$query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config WHERE user_id = '0' ORDER by option_name"); +while($data = $query->FetchRow()) +{ + $options[] = $data['option_name']; + $option_value_system[$data['option_name']] = $data['option_value']; +} + switch($cat2) { case 'layout': Modified: trunk/linpha2/admin/settings_all.php =================================================================== --- trunk/linpha2/admin/settings_all.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/settings_all.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -1,96 +1,31 @@ <?php if(!defined('LINPHA_DIR')) { exit(1); } -$options = array( - 'sys_db_version', - 'sys_im_bracket_support', - 'sys_im_imagemagick_path', - 'sys_im_use_imagemagick', - 'sys_im_video_thumbnail', - - 'sys_import_autoimport', - 'sys_import_exif', - 'sys_import_exif_autorot', - - 'sys_image_exif', - 'sys_image_iptc', - 'sys_image_xmp', - 'sys_lang', - 'sys_lang_autolang', - 'sys_path_album_dir', - 'sys_path_cache_dir', - 'sys_path_tmp_dir', - - 'sys_basket_mail_max_size', - 'sys_basket_download_limit', - - 'sys_style_sortorder', - 'sys_style_template', - 'sys_style_home_showbrowsebydate', - 'sys_style_home_nrrandomimages', - 'sys_style_home_showalbums', - 'sys_style_home_usedefaultwelcometext', - 'sys_style_home_firstsortorder', - 'sys_style_thumb_size_max', - 'sys_style_thumb_size_display', - 'sys_style_thumb_showsubfoldersseparate', - 'sys_style_thumb_selectsizes', - 'sys_style_thumb_selectnrimages', - 'sys_style_thumb_nojsnrrows', - 'sys_style_thumb_nojsnrcols', - 'sys_style_image_quality', - 'sys_style_image_size', - 'sys_style_image_nrprevnextthumbs', - - 'sys_user_autologin' -); - -$radio_options = array( - 'sys_im_bracket_support', - 'sys_im_use_imagemagick', - 'sys_im_video_thumbnail', - 'sys_import_autoimport', - 'sys_import_exif', - 'sys_import_exif_autorot', - 'sys_image_exif', - 'sys_image_iptc', - 'sys_image_xmp', - 'sys_lang_autolang', - 'sys_style_home_showbrowsebydate', - 'sys_style_home_showalbums', - 'sys_style_home_usedefaultwelcometext', - 'sys_style_thumb_showsubfoldersseparate', - 'sys_user_autologin' -); - - echo '<b>'.i18n("This Stuff here is only for advanced Users, don't play around...").'</b>'; ?> <br /><br /> <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_all'; ?>"> <?php +$radio_options = LinAdmin::getRadioOptions(); - - - /** - * save settings - */ - if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') - { - saveConfig($options); - } - - foreach($options AS $value) +/** + * save settings + */ + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - if(in_array($value,$radio_options)) - { - $type = 'radio'; - } - else - { - $type = 'text'; - } - printAdminConfig($type,$value,$value); + LinAdmin::saveConfig($options); } +foreach($options AS $option_name) +{ + if(in_array($option_name,$radio_options)) + { + $type = 'radio'; + } + else + { + $type = 'text'; + } + LinAdmin::printAdminConfig($type,$option_name,$option_name,$option_value_system[$option_name]); +} ?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_features.php =================================================================== --- trunk/linpha2/admin/settings_features.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/settings_features.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -10,7 +10,7 @@ 'others' => Array('name' => 'Others', 'link' => 'settings_features_others') ); -print_admin_menu($array_menu,$cat3); +LinAdmin::printAdminMenu($array_menu,$cat3); ?> <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_features_'.$cat3; ?>"> @@ -24,7 +24,7 @@ */ if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - saveConfig(Array( + LinAdmin::saveConfig(Array( 'sys_image_exif', 'sys_image_iptc', 'sys_image_xmp' @@ -32,9 +32,9 @@ } - printAdminConfig('radio',i18n("Use EXIF"),'sys_image_exif'); - printAdminConfig('radio',i18n("Use IPTC"),'sys_image_iptc'); - printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp'); + LinAdmin::printAdminConfig('radio',i18n("Use EXIF"),'sys_image_exif',$option_value_system['sys_image_exif']); + LinAdmin::printAdminConfig('radio',i18n("Use IPTC"),'sys_image_iptc',$option_value_system['sys_image_iptc']); + LinAdmin::printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp',$option_value_system['sys_image_xmp']); break; } ?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/settings_layout.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -12,7 +12,7 @@ 'others' => Array('name' => 'Others', 'link' => 'settings_layout_others') ); -print_admin_menu($array_menu,$cat3); +LinAdmin::printAdminMenu($array_menu,$cat3); ?> <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_layout_'.$cat3; ?>"> @@ -34,7 +34,7 @@ */ if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - saveConfig(Array('sys_style_home_usedefaultwelcometext', + LinAdmin::saveConfig(Array('sys_style_home_usedefaultwelcometext', 'sys_style_home_nrrandomimages', 'sys_style_home_showalbums', 'sys_style_home_firstsortorder', @@ -62,23 +62,23 @@ echo '<b>'.i18n("Welcome Text").'</b><br />'; - printAdminConfig('radio',i18n("Use Default Welcome Text"),'sys_style_home_usedefaultwelcometext'); + LinAdmin::printAdminConfig('radio',i18n("Use Default Welcome Text"),'sys_style_home_usedefaultwelcometext',$option_value_system['sys_style_home_usedefaultwelcometext']); ?> <textarea name="welcometext" rows="10" cols="50"><?php echo htmlspecialchars($welcometxt,ENT_QUOTES); ?></textarea> <br /><br /><br /> <?php - printAdminConfig('text',i18n("Nr Of Random Images (0 to disable)"),'sys_style_home_nrrandomimages'); - printAdminConfig('radio',i18n("Show Browse By Date"),'sys_style_home_showbrowsebydate'); - printAdminConfig('radio',i18n("Show Albums On Home Site"),'sys_style_home_showalbums'); - printAdminConfig('select',i18n("Sort Order Of First Level Albums"),'sys_style_home_firstsortorder',getSortOrders()); + LinAdmin::printAdminConfig('text',i18n("Nr Of Random Images (0 to disable)"),'sys_style_home_nrrandomimages',$option_value_system['sys_style_home_nrrandomimages']); + LinAdmin::printAdminConfig('radio',i18n("Show Browse By Date"),'sys_style_home_showbrowsebydate',$option_value_system['sys_style_home_showbrowsebydate']); + LinAdmin::printAdminConfig('radio',i18n("Show Albums On Home Site"),'sys_style_home_showalbums',$option_value_system['sys_style_home_showalbums']); + LinAdmin::printAdminConfig('select',i18n("Sort Order Of First Level Albums"),'sys_style_home_firstsortorder',$option_value_system['sys_style_home_firstsortorder'],getSortOrders()); break; case 'thumb': - printAdminConfig('radio',i18n("Show Subfolders Separate"),'sys_style_thumb_showsubfoldersseparate'); + LinAdmin::printAdminConfig('radio',i18n("Show Subfolders Separate"),'sys_style_thumb_showsubfoldersseparate',$option_value_system['sys_style_thumb_showsubfoldersseparate']); break; case 'image': - printAdminConfig('text',i18n("Nr Of Previous/Next Thumbnails"),'sys_style_image_nrprevnextthumbs'); + LinAdmin::printAdminConfig('text',i18n("Nr Of Previous/Next Thumbnails"),'sys_style_image_nrprevnextthumbs',$option_value_system['sys_style_image_nrprevnextthumbs']); break; case 'others': Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/docs/dev/TODO.txt 2006-08-27 22:16:12 UTC (rev 4561) @@ -32,9 +32,6 @@ - Plugins (copy from linpha1) -- Admin - - User Settings - - ImageMagick - Bracket Support, enable by default, only if old version found, disable it, or require imagemagick > "6.1.4" Modified: trunk/linpha2/docs/dev/important stuff.txt =================================================================== --- trunk/linpha2/docs/dev/important stuff.txt 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/docs/dev/important stuff.txt 2006-08-27 22:16:12 UTC (rev 4561) @@ -12,4 +12,27 @@ clearstatcache(); $handle = fopen($tmp_file, "rb"); - $file_data = fread($handle, filesize($tmp_file)); \ No newline at end of file + $file_data = fread($handle, filesize($tmp_file)); + +- adodb eof + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM meta_fields WHERE flags = '7'"); + if( ! $query->EOF ) -> on or more results + if( $query->EOF ) -> no results + +- trycatch + try + { + if(!isset( $_GET['id'] ) ) + { + throw new Exception("no id supplied!"); + } + } + catch(Exception $error) + { + echo "Error: ".$error -> getMessage(); + } + +- some common language strings + "Successfully updated data." + "Submit" + ?? \ No newline at end of file Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/index.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -38,6 +38,9 @@ case 'filemanager': include_once(LINPHA_DIR.'/lib/modules/module.filemanager.php'); break; +case 'settings': + include_once(LINPHA_DIR.'/lib/modules/module.settings.php'); + break; } ?> \ No newline at end of file Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/install/sql/sql.data.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -72,13 +72,35 @@ 'plugins_filemanager_nruploads' => '5' ); +$options_user_overridable = Array( + 'sys_lang', + 'sys_lang_autolang', + 'sys_style_sortorder', + 'sys_style_template', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_nrrandomimages', + 'sys_style_home_showalbums', + 'sys_style_home_firstsortorder', + 'sys_style_thumb_size_display', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_style_thumb_nojsnrrows', + 'sys_style_thumb_nojsnrcols', + 'sys_style_image_size', + 'sys_style_image_nrprevnextthumbs' +); + /** * create sql executes */ while( list($name, $value) = each($options) ) { - $sql_queries[] = "INSERT INTO ".PREFIX."config (option_name, option_value, user_id) " . - "VALUES ('".$name."', '".$value."', '0')"; + if(in_array($name,$options_user_overridable)) { + $override = 1; + } else { + $override = 0; + } + $sql_queries[] = "INSERT INTO ".PREFIX."config (option_name, option_value, override, user_id) " . + "VALUES ('".$name."', '".$value."', '".$override."', '0')"; } /** Added: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php (rev 0) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -0,0 +1,262 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* 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; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * This class provides functions for edit configs etc. + * @package Admin + */ +class LinAdmin +{ + +function printAdminMenu($array_menu,$active) +{ + ?> + <ul class="navlist"> + <?php + foreach($array_menu AS $key=>$value) + { + if($value['link']=='linpha_home') + { + echo '<li><a href="../">'.i18n($value['name']).'</a></li>'; + } + else + { + if($active==$key) + { + echo '<li class="active"><a href="./?cat='.$value['link'].'" class="current">'.i18n($value['name']).'</a></li>'; + } + else + { + echo '<li><a href="./?cat='.$value['link'].'">'.i18n($value['name']).'</a></li>'; + } + } + } + ?> + </ul> + <?php +} + +function printAdminConfig($type,$text,$id,$value,$options=array()) +{ + ?> + <div style="width: 600px; border: 1px solid black; padding: 5px; margin-bottom: 5px;"> + <div align="left" style="float: left;"> + <?php + switch($type) + { + case 'radio': + if($value) + { + $str_enabled = ' checked="checked"'; + $str_disabled = ''; + } + else + { + $str_enabled = ''; + $str_disabled = ' checked="checked"'; + } + echo $text; + ?> + </div> + <div align="right"> + <input type="radio" id="<?php echo $id; ?>01" name="<?php echo $id; ?>" value="1"<?php echo $str_enabled; ?> /><label for="<?php echo $id; ?>01"><?php echo i18n("Enable"); ?></label> + <input type="radio" id="<?php echo $id; ?>02" name="<?php echo $id; ?>" value="0"<?php echo $str_disabled; ?>/><label for="<?php echo $id; ?>02"><?php echo i18n("Disable"); ?></label> + <?php + break; + case 'text': + case 'password': + echo $text; + ?> + </div> + <div align="right"> + <input type="<?php echo $type; ?>" name="<?php echo $id; ?>" value="<?php echo htmlspecialchars($value, ENT_QUOTES); ?>" maxlength="255" style="width: 200px;" /> + <?php + + break; + case 'select': + echo $text; + ?> + </div> + <div align="right"> + <select name="<?php echo $id; ?>" size="1"> + <?php + foreach($options AS $key=>$value) + { + if($key == $value) + { + $selected = ' selected="selected"'; + } + else + { + $selected = ''; + } + echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>'; + } + ?> + </select> + <?php + break; + } + ?> + </div> + </div> + <?php +} + +function saveConfig($array,$userid=0) +{ + foreach($array AS $value) + { + /** + * does this config name exists? + */ + if(isset($GLOBALS['linpha']->sql->config->value[$value]) && + isset($_POST[$value])) + { + $GLOBALS['linpha']->sql->config->updateConfig($value,$_POST[$value],$userid); + } + } + + /** + * update config array + */ + $GLOBALS['linpha']->sql->config->reloadConfig(); + + /** + * update system config array, used in admin/settings*.php + */ + if(isset($GLOBALS['option_value_system'])) + { + + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config WHERE user_id = '0' ORDER by option_name"); + while($data = $query->FetchRow()) + { + $GLOBALS['option_value_system'][$data['option_name']] = $data['option_value']; + } + } +} + +/** + * thanks to http://www.ilovejackdaniels.com/php/email-address-validation/ + */ +function checkValidEmailAddress($email) +{ + // First, we check that there's one @ symbol, and that the lengths are right + if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { + // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. + return false; + } + // Split it into sections to make life easier + $email_array = explode("@", $email); + $local_array = explode(".", $email_array[0]); + for ($i = 0; $i < sizeof($local_array); $i++) { + if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { + return false; + } + } + if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name + $domain_array = explode(".", $email_array[1]); + if (sizeof($domain_array) < 2) { + return false; // Not enough parts to domain + } + for ($i = 0; $i < sizeof($domain_array); $i++) { + if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { + return false; + } + } + } + return true; +} + +/*function getOptions() +{ + return array( + 'sys_db_version', + 'sys_im_bracket_support', + 'sys_im_imagemagick_path', + 'sys_im_use_imagemagick', + 'sys_im_video_thumbnail', + + 'sys_import_autoimport', + 'sys_import_exif', + 'sys_import_exif_autorot', + + 'sys_image_exif', + 'sys_image_iptc', + 'sys_image_xmp', + 'sys_lang', + 'sys_lang_autolang', + 'sys_path_album_dir', + 'sys_path_cache_dir', + 'sys_path_tmp_dir', + + 'sys_basket_mail_max_size', + 'sys_basket_download_limit', + + 'sys_style_sortorder', + 'sys_style_template', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_nrrandomimages', + 'sys_style_home_showalbums', + 'sys_style_home_usedefaultwelcometext', + 'sys_style_home_firstsortorder', + 'sys_style_thumb_size_max', + 'sys_style_thumb_size_display', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_style_thumb_selectsizes', + 'sys_style_thumb_selectnrimages', + 'sys_style_thumb_nojsnrrows', + 'sys_style_thumb_nojsnrcols', + 'sys_style_image_quality', + 'sys_style_image_size', + 'sys_style_image_nrprevnextthumbs', + + 'sys_user_autologin' + ); +}*/ + +/** + * a list of all settings which are enable/disable + * to show radio buttons instead of text field + */ +function getRadioOptions() +{ + return array( + 'sys_im_bracket_support', + 'sys_im_use_imagemagick', + 'sys_im_video_thumbnail', + 'sys_import_autoimport', + 'sys_import_exif', + 'sys_import_exif_autorot', + 'sys_image_exif', + 'sys_image_iptc', + 'sys_image_xmp', + 'sys_lang_autolang', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_showalbums', + 'sys_style_home_usedefaultwelcometext', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_user_autologin' + ); +} + +} // end class LinAdmin + +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -337,6 +337,19 @@ { $_SESSION['basket_ids'] = Array(); } + + /** + * apply user overridden config values + * this has also to be here because the session isn't started yet in reloadConfig() + * but also has to be in reloadConfig() if it will be called during the script + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . + "FROM ".PREFIX."config WHERE user_id = '".$_SESSION['user_id']."'"); + + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + $GLOBALS['linpha']->sql->config->value[$data['0']] = $data['1']; + } } // end function startSession /** @@ -364,6 +377,7 @@ { $_SESSION['user_groups'][] = $data['group_id']; } + } @@ -698,17 +712,39 @@ $this->reloadConfig(); } +/** + * (re-)load config from db to array + * the overriden user configs will be load in startSession() + */ function reloadConfig() { unset($this->value); + /** + * load system values + */ $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . - "FROM ".PREFIX."config"); - + "FROM ".PREFIX."config WHERE user_id = '0'"); while($data = $query->FetchRow(ADODB_FETCH_NUM)) { $this->value[$data['0']] = $data['1']; - } + } + + /** + * apply user overridden config values + * this has also to be in startSession() because the session isn't started yet in reloadConfig() + * but also has to be in reloadConfig() if it will be called during the script + */ + if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . + "FROM ".PREFIX."config WHERE user_id = '".$_SESSION['user_id']."'"); + + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + $GLOBALS['linpha']->sql->config->value[$data['0']] = $data['1']; + } + } } function writeConfig($option_name,$option_value) @@ -719,12 +755,53 @@ ")"); } -function updateConfig($option_name,$option_value) +function updateConfig($option_name,$option_value,$user_id=0) { - $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."config SET option_value = ". - "'".linSql::linAddslashes($option_value)."'". - "WHERE option_name = ". - "'".linSql::linAddslashes($option_name)."'"); + if($user_id == 0) + { + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."config SET option_value = ". + "'".LinSql::linAddslashes($option_value)."'". + "WHERE option_name = '".LinSql::linAddslashes($option_name)."' " . + "AND user_id = '0'"); + } + else + { + /** + * if the value is the same like the system value, delete it + */ + $data = $GLOBALS['linpha']->db->GetRow("SELECT option_value FROM ".PREFIX."config " . + "WHERE option_name = '".LinSql::linAddslashes($option_name)."' AND user_id = '0'"); + if($option_value == $data['option_value']) + { + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."config " . + "WHERE option_name = '".LinSql::linAddslashes($option_name)."' " . + "AND user_id = '".$user_id."'"); + } + else + { + /** + * insert or update? + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."config " . + "WHERE option_name = '".$option_name."' AND user_id = '".$user_id."'"); + if( ! $query->EOF ) // update + { + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."config SET option_value = ". + "'".LinSql::linAddslashes($option_value)."'". + "WHERE option_name = '".LinSql::linAddslashes($option_name)."' " . + "AND user_id = '".$user_id."'"); + } + else // insert + { + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."config " . + "(option_name, option_value, user_id) " . + "VALUES ('".LinSql::linAddslashes($option_name)."', " . + "'".LinSql::linAddslashes($option_value)."', " . + "'".$user_id."')"); + + } + } + } } } // end sub-class linSqlConfig Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -937,7 +937,6 @@ $linpha->template->URL_full = LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; $linpha->template->output['title'] = i18n("Filemanager"); include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); -exit(); ?> Added: trunk/linpha2/lib/modules/module.settings.php =================================================================== --- trunk/linpha2/lib/modules/module.settings.php (rev 0) +++ trunk/linpha2/lib/modules/module.settings.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -0,0 +1,254 @@ +<?php +/* + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * Settings + * @package Modules + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +include_once(LINPHA_DIR.'/lib/classes/linpha.admin.class.php'); + +/** + * check permissions + */ + if( ! $GLOBALS['linpha']->sql->isLoggedIn()) + { + echo i18n("No Access!"); + exit(); + } + +/** + * get user data + */ + $data = $GLOBALS['linpha']->db->GetRow("SELECT username, password, display_name, user_email ". + "FROM ".PREFIX."users ". + "WHERE id = '".$_SESSION['user_id']."'"); + +/** + * get user settings + */ + $options = Array(); + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name FROM ".PREFIX."config WHERE override = 1 ORDER by option_name"); + while($data = $query->FetchRow()) + { + $options[] = $data['option_name']; + } + $radio_options = LinAdmin::getRadioOptions(); + +/** + * output buffering, to use in template + */ +ob_start(); + +/** + * parse POST data + */ +if(isset($_POST['cmd'])) +{ + try + { + switch($_POST['cmd']) + { + case 'saveuserinfos': + + /** + * check if username is empty + */ + if( empty($_POST['username']) ) + { + throw new Exception(i18n("The username may not be empty.")); + } + + /** + * check if username already exists + * (only if it will be changed) + */ + if( $data['username'] != $_POST['username'] ) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT username FROM ".PREFIX."users " . + "WHERE username = '".LinSql::linAddslashes($_POST['username'])."'"); + if( ! $query->EOF ) + { + throw new Exception(i18n("A user with the same username already exists.")); + } + } + + /** + * check if it is a valid email + */ + if( ! LinAdmin::checkValidEmailAddress($_POST['user_email']) ) + { + throw new Exception(i18n("This is not a valid email address.")); + } + + /** + * update data in db + */ + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."users SET " . + "username = '".LinSql::linAddslashes($_POST['username'])."', " . + "user_email = '".LinSql::linAddslashes($_POST['user_email'])."', " . + "display_name = '".LinSql::linAddslashes($_POST['display_name'])."' " . + "WHERE id = '".$_SESSION['user_id']."'"); + + /** + * update data also for show in html form + */ + $data['username'] = $_POST['username']; + $data['user_email'] = $_POST['user_email']; + $data['display_name'] = $_POST['display_name']; + + /** + * update session variables + */ + $_SESSION['user_name'] = $_POST['username']; + $_SESSION['user_displayname'] = (empty($_POST['display_name'])) ? $_POST['username'] : $_POST['display_name']; //Store user fullname. If fullname is blank - store username. + + + linSysLog(i18n("Successfully updated data.")); + + break; + case 'changepw': + /** + * check if old password is correct + */ + if( md5($_POST['old_password']) != $data['password'] ) + { + throw new Exception(i18n("Old password is not correct.")); + } + + /** + * check length of new password + */ + if( strlen($_POST['new_password'])<3 ) + { + throw new Exception(i18n("Password To Short")); + } + + /** + * check correct repeating passwords + */ + if( $_POST['new_password'] != $_POST['new_password2'] ) + { + throw new Exception(i18n("New password doesn't match with retyped password")); + } + + /** + * update password + */ + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."users SET " . + "password = '".md5($_POST['new_password'])."' WHERE id = '".$_SESSION['user_id']."'"); + + linSysLog(i18n("Password successfully updated.")); + + break; + case 'saveconfig': + /** + * save and reload config + */ + LinAdmin::saveConfig($options,$_SESSION['user_id']); + linSysLog(i18n("Successfully updated data.")); + break; + case 'loaddefault': + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."config " . + "WHERE user_id = '".$_SESSION['user_id']."'"); + $GLOBALS['linpha']->sql->config->reloadConfig(); + linSysLog(i18n("Successfully updated data.")); + break; + } + + } + catch(Exception $error) + { + linSysLog("Error: ".$error -> getMessage()); + } +} + +?> +<h2><?php echo i18n("Change User Information"); ?></h2> +<form method="POST" action="./?cat=settings"> +<?php +LinAdmin::printAdminConfig('text',i18n("Username"),'username',$data['username']); +LinAdmin::printAdminConfig('text',i18n("Display Name"),'display_name',$data['display_name']); +LinAdmin::printAdminConfig('text',i18n("Email"),'user_email',$data['user_email']); +?> +<input type="hidden" name="cmd" value="saveuserinfos" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="button" /> +</form> +<hr /> + +<h2><?php echo i18n("Change Password"); ?></h2> +<form method="POST" name="change_password" action="./?cat=settings"> +<?php +LinAdmin::printAdminConfig('password',i18n("Old Password"),'old_password',''); +LinAdmin::printAdminConfig('password',i18n("New Password"),'new_password',''); +LinAdmin::printAdminConfig('password',i18n("Repeat New Password"),'new_password2',''); +?> +<input type="hidden" name="cmd" value="changepw" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="button" onclick="return checkPassLength();" /> +</form> +<script language="JavaScript" type="text/javascript"> +function checkPassLength() +{ + if(document.change_password.new_password.value.length <3 ) + { + alert ('<?php echo i18n("Password To Short"); ?>'); + document.change_password.new_password.focus(); + return false; + } +} +</script> +<hr /> + +<h2><?php echo i18n("Change User Settings"); ?></h2> +<form method="POST" action="./?cat=settings"> +<?php +foreach($options AS $value) +{ + if(in_array($value,$radio_options)) + { + $type = 'radio'; + } + else + { + $type = 'text'; + } + LinAdmin::printAdminConfig($type,$value,$value,$GLOBALS['linpha']->sql->config->value[$value]); +} +?> +<input type="hidden" name="cmd" value="saveconfig" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="button" /> +</form> + +<form method="POST" action="./?cat=settings"> +<input type="hidden" name="cmd" value="loaddefault" /> +<input type="submit" name="submit" value="<?php echo i18n("Load default values"); ?>" class="button" /> +</form> +<hr /> + +<?php +$linpha->template->output['settings'] = ob_get_clean(); + +$linpha->template->setModuleName('settings'); +$linpha->template->URL_full = LINPHA_DIR.'/?cat=settings'; +$linpha->template->output['title'] = i18n("Settings"); +include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); +?> \ No newline at end of file Modified: trunk/linpha2/linpha2.specs.txt =================================================================== --- trunk/linpha2/linpha2.specs.txt 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/linpha2.specs.txt 2006-08-27 22:16:12 UTC (rev 4561) @@ -43,13 +43,13 @@ - all own methods get a "lin" prefix, class names start Uppercase - would be nice if we can define some coding format - wether to use single or doulbe quotes in html attributes (maybe..) - - which function to use to eoncode html data + - which function to use to encode html data all php output where quotes and other signs may break the html design (except ids and md5sums) needs to be encoded which function to use? - urlencode() -> doesn't work in <a href="" title="<?php echo $title; ?>"> - rawurlencode() - - htmlspecialchars() + - htmlspecialchars() -> will use this: htmlspecialchars($str, ENT_QUOTES) - htmlentities() - smart_htmlspecialchars() from phpmeta used several times in forms in linpha1 ? Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/templates/default/global.html.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -129,7 +129,7 @@ <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&slideshow=play"><img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png'; ?>" border="0" title="<?php echo i18n("Play Slideshow"); ?>" /></a> </div> <ul> - <li><a href="./admin/"><?php echo i18n("My Settings"); ?></a></li> + <li><a href="./?cat=settings"><?php echo i18n("My Settings"); ?></a></li> </ul> <?php $GLOBALS['linpha']->template->printMenu("Admin","./admin/"); ?> </div> Added: trunk/linpha2/templates/default/settings.html.php =================================================================== --- trunk/linpha2/templates/default/settings.html.php (rev 0) +++ trunk/linpha2/templates/default/settings.html.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -0,0 +1,19 @@ +<div id="divmain"> + <div class="roundtop"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + + <div id="main"> + + +<?php +echo $GLOBALS['linpha']->template->output['settings']; +?> + + + </div> + + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-08-28 15:09:49
|
Revision: 4562 Author: fangehrn Date: 2006-08-28 08:09:39 -0700 (Mon, 28 Aug 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4562&view=rev Log Message: ----------- 2006-08-28 flo * fixed php notice Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.sql.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-08-27 22:16:12 UTC (rev 4561) +++ trunk/linpha2/ChangeLog 2006-08-28 15:09:39 UTC (rev 4562) @@ -1,3 +1,6 @@ +2006-08-28 flo + * fixed php notice + 2006-08-27 flo * fixed image rotate with gdlib * implemented user settings Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-27 22:16:12 UTC (rev 4561) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-28 15:09:39 UTC (rev 4562) @@ -343,12 +343,15 @@ * this has also to be here because the session isn't started yet in reloadConfig() * but also has to be in reloadConfig() if it will be called during the script */ - $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . - "FROM ".PREFIX."config WHERE user_id = '".$_SESSION['user_id']."'"); - - while($data = $query->FetchRow(ADODB_FETCH_NUM)) + if(isset($_SESSION['user_id'])) { - $GLOBALS['linpha']->sql->config->value[$data['0']] = $data['1']; + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . + "FROM ".PREFIX."config WHERE user_id = '".$_SESSION['user_id']."'"); + + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + $GLOBALS['linpha']->sql->config->value[$data['0']] = $data['1']; + } } } // end function startSession This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-08-30 19:16:23
|
Revision: 4563 http://svn.sourceforge.net/linpha/?rev=4563&view=rev Author: fangehrn Date: 2006-08-30 12:16:00 -0700 (Wed, 30 Aug 2006) Log Message: ----------- * working on admin config, may be broken now untill finished Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/index.php trunk/linpha2/admin/permissions_readwrite.php trunk/linpha2/admin/settings.php trunk/linpha2/admin/settings_all.php trunk/linpha2/admin/settings_features.php trunk/linpha2/admin/settings_layout.php trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.basket.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/ChangeLog 2006-08-30 19:16:00 UTC (rev 4563) @@ -1,3 +1,6 @@ +2006-08-30 flo + * working on admin config, may be broken now untill finished + 2006-08-28 flo * fixed php notice Modified: trunk/linpha2/admin/index.php =================================================================== --- trunk/linpha2/admin/index.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/admin/index.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -6,7 +6,6 @@ */ include_once(LINPHA_DIR.'/lib/include/common.php'); include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); - include_once(LINPHA_DIR.'/lib/classes/linpha.admin.class.php'); $linpha = new linpha(); $linpha->sql->startSession(); @@ -17,6 +16,10 @@ exit(1); } + include_once(LINPHA_DIR.'/lib/classes/linpha.admin.class.php'); + $LinAdmin = new LinAdmin(); + + /** * @todo admin permission check */ Modified: trunk/linpha2/admin/permissions_readwrite.php =================================================================== --- trunk/linpha2/admin/permissions_readwrite.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/admin/permissions_readwrite.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -15,7 +15,7 @@ <?php if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - LinAdmin::saveConfig( + $LinAdmin->saveConfig( Array( 'plugins_filemanager_enable' ) @@ -23,7 +23,7 @@ } - LinAdmin::printAdminConfig('radio',i18n("Enable Filemanager For Non-Admin Users"),'plugins_filemanager_enable'); + $LinAdmin->printAdminConfig('radio',i18n("Enable Filemanager For Non-Admin Users"),'plugins_filemanager_enable'); ?> <input type="hidden" name="cmd" value="saveconfig" /> Modified: trunk/linpha2/admin/settings.php =================================================================== --- trunk/linpha2/admin/settings.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/admin/settings.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -15,16 +15,6 @@ LinAdmin::printAdminMenu($array_menu,$cat2); -/** - * get system option names and values - */ -$query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config WHERE user_id = '0' ORDER by option_name"); -while($data = $query->FetchRow()) -{ - $options[] = $data['option_name']; - $option_value_system[$data['option_name']] = $data['option_value']; -} - switch($cat2) { case 'layout': Modified: trunk/linpha2/admin/settings_all.php =================================================================== --- trunk/linpha2/admin/settings_all.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/admin/settings_all.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -13,10 +13,10 @@ */ if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - LinAdmin::saveConfig($options); + $LinAdmin->saveConfig($LinAdmin->options); } -foreach($options AS $option_name) +foreach($LinAdmin->options AS $option_name) { if(in_array($option_name,$radio_options)) { @@ -26,6 +26,6 @@ { $type = 'text'; } - LinAdmin::printAdminConfig($type,$option_name,$option_name,$option_value_system[$option_name]); + $LinAdmin->printAdminConfig($type,$option_name,$option_name,$LinAdmin->option_value_system[$option_name]); } ?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_features.php =================================================================== --- trunk/linpha2/admin/settings_features.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/admin/settings_features.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -24,7 +24,7 @@ */ if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - LinAdmin::saveConfig(Array( + $LinAdmin->saveConfig(Array( 'sys_image_exif', 'sys_image_iptc', 'sys_image_xmp' @@ -32,9 +32,9 @@ } - LinAdmin::printAdminConfig('radio',i18n("Use EXIF"),'sys_image_exif',$option_value_system['sys_image_exif']); - LinAdmin::printAdminConfig('radio',i18n("Use IPTC"),'sys_image_iptc',$option_value_system['sys_image_iptc']); - LinAdmin::printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp',$option_value_system['sys_image_xmp']); + $LinAdmin->printAdminConfig('radio',i18n("Use EXIF"),'sys_image_exif',$option_value_system['sys_image_exif']); + $LinAdmin->printAdminConfig('radio',i18n("Use IPTC"),'sys_image_iptc',$option_value_system['sys_image_iptc']); + $LinAdmin->printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp',$option_value_system['sys_image_xmp']); break; } ?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/admin/settings_layout.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -34,7 +34,7 @@ */ if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - LinAdmin::saveConfig(Array('sys_style_home_usedefaultwelcometext', + $LinAdmin->saveConfig(Array('sys_style_home_usedefaultwelcometext', 'sys_style_home_nrrandomimages', 'sys_style_home_showalbums', 'sys_style_home_firstsortorder', @@ -68,17 +68,17 @@ <textarea name="welcometext" rows="10" cols="50"><?php echo htmlspecialchars($welcometxt,ENT_QUOTES); ?></textarea> <br /><br /><br /> <?php - LinAdmin::printAdminConfig('text',i18n("Nr Of Random Images (0 to disable)"),'sys_style_home_nrrandomimages',$option_value_system['sys_style_home_nrrandomimages']); - LinAdmin::printAdminConfig('radio',i18n("Show Browse By Date"),'sys_style_home_showbrowsebydate',$option_value_system['sys_style_home_showbrowsebydate']); - LinAdmin::printAdminConfig('radio',i18n("Show Albums On Home Site"),'sys_style_home_showalbums',$option_value_system['sys_style_home_showalbums']); - LinAdmin::printAdminConfig('select',i18n("Sort Order Of First Level Albums"),'sys_style_home_firstsortorder',$option_value_system['sys_style_home_firstsortorder'],getSortOrders()); + $LinAdmin->printAdminConfig('text',i18n("Nr Of Random Images (0 to disable)"),'sys_style_home_nrrandomimages',$option_value_system['sys_style_home_nrrandomimages']); + $LinAdmin->printAdminConfig('radio',i18n("Show Browse By Date"),'sys_style_home_showbrowsebydate',$option_value_system['sys_style_home_showbrowsebydate']); + $LinAdmin->printAdminConfig('radio',i18n("Show Albums On Home Site"),'sys_style_home_showalbums',$option_value_system['sys_style_home_showalbums']); + $LinAdmin->printAdminConfig('select',i18n("Sort Order Of First Level Albums"),'sys_style_home_firstsortorder',$option_value_system['sys_style_home_firstsortorder'],getSortOrders()); break; case 'thumb': - LinAdmin::printAdminConfig('radio',i18n("Show Subfolders Separate"),'sys_style_thumb_showsubfoldersseparate',$option_value_system['sys_style_thumb_showsubfoldersseparate']); + $LinAdmin->printAdminConfig('radio',i18n("Show Subfolders Separate"),'sys_style_thumb_showsubfoldersseparate',$option_value_system['sys_style_thumb_showsubfoldersseparate']); break; case 'image': - LinAdmin::printAdminConfig('text',i18n("Nr Of Previous/Next Thumbnails"),'sys_style_image_nrprevnextthumbs',$option_value_system['sys_style_image_nrprevnextthumbs']); + $LinAdmin->printAdminConfig('text',i18n("Nr Of Previous/Next Thumbnails"),'sys_style_image_nrprevnextthumbs',$option_value_system['sys_style_image_nrprevnextthumbs']); break; case 'others': Modified: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -25,6 +25,25 @@ class LinAdmin { +public $options; +public $options_value_system; + +/** + * constructor + */ +function __construct() +{ + /** + * get system option names and values and save in array for easier access + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config WHERE user_id = '0' ORDER by option_name"); + while($data = $query->FetchRow()) + { + $this->options[] = $data['option_name']; + $this->option_value_system[$data['option_name']] = $data['option_value']; + } +} + function printAdminMenu($array_menu,$active) { ?> @@ -142,14 +161,10 @@ /** * update system config array, used in admin/settings*.php */ - if(isset($GLOBALS['option_value_system'])) + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config WHERE user_id = '0' ORDER by option_name"); + while($data = $query->FetchRow()) { - - $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config WHERE user_id = '0' ORDER by option_name"); - while($data = $query->FetchRow()) - { - $GLOBALS['option_value_system'][$data['option_name']] = $data['option_value']; - } + $this->option_value_system[$data['option_name']] = $data['option_value']; } } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -409,27 +409,45 @@ $GLOBALS['linpha']->template->output['menu_Icons'] = ''; if($this->mode == 'thumb') { - $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=download">'. - '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png" border="0" title="'.i18n("Download Images").'" />' - .'</a>'."\n"; - $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=print">'. - '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png" border="0" title="'.i18n("Print Images").'" />' - .'</a>'."\n"; - $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=mail">'. - '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Images").'" />' - .'</a>'."\n"; + if( $GLOBALS['linpha']->sql->checkPermission('basket_download')) + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=download">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png" border="0" title="'.i18n("Download Images").'" />' + .'</a>'."\n"; + } + if( $GLOBALS['linpha']->sql->checkPermission('basket_print')) + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=print">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png" border="0" title="'.i18n("Print Images").'" />' + .'</a>'."\n"; + } + if( $GLOBALS['linpha']->sql->checkPermission('basket_mail')) + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=mail">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Images").'" />' + .'</a>'."\n"; + } } elseif($this->mode == 'image') { - $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.LINPHA_DIR.'/download_file.php?id='.$this->id_current.'">'. - '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png" border="0" title="'.i18n("Download Image").'" />' - .'</a>'."\n"; - $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this_with_checkout&checkout_as=print">'. - '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png" border="0" title="'.i18n("Print Image").'" />' - .'</a>'."\n"; - $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this_with_checkout&checkout_as=mail">'. - '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Image").'" />' - .'</a>'."\n"; + if( $GLOBALS['linpha']->sql->checkPermission('download')) + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.LINPHA_DIR.'/download_file.php?id='.$this->id_current.'">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png" border="0" title="'.i18n("Download Image").'" />' + .'</a>'."\n"; + } + if( $GLOBALS['linpha']->sql->checkPermission('basket_print')) + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this_with_checkout&checkout_as=print">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png" border="0" title="'.i18n("Print Image").'" />' + .'</a>'."\n"; + } + if( $GLOBALS['linpha']->sql->checkPermission('basket_mail')) + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this_with_checkout&checkout_as=mail">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Image").'" />' + .'</a>'."\n"; + } } } Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -491,7 +491,7 @@ { return true; } - + $data = $GLOBALS['linpha']->db->GetRow("SELECT permission FROM ".PREFIX."permissions " . "WHERE perm_type = '".LinSql::linAddslashes($perm_type)."'"); $array_permissions = explodeAndSlice(';',$data['permission']); Modified: trunk/linpha2/lib/modules/module.basket.php =================================================================== --- trunk/linpha2/lib/modules/module.basket.php 2006-08-28 15:09:39 UTC (rev 4562) +++ trunk/linpha2/lib/modules/module.basket.php 2006-08-30 19:16:00 UTC (rev 4563) @@ -55,7 +55,7 @@ /** * check basket permission */ - if(! $GLOBALS['linpha']->sql->checkPermission($_REQUEST['checkout_as'])) + if(! $GLOBALS['linpha']->sql->checkPermission('basket_'.$_REQUEST['checkout_as'])) { throw new Exception(i18n("No Access")); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-08-30 21:43:05
|
Revision: 4564 http://svn.sourceforge.net/linpha/?rev=4564&view=rev Author: fangehrn Date: 2006-08-30 14:42:46 -0700 (Wed, 30 Aug 2006) Log Message: ----------- * improved admin config Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/index.php trunk/linpha2/admin/settings_features.php trunk/linpha2/admin/settings_layout.php trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.settings.php trunk/linpha2/templates/default/global.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-08-30 19:16:00 UTC (rev 4563) +++ trunk/linpha2/ChangeLog 2006-08-30 21:42:46 UTC (rev 4564) @@ -1,5 +1,5 @@ 2006-08-30 flo - * working on admin config, may be broken now untill finished + * improved admin config 2006-08-28 flo * fixed php notice Modified: trunk/linpha2/admin/index.php =================================================================== --- trunk/linpha2/admin/index.php 2006-08-30 19:16:00 UTC (rev 4563) +++ trunk/linpha2/admin/index.php 2006-08-30 21:42:46 UTC (rev 4564) @@ -12,8 +12,10 @@ if(!$linpha->sql->isAdmin()) { - echo i18n("Only Admin Has Access To This Area"); - exit(1); + linSysLog(i18n("Please Login!")); + $_GET['cat'] = 'alb'; + include_once(LINPHA_DIR.'/lib/modules/module.albums.php'); + exit(); } include_once(LINPHA_DIR.'/lib/classes/linpha.admin.class.php'); Modified: trunk/linpha2/admin/settings_features.php =================================================================== --- trunk/linpha2/admin/settings_features.php 2006-08-30 19:16:00 UTC (rev 4563) +++ trunk/linpha2/admin/settings_features.php 2006-08-30 21:42:46 UTC (rev 4564) @@ -31,10 +31,9 @@ )); } - - $LinAdmin->printAdminConfig('radio',i18n("Use EXIF"),'sys_image_exif',$option_value_system['sys_image_exif']); - $LinAdmin->printAdminConfig('radio',i18n("Use IPTC"),'sys_image_iptc',$option_value_system['sys_image_iptc']); - $LinAdmin->printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp',$option_value_system['sys_image_xmp']); + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_image_exif'),'sys_image_exif',$option_value_system['sys_image_exif']); + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_image_iptc'),'sys_image_iptc',$option_value_system['sys_image_iptc']); + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_image_xmp'),'sys_image_xmp',$option_value_system['sys_image_xmp']); break; } ?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2006-08-30 19:16:00 UTC (rev 4563) +++ trunk/linpha2/admin/settings_layout.php 2006-08-30 21:42:46 UTC (rev 4564) @@ -9,6 +9,7 @@ $array_menu = Array( 'home' => Array('name' => 'Home Site', 'link' => 'settings_layout_home'), 'thumb' => Array('name' => 'Thumb View', 'link' => 'settings_layout_thumb'), + 'image' => Array('name' => 'Image View', 'link' => 'settings_layout_image'), 'others' => Array('name' => 'Others', 'link' => 'settings_layout_others') ); @@ -34,11 +35,13 @@ */ if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - $LinAdmin->saveConfig(Array('sys_style_home_usedefaultwelcometext', + $LinAdmin->saveConfig(Array( + 'sys_style_home_usedefaultwelcometext', 'sys_style_home_nrrandomimages', 'sys_style_home_showalbums', 'sys_style_home_firstsortorder', - 'sys_style_home_showbrowsebydate')); + 'sys_style_home_showbrowsebydate' + )); if(isset($_POST['welcometext']) && $_POST['welcometext'] != $welcometxt) { /** @@ -62,26 +65,48 @@ echo '<b>'.i18n("Welcome Text").'</b><br />'; - LinAdmin::printAdminConfig('radio',i18n("Use Default Welcome Text"),'sys_style_home_usedefaultwelcometext',$option_value_system['sys_style_home_usedefaultwelcometext']); + $LinAdmin->printAdminConfig('radio',i18n("Use Default Welcome Text"),'sys_style_home_usedefaultwelcometext',$LinAdmin->option_value_system['sys_style_home_usedefaultwelcometext']); ?> <textarea name="welcometext" rows="10" cols="50"><?php echo htmlspecialchars($welcometxt,ENT_QUOTES); ?></textarea> <br /><br /><br /> <?php - $LinAdmin->printAdminConfig('text',i18n("Nr Of Random Images (0 to disable)"),'sys_style_home_nrrandomimages',$option_value_system['sys_style_home_nrrandomimages']); - $LinAdmin->printAdminConfig('radio',i18n("Show Browse By Date"),'sys_style_home_showbrowsebydate',$option_value_system['sys_style_home_showbrowsebydate']); - $LinAdmin->printAdminConfig('radio',i18n("Show Albums On Home Site"),'sys_style_home_showalbums',$option_value_system['sys_style_home_showalbums']); - $LinAdmin->printAdminConfig('select',i18n("Sort Order Of First Level Albums"),'sys_style_home_firstsortorder',$option_value_system['sys_style_home_firstsortorder'],getSortOrders()); + $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('sys_style_home_nrrandomimages'),'sys_style_home_nrrandomimages',$LinAdmin->option_value_system['sys_style_home_nrrandomimages']); + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_style_home_showbrowsebydate'),'sys_style_home_showbrowsebydate',$LinAdmin->option_value_system['sys_style_home_showbrowsebydate']); + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_style_home_showalbums'),'sys_style_home_showalbums',$LinAdmin->option_value_system['sys_style_home_showalbums']); + $LinAdmin->printAdminConfig('select',$LinAdmin->getDescriptionByOptionName('sys_style_home_firstsortorder'),'sys_style_home_firstsortorder',$LinAdmin->option_value_system['sys_style_home_firstsortorder'],getSortOrders()); break; case 'thumb': - $LinAdmin->printAdminConfig('radio',i18n("Show Subfolders Separate"),'sys_style_thumb_showsubfoldersseparate',$option_value_system['sys_style_thumb_showsubfoldersseparate']); + + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + $LinAdmin->saveConfig(Array( + 'sys_style_thumb_showsubfoldersseparate' + )); + } + + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_style_thumb_showsubfoldersseparate'),'sys_style_thumb_showsubfoldersseparate',$LinAdmin->option_value_system['sys_style_thumb_showsubfoldersseparate']); break; case 'image': - $LinAdmin->printAdminConfig('text',i18n("Nr Of Previous/Next Thumbnails"),'sys_style_image_nrprevnextthumbs',$option_value_system['sys_style_image_nrprevnextthumbs']); + + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + $LinAdmin->saveConfig(Array( + 'sys_style_image_nrprevnextthumbs' + )); + } + + $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('sys_style_image_nrprevnextthumbs'),'sys_style_image_nrprevnextthumbs',$LinAdmin->option_value_system['sys_style_image_nrprevnextthumbs']); break; case 'others': + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + /*$LinAdmin->saveConfig(Array( + '' + ));*/ + } break; Modified: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php 2006-08-30 19:16:00 UTC (rev 4563) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2006-08-30 21:42:46 UTC (rev 4564) @@ -27,6 +27,7 @@ public $options; public $options_value_system; +public $description_array; /** * constructor @@ -42,6 +43,26 @@ $this->options[] = $data['option_name']; $this->option_value_system[$data['option_name']] = $data['option_value']; } + + $this->description_array = Array( + 'sys_image_exif' => "Use EXIF", + 'sys_image_iptc' => "Use IPTC", + 'sys_image_xmp' => "Use XMP", + 'sys_style_home_nrrandomimages' => "Nr Of Random Images (0 to disable)", + 'sys_style_home_showbrowsebydate' => "Show Browse By Date", + 'sys_style_home_showalbums' => "Show Albums On Home Site", + 'sys_style_home_firstsortorder' => "Sort Order Of First Level Albums", + 'sys_style_thumb_showsubfoldersseparate' => "Show Subfolders Separate", + 'sys_style_image_nrprevnextthumbs' => "Nr Of Previous/Next Thumbnails", + 'sys_lang' => "Language", + 'sys_lang_autolang' => "Autodetection of language", + 'sys_style_image_size' => "Image size", + 'sys_style_sortorder' => "Sort order", + 'sys_style_template' => "Template", + 'sys_style_thumb_nojsnrcols' => "Nr Cols if Javascript deactivated", + 'sys_style_thumb_nojsnrrows' => "Nr Rows if Javascript deactivated", + 'sys_style_thumb_size_display' => "Thumb size" + ); } function printAdminMenu($array_menu,$active) @@ -268,10 +289,19 @@ 'sys_style_home_showalbums', 'sys_style_home_usedefaultwelcometext', 'sys_style_thumb_showsubfoldersseparate', - 'sys_user_autologin' + 'sys_user_autologin', + 'plugins_filemanager_enable' ); } +function getDescriptionByOptionName( $option_name ) +{ + if( isset( $this->description_array[ $option_name ] ) ) + { + return i18n( $this->description_array[ $option_name ] ); + } +} + } // end class LinAdmin ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-30 19:16:00 UTC (rev 4563) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-30 21:42:46 UTC (rev 4564) @@ -58,7 +58,7 @@ include_once(LINPHA_DIR.'/lib/adodb/adodb-errorhandler.inc.php'); $sql_dir = ''; - include_once(LINPHA_DIR.'/var/config.dir.php'); + include(LINPHA_DIR.'/var/config.dir.php'); // no include_once if we reconnect from another directory... $include_file = LinFilesys::getFullPath( $sql_dir ) . '/config.sql.php'; if( file_exists($include_file) ) @@ -96,7 +96,6 @@ switch(DB_TYPE) { case "sqlite": - { if(isset($_SESSION['installmode1'])) { $sql_dir = LinFilesys::getFullPath($_SESSION['sql_dir']); @@ -107,14 +106,10 @@ $GLOBALS['linpha']->db->Connect(LinFilesys::getFullPath( $sql_dir ).'/database.sqlite'); } break; - } - case "mysql": - $GLOBALS['linpha']->db->Connect("$db_hostname:$db_port", $db_username, $db_password, $db_name); + $GLOBALS['linpha']->db->Connect("$db_hostname:$db_port", $db_username, $db_password, $db_name); break; - case "postgres": - { if(isset($db_password)) { $GLOBALS['linpha']->db->Connect("host=$db_hostname port=$db_port user=$db_username password=$db_password dbname=$db_name"); @@ -123,15 +118,10 @@ { $GLOBALS['linpha']->db->Connect("host=$db_hostname port=$db_port user=$db_username dbname=$db_name"); } - break; - } case "oci8po": - { - $GLOBALS['linpha']->db->PConnect($db_hostname, $db_username, $db_password, $db_name); - + $GLOBALS['linpha']->db->PConnect($db_hostname, $db_username, $db_password, $db_name); break; - } } if( !isset($GLOBALS['linpha']->db) OR !$GLOBALS['linpha']->db->isConnected() ) Modified: trunk/linpha2/lib/modules/module.settings.php =================================================================== --- trunk/linpha2/lib/modules/module.settings.php 2006-08-30 19:16:00 UTC (rev 4563) +++ trunk/linpha2/lib/modules/module.settings.php 2006-08-30 21:42:46 UTC (rev 4564) @@ -26,20 +26,23 @@ if(!defined('LINPHA_DIR')) { exit(1); } include_once(LINPHA_DIR.'/lib/classes/linpha.admin.class.php'); +$LinAdmin = new LinAdmin(); /** * check permissions */ if( ! $GLOBALS['linpha']->sql->isLoggedIn()) { - echo i18n("No Access!"); + linSysLog(i18n("Please Login!")); + $_GET['cat'] = 'alb'; + include_once(LINPHA_DIR.'/lib/modules/module.albums.php'); exit(); } /** * get user data */ - $data = $GLOBALS['linpha']->db->GetRow("SELECT username, password, display_name, user_email ". + $user_data = $GLOBALS['linpha']->db->GetRow("SELECT username, password, display_name, user_email ". "FROM ".PREFIX."users ". "WHERE id = '".$_SESSION['user_id']."'"); @@ -82,7 +85,7 @@ * check if username already exists * (only if it will be changed) */ - if( $data['username'] != $_POST['username'] ) + if( $user_data['username'] != $_POST['username'] ) { $query = $GLOBALS['linpha']->db->Execute("SELECT username FROM ".PREFIX."users " . "WHERE username = '".LinSql::linAddslashes($_POST['username'])."'"); @@ -112,9 +115,9 @@ /** * update data also for show in html form */ - $data['username'] = $_POST['username']; - $data['user_email'] = $_POST['user_email']; - $data['display_name'] = $_POST['display_name']; + $user_data['username'] = $_POST['username']; + $user_data['user_email'] = $_POST['user_email']; + $user_data['display_name'] = $_POST['display_name']; /** * update session variables @@ -130,7 +133,7 @@ /** * check if old password is correct */ - if( md5($_POST['old_password']) != $data['password'] ) + if( md5($_POST['old_password']) != $user_data['password'] ) { throw new Exception(i18n("Old password is not correct.")); } @@ -164,7 +167,7 @@ /** * save and reload config */ - LinAdmin::saveConfig($options,$_SESSION['user_id']); + $LinAdmin->saveConfig($options,$_SESSION['user_id']); linSysLog(i18n("Successfully updated data.")); break; case 'loaddefault': @@ -186,9 +189,9 @@ <h2><?php echo i18n("Change User Information"); ?></h2> <form method="POST" action="./?cat=settings"> <?php -LinAdmin::printAdminConfig('text',i18n("Username"),'username',$data['username']); -LinAdmin::printAdminConfig('text',i18n("Display Name"),'display_name',$data['display_name']); -LinAdmin::printAdminConfig('text',i18n("Email"),'user_email',$data['user_email']); +$LinAdmin->printAdminConfig('text',i18n("Username"),'username',$user_data['username']); +$LinAdmin->printAdminConfig('text',i18n("Display Name"),'display_name',$user_data['display_name']); +$LinAdmin->printAdminConfig('text',i18n("Email"),'user_email',$user_data['user_email']); ?> <input type="hidden" name="cmd" value="saveuserinfos" /> <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="button" /> @@ -198,9 +201,9 @@ <h2><?php echo i18n("Change Password"); ?></h2> <form method="POST" name="change_password" action="./?cat=settings"> <?php -LinAdmin::printAdminConfig('password',i18n("Old Password"),'old_password',''); -LinAdmin::printAdminConfig('password',i18n("New Password"),'new_password',''); -LinAdmin::printAdminConfig('password',i18n("Repeat New Password"),'new_password2',''); +$LinAdmin->printAdminConfig('password',i18n("Old Password"),'old_password',''); +$LinAdmin->printAdminConfig('password',i18n("New Password"),'new_password',''); +$LinAdmin->printAdminConfig('password',i18n("Repeat New Password"),'new_password2',''); ?> <input type="hidden" name="cmd" value="changepw" /> <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="button" onclick="return checkPassLength();" /> @@ -231,7 +234,7 @@ { $type = 'text'; } - LinAdmin::printAdminConfig($type,$value,$value,$GLOBALS['linpha']->sql->config->value[$value]); + $LinAdmin->printAdminConfig($type,$LinAdmin->getDescriptionByOptionName($value),$value,$GLOBALS['linpha']->sql->config->value[$value]); } ?> <input type="hidden" name="cmd" value="saveconfig" /> Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-08-30 19:16:00 UTC (rev 4563) +++ trunk/linpha2/templates/default/global.html.php 2006-08-30 21:42:46 UTC (rev 4564) @@ -72,12 +72,12 @@ <!-- menu --> <div id="menu"> <ul> - <li><a href="./"><?php echo i18n("Home"); ?></a></li> + <li><a href="<?php echo LINPHA_DIR; ?>/"><?php echo i18n("Home"); ?></a></li> </ul> <ul> <li><span><?php echo i18n("Search"); ?> </span> <ul> - <li><a href="./?cat=search"><?php echo i18n("Extended Search"); ?></a></li> + <li><a href="<?php echo LINPHA_DIR; ?>/?cat=search"><?php echo i18n("Extended Search"); ?></a></li> <li> <div> <form method="GET" action="<?php echo LINPHA_DIR; ?>/?cat=search"> @@ -129,9 +129,9 @@ <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&slideshow=play"><img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png'; ?>" border="0" title="<?php echo i18n("Play Slideshow"); ?>" /></a> </div> <ul> - <li><a href="./?cat=settings"><?php echo i18n("My Settings"); ?></a></li> + <li><a href="<?php echo LINPHA_DIR; ?>/?cat=settings"><?php echo i18n("My Settings"); ?></a></li> </ul> - <?php $GLOBALS['linpha']->template->printMenu("Admin","./admin/"); ?> + <?php $GLOBALS['linpha']->template->printMenu("Admin",LINPHA_DIR."/admin/"); ?> </div> <div style="clear: both;"></div> <!-- end menu --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-09-25 21:07:34
|
Revision: 4566 http://svn.sourceforge.net/linpha/?rev=4566&view=rev Author: fangehrn Date: 2006-09-25 14:07:11 -0700 (Mon, 25 Sep 2006) Log Message: ----------- * some minor updates * improved admin/import Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/import.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/thumbnails.js trunk/linpha2/lib/modules/module.filemanager.php trunk/linpha2/templates/default/css/view_thumb.css trunk/linpha2/templates/default/global.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/ChangeLog 2006-09-25 21:07:11 UTC (rev 4566) @@ -1,3 +1,7 @@ +2006-09-25 flo + * some minor updates + * improved admin/import + 2006-08-30 flo * improved admin config Modified: trunk/linpha2/admin/import.php =================================================================== --- trunk/linpha2/admin/import.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/admin/import.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -1,12 +1,42 @@ <?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* 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; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * This file updates the database + * @package Import + */ + if(!defined('LINPHA_DIR')) { exit(1); } -$array_meta = Array('exif','iptc','xmp'); +/** + * try it, it works sometimes + */ +ini_set("max_execution_time", "6000"); +$array_meta = Array('exif','iptc','xmp'); if( isset($_POST['cmd']) && $_POST['cmd']=='import') { + echo '<h1>'.i18n("Running Import...").'</h1><br />'; + if(!isset($_REQUEST['album_select']) OR $_REQUEST['album_select'][0]=='all') { $all_albums = true; @@ -22,7 +52,7 @@ */ if($_REQUEST['index_import']=='index') { - echo i18n("Running Import...").'<br />'; + echo '<h2>'.i18n("Directory Import").'</h2><br />'; if($all_albums) { echo i18n("Parsing All Directories...").'<br />'; @@ -56,9 +86,9 @@ * we would have to take care to the script backwards, * that means first of the depest subfolder until we're on top */ - if($_REQUEST['index_thumbnails']!='no') + if($_REQUEST['index_thumbnails']!='no' OR isset($_REQUEST['index_thumbnails_delete'])) { - echo i18n("Creating Thumbnails...").'<br />'; + echo '<h2>'.i18n("Thumbnails").'</h2><br />'; $thumbnail = new LinImage(); @@ -67,120 +97,176 @@ $_GET['force'] = true; } + /** + * all albums selected + */ if($all_albums) { - echo i18n("Parsing All Directories...").'<br />'; - echo i18n("Create Thumbnail"); - - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); - while($data = $query->FetchRow(ADODB_FETCH_NUM)) + /** + * delete thumbnails + */ + if( isset($_REQUEST['index_thumbnails_delete']) ) { - if( ! $thumbnail->createThumbnail($data[0]) ) + echo i18n("Delete All Existing Thumbnails...").'<br />'; + $thumbcachepath = LinSql::getPath('cache').'/thumb'; + LinFilesys::rm_rf( $thumbcachepath ); // all subfolders will automatically be recreated on each image access + if(file_exists($thumbcachepath)) { - echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; + echo i18n("Warning while deleting file/folder, check permissions!").'<br />'; } - if( ! $thumbnail->isCached ) + else { - echo " ".$data[0].","; + mkdir( $thumbcachepath ); } - flush(); } - + + /** + * set query string for create/recreate thumbnails + */ + if($_REQUEST['index_thumbnails']!='no') + { + echo '<h3>'.i18n("Parsing All Directories...").'</h3><br />'; + $createthumbquery = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); + } } - else + else // $all_albums == false -> not all directory selected { + /** + * go through each selected directory + */ foreach($_REQUEST['album_select'] AS $key=>$value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); - echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; - echo i18n("Create Thumbnail"); + echo '<h3>'.i18n("Parsing Directory:").' '.$data['name'].'</h3><br />'; - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE " . + $sql = "SELECT id FROM ".PREFIX."photos WHERE " . "parent_id = '".LinSql::linAddslashes($value)."' AND " . - "img_type <> 0 AND img_type <> 9999999"); - while($data = $query->FetchRow(ADODB_FETCH_NUM)) + "img_type <> 0 AND img_type <> 9999999"; + + /** + * delete thumbnails + */ + if( isset($_REQUEST['index_thumbnails_delete']) ) { - if( ! $thumbnail->createThumbnail($data[0]) ) + echo i18n("Delete Thumbnails"); + $query = $GLOBALS['linpha']->db->Execute($sql); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; + if( LinImage::deleteCachedThumbnail($data[0]) ) + { + echo " ".$data[0].","; + } } - if( ! $thumbnail->isCached ) - { - echo " ".$data[0].","; - } - flush(); + echo '<br />'; } + + /** + * set query string for create/recreate thumbnails + */ + if($_REQUEST['index_thumbnails']!='no') + { + $createthumbquery = $GLOBALS['linpha']->db->Execute($sql); + } } } + /** + * now create thumbnails, $query has been set previously + */ + if($_REQUEST['index_thumbnails']!='no') + { + echo i18n("Create Thumbnail"); + while($data = $createthumbquery->FetchRow(ADODB_FETCH_NUM)) + { + if( ! $thumbnail->createThumbnail($data[0]) ) + { + echo i18n("Error While Creating Thumbnail!")."<br />Error: ".$thumbnail->error_msg."<br />"; + } + if( ! $thumbnail->isCached ) // thumbnail wasn't cached -> now created! + { + echo " ".$data[0].","; + } + flush(); + } + echo '<br />'; + } + echo '<br /><br />'; } /** * exif, iptc, xmp + * + * if "Delete First" and "All albums" was selected, the whole table will be deleted */ include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); $MetaData = new MetaData(); foreach($array_meta AS $meta_value) { - if( isset( $_REQUEST['index_'.$meta_value] ) ) + if( isset( $_REQUEST['index_'.$meta_value] ) && + ( $_REQUEST['index_'.$meta_value] == 'index' OR isset($_REQUEST['index_'.$meta_value.'_delete']) ) ) { - echo i18n("Indexing Files...").' ('.strtoupper($meta_value).')<br />'; + echo '<h2>'.i18n("File Indexing").' ('.strtoupper($meta_value).')</h2><br />'; /** * get imgids to indexing, if reindex is selected: delete these entries first */ if($all_albums) { - echo i18n("Parsing All Directories...").'<br />'; + echo i18n("All Directories selected").'<br />'; $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); while($data = $query->FetchRow()) { - if( $_REQUEST['index_'.$meta_value] != 'no') - { - $array_meta_ids[$data['id']] = $data['md5sum']; - } - - if( isset($_REQUEST['index_'.$meta_value.'_delete'])) - { - $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value." WHERE md5sum = '".$data['md5sum']."'"); - } + $array_meta_ids[$data['id']] = $data['md5sum']; } - } else { + echo i18n("Directory selected:").' '; foreach($_REQUEST['album_select'] AS $key=>$value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); - echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; + echo $data['name'].', '; $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".PREFIX."photos WHERE " . "parent_id = '".LinSql::linAddslashes($value)."' AND " . "img_type <> 0 AND img_type <> 9999999"); while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - if( $_REQUEST['index_'.$meta_value] != 'no') - { - $array_meta_ids[$data['id']] = $data['md5sum']; - } - - if( isset($_REQUEST['index_'.$meta_value.'_delete'])) - { - $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value." WHERE md5sum = '".$data['md5sum']."'"); - } + $array_meta_ids[$data['id']] = $data['md5sum']; } } + echo '<br />'; } - + /** - * parse all ids + * delete first (if selected) */ - if(isset($array_meta_ids)) + if( isset($_REQUEST['index_'.$meta_value.'_delete']) ) { + if( $all_albums ) + { + echo i18n("Delete all index data").'<br />'; + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value); + } + elseif( isset($array_meta_ids) ) + { + echo i18n("Delete index data of selected directories").'<br />'; + foreach($array_meta_ids AS $id=>$md5sum) + { + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value." WHERE md5sum = '".$md5sum."'"); + } + } + } + + /** + * index image, parse all saved ids + */ + if( isset($array_meta_ids) && $_REQUEST['index_'.$meta_value] == 'index' ) + { $MetaData->setFields($meta_value); echo i18n("Index Image"); @@ -223,7 +309,7 @@ } -echo '<h2>'.i18n("Import").'</h2>'; +echo '<h1>'.i18n("Import").'</h1>'; echo i18n("Select Folders For Import/Update:"); ?> <br /> @@ -241,6 +327,7 @@ <?php echo i18n("Thumbnails").':'; ?> <br /> +<input type="checkbox" id="index_thumbnails_deletefirst" name="index_thumbnails_delete" value="delete" /><label for="index_thumbnails_deletefirst"> <?php echo i18n("Delete First"); ?></label><br /> <input type="radio" id="index_thumbnails_no" name="index_thumbnails" value="no" /><label for="index_thumbnails_no"> <?php echo i18n("No Create"); ?></label><br /> <input type="radio" id="index_thumbnails_index" name="index_thumbnails" value="create" checked="checked" /><label for="index_thumbnails_index"> <?php echo i18n("Create"); ?></label><br /> <input type="radio" id="index_thumbnails_reindex" name="index_thumbnails" value="recreate" /><label for="index_thumbnails_reindex"> <?php echo i18n("Re-create"); ?></label><br /> @@ -320,6 +407,8 @@ /** * exif, iptc, xmp + * + * nr images to index: (nr_total - nr_indexed) */ $nr_total = $GLOBALS['linpha']->db->GetRow("SELECT sum(stats_numbers) FROM ".PREFIX."photos WHERE parent_id = '0' GROUP BY parent_id"); foreach($array_meta AS $value) Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -49,9 +49,15 @@ /** * delete recurisvely - same as "rm -rf" * @todo should we really have such a dangerous function in linpha? + * @param string $path folder to be deleted + * @param boolean $followLinks delete also contents inside links */ function rm_rf($path,$followLinks=false) { + if(empty($path)) { + return false; + } + if( is_file($path) ) { @unlink( $path ); @@ -163,6 +169,8 @@ /** * if $path is absolute, input is just returned, if $path is relative, * the relative path starting from the linpha root directory is returned +* +* always removed ending '/' to have unified paths in linpha * * @author flo * @param string $path a path Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -464,6 +464,10 @@ * returns the full path to the cached image * in thumb mode, $id is the photoid * in image mode, $id is the cached photoid + * + * @param string $what 'thumb' or 'img' + * @param int $id image id + * @return string full path to cached image */ function getCachePath($what,$id) { @@ -485,6 +489,7 @@ * deleteCached thumbnail by id * * @param int $id id of thumb in database + * @return boolean false if there was no image, true if there was an image to delete */ function deleteCachedThumbnail($id) { @@ -494,9 +499,15 @@ { if( ! @unlink( $output ) ) { - linSysLog('Warning: '.$output.' cannot be deleted, check permissions'); + linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); } + + return true; } + else + { + return false; + } } /** @@ -515,7 +526,7 @@ { if( ! @unlink( $output ) ) { - linSysLog('Warning: '.$output.' cannot be deleted, check permissions'); + linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); } } } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -463,7 +463,9 @@ case 'recreate': if($GLOBALS['linpha']->sql->isAdmin()) { - LinImage::createThumbnail($this->id_current,$this->img_type,$force=true); + $thumbnail = new LinImage(); + $_GET['force'] = true; + $thumbnail->createThumbnail($this->id_current); } break; case 'rotate_left': Modified: trunk/linpha2/lib/classes/thumbnails.js =================================================================== --- trunk/linpha2/lib/classes/thumbnails.js 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/classes/thumbnails.js 2006-09-25 21:07:11 UTC (rev 4566) @@ -57,7 +57,7 @@ /** * set correct main height only if photos_per_page == auto */ -// document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; + document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; /** * calculate nr of photos per page (from select form) Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -183,7 +183,7 @@ <?php break; case 'delete': - echo i18n("Delete All The Following Files/Folders including contensts:").'<br />'; + echo i18n("Delete all the following files/folders including contents:").'<br />'; foreach($_REQUEST['checkedfiles'] AS $value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos " . Modified: trunk/linpha2/templates/default/css/view_thumb.css =================================================================== --- trunk/linpha2/templates/default/css/view_thumb.css 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/templates/default/css/view_thumb.css 2006-09-25 21:07:11 UTC (rev 4566) @@ -1,6 +1,6 @@ -#main { +/*#main { height: 85%; -} +}*/ /** * need this to calculate heigh of main div Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-09-08 17:22:43 UTC (rev 4565) +++ trunk/linpha2/templates/default/global.html.php 2006-09-25 21:07:11 UTC (rev 4566) @@ -121,17 +121,22 @@ <?php if( isset( $GLOBALS['linpha']->template->output['menu_More'] ) ) { $GLOBALS['linpha']->template->printMenu("More"); } ?> + + <!-- icons --> <div> - <!-- icons --> <?php if( isset( $GLOBALS['linpha']->template->output['menu_Icons'] ) ) { echo $GLOBALS['linpha']->template->output['menu_Icons']; } ?> <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&slideshow=play"><img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png'; ?>" border="0" title="<?php echo i18n("Play Slideshow"); ?>" /></a> </div> + + <?php if($GLOBALS['linpha']->sql->isLoggedIn()) { ?> + <!-- my settings and admin links --> <ul> <li><a href="<?php echo LINPHA_DIR; ?>/?cat=settings"><?php echo i18n("My Settings"); ?></a></li> </ul> <?php $GLOBALS['linpha']->template->printMenu("Admin",LINPHA_DIR."/admin/"); ?> + <?php } ?> </div> <div style="clear: both;"></div> <!-- end menu --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-02 19:10:29
|
Revision: 4567 http://svn.sourceforge.net/linpha/?rev=4567&view=rev Author: fangehrn Date: 2006-10-02 12:09:18 -0700 (Mon, 02 Oct 2006) Log Message: ----------- 2006-10-02 flo * working on an ajax image view... ;-) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/templates/default/view_thumb.head.php trunk/linpha2/templates/default/view_thumb.html.php Added Paths: ----------- trunk/linpha2/templates/default/view_thumb_static.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-09-25 21:07:11 UTC (rev 4566) +++ trunk/linpha2/ChangeLog 2006-10-02 19:09:18 UTC (rev 4567) @@ -1,3 +1,6 @@ +2006-10-02 flo + * working on an ajax image view... ;-) + 2006-09-25 flo * some minor updates * improved admin/import Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-09-25 21:07:11 UTC (rev 4566) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-02 19:09:18 UTC (rev 4567) @@ -51,6 +51,14 @@ { $this->orderby = getSqlSortOrder($GLOBALS['linpha']->sql->config->value['sys_style_sortorder']); + /** + * set usage of javascript + */ + if(isset($_GET['use_js'])) + { + $_SESSION['use_js'] = true; + } + if(isset($_GET['id']) && $_GET['id'] != 0) { /** @@ -569,8 +577,6 @@ */ function viewThumb() { - $GLOBALS['linpha']->template->setModuleName('view_thumb'); - $this->viewThumbSetSubFolders(); /** @@ -617,11 +623,10 @@ /** * switch between javascript */ - if(isset($_GET['use_js'])) + if(isset($_SESSION['use_js'])) { - $this->use_javascript = 1; - $GLOBALS['linpha']->template->URL_base .= '&use_js=1'; - $GLOBALS['linpha']->template->URL_full .= '&use_js=1'; + $GLOBALS['linpha']->template->setModuleName('view_thumb'); + $GLOBALS['linpha']->template->output['page_nr_left'] = ''; $GLOBALS['linpha']->template->output['page_nr_right'] = ''; $GLOBALS['linpha']->template->output['page_nr'] = ''; @@ -655,7 +660,8 @@ } else { - $this->use_javascript = 0; + $GLOBALS['linpha']->template->setModuleName('view_thumb_static'); + $GLOBALS['linpha']->template->overrideModule('css','view_thumb'); $this->viewThumbNojs(); } @@ -663,7 +669,7 @@ /** - * thumbnail view with javascript disabled + * thumbnail view with javascript disabled (static) * @uses LinImgView::viewThumb() */ function viewThumbNojs() @@ -710,7 +716,7 @@ } /** - * setup page numbers + * setup page numbers (only used if static) */ function viewThumbWritePageNumbers() { @@ -1051,7 +1057,7 @@ /** - * stuff used img and meta view + * stuff used Img and Meta view * @uses LinImageview::viewImg * @uses LinImageview:viewMeta */ Modified: trunk/linpha2/templates/default/view_thumb.head.php =================================================================== --- trunk/linpha2/templates/default/view_thumb.head.php 2006-09-25 21:07:11 UTC (rev 4566) +++ trunk/linpha2/templates/default/view_thumb.head.php 2006-10-02 19:09:18 UTC (rev 4567) @@ -1,4 +1,3 @@ -<?php if($GLOBALS['linpha']->imgview->use_javascript) { ?> <script language="JavaScript" type="text/javascript"> var tot_photos = <?php echo $GLOBALS['linpha']->imgview->tot_photos; ?>; var startup_page = 1; @@ -8,5 +7,4 @@ var photos_per_page = 'auto'; <?php echo $GLOBALS['linpha']->template->output['files_db']."\n"; ?> </script> -<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/classes/thumbnails.js"> </script> -<?php } ?> \ No newline at end of file +<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/classes/thumbnails.js"> </script> \ No newline at end of file Modified: trunk/linpha2/templates/default/view_thumb.html.php =================================================================== --- trunk/linpha2/templates/default/view_thumb.html.php 2006-09-25 21:07:11 UTC (rev 4566) +++ trunk/linpha2/templates/default/view_thumb.html.php 2006-10-02 19:09:18 UTC (rev 4567) @@ -1,17 +1,7 @@ <script language="JavaScript" type="text/javascript"> <!-- - <?php // javascript enabled - if($GLOBALS['linpha']->imgview->use_javascript) { - ?> - window.onresize = display_images; - <?php - } else { // javascript disabled - ?> - location.href = "<?php echo convert_amp($GLOBALS['linpha']->template->URL_full.'&use_js=1'); ?>"; - <?php - } - ?> + window.onresize = display_images; //--> </script> @@ -47,42 +37,15 @@ </div> <div id="main"> - - <?php // javascript disabled - if( ! $GLOBALS['linpha']->imgview->use_javascript && isset($GLOBALS['linpha']->imgview->photos_show)) - { - for($i=1; list($key,$value) = each($GLOBALS['linpha']->imgview->photos_show); $i++) - { - // add clear float to last div on row - if( ($i-1) % $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrcols'] == 0) { - $str_clear = ' clear: left;'; - } else { - $str_clear = ''; - } - ?> - <div style="<?php echo $str_clear; ?>" class="imgdiv"> - <?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['before']; ?> - <a href="<?php echo LINPHA_DIR.'/?cat=alb&id='.$value['id']; ?>"><img height="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>" src="<?php echo LINPHA_DIR.'/get_thumb.php?id='.$value['id']; ?>" title="<?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['title']; ?>" class="img_thumbnail" /></a> - <?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['after']; ?> - </div> - <?php - } - } - ?> - + <noscript><h1><?php echo i18n("If you have just disabled Javascript, you will need to restart your browser."); ?></h1></noscript> </div> <div style="clear: both;"></div> + <div class="roundbottom"> <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> </div> - - <?php // javascript enabled - if($GLOBALS['linpha']->imgview->use_javascript) { - ?> - <script language="JavaScript" type="text/javascript"> - display_images(); - </script> - <?php - } - ?> \ No newline at end of file + +<script language="JavaScript" type="text/javascript"> +display_images(); +</script> \ No newline at end of file Added: trunk/linpha2/templates/default/view_thumb_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_thumb_static.html.php (rev 0) +++ trunk/linpha2/templates/default/view_thumb_static.html.php 2006-10-02 19:09:18 UTC (rev 4567) @@ -0,0 +1,68 @@ + +<script language="JavaScript" type="text/javascript"> +<!-- +location.href = "<?php echo convert_amp($GLOBALS['linpha']->template->URL_full.'&use_js=1'); ?>"; +//--> +</script> + +<!-- navigation --> +<?php if(isset($GLOBALS['linpha']->template->output['navigation']) && !empty($GLOBALS['linpha']->template->output['navigation'])) { ?> + <div id="divnavigation"> + <div class="roundtop"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + <div id="navigation"> + <?php echo $GLOBALS['linpha']->template->output['navigation']; ?> + </div> + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + </div> +<?php } ?> + +<div id="spacer_height"> +</div> + +<div id="divmain"> + <div class="roundtop"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + + <div id="divpage_nr"> + <div id="page_nr"> + <div id="page_nr_left" class="page_nr_divs"><?php echo $GLOBALS['linpha']->template->output['page_nr_left']; ?></div> + <div id="page_nr_middle" class="page_nr_divs page_nr_maindiv"><?php echo $GLOBALS['linpha']->template->output['page_nr']; ?></div> + <div id="page_nr_right" class="page_nr_divs"><?php echo $GLOBALS['linpha']->template->output['page_nr_right']; ?></div> + </div> + </div> + + <div id="main"> + + <?php + if( isset($GLOBALS['linpha']->imgview->photos_show)) + { + for($i=1; list($key,$value) = each($GLOBALS['linpha']->imgview->photos_show); $i++) + { + // add clear float to last div on row + if( ($i-1) % $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrcols'] == 0) { + $str_clear = ' clear: left;'; + } else { + $str_clear = ''; + } + ?> + <div style="<?php echo $str_clear; ?>" class="imgdiv"> + <?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['before']; ?> + <a href="<?php echo LINPHA_DIR.'/?cat=alb&id='.$value['id']; ?>"><img height="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>" src="<?php echo LINPHA_DIR.'/get_thumb.php?id='.$value['id']; ?>" title="<?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['title']; ?>" class="img_thumbnail" /></a> + <?php echo $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['after']; ?> + </div> + <?php + } + } + ?> + + </div> + <div style="clear: both;"></div> + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-02 19:34:17
|
Revision: 4569 http://svn.sourceforge.net/linpha/?rev=4569&view=rev Author: fangehrn Date: 2006-10-02 12:34:03 -0700 (Mon, 02 Oct 2006) Log Message: ----------- 2006-10-02 flo * working on an ajax image view... ;-) Modified Paths: -------------- trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/templates/default/view_img_static.html.php Added Paths: ----------- trunk/linpha2/templates/default/view_img.html.php Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-02 19:10:42 UTC (rev 4568) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-02 19:34:03 UTC (rev 4569) @@ -203,7 +203,7 @@ switch($_SESSION['mode_imageview']) { case 'img': - $this->viewImg(); + $this->viewImg(); /* will exit in xml mode */ break; case 'meta': $this->viewMeta(); @@ -1057,6 +1057,43 @@ /** + * setup image view + */ +function viewImg() +{ + $this->viewImgCommon(); + $this->viewImgComments(); + + if($_SESSION['use_js']) + { + $GLOBALS['linpha']->template->setModuleName('view_img'); + + if(isset($_GET['xml'])) + { + $this->viewImgAjax(); + exit(); + } + } + else + { + $GLOBALS['linpha']->template->setModuleName('view_img_static'); + $GLOBALS['linpha']->template->overrideModule('css','view_img'); + } +} + +/** + * generate xml data for ajax image view + */ +function viewImgAjax() +{ + print_r($GLOBALS['linpha']->template->output); + + /** + * @todo fetch comments + */ +} + +/** * stuff used Img and Meta view * @uses LinImageview::viewImg * @uses LinImageview:viewMeta @@ -1075,15 +1112,12 @@ } } + /** - * setup image view + * get/save image comments */ -function viewImg() +function viewImgComments() { - $GLOBALS['linpha']->template->setModuleName('view_img'); - - $this->viewImgCommon(); - /** * image comments */ @@ -1241,8 +1275,7 @@ /** * set current image and thumb */ - $GLOBALS['linpha']->template->output['image'] = '<img id="mainimage" src="'.LINPHA_DIR.'/get_image.php?id=' - . $this->photos_filtered[$this->current_key]['id'] . '" />'; + $GLOBALS['linpha']->template->output['image'] = LINPHA_DIR.'/get_image.php?id=' . $this->photos_filtered[$this->current_key]['id']; $GLOBALS['linpha']->template->output['current_thumb'] = $this->viewImgThumbHtml( $this->current_key , 'current' ); } @@ -1252,7 +1285,8 @@ */ function viewMeta() { - $GLOBALS['linpha']->template->setModuleName('view_img'); + $GLOBALS['linpha']->template->setModuleName('view_img_static'); + $GLOBALS['linpha']->template->overrideModule('css','view_img'); $this->viewImgCommon(); Added: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php (rev 0) +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-02 19:34:03 UTC (rev 4569) @@ -0,0 +1,100 @@ +<?php if(isset($GLOBALS['linpha']->template->output['navigation']) && !empty($GLOBALS['linpha']->template->output['navigation'])) { ?> +<div id="navigation"> + <?php echo $GLOBALS['linpha']->template->output['navigation']; ?> +</div> +<?php } ?> + +<div id="divthumbnavi"> + <div class="roundtop"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + + <div id="thumbnavi"> + <div class="thumbnavi_prevthumb"> + <?php /*echo $GLOBALS['linpha']->template->output['prev_thumb'];*/ ?> + </div> + <?php /*echo $GLOBALS['linpha']->template->output['current_thumb'];*/ ?> + <div class="thumbnavi_nextthumb"> + <?php /*echo $GLOBALS['linpha']->template->output['next_thumb'];*/ ?> + </div> + </div> + + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> + +<div id="divmain"> + <div class="roundtop"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + <div id="main"> + <noscript><h1><?php echo i18n("If you have just disabled Javascript, you will need to restart your browser."); ?></h1></noscript> + + <!-- show image --> + <img id="mainimage" src="" /> + + <br /><br /> + + <!-- comments --> + <?php if($GLOBALS['linpha']->sql->checkPermission('metadata_comments')) { ?> + <!-- show add comment form --> + <div class="add_comment"> + <form action="<?php echo $GLOBALS['linpha']->template->URL_full; ?>" method="POST"> + <?php echo i18n("Add Comment"); ?>:<br /> + <div id="comment_div_text"> + <input type="text" id="comment_input_text" name="comment_text" value="" tabindex="1" size="40" maxlength="40" /> + <a href="javascript:open_textarea()">(+)</a> + </div> + <textarea style="display: none;" id="comment_textarea" name="comment_textarea" tabindex="1" rows="10" cols="50"></textarea> + <?php echo i18n("Name"); ?>: <input type="text" name="author" value="" tabindex="2" size="10" maxlength="40" /> + <input type="hidden" name="cmd" value="add_comment" /> + <input type="submit" name="submit" value="<?php echo i18n("submit"); ?>" /> + </form> + </div> + <script language="JavaScript" type="text/javascript"> + function open_textarea() + { + document.getElementById('comment_textarea').style.display = 'block'; + document.getElementById('comment_div_text').style.display = 'none'; + + document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; + } + </script> + + <br /><br /> + <?php } /* end if checkPermission('metadata_comments') */ ?> + + <!-- show image comments --> + <?php /*while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) { ?> + <div class="comments"> + <?php echo $data['meta_time']; ?> <?php echo htmlspecialchars($data['meta_author'],ENT_QUOTES); ?> + <br /> + <?php echo htmlspecialchars($data['meta_comment'],ENT_QUOTES); ?> + <br /><br /> + </div> + <?php } */?> + + </div> + + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> + +<div id="divright"> + <div class="roundtop"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + <div id="right"> + <?php + /*foreach($GLOBALS['linpha']->template->output['image_infos'] AS $value) + { + echo $value['name'].': '.$value['value'].'<br />'; + }*/ + ?> + </div> + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> \ No newline at end of file Modified: trunk/linpha2/templates/default/view_img_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_img_static.html.php 2006-10-02 19:10:42 UTC (rev 4568) +++ trunk/linpha2/templates/default/view_img_static.html.php 2006-10-02 19:34:03 UTC (rev 4569) @@ -1,3 +1,10 @@ + +<script language="JavaScript" type="text/javascript"> +<!-- +location.href = "<?php echo convert_amp($GLOBALS['linpha']->template->URL_full.'&use_js=1'); ?>"; +//--> +</script> + <?php if(isset($GLOBALS['linpha']->template->output['navigation']) && !empty($GLOBALS['linpha']->template->output['navigation'])) { ?> <div id="navigation"> <?php echo $GLOBALS['linpha']->template->output['navigation']; ?> @@ -35,7 +42,7 @@ } else { ?> <!-- show image --> - <?php echo $GLOBALS['linpha']->template->output['image']; ?> + <img id="mainimage" src="<?php echo $GLOBALS['linpha']->template->output['image']; ?>" /> <br /><br /> <!-- comments --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-03 06:05:52
|
Revision: 4570 http://svn.sourceforge.net/linpha/?rev=4570&view=rev Author: fangehrn Date: 2006-10-02 23:05:34 -0700 (Mon, 02 Oct 2006) Log Message: ----------- 2006-10-03 flo * working on an ajax image view... ;-) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/templates/default/view_img_static.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-02 19:34:03 UTC (rev 4569) +++ trunk/linpha2/ChangeLog 2006-10-03 06:05:34 UTC (rev 4570) @@ -1,3 +1,6 @@ +2006-10-03 flo + * working on an ajax image view... ;-) + 2006-10-02 flo * working on an ajax image view... ;-) Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2006-10-02 19:34:03 UTC (rev 4569) +++ trunk/linpha2/install/step4_selectdirectories.php 2006-10-03 06:05:34 UTC (rev 4570) @@ -99,7 +99,9 @@ </div> (-> <?php echo installLinRealpath( installGetFullPath($tmp_dir) ); ?>) <br /><br /> +<input type="hidden" name="cmd_step4" value="save"> + <?php $array_check = array( Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2006-10-02 19:34:03 UTC (rev 4569) +++ trunk/linpha2/install/step5_getlogin.php 2006-10-03 06:05:34 UTC (rev 4570) @@ -29,30 +29,34 @@ /** * validate settings */ -if(!isset($_POST['album_dir']) OR empty($_POST['album_dir']) OR - !isset($_POST['sql_dir']) OR empty($_POST['sql_dir']) OR - !isset($_POST['cache_dir']) OR empty($_POST['cache_dir']) OR - !isset($_POST['tmp_dir']) OR empty($_POST['tmp_dir']) ) +if(isset($_POST['cmd_step4'])) { - include_once(LINPHA_DIR.'/install/header_html.php'); - - echo tr("Validating Information")."... "; - echo failed_msg(); - echo "<br />".tr("Please Fill In All Fields").""; + if(!isset($_POST['album_dir']) OR empty($_POST['album_dir']) OR + !isset($_POST['sql_dir']) OR empty($_POST['sql_dir']) OR + !isset($_POST['cache_dir']) OR empty($_POST['cache_dir']) OR + !isset($_POST['tmp_dir']) OR empty($_POST['tmp_dir']) ) + { + include_once(LINPHA_DIR.'/install/header_html.php'); - echo "</form>"; - $show_next_button = false; + echo tr("Validating Information")."... "; + echo failed_msg(); + echo "<br />".tr("Please Fill In All Fields").""; + + echo "</form>"; + $show_next_button = false; + + include_once(LINPHA_DIR.'/install/footer.php'); + exit(); + } + else + { + /** + * save settings from previous page + */ + $dirs = initSessionValues(); + } - include_once(LINPHA_DIR.'/install/footer.php'); - exit(); -} - /** - * save settings from previous page - */ - $dirs = initSessionValues(); - - /** * goto manual mode */ if(isset($_SESSION['install_mode']) && $_SESSION['install_mode'] =="manual") @@ -60,49 +64,53 @@ header("Location: manual_install.php"); exit(); } + +} - include_once(LINPHA_DIR.'/install/header_html.php'); -/** - * validate writable directories - */ - echo "<h2>".tr("Checking Directory Permissions")."</h2><br />"; - -/** - * checking album directory - */ - echo tr("Album Directory")."... "; - if( is_dir( $dirs['album'] ) ) - { - if( is_writable( $dirs['album'] ) ) +if(isset($_POST['cmd_step4'])) +{ + /** + * validate writable directories + */ + echo "<h2>".tr("Checking Directory Permissions")."</h2><br />"; + + /** + * checking album directory + */ + echo tr("Album Directory")."... "; + if( is_dir( $dirs['album'] ) ) { - echo success_msg(); - echo '<br /> ('.$_SESSION['album_dir'].' => '.installLinRealpath( $dirs['album'] ).')'; + if( is_writable( $dirs['album'] ) ) + { + echo success_msg(); + echo '<br /> ('.$_SESSION['album_dir'].' => '.installLinRealpath( $dirs['album'] ).')'; + } + else + { + echo warning_msg(); + echo '<br /> ('.$_SESSION['album_dir'].' => '.installLinRealpath( $dirs['album'] ).')'; + echo "<br />".tr("Album Directory Not Writable. Some Features May Not Work")."<br />"; + } } else { - echo warning_msg(); - echo '<br /> ('.$_SESSION['album_dir'].' => '.installLinRealpath( $dirs['album'] ).')'; - echo "<br />".tr("Album Directory Not Writable. Some Features May Not Work")."<br />"; + echo failed_msg(); + echo '<br /> ('.$_SESSION['album_dir'].')'; + echo "<br />".tr("No Valid Directory Found")."!"; } - } - else - { - echo failed_msg(); - echo '<br /> ('.$_SESSION['album_dir'].')'; - echo "<br />".tr("No Valid Directory Found")."!"; - } - -/** - * checking sql, cache and tmp directory - */ - if(initInitialDirectories($dirs) != true) - { - $show_next_button = false; - include_once(LINPHA_DIR.'/install/footer.php'); - exit(); - } + + /** + * checking sql, cache and tmp directory + */ + if(initInitialDirectories($dirs) != true) + { + $show_next_button = false; + include_once(LINPHA_DIR.'/install/footer.php'); + exit(); + } +} ?> <br /><br /> <hr /> Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-02 19:34:03 UTC (rev 4569) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-03 06:05:34 UTC (rev 4570) @@ -1086,13 +1086,37 @@ */ function viewImgAjax() { - print_r($GLOBALS['linpha']->template->output); - - /** - * @todo fetch comments - */ +?> +<xml> +<?php +foreach($this->xmldata['prev_thumb'] AS $value) +{ + echo '<prev_thumb>'.$value.'</prev_thumb>'."\n"; } +foreach($this->xmldata['next_thumb'] AS $value) +{ + echo '<next_thumb>'.$value.'</next_thumb>'."\n"; +} +foreach($GLOBALS['linpha']->template->output['image_infos'] AS $value) +{ ?> +<meta> + <name><?php echo $value['name']; ?></name><value><?php echo $value['value']; ?></value> +</meta> +<?php +} + +while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) +{ ?> +<comment> + <time><?php echo $data['meta_time']; ?></time> + <author><?php echo htmlspecialchars($data['meta_author'],ENT_QUOTES); ?></author> + <text><?php echo htmlspecialchars($data['meta_comment'],ENT_QUOTES); ?></text> +</comment> +<?php } + +} // end viewImgAjax() + /** * stuff used Img and Meta view * @uses LinImageview::viewImg @@ -1255,7 +1279,14 @@ { if($this->current_key >= $i) { - $GLOBALS['linpha']->template->output['prev_thumb'] .= $this->viewImgThumbHtml( $this->current_key - $i , 'prevnext' ); + if(isset($_GET['xml'])) + { + $this->xmldata['prev_thumb'][] = $this->photos_filtered[$this->current_key - $i]['id']; + } + else + { + $GLOBALS['linpha']->template->output['prev_thumb'] .= $this->viewImgThumbHtml( $this->current_key - $i , 'prevnext' ); + } } } @@ -1267,7 +1298,14 @@ { if($this->current_key < ( count($this->photos_filtered) - ($i+1) ) ) { - $GLOBALS['linpha']->template->output['next_thumb'] .= $this->viewImgThumbHtml($this->current_key + ($i+1) ,'prevnext'); + if(isset($_GET['xml'])) + { + $this->xmldata['next_thumb'][] = $this->photos_filtered[$this->current_key + ($i+1)]['id']; + } + else + { + $GLOBALS['linpha']->template->output['next_thumb'] .= $this->viewImgThumbHtml( $this->current_key + ($i+1) , 'prevnext' ); + } } } @@ -1275,9 +1313,13 @@ /** * set current image and thumb */ - $GLOBALS['linpha']->template->output['image'] = LINPHA_DIR.'/get_image.php?id=' . $this->photos_filtered[$this->current_key]['id']; - - $GLOBALS['linpha']->template->output['current_thumb'] = $this->viewImgThumbHtml( $this->current_key , 'current' ); + if(isset($_GET['xml'])) + { + } + else + { + $GLOBALS['linpha']->template->output['current_thumb'] = $this->viewImgThumbHtml( $this->current_key , 'current' ); + } } /** Modified: trunk/linpha2/templates/default/view_img_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_img_static.html.php 2006-10-02 19:34:03 UTC (rev 4569) +++ trunk/linpha2/templates/default/view_img_static.html.php 2006-10-03 06:05:34 UTC (rev 4570) @@ -42,7 +42,7 @@ } else { ?> <!-- show image --> - <img id="mainimage" src="<?php echo $GLOBALS['linpha']->template->output['image']; ?>" /> + <img id="mainimage" src="<?php echo LINPHA_DIR.'/get_image.php?id='.$GLOBALS['linpha']->imgview->id_current; ?>" /> <br /><br /> <!-- comments --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-03 21:46:08
|
Revision: 4571 http://svn.sourceforge.net/linpha/?rev=4571&view=rev Author: fangehrn Date: 2006-10-03 14:45:49 -0700 (Tue, 03 Oct 2006) Log Message: ----------- 2006-10-03 flo * working on an ajax image view basic things will work now Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/templates/default/view_img.html.php Added Paths: ----------- trunk/linpha2/lib/classes/image.js trunk/linpha2/templates/default/view_img.head.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-03 06:05:34 UTC (rev 4570) +++ trunk/linpha2/ChangeLog 2006-10-03 21:45:49 UTC (rev 4571) @@ -1,5 +1,6 @@ 2006-10-03 flo - * working on an ajax image view... ;-) + * working on an ajax image view + basic things will work now 2006-10-02 flo * working on an ajax image view... ;-) Added: trunk/linpha2/lib/classes/image.js =================================================================== --- trunk/linpha2/lib/classes/image.js (rev 0) +++ trunk/linpha2/lib/classes/image.js 2006-10-03 21:45:49 UTC (rev 4571) @@ -0,0 +1,165 @@ +var http_request = false; + +function loadImage(imgid) { + + http_request = false; + + if (window.XMLHttpRequest) { // Mozilla, Safari,... + http_request = new XMLHttpRequest(); + if (http_request.overrideMimeType) { + http_request.overrideMimeType('text/xml'); + // zu dieser Zeile siehe weiter unten + } + } else if (window.ActiveXObject) { // IE + try { + http_request = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + http_request = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) {} + } + } + + if (!http_request) { + alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen'); + return false; + } + http_request.onreadystatechange = loadImageData; + http_request.open('GET', imagedata_url + '&id=' + imgid + '&xml', true); + http_request.send(null); + +} + +function loadImageData() { + + if (http_request.readyState == 4) { + if (http_request.status == 200) + { +// alert(http_request.responseText); + + var xmldoc = http_request.responseXML; + + /** + * set image source + */ + var imgid = xmldoc.getElementsByTagName('imgid').item(0).firstChild.data; + document.getElementById('mainimage').src = image_src + imgid; + + /** + * set meta data + */ + if(xmldoc.getElementsByTagName('meta').length > 0) + { + var DivRight = document.getElementById("right"); + DivRight.innerHTML = ''; + + for(var i = 0; i < xmldoc.getElementsByTagName('meta').length; i++) + { + var meta = xmldoc.getElementsByTagName('meta').item(i); + var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); + var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); + + DivRight.appendChild(metaname); + DivRight.appendChild(metavalue); + DivRight.appendChild( document.createElement("br") ); + } + } + + /** + * set current thumb + */ + DivCurrentThumb = document.getElementById('thumbnavi_currentthumb'); + DivCurrentThumb.innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; + + /** + * set prev thumbs + */ + DivPrevThumbs = document.getElementById('thumbnavi_prevthumb'); + DivPrevThumbs.innerHTML = ''; + if(xmldoc.getElementsByTagName('prevthumb').length > 0) + { + for(var i = 0; i < xmldoc.getElementsByTagName('prevthumb').length; i++) + { + var prevThumbId = xmldoc.getElementsByTagName('prevthumb').item(i).firstChild.data; + + var ElemImg = document.createElement("img"); + var myAttribute=document.createAttribute("class"); + myAttribute.nodeValue = 'img_prevnextthumb'; + ElemImg.setAttributeNode(myAttribute); + var myAttribute=document.createAttribute("src"); + myAttribute.nodeValue = thumb_src + prevThumbId; + ElemImg.setAttributeNode(myAttribute); + + var ElemA = document.createElement("a"); + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:loadImage(' + prevThumbId + ')'; + ElemA.setAttributeNode(myAttribute); + ElemA.appendChild(ElemImg); + + var ElemDiv = document.createElement("div"); + var myAttribute=document.createAttribute("class"); + myAttribute.nodeValue = 'thumbnavi_prevnextthumb'; + ElemDiv.setAttributeNode(myAttribute); + ElemDiv.appendChild(ElemA); + + DivPrevThumbs.appendChild(ElemDiv); + } + } + + /** + * set next thumbs + */ + DivNextThumbs = document.getElementById('thumbnavi_nextthumb'); + DivNextThumbs.innerHTML = ''; + if(xmldoc.getElementsByTagName('nextthumb').length > 0) + { + for(var i = 0; i < xmldoc.getElementsByTagName('nextthumb').length; i++) + { + var nextThumbId = xmldoc.getElementsByTagName('nextthumb').item(i).firstChild.data; + + var ElemImg = document.createElement("img"); + var myAttribute=document.createAttribute("class"); + myAttribute.nodeValue = 'img_prevnextthumb'; + ElemImg.setAttributeNode(myAttribute); + var myAttribute=document.createAttribute("src"); + myAttribute.nodeValue = thumb_src + nextThumbId; + ElemImg.setAttributeNode(myAttribute); + + var ElemA = document.createElement("a"); + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:loadImage(' + nextThumbId + ')'; + ElemA.setAttributeNode(myAttribute); + ElemA.appendChild(ElemImg); + + var ElemDiv = document.createElement("div"); + var myAttribute=document.createAttribute("class"); + myAttribute.nodeValue = 'thumbnavi_prevnextthumb'; + ElemDiv.setAttributeNode(myAttribute); + ElemDiv.appendChild(ElemA); + + DivNextThumbs.appendChild(ElemDiv); + } + } + +// <div class="thumbnavi_prevnextthumb"><a href="./?cat=alb&id=9"><img class="img_prevnextthumb" src="./get_thumb.php?id=9" /></a><br />0067_img.jpg</div> + +// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(0); +// alert(xmldoc.getElementsByTagName('nextthumb').length); +// alert(nextthumb.firstChild.data); + +// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(1); +// alert(nextthumb.firstChild.data); + +// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(2); +// alert(nextthumb.firstChild.data); + +// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(3); +// alert(nextthumb.firstChild.data); + + + } else { + alert('Bei dem Request ist ein Problem aufgetreten.'); + } + } + +} \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-03 06:05:34 UTC (rev 4570) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-03 21:45:49 UTC (rev 4571) @@ -1086,35 +1086,45 @@ */ function viewImgAjax() { -?> -<xml> + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + ?> +<root> +<imgid><?php echo $this->id_current; ?></imgid> <?php -foreach($this->xmldata['prev_thumb'] AS $value) -{ - echo '<prev_thumb>'.$value.'</prev_thumb>'."\n"; -} -foreach($this->xmldata['next_thumb'] AS $value) -{ - echo '<next_thumb>'.$value.'</next_thumb>'."\n"; -} + if(isset($this->xmldata['prev_thumb'])) { + foreach($this->xmldata['prev_thumb'] AS $value) + { + echo '<prevthumb>'.$value.'</prevthumb>'."\n"; + } + } + if(isset($this->xmldata['next_thumb'])) { + foreach($this->xmldata['next_thumb'] AS $value) + { + echo '<nextthumb>'.$value.'</nextthumb>'."\n"; + } + } -foreach($GLOBALS['linpha']->template->output['image_infos'] AS $value) -{ ?> + foreach($GLOBALS['linpha']->template->output['image_infos'] AS $value) + { ?> <meta> <name><?php echo $value['name']; ?></name><value><?php echo $value['value']; ?></value> </meta> <?php -} + } -while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) -{ ?> + while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) + { ?> <comment> <time><?php echo $data['meta_time']; ?></time> <author><?php echo htmlspecialchars($data['meta_author'],ENT_QUOTES); ?></author> <text><?php echo htmlspecialchars($data['meta_comment'],ENT_QUOTES); ?></text> </comment> -<?php } +<?php } ?> +</root> +<?php + } // end viewImgAjax() /** Added: trunk/linpha2/templates/default/view_img.head.php =================================================================== --- trunk/linpha2/templates/default/view_img.head.php (rev 0) +++ trunk/linpha2/templates/default/view_img.head.php 2006-10-03 21:45:49 UTC (rev 4571) @@ -0,0 +1,6 @@ +<script language="JavaScript" type="text/javascript"> +var imagedata_url = '<?php echo convert_amp($GLOBALS['linpha']->template->URL_base); ?>'; +var image_src = '<?php echo LINPHA_DIR.'/get_image.php?id='; ?>'; +var thumb_src = '<?php echo LINPHA_DIR.'/get_thumb.php?id='; ?>'; +</script> +<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/classes/image.js"> </script> \ No newline at end of file Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-10-03 06:05:34 UTC (rev 4570) +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-03 21:45:49 UTC (rev 4571) @@ -9,16 +9,32 @@ <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> +<?php /* <div id="thumbnavi"> <div class="thumbnavi_prevthumb"> - <?php /*echo $GLOBALS['linpha']->template->output['prev_thumb'];*/ ?> + <?php /*echo $GLOBALS['linpha']->template->output['prev_thumb']; </div> - <?php /*echo $GLOBALS['linpha']->template->output['current_thumb'];*/ ?> + <?php /*echo $GLOBALS['linpha']->template->output['current_thumb']; <div class="thumbnavi_nextthumb"> - <?php /*echo $GLOBALS['linpha']->template->output['next_thumb'];*/ ?> + <?php /*echo $GLOBALS['linpha']->template->output['next_thumb']; </div> </div> + + <a href="./?cat=alb&id=8"><img class="img_currentthumb" src="./get_thumb.php?id=8" /></a><br />0066_img.jpg + <div class="thumbnavi_prevnextthumb"><a href="./?cat=alb&id=9"><img class="img_prevnextthumb" src="./get_thumb.php?id=9" /></a><br />0067_img.jpg</div> + */ +?> + + <div id="thumbnavi"> + <div class="thumbnavi_prevthumb" id="thumbnavi_prevthumb"></div> + <div class="thumbnavi_currentthumb" id="thumbnavi_currentthumb"></div> + <div class="thumbnavi_nextthumb" id="thumbnavi_nextthumb"></div> + </div> + + + + <div class="roundbottom"> <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> @@ -44,7 +60,7 @@ <?php echo i18n("Add Comment"); ?>:<br /> <div id="comment_div_text"> <input type="text" id="comment_input_text" name="comment_text" value="" tabindex="1" size="40" maxlength="40" /> - <a href="javascript:open_textarea()">(+)</a> + <a href="javascript:openTextarea()">(+)</a> </div> <textarea style="display: none;" id="comment_textarea" name="comment_textarea" tabindex="1" rows="10" cols="50"></textarea> <?php echo i18n("Name"); ?>: <input type="text" name="author" value="" tabindex="2" size="10" maxlength="40" /> @@ -53,7 +69,7 @@ </form> </div> <script language="JavaScript" type="text/javascript"> - function open_textarea() + function openTextarea() { document.getElementById('comment_textarea').style.display = 'block'; document.getElementById('comment_div_text').style.display = 'none'; @@ -97,4 +113,8 @@ <div class="roundbottom"> <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> -</div> \ No newline at end of file +</div> + +<script language="JavaScript" type="text/javascript"> +loadImage(<?php echo $GLOBALS['linpha']->imgview->id_current; ?>); +</script> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-07 13:33:33
|
Revision: 4572 http://svn.sourceforge.net/linpha/?rev=4572&view=rev Author: fangehrn Date: 2006-10-07 06:32:45 -0700 (Sat, 07 Oct 2006) Log Message: ----------- adding javascript libraries prototype and scriptaculous working on ajax image view Modified Paths: -------------- trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/templates/default/css/global.css trunk/linpha2/templates/default/css/view_img.css trunk/linpha2/templates/default/view_img.head.php trunk/linpha2/templates/default/view_img.html.php trunk/linpha2/templates/default/view_img_static.html.php Added Paths: ----------- trunk/linpha2/lib/js/ trunk/linpha2/lib/js/LinImage.js trunk/linpha2/lib/js/LinSyslog.js trunk/linpha2/lib/js/LinThumbnails.js trunk/linpha2/lib/js/builder.js trunk/linpha2/lib/js/controls.js trunk/linpha2/lib/js/dragdrop.js trunk/linpha2/lib/js/effects.js trunk/linpha2/lib/js/prototype-1.5.0_rc1/ trunk/linpha2/lib/js/prototype-1.5.0_rc1/CHANGELOG trunk/linpha2/lib/js/prototype-1.5.0_rc1/LICENSE trunk/linpha2/lib/js/prototype-1.5.0_rc1/README trunk/linpha2/lib/js/prototype-1.5.0_rc1/Rakefile trunk/linpha2/lib/js/prototype.js trunk/linpha2/lib/js/scriptaculous-js-1.6.4/ trunk/linpha2/lib/js/scriptaculous-js-1.6.4/CHANGELOG trunk/linpha2/lib/js/scriptaculous-js-1.6.4/MIT-LICENSE trunk/linpha2/lib/js/scriptaculous-js-1.6.4/README trunk/linpha2/lib/js/scriptaculous.js trunk/linpha2/lib/js/slider.js trunk/linpha2/lib/js/unittest.js Removed Paths: ------------- trunk/linpha2/lib/classes/image.js trunk/linpha2/lib/classes/syslog.js trunk/linpha2/lib/classes/thumbnails.js Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/docs/dev/TODO.txt 2006-10-07 13:32:45 UTC (rev 4572) @@ -4,9 +4,8 @@ ## Small Todos -- Better Javascript detection - Currently the no-javscript site is loaded with a javascript location.href to the javascript enabled site - -> High Pageload, LinSysLog doesnt work +- add possibility to force static view for old browsers with half javascript working +- save image height and width in database to reduce file access in get_image.php and imgview() ? ## Big Todos @@ -43,6 +42,9 @@ DONE ==== +- Better Javascript detection + Currently the no-javscript site is loaded with a javascript location.href to the javascript enabled site + -> High Pageload, LinSysLog doesnt work - Filemanager (copy from linpha1) - Add support for Write-Permissions - Admin Deleted: trunk/linpha2/lib/classes/image.js =================================================================== --- trunk/linpha2/lib/classes/image.js 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/lib/classes/image.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -1,165 +0,0 @@ -var http_request = false; - -function loadImage(imgid) { - - http_request = false; - - if (window.XMLHttpRequest) { // Mozilla, Safari,... - http_request = new XMLHttpRequest(); - if (http_request.overrideMimeType) { - http_request.overrideMimeType('text/xml'); - // zu dieser Zeile siehe weiter unten - } - } else if (window.ActiveXObject) { // IE - try { - http_request = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - http_request = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (e) {} - } - } - - if (!http_request) { - alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen'); - return false; - } - http_request.onreadystatechange = loadImageData; - http_request.open('GET', imagedata_url + '&id=' + imgid + '&xml', true); - http_request.send(null); - -} - -function loadImageData() { - - if (http_request.readyState == 4) { - if (http_request.status == 200) - { -// alert(http_request.responseText); - - var xmldoc = http_request.responseXML; - - /** - * set image source - */ - var imgid = xmldoc.getElementsByTagName('imgid').item(0).firstChild.data; - document.getElementById('mainimage').src = image_src + imgid; - - /** - * set meta data - */ - if(xmldoc.getElementsByTagName('meta').length > 0) - { - var DivRight = document.getElementById("right"); - DivRight.innerHTML = ''; - - for(var i = 0; i < xmldoc.getElementsByTagName('meta').length; i++) - { - var meta = xmldoc.getElementsByTagName('meta').item(i); - var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); - var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); - - DivRight.appendChild(metaname); - DivRight.appendChild(metavalue); - DivRight.appendChild( document.createElement("br") ); - } - } - - /** - * set current thumb - */ - DivCurrentThumb = document.getElementById('thumbnavi_currentthumb'); - DivCurrentThumb.innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; - - /** - * set prev thumbs - */ - DivPrevThumbs = document.getElementById('thumbnavi_prevthumb'); - DivPrevThumbs.innerHTML = ''; - if(xmldoc.getElementsByTagName('prevthumb').length > 0) - { - for(var i = 0; i < xmldoc.getElementsByTagName('prevthumb').length; i++) - { - var prevThumbId = xmldoc.getElementsByTagName('prevthumb').item(i).firstChild.data; - - var ElemImg = document.createElement("img"); - var myAttribute=document.createAttribute("class"); - myAttribute.nodeValue = 'img_prevnextthumb'; - ElemImg.setAttributeNode(myAttribute); - var myAttribute=document.createAttribute("src"); - myAttribute.nodeValue = thumb_src + prevThumbId; - ElemImg.setAttributeNode(myAttribute); - - var ElemA = document.createElement("a"); - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:loadImage(' + prevThumbId + ')'; - ElemA.setAttributeNode(myAttribute); - ElemA.appendChild(ElemImg); - - var ElemDiv = document.createElement("div"); - var myAttribute=document.createAttribute("class"); - myAttribute.nodeValue = 'thumbnavi_prevnextthumb'; - ElemDiv.setAttributeNode(myAttribute); - ElemDiv.appendChild(ElemA); - - DivPrevThumbs.appendChild(ElemDiv); - } - } - - /** - * set next thumbs - */ - DivNextThumbs = document.getElementById('thumbnavi_nextthumb'); - DivNextThumbs.innerHTML = ''; - if(xmldoc.getElementsByTagName('nextthumb').length > 0) - { - for(var i = 0; i < xmldoc.getElementsByTagName('nextthumb').length; i++) - { - var nextThumbId = xmldoc.getElementsByTagName('nextthumb').item(i).firstChild.data; - - var ElemImg = document.createElement("img"); - var myAttribute=document.createAttribute("class"); - myAttribute.nodeValue = 'img_prevnextthumb'; - ElemImg.setAttributeNode(myAttribute); - var myAttribute=document.createAttribute("src"); - myAttribute.nodeValue = thumb_src + nextThumbId; - ElemImg.setAttributeNode(myAttribute); - - var ElemA = document.createElement("a"); - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:loadImage(' + nextThumbId + ')'; - ElemA.setAttributeNode(myAttribute); - ElemA.appendChild(ElemImg); - - var ElemDiv = document.createElement("div"); - var myAttribute=document.createAttribute("class"); - myAttribute.nodeValue = 'thumbnavi_prevnextthumb'; - ElemDiv.setAttributeNode(myAttribute); - ElemDiv.appendChild(ElemA); - - DivNextThumbs.appendChild(ElemDiv); - } - } - -// <div class="thumbnavi_prevnextthumb"><a href="./?cat=alb&id=9"><img class="img_prevnextthumb" src="./get_thumb.php?id=9" /></a><br />0067_img.jpg</div> - -// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(0); -// alert(xmldoc.getElementsByTagName('nextthumb').length); -// alert(nextthumb.firstChild.data); - -// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(1); -// alert(nextthumb.firstChild.data); - -// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(2); -// alert(nextthumb.firstChild.data); - -// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(3); -// alert(nextthumb.firstChild.data); - - - } else { - alert('Bei dem Request ist ein Problem aufgetreten.'); - } - } - -} \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-07 13:32:45 UTC (rev 4572) @@ -1070,7 +1070,7 @@ if(isset($_GET['xml'])) { - $this->viewImgAjax(); + $this->viewImgXml(); exit(); } } @@ -1084,13 +1084,18 @@ /** * generate xml data for ajax image view */ -function viewImgAjax() +function viewImgXml() { + + header('Content-type: text/xml'); echo '<?xml version="1.0" ?>'."\n"; ?> <root> <imgid><?php echo $this->id_current; ?></imgid> +<imgwidth><?php echo $this->org_width; ?></imgwidth> +<imgheight><?php echo $this->org_height; ?></imgheight> +<title><?php echo str_replace('<','<',$GLOBALS['linpha']->template->linpha_title." :: ".$GLOBALS['linpha']->template->output['title']); ?></title> <?php if(isset($this->xmldata['prev_thumb'])) { foreach($this->xmldata['prev_thumb'] AS $value) @@ -1134,6 +1139,18 @@ */ function viewImgCommon() { + /** + * get image width and height + * @todo see todo.txt wether to save width and height in database + */ + $this->src_file = LinSql::getFullImagePath( $this->id_current ); + list($this->org_width,$this->org_height,$org_type) = LinIdentify::linGetImageSize( $this->src_file ); + $this->max_width = $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; + $this->max_height = $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; + $array = LinImage::scaleToFit($this->org_width,$this->org_height,$this->max_width,$this->max_height); + $this->img_width = $array['w']; + $this->img_height = $array['h']; + $this->viewImgSetPrevNextThumb(); $this->viewImgStoreImageInformation(); Deleted: trunk/linpha2/lib/classes/syslog.js =================================================================== --- trunk/linpha2/lib/classes/syslog.js 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/lib/classes/syslog.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -1,24 +0,0 @@ -var window_is_open = false; -function toggleWindow() -{ - if( window_is_open ) - { - window_is_open = false; - - document.getElementById('sys_log').style.width = '20px'; - document.getElementById('sys_log').style.height = '20px'; - - document.getElementById('sys_log_text').style.visibility = 'hidden'; - } - else - { - window_is_open = true; - - document.getElementById('sys_log').style.width = 'auto'; - document.getElementById('sys_log').style.height = 'auto'; - - document.getElementById('sys_log_text').style.visibility = ''; - } -} - -toggleWindow(); \ No newline at end of file Deleted: trunk/linpha2/lib/classes/thumbnails.js =================================================================== --- trunk/linpha2/lib/classes/thumbnails.js 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/lib/classes/thumbnails.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -1,447 +0,0 @@ -/** - * javascript thumbnail viewer - * - * check performance: - var start = new Date().getTime(); - alert( (new Date().getTime() - start) ); - * - */ - -var current_page = startup_page -var nr_pages = 0; - -/** - * fine tuning - * better a space more than a space too less - */ -var img_spacer_width = 12; // used to calculate nr_cols -var img_spacer_height = 9; // used to calculate nr_rows -var img_div_spacer_height = 11; // used to calculate max-height of the image (depending how much text we would like to add) - -/** - * page numbers - */ -var pn_left = 3; -var pn_right = 3; -var pn_middle_left = 2; -var pn_middle_right = 4; -var pn_constant = pn_left + pn_right + pn_middle_left + pn_middle_right + 1; -var space_min = 2; // minimum space before replacing numbers with dots - - -function display_images() -{ - /** - * get some values - * browser incompatibilities... - * - * needs to be in display_images! - */ - var linInnerWidth, linInnerHeight; - if (window.innerHeight) // all except Explorer - { - linInnerWidth = self.innerWidth; - linInnerHeight = self.innerHeight; - } - else if (document.body && document.body.offsetWidth) - { - linInnerWidth = document.body.offsetWidth; - linInnerHeight = document.body.offsetHeight; - } - else - { - linInnerWidth = 500; // take a default value (@todo needs testing, maybe anyway never needed) - linInnerHeight = 300; // take a default value (needs teseting) - } - - /** - * set correct main height only if photos_per_page == auto - */ - document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; - - /** - * calculate nr of photos per page (from select form) - */ - switch( photos_per_page ) - { - case 'auto': - var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); - var nr_rows = Math.floor( document.getElementById('main')['offsetHeight'] / (tn_size + img_spacer_height + img_div_spacer_height) ); - var max_photos_per_page = nr_rows * nr_cols; - break; - case 'all': - var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); - var max_photos_per_page = tot_photos; - var nr_rows = Math.ceil(max_photos_per_page / nr_cols); - break; - default: - /** - * ceil max_photos_per_page to complet the row! - */ - var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); - var nr_rows = Math.ceil( photos_per_page / nr_cols); - var max_photos_per_page = nr_rows * nr_cols; - break; - } - /** - * at least on image per page - */ - (nr_cols == 0) ? nr_cols = 1 : ''; - (nr_rows == 0) ? nr_rows = 1 : ''; - (max_photos_per_page == 0) ? max_photos_per_page = nr_rows * nr_cols : ''; - - - /** - * prepare page numbers - */ - nr_pages = Math.ceil( tot_photos / max_photos_per_page ); - - - /** - * check if our current page still exists (maybe we changed the tn_size and now there arent so much pages anymore) - * (but not if current_page == 1 and nr_pages == 0) - */ - if(current_page > nr_pages && current_page != 1) - { - current_page = nr_pages; - } - - /** - * write page numbers - */ - write_page_numbers(); - - /** - * write divs - */ - var img_nr = 1; - var startup_img_nr = (current_page - 1)*max_photos_per_page; - - var DivMain = document.getElementById("main"); - DivMain.innerHTML=''; - divhtmltext = ''; - - for (i in img_ids) - { - if(i >= startup_img_nr && img_nr <= max_photos_per_page) - { - if( (img_nr-1) % nr_cols == 0) - { - styletext = ' style="clear:left;"'; - } - else - { - styletext = ''; - } - - divhtmltext += - '<div id="div' + i + '"' + styletext + ' class="imgdiv">' + - img_ids[i]['before'] + - '<a href="' + link_url + '&id=' + img_ids[i]['id'] + '">' + - '<img src="' + link_get_thumb + img_ids[i]['id'] + '"' + - ' height="' + tn_size + '" width="' + tn_size + '" ' + - ' alt="' + img_ids[i]['title'] + '" title="' + img_ids[i]['title'] + '"' + - ' class="img_thumbnail" />' + - '</a>' + img_ids[i]['after'] + '</div>'; - - /** - * flush buffer of divhtmltext on end of line - * with this buffer, we're 3-4 as fast as without !! - * see also http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation !! - */ - if( (img_nr-1) % nr_cols == 0) - { - DivMain.innerHTML += divhtmltext; - divhtmltext = ''; - } - - img_nr++; - } - } - - DivMain.innerHTML += divhtmltext; -} - -function goto_page(nr) -{ - current_page = nr; - display_images(); -} - -function write_page_numbers() -{ - /** - * create an array with page numbers - */ - pn_nrs = new Array(); - var nr_pages_shown = 0; - var start_gap = 0; - var end_gap = 0; - - /** - * get all pages which should be shown - */ - for(var i = 1; i <= nr_pages; i++) - { - if( pn_constant >= nr_pages // show all pages if we dont have much - || i <= pn_left // left side - || (i > ( nr_pages - pn_right ) ) // right side - || (i >= ( current_page - pn_middle_left ) && i <= current_page) // middle left - || (i <= ( current_page + pn_middle_right ) && i >= current_page) // middle right - ) - { - pn_nrs[i] = 1; - nr_pages_shown++; - - if(start_gap != 0 && end_gap == 0) // make sure this is done only with the first gap - { - end_gap = i-1; // used later to fill up this gap if needed - } - } - else - { - pn_nrs[i] = 0; - - if(start_gap == 0) // make sure this is done only with the first gap - { - start_gap = i; // used later to fill up this gap if needed - } - } - } - - /** - * add current_page to array, and increment nr_pages_shown if needed - */ - if(pn_nrs[current_page] == 0) - { - nr_pages_shown++; - } - pn_nrs[current_page] = 2; - - /** - * if with have a lot of pages, fill up the array so that we have all the time the same number of page numbers - */ - if( pn_constant > nr_pages_shown && nr_pages > pn_constant) - { - /** - * fill up the gap (there is only _one_ gap if we have to fill up the array) - * stop if we filled up enough the needed value, - * or stop if we are reaching the space_min (to prevent: 1 2 3 4 5 6 ... 8 9 10 11) - */ - beginn_with_startgap = 1; - while( pn_constant > nr_pages_shown && (end_gap - start_gap) >= space_min) - { - if(beginn_with_startgap == 1) - { - pn_nrs[start_gap] = 1; - nr_pages_shown++; - start_gap++; - - beginn_with_startgap = 0; - } - else //beginn_with_startgap = 0 - { - pn_nrs[end_gap] = 1; - nr_pages_shown++; - end_gap--; - - beginn_with_startgap = 1; - } - } - } - - /** - * search for small gaps (space_min) and fill up - */ - var counter = 0; - for(var i = 1; i <= nr_pages; i++) - { - if(pn_nrs[i] == 0) - { - counter++; - } - else - { - if(counter < space_min) - { - /** - * fill up gap - */ - for(var ii = (i-1); ii >= (i-counter); ii--) - { - pn_nrs[ii] = 1; - } - } - - /** - * reset counter - */ - counter = 0; - } - } - - - - - /** - * start writing out infos - */ - - /** - * write starting '<<' and '<' - */ - DivPageNr = document.getElementById("page_nr_left"); - DivPageNr.innerHTML=''; - - if(current_page != 1) - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page(1)'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode("<<"); - myText.appendChild(myText2); - DivPageNr.appendChild(myText); - } - else - { - var myText = document.createTextNode('<<'); - DivPageNr.appendChild(myText); - } - - var myText = document.createTextNode(' '); - DivPageNr.appendChild(myText); - - /** - * write starting '<' - */ - if(current_page != 1) - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page(current_page-1)'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode("<"); - myText.appendChild(myText2); - DivPageNr.appendChild(myText); - } - else - { - var myText = document.createTextNode('<'); - DivPageNr.appendChild(myText); - } - - /** - * write page numbers - */ - DivPageNr = document.getElementById("page_nr_middle"); - DivPageNr.innerHTML=''; - - for(var i = 1; i <= nr_pages; i++) - { - if(pn_nrs[i] != 0) - { - start_gap = 0; - - if(pn_nrs[i] == 2) - { - var myText = document.createTextNode(i); - } - else if(pn_nrs[i] == 1) - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page('+i+')'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode(i); - myText.appendChild(myText2); - } - DivPageNr.appendChild(myText); - - var myText = document.createTextNode(' '); - DivPageNr.appendChild(myText); - } - else - { - if(start_gap == 0) - { - start_gap = 1; - - var myText = document.createTextNode(' ... '); - DivPageNr.appendChild(myText); - } - } - } - - /** - * write ending '>' and '>>' - */ - DivPageNr = document.getElementById("page_nr_right"); - DivPageNr.innerHTML=''; - - if(current_page != nr_pages && nr_pages != 0) // need check nr_pages != 0 because we don't need links if nr_pages == 0! - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page(current_page+1)'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode(">"); - myText.appendChild(myText2); - DivPageNr.appendChild(myText); - } - else - { - var myText = document.createTextNode('>'); - DivPageNr.appendChild(myText); - } - - var myText = document.createTextNode(' '); - DivPageNr.appendChild(myText); - - /** - * write ending '>>' - */ - if(current_page != nr_pages && nr_pages != 0) // need check nr_pages != 0 because we don't need links if nr_pages == 0! - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page(nr_pages)'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode(">>"); - myText.appendChild(myText2); - DivPageNr.appendChild(myText); - } - else - { - var myText = document.createTextNode('>>'); - DivPageNr.appendChild(myText); - } -} - -function set_tn_size( tn_size_local ) -{ - tn_size = tn_size_local; - display_images(); -} - -function set_nr_images( photos_per_page_local) -{ - photos_per_page = photos_per_page_local; - display_images(); -} - -/** - * function view_source_code() removed - * use firefox extension "Aardvark" - * much nicer ;-) - */ \ No newline at end of file Added: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js (rev 0) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,310 @@ +var http_request = false; +var img_width; +var img_height; + +var colorinfoactive; +var colorinfonotactive; + + +function loadImage(imgid) { + + http_request = false; + + if (window.XMLHttpRequest) { // Mozilla, Safari,... + http_request = new XMLHttpRequest(); + if (http_request.overrideMimeType) { + http_request.overrideMimeType('text/xml'); + // zu dieser Zeile siehe weiter unten + } + } else if (window.ActiveXObject) { // IE + try { + http_request = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + http_request = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) {} + } + } + + if (!http_request) { + alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen'); + return false; + } + http_request.onreadystatechange = loadImageData; + http_request.open('GET', imagedata_url + '&id=' + imgid + '&xml', true); + http_request.send(null); + +} + +function loadImageData() { + + if (http_request.readyState == 4) { + if (http_request.status == 200) + { + setImageData(); + } else { + alert('Bei dem Request ist ein Problem aufgetreten.'); + } + } +} // end function loadImageData() + +function setImageData() +{ +// alert(http_request.responseText); + + /** + * hide meta text immediately + */ + hideImgInfoNow(); + + var xmldoc = http_request.responseXML; + + /** + * set image with source, width and height + */ + var imgid = xmldoc.getElementsByTagName('imgid').item(0).firstChild.data; + var orgwidth = xmldoc.getElementsByTagName('imgwidth').item(0).firstChild.data; + var orgheight = xmldoc.getElementsByTagName('imgheight').item(0).firstChild.data; + var sizearray = scaleToFit(orgwidth,orgheight,image_size,image_size,1); + imgwidth = sizearray[0]; + imgheight = sizearray[1]; + + var ElemImg = document.createElement("img"); + ElemImg.setAttribute('src',image_src + imgid + '&max_width=' + imgwidth + '&max_height=' + imgheight); + ElemImg.setAttribute('id','mainimage'); + ElemImg.setAttribute('width',imgwidth); + ElemImg.setAttribute('height',imgheight); + + var DivMainImage = document.getElementById('divimage'); + DivMainImage.innerHTML = ''; + DivMainImage.appendChild(ElemImg); + + /** + * set title + */ + var title = xmldoc.getElementsByTagName('title').item(0).firstChild.data; + document.getElementById('title').innerHTML = title; + + /** + * set current thumb + */ + var DivCurrentThumb = document.getElementById('thumbnavi_currentthumb'); + DivCurrentThumb.innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; + + /** + * set prev thumbs + */ + var DivPrevThumbs = document.getElementById('thumbnavi_prevthumb'); + DivPrevThumbs.innerHTML = ''; + if(xmldoc.getElementsByTagName('prevthumb').length > 0) + { + for(var i = 0; i < xmldoc.getElementsByTagName('prevthumb').length; i++) + { + var prevThumbId = xmldoc.getElementsByTagName('prevthumb').item(i).firstChild.data; + + var ElemImg = document.createElement("img"); + ElemImg.setAttribute('class','img_prevnextthumb'); + ElemImg.setAttribute('src',thumb_src + prevThumbId); + + var ElemA = document.createElement("a"); + ElemA.setAttribute('href','javascript:loadImage(' + prevThumbId + ')'); + ElemA.appendChild(ElemImg); + + var ElemDiv = document.createElement("div"); + ElemDiv.setAttribute('class','thumbnavi_prevnextthumb'); + ElemDiv.appendChild(ElemA); + + DivPrevThumbs.appendChild(ElemDiv); + } + } + + /** + * set next thumbs + */ + var DivNextThumbs = document.getElementById('thumbnavi_nextthumb'); + DivNextThumbs.innerHTML = ''; + if(xmldoc.getElementsByTagName('nextthumb').length > 0) + { + for(var i = 0; i < xmldoc.getElementsByTagName('nextthumb').length; i++) + { + var nextThumbId = xmldoc.getElementsByTagName('nextthumb').item(i).firstChild.data; + + var ElemImg = document.createElement("img"); + ElemImg.setAttribute('class','img_prevnextthumb'); + ElemImg.setAttribute('src',thumb_src + nextThumbId); + + var ElemA = document.createElement("a"); + ElemA.setAttribute('href','javascript:loadImage(' + nextThumbId + ')'); + ElemA.appendChild(ElemImg); + + var ElemDiv = document.createElement("div"); + ElemDiv.setAttribute('class','thumbnavi_prevnextthumb'); + ElemDiv.appendChild(ElemA); + + DivNextThumbs.appendChild(ElemDiv); + } + } + + /** + * set meta data + */ + if(xmldoc.getElementsByTagName('meta').length > 0) + { + var DivMeta = document.getElementById("divmeta"); + DivMeta.innerHTML = ''; + + for(var i = 0; i < xmldoc.getElementsByTagName('meta').length; i++) + { + var meta = xmldoc.getElementsByTagName('meta').item(i); + var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); + var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); + + DivMeta.appendChild(metaname); + DivMeta.appendChild(metavalue); + DivMeta.appendChild( document.createElement("br") ); + } + } + + /** + * set comments + */ + var DivComments = document.getElementById('divcomments'); + DivComments.innerHTML = ''; + if(xmldoc.getElementsByTagName('comment').length > 0) + { + for(var i = 0; i < xmldoc.getElementsByTagName('comment').length; i++) + { + var comment = xmldoc.getElementsByTagName('comment').item(i); + var commenttime = document.createTextNode( comment.getElementsByTagName('time').item(0).firstChild.data + ' ' ); + var commentauthor = document.createTextNode( comment.getElementsByTagName('author').item(0).firstChild.data ); + var commenttext = document.createTextNode( comment.getElementsByTagName('text').item(0).firstChild.data ); + + var ElemDiv = document.createElement("div"); + ElemDiv.setAttribute('class','comments'); + ElemDiv.appendChild(commenttime); + ElemDiv.appendChild(commentauthor); + ElemDiv.appendChild( document.createElement("br") ); + ElemDiv.appendChild(commenttext); + ElemDiv.appendChild( document.createElement("br") ); + + DivComments.appendChild(ElemDiv); + } + } + + /** + * set positions of info link + */ + var mainimage = document.getElementById('mainimage'); + var divinfolinks = document.getElementById('divinfolinks'); + divinfolinks.style.top = mainimage.offsetTop + mainimage.offsetHeight; + divinfolinks.style.left = mainimage.offsetLeft + mainimage.offsetWidth - divinfolinks.offsetWidth; +// alert(mainimage.offsetLeft + ' ' + mainimage.offsetTop + ' ' + mainimage.offsetWidth + ' ' + mainimage.offsetHeight); + + + +} // end function setImageData() + +function testsize() +{ + /** + * set positions of info link + */ + var mainimage = document.getElementById('mainimage'); + alert(mainimage.offsetLeft + ' ' + mainimage.offsetTop + ' ' + mainimage.offsetWidth + ' ' + mainimage.offsetHeight); + +} + +var showhide = 'hide'; +function showImgInfo() +{ + /** + * make visible/invisible + */ + if( showhide == 'hide' ) + { + showhide = 'show'; + + /** + * set position + */ + $('divmeta').style.top = $('mainimage').offsetTop + 50; + $('divmeta').style.left = $('mainimage').offsetLeft + 50; + + /** + * fade in + */ + new Effect.Appear('divmeta', { duration: 0.5, from: 0.0, to: 1.0 }); + new Effect.Appear('divimage', { duration: 0.5, from: 1.0, to: 0.3 }); + + document.getElementById('hrefinfolinks').style.color = colorinfonotactive; + } + else + { + showhide = 'hide'; + + new Effect.Appear('divmeta', { duration: 0.5, from: 1.0, to: 0.0 }); + new Effect.Appear('divimage', { duration: 0.5, from: 0.3, to: 1.3 }); + + document.getElementById('hrefinfolinks').style.color = colorinfoactive; + } +} +function hideImgInfoNow() +{ + $('divmeta').style.display = 'none'; + Element.setOpacity('divimage',1); + showhide = 'hide'; +} + + +/** + * with that function it is possible to set the colors in the css template (and not in javascript file) + */ +function setInfoColors() +{ + colorinfonotactive = document.getElementById('divinfolinks').style.color; + colorinfoactive = document.getElementById('hrefinfolinks').style.color; +} + +/** + * returns an array(width, height) with the correct size to fit + * in dst_w and dst_h + */ +function scaleToFit(src_w,src_h,dst_w,dst_h,no_increase) +{ + if(src_h == 0 || src_w == 0) + { + return new Array(0, 0); + } + + var img_relation = src_w / src_h; + + // Image is smaller than screen, no resize required + if ((src_w <= dst_w) && (src_h <= dst_h) && no_increase) + { + var returnarray = new Array(src_w, src_h); + } + else + { + /* + The image is way bigger than the screen, resize maintaining aspect ratio + + $src_w, $src_h: original image sizes + $dst_w, $dst_h: screen width and height + $img_relation = $src_w/$src_h; + + Either $dst_w decisive or $dst_h, usually $dst_h + */ + + var tmp_height = dst_w / img_relation; // calc the new height with screen width + if (tmp_height > dst_h) // we were wrong, it's still widther than screen -> $dst_h is decisive + { + var returnarray = new Array(Math.round(img_relation*dst_h), dst_h); + } + else + { + var returnarray = new Array(dst_w, tmp_height); + } + } + + return returnarray; +} \ No newline at end of file Added: trunk/linpha2/lib/js/LinSyslog.js =================================================================== --- trunk/linpha2/lib/js/LinSyslog.js (rev 0) +++ trunk/linpha2/lib/js/LinSyslog.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,24 @@ +var window_is_open = false; +function toggleWindow() +{ + if( window_is_open ) + { + window_is_open = false; + + document.getElementById('sys_log').style.width = '20px'; + document.getElementById('sys_log').style.height = '20px'; + + document.getElementById('sys_log_text').style.visibility = 'hidden'; + } + else + { + window_is_open = true; + + document.getElementById('sys_log').style.width = 'auto'; + document.getElementById('sys_log').style.height = 'auto'; + + document.getElementById('sys_log_text').style.visibility = ''; + } +} + +toggleWindow(); \ No newline at end of file Added: trunk/linpha2/lib/js/LinThumbnails.js =================================================================== --- trunk/linpha2/lib/js/LinThumbnails.js (rev 0) +++ trunk/linpha2/lib/js/LinThumbnails.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,447 @@ +/** + * javascript thumbnail viewer + * + * check performance: + var start = new Date().getTime(); + alert( (new Date().getTime() - start) ); + * + */ + +var current_page = startup_page +var nr_pages = 0; + +/** + * fine tuning + * better a space more than a space too less + */ +var img_spacer_width = 12; // used to calculate nr_cols +var img_spacer_height = 9; // used to calculate nr_rows +var img_div_spacer_height = 11; // used to calculate max-height of the image (depending how much text we would like to add) + +/** + * page numbers + */ +var pn_left = 3; +var pn_right = 3; +var pn_middle_left = 2; +var pn_middle_right = 4; +var pn_constant = pn_left + pn_right + pn_middle_left + pn_middle_right + 1; +var space_min = 2; // minimum space before replacing numbers with dots + + +function display_images() +{ + /** + * get some values + * browser incompatibilities... + * + * needs to be in display_images! + */ + var linInnerWidth, linInnerHeight; + if (window.innerHeight) // all except Explorer + { + linInnerWidth = self.innerWidth; + linInnerHeight = self.innerHeight; + } + else if (document.body && document.body.offsetWidth) + { + linInnerWidth = document.body.offsetWidth; + linInnerHeight = document.body.offsetHeight; + } + else + { + linInnerWidth = 500; // take a default value (@todo needs testing, maybe anyway never needed) + linInnerHeight = 300; // take a default value (needs teseting) + } + + /** + * set correct main height only if photos_per_page == auto + */ + document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; + + /** + * calculate nr of photos per page (from select form) + */ + switch( photos_per_page ) + { + case 'auto': + var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); + var nr_rows = Math.floor( document.getElementById('main')['offsetHeight'] / (tn_size + img_spacer_height + img_div_spacer_height) ); + var max_photos_per_page = nr_rows * nr_cols; + break; + case 'all': + var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); + var max_photos_per_page = tot_photos; + var nr_rows = Math.ceil(max_photos_per_page / nr_cols); + break; + default: + /** + * ceil max_photos_per_page to complet the row! + */ + var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); + var nr_rows = Math.ceil( photos_per_page / nr_cols); + var max_photos_per_page = nr_rows * nr_cols; + break; + } + /** + * at least on image per page + */ + (nr_cols == 0) ? nr_cols = 1 : ''; + (nr_rows == 0) ? nr_rows = 1 : ''; + (max_photos_per_page == 0) ? max_photos_per_page = nr_rows * nr_cols : ''; + + + /** + * prepare page numbers + */ + nr_pages = Math.ceil( tot_photos / max_photos_per_page ); + + + /** + * check if our current page still exists (maybe we changed the tn_size and now there arent so much pages anymore) + * (but not if current_page == 1 and nr_pages == 0) + */ + if(current_page > nr_pages && current_page != 1) + { + current_page = nr_pages; + } + + /** + * write page numbers + */ + write_page_numbers(); + + /** + * write divs + */ + var img_nr = 1; + var startup_img_nr = (current_page - 1)*max_photos_per_page; + + var DivMain = document.getElementById("main"); + DivMain.innerHTML=''; + divhtmltext = ''; + + for (i in img_ids) + { + if(i >= startup_img_nr && img_nr <= max_photos_per_page) + { + if( (img_nr-1) % nr_cols == 0) + { + styletext = ' style="clear:left;"'; + } + else + { + styletext = ''; + } + + divhtmltext += + '<div id="div' + i + '"' + styletext + ' class="imgdiv">' + + img_ids[i]['before'] + + '<a href="' + link_url + '&id=' + img_ids[i]['id'] + '">' + + '<img src="' + link_get_thumb + img_ids[i]['id'] + '"' + + ' height="' + tn_size + '" width="' + tn_size + '" ' + + ' alt="' + img_ids[i]['title'] + '" title="' + img_ids[i]['title'] + '"' + + ' class="img_thumbnail" />' + + '</a>' + img_ids[i]['after'] + '</div>'; + + /** + * flush buffer of divhtmltext on end of line + * with this buffer, we're 3-4 as fast as without !! + * see also http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation !! + */ + if( (img_nr-1) % nr_cols == 0) + { + DivMain.innerHTML += divhtmltext; + divhtmltext = ''; + } + + img_nr++; + } + } + + DivMain.innerHTML += divhtmltext; +} + +function goto_page(nr) +{ + current_page = nr; + display_images(); +} + +function write_page_numbers() +{ + /** + * create an array with page numbers + */ + pn_nrs = new Array(); + var nr_pages_shown = 0; + var start_gap = 0; + var end_gap = 0; + + /** + * get all pages which should be shown + */ + for(var i = 1; i <= nr_pages; i++) + { + if( pn_constant >= nr_pages // show all pages if we dont have much + || i <= pn_left // left side + || (i > ( nr_pages - pn_right ) ) // right side + || (i >= ( current_page - pn_middle_left ) && i <= current_page) // middle left + || (i <= ( current_page + pn_middle_right ) && i >= current_page) // middle right + ) + { + pn_nrs[i] = 1; + nr_pages_shown++; + + if(start_gap != 0 && end_gap == 0) // make sure this is done only with the first gap + { + end_gap = i-1; // used later to fill up this gap if needed + } + } + else + { + pn_nrs[i] = 0; + + if(start_gap == 0) // make sure this is done only with the first gap + { + start_gap = i; // used later to fill up this gap if needed + } + } + } + + /** + * add current_page to array, and increment nr_pages_shown if needed + */ + if(pn_nrs[current_page] == 0) + { + nr_pages_shown++; + } + pn_nrs[current_page] = 2; + + /** + * if with have a lot of pages, fill up the array so that we have all the time the same number of page numbers + */ + if( pn_constant > nr_pages_shown && nr_pages > pn_constant) + { + /** + * fill up the gap (there is only _one_ gap if we have to fill up the array) + * stop if we filled up enough the needed value, + * or stop if we are reaching the space_min (to prevent: 1 2 3 4 5 6 ... 8 9 10 11) + */ + beginn_with_startgap = 1; + while( pn_constant > nr_pages_shown && (end_gap - start_gap) >= space_min) + { + if(beginn_with_startgap == 1) + { + pn_nrs[start_gap] = 1; + nr_pages_shown++; + start_gap++; + + beginn_with_startgap = 0; + } + else //beginn_with_startgap = 0 + { + pn_nrs[end_gap] = 1; + nr_pages_shown++; + end_gap--; + + beginn_with_startgap = 1; + } + } + } + + /** + * search for small gaps (space_min) and fill up + */ + var counter = 0; + for(var i = 1; i <= nr_pages; i++) + { + if(pn_nrs[i] == 0) + { + counter++; + } + else + { + if(counter < space_min) + { + /** + * fill up gap + */ + for(var ii = (i-1); ii >= (i-counter); ii--) + { + pn_nrs[ii] = 1; + } + } + + /** + * reset counter + */ + counter = 0; + } + } + + + + + /** + * start writing out infos + */ + + /** + * write starting '<<' and '<' + */ + DivPageNr = document.getElementById("page_nr_left"); + DivPageNr.innerHTML=''; + + if(current_page != 1) + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page(1)'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode("<<"); + myText.appendChild(myText2); + DivPageNr.appendChild(myText); + } + else + { + var myText = document.createTextNode('<<'); + DivPageNr.appendChild(myText); + } + + var myText = document.createTextNode(' '); + DivPageNr.appendChild(myText); + + /** + * write starting '<' + */ + if(current_page != 1) + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page(current_page-1)'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode("<"); + myText.appendChild(myText2); + DivPageNr.appendChild(myText); + } + else + { + var myText = document.createTextNode('<'); + DivPageNr.appendChild(myText); + } + + /** + * write page numbers + */ + DivPageNr = document.getElementById("page_nr_middle"); + DivPageNr.innerHTML=''; + + for(var i = 1; i <= nr_pages; i++) + { + if(pn_nrs[i] != 0) + { + start_gap = 0; + + if(pn_nrs[i] == 2) + { + var myText = document.createTextNode(i); + } + else if(pn_nrs[i] == 1) + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page('+i+')'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode(i); + myText.appendChild(myText2); + } + DivPageNr.appendChild(myText); + + var myText = document.createTextNode(' '); + DivPageNr.appendChild(myText); + } + else + { + if(start_gap == 0) + { + start_gap = 1; + + var myText = document.createTextNode(' ... '); + DivPageNr.appendChild(myText); + } + } + } + + /** + * write ending '>' and '>>' + */ + DivPageNr = document.getElementById("page_nr_right"); + DivPageNr.innerHTML=''; + + if(current_page != nr_pages && nr_pages != 0) // need check nr_pages != 0 because we don't need links if nr_pages == 0! + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page(current_page+1)'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode(">"); + myText.appendChild(myText2); + DivPageNr.appendChild(myText); + } + else + { + var myText = document.createTextNode('>'); + DivPageNr.appendChild(myText); + } + + var myText = document.createTextNode(' '); + DivPageNr.appendChild(myText); + + /** + * write ending '>>' + */ + if(current_page != nr_pages && nr_pages != 0) // need check nr_pages != 0 because we don't need links if nr_pages == 0! + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page(nr_pages)'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode(">>"); + myText.appendChild(myText2); + DivPageNr.appendChild(myText); + } + else + { + var myText = document.createTextNode('>>'); + DivPageNr.appendChild(myText); + } +} + +function set_tn_size( tn_size_local ) +{ + tn_size = tn_size_local; + display_images(); +} + +function set_nr_images( photos_per_page_local) +{ + photos_per_page = photos_per_page_local; + display_images(); +} + +/** + * function view_source_code() removed + * use firefox extension "Aardvark" + * much nicer ;-) + */ \ No newline at end of file Added: trunk/linpha2/lib/js/builder.js =================================================================== --- trunk/linpha2/lib/js/builder.js (rev 0) +++ trunk/linpha2/lib/js/builder.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,119 @@ +// script.aculo.us builder.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006 + +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// +// See scriptaculous.js for full license. + +var Builder = { + NODEMAP: { + AREA: 'map', + CAPTION: 'table', + COL: 'table', + COLGROUP: 'table', + LEGEND: 'fieldset', + OPTGROUP: 'select', + OPTION: 'select', + PARAM: 'object', + TBODY: 'table', + TD: 'table', + TFOOT: 'table', + TH: 'table', + THEAD: 'table', + TR: 'table' + }, + // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken, + // due to a Firefox bug + node: function(elementName) { + elementName = elementName.toUpperCase(); + + // try innerHTML approach + var parentTag = this.NODEMAP[elementName] || 'div'; + var parentElement = document.createElement(parentTag); + try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 + parentElement.innerHTML = "<" + elementName + "></" + elementName + ">"; + } catch(e) {} + var element = parentElement.firstChild || null; + + // see if browser added wrapping tags + if(element && (element.tagName != elementName)) + element = element.getElementsByTagName(elementName)[0]; + + // fallback to createElement approach + if(!element) element = document.createElement(elementName); + + // abort if nothing could be created + if(!element) return; + + // attributes (or text) + if(arguments[1]) + if(this._isStringOrNumber(arguments[1]) || + (arguments[1] instanceof Array)) { + this._children(element, arguments[1]); + } else { + var attrs = this._attributes(arguments[1]); + if(attrs.length) { + try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 + parentElement.innerHTML = "<" +elementName + " " + + attrs + "></" + elementName + ">"; + } catch(e) {} + element = parentElement.firstChild || null; + // workaround firefox 1.0.X bug + if(!element) { + element = document.createElement(elementName); + for(attr in arguments[1]) + element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; + } + if(element.tagName != elementName) + element = parentElement.getElementsByTagName(elementName)[0]; + } + } + + // text, or array of children + if(arguments[2]) + this._children(element, arguments[2]); + + return element; + }, + _text: function(text) { + return document.createTextNode(text); + }, + _attributes: function(attributes) { + var attrs = []; + for(attribute in attributes) + attrs.push((attribute=='className' ? 'class' : attribute) + + '="' + attributes[attribute].toString().escapeHTML() + '"'); + return attrs.join(" "); + }, + _children: function(element, children) { + if(typeof children=='object') { // array can hold nodes and text + children.flatten().each( function(e) { + if(typeof e=='object') + element.appendChild(e) + else + if(Builder._isStringOrNumber(e)) + element.appendChild(Builder._text(e)); + }); + } else + if(Builder._isStringOrNumber(children)) + element.appendChild(Builder._text(children)); + }, + _isStringOrNumber: function(param) { + return(typeof param=='string' || typeof param=='number'); + }, + dump: function(scope) { + if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope + + var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + + "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + + "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ + "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ + "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ + "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); + + tags.each( function(tag){ + scope[tag] = function() { + return Builder.node.apply(Builder, [tag].concat($A(arguments))); + } + }); + } +} \ No newline at end of file Added: trunk/linpha2/lib/js/controls.js =================================================================== --- trunk/linpha2/lib/js/controls.js (rev 0) +++ trunk/linpha2/lib/js/controls.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,833 @@ +// script.aculo.us controls.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006 + +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) +// (c) 2005 Jon Tirsen (http://www.tirsen.com) +// Contributors: +// Richard Livsey +// Rahul Bhargava +// Rob Wills +// +// See scriptaculous.js for full license. + +// Autocompleter.Base handles all the autocompletion functionality +// that's independent of the data source for autocompletion. This +// includes drawing the autocompletion menu, observing keyboard +// and mouse events, and similar. +// +// Specific autocompleters need to provide, at the very least, +// a getUpdatedChoices function that will be invoked every time +// the text inside the monitored textbox changes. This method +// should get the text for which to provide autocompletion by +// invoking this.getToken(), NOT by directly accessing +// this.element.value. This is to allow incremental tokenized +// autocompletion. Specific auto-completion logic (AJAX, etc) +// belongs in getUpdatedChoices. +// +// Tokenized incremental autocompletion is enabled automatically +// when an autocompleter is instantiated with the 'tokens' option +// in the options parameter, e.g.: +// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); +// will incrementally autocomplete with a comma as the token. +// Additionally, ',' in the above example can be replaced with +// a token array, e.g. { tokens: [',', '\n'] } which +// enables autocompletion on multiple tokens. This is most +// useful when one of the tokens is \n (a newline), as it +// allows smart autocompletion after linebreaks. + +if(typeof Effect == 'undefined') + throw("controls.js requires including script.aculo.us' effects.js library"); + +var Autocompleter = {} +Autocompleter.Base = function() {}; +Autocompleter.Base.prototype = { + baseInitialize: function(element, update, options) { + this.element = $(element); + this.update = $(update); + this.hasFocus = false; + this.changed = false; + this.active = false; + this.index = 0; + this.entryCount = 0; + + if(this.setOptions) + this.setOptions(options); + else + this.options = options || {}; + + this.options.paramName = this.options.paramName || this.element.name; + this.options.tokens = this.options.tokens || []; + this.options.frequency = this.options.frequency || 0.4; + this.options.minChars = this.options.minChars || 1; + this.options.onShow = this.options.onShow || + function(element, update){ + if(!update.style.position || update.style.position=='absolute') { + update.style.position = 'absolute'; + Position.clone(element, update, { + setHeight: false, + offsetTop: element.offsetHeight + }); + } + Effect.Appear(update,{duration:0.15}); + }; + this.options.onHide = this.options.onHide || + function(element, update){ new Effect.Fade(update,{duration:0.15}) }; + + if(typeof(this.options.tokens) == 'string') + this.options.tokens = new Array(this.options.tokens); + + this.observer = null; + + this.element.setAttribute('autocomplete','off'); + + Element.hide(this.update); + + Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); + Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); + }, + + show: function() { + if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); + if(!this.iefix && + (navigator.appVersion.indexOf('MSIE')>0) && + (navigator.userAgent.indexOf('Opera')<0) && + (Element.getStyle(this.update, 'position')=='absolute')) { + new Insertion.After(this.update, + '<iframe id="' + this.update.id + '_iefix" '+ + 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' + + 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>'); + this.iefix = $(this.update.id+'_iefix'); + } + if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50); + }, + + fixIEOverlapping: function() { + Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); + this.iefix.style.zIndex = 1; + this.update.style.zIndex = 2; + Element.show(this.iefix); + }, + + hide: function() { + this.stopIndicator(); + if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update); + if(this.iefix) Element.hide(this.iefix); + }, + + startIndicator: function() { + if(this.options.indicator) Element.show(this.options.indicator); + }, + + stopIndicator: function() { + if(this.options.indicator) Element.hide(this.options.indicator); + }, + + onKeyPress: function(event) { + if(this.active) + switch(event.keyCode) { + case Event.KEY_TAB: + case Event.KEY_RETURN: + this.selectEntry(); + Event.stop(event); + case Event.KEY_ESC: + this.hide(); + this.active = false; + Event.stop(event); + return; + case Event.KEY_LEFT: + case Event.KEY_RIGHT: + return; + case Event.KEY_UP: + this.markPrevious(); + this.render(); + if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); + return; + case Event.KEY_DOWN: + this.markNext(); + this.render(); + if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); + return; + } + else + if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || + (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return; + + this.changed = true; + this.hasFocus = true; + + if(this.observer) clearTimeout(this.observer); + this.observer = + setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); + }, + + activate: function() { + this.changed = false; + this.hasFocus = true; + this.getUpdatedChoices(); + }, + + onHover: function(event) { + var element = Event.findElement(event, 'LI'); + if(this.index != element.autocompleteIndex) + { + this.index = element.autocompleteIndex; + this.render(); + } + Event.stop(event); + }, + + onClick: function(event) { + var element = Event.findElement(event, 'LI'); + this.index = element.autocompleteIndex; + this.selectEntry(); + this.hide(); + }, + + onBlur: function(event) { + // needed to make click events working + setTimeout(this.hide.bind(this), 250); + this.hasFocus = false; + this.active = false; + }, + + render: function() { + if(this.entryCount > 0) { + for (var i = 0; i < this.entryCount; i++) + this.index==i ? + Element.addClassName(this.getEntry(i),"selected") : + Element.removeClassName(this.getEntry(i),"selected"); + + if(this.hasFocus) { + this.show(); + this.active = true; + } + } else { + this.active = false; + this.hide(); + } + }, + + markPrevious: function() { + if(this.index > 0) this.index-- + else this.index = this.entryCount-1; + this.getEntry(this.index).scrollIntoView(true); + }, + + markNext: function() { + if(this.index < this.entryCount-1) this.index++ + else this.index = 0; + this.getEntry(this.index).scrollIntoView(false); + }, + + getEntry: function(index) { + return this.update.firstChild.childNodes[index]; + }, + + getCurrentEntry: function() { + return this.getEntry(this.index); + }, + + selectEntry: function() { + this.active = false; + this.updateElement(this.getCurrentEntry()); + }, + + updateElement: function(selectedElement) { + if (this.options.updateElement) { + this.options.updateElement(selectedElement); + return; + } + var value = ''; + if (this.options.select) { + var nodes = document.getElementsByClassName(this.options.select, selectedElement) || []; + if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select); + } else + value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); + + var lastTokenPos = this.findLastToken(); + if (lastTokenPos != -1) { + var newValue = this.element.value.substr(0, lastTokenPos + 1); + var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); + if (whitespace) + newValue += whitespace[0]; + this.element.value = newValue + value; + } else { + this.element.value = value; + } + this.element.focus(); + + if (this.options.afterUpdateElement) + this.options.afterUpdateElement(this.element, selectedElement); + }, + + updateChoices: function(choices) { + if(!this.changed && this.hasFocus) { + this.update.innerHTML = choices; + Element.cleanWhitespace(this.update); + Element.cleanWhitespace(this.update.firstChild); + + if(this.update.firstChild && this.update.firstChild.childNodes) { + this.entryCount = + this.update.firstChild.childNodes.length; + for (var i = 0; i < this.entryCount; i++) { + var entry = this.getEntry(i); + entry.autocompleteIndex = i; + this.addObservers(entry); + } + } else { + this.entryCount = 0; + } + + this.stopIndicator(); + this.index = 0; + + if(this.entryCount==1 && this.options.autoSelect) { + this.selectEntry(); + this.hide(); + } else { + this.render(); + } + } + }, + + addObservers: function(element) { + Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); + Event.observe(element, "click", this.onClick.bindAsEventListener(this)); + }, + + onObserverEvent: function() { + this.changed = false; + if(this.getToken().length>=this.options.minChars) { + this.startIndicator(); + this.getUpdatedChoices(); + } else { + this.active = false; + this.hide(); + } + }, + + getToken: function() { + var tokenPos = this.findLastToken(); + if (tokenPos != -1) + var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,''); + else + var ret = this.element.value; + + return /\n/.test(ret) ? '' : ret; + }, + + findLastToken: function() { + var lastTokenPos = -1; + + for (var i=0; i<this.options.tokens.length; i++) { + var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]); + if (thisTokenPos > lastTokenPos) + lastTokenPos = thisTokenPos; + } + return lastTokenPos; + } +} + +Ajax.Autocompleter = Class.create(); +Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { + initialize: function(element, update, url, options) { + this.baseInitialize(element, update, options); + ... [truncated message content] |
From: <fan...@us...> - 2006-10-07 14:26:07
|
Revision: 4575 http://svn.sourceforge.net/linpha/?rev=4575&view=rev Author: fangehrn Date: 2006-10-07 07:25:58 -0700 (Sat, 07 Oct 2006) Log Message: ----------- 2006-10-07 flo * adding javascript frameworks prototype and scriptaculous * implemented nice imageinfos Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/js/LinImage.js Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-07 14:25:40 UTC (rev 4574) +++ trunk/linpha2/ChangeLog 2006-10-07 14:25:58 UTC (rev 4575) @@ -1,3 +1,7 @@ +2006-10-07 flo + * adding javascript frameworks prototype and scriptaculous + * implemented nice imageinfos + 2006-10-03 flo * working on an ajax image view basic things will work now Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-07 14:25:40 UTC (rev 4574) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-07 14:25:58 UTC (rev 4575) @@ -75,73 +75,56 @@ ElemImg.setAttribute('width',imgwidth); ElemImg.setAttribute('height',imgheight); - var DivMainImage = document.getElementById('divimage'); - DivMainImage.innerHTML = ''; - DivMainImage.appendChild(ElemImg); + $('divimage').innerHTML = ''; + $('divimage').appendChild(ElemImg); /** * set title */ - var title = xmldoc.getElementsByTagName('title').item(0).firstChild.data; - document.getElementById('title').innerHTML = title; + $('title').innerHTML = xmldoc.getElementsByTagName('title').item(0).firstChild.data; /** * set current thumb */ - var DivCurrentThumb = document.getElementById('thumbnavi_currentthumb'); - DivCurrentThumb.innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; + $('thumbnavi_currentthumb').innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; /** * set prev thumbs */ - var DivPrevThumbs = document.getElementById('thumbnavi_prevthumb'); - DivPrevThumbs.innerHTML = ''; + $('thumbnavi_prevthumb').innerHTML = ''; if(xmldoc.getElementsByTagName('prevthumb').length > 0) { for(var i = 0; i < xmldoc.getElementsByTagName('prevthumb').length; i++) { var prevThumbId = xmldoc.getElementsByTagName('prevthumb').item(i).firstChild.data; - - var ElemImg = document.createElement("img"); - ElemImg.setAttribute('class','img_prevnextthumb'); - ElemImg.setAttribute('src',thumb_src + prevThumbId); - var ElemA = document.createElement("a"); - ElemA.setAttribute('href','javascript:loadImage(' + prevThumbId + ')'); - ElemA.appendChild(ElemImg); - - var ElemDiv = document.createElement("div"); - ElemDiv.setAttribute('class','thumbnavi_prevnextthumb'); - ElemDiv.appendChild(ElemA); + var ElemImg = Builder.node('img', {className: 'img_prevnextthumb', src: thumb_src + prevThumbId}); + var ElemA = Builder.node('a', {href: 'javascript:loadImage(' + prevThumbId + ')'}); + var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); - DivPrevThumbs.appendChild(ElemDiv); + ElemA.appendChild( ElemImg ); + ElemDiv.appendChild( ElemA ); + $('thumbnavi_prevthumb').appendChild(ElemDiv); } } /** * set next thumbs */ - var DivNextThumbs = document.getElementById('thumbnavi_nextthumb'); - DivNextThumbs.innerHTML = ''; + $('thumbnavi_nextthumb').innerHTML = ''; if(xmldoc.getElementsByTagName('nextthumb').length > 0) { for(var i = 0; i < xmldoc.getElementsByTagName('nextthumb').length; i++) { var nextThumbId = xmldoc.getElementsByTagName('nextthumb').item(i).firstChild.data; - - var ElemImg = document.createElement("img"); - ElemImg.setAttribute('class','img_prevnextthumb'); - ElemImg.setAttribute('src',thumb_src + nextThumbId); - var ElemA = document.createElement("a"); - ElemA.setAttribute('href','javascript:loadImage(' + nextThumbId + ')'); - ElemA.appendChild(ElemImg); - - var ElemDiv = document.createElement("div"); - ElemDiv.setAttribute('class','thumbnavi_prevnextthumb'); - ElemDiv.appendChild(ElemA); + var ElemImg = Builder.node('img', {className: 'img_prevnextthumb', src: thumb_src + nextThumbId}); + var ElemA = Builder.node('a', {href: 'javascript:loadImage(' + nextThumbId + ')'}); + var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); - DivNextThumbs.appendChild(ElemDiv); + ElemA.appendChild( ElemImg ); + ElemDiv.appendChild( ElemA ); + $('thumbnavi_nextthumb').appendChild(ElemDiv); } } @@ -150,8 +133,7 @@ */ if(xmldoc.getElementsByTagName('meta').length > 0) { - var DivMeta = document.getElementById("divmeta"); - DivMeta.innerHTML = ''; + $('divmeta').innerHTML = ''; for(var i = 0; i < xmldoc.getElementsByTagName('meta').length; i++) { @@ -159,17 +141,16 @@ var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); - DivMeta.appendChild(metaname); - DivMeta.appendChild(metavalue); - DivMeta.appendChild( document.createElement("br") ); + $('divmeta').appendChild(metaname); + $('divmeta').appendChild(metavalue); + $('divmeta').appendChild( document.createElement("br") ); } } /** * set comments */ - var DivComments = document.getElementById('divcomments'); - DivComments.innerHTML = ''; + $('divcomments').innerHTML = ''; if(xmldoc.getElementsByTagName('comment').length > 0) { for(var i = 0; i < xmldoc.getElementsByTagName('comment').length; i++) @@ -187,32 +168,19 @@ ElemDiv.appendChild(commenttext); ElemDiv.appendChild( document.createElement("br") ); - DivComments.appendChild(ElemDiv); + $('divcomments').appendChild(ElemDiv); } } /** * set positions of info link */ - var mainimage = document.getElementById('mainimage'); - var divinfolinks = document.getElementById('divinfolinks'); - divinfolinks.style.top = mainimage.offsetTop + mainimage.offsetHeight; - divinfolinks.style.left = mainimage.offsetLeft + mainimage.offsetWidth - divinfolinks.offsetWidth; -// alert(mainimage.offsetLeft + ' ' + mainimage.offsetTop + ' ' + mainimage.offsetWidth + ' ' + mainimage.offsetHeight); + $('divinfolinks').style.top = $('mainimage').offsetTop + $('mainimage').offsetHeight; + $('divinfolinks').style.left = $('mainimage').offsetLeft + $('mainimage').offsetWidth - $('divinfolinks').offsetWidth; - - } // end function setImageData() -function testsize() -{ - /** - * set positions of info link - */ - var mainimage = document.getElementById('mainimage'); - alert(mainimage.offsetLeft + ' ' + mainimage.offsetTop + ' ' + mainimage.offsetWidth + ' ' + mainimage.offsetHeight); -} var showhide = 'hide'; function showImgInfo() @@ -236,7 +204,7 @@ new Effect.Appear('divmeta', { duration: 0.5, from: 0.0, to: 1.0 }); new Effect.Appear('divimage', { duration: 0.5, from: 1.0, to: 0.3 }); - document.getElementById('hrefinfolinks').style.color = colorinfonotactive; + $('hrefinfolinks').style.color = colorinfonotactive; } else { @@ -245,7 +213,7 @@ new Effect.Appear('divmeta', { duration: 0.5, from: 1.0, to: 0.0 }); new Effect.Appear('divimage', { duration: 0.5, from: 0.3, to: 1.3 }); - document.getElementById('hrefinfolinks').style.color = colorinfoactive; + $('hrefinfolinks').style.color = colorinfoactive; } } function hideImgInfoNow() @@ -253,6 +221,8 @@ $('divmeta').style.display = 'none'; Element.setOpacity('divimage',1); showhide = 'hide'; + + $('hrefinfolinks').style.color = colorinfoactive; } @@ -261,8 +231,8 @@ */ function setInfoColors() { - colorinfonotactive = document.getElementById('divinfolinks').style.color; - colorinfoactive = document.getElementById('hrefinfolinks').style.color; + colorinfonotactive = $('divinfolinks').style.color; + colorinfoactive = $('hrefinfolinks').style.color; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-07 18:12:50
|
Revision: 4576 http://svn.sourceforge.net/linpha/?rev=4576&view=rev Author: fangehrn Date: 2006-10-07 11:12:35 -0700 (Sat, 07 Oct 2006) Log Message: ----------- 2006-10-07 flo * implementing lightbox in normal image view * preloading images and xml data * broken again.. :-/ Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/js/LinImage.js trunk/linpha2/templates/default/css/view_img.css trunk/linpha2/templates/default/view_img.head.php trunk/linpha2/templates/default/view_img.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-07 14:25:58 UTC (rev 4575) +++ trunk/linpha2/ChangeLog 2006-10-07 18:12:35 UTC (rev 4576) @@ -1,4 +1,9 @@ 2006-10-07 flo + * implementing lightbox in normal image view + * preloading images and xml data + * broken again.. :-/ + +2006-10-07 flo * adding javascript frameworks prototype and scriptaculous * implemented nice imageinfos Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-07 14:25:58 UTC (rev 4575) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-07 18:12:35 UTC (rev 4576) @@ -1,187 +1,297 @@ -var http_request = false; + +var errFunc = function(t) { + alert('Error ' + t.status + ' -- ' + t.statusText); +} + +var xmlDoc; +//var curImgId = startImgId; var img_width; var img_height; -var colorinfoactive; -var colorinfonotactive; +var borderSize = 0; +var resizeDuration = 0.5; +var LinImage = Class.create(); -function loadImage(imgid) { +LinImage.prototype = { + + // initialize() + // Constructor runs on completion of the DOM loading. + // + initialize: function() { + }, - http_request = false; + + loadStartData: function() { + // http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request + new Ajax.Request(xmlUrl + '&id=' + startImgId + '&xml', {asynchronous:true, onSuccess:this.loadStartImage, onFailure:errFunc} ); - if (window.XMLHttpRequest) { // Mozilla, Safari,... - http_request = new XMLHttpRequest(); - if (http_request.overrideMimeType) { - http_request.overrideMimeType('text/xml'); - // zu dieser Zeile siehe weiter unten - } - } else if (window.ActiveXObject) { // IE - try { - http_request = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - http_request = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (e) {} - } - } + }, - if (!http_request) { - alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen'); - return false; - } - http_request.onreadystatechange = loadImageData; - http_request.open('GET', imagedata_url + '&id=' + imgid + '&xml', true); - http_request.send(null); + loadStartImage: function(t) { + xmlDoc = t.responseXML.documentElement; + this.changeImage(); + }, -} + // + // changeImage() + // + changeImage: function(imgId) { + + alert('hallo'); -function loadImageData() { + /** + * hide meta text immediately + */ + hideImgInfoNow(); - if (http_request.readyState == 4) { - if (http_request.status == 200) - { - setImageData(); - } else { - alert('Bei dem Request ist ein Problem aufgetreten.'); - } - } -} // end function loadImageData() + // hide elements during transition + Element.show('divloading'); + Element.hide('mainImage'); -function setImageData() -{ -// alert(http_request.responseText); + /** + * set image width and height + */ + //var imgid = xmlDoc.getElementsByTagName('imgid').item(0).firstChild.data; + var orgWidth = xmlDoc.getElementsByTagName('imgwidth').item(0).firstChild.data; + var orgHeight = xmlDoc.getElementsByTagName('imgheight').item(0).firstChild.data; + var sizeArray = scaleToFit(orgWidth,orgHeight,imageSize,imageSize,1); + imgWidth = sizeArray[0]; + imgHeight = sizeArray[1]; - /** - * hide meta text immediately - */ - hideImgInfoNow(); + /** + * preload image + */ + imgPreloader = new Image(); + + // once image is preloaded, resize image container + imgPreloader.onload=function(){ + $('mainImage').src = image_src + imgid + '&max_width=' + imgWidth + '&max_height=' + imgHeight; + myLinImage.resizeImageContainer(imgWidth, imgHeight); + } + imgPreloader.src = image_src + imgid + '&max_width=' + imgWidth + '&max_height=' + imgHeight; + }, - var xmldoc = http_request.responseXML; + // + // resizeImageContainer() + // + resizeImageContainer: function( imgWidth, imgHeight) { - /** - * set image with source, width and height - */ - var imgid = xmldoc.getElementsByTagName('imgid').item(0).firstChild.data; - var orgwidth = xmldoc.getElementsByTagName('imgwidth').item(0).firstChild.data; - var orgheight = xmldoc.getElementsByTagName('imgheight').item(0).firstChild.data; - var sizearray = scaleToFit(orgwidth,orgheight,image_size,image_size,1); - imgwidth = sizearray[0]; - imgheight = sizearray[1]; - - var ElemImg = document.createElement("img"); - ElemImg.setAttribute('src',image_src + imgid + '&max_width=' + imgwidth + '&max_height=' + imgheight); - ElemImg.setAttribute('id','mainimage'); - ElemImg.setAttribute('width',imgwidth); - ElemImg.setAttribute('height',imgheight); + // get current height and width + this.wCur = $('mainImage').offsetWidth; + this.hCur = $('mainImage').offsetHeight; - $('divimage').innerHTML = ''; - $('divimage').appendChild(ElemImg); - - /** - * set title - */ - $('title').innerHTML = xmldoc.getElementsByTagName('title').item(0).firstChild.data; + // scalars based on change from old to new + this.xScale = ((imgWidth + (borderSize * 2)) / this.wCur) * 100; + this.yScale = ((imgHeight + (borderSize * 2)) / this.hCur) * 100; - /** - * set current thumb - */ - $('thumbnavi_currentthumb').innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; + // calculate size difference between new and old image, and resize if necessary + wDiff = (this.wCur - borderSize * 2) - imgWidth; + hDiff = (this.hCur - borderSize * 2) - imgHeight; - /** - * set prev thumbs - */ - $('thumbnavi_prevthumb').innerHTML = ''; - if(xmldoc.getElementsByTagName('prevthumb').length > 0) - { - for(var i = 0; i < xmldoc.getElementsByTagName('prevthumb').length; i++) - { - var prevThumbId = xmldoc.getElementsByTagName('prevthumb').item(i).firstChild.data; + if(!( hDiff == 0)){ new Effect.Scale('mainImage', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); } + if(!( wDiff == 0)){ new Effect.Scale('mainImage', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); } - var ElemImg = Builder.node('img', {className: 'img_prevnextthumb', src: thumb_src + prevThumbId}); - var ElemA = Builder.node('a', {href: 'javascript:loadImage(' + prevThumbId + ')'}); - var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); - - ElemA.appendChild( ElemImg ); - ElemDiv.appendChild( ElemA ); - $('thumbnavi_prevthumb').appendChild(ElemDiv); + // if new and old image are same size and no scaling transition is necessary, + // do a quick pause to prevent image flicker. + if((hDiff == 0) && (wDiff == 0)){ + if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} } - } - /** - * set next thumbs - */ - $('thumbnavi_nextthumb').innerHTML = ''; - if(xmldoc.getElementsByTagName('nextthumb').length > 0) - { - for(var i = 0; i < xmldoc.getElementsByTagName('nextthumb').length; i++) - { - var nextThumbId = xmldoc.getElementsByTagName('nextthumb').item(i).firstChild.data; + + /*Element.setHeight('prevLink', imgHeight); + Element.setHeight('nextLink', imgHeight); + Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2));*/ - var ElemImg = Builder.node('img', {className: 'img_prevnextthumb', src: thumb_src + nextThumbId}); - var ElemA = Builder.node('a', {href: 'javascript:loadImage(' + nextThumbId + ')'}); - var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); - - ElemA.appendChild( ElemImg ); - ElemDiv.appendChild( ElemA ); - $('thumbnavi_nextthumb').appendChild(ElemDiv); - } - } + this.showImage(); + }, + + // + // showImage() + // Display image and begin preloading neighbors. + // + showImage: function(){ + Element.hide('divloading'); + new Effect.Appear('mainImage', { duration: 0.5, queue: 'end', afterFinish: function(){ myLinImage.setImageData(); } }); +// this.preloadNeighborImages(); + }, - /** - * set meta data - */ - if(xmldoc.getElementsByTagName('meta').length > 0) - { - $('divmeta').innerHTML = ''; - for(var i = 0; i < xmldoc.getElementsByTagName('meta').length; i++) + setImageData: function() { + + /** + * set title + */ + $('title').innerHTML = xmlDoc.getElementsByTagName('title').item(0).firstChild.data; + + /** + * set current thumb + */ + $('thumbnavi_currentthumb').innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; + + /** + * set prev thumbs + */ + $('thumbnavi_prevthumb').innerHTML = ''; + if(xmlDoc.getElementsByTagName('prevthumb').length > 0) { - var meta = xmldoc.getElementsByTagName('meta').item(i); - var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); - var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); - - $('divmeta').appendChild(metaname); - $('divmeta').appendChild(metavalue); - $('divmeta').appendChild( document.createElement("br") ); + for(var i = 0; i < xmlDoc.getElementsByTagName('prevthumb').length; i++) + { + var prevThumbId = xmlDoc.getElementsByTagName('prevthumb').item(i).firstChild.data; + + var ElemImg = Builder.node('img', {className: 'img_prevnextthumb', src: thumb_src + prevThumbId}); + var ElemA = Builder.node('a', {href: 'javascript:loadImage(' + prevThumbId + ')'}); + var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); + + ElemA.appendChild( ElemImg ); + ElemDiv.appendChild( ElemA ); + $('thumbnavi_prevthumb').appendChild(ElemDiv); + } } - } - /** - * set comments - */ - $('divcomments').innerHTML = ''; - if(xmldoc.getElementsByTagName('comment').length > 0) - { - for(var i = 0; i < xmldoc.getElementsByTagName('comment').length; i++) + /** + * set next thumbs + */ + $('thumbnavi_nextthumb').innerHTML = ''; + if(xmlDoc.getElementsByTagName('nextthumb').length > 0) { - var comment = xmldoc.getElementsByTagName('comment').item(i); - var commenttime = document.createTextNode( comment.getElementsByTagName('time').item(0).firstChild.data + ' ' ); - var commentauthor = document.createTextNode( comment.getElementsByTagName('author').item(0).firstChild.data ); - var commenttext = document.createTextNode( comment.getElementsByTagName('text').item(0).firstChild.data ); + for(var i = 0; i < xmlDoc.getElementsByTagName('nextthumb').length; i++) + { + var nextThumbId = xmlDoc.getElementsByTagName('nextthumb').item(i).firstChild.data; + + var ElemImg = Builder.node('img', {className: 'img_prevnextthumb', src: thumb_src + nextThumbId}); + var ElemA = Builder.node('a', {href: 'javascript:loadImage(' + nextThumbId + ')'}); + var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); + + ElemA.appendChild( ElemImg ); + ElemDiv.appendChild( ElemA ); + $('thumbnavi_nextthumb').appendChild(ElemDiv); + } + } + + /** + * set meta data + */ + if(xmlDoc.getElementsByTagName('meta').length > 0) + { + $('divmeta').innerHTML = ''; + + for(var i = 0; i < xmlDoc.getElementsByTagName('meta').length; i++) + { + var meta = xmlDoc.getElementsByTagName('meta').item(i); + var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); + var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); + + $('divmeta').appendChild(metaname); + $('divmeta').appendChild(metavalue); + $('divmeta').appendChild( document.createElement("br") ); + } + } + + /** + * set comments + */ + $('divcomments').innerHTML = ''; + if(xmlDoc.getElementsByTagName('comment').length > 0) + { + for(var i = 0; i < xmlDoc.getElementsByTagName('comment').length; i++) + { + var comment = xmlDoc.getElementsByTagName('comment').item(i); + var commenttime = document.createTextNode( comment.getElementsByTagName('time').item(0).firstChild.data + ' ' ); + var commentauthor = document.createTextNode( comment.getElementsByTagName('author').item(0).firstChild.data ); + var commenttext = document.createTextNode( comment.getElementsByTagName('text').item(0).firstChild.data ); + + var ElemDiv = document.createElement("div"); + ElemDiv.setAttribute('class','comments'); + ElemDiv.appendChild(commenttime); + ElemDiv.appendChild(commentauthor); + ElemDiv.appendChild( document.createElement("br") ); + ElemDiv.appendChild(commenttext); + ElemDiv.appendChild( document.createElement("br") ); + + $('divcomments').appendChild(ElemDiv); + } + } + + /** + * set positions of info link + */ + $('divinfolinks').style.top = $('mainImage').offsetTop + $('mainImage').offsetHeight; + $('divinfolinks').style.left = $('mainImage').offsetLeft + $('mainImage').offsetWidth - $('divinfolinks').offsetWidth; + + }, + // end function setImageData() + // + // + // + // enableKeyboardNav() + // + enableKeyboardNav: function() { + document.onkeydown = this.keyboardAction; + }, - var ElemDiv = document.createElement("div"); - ElemDiv.setAttribute('class','comments'); - ElemDiv.appendChild(commenttime); - ElemDiv.appendChild(commentauthor); - ElemDiv.appendChild( document.createElement("br") ); - ElemDiv.appendChild(commenttext); - ElemDiv.appendChild( document.createElement("br") ); + // + // disableKeyboardNav() + // + disableKeyboardNav: function() { + document.onkeydown = ''; + }, - $('divcomments').appendChild(ElemDiv); + // + // keyboardAction() + // + keyboardAction: function(e) { + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; } + + key = String.fromCharCode(keycode).toLowerCase(); + + if((key == 'x') || (key == 'o') || (key == 'c')){ // close lightbox + myLinImage.end(); + } else if(key == 'p'){ // display previous image + if(activeImage != 0){ + myLinImage.disableKeyboardNav(); + myLinImage.changeImage(activeImage - 1); + } + } else if(key == 'n'){ // display next image + if(activeImage != (imageArray.length - 1)){ + myLinImage.disableKeyboardNav(); + myLinImage.changeImage(activeImage + 1); + } + } + + + }, + + // + // preloadNeighborImages() + // Preload previous and next images. + // + preloadNeighborImages: function(){ + + if((imageArray.length - 1) > activeImage){ + preloadNextImage = new Image(); + preloadNextImage.src = setImageUrl(imageArray[activeImage + 1][0]); + } + if(activeImage > 0){ + preloadPrevImage = new Image(); + preloadPrevImage.src = setImageUrl(imageArray[activeImage - 1][0]); + } + } - - /** - * set positions of info link - */ - $('divinfolinks').style.top = $('mainimage').offsetTop + $('mainimage').offsetHeight; - $('divinfolinks').style.left = $('mainimage').offsetLeft + $('mainimage').offsetWidth - $('divinfolinks').offsetWidth; +} -} // end function setImageData() +// ----------------------------------------------------------------------------------- +var colorinfoactive; +var colorinfonotactive; + + var showhide = 'hide'; function showImgInfo() { @@ -195,14 +305,11 @@ /** * set position */ - $('divmeta').style.top = $('mainimage').offsetTop + 50; - $('divmeta').style.left = $('mainimage').offsetLeft + 50; + $('divmeta').style.top = $('mainImage').offsetTop + 50; + $('divmeta').style.left = $('mainImage').offsetLeft + 50; - /** - * fade in - */ - new Effect.Appear('divmeta', { duration: 0.5, from: 0.0, to: 1.0 }); - new Effect.Appear('divimage', { duration: 0.5, from: 1.0, to: 0.3 }); + new Effect.Appear('divmeta', { duration: 0.5 }); //, from: 0.0, to: 1.0 + new Effect.Fade('divimage', { duration: 0.5, from: 1.0, to: 0.2 }); $('hrefinfolinks').style.color = colorinfonotactive; } @@ -210,8 +317,8 @@ { showhide = 'hide'; - new Effect.Appear('divmeta', { duration: 0.5, from: 1.0, to: 0.0 }); - new Effect.Appear('divimage', { duration: 0.5, from: 0.3, to: 1.3 }); + new Effect.Fade('divmeta', { duration: 0.5 }); // , from: 1.0, to: 0.0 + new Effect.Appear('divimage', { duration: 0.5, from: 0.3, to: 1.0 }); $('hrefinfolinks').style.color = colorinfoactive; } @@ -277,4 +384,16 @@ } return returnarray; -} \ No newline at end of file +} + + +/** + * init on finished page load + */ +function initLinImage() +{ + setInfoColors(); + var myLinImage = new LinImage(); + myLinImage.loadStartData(); +} +Event.observe(window, 'load', initLinImage, false); Modified: trunk/linpha2/templates/default/css/view_img.css =================================================================== --- trunk/linpha2/templates/default/css/view_img.css 2006-10-07 14:25:58 UTC (rev 4575) +++ trunk/linpha2/templates/default/css/view_img.css 2006-10-07 18:12:35 UTC (rev 4576) @@ -21,10 +21,11 @@ #divmeta { position: absolute; text-align: left; + padding: 10px; + border: 1px solid black; } #divinfolinks { position: absolute; -/* border: 1px solid black;*/ } Modified: trunk/linpha2/templates/default/view_img.head.php =================================================================== --- trunk/linpha2/templates/default/view_img.head.php 2006-10-07 14:25:58 UTC (rev 4575) +++ trunk/linpha2/templates/default/view_img.head.php 2006-10-07 18:12:35 UTC (rev 4576) @@ -1,11 +1,12 @@ + <script language="JavaScript" type="text/javascript"> -var imagedata_url = '<?php echo convert_amp($GLOBALS['linpha']->template->URL_base); ?>'; -var image_src = '<?php echo LINPHA_DIR.'/get_image.php?id='; ?>'; -var thumb_src = '<?php echo LINPHA_DIR.'/get_thumb.php?id='; ?>'; -var image_size = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; +var xmlUrl = '<?php echo convert_amp($GLOBALS['linpha']->template->URL_base); ?>'; +var imageSrc = '<?php echo LINPHA_DIR.'/get_image.php?id='; ?>'; +var thumbSrc = '<?php echo LINPHA_DIR.'/get_thumb.php?id='; ?>'; +var imageSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; +var startImgId = <?php echo $GLOBALS['linpha']->imgview->id_current; ?>; </script> -<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/LinImage.js"> </script> - <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/prototype.js"></script> <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/scriptaculous.js?load=effects,builder"></script> +<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/LinImage.js"> </script> Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-10-07 14:25:58 UTC (rev 4575) +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-07 18:12:35 UTC (rev 4576) @@ -28,8 +28,14 @@ <noscript><h1><?php echo i18n("If you have just disabled Javascript, you will need to restart your browser."); ?></h1></noscript> <!-- show image --> - <div id="divimage"></div> + <div id="divimage"> + <img id="mainImage"> + </div> + <div id="divloading"> + <img src="<?php echo LINPHA_DIR; ?>/lib/classes/lightbox/images/loading.gif"> + </div> + <div id="divmeta" style="display: none;"></div> <div id="divinfolinks" style="color: grey;"> @@ -76,20 +82,3 @@ <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> </div> - -<!-- -<div id="divright"> - <div class="roundtop"> - <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> - </div> - <div id="right"></div> - <div class="roundbottom"> - <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> - </div> -</div> ---> - -<script language="JavaScript" type="text/javascript"> -setInfoColors(); -loadImage(<?php echo $GLOBALS['linpha']->imgview->id_current; ?>); -</script> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-08 15:42:33
|
Revision: 4577 http://svn.sourceforge.net/linpha/?rev=4577&view=rev Author: fangehrn Date: 2006-10-08 08:42:12 -0700 (Sun, 08 Oct 2006) Log Message: ----------- 2006-10-08 flo * implemented "lightbox" image view * preload images and xml data Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/get_image.php trunk/linpha2/lib/classes/image/gdlib/thumbnail.php trunk/linpha2/lib/js/LinImage.js trunk/linpha2/templates/default/css/view_img.css trunk/linpha2/templates/default/view_img.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-07 18:12:35 UTC (rev 4576) +++ trunk/linpha2/ChangeLog 2006-10-08 15:42:12 UTC (rev 4577) @@ -1,3 +1,7 @@ +2006-10-08 flo + * implemented "lightbox" image view + * preload images and xml data + 2006-10-07 flo * implementing lightbox in normal image view * preloading images and xml data Modified: trunk/linpha2/get_image.php =================================================================== --- trunk/linpha2/get_image.php 2006-10-07 18:12:35 UTC (rev 4576) +++ trunk/linpha2/get_image.php 2006-10-08 15:42:12 UTC (rev 4577) @@ -22,6 +22,8 @@ * Thumb view related methods and functions * @package Image */ + +//sleep(3); if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','.'); } Modified: trunk/linpha2/lib/classes/image/gdlib/thumbnail.php =================================================================== --- trunk/linpha2/lib/classes/image/gdlib/thumbnail.php 2006-10-07 18:12:35 UTC (rev 4576) +++ trunk/linpha2/lib/classes/image/gdlib/thumbnail.php 2006-10-08 15:42:12 UTC (rev 4577) @@ -33,27 +33,26 @@ { $x = 0; $y = 0; - $w = $this->img_thumbsize; - $h = $this->img_thumbsize; + + $src_size = $this->org_width; // or $this->org_height, here it doesnt matter } - elseif($ratio>1) + elseif($ratio>1) // org_width > org_height { $x = ( $this->org_width - $this->org_height )/2; $y = 0; - $w = $this->img_thumbsize; - $h = $this->img_thumbsize; - $src_size = $this->org_height; + + $src_size = $this->org_height; // i think it does matter... } - elseif($ratio<1) + elseif($ratio<1) // org_height > org_width { $y = ( $this->org_height - $this->org_width )/2; $x = 0; - $w = $this->img_thumbsize; - $h = $this->img_thumbsize; - $src_size = $this->org_width; + $src_size = $this->org_width; // i think it does matter... } + $w = $this->img_thumbsize; + $h = $this->img_thumbsize; /** * create image resources Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-07 18:12:35 UTC (rev 4576) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-08 15:42:12 UTC (rev 4577) @@ -3,15 +3,18 @@ alert('Error ' + t.status + ' -- ' + t.statusText); } -var xmlDoc; -//var curImgId = startImgId; -var img_width; -var img_height; +var curImgId; +var xmlDoc = new Array(); +var preloadImage = new Array(); +var preloadImageFinished = new Array(); +var preloadXmlFinished = new Array(); + var borderSize = 0; var resizeDuration = 0.5; var LinImage = Class.create(); +var myLinImage; LinImage.prototype = { @@ -21,40 +24,62 @@ initialize: function() { }, + loadImage: function(imgId) { + curImgId = imgId; + + if(preloadXmlFinished[imgId] && xmlDoc[imgId] != "undefined") + { + this.changeImage(); + } + else + { + this.loadImageXml(imgId); + } + }, - loadStartData: function() { + loadImageXml: function(imgId) { // http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request - new Ajax.Request(xmlUrl + '&id=' + startImgId + '&xml', {asynchronous:true, onSuccess:this.loadStartImage, onFailure:errFunc} ); - + new Ajax.Request(xmlUrl + '&id=' + imgId + '&xml', {asynchronous:true, onSuccess:this.loadImageContinue, onFailure:errFunc} ); }, - loadStartImage: function(t) { - xmlDoc = t.responseXML.documentElement; - this.changeImage(); + loadImageContinue: function(t) { + var loadedimgid = t.responseXML.documentElement.getElementsByTagName('imgid').item(0).firstChild.data; + + xmlDoc[loadedimgid] = t.responseXML.documentElement; + + if( loadedimgid == curImgId) // coming from loadImage() + { + myLinImage.changeImage(); + } + else // coming from preloadImage() + { + preloadXmlFinished[loadedimgid] = true; + myLinImage.preloadImage(loadedimgid); + } }, + // // changeImage() // - changeImage: function(imgId) { + changeImage: function() { - alert('hallo'); - /** * hide meta text immediately */ hideImgInfoNow(); // hide elements during transition + $('divimage').style.height = $('mainImage').style.height; // set height of outer div to prevent the whole page getting smaller, and if the image is loaded getting bigger again Element.show('divloading'); Element.hide('mainImage'); + Element.hide('divinfolinks'); /** * set image width and height */ - //var imgid = xmlDoc.getElementsByTagName('imgid').item(0).firstChild.data; - var orgWidth = xmlDoc.getElementsByTagName('imgwidth').item(0).firstChild.data; - var orgHeight = xmlDoc.getElementsByTagName('imgheight').item(0).firstChild.data; + var orgWidth = xmlDoc[curImgId].getElementsByTagName('imgwidth').item(0).firstChild.data; + var orgHeight = xmlDoc[curImgId].getElementsByTagName('imgheight').item(0).firstChild.data; var sizeArray = scaleToFit(orgWidth,orgHeight,imageSize,imageSize,1); imgWidth = sizeArray[0]; imgHeight = sizeArray[1]; @@ -62,14 +87,15 @@ /** * preload image */ + var currentImgSrc = imageSrc + curImgId + '&max_width=' + imgWidth + '&max_height=' + imgHeight; imgPreloader = new Image(); // once image is preloaded, resize image container imgPreloader.onload=function(){ - $('mainImage').src = image_src + imgid + '&max_width=' + imgWidth + '&max_height=' + imgHeight; + $('mainImage').src = currentImgSrc; myLinImage.resizeImageContainer(imgWidth, imgHeight); } - imgPreloader.src = image_src + imgid + '&max_width=' + imgWidth + '&max_height=' + imgHeight; + imgPreloader.src = currentImgSrc; }, // @@ -78,7 +104,7 @@ resizeImageContainer: function( imgWidth, imgHeight) { // get current height and width - this.wCur = $('mainImage').offsetWidth; + /*this.wCur = $('mainImage').offsetWidth; this.hCur = $('mainImage').offsetHeight; // scalars based on change from old to new @@ -96,8 +122,11 @@ // do a quick pause to prevent image flicker. if((hDiff == 0) && (wDiff == 0)){ if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} - } + }*/ + $('mainImage').style.width = imgWidth; + $('mainImage').style.height = imgHeight; + /*Element.setHeight('prevLink', imgHeight); Element.setHeight('nextLink', imgHeight); @@ -108,12 +137,15 @@ // // showImage() - // Display image and begin preloading neighbors. + // Display image and begin preloading images. // showImage: function(){ Element.hide('divloading'); - new Effect.Appear('mainImage', { duration: 0.5, queue: 'end', afterFinish: function(){ myLinImage.setImageData(); } }); -// this.preloadNeighborImages(); + new Effect.Appear('mainImage', { duration: 0.5, afterFinish: function(){ myLinImage.setImageInfoLink(); } }); + $('divimage').style.height = $('mainImage').style.height; // reset height to auto change if image is bigger or smaller + + this.setImageData(); + this.preloadXml(); }, @@ -122,30 +154,34 @@ /** * set title */ - $('title').innerHTML = xmlDoc.getElementsByTagName('title').item(0).firstChild.data; - + $('title').innerHTML = xmlDoc[curImgId].getElementsByTagName('title').item(0).firstChild.data; + /** * set current thumb */ - $('thumbnavi_currentthumb').innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; + $('thumbnavi_currentthumb').innerHTML = '<a href="javascript:myLinImage.loadImage(' + curImgId + ')"><img class="img_currentthumb" src="' + thumbSrc + curImgId + '" /></a>'; /** * set prev thumbs */ $('thumbnavi_prevthumb').innerHTML = ''; - if(xmlDoc.getElementsByTagName('prevthumb').length > 0) + if(xmlDoc[curImgId].getElementsByTagName('prevthumb').length > 0) { - for(var i = 0; i < xmlDoc.getElementsByTagName('prevthumb').length; i++) + for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('prevthumb').length; i++) { - var prevThumbId = xmlDoc.getElementsByTagName('prevthumb').item(i).firstChild.data; + var prevThumbId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; - var ElemImg = Builder.node('img', {className: 'img_prevnextthumb', src: thumb_src + prevThumbId}); - var ElemA = Builder.node('a', {href: 'javascript:loadImage(' + prevThumbId + ')'}); + var ElemImg = Builder.node('img', {id: 'thumb'+prevThumbId, className: 'img_prevnextthumb', src: thumbSrc + prevThumbId}); + var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + prevThumbId + ')'}); var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); ElemA.appendChild( ElemImg ); ElemDiv.appendChild( ElemA ); $('thumbnavi_prevthumb').appendChild(ElemDiv); + + if(! preloadImageFinished[prevThumbId]) { + Element.setOpacity('thumb'+prevThumbId,0.5); + } } } @@ -153,32 +189,36 @@ * set next thumbs */ $('thumbnavi_nextthumb').innerHTML = ''; - if(xmlDoc.getElementsByTagName('nextthumb').length > 0) + if(xmlDoc[curImgId].getElementsByTagName('nextthumb').length > 0) { - for(var i = 0; i < xmlDoc.getElementsByTagName('nextthumb').length; i++) + for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('nextthumb').length; i++) { - var nextThumbId = xmlDoc.getElementsByTagName('nextthumb').item(i).firstChild.data; + var nextThumbId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; - var ElemImg = Builder.node('img', {className: 'img_prevnextthumb', src: thumb_src + nextThumbId}); - var ElemA = Builder.node('a', {href: 'javascript:loadImage(' + nextThumbId + ')'}); + var ElemImg = Builder.node('img', {id: 'thumb'+nextThumbId, className: 'img_prevnextthumb', src: thumbSrc + nextThumbId}); + var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + nextThumbId + ')'}); var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); ElemA.appendChild( ElemImg ); ElemDiv.appendChild( ElemA ); $('thumbnavi_nextthumb').appendChild(ElemDiv); + + if(! preloadImageFinished[nextThumbId]) { + Element.setOpacity('thumb'+nextThumbId,0.5); + } } } /** * set meta data */ - if(xmlDoc.getElementsByTagName('meta').length > 0) + if(xmlDoc[curImgId].getElementsByTagName('meta').length > 0) { $('divmeta').innerHTML = ''; - for(var i = 0; i < xmlDoc.getElementsByTagName('meta').length; i++) + for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('meta').length; i++) { - var meta = xmlDoc.getElementsByTagName('meta').item(i); + var meta = xmlDoc[curImgId].getElementsByTagName('meta').item(i); var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); @@ -192,11 +232,11 @@ * set comments */ $('divcomments').innerHTML = ''; - if(xmlDoc.getElementsByTagName('comment').length > 0) + if(xmlDoc[curImgId].getElementsByTagName('comment').length > 0) { - for(var i = 0; i < xmlDoc.getElementsByTagName('comment').length; i++) + for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('comment').length; i++) { - var comment = xmlDoc.getElementsByTagName('comment').item(i); + var comment = xmlDoc[curImgId].getElementsByTagName('comment').item(i); var commenttime = document.createTextNode( comment.getElementsByTagName('time').item(0).firstChild.data + ' ' ); var commentauthor = document.createTextNode( comment.getElementsByTagName('author').item(0).firstChild.data ); var commenttext = document.createTextNode( comment.getElementsByTagName('text').item(0).firstChild.data ); @@ -213,17 +253,23 @@ } } - /** - * set positions of info link - */ + + }, // end function setImageData() + + /** + * setImageInfoLink + * + * set positions of info link + * could only be done after image has been completly loaded + */ + setImageInfoLink: function() { $('divinfolinks').style.top = $('mainImage').offsetTop + $('mainImage').offsetHeight; - $('divinfolinks').style.left = $('mainImage').offsetLeft + $('mainImage').offsetWidth - $('divinfolinks').offsetWidth; - + $('divinfolinks').style.left = $('mainImage').offsetLeft + $('mainImage').offsetWidth - 50; // 50: value of view_img.css width = 50px; can't get width with javascript because element is hidden + Element.show('divinfolinks'); + }, - // end function setImageData() + // - // - // // enableKeyboardNav() // enableKeyboardNav: function() { @@ -270,17 +316,63 @@ // preloadNeighborImages() // Preload previous and next images. // - preloadNeighborImages: function(){ + preloadXml: function() { - if((imageArray.length - 1) > activeImage){ - preloadNextImage = new Image(); - preloadNextImage.src = setImageUrl(imageArray[activeImage + 1][0]); + // preload nextthumb from left to right + if(xmlDoc[curImgId].getElementsByTagName('nextthumb').length > 0) + { + for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('nextthumb').length; i++) + { + var thumbId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; + this.loadImageXml(thumbId); + } } - if(activeImage > 0){ - preloadPrevImage = new Image(); - preloadPrevImage.src = setImageUrl(imageArray[activeImage - 1][0]); + + // preload prevthumb from right to left + if(xmlDoc[curImgId].getElementsByTagName('prevthumb').length > 0) + { + for(var i = xmlDoc[curImgId].getElementsByTagName('prevthumb').length-1; i >= 0; i--) + { + var thumbId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; + this.loadImageXml(thumbId); + } } + }, + /** + * preloadImage() + * + * will be called after getting the xml data + */ + preloadImage: function(imgId) { + if(! preloadImageFinished[imgId] ) + { + /** + * set image width and height + */ + var orgWidth = xmlDoc[imgId].getElementsByTagName('imgwidth').item(0).firstChild.data; + var orgHeight = xmlDoc[imgId].getElementsByTagName('imgheight').item(0).firstChild.data; + var sizeArray = scaleToFit(orgWidth,orgHeight,imageSize,imageSize,1); + imgWidth = sizeArray[0]; + imgHeight = sizeArray[1]; + + var currentImgSrc = imageSrc + imgId + '&max_width=' + imgWidth + '&max_height=' + imgHeight; + + /** + * preload image + */ + preloadImage[imgId] = new Image(); + + preloadImage[imgId].onload=function(){ + myLinImage.preloadImageFinished(imgId); + } + preloadImage[imgId].src = currentImgSrc; + } + }, + + preloadImageFinished: function(imgId) { + new Effect.Appear('thumb'+imgId, { duration: 0.5, from: 0.5, to: 1.0 }); + preloadImageFinished[imgId] = true; } } @@ -309,7 +401,7 @@ $('divmeta').style.left = $('mainImage').offsetLeft + 50; new Effect.Appear('divmeta', { duration: 0.5 }); //, from: 0.0, to: 1.0 - new Effect.Fade('divimage', { duration: 0.5, from: 1.0, to: 0.2 }); + new Effect.Fade('divimage', { duration: 1, from: 1.0, to: 0.2 }); $('hrefinfolinks').style.color = colorinfonotactive; } @@ -317,8 +409,8 @@ { showhide = 'hide'; - new Effect.Fade('divmeta', { duration: 0.5 }); // , from: 1.0, to: 0.0 - new Effect.Appear('divimage', { duration: 0.5, from: 0.3, to: 1.0 }); + new Effect.Fade('divmeta', { duration: 1 }); // , from: 1.0, to: 0.0 + new Effect.Appear('divimage', { duration: 0.5, from: 0.2, to: 1.0 }); $('hrefinfolinks').style.color = colorinfoactive; } @@ -393,7 +485,9 @@ function initLinImage() { setInfoColors(); - var myLinImage = new LinImage(); - myLinImage.loadStartData(); + myLinImage = new LinImage(); + myLinImage.loadImage(startImgId); + window.onresize = myLinImage.setImageInfoLink; + } Event.observe(window, 'load', initLinImage, false); Modified: trunk/linpha2/templates/default/css/view_img.css =================================================================== --- trunk/linpha2/templates/default/css/view_img.css 2006-10-07 18:12:35 UTC (rev 4576) +++ trunk/linpha2/templates/default/css/view_img.css 2006-10-08 15:42:12 UTC (rev 4577) @@ -8,14 +8,20 @@ margin: 10px 10px 10px 10px; } #main { - text-align: center; +/* text-align: center;*/ position: relative; } #divimage { + text-align: center; } #mainimage { } +#divloading { + position: absolute; + left: 50%; + top: 20px; +} #divmeta { @@ -26,6 +32,8 @@ } #divinfolinks { position: absolute; + text-align: right; + width: 50px; /* hardcoded in LinImage.js setImageInfoLink() change to!*/ } @@ -38,7 +46,7 @@ #thumbnavi { position: relative; - height: 120px; + height: 80px; font-size: 0.5em; text-align: center; } @@ -58,8 +66,8 @@ .thumbnavi_prevnextthumb { /*border: 1px solid #000000;*/ float: left; - width: 90px; - height: 90px; + width: 80px; + height: 80px; margin: 2px; } Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-10-07 18:12:35 UTC (rev 4576) +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-08 15:42:12 UTC (rev 4577) @@ -25,20 +25,20 @@ <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> <div id="main"> + <div id="divloading"> + <img src="<?php echo LINPHA_DIR; ?>/lib/classes/lightbox/images/loading.gif"> + </div> + <noscript><h1><?php echo i18n("If you have just disabled Javascript, you will need to restart your browser."); ?></h1></noscript> <!-- show image --> <div id="divimage"> - <img id="mainImage"> + <img id="mainImage" style="display: none;"> </div> - <div id="divloading"> - <img src="<?php echo LINPHA_DIR; ?>/lib/classes/lightbox/images/loading.gif"> - </div> - <div id="divmeta" style="display: none;"></div> - <div id="divinfolinks" style="color: grey;"> + <div id="divinfolinks" style="display: none; color: grey;"> <a id="hrefinfolinks" href="javascript:showImgInfo()" style="color: black;">Info</a> </div> @@ -81,4 +81,4 @@ <div class="roundbottom"> <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> -</div> +</div> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-08 18:02:18
|
Revision: 4578 http://svn.sourceforge.net/linpha/?rev=4578&view=rev Author: fangehrn Date: 2006-10-08 11:02:04 -0700 (Sun, 08 Oct 2006) Log Message: ----------- 2006-10-08 flo * some improvements done, now it runs quite smooth :-) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/js/LinImage.js trunk/linpha2/templates/default/css/global.css trunk/linpha2/templates/default/view_img_static.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-08 15:42:12 UTC (rev 4577) +++ trunk/linpha2/ChangeLog 2006-10-08 18:02:04 UTC (rev 4578) @@ -1,4 +1,7 @@ 2006-10-08 flo + * some improvements done, now it runs quite smooth :-) + +2006-10-08 flo * implemented "lightbox" image view * preload images and xml data Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-08 15:42:12 UTC (rev 4577) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-08 18:02:04 UTC (rev 4578) @@ -45,15 +45,16 @@ loadImageContinue: function(t) { var loadedimgid = t.responseXML.documentElement.getElementsByTagName('imgid').item(0).firstChild.data; + // save xml data xmlDoc[loadedimgid] = t.responseXML.documentElement; + preloadXmlFinished[loadedimgid] = true; - if( loadedimgid == curImgId) // coming from loadImage() + if( loadedimgid == curImgId ) // coming from loadImage() { myLinImage.changeImage(); } else // coming from preloadImage() { - preloadXmlFinished[loadedimgid] = true; myLinImage.preloadImage(loadedimgid); } }, @@ -92,6 +93,7 @@ // once image is preloaded, resize image container imgPreloader.onload=function(){ + preloadImageFinished[curImgId] = true; $('mainImage').src = currentImgSrc; myLinImage.resizeImageContainer(imgWidth, imgHeight); } @@ -142,7 +144,7 @@ showImage: function(){ Element.hide('divloading'); new Effect.Appear('mainImage', { duration: 0.5, afterFinish: function(){ myLinImage.setImageInfoLink(); } }); - $('divimage').style.height = $('mainImage').style.height; // reset height to auto change if image is bigger or smaller + $('divimage').style.height = $('mainImage').style.height; // reset to correct height to prevent trouble if image is bigger or smaller this.setImageData(); this.preloadXml(); @@ -324,7 +326,10 @@ for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('nextthumb').length; i++) { var thumbId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; - this.loadImageXml(thumbId); + if(! preloadXmlFinished[thumbId]) + { + this.loadImageXml(thumbId); + } } } @@ -334,7 +339,10 @@ for(var i = xmlDoc[curImgId].getElementsByTagName('prevthumb').length-1; i >= 0; i--) { var thumbId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; - this.loadImageXml(thumbId); + if(! preloadXmlFinished[thumbId]) + { + this.loadImageXml(thumbId); + } } } }, Modified: trunk/linpha2/templates/default/css/global.css =================================================================== --- trunk/linpha2/templates/default/css/global.css 2006-10-08 15:42:12 UTC (rev 4577) +++ trunk/linpha2/templates/default/css/global.css 2006-10-08 18:02:04 UTC (rev 4578) @@ -115,19 +115,20 @@ /** * right */ -/* #divright + #divright { - position: absolute; + margin: 10px 10px 10px 10px; +/* position: absolute; top: 280px; - right: 10px; + right: 10px;*/ } #right { - width: 205px; +// width: 205px; padding: 5px; margin: 0px; - }*/ + } /** * menu Modified: trunk/linpha2/templates/default/view_img_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_img_static.html.php 2006-10-08 15:42:12 UTC (rev 4577) +++ trunk/linpha2/templates/default/view_img_static.html.php 2006-10-08 18:02:04 UTC (rev 4578) @@ -42,9 +42,11 @@ } else { ?> <!-- show image --> + <div id="divimage"> <img id="mainimage" width="<?php echo $GLOBALS['linpha']->imgview->img_width; ?>" height="<?php echo $GLOBALS['linpha']->imgview->img_height; ?>" src="<?php echo LINPHA_DIR.'/get_image.php?id='.$GLOBALS['linpha']->imgview->id_current. '&max_width='.$GLOBALS['linpha']->imgview->img_width.'&max_height='.$GLOBALS['linpha']->imgview->img_height; ?>" /> + </div> <br /><br /> <!-- comments --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-08 22:20:43
|
Revision: 4579 http://svn.sourceforge.net/linpha/?rev=4579&view=rev Author: fangehrn Date: 2006-10-08 15:20:11 -0700 (Sun, 08 Oct 2006) Log Message: ----------- 2006-10-08 flo * some minor improvements Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/get_image.php trunk/linpha2/index.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.template.class.php trunk/linpha2/lib/js/LinImage.js trunk/linpha2/lib/js/LinThumbnails.js trunk/linpha2/templates/default/css/global.css trunk/linpha2/templates/default/css/view_img.css trunk/linpha2/templates/default/css/view_thumb.css trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/view_img.head.php trunk/linpha2/templates/default/view_img_static.html.php trunk/linpha2/templates/default/view_thumb.head.php trunk/linpha2/templates/default/view_thumb_static.html.php Added Paths: ----------- trunk/linpha2/lib/js/LinGlobal.js trunk/linpha2/lib/modules/module.ajax.php Removed Paths: ------------- trunk/linpha2/lib/js/LinSyslog.js trunk/linpha2/templates/default/css/syslog.css Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/ChangeLog 2006-10-08 22:20:11 UTC (rev 4579) @@ -1,4 +1,7 @@ 2006-10-08 flo + * some minor improvements + +2006-10-08 flo * some improvements done, now it runs quite smooth :-) 2006-10-08 flo Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/docs/dev/TODO.txt 2006-10-08 22:20:11 UTC (rev 4579) @@ -4,7 +4,6 @@ ## Small Todos -- add possibility to force static view for old browsers with half javascript working - save image height and width in database to reduce file access in get_image.php and imgview() ? ## Big Todos Modified: trunk/linpha2/get_image.php =================================================================== --- trunk/linpha2/get_image.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/get_image.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -23,7 +23,7 @@ * @package Image */ -//sleep(3); +sleep(5); if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','.'); } Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/index.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -41,6 +41,9 @@ case 'settings': include_once(LINPHA_DIR.'/lib/modules/module.settings.php'); break; +case 'ajax': + include_once(LINPHA_DIR.'/lib/modules/module.ajax.php'); + break; } ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -212,6 +212,9 @@ break; } + /** + * at this point, there should be absolut no output + */ include_once(LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/global.html.php'); } Modified: trunk/linpha2/lib/classes/linpha.template.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.template.class.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/lib/classes/linpha.template.class.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -49,6 +49,52 @@ $filename = LINPHA_DIR.'/templates/'.$this->template_name.'/'.$this->body_name.'.html.php'; break; case 'head': +/** + * do some common definitions in head + */ +?> +<!-- css includes --> +<link rel='stylesheet' href='<?php echo LINPHA_DIR.'/templates/'.$this->template_name.'/css/global.css'; ?>' type='text/css'> +<link rel='stylesheet' href='<?php $this->includeFile('css'); ?>' type='text/css'> + <!-- IE hack for the menu--> + <!--[if IE]> + <style type="text/css" media="screen"> + #menu a, #menu span + { + width: 50px; + } + </style> + <![endif]--> + <!--[if lt IE 7]> + <style type="text/css" media="screen"> + body { + behavior: url(templates/default/css/csshover.htc); + font-size: 100%; + } + + #menu ul li a {height: 1%;} + + #menu a, #menu span { + font: bold 0.7em/1.4em arial, helvetica, sans-serif; + } + </style> + <![endif]--> + +<?php if( isset( $GLOBALS['linpha']->template->output['slideshow_head'] ) ) { + echo '<!-- slideshow-->'; + echo $GLOBALS['linpha']->template->output['slideshow_head']; +} ?> + +<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/prototype.js"></script> +<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/LinGlobal.js"></script> +<?php +if(! isset($_SESSION['use_js']) && ! isset($_SESSION['disable_ajax'])) +{ +?> +<script type="text/javascript" language="JavaScript">var LINPHA_DIR = '<?php echo LINPHA_DIR; ?>'; checkAjaxCompatibility();</script> +<?php +} + $filename = LINPHA_DIR.'/templates/'.$this->template_name.'/'.$this->head_name.'.head.php'; break; case 'css': Added: trunk/linpha2/lib/js/LinGlobal.js =================================================================== --- trunk/linpha2/lib/js/LinGlobal.js (rev 0) +++ trunk/linpha2/lib/js/LinGlobal.js 2006-10-08 22:20:11 UTC (rev 4579) @@ -0,0 +1,77 @@ + +/** + * dynamically open syslog + * used in ajax context + */ +function linSyslog(text) +{ + $('divSyslogText').innerHTML = text; + Element.show('divSyslog'); +} + +/** + * check ajax compatibilty + * will be on every page view until it was successfully + * then, the page will be reloaded + * + * use this on every page and not only on home page, because if user is linked directly to an image + * + * ajax may be disabled with ./?cat=ajax&disable_ajax + * and may be re-enabled with ./?cat=ajax&enable_ajax + */ +function checkAjaxCompatibility() +{ + new Ajax.Request(LINPHA_DIR + '/?cat=ajax&use_js', {asynchronous:true, onSuccess:checkAjaxCompatibilitySuccess} ); +} + +/** + * reload page, now with ajax activated + * will be called if the request in checkAjaxCompatibility() was successfully + */ +function checkAjaxCompatibilitySuccess(t) +{ + location.reload(); + linSyslog('Ajax enabled'); +} + +/** + * setMainHeight + * + * sets the height in thumb and image view of the "divmain" + */ +function setMainHeight() +{ + + /** + * get some values + * browser incompatibilities... + * + * needs to be in display_images! + */ + var linInnerWidth, linInnerHeight; + if (window.innerHeight) // all except Explorer + { + //linInnerWidth = self.innerWidth; + linInnerHeight = self.innerHeight; + } + else if (document.body && document.body.offsetWidth) + { + //linInnerWidth = document.body.offsetWidth; + linInnerHeight = document.body.offsetHeight; + } + else + { + //linInnerWidth = 500; // take a default value (@todo needs testing, maybe anyway never needed) + linInnerHeight = 300; // take a default value (needs teseting) + } + + var newHeight = linInnerHeight - $('main').offsetTop - 40; // 35 = 15 (bottom rounded corners) + 10 (margin-bottom) + 15 (??) + if(newHeight < 100) + { + newHeight = 100; + } + + $('main').style.height = newHeight; + +} + Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-08 22:20:11 UTC (rev 4579) @@ -486,6 +486,16 @@ return returnarray; } +/** + * onWindowResize + * + * will be called if the window is resized + */ +function onWindowResize() +{ + myLinImage.setImageInfoLink(); +// setMainHeight(); // defined in LinGlobal.js +} /** * init on finished page load @@ -493,9 +503,12 @@ function initLinImage() { setInfoColors(); + $('divimage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded + $('mainImage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded myLinImage = new LinImage(); myLinImage.loadImage(startImgId); - window.onresize = myLinImage.setImageInfoLink; +// setMainHeight(); // defined in LinGlobal.js + window.onresize = onWindowResize; } Event.observe(window, 'load', initLinImage, false); Deleted: trunk/linpha2/lib/js/LinSyslog.js =================================================================== --- trunk/linpha2/lib/js/LinSyslog.js 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/lib/js/LinSyslog.js 2006-10-08 22:20:11 UTC (rev 4579) @@ -1,24 +0,0 @@ -var window_is_open = false; -function toggleWindow() -{ - if( window_is_open ) - { - window_is_open = false; - - document.getElementById('sys_log').style.width = '20px'; - document.getElementById('sys_log').style.height = '20px'; - - document.getElementById('sys_log_text').style.visibility = 'hidden'; - } - else - { - window_is_open = true; - - document.getElementById('sys_log').style.width = 'auto'; - document.getElementById('sys_log').style.height = 'auto'; - - document.getElementById('sys_log_text').style.visibility = ''; - } -} - -toggleWindow(); \ No newline at end of file Modified: trunk/linpha2/lib/js/LinThumbnails.js =================================================================== --- trunk/linpha2/lib/js/LinThumbnails.js 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/lib/js/LinThumbnails.js 2006-10-08 22:20:11 UTC (rev 4579) @@ -15,7 +15,7 @@ * better a space more than a space too less */ var img_spacer_width = 12; // used to calculate nr_cols -var img_spacer_height = 9; // used to calculate nr_rows +var img_spacer_height = 11; // used to calculate nr_rows var img_div_spacer_height = 11; // used to calculate max-height of the image (depending how much text we would like to add) /** @@ -32,32 +32,9 @@ function display_images() { /** - * get some values - * browser incompatibilities... - * - * needs to be in display_images! - */ - var linInnerWidth, linInnerHeight; - if (window.innerHeight) // all except Explorer - { - linInnerWidth = self.innerWidth; - linInnerHeight = self.innerHeight; - } - else if (document.body && document.body.offsetWidth) - { - linInnerWidth = document.body.offsetWidth; - linInnerHeight = document.body.offsetHeight; - } - else - { - linInnerWidth = 500; // take a default value (@todo needs testing, maybe anyway never needed) - linInnerHeight = 300; // take a default value (needs teseting) - } - - /** * set correct main height only if photos_per_page == auto */ - document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; + setMainHeight(); // defined in LinGlobal.js /** * calculate nr of photos per page (from select form) @@ -148,6 +125,8 @@ * flush buffer of divhtmltext on end of line * with this buffer, we're 3-4 as fast as without !! * see also http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation !! + * + * update: using the DOM functions with createElement etc. we would be at least 2 times slower!! */ if( (img_nr-1) % nr_cols == 0) { Added: trunk/linpha2/lib/modules/module.ajax.php =================================================================== --- trunk/linpha2/lib/modules/module.ajax.php (rev 0) +++ trunk/linpha2/lib/modules/module.ajax.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -0,0 +1,59 @@ +<?php +/* + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * Ajax + * @package Modules + */ + +/** + * use ajax if requested + */ +if(isset($_GET['use_js'])) +{ + $_SESSION['use_js'] = true; + echo 'use_js saved'; +} + +/** + * force ajax disable + */ +if(isset($_GET['disable_ajax'])) +{ + $_SESSION['disable_ajax'] = true; + echo 'disable_ajax saved'; +} +/** + * re-enable + */ +if(isset($_GET['enable_ajax'])) +{ + if(isset($_SESSION['disable_ajax'])) + { + unset($_SESSION['disable_ajax']); + echo 'enable_ajax saved (was disabled before)'; + } + else + { + echo 'enable_ajax saved (but was not disabled before)'; + } +} + + ?> \ No newline at end of file Modified: trunk/linpha2/templates/default/css/global.css =================================================================== --- trunk/linpha2/templates/default/css/global.css 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/css/global.css 2006-10-08 22:20:11 UTC (rev 4579) @@ -5,6 +5,7 @@ body { font-family: arial, helvetica, sans-serif; margin: 0px; + padding: 0px; } a:link { @@ -107,6 +108,7 @@ */ #divmain { margin: 0px 10px 10px 10px; + padding: 0px; } #main { padding: 5px; @@ -114,22 +116,47 @@ /** * right + * + * @todo not used anymore, but in static view.. */ #divright { margin: 10px 10px 10px 10px; -/* position: absolute; - top: 280px; - right: 10px;*/ } #right { -// width: 205px; - padding: 5px; margin: 0px; } + +/** + * syslog + */ + #divSysLog { + position: absolute; + left: 15px; + top: 15px; + width: auto; + z-index: 10; + + padding: 5px; + + border: 1px solid #FFD500; + background-color: #FFFF81; + } + + #divSyslogClose { + position: absolute; + right: 0; + top: 0; + z-index: 10; + + background-color: #ffd5ee; + border: 1px solid #f09; + } + + /** * menu */ Deleted: trunk/linpha2/templates/default/css/syslog.css =================================================================== --- trunk/linpha2/templates/default/css/syslog.css 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/css/syslog.css 2006-10-08 22:20:11 UTC (rev 4579) @@ -1,24 +0,0 @@ -#sys_log { - position: absolute; - left: 15px; - top: 15px; - width: auto; - - z-index: 10; - - padding: 5px; - - border: 1px solid #FFD500; - background-color: #FFFF81; - -} - -#sys_log_close { - position: absolute; - right: 0; - top: 0; - z-index: 10; - - background-color: #ffd5ee; - border: 1px solid #f09; -} \ No newline at end of file Modified: trunk/linpha2/templates/default/css/view_img.css =================================================================== --- trunk/linpha2/templates/default/css/view_img.css 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/css/view_img.css 2006-10-08 22:20:11 UTC (rev 4579) @@ -33,7 +33,7 @@ #divinfolinks { position: absolute; text-align: right; - width: 50px; /* hardcoded in LinImage.js setImageInfoLink() change to!*/ + width: 50px; /* hardcoded in LinImage.js setImageInfoLink() better to not change!*/ } Modified: trunk/linpha2/templates/default/css/view_thumb.css =================================================================== --- trunk/linpha2/templates/default/css/view_thumb.css 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/css/view_thumb.css 2006-10-08 22:20:11 UTC (rev 4579) @@ -1,17 +1,16 @@ -/*#main { - height: 85%; -}*/ /** - * need this to calculate heigh of main div + * not used anymore + + need this to calculate heigh of main div * if you're gettings scrollbars, adjust the height! * height: 12.52em; dosent work, it increases to much if we adjust browsers font-size - */ + #spacer_height { height: 208px; position: absolute; visibility: hidden; -} +}*/ /** * page nr @@ -57,7 +56,7 @@ .img_thumbnail { border: 0; - width: auto; + /*width: auto;*/ } .img_text { Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/global.html.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -9,42 +9,6 @@ <head> <title><?php echo $GLOBALS['linpha']->template->linpha_title; ?></title> -<!-- css includes --> -<link rel='stylesheet' href='<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/css/global.css'; ?>' type='text/css'> -<link rel='stylesheet' href='<?php $GLOBALS['linpha']->template->includeFile('css'); ?>' type='text/css'> - <!-- IE hack for the menu--> - <!--[if IE]> - <style type="text/css" media="screen"> - #menu a, #menu span - { - width: 50px; - } - </style> - <![endif]--> - <!--[if lt IE 7]> - <style type="text/css" media="screen"> - body { - behavior: url(templates/default/css/csshover.htc); - font-size: 100%; - } - - #menu ul li a {height: 1%;} - - #menu a, #menu span { - font: bold 0.7em/1.4em arial, helvetica, sans-serif; - } - </style> - <![endif]--> - -<?php if( isset( $GLOBALS['linpha']->template->output['sys_log'] ) ) { ?> - <link rel='stylesheet' href='<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/css/syslog.css'; ?>' type='text/css'> -<?php } ?> - -<?php if( isset( $GLOBALS['linpha']->template->output['slideshow_head'] ) ) { - echo '<!-- slideshow-->'; - echo $GLOBALS['linpha']->template->output['slideshow_head']; -} ?> - <?php $GLOBALS['linpha']->template->includeFile('head'); ?> </head> @@ -52,17 +16,14 @@ <body> -<?php if( isset($GLOBALS['linpha']->template->output['sys_log']) ) { ?> - <!-- syslog --> - <div id="sys_log"> - <div id="sys_log_close"><a href="javascript:toggleWindow()">X</a></div> - <div id="sys_log_text"> - <?php echo i18n("Linpha Syslog"); ?>:<br /> - <?php echo $GLOBALS['linpha']->template->output['sys_log']; ?> - </div> +<!-- syslog --> +<div id="divSyslog"<?php if( ! isset($GLOBALS['linpha']->template->output['sys_log']) ) { echo ' style="display: none;"'; } ?>> + <div id="divSyslogClose"><a href="javascript:void(0);" onclick="Element.hide('divSyslog')">X</a></div> + <?php echo i18n("Linpha Syslog"); ?>:<br /> + <div id="divSyslogText"> + <?php echo $GLOBALS['linpha']->template->output['sys_log']; ?> </div> - <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/classes/syslog.js"> </script> -<?php } ?> +</div> <!-- title/navigation --> <div id="title"> Modified: trunk/linpha2/templates/default/view_img.head.php =================================================================== --- trunk/linpha2/templates/default/view_img.head.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/view_img.head.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -5,8 +5,8 @@ var thumbSrc = '<?php echo LINPHA_DIR.'/get_thumb.php?id='; ?>'; var imageSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; var startImgId = <?php echo $GLOBALS['linpha']->imgview->id_current; ?>; +var startImgHeight = <?php echo $GLOBALS['linpha']->imgview->img_height; ?>; </script> -<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/prototype.js"></script> <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/LinImage.js"> </script> Modified: trunk/linpha2/templates/default/view_img_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_img_static.html.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/view_img_static.html.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -1,10 +1,4 @@ -<script language="JavaScript" type="text/javascript"> -<!-- -location.href = "<?php echo convert_amp($GLOBALS['linpha']->template->URL_full.'&use_js=1'); ?>"; -//--> -</script> - <?php if(isset($GLOBALS['linpha']->template->output['navigation']) && !empty($GLOBALS['linpha']->template->output['navigation'])) { ?> <div id="navigation"> <?php echo $GLOBALS['linpha']->template->output['navigation']; ?> Modified: trunk/linpha2/templates/default/view_thumb.head.php =================================================================== --- trunk/linpha2/templates/default/view_thumb.head.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/view_thumb.head.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -7,4 +7,6 @@ var photos_per_page = 'auto'; <?php echo $GLOBALS['linpha']->template->output['files_db']."\n"; ?> </script> + +<script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/scriptaculous.js?load=builder"></script> <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/LinThumbnails.js"></script> Modified: trunk/linpha2/templates/default/view_thumb_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_thumb_static.html.php 2006-10-08 18:02:04 UTC (rev 4578) +++ trunk/linpha2/templates/default/view_thumb_static.html.php 2006-10-08 22:20:11 UTC (rev 4579) @@ -1,10 +1,4 @@ -<script language="JavaScript" type="text/javascript"> -<!-- -location.href = "<?php echo convert_amp($GLOBALS['linpha']->template->URL_full.'&use_js=1'); ?>"; -//--> -</script> - <!-- navigation --> <?php if(isset($GLOBALS['linpha']->template->output['navigation']) && !empty($GLOBALS['linpha']->template->output['navigation'])) { ?> <div id="divnavigation"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-09 20:53:27
|
Revision: 4580 http://svn.sourceforge.net/linpha/?rev=4580&view=rev Author: fangehrn Date: 2006-10-09 13:52:58 -0700 (Mon, 09 Oct 2006) Log Message: ----------- 2006-10-08 flo * implemented keyboard navigation ('n' for next, 'p' for prev, other suggestions?) * implemented full screen view with navigation please have a look!! :-) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/get_image.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/js/LinGlobal.js trunk/linpha2/lib/js/LinImage.js trunk/linpha2/lib/js/LinThumbnails.js trunk/linpha2/templates/default/css/global.css trunk/linpha2/templates/default/css/view_img.css trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/view_img.head.php trunk/linpha2/templates/default/view_img.html.php trunk/linpha2/templates/default/view_img_static.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/ChangeLog 2006-10-09 20:52:58 UTC (rev 4580) @@ -1,4 +1,9 @@ 2006-10-08 flo + * implemented keyboard navigation ('n' for next, 'p' for prev, other suggestions?) + * implemented full screen view with navigation + please have a look!! :-) + +2006-10-08 flo * some minor improvements 2006-10-08 flo Modified: trunk/linpha2/get_image.php =================================================================== --- trunk/linpha2/get_image.php 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/get_image.php 2006-10-09 20:52:58 UTC (rev 4580) @@ -23,7 +23,7 @@ * @package Image */ -sleep(5); +//sleep(5); if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','.'); } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-09 20:52:58 UTC (rev 4580) @@ -420,6 +420,9 @@ $GLOBALS['linpha']->template->output['menu_Icons'] = ''; if($this->mode == 'thumb') { + /** + * basket icons + */ if( $GLOBALS['linpha']->sql->checkPermission('basket_download')) { $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=download">'. @@ -438,9 +441,21 @@ '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Images").'" />' .'</a>'."\n"; } + /** + * slideshow icons + */ + if( $_SESSION['use_js']) { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="javascript:slideshowStartFromThumbview()">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Play Slideshow").'" />' + .'</a>'."\n"; + } + } elseif($this->mode == 'image') { + /** + * basket icons + */ if( $GLOBALS['linpha']->sql->checkPermission('download')) { $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.LINPHA_DIR.'/download_file.php?id='.$this->id_current.'">'. @@ -459,6 +474,15 @@ '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Image").'" />' .'</a>'."\n"; } + + /** + * slideshow icons + */ + if( $_SESSION['use_js']) { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="javascript:myLinImage.fullscreenStart()">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Play Slideshow").'" />' + .'</a>'."\n"; + } } } @@ -526,7 +550,7 @@ * prepare stuff for slideshow * @uses LinImgview::buildImgView() */ -function slideshow() +/*function slideshow() { foreach($this->photos_filtered AS $key=>$photo_value) { @@ -568,7 +592,7 @@ '<br /><a href="#" onclick="myLightbox.start();">'.i18n("Start Slideshow").'<img src="'.LINPHA_DIR.'/templates/default/images/slideshow.png" border="0" /></a>'."\n". '</div>'."\n"; } -} +}*/ @@ -1098,6 +1122,7 @@ <imgid><?php echo $this->id_current; ?></imgid> <imgwidth><?php echo $this->org_width; ?></imgwidth> <imgheight><?php echo $this->org_height; ?></imgheight> +<imgnr><?php printf(i18n("Image %s of %s"),$this->current_key+1,count($this->photos_filtered)); ?></imgnr> <title><?php echo str_replace('<','<',$GLOBALS['linpha']->template->linpha_title." :: ".$GLOBALS['linpha']->template->output['title']); ?></title> <?php if(isset($this->xmldata['prev_thumb'])) { Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-10-09 20:52:58 UTC (rev 4580) @@ -452,7 +452,15 @@ */ function getIgnoreFilelist() { - return Array('CVS','Thumbs.db','ZbThumbnail.info','lost+found'); + return Array( + 'CVS', // CVS + 'Thumbs.db', // Windows + 'ZbThumbnail.info', // ? + '_vti_cnf', // IIS + '_derived', // IIS + 'lost+found' // Linux + ); + } Modified: trunk/linpha2/lib/js/LinGlobal.js =================================================================== --- trunk/linpha2/lib/js/LinGlobal.js 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/lib/js/LinGlobal.js 2006-10-09 20:52:58 UTC (rev 4580) @@ -18,10 +18,12 @@ * * ajax may be disabled with ./?cat=ajax&disable_ajax * and may be re-enabled with ./?cat=ajax&enable_ajax + * + * http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request */ function checkAjaxCompatibility() { - new Ajax.Request(LINPHA_DIR + '/?cat=ajax&use_js', {asynchronous:true, onSuccess:checkAjaxCompatibilitySuccess} ); + new Ajax.Request(LINPHA_DIR + '/?cat=ajax&use_js', {method:'get', asynchronous:true, onSuccess:checkAjaxCompatibilitySuccess} ); } /** @@ -39,32 +41,34 @@ * * sets the height in thumb and image view of the "divmain" */ -function setMainHeight() +var linInnerWidth, linInnerHeight; + +function getWindowSize() { - /** - * get some values * browser incompatibilities... - * - * needs to be in display_images! */ - var linInnerWidth, linInnerHeight; if (window.innerHeight) // all except Explorer { - //linInnerWidth = self.innerWidth; + linInnerWidth = self.innerWidth; linInnerHeight = self.innerHeight; } else if (document.body && document.body.offsetWidth) { - //linInnerWidth = document.body.offsetWidth; + linInnerWidth = document.body.offsetWidth; linInnerHeight = document.body.offsetHeight; } else { - //linInnerWidth = 500; // take a default value (@todo needs testing, maybe anyway never needed) - linInnerHeight = 300; // take a default value (needs teseting) - } + linInnerWidth = 500; + linInnerHeight = 300; + } +} +function setMainHeight() +{ + getWindowSize(); + var newHeight = linInnerHeight - $('main').offsetTop - 40; // 35 = 15 (bottom rounded corners) + 10 (margin-bottom) + 15 (??) if(newHeight < 100) { @@ -72,6 +76,5 @@ } $('main').style.height = newHeight; - } Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-09 20:52:58 UTC (rev 4580) @@ -4,6 +4,10 @@ } var curImgId; +var nextThumbs = new Array(); +var prevThumbs = new Array(); +var slideshowActive = false; +var slideshowOldMaxWidth, slideshowOldMaxHeight; var xmlDoc = new Array(); var preloadImage = new Array(); @@ -39,7 +43,7 @@ loadImageXml: function(imgId) { // http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request - new Ajax.Request(xmlUrl + '&id=' + imgId + '&xml', {asynchronous:true, onSuccess:this.loadImageContinue, onFailure:errFunc} ); + new Ajax.Request(xmlUrl + '&id=' + imgId + '&xml', {method:'get', asynchronous:true, onSuccess:this.loadImageContinue, onFailure:errFunc} ); }, loadImageContinue: function(t) { @@ -59,6 +63,18 @@ } }, + movePrev: function() { + if(prevThumbs[ prevThumbs.length - 1 ]) + { + myLinImage.loadImage(prevThumbs[ prevThumbs.length - 1 ]); + } + }, + moveNext: function() { + if(nextThumbs[0]) + { + myLinImage.loadImage(nextThumbs[0]); + } + }, // // changeImage() @@ -66,12 +82,17 @@ changeImage: function() { /** - * hide meta text immediately + * set height of outer div to prevent the whole page getting smaller, and if the image is loaded getting bigger again + * but we want no activities in background */ - hideImgInfoNow(); + if(! slideshowActive) { + $('divimage').style.height = $('mainImage').style.height; + } - // hide elements during transition - $('divimage').style.height = $('mainImage').style.height; // set height of outer div to prevent the whole page getting smaller, and if the image is loaded getting bigger again + /** + * hide elements during transition + */ + hideImgInfoNow(); // hide meta text immediately Element.show('divloading'); Element.hide('mainImage'); Element.hide('divinfolinks'); @@ -81,9 +102,9 @@ */ var orgWidth = xmlDoc[curImgId].getElementsByTagName('imgwidth').item(0).firstChild.data; var orgHeight = xmlDoc[curImgId].getElementsByTagName('imgheight').item(0).firstChild.data; - var sizeArray = scaleToFit(orgWidth,orgHeight,imageSize,imageSize,1); - imgWidth = sizeArray[0]; - imgHeight = sizeArray[1]; + var sizeArray = scaleToFit(orgWidth,orgHeight,maxImageWidth,maxImageHeight,1); + var imgWidth = sizeArray[0]; + var imgHeight = sizeArray[1]; /** * preload image @@ -91,7 +112,13 @@ var currentImgSrc = imageSrc + curImgId + '&max_width=' + imgWidth + '&max_height=' + imgHeight; imgPreloader = new Image(); - // once image is preloaded, resize image container + /** + * once image is preloaded, resize image container + * + * pay attention with other image preloader! + * if imgWidth and imgWidth was not set with trailing 'var' it got overlapping with the other variables + * and hence the image was not resized correctly in resizeImageContainer() !!! + */ imgPreloader.onload=function(){ preloadImageFinished[curImgId] = true; $('mainImage').src = currentImgSrc; @@ -144,8 +171,13 @@ showImage: function(){ Element.hide('divloading'); new Effect.Appear('mainImage', { duration: 0.5, afterFinish: function(){ myLinImage.setImageInfoLink(); } }); - $('divimage').style.height = $('mainImage').style.height; // reset to correct height to prevent trouble if image is bigger or smaller + if(! slideshowActive) { + $('divimage').style.height = $('mainImage').style.height; // reset to correct height to prevent trouble if image is bigger or smaller + } + + this.enableKeyboardNav(); + this.setImageData(); this.preloadXml(); }, @@ -167,23 +199,14 @@ * set prev thumbs */ $('thumbnavi_prevthumb').innerHTML = ''; + prevThumbs = new Array(); if(xmlDoc[curImgId].getElementsByTagName('prevthumb').length > 0) { for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('prevthumb').length; i++) { - var prevThumbId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; - - var ElemImg = Builder.node('img', {id: 'thumb'+prevThumbId, className: 'img_prevnextthumb', src: thumbSrc + prevThumbId}); - var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + prevThumbId + ')'}); - var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); - - ElemA.appendChild( ElemImg ); - ElemDiv.appendChild( ElemA ); - $('thumbnavi_prevthumb').appendChild(ElemDiv); - - if(! preloadImageFinished[prevThumbId]) { - Element.setOpacity('thumb'+prevThumbId,0.5); - } + var thumbId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; + prevThumbs[i] = thumbId; + this.setPrevNextThumb(thumbId, 'thumbnavi_prevthumb'); } } @@ -191,23 +214,14 @@ * set next thumbs */ $('thumbnavi_nextthumb').innerHTML = ''; + nextThumbs = new Array(); if(xmlDoc[curImgId].getElementsByTagName('nextthumb').length > 0) { for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('nextthumb').length; i++) { - var nextThumbId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; - - var ElemImg = Builder.node('img', {id: 'thumb'+nextThumbId, className: 'img_prevnextthumb', src: thumbSrc + nextThumbId}); - var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + nextThumbId + ')'}); - var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); - - ElemA.appendChild( ElemImg ); - ElemDiv.appendChild( ElemA ); - $('thumbnavi_nextthumb').appendChild(ElemDiv); - - if(! preloadImageFinished[nextThumbId]) { - Element.setOpacity('thumb'+nextThumbId,0.5); - } + var thumbId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; + nextThumbs[i] = thumbId; + this.setPrevNextThumb(thumbId, 'thumbnavi_nextthumb'); } } @@ -255,20 +269,45 @@ } } + /** + * set image nr + * currently only in slideshow used + */ + $('divSlideshowImgNr').innerHTML = xmlDoc[curImgId].getElementsByTagName('imgnr').item(0).firstChild.data; + }, // end function setImageData() + setPrevNextThumb: function(thumbId, divId) + { + var ElemImg = Builder.node('img', {id: 'thumb'+thumbId, className: 'img_prevnextthumb', src: thumbSrc + thumbId}); + var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + thumbId + ')'}); + var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); + + ElemA.appendChild( ElemImg ); + ElemDiv.appendChild( ElemA ); + $(divId).appendChild(ElemDiv); + + if(! preloadImageFinished[thumbId]) { + Element.setOpacity('thumb'+thumbId,0.5); + } + + }, + /** * setImageInfoLink * * set positions of info link * could only be done after image has been completly loaded */ - setImageInfoLink: function() { - $('divinfolinks').style.top = $('mainImage').offsetTop + $('mainImage').offsetHeight; - $('divinfolinks').style.left = $('mainImage').offsetLeft + $('mainImage').offsetWidth - 50; // 50: value of view_img.css width = 50px; can't get width with javascript because element is hidden - Element.show('divinfolinks'); - + setImageInfoLink: function() + { + if(! slideshowActive) + { + $('divinfolinks').style.top = $('mainImage').offsetTop + $('mainImage').offsetHeight; + $('divinfolinks').style.left = $('mainImage').offsetLeft + $('mainImage').offsetWidth - 50; // 50: value of view_img.css width = 50px; can't get width with javascript because element is hidden + Element.show('divinfolinks'); + } }, // @@ -297,21 +336,15 @@ key = String.fromCharCode(keycode).toLowerCase(); - if((key == 'x') || (key == 'o') || (key == 'c')){ // close lightbox - myLinImage.end(); + if( slideshowActive && ( (key == 'x') || (key == 'o') || (key == 'c') ) ) { // close slideshow + myLinImage.fullscreenStop(); } else if(key == 'p'){ // display previous image - if(activeImage != 0){ - myLinImage.disableKeyboardNav(); - myLinImage.changeImage(activeImage - 1); - } + myLinImage.disableKeyboardNav(); + myLinImage.movePrev(); } else if(key == 'n'){ // display next image - if(activeImage != (imageArray.length - 1)){ - myLinImage.disableKeyboardNav(); - myLinImage.changeImage(activeImage + 1); - } + myLinImage.disableKeyboardNav(); + myLinImage.moveNext(); } - - }, // @@ -360,9 +393,9 @@ */ var orgWidth = xmlDoc[imgId].getElementsByTagName('imgwidth').item(0).firstChild.data; var orgHeight = xmlDoc[imgId].getElementsByTagName('imgheight').item(0).firstChild.data; - var sizeArray = scaleToFit(orgWidth,orgHeight,imageSize,imageSize,1); - imgWidth = sizeArray[0]; - imgHeight = sizeArray[1]; + var sizeArray = scaleToFit(orgWidth,orgHeight,maxImageWidth,maxImageHeight,1); + var imgWidth = sizeArray[0]; + var imgHeight = sizeArray[1]; var currentImgSrc = imageSrc + imgId + '&max_width=' + imgWidth + '&max_height=' + imgHeight; @@ -381,12 +414,126 @@ preloadImageFinished: function(imgId) { new Effect.Appear('thumb'+imgId, { duration: 0.5, from: 0.5, to: 1.0 }); preloadImageFinished[imgId] = true; + }, + + fullscreenStart: function() + { + slideshowActive = true; + + /** + * save old values to restore if slideshow ends + * and set new window size + */ + slideshowOldMaxWidth = maxImageWidth; + slideshowOldMaxHeight = maxImageHeight; + onWindowResize(); + + /** + * start slideshow with some superduper effects + */ + Effect.Appear('divSlideshowOverlay', { queue: 'end', duration: 1.0, from: 0.0, to: 0.9 }); + Effect.BlindDown('divSlideshowControls', { queue: 'end'} ); + Element.show('divSlideshowImage'); + + /** + * steal the mainimage + */ + $('divimage').innerHTML = ''; + $('divSlideshowImage').innerHTML = '<img id="mainImage" style="display: none;" class="imgSlideshow">'; + + /** + * reload image with new position and size + */ + this.loadImage( curImgId ); + }, + + + fullscreenStop: function() + { + slideshowActive = false; + + /** + * restore max image size + */ + maxImageWidth = slideshowOldMaxWidth; + maxImageHeight = slideshowOldMaxHeight; + + /** + * end slideshow with some superduper effects + */ + Effect.Fold('divSlideshowControls', { queue: 'end'} ); + Effect.Fade('divSlideshowOverlay', { queue: 'end', duration: 0.5, from: 0.9, to: 0.0 } ); + Element.hide('divSlideshowImage'); + + /** + * give back the mainimage + */ + $('divSlideshowImage').innerHTML = ''; + $('divimage').innerHTML = '<img id="mainImage" style="display: none;">'; + + /** + * reload image with old position and size + */ + this.loadImage( curImgId ); + }, + + slideshowPlay: function() + { + }, + slideshowPause: function() + { + + }, + slideshowChangeDelay: function() + { + //currentDelay=document.optionsForm.delay.options[document.optionsForm.delay.selectedIndex].value * 1000;*/ } } +/** + * onWindowResize + * + * will be called if the window is resized + */ +function onWindowResize() +{ + if(slideshowActive) + { + getWindowSize(); + maxImageWidth = linInnerWidth - 70; + maxImageHeight = linInnerHeight - 120; + } + else + { + myLinImage.setImageInfoLink(); + // setMainHeight(); // defined in LinGlobal.js + } +} + +/** + * init on finished page load + */ +function initLinImage() +{ + setInfoColors(); + $('divimage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded + $('mainImage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded + myLinImage = new LinImage(); + myLinImage.loadImage(startImgId); +// setMainHeight(); // defined in LinGlobal.js + window.onresize = onWindowResize; + +} +Event.observe(window, 'load', initLinImage, false); + // ----------------------------------------------------------------------------------- +// end class LinImage +// ----------------------------------------------------------------------------------- +// ----------------------------------------------------------------------------------- +// Common used functions +// ----------------------------------------------------------------------------------- var colorinfoactive; var colorinfonotactive; @@ -487,28 +634,15 @@ } /** - * onWindowResize + * openTextarea() * - * will be called if the window is resized + * opens the bigger textarea to enter longer image comments + * this function is defined in view_img_static.html.php too */ -function onWindowResize() +function openTextarea() { - myLinImage.setImageInfoLink(); -// setMainHeight(); // defined in LinGlobal.js -} - -/** - * init on finished page load - */ -function initLinImage() -{ - setInfoColors(); - $('divimage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded - $('mainImage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded - myLinImage = new LinImage(); - myLinImage.loadImage(startImgId); -// setMainHeight(); // defined in LinGlobal.js - window.onresize = onWindowResize; + document.getElementById('comment_textarea').style.display = 'block'; + document.getElementById('comment_div_text').style.display = 'none'; -} -Event.observe(window, 'load', initLinImage, false); + document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; +} \ No newline at end of file Modified: trunk/linpha2/lib/js/LinThumbnails.js =================================================================== --- trunk/linpha2/lib/js/LinThumbnails.js 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/lib/js/LinThumbnails.js 2006-10-09 20:52:58 UTC (rev 4580) @@ -33,6 +33,7 @@ { /** * set correct main height only if photos_per_page == auto + * needs to be in display_images! */ setMainHeight(); // defined in LinGlobal.js @@ -420,6 +421,16 @@ } /** + * slideshowStartFromThumbview() + * + * to start the slideshow, first open imageview with first image, and then start slideshow + */ +function slideshowStartFromThumbview() +{ + location.href = link_url + '&id=' + img_ids[0]['id'] + '&slideshow'; +} + +/** * function view_source_code() removed * use firefox extension "Aardvark" * much nicer ;-) Modified: trunk/linpha2/templates/default/css/global.css =================================================================== --- trunk/linpha2/templates/default/css/global.css 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/templates/default/css/global.css 2006-10-09 20:52:58 UTC (rev 4580) @@ -23,9 +23,9 @@ /** * background color - * #divthumbnavi used in view_img.html.php + * #divthumbnavi amd #divSlideshowControls used in view_img.html.php */ - #divleft, #divmain, #divright, #divthumbnavi, #divnavigation { + #divleft, #divmain, #divright, #divthumbnavi, #divnavigation, #divSlideshowControls { background-color: #f90; } @@ -306,21 +306,4 @@ display: block !important; } -/** - * slieshow - */ -#slideshow { - position: absolute; - top: 150px; - left: 150px; - - width: 400px; - height: 150px; - - padding: 5px; - - background-color: #d5fcf4; - - border: 1px solid #000000; -} --> \ No newline at end of file Modified: trunk/linpha2/templates/default/css/view_img.css =================================================================== --- trunk/linpha2/templates/default/css/view_img.css 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/templates/default/css/view_img.css 2006-10-09 20:52:58 UTC (rev 4580) @@ -111,4 +111,58 @@ width: 200px; margin: 5px; margin-left: 150px; - } \ No newline at end of file + } + +/** + * slieshow + */ +#divSlideshowOverlay +{ + position: absolute; + top: 0px; + left: 0px; + + width: 100%; + height: 100%; + + padding: 0px; + margin: 0px; + + z-index: 90; + background-color: #000; +} + +#divSlideshowControls +{ + position: absolute; + top: 0px; + left: 50%; + + padding: 0px; + margin: 0px; + + width: 500px; + margin-left: -250px; /* should be the half of 'width' */ + + z-index: 91; +} + + +#divSlideshowImage { + position: absolute; + top: 60px; + + padding: 0px; + margin: 0px; + + width: 100%; + + z-index: 91; + text-align: center; +} + +.imgSlideshow { + border: 20px solid white; +} + + Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/templates/default/global.html.php 2006-10-09 20:52:58 UTC (rev 4580) @@ -88,7 +88,6 @@ <?php if( isset( $GLOBALS['linpha']->template->output['menu_Icons'] ) ) { echo $GLOBALS['linpha']->template->output['menu_Icons']; } ?> - <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&slideshow=play"><img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png'; ?>" border="0" title="<?php echo i18n("Play Slideshow"); ?>" /></a> </div> <?php if($GLOBALS['linpha']->sql->isLoggedIn()) { ?> Modified: trunk/linpha2/templates/default/view_img.head.php =================================================================== --- trunk/linpha2/templates/default/view_img.head.php 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/templates/default/view_img.head.php 2006-10-09 20:52:58 UTC (rev 4580) @@ -3,7 +3,8 @@ var xmlUrl = '<?php echo convert_amp($GLOBALS['linpha']->template->URL_base); ?>'; var imageSrc = '<?php echo LINPHA_DIR.'/get_image.php?id='; ?>'; var thumbSrc = '<?php echo LINPHA_DIR.'/get_thumb.php?id='; ?>'; -var imageSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; +var maxImageWidth = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; +var maxImageHeight = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; var startImgId = <?php echo $GLOBALS['linpha']->imgview->id_current; ?>; var startImgHeight = <?php echo $GLOBALS['linpha']->imgview->img_height; ?>; </script> Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-09 20:52:58 UTC (rev 4580) @@ -26,7 +26,7 @@ </div> <div id="main"> <div id="divloading"> - <img src="<?php echo LINPHA_DIR; ?>/lib/classes/lightbox/images/loading.gif"> + <img src="<?php echo LINPHA_DIR; ?>/lib/graphics/loading.gif"> </div> <noscript><h1><?php echo i18n("If you have just disabled Javascript, you will need to restart your browser."); ?></h1></noscript> @@ -61,15 +61,6 @@ <input type="submit" name="submit" value="<?php echo i18n("submit"); ?>" /> </form> </div> - <script language="JavaScript" type="text/javascript"> - function openTextarea() - { - document.getElementById('comment_textarea').style.display = 'block'; - document.getElementById('comment_div_text').style.display = 'none'; - - document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; - } - </script> <br /> <?php } /* end if checkPermission('metadata_comments') */ ?> @@ -81,4 +72,49 @@ <div class="roundbottom"> <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> -</div> \ No newline at end of file +</div> + + +<div id="divSlideshowOverlay" style="display: none;"></div> +<div id="divSlideshowControls" style="display: none;"> + <div style="float: left; padding-left: 5px; "> + <a href="javascript:myLinImage.movePrev()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/prev.gif" width="25" height="25" border="0"></a> + <a href="javascript:myLinImage.moveNext()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/next.gif" width="25" height="25" border="0"></a> + || + <a href="javascript:myLinImage.slideshowPlay()">Play</a>/<a href="javascript:myLinImage.slideshowPause()">Pause</a> + <?php echo i18n("Delay"); ?>: + <select id="delay" name="delay" size="1" onchange="changeDelay()"> + <option value="3">3 s</option> + <option value="4">4 s</option> + <option value="5" selected>5 s</option> + <option value="10">10 s</option> + <option value="15">15 s</option> + <option value="30">30 s</option> + <option value="45">45 s</option> + <option value="60">60 s</option> + </select> + || + </div> + <div id="divSlideshowImgNr" style="float: left;"></div> + || + <a href="javascript:myLinImage.fullscreenStop()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/close.gif" width="25" height="25" border="0"></a> + + + <div style="clear: both;"></div> + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> +<div id="divSlideshowImage" style="display: none;"></div> + +<!-- +<div id="divSlideshowImage" style="display: none;"> + <div class="roundtop"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + <div id="divSlideshowImageInner"></div> + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> +--> Modified: trunk/linpha2/templates/default/view_img_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_img_static.html.php 2006-10-08 22:20:11 UTC (rev 4579) +++ trunk/linpha2/templates/default/view_img_static.html.php 2006-10-09 20:52:58 UTC (rev 4580) @@ -51,7 +51,7 @@ <?php echo i18n("Add Comment"); ?>:<br /> <div id="comment_div_text"> <input type="text" id="comment_input_text" name="comment_text" value="" tabindex="1" size="40" maxlength="40" /> - <a href="javascript:open_textarea()">(+)</a> + <a href="javascript:openTextarea()">(+)</a> </div> <textarea style="display: none;" id="comment_textarea" name="comment_textarea" tabindex="1" rows="10" cols="50"></textarea> <?php echo i18n("Name"); ?>: <input type="text" name="author" value="" tabindex="2" size="10" maxlength="40" /> @@ -60,7 +60,7 @@ </form> </div> <script language="JavaScript" type="text/javascript"> - function open_textarea() + function openTextarea() { document.getElementById('comment_textarea').style.display = 'block'; document.getElementById('comment_div_text').style.display = 'none'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: bzrudi <bz...@ce...> - 2006-10-10 11:45:21
|
Hi flo, great work, even if I testet just a couple of minutes :-) cheers bzrudi fan...@us... wrote: > Revision: 4580 > http://svn.sourceforge.net/linpha/?rev=4580&view=rev > Author: fangehrn > Date: 2006-10-09 13:52:58 -0700 (Mon, 09 Oct 2006) > > Log Message: > ----------- > 2006-10-08 flo > * implemented keyboard navigation ('n' for next, 'p' for prev, other suggestions?) > * implemented full screen view with navigation > please have a look!! :-) > > Modified Paths: > -------------- > trunk/linpha2/ChangeLog > trunk/linpha2/get_image.php > trunk/linpha2/lib/classes/linpha.imgview.class.php > trunk/linpha2/lib/classes/linpha.import.class.php > trunk/linpha2/lib/js/LinGlobal.js > trunk/linpha2/lib/js/LinImage.js > trunk/linpha2/lib/js/LinThumbnails.js > trunk/linpha2/templates/default/css/global.css > trunk/linpha2/templates/default/css/view_img.css > trunk/linpha2/templates/default/global.html.php > trunk/linpha2/templates/default/view_img.head.php > trunk/linpha2/templates/default/view_img.html.php > trunk/linpha2/templates/default/view_img_static.html.php > > Modified: trunk/linpha2/ChangeLog > =================================================================== > --- trunk/linpha2/ChangeLog 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/ChangeLog 2006-10-09 20:52:58 UTC (rev 4580) > @@ -1,4 +1,9 @@ > 2006-10-08 flo > + * implemented keyboard navigation ('n' for next, 'p' for prev, other suggestions?) > + * implemented full screen view with navigation > + please have a look!! :-) > + > +2006-10-08 flo > * some minor improvements > > 2006-10-08 flo > > Modified: trunk/linpha2/get_image.php > =================================================================== > --- trunk/linpha2/get_image.php 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/get_image.php 2006-10-09 20:52:58 UTC (rev 4580) > @@ -23,7 +23,7 @@ > * @package Image > */ > > -sleep(5); > +//sleep(5); > > if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','.'); } > > > Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php > =================================================================== > --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-09 20:52:58 UTC (rev 4580) > @@ -420,6 +420,9 @@ > $GLOBALS['linpha']->template->output['menu_Icons'] = ''; > if($this->mode == 'thumb') > { > + /** > + * basket icons > + */ > if( $GLOBALS['linpha']->sql->checkPermission('basket_download')) > { > $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=download">'. > @@ -438,9 +441,21 @@ > '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Images").'" />' > .'</a>'."\n"; > } > + /** > + * slideshow icons > + */ > + if( $_SESSION['use_js']) { > + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="javascript:slideshowStartFromThumbview()">'. > + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Play Slideshow").'" />' > + .'</a>'."\n"; > + } > + > } > elseif($this->mode == 'image') > { > + /** > + * basket icons > + */ > if( $GLOBALS['linpha']->sql->checkPermission('download')) > { > $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.LINPHA_DIR.'/download_file.php?id='.$this->id_current.'">'. > @@ -459,6 +474,15 @@ > '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Image").'" />' > .'</a>'."\n"; > } > + > + /** > + * slideshow icons > + */ > + if( $_SESSION['use_js']) { > + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="javascript:myLinImage.fullscreenStart()">'. > + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Play Slideshow").'" />' > + .'</a>'."\n"; > + } > } > } > > @@ -526,7 +550,7 @@ > * prepare stuff for slideshow > * @uses LinImgview::buildImgView() > */ > -function slideshow() > +/*function slideshow() > { > foreach($this->photos_filtered AS $key=>$photo_value) > { > @@ -568,7 +592,7 @@ > '<br /><a href="#" onclick="myLightbox.start();">'.i18n("Start Slideshow").'<img src="'.LINPHA_DIR.'/templates/default/images/slideshow.png" border="0" /></a>'."\n". > '</div>'."\n"; > } > -} > +}*/ > > > > @@ -1098,6 +1122,7 @@ > <imgid><?php echo $this->id_current; ?></imgid> > <imgwidth><?php echo $this->org_width; ?></imgwidth> > <imgheight><?php echo $this->org_height; ?></imgheight> > +<imgnr><?php printf(i18n("Image %s of %s"),$this->current_key+1,count($this->photos_filtered)); ?></imgnr> > <title><?php echo str_replace('<','<',$GLOBALS['linpha']->template->linpha_title." :: ".$GLOBALS['linpha']->template->output['title']); ?></title> > <?php > if(isset($this->xmldata['prev_thumb'])) { > > Modified: trunk/linpha2/lib/classes/linpha.import.class.php > =================================================================== > --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-10-09 20:52:58 UTC (rev 4580) > @@ -452,7 +452,15 @@ > */ > function getIgnoreFilelist() > { > - return Array('CVS','Thumbs.db','ZbThumbnail.info','lost+found'); > + return Array( > + 'CVS', // CVS > + 'Thumbs.db', // Windows > + 'ZbThumbnail.info', // ? > + '_vti_cnf', // IIS > + '_derived', // IIS > + 'lost+found' // Linux > + ); > + > } > > > > Modified: trunk/linpha2/lib/js/LinGlobal.js > =================================================================== > --- trunk/linpha2/lib/js/LinGlobal.js 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/lib/js/LinGlobal.js 2006-10-09 20:52:58 UTC (rev 4580) > @@ -18,10 +18,12 @@ > * > * ajax may be disabled with ./?cat=ajax&disable_ajax > * and may be re-enabled with ./?cat=ajax&enable_ajax > + * > + * http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request > */ > function checkAjaxCompatibility() > { > - new Ajax.Request(LINPHA_DIR + '/?cat=ajax&use_js', {asynchronous:true, onSuccess:checkAjaxCompatibilitySuccess} ); > + new Ajax.Request(LINPHA_DIR + '/?cat=ajax&use_js', {method:'get', asynchronous:true, onSuccess:checkAjaxCompatibilitySuccess} ); > } > > /** > @@ -39,32 +41,34 @@ > * > * sets the height in thumb and image view of the "divmain" > */ > -function setMainHeight() > +var linInnerWidth, linInnerHeight; > + > +function getWindowSize() > { > - > /** > - * get some values > * browser incompatibilities... > - * > - * needs to be in display_images! > */ > - var linInnerWidth, linInnerHeight; > if (window.innerHeight) // all except Explorer > { > - //linInnerWidth = self.innerWidth; > + linInnerWidth = self.innerWidth; > linInnerHeight = self.innerHeight; > } > else if (document.body && document.body.offsetWidth) > { > - //linInnerWidth = document.body.offsetWidth; > + linInnerWidth = document.body.offsetWidth; > linInnerHeight = document.body.offsetHeight; > } > else > { > - //linInnerWidth = 500; // take a default value (@todo needs testing, maybe anyway never needed) > - linInnerHeight = 300; // take a default value (needs teseting) > - } > + linInnerWidth = 500; > + linInnerHeight = 300; > + } > +} > > +function setMainHeight() > +{ > + getWindowSize(); > + > var newHeight = linInnerHeight - $('main').offsetTop - 40; // 35 = 15 (bottom rounded corners) + 10 (margin-bottom) + 15 (??) > if(newHeight < 100) > { > @@ -72,6 +76,5 @@ > } > > $('main').style.height = newHeight; > - > } > > > Modified: trunk/linpha2/lib/js/LinImage.js > =================================================================== > --- trunk/linpha2/lib/js/LinImage.js 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/lib/js/LinImage.js 2006-10-09 20:52:58 UTC (rev 4580) > @@ -4,6 +4,10 @@ > } > > var curImgId; > +var nextThumbs = new Array(); > +var prevThumbs = new Array(); > +var slideshowActive = false; > +var slideshowOldMaxWidth, slideshowOldMaxHeight; > > var xmlDoc = new Array(); > var preloadImage = new Array(); > @@ -39,7 +43,7 @@ > > loadImageXml: function(imgId) { > // http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request > - new Ajax.Request(xmlUrl + '&id=' + imgId + '&xml', {asynchronous:true, onSuccess:this.loadImageContinue, onFailure:errFunc} ); > + new Ajax.Request(xmlUrl + '&id=' + imgId + '&xml', {method:'get', asynchronous:true, onSuccess:this.loadImageContinue, onFailure:errFunc} ); > }, > > loadImageContinue: function(t) { > @@ -59,6 +63,18 @@ > } > }, > > + movePrev: function() { > + if(prevThumbs[ prevThumbs.length - 1 ]) > + { > + myLinImage.loadImage(prevThumbs[ prevThumbs.length - 1 ]); > + } > + }, > + moveNext: function() { > + if(nextThumbs[0]) > + { > + myLinImage.loadImage(nextThumbs[0]); > + } > + }, > > // > // changeImage() > @@ -66,12 +82,17 @@ > changeImage: function() { > > /** > - * hide meta text immediately > + * set height of outer div to prevent the whole page getting smaller, and if the image is loaded getting bigger again > + * but we want no activities in background > */ > - hideImgInfoNow(); > + if(! slideshowActive) { > + $('divimage').style.height = $('mainImage').style.height; > + } > > - // hide elements during transition > - $('divimage').style.height = $('mainImage').style.height; // set height of outer div to prevent the whole page getting smaller, and if the image is loaded getting bigger again > + /** > + * hide elements during transition > + */ > + hideImgInfoNow(); // hide meta text immediately > Element.show('divloading'); > Element.hide('mainImage'); > Element.hide('divinfolinks'); > @@ -81,9 +102,9 @@ > */ > var orgWidth = xmlDoc[curImgId].getElementsByTagName('imgwidth').item(0).firstChild.data; > var orgHeight = xmlDoc[curImgId].getElementsByTagName('imgheight').item(0).firstChild.data; > - var sizeArray = scaleToFit(orgWidth,orgHeight,imageSize,imageSize,1); > - imgWidth = sizeArray[0]; > - imgHeight = sizeArray[1]; > + var sizeArray = scaleToFit(orgWidth,orgHeight,maxImageWidth,maxImageHeight,1); > + var imgWidth = sizeArray[0]; > + var imgHeight = sizeArray[1]; > > /** > * preload image > @@ -91,7 +112,13 @@ > var currentImgSrc = imageSrc + curImgId + '&max_width=' + imgWidth + '&max_height=' + imgHeight; > imgPreloader = new Image(); > > - // once image is preloaded, resize image container > + /** > + * once image is preloaded, resize image container > + * > + * pay attention with other image preloader! > + * if imgWidth and imgWidth was not set with trailing 'var' it got overlapping with the other variables > + * and hence the image was not resized correctly in resizeImageContainer() !!! > + */ > imgPreloader.onload=function(){ > preloadImageFinished[curImgId] = true; > $('mainImage').src = currentImgSrc; > @@ -144,8 +171,13 @@ > showImage: function(){ > Element.hide('divloading'); > new Effect.Appear('mainImage', { duration: 0.5, afterFinish: function(){ myLinImage.setImageInfoLink(); } }); > - $('divimage').style.height = $('mainImage').style.height; // reset to correct height to prevent trouble if image is bigger or smaller > > + if(! slideshowActive) { > + $('divimage').style.height = $('mainImage').style.height; // reset to correct height to prevent trouble if image is bigger or smaller > + } > + > + this.enableKeyboardNav(); > + > this.setImageData(); > this.preloadXml(); > }, > @@ -167,23 +199,14 @@ > * set prev thumbs > */ > $('thumbnavi_prevthumb').innerHTML = ''; > + prevThumbs = new Array(); > if(xmlDoc[curImgId].getElementsByTagName('prevthumb').length > 0) > { > for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('prevthumb').length; i++) > { > - var prevThumbId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; > - > - var ElemImg = Builder.node('img', {id: 'thumb'+prevThumbId, className: 'img_prevnextthumb', src: thumbSrc + prevThumbId}); > - var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + prevThumbId + ')'}); > - var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); > - > - ElemA.appendChild( ElemImg ); > - ElemDiv.appendChild( ElemA ); > - $('thumbnavi_prevthumb').appendChild(ElemDiv); > - > - if(! preloadImageFinished[prevThumbId]) { > - Element.setOpacity('thumb'+prevThumbId,0.5); > - } > + var thumbId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; > + prevThumbs[i] = thumbId; > + this.setPrevNextThumb(thumbId, 'thumbnavi_prevthumb'); > } > } > > @@ -191,23 +214,14 @@ > * set next thumbs > */ > $('thumbnavi_nextthumb').innerHTML = ''; > + nextThumbs = new Array(); > if(xmlDoc[curImgId].getElementsByTagName('nextthumb').length > 0) > { > for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('nextthumb').length; i++) > { > - var nextThumbId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; > - > - var ElemImg = Builder.node('img', {id: 'thumb'+nextThumbId, className: 'img_prevnextthumb', src: thumbSrc + nextThumbId}); > - var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + nextThumbId + ')'}); > - var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); > - > - ElemA.appendChild( ElemImg ); > - ElemDiv.appendChild( ElemA ); > - $('thumbnavi_nextthumb').appendChild(ElemDiv); > - > - if(! preloadImageFinished[nextThumbId]) { > - Element.setOpacity('thumb'+nextThumbId,0.5); > - } > + var thumbId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; > + nextThumbs[i] = thumbId; > + this.setPrevNextThumb(thumbId, 'thumbnavi_nextthumb'); > } > } > > @@ -255,20 +269,45 @@ > } > } > > + /** > + * set image nr > + * currently only in slideshow used > + */ > + $('divSlideshowImgNr').innerHTML = xmlDoc[curImgId].getElementsByTagName('imgnr').item(0).firstChild.data; > + > > }, // end function setImageData() > > + setPrevNextThumb: function(thumbId, divId) > + { > + var ElemImg = Builder.node('img', {id: 'thumb'+thumbId, className: 'img_prevnextthumb', src: thumbSrc + thumbId}); > + var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + thumbId + ')'}); > + var ElemDiv = Builder.node('div', {className: 'thumbnavi_prevnextthumb'}); > + > + ElemA.appendChild( ElemImg ); > + ElemDiv.appendChild( ElemA ); > + $(divId).appendChild(ElemDiv); > + > + if(! preloadImageFinished[thumbId]) { > + Element.setOpacity('thumb'+thumbId,0.5); > + } > + > + }, > + > /** > * setImageInfoLink > * > * set positions of info link > * could only be done after image has been completly loaded > */ > - setImageInfoLink: function() { > - $('divinfolinks').style.top = $('mainImage').offsetTop + $('mainImage').offsetHeight; > - $('divinfolinks').style.left = $('mainImage').offsetLeft + $('mainImage').offsetWidth - 50; // 50: value of view_img.css width = 50px; can't get width with javascript because element is hidden > - Element.show('divinfolinks'); > - > + setImageInfoLink: function() > + { > + if(! slideshowActive) > + { > + $('divinfolinks').style.top = $('mainImage').offsetTop + $('mainImage').offsetHeight; > + $('divinfolinks').style.left = $('mainImage').offsetLeft + $('mainImage').offsetWidth - 50; // 50: value of view_img.css width = 50px; can't get width with javascript because element is hidden > + Element.show('divinfolinks'); > + } > }, > > // > @@ -297,21 +336,15 @@ > > key = String.fromCharCode(keycode).toLowerCase(); > > - if((key == 'x') || (key == 'o') || (key == 'c')){ // close lightbox > - myLinImage.end(); > + if( slideshowActive && ( (key == 'x') || (key == 'o') || (key == 'c') ) ) { // close slideshow > + myLinImage.fullscreenStop(); > } else if(key == 'p'){ // display previous image > - if(activeImage != 0){ > - myLinImage.disableKeyboardNav(); > - myLinImage.changeImage(activeImage - 1); > - } > + myLinImage.disableKeyboardNav(); > + myLinImage.movePrev(); > } else if(key == 'n'){ // display next image > - if(activeImage != (imageArray.length - 1)){ > - myLinImage.disableKeyboardNav(); > - myLinImage.changeImage(activeImage + 1); > - } > + myLinImage.disableKeyboardNav(); > + myLinImage.moveNext(); > } > - > - > }, > > // > @@ -360,9 +393,9 @@ > */ > var orgWidth = xmlDoc[imgId].getElementsByTagName('imgwidth').item(0).firstChild.data; > var orgHeight = xmlDoc[imgId].getElementsByTagName('imgheight').item(0).firstChild.data; > - var sizeArray = scaleToFit(orgWidth,orgHeight,imageSize,imageSize,1); > - imgWidth = sizeArray[0]; > - imgHeight = sizeArray[1]; > + var sizeArray = scaleToFit(orgWidth,orgHeight,maxImageWidth,maxImageHeight,1); > + var imgWidth = sizeArray[0]; > + var imgHeight = sizeArray[1]; > > var currentImgSrc = imageSrc + imgId + '&max_width=' + imgWidth + '&max_height=' + imgHeight; > > @@ -381,12 +414,126 @@ > preloadImageFinished: function(imgId) { > new Effect.Appear('thumb'+imgId, { duration: 0.5, from: 0.5, to: 1.0 }); > preloadImageFinished[imgId] = true; > + }, > + > + fullscreenStart: function() > + { > + slideshowActive = true; > + > + /** > + * save old values to restore if slideshow ends > + * and set new window size > + */ > + slideshowOldMaxWidth = maxImageWidth; > + slideshowOldMaxHeight = maxImageHeight; > + onWindowResize(); > + > + /** > + * start slideshow with some superduper effects > + */ > + Effect.Appear('divSlideshowOverlay', { queue: 'end', duration: 1.0, from: 0.0, to: 0.9 }); > + Effect.BlindDown('divSlideshowControls', { queue: 'end'} ); > + Element.show('divSlideshowImage'); > + > + /** > + * steal the mainimage > + */ > + $('divimage').innerHTML = ''; > + $('divSlideshowImage').innerHTML = '<img id="mainImage" style="display: none;" class="imgSlideshow">'; > + > + /** > + * reload image with new position and size > + */ > + this.loadImage( curImgId ); > + }, > + > + > + fullscreenStop: function() > + { > + slideshowActive = false; > + > + /** > + * restore max image size > + */ > + maxImageWidth = slideshowOldMaxWidth; > + maxImageHeight = slideshowOldMaxHeight; > + > + /** > + * end slideshow with some superduper effects > + */ > + Effect.Fold('divSlideshowControls', { queue: 'end'} ); > + Effect.Fade('divSlideshowOverlay', { queue: 'end', duration: 0.5, from: 0.9, to: 0.0 } ); > + Element.hide('divSlideshowImage'); > + > + /** > + * give back the mainimage > + */ > + $('divSlideshowImage').innerHTML = ''; > + $('divimage').innerHTML = '<img id="mainImage" style="display: none;">'; > + > + /** > + * reload image with old position and size > + */ > + this.loadImage( curImgId ); > + }, > + > + slideshowPlay: function() > + { > + }, > + slideshowPause: function() > + { > + > + }, > + slideshowChangeDelay: function() > + { > + //currentDelay=document.optionsForm.delay.options[document.optionsForm.delay.selectedIndex].value * 1000;*/ > } > } > > +/** > + * onWindowResize > + * > + * will be called if the window is resized > + */ > +function onWindowResize() > +{ > + if(slideshowActive) > + { > + getWindowSize(); > + maxImageWidth = linInnerWidth - 70; > + maxImageHeight = linInnerHeight - 120; > + } > + else > + { > + myLinImage.setImageInfoLink(); > + // setMainHeight(); // defined in LinGlobal.js > + } > +} > + > +/** > + * init on finished page load > + */ > +function initLinImage() > +{ > + setInfoColors(); > + $('divimage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded > + $('mainImage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded > + myLinImage = new LinImage(); > + myLinImage.loadImage(startImgId); > +// setMainHeight(); // defined in LinGlobal.js > + window.onresize = onWindowResize; > + > +} > +Event.observe(window, 'load', initLinImage, false); > + > // ----------------------------------------------------------------------------------- > +// end class LinImage > +// ----------------------------------------------------------------------------------- > > > +// ----------------------------------------------------------------------------------- > +// Common used functions > +// ----------------------------------------------------------------------------------- > > var colorinfoactive; > var colorinfonotactive; > @@ -487,28 +634,15 @@ > } > > /** > - * onWindowResize > + * openTextarea() > * > - * will be called if the window is resized > + * opens the bigger textarea to enter longer image comments > + * this function is defined in view_img_static.html.php too > */ > -function onWindowResize() > +function openTextarea() > { > - myLinImage.setImageInfoLink(); > -// setMainHeight(); // defined in LinGlobal.js > -} > - > -/** > - * init on finished page load > - */ > -function initLinImage() > -{ > - setInfoColors(); > - $('divimage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded > - $('mainImage').style.height = startImgHeight; // initial sets correct height at begin and not after the image is loaded > - myLinImage = new LinImage(); > - myLinImage.loadImage(startImgId); > -// setMainHeight(); // defined in LinGlobal.js > - window.onresize = onWindowResize; > + document.getElementById('comment_textarea').style.display = 'block'; > + document.getElementById('comment_div_text').style.display = 'none'; > > -} > -Event.observe(window, 'load', initLinImage, false); > + document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; > +} > \ No newline at end of file > > Modified: trunk/linpha2/lib/js/LinThumbnails.js > =================================================================== > --- trunk/linpha2/lib/js/LinThumbnails.js 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/lib/js/LinThumbnails.js 2006-10-09 20:52:58 UTC (rev 4580) > @@ -33,6 +33,7 @@ > { > /** > * set correct main height only if photos_per_page == auto > + * needs to be in display_images! > */ > setMainHeight(); // defined in LinGlobal.js > > @@ -420,6 +421,16 @@ > } > > /** > + * slideshowStartFromThumbview() > + * > + * to start the slideshow, first open imageview with first image, and then start slideshow > + */ > +function slideshowStartFromThumbview() > +{ > + location.href = link_url + '&id=' + img_ids[0]['id'] + '&slideshow'; > +} > + > +/** > * function view_source_code() removed > * use firefox extension "Aardvark" > * much nicer ;-) > > Modified: trunk/linpha2/templates/default/css/global.css > =================================================================== > --- trunk/linpha2/templates/default/css/global.css 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/templates/default/css/global.css 2006-10-09 20:52:58 UTC (rev 4580) > @@ -23,9 +23,9 @@ > > /** > * background color > - * #divthumbnavi used in view_img.html.php > + * #divthumbnavi amd #divSlideshowControls used in view_img.html.php > */ > - #divleft, #divmain, #divright, #divthumbnavi, #divnavigation { > + #divleft, #divmain, #divright, #divthumbnavi, #divnavigation, #divSlideshowControls { > background-color: #f90; > } > > @@ -306,21 +306,4 @@ > display: block !important; > } > > -/** > - * slieshow > - */ > -#slideshow { > - position: absolute; > - top: 150px; > - left: 150px; > - > - width: 400px; > - height: 150px; > - > - padding: 5px; > - > - background-color: #d5fcf4; > - > - border: 1px solid #000000; > -} > --> > \ No newline at end of file > > Modified: trunk/linpha2/templates/default/css/view_img.css > =================================================================== > --- trunk/linpha2/templates/default/css/view_img.css 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/templates/default/css/view_img.css 2006-10-09 20:52:58 UTC (rev 4580) > @@ -111,4 +111,58 @@ > width: 200px; > margin: 5px; > margin-left: 150px; > - } > \ No newline at end of file > + } > + > +/** > + * slieshow > + */ > +#divSlideshowOverlay > +{ > + position: absolute; > + top: 0px; > + left: 0px; > + > + width: 100%; > + height: 100%; > + > + padding: 0px; > + margin: 0px; > + > + z-index: 90; > + background-color: #000; > +} > + > +#divSlideshowControls > +{ > + position: absolute; > + top: 0px; > + left: 50%; > + > + padding: 0px; > + margin: 0px; > + > + width: 500px; > + margin-left: -250px; /* should be the half of 'width' */ > + > + z-index: 91; > +} > + > + > +#divSlideshowImage { > + position: absolute; > + top: 60px; > + > + padding: 0px; > + margin: 0px; > + > + width: 100%; > + > + z-index: 91; > + text-align: center; > +} > + > +.imgSlideshow { > + border: 20px solid white; > +} > + > + > > Modified: trunk/linpha2/templates/default/global.html.php > =================================================================== > --- trunk/linpha2/templates/default/global.html.php 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/templates/default/global.html.php 2006-10-09 20:52:58 UTC (rev 4580) > @@ -88,7 +88,6 @@ > <?php if( isset( $GLOBALS['linpha']->template->output['menu_Icons'] ) ) { > echo $GLOBALS['linpha']->template->output['menu_Icons']; > } ?> > - <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&slideshow=play"><img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png'; ?>" border="0" title="<?php echo i18n("Play Slideshow"); ?>" /></a> > </div> > > <?php if($GLOBALS['linpha']->sql->isLoggedIn()) { ?> > > Modified: trunk/linpha2/templates/default/view_img.head.php > =================================================================== > --- trunk/linpha2/templates/default/view_img.head.php 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/templates/default/view_img.head.php 2006-10-09 20:52:58 UTC (rev 4580) > @@ -3,7 +3,8 @@ > var xmlUrl = '<?php echo convert_amp($GLOBALS['linpha']->template->URL_base); ?>'; > var imageSrc = '<?php echo LINPHA_DIR.'/get_image.php?id='; ?>'; > var thumbSrc = '<?php echo LINPHA_DIR.'/get_thumb.php?id='; ?>'; > -var imageSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; > +var maxImageWidth = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; > +var maxImageHeight = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; > var startImgId = <?php echo $GLOBALS['linpha']->imgview->id_current; ?>; > var startImgHeight = <?php echo $GLOBALS['linpha']->imgview->img_height; ?>; > </script> > > Modified: trunk/linpha2/templates/default/view_img.html.php > =================================================================== > --- trunk/linpha2/templates/default/view_img.html.php 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-09 20:52:58 UTC (rev 4580) > @@ -26,7 +26,7 @@ > </div> > <div id="main"> > <div id="divloading"> > - <img src="<?php echo LINPHA_DIR; ?>/lib/classes/lightbox/images/loading.gif"> > + <img src="<?php echo LINPHA_DIR; ?>/lib/graphics/loading.gif"> > </div> > > <noscript><h1><?php echo i18n("If you have just disabled Javascript, you will need to restart your browser."); ?></h1></noscript> > @@ -61,15 +61,6 @@ > <input type="submit" name="submit" value="<?php echo i18n("submit"); ?>" /> > </form> > </div> > - <script language="JavaScript" type="text/javascript"> > - function openTextarea() > - { > - document.getElementById('comment_textarea').style.display = 'block'; > - document.getElementById('comment_div_text').style.display = 'none'; > - > - document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; > - } > - </script> > > <br /> > <?php } /* end if checkPermission('metadata_comments') */ ?> > @@ -81,4 +72,49 @@ > <div class="roundbottom"> > <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> > </div> > -</div> > \ No newline at end of file > +</div> > + > + > +<div id="divSlideshowOverlay" style="display: none;"></div> > +<div id="divSlideshowControls" style="display: none;"> > + <div style="float: left; padding-left: 5px; "> > + <a href="javascript:myLinImage.movePrev()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/prev.gif" width="25" height="25" border="0"></a> > + <a href="javascript:myLinImage.moveNext()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/next.gif" width="25" height="25" border="0"></a> > + || > + <a href="javascript:myLinImage.slideshowPlay()">Play</a>/<a href="javascript:myLinImage.slideshowPause()">Pause</a> > + <?php echo i18n("Delay"); ?>: > + <select id="delay" name="delay" size="1" onchange="changeDelay()"> > + <option value="3">3 s</option> > + <option value="4">4 s</option> > + <option value="5" selected>5 s</option> > + <option value="10">10 s</option> > + <option value="15">15 s</option> > + <option value="30">30 s</option> > + <option value="45">45 s</option> > + <option value="60">60 s</option> > + </select> > + || > + </div> > + <div id="divSlideshowImgNr" style="float: left;"></div> > + || > + <a href="javascript:myLinImage.fullscreenStop()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/close.gif" width="25" height="25" border="0"></a> > + > + > + <div style="clear: both;"></div> > + <div class="roundbottom"> > + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> > + </div> > +</div> > +<div id="divSlideshowImage" style="display: none;"></div> > + > +<!-- > +<div id="divSlideshowImage" style="display: none;"> > + <div class="roundtop"> > + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> > + </div> > + <div id="divSlideshowImageInner"></div> > + <div class="roundbottom"> > + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> > + </div> > +</div> > +--> > > Modified: trunk/linpha2/templates/default/view_img_static.html.php > =================================================================== > --- trunk/linpha2/templates/default/view_img_static.html.php 2006-10-08 22:20:11 UTC (rev 4579) > +++ trunk/linpha2/templates/default/view_img_static.html.php 2006-10-09 20:52:58 UTC (rev 4580) > @@ -51,7 +51,7 @@ > <?php echo i18n("Add Comment"); ?>:<br /> > <div id="comment_div_text"> > <input type="text" id="comment_input_text" name="comment_text" value="" tabindex="1" size="40" maxlength="40" /> > - <a href="javascript:open_textarea()">(+)</a> > + <a href="javascript:openTextarea()">(+)</a> > </div> > <textarea style="display: none;" id="comment_textarea" name="comment_textarea" tabindex="1" rows="10" cols="50"></textarea> > <?php echo i18n("Name"); ?>: <input type="text" name="author" value="" tabindex="2" size="10" maxlength="40" /> > @@ -60,7 +60,7 @@ > </form> > </div> > <script language="JavaScript" type="text/javascript"> > - function open_textarea() > + function openTextarea() > { > document.getElementById('comment_textarea').style.display = 'block'; > document.getElementById('comment_div_text').style.display = 'none'; > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Linpha-cvs mailing list > Lin...@li... > https://lists.sourceforge.net/lists/listinfo/linpha-cvs |
From: <fan...@us...> - 2006-10-10 19:30:39
|
Revision: 4581 http://svn.sourceforge.net/linpha/?rev=4581&view=rev Author: fangehrn Date: 2006-10-10 12:30:27 -0700 (Tue, 10 Oct 2006) Log Message: ----------- updated Modified Paths: -------------- trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/linpha2.specs.txt Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2006-10-09 20:52:58 UTC (rev 4580) +++ trunk/linpha2/docs/dev/TODO.txt 2006-10-10 19:30:27 UTC (rev 4581) @@ -5,7 +5,42 @@ ## Small Todos - save image height and width in database to reduce file access in get_image.php and imgview() ? +- using rounded corners without images: +------------------- +<style type="text/css"> +.curvy {position:relative; width:400px; height:150px; background:#08c; color:#000; margin:5em auto;} +#ctl, #cbl, #ctr, #cbr {position:absolute; width:20px; height:20px; color:#08c; background:#fff;overflow:hidden;} +#ctl {top:0px; left:0px;} +#cbl {top:130px; left:0px;} +#ctr {top:0px; left:380px;} +#cbr {top:130px; left:380px;} +#quadtl, #quadtr, #quadbl, #quadbr {position:absolute; font-size:150px; font-family:arial; color:#08c;line-height:40px;} +#quadtl {left:-8px;} +#quadtr {left:-25px;} +#quadbl {left:-8px; top:-17px;} +#quadbr {left:-25px; top:-17px;} +#txt {position:absolute; top:5px; left:5px; width:390px; height:140px;} +#txt p {font-size:10px; line-height:17px; color:#fff;} + +</style> + +<div id="info"> + +<h2>Curved Corners</h2> + +<div class="curvy"> +<div id="ctl"><div id="quadtl">•</div></div> +<div id="cbl"><div id="quadbl">•</div></div> +<div id="ctr"><div id="quadtr">•</div></div> +<div id="cbr"><div id="quadbr">•</div></div> +<div id="txt"><p>I know it's been done before, but not this way!<br />A box with curved corners into which you can put text that goes right up to the corners.<br /> +Again, no graphics were used in the making of this demonstration.<br />All it takes is four quadrants of a bullet point positioned absolutely in each corner (arial font this time as it's the safest one to use).</p> +</div> +</div> +-------------------------- + + ## Big Todos - Installer Modified: trunk/linpha2/linpha2.specs.txt =================================================================== --- trunk/linpha2/linpha2.specs.txt 2006-10-09 20:52:58 UTC (rev 4580) +++ trunk/linpha2/linpha2.specs.txt 2006-10-10 19:30:27 UTC (rev 4581) @@ -77,8 +77,8 @@ - Float Tutorial http://css.maxdesign.com.au/floatutorial/ - CSS Layouts, sehr ausfuehrlich http://www.thestyleworks.de/tut-art/layout_div.shtml - http://www.quirksmode.org/viewport/ !! - - - max-width in IE: http://www.svendtofte.com/code/max_width_in_ie/ + - min-/max-width in IE: http://www.cssplay.co.uk/boxes/minwidth.html + http://www.svendtofte.com/code/max_width_in_ie/ - Fenster ueberwachen http://de.selfhtml.org/javascript/beispiele/fensterueberwachen.htm @@ -100,28 +100,7 @@ - thumbnail size, set a max size (for example 150px), to be able to switch the size on fly -- load all class files on every page view, or dynamically load if needed - PHP5 supports autoloading of classes!! - <?php - function __autoload($class_name) { - require_once $class_name . '.php'; - } - $obj = new MyClass1(); - $obj2 = new MyClass2(); - ?> - but it would only make sence if we create new instance of a class - most classes (filesys,identify,image,import) we use directly (with '::') - - oh, just found this: - You can enable this behaviour for undefined classes while unserializing objects - by setting the .ini-variable 'unserialize_callback_func' to '__autoload'. - needs testing... - - /* edit bzrudi */ - we should not rely on the autoload feature - it's better to know when we - need to initiate a class - - image cache plugin automatically turned on? in normal image view, image is displayed javascript based the largest possible -> we're going to have problems with the image cache, as size ever changes.. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-10 20:30:35
|
Revision: 4583 http://svn.sourceforge.net/linpha/?rev=4583&view=rev Author: fangehrn Date: 2006-10-10 13:30:19 -0700 (Tue, 10 Oct 2006) Log Message: ----------- 2006-10-10 flo * disable scrollbars on fullscreen * added accesskey: 'f' for fullscreen start/stop * better position of username/password fields Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/js/LinImage.js trunk/linpha2/templates/default/global.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-10 19:46:47 UTC (rev 4582) +++ trunk/linpha2/ChangeLog 2006-10-10 20:30:19 UTC (rev 4583) @@ -1,4 +1,9 @@ -2006-10-08 flo +2006-10-10 flo + * disable scrollbars on fullscreen + * added accesskey: 'f' for fullscreen start/stop + * better position of username/password fields + +2006-10-09 flo * implemented keyboard navigation ('n' for next, 'p' for prev, other suggestions?) * implemented full screen view with navigation please have a look!! :-) Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-10 19:46:47 UTC (rev 4582) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-10 20:30:19 UTC (rev 4583) @@ -338,6 +338,12 @@ if( slideshowActive && ( (key == 'x') || (key == 'o') || (key == 'c') ) ) { // close slideshow myLinImage.fullscreenStop(); + } else if(key == 'f'){ // display previous image + if( slideshowActive ) { + myLinImage.fullscreenStop(); + } else { + myLinImage.fullscreenStart(); + } } else if(key == 'p'){ // display previous image myLinImage.disableKeyboardNav(); myLinImage.movePrev(); @@ -429,6 +435,11 @@ onWindowResize(); /** + * disable scrollbars + */ + document.getElementsByTagName("body")[0].style.overflow='hidden'; + + /** * start slideshow with some superduper effects */ Effect.Appear('divSlideshowOverlay', { queue: 'end', duration: 1.0, from: 0.0, to: 0.9 }); @@ -459,6 +470,11 @@ maxImageHeight = slideshowOldMaxHeight; /** + * re-enable scrollbars + */ + document.getElementsByTagName("body")[0].style.overflow='auto'; + + /** * end slideshow with some superduper effects */ Effect.Fold('divSlideshowControls', { queue: 'end'} ); Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-10-10 19:46:47 UTC (rev 4582) +++ trunk/linpha2/templates/default/global.html.php 2006-10-10 20:30:19 UTC (rev 4583) @@ -14,7 +14,7 @@ -<body> +<body id="linBody"> <!-- syslog --> <div id="divSyslog"<?php if( ! isset($GLOBALS['linpha']->template->output['sys_log']) ) { echo ' style="display: none;"'; } ?>> @@ -67,9 +67,9 @@ <input type="submit" name="submit" value="<?php echo i18n("Logout"); ?>" /> <?php } else { ?> <!-- login infos --> - <?php echo i18n("Username"); ?>: <input type="text" name="username" value="" /><br /> - <?php echo i18n("Password"); ?>: <input type="password" name="password" value="" /><br /> - <?php if($GLOBALS['linpha']->sql->config->value['sys_user_autologin']) { ?><input type="checkbox" name="rememberme" value="true" id="checkbox_remember" /><label for="checkbox_remember"><?php echo i18n("Remember Me"); ?></label><?php } ?> + <label for="formUsername" style="display: block; float: left; width: 80px;"><?php echo i18n("Username"); ?>: </label><input style="width: 105px;" type="text" name="username" value="" id="formUsername" /><br /> + <label for="formPassword" style="display: block; float: left; width: 80px;"><?php echo i18n("Password"); ?>: </label><input style="width: 105px;" type="password" name="password" value="" id="formPassword" /><br /> + <?php if($GLOBALS['linpha']->sql->config->value['sys_user_autologin']) { ?><input type="checkbox" name="rememberme" value="true" id="formCheckboxRemember" /><label for="formCheckboxRemember"><?php echo i18n("Remember Me"); ?></label><?php } ?> <input type="hidden" name="cmd" value="login" /> <input type="submit" name="submit" value="<?php echo i18n("Login"); ?>" /> <?php } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-12 06:44:03
|
Revision: 4584 http://svn.sourceforge.net/linpha/?rev=4584&view=rev Author: fangehrn Date: 2006-10-11 14:22:44 -0700 (Wed, 11 Oct 2006) Log Message: ----------- 2006-10-11 flo * modified controls of slideshow/fullscreen slideshow does not yet work * added missing graphics - sorry... Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/js/LinImage.js trunk/linpha2/templates/default/css/view_img.css trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/view_img.html.php Added Paths: ----------- trunk/linpha2/lib/graphics/loading.gif trunk/linpha2/lib/graphics/ss_first.gif trunk/linpha2/lib/graphics/ss_last.gif trunk/linpha2/lib/graphics/ss_loop.gif trunk/linpha2/lib/graphics/ss_next.gif trunk/linpha2/lib/graphics/ss_noloop.gif trunk/linpha2/lib/graphics/ss_norandom.gif trunk/linpha2/lib/graphics/ss_play.gif trunk/linpha2/lib/graphics/ss_previous.gif trunk/linpha2/lib/graphics/ss_random.gif trunk/linpha2/lib/graphics/ss_stop.gif Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-10 20:30:19 UTC (rev 4583) +++ trunk/linpha2/ChangeLog 2006-10-11 21:22:44 UTC (rev 4584) @@ -1,3 +1,8 @@ +2006-10-11 flo + * modified controls of slideshow/fullscreen + slideshow does not yet work + * added missing graphics - sorry... + 2006-10-10 flo * disable scrollbars on fullscreen * added accesskey: 'f' for fullscreen start/stop Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-10 20:30:19 UTC (rev 4583) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-11 21:22:44 UTC (rev 4584) @@ -163,9 +163,9 @@ if(isset($_GET['admin_cmd'])) { $this->adminCommands(); } - if(isset($_GET['slideshow'])) { + /*if(isset($_GET['slideshow'])) { $this->slideshow(); - } + }*/ /** * set admin menu and more menu Added: trunk/linpha2/lib/graphics/loading.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/loading.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_first.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_first.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_last.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_last.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_loop.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_loop.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_next.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_next.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_noloop.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_noloop.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_norandom.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_norandom.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_play.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_play.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_previous.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_previous.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_random.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_random.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/graphics/ss_stop.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/ss_stop.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-10 20:30:19 UTC (rev 4583) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-11 21:22:44 UTC (rev 4584) @@ -64,15 +64,17 @@ }, movePrev: function() { - if(prevThumbs[ prevThumbs.length - 1 ]) - { + if(prevThumbs[ prevThumbs.length - 1 ]) { myLinImage.loadImage(prevThumbs[ prevThumbs.length - 1 ]); + } else { // end reached, do nothing but enable keyboard navigation again + myLinImage.enableKeyboardNav(); } }, moveNext: function() { - if(nextThumbs[0]) - { + if(nextThumbs[0]) { myLinImage.loadImage(nextThumbs[0]); + } else { // end reached, do nothing but enable keyboard navigation again + myLinImage.enableKeyboardNav(); } }, @@ -333,7 +335,7 @@ } else { // mozilla keycode = e.which; } - + key = String.fromCharCode(keycode).toLowerCase(); if( slideshowActive && ( (key == 'x') || (key == 'o') || (key == 'c') ) ) { // close slideshow @@ -503,6 +505,22 @@ slideshowChangeDelay: function() { //currentDelay=document.optionsForm.delay.options[document.optionsForm.delay.selectedIndex].value * 1000;*/ + }, + slideshowChangeLoop: function() + { + if( Element.getOpacity('ssLoop') > 0.9) { + Element.setOpacity('ssLoop',0.7); + } else { + Element.setOpacity('ssLoop',1); + } + }, + slideshowChangeRandom: function() + { + if( Element.getOpacity('ssRandom') > 0.9) { + Element.setOpacity('ssRandom',0.7); + } else { + Element.setOpacity('ssRandom',1); + } } } Modified: trunk/linpha2/templates/default/css/view_img.css =================================================================== --- trunk/linpha2/templates/default/css/view_img.css 2006-10-10 20:30:19 UTC (rev 4583) +++ trunk/linpha2/templates/default/css/view_img.css 2006-10-11 21:22:44 UTC (rev 4584) @@ -141,16 +141,21 @@ padding: 0px; margin: 0px; - width: 500px; - margin-left: -250px; /* should be the half of 'width' */ - + width: 600px; + margin-left: -300px; /* should be the half of 'width' */ + z-index: 91; } +#divSlideshowControlsInner +{ + padding: 5px; + margin: 0px; +} #divSlideshowImage { position: absolute; - top: 60px; + top: 65px; padding: 0px; margin: 0px; Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-10-10 20:30:19 UTC (rev 4583) +++ trunk/linpha2/templates/default/global.html.php 2006-10-11 21:22:44 UTC (rev 4584) @@ -103,9 +103,5 @@ <?php $GLOBALS['linpha']->template->includeFile('body'); ?> -<?php if( isset( $GLOBALS['linpha']->template->output['slideshow_body'] ) ) { - echo '<!-- slideshow-->'; - echo $GLOBALS['linpha']->template->output['slideshow_body']; -} ?> </body> </html> \ No newline at end of file Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-10-10 20:30:19 UTC (rev 4583) +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-11 21:22:44 UTC (rev 4584) @@ -77,13 +77,18 @@ <div id="divSlideshowOverlay" style="display: none;"></div> <div id="divSlideshowControls" style="display: none;"> - <div style="float: left; padding-left: 5px; "> - <a href="javascript:myLinImage.movePrev()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/prev.gif" width="25" height="25" border="0"></a> - <a href="javascript:myLinImage.moveNext()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/next.gif" width="25" height="25" border="0"></a> - || - <a href="javascript:myLinImage.slideshowPlay()">Play</a>/<a href="javascript:myLinImage.slideshowPause()">Pause</a> - <?php echo i18n("Delay"); ?>: - <select id="delay" name="delay" size="1" onchange="changeDelay()"> + <div id="divSlideshowControlsInner"> + <div style="float: left; margin-left: 10px; "> + <a href="javascript:myLinImage.moveFirst()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_first.gif" width="25" height="25" border="0" alt="First" title="<?php echo i18n("First"); ?>" /></a> + <a href="javascript:myLinImage.movePrev()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_previous.gif" width="25" height="25" border="0" alt="Previous" title="<?php echo i18n("Previous"); ?>" /></a> + <a href="javascript:myLinImage.slideshowPlay()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_play.gif" width="25" height="25" border="0" alt="Play" title="<?php echo i18n("Play"); ?>" /></a> + <a href="javascript:myLinImage.slideshowPause()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_stop.gif" width="25" height="25" border="0" alt="Stop" title="<?php echo i18n("Stop"); ?>" /></a> + <a href="javascript:myLinImage.moveNext()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_next.gif" width="25" height="25" border="0" alt="Next" title="<?php echo i18n("Next"); ?>" /></a> + <a href="javascript:myLinImage.moveLast()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_last.gif" width="25" height="25" border="0" alt="Last" title="<?php echo i18n("Last"); ?>" /></a> + </div> + + <div style="float: left; margin-left: 40px; "> + <select id="ssDelay" name="delay" size="1" onchange="changeDelay()" title="<?php echo i18n("Delay"); ?>"> <option value="3">3 s</option> <option value="4">4 s</option> <option value="5" selected>5 s</option> @@ -93,28 +98,26 @@ <option value="45">45 s</option> <option value="60">60 s</option> </select> - || - </div> - <div id="divSlideshowImgNr" style="float: left;"></div> - || - <a href="javascript:myLinImage.fullscreenStop()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/close.gif" width="25" height="25" border="0"></a> + </div> + <div style="float: left; margin-left: 10px; "> + <a href="javascript:myLinImage.slideshowChangeLoop()"><img id="ssLoop" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_loop.gif" width="25" height="25" border="0" alt="Loop" title="<?php echo i18n("Enable/disable Loop"); ?>" /></a> + <!--<a href="javascript:myLinImage.slideshowChangeLoop()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_noloop.gif" width="25" height="25" border="0" /></a>--> + <a href="javascript:myLinImage.slideshowChangeRandom()"><img id="ssRandom" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_norandom.gif" width="25" height="25" border="0" alt="Random" title="<?php echo i18n("Enable/disable Random Play Order"); ?>" /></a> + <!--<a href="javascript:myLinImage.slideshowChangeRandom()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_random.gif" width="25" height="25" border="0" /></a>--> + </div> - <div style="clear: both;"></div> + <div id="divSlideshowImgNr" style="float: left; margin-left: 40px; "></div> + + <div style="float: left; margin-left: 40px; "> + <a href="javascript:myLinImage.fullscreenStop()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_stop.gif" width="25" height="25" border="0" alt="Exit" title="<?php echo i18n("Exit Fullscreen"); ?>" ></a> + </div> + + <div style="clear: both;"></div> + </div> <div class="roundbottom"> <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> </div> <div id="divSlideshowImage" style="display: none;"></div> -<!-- -<div id="divSlideshowImage" style="display: none;"> - <div class="roundtop"> - <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> - </div> - <div id="divSlideshowImageInner"></div> - <div class="roundbottom"> - <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> - </div> -</div> ---> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-10-15 21:20:47
|
Revision: 4585 http://svn.sourceforge.net/linpha/?rev=4585&view=rev Author: fangehrn Date: 2006-10-15 14:20:26 -0700 (Sun, 15 Oct 2006) Log Message: ----------- 2006-10-11 flo * implemented slideshow * implemented movefirst() and movelast() * added accesskey 's' for play/pause now its possible to view the slideshow without fullscreen enabled Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/js/LinImage.js trunk/linpha2/templates/default/css/view_img.css trunk/linpha2/templates/default/view_img.head.php trunk/linpha2/templates/default/view_img.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-10-11 21:22:44 UTC (rev 4584) +++ trunk/linpha2/ChangeLog 2006-10-15 21:20:26 UTC (rev 4585) @@ -1,4 +1,10 @@ 2006-10-11 flo + * implemented slideshow + * implemented movefirst() and movelast() + * added accesskey 's' for play/pause + now its possible to view the slideshow without fullscreen enabled + +2006-10-11 flo * modified controls of slideshow/fullscreen slideshow does not yet work * added missing graphics - sorry... Modified: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2006-10-11 21:22:44 UTC (rev 4584) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-15 21:20:26 UTC (rev 4585) @@ -6,12 +6,18 @@ var curImgId; var nextThumbs = new Array(); var prevThumbs = new Array(); + +var fullscreenActive = false; +var fullscreenOldMaxWidth, fullscreenOldMaxHeight; var slideshowActive = false; -var slideshowOldMaxWidth, slideshowOldMaxHeight; +var ssCurrentTimerID; +var ssCurrentDelay = 5000; +var ssRandom = false; +var ssLoop = false; var xmlDoc = new Array(); -var preloadImage = new Array(); -var preloadImageFinished = new Array(); +var preloadImage = new Array(); // image array, will contain a lot of preloaded images +var preloadImageFinished = new Array(); // set to true after preload completed var preloadXmlFinished = new Array(); var borderSize = 0; @@ -64,19 +70,45 @@ }, movePrev: function() { - if(prevThumbs[ prevThumbs.length - 1 ]) { + if(prevThumbs[ prevThumbs.length - 1 ]) + { + Element.setOpacity('ssImgPrev',0.7); + new Effect.Appear('ssImgPrev', { duration: 0.5, from: 0.7, to: 1.0 }); myLinImage.loadImage(prevThumbs[ prevThumbs.length - 1 ]); - } else { // end reached, do nothing but enable keyboard navigation again + } + else // end reached, do nothing but enable keyboard navigation again + { myLinImage.enableKeyboardNav(); } }, moveNext: function() { - if(nextThumbs[0]) { + if(nextThumbs[0]) + { + Element.setOpacity('ssImgNext',0.7); + new Effect.Appear('ssImgNext', { duration: 0.5, from: 0.7, to: 1.0 }); myLinImage.loadImage(nextThumbs[0]); - } else { // end reached, do nothing but enable keyboard navigation again + } + else if( ssLoop ) + { + Element.setOpacity('ssImgNext',0.7); + new Effect.Appear('ssImgNext', { duration: 0.5, from: 0.7, to: 1.0 }); + this.moveFirst(); + } + else // end reached, do nothing but enable keyboard navigation again + { myLinImage.enableKeyboardNav(); } }, + moveFirst: function() { + Element.setOpacity('ssImgFirst',0.7); + new Effect.Appear('ssImgFirst', { duration: 0.5, from: 0.7, to: 1.0 }); + myLinImage.loadImage( firstImgId ); + }, + moveLast: function() { + Element.setOpacity('ssImgLast',0.7); + new Effect.Appear('ssImgLast', { duration: 0.5, from: 0.7, to: 1.0 }); + myLinImage.loadImage( lastImgId ); + }, // // changeImage() @@ -87,7 +119,7 @@ * set height of outer div to prevent the whole page getting smaller, and if the image is loaded getting bigger again * but we want no activities in background */ - if(! slideshowActive) { + if(! fullscreenActive) { $('divimage').style.height = $('mainImage').style.height; } @@ -95,10 +127,15 @@ * hide elements during transition */ hideImgInfoNow(); // hide meta text immediately - Element.show('divloading'); - Element.hide('mainImage'); + Element.hide('mainImage'); // hide mainimage while changing image to prevent flicker Element.hide('divinfolinks'); + if(! preloadImageFinished[curImgId] ) + { + Element.show('divloading'); + } + + /** * set image width and height */ @@ -111,7 +148,7 @@ /** * preload image */ - var currentImgSrc = imageSrc + curImgId + '&max_width=' + imgWidth + '&max_height=' + imgHeight; + var currentImgSrc = imageSrc + curImgId + '&width=' + imgWidth + '&height=' + imgHeight; imgPreloader = new Image(); /** @@ -174,7 +211,7 @@ Element.hide('divloading'); new Effect.Appear('mainImage', { duration: 0.5, afterFinish: function(){ myLinImage.setImageInfoLink(); } }); - if(! slideshowActive) { + if(! fullscreenActive) { $('divimage').style.height = $('mainImage').style.height; // reset to correct height to prevent trouble if image is bigger or smaller } @@ -304,7 +341,7 @@ */ setImageInfoLink: function() { - if(! slideshowActive) + if(! fullscreenActive) { $('divinfolinks').style.top = $('mainImage').offsetTop + $('mainImage').offsetHeight; $('divinfolinks').style.left = $('mainImage').offsetLeft + $('mainImage').offsetWidth - 50; // 50: value of view_img.css width = 50px; can't get width with javascript because element is hidden @@ -338,14 +375,16 @@ key = String.fromCharCode(keycode).toLowerCase(); - if( slideshowActive && ( (key == 'x') || (key == 'o') || (key == 'c') ) ) { // close slideshow + if( fullscreenActive && ( (key == 'x') || (key == 'o') || (key == 'c') ) ) { // close fullscreen myLinImage.fullscreenStop(); - } else if(key == 'f'){ // display previous image - if( slideshowActive ) { + } else if(key == 'f'){ // start/stop fullscreen + if( fullscreenActive ) { myLinImage.fullscreenStop(); } else { myLinImage.fullscreenStart(); } + } else if(key == 's'){ // start/stop slideshow + myLinImage.slideshowStartStop(); } else if(key == 'p'){ // display previous image myLinImage.disableKeyboardNav(); myLinImage.movePrev(); @@ -355,10 +394,15 @@ } }, - // - // preloadNeighborImages() - // Preload previous and next images. - // + /** + * preloadXml() + * Preload previous and next images. + * + * normally, loadImageXml() will call also preloadImage() + * but we also need to call preloadImage() if the Xml data is preloaded, + * but not yet the image (this may occur if we change to fullscreen, + * then, the images need to be re preloaded all + */ preloadXml: function() { // preload nextthumb from left to right @@ -366,11 +410,15 @@ { for(var i = 0; i < xmlDoc[curImgId].getElementsByTagName('nextthumb').length; i++) { - var thumbId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; - if(! preloadXmlFinished[thumbId]) + var imgId = xmlDoc[curImgId].getElementsByTagName('nextthumb').item(i).firstChild.data; + if(! preloadXmlFinished[imgId]) { - this.loadImageXml(thumbId); + this.loadImageXml(imgId); } + else if(! preloadImageFinished[imgId] ) + { + this.preloadImage(imgId); + } } } @@ -379,11 +427,15 @@ { for(var i = xmlDoc[curImgId].getElementsByTagName('prevthumb').length-1; i >= 0; i--) { - var thumbId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; - if(! preloadXmlFinished[thumbId]) + var imgId = xmlDoc[curImgId].getElementsByTagName('prevthumb').item(i).firstChild.data; + if(! preloadXmlFinished[imgId]) { - this.loadImageXml(thumbId); + this.loadImageXml(imgId); } + else if(! preloadImageFinished[imgId] ) + { + this.preloadImage(imgId); + } } } }, @@ -405,7 +457,7 @@ var imgWidth = sizeArray[0]; var imgHeight = sizeArray[1]; - var currentImgSrc = imageSrc + imgId + '&max_width=' + imgWidth + '&max_height=' + imgHeight; + var currentImgSrc = imageSrc + imgId + '&width=' + imgWidth + '&height=' + imgHeight; /** * preload image @@ -426,21 +478,19 @@ fullscreenStart: function() { - slideshowActive = true; + fullscreenActive = true; /** * save old values to restore if slideshow ends - * and set new window size */ - slideshowOldMaxWidth = maxImageWidth; - slideshowOldMaxHeight = maxImageHeight; - onWindowResize(); - + fullscreenOldMaxWidth = maxImageWidth; + fullscreenOldMaxHeight = maxImageHeight; + /** * disable scrollbars */ document.getElementsByTagName("body")[0].style.overflow='hidden'; - + /** * start slideshow with some superduper effects */ @@ -457,19 +507,19 @@ /** * reload image with new position and size */ - this.loadImage( curImgId ); + onWindowResize(); }, fullscreenStop: function() { - slideshowActive = false; + fullscreenActive = false; /** * restore max image size */ - maxImageWidth = slideshowOldMaxWidth; - maxImageHeight = slideshowOldMaxHeight; + maxImageWidth = fullscreenOldMaxWidth; + maxImageHeight = fullscreenOldMaxHeight; /** * re-enable scrollbars @@ -477,6 +527,11 @@ document.getElementsByTagName("body")[0].style.overflow='auto'; /** + * delete preloaded images after stopping fullscreen + */ + preloadImageFinished = new Array(); + + /** * end slideshow with some superduper effects */ Effect.Fold('divSlideshowControls', { queue: 'end'} ); @@ -495,31 +550,60 @@ this.loadImage( curImgId ); }, - slideshowPlay: function() + slideshowStartStop: function() { + // start Slideshow + if(! slideshowActive) + { + slideshowActive = true; + Element.setOpacity('ssImgStart',0.7); + ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", ssCurrentDelay); + } + else // stop Slideshow + { + slideshowActive = false; + Element.setOpacity('ssImgStart',1); + clearTimeout(ssCurrentTimerID); + } }, - slideshowPause: function() + slideshowPlay: function() { - + if(nextThumbs[0] || ssLoop) + { + this.moveNext(); + ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", ssCurrentDelay); + } + else + { + // force stop slideshow + slideshowActive = true; + this.slideshowStartStop(); + } }, + slideshowChangeDelay: function() { - //currentDelay=document.optionsForm.delay.options[document.optionsForm.delay.selectedIndex].value * 1000;*/ + ssCurrentDelay = $('ssDelay').options[ $('ssDelay').selectedIndex ].value * 1000; + //document.optionsForm.delay.options[document.optionsForm.delay.selectedIndex].value * 1000; }, slideshowChangeLoop: function() { - if( Element.getOpacity('ssLoop') > 0.9) { - Element.setOpacity('ssLoop',0.7); + if(! ssLoop) { + ssLoop = true; + Element.setOpacity('ssImgLoop',0.7); } else { - Element.setOpacity('ssLoop',1); + ssLoop = false; + Element.setOpacity('ssImgLoop',1); } }, slideshowChangeRandom: function() { - if( Element.getOpacity('ssRandom') > 0.9) { - Element.setOpacity('ssRandom',0.7); + if(! ssRandom) { + ssRandom = true; + Element.setOpacity('ssImgRandom',0.7); } else { - Element.setOpacity('ssRandom',1); + ssRandom = false; + Element.setOpacity('ssImgRandom',1); } } } @@ -527,15 +611,22 @@ /** * onWindowResize * - * will be called if the window is resized + * will be called if the window is resized, and also on start of fullscreen */ function onWindowResize() { - if(slideshowActive) + if(fullscreenActive) { + /** + * delete preloaded images after starting fullscreen and resizing window + */ + preloadImageFinished = new Array(); + getWindowSize(); maxImageWidth = linInnerWidth - 70; maxImageHeight = linInnerHeight - 120; + + myLinImage.loadImage( curImgId ); } else { @@ -639,7 +730,7 @@ // Image is smaller than screen, no resize required if ((src_w <= dst_w) && (src_h <= dst_h) && no_increase) { - var returnarray = new Array(src_w, src_h); + var returnarray = new Array( Math.round(src_w), Math.round(src_h) ); } else { @@ -656,11 +747,11 @@ var tmp_height = dst_w / img_relation; // calc the new height with screen width if (tmp_height > dst_h) // we were wrong, it's still widther than screen -> $dst_h is decisive { - var returnarray = new Array(Math.round(img_relation*dst_h), dst_h); + var returnarray = new Array( Math.round(img_relation*dst_h), Math.round(dst_h) ); } else { - var returnarray = new Array(dst_w, tmp_height); + var returnarray = new Array( Math.round(dst_w), Math.round(tmp_height) ); } } Modified: trunk/linpha2/templates/default/css/view_img.css =================================================================== --- trunk/linpha2/templates/default/css/view_img.css 2006-10-11 21:22:44 UTC (rev 4584) +++ trunk/linpha2/templates/default/css/view_img.css 2006-10-15 21:20:26 UTC (rev 4585) @@ -21,6 +21,7 @@ position: absolute; left: 50%; top: 20px; + z-index: 95; } Modified: trunk/linpha2/templates/default/view_img.head.php =================================================================== --- trunk/linpha2/templates/default/view_img.head.php 2006-10-11 21:22:44 UTC (rev 4584) +++ trunk/linpha2/templates/default/view_img.head.php 2006-10-15 21:20:26 UTC (rev 4585) @@ -7,6 +7,8 @@ var maxImageHeight = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; ?>; var startImgId = <?php echo $GLOBALS['linpha']->imgview->id_current; ?>; var startImgHeight = <?php echo $GLOBALS['linpha']->imgview->img_height; ?>; +var firstImgId = <?php echo $GLOBALS['linpha']->imgview->photos_filtered[0]['id']; /* @todo needs updating on change of sort order */ ?>; +var lastImgId = <?php echo $GLOBALS['linpha']->imgview->photos_filtered[ count($GLOBALS['linpha']->imgview->photos_filtered)-1 ]['id']; /* @todo needs updating on change of sort order */ ?>; </script> <script type="text/javascript" language="javascript" src="<?php echo LINPHA_DIR; ?>/lib/js/scriptaculous.js?load=effects,builder"></script> Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-10-11 21:22:44 UTC (rev 4584) +++ trunk/linpha2/templates/default/view_img.html.php 2006-10-15 21:20:26 UTC (rev 4585) @@ -79,16 +79,16 @@ <div id="divSlideshowControls" style="display: none;"> <div id="divSlideshowControlsInner"> <div style="float: left; margin-left: 10px; "> - <a href="javascript:myLinImage.moveFirst()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_first.gif" width="25" height="25" border="0" alt="First" title="<?php echo i18n("First"); ?>" /></a> - <a href="javascript:myLinImage.movePrev()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_previous.gif" width="25" height="25" border="0" alt="Previous" title="<?php echo i18n("Previous"); ?>" /></a> - <a href="javascript:myLinImage.slideshowPlay()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_play.gif" width="25" height="25" border="0" alt="Play" title="<?php echo i18n("Play"); ?>" /></a> - <a href="javascript:myLinImage.slideshowPause()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_stop.gif" width="25" height="25" border="0" alt="Stop" title="<?php echo i18n("Stop"); ?>" /></a> - <a href="javascript:myLinImage.moveNext()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_next.gif" width="25" height="25" border="0" alt="Next" title="<?php echo i18n("Next"); ?>" /></a> - <a href="javascript:myLinImage.moveLast()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_last.gif" width="25" height="25" border="0" alt="Last" title="<?php echo i18n("Last"); ?>" /></a> + <a href="javascript:myLinImage.moveFirst()"><img id="ssImgFirst" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_first.gif" width="25" height="25" border="0" alt="First" title="<?php echo i18n("First"); ?>" /></a> + <a href="javascript:myLinImage.movePrev()"><img id="ssImgPrev" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_previous.gif" width="25" height="25" border="0" alt="Previous" title="<?php echo i18n("Previous"); ?>" /></a> + <a href="javascript:myLinImage.slideshowStartStop()"><img id="ssImgStart" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_play.gif" width="25" height="25" border="0" alt="Play" title="<?php echo i18n("Play/Pause"); ?>" /></a> + <!--<a href="javascript:myLinImage.slideshowStop()"><img id="ssImgStop" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_stop.gif" width="25" height="25" border="0" alt="Stop" title="<?php echo i18n("Stop"); ?>" /></a>--> + <a href="javascript:myLinImage.moveNext()"><img id="ssImgNext" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_next.gif" width="25" height="25" border="0" alt="Next" title="<?php echo i18n("Next"); ?>" /></a> + <a href="javascript:myLinImage.moveLast()"><img id="ssImgLast" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_last.gif" width="25" height="25" border="0" alt="Last" title="<?php echo i18n("Last"); ?>" /></a> </div> <div style="float: left; margin-left: 40px; "> - <select id="ssDelay" name="delay" size="1" onchange="changeDelay()" title="<?php echo i18n("Delay"); ?>"> + <select id="ssDelay" name="delay" size="1" onchange="myLinImage.slideshowChangeDelay()" title="<?php echo i18n("Delay"); ?>"> <option value="3">3 s</option> <option value="4">4 s</option> <option value="5" selected>5 s</option> @@ -101,9 +101,9 @@ </div> <div style="float: left; margin-left: 10px; "> - <a href="javascript:myLinImage.slideshowChangeLoop()"><img id="ssLoop" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_loop.gif" width="25" height="25" border="0" alt="Loop" title="<?php echo i18n("Enable/disable Loop"); ?>" /></a> + <a href="javascript:myLinImage.slideshowChangeLoop()"><img id="ssImgLoop" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_loop.gif" width="25" height="25" border="0" alt="Loop" title="<?php echo i18n("Enable/disable Loop"); ?>" /></a> <!--<a href="javascript:myLinImage.slideshowChangeLoop()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_noloop.gif" width="25" height="25" border="0" /></a>--> - <a href="javascript:myLinImage.slideshowChangeRandom()"><img id="ssRandom" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_norandom.gif" width="25" height="25" border="0" alt="Random" title="<?php echo i18n("Enable/disable Random Play Order"); ?>" /></a> + <a href="javascript:myLinImage.slideshowChangeRandom()"><img id="ssImgRandom" src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_norandom.gif" width="25" height="25" border="0" alt="Random" title="<?php echo i18n("Enable/disable Random Play Order"); ?>" /></a> <!--<a href="javascript:myLinImage.slideshowChangeRandom()"><img src="<?php echo LINPHA_DIR; ?>/lib/graphics/ss_random.gif" width="25" height="25" border="0" /></a>--> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |