Thread: [Linpha-cvs] SF.net SVN: linpha: [4669] trunk/linpha2 (Page 7)
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2007-01-23 20:03:31
|
Revision: 4669 http://svn.sourceforge.net/linpha/?rev=4669&view=rev Author: fangehrn Date: 2007-01-23 12:03:15 -0800 (Tue, 23 Jan 2007) Log Message: ----------- 2007-01-23 flo * removed old files * updated todo Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/docs/dev/TODO.txt Removed Paths: ------------- trunk/linpha2/index_template.php trunk/linpha2/lib/classes/linpha.template_old.class.php trunk/linpha2/lib/classes/metadata_editor.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-01-19 15:00:57 UTC (rev 4668) +++ trunk/linpha2/ChangeLog 2007-01-23 20:03:15 UTC (rev 4669) @@ -1,3 +1,7 @@ +2007-01-23 flo + * removed old files + * updated todo + 2007-01-19 flo * added new ptviewer.jar * added panorama support (copy from linpha1) Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2007-01-19 15:00:57 UTC (rev 4668) +++ trunk/linpha2/docs/dev/TODO.txt 2007-01-23 20:03:15 UTC (rev 4669) @@ -31,7 +31,6 @@ - add option to limit the imagesize to the max image size on all pages (get_image.php, menu more, ..?) -- make the scripts in image/gdlib and image/imagemagick as functions ## Big Todos @@ -44,18 +43,8 @@ - user have to delete var/sql/config.sql.php before another installation can continue ? -> otherwise it would be possible to overwrite the current installation, (and to delete cache folders) - DONT add feature to drop tables if they already exists + - add Usage link after installation has been successfully finished -- Videos - - Video thumbnail (what about ffmpeg?) - - switch between quicktime and mplayer? - - nice to have: - - ability to play flash videos - free player: FlowPlayer - convert videos in flash format: - # ffmpeg -i input_file -b bitrate -s XxY -pass 1 -passlogfile log_file video.flv - # ffmpeg -i input_file -b bitrate -s XxY -pass 2 -passlogfile log_file video.flv - for details see c't 21 / 2006 - - Plugins (copy from linpha1) - Guestbook, first apply patch with security image - Logger @@ -75,6 +64,19 @@ DONE ==== +- Videos + - Video thumbnail (what about ffmpeg?) + - switch between quicktime and mplayer? + - nice to have: + - ability to play flash videos + free player: FlowPlayer + convert videos in flash format: + # ffmpeg -i input_file -b bitrate -s XxY -pass 1 -passlogfile log_file video.flv + # ffmpeg -i input_file -b bitrate -s XxY -pass 2 -passlogfile log_file video.flv + for details see c't 21 / 2006 + +- make the scripts in image/gdlib and image/imagemagick as functions + - IPTC/XMP Image fields - Read XMP entries - Write IPTC/XMP entries Deleted: trunk/linpha2/index_template.php =================================================================== --- trunk/linpha2/index_template.php 2007-01-19 15:00:57 UTC (rev 4668) +++ trunk/linpha2/index_template.php 2007-01-23 20:03:15 UTC (rev 4669) @@ -1,52 +0,0 @@ -<?php -/* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* -* 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. -*/ - - -if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','.'); } -define("LINPHA2_INC", "42"); - -//include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); - -//$linpha = new linpha(); -//$linpha->sql->dbConnect(); - -/** - * try/catch include errors (PHP5 exceptions)! - */ -try -{ - //if(!include_once(LINPHA_DIR.'/lib/include/dbconnect.php')) - //{ - // throw new Exception ("ERROR: failed to include " . - // "<lib/include/dbconnect.php> in $_SERVER[SCRIPT_FILENAME]"); - //} - - if(!include_once(LINPHA_DIR.'/templates/default_old/main.php')) - { - throw new Exception ("ERROR: failed to include " . - "</templates/default/main.php><br>LOCATION: index.php"); - } - -} - -catch(Exception $error) -{ - echo $error -> getMessage(); -} -?> \ No newline at end of file Deleted: trunk/linpha2/lib/classes/linpha.template_old.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.template_old.class.php 2007-01-19 15:00:57 UTC (rev 4668) +++ trunk/linpha2/lib/classes/linpha.template_old.class.php 2007-01-23 20:03:15 UTC (rev 4669) @@ -1,78 +0,0 @@ -<?php -/* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* -* 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. -*/ -if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','../..'); } -if(!defined('LINPHA2_INC')) { die("ERROR: Direct access forbidden."); } - -/** - * This class takes care of all common operations in the linpha template system. - * @param string Template name - */ -class Template -{ - -public $template_name; - - function __construct($template_name) - { - if(strlen($template_name) < "1") - { - throw new Exception("ERROR: No template name defined " . - "while starting new instance of class Template " . - "<br>LOCATION: linpha.template.class.php. Please " . - "set template name in main.php"); - } - else - { - $this -> template_name = "$template_name"; - } - } - - /** - * Init valid XHTML header - * @todo set language, charset and title - */ - function linXhtmlHeader() - { - ?> - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - - <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-AU"> - - <head> - - <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/> - <meta name="author" content="The LinPHA Developers" /> - <meta name="keywords" content="Linpha album fotoalbum gallery " . - "galerie archive Archiv image Bilder Fotos PHP Photo ". - "Bildergalerie Webalbum" /> - <meta name="description" content="The LinPHA2 Photo Archive" /> - - <title>LinPHA - The PHP Photo Archive</title> - - <link rel="stylesheet" type="text/css" - href="<?php echo LINPHA_DIR;?>/templates/<?php echo $this->template_name;?>/css/style.css" /> - - </head> - <?php echo LINPHA_DIR;?> - <?php - } - -} // end class -?> \ No newline at end of file Deleted: trunk/linpha2/lib/classes/metadata_editor.php =================================================================== --- trunk/linpha2/lib/classes/metadata_editor.php 2007-01-19 15:00:57 UTC (rev 4668) +++ trunk/linpha2/lib/classes/metadata_editor.php 2007-01-23 20:03:15 UTC (rev 4669) @@ -1,1188 +0,0 @@ -<html> - -<!--*************************************************************************** -* -* Filename: Example.php -* -* Description: An example of how the PHP JPEG Metadata Toolkit can be used to -* display JPEG Metadata. -* -* Author: Evan Hunter -* -* Date: 30/7/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.10 -* -* Changes: 1.00 -> 1.10 : Changed name of GET parameter from 'filename' to 'jpeg_fname' -* to stop script-kiddies using the google command 'allinurl:*.php?filename=*' -* to find servers to attack -* Changed behavior when no filename is given, to be cleaner -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit 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. -* -* The PHP JPEG Metadata Toolkit 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 the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************--> - -<?php -/** - * linpha mods - * make use of image id when calling (security) - */ - -/** - * read path and filename from DB - */ -if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','..'); } -include_once(LINPHA_DIR.'/include/db_connect.php'); - -unset($filename); - -$query = $GLOBALS['db']->Execute("SELECT filename, prev_path FROM ".LIN_PREFIX."photos " . - "WHERE md5sum = '".$_GET['md5sum']."'"); -$path = $query->FetchRow(); -$filename = "../".$path[1]."/".$path[0].""; - -/** - * security - */ -if(!isset($filename) || strlen($_GET['md5sum']) <> 32) -{ - echo "Unknown operation requested, exiting"; - exit(); -} -?> - <head> - - <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> - <STYLE TYPE="text/css" MEDIA="screen, print, projection"> - <!-- - - BODY { background-color:#505050; color:#F0F0F0 } - a { color:orange } - .EXIF_Main_Heading { color:red } - .EXIF_Secondary_Heading{ color: orange} - .EXIF_Table { border-collapse: collapse ; border: 1px solid #909000} - .EXIF_Table tbody td{border-width: 1px; border-style:solid; border-color: #909000;} - - --> - </STYLE> - - - <?php - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - - include './pjmt/JPEG.php'; - include './pjmt/JFIF.php'; - include './pjmt/PictureInfo.php'; - include './pjmt/XMP.php'; - include './pjmt/Photoshop_IRB.php'; - include './pjmt/EXIF.php'; - - // Output the title - echo "<title>Metadata details for $filename</title>"; - - // Retrieve the header information - $jpeg_header_data = get_jpeg_header_data( $filename ); - - ?> - - </head> - - <body> - <B><U>Metadata for "<?php echo $filename; ?>"</U></B> - <br> - - <!-- Output a link allowing user to edit the Photoshop File Info --> - <!-- - <h4><a href="Edit_File_Info_Example.php?jpeg_fname=<?php echo $filename; ?>" >Click here to edit the Photoshop File Info for this file</a></h4> - <br> - --> - - - <!-- Output the information about the APP segments --> - <?php echo Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ); ?> - - <BR> - - <!-- Output the Intrinsic JPEG Information --> - <?php echo Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ); ?> - - <BR> - - <!-- Output the JPEG Comment --> - <?php echo Interpret_Comment_to_HTML( $jpeg_header_data ); ?> - - <BR> - - <!-- Output the JPEG File Interchange Format Information --> - <?php echo Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ); ?> - - <BR> - - <!-- Output the JFIF Extension Information --> - <?php echo Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ); ?> - - <BR> - - <!-- Output the Picture Info Text --> - <?php echo Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ); ?> - - <BR> - - <!-- Output the EXIF Information --> - <?php echo Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename ); ?> - - <BR> - - <!-- Output the XMP Information --> - <?php echo Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ) ); ?> - - <BR> - - <!-- Output the Photoshop IRB (including the IPTC-NAA info --> - <?php echo Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ); ?> - - <BR> - - <!-- Output the Meta Information --> - <?php echo Interpret_EXIF_to_HTML( get_Meta_JPEG( $filename ), $filename ); ?> - - <BR> - <p>Interpreted using:</p> - <p><a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version 1.0, Copyright (C) 2004 Evan Hunter</a></p> - - </body> - -</html> - -<?php - -/** -* NOT YET USED -*/ -/* -<html> - -<!--*************************************************************************** -* -* Filename: Edit_File_Info_Example.php -* -* Description: An example file showing how edit_file_info allows the user to edit -* the metadata of an image over the internet in the same way -* that Photoshop edits 'File Info' data -* -* Author: Evan Hunter -* -* Date: 17/11/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.10 -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit 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. -* -* The PHP JPEG Metadata Toolkit 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 the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************--> - - <head> - - <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> - <STYLE TYPE="text/css" MEDIA="screen, print, projection"> - <!-- - - BODY { background-color:#505050; color:#F0F0F0 } - a { color:orange } - .EXIF_Main_Heading { color:red } - .EXIF_Secondary_Heading{ color: orange} - .EXIF_Table { border-collapse: collapse ; border: 1px solid #909000} - .EXIF_Table tbody td{border-width: 1px; border-style:solid; border-color: #909000;} - - --> - </STYLE> - - - <?php - // Turn off Error Reporting - error_reporting ( 0 ); - - // Retrieve the JPEG image filename from the http url request - if ( ( !array_key_exists( 'jpeg_fname', $GLOBALS['HTTP_GET_VARS'] ) ) || - ( $GLOBALS['HTTP_GET_VARS']['jpeg_fname'] == "" ) ) - { - echo "<title>No image filename defined</title>\n"; - echo "</head>\n"; - echo "<body>\n"; - echo "<p>No image filename defined - use GET method with field: jpeg_fname</p>\n"; - echo "<p><a href=\"http://www.ozhiker.com/electronics/pjmt/\" >PHP JPEG Metadata Toolkit version 1.0, Copyright (C) 2004 Evan Hunter</a></p>\n"; - echo "</body>\n"; - exit( ); - - } - else - { - $filename = $GLOBALS['HTTP_GET_VARS']['jpeg_fname']; - } - ?> - - - <title>Edit Photoshop File Info details for <?php $filename ?></title> - </head> - - <body > - <p>Powered by: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version 1.0, Copyright (C) 2004 Evan Hunter</a></p> - <br> - <br> - - - <?php - // Output a heading - echo "<H1>Edit Photoshop File Info details for $filename</H1>"; - - // Output a link to display the full metadata - echo "<p><a href=\"Example.php?jpeg_fname=" . $filename . "\" >View Full Metatdata Information</a></p>\n"; - - - // Display a small copy of the image - echo "<p><img src=\"$filename\" height=\"50%\"></p>"; - - // Define defaults for the fields - These are only used where the image has blank fields - $default_ps_file_info_array = array ( - 'title' => "", - 'author' => "Evan Hunter", - 'authorsposition' => "", - 'caption' => "", - 'captionwriter' => "Evan Hunter", - 'jobname' => "", - 'copyrightstatus' => "Copyrighted Work", - 'copyrightnotice' => "Copyright (c) Evan Hunter 2004", - 'ownerurl' => "http://www.ozhiker.com", - 'keywords' => array(), - 'category' => "", - 'supplementalcategories'=> array(), - 'date' => "", - 'city' => "", - 'state' => "Tasmania", - 'country' => "Australia", - 'credit' => "Evan Hunter", - 'source' => "Evan Hunter", - 'headline' => "", - 'instructions' => "", - 'transmissionreference' => "", - 'urgency' => "" - ); - - // outputfilename must always be defined, as it specifies the - // file which will be changed - - // These two lines create a temporary copy of the file - // which will be the one that is edited, keeping - // the original intact. - This would not be required if you wanted - // to change the original - in that case just set $outputfilename = $filename - $outputfilename = get_next_filename( ); - copy( $filename, $outputfilename ); - - - - - // Include the File Info Editor. - - include "Edit_File_Info.php"; - - ?> - - - </body> - -</html> -<?php - -/****************************************************************************** -* -* Function: get_next_filename -* -* Description: Simple function to cycle through temporary filenames ( a to z ) -* This means that there will only be a maximum of 26 temporary files, -* hence avoiding filling up the server or having a cron job to remove them. -* -* NOTE: This function would not normally be required, and is just -* to protect my website (and others) from filling up with -* temporary files whilst demonstrating the toolkit -* -* Parameters: none -* -* Returns: TRUE - on Success -* FALSE - on Failure -* -******************************************************************************/ -/* -function get_next_filename( ) -{ - // Read the letter of the next temp file from disk - $filename = file( "next_temp_file.dat" ); - // If it wasn't read - start at 'a' - if ( $filename == FALSE ) - { - $filename = 'a'; - } - else - { - $filename = $filename{0}; - } - - // Ensure the filename letter is valid - if ( ( $filename < 'a' ) || ( $filename > 'z' ) ) - { - $filename = 'a'; - } - - - // Check if the names are up to 'z' - if( $filename == 'z' ) - { - // Name is at z - the next one should be 'a' - $new_filename = 'a'; - } - else - { - // The name is not 'z' add one to it to get the next value - $new_filename = chr( ord( $filename ) + 1 ); - } - - // Write the next temp file letter back into the file - $Fhnd = fopen ("next_temp_file.dat", "w"); - fwrite ($Fhnd, $new_filename); - fclose ($Fhnd); - - // return the filename - return "temp_$filename.jpg"; -} - -/****************************************************************************** -* End of Function: get_next_filename -******************************************************************************/ - -/* - * NOT YET USED - */ - /* - -/**************************************************************************** -* -* Filename: Edit_File_Info.php -* -* Description: Allows the user to edit the metadata of an image over the internet -* in the same way that Photoshop edits 'File Info' data -* This file provides only the html for a form containing the file info -* input fields. The rest of the html file must be provided by the calling script. -* $outputfilename must always be defined - it is ne name of the file which -* have the metadata changed after the form has been submitted -* -* This file has several modes of operation: -* -* 1) If $new_ps_file_info_array is defined then it's data will be used -* to fill the fields. -* 2) If $new_ps_file_info_array is not defined but $filename is defined, -* then the file info fields will be filled from the metadata in the file specified -* 3) If $new_ps_file_info_array is not defined but $filename and $default_ps_file_info_array -* are defined, then the file info fields will be filled from the metadata -* in the file specified, but where fields are blank, they will be filled from $default_ps_file_info_array -* 4) Otherwise the fields will be blank -* -* See Edit_File_Info_Example.php for an example of usage -* -* Author: Evan Hunter -* -* Date: 17/11/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.10 -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit 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. -* -* The PHP JPEG Metadata Toolkit 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 the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************/ - -/* - - // Turn off Error Reporting - error_reporting ( E_ALL ); - - // Check for operation modes 2 or 3 - // i.e. $filename is defined, and $new_ps_file_info_array is not - if ( ( ! isset( $new_ps_file_info_array ) ) && - ( isset( $filename ) ) && - ( is_string( $filename ) ) ) - { - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - - // Accessing the existing file info for the specified file requires these includes - include 'JPEG.php'; - include 'XMP.php'; - include 'Photoshop_IRB.php'; - include 'EXIF.php'; - include 'Photoshop_File_Info.php'; - - // Retrieve the header information from the JPEG file - $jpeg_header_data = get_jpeg_header_data( $filename ); - - // Retrieve EXIF information from the JPEG file - $Exif_array = get_EXIF_JPEG( $filename ); - - // Retrieve XMP information from the JPEG file - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); - - // Retrieve Photoshop IRB information from the JPEG file - $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); - - // Retrieve Photoshop File Info from the three previous arrays - $new_ps_file_info_array = get_photoshop_file_info( $Exif_array, $XMP_array, $IRB_array ); - - - - // Check if there is an array of defaults available - if ( ( isset( $default_ps_file_info_array) ) && - ( is_array( $default_ps_file_info_array) ) ) - { - // There are defaults defined - - // Check if there is a default for the date defined - if ( ( ! array_key_exists( 'date', $default_ps_file_info_array ) ) || - ( ( array_key_exists( 'date', $default_ps_file_info_array ) ) && - ( $default_ps_file_info_array['date'] == '' ) ) ) - { - // No default for the date defined - // figure out a default from the file - - // Check if there is a EXIF Tag 36867 "Date and Time of Original" - if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 34665, $Exif_array[0] ) ) && - ( array_key_exists( 0, $Exif_array[0][34665] ) ) && - ( array_key_exists( 36867, $Exif_array[0][34665][0] ) ) ) - { - // Tag "Date and Time of Original" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36867]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - // Check if there is a EXIF Tag 36868 "Date and Time when Digitized" - else if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 34665, $Exif_array[0] ) ) && - ( array_key_exists( 0, $Exif_array[0][34665] ) ) && - ( array_key_exists( 36868, $Exif_array[0][34665][0] ) ) ) - { - // Tag "Date and Time when Digitized" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36868]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - // Check if there is a EXIF Tag 306 "Date and Time" - else if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 306, $Exif_array[0] ) ) ) - { - // Tag "Date and Time" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][306]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - else - { - // Couldn't find an EXIF date in the image - // Set default date as creation date of file - $default_ps_file_info_array['date'] = date ("Y-m-d", filectime( $filename )); - } - } - - // Cycle through all the elements of the default values array - foreach( $default_ps_file_info_array as $def_key =>$default_item ) - { - // Check if the current element is Keywords or - // Supplemental Categories as these are arrays - // and need to be treated differently - if ( ( strcasecmp( $def_key, "keywords" ) == 0 ) || - ( strcasecmp( $def_key, "supplementalcategories" ) == 0 ) ) - { - // Keywords or Supplemental Categories found - // Check if the File Info from the file is empty for this element - // and if there are default values in this array element - if ( ( count( $new_ps_file_info_array[ $def_key ] ) == 0 ) && - ( is_array( $default_item ) ) && - ( count( $default_item ) >= 0 ) ) - { - // The existing file info is empty, and there are - // defaults - add them - $new_ps_file_info_array[ $def_key ] = $default_item; - } - } - // Otherwise, this is not an array element, just check if it is blank in the existing file info - else if ( trim( $new_ps_file_info_array[ $def_key ] ) == "" ) - { - // The existing file info is blank, add the default value - $new_ps_file_info_array[ $def_key ] = $default_item; - } - - } - } - } - // Check for operation mode 4 - $new_ps_file_info_array and $filename are not defined, - else if ( ( ( !isset($new_ps_file_info_array) ) || ( ! is_array($new_ps_file_info_array) ) ) && - ( ( !isset($filename) ) || ( ! is_string( $filename ) ) ) ) - { - // No filename or new_ps_file_info_array defined, create a blank file info array to display - $new_ps_file_info_array = array( - "title" => "", - "author" => "", - "authorsposition" => "", - "caption" => "", - "captionwriter" => "", - "jobname" => "", - "copyrightstatus" => "", - "copyrightnotice" => "", - "ownerurl" => "", - "keywords" => array(), - "category" => "", - "supplementalcategories" => array(), - "date" => "", - "city" => "", - "state" => "", - "country" => "", - "credit" => "", - "source" => "", - "headline" => "", - "instructions" => "", - "transmissionreference" => "", - "urgency" => "" ); - } - - - -/*************************************************************************** -* -* Now output the actual HTML form -* -***************************************************************************/ -/* -?> - - - - - <form name="EditJPEG" action="Write_File_Info.php" method="post"> - - - <?php echo "<input name=\"filename\" type=\"hidden\" value=\"$outputfilename\">"; ?> - - <table> - - <tr> - <td> - Title - </td> - <td> - <?php - echo "<input size=49 name=\"title\" type=\"text\" value=\"". $new_ps_file_info_array[ 'title' ] ."\">"; - ?> - </td> - </tr> - - <tr> - <td> - Author - </td> - <td> - <?php - echo "<input size=49 name=\"author\" type=\"text\" value=\"". $new_ps_file_info_array[ 'author' ] ."\">"; - ?> - </td> - </tr> - - <tr> - <td> - Authors Position - </td> - <td> - <?php - echo "<input size=49 name=\"authorsposition\" type=\"text\" value=\"". $new_ps_file_info_array[ 'authorsposition' ] ."\"> - Note: not used in Photoshop 7 or higher"; - ?> - </td> - </tr> - - <tr> - <td> - Description - </td> - <td> - <textarea name="caption" rows=3 cols=37 wrap="off"><?php echo $new_ps_file_info_array[ 'caption' ]; ?></textarea> - </td> - </tr> - - <tr> - <td> - Description Writer - </td> - <td> - <?php - echo "<input size=49 name=\"captionwriter\" type=\"text\" value=\"". $new_ps_file_info_array[ 'captionwriter' ] ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Keywords - </td> - <td> - <textarea name="keywords" rows=3 cols=37 wrap="off"><?php - foreach( $new_ps_file_info_array[ 'keywords' ] as $keyword ) - { - echo "$keyword
"; - } - ?></textarea> - </td> - </tr> - - - <tr> - <td> - Copyright Status - </td> - <td> - <select size=1 name="copyrightstatus"> - <?php - $copystatus = $new_ps_file_info_array[ 'copyrightstatus' ]; - if ( $copystatus == "Unknown" ) - { - echo "<option value=\"Unknown\" SELECTED >Unknown</option>\n"; - } - else - { - echo "<option value=\"Unknown\">Unknown</option>\n"; - } - - if ( $copystatus == "Copyrighted Work" ) - { - echo "<option value=\"Copyrighted Work\" SELECTED >Copyrighted Work</option>\n"; - } - else - { - echo "<option value=\"Copyrighted Work\">Copyrighted Work</option>\n"; - } - - if ( $copystatus == "Public Domain" ) - { - echo "<option value=\"Public Domain\" SELECTED >Public Domain</option>\n"; - } - else - { - echo "<option value=\"Public Domain\">Public Domain</option>\n"; - } - ?> - </select> - </td> - </tr> - - - <tr> - <td> - Copyright Notice - </td> - <td> - <textarea name="copyrightnotice" rows=3 cols=37 wrap="off"><?php echo $new_ps_file_info_array[ 'copyrightnotice' ]; ?></textarea> - </td> - </tr> - - - <tr> - <td> - Copyright Info URL - </td> - <td> - <?php - echo "<input size=49 name=\"ownerurl\" type=\"text\" value=\"". $new_ps_file_info_array[ 'ownerurl' ] ."\">\n"; - if ($new_ps_file_info_array[ 'ownerurl' ] != "" ) - { - echo "<a href=\"". $new_ps_file_info_array[ 'ownerurl' ] ."\" > (". $new_ps_file_info_array[ 'ownerurl' ] .")</a>\n"; - } - ?> - - </td> - </tr> - - - <tr> - <td> - Category - </td> - <td> - <?php - echo "<input size=49 name=\"category\" type=\"text\" value=\"". $new_ps_file_info_array[ 'category' ] ."\">\n"; - ?> - - </td> - </tr> - - <tr> - <td> - Supplemental Categories - </td> - <td> - <textarea name="supplementalcategories" rows=3 cols=37 wrap="off"><?php - foreach( $new_ps_file_info_array[ 'supplementalcategories' ] as $supcat ) - { - echo "$supcat
"; - } - ?> - </textarea> - </td> - </tr> - - - - <tr> - <td> - Date Created - </td> - <td> - <?php - echo "<input size=49 name=\"date\" type=\"text\" value=\"". $new_ps_file_info_array[ 'date' ] ."\">"; - ?> - (Note date must be YYYY-MM-DD format) - </td> - </tr> - - <tr> - <td> - City - </td> - <td> - <?php - echo "<input size=49 name=\"city\" type=\"text\" value=\"". $new_ps_file_info_array[ 'city' ] ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - State - </td> - <td> - <?php - echo "<input size=49 name=\"state\" type=\"text\" value=\"". $new_ps_file_info_array[ 'state' ] ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Country - </td> - <td> - <?php - echo "<input size=49 name=\"country\" type=\"text\" value=\"". $new_ps_file_info_array[ 'country' ] ."\">"; - ?> - </td> - </tr> - - - - <tr> - <td> - Credit - </td> - <td> - <?php - echo "<input size=49 name=\"credit\" type=\"text\" value=\"". $new_ps_file_info_array[ 'credit' ] ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Source - </td> - <td> - <?php - echo "<input size=49 name=\"source\" type=\"text\" value=\"". $new_ps_file_info_array[ 'source' ] ."\">"; - ?> - </td> - </tr> - - - - <tr> - <td> - Headline - </td> - <td> - <textarea name="headline" rows=3 cols=37 wrap="off"><?php echo $new_ps_file_info_array[ 'headline' ]; ?></textarea> - </td> - </tr> - - - - <tr> - <td> - Instructions - </td> - <td> - <textarea name="instructions" rows=3 cols=37 wrap="off"><?php echo $new_ps_file_info_array[ 'instructions' ]; ?></textarea> - </td> - </tr> - - - <tr> - <td> - Transmission Reference - </td> - <td> - <textarea name="transmissionreference" rows=3 cols=37 wrap="off"><?php echo $new_ps_file_info_array[ 'transmissionreference' ]; ?></textarea> - </td> - </tr> - - <tr> - <td> - Job Name - </td> - <td> - <?php - echo "<input size=49 name=\"jobname\" type=\"text\" value=\"". $new_ps_file_info_array[ 'jobname' ] ."\"> - Note: not used in Photoshop CS"; - ?> - </td> - </tr> - - <tr> - <td> - Urgency - </td> - <td> - <select size="1" name="urgency"> - <?php - for( $i = 1; $i <= 8; $i++ ) - { - echo "<option value=\"$i\""; - if ( $new_ps_file_info_array[ 'urgency' ] == $i ) - { - echo " SELECTED "; - } - echo ">"; - if ( $i == 1 ) - { - echo "High"; - } - else if ( $i == 5 ) - { - echo "Normal"; - } - else if ( $i == 8 ) - { - echo "Low"; - } - else - { - echo "$i"; - } - echo "</option>\n"; - } - if ( $new_ps_file_info_array[ 'urgency' ] == "none" ) - { - echo "<option value=\"none\" SELECTED >None</option>"; - } - else - { - echo "<option value=\"none\" >None</option>"; - } - ?> - - </select> - </td> - </tr> - - </table> - <br> - <input type="submit" value="Update!"> - - - </form> - - <br> - <br> - <p>Powered by: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version 1.0, Copyright (C) 2004 Evan Hunter</a></p> - <br> - <br> - - */ - -/* - * NOT YET USED - */ -/* -<html> - -<!--*************************************************************************** -* -* Filename: Write_File_Info.php -* -* Description: An example file showing how a user can write the metadata of an -* image over the internet in the same way that Photoshop -* edits 'File Info' data. -* This script pairs with Edit_File_Info_Example.php, receiving -* and processing the data from the HTML form in that script -* -* Author: Evan Hunter -* -* Date: 17/11/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.10 -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit 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. -* -* The PHP JPEG Metadata Toolkit 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 the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************--> - - - - <head> - <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> - <STYLE TYPE="text/css" MEDIA="screen, print, projection"> - <!-- - - BODY { background-color:#505050; color:#F0F0F0 } - a { color:orange } - .EXIF_Main_Heading { color:red } - .EXIF_Secondary_Heading{ color: orange} - .EXIF_Table { border-collapse: collapse ; border: 1px solid #909000} - .EXIF_Table tbody td{border-width: 1px; border-style:solid; border-color: #909000;} - - --> - </STYLE> - - <title>Writing Photoshop File Info Metadata</title> - </head> - - <body> - <p>Powered by: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version 1.0, Copyright (C) 2004 Evan Hunter</a></p> - <br> - <br> - - <?php - // Turn off Error Reporting - error_reporting ( E_ALL ); - - // Include the required files for reading and writing Photoshop File Info - include 'JPEG.php'; - include 'XMP.php'; - include 'Photoshop_IRB.php'; - include 'EXIF.php'; - include 'Photoshop_File_Info.php'; - - - // Copy all of the HTML Posted variables into an array - $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS']; - - // Some characters are escaped with backslashes in HTML Posted variable - // Cycle through each of the HTML Posted variables, and strip out the slashes - foreach( $new_ps_file_info_array as $var_key => $var_val ) - { - $new_ps_file_info_array[ $var_key ] = stripslashes( $var_val ); - } - - // Keywords should be an array - explode it on newline boundarys - $new_ps_file_info_array[ 'keywords' ] = explode( "\n", trim( $new_ps_file_info_array[ 'keywords' ] ) ); - - // Supplemental Categories should be an array - explode it on newline boundarys - $new_ps_file_info_array[ 'supplementalcategories' ] = explode( "\n", trim( $new_ps_file_info_array[ 'supplementalcategories' ] ) ); - - // Make the filename easier to access - $filename = $new_ps_file_info_array[ 'filename' ]; - - // Protect against hackers editing other files - $path_parts = pathinfo( $filename ); - if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) - { - echo "Incorrect File Type - JPEG Only\n"; - exit( ); - } - $filename = $path_parts["basename"]; - - - // Retrieve the header information - $jpeg_header_data = get_jpeg_header_data( $filename ); - - // Retreive the EXIF, XMP and Photoshop IRB information from - // the existing file, so that it can be updated - $Exif_array = get_EXIF_JPEG( $filename ); - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); - $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); - - // Update the JPEG header information with the new Photoshop File Info - $jpeg_header_data = put_photoshop_file_info( $jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array ); - - //... [truncated message content] |
From: <bz...@us...> - 2007-02-02 11:38:51
|
Revision: 4671 http://svn.sourceforge.net/linpha/?rev=4671&view=rev Author: bzrudi Date: 2007-02-02 03:38:45 -0800 (Fri, 02 Feb 2007) Log Message: ----------- fixed wrong MetaDataIndex instance, should read LinMetaDataIndex. As reported by sx03 in LinPHA2 Forum. Thanks! Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/maintenance_import.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-01-23 20:17:49 UTC (rev 4670) +++ trunk/linpha2/ChangeLog 2007-02-02 11:38:45 UTC (rev 4671) @@ -1,3 +1,7 @@ +2007-02-02 bzrudi + * fixed wrong MetaDataIndex instance, should read LinMetaDataIndex. As + reported by sx03 in LinPHA2 Forum. Thanks! + 2007-01-23 flo * removed old files * updated todo Modified: trunk/linpha2/admin/maintenance_import.php =================================================================== --- trunk/linpha2/admin/maintenance_import.php 2007-01-23 20:17:49 UTC (rev 4670) +++ trunk/linpha2/admin/maintenance_import.php 2007-02-02 11:38:45 UTC (rev 4671) @@ -200,7 +200,7 @@ * * if "Delete First" and "All albums" was selected, the whole table will be deleted */ - $MetaData = new MetaDataIndex(); + $MetaData = new LinMetaDataIndex(); foreach($array_meta AS $meta_value) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-02-13 16:30:48
|
Revision: 4675 http://svn.sourceforge.net/linpha/?rev=4675&view=rev Author: bzrudi Date: 2007-02-13 08:30:32 -0800 (Tue, 13 Feb 2007) Log Message: ----------- Huge rework of metadata stuff and in particular XMP. Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/maintenance_import.php trunk/linpha2/admin/metadata_define.php trunk/linpha2/admin/metadata_define_post.php trunk/linpha2/docs/dev/external_libraries.txt trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/pjmt/XMP.php trunk/linpha2/lib/include/File_Info_Show.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/ChangeLog 2007-02-13 16:30:32 UTC (rev 4675) @@ -1,3 +1,10 @@ +2007-02-13 bzrudi + * huge rework of the metadata stuff and in particular XMP. Do not expect to + see something, I just prepared alle things to work together. + We will have a new XMP relation which holds XMP seperated from IPTC. + At least the basic xmp table should be created, no read of data and still + very incomplete + 2007-02-02 bzrudi * fixed wrong MetaDataIndex instance, should read LinMetaDataIndex. As reported by sx03 in LinPHA2 Forum. Thanks! Modified: trunk/linpha2/admin/maintenance_import.php =================================================================== --- trunk/linpha2/admin/maintenance_import.php 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/admin/maintenance_import.php 2007-02-13 16:30:32 UTC (rev 4675) @@ -286,6 +286,7 @@ $MetaData->saveData( 'iptc', $full_filename,$md5sum ); break; case 'xmp': + $MetaData->saveData( 'xmp', $full_filename,$md5sum ); break; } Modified: trunk/linpha2/admin/metadata_define.php =================================================================== --- trunk/linpha2/admin/metadata_define.php 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/admin/metadata_define.php 2007-02-13 16:30:32 UTC (rev 4675) @@ -20,8 +20,9 @@ $array_menu = Array( 'own' => Array('name' => 'Own fields', 'link' => 'metadata_define_own'), 'adddata' => Array('name' => 'Add select data (set Category names)', 'link' => 'metadata_define_adddata'), - 'exif' => Array('name' => 'Exif fields', 'link' => 'metadata_define_exif'), - 'iptc' => Array('name' => 'Iptc fields', 'link' => 'metadata_define_iptc') + 'exif' => Array('name' => 'EXIF fields', 'link' => 'metadata_define_exif'), + 'iptc' => Array('name' => 'IPTC fields', 'link' => 'metadata_define_iptc'), + 'xmp' => Array('name' => 'XMP fields', 'link' => 'metadata_define_xmp') ); LinAdmin::printAdminMenu($array_menu,$cat3); @@ -42,17 +43,32 @@ show_add_data(); break; case 'exif': - echo i18n("The exif data are normally automatically created by the digital camera. These values may not be edited whitin LinPHA."); - echo '<br /><br />'; - echo i18n("You probably may not choose all exif tags, because the database table would get to big."); + echo i18n("EXIF data is usually created by the any Digital Camera. " . + "These values will be indexed for searching and displaying them, " . + "but can't be edited with LinPHA."); + echo '<br />'; + echo i18n("Hint: You should't choose all available EXIF tags " . + "because the database table may get to large (MySQL) and therefore " . + "could result in an error."); echo '<br /><br /><br />'; - show_exif_iptc(); + show_metadata(); break; case 'iptc': + echo i18n("IPTC data is usually not available by default. " . + "It needs to be filled up either with LinPHA, " . + "or with any external program which allows IPTC editing like Photoshop. " . + "IPTC is a standard within professional Photographer business."); + echo '<br /><br />'; + show_metadata(); + break; + case 'xmp': - echo i18n("The iptc/xmp data are normally not created by default. They need to be filled in within LinPHA or with an external program like photoshop. The iptc/xmp tags are very common in the photographer industry."); + echo i18n("XMP data is usually not available by default. " . + "It needs to be filled up either with LinPHA, " . + "or with any external program which allows XMP editing like Photoshop. " . + "XMP is standard within professional Photographer business."); echo '<br /><br />'; - show_exif_iptc(); + show_metadata(); break; } @@ -259,7 +275,7 @@ } } -function show_exif_iptc() +function show_metadata() { $MetaData = new LinMetaDataAdmin(); $MetaData->setFields( $GLOBALS['cat3'] ); @@ -272,9 +288,9 @@ <div align="center"> <form action="./?cat=metadata_define_<?php echo $GLOBALS['cat3']; ?>" method="POST"> - <input type="radio" name="exifiptc_enable" value="1"<?php echo ($enabled ? ' checked="checked"' : ''); ?> />Enable - <input type="radio" name="exifiptc_enable" value="0"<?php echo ($enabled ? '' : ' checked="checked"'); ?> />Disable - <input type="hidden" name="cmd" value="update_exifiptc" /> + <input type="radio" name="metadata_config_enable" value="1"<?php echo ($enabled ? ' checked="checked"' : ''); ?> />Enable + <input type="radio" name="metadata_config_enable" value="0"<?php echo ($enabled ? '' : ' checked="checked"'); ?> />Disable + <input type="hidden" name="cmd" value="update_config_metadata" /> <input type="submit" name="name" value="update" /> </form> <br /><br /> @@ -312,7 +328,7 @@ </td> </tr> </table> - <input type="hidden" name="cmd" value="create_exifiptc" /> + <input type="hidden" name="cmd" value="create_metadata_table" /> <input type="submit" name="name" value="Submit" /> </form> Modified: trunk/linpha2/admin/metadata_define_post.php =================================================================== --- trunk/linpha2/admin/metadata_define_post.php 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/admin/metadata_define_post.php 2007-02-13 16:30:32 UTC (rev 4675) @@ -77,17 +77,17 @@ $linpha->db->Execute("UPDATE ".LIN_PREFIX."meta_category SET " . "name = '".LinSql::linAddslashes($_POST['new_name'])."', ". "isprivate = '".$isprivate."' ". - "WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); + "WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; case 'delete_category': $linpha->db->Execute("DELETE FROM ".LIN_PREFIX."meta_category WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; -case 'update_exifiptc': - $linpha->sql->config->updateConfig('sys_image_'.$cat3,$_POST['exifiptc_enable']); +case 'update_config_metadata': + $linpha->sql->config->updateConfig('sys_image_'.$cat3,$_POST['metadata_config_enable']); $linpha->sql->config->reloadConfig(); break; -case 'create_exifiptc': +case 'create_metadata_table': if( ! isset($_POST['selected_fields'])) { $_POST['selected_fields'] = Array(); @@ -98,6 +98,9 @@ } elseif($cat3 == 'iptc') { $linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_iptc"); $linpha->db->Execute( LinMetadataAdmin::createIptcTable( $_POST['selected_fields'] ) ); + } elseif($cat3 == 'xmp') { + $linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_xmp"); + $linpha->db->Execute( LinMetadataAdmin::createXmpTable( $_POST['selected_fields'] ) ); } break; } Modified: trunk/linpha2/docs/dev/external_libraries.txt =================================================================== --- trunk/linpha2/docs/dev/external_libraries.txt 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/docs/dev/external_libraries.txt 2007-02-13 16:30:32 UTC (rev 4675) @@ -43,6 +43,9 @@ "RecName" => @$GLOBALS[ "IPTC_Entry_Names" ][ $iptctype ], "RecDesc" => @$GLOBALS[ "IPTC_Entry_Descriptions" ][ $iptctype ], ---- + + XMP.php + - add Iptc4xmpCore Segment entries File_Info_Edit.php (located in /lib/include) - base file from "Edit_File_Info.php", a lot of changes... Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-02-13 16:30:32 UTC (rev 4675) @@ -1313,7 +1313,7 @@ */ function viewImgStoreImageInformation() { - $array_meta = array('exif','iptc'); + $array_meta = array('exif','iptc','xmp'); foreach($array_meta AS $value) { if( !isset($MetaData) ) @@ -1322,7 +1322,7 @@ } /** - * read exif/iptc from file if no entry + * read exif/iptc/xmp from file if no entry */ if($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) { Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-13 16:30:32 UTC (rev 4675) @@ -183,6 +183,7 @@ } } break; + //TODO add XMP } if($value != '') @@ -356,6 +357,56 @@ return $str; } + function createXmpTable($array='') + { + if(empty($array)) + { + $array = Array(); + } + + if(LIN_DB_TYPE == "mysql") + { + $str = "CREATE TABLE ".LIN_PREFIX."meta_xmp (". + "md5sum VARCHAR(32) NOT NULL, "; + + foreach($array AS $key=>$value) + { + $str .= LinSql::linAddslashes(strtolower($value))." VARCHAR(255), "; + } + $str .= "PRIMARY KEY (md5sum), "; + $str .= "KEY (md5sum) )"; + } + elseif(LIN_DB_TYPE == "sqlite") + { + $str = "CREATE TABLE ".LIN_PREFIX."meta_xmp (". + "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; + foreach($array AS $key=>$value) + { + $str .= strtolower($value)." VARCHAR(255), "; + } + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str,0,strlen($str)-2).")"; + } + elseif(LIN_DB_TYPE == "postgres") + { + $str = "CREATE TABLE ".LIN_PREFIX."meta_xmp (". + "md5sum VARCHAR(32) NOT NULL, "; + + foreach($array AS $key=>$value) + { + $str .= strtolower($value)." VARCHAR(255), "; + } + + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str,0,strlen($str)-2).")"; + } + return $str; + } + } // end class LinMetaDataAdmin @@ -365,7 +416,8 @@ class LinMetaDataIndex extends LinMetaData { /** - * wrapper function for saveExifData and saveIptcDate for easier access + * wrapper function for saveExifData, saveIptcData and saveXmpData + * for easier access */ function saveData($what,$filename,$md5sum) { @@ -395,6 +447,9 @@ case 'iptc': $this->saveIptcData($filename,$md5sum); break; + case 'xmp': + $this->saveXmpData($filename,$md5sum); + break; } } } @@ -562,7 +617,121 @@ "VALUES (".$str_values.")"); } + /** + * store XMP data in DB + */ + function saveXmpData($filename, $md5sum) + { + include_once(LINPHA_DIR.'/lib/classes/pjmt/XMP.php'); + include_once(LINPHA_DIR.'/lib/classes/pjmt/JPEG.php'); + + $str_columns = "md5sum, "; + $str_values = "'".$md5sum."', "; + + $jpeg_header_data = get_jpeg_header_data($filename); + $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); + + // Check if the XMP tree structure array is valid + if ( $XMP_array !== FALSE ) + { + // Check if there is a rdf:RDF tag at either the first or second level + if ( ( $XMP_array[0]['tag'] == "x:xapmeta" ) && ( $XMP_array[0]['children'][0]['tag'] == "rdf:RDF" ) ) + { + // RDF found at second level - Save it's position + $RDF_Contents = &$XMP_array[0]['children'][0]['children']; + } + else if ( ( $XMP_array[0]['tag'] == "x:xmpmeta" ) && ( $XMP_array[0]['children'][0]['tag'] == "rdf:RDF" ) ) + { + // RDF found at second level - Save it's position + $RDF_Contents = &$XMP_array[0]['children'][0]['children']; + } + else if ( $XMP_array[0]['tag'] == "rdf:RDF" ) + { + // RDF found at first level - Save it's position + $RDF_Contents = &$XMP_array[0]['children']; + } + else + { + // RDF section not found - abort + return ""; + } + + // Cycle through each of the items in the RDF tree array, and process them + foreach ($RDF_Contents as $RDF_Item) + { + // Check if this element has sub-items + if ( array_key_exists( 'children', $RDF_Item ) ) + { + // Cycle through each of the sub-items + foreach( $RDF_Item['children'] as $child_item ) + { + /** + * Get user defined fields for xmp + */ + foreach($this->defined_fields['xmp'] AS $key=>$value) + { + if( !empty(LinMetaData::$Tags['xmp'][$key]['path']) ) + { + + /** + * Field hit! e.g. image contains data user want's to + * have in DB later + */ + if(LinMetaData::$Tags['xmp'][$key]['path'] == $child_item['tag']) + { + /** + * If value is empty, it does not necesarry mean there + * is no data, so we have to cycle through, this + * is a real mess ;-) + */ + if(!isset($child_item['value'])) + { + if(is_array($child_item['children'])) + { + /** + * We need to get value for rdf:li which may be an + * order or unorder list, or even a list of alternatives, bah! + * However we handle them all the same + */ + $child_item['value'] = $child_item['children'][0]['children'][0]['value']; + + } + } + + $str_columns .= LinMetaData::$Tags['xmp'][$key]['pathkey'].', '; + $str_values .= "'".trim( $child_item['value']).""; + $str_values .= "', "; + + break; + + } + } + + } + } + } + } + + /** + * remove last two signs (the comma and the space) which we added to much + */ + $str_columns = substr($str_columns,0,strlen($str_columns)-2); + $str_values = substr($str_values,0,strlen($str_values)-2); + + + $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_xmp (".$str_columns.") ". + "VALUES (".$str_values.")"); + } + else + { + //linSysLog( i18n("NO XMP FOUND:" .' '. $filename) ); + //linLog( LOG_TYPE_META, ERROR, 'meta_xmp', "ERROR:" .' '. $filename ); + //exit(); + } + } + + /** * Autorotate Images via EXIF tag * Most Images contain an orientation tag which shows if and how to rotate * the images @@ -1028,37 +1197,37 @@ // A. Tags relating to image data structure 'imagewidth' => array('name' => 'Image Width', 'pathkey' => 'ImageWidth', 'pathvalue' => ''), 'imagelength' => array('name' => 'Image Length', 'pathkey' => 'ImageLength', 'pathvalue' => ''), - 'bitspersample' => array('name' => 'Bits Per Sample', 'pathkey' => 'BitsPerSample', 'pathvalue' => ''), + 'bitspersample' => array('name' => 'Bits Per Sample', 'pathkey' => 'BitsPerSample', 'pathvalue' => ''), 'compression' => array('name' => 'Compression', 'pathkey' => 'Compression', 'pathvalue' => ''), - 'photometricinterpretation' => array('name' => 'Photometric Interpretation', 'pathkey' => 'PhotometricInterpretation', 'pathvalue' => ''), + 'photometricinterpretation' => array('name' => 'Photometric Interpretation', 'pathkey' => 'PhotometricInterpretation', 'pathvalue' => ''), 'orientation' => array('name' => 'Orientation', 'pathkey' => 'Orientation', 'pathvalue' => '0/274'), 'samplesperpixel' => array('name' => 'Samples Per Pixel', 'pathkey' => 'SamplesPerPixel', 'pathvalue' => ''), - 'planarconfiguration' => array('name' => 'Planar Configuration', 'pathkey' => 'PlanarConfiguration', 'pathvalue' => ''), - 'ycbcrsubsampling' => array('name' => 'YCbCr Sub Sampling', 'pathkey' => 'YCbCrSubSampling', 'pathvalue' => ''), - 'ycbcrpositioning' => array('name' => 'YCbCr Positioning', 'pathkey' => 'YCbCrPositioning', 'pathvalue' => '0/531'), + 'planarconfiguration' => array('name' => 'Planar Configuration', 'pathkey' => 'PlanarConfiguration', 'pathvalue' => ''), + 'ycbcrsubsampling' => array('name' => 'YCbCr Sub Sampling', 'pathkey' => 'YCbCrSubSampling', 'pathvalue' => ''), + 'ycbcrpositioning' => array('name' => 'YCbCr Positioning', 'pathkey' => 'YCbCrPositioning', 'pathvalue' => '0/531'), 'xresolution' => array('name' => 'X Resolution', 'pathkey' => 'XResolution', 'pathvalue' => '0/282'), 'yresolution' => array('name' => 'Y Resolution', 'pathkey' => 'YResolution', 'pathvalue' => '0/283'), 'resolutionunit' => array('name' => 'Resolution Unit', 'pathkey' => 'ResolutionUnit', 'pathvalue' => '0/296'), // B. Tags relating to recording offset - 'stripoffsets' => array('name' => 'Strip Offsets', 'pathkey' => 'StripOffsets', 'pathvalue' => ''), - 'rowsperstrip' => array('name' => 'Rows Per Strip', 'pathkey' => 'RowsPerStrip', 'pathvalue' => ''), + 'stripoffsets' => array('name' => 'Strip Offsets', 'pathkey' => 'StripOffsets', 'pathvalue' => ''), + 'rowsperstrip' => array('name' => 'Rows Per Strip', 'pathkey' => 'RowsPerStrip', 'pathvalue' => ''), 'stripbytecounts' => array('name' => 'Strip Byte Counts', 'pathkey' => 'StripByteCounts', 'pathvalue' => ''), - 'jpeginterchangeformat' => array('name' => 'JPEG Interchange Format', 'pathkey' => 'JPEGInterchangeFormat', 'pathvalue' => ''), - 'jpeginterchangeformatlength' => array('name' => 'JPEG Interchange Format Length', 'pathkey' => 'JPEGInterchangeFormatLength', 'pathvalue' => ''), + 'jpeginterchangeformat' => array('name' => 'JPEG Interchange Format', 'pathkey' => 'JPEGInterchangeFormat', 'pathvalue' => ''), + 'jpeginterchangeformatlength'=> array('name' => 'JPEG Interchange Format Length', 'pathkey' => 'JPEGInterchangeFormatLength', 'pathvalue' => ''), // C. Tags relating to image data characteristics - 'transferfunction' => array('name' => 'Transfer Function', 'pathkey' => 'TransferFunction', 'pathvalue' => ''), + 'transferfunction' => array('name' => 'Transfer Function', 'pathkey' => 'TransferFunction', 'pathvalue' => ''), 'whitepoint' => array('name' => 'White Point', 'pathkey' => 'WhitePoint', 'pathvalue' => ''), - 'primarychromaticities' => array('name' => 'Primary Chromaticities', 'pathkey' => 'PrimaryChromaticities', 'pathvalue' => ''), - 'ycbcrcoefficients' => array('name' => 'YCbCr Coefficients', 'pathkey' => 'YCbCrCoefficients', 'pathvalue' => ''), - 'referenceblackwhite' => array('name' => 'Reference Black White', 'pathkey' => 'ReferenceBlackWhite', 'pathvalue' => ''), + 'primarychromaticities' => array('name' => 'Primary Chromaticities', 'pathkey' => 'PrimaryChromaticities', 'pathvalue' => ''), + 'ycbcrcoefficients' => array('name' => 'YCbCr Coefficients', 'pathkey' => 'YCbCrCoefficients', 'pathvalue' => ''), + 'referenceblackwhite' => array('name' => 'Reference Black White', 'pathkey' => 'ReferenceBlackWhite', 'pathvalue' => ''), // D. Other tags 'datetime' => array('name' => 'Date Time', 'pathkey' => 'DateTime', 'pathvalue' => '0/306'), - 'imagedescription' => array('name' => 'Image Description', 'pathkey' => 'ImageDescription', 'pathvalue' => '0/270'), + 'imagedescription' => array('name' => 'Image Description', 'pathkey' => 'ImageDescription', 'pathvalue' => '0/270'), 'make' => array('name' => 'Make', 'pathkey' => 'Make', 'pathvalue' => '0/271'), - 'model' => array('name' => 'Model', 'pathkey' => 'Model', 'pathvalue' => '0/272'), + 'model' => array('name' => 'Model', 'pathkey' => 'Model', 'pathvalue' => '0/272'), 'software' => array('name' => 'Software', 'pathkey' => 'Software', 'pathvalue' => '0/305'), 'artist' => array('name' => 'Artist', 'pathkey' => 'Artist', 'pathvalue' => '0/315'), 'copyright' => array('name' => 'Copyright', 'pathkey' => 'Copyright', 'pathvalue' => '0/33432'), @@ -1082,72 +1251,72 @@ 'usercomment' => array('name' => 'User Comment', 'pathkey' => 'UserComment', 'pathvalue' => '0/34665/Data/0/37510'), // E. Tag Relating to Related File Information - 'relatedsoundfile' => array('name' => 'Related Sound File', 'pathkey' => 'RelatedSoundFile', 'pathvalue' => ''), + 'relatedsoundfile' => array('name' => 'Related Sound File', 'pathkey' => 'RelatedSoundFile', 'pathvalue' => ''), // F. Tags Relating to Date and Time - 'datetimeoriginal' => array('name' => 'Date Time Original', 'pathkey' => 'DateTimeOriginal', 'pathvalue' => '0/34665/Data/0/36867'), - 'datetimedigitized' => array('name' => 'Date Time Digitized', 'pathkey' => 'DateTimeDigitized', 'pathvalue' => '0/34665/Data/0/36868'), + 'datetimeoriginal' => array('name' => 'Date Time Original', 'pathkey' => 'DateTimeOriginal', 'pathvalue' => '0/34665/Data/0/36867'), + 'datetimedigitized' => array('name' => 'Date Time Digitized', 'pathkey' => 'DateTimeDigitized', 'pathvalue' => '0/34665/Data/0/36868'), 'subsectime' => array('name' => 'Sub Sec Time', 'pathkey' => 'SubSecTime', 'pathvalue' => ''), 'subsectimeoriginal' => array('name' => 'Sub Sec Time Original', 'pathkey' => 'SubSecTimeOriginal', 'pathvalue' => ''), 'subsectimedigitized' => array('name' => 'Sub Sec Time Digitized', 'pathkey' => 'SubSecTimeDigitized', 'pathvalue' => ''), // G. Tags Relating to Picture-Taking Conditions - 'exposuretime' => array('name' => 'Exposure Time', 'pathkey' => 'ExposureTime', 'pathvalue' => '0/34665/Data/0/33434'), + 'exposuretime' => array('name' => 'Exposure Time', 'pathkey' => 'ExposureTime', 'pathvalue' => '0/34665/Data/0/33434'), 'fnumber' => array('name' => 'F Number', 'pathkey' => 'FNumber', 'pathvalue' => '0/34665/Data/0/33437'), 'exposureprogram' => array('name' => 'Exposure Program', 'pathkey' => 'ExposureProgram', 'pathvalue' => '0/34665/Data/0/34850'), - 'spectralsensitivity' => array('name' => 'Spectral Sensitivity', 'pathkey' => 'SpectralSensitivity', 'pathvalue' => ''), + 'spectralsensitivity' => array('name' => 'Spectral Sensitivity', 'pathkey' => 'SpectralSensitivity', 'pathvalue' => ''), 'isospeedratings' => array('name' => 'ISO Speed Ratings', 'pathkey' => 'ISOSpeedRatings', 'pathvalue' => '0/34665/Data/0/34855'), 'oecf' => array('name' => 'OECF', 'pathkey' => 'OECF', 'pathvalue' => ''), - 'shutterspeedvalue' => array('name' => 'Shutter Speed Value', 'pathkey' => 'ShutterSpeedValue', 'pathvalue' => '0/34665/Data/0/37377'), - 'aperturevalue' => array('name' => 'Aperture Value', 'pathkey' => 'ApertureValue', 'pathvalue' => '0/34665/Data/0/37378'), + 'shutterspeedvalue' => array('name' => 'Shutter Speed Value', 'pathkey' => 'ShutterSpeedValue', 'pathvalue' => '0/34665/Data/0/37377'), + 'aperturevalue' => array('name' => 'Aperture Value', 'pathkey' => 'ApertureValue', 'pathvalue' => '0/34665/Data/0/37378'), 'brightnessvalue' => array('name' => 'Brightness Value', 'pathkey' => 'BrightnessValue', 'pathvalue' => '0/34665/Data/0/37379'), - 'exposurebiasvalue' => array('name' => 'Exposure Bias Value', 'pathkey' => 'ExposureBiasValue', 'pathvalue' => '0/34665/Data/0/37380'), - 'maxaperturevalue' => array('name' => 'MaxAperture Value', 'pathkey' => 'MaxApertureValue', 'pathvalue' => '0/34665/Data/0/37381'), + 'exposurebiasvalue' => array('name' => 'Exposure Bias Value', 'pathkey' => 'ExposureBiasValue', 'pathvalue' => '0/34665/Data/0/37380'), + 'maxaperturevalue' => array('name' => 'MaxAperture Value', 'pathkey' => 'MaxApertureValue', 'pathvalue' => '0/34665/Data/0/37381'), 'subjectdistance' => array('name' => 'Subject Distance', 'pathkey' => 'SubjectDistance', 'pathvalue' => '0/34665/Data/0/37382'), - 'meteringmode' => array('name' => 'Metering Mode', 'pathkey' => 'MeteringMode', 'pathvalue' => '0/34665/Data/0/37383'), + 'meteringmode' => array('name' => 'Metering Mode', 'pathkey' => 'MeteringMode', 'pathvalue' => '0/34665/Data/0/37383'), 'lightsource' => array('name' => 'Light Source', 'pathkey' => 'LightSource', 'pathvalue' => '0/34665/Data/0/37384'), - 'flash' => array('name' => 'Flash', 'pathkey' => 'Flash', 'pathvalue' => '0/34665/Data/0/37385'), + 'flash' => array('name' => 'Flash', 'pathkey' => 'Flash', 'pathvalue' => '0/34665/Data/0/37385'), 'focallength' => array('name' => 'Focal Length', 'pathkey' => 'FocalLength', 'pathvalue' => '0/34665/Data/0/37386'), 'subjectarea' => array('name' => 'Subject Area', 'pathkey' => 'SubjectArea', 'pathvalue' => ''), 'flashenergy' => array('name' => 'Flash Energy', 'pathkey' => 'FlashEnergy', 'pathvalue' => ''), - 'spatialfrequencyresponse' => array('name' => 'Spatial Frequency Response', 'pathkey' => 'SpatialFrequencyResponse', 'pathvalue' => ''), - 'focalplanexresolution' => array('name' => 'Focal Plane X Resolution', 'pathkey' => 'FocalPlaneXResolution', 'pathvalue' => '0/34665/Data/0/41486'), - 'focalplaneyresolution' => array('name' => 'Foca Plane Y Resolution', 'pathkey' => 'FocalPlaneYResolution', 'pathvalue' => '0/34665/Data/0/41487'), - 'focalplaneresolutionunit' => array('name' => 'Focal Plane Resolution Unit', 'pathkey' => 'FocalPlaneResolutionUnit', 'pathvalue' => '0/34665/Data/0/41488'), + 'spatialfrequencyresponse' => array('name' => 'Spatial Frequency Response', 'pathkey' => 'SpatialFrequencyResponse', 'pathvalue' => ''), + 'focalplanexresolution' => array('name' => 'Focal Plane X Resolution', 'pathkey' => 'FocalPlaneXResolution', 'pathvalue' => '0/34665/Data/0/41486'), + 'focalplaneyresolution' => array('name' => 'Foca Plane Y Resolution', 'pathkey' => 'FocalPlaneYResolution', 'pathvalue' => '0/34665/Data/0/41487'), + 'focalplaneresolutionunit' => array('name' => 'Focal Plane Resolution Unit', 'pathkey' => 'FocalPlaneResolutionUnit', 'pathvalue' => '0/34665/Data/0/41488'), 'subjectlocation' => array('name' => 'Subject Location', 'pathkey' => 'SubjectLocation', 'pathvalue' => ''), - 'exposureindex' => array('name' => 'Exposure Index', 'pathkey' => 'ExposureIndex', 'pathvalue' => ''), - 'sensingmethod' => array('name' => 'Sensing Method', 'pathkey' => 'SensingMethod', 'pathvalue' => '0/34665/Data/0/41495'), + 'exposureindex' => array('name' => 'Exposure Index', 'pathkey' => 'ExposureIndex', 'pathvalue' => ''), + 'sensingmethod' => array('name' => 'Sensing Method', 'pathkey' => 'SensingMethod', 'pathvalue' => '0/34665/Data/0/41495'), 'filesource' => array('name' => 'File Source', 'pathkey' => 'FileSource', 'pathvalue' => '0/34665/Data/0/41728'), - 'scenetype' => array('name' => 'Scene Type', 'pathkey' => 'SceneType', 'pathvalue' => '0/34665/Data/0/41729'), + 'scenetype' => array('name' => 'Scene Type', 'pathkey' => 'SceneType', 'pathvalue' => '0/34665/Data/0/41729'), 'cfapattern' => array('name' => 'CFA Pattern', 'pathkey' => 'CFAPattern', 'pathvalue' => ''), 'customrendered' => array('name' => 'Custom Rendered', 'pathkey' => 'CustomRendered', 'pathvalue' => '0/34665/Data/0/41985'), - 'exposuremode' => array('name' => 'Exposure Mode', 'pathkey' => 'ExposureMode', 'pathvalue' => '0/34665/Data/0/41986'), - 'whitebalance' => array('name' => 'White Balance', 'pathkey' => 'WhiteBalance', 'pathvalue' => '0/34665/Data/0/41987'), - 'digitalzoomratio' => array('name' => 'Digital Zoom Ratio', 'pathkey' => 'DigitalZoomRatio', 'pathvalue' => '0/34665/Data/0/41988'), - 'focallengthin35mmfilm' => array('name' => 'Focal Length In 35mm Film', 'pathkey' => 'FocalLengthIn35mmFilm', 'pathvalue' => ''), - 'scenecapturetype' => array('name' => 'Scene Capture Type', 'pathkey' => 'SceneCaptureType', 'pathvalue' => '0/34665/Data/0/41990'), + 'exposuremode' => array('name' => 'Exposure Mode', 'pathkey' => 'ExposureMode', 'pathvalue' => '0/34665/Data/0/41986'), + 'whitebalance' => array('name' => 'White Balance', 'pathkey' => 'WhiteBalance', 'pathvalue' => '0/34665/Data/0/41987'), + 'digitalzoomratio' => array('name' => 'Digital Zoom Ratio', 'pathkey' => 'DigitalZoomRatio', 'pathvalue' => '0/34665/Data/0/41988'), + 'focallengthin35mmfilm' => array('name' => 'Focal Length In 35mm Film', 'pathkey' => 'FocalLengthIn35mmFilm', 'pathvalue' => ''), + 'scenecapturetype' => array('name' => 'Scene Capture Type', 'pathkey' => 'SceneCaptureType', 'pathvalue' => '0/34665/Data/0/41990'), 'gaincontrol' => array('name' => 'Gain Control', 'pathkey' => 'GainControl', 'pathvalue' => '0/34665/Data/0/41991'), 'contrast' => array('name' => 'Contrast', 'pathkey' => 'Contrast', 'pathvalue' => '0/34665/Data/0/41992'), 'saturation' => array('name' => 'Saturation', 'pathkey' => 'Saturation', 'pathvalue' => '0/34665/Data/0/41993'), - 'sharpness' => array('name' => 'Sharpness', 'pathkey' => 'Sharpness', 'pathvalue' => '0/34665/Data/0/41994'), - 'devicesettingdescription' => array('name' => 'Device Setting Description', 'pathkey' => 'DeviceSettingDescription', 'pathvalue' => ''), - 'subjectdistancerange' => array('name' => 'Subject Distance Range', 'pathkey' => 'SubjectDistanceRange', 'pathvalue' => ''), + 'sharpness' => array('name' => 'Sharpness', 'pathkey' => 'Sharpness', 'pathvalue' => '0/34665/Data/0/41994'), + 'devicesettingdescription' => array('name' => 'Device Setting Description', 'pathkey' => 'DeviceSettingDescription', 'pathvalue' => ''), + 'subjectdistancerange' => array('name' => 'Subject Distance Range', 'pathkey' => 'SubjectDistanceRange', 'pathvalue' => ''), // H. Other Tags - 'imageuniqueid' => array('name' => 'Image Unique ID', 'pathkey' => 'ImageUniqueID', 'pathvalue' => ''), + 'imageuniqueid' => array('name' => 'Image Unique ID', 'pathkey' => 'ImageUniqueID', 'pathvalue' => ''), // GPS Attribute Information // A. Tags Relating to GPS - 'gpsversionid' => array('name' => 'GPS Version ID', 'pathkey' => 'GPSVersionID', 'pathvalue' => '0/34853/Data/0/0'), + 'gpsversionid' => array('name' => 'GPS Version ID', 'pathkey' => 'GPSVersionID', 'pathvalue' => '0/34853/Data/0/0'), 'gpslatituderef' => array('name' => 'GPS Latitude Ref', 'pathkey' => 'GPSLatitudeRef', 'pathvalue' => '0/34853/Data/0/1'), 'gpslatitude' => array('name' => 'GPS Latitude', 'pathkey' => 'GPSLatitude', 'pathvalue' => '0/34853/Data/0/2'), 'gpslongituderef' => array('name' => 'GPS Longitude Ref', 'pathkey' => 'GPSLongitudeRef', 'pathvalue' => '0/34853/Data/0/3'), - 'gpslongitude' => array('name' => 'GPS Longitude', 'pathkey' => 'GPSLongitude', 'pathvalue' => '0/34853/Data/0/4'), + 'gpslongitude' => array('name' => 'GPS Longitude', 'pathkey' => 'GPSLongitude', 'pathvalue' => '0/34853/Data/0/4'), 'gpsaltituderef' => array('name' => 'GPS Altitude Ref', 'pathkey' => 'GPSAltitudeRef', 'pathvalue' => '0/34853/Data/0/5'), 'gpsaltitude' => array('name' => 'GPS Altitude', 'pathkey' => 'GPSAltitude', 'pathvalue' => '0/34853/Data/0/6'), - 'gpstimestamp' => array('name' => 'GPS Timestamp', 'pathkey' => 'GPSTimeStamp', 'pathvalue' => '0/34853/Data/0/7'), - 'gpssatellites' => array('name' => 'GPS Satellites', 'pathkey' => 'GPSSatellites', 'pathvalue' => '0/34853/Data/0/8'), - 'gpsstatus' => array('name' => 'GPS Status', 'pathkey' => 'GPSStatus', 'pathvalue' => '0/34853/Data/0/9'), + 'gpstimestamp' => array('name' => 'GPS Timestamp', 'pathkey' => 'GPSTimeStamp', 'pathvalue' => '0/34853/Data/0/7'), + 'gpssatellites' => array('name' => 'GPS Satellites', 'pathkey' => 'GPSSatellites', 'pathvalue' => '0/34853/Data/0/8'), + 'gpsstatus' => array('name' => 'GPS Status', 'pathkey' => 'GPSStatus', 'pathvalue' => '0/34853/Data/0/9'), 'gpsmeasuremode' => array('name' => 'GPS Measure Mode', 'pathkey' => 'GPSMeasureMode', 'pathvalue' => '0/34853/Data/0/10'), 'gpsdop' => array('name' => 'GPS DOP', 'pathkey' => 'GPSDOP', 'pathvalue' => '0/34853/Data/0/11'), 'gpsspeedref' => array('name' => 'GPS Speed Ref', 'pathkey' => 'GPSSpeedRef', 'pathvalue' => '0/34853/Data/0/12'), @@ -1159,15 +1328,15 @@ 'gpsmapdatum' => array('name' => 'GPS Map Datum', 'pathkey' => 'GPSMapDatum', 'pathvalue' => '0/34853/Data/0/18'), 'gpsdestlatituderef' => array('name' => 'GPS Dest Latitude Ref', 'pathkey' => 'GPSDestLatitudeRef', 'pathvalue' => '0/34853/Data/0/19'), 'gpsdestlatitude' => array('name' => 'GPS Dest Latitude', 'pathkey' => 'GPSDestLatitude', 'pathvalue' => '0/34853/Data/0/20'), - 'gpsdestlongituderef' => array('name' => 'GPS Dest Longitude Ref', 'pathkey' => 'GPSDestLongitudeRef', 'pathvalue' => '0/34853/Data/0/21'), - 'gpsdestlongitude' => array('name' => 'GPS Dest Longitude', 'pathkey' => 'GPSDestLongitude', 'pathvalue' => '0/34853/Data/0/22'), - 'gpsdestbearingref' => array('name' => 'GPS Dest Bearing Ref', 'pathkey' => 'GPSDestBearingRef', 'pathvalue' => '0/34853/Data/0/23'), + 'gpsdestlongituderef' => array('name' => 'GPS Dest Longitude Ref', 'pathkey' => 'GPSDestLongitudeRef', 'pathvalue' => '0/34853/Data/0/21'), + 'gpsdestlongitude' => array('name' => 'GPS Dest Longitude', 'pathkey' => 'GPSDestLongitude', 'pathvalue' => '0/34853/Data/0/22'), + 'gpsdestbearingref' => array('name' => 'GPS Dest Bearing Ref', 'pathkey' => 'GPSDestBearingRef', 'pathvalue' => '0/34853/Data/0/23'), 'gpsdestbearing' => array('name' => 'GPS Dest Bearing', 'pathkey' => 'GPSDestBearing', 'pathvalue' => '0/34853/Data/0/24'), 'gpsdestdistanceref' => array('name' => 'GPS Dest Distance Ref', 'pathkey' => 'GPSDestDistanceRef', 'pathvalue' => '0/34853/Data/0/25'), 'gpsdestdistance' => array('name' => 'GPS Dest Distance', 'pathkey' => 'GPSDestDistance', 'pathvalue' => '0/34853/Data/0/26'), - 'gpsprocessingmethod' => array('name' => 'GPS Processing Method', 'pathkey' => 'GPSProcessingMethod', 'pathvalue' => '0/34853/Data/0/27'), + 'gpsprocessingmethod' => array('name' => 'GPS Processing Method', 'pathkey' => 'GPSProcessingMethod', 'pathvalue' => '0/34853/Data/0/27'), 'gpsareainformation' => array('name' => 'GPS Area Information', 'pathkey' => 'GPSAreaInformation', 'pathvalue' => '0/34853/Data/0/28'), - 'gpsdatestamp' => array('name' => 'GPS DateStamp', 'pathkey' => 'GPSDateStamp', 'pathvalue' => '0/34853/Data/0/29'), + 'gpsdatestamp' => array('name' => 'GPS DateStamp', 'pathkey' => 'GPSDateStamp', 'pathvalue' => '0/34853/Data/0/29'), 'gpsdifferential' => array('name' => 'GPS Differential', 'pathkey' => 'GPSDifferential', 'pathvalue' => '0/34853/Data/0/30'), // Custom Makernotes http://www.ozhiker.com/electronics/pjmt/jpeg_info/makernotes.html @@ -1190,38 +1359,93 @@ // Panasonic // Ricoh - 'jpegcomment' => array('name' => 'JPEG Comment', 'pathkey' => 'JpegComment', 'pathvalue' => ''), + 'jpegcomment' => array('name' => 'JPEG Comment', 'pathkey' => 'JpegComment', 'pathvalue' => ''), ), 'iptc' => array( - 'caption' => array('name' => 'Caption', 'path' => '2:120'), - 'caption_writer' => array('name' => 'Caption Writer', 'path' => '2:122'), - 'headline' => array('name' => 'Headline', 'path' => '2:105'), - 'instructions' => array('name' => 'Special Instructions', 'path' => '2:40'), - 'keywords' => array('name' => 'Keywords', 'path' => '2:25'), - 'category' => array('name' => 'Category', 'path' => '2:15'), - 'supplemental_categorie' => array('name' => 'Supplemental Category', 'path' => '2:20'), - 'copyright' => array('name' => 'Copyright Notice', 'path' => '2:116'), - 'byline' => array('name' => 'By-Line (Author)', 'path' => '2:80'), - 'byline_title' => array('name' => 'By-Line Title', 'path' => '2:85'), // Not used in Photoshop 7 - 'credit' => array('name' => 'Credit', 'path' => '2:110'), - 'source' => array('name' => 'Source', 'path' => '2:115'), - 'edit_status' => array('name' => 'Edit Status', 'path' => '2:07'), - 'priority' => array('name' => 'Priority', 'path' => '2:10'), - 'object_cycle' => array('name' => 'Object Cycle', 'path' => '2:75'), - 'job_id' => array('name' => 'Fixture Identifier', 'path' => '2:22'), - 'program' => array('name' => 'Originating Program', 'path' => '2:65'), - 'object_name' => array('name' => 'Object Name (Title)', 'path' => '2:05'), - 'date_created' => array('name' => 'Date Created', 'path' => '2:55'), - 'date_released' => array('name' => 'Release Date', 'path' => '2:30'), - 'time_created' => array('name' => 'Time Created', 'path' => '2:60'), - 'time_released' => array('name' => 'Release Time', 'path' => '2:25'), - 'city' => array('name' => 'City', 'path' => '2:90'), - 'sublocation' => array('name' => 'Sub-Location', 'path' => '2:92'), - 'state' => array('name' => 'Province/State', 'path' => '2:95'), - 'country' => array('name' => 'Country Name', 'path' => '2:101'), - 'country_code' => array('name' => 'Country Code', 'path' => '2:100'), - 'trans_reference' => array('name' => 'Transmission Reference', 'path' => '2:103'), + 'caption' => array('name' => 'Caption', 'path' => '2:120'), + 'caption_writer' => array('name' => 'Caption Writer', 'path' => '2:122'), + 'headline' => array('name' => 'Headline', 'path' => '2:105'), + 'instructions' => array('name' => 'Special Instructions', 'path' => '2:40'), + 'keywords' => array('name' => 'Keywords', 'path' => '2:25'), + 'category' => array('name' => 'Category', 'path' => '2:15'), + 'supplemental_categorie' => array('name' => 'Supplemental Category', 'path' => '2:20'), + 'copyright' => array('name' => 'Copyright Notice', 'path' => '2:116'), + 'byline' => array('name' => 'By-Line (Author)', 'path' => '2:80'), + 'byline_title' => array('name' => 'By-Line Title', 'path' => '2:85'), // Not used in Photoshop 7 + 'credit' => array('name' => 'Credit', 'path' => '2:110'), + 'source' => array('name' => 'Source', 'path' => '2:115'), + 'edit_status' => array('name' => 'Edit Status', 'path' => '2:07'), + 'priority' => array('name' => 'Priority', 'path' => '2:10'), + 'object_cycle' => array('name' => 'Object Cycle', 'path' => '2:75'), + 'job_id' => array('name' => 'Fixture Identifier', 'path' => '2:22'), + 'program' => array('name' => 'Originating Program', 'path' => '2:65'), + 'object_name' => array('name' => 'Object Name (Title)', 'path' => '2:05'), + 'date_created' => array('name' => 'Date Created', 'path' => '2:55'), + 'date_released' => array('name' => 'Release Date', 'path' => '2:30'), + 'time_created' => array('name' => 'Time Created', 'path' => '2:60'), + 'time_released' => array('name' => 'Release Time', 'path' => '2:25'), + 'city' => array('name' => 'City', 'path' => '2:90'), + 'sublocation' => array('name' => 'Sub-Location', 'path' => '2:92'), + 'state' => array('name' => 'Province/State', 'path' => '2:95'), + 'country' => array('name' => 'Country Name', 'path' => '2:101'), + 'country_code' => array('name' => 'Country Code', 'path' => '2:100'), + 'trans_reference' => array('name' => 'Transmission Reference','path' => '2:103'), + ), + + 'xmp' => array( + 'i4xcore_country_code' => array('name' => 'Country Code', + 'pathkey' => 'i4xcore_country_code', + 'path' => 'Iptc4xmpCore:CountryCode'), + + 'i4xcore_addr_city' => array('name' => 'Creator Info City', + 'pathkey' => 'i4xcore_addr_city', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrCity'), + + 'i4xcore_addr_ctry' => array('name' => 'Creator Info Country', + 'pathkey' => 'i4xcore_addr_ctry', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrCtry'), + + 'i4xcore_addr_etra' => array('name' => 'Creator Extra Information', + 'pathkey' => 'i4xcore_addr_etra', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrExtadr'), + + 'i4xcore_zip_code' => array('name' => 'Creator Info Zip Code', + 'pathkey' => 'i4xcore_zip_code', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrPcode'), + + 'i4xcore_region_code' => array('name' => 'Creator Info Region', + 'pathkey' => 'i4xcore_region_code', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrRegion'), + + 'i4xcore_email_work' => array('name' => 'Creator Email Work', + 'pathkey' => 'i4xcore_email_work', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiEmailWork'), + + 'i4xcore_tel_work' => array('name' => 'Creator Telephone Work', + 'pathkey' => 'i4xcore_tel_work', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiTelWork'), + + 'i4xcore_url_work' => array('name' => 'Creator Website Work', + 'pathkey' => 'i4xcore_url_work', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiUrlWork'), + + 'i4xcore_intel_genre' => array('name' => 'Creator Intellectual Genre', + 'pathkey' => 'i4xcore_intel_genre', + 'path' => 'Iptc4xmpCore:IntellectualGenre'), + + 'i4xcore_location' => array('name' => 'Creator Location', + 'pathkey' => 'i4xcore_location', + 'path' => 'Iptc4xmpCore:Location'), + + 'i4xcore_scene' => array('name' => 'Creator Scene', + 'pathkey' => 'i4xcore_scene', + 'path' => 'Iptc4xmpCore:Scene'), + + 'i4xcore_subject_code' => array('name' => 'Subject Code', + 'pathkey' => 'i4xcore_subject_code', + 'path' => 'Iptc4xmpCore:SubjectCode'), + ) ); Modified: trunk/linpha2/lib/classes/pjmt/XMP.php =================================================================== --- trunk/linpha2/lib/classes/pjmt/XMP.php 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/lib/classes/pjmt/XMP.php 2007-02-13 16:30:32 UTC (rev 4675) @@ -233,8 +233,8 @@ function write_XMP_array_to_text( $xmparray ) { // Add the XMP packet header - // The sequence 0xEFBBBF is the UTF-8 encoded version of the Unicode \x93zero - // width non-breaking space character\x94 (U+FEFF), which is used for detecting + // The sequence 0xEFBBBF is the UTF-8 encoded version of the Unicode �zero + // width non-breaking space character� (U+FEFF), which is used for detecting // whether UTF-16 or UTF-8 is being used. $output_XMP_text = "<?xpacket begin='\xef\xbb\xbf' id='W5M0MpCehiHzreSzNTczkc9d'?>\n"; @@ -336,6 +336,10 @@ // Add heading to the HTML according to which Namespace the RDF items have switch ( substr( $key,6) ) { + //bzrudi + case "Iptc4xmpCore": + $output .= "<h3 class=\"XMP_Secondary_Heading\">Iptc4xmpCore Segment</h3>\n"; + break; case "photoshop": $output .= "<h3 class=\"XMP_Secondary_Heading\">Photoshop RDF Segment</h3>\n"; break; @@ -792,6 +796,21 @@ $GLOBALS[ 'XMP_tag_captions' ] = array ( +// added by bzrudi +"Iptc4xmpCore:CountryCode" => "Country Code", +"Iptc4xmpCore:CreatorContactInfoCiAdrCity" => "Creator Info City", +"Iptc4xmpCore:CreatorContactInfoCiAdrCtry" => "Creator Info Country", +"Iptc4xmpCore:CreatorContactInfoCiAdrExtadr" => "Creator Info Extra", +"Iptc4xmpCore:CreatorContactInfoCiAdrPcode" => "Creator Info Region Code", +"Iptc4xmpCore:CreatorContactInfoCiAdrRegion" => "Creator Info Region", +"Iptc4xmpCore:CreatorContactInfoCiEmailWork" => "Creator Email Work", +"Iptc4xmpCore:CreatorContactInfoCiTelWork" => "Creator Tel Work", +"Iptc4xmpCore:CreatorContactInfoCiUrlWork" => "Creator Web Work", +"Iptc4xmpCore:IntellectualGenre" => "Intellectual Genre", +"Iptc4xmpCore:Location" => "Location", +"Iptc4xmpCore:Scene" => "Scene", +"Iptc4xmpCore:SubjectCode" => "Subject Code", + "dc:contributor" => "Other Contributor(s)", "dc:coverage" => "Coverage (scope)", "dc:creator" => "Creator(s) (Authors)", Modified: trunk/linpha2/lib/include/File_Info_Show.php =================================================================== --- trunk/linpha2/lib/include/File_Info_Show.php 2007-02-11 10:33:47 UTC (rev 4674) +++ trunk/linpha2/lib/include/File_Info_Show.php 2007-02-13 16:30:32 UTC (rev 4675) @@ -241,7 +241,6 @@ <!-- Output the XMP Information --> <?php echo Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ) ); ?> - <BR> <HR> <BR> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-02-14 12:54:15
|
Revision: 4677 http://svn.sourceforge.net/linpha/?rev=4677&view=rev Author: bzrudi Date: 2007-02-14 04:54:11 -0800 (Wed, 14 Feb 2007) Log Message: ----------- Even more improvements to the XMP MeetaData stuff Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/metadata_select.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/templates/default/fragments.php trunk/linpha2/templates/default/view_img.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-02-13 16:39:25 UTC (rev 4676) +++ trunk/linpha2/ChangeLog 2007-02-14 12:54:11 UTC (rev 4677) @@ -1,3 +1,9 @@ +2007-02-14 bzrudi + * Even more improvements to the MeetaData stuff, basics should work now. Btw. + I will replace "medadata, meta data, Meta Data, Metadata..." by MetaData + to have things unique ;-) + TODO - enable XMP write and take good care of encodings... + 2007-02-13 bzrudi * Huge rework of the metadata stuff and in particular XMP. Do not expect to see something yet, I just prepared some things to work together later. Modified: trunk/linpha2/admin/metadata_select.php =================================================================== --- trunk/linpha2/admin/metadata_select.php 2007-02-13 16:39:25 UTC (rev 4676) +++ trunk/linpha2/admin/metadata_select.php 2007-02-14 12:54:11 UTC (rev 4677) @@ -72,7 +72,7 @@ } /** - * set exif/iptc fields + * set exif/iptc/xmp fields */ $MetaData = new LinMetaDataAdmin(); ?> @@ -80,7 +80,7 @@ <div align="center"> <table border="0"> <tr> - <td valign="top" rowspan="4" align="center"> + <td valign="top" rowspan="5" align="center"> Selected fields<br /> <select id="select_image_fields" name="select_image_fields[]" size="25" style="width: 200px;" multiple="multiple"> <?php @@ -105,7 +105,7 @@ </td> <td> Image fields (builtin)<br /> - <select id="image_fields" name="image_fields" size="7" style="width: 200px;"> + <select id="image_fields" name="image_fields" size="5" style="width: 200px;"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".LIN_PREFIX."meta_fields " . "WHERE flags = '1' OR flags = '5'"); @@ -123,7 +123,7 @@ </td> <td> Image fields (own) (<a href="./?cat=metadata_define_own">define</a>)<br /> - <select id="own_fields" name="own_fields" size="7" style="width: 200px;"> + <select id="own_fields" name="own_fields" size="5" style="width: 200px;"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".LIN_PREFIX."meta_fields " . "WHERE flags = '7'"); @@ -144,7 +144,7 @@ <input type="button" name="exif_shiftleft" value="<" onclick="copyElement('exif_fields')" /> </td> <td> - Exif fields (<a href="./?cat=metadata_define_exif">define</a>)<br /> + EXIF fields (<a href="./?cat=metadata_define_exif">define</a>)<br /> <?php if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) { $str_disabled = ''; @@ -152,7 +152,7 @@ $str_disabled = ' disabled="disabled"'; } ?> - <select id="exif_fields" name="exif_fields" size="7" style="width: 200px;"<?php echo $str_disabled; ?>> + <select id="exif_fields" name="exif_fields" size="5" style="width: 200px;"<?php echo $str_disabled; ?>> <?php $MetaData->setFields('exif'); foreach($MetaData->defined_fields['exif'] AS $key=>$value) @@ -176,7 +176,7 @@ $str_disabled = ' disabled="disabled"'; } ?> - <select id="iptc_fields" name="iptc_fields" size="7" style="width: 200px;"<?php echo $str_disabled; ?>> + <select id="iptc_fields" name="iptc_fields" size="5" style="width: 200px;"<?php echo $str_disabled; ?>> <?php $MetaData->setFields('iptc'); foreach($MetaData->defined_fields['iptc'] AS $key=>$value) @@ -187,6 +187,30 @@ </select> </td> </tr> + <tr> + <td> + <input type="button" name="xmp_shiftleft" value="<" onclick="copyElement('xmp_fields')" /> + </td> + <td> + XMP fields (<a href="./?cat=metadata_define_xmp">define</a>)<br /> + <?php + if($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { + $str_disabled = ''; + } else { + $str_disabled = ' disabled="disabled"'; + } + ?> + <select id="xmp_fields" name="xmp_fields" size="5" style="width: 200px;"<?php echo $str_disabled; ?>> + <?php + $MetaData->setFields('xmp'); + foreach($MetaData->defined_fields['xmp'] AS $key=>$value) + { + echo '<option value="xmp_'.$key.'">'.$value.'</option>'; + } + ?> + </select> + </td> + </tr> <?php } else @@ -225,16 +249,21 @@ obj.options[ obj.options.length ] = NewEntry; /** - * append ' (exif)' and ' (iptc)' + * append ' (EXIF)' and ' (IPTC)' */ if(coming_from=='exif_fields') { - obj.options[ obj.options.length-1 ].text = obj.options[ obj.options.length-1 ].text + ' (exif)'; + obj.options[ obj.options.length-1 ].text = obj.options[ obj.options.length-1 ].text + ' (EXIF)'; } if(coming_from=='iptc_fields') { - obj.options[ obj.options.length-1 ].text = obj.options[ obj.options.length-1 ].text + ' (iptc)'; + obj.options[ obj.options.length-1 ].text = obj.options[ obj.options.length-1 ].text + ' (IPTC)'; } + if(coming_from=='xmp_fields') + { + obj.options[ obj.options.length-1 ].text = obj.options[ obj.options.length-1 ].text + ' (XMP)'; + } + /** Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-13 16:39:25 UTC (rev 4676) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-14 12:54:11 UTC (rev 4677) @@ -183,7 +183,16 @@ } } break; - //TODO add XMP + case 'xmp': + if($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { + $xmp_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." " . + "FROM ".LIN_PREFIX."meta_xmp WHERE md5sum = '".$array_src_infos['md5sum']."'"); + + if(isset($xmp_data[$last_part])) { + $value = htmlspecialchars($xmp_data[$last_part],ENT_QUOTES); + } + } + break; } if($value != '') @@ -914,29 +923,30 @@ $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td></tr>'; } - /** - * set meta iptc - */ - if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) + /** + * set meta IPTC + */ + if($GLOBALS['linpha']->sql->config->value['sys_image_iptc'] || + $GLOBALS['linpha']->sql->config->value['sys_image_xmp'] ) { - if( isset($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) + if( isset($GLOBALS['linpha']->imgview->src_file) + && file_exists($GLOBALS['linpha']->imgview->src_file)) { if( is_writable($GLOBALS['linpha']->imgview->src_file)) { - $edit_possible = true; + $meta_edit_possible = true; $filename = $GLOBALS['linpha']->imgview->src_file; // used in IPTC Edit_File_Info.php } else { - $edit_possible = false; + $meta_edit_possible = false; } } else { - $edit_possible = false; + $meta_edit_possible = false; } } - /** * build the meta data view */ @@ -1345,55 +1355,107 @@ // Canon // overwrite Artist => 0/315 //'OwnerName' => 'Makernote_Tag/Decoded Data/0/9' - // Casio - // Fujifilm - // Konica/Minolta - // Nikon - // Olympus - // Panasonic - // Ricoh + 'jpegcomment' => array('name' => 'JPEG Comment', 'pathkey' => 'JpegComment', 'pathvalue' => ''), ), 'iptc' => array( - 'caption' => array('name' => 'Caption', 'path' => '2:120'), - 'caption_writer' => array('name' => 'Caption Writer', 'path' => '2:122'), - 'headline' => array('name' => 'Headline', 'path' => '2:105'), - 'instructions' => array('name' => 'Special Instructions', 'path' => '2:40'), - 'keywords' => array('name' => 'Keywords', 'path' => '2:25'), - 'category' => array('name' => 'Category', 'path' => '2:15'), - 'supplemental_categorie' => array('name' => 'Supplemental Category', 'path' => '2:20'), - 'copyright' => array('name' => 'Copyright Notice', 'path' => '2:116'), - 'byline' => array('name' => 'By-Line (Author)', 'path' => '2:80'), - 'byline_title' => array('name' => 'By-Line Title', 'path' => '2:85'), // Not used in Photoshop 7 - 'credit' => array('name' => 'Credit', 'path' => '2:110'), - 'source' => array('name' => 'Source', 'path' => '2:115'), - 'edit_status' => array('name' => 'Edit Status', 'path' => '2:07'), - 'priority' => array('name' => 'Priority', 'path' => '2:10'), - 'object_cycle' => array('name' => 'Object Cycle', 'path' => '2:75'), - 'job_id' => array('name' => 'Fixture Identifier', 'path' => '2:22'), - 'program' => array('name' => 'Originating Program', 'path' => '2:65'), - 'object_name' => array('name' => 'Object Name (Title)', 'path' => '2:05'), - 'date_created' => array('name' => 'Date Created', 'path' => '2:55'), - 'date_released' => array('name' => 'Release Date', 'path' => '2:30'), - 'time_created' => array('name' => 'Time Created', 'path' => '2:60'), - 'time_released' => array('name' => 'Release Time', 'path' => '2:25'), - 'city' => array('name' => 'City', 'path' => '2:90'), - 'sublocation' => array('name' => 'Sub-Location', 'path' => '2:92'), - 'state' => array('name' => 'Province/State', 'path' => '2:95'), - 'country' => array('name' => 'Country Name', 'path' => '2:101'), - 'country_code' => array('name' => 'Country Code', 'path' => '2:100'), - 'trans_reference' => array('name' => 'Transmission Reference','path' => '2:103'), + 'caption' => array('name' => 'Caption', + 'path' => '2:120'), + + 'caption_writer' => array('name' => 'Caption Writer', + 'path' => '2:122'), + + 'headline' => array('name' => 'Headline', + 'path' => '2:105'), + + 'instructions' => array('name' => 'Special Instructions', + 'path' => '2:40'), + + 'keywords' => array('name' => 'Keywords', + 'path' => '2:25'), + + 'category' => array('name' => 'Category', + 'path' => '2:15'), + + 'supplemental_categorie' => array('name' => 'Supplemental Category', + 'path' => '2:20'), + + 'copyright' => array('name' => 'Copyright Notice', + 'path' => '2:116'), + + 'byline' => array('name' => 'By-Line (Author)', + 'path' => '2:80'), + + 'byline_title' => array('name' => 'By-Line Title', + 'path' => '2:85'), // Not used in Photoshop 7 + + 'credit' => array('name' => 'Credit', + 'path' => '2:110'), + + 'source' => array('name' => 'Source', + 'path' => '2:115'), + + 'edit_status' => array('name' => 'Edit Status', + 'path' => '2:07'), + + 'priority' => array('name' => 'Priority', + 'path' => '2:10'), + + 'object_cycle' => array('name' => 'Object Cycle', + 'path' => '2:75'), + + 'job_id' => array('name' => 'Fixture Identifier', + 'path' => '2:22'), + + 'program' => array('name' => 'Originating Program', + 'path' => '2:65'), + + 'object_name' => array('name' => 'Object Name (Title)', + 'path' => '2:05'), + + 'date_created' => array('name' => 'Date Created', + 'path' => '2:55'), + + 'date_released' => array('name' => 'Release Date', + 'path' => '2:30'), + + 'time_created' => array('name' => 'Time Created', + 'path' => '2:60'), + + 'time_released' => array('name' => 'Release Time', + 'path' => '2:25'), + + 'city' => array('name' => 'City', + 'path' => '2:90'), + + 'sublocation' => array('name' => 'Sub-Location', + 'path' => '2:92'), + + 'state' => array('name' => 'Province/State', + 'path' => '2:95'), + + 'country' => array('name' => 'Country Name', + 'path' => '2:101'), + + 'country_code' => array('name' => 'Country Code', + 'path' => '2:100'), + + 'trans_reference' => array('name' => 'Transmission Reference', + 'path' => '2:103'), ), 'xmp' => array( + + // Iptc4xmpCore Segment + 'i4xcore_country_code' => array('name' => 'Country Code', 'pathkey' => 'i4xcore_country_code', 'path' => 'Iptc4xmpCore:CountryCode'), @@ -1446,12 +1508,135 @@ 'pathkey' => 'i4xcore_subject_code', 'path' => 'Iptc4xmpCore:SubjectCode'), + // Photoshop RDF Segment + + 'ps_authors_pos' => array('name' => 'Authors Position', + 'pathkey' => 'ps_authors_pos', + 'path' => 'photoshop:AuthorsPosition'), + + 'ps_cap_writer' => array('name' => 'Caption Writer', + 'pathkey' => 'ps_cap_writer', + 'path' => 'photoshop:CaptionWriter'), + + 'ps_category' => array('name' => 'Category', + 'pathkey' => 'ps_category', + 'path' => 'photoshop:Category'), + + 'ps_city' => array('name' => 'City', + 'pathkey' => 'ps_city', + 'path' => 'photoshop:City'), + + 'ps_country' => array('name' => 'Country', + 'pathkey' => 'ps_country', + 'path' => 'photoshop:Country'), + + 'ps_credit' => array('name' => 'Credit', + 'pathkey' => 'ps_credit', + 'path' => 'photoshop:Credit'), + + 'ps_date_create' => array('name' => 'Creation Date', + 'pathkey' => 'ps_date_create', + 'path' => 'photoshop:DateCreated'), + + 'ps_headline' => array('name' => 'Headline', + 'pathkey' => 'ps_headline', + 'path' => 'photoshop:Headline'), + + 'ps_history' => array('name' => 'History', + 'pathkey' => 'ps_history', + 'path' => 'photoshop:History'), + + 'ps_instructions' => array('name' => 'Instructions', + 'pathkey' => 'ps_instructions', + 'path' => 'photoshop:Instructions'), + + 'ps_source' => array('name' => 'Source', + 'pathkey' => 'ps_source', + 'path' => 'photoshop:Source'), + + 'ps_state' => array('name' => 'State', + 'pathkey' => 'ps_state', + 'path' => 'photoshop:State'), + + 'ps_supplemental_cat' => array('name' => 'Supplemental Categories', + 'pathkey' => 'ps_supplemental_cat', + 'path' => 'photoshop:SupplementalCategories'), + + 'ps_transmission_ref' => array('name' => 'Technical (Transmission) Reference', + 'pathkey' => 'ps_transmission_ref', + 'path' => 'photoshop:TransmissionReference'), + + 'ps_urgency' => array('name' => 'Urgency', + 'pathkey' => 'ps_urgency', + 'path' => 'photoshop:Urgency'), + + // Dublin Core Metadata Initiative RDF Segment + + 'dc_contributor' => array('name' => 'Other Contributor(s)', + 'pathkey' => 'dc_contributor', + 'path' => 'dc:contributor'), + + 'dc_coverage' => array('name' => 'Coverage (scope)', + 'pathkey' => 'dc_coverage', + 'path' => 'dc:coverage'), + + 'dc_creator' => array('name' => 'Creator(s) (Authors)', + 'pathkey' => 'dc_creator', + 'path' => 'dc:creator'), + + 'dc_date' => array('name' => 'Date', + 'pathkey' => 'dc_date', + 'path' => 'dc:date'), + + 'dc_description' => array('name' => 'Description (Caption)', + 'pathkey' => 'dc_description', + 'path' => 'dc:description'), + + 'dc_format' => array('name' => 'MIME Data Format', + 'pathkey' => 'dc_format', + 'path' => 'dc:format'), + + 'dc_identifier' => array('name' => 'Unique Resource Identifer', + 'pathkey' => 'dc_identifier', + 'path' => 'dc:identifier'), + + 'dc_language' => array('name' => 'Language(s)', + 'pathkey' => 'dc_language', + 'path' => 'dc:language'), + + 'dc_publisher' => array('name' => 'Publisher(s)', + 'pathkey' => 'dc_publisher', + 'path' => 'dc:publisher'), + + 'dc_relation' => array('name' => 'Relations to other documents', + 'pathkey' => 'dc_relation', + 'path' => 'dc:relation'), + + 'dc_rights' => array('name' => 'Rights Statement', + 'pathkey' => 'dc_rights', + 'path' => 'dc:rights'), + + 'dc_source' => array('name' => 'Source (from which this Resource is derived)', + 'pathkey' => 'dc_source', + 'path' => 'dc:source'), + + 'dc_subject' => array('name' => 'Subject and Keywords', + 'pathkey' => 'dc_subject', + 'path' => 'dc:subject'), + + 'dc_title' => array('name' => 'Title', + 'pathkey' => 'dc_title', + 'path' => 'dc:title'), + + 'dc_type' => array('name' => 'Resource Type', + 'pathkey' => 'dc_type', + 'path' => 'dc:type'), ) ); /** * define tags to index and set available fields - * @param string $what [exif,iptc] + * @param string $what [exif,iptc,xmp] */ function setFields($what) { @@ -1484,9 +1669,10 @@ } /** - * show nice name for exif, iptc, builtin and own fields, for example: convert "exif_datetimeoriginal" to "DateTime Original" + * show nice name for exif, iptc, xmp, builtin and own fields, + * for example: convert "exif_datetimeoriginal" to "DateTime Original" */ - function getNameOfField( $key , $show_exifiptc_in_brackets) + function getNameOfField( $key , $show_metadata_extra_info) { $pos = strpos($key,'_'); $first_part = substr($key,0,$pos); @@ -1520,16 +1706,22 @@ break; case 'exif': $value = LinMetaData::$Tags['exif'][$last_part]['name']; - if($show_exifiptc_in_brackets) { - $value .= ' (exif)'; + if($show_metadata_extra_info) { + $value .= ' (EXIF Resource)'; } break; case 'iptc': $value = LinMetaData::$Tags['iptc'][$last_part]['name']; - if($show_exifiptc_in_brackets) { - $value .= ' (iptc)'; + if($show_metadata_extra_info) { + $value .= ' (IPTC Resource)'; } break; + case 'xmp': + $value = LinMetaData::$Tags['xmp'][$last_part]['name']; + if($show_metadata_extra_info) { + $value .= ' (XMP Resource)'; + } + break; } return $value; Modified: trunk/linpha2/templates/default/fragments.php =================================================================== --- trunk/linpha2/templates/default/fragments.php 2007-02-13 16:39:25 UTC (rev 4676) +++ trunk/linpha2/templates/default/fragments.php 2007-02-14 12:54:11 UTC (rev 4677) @@ -181,7 +181,8 @@ <?php if($GLOBALS['linpha']->imgview->img_type!=0) { ?> <ul class="linUlMenu"> <li><a id="linAMetaLinpha" href="javascript:showMetaLinpha()">LinPHA MetaData</a></li> - <li><a id="linAMetaIptc" href="javascript:showMetaIptc()">XMP (IPTC)</a></li> + <li><a id="linAMetaIptc" href="javascript:showMetaIptc()">IPTC MetaData</a></li> + <li><a id="linAMetaXmp" href="javascript:showMetaXmp()">XMP MetaData</a></li> </ul> <?php } /* end if img_type!=0 */ ?> @@ -209,7 +210,7 @@ <div id="linDivMetaIptc"> <?php if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { echo '<br /><br />'; - if($edit_possible) { ?> + if($meta_edit_possible) { ?> <form action="<?php echo $linTpl->URL_full; ?>" method="POST"> <table border="0"> <?php @@ -230,7 +231,7 @@ <p>Powered by: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> <?php } else { - echo i18n("Error: This file is not writable. Please check the file permissions."); /* @todo use unified language string */ + echo i18n("Error: File not writable. Please check the file permissions."); /* @todo use unified language string */ } } else { echo i18n("IPTC Is Currently Disabled.").'<br /><br />'; @@ -239,6 +240,39 @@ echo '<br /><br />'; } } ?> + </div> + <div id="linDivMetaXmp"> + <?php if($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { + echo '<br /><br />'; + if($meta_edit_possible) { ?> + <form action="<?php echo $linTpl->URL_full; ?>" method="POST"> + <table border="0"> + <?php + include(LINPHA_DIR.'/lib/include/File_Info_Edit.php'); + ?> + <tr> + <td rowspan="2"> + <br /> + <input type="hidden" name="linCmd" value="linInsertMetaXmp" /> + <input type="submit" class="linButton" name="submit" value="<?php echo i18n("Submit"); ?>" /> + </td> + </tr> + </form> + </table> + <br> + <br> + <p>Powered by: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> + <?php + } else { + echo i18n("Error: File not writable. Please check the file permissions."); /* @todo use unified language string */ + } + } else { + echo i18n("XMP Is Currently Disabled.").'<br /><br />'; + if($GLOBALS['linpha']->sql->isAdmin()) { + echo '<a href="'.LINPHA_CLIENT.'/admin/?cat=metadata_define_xmp">'.i18n("Enable XMP").'</a>'; + echo '<br /><br />'; + } + } ?> </div> <?php } /* end if img_type!=0 */ ?> @@ -256,7 +290,6 @@ Element.hide('linDivMetaIptc'); Element.show('linDivMetaLinpha'); } - function showMetaIptc() { $('linAMetaLinpha').className = ''; @@ -264,6 +297,14 @@ Element.hide('linDivMetaLinpha'); Element.show('linDivMetaIptc'); } + function showMetaXmp() + { + $('linAMetaLinpha').className = ''; + $('linAMetaXmp').className = 'current'; + Element.hide('linDivMetaLinpha'); + Element.hide('linDivMetaIptc'); + Element.show('linDivMetaXmp'); + } showMetaLinpha(); --> </script> Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2007-02-13 16:39:25 UTC (rev 4676) +++ trunk/linpha2/templates/default/view_img.html.php 2007-02-14 12:54:11 UTC (rev 4677) @@ -42,7 +42,7 @@ <div id="linDivMetaOuter" style="display: none;"> <div id="linDivMeta"></div> - <div id="linDivExifLink" class="linDivMetaLinks"><a href="<?php echo LINPHA_LINK.'linCat=exif&linId='.$linTpl->idCurrent; ?>" onclick="javascript:myLinImage.updateLinId(this)" target="_blank"><?php echo i18n("Show All Exif/Iptc Information"); ?></a></div> + <div id="linDivExifLink" class="linDivMetaLinks"><a href="<?php echo LINPHA_LINK.'linCat=exif&linId='.$linTpl->idCurrent; ?>" onclick="javascript:myLinImage.updateLinId(this)" target="_blank"><?php echo i18n("Show All Metadata"); ?></a></div> <div id="linDivVideoLink" class="linDivMetaLinks"> <a href="<?php echo LINPHA_LINK.'linCat=video&linId='.$linTpl->idCurrent; ?>" onclick="javascript:myLinImage.updateLinId(this)" target="_blank"><?php echo i18n("Play Video"); ?></a> <br /><br /> @@ -51,7 +51,7 @@ </div> <div id="linDivInfoLink" style="display: none; color: grey;"> - <a id="linHrefPanoLink" href="<?php echo LINPHA_LINK.'linCat=panorama&linId='.$linTpl->idCurrent; ?>" onclick="javascript:myLinImage.updateLinId(this)" target="_blank" style="color: black;">Panorama</a> + <a id="linHrefPanoLink" href="<?php echo LINPHA_LINK.'linCat=panorama&linId='.$linTpl->idCurrent; ?>" onclick="javascript:myLinImage.updateLinId(this)" target="_blank" style="color: black;"><?php echo i18n("Panorama"); ?></a> <a id="linHrefInfoLink" href="javascript:myLinImage.showImgInfo()" style="color: black;">Info</a> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-02-14 14:43:38
|
Revision: 4678 http://svn.sourceforge.net/linpha/?rev=4678&view=rev Author: bzrudi Date: 2007-02-14 06:43:32 -0800 (Wed, 14 Feb 2007) Log Message: ----------- unique MetaData String Modified Paths: -------------- trunk/linpha2/admin/index.php trunk/linpha2/admin/maintenance_db.php trunk/linpha2/admin/metadata_select.php trunk/linpha2/admin/permissions.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php Modified: trunk/linpha2/admin/index.php =================================================================== --- trunk/linpha2/admin/index.php 2007-02-14 12:54:11 UTC (rev 4677) +++ trunk/linpha2/admin/index.php 2007-02-14 14:43:32 UTC (rev 4678) @@ -70,7 +70,7 @@ 'settings' => Array('name' => 'Settings', 'link' => 'settings'), 'permissions' => Array('name' => 'Permissions', 'link' => 'permissions'), 'maintenance' => Array('name' => 'Maintenance', 'link' => 'maintenance'), - 'metadata' => Array('name' => 'Meta Data', 'link' => 'metadata'), + 'metadata' => Array('name' => 'MetaData', 'link' => 'metadata'), ); LinAdmin::printAdminMenu($array_menu,$cat1); Modified: trunk/linpha2/admin/maintenance_db.php =================================================================== --- trunk/linpha2/admin/maintenance_db.php 2007-02-14 12:54:11 UTC (rev 4677) +++ trunk/linpha2/admin/maintenance_db.php 2007-02-14 14:43:32 UTC (rev 4678) @@ -203,7 +203,7 @@ /** * check comment/exif/iptc/xmp to photo association */ - echo '<br /><h2>'.i18n("Checking meta data").'</h2>'; + echo '<br /><h2>'.i18n("Checking MetaData").'</h2>'; $array_meta = array('comments','data','exif','iptc'/*,'xmp'*/); foreach($array_meta AS $value) { Modified: trunk/linpha2/admin/metadata_select.php =================================================================== --- trunk/linpha2/admin/metadata_select.php 2007-02-14 12:54:11 UTC (rev 4677) +++ trunk/linpha2/admin/metadata_select.php 2007-02-14 14:43:32 UTC (rev 4678) @@ -3,7 +3,7 @@ /** * @package admin - * @subpackage metadata + * @subpackage MetaData * * for a description of the table structure, flag nr etc. see in the developper wiki at * http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields Modified: trunk/linpha2/admin/permissions.php =================================================================== --- trunk/linpha2/admin/permissions.php 2007-02-14 12:54:11 UTC (rev 4677) +++ trunk/linpha2/admin/permissions.php 2007-02-14 14:43:32 UTC (rev 4678) @@ -13,7 +13,7 @@ 'view' => Array('name' => 'View', 'link' => 'permissions_view'), 'write' => Array('name' => 'Write', 'link' => 'permissions_write'), 'basket' => Array('name' => 'Basket', 'link' => 'permissions_basket'), - 'metadata' => Array('name' => 'Meta Data', 'link' => 'permissions_metadata'), + 'metadata' => Array('name' => 'MetaData', 'link' => 'permissions_metadata'), 'others' => Array('name' => 'Others', 'link' => 'permissions_others'), ); Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2007-02-14 12:54:11 UTC (rev 4677) +++ trunk/linpha2/install/sql/sql.data.php 2007-02-14 14:43:32 UTC (rev 4678) @@ -181,7 +181,7 @@ "VALUES ('download', '')"; /** - * metadata + * MetaData * see http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields for the definition */ /** Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-02-14 12:54:11 UTC (rev 4677) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-02-14 14:43:32 UTC (rev 4678) @@ -1146,7 +1146,7 @@ } /** - * save modified meta data + * save modified MetaData */ LinMetaDataModificate::saveModifiedMetaData(); } @@ -1426,7 +1426,7 @@ } /** - * setup meta data view + * setup MetaData view */ function viewMeta() { @@ -1436,7 +1436,7 @@ $this->src_file = LinSql::getFullImagePath( $GLOBALS['linpha']->template->idCurrent ); /** - * save modified meta data + * save modified MetaData */ LinMetaDataModificate::saveModifiedMetaData(); Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2007-02-14 12:54:11 UTC (rev 4677) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2007-02-14 14:43:32 UTC (rev 4678) @@ -256,7 +256,7 @@ LinImage::deleteCachedImage($photo_id,$data['img_type']); /** - * delete metadata (exif,iptc,xmp) + * delete MetaData (EXIF,IPTC,XMP) */ $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."meta_exif WHERE md5sum = '".$data['md5sum']."'"); $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."meta_iptc WHERE md5sum = '".$data['md5sum']."'"); @@ -468,7 +468,7 @@ * exif date and exif rotate stuff * globally turn off using 'sys_import_exif' if having problems with pjmt * - * @todo index all exif tags if we already have read the meta data! + * @todo index all exif tags if we already have read the MetaData! * but should we also read iptc at this point? */ if( $GLOBALS['linpha']->sql->config->value['sys_import_exif'] ) Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-14 12:54:11 UTC (rev 4677) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-14 14:43:32 UTC (rev 4678) @@ -833,7 +833,7 @@ /** - * Modificate metadata and save the information back to the file (iptc and xmp) + * Modificate MetaData and save the information back to the file (IPTC and XMP) */ class LinMetaDataModificate extends LinMetaData { @@ -1054,7 +1054,7 @@ } /** - * save iptc metadata back to file + * save IPTC MetaData back to file * * copied from pjmt/Write_File_Info.php */ @@ -1181,7 +1181,7 @@ echo "<p><a href=\"Example.php?jpeg_fname=$filename\" >View Full Metatdata Information</a></p>\n"; echo "<p><a href=\"Edit_File_Info_Example.php?jpeg_fname=$filename\" >Re-Edit Photoshop File Info</a></p>\n"; echo "<br><br>\n"; - echo "<p>Below is the updated image, you can save it and look at the changed metadata in your favorite image editor</p>\n"; + echo "<p>Below is the updated image, you can save it and look at the changed MetaData in your favorite image editor</p>\n"; echo "<p><img src=\"$filename\" ></p>\n";*/ return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-02-15 11:18:26
|
Revision: 4679 http://svn.sourceforge.net/linpha/?rev=4679&view=rev Author: bzrudi Date: 2007-02-15 03:18:24 -0800 (Thu, 15 Feb 2007) Log Message: ----------- code cleanups and some minor fixes to the MetaData stuff Modified Paths: -------------- trunk/linpha2/admin/metadata.php trunk/linpha2/admin/metadata_define.php trunk/linpha2/admin/metadata_define_post.php trunk/linpha2/admin/metadata_select.php trunk/linpha2/index.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/templates/default/fragments.php Added Paths: ----------- trunk/linpha2/lib/include/metadata_info_edit.php trunk/linpha2/lib/include/metadata_info_show.php Removed Paths: ------------- trunk/linpha2/lib/include/File_Info_Edit.php trunk/linpha2/lib/include/File_Info_Show.php Modified: trunk/linpha2/admin/metadata.php =================================================================== --- trunk/linpha2/admin/metadata.php 2007-02-14 14:43:32 UTC (rev 4678) +++ trunk/linpha2/admin/metadata.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -1,4 +1,31 @@ <?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. +*/ + +/** + * @package admin + * @subpackage MetaData + * + * For a description of the table structure, flags, etc. consult the developper + * wiki at http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields + */ + if(!defined('LINPHA_DIR')) { exit(1); } if(!isset($cat2)) Modified: trunk/linpha2/admin/metadata_define.php =================================================================== --- trunk/linpha2/admin/metadata_define.php 2007-02-14 14:43:32 UTC (rev 4678) +++ trunk/linpha2/admin/metadata_define.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -1,4 +1,31 @@ <?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. +*/ + +/** + * @package admin + * @subpackage MetaData + * + * For a description of the table structure, flags, etc. consult the developper + * wiki at http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields + */ + if(!defined('LINPHA_DIR')) { exit(1); } /** Modified: trunk/linpha2/admin/metadata_define_post.php =================================================================== --- trunk/linpha2/admin/metadata_define_post.php 2007-02-14 14:43:32 UTC (rev 4678) +++ trunk/linpha2/admin/metadata_define_post.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -1,4 +1,31 @@ <?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. +*/ + +/** + * @package admin + * @subpackage MetaData + * + * For a description of the table structure, flags, etc. consult the developper + * wiki at http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields + */ + if(!defined('LINPHA_DIR')) { exit(1); } switch($_POST['cmd']) Modified: trunk/linpha2/admin/metadata_select.php =================================================================== --- trunk/linpha2/admin/metadata_select.php 2007-02-14 14:43:32 UTC (rev 4678) +++ trunk/linpha2/admin/metadata_select.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -1,13 +1,32 @@ <?php -if(!defined('LINPHA_DIR')) { exit(1); } +/* +* 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. +*/ /** * @package admin * @subpackage MetaData * - * for a description of the table structure, flag nr etc. see in the developper wiki at - * http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields + * For a description of the table structure, flags, etc. consult the developper + * wiki at http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields */ + +if(!defined('LINPHA_DIR')) { exit(1); } if(!isset($cat3)) { Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2007-02-14 14:43:32 UTC (rev 4678) +++ trunk/linpha2/index.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -56,7 +56,7 @@ require_once(LINPHA_DIR.'/lib/modules/module.newimg.php'); break; case 'exif': - require_once(LINPHA_DIR.'/lib/include/File_Info_Show.php'); + require_once(LINPHA_DIR.'/lib/include/metadata_info_show.php'); break; case 'video': require_once(LINPHA_DIR.'/lib/modules/module.video.php'); Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-14 14:43:32 UTC (rev 4678) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -19,8 +19,8 @@ */ /** - * This class handles all the EXIF and IPTC stuff used in LinPHA - * @package Metadata + * This class handles all the EXIF/IPTC/XMP stuff used in LinPHA + * @package MetaData * @author flo, bzrudi */ @@ -1060,12 +1060,6 @@ */ function saveModifiedMetaDataIptc( & $new_ps_file_info_array, $filename ) { - /** // Turn off Error Reporting - error_reporting ( 0 ); // Change: changed to no reporting - as of version 1.11 - - include 'Toolkit_Version.php'; // Change: added as of version 1.11*/ - - // Include the required files for reading and writing Photoshop File Info include_once(LINPHA_DIR.'/lib/classes/pjmt/JPEG.php'); include_once(LINPHA_DIR.'/lib/classes/pjmt/XMP.php'); include_once(LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php'); @@ -1074,48 +1068,19 @@ $GLOBALS[ "Software Name" ] = "LinPHA v".LINPHA_VERSION.", powered by PHP JPEG Metadata Toolkit v" . $GLOBALS['Toolkit_Version'] ; - // Copy all of the HTML Posted variables into an array - /** - * $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS']; - */ - - // Some characters are escaped with backslashes in HTML Posted variable - // Cycle through each of the HTML Posted variables, and strip out the slashes - /** - * already done in /include/common.php !! - * foreach( $new_ps_file_info_array as $var_key => $var_val ) - { - $new_ps_file_info_array[ $var_key ] = stripslashes( $var_val ); - }*/ - // Keywords should be an array - explode it on newline boundarys $new_ps_file_info_array[ 'keywords' ] = explode( "\n", trim( $new_ps_file_info_array[ 'keywords' ] ) ); // Supplemental Categories should be an array - explode it on newline boundarys $new_ps_file_info_array[ 'supplementalcategories' ] = explode( "\n", trim( $new_ps_file_info_array[ 'supplementalcategories' ] ) ); - /** - // Make the filename easier to access - $filename = $new_ps_file_info_array[ 'filename' ]; - - // Protect against hackers editing other files - $path_parts = pathinfo( $filename ); - if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) - { - echo "Incorrect File Type - JPEG Only\n"; - exit( ); - } - // Change: removed limitation on file being in current directory - as of version 1.11 - * - */ - // Retrieve the header information $jpeg_header_data = get_jpeg_header_data( $filename ); // Retreive the EXIF, XMP and Photoshop IRB information from // the existing file, so that it can be updated - $Exif_array = get_EXIF_JPEG( $filename ); - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); + //$Exif_array = get_EXIF_JPEG( $filename ); + //$XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); // Update the JPEG header information with the new Photoshop File Info @@ -1124,65 +1089,31 @@ // Check if the Update worked if ( $jpeg_header_data == FALSE ) { - // Update of file info didn't work - output error message /** * echo "Error - Failure update Photoshop File Info : $filename <br>\n"; */ linSysLog( i18n("Error: Failure update Photoshop File Info:" .' '. $filename) ); linLog( LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Failure update Photoshop File Info:" .' '. $filename ); - // Output HTML with the form and data which was - // sent, to allow the user to fix it - - /**$outputfilename = $filename; - include "Edit_File_info.php"; - echo "</body>\n"; - echo "</html>\n"; - - // Abort processing - exit( );*/ - return false; } // Attempt to write the new JPEG file elseif ( FALSE == put_jpeg_header_data( $filename, $filename, $jpeg_header_data ) ) { - // Writing of the new file didn't work - output error message /** * echo "Error - Failure to write new JPEG : $filename <br>\n"; */ linSysLog( i18n("Error: Failure to write new JPEG:" .' '. $filename) ); linLog( LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Failure to write new JPEG:" .' '. $filename ); - - // Output HTML with the form and data which was - // sent, to allow the user to fix it - - /**$outputfilename = $filename; - include "Edit_File_info.php"; - echo "</body>\n"; - echo "</html>\n"; - - // Abort processing - exit( );*/ - + return false; } else { // Writing of new JPEG succeeded - - // Output information about new file - linSysLog( i18n("DONE! Updated:" .' '. $filename) ); linLog( LOG_TYPE_META, LOG_NOTICE, 'meta_iptc', "Updated:" .' '. $filename ); - /** - echo "<h1>DONE! - $filename updated</h1>\n"; - echo "<p><a href=\"Example.php?jpeg_fname=$filename\" >View Full Metatdata Information</a></p>\n"; - echo "<p><a href=\"Edit_File_Info_Example.php?jpeg_fname=$filename\" >Re-Edit Photoshop File Info</a></p>\n"; - echo "<br><br>\n"; - echo "<p>Below is the updated image, you can save it and look at the changed MetaData in your favorite image editor</p>\n"; - echo "<p><img src=\"$filename\" ></p>\n";*/ return true; } Deleted: trunk/linpha2/lib/include/File_Info_Edit.php =================================================================== --- trunk/linpha2/lib/include/File_Info_Edit.php 2007-02-14 14:43:32 UTC (rev 4678) +++ trunk/linpha2/lib/include/File_Info_Edit.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -1,590 +0,0 @@ -<?php -if(!defined('LINPHA_DIR')) { exit(1); } - -/**************************************************************************** -* -* Filename: Edit_File_Info.php -* -* Description: Allows the user to edit the metadata of an image over the internet -* in the same way that Photoshop edits 'File Info' data -* This file provides only the html for a form containing the file info -* input fields. The rest of the html file must be provided by the calling script. -* $outputfilename must always be defined - it is ne name of the file which -* have the metadata changed after the form has been submitted -* -* This file has several modes of operation: -* -* 1) If $new_ps_file_info_array is defined then it's data will be used -* to fill the fields. -* 2) If $new_ps_file_info_array is not defined but $filename is defined, -* then the file info fields will be filled from the metadata in the file specified -* 3) If $new_ps_file_info_array is not defined but $filename and $default_ps_file_info_array -* are defined, then the file info fields will be filled from the metadata -* in the file specified, but where fields are blank, they will be filled from $default_ps_file_info_array -* 4) Otherwise the fields will be blank -* -* See Edit_File_Info_Example.php for an example of usage -* -* Author: Evan Hunter -* -* Date: 17/11/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.11 -* -* Changes: 1.10 -> 1.11 : Changed displayed toolkit version numbers to reference Toolkit_Version.php -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit 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. -* -* The PHP JPEG Metadata Toolkit 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 the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************/ - -/** - * if $default_ps_file_info_array is set and the key 'date' is empty - * it will be auto filled with the exif date and we prevent errors like - * "Invalid Date - must be YYYY-MM-DD format" - */ -$default_ps_file_info_array = array ( - 'title' => "", - 'author' => "", - 'authorsposition' => "", - 'caption' => "", - 'captionwriter' => "", - 'jobname' => "", - 'copyrightstatus' => "", - 'copyrightnotice' => "", - 'ownerurl' => "", - 'keywords' => array(), - 'category' => "", - 'supplementalcategories'=> array(), - 'date' => "", - 'city' => "", - 'state' => "", - 'country' => "", - 'credit' => "", - 'source' => "", - 'headline' => "", - 'instructions' => "", - 'transmissionreference' => "", - 'urgency' => "" - ); - - include LINPHA_DIR.'/lib/classes/pjmt/Toolkit_Version.php'; // Change: added as of version 1.11 - global $new_ps_file_info_array; - - // Check for operation modes 2 or 3 - // i.e. $filename is defined, and $new_ps_file_info_array is not - if ( ( ! isset( $new_ps_file_info_array ) ) && - ( isset( $filename ) ) && - ( is_string( $filename ) ) ) - { - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - - // Accessing the existing file info for the specified file requires these includes - include_once( LINPHA_DIR.'/lib/classes/pjmt/JPEG.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/XMP.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php' ); - - // Retrieve the header information from the JPEG file - $jpeg_header_data = get_jpeg_header_data( $filename ); - - // Retrieve EXIF information from the JPEG file - $Exif_array = get_EXIF_JPEG( $filename ); - - // Retrieve XMP information from the JPEG file - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); - - // Retrieve Photoshop IRB information from the JPEG file - $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); - - // Retrieve Photoshop File Info from the three previous arrays - $new_ps_file_info_array = get_photoshop_file_info( $Exif_array, $XMP_array, $IRB_array ); - - - - // Check if there is an array of defaults available - if ( ( isset( $default_ps_file_info_array) ) && - ( is_array( $default_ps_file_info_array) ) ) - { - // There are defaults defined - - // Check if there is a default for the date defined - if ( ( ! array_key_exists( 'date', $default_ps_file_info_array ) ) || - ( ( array_key_exists( 'date', $default_ps_file_info_array ) ) && - ( $default_ps_file_info_array['date'] == '' ) ) ) - { - // No default for the date defined - // figure out a default from the file - - // Check if there is a EXIF Tag 36867 "Date and Time of Original" - if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 34665, $Exif_array[0] ) ) && - ( array_key_exists( 0, $Exif_array[0][34665] ) ) && - ( array_key_exists( 36867, $Exif_array[0][34665][0] ) ) ) - { - // Tag "Date and Time of Original" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36867]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - // Check if there is a EXIF Tag 36868 "Date and Time when Digitized" - else if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 34665, $Exif_array[0] ) ) && - ( array_key_exists( 0, $Exif_array[0][34665] ) ) && - ( array_key_exists( 36868, $Exif_array[0][34665][0] ) ) ) - { - // Tag "Date and Time when Digitized" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36868]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - // Check if there is a EXIF Tag 306 "Date and Time" - else if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 306, $Exif_array[0] ) ) ) - { - // Tag "Date and Time" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][306]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - else - { - // Couldn't find an EXIF date in the image - // Set default date as creation date of file - $default_ps_file_info_array['date'] = date ("Y-m-d", filectime( $filename )); - } - } - - // Cycle through all the elements of the default values array - foreach( $default_ps_file_info_array as $def_key =>$default_item ) - { - // Check if the current element is Keywords or - // Supplemental Categories as these are arrays - // and need to be treated differently - if ( ( strcasecmp( $def_key, "keywords" ) == 0 ) || - ( strcasecmp( $def_key, "supplementalcategories" ) == 0 ) ) - { - // Keywords or Supplemental Categories found - // Check if the File Info from the file is empty for this element - // and if there are default values in this array element - if ( ( count( $new_ps_file_info_array[ $def_key ] ) == 0 ) && - ( is_array( $default_item ) ) && - ( count( $default_item ) >= 0 ) ) - { - // The existing file info is empty, and there are - // defaults - add them - $new_ps_file_info_array[ $def_key ] = $default_item; - } - } - // Otherwise, this is not an array element, just check if it is blank in the existing file info - else if ( trim( $new_ps_file_info_array[ $def_key ] ) == "" ) - { - // The existing file info is blank, add the default value - $new_ps_file_info_array[ $def_key ] = $default_item; - } - - } - } - } - // Check for operation mode 4 - $new_ps_file_info_array and $filename are not defined, - else if ( ( ( !isset($new_ps_file_info_array) ) || ( ! is_array($new_ps_file_info_array) ) ) && - ( ( !isset($filename) ) || ( ! is_string( $filename ) ) ) ) - { - // No filename or new_ps_file_info_array defined, create a blank file info array to display - $new_ps_file_info_array = array( - "title" => "", - "author" => "", - "authorsposition" => "", - "caption" => "", - "captionwriter" => "", - "jobname" => "", - "copyrightstatus" => "", - "copyrightnotice" => "", - "ownerurl" => "", - "keywords" => array(), - "category" => "", - "supplementalcategories" => array(), - "date" => "", - "city" => "", - "state" => "", - "country" => "", - "credit" => "", - "source" => "", - "headline" => "", - "instructions" => "", - "transmissionreference" => "", - "urgency" => "" ); - } - - -/*************************************************************************** -* -* Now output the actual HTML form -* -***************************************************************************/ -/** -?> - - - - - <form name="EditJPEG" action="Write_File_Info.php" method="post"> - - - echo "<input name=\"filename\" type=\"hidden\" value=\"$outputfilename\">"; - - <table> -*/ -?> - <tr> - <td> - Title - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"title\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'title' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - <tr> - <td> - Author - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"author\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'author' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - <tr> - <td> - Authors Position - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"authorsposition\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'authorsposition' ], ENT_QUOTES) ."\"> - Note: not used in Photoshop 7 or higher"; - ?> - </td> - </tr> - - <tr> - <td> - Description - </td> - <td> - <textarea name="caption" class="linForms" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'caption' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - <tr> - <td> - Description Writer - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"captionwriter\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'captionwriter' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Keywords - </td> - <td> - <textarea class="linForms" name="keywords" rows=3 cols=37 wrap="off"><?php - foreach( $new_ps_file_info_array[ 'keywords' ] as $keyword ) - { - echo htmlspecialchars($keyword, ENT_QUOTES)."
"; - } - ?></textarea> - </td> - </tr> - - - <tr> - <td> - Copyright Status - </td> - <td> - <select size=1 class="linForms" name="copyrightstatus"> - <?php - $copystatus = $new_ps_file_info_array[ 'copyrightstatus' ]; - if ( $copystatus == "Unknown" ) - { - echo "<option value=\"Unknown\" SELECTED >Unknown</option>\n"; - } - else - { - echo "<option value=\"Unknown\">Unknown</option>\n"; - } - - if ( $copystatus == "Copyrighted Work" ) - { - echo "<option value=\"Copyrighted Work\" SELECTED >Copyrighted Work</option>\n"; - } - else - { - echo "<option value=\"Copyrighted Work\">Copyrighted Work</option>\n"; - } - - if ( $copystatus == "Public Domain" ) - { - echo "<option value=\"Public Domain\" SELECTED >Public Domain</option>\n"; - } - else - { - echo "<option value=\"Public Domain\">Public Domain</option>\n"; - } - ?> - </select> - </td> - </tr> - - - <tr> - <td> - Copyright Notice - </td> - <td> - <textarea class="linForms" name="copyrightnotice" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'copyrightnotice' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - <tr> - <td> - Copyright Info URL - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"ownerurl\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) ."\">\n"; - if ($new_ps_file_info_array[ 'ownerurl' ] != "" ) - { - echo "<a href=\"". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) ."\" > (". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) .")</a>\n"; - } - ?> - - </td> - </tr> - - - <tr> - <td> - Category - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"category\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'category' ], ENT_QUOTES) ."\">\n"; - ?> - - </td> - </tr> - - <tr> - <td> - Supplemental Categories - </td> - <td> - <textarea class="linForms" name="supplementalcategories" rows=3 cols=37 wrap="off"><?php - foreach( $new_ps_file_info_array[ 'supplementalcategories' ] as $supcat ) - { - echo htmlspecialchars($supcat, ENT_QUOTES)."
"; - } - ?></textarea> - </td> - </tr> - - - - <tr> - <td> - Date Created - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"date\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'date' ], ENT_QUOTES) ."\">"; - ?> - - Note date must be YYYY-MM-DD format - </td> - </tr> - - <tr> - <td> - City - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"city\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'city' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - State - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"state\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'state' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Country - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"country\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'country' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - - <tr> - <td> - Credit - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"credit\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'credit' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Source - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"source\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'source' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - - <tr> - <td> - Headline - </td> - <td> - <textarea class="linForms" name="headline" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'headline' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - - <tr> - <td> - Instructions - </td> - <td> - <textarea class="linForms" name="instructions" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'instructions' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - <tr> - <td> - Transmission Reference - </td> - <td> - <textarea class="linForms" name="transmissionreference" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'transmissionreference' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - <tr> - <td> - Job Name - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"jobname\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'jobname' ], ENT_QUOTES) ."\"> - Note: not used in Photoshop CS"; - ?> - </td> - </tr> - - <tr> - <td> - Urgency - </td> - <td> - <select size="1" class="linForms" name="urgency"> - <?php - for( $i = 1; $i <= 8; $i++ ) - { - echo "<option value=\"$i\""; - if ( $new_ps_file_info_array[ 'urgency' ] == $i ) - { - echo " SELECTED "; - } - echo ">"; - if ( $i == 1 ) - { - echo "High"; - } - else if ( $i == 5 ) - { - echo "Normal"; - } - else if ( $i == 8 ) - { - echo "Low"; - } - else - { - echo "$i"; - } - echo "</option>\n"; - } - if ( $new_ps_file_info_array[ 'urgency' ] == "none" ) - { - echo "<option value=\"none\" SELECTED >None</option>"; - } - else - { - echo "<option value=\"none\" >None</option>"; - } - ?> - - </select> - </td> - </tr> Deleted: trunk/linpha2/lib/include/File_Info_Show.php =================================================================== --- trunk/linpha2/lib/include/File_Info_Show.php 2007-02-14 14:43:32 UTC (rev 4678) +++ trunk/linpha2/lib/include/File_Info_Show.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -1,280 +0,0 @@ -<?php -if(!defined('LINPHA_DIR')) { exit(1); } - -/** - * check permissions - */ -if( !LinSql::photoIsAllowed( $GLOBALS['linpha']->template->idCurrent, $sql_perm_type = 'read' ) ) -{ - /** - * @todo use unified i18n STR_ACCESS_DENIED - */ - echo i18n("Access Denied!"); - exit(); -} - -/** - * valid id? - */ -$data = $GLOBALS['linpha']->db->GetRow( - "SELECT id, img_type FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($GLOBALS['linpha']->template->idCurrent)."'" -); - -if( ! isset($data['id']) ) -{ - /** - * @todo use unified i18n STR_ACCESS_DENIED - */ - echo i18n("Access Denied!"); - exit(); -} - -/** - * only images - */ -if( ! LinIdentify::isSupportedImage($data['img_type'])) -{ - echo i18n("This Is Not An Image!"); - exit; -} - -$filename = LinSql::getFullImagePath( $GLOBALS['linpha']->template->idCurrent ); -$filenameShow = implode( '/', LinSql::getFullFilenameFromId( $GLOBALS['linpha']->template->idCurrent ) ); - -?> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - -<!--*************************************************************************** -* -* Filename: Example.php -* -* Description: An example of how the PHP JPEG Metadata Toolkit can be used to -* display JPEG Metadata. -* -* Author: Evan Hunter -* -* Date: 30/7/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.11 -* -* Changes: 1.00 -> 1.10 : Changed name of GET parameter from 'filename' to 'jpeg_fname' -* to stop script-kiddies using the google command 'allinurl:*.php?filename=*' -* to find servers to attack -* Changed behavior when no filename is given, to be cleaner -* 1.10 -> 1.11 : Changed displayed toolkit version numbers to reference Toolkit_Version.php -* Changed this example file to be easily relocatable -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit 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. -* -* The PHP JPEG Metadata Toolkit 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 the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************--> - - <head> - - <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> - <STYLE TYPE="text/css" MEDIA="screen, print, projection"> - <!-- - - BODY { background-color:#505050; color:#F0F0F0 } - a { color:orange } - .EXIF_Main_Heading { color:red } - .EXIF_Secondary_Heading{ color: orange} - .EXIF_Table { border-collapse: collapse ; border: 1px solid #909000} - .EXIF_Table tbody td{border-width: 1px; border-style:solid; border-color: #909000;} - - --> - </STYLE> - - - <?php - // Turn off Error Reporting - error_reporting ( 0 ); - - // Change: Allow this example file to be easily relocatable - as of version 1.11 - /**$Toolkit_Dir = "./"; // Ensure dir name includes trailing slash*/ - - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - - /**include $Toolkit_Dir . 'Toolkit_Version.php'; // Change: added as of version 1.11 - include $Toolkit_Dir . 'JPEG.php'; // Change: Allow this example file to be easily relocatable - as of version 1.11 - include $Toolkit_Dir . 'JFIF.php'; - include $Toolkit_Dir . 'PictureInfo.php'; - include $Toolkit_Dir . 'XMP.php'; - include $Toolkit_Dir . 'Photoshop_IRB.php'; - include $Toolkit_Dir . 'EXIF.php';*/ - - include_once(LINPHA_DIR.'/lib/classes/pjmt/Toolkit_Version.php'); // Change: added as of version 1.11 - include_once(LINPHA_DIR.'/lib/classes/pjmt/JPEG.php'); // Change: Allow this example file to be easily relocatable - as of version 1.11 - include_once(LINPHA_DIR.'/lib/classes/pjmt/JFIF.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/PictureInfo.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/XMP.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/EXIF.php'); - - /** - // Retrieve the JPEG image filename from the http url request - if ( ( !array_key_exists( 'jpeg_fname', $GLOBALS['HTTP_GET_VARS'] ) ) || - ( $GLOBALS['HTTP_GET_VARS']['jpeg_fname'] == "" ) ) - { - echo "<title>No image filename defined</title>\n"; - echo "</head>\n"; - echo "<body>\n"; - echo "<p>No image filename defined - use GET method with field: jpeg_fname</p>\n"; - echo "<p><a href=\"http://www.ozhiker.com/electronics/pjmt/\" >PHP JPEG Metadata Toolkit version " . $GLOBALS['Toolkit_Version'] . ", Copyright (C) 2004 Evan Hunter</a></p>\n"; // Change: displayed toolkit version numbers to reference Toolkit_Version.php - as of version 1.11 - echo "</body>\n"; - exit( ); - } - else - { - $filename = $GLOBALS['HTTP_GET_VARS']['jpeg_fname']; - }*/ - - - // Output the title - echo "<title>Metadata details for $filenameShow</title>"; - - // Retrieve the header information - $jpeg_header_data = get_jpeg_header_data( $filename ); - - ?> - - </head> - - <body> - - <p>Interpreted using: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> <!-- Change: displayed toolkit version numbers to reference Toolkit_Version.php - as of version 1.11 --> - <br> - <br> - - <h1><B><U>Metadata for "<?php echo $filenameShow; ?>"</U></B></h1> - <br> - - <?php - /** - <!-- Output a link allowing user to edit the Photoshop File Info - Change: Allow this example file to be easily relocatable - as of version 1.11 - --> - <?php $relative_filename = get_relative_path( $filename, $Toolkit_Dir ); ?> - <h4><a href="<?php echo $Toolkit_Dir."Edit_File_Info_Example.php?jpeg_fname=$relative_filename"; ?>" >Click here to edit the Photoshop File Info for this file</a></h4> - <br> - */ - ?> - - - - <!-- Output the information about the APP segments --> - <?php echo Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the Intrinsic JPEG Information --> - <?php echo Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the JPEG Comment --> - <?php echo Interpret_Comment_to_HTML( $jpeg_header_data ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the JPEG File Interchange Format Information --> - <?php echo Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the JFIF Extension Information --> - <?php echo Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the Picture Info Text --> - <?php echo Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the EXIF Information --> - <?php echo Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the XMP Information --> - <?php echo Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ) ); ?> - <BR> - <HR> - <BR> - - <!-- Output the Photoshop IRB (including the IPTC-NAA info --> - <?php echo Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the Meta Information --> - <?php echo Interpret_EXIF_to_HTML( get_Meta_JPEG( $filename ), $filename ); ?> - - <BR> - <HR> - <BR> - - <?php - /** - <!-- Display the original image --> - - <h2>Original Image</h2> - <?php echo "<img src=\"$filename\">"; ?> - */ - ?> - - - <BR> - <BR> - <BR> - <p>Interpreted using:</p> - <p><a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> <!-- Change: displayed toolkit version numbers to reference Toolkit_Version.php - as of version 1.11 --> - - </body> - -</html> \ No newline at end of file Copied: trunk/linpha2/lib/include/metadata_info_edit.php (from rev 4671, trunk/linpha2/lib/include/File_Info_Edit.php) =================================================================== --- trunk/linpha2/lib/include/metadata_info_edit.php (rev 0) +++ trunk/linpha2/lib/include/metadata_info_edit.php 2007-02-15 11:18:24 UTC (rev 4679) @@ -0,0 +1,590 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +/**************************************************************************** +* +* Filename: Edit_File_Info.php +* +* Description: Allows the user to edit the metadata of an image over the internet +* in the same way that Photoshop edits 'File Info' data +* This file provides only the html for a form containing the file info +* input fields. The rest of the html file must be provided by the calling script. +* $outputfilename must always be defined - it is ne name of the file which +* have the metadata changed after the form has been submitted +* +* This file has several modes of operation: +* +* 1) If $new_ps_file_info_array is defined then it's data will be used +* to fill the fields. +* 2) If $new_ps_file_info_array is not defined but $filename is defined, +* then the file info fields will be filled from the metadata in the file specified +* 3) If $new_ps_file_info_array is not defined but $filename and $default_ps_file_info_array +* are defined, then the file info fields will be filled from the metadata +* in the file specified, but where fields are blank, they will be filled from $default_ps_file_info_array +* 4) Otherwise the fields will be blank +* +* See Edit_File_Info_Example.php for an example of usage +* +* Author: Evan Hunter +* +* Date: 17/11/2004 +* +* Project: PHP JPEG Metadata Toolkit +* +* Revision: 1.11 +* +* Changes: 1.10 -> 1.11 : Changed displayed toolkit version numbers to reference Toolkit_Version.php +* +* URL: http://electronics.ozhiker.com +* +* Copyright: Copyright Evan Hunter 2004 +* +* License: This file is part of the PHP JPEG Metadata Toolkit. +* +* The PHP JPEG Metadata Toolkit 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. +* +* The PHP JPEG Metadata Toolkit is distributed in the hope +* th... [truncated message content] |
From: <bz...@us...> - 2007-02-16 15:12:48
|
Revision: 4680 http://svn.sourceforge.net/linpha/?rev=4680&view=rev Author: bzrudi Date: 2007-02-16 07:12:43 -0800 (Fri, 16 Feb 2007) Log Message: ----------- Still MetaData mining ;-) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/templates/default/fragments.php Added Paths: ----------- trunk/linpha2/lib/include/metadata_iptc_edit.php Removed Paths: ------------- trunk/linpha2/lib/include/metadata_info_edit.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-02-15 11:18:24 UTC (rev 4679) +++ trunk/linpha2/ChangeLog 2007-02-16 15:12:43 UTC (rev 4680) @@ -1,3 +1,6 @@ +2007-02-15 bzrudi + * Still MetaData mining ;-) + 2007-02-14 bzrudi * Even more improvements to the MeetaData stuff, basics should work now. Btw. I will replace "medadata, meta data, Meta Data, Metadata..." by MetaData Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-15 11:18:24 UTC (rev 4679) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-16 15:12:43 UTC (rev 4680) @@ -1,4 +1,5 @@ <?php + /* * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> * Florian Angehrn @@ -23,285 +24,269 @@ * @package MetaData * @author flo, bzrudi */ - -if(!defined('LINPHA_DIR')) { exit(1); } +if (!defined('LINPHA_DIR')) { + exit (1); +} + /** * Functions to read MetaData from the database */ -class LinMetaDataRead extends LinMetaData -{ +class LinMetaDataRead extends LinMetaData { public $cachedFieldNames, $cachedFieldIds, $cachedSelectedFieldNames; - + /** * read image information from database * and escape data with htmlspecialchars() if necessary * - * @param array array_src_infos array containing needed source file informations, same as LIN_SELECT_FIELDS + * @param array array_src_infos array containing needed source file + * informations, same as LIN_SELECT_FIELDS * */ - function readInformations($array_src_infos, $flag_nr) - { + function readInformations($array_src_infos, $flag_nr) { /** * cache field names if not already done * readInformations() is executed for each thumbnail on a folder * save a lot of time if do it only once! */ - if( !isset($this->cachedSelectedFieldNames) OR !is_array($this->cachedSelectedFieldNames)) - { + if (!isset ($this->cachedSelectedFieldNames) OR !is_array($this->cachedSelectedFieldNames)) { $query = $GLOBALS['linpha']->db->Execute("SELECT name " . - "FROM ".LIN_PREFIX."meta_fields " . - "WHERE flags = '".$flag_nr."' ORDER by id"); - - while($fields_data = $query->FetchRow(ADODB_FETCH_NUM)) - { + "FROM " . LIN_PREFIX . "meta_fields " . + "WHERE flags = '" . $flag_nr . "' ORDER by id"); + + while ($fields_data = $query->FetchRow(ADODB_FETCH_NUM)) { $this->cachedSelectedFieldNames[] = $fields_data['0']; } } - - foreach($this->cachedSelectedFieldNames AS $field_name) - { - $name = $this->getNameOfField( $field_name, false ); + + foreach ($this->cachedSelectedFieldNames AS $field_name) { + $name = $this->getNameOfField($field_name, false); $value = ''; - - $pos = strpos($field_name,'_'); - $first_part = substr($field_name,0,$pos); - $last_part = substr($field_name,$pos+1); - - switch($first_part) - { - case 'builtin': - - switch($last_part) - { - case 'filename': - $value = $array_src_infos['name']; // is already escaped - break; - case 'imagesize': - $value = LinFilesys::niceFilesize( $array_src_infos['filesize'], 2 ); - break; - case 'dimension': - $value = $array_src_infos['width'].'x'.$array_src_infos['height']; - break; - case 'thumbnail': - $value = 'thumbnail'; - break; - case 'time_add': - $name = i18n("Date Added"); - $value = linStrftime($array_src_infos['time_add']); - break; - case 'time_mod': - $name = i18n("Date Modified"); - $value = linStrftime($array_src_infos['time_mod']); - break; - case 'time_exif': - $name = i18n("Date Taken"); - $value = linStrftime($array_src_infos['time_exif']); - break; - case 'stats_numbers': - $name = i18n("Photos"); - $value = $array_src_infos['stats_numbers']; - break; - case 'stats_views': - $name = i18n("Nr Of Views"); - $value = $array_src_infos['stats_views']; - break; - case 'stats_downloads': - $name = i18n("Nr Of Downloads"); - $value = $array_src_infos['stats_downloads']; - break; - case 'first_comment': - $name = i18n("First Comment"); - $value = linHtmlTag( - $GLOBALS['linpha']->db->GetOne( - "SELECT meta_comment FROM ".LIN_PREFIX."meta_comments " . - "WHERE md5sum = '".LinSql::linAddslashes($array_src_infos['md5sum'])."' " . - "ORDER by meta_time ASC") - ); - break; - - default: - /** - * description, category, persons, date (field entries which are stored in linpha_meta_data) - */ + + $pos = strpos($field_name, '_'); + $first_part = substr($field_name, 0, $pos); + $last_part = substr($field_name, $pos +1); + + switch ($first_part) { + case 'builtin' : + + switch ($last_part) { + case 'filename' : + $value = $array_src_infos['name']; // already escaped + break; + case 'imagesize' : + $value = LinFilesys :: niceFilesize($array_src_infos['filesize'], 2); + break; + case 'dimension' : + $value = $array_src_infos['width'] . 'x' . $array_src_infos['height']; + break; + case 'thumbnail' : + $value = 'thumbnail'; + break; + case 'time_add' : + $name = i18n("Date Added"); + $value = linStrftime($array_src_infos['time_add']); + break; + case 'time_mod' : + $name = i18n("Date Modified"); + $value = linStrftime($array_src_infos['time_mod']); + break; + case 'time_exif' : + $name = i18n("Date Taken"); + $value = linStrftime($array_src_infos['time_exif']); + break; + case 'stats_numbers' : + $name = i18n("Photos"); + $value = $array_src_infos['stats_numbers']; + break; + case 'stats_views' : + $name = i18n("Nr Of Views"); + $value = $array_src_infos['stats_views']; + break; + case 'stats_downloads' : + $name = i18n("Nr Of Downloads"); + $value = $array_src_infos['stats_downloads']; + break; + case 'first_comment' : + $name = i18n("First Comment"); + $value = linHtmlTag($GLOBALS['linpha']->db->GetOne("SELECT meta_comment FROM " . + LIN_PREFIX . "meta_comments " . + "WHERE md5sum = '" . LinSql :: linAddslashes($array_src_infos['md5sum']) . "' " . + "ORDER by meta_time ASC")); + break; + + default : /** + * description, category, persons, + * date (field entries which are stored in linpha_meta_data) + */ + /** * get field id, and cache it */ - if( !isset($this->cachedFieldIds[$last_part]) ) - { + if (!isset ($this->cachedFieldIds[$last_part])) { $this->cachedFieldIds[$last_part] = $GLOBALS['linpha']->db->GetOne("SELECT id " . - "FROM ".LIN_PREFIX."meta_fields WHERE name = '".$last_part."'"); + "FROM " . LIN_PREFIX . "meta_fields WHERE name = '" . $last_part . "'"); } - + /** * get data */ $meta_data = $GLOBALS['linpha']->db->GetOne("SELECT meta_data " . - "FROM ".LIN_PREFIX."meta_data ". - "WHERE field_id = '".$this->cachedFieldIds[$last_part]."' " . - "AND md5sum = '".$array_src_infos['md5sum']."'"); - - if( !empty($meta_data) ) { - $value = htmlspecialchars($meta_data,ENT_QUOTES); + "FROM " . LIN_PREFIX . "meta_data " . + "WHERE field_id = '" . $this->cachedFieldIds[$last_part] . "' " . + "AND md5sum = '" . $array_src_infos['md5sum'] . "'"); + + if (!empty ($meta_data)) { + $value = htmlspecialchars($meta_data, ENT_QUOTES); } - break; - } // end switch($last_part) - break; // end case 'builtin' + break; + } // end switch($last_part) + break; // end case 'builtin' - case 'id': // own fields + case 'id' : // own fields - /** - * get data - */ - $meta_data = $GLOBALS['linpha']->db->GetOne("SELECT meta_data " . - "FROM ".LIN_PREFIX."meta_data " . - "WHERE field_id = '".$last_part."' " . - "AND md5sum = '".$array_src_infos['md5sum']."'"); - - if(isset($meta_data) && !empty($meta_data)) { - $value = htmlspecialchars($meta_data,ENT_QUOTES); - } - break; + /** + * get data + */ + $meta_data = $GLOBALS['linpha']->db->GetOne("SELECT meta_data " . + "FROM " . LIN_PREFIX . "meta_data " . + "WHERE field_id = '" . $last_part . "' " . + "AND md5sum = '" . $array_src_infos['md5sum'] . "'"); - case 'exif': - if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) { - $exif_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." " . - "FROM ".LIN_PREFIX."meta_exif WHERE md5sum = '".$array_src_infos['md5sum']."'"); - - if(isset($exif_data[$last_part])) { - $value = htmlspecialchars($exif_data[$last_part],ENT_QUOTES); + if (isset ($meta_data) && !empty ($meta_data)) { + $value = htmlspecialchars($meta_data, ENT_QUOTES); } - } - break; - case 'iptc': - if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { - $iptc_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." " . - "FROM ".LIN_PREFIX."meta_iptc WHERE md5sum = '".$array_src_infos['md5sum']."'"); - - if(isset($iptc_data[$last_part])) { - $value = htmlspecialchars($iptc_data[$last_part],ENT_QUOTES); + break; + + case 'exif' : + if ($GLOBALS['linpha']->sql->config->value['sys_image_exif']) { + $exif_data = $GLOBALS['linpha']->db->GetRow("SELECT " . $last_part . " " . + "FROM " . LIN_PREFIX . "meta_exif " . + "WHERE md5sum = '" . $array_src_infos['md5sum'] . "'"); + + if (isset ($exif_data[$last_part])) { + $value = htmlspecialchars($exif_data[$last_part], ENT_QUOTES); + } } - } - break; - case 'xmp': - if($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { - $xmp_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." " . - "FROM ".LIN_PREFIX."meta_xmp WHERE md5sum = '".$array_src_infos['md5sum']."'"); - - if(isset($xmp_data[$last_part])) { - $value = htmlspecialchars($xmp_data[$last_part],ENT_QUOTES); + break; + case 'iptc' : + if ($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { + $iptc_data = $GLOBALS['linpha']->db->GetRow("SELECT " . $last_part . " " . + "FROM " . LIN_PREFIX . "meta_iptc " . + "WHERE md5sum = '" . $array_src_infos['md5sum'] . "'"); + + if (isset ($iptc_data[$last_part])) { + $value = htmlspecialchars($iptc_data[$last_part], ENT_QUOTES); + } } - } - break; + break; + case 'xmp' : + if ($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { + $xmp_data = $GLOBALS['linpha']->db->GetRow("SELECT " . $last_part . " " . + "FROM " . LIN_PREFIX . "meta_xmp " . + "WHERE md5sum = '" . $array_src_infos['md5sum'] . "'"); + + if (isset ($xmp_data[$last_part])) { + $value = htmlspecialchars($xmp_data[$last_part], ENT_QUOTES); + } + } + break; } - - if($value != '') - { + + if ($value != '') { /** * get category names if the data looks like ';5;4;44;' or at least ';2;' */ - if( preg_match( '/^;[0-9;]*;$/', $value) ) - { - $array_catids = linExplodeAndSlice(';',$value); + if (preg_match('/^;[0-9;]*;$/', $value)) { + $array_catids = linExplodeAndSlice(';', $value); $str_catnames = ''; $isValidCategory = true; - for($i=1; list($key,$catid) = each($array_catids) ; $i++) - { - $str_catnames .= $GLOBALS['linpha']->db->GetOne("SELECT name FROM ".LIN_PREFIX."meta_category WHERE id = '".LinSql::linAddslashes($catid)."'"); - + for ($i = 1; list ($key, $catid) = each($array_catids); $i++) { + $str_catnames .= $GLOBALS['linpha']->db->GetOne("SELECT name " . + "FROM " . LIN_PREFIX . "meta_category " . + "WHERE id = '" . LinSql :: linAddslashes($catid) . "'"); + /** * was this a valid category id? * maybe someone just added ;nice; as a description * * this will only check the first category id, but thats okay */ - if(empty($str_catnames)) - { + if (empty ($str_catnames)) { $isValidCategory = false; break; } - - if( $i < count($array_catids) ) - { + + if ($i < count($array_catids)) { $str_catnames .= ', '; } } - - if($isValidCategory) - { + + if ($isValidCategory) { $value = $str_catnames; } } - - $output_array[$field_name] = Array('name' => $name, 'value' => $value); + + $output_array[$field_name] = Array ( + 'name' => $name, + 'value' => $value + ); } } - + return $output_array; } - + } // end class LinMetaData - /** * Admin functions to select the tags which should be indexed */ -class LinMetaDataAdmin extends LinMetaData -{ - function createExifTable($array='') - { - if(empty($array)) - { - $array = $this->getDefaultExifFields(); - } - - if(LIN_DB_TYPE == "mysql") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_exif (". - "md5sum VARCHAR(32) NOT NULL, "; - foreach($array AS $key=>$value) - { - $str .= LinSql::linAddslashes(strtolower($value))." VARCHAR(255), "; - } - $str .= "PRIMARY KEY (md5sum), "; - $str .= "KEY (md5sum) )"; - } - elseif(LIN_DB_TYPE == "sqlite") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_exif (". - "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; - foreach($array AS $key=>$value) - { - $str .= strtolower($value)." VARCHAR(255), "; - } - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str,0,strlen($str)-2).")"; - } - elseif(LIN_DB_TYPE == "postgres") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_exif (". - "md5sum VARCHAR(32) NOT NULL, "; - - foreach($array AS $key=>$value) - { - $str .= strtolower($value)." VARCHAR(255), "; - } - - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str,0,strlen($str)-2).")"; - } - return $str; +class LinMetaDataAdmin extends LinMetaData { + function createExifTable($array = '') { + if (empty ($array)) { + $array = $this->getDefaultExifFields(); + } + + if (LIN_DB_TYPE == "mysql") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_exif (" . + "md5sum VARCHAR(32) NOT NULL, "; + foreach ($array AS $key => $value) { + $str .= LinSql :: linAddslashes(strtolower($value)) . " VARCHAR(255), "; + } + $str .= "PRIMARY KEY (md5sum), "; + $str .= "KEY (md5sum) )"; + } + elseif (LIN_DB_TYPE == "sqlite") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_exif (" . + "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; + foreach ($array AS $key => $value) { + $str .= strtolower($value) . " VARCHAR(255), "; + } + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str, 0, strlen($str) - 2) . ")"; + } + elseif (LIN_DB_TYPE == "postgres") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_exif (" . + "md5sum VARCHAR(32) NOT NULL, "; + + foreach ($array AS $key => $value) { + $str .= strtolower($value) . " VARCHAR(255), "; + } + + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str, 0, strlen($str) - 2) . ")"; + } + return $str; } - - function getDefaultExifFields() - { - return Array - ( - 'datetimeoriginal', + + function getDefaultExifFields() { + return Array ( + 'datetimeoriginal', 'make', 'model', 'artist', @@ -316,153 +301,133 @@ ); } - function createIptcTable($array='') - { - if(empty($array)) - { - $array = Array(); - } - - if(LIN_DB_TYPE == "mysql") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_iptc (". - "md5sum VARCHAR(32) NOT NULL, "; - - foreach($array AS $key=>$value) - { - $str .= LinSql::linAddslashes(strtolower($value))." VARCHAR(255), "; - } - $str .= "PRIMARY KEY (md5sum), "; - $str .= "KEY (md5sum) )"; - } - elseif(LIN_DB_TYPE == "sqlite") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_iptc (". - "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; - foreach($array AS $key=>$value) - { - $str .= strtolower($value)." VARCHAR(255), "; - } - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str,0,strlen($str)-2).")"; - } - elseif(LIN_DB_TYPE == "postgres") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_iptc (". - "md5sum VARCHAR(32) NOT NULL, "; - - foreach($array AS $key=>$value) - { - $str .= strtolower($value)." VARCHAR(255), "; - } - - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str,0,strlen($str)-2).")"; - } - return $str; - } + function createIptcTable($array = '') { + if (empty ($array)) { + $array = Array (); + } - function createXmpTable($array='') - { - if(empty($array)) - { - $array = Array(); - } - - if(LIN_DB_TYPE == "mysql") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_xmp (". - "md5sum VARCHAR(32) NOT NULL, "; - - foreach($array AS $key=>$value) - { - $str .= LinSql::linAddslashes(strtolower($value))." VARCHAR(255), "; - } - $str .= "PRIMARY KEY (md5sum), "; - $str .= "KEY (md5sum) )"; - } - elseif(LIN_DB_TYPE == "sqlite") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_xmp (". - "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; - foreach($array AS $key=>$value) - { - $str .= strtolower($value)." VARCHAR(255), "; - } - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str,0,strlen($str)-2).")"; - } - elseif(LIN_DB_TYPE == "postgres") - { - $str = "CREATE TABLE ".LIN_PREFIX."meta_xmp (". - "md5sum VARCHAR(32) NOT NULL, "; - - foreach($array AS $key=>$value) - { - $str .= strtolower($value)." VARCHAR(255), "; - } - - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str,0,strlen($str)-2).")"; - } - return $str; - } + if (LIN_DB_TYPE == "mysql") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_iptc (" . + "md5sum VARCHAR(32) NOT NULL, "; + foreach ($array AS $key => $value) { + $str .= LinSql :: linAddslashes(strtolower($value)) . " VARCHAR(255), "; + } + $str .= "PRIMARY KEY (md5sum), "; + $str .= "KEY (md5sum) )"; + } + elseif (LIN_DB_TYPE == "sqlite") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_iptc (" . + "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; + foreach ($array AS $key => $value) { + $str .= strtolower($value) . " VARCHAR(255), "; + } + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str, 0, strlen($str) - 2) . ")"; + } + elseif (LIN_DB_TYPE == "postgres") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_iptc (" . + "md5sum VARCHAR(32) NOT NULL, "; + + foreach ($array AS $key => $value) { + $str .= strtolower($value) . " VARCHAR(255), "; + } + + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str, 0, strlen($str) - 2) . ")"; + } + return $str; + } + + function createXmpTable($array = '') { + if (empty ($array)) { + $array = Array (); + } + + if (LIN_DB_TYPE == "mysql") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_xmp (" . + "md5sum VARCHAR(32) NOT NULL, "; + + foreach ($array AS $key => $value) { + $str .= LinSql :: linAddslashes(strtolower($value)) . " VARCHAR(255), "; + } + $str .= "PRIMARY KEY (md5sum), "; + $str .= "KEY (md5sum) )"; + } + elseif (LIN_DB_TYPE == "sqlite") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_xmp (" . + "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; + foreach ($array AS $key => $value) { + $str .= strtolower($value) . " VARCHAR(255), "; + } + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str, 0, strlen($str) - 2) . ")"; + } + elseif (LIN_DB_TYPE == "postgres") { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_xmp (" . + "md5sum VARCHAR(32) NOT NULL, "; + + foreach ($array AS $key => $value) { + $str .= strtolower($value) . " VARCHAR(255), "; + } + + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str, 0, strlen($str) - 2) . ")"; + } + return $str; + } + } // end class LinMetaDataAdmin - /** * Index functions (save data in DB) */ -class LinMetaDataIndex extends LinMetaData -{ +class LinMetaDataIndex extends LinMetaData { /** * wrapper function for saveExifData, saveIptcData and saveXmpData * for easier access */ - function saveData($what,$filename,$md5sum) - { + function saveData($what, $filename, $md5sum) { /** * no double entries * do this check at very first position to improve performance! * also do not setFields in the __contruct() because they may never be used - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum FROM ".LIN_PREFIX."meta_".$what." ". - "WHERE md5sum = '".$md5sum."'"); + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum " . + "FROM " . LIN_PREFIX . "meta_" . $what . " " . + "WHERE md5sum = '" . $md5sum . "'"); - if( $query->EOF) // not a single value returned - { + if ($query->EOF) // not a single value returned + { /** * define tags to index if not already done */ - if( !isset($this->defined_fields[$what])) - { + if (!isset ($this->defined_fields[$what])) { $this->setFields($what); } - switch($what) - { - case 'exif': - $this->saveExifData($filename,$md5sum); - break; - case 'iptc': - $this->saveIptcData($filename,$md5sum); - break; - case 'xmp': - $this->saveXmpData($filename,$md5sum); - break; + switch ($what) { + case 'exif' : + $this->saveExifData($filename, $md5sum); + break; + case 'iptc' : + $this->saveIptcData($filename, $md5sum); + break; + case 'xmp' : + $this->saveXmpData($filename, $md5sum); + break; } } } - + /** * store EXIF data in DB * @@ -470,274 +435,233 @@ * to prevent img_view.class.php to call this function every time * the image is viewed */ - function saveExifData($filename,$md5sum) - { - include_once(LINPHA_DIR.'/lib/classes/pjmt/JPEG.php'); // used for jpeg comment - include_once(LINPHA_DIR.'/lib/classes/pjmt/EXIF.php'); + function saveExifData($filename, $md5sum) { + include_once (LINPHA_DIR . '/lib/classes/pjmt/JPEG.php'); + include_once (LINPHA_DIR . '/lib/classes/pjmt/EXIF.php'); - $str_columns = "md5sum, "; - $str_values = "'".$md5sum."', "; + $str_columns = "md5sum, "; + $str_values = "'" . $md5sum . "', "; - /** - * get exif info from file - */ - $exif_data = get_EXIF_JPEG( $filename ); - if( $exif_data) - { - /** - * special tags - */ - // Canon Owner Name append to Artist - if(isset($exif_data['Makernote_Tag']['Decoded Data']) - && is_array($exif_data['Makernote_Tag']['Decoded Data']) // sometimes 'Decoded Data' is an empty string - && isset($exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value'])) - { - $owner = $exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value']; - if(isset($exif_data[0][315]['Text Value'])) - { - $exif_data[0][315]['Text Value'] .= $owner; - } - else - { - $exif_data[0][315]['Text Value'] = $owner; - } - - } - - /** - * search for valid tags - */ - foreach($this->defined_fields['exif'] AS $key=>$value) - //foreach(LinMetaData::$Tags['exif'] AS $key=>$value) - { - if( !empty(LinMetaData::$Tags['exif'][$key]['pathvalue']) ) - { - /** - * there are currently only entries at level deep 2 and 5 in the array - */ - $array_pieces = explode('/',LinMetaData::$Tags['exif'][$key]['pathvalue']); - switch(count($array_pieces)) - { - case 2: - if(isset($exif_data[ $array_pieces[0] ][ $array_pieces[1] ]['Text Value'])) - { - $str_columns .= $key.', '; - - $exif_value = $exif_data[ $array_pieces[0] ][ $array_pieces[1] ]['Text Value']; - $str_values .= "'".LinSql::linAddslashes(trim( $exif_value ))."', "; - } - break; - case 5: - if(isset($exif_data[ $array_pieces[0] ][ $array_pieces[1] ][ $array_pieces[2] ][ $array_pieces[3] ][ $array_pieces[4] ]['Text Value'])) - { - $str_columns .= $key.', '; - - $exif_value = $exif_data[ $array_pieces[0] ][ $array_pieces[1] ][ $array_pieces[2] ][ $array_pieces[3] ][ $array_pieces[4] ]['Text Value']; - $str_values .= "'".LinSql::linAddslashes(trim( $exif_value ))."', "; - } - break; - default: - echo "Error no valid path for key: ".$key." value: ".LinMetaData::$Tags['exif'][$key]['pathvalue']."<br />"; - break; - } - } - } - + /** + * get exif info from file + */ + $exif_data = get_EXIF_JPEG($filename); + if ($exif_data) { /** + * special tags + */ + // Canon Owner Name append to Artist + if (isset ($exif_data['Makernote_Tag']['Decoded Data']) && is_array($exif_data['Makernote_Tag']['Decoded Data']) // sometimes 'Decoded Data' is an empty string + && isset ($exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value'])) { + $owner = $exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value']; + if (isset ($exif_data[0][315]['Text Value'])) { + $exif_data[0][315]['Text Value'] .= $owner; + } else { + $exif_data[0][315]['Text Value'] = $owner; + } + + } + + /** + * search for valid tags + */ + foreach ($this->defined_fields['exif'] AS $key => $value) + //foreach(LinMetaData::$Tags['exif'] AS $key=>$value) + { + if (!empty (LinMetaData :: $Tags['exif'][$key]['pathvalue'])) { + /** + * there are currently only entries at level deep 2 and 5 in the array + */ + $array_pieces = explode('/', LinMetaData :: $Tags['exif'][$key]['pathvalue']); + switch (count($array_pieces)) { + case 2 : + if (isset ($exif_data[$array_pieces[0]][$array_pieces[1]]['Text Value'])) { + $str_columns .= $key . ', '; + + $exif_value = $exif_data[$array_pieces[0]][$array_pieces[1]]['Text Value']; + $str_values .= "'" . LinSql :: linAddslashes(trim($exif_value)) . "', "; + } + break; + case 5 : + if (isset ($exif_data[$array_pieces[0]][$array_pieces[1]][$array_pieces[2]][$array_pieces[3]][$array_pieces[4]]['Text Value'])) { + $str_columns .= $key . ', '; + + $exif_value = $exif_data[$array_pieces[0]][$array_pieces[1]][$array_pieces[2]][$array_pieces[3]][$array_pieces[4]]['Text Value']; + $str_values .= "'" . LinSql :: linAddslashes(trim($exif_value)) . "', "; + } + break; + default : + echo "Error no valid path for key: " . $key . " value: " . LinMetaData :: $Tags['exif'][$key]['pathvalue'] . "<br />"; + break; + } + } + } + + /** * add jpegcomment */ - if(isset($this->defined_fields['exif']['jpegcomment'])) - { - $jpeg_header_data = get_jpeg_header_data( $filename ); - $comment = get_jpeg_Comment( $jpeg_header_data ); - if(!empty($comment)) - { + if (isset ($this->defined_fields['exif']['jpegcomment'])) { + $jpeg_header_data = get_jpeg_header_data($filename); + $comment = get_jpeg_Comment($jpeg_header_data); + if (!empty ($comment)) { $str_columns .= 'jpegcomment, '; - $str_values .= "'".LinSql::linAddslashes(trim( $comment ))."', "; + $str_values .= "'" . LinSql :: linAddslashes(trim($comment)) . "', "; } } - } - - /** - * remove last two signs (the comma and the space) which we added to much - */ - $str_columns = substr($str_columns,0,strlen($str_columns)-2); - $str_values = substr($str_values,0,strlen($str_values)-2); - + } - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_exif (".$str_columns.") ". - "VALUES (".$str_values.")"); + /** + * remove last two signs (the comma and the space) which we added to much + */ + $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); + $str_values = substr($str_values, 0, strlen($str_values) - 2); + + $GLOBALS['linpha']->db->Execute("INSERT into " . LIN_PREFIX . "meta_exif (" . $str_columns . ") " . + "VALUES (" . $str_values . ")"); } - + /** * store IPTC data in DB */ - function saveIptcData($filename, $md5sum) - { - include_once(LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/JPEG.php'); + function saveIptcData($filename, $md5sum) { + include_once (LINPHA_DIR . '/lib/classes/pjmt/Photoshop_IRB.php'); + include_once (LINPHA_DIR . '/lib/classes/pjmt/JPEG.php'); - $str_columns = "md5sum, "; - $str_values = "'".$md5sum."', "; + $str_columns = "md5sum, "; + $str_values = "'" . $md5sum . "', "; - // Retrieve the header information - $jpeg_header_data = get_jpeg_header_data($filename); + // Retrieve the header information + $jpeg_header_data = get_jpeg_header_data($filename); - if( $jpeg_header_data ) - { - // get array with all available IPTC data - $IPTC_Info = get_Photoshop_IPTC(get_Photoshop_IRB($jpeg_header_data)); - - if(is_array($IPTC_Info)) - { - /** - * search for valid tags - */ - foreach($this->defined_fields['iptc'] AS $key=>$value) - { - if( !empty(LinMetaData::$Tags['iptc'][$key]['path']) ) - { - $str_columns .= $key.', '; + if ($jpeg_header_data) { + // get array with all available IPTC data + $IPTC_Info = get_Photoshop_IPTC(get_Photoshop_IRB($jpeg_header_data)); + + if (is_array($IPTC_Info)) { + /** + * search for valid tags + */ + foreach ($this->defined_fields['iptc'] AS $key => $value) { + if (!empty (LinMetaData :: $Tags['iptc'][$key]['path'])) { + $str_columns .= $key . ', '; $str_values .= "'"; - foreach($IPTC_Info as $IPTC_Record) - { - if( $IPTC_Record['IPTC_Type'] == LinMetaData::$Tags['iptc'][$key]['path'] ) - { - $str_values .= "".LinSql::linAddslashes(trim( $IPTC_Record['RecData'] ))." "; - + foreach ($IPTC_Info as $IPTC_Record) { + if ($IPTC_Record['IPTC_Type'] == LinMetaData :: $Tags['iptc'][$key]['path']) { + $str_values .= "" . LinSql :: linAddslashes(trim($IPTC_Record['RecData'])) . " "; + } } - + $str_values .= "', "; - } - } + } + } } - } - - /** - * remove last two signs (the comma and the space) which we added to much - */ - $str_columns = substr($str_columns,0,strlen($str_columns)-2); - $str_values = substr($str_values,0,strlen($str_values)-2); - + } - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_iptc (".$str_columns.") ". - "VALUES (".$str_values.")"); + /** + * remove last two signs (the comma and the space) which we added to much + */ + $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); + $str_values = substr($str_values, 0, strlen($str_values) - 2); + + $GLOBALS['linpha']->db->Execute("INSERT into " . LIN_PREFIX . "meta_iptc (" . $str_columns . ") " . + "VALUES (" . $str_values . ")"); } - /** * store XMP data in DB */ - function saveXmpData($filename, $md5sum) - { - include_once(LINPHA_DIR.'/lib/classes/pjmt/XMP.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/JPEG.php'); + function saveXmpData($filename, $md5sum) { + include_once (LINPHA_DIR . '/lib/classes/pjmt/XMP.php'); + include_once (LINPHA_DIR . '/lib/classes/pjmt/JPEG.php'); $str_columns = "md5sum, "; - $str_values = "'".$md5sum."', "; + $str_values = "'" . $md5sum . "', "; $jpeg_header_data = get_jpeg_header_data($filename); - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); + $XMP_array = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); // Check if the XMP tree structure array is valid - if ( $XMP_array !== FALSE ) - { + if ($XMP_array !== FALSE) { // Check if there is a rdf:RDF tag at either the first or second level - if ( ( $XMP_array[0]['tag'] == "x:xapmeta" ) && ( $XMP_array[0]['children'][0]['tag'] == "rdf:RDF" ) ) - { - // RDF found at second level - Save it's position - $RDF_Contents = &$XMP_array[0]['children'][0]['children']; - } - else if ( ( $XMP_array[0]['tag'] == "x:xmpmeta" ) && ( $XMP_array[0]['children'][0]['tag'] == "rdf:RDF" ) ) - { + if (($XMP_array[0]['tag'] == "x:xapmeta") && ($XMP_array[0]['children'][0]['tag'] == "rdf:RDF")) { // RDF found at second level - Save it's position - $RDF_Contents = &$XMP_array[0]['children'][0]['children']; - } - else if ( $XMP_array[0]['tag'] == "rdf:RDF" ) - { - // RDF found at first level - Save it's position - $RDF_Contents = &$XMP_array[0]['children']; - } - else - { - // RDF section not found - abort - return ""; - } + $RDF_Contents = & $XMP_array[0]['children'][0]['children']; + } else + if (($XMP_array[0]['tag'] == "x:xmpmeta") && ($XMP_array[0]['children'][0]['tag'] == "rdf:RDF")) { + // RDF found at second level - Save it's position + $RDF_Contents = & $XMP_array[0]['children'][0]['children']; + } else + if ($XMP_array[0]['tag'] == "rdf:RDF") { + // RDF found at first level - Save it's position + $RDF_Contents = & $XMP_array[0]['children']; + } else { + // RDF section not found - abort + return ""; + } // Cycle through each of the items in the RDF tree array, and process them - foreach ($RDF_Contents as $RDF_Item) - { + foreach ($RDF_Contents as $RDF_Item) { // Check if this element has sub-items - if ( array_key_exists( 'children', $RDF_Item ) ) - { + if (array_key_exists('children', $RDF_Item)) { // Cycle through each of the sub-items - foreach( $RDF_Item['children'] as $child_item ) - { + foreach ($RDF_Item['children'] as $child_item) { /** * Get user defined fields for xmp */ - foreach($this->defined_fields['xmp'] AS $key=>$value) - { - if( !empty(LinMetaData::$Tags['xmp'][$key]['path']) ) - { - - /** - * Field hit! e.g. image contains data user want's to - * have in DB later - */ - if(LinMetaData::$Tags['xmp'][$key]['path'] == $child_item['tag']) - { + foreach ($this->defined_fields['xmp'] AS $key => $value) { + if (!empty (LinMetaData :: $Tags['xmp'][$key]['path'])) { + /** - * If value is empty, it does not necesarry mean there - * is no data, so we have to cycle through, this - * is a real mess ;-) + * Field hit! e.g. image contains data user want's to + * have in DB later */ - if(!isset($child_item['value'])) - { - if(is_array($child_item['children'])) - { + if (LinMetaData :: $Tags['xmp'][$key]['path'] == $child_item['tag']) { /** - * We need to get value for rdf:li which may be an - * order or unorder list, or even a list of alternatives, bah! - * However we handle them all the same - */ - $child_item['value'] = $child_item['children'][0]['children'][0]['value']; + * If value is empty, it does not necesarry mean there + * is no data, so we have to cycle through, this + * is a real mess ;-) + */ + if (!isset ($child_item['value'])) { + if (is_array($child_item['children'])) { + /** + * We need to get value for rdf:li which may be an + * order or unorder list, or even a list of alternatives, bah! + * However we handle them all the same + */ + $child_item['value'] = $child_item['children'][0]['children'][0]['value']; + } } + + $str_columns .= LinMetaData :: $Tags['xmp'][$key]['pathkey'] . ', '; + $str_values .= "'" . trim($child_item['value']) . ""; + $str_values .= "', "; + + break; + } - - $str_columns .= LinMetaData::$Tags['xmp'][$key]['pathkey'].', '; - $str_values .= "'".trim( $child_item['value']).""; - $str_values .= "', "; - - break; - - } - } - - } - } + } + + } + } } } - /** - * remove last two signs (the comma and the space) which we added to much - */ - $str_columns = substr($str_columns,0,strlen($str_columns)-2); - $str_values = substr($str_values,0,strlen($str_values)-2); - + /** + * remove last two signs (the comma and the space) which we added to much + */ + $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); + $str_values = substr($str_values, 0, strlen($str_values) - 2); - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_xmp (".$str_columns.") ". - "VALUES (".$str_values.")"); + $GLOBALS['linpha']->db->Execute("INSERT into " . LIN_PREFIX . "meta_xmp (" . $str_columns . ") " . + "VALUES (" . $str_values . ")"); + } else { + //linSysLog( i18n("NO XMP FOUND:" .' '. $filename) ); + //linLog( LOG_TYPE_META, ERROR, 'meta_xmp', "ERROR:" .' '. $filename ); + //exit(); } - else - { - //linSysLog( i18n("NO XMP FOUND:" .' '. $filename) ); - //linLog( LOG_TYPE_META, ERROR, 'meta_xmp', "ERROR:" .' '. $filename ); - //exit(); - } } /** @@ -747,69 +671,65 @@ * @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" - { + */ + 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; + return $rotate; } // end function getRotationByExifTag() - + /** * converts a exif date to a unix timestamp * example: 2004:02:14 18:24:19 -> 11167594589 @@ -818,846 +738,1405 @@ * @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); + 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 LinMetaDataIndex - /** * Modificate MetaData and save the information back to the file (IPTC and XMP) */ -class LinMetaDataModificate extends LinMetaData -{ - function showEditMetaData() - { +class LinMetaDataModificate extends LinMetaData { + function showEditMetaData() { /** * set meta linpha */ - $GLOBALS['linpha']->template->output['meta_linpha'] = ''; - - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, flags " . - "FROM ".LIN_PREFIX."meta_fields " . - "WHERE flags = '5' OR flags = '7' ORDER by id"); - while($data = $query->FetchRow()) - { - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<tr><td width="150" valign="top">'; - - if( $data['flags']==5 ) - { - $GLOBALS['linpha']->template->output['meta_linpha'] .= LinMetaData::getNameOfField('builtin_'.$data['name'],false); - } - elseif( $data['flags']==7 ) - { - $GLOBALS['linpha']->template->output['meta_linpha'] .= LinMetaData::getNameOfField('id_'.$data['id'],false); - } - $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td><td>'; - - $meta_data = $GLOBALS['linpha']->db->GetRow("SELECT meta_data FROM ".LIN_PREFIX."meta_data " . - "WHERE md5sum = '".$GLOBALS['linpha']->imgview->md5sum."'" . - "AND field_id = '".$data['id']."'"); - - switch($data['field_type']) - { - case 1: - if(isset($meta_data['meta_data'])) { - $value = htmlspecialchars($meta_data['meta_data'],ENT_QUOTES); + $GLOBALS['linpha']->template->output['meta_linpha'] = ''; + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, flags " . + "FROM " . LIN_PREFIX . "meta_fields " . + "WHERE flags = '5' OR flags = '7' ORDER by id"); + while ($data = $query->FetchRow()) { + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<tr><td width="150" valign="top">'; + + if ($data['flags'] == 5) { + $GLOBALS['linpha']->template->output['meta_linpha'] .= LinMetaData :: getNameOfField('builtin_' . $data['name'], false); + } + elseif ($data['flags'] == 7) { + $GLOBALS['linpha']->template->output['meta_linpha'] .= LinMetaData :: getNameOfField('id_' . $data['id'], false); + } + $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td><td>'; + + $meta_data = $GLOBALS['linpha']->db->GetRow("SELECT meta_data FROM " . LIN_PREFIX . "meta_data " . + "WHERE md5sum = '" . $GLOBALS['linpha']->imgview->md5sum . "'" . + "AND field_id = '" . $data['id'] . "'"); + + switch ($data['field_type']) { + case 1 : + if (isset ($meta_data['meta_data'])) { + $value = htmlspecialchars($meta_data['meta_data'], ENT_QUOTES); } else { $value = ''; } - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<input type="text" class="linForms" name="linMetaField['.$data['id'].']" value="'.$value.'" style="width: 250px;" maxlength="255" />'; + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<input type="text" class="linForms" name="linMetaField[' . + $data['id'] . ']" ' . + 'value="' . $value . '" style="width: 250px;" maxlength="255" />'; break; - case 3: - if(isset($meta_data['meta_data'])) { - $value = htmlspecialchars($meta_data['meta_data'],ENT_QUOTES); + case 3 : + if (isset ($meta_data['meta_data'])) { + $value = htmlspecialchars($meta_data['meta_data'], ENT_QUOTES); } else { $value = ''; } - $GLOBALS['linpha']->template->output['meta_linpha'] .= - '<input type="text" class="linForms" name="linMetaField['.$data['id'].']" id="linField'.$data['id'].'" value="'.$value.'" style="width: 150px;" maxlength="255" />' - .' <a href="javascript:void(0);" onclick="var loginWin = window.open(\''.LINPHA_CLIENT.'/lib/include/calendar.php?form=linField'.$data['id'].'\''. - ',\'Calendar\',\'height=250,width=300,scrollbars=no,menubar=no,status=no\');" target="_top">'.i18n("Calendar").'</a>'; - + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<input type="text" class="linForms" name="linMetaField[' . + $data['id'] . ']" id="linField' . $data['id'] . '" value="' . $value . '" style="width: 150px;" maxlength="255" />' . + ' <a href="javascript:void(0);" onclick="var loginWin = window.open(\'' . LINPHA_CLIENT . '/lib/include/calendar.php?form=linField' . $data['id'] . '\'' . + ',\'Calendar\',\'height=250,width=300,scrollbars=no,menubar=no,status=no\');" target="_top">' . i18n("Calendar") . '</a>'; + break; - case 2: - if(isset($meta_data['meta_data'])) { - $array_pieces = linExplodeAndSlice(';',$meta_data['meta_data']); + case 2 : + if (isset ($meta_data['meta_data'])) { + $array_pieces = linExplodeAndSlice(';', $meta_data['meta_data']); } else { - $array_pieces = Array(); + $array_pieces = Array (); } - - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<select name="linMetaField['.$data['id'].'][]" class="linForms" size="7" multiple="multiple" style="width: 250px;">'; - + + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<select name="linMetaField[' . $data['id'] . '][]" class="linForms" size="7" multiple="multiple" style="width: 250px;">'; + $cat_query = $GLOBALS['linpha']->db->Execute("SELECT id, name " . - "FROM ".LIN_PREFIX."meta_category " . - "WHERE field_id = '".$data['id']."'"); - while($cat_data = $cat_query->FetchRow()) - { - if(in_array($cat_data['id'],$array_pieces)) { + "FROM " . LIN_PREFIX . "meta_category " . + "WHERE field_id = '" . $data['id'] . "'"); + while ($cat_data = $cat_query->FetchRow()) { + if (in_array($cat_data['id'], $array_pieces)) { $checked = ' selected="selected"'; } else { $checked = ''; } - - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<option value="'.$cat_data['id'].'"'.$checked.'>'.htmlspecialchars($cat_data['name'],ENT_QUOTES).'</option>'."\n"; + + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<option value="' . $cat_data['id'] . '"' . $checked . '>' . htmlspecialchars($cat_data['name'], ENT_QUOTES) . '</option>' . "\n"; } - $GLOBALS['linpha']->template->output['meta_linpha'] .= '</select>'."\n". - '<br /><span style="font-size: smaller;">'.i18n("For Multiple Select Use CTRL").'</span>'; - - if($GLOBALS['linpha']->sql->isAdmin()) - { - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<br /><span style="font-size: smaller;"><a href="'.LINPHA_CLIENT.'/admin/?cat=metadata_define_adddata">'.i18n("Add More Options").'</a><br /><br /></span>'; + $GLOBALS['linpha']->template->output['meta_linpha'] .= '</select>' . "\n" . + '<br /><span style="font-size: smaller;">' . i18n("For Multiple Select Use CTRL") . '</span>'; + + if ($GLOBALS['linpha']->sql->isAdmin()) { + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<br /><span style="font-size: smaller;"><a href="' . LINPHA_CLIENT . '/admin/?cat=metadata_define_adddata">' . i18n("Add More Options") . '</a><br /><br /></span>'; } - + break; - } - - $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td></tr>'; } - - /** - * set meta IPTC - */ - if($GLOBALS['linpha']->sql->config->value['sys_image_iptc'] || - $GLOBALS['linpha']->sql->config->value['sys_image_xmp'] ) - { - if( isset($GLOBALS['linpha']->imgview->src_file) - && file_exists($GLOBALS['linpha']->imgview->src_file)) - { - if( is_writable($GLOBALS['linpha']->imgview->src_file)) - { - $meta_edit_possible = true; - $filename = $GLOBALS['linpha']->imgview->src_file; // used in IPTC Edit_File_Info.php - } - else - { - $meta_edit_possible = false; - } - } - else - { + + $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td></tr>'; + } + + /** + * set meta IPTC + */ + if ($GLOBALS['linpha']->sql->config->value['sys_image_iptc'] || $GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { + if (isset ($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) { + if (is_writable($GLOBALS['linpha']->imgview->src_file)) { + $meta_edit_possible = true; + $filename = $GLOBALS['linpha']->imgview->src_file; // used in IPTC Edit_File_Info.php + } else { $meta_edit_possible = false; } + } else { + $meta_edit_possible = false; } + } /** * build the meta data view */ - $fragment = 'edit_meta'; - global $linTpl; - include(LINPHA_DIR.'/templates/'.$this->template_name.'/fragments.php'); + $fragment = 'edit_meta'; + global $linTpl; + include (LINPHA_DIR . '/templates/' . $this->template_name . '/fragments.php'); } // end function showEditMetaData() - + /** * save meta linpha and meta iptc separetaly */ - function saveModifiedMetaData() - { - if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) - { + function saveModifiedMetaData() { + if ($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) { /** * write linpha meta data */ - if(isset($_POST['linCmd']) && $_POST['linCmd']=='linInsertMetaLinpha') - { - LinMetaDataModificate::saveModifiedMetaDataLinpha(); - linSysLog( i18n("Successfully updated data.") ); + if (isset ($_POST['linCmd']) && $_POST['linCmd'] == 'linInsertMetaLinpha') { + LinMetaDataModificate :: saveModifiedMetaDataLinpha(); + linSysLog(i18n("Successfully updated data.")); } /** * write iptc data */ - if( isset($_POST['linCmd']) - && $_POST['linCmd']=='linInsertMetaIptc' - && $GLOBALS['linpha']->sql->config->value['sys_image_iptc'] - && isset($GLOBALS['linpha']->imgview->src_file) - && file_exists($GLOBALS['linpha']->imgview->src_file) ) - { + if (isset ($_POST['linCmd']) && $_POST['linCmd'] == 'linInsertMetaIptc' && $GLOBALS['linpha']->sql->config->value['sys_image_iptc'] && isset ($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) { global $new_ps_file_info_array; $new_ps_file_info_array = $GLOBALS['_POST']; - + /** * important! * remove other POST data from this array, because pjmt just takes all values and this will generate unexpected results!!! * we got problems because $_POST['linMetaField'] is an array and pjmt couldnt handle this */ - unset($new_ps_file_info_array['linCmd']); - unset($new_ps_file_info_array['linMetaField']); - unset($new_ps_file_info_array['submit']); - + unset ($new_ps_file_info_array['linCmd']); + unset ($new_ps_file_info_array['linMetaField']); + unset ($new_ps_file_info_array['submit']); + /** * if the backup went wrong, the saveModifiedMetaDataIptc() would most probably also fail */ - if( LinFilesys::backupFile($GLOBALS['linpha']->imgview->src_file)) - { - if( LinMetaDataModificate::saveModifiedMetaDataIptc( $new_ps_file_info_array, $GLOBALS['linpha']->imgview->src_file ) ) // error handling already done - { + if (LinFilesys :: backupFile($GLOBALS['linpha']->imgview->src_file)) { + if (LinMetaDataModificate :: saveModifiedMetaDataIptc($new_ps_file_info_array, $GLOBALS['linpha']->imgview->src_file)) // error handling already done + { /** * force read data from file again if write was successful */ - unset($new_ps_file_info_array); - LinImport::updateEntry( - $GLOBALS['linpha']->template->idCurrent , - dirname($GLOBALS['linpha']->imgview->src_file) , - basename($GLOBALS['linpha']->imgview->src_file) - ); + unset ($new_ps_file_info_array); + LinImport :: updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); } + } else { + linSysLog(sprintf(i18n("Error: Cannot create backup of: %s"), $GLOBALS['linpha']->imgview->src_file)); + linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Cannot create backup of:" . ' ' . $GLOBALS['linpha']->imgview->src_file); } - else - { - linSysLog( sprintf( i18n("Error: Cannot create backup of: %s"), $GLOBALS['linpha']->imgview->src_file) ); - linLog( LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Cannot create backup of:" .' '. $GLOBALS['linpha']->imgview->src_file ); - } } } } - + /** * save modified linpha meta data to database */ - function saveModifiedMetaDataLinpha() - { - if( isset($_POST['linMetaField']) && is_array($_POST['linMetaField']) ) - { + function saveModifiedMetaDataLinpha() { + if (isset ($_POST['linMetaField']) && is_array($_POST['linMetaField'])) { /** * delete existing entries */ - $query = $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."meta_data " . - "WHERE md5sum = '".$GLOBALS['linpha']->imgview->md5sum."'"); + $query = $GLOBALS['linpha']->db->Execute("DELETE FROM " . LIN_PREFIX . "meta_data " . + "WHERE md5sum = '" . $GLOBALS['linpha']->imgview->md5sum . "'"); /** * insert new entries */ - foreach($_POST['linMetaField'] AS $key=>$value) - { - if(is_array($value)) // coming from a select (categories etc.) - { - $value = ';'.implode(';',$value).';'; + foreach ($_POST['linMetaField'] AS $key => $value) { + if (is_array($value)) // coming from a select (categories etc.) + { + $value = ';' . implode(';', $value) . ';'; } - - if(! empty($value) ) - { - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_data ". - "(field_id, md5sum, meta_data) VALUES " . - "('".LinSql::linAddslashes($key)."','".$GLOBALS['linpha']->imgview->md5sum."','".LinSql::linAddslashes($value)."')"); + + if (!empty ($value)) { + $GLOBALS['linpha']->db->Execute("INSERT into " . LIN_PREFIX . "meta_data " . + "(field_id, md5sum, meta_data) VALUES " . + "('" . LinSql :: linAddslashes($key) . "','" . $GLOBALS['linpha']->imgview->md5sum . "','" . LinSql :: linAddslashes($value) . "')"); } } } } - + /** * save IPTC MetaData back to file * * copied from pjmt/Write_File_Info.php */ - function saveModifiedMetaDataIptc( & $new_ps_file_info_array, $filename ) - { - include_once(LINPHA_DIR.'/lib/classes/pjmt/JPEG.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/XMP.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/EXIF.php'); - include_once(LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php'); - - $GLOBALS[ "Software Name" ] = "LinPHA v".LINPHA_VERSION.", powered by PHP JPEG Metadata Toolkit v" . $GLOBALS['Toolkit_Version'] ; - + function saveModifiedMetaDataIptc(& $new_ps_file_info_array, $filename) { + include_once (LINPHA_DIR . '/lib/classes/pjmt/JPEG.php'); + include_once (LINPHA_DIR . '/lib/classes/pjmt/XMP.php'); + include_once (LINPHA_DIR . '/lib/classes/pjmt/Photoshop_IRB.php'); + include_once (LINPHA_DIR . '/lib/classes/pjmt/EXIF.php'); + include_once (LINPHA_DIR . '/lib/classes/pjmt/Photoshop_File_Info.php'); + + $GLOBALS["Software Name"] = "LinPHA v" . LINPHA_VERSION . ", powered by PHP JPEG Metadata Toolkit v" . $GLOBALS['Toolkit_Version']; + // Keywords should be an array - explode it on newline boundarys - $new_ps_file_info_array[ 'keywords' ] = explode( "\n", trim( $new_ps_file_info_array[ 'keywords' ] ) ); - + $new_ps_file_info_array['keywords'] = explode("\n", trim($new_ps_file_info_array['keywords'])); + // Supplemental Categories should be an array - explode it on newline boundarys - $new_ps_file_info_array[ 'supplementalcategories' ] = explode( "\n", trim( $new_ps_file_info_array[ 'supplementalcategories' ] ) ); - + $new_ps_file_info_array['supplementalcategories'] = explode("\n", trim($new_ps_file_info_array['supplementalcategories'])); + // Retrieve the header information - $jpeg_header_data = get_jpeg_header_data( $filename ); - + $jpeg_header_data = get_jpeg_header_data($filename); + // Retreive the EXIF, XMP and Photoshop IRB information from // the existing file, so that it can be updated... [truncated message content] |
From: <fan...@us...> - 2007-02-18 23:21:05
|
Revision: 4682 http://svn.sourceforge.net/linpha/?rev=4682&view=rev Author: fangehrn Date: 2007-02-18 15:21:00 -0800 (Sun, 18 Feb 2007) Log Message: ----------- 2007-02-19 flo * finished i18n - admin config - instructions (readme.txt and wiki) - i18n() and i18n_install() - editlang.php: update language files - installer: improved language support @todo check for outdated entries, handle modified entries somehow Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/settings_layout.php trunk/linpha2/install/footer.php trunk/linpha2/install/header.php trunk/linpha2/install/header_html.php trunk/linpha2/install/index.php trunk/linpha2/install/lib.install.php trunk/linpha2/install/manual_install.php trunk/linpha2/install/step10_postsettings.php trunk/linpha2/install/step11_finish.php trunk/linpha2/install/step1_license.php trunk/linpha2/install/step2_requirements.php trunk/linpha2/install/step3_dbtype.php trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step6_selectdatabase.php trunk/linpha2/install/step7_selectprefix.php trunk/linpha2/install/step8_testing.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/classes/linpha.class.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/lang/lang.German.php Added Paths: ----------- trunk/linpha2/docs/translations.txt trunk/linpha2/install/lang/lang.Example.php trunk/linpha2/install/lang/lang.German.php trunk/linpha2/lib/lang/editlang.php Removed Paths: ------------- trunk/linpha2/lib/lang/language.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/ChangeLog 2007-02-18 23:21:00 UTC (rev 4682) @@ -1,3 +1,14 @@ + +2007-02-19 flo + * finished i18n + - admin config + - instructions (readme.txt and wiki) + - i18n() and i18n_install() + - editlang.php: update language files + - installer: improved language support + + @todo check for outdated entries, handle modified entries somehow + 2007-02-15 bzrudi * Still MetaData mining ;-) Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/admin/settings_layout.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -75,6 +75,8 @@ 'sys_style_layout_title', 'sys_style_layout_template', 'sys_style_layout_theme', + 'sys_lang_autolang', + 'sys_lang', 'sys_style_layout_color_bodybg', 'sys_style_layout_color_elembg', 'sys_style_layout_color_font', @@ -88,8 +90,10 @@ $LinAdmin->printAdminConfig('select',$LinAdmin->getDescriptionByOptionName('sys_style_layout_template'),'sys_style_layout_template',$LinAdmin->option_value_system['sys_style_layout_template'],array('options' => LinAdmin::getTemplates())); $LinAdmin->printAdminConfig('select',$LinAdmin->getDescriptionByOptionName('sys_style_layout_theme'),'sys_style_layout_theme',$LinAdmin->option_value_system['sys_style_layout_theme'],array('options' => LinAdmin::getThemes($LinAdmin->option_value_system['sys_style_layout_template']))); + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_lang_autolang'),'sys_lang_autolang',$LinAdmin->option_value_system['sys_lang_autolang']); + $LinAdmin->printAdminConfig('select',$LinAdmin->getDescriptionByOptionName('sys_lang'),'sys_lang',$LinAdmin->option_value_system['sys_lang'],array('options' => linGetAvailableLanguageFiles( 'lib/lang', $withEnglish = true ) ) ); - echo '<h2 class="linStyle">'.i18n("Colors").'</h2>'; + echo '<br /><h2 class="linStyle">'.i18n("Colors").'</h2>'; ?> <script language="JavaScript" type="text/javascript"> function updateSelectBox(form_select) Added: trunk/linpha2/docs/translations.txt =================================================================== --- trunk/linpha2/docs/translations.txt (rev 0) +++ trunk/linpha2/docs/translations.txt 2007-02-18 23:21:00 UTC (rev 4682) @@ -0,0 +1,3 @@ + +Please see http://linpha.sourceforge.net/wiki/index.php/Translator_Instructions +for instructions how to create new and update existing language files. \ No newline at end of file Modified: trunk/linpha2/install/footer.php =================================================================== --- trunk/linpha2/install/footer.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/footer.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -27,7 +27,7 @@ <br /><br /> <div class="button button_next"> -<input type="submit" name ="next_button" value="Continue"<?php echo $show_next_button ? '' : ' disabled="disabled"'; ?>> +<input type="submit" name ="next_button" value="<?php echo i18n_install("Continue"); ?>"<?php echo $show_next_button ? '' : ' disabled="disabled"'; ?>> </div> </form> Modified: trunk/linpha2/install/header.php =================================================================== --- trunk/linpha2/install/header.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/header.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -24,28 +24,27 @@ * @package Installation */ -include_once(LINPHA_DIR."/install/lib.install.php"); +include_once(LINPHA_DIR.'/install/lib.install.php'); +include_once(LINPHA_DIR.'/lib/classes/linpha.filesys.class.php'); +include_once(LINPHA_DIR.'/lib/classes/linpha.functions.php'); - /** * language file */ + $lang = 'English'; + $folder = 'install/lang'; + $options = linGetAvailableLanguageFiles($folder); + if(isset($_SESSION['language'])) // come from install pages { /** * strict division from $_SESSION['language'] and include() !!! * make sure we don't have a include($_GET['language']) !!! */ - $array_langs = get_available_language_files(); - $key = array_search( $_SESSION['language'], $array_langs); - if( $key === false ) - { - $include_lang = 'English'; + $key = array_search( $_SESSION['language'], $options); + if( $key !== false ) { + $lang = $options[$key]; } - else - { - $include_lang = $array_langs[$key]; - } } elseif(isset($_POST['language'])) { @@ -53,33 +52,26 @@ * strict division from $_POST['language'] and include() !!! * make sure we don't have a include($_POST['language']) !!! */ - $array_langs = get_available_language_files(); - $key = @array_search( $_POST['language'], $array_langs); - if( $key === false ) - { - $include_lang = 'English'; - } - else - { - $include_lang = $array_langs[$key]; + $key = array_search( $_POST['language'], $options); + if( $key !== false ) { + $lang = $options[$key]; } } - elseif(isset($lang)) // step 1 (index.php) + else { - $include_lang = $lang; + $lang = linGetHttpAcceptLang($folder); } - else + + if( $lang && $lang!='English' && file_exists(LINPHA_DIR.'/'.$folder.'/lang.'.$lang.'.php') ) { - $include_lang = 'English'; - $_SESSION['language'] = "English"; + global $linTranslate; + $linTranslate=array(); + include_once( LINPHA_DIR.'/'.$folder.'/lang.'.$lang.'.php' ); } - if(file_exists(LINPHA_DIR."/install/lang/lang.".$include_lang.".php")) { - include_once(LINPHA_DIR."/install/lang/lang.".$include_lang.".php"); - } -$files = Array( +$files = array( "index.php", "step1_license.php", "step2_requirements.php", @@ -94,18 +86,18 @@ "step11_finish.php" ); -$title_str[0] = "Welcome"; -$title_str[1] = "Accept GPL"; -$title_str[2] = "Requirements Check"; -$title_str[3] = "Database Type"; -$title_str[4] = "Directories"; -$title_str[5] = "Database Login"; -$title_str[6] = "Select Database"; -$title_str[7] = "Select Prefix"; -$title_str[8] = "System Checks"; -$title_str[9] = "Database Tables"; -$title_str[10] = "Post Settings"; -$title_str[11] = "Finalizing"; +$title_str[0] = i18n_install("Welcome"); +$title_str[1] = i18n_install("Accept GPL"); +$title_str[2] = i18n_install("Requirements Check"); +$title_str[3] = i18n_install("Database Type"); +$title_str[4] = i18n_install("Directories"); +$title_str[5] = i18n_install("Database Login"); +$title_str[6] = i18n_install("Select Database"); +$title_str[7] = i18n_install("Select Prefix"); +$title_str[8] = i18n_install("System Checks"); +$title_str[9] = i18n_install("Database Tables"); +$title_str[10] = i18n_install("Post Settings"); +$title_str[11] = i18n_install("Finalizing"); if(! isset($is_special)) { @@ -156,7 +148,7 @@ } -if(isset($_GET ['reset'])) +if(isset($_GET['reset'])) { $_SESSION = array(); header("Location: index.php"); Modified: trunk/linpha2/install/header_html.php =================================================================== --- trunk/linpha2/install/header_html.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/header_html.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -28,7 +28,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="de"> <head> -<title><?php echo tr("LinPHA Web Installer"); echo "-". $title_str[$key]; ?></title> +<title><?php echo i18n_install("LinPHA Web Installer")." - ".$title_str[$key]; ?></title> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link rel="stylesheet" type="text/css" href="layout.css"> @@ -56,13 +56,13 @@ switch($i) { case 0: - echo tr("Welcome"); + echo i18n_install("Welcome"); break; case $end: - echo tr("Finish"); + echo i18n_install("Finish"); break; default: - echo tr("$title_str[$i]"); + echo $title_str[$i]; break; } echo "</div>"; @@ -75,7 +75,7 @@ <div class="button button_back"> <form method="POST" name="back_form" action="<?php echo $back_file; ?>"> -<input type="submit" name="submit_button" value="Back"<?php echo $show_back_button ? '' : ' disabled="disabled"'; ?>> +<input type="submit" name="submit_button" value="<?php echo i18n_install("Back"); ?>"<?php echo $show_back_button ? '' : ' disabled="disabled"'; ?>> </form> </div> @@ -83,7 +83,7 @@ </div> <div class="rightside"> -<h1><?php echo tr("$title_str[$key]"); ?></h1> +<h1><?php echo $title_str[$key]; ?></h1> <br /> <?php Modified: trunk/linpha2/install/index.php =================================================================== --- trunk/linpha2/install/index.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/index.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -25,38 +25,24 @@ if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','..'); } include_once(LINPHA_DIR.'/lib/include/common.php'); -include_once(LINPHA_DIR.'/install/lib.install.php'); - -/** - * autodetect language - */ -$http_accept_lang = get_http_accept_lang(); - -if( !empty($http_accept_lang) ) -{ - $lang = $http_accept_lang; -} else { - $lang = "English"; -} - include_once(LINPHA_DIR.'/install/header.php'); include_once(LINPHA_DIR.'/install/header_html.php'); -echo tr("Welcome To LinPHA2 Installation"); +echo i18n_install("Welcome To LinPHA2 Installation"); echo "<br /><br /><br />"; -echo tr("Please Select Your Preferred Language").":"; +echo i18n_install("Please Select Your Preferred Language"); echo "<br /><select name='language' size='1'>"; -$options = get_available_language_files(); +$options = linGetAvailableLanguageFiles('install/lang' , $withEnglish=true); if(is_array($options)) { /** * always include enable English */ -echo "<option value='English' selected='selected'>English</option>\n"; + //echo "<option value='English' selected='selected'>English</option>\n"; foreach($options AS $value) { Added: trunk/linpha2/install/lang/lang.Example.php =================================================================== --- trunk/linpha2/install/lang/lang.Example.php (rev 0) +++ trunk/linpha2/install/lang/lang.Example.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -0,0 +1,12 @@ +<?php + +$linTranslate = array( + + + +// paste new language entries here + + + +); +?> \ No newline at end of file Added: trunk/linpha2/install/lang/lang.German.php =================================================================== --- trunk/linpha2/install/lang/lang.German.php (rev 0) +++ trunk/linpha2/install/lang/lang.German.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -0,0 +1,12 @@ +<?php + +$linTranslate = array( + + + +// paste new language entries here + + + +); +?> \ No newline at end of file Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/lib.install.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -19,60 +19,11 @@ if(!defined('LINPHA_DIR')) { exit(1); } -/** - * Take care of translation - * - * This simple method takes care of all translation related stuff. - * If option tr_learn is set - all new entries will be autolearned. - * @param string $text phrase/word to translate - * @package Installation - */ - function tr($text) - { - global $translate; - $tr_learn = false; //autolearn new language entries - - /** - * translation starts here - */ - if(true == isset($translate[$text])) - { - $str = "$translate[$text]"; - } - else - { - $str = "$text"; - } +function i18n_install($text) +{ + return i18n($text); +} - /** - * autolearn new language entries defined by tr() function. - */ - if($tr_learn == true) - { - $tmpfile = LINPHA_DIR."/var/lang.install.temp.txt"; - - if(false == file_exists("$tmpfile")) - { - if(false == touch("$tmpfile")) - { - echo "Unable to create ".$tmpfile." - please check permissions"; - } - } - - $filedata = file("$tmpfile"); - - if(false == in_array($text."\n", $filedata)) - { - $filedata[] = $text."\n"; - natcasesort($filedata); // Sort an array using a case insensitive "natural order" algorithm - file_put_contents($tmpfile, $filedata); - } - } - - return $str; - -} // end tr() - function installGetPATH($array_path) { /** @@ -248,109 +199,6 @@ } /** - * return an array with all language files found in the folder 'lang' - */ -function get_available_language_files() -{ - $folder = installGetFullPath('install/lang'); - - $file_handle = opendir($folder); - $file = readdir($file_handle); - - //$options = array(); - while($file != false) - { - $explode = explode(".",$file); - - /* Only files that starts with 'lang.' are language files. */ - if($explode[0] == "lang") - { - $options[$explode[1]] = $explode[1]; - } - $file = readdir($file_handle); - } - - /* Sort language files aphabetically */ - if(@is_array($options)) - { - asort($options); - } - return @$options; -} - -function get_http_accept_lang() -{ - /*########################################################## -## used in: header.php/install.php -## The magic of language auto-detection -## This alows us to welcome users with their natural language if already available -## returns: -## language to use -##########################################################*/ - - $http_accept_language = trim($_SERVER["HTTP_ACCEPT_LANGUAGE"]); - // Accept-Language Header detail, see RFC2616 - $knownlangs = array( "" => "" ); - /* - "dk" => "Danish", - "nl" => "Dutch", - "en" => "English", - "de" => "German", - "de-ch" => "German", // for IE 6 - "de-at" => "German", // for IE 6 - "ja" => "Japanese", - "it" => "Italian", - "es" => "Spanish", - "co" => "Spanish", - "fr" => "French", - "no" => "Norwegian", - "pt" => "BrazilianPortuguese", - "br" => "BrazilianPortuguese", - "zh" => "zh-tw", - "tw" => "zh-tw", - "cz" => "Czech", - "cs" => "Czech", - "ro" => "Romanian", - "cn" => "zh-cn", - "se" => "Swedish", - "sv" => "Swedish", - "ru" => "Russian" ); - */ - -$accept_lang = 'English'; -$lastquality = 0.0; - -$langtag = '((?:[a-zA-Z]{1,8})(?:-[a-zA-Z]{1,8})*)'; -$qvalue ='(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3}))'; -$eachbit = '^' . $langtag . '(?:;q=' . $qvalue . ')?(?:,\s*)?(.*)$'; - -while(strlen($http_accept_language)) -{ - $m = Array(); // do not this directly in preg_match() ! - if(preg_match( "/$eachbit/", $http_accept_language, $m)) - { - $tag = $m[1]; - $quality = $m[2]; - - if(strlen($quality) == 0) $quality = 1; - $http_accept_language = $m[3]; - - if(array_key_exists($tag, $knownlangs) && $quality > $lastquality) - { - $accept_lang = $knownlangs[$tag]; - $lastquality = $quality; - } - } - else - { - break; - } -} - -return $accept_lang; -} - -/** * creates a random password */ function random_password($len) @@ -483,12 +331,12 @@ try { $init_ok = true; - echo "<h2>".tr("Checking Directory Permissions")."</h2><br />"; + echo "<h2>".i18n_install("Checking Directory Permissions")."</h2><br />"; /** * checking album directory */ - echo tr("Album Directory")."... "; + echo i18n_install("Album Directory")."... "; if( is_dir( $dirs['album'] ) ) { if( is_writable( $dirs['album'] ) ) @@ -500,22 +348,22 @@ { 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 "<br />".i18n_install("Album Directory Not Writable. Some Features May Not Work")."<br />"; } } else { - throw new Exception(failed_msg()."<br />".$_SESSION['album_dir']."<br />".tr("No Valid Directory Found")); + throw new Exception(failed_msg()."<br />".$_SESSION['album_dir']."<br />".i18n_install("No Valid Directory Found!")); } echo "<br /><br />"; - echo tr("Creating Required Directories")."... "; + echo i18n_install("Creating Required Directories...").' '; $array = array('sql','cache','tmp'); foreach($array AS $value) { - echo "<br /><br />".tr("Checking Directory").": ".$value."..."; + echo "<br /><br />".i18n_install("Checking Directory:")." ".$value."..."; if( file_exists( $dirs[$value] ) ) { @@ -526,35 +374,35 @@ if( $_SESSION[$value.'_dir'] == 'var/'.$value) { echo warning_msg(); - echo "<br />".tr("Directory Already Exists - Trying To Delete")."... "; + echo "<br />".i18n_install("Directory Already Exists - Trying To Delete...").' '; if( installRm_rf( $dirs[$value] ) ) { echo success_msg(); } else { - throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); + throw new Exception(failed_msg()."<br />".i18n_install("Please Delete Folder Manually!")); } } else { - throw new Exception(failed_msg()."<br />".tr("Directory Allready Exists, Please Delete Folder Manually")); + throw new Exception(failed_msg()."<br />".i18n_install("Directory Allready Exists, Please Delete Folder Manually!")); } } - echo "<br /> ".tr("Trying To Create Directory")."... "; + echo "<br /> ".i18n_install("Trying To Create Directory...").' '; if( installMkdir_p( $dirs[$value] ) ) { echo success_msg(); if( ! is_writable( $dirs[$value] ) ) { - echo "<br />".tr("No Write Permissions. Please Change Permissions Manually!"); + echo "<br />".i18n_install("No Write Permissions. Please Change Permissions Manually!"); } } else { - throw new Exception(failed_msg()."<br />".tr("Cannot create folder, please check permissions!")); + throw new Exception(failed_msg()."<br />".i18n_install("Cannot create folder, please check permissions!")); } echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.installLinRealpath( $dirs[$value] ).')<br />'; Modified: trunk/linpha2/install/manual_install.php =================================================================== --- trunk/linpha2/install/manual_install.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/manual_install.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -65,13 +65,13 @@ -echo "<h2>".tr("LinPHA Manual Install")."</h2>"; +echo "<h2>".i18n_install("LinPHA Manual Install")."</h2>"; ?> <br /> </form> <form method="POST" action="manual_install.php"> -<?php echo tr("Table Prefix").":"; ?> +<?php echo i18n_install("Table Prefix").":"; ?> <input type="text" name="sql_prefix" value="<?php echo $_SESSION['sql_prefix']; ?>"> <input type="submit" name="submit" value="Change"> </form> @@ -115,7 +115,7 @@ ?> <br /> -<?php echo tr("SQL Queries To Execute")."<br />"; ?> +<?php echo i18n_install("SQL Queries To Execute:")."<br />"; ?> <textarea style="width: 95%; " rows="8" wrap="off"><?php echo $str_query; ?></textarea> @@ -130,7 +130,7 @@ include_once(LINPHA_DIR.'/install/sql/config.dir.php'); ?> <br /><br /> -<?php echo tr("Folders To Create")."<br />"; ?> +<?php echo i18n_install("Folders To Create:")."<br />"; ?> <textarea style="width: 95%; " rows="3" wrap="off"> <?php echo $_SESSION['album_dir']."\n"; @@ -152,7 +152,7 @@ </textarea> <br /><br /> -<?php echo tr("Config File <b>sql/config.dir.php</b>")."<br />"; ?> +<?php echo i18n_install("LinPHA Config File")." <b>sql/config.dir.php</b><br />"; ?> <textarea style="width: 95%; " rows="3" wrap="off"><?php echo $str; ?></textarea> @@ -167,7 +167,7 @@ include_once(LINPHA_DIR.'/install/sql/config.sql.php'); ?> <br /><br /> -<?php echo tr("Database Connection File"); ?><b><?php echo $_SESSION['sql_dir']; ?>config.sql.php</b><br /> +<?php echo i18n_install("Database Connection File")." <b>".$_SESSION['sql_dir']."config.sql.php</b><br />"; ?> <textarea style="width: 95%; " rows="5" wrap="off"><?php echo $str; ?></textarea> Modified: trunk/linpha2/install/step10_postsettings.php =================================================================== --- trunk/linpha2/install/step10_postsettings.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step10_postsettings.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -43,7 +43,7 @@ include_once(LINPHA_DIR.'/install/header_html.php'); -echo tr("Connecting To Database")."... "; +echo i18n_install("Connecting To Database...").' '; unset($_SESSION['installmode1']); include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); @@ -57,22 +57,22 @@ * add new linpha admin user */ echo "<br /><br />"; -echo "<h2>".tr("Setup Linpha Admin User").".</h2>"; +echo "<h2>".i18n_install("Setup Linpha Admin User")."</h2>"; ?> <div class="boxalign"> -<?php echo tr("Admin Username").":"; ?> +<?php echo i18n_install("Admin Username").":"; ?> <input class="boxalignelement" type="text" id="check01" onKeyup="checkForm()" name="admin_name" value="root"> </div> <div class="boxalign"> -<?php echo tr("Admin Password").":"; ?> +<?php echo i18n_install("Admin Password").":"; ?> <input class="boxalignelement" type="password" id="check02" onKeyup="checkForm()" name="admin_pass"> </div> <div class="boxalign"> -<?php echo tr("Admin eMail").":"; ?> +<?php echo i18n_install("Admin eMail").":"; ?> <input class="boxalignelement" type="text" id="check03" onKeyup="checkForm()" name="admin_email"> </div> @@ -87,7 +87,7 @@ if(false === $data[0]) { - echo "<h2>".tr("Please Choose Thumbnail Quality")."</h2>"; + echo "<h2>".i18n_install("Please Choose Thumbnail Quality")."</h2>"; ?> <div align="center"> <div class="box2"> @@ -101,12 +101,12 @@ </div> </div> <?php - echo tr("Warning: High Quality Requires CPU > 1 GHz"); + echo i18n_install("Warning: High Quality Requires CPU > 1 GHz"); } ?> <br /><br /> <?php -echo "<h2>".tr("Please Choose Default Thumbnail Size")."</h2>"; +echo "<h2>".i18n_install("Please Choose Default Thumbnail Size")."</h2>"; ?> <div align="center"> Modified: trunk/linpha2/install/step11_finish.php =================================================================== --- trunk/linpha2/install/step11_finish.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step11_finish.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -45,9 +45,9 @@ if(isset($error_nr)) { - echo tr("Validating Information")."... "; + echo i18n_install("Validating Information...").' '; echo failed_msg(); - echo "<br />".tr("Please Fill In All Fields").""; + echo "<br />".i18n_install("Please Fill In All Fields"); echo "</form>"; $show_next_button = false; include_once(LINPHA_DIR.'/install/footer.php'); @@ -82,7 +82,7 @@ /** * save thumbnails default size */ -echo "<br />".tr("Saving Thumbnail Size To Database")."... "; +echo "<br />".i18n_install("Saving Thumbnail Size To Database...").' '; if( isset( $_POST['sys_style_tn_size'] ) ) { $result = $linpha->db->Execute("UPDATE ".LIN_PREFIX."config " . @@ -101,7 +101,7 @@ else { echo failed_msg(); - echo "<br />".tr("Error - No Value Specified")."!"; + echo "<br />".i18n_install("Error - No Value Specified!"); $error_nr = 1; } @@ -114,8 +114,8 @@ echo "<br /><br /><hr /><br />"; -echo "<h2>".tr("Congratulations")."</h2><br />"; -echo tr("Installation Finished")."!"; +echo "<h2>".i18n_install("Congratulations")."</h2><br />"; +echo i18n_install("Installation Finished!"); ?> <script language="JavaScript" type='text/javascript'> <!-- Modified: trunk/linpha2/install/step1_license.php =================================================================== --- trunk/linpha2/install/step1_license.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step1_license.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -32,7 +32,7 @@ <br /> <input type="hidden" name="language" value="<?php echo isset($_POST['language']) ? $_POST['language'] : ''; ?>"> <input type="checkbox" id="check01" onChange="checkForm()"> -<label for="check01"><?php echo tr("Please Accept The GNU General Public License"); ?></label> +<label for="check01"><?php echo i18n_install("Please Accept The GNU General Public License"); ?></label> <br /> <?php $array_check = array('check01' => 'checkbox'); Modified: trunk/linpha2/install/step2_requirements.php =================================================================== --- trunk/linpha2/install/step2_requirements.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step2_requirements.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -67,7 +67,7 @@ /** * checking php version */ - print_line_left("PHP Version"); + print_line_left( i18n_install("PHP Version") ); print_line_middle(PHP_VERSION); if(version_compare(PHP_VERSION, "5.0.0", ">=")) { @@ -76,7 +76,7 @@ else { print_line_right(failed_msg()); - print_line_info("PHP Version >= 5.0.0 is required"); + print_line_info( i18n_install("PHP Version >= 5.0.0 is required") ); $error = 1; } @@ -84,7 +84,7 @@ /** * check for supported databases */ - print_line_left("Supported Databases (MySQL, PostgreSQL, SQLite)"); + print_line_left( i18n_install("Supported Databases")." (MySQL, PostgreSQL, SQLite)" ); if(function_exists('mysql_connect')) { $supported_db['mysql'] = 1; } @@ -97,15 +97,14 @@ if(!isset($supported_db)) { - print_line_middle("NONE"); + print_line_middle( i18n_install("NONE") ); print_line_right(failed_msg()); - print_line_info("Enable at least support for one Database in " . - "your PHP configuration file (php.ini)"); + print_line_info( i18n_install("Enable at least support for one Database in your PHP configuration file (php.ini)") ); $error = 1; } else { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); $str = ""; @@ -113,7 +112,7 @@ { $str .= $key.' '; } - print_line_info("Supported Databases: ".$str); + print_line_info( i18n_install("Supported Databases:")." ".$str); } /** @@ -143,9 +142,7 @@ if($convert_version == "6.1.1" OR $convert_version == "6.1.2" OR $convert_version == "6.1.3") { print_line_right(warning_msg()); - print_line_info("ImageMagick Versions 6.1.1 to 6.1.3 contain a bug " . - "which makes it unusable. Please consider using another " . - "Version or make use of GD library"); + print_line_info( i18n_install("ImageMagick Versions 6.1.1 to 6.1.3 contain a bug which makes it unusable. Please consider using another Version or make use of GD library") ); } else { @@ -200,8 +197,7 @@ else { print_line_right(warning_msg()); - print_line_info("ImageMagick was NOT found on this server. " . - "This will result in lower quality thumbnails"); + print_line_info( i18n_install("ImageMagick was NOT found on this server. This will result in lower quality thumbnails") ); } @@ -211,32 +207,31 @@ */ if(! isset($convert_ok)) { - print_line_left("GD Library"); + print_line_left( i18n_install("GD Library") ); if(extension_loaded('gd')) { - print_line_middle("Installed"); + print_line_middle( i18n_install("Installed") ); print_line_right(success_msg()); } else { - print_line_middle("Not Found"); + print_line_middle( i18n_install("Not Found") ); print_line_right(failed_msg()); $error = 1; } - print_line_left("GD JPEG Support"); + print_line_left( i18n_install("GD JPEG Support") ); if(!function_exists('imagecreatefromjpeg') || !function_exists('imagejpeg')) { - print_line_middle("No"); + print_line_middle( i18n_install("No") ); print_line_right(failed_msg()); - print_line_info("Your GD Library lacks JPEG support, " . - "LinPHA will not support JPEG Images")."!"; + print_line_info( i18n_install("Your GD Library lacks JPEG support, LinPHA will not support JPEG Images!") ); $error = 1; } else { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); } } @@ -247,74 +242,70 @@ */ if( LIN_OS != "win" ) { - print_line_left("Posix Extension"); + print_line_left( i18n_install("Posix Extension") ); if(installCheckPosix()) { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); } else { - print_line_middle("No"); + print_line_middle( i18n_install("No") ); print_line_right(warning_msg()); - print_line_info("Missing POSIX Extension"); + print_line_info( i18n_install("Missing POSIX Extension") ); } } /** * checking safe mode */ - print_line_left("Safe Mode Activated"); + print_line_left( i18n_install("Safe Mode Activated") ); if(! ini_get('safe_mode')) { - print_line_middle("No"); + print_line_middle( i18n_install("No") ); print_line_right(success_msg()); } else { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(warning_msg()); - print_line_info("Safe mode is activated - Bad fun - " . - "Some things may not work as expected"); + print_line_info( i18n_install("Safe mode is activated - Bad fun - Some things may not work as expected") ); } /** * checking open basedir */ - print_line_left("Open Basedir Activated"); + print_line_left( i18n_install("Open Basedir Activated") ); $basedir_name=ini_get("open_basedir"); if(empty($basedir_name)) { - print_line_middle("No"); + print_line_middle( i18n_install("No") ); print_line_right(success_msg()); } else { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(warning_msg()); - print_line_info("Open Basedir restrictions in effekt - " . - "Some things may not work as expected"); + print_line_info( i18n_install("Open Basedir restrictions activated - Some things may not work as expected") ); } /** * memory limit */ - print_line_left("PHP Memory limit"); + print_line_left( i18n_install("PHP Memory limit") ); $limit = installGetMemLimit(); if($limit === false) { - print_line_middle("Unlimited"); + print_line_middle( i18n_install("Unlimited") ); print_line_right(success_msg()); } elseif($limit <= 12) { print_line_middle($limit.' MB'); print_line_right(warning_msg()); - print_line_info("Your PHP memory limit is probably to low. If you " . - "encounter problems with creating thumbnails, try to increase " . - "the memory_limit in php.ini or resize your pictures to a " . - "lower resolution and try again."); + print_line_info( i18n_install("Your PHP memory limit is probably to low. If you encounter problems with creating thumbnails, try to increase the memory_limit in php.ini or resize your pictures to a lower resolution before uploading and then try again.") ); + // do not break the line above!! } else { @@ -325,81 +316,89 @@ /** * checking session variables */ - print_line_left("Session Save Path Set Correctly"); + print_line_left( i18n_install("Session Save Path Set Correctly") ); $session_path=session_save_path(); if(!empty($session_path)) { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); - print_line_info("Session Save Path set to: ".$session_path); + print_line_info( sprintf(i18n_install("Session Save Path set to: %s"),$session_path) ); } else { - print_line_middle("No"); + print_line_middle( i18n_install("No") ); print_line_right(warning_msg()); - print_line_info("Session Save Path not set - Please set in " . - "php.ini first."); + print_line_info( i18n_install("Session Save Path not set - Please set in php.ini first.") ); } - print_line_left("Session Save Handler Set Correctly"); + print_line_left( i18n_install("Session Save Handler Set Correctly") ); $session_save_handler = strtolower(ini_get('session.save_handler')); if($session_save_handler == 'files') { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); } else { - print_line_middle("No"); + print_line_middle( i18n_install("No") ); print_line_right(failed_msg()); - print_line_info("Session save handler NOT set correctly.<br />". - "Open php.ini and change session.save_handler value " . - "to \"files\""); + print_line_info( + i18n_install("Session save handler NOT set correctly.")."<br />". + i18n_install("Open php.ini and change session.save_handler value to \"files\"") + ); } /** * checking file permissions */ - print_line_left("File Permissions Set Correctly"); + print_line_left( i18n_install("File Permissions Set Correctly") ); - if( is_writable(LINPHA_DIR.'/var') ) + if( is_writable(LINPHA_DIR.'/var') ) // this check may not work correctly under windows! { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); } else { - print_line_middle("No"); + print_line_middle( i18n_install("No") ); print_line_right(failed_msg()); - print_line_info("Please make sure the directory /linpha/var/ is writeable"); - + print_line_info( sprintf(i18n_install("Please make sure the directory %s is writeable!"),'/linpha/var/') ); $error = 1; } /** * checking album and var folder are protected from outside */ - print_line_left("Album And System Folder Protected From Outside"); + print_line_left( i18n_install("Album And System Folder Protected From Outside") ); $ret = installCheckProtectedFromOutside(); if( $ret == 1 ) { - print_line_middle("Yes"); + print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); - print_line_info("The /albums and /var folders are protected from outside. See <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details."); + print_line_info( + i18n_install("The /albums and /var folders are protected from outside."). + i18n_install("Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details.") + ); } elseif( $ret == 2 ) { - print_line_middle("No"); + print_line_middle( i18n_install("No") ); print_line_right(warning_msg()); - print_line_info("The /albums and /var folders are not protected from outside! Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details."); + print_line_info( + i18n_install("The /albums and /var folders are not protected from outside!"). + i18n_install("Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details.") + ); } elseif( $ret == 3 ) { - print_line_middle("Unknown"); + print_line_middle( i18n_install("Unknown") ); print_line_right(warning_msg()); - print_line_info("Cannot determine wether the /albums and /var folders are protected from outside! Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details."); + print_line_info( + i18n_install("Cannot determine wether the /albums and /var folders are protected from outside!"). + i18n_install("Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details.") + ); } @@ -409,11 +408,11 @@ print_foot(); echo "<br />"; -echo tr("For more detailed info - Please click on the status info text above")."<br />"; +echo i18n_install("For more detailed info - Please click on the status info text above")."<br />"; ?> <a href="#" onclick="show_hide_tables('',<?php echo $table_lines; ?>)"> -(<?php echo tr("Show All Information"); ?></a>). +(<?php echo i18n_install("Show All Information"); ?></a>). <script language="JavaScript" type='text/javascript'> <!-- @@ -430,8 +429,8 @@ if(isset($error)) { - echo "<h2>".tr("!!! INSTALLATION ABORTED !!!")."</h2><br />"; - echo tr("There was at least one serious error - continue at your own risk"); + echo "<h2>".i18n_install("!!! INSTALLATION ABORTED !!!")."</h2><br />"; + echo i18n_install("There was at least one serious error - continue at your own risk"); echo "<br /><br />"; } @@ -445,8 +444,8 @@ <table width="95%"> <tr> <td> </td> - <td><?php echo tr("Result"); ?></td> - <td><?php echo tr("Status"); ?></td> + <td><?php echo i18n_install("Result"); ?></td> + <td><?php echo i18n_install("Status"); ?></td> </tr> <?php } @@ -456,14 +455,14 @@ $GLOBALS['table_lines']++; ?> <tr> - <td style="text-align: left;"><?php echo tr("$str"); ?></td> + <td style="text-align: left;"><?php echo $str; ?></td> <?php } function print_line_middle($str) { ?> - <td width="50"><?php echo tr("$str"); ?></td> + <td width="50"><?php echo $str; ?></td> <?php } @@ -471,7 +470,7 @@ { ?> <td width="50"><a href="#" onclick="switch_visibility(<?php echo $GLOBALS['table_lines']; ?>)"><?php - echo tr("$str"); ?></a></td> + echo $str; ?></a></td> </tr> <?php } @@ -481,7 +480,7 @@ ?> <tr id="table_line_<?php echo $GLOBALS['table_lines']; ?>" style="display:"> <td colspan="3" style="text-align: left; border-left: none; border-right: none; border-bottom: none; "> - <?php echo tr("$str"); ?><br /><br /></td> + <?php echo $str; ?><br /><br /></td> </tr> <?php } Modified: trunk/linpha2/install/step3_dbtype.php =================================================================== --- trunk/linpha2/install/step3_dbtype.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step3_dbtype.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -98,7 +98,7 @@ if(!function_exists($value)) { - echo '<b>'.tr("No Support In PHP Config (php.ini)").'</b><br />'; + echo '<b>'.i18n_install("No Support In PHP Config (php.ini)").'</b><br />'; } echo '<br />'."\n\n"; @@ -106,13 +106,13 @@ ?> <br /><br /> -<h1><?php echo tr("Select Installation Mode"); ?></h1> +<h1><?php echo i18n_install("Select Installation Mode"); ?></h1> <br /> <input type='radio' name='install_mode' value='automatic' checked="checked"> -<?php echo tr("Automatic mode"); ?> +<?php echo i18n_install("Automatic mode"); ?> <br /><br /> <input type='radio' name='install_mode' value='manual'> -<?php echo tr("Manual Mode (Experts Only)"); ?> +<?php echo i18n_install("Manual Mode (Experts Only)"); ?> <?php include_once(LINPHA_DIR.'/install/footer.php'); Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step4_selectdirectories.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -66,7 +66,7 @@ ?> <div class="boxalign"> -<?php echo tr("Album Directory").":"; ?> +<?php echo i18n_install("Album Directory").":"; ?> <input class="boxalignelement" type="text" id="check01" onKeyup="checkForm()" name="album_dir" size="30" value="<?php echo $album_dir; ?>"> </div> @@ -74,11 +74,11 @@ <br /><br /> <br /> -<h2 style="color: red;"><?php echo tr("Warning: All directories below will be deleted if they exists !!"); ?></h2> +<h2 style="color: red;"><?php echo i18n_install("Warning: All directories below will be deleted if they exists !!"); ?></h2> <br /> <div class="boxalign"> -<?php echo tr("Sql Directory").":"; ?> +<?php echo i18n_install("Sql Directory").":"; ?> <input class="boxalignelement" type="text" id="check02" onKeyup="checkForm()" name="sql_dir" size="30" value="<?php echo $sql_dir; ?>"> </div> @@ -86,7 +86,7 @@ <br /><br /> <div class="boxalign"> -<?php echo tr("Cache Directory").":"; ?> +<?php echo i18n_install("Cache Directory").":"; ?> <input class="boxalignelement" type="text" id="check03" onKeyup="checkForm()" name="cache_dir" size="30" value="<?php echo $cache_dir; ?>"> </div> @@ -94,7 +94,7 @@ <br /><br /> <div class="boxalign"> -<?php echo tr("Temp Directory").":"; ?> +<?php echo i18n_install("Temp Directory").":"; ?> <input class="boxalignelement" type="text" id="check04" onKeyup="checkForm()" name="tmp_dir" size="30" value="<?php echo $tmp_dir; ?>"> </div> Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step5_getlogin.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -38,9 +38,9 @@ { include_once(LINPHA_DIR.'/install/header_html.php'); - echo tr("Validating Information")."... "; + echo i18n_install("Validating Information...").' '; echo failed_msg(); - echo "<br />".tr("Please Fill In All Fields").""; + echo "<br />".i18n_install("Please Fill In All Fields").""; echo "</form>"; $show_next_button = false; @@ -84,54 +84,52 @@ ?> <br /><br /> <hr /> -<h1><?php echo tr("$title_str[$key]"); ?></h1> +<h1><?php echo $title_str[$key]; ?></h1> <br /> <?php if($_SESSION['sql_dbtype'] == 'mysql') { - echo tr("NOTE: If you have setup a root Password for your MySQL Database " . - "please login using your root account.")."<br /><br />"; + echo i18n_install("NOTE: If you have setup a root Password for your MySQL Database please login using your root account."); + echo "<br /><br />"; $_SESSION['sql_dbport'] = '3306'; } elseif($_SESSION['sql_dbtype'] == 'postgres') { - echo tr("NOTE: There is currently now way to let LinPHA create the required " . - "Database, so you have to create a new Database using \"createdb\" " . - "from commandline before you proceed.")."<br /><br />"; + echo i18n_install("NOTE: There is currently now way to let LinPHA create the required Database, so you have to create a new Database using \"createdb\" from commandline before you proceed."); + echo "<br /><br />"; $_SESSION['sql_dbport'] = '5432'; } elseif($_SESSION['sql_dbtype'] == 'oci8po') { - echo tr("NOTE: Oracle support is only testet on XE the \"Free\" Edition. " . - "If you get things running using a \"real\" Oracle Database please " . - "drop us a note!")."<br /><br />"; + echo i18n_install("NOTE: Oracle support is only testet on XE the \"Free\" Edition. If you get things running using a \"real\" Oracle Database please drop us a note!"); + echo "<br /><br />"; $_SESSION['sql_dbport'] = '1521'; } ?> <div class="boxalign"> -<?php echo tr("Username").":"; ?> +<?php echo i18n_install("Username").":"; ?> <input class="boxalignelement" type="text" id="check01" onKeyup="checkForm()" name="sql_username" value="<?php echo isset($_SESSION['sql_username']) ? $_SESSION['sql_username'] : 'root' ; ?>"> <br /> </div> <div class="boxalign"> -<?php echo tr("Password").":"; ?> +<?php echo i18n_install("Password").":"; ?> <input class="boxalignelement" type="password" id="check02" onKeyup="checkForm()" name="sql_password"> <br /> </div> <div class="boxalign"> -<?php echo tr("Hostname").":"; ?> +<?php echo i18n_install("Hostname").":"; ?> <input class="boxalignelement" type="text" id="check03" onKeyup="checkForm()" name="sql_hostname" value="<?php echo isset($_SESSION['sql_hostname']) ? $_SESSION['sql_hostname'] : 'localhost' ; ?>"> </div> <div class="boxalign"> -<?php echo tr("Port").":"; ?> +<?php echo i18n_install("Port").":"; ?> <input class="boxalignelement" type="text" id="check04" onKeyup="checkForm()" name="sql_dbport" value="<?php echo isset($_SESSION['sql_dbport']) ? $_SESSION['sql_dbport'] : '3306' ; ?>"> Modified: trunk/linpha2/install/step6_selectdatabase.php =================================================================== --- trunk/linpha2/install/step6_selectdatabase.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step6_selectdatabase.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -49,9 +49,9 @@ if(empty($_SESSION['sql_hostname']) OR empty($_SESSION['sql_username']) OR empty($_SESSION['sql_dbport'])) { - echo tr("Validating Information")."... "; + echo i18n_install("Validating Information...").' '; echo failed_msg(); - echo "<br />".tr("Please Fill In All Fields").""; + echo "<br />".i18n_install("Please Fill In All Fields"); echo "</form>"; $show_next_button = false; @@ -63,15 +63,15 @@ switch($_SESSION['sql_dbtype']) { case "mysql": - echo tr("Testing Server Connection")."<br /><br />"; - echo tr("Connecting MySQL-Server")."... "; + echo i18n_install("Testing Server Connection")."<br /><br />"; + echo i18n_install("Connecting MySQL-Server..."); $link = @mysql_connect($_SESSION['sql_hostname'].":".$_SESSION['sql_dbport'], $_SESSION['sql_username'], $_SESSION['sql_password']); if (!$link) { echo failed_msg(); - echo "<br />".tr("Error Connecting To Server").": ".mysql_error().""; + echo "<br />".i18n_install("Error Connecting To Server").": ".mysql_error().""; $error_nr = 2; } else @@ -164,20 +164,20 @@ $checked_dontcreate = ''; } - echo tr("You Are Allowed To Create A New Database (Recommended)"); + echo i18n_install("You Are Allowed To Create A New Database (Recommended)"); ?> <br /> <input type="radio" id="radio_db1" name="create_database" value="create"<?php echo $checked_create; ?>> - <?php echo tr("New Database Name").": "; ?> + <?php echo i18n_install("New Database Name").": "; ?> <input type="text" name="sql_dbname_create" value="<?php echo isset($_SESSION['sql_dbname']) ? $_SESSION['sql_dbname'] : $dbname ; ?>" onKeyup="document.getElementById('radio_db1').checked = true;"> <br /><br /> - <?php echo tr("Or").","; ?><br /> + <?php echo i18n_install("Or").","; ?><br /> <input type="radio" id="radio_db2" name="create_database" value="false"<?php echo $checked_dontcreate; ?>> <?php @@ -185,7 +185,7 @@ if(isset($databases)) { - echo tr("Install Into Existing Database").": "; + echo i18n_install("Install Into Existing Database:").' '; ?> <br /> <select name="sql_dbname_installinto"<?php @@ -216,13 +216,14 @@ { if($_SESSION['sql_dbtype'] == 'oci8po') { - echo tr("Name Of Database To Use, this is usually \"XE\" For Oracle Express Edition"); + echo i18n_install("Name Of Database To Use, this is usually \"XE\" For Oracle Express Edition:"); } else { - echo tr("Name Of Database To Use (Must Exist)").":<br />"; + echo i18n_install("Name Of Database To Use (Must Allready Exist):"); } ?> + <br /> <input type="text" name="sql_dbname_installinto" value="<?php echo isset($_SESSION['sql_dbname']) ? $_SESSION['sql_dbname'] : '' ; ?>"> Modified: trunk/linpha2/install/step7_selectprefix.php =================================================================== --- trunk/linpha2/install/step7_selectprefix.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step7_selectprefix.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -56,9 +56,9 @@ */ if( empty($_SESSION['sql_dbname']) ) { - echo tr("Validating Information")."... "; + echo i18n_install("Validating Information...").' '; echo failed_msg(); - echo "<br />".tr("Please Fill In All Fields").""; + echo "<br />".i18n_install("Please Fill In All Fields"); echo "</form>"; $show_next_button = false; include_once(LINPHA_DIR.'/install/footer.php'); @@ -68,14 +68,14 @@ switch($_SESSION['sql_dbtype']) { case "mysql": - echo "<h2>".tr("Checking Database")."</h2><br />"; + echo "<h2>".i18n_install("Checking Database")."</h2><br />"; $link = @mysql_connect($_SESSION['sql_hostname'].":".$_SESSION['sql_dbport'], $_SESSION['sql_username'], $_SESSION['sql_password']); if(isset($_POST['create_database']) && $_POST['create_database'] == "create") { - echo tr("Creating Database")."... "; + echo i18n_install("Creating Database...").' '; $result = @mysql_query("CREATE database ".$_SESSION['sql_dbname']); if($result) @@ -93,12 +93,12 @@ if(!isset($error_nr)) { - echo "<br />".tr("Selecting Database").". ".$_SESSION['sql_dbname'].'... '; + echo "<br />".i18n_install("Selecting Database").' '.$_SESSION['sql_dbname'].'... '; $db_selected = @mysql_select_db($_SESSION['sql_dbname'], $link); if (!$db_selected) { echo failed_msg(); - echo "<br />".tr("Failed Opening Database").". ".$_SESSION['sql_dbname'].": " . mysql_error() . "<br />"; + echo "<br />".i18n_install("Failed Opening Database").' '.$_SESSION['sql_dbname'].": " . mysql_error() . "<br />"; $error_nr = 3; } else @@ -109,8 +109,8 @@ break; case "postgres": - echo tr("Testing Server Connection")."<br /><br />"; - echo tr("Connecting PostgreSQL-Server")."... "; + echo i18n_install("Testing Server Connection")."<br /><br />"; + echo i18n_install("Connecting PostgreSQL-Server...").' '; $link = pg_connect("host=".$_SESSION['sql_hostname']." " . "port=".$_SESSION['sql_dbport']." " . @@ -121,7 +121,7 @@ if (!$link) { echo failed_msg(); - echo "<br />".tr("Error Connecting To Server").": ".pg_last_error($link); + echo "<br />".i18n_install("Error Connecting To Server").": ".pg_last_error($link); $error_nr = 2; } else @@ -142,13 +142,13 @@ exit(); } - echo tr("Testing File Connection")."<br /><br />"; - echo tr("Connecting SQLite Database")."... "; + echo i18n_install("Testing File Connection")."<br /><br />"; + echo i18n_install("Connecting SQLite Database...").' '; if(file_exists(LINPHA_DIR.'/'.$_SESSION['sql_dir'].'/'.$_SESSION['sql_dbname'])) { echo failed_msg(); - echo "<br />".tr("Database Already Exists, Delete The File ".$_SESSION['sql_dbname']." first!").""; + echo "<br />".sprintf( i18n_install("Database Already Exists, Delete First The File %s!"),$_SESSION['sql_dbname'] ); $error_nr = 3; } else @@ -165,14 +165,14 @@ else { echo failed_msg(); - echo "<br />".tr("Failed To Create Database").": ".$sqliteerror; + echo "<br />".i18n_install("Failed To Create Database").": ".$sqliteerror; $error_nr = 3; } } break; case "oci8po": - echo tr("Testing Server Connection")."<br /><br />"; - echo tr("Connecting ORACLE-Server")."... "; + echo i18n_install("Testing Server Connection")."<br /><br />"; + echo i18n_install("Connecting ORACLE-Server...").' '; /** * make already use of ADBDO as native oci_connet() sucks */ @@ -182,7 +182,7 @@ if (!$link) { echo failed_msg(); - echo "<br />".tr("Error Connecting To Server").":"; + echo "<br />".i18n_install("Error Connecting To Server").":"; $error_nr = 2; } else @@ -214,7 +214,7 @@ <br /><br /> <hr> <br /> - <?php echo tr("Please Enter Database Prefix For Linpha Tables (Default: linpha_)").": <br />" ?> + <?php echo i18n_install("Please Enter Database Prefix For Linpha Tables (Default: linpha_)").": <br />" ?> <input type="text" id="check01" onKeyup="checkForm()" name="sql_prefix" value="<?php echo isset($_SESSION['sql_prefix']) ? $_SESSION['sql_prefix'] : 'linpha_' ; ?>"> Modified: trunk/linpha2/install/step8_testing.php =================================================================== --- trunk/linpha2/install/step8_testing.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step8_testing.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -48,9 +48,9 @@ */ if( empty($_SESSION['sql_prefix']) ) { - echo tr("Validating Information")."... "; + echo i18n_install("Validating Information...").' '; echo failed_msg(); - echo "<br />".tr("Please Fill In All Fields").""; + echo "<br />".i18n_install("Please Fill In All Fields"); echo "</form>"; $show_next_button = false; include_once(LINPHA_DIR.'/install/footer.php'); @@ -61,7 +61,7 @@ * switching to AdoDB * connect to db and check if connection was succesfull */ - echo tr("Switching To AdoDB")."... "; + echo i18n_install("Switching To AdoDB...").' '; $_SESSION['installmode1'] = true; $_SESSION['installmode2'] = true; @@ -81,16 +81,16 @@ if($_SESSION['sql_dbtype'] != "sqlite") { ?> - <h2><?php echo tr("Checking Table Prefix"); ?></h2><br /> + <h2><?php echo i18n_install("Checking Table Prefix"); ?></h2><br /> - <?php echo tr("Checking For Existing Tables")."... "; ?> + <?php echo i18n_install("Checking For Existing Tables...").' '; ?> <?php $array_tables = $linpha->db->MetaTables(); if (! isset($array_tables) OR ! is_array($array_tables)) { echo failed_msg(); - echo "<br />".tr("Cannot Read Tables").": ".mysql_error(); + echo "<br />".i18n_install("Cannot Read Tables").": ".mysql_error(); $error_nr = 2; } else @@ -110,7 +110,7 @@ if(isset($result) && is_array($result) && (count($result) > 0) ) { echo failed_msg(); - echo "<br />".tr("Table Prefix Already Exists, Please Choose Another One").".!"; + echo "<br />".i18n_install("Table Prefix Already Exists, Please Choose Another One!"); echo "</form>"; $show_next_button = false; include_once(LINPHA_DIR.'/install/footer.php'); @@ -130,7 +130,7 @@ $n_runs = 1; if($_SESSION['sql_dbtype'] == "mysql") { - echo tr("Trying To Create New LinPHA Database User")."... "; + echo i18n_install("Trying To Create New LinPHA Database User...").' '; $random_pass = random_password(8); $random_user = "linpha_".random_password(4); @@ -145,18 +145,18 @@ "IDENTIFIED BY '".$random_pass."' WITH GRANT OPTION") ) { echo warning_msg(); - echo "<br />".tr("Failed To Create New LinPHA User"); - echo "<br />".tr("Seems you are not allowed to create new Database users - " . - "using given defaults (NOTE: Installation should still work)")."... "; + echo "<br />".i18n_install("Failed To Create New LinPHA User"); + echo "<br />".i18n_install("Seems you are not allowed to create new Database users using given defaults."); + echo ' ('.i18n_install("NOTE: Installation should still work").')'; } else { if(! $linpha->db->Execute("FLUSH PRIVILEGES") ) { echo warning_msg(); - echo "<br />".tr("Failed To Create New LinPHA User"); - echo "<br />".tr("Seems you are not allowed to create new Database users - " . - "using given defaults (NOTE: Installation should still work)")."... "; + echo "<br />".i18n_install("Failed To Create New LinPHA User"); + echo "<br />".i18n_install("Seems you are not allowed to create new Database users using given defaults."); + echo ' ('.i18n_install("NOTE: Installation should still work").')'; } else { @@ -167,9 +167,9 @@ if(! $test_conn->Connect($_SESSION['sql_hostname'].":".$_SESSION['sql_dbport'], $random_user, $random_pass, $_SESSION['sql_dbname']) ) { echo warning_msg(); - echo "<br />".tr("Failed To Create New LinPHA User"); - echo "<br />".tr("Seems you are not allowed to create new Database users - " . - "using given defaults (NOTE: Installation should still work)")."... "; + echo "<br />".i18n_install("Failed To Create New LinPHA User"); + echo "<br />".i18n_install("Seems you are not allowed to create new Database users using given defaults."); + echo ' ('.i18n_install("NOTE: Installation should still work").')'; } else { @@ -203,7 +203,7 @@ */ if($i == 2) { - echo "<br /><br />".tr("User Created, Now Running Tests")."...<br /><br />"; + echo "<br /><br />".i18n_install("User Created, Now Running Tests...")."<br /><br />"; $orig_conn = $linpha->db; $linpha->db = $test_conn; } @@ -211,10 +211,10 @@ /** * Test table stuff */ - echo "<h2>".tr("Testing Tables")."</h2>"; + echo "<h2>".i18n_install("Testing Tables")."</h2>"; $table_name = $_SESSION['sql_prefix']."test".time(); - echo "<br />".tr("Running Tests").": "; + echo "<br />".i18n_install("Running Tests").": "; $array_tests = array( "CREATE" => "CREATE TABLE ".$table_name." ( id INT NOT NULL )", @@ -290,14 +290,14 @@ /** * skip tests for sqlite */ - echo tr("Skipping Database Tests"); + echo i18n_install("Skipping Database Tests"); } /** * new user failed, use old connection */ if(isset($use_other_conn)) { - echo "<br /><br /><b>".tr("New User Tests Failed, Falling Back")."...</b>"; + echo "<br /><br /><b>".i18n_install("New User Tests Failed, Falling Back...")."</b>"; $linpha->db = $orig_conn; } elseif($n_runs == 2) Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2007-02-16 15:13:33 UTC (rev 4681) +++ trunk/linpha2/install/step9_createtables.php 2007-02-18 23:21:00 UTC (rev 4682) @@ -57,7 +57,7 @@ /** * finally create tables */ - echo tr("Creating Tables")."... "; + echo i18n_install("Creating Tables...").' '; $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) @@ -72,11 +72,11 @@ } } /** - * take care of oracle seqeunces and triggers + * take care of oracle sequences and triggers */ if($_SESSION['sql_dbtype'] == 'oci8po') { - echo tr("Creating Sequences")."...<br /> "; + echo i18n_install("Creating Sequences...")."<br /> "; /** * create sequences @@ -86,8 +86,8 @@ $result = $linpha->db->Execute($query); if(!$result) { - echo tr("Failed To Create Sequence for [$key]."); echo failed_msg(); + echo sprintf( i18n_install("Failed To Create Sequence for [%s]",$key) ); echo ' '.$linpha->db->ErrorMsg().'<br />'; $error_nr = 1; } @@ -96,14 +96,14 @@ /** * create triggers */ - echo tr("Creating Triggers")."...<br /> "; + echo i18n_install("Creating Triggers...")."<br /> "; while( list($key, $query) = each($sql_trigger) ) { $result = $linpha->db->Execute($query); if(!$result) { - echo tr("Failed To Create Trigger for [$key]."); echo failed_msg(); + echo sprintf( i18n_install("Failed To Create Trigger for [%s]",$key) ); echo ' '.$linpha->db->ErrorMsg().'<br />'; $error_nr = 1; } @@ -124,7 +124,7 @@ /** * insert data */ - echo "<br /><br />".tr("Inserting Table Data")."... "; + echo "<br /><br />".i18n_install("Inserting Table Data...").' '; include_once(LINPHA_DIR.'/install/sql/sql.data.php'); foreach($sql_queries AS $value) { @@ -154,7 +154,7 @@ /** * create cache directories */ - echo "<br /><br />".tr("Creating Cache Directories")."... "; + echo "<br /><br />".i18n_install("Creating Cache Directories...").' '; mkdir(installGetFullPath( $_SESSION['cache_dir'] ).'/img', 0700); mkdir(installGetFullPath( $_SESSION['cache_dir'] ).'/thumb', 0700); @@ -166,7 +166,7 @@ /** * create config.dir.php file */ - echo "<br /><br />".tr("Writing config.dir.php File")."... "; + echo "<br /><br />".sprintf( i18n_install("Creating... [truncated message content] |
From: <fan...@us...> - 2007-02-18 23:23:47
|
Revision: 4683 http://svn.sourceforge.net/linpha/?rev=4683&view=rev Author: fangehrn Date: 2007-02-18 15:23:43 -0800 (Sun, 18 Feb 2007) Log Message: ----------- 2007-02-19 flo * .htaccess added .htaccess files to albums/ and var/ i thought they were already there...? Modified Paths: -------------- trunk/linpha2/ChangeLog Added Paths: ----------- trunk/linpha2/albums/.htaccess trunk/linpha2/var/.htaccess Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-02-18 23:21:00 UTC (rev 4682) +++ trunk/linpha2/ChangeLog 2007-02-18 23:23:43 UTC (rev 4683) @@ -9,6 +9,10 @@ @todo check for outdated entries, handle modified entries somehow + * .htaccess + added .htaccess files to albums/ and var/ + i thought they were already there...? + 2007-02-15 bzrudi * Still MetaData mining ;-) Added: trunk/linpha2/albums/.htaccess =================================================================== --- trunk/linpha2/albums/.htaccess (rev 0) +++ trunk/linpha2/albums/.htaccess 2007-02-18 23:23:43 UTC (rev 4683) @@ -0,0 +1 @@ +Deny from all \ No newline at end of file Added: trunk/linpha2/var/.htaccess =================================================================== --- trunk/linpha2/var/.htaccess (rev 0) +++ trunk/linpha2/var/.htaccess 2007-02-18 23:23:43 UTC (rev 4683) @@ -0,0 +1 @@ +Deny from all \ 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...> - 2007-02-20 19:31:31
|
Revision: 4684 http://svn.sourceforge.net/linpha/?rev=4684&view=rev Author: fangehrn Date: 2007-02-20 11:31:26 -0800 (Tue, 20 Feb 2007) Log Message: ----------- 2007-02-20 flo * i18n - added check for outdated strings - there is no need for checking modified entries because every changed entries will cause a new entry ;-) - gone through all 928 i18n calls and fixed a lot... Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/index.php trunk/linpha2/admin/maintenance.php trunk/linpha2/admin/metadata.php trunk/linpha2/admin/metadata_define.php trunk/linpha2/admin/metadata_select.php trunk/linpha2/admin/permissions.php trunk/linpha2/admin/permissions_others.php trunk/linpha2/admin/settings.php trunk/linpha2/admin/settings_features.php trunk/linpha2/admin/settings_layout.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/install/step2_requirements.php trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.template.class.php trunk/linpha2/lib/include/metadata_info_show.php trunk/linpha2/lib/lang/editlang.php trunk/linpha2/lib/modules/module.filemanager.php trunk/linpha2/templates/default/home.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/ChangeLog 2007-02-20 19:31:26 UTC (rev 4684) @@ -1,4 +1,11 @@ +2007-02-20 flo + * i18n + - added check for outdated strings + - there is no need for checking modified entries + because every changed entries will cause a new entry ;-) + - gone through all 928 i18n calls and fixed a lot... + 2007-02-19 flo * finished i18n - admin config @@ -7,8 +14,6 @@ - editlang.php: update language files - installer: improved language support - @todo check for outdated entries, handle modified entries somehow - * .htaccess added .htaccess files to albums/ and var/ i thought they were already there...? Modified: trunk/linpha2/admin/index.php =================================================================== --- trunk/linpha2/admin/index.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/index.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -65,12 +65,11 @@ ?> <?php -$array_menu = Array( - //'linpha_home' => Array('name' => 'Linpha Home', 'link' => 'linpha_home'), - 'settings' => Array('name' => 'Settings', 'link' => 'settings'), - 'permissions' => Array('name' => 'Permissions', 'link' => 'permissions'), - 'maintenance' => Array('name' => 'Maintenance', 'link' => 'maintenance'), - 'metadata' => Array('name' => 'MetaData', 'link' => 'metadata'), +$array_menu = array( + 'settings' => array('name' => i18n("Settings"), 'link' => 'settings'), + 'permissions' => array('name' => i18n("Permissions"), 'link' => 'permissions'), + 'maintenance' => array('name' => i18n("Maintenance"), 'link' => 'maintenance'), + 'metadata' => array('name' => i18n("MetaData"), 'link' => 'metadata'), ); LinAdmin::printAdminMenu($array_menu,$cat1); Modified: trunk/linpha2/admin/maintenance.php =================================================================== --- trunk/linpha2/admin/maintenance.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/maintenance.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -6,9 +6,9 @@ $cat2 = 'import'; } -$array_menu = Array( - 'import' => Array('name' => 'Import', 'link' => 'maintenance_import'), - 'db' => Array('name' => 'Database', 'link' => 'maintenance_db'), +$array_menu = array( + 'import' => array('name' => i18n("Import"), 'link' => 'maintenance_import'), + 'db' => array('name' => i18n("Database"), 'link' => 'maintenance_db'), ); LinAdmin::printAdminMenu($array_menu,$cat2); Modified: trunk/linpha2/admin/metadata.php =================================================================== --- trunk/linpha2/admin/metadata.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/metadata.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -33,9 +33,9 @@ $cat2 = 'select'; } -$array_menu = Array( - 'select' => Array('name' => 'Select image fields', 'link' => 'metadata_select'), - 'define' => Array('name' => 'Define image fields', 'link' => 'metadata_define') +$array_menu = array( + 'select' => array('name' => i18n("Select image fields"), 'link' => 'metadata_select'), + 'define' => array('name' => i18n("Define image fields"), 'link' => 'metadata_define') ); LinAdmin::printAdminMenu($array_menu,$cat2); Modified: trunk/linpha2/admin/metadata_define.php =================================================================== --- trunk/linpha2/admin/metadata_define.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/metadata_define.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -44,12 +44,12 @@ /** * show subsubmenu */ - $array_menu = Array( - 'own' => Array('name' => 'Own fields', 'link' => 'metadata_define_own'), - 'adddata' => Array('name' => 'Add select data (set Category names)', 'link' => 'metadata_define_adddata'), - 'exif' => Array('name' => 'EXIF fields', 'link' => 'metadata_define_exif'), - 'iptc' => Array('name' => 'IPTC fields', 'link' => 'metadata_define_iptc'), - 'xmp' => Array('name' => 'XMP fields', 'link' => 'metadata_define_xmp') + $array_menu = array( + 'own' => array('name' => i18n("Own fields"), 'link' => 'metadata_define_own'), + 'adddata' => array('name' => i18n("Add select data (set Category names)"), 'link' => 'metadata_define_adddata'), + 'exif' => array('name' => i18n("EXIF fields"), 'link' => 'metadata_define_exif'), + 'iptc' => array('name' => i18n("IPTC fields"), 'link' => 'metadata_define_iptc'), + 'xmp' => array('name' => i18n("XMP fields"), 'link' => 'metadata_define_xmp') ); LinAdmin::printAdminMenu($array_menu,$cat3); @@ -70,30 +70,16 @@ show_add_data(); break; case 'exif': - echo i18n("EXIF data is usually created by the any Digital Camera. " . - "These values will be indexed for searching and displaying them, " . - "but can't be edited with LinPHA."); + echo i18n("EXIF data is usually created by the any Digital Camera. These values will be indexed for searching and displaying them, but can't be edited with LinPHA."); echo '<br />'; - echo i18n("Hint: You should't choose all available EXIF tags " . - "because the database table may get to large (MySQL) and therefore " . - "could result in an error."); + echo i18n("Hint: You should't choose all available EXIF tags because the database table may get to large (MySQL) and therefore could result in an error."); echo '<br /><br /><br />'; show_metadata(); break; case 'iptc': - echo i18n("IPTC data is usually not available by default. " . - "It needs to be filled up either with LinPHA, " . - "or with any external program which allows IPTC editing like Photoshop. " . - "IPTC is a standard within professional Photographer business."); - echo '<br /><br />'; - show_metadata(); - break; - case 'xmp': - echo i18n("XMP data is usually not available by default. " . - "It needs to be filled up either with LinPHA, " . - "or with any external program which allows XMP editing like Photoshop. " . - "XMP is standard within professional Photographer business."); + echo i18n("IPTC/XMP data is usually not available by default."); + echo i18n("It needs to be filled up either with LinPHA, or with any external program which allows IPTC/XMP editing like Photoshop. IPTC/XMP is a standard within professional Photographer business."); echo '<br /><br />'; show_metadata(); break; @@ -243,11 +229,11 @@ while($data = $query->FetchRow()) { ?> - <h3><?php echo i18n( ucfirst( $data['name'] ) ); ?></h3> + <h3><?php echo i18n( ucfirst($data['name']) ); /* already translated in sql.data.php */ ?></h3> <table border="0"> <tr> <td width="170"><b><?php echo i18n("Name"); ?></b></td> - <td width="150"><b><?php echo i18n("Private"); echo ' <span title="'.i18n("not visible in the search page by the normal user").'">(Info)</span>'; ?></b></td> + <td width="150"><b><?php echo i18n("Private"); echo ' <span title="'.i18n("Not visible in the search page by a normal user").'">'. i18n("Info").'</span>'; ?></b></td> <td><b>Commands</b></td> <td> </td> </tr> Modified: trunk/linpha2/admin/metadata_select.php =================================================================== --- trunk/linpha2/admin/metadata_select.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/metadata_select.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -33,13 +33,13 @@ $cat3 = 'image'; } -$array_menu = Array( - 'image' => Array('name' => 'Image', 'link' => 'metadata_select_image'), - 'slideshow' => Array('name' => 'Slideshow', 'link' => 'metadata_select_slideshow'), - 'thumb' => Array('name' => 'Thumbnail', 'link' => 'metadata_select_thumb'), - 'thumbdetail' => Array('name' => 'Thumbnail Detail View', 'link' => 'metadata_select_thumbdetail'), - 'video' => Array('name' => 'Video', 'link' => 'metadata_select_video'), - 'album' => Array('name' => 'Album', 'link' => 'metadata_select_album') +$array_menu = array( + 'image' => array('name' => i18n("Image"), 'link' => 'metadata_select_image'), + 'slideshow' => array('name' => i18n("Slideshow"), 'link' => 'metadata_select_slideshow'), + 'thumb' => array('name' => i18n("Thumbnail"), 'link' => 'metadata_select_thumb'), + 'thumbdetail' => array('name' => i18n("Thumbnail Detail View"), 'link' => 'metadata_select_thumbdetail'), + 'video' => array('name' => i18n("Video"), 'link' => 'metadata_select_video'), + 'album' => array('name' => i18n("Album"), 'link' => 'metadata_select_album') ); LinAdmin::printAdminMenu($array_menu,$cat3); Modified: trunk/linpha2/admin/permissions.php =================================================================== --- trunk/linpha2/admin/permissions.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/permissions.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -6,15 +6,15 @@ $cat2 = 'users'; } -$array_menu = Array( - 'users' => Array('name' => 'Users', 'link' => 'permissions_users'), - 'groups' => Array('name' => 'Groups', 'link' => 'permissions_groups'), - 'usergroup' => Array('name' => 'Group Memberships', 'link' => 'permissions_usergroup'), - 'view' => Array('name' => 'View', 'link' => 'permissions_view'), - 'write' => Array('name' => 'Write', 'link' => 'permissions_write'), - 'basket' => Array('name' => 'Basket', 'link' => 'permissions_basket'), - 'metadata' => Array('name' => 'MetaData', 'link' => 'permissions_metadata'), - 'others' => Array('name' => 'Others', 'link' => 'permissions_others'), +$array_menu = array( + 'users' => array('name' => i18n("Users"), 'link' => 'permissions_users'), + 'groups' => array('name' => i18n("Groups"), 'link' => 'permissions_groups'), + 'usergroup' => array('name' => i18n("Group Memberships"), 'link' => 'permissions_usergroup'), + 'view' => array('name' => i18n("View"), 'link' => 'permissions_view'), + 'write' => array('name' => i18n("Write"), 'link' => 'permissions_write'), + 'basket' => array('name' => i18n("Basket"), 'link' => 'permissions_basket'), + 'metadata' => array('name' => i18n("MetaData"), 'link' => 'permissions_metadata'), + 'others' => array('name' => i18n("Others"), 'link' => 'permissions_others'), ); LinAdmin::printAdminMenu($array_menu,$cat2); Modified: trunk/linpha2/admin/permissions_others.php =================================================================== --- trunk/linpha2/admin/permissions_others.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/permissions_others.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -10,23 +10,23 @@ { case 'basket': $array_menu = array( - 'print' => Array('name' => "Print", 'link' => 'permissions_basket_print'), - 'mail' => Array('name' => "Mail", 'link' => 'permissions_basket_mail'), - 'download' => Array('name' => "Download", 'link' => 'permissions_basket_download'), + 'print' => array('name' => i18n("Print"), 'link' => 'permissions_basket_print'), + 'mail' => array('name' => i18n("Mail"), 'link' => 'permissions_basket_mail'), + 'download' => array('name' => i18n("Download"), 'link' => 'permissions_basket_download'), ); break; case 'metadata': $array_menu = array( - 'comments' => Array('name' => "Write Comments", 'link' => 'permissions_metadata_comments'), - 'deletecomments' => Array('name' => "Delete Comments", 'link' => 'permissions_metadata_deletecomments'), - 'edit' => Array('name' => "Edit Image Informations", 'link' => 'permissions_metadata_edit'), + 'comments' => array('name' => i18n("Write Comments"), 'link' => 'permissions_metadata_comments'), + 'deletecomments' => array('name' => i18n("Delete Comments"), 'link' => 'permissions_metadata_deletecomments'), + 'edit' => array('name' => i18n("Edit Image Informations"), 'link' => 'permissions_metadata_edit'), ); break; case 'others': $array_menu = array( - 'watermark' => Array('name' => "Watermark", 'link' => 'permissions_others_watermark'), - 'stats' => Array('name' => "Statistics", 'link' => 'permissions_others_stats'), - 'download' => Array('name' => "Download", 'link' => 'permissions_others_download'), + 'watermark' => array('name' => i18n("Watermark"), 'link' => 'permissions_others_watermark'), + 'stats' => array('name' => i18n("Statistics"), 'link' => 'permissions_others_stats'), + 'download' => array('name' => i18n("Download"), 'link' => 'permissions_others_download'), ); break; } @@ -73,7 +73,7 @@ } - echo '<b>'.i18n("Edit").': '.i18n($array_menu[$cat3]['name']).'</b><br />'; + echo '<b>'.i18n("Edit").': '.$array_menu[$cat3]['name'].'</b><br />'; $data = $GLOBALS['linpha']->db->GetRow("SELECT permission FROM ".LIN_PREFIX."permissions " . "WHERE perm_type = '".LinSql::linAddslashes($key)."'"); Modified: trunk/linpha2/admin/settings.php =================================================================== --- trunk/linpha2/admin/settings.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/settings.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -6,11 +6,11 @@ $cat2 = 'layout'; } -$array_menu = Array( - 'layout' => Array('name' => 'Layout', 'link' => 'settings_layout'), - 'features' => Array('name' => 'Features', 'link' => 'settings_features'), - 'others' => Array('name' => 'Others', 'link' => 'settings_others'), - 'all' => Array('name' => 'All', 'link' => 'settings_all') +$array_menu = array( + 'layout' => array('name' => i18n("Layout"), 'link' => 'settings_layout'), + 'features' => array('name' => i18n("Features"), 'link' => 'settings_features'), + 'others' => array('name' => i18n("Others"), 'link' => 'settings_others'), + 'all' => array('name' => i18n("All"), 'link' => 'settings_all') ); LinAdmin::printAdminMenu($array_menu,$cat2); Modified: trunk/linpha2/admin/settings_features.php =================================================================== --- trunk/linpha2/admin/settings_features.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/settings_features.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -6,9 +6,9 @@ $cat3 = 'others'; } -$array_menu = Array( - 'log' => Array('name' => 'Logging', 'link' => 'settings_features_log'), - 'others' => Array('name' => 'Others', 'link' => 'settings_features_others'), +$array_menu = array( + 'log' => array('name' => i18n("Logging"), 'link' => 'settings_features_log'), + 'others' => array('name' => i18n("Others"), 'link' => 'settings_features_others'), ); LinAdmin::printAdminMenu($array_menu,$cat3); @@ -47,7 +47,7 @@ $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_log_syslog_enable'),'plugins_log_syslog_enable',$LinAdmin->option_value_system['plugins_log_syslog_enable']); $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_syslog_add_events'),'plugins_log_syslog_add_events',$LinAdmin->option_value_system['plugins_log_syslog_add_events']); - echo i18n("Comma separated list. Valid events: login, logout, rotate, comments, guestbook, fm_others, fm_upload, fm_delete, fm_move, fm_copy, fm_rename, fm_create_folder, fm_perm"); + echo i18n("Comma separated list. Valid events:")." login, logout, rotate, comments, guestbook, fm_others, fm_upload, fm_delete, fm_move, fm_copy, fm_rename, fm_create_folder, fm_perm"; echo '<br />'; echo '<br /><h2 class="linStyle">'.i18n("Email").'</h2>'; @@ -57,7 +57,7 @@ $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_headers'),'plugins_log_email_headers',$LinAdmin->option_value_system['plugins_log_email_headers']); $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_add_events'),'plugins_log_email_add_events',$LinAdmin->option_value_system['plugins_log_email_add_events']); - echo i18n("Comma separated list. Valid events: login, logout, rotate, comments, guestbook, fm_others, fm_upload, fm_delete, fm_move, fm_copy, fm_rename, fm_create_folder, fm_perm"); + echo i18n("Comma separated list. Valid events:")." login, logout, rotate, comments, guestbook, fm_others, fm_upload, fm_delete, fm_move, fm_copy, fm_rename, fm_create_folder, fm_perm"; break; Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/admin/settings_layout.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -6,12 +6,12 @@ $cat3 = 'general'; } -$array_menu = Array( - 'general' => Array('name' => 'General', 'link' => 'settings_layout_general'), - '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') +$array_menu = array( + 'general' => array('name' => i18n("General"), 'link' => 'settings_layout_general'), + 'home' => array('name' => i18n("Home Site"), 'link' => 'settings_layout_home'), + 'thumb' => array('name' => i18n("Thumb View"), 'link' => 'settings_layout_thumb'), + 'image' => array('name' => i18n("Image View"), 'link' => 'settings_layout_image'), + 'others' => array('name' => i18n("Others"), 'link' => 'settings_layout_others') ); LinAdmin::printAdminMenu($array_menu,$cat3); Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/install/sql/sql.data.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -213,6 +213,12 @@ $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . "(name, field_type, flags) VALUES ('first_comment', 0, 1)"; + /** + * workaround for i18n + * they wouldn't get detected otherwise... + * some are defined in linpha.metadata.php + */ + i18n("Filename"); i18n("Imagesize"); i18n("Dimension"); i18n("Thumbnail"); /** @@ -227,7 +233,14 @@ "(name, field_type, flags) VALUES ('persons', 2, 5)"; $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . "(name, field_type, flags) VALUES ('date', 3, 5)"; + /** + * workaround for i18n + * they wouldn't get detected otherwise... + * some are defined in linpha.metadata.php + */ + i18n("Description"); i18n("Category"); i18n("Persons"); i18n("Date"); + /** * image fields * flag_nr 10 Modified: trunk/linpha2/install/step2_requirements.php =================================================================== --- trunk/linpha2/install/step2_requirements.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/install/step2_requirements.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -76,7 +76,7 @@ else { print_line_right(failed_msg()); - print_line_info( i18n_install("PHP Version >= 5.0.0 is required") ); + print_line_info( sprintf(i18n_install("PHP Version >= %s is required"),'5.0.0') ); $error = 1; } Modified: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -99,17 +99,17 @@ { if($value['link']=='linpha_home') { - echo '<li><a href="../">'.i18n($value['name']).'</a></li>'; + echo '<li><a href="../">'.$value['name'].'</a></li>'; } else { if($active==$key) { - echo '<li><a href="./?cat='.$value['link'].'" class="current">'.i18n($value['name']).'</a></li>'; + echo '<li><a href="./?cat='.$value['link'].'" class="current">'.$value['name'].'</a></li>'; } else { - echo '<li><a href="./?cat='.$value['link'].'">'.i18n($value['name']).'</a></li>'; + echo '<li><a href="./?cat='.$value['link'].'">'.$value['name'].'</a></li>'; } } } Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/classes/linpha.functions.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -413,10 +413,10 @@ /** * if making any changes in these arrays, all language files needs updating */ - $arr_month_short = Array('1' => i18n('Jan'),'2' => i18n('Feb'),'3' => i18n('Mar'),'4' => i18n('Apr'),'5' => i18n('May'),'6' => i18n('Jun'),'7' => i18n('Jul'),'8' => i18n('Aug'),'9' => i18n('Sep'),'10' => i18n('Oct'),'11' => i18n('Nov'),'12' => i18n('Dec')); /* abrevations of months */ - $arr_month_long = Array('1' => i18n('January'),'2' => i18n('February'),'3' => i18n('March'),'4' => i18n('April'),'5' => i18n('May'),'6' => i18n('June'),'7' => i18n('July'),'8' => i18n('August'),'9' => i18n('September'),'10' => i18n('October'),'11' => i18n('November'),'12' => i18n('December')); /* months */ - $arr_day_short = Array(i18n('Sun'),i18n('Mon'),i18n('Tue'),i18n('Wed'),i18n('Thu'),i18n('Fri'),i18n('Sat')); /* abrevations of weekdays */ - $arr_day_long = Array(i18n('Sunday'),i18n('Monday'),i18n('Tuesday'),i18n('Wednesday'),i18n('Thursday'),i18n('Friday'),i18n('Saturday')); /* weekdays */ + $arr_month_short = Array('1' => i18n("Jan"),'2' => i18n("Feb"),'3' => i18n("Mar"),'4' => i18n("Apr"),'5' => i18n("May"),'6' => i18n("Jun"),'7' => i18n("Jul"),'8' => i18n("Aug"),'9' => i18n("Sep"),'10' => i18n("Oct"),'11' => i18n("Nov"),'12' => i18n("Dec")); /* abrevations of months */ + $arr_month_long = Array('1' => i18n("January"),'2' => i18n("February"),'3' => i18n("March"),'4' => i18n("April"),'5' => i18n("May"),'6' => i18n("June"),'7' => i18n("July"),'8' => i18n("August"),'9' => i18n("September"),'10' => i18n("October"),'11' => i18n("November"),'12' => i18n("December")); /* months */ + $arr_day_short = Array(i18n("Sun"),i18n("Mon"),i18n("Tue"),i18n("Wed"),i18n("Thu"),i18n("Fri"),i18n("Sat")); /* abrevations of weekdays */ + $arr_day_long = Array(i18n("Sunday"),i18n("Monday"),i18n("Tuesday"),i18n("Wednesday"),i18n("Thursday"),i18n("Friday"),i18n("Saturday")); /* weekdays */ if(empty($str_format)) { $str_format = linGetDateFormat().' '.linGetTimeFormat(); @@ -459,10 +459,10 @@ */ function linGetDateFormat() { - if( i18n('special_date_format') == 'special_date_format') { + if( i18n("special_date_format") == 'special_date_format') { return $GLOBALS['linpha']->sql->config->value['sys_style_datetime_dates']; } else { - return i18n('special_date_format'); + return i18n("special_date_format"); } } @@ -477,10 +477,10 @@ */ function linGetTimeFormat() { - if( i18n('special_time_format') == 'special_time_format') { + if( i18n("special_time_format") == 'special_time_format') { return $GLOBALS['linpha']->sql->config->value['sys_style_datetime_times']; } else { - return i18n('special_time_format'); + return i18n("special_time_format"); } } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -329,9 +329,9 @@ * more than one time used stuff */ $array = linGetSortOrders(); - foreach($array AS $value) + foreach($array AS $value) // i18n() already called { - $array_sort_orders_links[] = array('name' => i18n($value), 'value' => $GLOBALS['linpha']->template->URL_full.'&order_by='.$value); + $array_sort_orders_links[] = array('name' => $value, 'value' => $GLOBALS['linpha']->template->URL_full.'&order_by='.$value); } $open_basket_link = LINPHA_LINK.'&linCat=basket'; @@ -909,8 +909,7 @@ if($GLOBALS['linpha']->sql->config->value['sys_style_home_usedefaultwelcometext']) { $GLOBALS['linpha']->template->output['welcome'] = '<h1 class="linStyle">'.i18n("Welcome").'</h1>'. - i18n("Hi, this is the home of \"The PHP Photo Archive\" " . - "<a href=\"http://linpha.sf.net\">aka LinPHA</a>.").'<br />'; + i18n("Hi, this is the home of \"The PHP Photo Archive\" <a href=\"http://linpha.sf.net\">aka LinPHA</a>.").'<br />'; } else { @@ -1235,7 +1234,7 @@ if($this->newCommentAdded) { - echo '<commentadded>'.i18n('Comment successfully added.').'</commentadded>'."\n"; + echo '<commentadded>'.i18n("Comment successfully added.").'</commentadded>'."\n"; } while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -494,7 +494,7 @@ } } } - else + else // this should not happen { linSysLog(i18n("Import").': Error: what am i? '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)); linLog(LOG_TYPE_IMPORT,LOG_NOTICE,'import_fileinfo','Error: what am i? '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)); Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -974,7 +974,7 @@ /** * echo "Error - Failure update Photoshop File Info : $filename <br>\n"; */ - linSysLog(i18n("Error: Failure update Photoshop File Info:" . ' ' . $filename)); + linSysLog(i18n("Error: Failure update Photoshop File Info:") . ' ' . $filename); linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Failure update Photoshop File Info:" . ' ' . $filename); return false; @@ -985,13 +985,13 @@ /** * echo "Error - Failure to write new JPEG : $filename <br>\n"; */ - linSysLog(i18n("Error: Failure to write new JPEG:" . ' ' . $filename)); + linSysLog(i18n("Error: Failure to write new JPEG:") . ' ' . $filename); linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Failure to write new JPEG:" . ' ' . $filename); return false; } else { // Writing of new JPEG succeeded - linSysLog(i18n("DONE! Updated:" . ' ' . $filename)); + linSysLog(i18n("DONE! Updated:") . ' ' . $filename); linLog(LOG_TYPE_META, LOG_NOTICE, 'meta_iptc', "Updated:" . ' ' . $filename); return true; @@ -2094,7 +2094,7 @@ $last_part = substr($key, $pos +1); switch ($first_part) { case 'builtin' : // builtin and special fields like filename, imagesize and dimension - $value = i18n(ucfirst($last_part)); + $value = i18n(ucfirst($last_part)); // i18n already called in sql.data.php break; case 'id' : // own fields @@ -2104,10 +2104,10 @@ * we dont want have to read this for each thumbnail */ if (isset ($this->cachedFieldNames[$last_part])) { - $value = i18n(ucfirst($this->cachedFieldNames[$last_part])); + $value = i18n(ucfirst($this->cachedFieldNames[$last_part])); // i18n already called in sql.data.php } else { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM " . LIN_PREFIX . "meta_fields WHERE id = '" . $last_part . "'"); - $value = i18n(ucfirst($data['name'])); + $value = i18n(ucfirst($data['name'])); // i18n already called in sql.data.php if (isset ($this)) // cache entry, but only in object context { Modified: trunk/linpha2/lib/classes/linpha.template.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.template.class.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/classes/linpha.template.class.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -193,13 +193,13 @@ case 'settings': if($GLOBALS['linpha']->sql->isLoggedIn()) { echo '<!-- my settings -->'."\n"; - $this->printMenu("My Settings",LINPHA_LINK."&linCat=settings"); + $this->printMenu("My Settings",i18n("My Settings"),LINPHA_LINK."&linCat=settings"); } break; case 'admin': if($GLOBALS['linpha']->sql->isLoggedIn()) { echo '<!-- admin links -->'."\n"; - $this->printMenu("Admin",LINPHA_CLIENT."/admin/"); + $this->printMenu("Admin",i18n("Admin"),LINPHA_CLIENT."/admin/"); } break; default: // all other, like home, search, login, guestbook, icons, more @@ -218,12 +218,12 @@ /** * print the main menu entries (more, admin, ...) */ - function printMenu($index,$link='') + function printMenu($index,$text,$link='') { if( ! isset( $GLOBALS['linpha']->template->output['menu_'.$index] ) ) { echo "\n".'<ul>'."\n"; - echo "\t".'<li><a href="'.$link.'">'.i18n($index).'</a>'."\n"; + echo "\t".'<li><a href="'.$link.'">'.$text.'</a>'."\n"; echo "\n".'</ul>'."\n"; } else @@ -231,11 +231,11 @@ echo "\n".'<ul>'."\n"; if(!empty($link)) { - echo "\t".'<li><a href="'.$link.'">'.i18n($index).'</a>'."\n"; + echo "\t".'<li><a href="'.$link.'">'.$text.'</a>'."\n"; } else { - echo "\t".'<li><span>'.i18n($index).' </span>'."\n"; + echo "\t".'<li><span>'.$text.' </span>'."\n"; } echo "\n".'<ul id="linMenu'.$index.'" onmouseover="myLinGlobal.reloadMenu()">'."\n"; Modified: trunk/linpha2/lib/include/metadata_info_show.php =================================================================== --- trunk/linpha2/lib/include/metadata_info_show.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/include/metadata_info_show.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -6,9 +6,6 @@ */ if( !LinSql::photoIsAllowed( $GLOBALS['linpha']->template->idCurrent, $sql_perm_type = 'read' ) ) { - /** - * @todo use unified i18n STR_ACCESS_DENIED - */ echo i18n("Access Denied!"); exit(); } @@ -23,9 +20,6 @@ if( ! isset($data['id']) ) { - /** - * @todo use unified i18n STR_ACCESS_DENIED - */ echo i18n("Access Denied!"); exit(); } Modified: trunk/linpha2/lib/lang/editlang.php =================================================================== --- trunk/linpha2/lib/lang/editlang.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/lang/editlang.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -17,12 +17,6 @@ $linpha = new Linpha(); $linpha->sql->startSession(); - if( ! $GLOBALS['linpha']->sql->isAdmin() ) - { - echo i18n("Access denied!"); - exit(); - } - /** * some defines */ @@ -39,6 +33,12 @@ ob_start(); +if( ! $GLOBALS['linpha']->sql->isAdmin() ) +{ + echo i18n("Access denied!"); +} +else +{ ?> <div style="float: left; width: 500px;"> <h2>LinPHA language files</h2> @@ -49,8 +49,8 @@ <form method="POST" action="<?php echo LINPHA_LINK.'&linCat=updatefile'; ?>"> <select name="languageFile"> <?php -$languageFiles = linGetAvailableLanguageFiles( $languagefilePaths['default'] ); -foreach($languageFiles as $key=>$value) +$languageFilesDefault = linGetAvailableLanguageFiles( $languagefilePaths['default'] ); +foreach($languageFilesDefault as $key=>$value) { echo '<option value="'.$value.'">'.$value.'</option>'; } @@ -69,8 +69,8 @@ <form method="POST" action="<?php echo LINPHA_LINK.'&linCat=updatefile&isInstaller=true'; ?>"> <select name="languageFile"> <?php -$languageFiles = linGetAvailableLanguageFiles( $languagefilePaths['installer'] ); -foreach($languageFiles as $key=>$value) +$languageFilesInstaller = linGetAvailableLanguageFiles( $languagefilePaths['installer'] ); +foreach($languageFilesInstaller as $key=>$value) { echo '<option value="'.$value.'">'.$value.'</option>'; } @@ -80,6 +80,9 @@ </form> </div> <div style="clear: both;"></div> +Please see <a href="http://linpha.sourceforge.net/wiki/index.php/Translator_Instructions">http://linpha.sourceforge.net/wiki/index.php/Translator_Instructions</a> +for instructions how to update the language files. +<br /><br /><br /> <?php if(isset($_GET['linCat'])) @@ -112,7 +115,7 @@ foreach($filelist as $file) { - echo '<br /><br /><b>'.$file.'</b><br />'; + echo '<br /><br /><b>'.str_replace( LINPHA_DIR.'/', '', $file).'</b><br />'; $i18nStrs = array(); scanFile($file, $languageFunction); @@ -125,6 +128,58 @@ break; case 'checkoutdated': + + $filelist = array(); + scanRecursive(LINPHA_DIR); + + $i18nStrs = array(); + foreach($filelist as $file) + { + scanFile($file, $languageFunction); + } + + if( isset($_GET['isInstaller']) ) { + $languageFiles = linGetAvailableLanguageFiles( $languagefilePaths['installer'] ); + } else { + $languageFiles = linGetAvailableLanguageFiles( $languagefilePaths['default'] ); + } + + foreach( $languageFiles as $key=>$value) + { + $languagefile = $languagefileFolder.'/lang.'.$value.'.php'; + + echo '<h2 class="linStyle">Parsing '.str_replace( LINPHA_DIR.'/', '', $languagefile).'</h2>'; + + if( !file_exists( $languagefile )) + { + echo "Error: File does not exists: ".$languagefile; // this should not happen + } + else + { + $linTranslate = array(); // after this command it is not recommended to use i18n() again + include( $languagefile ); + + foreach( $linTranslate as $key=>$value ) + { + if( !in_array( $key, $i18nStrs )) + { + echo htmlspecialchars("$key => $value", ENT_QUOTES).'<br />'; + $found = true; + } + } + if( isset($found) ) + { + echo '<br /><b>There are out-dated files, you should remove them from the language file.</b><br />'; + } + else + { + echo 'No out-dated entries found!<br />'; + } + } + + echo '<br /><br />'; + } + break; case 'updatefile': @@ -145,14 +200,14 @@ echo "Error"; // this should not happen } - $translate = array(); // after this command it is not recommended to use i18n() again + $linTranslate = array(); // after this command it is not recommended to use i18n() again include( $languagefile ); - echo '<br /><br />---------------------------------------<br />'; + echo '---------------------------------------<br />'; foreach( array_count_values($i18nStrs) as $key=>$value ) { - if( !isset($translate[$key]) ) + if( !isset($linTranslate[$key]) ) { echo '"'.htmlspecialchars($key, ENT_QUOTES).'" => "",<br />'; } @@ -162,9 +217,10 @@ break; -} // end switch() -} // end if +} // end switch($_GET['linCat']) +} // end if(isset($_GET['linCat'])) +} // end if( isAdmin ) ?> Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/lib/modules/module.filemanager.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -48,12 +48,11 @@ /** * some double used i18n entries - * @todo what should we do with double used entries?? */ - $str_checkpermissions = "Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)"; - $str_autoimportdisabled = "Autoimport is disabled, you need now to start the manual import to make your changes appear, but you maybe don't have permissions to do that..."; - $str_nopermission = "You don't have permissions to this folder!"; - $str_filealreadyexists = "A File/Folder with the same name already exists!"; + $str_checkpermissions = i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)"); + $str_autoimportdisabled = i18n("Autoimport is disabled, you need now to start the manual import to make your changes appear, but you maybe don't have permissions to do that..."); + $str_nopermission = i18n("You don't have permissions to this folder!"); + $str_filealreadyexists = i18n("A File/Folder with the same name already exists!"); /** * init stuff @@ -288,19 +287,19 @@ "WHERE id = '".LinSql::linAddslashes($_POST['file_id'])."'"); if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) { - throw new Exception(i18n($str_nopermission)); + throw new Exception($str_nopermission); } if( nameAlreadyExists( $new_name, $data['parent_id'] )) { - throw new Exception(i18n($str_filealreadyexists)); + throw new Exception($str_filealreadyexists); } if( ! @rename( $full_filename , $parent_dirname."/".$new_name ) ) { throw new Exception(i18n("Rename File/Folder Failed!"). htmlspecialchars($full_filename,ENT_QUOTES).' '.i18n("to").' '.htmlspecialchars($parent_dirname.'/'.$new_name,ENT_QUOTES). - LIN_NL.i18n($str_checkpermissions) + LIN_NL.$str_checkpermissions ); } @@ -323,7 +322,7 @@ */ if( ! $linpha->sql->photoIsAllowed( $_POST['movecopy_to'], 'write') ) { - throw new Exception(i18n($str_nopermission)); + throw new Exception($str_nopermission); } /** @@ -346,8 +345,7 @@ i18n("Cannot Copy/Move to Folder \"%s\" because its not writable!"), htmlspecialchars($full_destparentname,ENT_QUOTES) ). - LIN_NL. - i18n($str_checkpermissions) + LIN_NL.$str_checkpermissions ); } @@ -373,7 +371,7 @@ */ if( ! $linpha->sql->photoIsAllowed( $value, 'read') ) { - throw new Exception(i18n($str_nopermission)); + throw new Exception($str_nopermission); } /** @@ -381,7 +379,7 @@ */ if( nameAlreadyExists( basename($full_sourcename), $_POST['movecopy_to'] )) { - throw new Exception(i18n($str_filealreadyexists)); + throw new Exception($str_filealreadyexists); } /** @@ -398,7 +396,7 @@ { if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) { - throw new Exception(i18n($str_nopermission)); + throw new Exception($str_nopermission); } } @@ -411,7 +409,7 @@ htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) ) ); - linSysLog(i18n($str_checkpermissions)); + linSysLog($str_checkpermissions); linLog(LOG_TYPE_FILEMANAGER,LOG_ERR,'fm_move',"cannot moved file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); } @@ -451,7 +449,7 @@ htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) ) ); - linSysLog(i18n($str_checkpermissions)); + linSysLog($str_checkpermissions); linLog(LOG_TYPE_FILEMANAGER,LOG_ERR,'fm_copy',"Cannot copy file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); } @@ -494,7 +492,7 @@ */ if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) { - throw new Exception(i18n($str_nopermission)); + throw new Exception($str_nopermission); } $full_filename = LinSql::getFullImagePath( $value ); @@ -508,7 +506,7 @@ if(file_exists($full_filename)) { - throw new Exception(i18n("Deleting Files/Folders Failed").": \"".htmlspecialchars($full_filename,ENT_QUOTES)."\"".LIN_NL.i18n($str_checkpermissions)); + throw new Exception(i18n("Deleting Files/Folders Failed").": \"".htmlspecialchars($full_filename,ENT_QUOTES)."\"".LIN_NL.$str_checkpermissions); } linSysLog(i18n("File/Folder deleted successfully!")); @@ -524,14 +522,14 @@ */ if( ! $linpha->sql->photoIsAllowed( $linpha->template->idCurrent, 'write') ) { - throw new Exception(i18n($str_nopermission)); + throw new Exception($str_nopermission); } $new_name = removeUnWantedChars( $_POST['folder_name'] ); if( nameAlreadyExists( $new_name, $linpha->template->idCurrent )) { - throw new Exception(i18n($str_filealreadyexists)); + throw new Exception($str_filealreadyexists); } $full_filename = LinSql::getFullImagePath( $linpha->template->idCurrent ); @@ -547,7 +545,7 @@ } elseif(! @mkdir( $full_filename .'/'. $new_name ) ) { - throw new Exception(i18n("Create Folder Failed").": \"".htmlspecialchars($new_name,ENT_QUOTES)."\"".LIN_NL.i18n($str_checkpermissions)); + throw new Exception(i18n("Create Folder Failed").": \"".htmlspecialchars($new_name,ENT_QUOTES)."\"".LIN_NL.$str_checkpermissions); } linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_create_folder',"Created folder (".$full_filename.'/'.$new_name.")"); @@ -555,7 +553,7 @@ if( ! $linpha->sql->config->value['sys_import_autoimport'] ) { - linSysLog(i18n($str_autoimportdisabled)); + linSysLog($str_autoimportdisabled); } break; @@ -585,7 +583,7 @@ if(! @chmod($full_filename,intval($mode,8))) { - throw new Exception(i18n("Change Permissions Failed").": \"".htmlspecialchars($full_filename,ENT_QUOTES)."\" to ".$mode.LIN_NL.i18n($str_checkpermissions)); + throw new Exception(i18n("Change Permissions Failed").": \"".htmlspecialchars($full_filename,ENT_QUOTES)."\" to ".$mode.LIN_NL.$str_checkpermissions); } linSysLog(i18n("Permissions Changed Successfully!")); @@ -619,7 +617,7 @@ htmlspecialchars($thisfile['name'],ENT_QUOTES), ini_get('upload_max_filesize') ) ); break; case 2: - throw new Exception( sprintf(i18n("size of uploaded file %s exceeds the HTML FORM settings"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); + throw new Exception( sprintf(i18n("Error: Size of uploaded file %s exceeds the HTML FORM settings"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); break; case 3: throw new Exception( sprintf(i18n("The uploaded file %s was only partially uploaded"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); @@ -699,7 +697,7 @@ { if( ! $linpha->sql->config->value['sys_import_autoimport'] ) { - linSysLog(i18n($str_autoimportdisabled)); + linSysLog($str_autoimportdisabled); } } break; Modified: trunk/linpha2/templates/default/home.html.php =================================================================== --- trunk/linpha2/templates/default/home.html.php 2007-02-18 23:23:43 UTC (rev 4683) +++ trunk/linpha2/templates/default/home.html.php 2007-02-20 19:31:26 UTC (rev 4684) @@ -46,7 +46,7 @@ } ?> <div style="clear: both;"></div> - <?php echo '<a href="'.LINPHA_LINK.'&linCat=newimg">'.i18n('Show All New Images').'</a>'; ?> + <?php echo '<a href="'.LINPHA_LINK.'&linCat=newimg">'.i18n("Show All New Images").'</a>'; ?> <?php } ?> <!-- Browse by Date --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-02-21 10:42:05
|
Revision: 4687 http://svn.sourceforge.net/linpha/?rev=4687&view=rev Author: bzrudi Date: 2007-02-21 02:42:02 -0800 (Wed, 21 Feb 2007) Log Message: ----------- cleanup in metadata table create Modified Paths: -------------- trunk/linpha2/admin/metadata_define_post.php trunk/linpha2/lib/classes/linpha.metadata.class.php Modified: trunk/linpha2/admin/metadata_define_post.php =================================================================== --- trunk/linpha2/admin/metadata_define_post.php 2007-02-20 19:59:36 UTC (rev 4686) +++ trunk/linpha2/admin/metadata_define_post.php 2007-02-21 10:42:02 UTC (rev 4687) @@ -121,13 +121,13 @@ } if($cat3 == 'exif') { $linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_exif"); - $linpha->db->Execute( LinMetadataAdmin::createExifTable( $_POST['selected_fields'] ) ); + $linpha->db->Execute( LinMetaDataAdmin::createMetaDataTable( $_POST['selected_fields'], 'exif')); } elseif($cat3 == 'iptc') { $linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_iptc"); - $linpha->db->Execute( LinMetadataAdmin::createIptcTable( $_POST['selected_fields'] ) ); + $linpha->db->Execute( LinMetaDataAdmin::createMetaDataTable( $_POST['selected_fields'], 'iptc')); } elseif($cat3 == 'xmp') { $linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_xmp"); - $linpha->db->Execute( LinMetadataAdmin::createXmpTable( $_POST['selected_fields'] ) ); + $linpha->db->Execute( LinMetaDataAdmin::createMetaDataTable( $_POST['selected_fields'], 'xmp' )); } break; } Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-20 19:59:36 UTC (rev 4686) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-21 10:42:02 UTC (rev 4687) @@ -243,13 +243,17 @@ * Admin functions to select the tags which should be indexed */ class LinMetaDataAdmin extends LinMetaData { - function createExifTable($array = '') { - if (empty ($array)) { + function createMetaDataTable($array = '', $meta_type) { + + if (!is_array($array) && $meta_type == 'exif') { $array = $this->getDefaultExifFields(); } - + elseif(!is_array($array)) { + $array = array(); + } + if (LIN_DB_TYPE == "mysql") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_exif (" . + $str = "CREATE TABLE " . LIN_PREFIX . "meta_$meta_type (" . "md5sum VARCHAR(32) NOT NULL, "; foreach ($array AS $key => $value) { $str .= LinSql :: linAddslashes(strtolower($value)) . " VARCHAR(255), "; @@ -258,7 +262,7 @@ $str .= "KEY (md5sum) )"; } elseif (LIN_DB_TYPE == "sqlite") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_exif (" . + $str = "CREATE TABLE " . LIN_PREFIX . "meta_$meta_type (" . "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; foreach ($array AS $key => $value) { $str .= strtolower($value) . " VARCHAR(255), "; @@ -269,7 +273,7 @@ $str = substr($str, 0, strlen($str) - 2) . ")"; } elseif (LIN_DB_TYPE == "postgres") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_exif (" . + $str = "CREATE TABLE " . LIN_PREFIX . "meta_$meta_type (" . "md5sum VARCHAR(32) NOT NULL, "; foreach ($array AS $key => $value) { @@ -301,92 +305,9 @@ ); } - function createIptcTable($array = '') { - if (empty ($array)) { - $array = Array (); - } - - if (LIN_DB_TYPE == "mysql") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_iptc (" . - "md5sum VARCHAR(32) NOT NULL, "; - - foreach ($array AS $key => $value) { - $str .= LinSql :: linAddslashes(strtolower($value)) . " VARCHAR(255), "; - } - $str .= "PRIMARY KEY (md5sum), "; - $str .= "KEY (md5sum) )"; - } - elseif (LIN_DB_TYPE == "sqlite") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_iptc (" . - "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; - foreach ($array AS $key => $value) { - $str .= strtolower($value) . " VARCHAR(255), "; - } - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str, 0, strlen($str) - 2) . ")"; - } - elseif (LIN_DB_TYPE == "postgres") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_iptc (" . - "md5sum VARCHAR(32) NOT NULL, "; - - foreach ($array AS $key => $value) { - $str .= strtolower($value) . " VARCHAR(255), "; - } - - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str, 0, strlen($str) - 2) . ")"; - } - return $str; - } - - function createXmpTable($array = '') { - if (empty ($array)) { - $array = Array (); - } - - if (LIN_DB_TYPE == "mysql") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_xmp (" . - "md5sum VARCHAR(32) NOT NULL, "; - - foreach ($array AS $key => $value) { - $str .= LinSql :: linAddslashes(strtolower($value)) . " VARCHAR(255), "; - } - $str .= "PRIMARY KEY (md5sum), "; - $str .= "KEY (md5sum) )"; - } - elseif (LIN_DB_TYPE == "sqlite") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_xmp (" . - "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; - foreach ($array AS $key => $value) { - $str .= strtolower($value) . " VARCHAR(255), "; - } - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str, 0, strlen($str) - 2) . ")"; - } - elseif (LIN_DB_TYPE == "postgres") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_xmp (" . - "md5sum VARCHAR(32) NOT NULL, "; - - foreach ($array AS $key => $value) { - $str .= strtolower($value) . " VARCHAR(255), "; - } - - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str, 0, strlen($str) - 2) . ")"; - } - return $str; - } - } // end class LinMetaDataAdmin + /** * Index functions (save data in DB) */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-02-28 17:43:21
|
Revision: 4688 http://svn.sourceforge.net/linpha/?rev=4688&view=rev Author: bzrudi Date: 2007-02-28 09:41:13 -0800 (Wed, 28 Feb 2007) Log Message: ----------- Improved Metadata Support (still not complete) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/metadata_define_post.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/metadata_iptc_edit.php trunk/linpha2/lib/include/metadata_xmp_edit.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-02-21 10:42:02 UTC (rev 4687) +++ trunk/linpha2/ChangeLog 2007-02-28 17:41:13 UTC (rev 4688) @@ -1,4 +1,7 @@ - +2007-02-28 bzrudi + * Improved MetaData support + TODO: XMP write, code cleanups, encoding + 2007-02-20 flo * i18n - added check for outdated strings Modified: trunk/linpha2/admin/metadata_define_post.php =================================================================== --- trunk/linpha2/admin/metadata_define_post.php 2007-02-21 10:42:02 UTC (rev 4687) +++ trunk/linpha2/admin/metadata_define_post.php 2007-02-28 17:41:13 UTC (rev 4688) @@ -46,6 +46,7 @@ } break; + case 'add_new': /** * check for duplicates with the same name @@ -53,6 +54,7 @@ $linpha->db->Execute("INSERT into ".LIN_PREFIX."meta_fields (name, field_type, flags) " . "VALUES ('".LinSql::linAddslashes($_POST['new_name'])."', '".LinSql::linAddslashes($_POST['new_type'])."', '7') "); break; + case 'change_field': if(LinSql::linAddslashes($_POST['builtin'][$_POST['id']])) { @@ -66,6 +68,7 @@ "flags = '".$flag."' ". "WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; + case 'delete': ?> <h3>Delete selected field</h3> @@ -79,9 +82,11 @@ <br /><br /> <?php break; + case 'do_delete': $linpha->db->Execute("DELETE FROM ".LIN_PREFIX."meta_fields WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; + case 'add_new_category': if(isset($_POST['isprivate'])) { $isprivate = 1; @@ -94,6 +99,7 @@ "'".$isprivate."')"); break; + case 'mod_category': if(isset($_POST['isprivate'])) { $isprivate = 1; @@ -107,30 +113,33 @@ "WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; + case 'delete_category': $linpha->db->Execute("DELETE FROM ".LIN_PREFIX."meta_category WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; + case 'update_config_metadata': $linpha->sql->config->updateConfig('sys_image_'.$cat3,$_POST['metadata_config_enable']); $linpha->sql->config->reloadConfig(); break; + case 'create_metadata_table': - if( ! isset($_POST['selected_fields'])) - { + if( ! isset($_POST['selected_fields'])) { $_POST['selected_fields'] = Array(); } - if($cat3 == 'exif') { - $linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_exif"); - $linpha->db->Execute( LinMetaDataAdmin::createMetaDataTable( $_POST['selected_fields'], 'exif')); - } elseif($cat3 == 'iptc') { - $linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_iptc"); - $linpha->db->Execute( LinMetaDataAdmin::createMetaDataTable( $_POST['selected_fields'], 'iptc')); - } elseif($cat3 == 'xmp') { - $linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_xmp"); - $linpha->db->Execute( LinMetaDataAdmin::createMetaDataTable( $_POST['selected_fields'], 'xmp' )); + if(isset($cat3)) { + if(LIN_DB_TYPE == "mysql") { + $linpha->db->Execute("DROP TABLE IF EXISTS ".LIN_PREFIX."meta_$cat3"); + } else { + @$linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_$cat3"); + } + $linpha->db->Execute( LinMetaDataAdmin::createMetaDataTable( $_POST['selected_fields'], $cat3)); } break; + +default: + echo i18n("FATAL: Unknown POST Request"); + exit(); + break; } - - -?> \ No newline at end of file +?> Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-21 10:42:02 UTC (rev 4687) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-02-28 17:41:13 UTC (rev 4688) @@ -1708,90 +1708,9 @@ ), 'xmp' => array ( - - // Iptc4xmpCore Segment - - 'i4xcore_country_code' => array ( - 'name' => 'Country Code', - 'pathkey' => 'i4xcore_country_code', - 'path' => 'Iptc4xmpCore:CountryCode' - ), - - 'i4xcore_addr_city' => array ( - 'name' => 'Creator Info City', - 'pathkey' => 'i4xcore_addr_city', - 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrCity' - ), - - 'i4xcore_addr_ctry' => array ( - 'name' => 'Creator Info Country', - 'pathkey' => 'i4xcore_addr_ctry', - 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrCtry' - ), - - 'i4xcore_addr_etra' => array ( - 'name' => 'Creator Extra Information', - 'pathkey' => 'i4xcore_addr_etra', - 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrExtadr' - ), - - 'i4xcore_zip_code' => array ( - 'name' => 'Creator Info Zip Code', - 'pathkey' => 'i4xcore_zip_code', - 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrPcode' - ), - - 'i4xcore_region_code' => array ( - 'name' => 'Creator Info Region', - 'pathkey' => 'i4xcore_region_code', - 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrRegion' - ), - - 'i4xcore_email_work' => array ( - 'name' => 'Creator Email Work', - 'pathkey' => 'i4xcore_email_work', - 'path' => 'Iptc4xmpCore:CreatorContactInfoCiEmailWork' - ), - - 'i4xcore_tel_work' => array ( - 'name' => 'Creator Telephone Work', - 'pathkey' => 'i4xcore_tel_work', - 'path' => 'Iptc4xmpCore:CreatorContactInfoCiTelWork' - ), - - 'i4xcore_url_work' => array ( - 'name' => 'Creator Website Work', - 'pathkey' => 'i4xcore_url_work', - 'path' => 'Iptc4xmpCore:CreatorContactInfoCiUrlWork' - ), - - 'i4xcore_intel_genre' => array ( - 'name' => 'Creator Intellectual Genre', - 'pathkey' => 'i4xcore_intel_genre', - 'path' => 'Iptc4xmpCore:IntellectualGenre' - ), - - 'i4xcore_location' => array ( - 'name' => 'Creator Location', - 'pathkey' => 'i4xcore_location', - 'path' => 'Iptc4xmpCore:Location' - ), - - 'i4xcore_scene' => array ( - 'name' => 'Creator Scene', - 'pathkey' => 'i4xcore_scene', - 'path' => 'Iptc4xmpCore:Scene' - ), - - 'i4xcore_subject_code' => array ( - 'name' => 'Subject Code', - 'pathkey' => 'i4xcore_subject_code', - 'path' => 'Iptc4xmpCore:SubjectCode' - ), - // Photoshop RDF Segment - 'ps_authors_pos' => array ( + 'ps_authors_pos' => array ( 'name' => 'Authors Position', 'pathkey' => 'ps_authors_pos', 'path' => 'photoshop:AuthorsPosition' @@ -1881,6 +1800,86 @@ 'path' => 'photoshop:Urgency' ), + // Iptc4xmpCore Segment + + 'i4xcore_country_code' => array ( + 'name' => 'Country Code', + 'pathkey' => 'i4xcore_country_code', + 'path' => 'Iptc4xmpCore:CountryCode' + ), + + 'i4xcore_addr_city' => array ( + 'name' => 'Creator Info City', + 'pathkey' => 'i4xcore_addr_city', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrCity' + ), + + 'i4xcore_addr_ctry' => array ( + 'name' => 'Creator Info Country', + 'pathkey' => 'i4xcore_addr_ctry', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrCtry' + ), + + 'i4xcore_addr_etra' => array ( + 'name' => 'Creator Extra Information', + 'pathkey' => 'i4xcore_addr_etra', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrExtadr' + ), + + 'i4xcore_zip_code' => array ( + 'name' => 'Creator Info Zip Code', + 'pathkey' => 'i4xcore_zip_code', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrPcode' + ), + + 'i4xcore_region_code' => array ( + 'name' => 'Creator Info Region', + 'pathkey' => 'i4xcore_region_code', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiAdrRegion' + ), + + 'i4xcore_email_work' => array ( + 'name' => 'Creator Email Work', + 'pathkey' => 'i4xcore_email_work', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiEmailWork' + ), + + 'i4xcore_tel_work' => array ( + 'name' => 'Creator Telephone Work', + 'pathkey' => 'i4xcore_tel_work', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiTelWork' + ), + + 'i4xcore_url_work' => array ( + 'name' => 'Creator Website Work', + 'pathkey' => 'i4xcore_url_work', + 'path' => 'Iptc4xmpCore:CreatorContactInfoCiUrlWork' + ), + + 'i4xcore_intel_genre' => array ( + 'name' => 'Creator Intellectual Genre', + 'pathkey' => 'i4xcore_intel_genre', + 'path' => 'Iptc4xmpCore:IntellectualGenre' + ), + + 'i4xcore_location' => array ( + 'name' => 'Creator Location', + 'pathkey' => 'i4xcore_location', + 'path' => 'Iptc4xmpCore:Location' + ), + + 'i4xcore_scene' => array ( + 'name' => 'Creator Scene', + 'pathkey' => 'i4xcore_scene', + 'path' => 'Iptc4xmpCore:Scene' + ), + + 'i4xcore_subject_code' => array ( + 'name' => 'Subject Code', + 'pathkey' => 'i4xcore_subject_code', + 'path' => 'Iptc4xmpCore:SubjectCode' + ), + // Dublin Core Metadata Initiative RDF Segment 'dc_contributor' => array ( @@ -2060,4 +2059,4 @@ } } // end class LinMetaData -?> \ No newline at end of file +?> Modified: trunk/linpha2/lib/include/metadata_iptc_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-02-21 10:42:02 UTC (rev 4687) +++ trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-02-28 17:41:13 UTC (rev 4688) @@ -1,228 +1,229 @@ <?php -if(!defined('LINPHA_DIR')) { exit(1); } - -/**************************************************************************** +/* +* 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. * -* Filename: Edit_File_Info.php +* 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. * -* Description: Allows the user to edit the metadata of an image over the internet -* in the same way that Photoshop edits 'File Info' data -* This file provides only the html for a form containing the file info -* input fields. The rest of the html file must be provided by the calling script. -* $outputfilename must always be defined - it is ne name of the file which -* have the metadata changed after the form has been submitted -* -* This file has several modes of operation: -* -* 1) If $new_ps_file_info_array is defined then it's data will be used -* to fill the fields. -* 2) If $new_ps_file_info_array is not defined but $filename is defined, -* then the file info fields will be filled from the metadata in the file specified -* 3) If $new_ps_file_info_array is not defined but $filename and $default_ps_file_info_array -* are defined, then the file info fields will be filled from the metadata -* in the file specified, but where fields are blank, they will be filled from $default_ps_file_info_array -* 4) Otherwise the fields will be blank -* -* See Edit_File_Info_Example.php for an example of usage -* -* Author: Evan Hunter -* -* Date: 17/11/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.11 -* -* Changes: 1.10 -> 1.11 : Changed displayed toolkit version numbers to reference Toolkit_Version.php -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit 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. -* -* The PHP JPEG Metadata Toolkit 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 the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************/ +* 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 handles IPTC editing + * @package MetaData + * @author bzrudi,flo + */ +if(!defined('LINPHA_DIR')) { exit(1); } - - /** * if $default_ps_file_info_array is set and the key 'date' is empty * it will be auto filled with the exif date and we prevent errors like * "Invalid Date - must be YYYY-MM-DD format" */ -$default_ps_file_info_array = array ( - 'title' => "", - 'author' => "", - 'authorsposition' => "", - 'caption' => "", - 'captionwriter' => "", - 'jobname' => "", - 'copyrightstatus' => "", - 'copyrightnotice' => "", - 'ownerurl' => "", - 'keywords' => array(), - 'category' => "", - 'supplementalcategories'=> array(), - 'date' => "", - 'city' => "", - 'state' => "", - 'country' => "", - 'credit' => "", - 'source' => "", - 'headline' => "", - 'instructions' => "", - 'transmissionreference' => "", - 'urgency' => "" - ); +$default_ps_file_info_array = array( + 'title' => "", + 'author' => "", + 'authorsposition' => "", + 'caption' => "", + 'captionwriter' => "", + 'jobname' => "", + 'copyrightstatus' => "", + 'copyrightnotice' => "", + 'ownerurl' => "", + 'keywords' => array(), + 'category' => "", + 'supplementalcategories'=> array(), + 'date' => "", + 'city' => "", + 'state' => "", + 'country' => "", + 'credit' => "", + 'source' => "", + 'headline' => "", + 'instructions' => "", + 'transmissionreference' => "", + 'urgency' => "" + ); - include LINPHA_DIR.'/lib/classes/pjmt/Toolkit_Version.php'; // Change: added as of version 1.11 - global $new_ps_file_info_array; +include LINPHA_DIR.'/lib/classes/pjmt/Toolkit_Version.php'; - // Check for operation modes 2 or 3 - // i.e. $filename is defined, and $new_ps_file_info_array is not - if ( ( ! isset( $new_ps_file_info_array ) ) && - ( isset( $filename ) ) && - ( is_string( $filename ) ) ) - { - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; +global $new_ps_file_info_array; - // Accessing the existing file info for the specified file requires these includes - include_once( LINPHA_DIR.'/lib/classes/pjmt/JPEG.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/XMP.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php' ); +// Check for operation modes 2 or 3 +// i.e. $filename is defined, and $new_ps_file_info_array is not +if ((!isset($new_ps_file_info_array)) && (isset($filename)) + && (is_string($filename))) +{ + // Hide any unknown EXIF tags + $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - // Retrieve the header information from the JPEG file - $jpeg_header_data = get_jpeg_header_data( $filename ); +/** + * @TODO check what really needs to be included! + */ + include_once( LINPHA_DIR.'/lib/classes/pjmt/JPEG.php' ); + include_once( LINPHA_DIR.'/lib/classes/pjmt/XMP.php' ); + include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php' ); + include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); + include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php' ); - // Retrieve EXIF information from the JPEG file - $Exif_array = get_EXIF_JPEG( $filename ); + // Retrieve the header information from the JPEG file + $jpeg_header_data = get_jpeg_header_data( $filename ); + + // Retrieve EXIF information from the JPEG file + $Exif_array = get_EXIF_JPEG( $filename ); - // Retrieve XMP information from the JPEG file - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); - //$XMP_array = array(); - // Retrieve Photoshop IRB information from the JPEG file - $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); + // Retrieve XMP information from the JPEG file + $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); - // Retrieve Photoshop File Info from the three previous arrays - $new_ps_file_info_array = get_photoshop_file_info( $Exif_array, $XMP_array, $IRB_array ); + // Retrieve Photoshop IRB information from the JPEG file + $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); + // Retrieve Photoshop File Info from the three previous arrays + $new_ps_file_info_array = get_photoshop_file_info( $Exif_array, $XMP_array, $IRB_array ); +//echo '<pre>', print_r($new_ps_file_info_array), '</pre>'; - // Check if there is an array of defaults available - if ( ( isset( $default_ps_file_info_array) ) && - ( is_array( $default_ps_file_info_array) ) ) + // Check if there is an array of defaults available + if((isset($default_ps_file_info_array)) && + (is_array($default_ps_file_info_array))) + { + // There are defaults defined + // Check if there is a default for the date defined + if((!array_key_exists('date', $default_ps_file_info_array)) || + ((array_key_exists('date', $default_ps_file_info_array)) && + ($default_ps_file_info_array['date'] == '' ))) + { + /** + * No default for the date defined figure out a default from + * the file check if there is a EXIF Tag 36867 "Date and Time + * of Original" + */ + if(($Exif_array != FALSE) && + (array_key_exists(0, $Exif_array)) && + (array_key_exists(34665, $Exif_array[0])) && + (array_key_exists(0, $Exif_array[0][34665])) && + (array_key_exists(36867, $Exif_array[0][34665][0]))) + { + /** + * Tag "Date and Time of Original" found - use it for + * the default date + */ + $default_ps_file_info_array['date'] = + $Exif_array[0][34665][0][36867]['Data'][0]; + $default_ps_file_info_array['date'] = + preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); + } + /** + * Check if there is a EXIF Tag 36868 "Date and Time when + * Digitized" + */ + elseif(($Exif_array != FALSE) && + (array_key_exists(0, $Exif_array)) && + (array_key_exists(34665, $Exif_array[0])) && + (array_key_exists(0, $Exif_array[0][34665])) && + (array_key_exists(36868, $Exif_array[0][34665][0]))) + { + /** + * Tag "Date and Time when Digitized" found - use it for + * the default date + */ + $default_ps_file_info_array['date'] = + $Exif_array[0][34665][0][36868]['Data'][0]; + $default_ps_file_info_array['date'] = + preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); + } + /** + * Check if there is a EXIF Tag 306 "Date and Time" + */ + elseif(($Exif_array != FALSE) && + (array_key_exists(0, $Exif_array)) && + (array_key_exists(306, $Exif_array[0]))) + { + /** + * Tag "Date and Time" found - use it for the default date + */ + $default_ps_file_info_array['date'] = + $Exif_array[0][306]['Data'][0]; + $default_ps_file_info_array['date'] = + preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); + } + else + { + /** + * Couldn't find an EXIF date in the image set default date + * as creation date of file + */ + $default_ps_file_info_array['date'] = + date ("Y-m-d", filectime( $filename )); + } + } + /* + * Cycle through all the elements of the default values array + */ + foreach( $default_ps_file_info_array as $def_key =>$default_item ) + { + /** + * Check if the current element is Keywords or Supplemental + * Categories as these are arrays and need to be treated + * differently + */ + if((strcasecmp($def_key, "keywords") == 0) || + (strcasecmp($def_key, "supplementalcategories" ) == 0)) + { + /** + * Keywords or Supplemental Categories found check if the + * File Info from the file is empty for this element and if + * there are default values in this array element + */ + if((count($new_ps_file_info_array[ $def_key ]) == 0) && + (is_array($default_item)) && + (count($default_item) >= 0)) { - // There are defaults defined - - // Check if there is a default for the date defined - if ( ( ! array_key_exists( 'date', $default_ps_file_info_array ) ) || - ( ( array_key_exists( 'date', $default_ps_file_info_array ) ) && - ( $default_ps_file_info_array['date'] == '' ) ) ) - { - // No default for the date defined - // figure out a default from the file - - // Check if there is a EXIF Tag 36867 "Date and Time of Original" - if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 34665, $Exif_array[0] ) ) && - ( array_key_exists( 0, $Exif_array[0][34665] ) ) && - ( array_key_exists( 36867, $Exif_array[0][34665][0] ) ) ) - { - // Tag "Date and Time of Original" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36867]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - // Check if there is a EXIF Tag 36868 "Date and Time when Digitized" - else if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 34665, $Exif_array[0] ) ) && - ( array_key_exists( 0, $Exif_array[0][34665] ) ) && - ( array_key_exists( 36868, $Exif_array[0][34665][0] ) ) ) - { - // Tag "Date and Time when Digitized" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36868]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - // Check if there is a EXIF Tag 306 "Date and Time" - else if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 306, $Exif_array[0] ) ) ) - { - // Tag "Date and Time" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][306]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - else - { - // Couldn't find an EXIF date in the image - // Set default date as creation date of file - $default_ps_file_info_array['date'] = date ("Y-m-d", filectime( $filename )); - } - } - - // Cycle through all the elements of the default values array - foreach( $default_ps_file_info_array as $def_key =>$default_item ) - { - // Check if the current element is Keywords or - // Supplemental Categories as these are arrays - // and need to be treated differently - if ( ( strcasecmp( $def_key, "keywords" ) == 0 ) || - ( strcasecmp( $def_key, "supplementalcategories" ) == 0 ) ) - { - // Keywords or Supplemental Categories found - // Check if the File Info from the file is empty for this element - // and if there are default values in this array element - if ( ( count( $new_ps_file_info_array[ $def_key ] ) == 0 ) && - ( is_array( $default_item ) ) && - ( count( $default_item ) >= 0 ) ) - { - // The existing file info is empty, and there are - // defaults - add them - $new_ps_file_info_array[ $def_key ] = $default_item; - } - } - // Otherwise, this is not an array element, just check if it is blank in the existing file info - else if ( trim( $new_ps_file_info_array[ $def_key ] ) == "" ) - { - // The existing file info is blank, add the default value - $new_ps_file_info_array[ $def_key ] = $default_item; - } - - } + /** + * The existing file info is empty, and there are + * defaults - add them + */ + $new_ps_file_info_array[ $def_key ] = $default_item; } + } + /** + * Otherwise, this is not an array element, just check if it is + * blank in the existing file info + */ + elseif(trim($new_ps_file_info_array[$def_key] ) == "" ) + { + /** + * The existing file info is blank, add the default value + */ + $new_ps_file_info_array[ $def_key ] = $default_item; + } } - // Check for operation mode 4 - $new_ps_file_info_array and $filename are not defined, - else if ( ( ( !isset($new_ps_file_info_array) ) || ( ! is_array($new_ps_file_info_array) ) ) && - ( ( !isset($filename) ) || ( ! is_string( $filename ) ) ) ) - { - // No filename or new_ps_file_info_array defined, create a blank file info array to display - $new_ps_file_info_array = array( + } +} +/** + * Check for operation mode 4 - $new_ps_file_info_array and $filename are + * not defined, + */ +elseif(((!isset($new_ps_file_info_array)) || + (!is_array($new_ps_file_info_array))) && + ((!isset($filename)) || (!is_string($filename)))) +{ +/** + * No filename or new_ps_file_info_array defined, create a blank file + * info array to display + */ + $new_ps_file_info_array = array( "title" => "", "author" => "", "authorsposition" => "", @@ -245,41 +246,26 @@ "instructions" => "", "transmissionreference" => "", "urgency" => "" ); - } - +} /*************************************************************************** * * Now output the actual HTML form * ***************************************************************************/ -/** -?> - - - - <form name="EditJPEG" action="Write_File_Info.php" method="post"> - - - echo "<input name=\"filename\" type=\"hidden\" value=\"$outputfilename\">"; - - <table> -*/ +echo + "<tr>" . + "<td>Title</td>" . + "<td> ". + "<input size=49 class='linForms' name='title' type='text' + value=". htmlspecialchars($new_ps_file_info_array[ 'title' ], + ENT_QUOTES).">" . + "</td>" . + "</tr>"; ?> <tr> <td> - Title - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"title\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'title' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - <tr> - <td> Author </td> <td> Modified: trunk/linpha2/lib/include/metadata_xmp_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-02-21 10:42:02 UTC (rev 4687) +++ trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-02-28 17:41:13 UTC (rev 4688) @@ -19,42 +19,425 @@ */ /** - * This File handles XMP editing + * This file handles XMP MetaData editing + * * @package MetaData * @author bzrudi */ +if(!defined('LINPHA_DIR')) { exit(1); } + include LINPHA_DIR.'/lib/classes/pjmt/Toolkit_Version.php'; if ( isset( $filename ) && is_string( $filename )) { - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - // Accessing the existing file info for the specified file requires these includes - include_once( LINPHA_DIR.'/lib/classes/pjmt/JPEG.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/XMP.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php' ); +/** + * @TODO check what really needs to be included! + */ + include_once( LINPHA_DIR.'/lib/classes/pjmt/JPEG.php' ); + include_once( LINPHA_DIR.'/lib/classes/pjmt/XMP.php' ); + include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php' ); + include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); + include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php' ); - // Retrieve the header information from the JPEG file - $jpeg_header_data = get_jpeg_header_data( $filename ); + /** + * Retrieve the header information from the JPEG file + */ + $jpeg_header_data = get_jpeg_header_data( $filename ); + $XMP_from_image = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); - // Retrieve EXIF information from the JPEG file - $Exif_array = get_EXIF_JPEG( $filename ); + /** + * Check if the XMP tree structure array is valid + */ + if($XMP_from_image !== FALSE) + { + /** + * Check if there is a rdf:RDF tag at either the first or second level + */ + if(($XMP_array[0]['tag'] == "x:xapmeta") + && ($XMP_array[0]['children'][0]['tag'] == "rdf:RDF")) + { + /** + * RDF found at second level - Save it's position + */ + $RDF_Contents = &$XMP_array[0]['children'][0]['children']; + } + else if ( ( $XMP_array[0]['tag'] == "x:xmpmeta" ) + && ( $XMP_array[0]['children'][0]['tag'] == "rdf:RDF" ) ) + { + /** + * RDF found at second level - Save it's position + */ + $RDF_Contents = &$XMP_array[0]['children'][0]['children']; + } + else if ( $XMP_array[0]['tag'] == "rdf:RDF" ) + { + /** + * RDF found at first level - Save it's position + */ + $RDF_Contents = &$XMP_array[0]['children']; + } + } - // Retrieve XMP information from the JPEG file - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); +/** + * This function creates an array with all available fields from the XMP + * MetaData relation, as defined in linpha.metadata.class.php + * + * @param none + * @return array or in case of failure FALSE + * @author bzrudi + */ +function createNewEmptyXmpArray() +{ + /** + * create new empty array with no defaults + */ + foreach(array_values(LinMetaData::$Tags['xmp']) AS $value) + { + $new_xmp_array[$value['path']] = ""; + } + + if(is_array($new_xmp_array)) + { + return $new_xmp_array; + } + else + { + return FALSE; + } +} - // Retrieve Photoshop IRB information from the JPEG file - $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); +/** + * This function just prevents Notices when calling unset array data + * + * @param string + * @return string + * @author bzrudi + */ +function preventNotice($item) +{ + if(!isset($item)) + { + $item = ''; + } +return $item; +} - // Retrieve Photoshop File Info from the three previous arrays - $new_xmp_file_info_array = get_photoshop_file_info( $Exif_array, $XMP_array, $IRB_array ); +/** + * This function is mainly a copy from the pjmt, but as we need to have it mod + * slightly it's required. + * + * @param array XMP item + * @return array with key and value + * @author pjmt, bzrudi + */ +function linInterpretRdfItem( $Item ) +{ + $value_str = ""; -$test = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); -print_r($test); + /** + * Check if the item has is in the lookup table of tag captions + */ + if ( array_key_exists( $Item['tag'], $GLOBALS[ 'XMP_tag_captions' ] ) ) + { + /** + * Item is in list of captions, get the caption + */ + $tag_caption = $GLOBALS[ 'XMP_tag_captions' ][ $Item['tag'] ]; + } + else + { + /** + * Item has no caption - make one + */ + $tag_caption = "Unknown field " . $Item['tag']; + } + + /** + * Process specially the item according to it's tag + */ + switch($Item['tag']) + { + case "photoshopDateCreated": + list( $year, $month, $day ) = sscanf( $Item['value'], "%d-%d-%d" ); + /** + * Make a new date string with Day, Month, Year + */ + $value_str = "$day/$month/$year"; + break; + + default : + $value_str = linGetRdfField( $Item ); + break; + } + /** + * Return the caption and the value + */ + return array($tag_caption, $value_str); } + +/** + * This function is mainly a copy from the pjmt, but as we need to have it mod + * it slightly it's required + * + * @param array XMP item + * @return string interpreted item value + * @author pjmt, bzrudi + */ +function linGetRdfField($rdf_item) +{ + $output_str = ""; + + /** + * Check if the item has a value + */ + if(array_key_exists('value', $rdf_item)) + { + /** + * The item does have a value - add it to the text + */ + $output_str .= $rdf_item['value']; + } + + /** + * Check if the item has any attributes + */ + if (array_key_exists( 'attributes', $rdf_item)) + { + /** + * Cycle through each of the attributes + */ + foreach($rdf_item['attributes'] as $key => $val) + { + /** + * Check if this attribute is rdf:parseType = 'Resource' + * i.e. a sub-resource indicator + */ + if(($key == "rdf:parseType") && ($val == "Resource")) + { + /** + * This item has a attribute indicating sub-resources + */ + if (array_key_exists('children', $rdf_item)) + { + /** + * The item does have sub-items, Cycle through each, + * Interpreting them and adding the result to the + * output text + */ + foreach($rdf_item['children'] as $child) + { + list($tag_caption, $value_str) = linInterpretRdfItem($child); + $output_str .= "$tag_caption = $value_str\n"; + } + /** + * The output text will have an extra \n on it - remove it + */ + $output_str = rtrim($output_str); + } + } + } + } + /** + * If the item did not have sub-resources, it may still have + * sub-items - check for this + */ + else if (array_key_exists('children', $rdf_item)) + { + /** + * Non-resource Sub-items found, Cycle through each + */ + foreach($rdf_item['children'] as $child_item) + { + /** + * Check if this sub-item has a tag + */ + if (array_key_exists('tag', $child_item)) + { + /** + * Sub item has a tag, Process it according to the tag + */ + switch ($child_item['tag']) + { + // Collections + case "rdf:Alt": + $output_str .= interpret_RDF_collection( $child_item ); + break; + + case "rdf:Bag": + $output_str .= interpret_RDF_collection( $child_item ); + break; + + case "rdf:Seq": + $output_str .= interpret_RDF_collection( $child_item ); + break; + // Sub-Resource + case "rdf:Description": + // Check that the item has sub items + if (array_key_exists('children', $child_item)) + { + /** + * The item does have sub-items, Cycle through + * each, Interpreting them and adding the + * result to the output text + */ + foreach($child_item['children'] as $child) + { + list($tag_caption, $value_str) = + linInterpretRdfItem( $child ); + $output_str .= "$tag_caption = $value_str\n"; + } + /** + * The output text will have an extra \n on it + * - remove it + */ + $output_str = rtrim( $output_str ); + } + break; + + default: + $output_str .= "Unknown Item:".$child_item['tag']."\n"; + break; + } + } // sub-item Has no tags, look for a value + elseif(array_key_exists('value', $child_item)) + { + $output_str .= $rdf_item['value'] . "\n"; + } + } + } + // return the resulting value string + return $output_str; +} + +$XMP_default = createNewEmptyXmpArray(); + +foreach($RDF_Contents AS $RDF_Item) +{ + if(($RDF_Item['tag'] == "rdf:Description") + && (array_key_exists('children', $RDF_Item))) + { + /** + * Bingo item is a rdf:Description tag. + * Cycle through each of the attributes for this tag, looking + * for a xmlns: attribute, which tells us what Namespace the + * sub-items will be in. + */ + foreach( $RDF_Item['attributes'] as $key => $val ) + { + if(substr($key,0,6) == "xmlns:") +{ + /** + * Now lets take good care of the subchildren items and the + * data itself + */ + if(array_key_exists('children', $RDF_Item)) + { + /** + * Let's get each of the sub items + */ + foreach( $RDF_Item['children'] as $child_item ) + { + $XMP_default[$child_item['tag']] = + linInterpretRdfItem($child_item); + } + } + } + } + } +} +//echo '<pre>', print_r($XMP_default), '</pre>'; +//echo '<pre>', print_r($XMP_from_image), '</pre>'; +} + +/** + * Generate form data. + */ +echo "<tr>" . + "<td colspan='2'><b>".i18n("Photoshop XMP Segment")."</b><hr>" . + "</td></tr>"; + +foreach($XMP_default AS $key => $value) +{ + if(strpos($key, "photoshop") !== false) + { + echo + "<tr>" . + "<td>".$GLOBALS['XMP_tag_captions'][$key]."</td>" . + "<td>" . + "<input size='50' class='linForms' " . + "name=".$XMP_default[$key]." type='text' " . + "value=".@preventNotice($XMP_default[$key][1]).">" . + "</td>" . + "</tr>"; + } +} + +/** + * IPTC4XMP Core Segment Data + */ +echo "<tr><td colspan='2'> </td></tr>" . + "<tr>" . + "<td colspan='2'><b>".i18n("Iptc4xmp Core XMP Segment")."</b><hr>" . + "</td></tr>"; + +foreach($XMP_default AS $key => $value) +{ + if(strpos($key, "Iptc4xmpCore") !== false) + { + /** + * Iptc4xmpCore:SubjectCode needs special attention (unordered list) + */ + if($key == "Iptc4xmpCore:SubjectCode") + { + echo + "<tr>" . + "<td>".$GLOBALS['XMP_tag_captions'][$key]."</td>" . + "<td>" . + "<textarea class='linForms' " . + "name=".$XMP_default[$key]." rows='3' cols='50' wrap='off'>" . + "".@preventNotice($XMP_default[$key][1])."</textarea>" . + "</td>" . + "</tr>"; + } + else + { + echo + "<tr>" . + "<td>".$GLOBALS['XMP_tag_captions'][$key]."</td>" . + "<td>" . + "<input size='50' class='linForms' " . + "name=".$XMP_default[$key]." type='text' " . + "value=".@preventNotice($XMP_default[$key][1]).">" . + "</td>" . + "</tr>"; + } + + } +} + +/** + * DC Dublin Core Segment Data + */ +echo "<tr><td colspan='2'> </td></tr>" . + "<tr><td colspan='2'><b>".i18n("Dublin Core XMP Segment")."</b><hr>" . + "</td></tr>"; + +foreach($XMP_default AS $key => $value) +{ + if(strpos($key, "dc") !== false) + { + echo + "<tr>" . + "<td>".$GLOBALS['XMP_tag_captions'][$key]."</td>" . + "<td>" . + "<textarea class='linForms' " . + "name=".$XMP_default[$key]." rows='3' cols='50' wrap='off'>" . + "".@preventNotice($XMP_default[$key][1])."</textarea>" . + "</td>" . + "</tr>"; + } +} +/* vi: set ts=4 sw=4 sts=4 */ ?> - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-18 12:22:39
|
Revision: 4699 http://svn.sourceforge.net/linpha/?rev=4699&view=rev Author: bzrudi Date: 2007-03-17 09:29:01 -0700 (Sat, 17 Mar 2007) Log Message: ----------- made PJMT work again for EXIF data and set to default as metadata tool for now... Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.pjmt.class.php trunk/linpha2/lib/modules/module.search.php trunk/linpha2/templates/default/search.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-17 12:02:05 UTC (rev 4698) +++ trunk/linpha2/ChangeLog 2007-03-17 16:29:01 UTC (rev 4699) @@ -1,4 +1,11 @@ 2007-03-17 bzrudi + * PJMT is working again and the default for now, even so exiftool also works + fine for EXIF data right now. ;-) + Status: Currently EXIF should work again using PJMT and exiftool. No IPTC, + no XMP, no searching and tons of other littel bugs and + improvements left open. + +2007-03-17 bzrudi * Next step towards clean MetaData handling. Rewitten MetaData classes and tons of ot other things. Naturally most everything is broken this time. This update requires to run "reset_database.php" and will only work for @@ -14,7 +21,7 @@ will replace PJMT even for EXIF data once it's been testet. PJMT will just be available as fallback when ExifTool can't be used for some reason. Do not expect MetaData working smoothly right now, it's just dirt hacking - to get some results using ExifTool. Things will get better of the next + to get some results using ExifTool. Things will get better over the next weeks ;-) This includes rewrite of of the linpha.metadata.class.php and friends. Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2007-03-17 12:02:05 UTC (rev 4698) +++ trunk/linpha2/install/sql/sql.data.php 2007-03-17 16:29:01 UTC (rev 4699) @@ -36,7 +36,7 @@ 'sys_import_autoimport' => '1', 'sys_import_exif' => '1', 'sys_import_exif_autorot' => '1', - 'sys_import_use_exiftool' => '1', + 'sys_import_use_exiftool' => '0', 'sys_image_exif' => '1', 'sys_image_iptc' => '0', Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-17 12:02:05 UTC (rev 4698) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-17 16:29:01 UTC (rev 4699) @@ -113,7 +113,7 @@ * Save all MetaData to database * @param string $filename filename to parse for MetaData * @param string $md5sum md5sum of file - * @param string $tag save IPTC or XMP MetaData + * @param string $tag save EXIF, IPTC or XMP MetaData */ function saveMetaData($filename, $md5sum, $tag) { @@ -158,10 +158,64 @@ } } - public function getRotationByExifTag($rotation) + + /** + * Simple method to return just exif date and orientation tag during + * import as needed by linpha_photos, this is not used for any meta_x table. + * example: 2004:02:14 18:24:19 and -90 + * + * @param string $dirname, $filename + * @return array $time_exif (unix timestamp) + * $rotate (degrees to rotate) + * @author bzrudi,flo + **/ + public function getBasicMeta($dirname, $filename) { - $rotate = "0"; - return $rotate; + $return = ""; + $meta = ""; + $filename = "".$dirname."/".$filename.""; + $parameters = "-exif:datetimeoriginal " . // Get date tag + "-exif:orientation " . // Get orientation tag + "-s -n -t"; // Print tag name tab seper. + + exec("$this->exiftool $parameters $filename", $meta, $return); + + if(is_array($meta)) + { + foreach($meta AS $value) + { + $temp = explode("\t", $value); + $metaArray[strtolower(trim($temp['0']))] = @trim($temp['1']); + } + + } + + $date = $metaArray['datetimeoriginal']; + if(strlen($date) > 4) + { + $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); + $time_exif = mktime($hour, $min, $sec, $month, $day, $year); + } + else + { + $time_exif = "0"; + } + + if($metaArray['orientation']) + { + $rotate = $metaArray['orientation']; + } + else + { + $rotate = "0"; + } + + return array($time_exif, $rotate); } /** Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2007-03-17 12:02:05 UTC (rev 4698) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2007-03-17 16:29:01 UTC (rev 4699) @@ -475,25 +475,37 @@ */ if( $GLOBALS['linpha']->sql->config->value['sys_import_exif'] ) { - include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); + + /** + * Get EXIF date and orientation tag from image if avail + */ + list($time_exif, $rotate) = $MetaData->getBasicMeta($dirname, $filename); + + + /* + include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); $meta = get_EXIF_JPEG($dirname.'/'.$filename); - + */ /** * get date */ + /* if( isset($meta[0][34665]['Data'][0][36867]['Data'][0]) ) { $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'] && isset($meta[0][274]['Data'][0]) ) { $rotate = 0; //$rotate = $MetaData->getRotationByExifTag( $meta[0][274]['Data'][0] ); } + */ } } } Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-17 12:02:05 UTC (rev 4698) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-17 16:29:01 UTC (rev 4699) @@ -590,21 +590,7 @@ $this->available_fields = $this->objMetaTool->available_fields; } - - /** - * Simple wrapper method to take care of used MetaData Toolkit - * @param string $rotation - * @return string degrees to rotate - * @author bzrudi - */ - public function getRotationByExifTag($rotation) - { - $this->objMetaTool->getRotationByExifTag($rotation); - } - - - - + public function createMetaDataTable($array, $metatype) { if (!is_array($array)) @@ -695,23 +681,94 @@ } /** - * converts a exif date to a unix timestamp + * Simple wrapper method to convert an exif date to an unix timestamp + * and also return orientation tag if avail * example: 2004:02:14 18:24:19 -> 11167594589 * - * @author flo * @param string $date * @return int unix timestamp + * @author flo,bzrudi + **/ + public function getBasicMeta($dirname, $filename) + { + + list($time_exif, $rotate) = + $this->objMetaTool->getBasicMeta($dirname, $filename); + + if(isset($rotate)) + { + $rotate = $this->getRotationByExifTag($rotate); + } + return array($time_exif, $rotate); + + } + + /** + * 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 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); + protected 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 class LinMetaData +} /* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/lib/classes/linpha.pjmt.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.pjmt.class.php 2007-03-17 12:02:05 UTC (rev 4698) +++ trunk/linpha2/lib/classes/linpha.pjmt.class.php 2007-03-17 16:29:01 UTC (rev 4699) @@ -26,14 +26,22 @@ */ class LinPjmtTool extends LinMetaData { - + /** + * Constructor + */ function __construct() { } - - public function saveMetaData($filename, $md5sum, $metatype) { + /** + * Save all MetaData to database + * @param string $filename filename to parse for MetaData + * @param string $md5sum md5sum of file + * @param string $tag save IPTC or XMP MetaData + */ + public function saveMetaData($filename, $md5sum, $metatype) + { include_once (LINPHA_DIR . '/lib/classes/pjmt/JPEG.php'); include_once (LINPHA_DIR . '/lib/classes/pjmt/EXIF.php'); @@ -44,17 +52,23 @@ * get exif info from file */ $exif_data = get_EXIF_JPEG($filename); - if ($exif_data) { + if($exif_data) + { /** * special tags */ // Canon Owner Name append to Artist - if (isset ($exif_data['Makernote_Tag']['Decoded Data']) && is_array($exif_data['Makernote_Tag']['Decoded Data']) // sometimes 'Decoded Data' is an empty string - && isset ($exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value'])) { + if (isset ($exif_data['Makernote_Tag']['Decoded Data']) + && is_array($exif_data['Makernote_Tag']['Decoded Data']) // sometimes 'Decoded Data' is an empty string + && isset ($exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value'])) + { $owner = $exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value']; - if (isset ($exif_data[0][315]['Text Value'])) { + if (isset ($exif_data[0][315]['Text Value'])) + { $exif_data[0][315]['Text Value'] .= $owner; - } else { + } + else + { $exif_data[0][315]['Text Value'] = $owner; } @@ -63,33 +77,40 @@ /** * search for valid tags */ - foreach ($this->defined_fields['exif'] AS $key => $value) - //foreach(LinMetaData::$Tags['exif'] AS $key=>$value) + foreach($this->defined_fields['exif'] AS $key => $value) + { + if(!empty(LinPjmtTool::$metaTags['exif'][$key]['pathvalue'])) { - if (!empty ($objMetaTool->metaTags['exif'][$key]['pathvalue'])) { /** - * there are currently only entries at level deep 2 and 5 in the array + * there are currently only entries at level deep 2 and 5 + * in the array */ - $array_pieces = explode('/', $objMetaTool->metaTags['exif'][$key]['pathvalue']); - switch (count($array_pieces)) { + $ap = explode('/', + LinPjmtTool::$metaTags['exif'][$key]['pathvalue']); + + switch(count($ap)) + { case 2 : - if (isset ($exif_data[$array_pieces[0]][$array_pieces[1]]['Text Value'])) { + if(isset($exif_data[$ap[0]][$ap[1]]['Text Value'])) + { $str_columns .= $key . ', '; - $exif_value = $exif_data[$array_pieces[0]][$array_pieces[1]]['Text Value']; + $exif_value = $exif_data[$ap[0]][$ap[1]]['Text Value']; $str_values .= "'" . LinSql :: linAddslashes(trim($exif_value)) . "', "; } break; case 5 : - if (isset ($exif_data[$array_pieces[0]][$array_pieces[1]][$array_pieces[2]][$array_pieces[3]][$array_pieces[4]]['Text Value'])) { + if(isset ($exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value'])) + { $str_columns .= $key . ', '; - $exif_value = $exif_data[$array_pieces[0]][$array_pieces[1]][$array_pieces[2]][$array_pieces[3]][$array_pieces[4]]['Text Value']; + $exif_value = $exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value']; $str_values .= "'" . LinSql :: linAddslashes(trim($exif_value)) . "', "; } break; default : - echo "Error no valid path for key: " . $key . " value: " . $objMetaTool->metaTags['exif'][$key]['pathvalue'] . "<br />"; + echo "Error no valid path for key: " . $key . " value: " . + LinPjmtTool::$metaTags['exif'][$key]['pathvalue'] . "<br />"; break; } } @@ -98,10 +119,12 @@ /** * add jpegcomment */ - if (isset ($this->defined_fields['exif']['jpegcomment'])) { + if(isset ($this->defined_fields['exif']['jpegcomment'])) + { $jpeg_header_data = get_jpeg_header_data($filename); $comment = get_jpeg_Comment($jpeg_header_data); - if (!empty ($comment)) { + if(!empty ($comment)) + { $str_columns .= 'jpegcomment, '; $str_values .= "'" . LinSql :: linAddslashes(trim($comment)) . "', "; } @@ -114,13 +137,14 @@ $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); $str_values = substr($str_values, 0, strlen($str_values) - 2); - $GLOBALS['linpha']->db->Execute("INSERT into " . LIN_PREFIX . "meta_exif (" . $str_columns . ") " . - "VALUES (" . $str_values . ")"); + $GLOBALS['linpha']->db->Execute("INSERT INTO " . LIN_PREFIX . + "meta_exif (" . $str_columns . ") " . + "VALUES (" . $str_values . ")"); } /** - * define tags to index and set available fields + * Define tags to index and set available fields * @param string $tag [exif] */ public function setMetaFields($tag) @@ -156,72 +180,57 @@ } } + /** - * 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"; + * Simple method to return just exif date and orientation tag during + * import as needed by linpha_photos, this is not used for any meta_x table. + * example: 2004:02:14 18:24:19 and -90 + * + * @param string $dirname, $filename + * @return array $time_exif (unix timestamp) + * $rotate (degrees to rotate) + * @author bzrudi,flo + **/ + public function getBasicMeta($dirname, $filename) + { + include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); + $date = ""; + $meta = get_EXIF_JPEG($dirname.'/'.$filename); + + if(isset($meta[0][34665]['Data'][0][36867]['Data'][0]) ) + { + $date = $meta[0][34665]['Data'][0][36867]['Data'][0]; } - return $rotate; + + if(strlen($date) > 4) + { + $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); + $time_exif = mktime($hour, $min, $sec, $month, $day, $year); + } + else + { + $time_exif = "0"; + } + + if(isset($meta[0][274]['Data'][0])) + { + $rotate = $meta[0][274]['Data'][0]; + } + else + { + $rotate = "0"; + } + + + return array($time_exif, $rotate); + } - + /** * Define array with allowed EXIF tags and human readable translation * @param none Modified: trunk/linpha2/lib/modules/module.search.php =================================================================== --- trunk/linpha2/lib/modules/module.search.php 2007-03-17 12:02:05 UTC (rev 4698) +++ trunk/linpha2/lib/modules/module.search.php 2007-03-17 16:29:01 UTC (rev 4699) @@ -245,8 +245,7 @@ /** * exif/iptc/xmp */ - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); - $MetaData = new LinExifTool(); + $MetaData = new LinMetaData(); /** * exif Modified: trunk/linpha2/templates/default/search.html.php =================================================================== --- trunk/linpha2/templates/default/search.html.php 2007-03-17 12:02:05 UTC (rev 4698) +++ trunk/linpha2/templates/default/search.html.php 2007-03-17 16:29:01 UTC (rev 4699) @@ -78,8 +78,7 @@ echo '<label for="b_'.$data['id'].'">'.$data['name'].'</label><br />'; } - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); - $MetaData = new LinExifTool(); + $MetaData = new LinMetaData(); /** * Exif/Iptc/Xmp Informations This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-18 12:25:08
|
Revision: 4693 http://svn.sourceforge.net/linpha/?rev=4693&view=rev Author: bzrudi Date: 2007-03-17 01:42:20 -0700 (Sat, 17 Mar 2007) Log Message: ----------- Major rewrites in MetaData handling. Please SEE Changelog for known issues! Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/step9_createtables.php trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.pjmt.class.php Property Changed: ---------------- trunk/linpha2/albums/ Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-17 08:04:06 UTC (rev 4692) +++ trunk/linpha2/ChangeLog 2007-03-17 08:42:20 UTC (rev 4693) @@ -1,3 +1,12 @@ +2007-03-17 bzrudi + * Next step towards clean MetaData handling. Rewitten MetaData classes and + tons of ot other things. Naturally most everything is broken this time. + This update requires to run "reset_database.php" and will only work for + UNIX this time, no win, no mac!. This will change, once I got PJMT back + to working correctly (which is the next thing todo). + Status: Currently only EXIF works using exiftool on unix. Hopefully I get + more things up and running over this weekend + 2007-03-14 bzrudi * Start of complete rewrite the MetaData stuff. PJMT is a mess for class based programming and no longer really activ. I switched to ExifTool as tool of Property changes on: trunk/linpha2/albums ___________________________________________________________________ Name: svn:ignore - 20* test* alb* lost+found + 20* test* alb* lost+found special Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2007-03-17 08:04:06 UTC (rev 4692) +++ trunk/linpha2/install/step9_createtables.php 2007-03-17 08:42:20 UTC (rev 4693) @@ -233,4 +233,4 @@ } include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file +?> Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-17 08:04:06 UTC (rev 4692) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-17 08:42:20 UTC (rev 4693) @@ -25,11 +25,10 @@ * @package MetaData * @author bzrudi */ -class LinExifTool +class LinExifTool extends LinMetaData { private $exiftool, $filename; -public $defined_fields, $available_fields; /** * Constructor @@ -53,10 +52,6 @@ $this->exiftool = LINPHA_DIR.'/lib/classes/exiftool/exiftool.???'; } - - //$this->filename = "/tmp/test.JPG"; - //$this->filename = "/tmp/iptc.jpg"; - //$this->filename = "/tmp/xmp.jpg"; } /** @@ -80,20 +75,20 @@ /** * This method reads all available MetaData (Group) Information from image. - * @param string $tag iptc, xmp, exif, makernotes... + * @param string $metatype iptc, xmp, exif, makernotes... * @param string $filename * @return array Array with all available Tag informations * @author bzrudi * @todo respect exec return status, don't use filename as input (security) */ - public function readMetaDataFromFile($tag, $filename) + public function readMetaDataFromFile($metatype, $filename) { $meta =""; $return=""; $metaArray = array(); - $parameters = "-$tag:all " . // Get all Tag Information - "-s "; // Print tag names instead of descr. + $parameters = "-$metatype:all " . // Get all Tag Information + "-s "; // Print tag names instead of descr. exec("$this->exiftool $parameters $filename", $meta, $return); @@ -114,32 +109,88 @@ /** + * Save all MetaData to database + * @param string $filename filename to parse for MetaData + * @param string $md5sum md5sum of file + * @param string $tag save IPTC or XMP MetaData + */ + function saveMetaData($filename, $md5sum, $tag) + { + include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); + $objExifTool = new LinExifTool; + $objExifTool->setMetaFields($tag); + + $dataArray = $this->readMetaDataFromFile($tag, $filename); + +// echo '<pre>', print_r($dataArray), '</pre>'; + + $str_columns = "md5sum, "; + $str_values = "'" . $md5sum . "', "; + + if(is_array($dataArray)) + { + /** + * Lower array data to make it compareable to LinExifTool::$metaTags + */ + $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); + + /** + * Search for valid and filled tags + */ + foreach($this->defined_fields[$tag] AS $key => $value) + { + if(array_key_exists($key, $lowerDataArray)) + { + $str_columns .= $key . ', '; + $str_values .= "'".utf8_encode(trim($lowerDataArray[$key]))."', "; + } + } + + /** + * Remove last two signs (the comma and the space) which we add to much + */ + $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); + $str_values = substr($str_values, 0, strlen($str_values) - 2); + + $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_$tag " . + "(" . $str_columns . ") VALUES (" . $str_values . ")"); + } + } + + public function getRotationByExifTag($rotation) + { + $rotate = "0"; + return $rotate; + } + + /** * This method defines tags to index, e.g. create them in MetaData relation. * And also sets available fields, e.g. those defined in $metaTags, but * not used in database yet. - * @param string $tag [exif,iptc,xmp] + * @param string $metatype [exif,iptc,xmp] * @return array fileds already selected to be used (defined_fields) * and also available fields from $metaTags (available_fields) * @author bzrudi,flo */ - public function setMetaFields($tag) + public function setMetaFields($metatype) { + /** * Create defined_fields var, use a new array with lowercase keys and * without the md5sum entry. * MetaColumns() returns the keys always uppercase independent * of ADODB_ASSOC_CASE setting, so strtolower() them. */ - $array = $GLOBALS['linpha']->db->MetaColumns(LIN_PREFIX."meta_".$tag); - $this->defined_fields[$tag] = array (); + $array = $GLOBALS['linpha']->db->MetaColumns(LIN_PREFIX."meta_".$metatype); + $this->defined_fields[$metatype] = array (); foreach ($array AS $key => $value) { - if ($key != 'MD5SUM') + if ($key != 'MD5SUM') //todo check array_pop { $new_key = strtolower($key); - $this->defined_fields[$tag][$new_key] = - LinExifTool::$metaTags[$tag][$new_key]; + $this->defined_fields[$metatype][$new_key] = + LinExifTool::$metaTags[$metatype][$new_key]; } } @@ -147,11 +198,11 @@ * Create available_fields, mostly used in admin section where one will * setup the MetaData fields to index. */ - foreach (LinExifTool::$metaTags[$tag] AS $key => $value) + foreach (LinExifTool::$metaTags[$metatype] AS $key => $value) { - if (!isset ($this->defined_fields[$tag][$key])) + if (!isset ($this->defined_fields[$metatype][$key])) { - $this->available_fields[$tag][$key] = $value; + $this->available_fields[$metatype][$key] = $value; } } } @@ -187,7 +238,6 @@ 'title' => 'Title', //Adobe Photoshop schema tags - 'authorsposition' => 'Authors Position', 'captionwriter' => 'Caption Writer', 'category' => 'Category', @@ -205,40 +255,139 @@ 'transmissionreference' => 'Transmission Reference', 'urgency' => 'urgency' - ), + ), - //IPTC schema tags - 'iptc' => array( + //IPTC schema tags + 'iptc' => array( - //IPTC ApplicationRecord Tags - 'applicationrecordversion' => 'Application Record Version', - 'objecttypereference' => 'Object Type Reference', - 'objectattributereference' => 'Object Attribute Reference', - 'objectname' => 'Object Name', - 'editstatus' => 'Edit Status', - 'subjectreference' => 'Subject Reference', - 'category' => 'Category', - 'supplementalcategories' => 'Supplemental Categories', - 'keywords' => 'Keywords', - 'specialinstructions' => 'Special Instructions', - 'datecreated' => 'Date Created', - 'timecreated' => 'Time Created', - 'byline' => 'By-line', - 'bylinetitle' => 'By-line Title', - 'city' => 'City', - 'sublocation' => 'Sub-location', - 'provincestate' => 'Province-State', - 'countryprimarylocationcode' => 'Country-Primary Location Code', - 'countryprimarylocationname' => 'Country-Primary Location Name', - 'originaltransmissionreference' => 'Original Transmission Reference', - 'headline' => 'Headline', - 'credit' => 'Credit', - 'source' => 'Source', - 'copyrightnotice' => 'Copyright Notice', - 'contact' => 'Contact', - 'captionabstract' => 'Caption-Abstract', - 'writereditor' => 'Writer-Editor' - ) + //IPTC ApplicationRecord Tags + 'applicationrecordversion' => 'Application Record Version', + 'objecttypereference' => 'Object Type Reference', + 'objectattributereference' => 'Object Attribute Reference', + 'objectname' => 'Object Name', + 'editstatus' => 'Edit Status', + 'subjectreference' => 'Subject Reference', + 'category' => 'Category', + 'supplementalcategories' => 'Supplemental Categories', + 'keywords' => 'Keywords', + 'specialinstructions' => 'Special Instructions', + 'datecreated' => 'Date Created', + 'timecreated' => 'Time Created', + 'byline' => 'By-line', + 'bylinetitle' => 'By-line Title', + 'city' => 'City', + 'sublocation' => 'Sub-location', + 'provincestate' => 'Province-State', + 'countryprimarylocationcode' => 'Country-Primary Location Code', + 'countryprimarylocationname' => 'Country-Primary Location Name', + 'originaltransmissionreference' => 'Original Transmission Reference', + 'headline' => 'Headline', + 'credit' => 'Credit', + 'source' => 'Source', + 'copyrightnotice' => 'Copyright Notice', + 'contact' => 'Contact', + 'captionabstract' => 'Caption-Abstract', + 'writereditor' => 'Writer-Editor' + ), + + //EXIF schema tags + 'exif' => array( + + //IFD0 + 'processingsoftware' => 'Processing Software', + 'imagewidth' => 'Image Width', + 'imagelength' => 'Image Length', + 'bitspersample' => 'Bits Per Sample', + 'compression' => 'Compression', + 'photometricinterpretation' => 'Photometric Interpretation', + 'thresholding' => 'Thresholding', + 'cellwidth' => 'Cell Width', + 'celllength' => 'Cell Length', + 'fillorder' => 'Fill Order', + 'documentname' => 'Document Name', + 'imagedescription' => 'Image Description', + 'make' => 'Maker', + 'model' => 'Model', + 'orientation' => 'Orientation', + 'samplesperpixel' => 'Samples Per Pixel', + 'rowsperstrip' => 'Rows Per Strip', + 'minsamplevalue' => 'Min Sample Value', + 'maxsamplevalue' => 'Max Sample Value', + 'xresolution' => 'X Resolution', + 'yresolution' => 'Y Resolution', + 'planarconfiguration' => 'Planar Configuration', + 'pagename' => 'Page Name', + 'xposition' => 'X Position', + 'yposition' => 'Y Position', + 'grayresponseunit' => 'Gray Response Unit', + 'resolutionunit' => 'Resolution Unit', + 'pagenumber' => 'Page Number', + 'software' => 'Software', + 'modifydate' => 'Modify Date', + 'artist' => 'Artist', + 'hostcomputer' => 'Host Computer', + 'predictor' => 'Predictor', + 'whitepoint' => 'White Point', + 'primarychromaticities' => 'Primary Chromaticities', + 'halftonehints' => 'Halftone Hints', + 'tilewidth' => 'Tile Width', + 'tilelength' => 'Tile Length', + 'ycbcrcoefficients' => 'YCbCr Coefficients', + 'ycbcrsubsampling' => 'YCbCr Sub Sampling', + 'ycbcrpositioning' => 'YCbCr Positioning', + 'referenceblackwhite' => 'Reference Black White', + 'relatedimagefileformat' => 'Related Image File Format', + 'relatedimagewidth' => 'Related Image Width', + 'relatedimagelength' => 'Related Image Length', + 'rating' => 'Rating', + 'ratingpercent' => 'Rating Percent', + 'copyright' => 'Copyright', + + //ExifIFD + 'exposuretime' => 'Exposure Time', + 'fnumber' => 'F Number', + 'exposureprogram' => 'Exposure Program', + 'spectralsensitivity' => 'Spectral Sensitivity', + 'iso' => 'ISO', + 'timezoneoffset' => 'Time Zone Offset', + 'selftimermode' => 'Self Timer Mode', + 'exifversion' => 'Exif Version', + 'datetimeoriginal' => 'Date Time Original', + 'createdate' => 'Create Date', + 'componentsconfiguration' => 'Components Configuration', + 'compressedbitsperpixel' => 'Compressed Bits Per Pixel', + 'shutterspeedvalue' => 'Shutter Speed Value', + 'aperturevalue' => 'Aperture Value', + 'brightnessvalue' => 'Brightness Value', + 'exposurecompensation' => 'Exposure Compensation', + 'maxaperturevalue' => 'Max Aperture Value', + 'subjectdistance' => 'Subject Distance', + 'meteringmode' => 'Metering Mode', + 'lightsource' => 'Light Source', + 'flash' => 'Flash', + 'focallength' => 'Focal Length', + 'imagenumber' => 'Image Number', + 'securityclassification' => 'Security Classification', + 'imagehistory' => 'Image History', + 'subjectlocation' => 'Subject Location', + 'exposureindex' => 'Exposure Index', + 'sensingmethod' => 'Sensing Method', + 'filesource' => 'File Source', + 'scenetype' => 'Scene Type', + 'cfapattern' => 'CFA Pattern', + 'customrendered' => 'Custom Rendered', + 'exposuremode' => 'Exposure Mode', + 'whitebalance' => 'White Balance', + 'digitalzoomratio' => 'Digital Zoom Ratio', + 'focallengthin35mmformat' => 'Focal Length In 35mm Format', + 'scenecapturetype' => 'Scene Capture Type', + 'gaincontrol' => 'Gain Control', + 'contrast' => 'Contrast', + 'saturation' => 'Saturation', + 'sharpness' => 'Sharpness', + 'subjectdistancerange' => 'Subject Distance Range', + 'gamma' => 'Gamma' + ) ); } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-03-17 08:04:06 UTC (rev 4692) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-03-17 08:42:20 UTC (rev 4693) @@ -50,6 +50,7 @@ */ function __construct() { + } @@ -625,7 +626,7 @@ * create thumbnail info text (filename, description, etc.) */ $i=0; - //$MetaData = new LinMetaDataRead(); + foreach($this->photos_filtered AS $key=>$photo_value) { if($_SESSION['mode_thumbview'] == 'thumbdetail') { @@ -945,8 +946,6 @@ /** * album informations */ - //todo: check function and remove - //$MetaData = new LinMetaDataRead(); foreach($this->photos_filtered AS $photo_key=>$photo_value) { $array_image_infos = LinMetaData::readInformations($photo_value,$flag_nr=12); @@ -1260,13 +1259,11 @@ $this->viewImgSetPrevNextThumb(); $this->viewImgStoreImageInformation(); - - //todo: check function and remove - //$MetaData = new LinMetaDataRead(); + $GLOBALS['linpha']->template->output['image_infos'] = - LinMetaData::readInformations($this->photos_filtered[$this->current_key], - $flag_nr=10 - ); + LinMetaData::readInformations($this->photos_filtered[$this->current_key], + $flag_nr=10); + } /** @@ -1314,21 +1311,22 @@ */ function viewImgStoreImageInformation() { - $array_meta = array('exif','iptc','xmp'); + $array_meta = array('exif'); //,'iptc','xmp'); foreach($array_meta AS $value) { - if( !isset($MetaData) ) - { - $MetaData = new LinMetaDataIndex(); - } - - /** - * read exif/iptc/xmp from file if no entry - */ - if($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) - { - $MetaData->saveData( $value, $this->src_file, $this->md5sum ); - } + /* + if(!isset($MetaData)) + { + //$MetaData = new LinMetaData(); + } + */ + /** + * read exif/iptc/xmp from file if no entry + */ + if($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) + { + LinMetaData::saveData( $value, $this->src_file, $this->md5sum ); + } } } Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2007-03-17 08:04:06 UTC (rev 4692) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2007-03-17 08:42:20 UTC (rev 4693) @@ -464,6 +464,8 @@ if( LinIdentify::isSupportedImage($file_type) ) { + + $MetaData = new LinMetaData(); /** * exif date and exif rotate stuff * globally turn off using 'sys_import_exif' if having problems with pjmt @@ -480,8 +482,8 @@ * get date */ if( isset($meta[0][34665]['Data'][0][36867]['Data'][0]) ) { - $time_exif = LinMetaDataIndex::convertExifDateToUnix( $meta[0][34665]['Data'][0][36867]['Data'][0] ); - } + $time_exif = $MetaData->convertExifDateToUnix( $meta[0][34665]['Data'][0][36867]['Data'][0] ); + } /** * get rotate information @@ -489,7 +491,8 @@ */ if( $GLOBALS['linpha']->sql->config->value['sys_import_exif_autorot'] && isset($meta[0][274]['Data'][0]) ) { - $rotate = LinMetaDataIndex::getRotationByExifTag( $meta[0][274]['Data'][0] ); + $rotate = 0; + //$rotate = $MetaData->getRotationByExifTag( $meta[0][274]['Data'][0] ); } } } Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-17 08:04:06 UTC (rev 4692) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-17 08:42:20 UTC (rev 4693) @@ -29,362 +29,6 @@ if (!defined('LINPHA_DIR')) { exit (1); } /** - * Admin functions to select the tags which should be indexed - */ -class LinMetaDataAdmin extends LinMetaData { - function createMetaDataTable($array = '', $meta_type) { - - if (!is_array($array) && $meta_type == 'exif') { - $array = $this->getDefaultExifFields(); - } - elseif(!is_array($array)) { - $array = array(); - } - - if (LIN_DB_TYPE == "mysql") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_$meta_type (" . - "md5sum VARCHAR(32) NOT NULL, "; - foreach ($array AS $key => $value) { - $str .= LinSql :: linAddslashes(strtolower($value)) . " VARCHAR(255), "; - } - $str .= "PRIMARY KEY (md5sum), "; - $str .= "KEY (md5sum) )"; - } - elseif (LIN_DB_TYPE == "sqlite") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_$meta_type (" . - "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; - foreach ($array AS $key => $value) { - $str .= strtolower($value) . " VARCHAR(255), "; - } - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str, 0, strlen($str) - 2) . ")"; - } - elseif (LIN_DB_TYPE == "postgres") { - $str = "CREATE TABLE " . LIN_PREFIX . "meta_$meta_type (" . - "md5sum VARCHAR(32) NOT NULL, "; - - foreach ($array AS $key => $value) { - $str .= strtolower($value) . " VARCHAR(255), "; - } - - /** - * remove last 2 signs (the comma and the space) - */ - $str = substr($str, 0, strlen($str) - 2) . ")"; - } - return $str; - } - - function getDefaultExifFields() { - return Array ( - 'datetimeoriginal', - 'make', - 'model', - 'artist', - 'copyright', - 'aperturevalue', - 'shutterspeedvalue', - 'exposuretime', - 'isospeedratings', - 'flash', - 'focallength', - 'fnumber' - ); - } - -} // end class LinMetaDataAdmin - - -/** - * Index functions (save data in DB) - */ -class LinMetaDataIndex extends LinMetaData -{ - /** - * wrapper function for saveExifData, saveIptcData and saveXmpData - * for easier access - */ - function saveData($what, $filename, $md5sum) { - /** - * no double entries - * do this check at very first position to improve performance! - * also do not setFields in the __contruct() because they may never be used - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum " . - "FROM " . LIN_PREFIX . "meta_" . $what . " " . - "WHERE md5sum = '" . $md5sum . "'"); - - if ($query->EOF) // not a single value returned - { - /** - * define tags to index if not already done - */ - if (!isset ($this->defined_fields[$what])) { - /** - * @todo remove, once exif is handled by exiftool - */ - if($what != 'exif') - { - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); - $objExifTool = new LinExifTool; - $objExifTool->setMetaFields($what); - } - else - { - include_once(LINPHA_DIR.'/lib/classes/linpha.pjmt.class.php'); - //$objExifTool = new LinExifTool; - //$objExifTool->setMetaFields($what); - //$this->setFields($what); - LinPjmtTool::setMetaFields($what); - } - } - - /** - * @todo remove, once exif is handled by exiftool - */ - switch ($what) { - case 'exif' : - $this->saveExifData($filename, $md5sum); - break; - default: - $this->saveMetaData($filename, $md5sum, $what); - break; - } - } - } - - /** - * store EXIF data in DB - * - * create an entry in the db even if we haven't found anything - * to prevent img_view.class.php to call this function every time - * the image is viewed - */ - function saveExifData($filename, $md5sum) { - include_once (LINPHA_DIR . '/lib/classes/pjmt/JPEG.php'); - include_once (LINPHA_DIR . '/lib/classes/pjmt/EXIF.php'); - - $str_columns = "md5sum, "; - $str_values = "'" . $md5sum . "', "; - - /** - * get exif info from file - */ - $exif_data = get_EXIF_JPEG($filename); - if ($exif_data) { - /** - * special tags - */ - // Canon Owner Name append to Artist - if (isset ($exif_data['Makernote_Tag']['Decoded Data']) && is_array($exif_data['Makernote_Tag']['Decoded Data']) // sometimes 'Decoded Data' is an empty string - && isset ($exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value'])) { - $owner = $exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value']; - if (isset ($exif_data[0][315]['Text Value'])) { - $exif_data[0][315]['Text Value'] .= $owner; - } else { - $exif_data[0][315]['Text Value'] = $owner; - } - - } - - /** - * search for valid tags - */ - foreach ($this->defined_fields['exif'] AS $key => $value) - //foreach(LinMetaData::$Tags['exif'] AS $key=>$value) - { - if (!empty (LinMetaData :: $Tags['exif'][$key]['pathvalue'])) { - /** - * there are currently only entries at level deep 2 and 5 in the array - */ - $array_pieces = explode('/', LinMetaData :: $Tags['exif'][$key]['pathvalue']); - switch (count($array_pieces)) { - case 2 : - if (isset ($exif_data[$array_pieces[0]][$array_pieces[1]]['Text Value'])) { - $str_columns .= $key . ', '; - - $exif_value = $exif_data[$array_pieces[0]][$array_pieces[1]]['Text Value']; - $str_values .= "'" . LinSql :: linAddslashes(trim($exif_value)) . "', "; - } - break; - case 5 : - if (isset ($exif_data[$array_pieces[0]][$array_pieces[1]][$array_pieces[2]][$array_pieces[3]][$array_pieces[4]]['Text Value'])) { - $str_columns .= $key . ', '; - - $exif_value = $exif_data[$array_pieces[0]][$array_pieces[1]][$array_pieces[2]][$array_pieces[3]][$array_pieces[4]]['Text Value']; - $str_values .= "'" . LinSql :: linAddslashes(trim($exif_value)) . "', "; - } - break; - default : - echo "Error no valid path for key: " . $key . " value: " . LinMetaData :: $Tags['exif'][$key]['pathvalue'] . "<br />"; - break; - } - } - } - - /** - * add jpegcomment - */ - if (isset ($this->defined_fields['exif']['jpegcomment'])) { - $jpeg_header_data = get_jpeg_header_data($filename); - $comment = get_jpeg_Comment($jpeg_header_data); - if (!empty ($comment)) { - $str_columns .= 'jpegcomment, '; - $str_values .= "'" . LinSql :: linAddslashes(trim($comment)) . "', "; - } - } - } - - /** - * remove last two signs (the comma and the space) which we added to much - */ - $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); - $str_values = substr($str_values, 0, strlen($str_values) - 2); - - $GLOBALS['linpha']->db->Execute("INSERT into " . LIN_PREFIX . "meta_exif (" . $str_columns . ") " . - "VALUES (" . $str_values . ")"); - } - - /** - * Save all MetaData to database - * @param string $filename filename to parse for MetaData - * @param string $md5sum md5sum of file - * @param string $tag save IPTC or XMP MetaData - */ - function saveMetaData($filename, $md5sum, $tag) - { - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); - $objExifTool = new LinExifTool; - $objExifTool->setMetaFields($tag); - - $dataArray = $objExifTool->readMetaDataFromFile($tag, $filename); - -// echo '<pre>', print_r($dataArray), '</pre>'; - - $str_columns = "md5sum, "; - $str_values = "'" . $md5sum . "', "; - - if(is_array($dataArray)) - { - /** - * Lower array data to make it compareable to LinExifTool::$metaTags - */ - $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); - - /** - * Search for valid and filled tags - */ - foreach($objExifTool->defined_fields[$tag] AS $key => $value) - { - if(array_key_exists($key, $lowerDataArray)) - { - $str_columns .= $key . ', '; - $str_values .= "'".utf8_encode(trim($lowerDataArray[$key]))."', "; - } - } - - /** - * Remove last two signs (the comma and the space) which we add to much - */ - $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); - $str_values = substr($str_values, 0, strlen($str_values) - 2); - - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_$tag " . - "(" . $str_columns . ") VALUES (" . $str_values . ")"); - - //echo "<br>BUILDSTRING: ". ".$tag. " . $str_columns . "+" . $str_values; - } - } - - /** - * 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 LinMetaDataIndex - -/** * Modificate MetaData and save the information back to the file (IPTC and XMP) */ class LinMetaDataModificate extends LinMetaData { @@ -570,79 +214,31 @@ } } } +} - /** - * save IPTC MetaData back to file - * - * copied from pjmt/Write_File_Info.php - */ - function saveModifiedMetaDataIptc(& $new_ps_file_info_array, $filename) { - include_once (LINPHA_DIR . '/lib/classes/pjmt/JPEG.php'); - include_once (LINPHA_DIR . '/lib/classes/pjmt/XMP.php'); - include_once (LINPHA_DIR . '/lib/classes/pjmt/Photoshop_IRB.php'); - include_once (LINPHA_DIR . '/lib/classes/pjmt/EXIF.php'); - include_once (LINPHA_DIR . '/lib/classes/pjmt/Photoshop_File_Info.php'); - $GLOBALS["Software Name"] = "LinPHA v" . LINPHA_VERSION . ", powered by PHP JPEG Metadata Toolkit v" . $GLOBALS['Toolkit_Version']; - - // Keywords should be an array - explode it on newline boundarys - $new_ps_file_info_array['keywords'] = explode("\n", trim($new_ps_file_info_array['keywords'])); - - // Supplemental Categories should be an array - explode it on newline boundarys - $new_ps_file_info_array['supplementalcategories'] = explode("\n", trim($new_ps_file_info_array['supplementalcategories'])); - - // Retrieve the header information - $jpeg_header_data = get_jpeg_header_data($filename); - - // Retreive the EXIF, XMP and Photoshop IRB information from - // the existing file, so that it can be updated - $Exif_array = get_EXIF_JPEG( $filename ); - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); - $IRB_array = get_Photoshop_IRB($jpeg_header_data); - - // Update the JPEG header information with the new Photoshop File Info - $jpeg_header_data = put_photoshop_file_info($jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array); - - // Check if the Update worked - if ($jpeg_header_data == FALSE) { - /** - * echo "Error - Failure update Photoshop File Info : $filename <br>\n"; - */ - linSysLog(i18n("Error: Failure update Photoshop File Info:") . ' ' . $filename); - linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Failure update Photoshop File Info:" . ' ' . $filename); - - return false; - } - - // Attempt to write the new JPEG file - elseif (FALSE == put_jpeg_header_data($filename, $filename, $jpeg_header_data)) { - /** - * echo "Error - Failure to write new JPEG : $filename <br>\n"; - */ - linSysLog(i18n("Error: Failure to write new JPEG:") . ' ' . $filename); - linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Failure to write new JPEG:" . ' ' . $filename); - - return false; - } else { - // Writing of new JPEG succeeded - linSysLog(i18n("DONE! Updated:") . ' ' . $filename); - linLog(LOG_TYPE_META, LOG_NOTICE, 'meta_iptc', "Updated:" . ' ' . $filename); - - return true; - } - } - -} // end class LinMetaDataModificate - - class LinMetaData { - + +public $defined_fields, $available_fields; +protected $objMetaTool; private $cachedFieldNames, $cachedFieldIds, $cachedSelectedFieldNames; + /** + * Constructor + */ function __construct() { - + if($GLOBALS['linpha']->sql->config->value['sys_import_use_exiftool']) + { + include_once LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'; + $this->objMetaTool = new LinExifTool(); + } + else + { + include_once LINPHA_DIR.'/lib/classes/linpha.pjmt.class.php'; + $this->objMetaTool = new LinPjmtTool(); + } } /** @@ -665,7 +261,8 @@ { $query = $GLOBALS['linpha']->db->Execute("SELECT name " . "FROM " . LIN_PREFIX . "meta_fields " . - "WHERE flags = '" . $flag_nr . "' ORDER by id"); + "WHERE flags = '" . $flag_nr . "' " . + "ORDER by id"); while ($fields_data = $query->FetchRow(ADODB_FETCH_NUM)) { @@ -886,19 +483,21 @@ } break; case 'exif' : - $value = LinPjmtTool::$metaTags['exif'][$last_part]['name']; - if ($show_metadata_extra_info) { +// $value = $this->objMetaTool->metaTags['exif'][$last_part]['name']; + $value = $this->objMetaTool->metaTags['exif'][$las_part]; + + if ($show_metadata_extra_info) { $value .= ' (EXIF Resource)'; } break; case 'iptc' : - $value = LinExifTool::$metaTags['iptc']; + $value = $this->objMetaTool->metaTags['iptc'][$last_part]; if ($show_metadata_extra_info) { $value .= ' (IPTC Resource)'; } break; case 'xmp' : - $value = LinExifTool::$metaTags['xmp']; + $value = $this->objMetaTool->metaTags['xmp'][$last_part]; if ($show_metadata_extra_info) { $value .= ' (XMP Resource)'; } @@ -907,6 +506,212 @@ return $value; } + + /** + * This method is used to setup the initial most useful defaults for the + * MetaData tables EXIF/IPTC/XMP during creation + * @param string exif,iptc,xmp + * @return array initial metadata values used for table create + * @author bzrudi,flo + */ + private function getDefaultMetaTags($type) + { + switch($type) + { + case 'exif': + return array ( + 'datetimeoriginal', + 'make', + 'model', + 'artist', + 'copyright', + 'aperturevalue', + 'shutterspeedvalue', + 'exposuretime', + 'isospeedratings', + 'flash', + 'focallength', + 'fnumber' + ); + break; + + case 'iptc': + return array ( + 'supplementalcategories', + 'keywords', + 'datecreated', + 'timecreated', + 'byline', + 'city', + 'provincestate', + 'headline', + 'credit', + 'copyrightnotice', + 'writereditor' + ); + break; + + case 'xmp': + return array ( + 'location', + 'date', + 'description', + 'publisher', + 'rights', + 'title', + 'captionwriter', + 'category', + 'credit', + 'datecreated', + 'headline', + 'instructions', + 'supplementalcategories', + ); + break; + + default: + return array(); + break; + } + + } + + /** + * Simple wrapper method to take care of used MetaData Toolkit + * @param string $metatype exif,iptc,xmp + * @return none + * @author bzrudi + */ + public function setMetaFields($metatype) + { + $this->objMetaTool->setMetaFields($metatype); + $this->defined_fields = $this->objMetaTool->defined_fields; + $this->available_fields = $this->objMetaTool->available_fields; + } + + + /** + * Simple wrapper method to take care of used MetaData Toolkit + * @param string $rotation + * @return string degrees to rotate + * @author bzrudi + */ + public function getRotationByExifTag($rotation) + { + $this->objMetaTool->getRotationByExifTag($rotation); + } + + + + + public function createMetaDataTable($array, $metatype) + { + if (!is_array($array)) + { + $array = $this->getDefaultMetaTags($metatype); + } + + if (LIN_DB_TYPE == "mysql") + { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_$metatype " . + "(md5sum VARCHAR(32) NOT NULL, "; + foreach ($array AS $key => $value) + { + $str .= LinSql::linAddslashes(strtolower($value))."VARCHAR(255), "; + } + $str .= "PRIMARY KEY (md5sum), "; + $str .= "KEY (md5sum) )"; + } + elseif (LIN_DB_TYPE == "sqlite") + { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_$metatype " . + "(md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; + foreach ($array AS $key => $value) + { + $str .= strtolower($value) . " VARCHAR(255), "; + } + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str, 0, strlen($str) - 2) . ")"; + } + elseif (LIN_DB_TYPE == "postgres") + { + $str = "CREATE TABLE " . LIN_PREFIX . "meta_$metatype " . + "(md5sum VARCHAR(32) NOT NULL, "; + + foreach ($array AS $key => $value) + { + $str .= strtolower($value) . " VARCHAR(255), "; + } + + /** + * remove last 2 signs (the comma and the space) + */ + $str = substr($str, 0, strlen($str) - 2) . ")"; + } + return $str; + } + + + /** + * wrapper function for saveExifData, saveIptcData and saveXmpData + * for easier access + */ + function saveData($what, $filename, $md5sum) { + /** + * no double entries + * do this check at very first position to improve performance! + * also do not setMetaFields in the __contruct() because they may never be used + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum " . + "FROM " . LIN_PREFIX . "meta_" . $what . " " . + "WHERE md5sum = '" . $md5sum . "'"); + + if ($query->EOF) // not a single value returned + { + /** + * define tags to index if not already done + */ + if (!isset ($this->defined_fields[$what])) + { + $this->objMetaTool->setMetaFields($what); + } + switch($what) + { + case 'exif': + $this->objMetaTool->saveMetaData($filename, $md5sum, $what); + break; + case 'iptc': + $this->objMetaTool->saveMetaData($filename, $md5sum, $what); + break; + case 'xmp': + $this->objMetaTool->saveMetaData($filename, $md5sum, $what); + break; + } + + } + } + + /** + * 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 LinMetaData +/* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/lib/classes/linpha.pjmt.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.pjmt.class.php 2007-03-17 08:04:06 UTC (rev 4692) +++ trunk/linpha2/lib/classes/linpha.pjmt.class.php 2007-03-17 08:42:20 UTC (rev 4693) @@ -24,16 +24,101 @@ * @package MetaData * @author bzrudi,flo */ -class LinPjmtTool +class LinPjmtTool extends LinMetaData { -public $available_fields, $defined_fields; - function __construct() { } + + public function saveMetaData($filename, $md5sum, $metatype) { + include_once (LINPHA_DIR . '/lib/classes/pjmt/JPEG.php'); + include_once (LINPHA_DIR . '/lib/classes/pjmt/EXIF.php'); + + $str_columns = "md5sum, "; + $str_values = "'" . $md5sum . "', "; + + /** + * get exif info from file + */ + $exif_data = get_EXIF_JPEG($filename); + if ($exif_data) { + /** + * special tags + */ + // Canon Owner Name append to Artist + if (isset ($exif_data['Makernote_Tag']['Decoded Data']) && is_array($exif_data['Makernote_Tag']['Decoded Data']) // sometimes 'Decoded Data' is an empty string + && isset ($exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value'])) { + $owner = $exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value']; + if (isset ($exif_data[0][315]['Text Value'])) { + $exif_data[0][315]['Text Value'] .= $owner; + } else { + $exif_data[0][315]['Text Value'] = $owner; + } + + } + + /** + * search for valid tags + */ + foreach ($this->defined_fields['exif'] AS $key => $value) + //foreach(LinMetaData::$Tags['exif'] AS $key=>$value) + { + if (!empty ($objMetaTool->metaTags['exif'][$key]['pathvalue'])) { + /** + * there are currently only entries at level deep 2 and 5 in the array + */ + $array_pieces = explode('/', $objMetaTool->metaTags['exif'][$key]['pathvalue']); + switch (count($array_pieces)) { + case 2 : + if (isset ($exif_data[$array_pieces[0]][$array_pieces[1]]['Text Value'])) { + $str_columns .= $key . ', '; + + $exif_value = $exif_data[$array_pieces[0]][$array_pieces[1]]['Text Value']; + $str_values .= "'" . LinSql :: linAddslashes(trim($exif_value)) . "', "; + } + break; + case 5 : + if (isset ($exif_data[$array_pieces[0]][$array_pieces[1]][$array_pieces[2]][$array_pieces[3]][$array_pieces[4]]['Text Value'])) { + $str_columns .= $key . ', '; + + $exif_value = $exif_data[$array_pieces[0]][$array_pieces[1]][$array_pieces[2]][$array_pieces[3]][$array_pieces[4]]['Text Value']; + $str_values .= "'" . LinSql :: linAddslashes(trim($exif_value)) . "', "; + } + break; + default : + echo "Error no valid path for key: " . $key . " value: " . $objMetaTool->metaTags['exif'][$key]['pathvalue'] . "<br />"; + break; + } + } + } + + /** + * add jpegcomment + */ + if (isset ($this->defined_fields['exif']['jpegcomment'])) { + $jpeg_header_data = get_jpeg_header_data($filename); + $comment = get_jpeg_Comment($jpeg_header_data); + if (!empty ($comment)) { + $str_columns .= 'jpegcomment, '; + $str_values .= "'" . LinSql :: linAddslashes(trim($comment)) . "', "; + } + } + } + + /** + * remove last two signs (the comma and the space) which we added to much + */ + $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); + $str_values = substr($str_values, 0, strlen($str_values) - 2); + + $GLOBALS['linpha']->db->Execute("INSERT into " . LIN_PREFIX . "meta_exif (" . $str_columns . ") " . + "VALUES (" . $str_values . ")"); + } + + /** * define tags to index and set available fields * @param string $tag [exif] @@ -55,7 +140,7 @@ { $new_key = strtolower($key); $this->defined_fields[$tag][$new_key] = - LinPjmtTool::$Tags[$tag][$new_key]['name']; + LinPjmtTool::$metaTags[$tag][$new_key]['name']; } } @@ -71,8 +156,73 @@ } } - /** + * 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; + } + + /** * Define array with allowed EXIF tags and human readable translation * @param none * @return none This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-18 12:57:59
|
Revision: 4700 http://svn.sourceforge.net/linpha/?rev=4700&view=rev Author: bzrudi Date: 2007-03-18 05:57:57 -0700 (Sun, 18 Mar 2007) Log Message: ----------- more metadata fixes and cleanups in classes, exif should work again Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/metadata_define.php trunk/linpha2/admin/metadata_define_post.php trunk/linpha2/admin/metadata_select.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.pjmt.class.php trunk/linpha2/templates/default/view_albmeta.html.php trunk/linpha2/templates/default/view_img_static.html.php Property Changed: ---------------- trunk/linpha2/albums/ Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/ChangeLog 2007-03-18 12:57:57 UTC (rev 4700) @@ -1,3 +1,13 @@ +2007-03-18 bzrudi + * linpha.import.class.php: Make PJMT tool of choice while running import, as + it faster and we just need basic exif information here. Namely exifdate and + orientation for use in linpha_photos. + However, it may be a wise choice to fall back to exiftool if we are low + on PHP memory limit, let's say 8MB or so. (Installer Task) + * More MetaData improvements in Admin section. EXIF should now be fully + functional again (PJMT) + * linpha.metadata.class: more cleanups and improvements + 2007-03-17 bzrudi * PJMT is working again and the default for now, even so exiftool also works fine for EXIF data right now. ;-) @@ -2,3 +12,3 @@ Status: Currently EXIF should work again using PJMT and exiftool. No IPTC, - no XMP, no searching and tons of other littel bugs and + no XMP, no searching and tons of other little bugs and improvements left open. Modified: trunk/linpha2/admin/metadata_define.php =================================================================== --- trunk/linpha2/admin/metadata_define.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/admin/metadata_define.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -72,19 +72,52 @@ show_add_data(); break; case 'exif': - echo i18n("EXIF data is usually created by the any Digital Camera. These values will be indexed for searching and displaying them, but can't be edited with LinPHA."); + echo i18n("EXIF data is usually created by the any Digital Camera. " . + "These values will be indexed for searching and displaying them, " . + "but can't be edited with LinPHA."); echo '<br />'; - echo i18n("Hint: You should't choose all available EXIF tags because the database table may get to large (MySQL) and therefore could result in an error."); + echo i18n("Hint: You should't choose all available EXIF tags because " . + "the database table may get to large (MySQL) and therefore could " . + "result in an error."); echo '<br /><br /><br />'; show_metadata(); break; case 'iptc': + if($GLOBALS['linpha']->sql->config->value['sys_import_use_exiftool']) + { + echo i18n("IPTC/XMP data is usually not available by default."); + echo i18n("It needs to be filled up either with LinPHA, or with any " . + "other external program which allows IPTC/XMP editing like " . + "Photoshop. IPTC/XMP is a standard within professional " . + "Photographer business."); + echo '<br /><br />'; + show_metadata(); + } + else + { + echo i18n("IPTC disabled due missing dependencies. Exiftool can't " . + "be used in your configuration. Please see the LinPHA FAQ " . + "for details"); + } +break; case 'xmp': - echo i18n("IPTC/XMP data is usually not available by default."); - echo i18n("It needs to be filled up either with LinPHA, or with any external program which allows IPTC/XMP editing like Photoshop. IPTC/XMP is a standard within professional Photographer business."); - echo '<br /><br />'; - show_metadata(); - break; + if($GLOBALS['linpha']->sql->config->value['sys_import_use_exiftool']) + { + echo i18n("IPTC/XMP data is usually not available by default."); + echo i18n("It needs to be filled up either with LinPHA, or with any " . + "other external program which allows IPTC/XMP editing like " . + "Photoshop. IPTC/XMP is a standard within professional " . + "Photographer business."); + echo '<br /><br />'; + show_metadata(); + } + else + { + echo i18n("XMP is disabled due missing dependencies. Exiftool can't " . + "be used in your configuration. Please see the LinPHA FAQ " . + "for details"); + } +break; } function show_own_fields() Modified: trunk/linpha2/admin/metadata_define_post.php =================================================================== --- trunk/linpha2/admin/metadata_define_post.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/admin/metadata_define_post.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -133,8 +133,7 @@ } else { @$linpha->db->Execute("DROP TABLE ".LIN_PREFIX."meta_$cat3"); } - $MetaData = new LinMetaData(); - $linpha->db->Execute($MetaData->createMetaDataTable( $_POST['selected_fields'], $cat3)); + $linpha->db->Execute(LinMetaData::createMetaDataTable( $_POST['selected_fields'], $cat3)); } break; Modified: trunk/linpha2/admin/metadata_select.php =================================================================== --- trunk/linpha2/admin/metadata_select.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/admin/metadata_select.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -200,7 +200,6 @@ <?php $MetaData->setMetaFields('iptc'); foreach($MetaData->defined_fields['iptc'] AS $key=>$value) - //foreach(LinExifTool::$metaTags['iptc'] AS $key=>$value) { echo '<option value="iptc_'.$key.'">'.$value.'</option>'; } Property changes on: trunk/linpha2/albums ___________________________________________________________________ Name: svn:ignore - 20* test* alb* lost+found special + 20* test* alb* lost+found special ausfluege haus_und_garten mbesa Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -1147,7 +1147,7 @@ /** * save modified MetaData */ - LinMetaDataModificate::saveModifiedMetaData(); + LinMetaData::saveModifiedMetaData(); } @@ -1240,7 +1240,7 @@ while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) { ?> <comment> - <time><?php echo linStrftime($data['meta_time']); ?></time> + <time><?php echo htmlspecialchars(linStrftime($data['meta_time'])); ?></time> <author><?php echo htmlspecialchars($data['meta_author'],ENT_QUOTES); ?></author> <text><?php echo str_replace('<','<',linHtmlTag($data['meta_comment'],ENT_QUOTES) ); ?></text> </comment> @@ -1280,11 +1280,10 @@ * save comment */ if( isset( $_POST['cmd'] ) && $_POST['cmd']=='add_comment' - && isset($_POST['inputAddCommentAuthor']) && !empty($_POST['inputAddCommentAuthor']) - && ( ( isset($_POST['inputAddCommentText']) && !empty($_POST['inputAddCommentText']) ) - || ( isset($_POST['inputAddCommentTextarea']) && !empty($_POST['inputAddCommentTextarea']) ) - ) - ) + && isset($_POST['inputAddCommentAuthor']) + && !empty($_POST['inputAddCommentAuthor']) + && ((isset($_POST['inputAddCommentText']) && !empty($_POST['inputAddCommentText'])) + || (isset($_POST['inputAddCommentTextarea']) && !empty($_POST['inputAddCommentTextarea'])))) { if( !empty($_POST['inputAddCommentTextarea'])) { $comment = $_POST['inputAddCommentTextarea']; @@ -1325,7 +1324,7 @@ */ if($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) { - $MetaData->saveData( $value, $this->src_file, $this->md5sum ); + $MetaData->saveData($value, $this->src_file, $this->md5sum ); } } } @@ -1437,7 +1436,7 @@ /** * save modified MetaData */ - LinMetaDataModificate::saveModifiedMetaData(); + LinMetaData::saveModifiedMetaData(); $this->viewImgCommon(); } Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -478,41 +478,53 @@ /** * Get EXIF date and orientation tag from image if avail + * I found that PJMT is faster than exiftool for this purpose + * about ten times, so we only make use of PJMT for performance + * reasons here. + * However, it may be a wise choice to fall back to exiftool if + * we are low on PHP memory limit, let's say 8MB or so. + * TODO make use if low on memory and exiftool is avail */ - list($time_exif, $rotate) = $MetaData->getBasicMeta($dirname, $filename); - - - /* + //list($time_exif, $rotate) = + //$MetaData->getBasicMeta($dirname, $filename); + include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); $meta = get_EXIF_JPEG($dirname.'/'.$filename); - */ + /** * get date */ - /* - if( isset($meta[0][34665]['Data'][0][36867]['Data'][0]) ) { - $time_exif = $MetaData->convertExifDateToUnix( $meta[0][34665]['Data'][0][36867]['Data'][0] ); + if(isset($meta[0][34665]['Data'][0][36867]['Data'][0])) + { + $date = $meta[0][34665]['Data'][0][36867]['Data'][0]; + + $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); + + $time_exif = mktime($hour, $min, $sec, $month, $day, $year); } - */ - + /** * get rotate information * turn off exif autorotate using 'sys_import_exif_autorot' */ - /* - if( $GLOBALS['linpha']->sql->config->value['sys_import_exif_autorot'] && isset($meta[0][274]['Data'][0]) ) + if($GLOBALS['linpha']->sql->config->value['sys_import_exif_autorot'] + && isset($meta[0][274]['Data'][0]) ) { - $rotate = 0; - //$rotate = $MetaData->getRotationByExifTag( $meta[0][274]['Data'][0] ); + $rotate = $MetaData->getRotationByExifTag($meta[0][274]['Data'][0] ); } - */ + } } } else // this should not happen { - linSysLog(i18n("Import").': Error: what am i? '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)); - linLog(LOG_TYPE_IMPORT,LOG_NOTICE,'import_fileinfo','Error: what am i? '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)); + linSysLog(i18n("Import").': Error: Filename? '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)); + linLog(LOG_TYPE_IMPORT,LOG_NOTICE,'import_fileinfo','Error: Filename? '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)); } return array($md5sum,$file_type,$org_width,$org_height,$stats_number,$time_exif,$rotate,$filesize); Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -1,5 +1,4 @@ <?php - /* * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> * Florian Angehrn @@ -19,204 +18,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +if (!defined('LINPHA_DIR')) { exit (1); } + /** * This is the baseclass to handle all the EXIF/IPTC/XMP stuff used in LinPHA * It is extended by LinExifTool and LinPjmtTool class * @package MetaData - * @author flo, bzrudi + * @author bzrudi,flo */ - -if (!defined('LINPHA_DIR')) { exit (1); } - -/** - * Modificate MetaData and save the information back to the file (IPTC and XMP) - */ -class LinMetaDataModificate extends LinMetaData { - function showEditMetaData() { - /** - * set meta linpha - */ - $GLOBALS['linpha']->template->output['meta_linpha'] = ''; - - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, flags " . - "FROM " . LIN_PREFIX . "meta_fields " . - "WHERE flags = '5' OR flags = '7' ORDER by id"); - while ($data = $query->FetchRow()) { - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<tr><td width="150" valign="top">'; - - if ($data['flags'] == 5) { - $GLOBALS['linpha']->template->output['meta_linpha'] .= LinMetaData :: getNameOfField('builtin_' . $data['name'], false); - } - elseif ($data['flags'] == 7) { - $GLOBALS['linpha']->template->output['meta_linpha'] .= LinMetaData :: getNameOfField('id_' . $data['id'], false); - } - $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td><td>'; - - $meta_data = $GLOBALS['linpha']->db->GetRow("SELECT meta_data FROM " . LIN_PREFIX . "meta_data " . - "WHERE md5sum = '" . $GLOBALS['linpha']->imgview->md5sum . "'" . - "AND field_id = '" . $data['id'] . "'"); - - switch ($data['field_type']) { - case 1 : - if (isset ($meta_data['meta_data'])) { - $value = htmlspecialchars($meta_data['meta_data'], ENT_QUOTES); - } else { - $value = ''; - } - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<input type="text" class="linForms" name="linMetaField[' . - $data['id'] . ']" ' . - 'value="' . $value . '" style="width: 250px;" maxlength="255" />'; - break; - case 3 : - if (isset ($meta_data['meta_data'])) { - $value = htmlspecialchars($meta_data['meta_data'], ENT_QUOTES); - } else { - $value = ''; - } - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<input type="text" class="linForms" name="linMetaField[' . - $data['id'] . ']" id="linField' . $data['id'] . '" value="' . $value . '" style="width: 150px;" maxlength="255" />' . - ' <a href="javascript:void(0);" onclick="var loginWin = window.open(\'' . LINPHA_CLIENT . '/lib/include/calendar.php?form=linField' . $data['id'] . '\'' . - ',\'Calendar\',\'height=250,width=300,scrollbars=no,menubar=no,status=no\');" target="_top">' . i18n("Calendar") . '</a>'; - - break; - case 2 : - if (isset ($meta_data['meta_data'])) { - $array_pieces = linExplodeAndSlice(';', $meta_data['meta_data']); - } else { - $array_pieces = Array (); - } - - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<select name="linMetaField[' . $data['id'] . '][]" class="linForms" size="7" multiple="multiple" style="width: 250px;">'; - - $cat_query = $GLOBALS['linpha']->db->Execute("SELECT id, name " . - "FROM " . LIN_PREFIX . "meta_category " . - "WHERE field_id = '" . $data['id'] . "'"); - while ($cat_data = $cat_query->FetchRow()) { - if (in_array($cat_data['id'], $array_pieces)) { - $checked = ' selected="selected"'; - } else { - $checked = ''; - } - - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<option value="' . $cat_data['id'] . '"' . $checked . '>' . htmlspecialchars($cat_data['name'], ENT_QUOTES) . '</option>' . "\n"; - } - $GLOBALS['linpha']->template->output['meta_linpha'] .= '</select>' . "\n" . - '<br /><span style="font-size: smaller;">' . i18n("For Multiple Select Use CTRL") . '</span>'; - - if ($GLOBALS['linpha']->sql->isAdmin()) { - $GLOBALS['linpha']->template->output['meta_linpha'] .= '<br /><span style="font-size: smaller;"><a href="' . LINPHA_CLIENT . '/admin/?cat=metadata_define_adddata">' . i18n("Add More Options") . '</a><br /><br /></span>'; - } - - break; - } - - $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td></tr>'; - } - - /** - * set meta IPTC - */ - if ($GLOBALS['linpha']->sql->config->value['sys_image_iptc'] || $GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { - if (isset ($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) { - if (is_writable($GLOBALS['linpha']->imgview->src_file)) { - $meta_edit_possible = true; - $filename = $GLOBALS['linpha']->imgview->src_file; // used in IPTC Edit_File_Info.php - } else { - $meta_edit_possible = false; - } - } else { - $meta_edit_possible = false; - } - } - /** - * build the meta data view - */ - $fragment = 'edit_meta'; - global $linTpl; - include (LINPHA_DIR . '/templates/' . $this->template_name . '/fragments.php'); - - } // end function showEditMetaData() - - /** - * save meta linpha and meta iptc separetaly - */ - function saveModifiedMetaData() { - if ($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) { - /** - * write linpha meta data - */ - if (isset ($_POST['linCmd']) && $_POST['linCmd'] == 'linInsertMetaLinpha') { - LinMetaDataModificate :: saveModifiedMetaDataLinpha(); - linSysLog(i18n("Successfully updated data.")); - } - - /** - * write iptc data - */ - if (isset ($_POST['linCmd']) && $_POST['linCmd'] == 'linInsertMetaIptc' && $GLOBALS['linpha']->sql->config->value['sys_image_iptc'] && isset ($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) { - global $new_ps_file_info_array; - $new_ps_file_info_array = $GLOBALS['_POST']; - - /** - * important! - * remove other POST data from this array, because pjmt just takes all values and this will generate unexpected results!!! - * we got problems because $_POST['linMetaField'] is an array and pjmt couldnt handle this - */ - unset ($new_ps_file_info_array['linCmd']); - unset ($new_ps_file_info_array['linMetaField']); - unset ($new_ps_file_info_array['submit']); - - /** - * if the backup went wrong, the saveModifiedMetaDataIptc() would most probably also fail - */ - if (LinFilesys :: backupFile($GLOBALS['linpha']->imgview->src_file)) { - if (LinMetaDataModificate :: saveModifiedMetaDataIptc($new_ps_file_info_array, $GLOBALS['linpha']->imgview->src_file)) // error handling already done - { - /** - * force read data from file again if write was successful - */ - unset ($new_ps_file_info_array); - LinImport :: updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); - } - } else { - linSysLog(sprintf(i18n("Error: Cannot create backup of: %s"), $GLOBALS['linpha']->imgview->src_file)); - linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Cannot create backup of:" . ' ' . $GLOBALS['linpha']->imgview->src_file); - } - } - } - } - - /** - * save modified linpha meta data to database - */ - function saveModifiedMetaDataLinpha() { - if (isset ($_POST['linMetaField']) && is_array($_POST['linMetaField'])) { - /** - * delete existing entries - */ - $query = $GLOBALS['linpha']->db->Execute("DELETE FROM " . LIN_PREFIX . "meta_data " . - "WHERE md5sum = '" . $GLOBALS['linpha']->imgview->md5sum . "'"); - - /** - * insert new entries - */ - foreach ($_POST['linMetaField'] AS $key => $value) { - if (is_array($value)) // coming from a select (categories etc.) - { - $value = ';' . implode(';', $value) . ';'; - } - - if (!empty ($value)) { - $GLOBALS['linpha']->db->Execute("INSERT into " . LIN_PREFIX . "meta_data " . - "(field_id, md5sum, meta_data) VALUES " . - "('" . LinSql :: linAddslashes($key) . "','" . $GLOBALS['linpha']->imgview->md5sum . "','" . LinSql :: linAddslashes($value) . "')"); - } - } - } - } -} - - class LinMetaData { @@ -242,22 +51,21 @@ } /** - * read image information from database - * and escape data with htmlspecialchars() if necessary - * + * Read image information from database and escape data using + * htmlspecialchars() if necessary * @param array array_src_infos array containing needed source file - * informations, same as LIN_SELECT_FIELDS - * + * informations, same as LIN_SELECT_FIELDS (edit bzrudi ????) + * @author flo,bzrudi */ public function readInformations($array_src_infos, $flag_nr) { /** - * cache field names if not already done - * readInformations() is executed for each thumbnail on a folder - * save a lot of time if do it only once! + * Cache field names if not already done as readInformations() is + * executed for each thumbnail on a folder this should save a lot of + * time if do it only once! */ if (!isset ($this->cachedSelectedFieldNames) - OR !is_array($this->cachedSelectedFieldNames)) + OR !is_array($this->cachedSelectedFieldNames)) { $query = $GLOBALS['linpha']->db->Execute("SELECT name " . "FROM " . LIN_PREFIX . "meta_fields " . @@ -275,6 +83,11 @@ $name = LinMetaData::getNameOfField($field_name, false); $value = ''; + /** + * Example exif_orientation will become + * $first_part = exif + * $last_part = orientation + */ $pos = strpos($field_name, '_'); $first_part = substr($field_name, 0, $pos); $last_part = substr($field_name, $pos +1); @@ -282,230 +95,498 @@ switch ($first_part) { case 'builtin' : - switch ($last_part) { case 'filename' : - $value = $array_src_infos['name']; // already escaped - break; + $value = $array_src_infos['name']; // already esc. + break; case 'imagesize' : - $value = LinFilesys :: niceFilesize($array_src_infos['filesize'], 2); - break; + $value = LinFilesys::niceFilesize($array_src_infos['filesize'], 2); + break; case 'dimension' : $value = $array_src_infos['width'] . 'x' . $array_src_infos['height']; - break; + break; case 'thumbnail' : $value = 'thumbnail'; - break; + break; case 'time_add' : $name = i18n("Date Added"); $value = linStrftime($array_src_infos['time_add']); - break; + break; case 'time_mod' : $name = i18n("Date Modified"); $value = linStrftime($array_src_infos['time_mod']); - break; + break; case 'time_exif' : $name = i18n("Date Taken"); $value = linStrftime($array_src_infos['time_exif']); - break; + break; case 'stats_numbers' : $name = i18n("Photos"); $value = $array_src_infos['stats_numbers']; - break; + break; case 'stats_views' : $name = i18n("Nr Of Views"); $value = $array_src_infos['stats_views']; - break; + break; case 'stats_downloads' : $name = i18n("Nr Of Downloads"); $value = $array_src_infos['stats_downloads']; - break; + break; case 'first_comment' : $name = i18n("First Comment"); $value = linHtmlTag($GLOBALS['linpha']->db->GetOne("SELECT meta_comment FROM " . - LIN_PREFIX . "meta_comments " . - "WHERE md5sum = '" . LinSql :: linAddslashes($array_src_infos['md5sum']) . "' " . - "ORDER by meta_time ASC")); - break; + LIN_PREFIX . "meta_comments " . + "WHERE md5sum = '".LinSql::linAddslashes($array_src_infos['md5sum'])."' " . + "ORDER by meta_time ASC")); + break; + /** + * description, category, persons, date (field + * entries which are stored in linpha_meta_data) + */ default : /** - * description, category, persons, - * date (field entries which are stored in linpha_meta_data) - */ - /** * get field id, and cache it */ - if (!isset ($this->cachedFieldIds[$last_part])) { - $this->cachedFieldIds[$last_part] = $GLOBALS['linpha']->db->GetOne("SELECT id " . - "FROM " . LIN_PREFIX . "meta_fields WHERE name = '" . $last_part . "'"); + if(!isset ($this->cachedFieldIds[$last_part])) + { + $this->cachedFieldIds[$last_part] = + $GLOBALS['linpha']->db->GetOne("SELECT id " . + "FROM ".LIN_PREFIX."meta_fields " . + "WHERE name = '".$last_part."'"); } /** * get data */ $meta_data = $GLOBALS['linpha']->db->GetOne("SELECT meta_data " . - "FROM " . LIN_PREFIX . "meta_data " . - "WHERE field_id = '" . $this->cachedFieldIds[$last_part] . "' " . - "AND md5sum = '" . $array_src_infos['md5sum'] . "'"); + "FROM ".LIN_PREFIX."meta_data " . + "WHERE field_id = '".$this->cachedFieldIds[$last_part]."' " . + "AND md5sum = '".$array_src_infos['md5sum']."'"); - if (!empty ($meta_data)) { + if(!empty ($meta_data)) + { $value = htmlspecialchars($meta_data, ENT_QUOTES); } - break; - } // end switch($last_part) - break; // end case 'builtin' + break; + } + break; // end case 'builtin' case 'id' : // own fields - /** * get data */ $meta_data = $GLOBALS['linpha']->db->GetOne("SELECT meta_data " . - "FROM " . LIN_PREFIX . "meta_data " . - "WHERE field_id = '" . $last_part . "' " . - "AND md5sum = '" . $array_src_infos['md5sum'] . "'"); + "FROM ".LIN_PREFIX."meta_data " . + "WHERE field_id = '".$last_part."' " . + "AND md5sum = '".$array_src_infos['md5sum']."'"); - if (isset ($meta_data) && !empty ($meta_data)) { + if(isset($meta_data) && !empty($meta_data)) + { $value = htmlspecialchars($meta_data, ENT_QUOTES); } - break; + break; case 'exif' : - if ($GLOBALS['linpha']->sql->config->value['sys_image_exif']) { - $exif_data = $GLOBALS['linpha']->db->GetRow("SELECT " . $last_part . " " . - "FROM " . LIN_PREFIX . "meta_exif " . - "WHERE md5sum = '" . $array_src_infos['md5sum'] . "'"); + if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) + { + $exif_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." " . + "FROM ".LIN_PREFIX."meta_exif " . + "WHERE md5sum = '".$array_src_infos['md5sum']."'"); - if (isset ($exif_data[$last_part])) { + if(isset ($exif_data[$last_part])) + { $value = htmlspecialchars($exif_data[$last_part], ENT_QUOTES); } } - break; + break; + case 'iptc' : - if ($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { - $iptc_data = $GLOBALS['linpha']->db->GetRow("SELECT " . $last_part . " " . - "FROM " . LIN_PREFIX . "meta_iptc " . - "WHERE md5sum = '" . $array_src_infos['md5sum'] . "'"); + if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) + { + $iptc_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." " . + "FROM ".LIN_PREFIX."meta_iptc " . + "WHERE md5sum = '".$array_src_infos['md5sum']."'"); - if (isset ($iptc_data[$last_part])) { + if(isset ($iptc_data[$last_part])) + { $value = htmlspecialchars($iptc_data[$last_part], ENT_QUOTES); } } - break; + break; + case 'xmp' : - if ($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { - $xmp_data = $GLOBALS['linpha']->db->GetRow("SELECT " . $last_part . " " . - "FROM " . LIN_PREFIX . "meta_xmp " . - "WHERE md5sum = '" . $array_src_infos['md5sum'] . "'"); + if($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) + { + $xmp_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." " . + "FROM ".LIN_PREFIX."meta_xmp " . + "WHERE md5sum = '".$array_src_infos['md5sum']."'"); - if (isset ($xmp_data[$last_part])) { + if(isset ($xmp_data[$last_part])) + { $value = htmlspecialchars($xmp_data[$last_part], ENT_QUOTES); } } - break; + break; } - if ($value != '') { - /** - * get category names if the data looks like ';5;4;44;' or at least ';2;' - */ - if (preg_match('/^;[0-9;]*;$/', $value)) { + /** + * Get category names if the data looks like ';5;4;44;' + * or at least ';2;' + * TODO explain what is going on here + */ + if ($value != '') + { + if(preg_match('/^;[0-9;]*;$/', $value)) + { $array_catids = linExplodeAndSlice(';', $value); $str_catnames = ''; $isValidCategory = true; - for ($i = 1; list ($key, $catid) = each($array_catids); $i++) { + + for($i = 1; list($key, $catid) = each($array_catids); $i++) + { $str_catnames .= $GLOBALS['linpha']->db->GetOne("SELECT name " . - "FROM " . LIN_PREFIX . "meta_category " . - "WHERE id = '" . LinSql :: linAddslashes($catid) . "'"); + "FROM ".LIN_PREFIX."meta_category " . + "WHERE id = '".LinSql::linAddslashes($catid)."'"); /** - * was this a valid category id? - * maybe someone just added ;nice; as a description + * Was this a valid category id? + * Maybe someone just added ;nice; as a description * - * this will only check the first category id, but thats okay + * This will only check the first category id, but + * thats okay + * TODO explain what is going on here */ - if (empty ($str_catnames)) { + if(empty ($str_catnames)) + { $isValidCategory = false; break; } - if ($i < count($array_catids)) { + if($i < count($array_catids)) + { $str_catnames .= ', '; } } - if ($isValidCategory) { + if($isValidCategory) + { $value = $str_catnames; } } - $output_array[$field_name] = Array ( + $output_array[$field_name] = array ( 'name' => $name, 'value' => $value ); } } - - return $output_array; + return $output_array; } /** - * show nice name for exif, iptc, xmp, builtin and own fields, - * for example: convert "exif_datetimeoriginal" to "DateTime Original" + * This method is used to show nice names for EXIF, IPTC, XMP, builtin + * and own fields, for example: "exif_datetimeoriginal" is displayed + * as "Date Time Original" + * @param string $key something like builtin_xyz or exif_xyz + * @param bool $show_metadata_extra_info if true entries will look like: + * "(EXIF) Orientation" or just + * "Orientation" if false + * @return string $value the niced field value + * @author flo, bzrudi */ - public function getNameOfField($key, $show_metadata_extra_info) { + public function getNameOfField($key, $show_metadata_extra_info) + { $pos = strpos($key, '_'); $first_part = substr($key, 0, $pos); $last_part = substr($key, $pos +1); - switch ($first_part) { - case 'builtin' : // builtin and special fields like filename, imagesize and dimension - $value = i18n(ucfirst($last_part)); // i18n already called in sql.data.php - break; + + switch($first_part) + { + /** + * Builtin and special fields like filename, imagesize and dimension + */ + case 'builtin' : + $value = i18n(ucfirst($last_part)); + break; - case 'id' : // own fields - + /** + * Own fileds + */ + case 'id' : /** - * enable cache (only possible in object context) - * we dont want have to read this for each thumbnail + * Enable cache (only possible in object context) + * We dont want have to read this for each thumbnail */ - if (isset ($this->cachedFieldNames[$last_part])) { - $value = i18n(ucfirst($this->cachedFieldNames[$last_part])); // i18n already called in sql.data.php - } else { - $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM " . LIN_PREFIX . "meta_fields WHERE id = '" . $last_part . "'"); - $value = i18n(ucfirst($data['name'])); // i18n already called in sql.data.php + if(isset($this->cachedFieldNames[$last_part])) + { + $value = i18n(ucfirst($this->cachedFieldNames[$last_part])); + } + else + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT name " . + "FROM ".LIN_PREFIX."meta_fields " . + "WHERE id = '".$last_part."'"); + $value = i18n(ucfirst($data['name'])); - if (isset ($this)) // cache entry, but only in object context - { + if(isset($this)) //cache entry, but only in object context + { $this->cachedFieldNames[$last_part] = $data['name']; } } - break; + break; + case 'exif' : -// $value = $this->objMetaTool->metaTags['exif'][$last_part]['name']; - $value = $this->objMetaTool->metaTags['exif'][$last_part]; - - if ($show_metadata_extra_info) { - $value .= ' (EXIF Resource)'; + $value = '(EXIF) '; + if($show_metadata_extra_info) + { + //TODO make exiftool proof + $value .= LinPjmtTool::$metaTags['exif'][$last_part]['name']; } - break; + break; + case 'iptc' : - $value = $this->objMetaTool->metaTags['iptc'][$last_part]; - if ($show_metadata_extra_info) { - $value .= ' (IPTC Resource)'; + $value = '(IPTC) '; + if($show_metadata_extra_info) + { + $value .= $this->objMetaTool->metaTags['iptc'][$last_part]; } - break; + break; + case 'xmp' : - $value = $this->objMetaTool->metaTags['xmp'][$last_part]; - if ($show_metadata_extra_info) { - $value .= ' (XMP Resource)'; + $value = '(XMP) '; + if($show_metadata_extra_info) + { + $value = $this->objMetaTool->metaTags['xmp'][$last_part]; } - break; + break; + + default: + linLog(LOG_TYPE_IMPORT,LOG_ERR,'import_others', + "Error in getNameOfField(); linpha.metadata.class.php"); + $value = ""; + break; } return $value; } + + + /** + * This method takes care of storing modified MetaData. It takes care + * whether we are trying to save "own" LinPHA MetaData or MetaData found + * in images (EXIF,IPTC,XMP) + * @param none + * @return none + * @author flo, bzrudi + */ + public function saveModifiedMetaData() + { + if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) + { + /** + * Write "own" linpha MetaData fields + */ + if(isset($_POST['linCmd']) + && $_POST['linCmd'] == 'linInsertMetaLinpha') + { + LinMetaData::saveModifiedMetaDataLinpha(); + linSysLog(i18n("Successfully updated data.")); + } + + /** + * Write iptc data + * TODO rewrite! + */ + if(isset($_POST['linCmd']) + && $_POST['linCmd'] == 'linInsertMetaIptc' + && $GLOBALS['linpha']->sql->config->value['sys_image_iptc'] + && isset ($GLOBALS['linpha']->imgview->src_file) + && file_exists($GLOBALS['linpha']->imgview->src_file)) + { + global $new_ps_file_info_array; + $new_ps_file_info_array = $GLOBALS['_POST']; + + /** + * important! + * remove other POST data from this array, because pjmt just takes all values and this will generate unexpected results!!! + * we got problems because $_POST['linMetaField'] is an array and pjmt couldnt handle this + */ + unset ($new_ps_file_info_array['linCmd']); + unset ($new_ps_file_info_array['linMetaField']); + unset ($new_ps_file_info_array['submit']); + + /** + * if the backup went wrong, the saveModifiedMetaDataIptc() would most probably also fail + */ + if (LinFilesys :: backupFile($GLOBALS['linpha']->imgview->src_file)) { + if (LinMetaDataModificate :: saveModifiedMetaDataIptc($new_ps_file_info_array, $GLOBALS['linpha']->imgview->src_file)) // error handling already done + { + /** + * force read data from file again if write was successful + */ + unset ($new_ps_file_info_array); + LinImport :: updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); + } + } else { + linSysLog(sprintf(i18n("Error: Cannot create backup of: %s"), $GLOBALS['linpha']->imgview->src_file)); + linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Cannot create backup of:" . ' ' . $GLOBALS['linpha']->imgview->src_file); + } + } + } + } + + + /** + * This method is used to store changed MetaData to database. Note + * this applies only to "own" LinPHA fields and has nothing todo with + * EXIF and friends MetaData! + * @param none + * @return none + * @author flo + */ + public function saveModifiedMetaDataLinpha() + { + if(isset($_POST['linMetaField']) + && is_array($_POST['linMetaField'])) + { + /** + * Delete existing entries + */ + $query = $GLOBALS['linpha']->db->Execute("DELETE FROM " . + "".LIN_PREFIX."meta_data " . + "WHERE md5sum = '".$GLOBALS['linpha']->imgview->md5sum."'"); + + /** + * Insert new entries + */ + foreach($_POST['linMetaField'] AS $key => $value) + { + if(is_array($value)) // coming from a select (categories etc.) + { + $value = ';' . implode(';', $value) . ';'; + } + + if(!empty ($value)) + { + $GLOBALS['linpha']->db->Execute("INSERT " . + "INTO ".LIN_PREFIX."meta_data (field_id, md5sum, meta_data) " . + "VALUES ('".LinSql::linAddslashes($key)."','".$GLOBALS['linpha']->imgview->md5sum."','".LinSql::linAddslashes($value)."')"); + } + } + } + } + + + /** + * + */ + public function showEditMetaData() + { + /** + * set meta linpha + */ + $GLOBALS['linpha']->template->output['meta_linpha'] = ''; + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, flags " . + "FROM " . LIN_PREFIX . "meta_fields " . + "WHERE flags = '5' OR flags = '7' ORDER by id"); + while ($data = $query->FetchRow()) { + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<tr><td width="150" valign="top">'; + + if ($data['flags'] == 5) { + $GLOBALS['linpha']->template->output['meta_linpha'] .= LinMetaData :: getNameOfField('builtin_' . $data['name'], false); + } + elseif ($data['flags'] == 7) { + $GLOBALS['linpha']->template->output['meta_linpha'] .= LinMetaData :: getNameOfField('id_' . $data['id'], false); + } + $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td><td>'; + + $meta_data = $GLOBALS['linpha']->db->GetRow("SELECT meta_data FROM " . LIN_PREFIX . "meta_data " . + "WHERE md5sum = '" . $GLOBALS['linpha']->imgview->md5sum . "'" . + "AND field_id = '" . $data['id'] . "'"); + + switch ($data['field_type']) { + case 1 : + if (isset ($meta_data['meta_data'])) { + $value = htmlspecialchars($meta_data['meta_data'], ENT_QUOTES); + } else { + $value = ''; + } + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<input type="text" class="linForms" name="linMetaField[' . + $data['id'] . ']" ' . + 'value="' . $value . '" style="width: 250px;" maxlength="255" />'; + break; + case 3 : + if (isset ($meta_data['meta_data'])) { + $value = htmlspecialchars($meta_data['meta_data'], ENT_QUOTES); + } else { + $value = ''; + } + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<input type="text" class="linForms" name="linMetaField[' . + $data['id'] . ']" id="linField' . $data['id'] . '" value="' . $value . '" style="width: 150px;" maxlength="255" />' . + ' <a href="javascript:void(0);" onclick="var loginWin = window.open(\'' . LINPHA_CLIENT . '/lib/include/calendar.php?form=linField' . $data['id'] . '\'' . + ',\'Calendar\',\'height=250,width=300,scrollbars=no,menubar=no,status=no\');" target="_top">' . i18n("Calendar") . '</a>'; + + break; + case 2 : + if (isset ($meta_data['meta_data'])) { + $array_pieces = linExplodeAndSlice(';', $meta_data['meta_data']); + } else { + $array_pieces = Array (); + } + + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<select name="linMetaField[' . $data['id'] . '][]" class="linForms" size="7" multiple="multiple" style="width: 250px;">'; + + $cat_query = $GLOBALS['linpha']->db->Execute("SELECT id, name " . + "FROM " . LIN_PREFIX . "meta_category " . + "WHERE field_id = '" . $data['id'] . "'"); + while ($cat_data = $cat_query->FetchRow()) { + if (in_array($cat_data['id'], $array_pieces)) { + $checked = ' selected="selected"'; + } else { + $checked = ''; + } + + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<option value="' . $cat_data['id'] . '"' . $checked . '>' . htmlspecialchars($cat_data['name'], ENT_QUOTES) . '</option>' . "\n"; + } + $GLOBALS['linpha']->template->output['meta_linpha'] .= '</select>' . "\n" . + '<br /><span style="font-size: smaller;">' . i18n("For Multiple Select Use CTRL") . '</span>'; + + if ($GLOBALS['linpha']->sql->isAdmin()) { + $GLOBALS['linpha']->template->output['meta_linpha'] .= '<br /><span style="font-size: smaller;"><a href="' . LINPHA_CLIENT . '/admin/?cat=metadata_define_adddata">' . i18n("Add More Options") . '</a><br /><br /></span>'; + } + + break; + } + + $GLOBALS['linpha']->template->output['meta_linpha'] .= '</td></tr>'; + } + + /** + * set meta IPTC + */ + if ($GLOBALS['linpha']->sql->config->value['sys_image_iptc'] || $GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { + if (isset ($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) { + if (is_writable($GLOBALS['linpha']->imgview->src_file)) { + $meta_edit_possible = true; + $filename = $GLOBALS['linpha']->imgview->src_file; // used in IPTC Edit_File_Info.php + } else { + $meta_edit_possible = false; + } + } else { + $meta_edit_possible = false; + } + } + /** + * build the meta data view + */ + $fragment = 'edit_meta'; + global $linTpl; + include (LINPHA_DIR . '/templates/' . $this->template_name . '/fragments.php'); + + } /** * This method is used to setup the initial most useful defaults for the @@ -573,7 +654,6 @@ return array(); break; } - } @@ -590,7 +670,15 @@ $this->available_fields = $this->objMetaTool->available_fields; } - + + /** + * This method is used to create any required MEtaData table + * @param array $array array of fields (columns) to create + * @param string $metatype exif,iptc,xmp + * @return none + * @author bzrudi,flo + * TODO cleanup + set required indexes! + */ public function createMetaDataTable($array, $metatype) { if (!is_array($array)) @@ -642,18 +730,23 @@ /** - * wrapper function for saveExifData, saveIptcData and saveXmpData - * for easier access + * Simple wrapper method for saveMetaData() + * @param string $what meta type exif,iptc,xmp + * @param string $filename filename + * @param string $md5sum md5sum of image + * @return none + * @author bzrudi,flo */ - function saveData($what, $filename, $md5sum) { + public function saveData($what, $filename, $md5sum) { /** - * no double entries - * do this check at very first position to improve performance! - * also do not setMetaFields in the __contruct() because they may never be used + * Prevent double entries. We do this check at very first position + * to improve performance! + * Also we do not setMetaFields in the __contruct() because they may + * never be used */ $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum " . - "FROM " . LIN_PREFIX . "meta_" . $what . " " . - "WHERE md5sum = '" . $md5sum . "'"); + "FROM " . LIN_PREFIX . "meta_" . $what . " " . + "WHERE md5sum = '" . $md5sum . "'"); if ($query->EOF) // not a single value returned { @@ -676,7 +769,6 @@ $this->objMetaTool->saveMetaData($filename, $md5sum, $what); break; } - } } @@ -684,10 +776,13 @@ * Simple wrapper method to convert an exif date to an unix timestamp * and also return orientation tag if avail * example: 2004:02:14 18:24:19 -> 11167594589 + * HINT: Not yet used, as it only makes sense, once installer takes care + * of exiftool avail and PHP memory limit. See linpha.import.class.php-> + * getFileInformation() for details * * @param string $date * @return int unix timestamp - * @author flo,bzrudi + * @author bzrudi **/ public function getBasicMeta($dirname, $filename) { @@ -699,76 +794,105 @@ { $rotate = $this->getRotationByExifTag($rotate); } - return array($time_exif, $rotate); - + return array($time_exif, $rotate); } /** - * Autorotate Images via EXIF tag - * Most Images contain an orientation tag which shows if and how to rotate + * 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 */ - protected 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 + public function getRotationByExifTag($rotation) + { + if(is_numeric($rotation)) + { + switch($rotation) + { case "1" : + /** + * No Rotation, No Flip Row 0 is at the visual top of the + * image, and column 0 is the visual left-hand side + */ $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 + break; + case "2" : + /** + * No Rotation, Flipped Horizontally Row 0 is at the + * visual top of the image,and column 0 is the visual + * right-hand side + */ $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 + break; + case "3" : + /** + * Rotated 180 degrees, No Flip Row 0 is at the visual + * bottom of the image, and column 0 is the visual + * right-hand side + */ $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 + break; + 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 + /** + * No Rotation, Flipped Vertically Row 0 is at the visual + * bottom of the image, and column 0 is the visual + * left-hand side + */ + $rotate = "0"; + break; + case "5" : + /** + * 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 + */ $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 + break; + case "6" : + /** + * 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 + */ $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 + break; + case "7" : + /** + * 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 + */ $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 + break; + case "8" : + /** + * 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 + */ $rotate = "-90"; - break; + break; + default : $rotate = "0"; - break; - + break; } - } else // no rotation data is found, default to "0" - { + } + else + { $rotate = "0"; } - return $rotate; + return $rotate; } - } /* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/lib/classes/linpha.pjmt.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.pjmt.class.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/lib/classes/linpha.pjmt.class.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -26,6 +26,7 @@ */ class LinPjmtTool extends LinMetaData { + /** * Constructor */ Modified: trunk/linpha2/templates/default/view_albmeta.html.php =================================================================== --- trunk/linpha2/templates/default/view_albmeta.html.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/templates/default/view_albmeta.html.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -18,7 +18,7 @@ <br /> <h1 class="linStyle"><?php echo i18n("Edit Album Informations"); ?></h1> - <?php LinMetaDataModificate::showEditMetaData(); ?> + <?php LinMetaData::showEditMetaData(); ?> </div> Modified: trunk/linpha2/templates/default/view_img_static.html.php =================================================================== --- trunk/linpha2/templates/default/view_img_static.html.php 2007-03-17 16:29:01 UTC (rev 4699) +++ trunk/linpha2/templates/default/view_img_static.html.php 2007-03-18 12:57:57 UTC (rev 4700) @@ -39,7 +39,7 @@ <a href="<?php echo $linTpl->URL_full.'&view=img'; ?>"><?php echo i18n("<< Back To Default View");?></a> <br /><br /> <h1 class="linStyle"><?php echo i18n("Edit Image Imformation")?></h1> - <?php LinMetaDataModificate::showEditMetaData(); + <?php LinMetaData::showEditMetaData(); } else { ?> <!-- show image --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-20 11:48:43
|
Revision: 4705 http://svn.sourceforge.net/linpha/?rev=4705&view=rev Author: bzrudi Date: 2007-03-20 04:48:41 -0700 (Tue, 20 Mar 2007) Log Message: ----------- Argh, after hours of boring debugging, AJAX stuff is working again when using exiftool instead of PJMT. Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/pjmt/EXIF.php trunk/linpha2/templates/default/global.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-18 18:30:49 UTC (rev 4704) +++ trunk/linpha2/ChangeLog 2007-03-20 11:48:41 UTC (rev 4705) @@ -1,3 +1,11 @@ +2007-03-12 bzrudi + * Argh, after hours of boring debugging, AJAX stuff is working again when + using exiftool instead of PJMT. The images were not showing due to an + additional empty!!!! line at the end of linpha.exiftool.class.php. + So if you ever find something like "xml declaration not at start of + external entity" in the JS console, watch your files for empty lines + before php opening tag <?php and after the closing tag ?> !!!!! + 2007-03-18 bzrudi * linpha.import.class.php: Make PJMT tool of choice while running import, as it faster and we just need basic exif information here. Namely exifdate and Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2007-03-18 18:30:49 UTC (rev 4704) +++ trunk/linpha2/install/sql/sql.data.php 2007-03-20 11:48:41 UTC (rev 4705) @@ -36,7 +36,7 @@ 'sys_import_autoimport' => '1', 'sys_import_exif' => '1', 'sys_import_exif_autorot' => '1', - 'sys_import_use_exiftool' => '0', + 'sys_import_use_exiftool' => '1', 'sys_image_exif' => '1', 'sys_image_iptc' => '0', Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-18 18:30:49 UTC (rev 4704) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-20 11:48:41 UTC (rev 4705) @@ -28,7 +28,7 @@ class LinExifTool extends LinMetaData { -private $exiftool, $filename; +public $exiftool, $filename; /** * Constructor @@ -117,11 +117,8 @@ */ function saveMetaData($filename, $md5sum, $tag) { - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); - $objExifTool = new LinExifTool; - $objExifTool->setMetaFields($tag); - $dataArray = $this->readMetaDataFromFile($tag, $filename); + $dataArray = LinExifTool::readMetaDataFromFile($tag, $filename); // echo '<pre>', print_r($dataArray), '</pre>'; @@ -453,4 +450,3 @@ /* vi: set ts=4 sw=4 sts=4 */ ?> - Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-03-18 18:30:49 UTC (rev 4704) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-03-20 11:48:41 UTC (rev 4705) @@ -991,7 +991,9 @@ */ $min_year = substr($data[0],0,4); $max_year = substr($data[1],0,4); - + include_once(LINPHA_DIR.'/lib/classes/pjmt/Unicode.php'); + echo HTML_UTF8_escape("Rüdi"); + error_log(HTML_UTF8_Escape('Rüdi'), "0"); /** * get years between */ @@ -1313,7 +1315,6 @@ $array_meta = array('exif','iptc','xmp'); foreach($array_meta AS $value) { - if(!isset($MetaData)) { $MetaData = new LinMetaData(); Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-18 18:30:49 UTC (rev 4704) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-20 11:48:41 UTC (rev 4705) @@ -341,9 +341,16 @@ $value = '(EXIF) '; if($show_metadata_extra_info) { - //TODO make exiftool proof - $value .= LinPjmtTool::$metaTags['exif'][$last_part]['name']; - } + //TODO make exiftool proof in an clean way + if($GLOBALS['linpha']->sql->config->value['sys_import_use_exiftool']) + { + $value .= LinExifTool::$metaTags['exif'][$last_part]; + } + else + { + $value .= LinPjmtTool::$metaTags['exif'][$last_part]['name']; + } + } break; case 'iptc' : @@ -748,12 +755,12 @@ "FROM " . LIN_PREFIX . "meta_" . $what . " " . "WHERE md5sum = '" . $md5sum . "'"); - if ($query->EOF) // not a single value returned + if($query->EOF) // not a single value returned { /** * define tags to index if not already done */ - if (!isset ($this->defined_fields[$what])) + if(!isset ($this->defined_fields[$what])) { $this->objMetaTool->setMetaFields($what); } Modified: trunk/linpha2/lib/classes/pjmt/EXIF.php =================================================================== --- trunk/linpha2/lib/classes/pjmt/EXIF.php 2007-03-18 18:30:49 UTC (rev 4704) +++ trunk/linpha2/lib/classes/pjmt/EXIF.php 2007-03-20 11:48:41 UTC (rev 4705) @@ -1297,7 +1297,7 @@ if ( $Data_Count > 100000 ) { - echo "<p>Error: huge EXIF data count - EXIF is probably Corrupted</p>\n"; + //echo "<p>Error: huge EXIF data count - EXIF is probably Corrupted</p>\n"; // Some Casio files have no Next IFD pointer, hence cause errors Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2007-03-18 18:30:49 UTC (rev 4704) +++ trunk/linpha2/templates/default/global.html.php 2007-03-20 11:48:41 UTC (rev 4705) @@ -6,7 +6,7 @@ */ global $linTpl; ?> -<?php /*header('Content-type: text/html; charset='.$html_charset);*/ ?> +<?php header('Content-type: text/html; charset=utf8'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-20 15:38:53
|
Revision: 4707 http://svn.sourceforge.net/linpha/?rev=4707&view=rev Author: bzrudi Date: 2007-03-20 08:31:20 -0700 (Tue, 20 Mar 2007) Log Message: ----------- added IPTC, XMP read support and database storage using exiftool Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/metadata_iptc_edit.php trunk/linpha2/lib/include/metadata_xmp_edit.php trunk/linpha2/templates/default/fragments.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-20 11:53:19 UTC (rev 4706) +++ trunk/linpha2/ChangeLog 2007-03-20 15:31:20 UTC (rev 4707) @@ -1,10 +1,11 @@ -2007-03-12 bzrudi +2007-03-20 bzrudi * Argh, after hours of boring debugging, AJAX stuff is working again when using exiftool instead of PJMT. The images were not showing due to an additional empty!!!! line at the end of linpha.exiftool.class.php. So if you ever find something like "xml declaration not at start of external entity" in the JS console, watch your files for empty lines before php opening tag <?php and after the closing tag ?> !!!!! + * Made IPTC and XMP read support work again. Played a bit with UTF8 encoding 2007-03-18 bzrudi * linpha.import.class.php: Make PJMT tool of choice while running import, as Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-20 11:53:19 UTC (rev 4706) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-20 15:31:20 UTC (rev 4707) @@ -140,7 +140,7 @@ if(array_key_exists($key, $lowerDataArray)) { $str_columns .= $key . ', '; - $str_values .= "'".utf8_encode(trim($lowerDataArray[$key]))."', "; + $str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; } } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-03-20 11:53:19 UTC (rev 4706) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-03-20 15:31:20 UTC (rev 4707) @@ -991,9 +991,6 @@ */ $min_year = substr($data[0],0,4); $max_year = substr($data[1],0,4); - include_once(LINPHA_DIR.'/lib/classes/pjmt/Unicode.php'); - echo HTML_UTF8_escape("Rüdi"); - error_log(HTML_UTF8_Escape('Rüdi'), "0"); /** * get years between */ Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-20 11:53:19 UTC (rev 4706) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-20 15:31:20 UTC (rev 4707) @@ -19,6 +19,7 @@ */ if (!defined('LINPHA_DIR')) { exit (1); } +include_once LINPHA_DIR.'/lib/classes/pjmt/Unicode.php'; /** * This is the baseclass to handle all the EXIF/IPTC/XMP stuff used in LinPHA @@ -696,7 +697,7 @@ if (LIN_DB_TYPE == "mysql") { $str = "CREATE TABLE " . LIN_PREFIX . "meta_$metatype " . - "(md5sum VARCHAR(32) NOT NULL, "; + "(md5sum CHAR(32) NOT NULL, "; foreach ($array AS $key => $value) { $str .= LinSql::linAddslashes(strtolower($value))."VARCHAR(255), "; @@ -707,7 +708,7 @@ elseif (LIN_DB_TYPE == "sqlite") { $str = "CREATE TABLE " . LIN_PREFIX . "meta_$metatype " . - "(md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; + "(md5sum CHAR(32) PRIMARY KEY NOT NULL, "; foreach ($array AS $key => $value) { $str .= strtolower($value) . " VARCHAR(255), "; @@ -720,12 +721,12 @@ elseif (LIN_DB_TYPE == "postgres") { $str = "CREATE TABLE " . LIN_PREFIX . "meta_$metatype " . - "(md5sum VARCHAR(32) NOT NULL, "; + "(md5sum CHAR(32) NOT NULL, "; foreach ($array AS $key => $value) { - $str .= strtolower($value) . " VARCHAR(255), "; - } + $str .= strtolower($value) . " TEXT, "; + } /** * remove last 2 signs (the comma and the space) Modified: trunk/linpha2/lib/include/metadata_iptc_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-20 11:53:19 UTC (rev 4706) +++ trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-20 15:31:20 UTC (rev 4707) @@ -1,580 +1,75 @@ -<?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 handles IPTC editing - * @package MetaData - * @author bzrudi,flo - */ - -if(!defined('LINPHA_DIR')) { exit(1); } - - -/** - * if $default_ps_file_info_array is set and the key 'date' is empty - * it will be auto filled with the exif date and we prevent errors like - * "Invalid Date - must be YYYY-MM-DD format" - */ -$default_ps_file_info_array = array( - 'title' => "", - 'author' => "", - 'authorsposition' => "", - 'caption' => "", - 'captionwriter' => "", - 'jobname' => "", - 'copyrightstatus' => "", - 'copyrightnotice' => "", - 'ownerurl' => "", - 'keywords' => array(), - 'category' => "", - 'supplementalcategories'=> array(), - 'date' => "", - 'city' => "", - 'state' => "", - 'country' => "", - 'credit' => "", - 'source' => "", - 'headline' => "", - 'instructions' => "", - 'transmissionreference' => "", - 'urgency' => "" - ); - -include LINPHA_DIR.'/lib/classes/pjmt/Toolkit_Version.php'; - -global $new_ps_file_info_array; - -// Check for operation modes 2 or 3 -// i.e. $filename is defined, and $new_ps_file_info_array is not -if ((!isset($new_ps_file_info_array)) && (isset($filename)) - && (is_string($filename))) -{ - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - -/** - * @TODO check what really needs to be included! - */ - include_once( LINPHA_DIR.'/lib/classes/pjmt/JPEG.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/XMP.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php' ); - - // Retrieve the header information from the JPEG file - $jpeg_header_data = get_jpeg_header_data( $filename ); - - // Retrieve EXIF information from the JPEG file - $Exif_array = get_EXIF_JPEG( $filename ); - - // Retrieve XMP information from the JPEG file - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); - - // Retrieve Photoshop IRB information from the JPEG file - $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); - - // Retrieve Photoshop File Info from the three previous arrays - $new_ps_file_info_array = get_photoshop_file_info( $Exif_array, $XMP_array, $IRB_array ); - -//echo '<pre>', print_r($new_ps_file_info_array), '</pre>'; - - // Check if there is an array of defaults available - if((isset($default_ps_file_info_array)) && - (is_array($default_ps_file_info_array))) - { - // There are defaults defined - // Check if there is a default for the date defined - if((!array_key_exists('date', $default_ps_file_info_array)) || - ((array_key_exists('date', $default_ps_file_info_array)) && - ($default_ps_file_info_array['date'] == '' ))) - { - /** - * No default for the date defined figure out a default from - * the file check if there is a EXIF Tag 36867 "Date and Time - * of Original" - */ - if(($Exif_array != FALSE) && - (array_key_exists(0, $Exif_array)) && - (array_key_exists(34665, $Exif_array[0])) && - (array_key_exists(0, $Exif_array[0][34665])) && - (array_key_exists(36867, $Exif_array[0][34665][0]))) - { - /** - * Tag "Date and Time of Original" found - use it for - * the default date - */ - $default_ps_file_info_array['date'] = - $Exif_array[0][34665][0][36867]['Data'][0]; - $default_ps_file_info_array['date'] = - preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - /** - * Check if there is a EXIF Tag 36868 "Date and Time when - * Digitized" - */ - elseif(($Exif_array != FALSE) && - (array_key_exists(0, $Exif_array)) && - (array_key_exists(34665, $Exif_array[0])) && - (array_key_exists(0, $Exif_array[0][34665])) && - (array_key_exists(36868, $Exif_array[0][34665][0]))) - { - /** - * Tag "Date and Time when Digitized" found - use it for - * the default date - */ - $default_ps_file_info_array['date'] = - $Exif_array[0][34665][0][36868]['Data'][0]; - $default_ps_file_info_array['date'] = - preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - /** - * Check if there is a EXIF Tag 306 "Date and Time" - */ - elseif(($Exif_array != FALSE) && - (array_key_exists(0, $Exif_array)) && - (array_key_exists(306, $Exif_array[0]))) - { - /** - * Tag "Date and Time" found - use it for the default date - */ - $default_ps_file_info_array['date'] = - $Exif_array[0][306]['Data'][0]; - $default_ps_file_info_array['date'] = - preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - else - { - /** - * Couldn't find an EXIF date in the image set default date - * as creation date of file - */ - $default_ps_file_info_array['date'] = - date ("Y-m-d", filectime( $filename )); - } - } - /* - * Cycle through all the elements of the default values array - */ - foreach( $default_ps_file_info_array as $def_key =>$default_item ) - { - /** - * Check if the current element is Keywords or Supplemental - * Categories as these are arrays and need to be treated - * differently - */ - if((strcasecmp($def_key, "keywords") == 0) || - (strcasecmp($def_key, "supplementalcategories" ) == 0)) - { - /** - * Keywords or Supplemental Categories found check if the - * File Info from the file is empty for this element and if - * there are default values in this array element - */ - if((count($new_ps_file_info_array[ $def_key ]) == 0) && - (is_array($default_item)) && - (count($default_item) >= 0)) - { - /** - * The existing file info is empty, and there are - * defaults - add them - */ - $new_ps_file_info_array[ $def_key ] = $default_item; - } - } - /** - * Otherwise, this is not an array element, just check if it is - * blank in the existing file info - */ - elseif(trim($new_ps_file_info_array[$def_key] ) == "" ) - { - /** - * The existing file info is blank, add the default value - */ - $new_ps_file_info_array[ $def_key ] = $default_item; - } - } - } -} -/** - * Check for operation mode 4 - $new_ps_file_info_array and $filename are - * not defined, - */ -elseif(((!isset($new_ps_file_info_array)) || - (!is_array($new_ps_file_info_array))) && - ((!isset($filename)) || (!is_string($filename)))) -{ -/** - * No filename or new_ps_file_info_array defined, create a blank file - * info array to display - */ - $new_ps_file_info_array = array( - "title" => "", - "author" => "", - "authorsposition" => "", - "caption" => "", - "captionwriter" => "", - "jobname" => "", - "copyrightstatus" => "", - "copyrightnotice" => "", - "ownerurl" => "", - "keywords" => array(), - "category" => "", - "supplementalcategories" => array(), - "date" => "", - "city" => "", - "state" => "", - "country" => "", - "credit" => "", - "source" => "", - "headline" => "", - "instructions" => "", - "transmissionreference" => "", - "urgency" => "" ); -} - -/*************************************************************************** -* -* Now output the actual HTML form -* -***************************************************************************/ - -echo - "<tr>" . - "<td>Title</td>" . - "<td> ". - "<input size=49 class='linForms' name='title' type='text' - value=". htmlspecialchars($new_ps_file_info_array[ 'title' ], - ENT_QUOTES).">" . - "</td>" . - "</tr>"; -?> - <tr> - <td> - Author - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"author\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'author' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - <tr> - <td> - Authors Position - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"authorsposition\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'authorsposition' ], ENT_QUOTES) ."\"> - Note: not used in Photoshop 7 or higher"; - ?> - </td> - </tr> - - <tr> - <td> - Description - </td> - <td> - <textarea name="caption" class="linForms" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'caption' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - <tr> - <td> - Description Writer - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"captionwriter\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'captionwriter' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Keywords - </td> - <td> - <textarea class="linForms" name="keywords" rows=3 cols=37 wrap="off"><?php - foreach( $new_ps_file_info_array[ 'keywords' ] as $keyword ) - { - echo htmlspecialchars($keyword, ENT_QUOTES)."
"; - } - ?></textarea> - </td> - </tr> - - - <tr> - <td> - Copyright Status - </td> - <td> - <select size=1 class="linForms" name="copyrightstatus"> - <?php - $copystatus = $new_ps_file_info_array[ 'copyrightstatus' ]; - if ( $copystatus == "Unknown" ) - { - echo "<option value=\"Unknown\" SELECTED >Unknown</option>\n"; - } - else - { - echo "<option value=\"Unknown\">Unknown</option>\n"; - } - - if ( $copystatus == "Copyrighted Work" ) - { - echo "<option value=\"Copyrighted Work\" SELECTED >Copyrighted Work</option>\n"; - } - else - { - echo "<option value=\"Copyrighted Work\">Copyrighted Work</option>\n"; - } - - if ( $copystatus == "Public Domain" ) - { - echo "<option value=\"Public Domain\" SELECTED >Public Domain</option>\n"; - } - else - { - echo "<option value=\"Public Domain\">Public Domain</option>\n"; - } - ?> - </select> - </td> - </tr> - - - <tr> - <td> - Copyright Notice - </td> - <td> - <textarea class="linForms" name="copyrightnotice" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'copyrightnotice' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - <tr> - <td> - Copyright Info URL - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"ownerurl\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) ."\">\n"; - if ($new_ps_file_info_array[ 'ownerurl' ] != "" ) - { - echo "<a href=\"". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) ."\" > (". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) .")</a>\n"; - } - ?> - - </td> - </tr> - - - <tr> - <td> - Category - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"category\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'category' ], ENT_QUOTES) ."\">\n"; - ?> - - </td> - </tr> - - <tr> - <td> - Supplemental Categories - </td> - <td> - <textarea class="linForms" name="supplementalcategories" rows=3 cols=37 wrap="off"><?php - foreach( $new_ps_file_info_array[ 'supplementalcategories' ] as $supcat ) - { - echo htmlspecialchars($supcat, ENT_QUOTES)."
"; - } - ?></textarea> - </td> - </tr> - - - - <tr> - <td> - Date Created - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"date\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'date' ], ENT_QUOTES) ."\">"; - ?> - - Note date must be YYYY-MM-DD format - </td> - </tr> - - <tr> - <td> - City - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"city\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'city' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - State - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"state\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'state' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Country - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"country\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'country' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - - <tr> - <td> - Credit - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"credit\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'credit' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Source - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"source\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'source' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - - <tr> - <td> - Headline - </td> - <td> - <textarea class="linForms" name="headline" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'headline' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - - <tr> - <td> - Instructions - </td> - <td> - <textarea class="linForms" name="instructions" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'instructions' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - <tr> - <td> - Transmission Reference - </td> - <td> - <textarea class="linForms" name="transmissionreference" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'transmissionreference' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - <tr> - <td> - Job Name - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"jobname\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'jobname' ], ENT_QUOTES) ."\"> - Note: not used in Photoshop CS"; - ?> - </td> - </tr> - - <tr> - <td> - Urgency - </td> - <td> - <select size="1" class="linForms" name="urgency"> - <?php - for( $i = 1; $i <= 8; $i++ ) - { - echo "<option value=\"$i\""; - if ( $new_ps_file_info_array[ 'urgency' ] == $i ) - { - echo " SELECTED "; - } - echo ">"; - if ( $i == 1 ) - { - echo "High"; - } - else if ( $i == 5 ) - { - echo "Normal"; - } - else if ( $i == 8 ) - { - echo "Low"; - } - else - { - echo "$i"; - } - echo "</option>\n"; - } - if ( $new_ps_file_info_array[ 'urgency' ] == "none" ) - { - echo "<option value=\"none\" SELECTED >None</option>"; - } - else - { - echo "<option value=\"none\" >None</option>"; - } - ?> - - </select> - </td> - </tr> +<?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 handles IPTC editing + * @package MetaData + * @author bzrudi + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +include_once(LINPHA_DIR.'/lib/classes/pjmt/Unicode.php'); + +$MetaData = new LinMetaData(); +$MetaData->setMetaFields('iptc'); +$file_data = $MetaData->objMetaTool->readMetaDataFromFile('iptc', $filename); + +$iptc_avail = $MetaData->available_fields['iptc']; +if(!is_array($iptc_avail)){ $iptc_avail = array(); }; + +$iptc_defined = $MetaData->defined_fields['iptc']; +if(!is_array($iptc_defined)){ $iptc_defined = array(); }; + +/** + * Merge arrays + */ +$iptc_array = $iptc_avail + $iptc_defined; + +//var_dump($file_data); + +/** +* Now output the actual HTML form +*/ + +foreach($iptc_array AS $name => $value) +{ + $lower_array = array_change_key_case($file_data, CASE_LOWER); + + if(isset($lower_array[$name])) + { + $file_iptc = HTML_UTF8_Escape($lower_array[$name]); + } + else + { + $file_iptc = ""; + } + + echo + "<tr>" . + "<td>$value</td>" . + "<td> ". + "<input size=55 class='linForms' name='$name' + type='text' value='".$file_iptc."'>" . + "</td>" . + "</tr>"; + +} +?> + Modified: trunk/linpha2/lib/include/metadata_xmp_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-03-20 11:53:19 UTC (rev 4706) +++ trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-03-20 15:31:20 UTC (rev 4707) @@ -17,435 +17,56 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - /** - * This file handles XMP MetaData editing - * + * This file handles XMP editing * @package MetaData * @author bzrudi */ if(!defined('LINPHA_DIR')) { exit(1); } - -include LINPHA_DIR.'/lib/classes/pjmt/Toolkit_Version.php'; -if ( isset( $filename ) && is_string( $filename )) -{ +$MetaData = new LinMetaData(); +$MetaData->setMetaFields('xmp'); +$file_data = $MetaData->objMetaTool->readMetaDataFromFile('xmp', $filename); -/** - * @TODO check what really needs to be included! - */ - include_once( LINPHA_DIR.'/lib/classes/pjmt/JPEG.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/XMP.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php' ); +$xmp_avail = $MetaData->available_fields['xmp']; +if(!is_array($xmp_avail)){ $xmp_avail = array(); }; - include_once( LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php' ); - - $objExifTool = new LinExifTool (); - $meta = $objExifTool->readMetaDataFromFile('iptc', $filename); - echo '<pre>', print_r($meta), '</pre>'; - - //echo $objExifTool->metaTags['xmp']['CountryCode']; - - /** - * Retrieve the header information from the JPEG file - */ - $jpeg_header_data = get_jpeg_header_data( $filename ); - $XMP_from_image = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); +$xmp_defined = $MetaData->defined_fields['xmp']; +if(!is_array($xmp_defined)){ $xmp_defined = array(); }; - /** - * Check if the XMP tree structure array is valid - */ - if($XMP_from_image !== FALSE) - { - /** - * Check if there is a rdf:RDF tag at either the first or second level - */ - if(($XMP_array[0]['tag'] == "x:xapmeta") - && ($XMP_array[0]['children'][0]['tag'] == "rdf:RDF")) - { - /** - * RDF found at second level - Save it's position - */ - $RDF_Contents = &$XMP_array[0]['children'][0]['children']; - } - else if ( ( $XMP_array[0]['tag'] == "x:xmpmeta" ) - && ( $XMP_array[0]['children'][0]['tag'] == "rdf:RDF" ) ) - { - /** - * RDF found at second level - Save it's position - */ - $RDF_Contents = &$XMP_array[0]['children'][0]['children']; - } - else if ( $XMP_array[0]['tag'] == "rdf:RDF" ) - { - /** - * RDF found at first level - Save it's position - */ - $RDF_Contents = &$XMP_array[0]['children']; - } - } - /** - * This function creates an array with all available fields from the XMP - * MetaData relation, as defined in linpha.metadata.class.php - * - * @param none - * @return array or in case of failure FALSE - * @author bzrudi + * Merge arrays */ -function createNewEmptyXmpArray() -{ - /** - * create new empty array with no defaults - */ - foreach(array_values(LinMetaData::$Tags['xmp']) AS $value) - { - $new_xmp_array[$value['path']] = ""; - } - - if(is_array($new_xmp_array)) - { - return $new_xmp_array; - } - else - { - return FALSE; - } -} +$xmp_array = $xmp_avail + $xmp_defined; -/** - * This function just prevents Notices when calling unset array data - * - * @param string - * @return string - * @author bzrudi - */ -function preventNotice($item) -{ - if(!isset($item)) - { - $item = ''; - } -return $item; -} +//var_dump($file_data); /** - * This function is mainly a copy from the pjmt, but as we need to have it mod - * slightly it's required. - * - * @param array XMP item - * @return array with key and value - * @author pjmt, bzrudi - */ -function linInterpretRdfItem( $Item ) +* Now output the actual HTML form +*/ +foreach($xmp_array AS $name => $value) { - $value_str = ""; - - /** - * Check if the item has is in the lookup table of tag captions - */ - if ( array_key_exists( $Item['tag'], $GLOBALS[ 'XMP_tag_captions' ] ) ) + $lower_array = array_change_key_case($file_data, CASE_LOWER); + + if(isset($lower_array[$name])) { - /** - * Item is in list of captions, get the caption - */ - $tag_caption = $GLOBALS[ 'XMP_tag_captions' ][ $Item['tag'] ]; + $file_xmp = $lower_array[$name]; } else { - /** - * Item has no caption - make one - */ - $tag_caption = "Unknown field " . $Item['tag']; + $file_xmp = ""; } - /** - * Process specially the item according to it's tag - */ - switch($Item['tag']) - { - case "photoshopDateCreated": - list( $year, $month, $day ) = sscanf( $Item['value'], "%d-%d-%d" ); - /** - * Make a new date string with Day, Month, Year - */ - $value_str = "$day/$month/$year"; - break; - - default : - $value_str = linGetRdfField( $Item ); - break; - } - /** - * Return the caption and the value - */ - return array($tag_caption, $value_str); + echo + "<tr>" . + "<td>$value</td>" . + "<td> ". + "<input size=55 class='linForms' name='$name' + type='text' value='".$file_xmp."'>" . + "</td>" . + "</tr>"; + } - -/** - * This function is mainly a copy from the pjmt, but as we need to have it mod - * it slightly it's required - * - * @param array XMP item - * @return string interpreted item value - * @author pjmt, bzrudi - */ -function linGetRdfField($rdf_item) -{ - $output_str = ""; - - /** - * Check if the item has a value - */ - if(array_key_exists('value', $rdf_item)) - { - /** - * The item does have a value - add it to the text - */ - $output_str .= $rdf_item['value']; - } - - /** - * Check if the item has any attributes - */ - if (array_key_exists( 'attributes', $rdf_item)) - { - /** - * Cycle through each of the attributes - */ - foreach($rdf_item['attributes'] as $key => $val) - { - /** - * Check if this attribute is rdf:parseType = 'Resource' - * i.e. a sub-resource indicator - */ - if(($key == "rdf:parseType") && ($val == "Resource")) - { - /** - * This item has a attribute indicating sub-resources - */ - if (array_key_exists('children', $rdf_item)) - { - /** - * The item does have sub-items, Cycle through each, - * Interpreting them and adding the result to the - * output text - */ - foreach($rdf_item['children'] as $child) - { - list($tag_caption, $value_str) = linInterpretRdfItem($child); - $output_str .= "$tag_caption = $value_str\n"; - } - /** - * The output text will have an extra \n on it - remove it - */ - $output_str = rtrim($output_str); - } - } - } - } - /** - * If the item did not have sub-resources, it may still have - * sub-items - check for this - */ - else if (array_key_exists('children', $rdf_item)) - { - /** - * Non-resource Sub-items found, Cycle through each - */ - foreach($rdf_item['children'] as $child_item) - { - /** - * Check if this sub-item has a tag - */ - if (array_key_exists('tag', $child_item)) - { - /** - * Sub item has a tag, Process it according to the tag - */ - switch ($child_item['tag']) - { - // Collections - case "rdf:Alt": - $output_str .= interpret_RDF_collection( $child_item ); - break; - - case "rdf:Bag": - $output_str .= interpret_RDF_collection( $child_item ); - break; - - case "rdf:Seq": - $output_str .= interpret_RDF_collection( $child_item ); - break; - // Sub-Resource - case "rdf:Description": - // Check that the item has sub items - if (array_key_exists('children', $child_item)) - { - /** - * The item does have sub-items, Cycle through - * each, Interpreting them and adding the - * result to the output text - */ - foreach($child_item['children'] as $child) - { - list($tag_caption, $value_str) = - linInterpretRdfItem( $child ); - $output_str .= "$tag_caption = $value_str\n"; - } - /** - * The output text will have an extra \n on it - * - remove it - */ - $output_str = rtrim( $output_str ); - } - break; - - default: - $output_str .= "Unknown Item:".$child_item['tag']."\n"; - break; - } - } // sub-item Has no tags, look for a value - elseif(array_key_exists('value', $child_item)) - { - $output_str .= $rdf_item['value'] . "\n"; - } - } - } - // return the resulting value string - return $output_str; -} - -$XMP_default = createNewEmptyXmpArray(); - -foreach($RDF_Contents AS $RDF_Item) -{ - if(($RDF_Item['tag'] == "rdf:Description") - && (array_key_exists('children', $RDF_Item))) - { - /** - * Bingo item is a rdf:Description tag. - * Cycle through each of the attributes for this tag, looking - * for a xmlns: attribute, which tells us what Namespace the - * sub-items will be in. - */ - foreach( $RDF_Item['attributes'] as $key => $val ) - { - if(substr($key,0,6) == "xmlns:") -{ - /** - * Now lets take good care of the subchildren items and the - * data itself - */ - if(array_key_exists('children', $RDF_Item)) - { - /** - * Let's get each of the sub items - */ - foreach( $RDF_Item['children'] as $child_item ) - { - $XMP_default[$child_item['tag']] = - linInterpretRdfItem($child_item); - } - } - } - } - } -} -//echo '<pre>', print_r($XMP_default), '</pre>'; -//echo '<pre>', print_r($XMP_from_image), '</pre>'; -} - -/** - * Generate form data. - */ -echo "<tr>" . - "<td colspan='2'><b>".i18n("Photoshop XMP Segment")."</b><hr>" . - "</td></tr>"; - -foreach($XMP_default AS $key => $value) -{ - if(strpos($key, "photoshop") !== false) - { - echo - "<tr>" . - "<td>".$GLOBALS['XMP_tag_captions'][$key]."</td>" . - "<td>" . - "<input size='50' class='linForms' " . - "name=".$XMP_default[$key]." type='text' " . - "value=".@preventNotice($XMP_default[$key][1]).">" . - "</td>" . - "</tr>"; - } -} - -/** - * IPTC4XMP Core Segment Data - */ -echo "<tr><td colspan='2'> </td></tr>" . - "<tr>" . - "<td colspan='2'><b>".i18n("Iptc4xmp Core XMP Segment")."</b><hr>" . - "</td></tr>"; - -foreach($XMP_default AS $key => $value) -{ - if(strpos($key, "Iptc4xmpCore") !== false) - { - /** - * Iptc4xmpCore:SubjectCode needs special attention (unordered list) - */ - if($key == "Iptc4xmpCore:SubjectCode") - { - echo - "<tr>" . - "<td>".$GLOBALS['XMP_tag_captions'][$key]."</td>" . - "<td>" . - "<textarea class='linForms' " . - "name=".$XMP_default[$key]." rows='3' cols='50' wrap='off'>" . - "".@preventNotice($XMP_default[$key][1])."</textarea>" . - "</td>" . - "</tr>"; - } - else - { - echo - "<tr>" . - "<td>".$GLOBALS['XMP_tag_captions'][$key]."</td>" . - "<td>" . - "<input size='50' class='linForms' " . - "name=".$XMP_default[$key]." type='text' " . - "value=".@preventNotice($XMP_default[$key][1]).">" . - "</td>" . - "</tr>"; - } - - } -} - -/** - * DC Dublin Core Segment Data - */ -echo "<tr><td colspan='2'> </td></tr>" . - "<tr><td colspan='2'><b>".i18n("Dublin Core XMP Segment")."</b><hr>" . - "</td></tr>"; - -foreach($XMP_default AS $key => $value) -{ - if(strpos($key, "dc") !== false) - { - echo - "<tr>" . - "<td>".$GLOBALS['XMP_tag_captions'][$key]."</td>" . - "<td>" . - "<textarea class='linForms' " . - "name=".$XMP_default[$key]." rows='3' cols='50' wrap='off'>" . - "".@preventNotice($XMP_default[$key][1])."</textarea>" . - "</td>" . - "</tr>"; - } -} -/* vi: set ts=4 sw=4 sts=4 */ ?> + Modified: trunk/linpha2/templates/default/fragments.php =================================================================== --- trunk/linpha2/templates/default/fragments.php 2007-03-20 11:53:19 UTC (rev 4706) +++ trunk/linpha2/templates/default/fragments.php 2007-03-20 15:31:20 UTC (rev 4707) @@ -227,7 +227,7 @@ </table> <br> <br> - <p>Powered by: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> + <p>Powered by: <a href="http://owl.phy.queensu.ca/~phil/exiftool/" >ExifTool</a></p> <?php } else { echo i18n("Error: File not writable. Please check the file permissions."); /* @todo use unified language string */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-21 08:54:43
|
Revision: 4709 http://svn.sourceforge.net/linpha/?rev=4709&view=rev Author: bzrudi Date: 2007-03-21 01:54:41 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Prepared support for extracting the embedded thumbnail from the EXIF segment of the images as thumbnail. Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/classes/linpha.image.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-21 08:32:01 UTC (rev 4708) +++ trunk/linpha2/ChangeLog 2007-03-21 08:54:41 UTC (rev 4709) @@ -1,3 +1,7 @@ +2007-03-21 bzrudi + * Prepared support for extracting the embedded thumbnail from the EXIF + segment of the images as thumbnail. Currently disabled by default. + 2007-03-20 bzrudi * Argh, after hours of boring debugging, AJAX stuff is working again when using exiftool instead of PJMT. The images were not showing due to an Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2007-03-21 08:32:01 UTC (rev 4708) +++ trunk/linpha2/install/sql/sql.data.php 2007-03-21 08:54:41 UTC (rev 4709) @@ -37,7 +37,8 @@ 'sys_import_exif' => '1', 'sys_import_exif_autorot' => '1', 'sys_import_use_exiftool' => '0', - + 'sys_import_use_emb_thumb' => '0', + 'sys_image_exif' => '1', 'sys_image_iptc' => '0', 'sys_image_xmp' => '0', Modified: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php 2007-03-21 08:32:01 UTC (rev 4708) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2007-03-21 08:54:41 UTC (rev 4709) @@ -306,6 +306,7 @@ 'sys_im_bracket_support', 'sys_im_use_imagemagick', 'sys_im_video_thumbnail', + 'sys_import_use_emb_thumb', 'sys_import_autoimport', 'sys_import_exif', 'sys_import_exif_autorot', Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 08:32:01 UTC (rev 4708) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 08:54:41 UTC (rev 4709) @@ -58,18 +58,44 @@ * This method extracts the Thumbnail from EXIF/Composite section. * Most modern Cameras should support it. * @param string $filename The filename of the Image - * @return RAW image data + * @param string $outfile The filename inkl. path to store thumb to + * @return bool * @author bzrudi */ - protected function getEmbeddedThumbnail($filename) + public function getEmbeddedThumbnail($filename, $outfile) { $parameters = "-b " . // get binary data "-ThumbnailImage"; // get thumbnail from composite - - Header("Content-type: image/jpeg"); - passthru("$this->exiftool $parameters $this->filename"); - + + /** + * Buffer output of passthru and save to $thumb var + */ + ob_start(); + passthru("$this->exiftool $parameters $filename"); + $thumb = ob_get_contents(); + ob_end_clean(); + + if(strlen($thumb)>10) + { + if(file_put_contents($outfile, $thumb)) + { + $got_thumb = true; + } + else + { + $got_thumb = false; + } + } + + if($got_thumb) + { + return true; + } + else + { + return false; + } } Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2007-03-21 08:32:01 UTC (rev 4708) +++ trunk/linpha2/lib/classes/linpha.functions.php 2007-03-21 08:54:41 UTC (rev 4709) @@ -77,7 +77,7 @@ */ function linGetMemoryLimit() { - $memlimit=ini_get('memory_limit'); + $memlimit = ini_get('memory_limit'); if(empty($memlimit)) { $memlimit = get_cfg_var('memory_limit'); @@ -88,11 +88,11 @@ */ if(empty($memlimit) OR $memlimit == -1) { - return false; + return "0"; } else { - $memlimit=str_replace("M", "", $memlimit); + $memlimit = str_replace("M", "", $memlimit); return $memlimit; } } Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2007-03-21 08:32:01 UTC (rev 4708) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2007-03-21 08:54:41 UTC (rev 4709) @@ -381,12 +381,29 @@ function createThumbnailImage() { /** + * Exiftool can be used to extract the embedded thumbnail within the + * EXIF segment of the image. Most cameras support it. + * It is usually 5-10 times faster than using convert and is perfect + * when low on memory or with older CPU, even so the thumbs didn't look + * that nice as the ones created with convert ;-) + */ + if($GLOBALS['linpha']->sql->config->value['sys_import_use_emb_thumb']) + { + include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); + + $objExifTool = new LinExifTool; + $objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file); + } + else + { + /** * include the file which contains the imagemagick strings and exec() / gdlib instructions */ $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; $this->imageTool->imgQuality = 75; $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); + } } function createThumbnailFolder() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-21 12:41:49
|
Revision: 4710 http://svn.sourceforge.net/linpha/?rev=4710&view=rev Author: bzrudi Date: 2007-03-21 05:41:45 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Added basic IPTC write support Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/metadata_iptc_edit.php trunk/linpha2/templates/default/fragments.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/ChangeLog 2007-03-21 12:41:45 UTC (rev 4710) @@ -1,7 +1,14 @@ 2007-03-21 bzrudi * Prepared support for extracting the embedded thumbnail from the EXIF segment of the images as thumbnail. Currently disabled by default. - + * Added basic IPTC write support + TODO: Create all MetaData table columns with their right datatype defined + CHAR/TEXT/INT/VARCHAR and so on. + IPTC and XMP expect some data values with a defined length and + format, take good care of it or the data won't be written! + Take care of changed md5sum when writing IPTC/XMP! + Take care of encoding stuff! + 2007-03-20 bzrudi * Argh, after hours of boring debugging, AJAX stuff is working again when using exiftool instead of PJMT. The images were not showing due to an Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 12:41:45 UTC (rev 4710) @@ -165,7 +165,7 @@ { if(array_key_exists($key, $lowerDataArray)) { - $str_columns .= $key . ', '; + $str_columns .= str_replace("_", "-", $key) . ', '; $str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; } } @@ -331,7 +331,7 @@ 'state' => 'State', 'supplementalcategories' => 'Supplemental Categories', 'transmissionreference' => 'Transmission Reference', - 'urgency' => 'urgency' + 'urgency' => 'Urgency' ), @@ -351,21 +351,21 @@ 'specialinstructions' => 'Special Instructions', 'datecreated' => 'Date Created', 'timecreated' => 'Time Created', - 'byline' => 'By-line', - 'bylinetitle' => 'By-line Title', + 'by_line' => 'By-line', + 'by_linetitle' => 'By-line Title', 'city' => 'City', - 'sublocation' => 'Sub-location', + 'sub_location' => 'Sub-location', 'provincestate' => 'Province-State', - 'countryprimarylocationcode' => 'Country-Primary Location Code', - 'countryprimarylocationname' => 'Country-Primary Location Name', + 'country_primarylocationcode' => 'Country-Primary Location Code', + 'country_primarylocationname' => 'Country-Primary Location Name', 'originaltransmissionreference' => 'Original Transmission Reference', 'headline' => 'Headline', 'credit' => 'Credit', 'source' => 'Source', 'copyrightnotice' => 'Copyright Notice', 'contact' => 'Contact', - 'captionabstract' => 'Caption-Abstract', - 'writereditor' => 'Writer-Editor' + 'caption_abstract' => 'Caption-Abstract', + 'writer_editor' => 'Writer-Editor' ), //EXIF schema tags Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-21 12:41:45 UTC (rev 4710) @@ -413,31 +413,50 @@ && isset ($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) { - global $new_ps_file_info_array; - $new_ps_file_info_array = $GLOBALS['_POST']; + global $iptc_array; + $iptc_array = $GLOBALS['_POST']; /** - * important! - * remove other POST data from this array, because pjmt just takes all values and this will generate unexpected results!!! - * we got problems because $_POST['linMetaField'] is an array and pjmt couldnt handle this + * Important! + * Remove other POST data from this array, because we just + * take all values and this will generate unexpected results!!! + * We got problems because $_POST['linMetaField'] is an array. */ - unset ($new_ps_file_info_array['linCmd']); - unset ($new_ps_file_info_array['linMetaField']); - unset ($new_ps_file_info_array['submit']); + unset ($iptc_array['linCmd']); + unset ($iptc_array['linMetaField']); + unset ($iptc_array['submit']); /** * if the backup went wrong, the saveModifiedMetaDataIptc() would most probably also fail */ - if (LinFilesys :: backupFile($GLOBALS['linpha']->imgview->src_file)) { - if (LinMetaDataModificate :: saveModifiedMetaDataIptc($new_ps_file_info_array, $GLOBALS['linpha']->imgview->src_file)) // error handling already done - { - /** - * force read data from file again if write was successful - */ - unset ($new_ps_file_info_array); - LinImport :: updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); - } - } else { + if(LinFilesys::backupFile($GLOBALS['linpha']->imgview->src_file)) + { + $parameter = "-overwrite_original "; + + foreach($iptc_array AS $name => $value) + { + if(strlen(trim($value)) >= 1) + { + $name = str_replace("_", "-", $name); + $parameter .= "-iptc:$name='$value' "; + } + } + //echo '<pre>', print_r($iptc_array), '</pre>'; + + LinMetaData::__construct(); + $file = $GLOBALS['linpha']->imgview->src_file; + $exiftool = $this->objMetaTool->exiftool; + + exec("$exiftool $parameter $file"); + + /** + * force read data from file again if write was successful + */ + unset ($iptc_array); + LinImport :: updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); + } + else + { linSysLog(sprintf(i18n("Error: Cannot create backup of: %s"), $GLOBALS['linpha']->imgview->src_file)); linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Cannot create backup of:" . ' ' . $GLOBALS['linpha']->imgview->src_file); } @@ -700,6 +719,7 @@ "(md5sum CHAR(32) NOT NULL, "; foreach ($array AS $key => $value) { + $value = str_replace("-", "_", strtolower($value)); $str .= LinSql::linAddslashes(strtolower($value))."VARCHAR(255), "; } $str .= "PRIMARY KEY (md5sum), "; @@ -711,6 +731,7 @@ "(md5sum CHAR(32) PRIMARY KEY NOT NULL, "; foreach ($array AS $key => $value) { + $value = str_replace("-", "_", strtolower($value)); $str .= strtolower($value) . " VARCHAR(255), "; } /** @@ -725,7 +746,8 @@ foreach ($array AS $key => $value) { - $str .= strtolower($value) . " TEXT, "; + $value = str_replace("-", "_", strtolower($value)); + $str .= "$value" . " TEXT, "; } /** Modified: trunk/linpha2/lib/include/metadata_iptc_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-21 12:41:45 UTC (rev 4710) @@ -52,6 +52,8 @@ { $lower_array = array_change_key_case($file_data, CASE_LOWER); + $name = str_replace("_", "-", $name); + if(isset($lower_array[$name])) { $file_iptc = HTML_UTF8_Escape($lower_array[$name]); Modified: trunk/linpha2/templates/default/fragments.php =================================================================== --- trunk/linpha2/templates/default/fragments.php 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/templates/default/fragments.php 2007-03-21 12:41:45 UTC (rev 4710) @@ -262,7 +262,7 @@ </table> <br> <br> - <p>Powered by: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> + <p>Powered by: <a href="http://owl.phy.queensu.ca/~phil/exiftool/" >ExifTool</a></p> <?php } else { echo i18n("Error: File not writable. Please check the file permissions."); /* @todo use unified language string */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-21 15:49:38
|
Revision: 4711 http://svn.sourceforge.net/linpha/?rev=4711&view=rev Author: bzrudi Date: 2007-03-21 08:43:38 -0700 (Wed, 21 Mar 2007) Log Message: ----------- XMP/IPTC write support plus some more additions and improvements Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/metadata_iptc_edit.php trunk/linpha2/lib/include/metadata_xmp_edit.php trunk/linpha2/templates/default/fragments.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-21 12:41:45 UTC (rev 4710) +++ trunk/linpha2/ChangeLog 2007-03-21 15:43:38 UTC (rev 4711) @@ -1,7 +1,12 @@ 2007-03-21 bzrudi * Prepared support for extracting the embedded thumbnail from the EXIF segment of the images as thumbnail. Currently disabled by default. + * Added basic XMP write support * Added basic IPTC write support + + Option to save both, IPTC fields in XMP and vice versa in one step + + Option to save MetaData to all files in album at once, which is + pretty handy I think :-) + + Option to toggle file backup before writing MetaData TODO: Create all MetaData table columns with their right datatype defined CHAR/TEXT/INT/VARCHAR and so on. IPTC and XMP expect some data values with a defined length and Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 12:41:45 UTC (rev 4710) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 15:43:38 UTC (rev 4711) @@ -115,7 +115,8 @@ $parameters = "-$metatype:all " . // Get all Tag Information "-s " . // Print tag names instead of descr. - "-t "; // Use tab \t as delimiter + "-t " . // Use tab \t as delimiter + "-fast "; // Do not read to EOF exec("$this->exiftool $parameters $filename", $meta, $return); //echo '<pre>', print_r($meta), '</pre>'; Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-21 12:41:45 UTC (rev 4710) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-21 15:43:38 UTC (rev 4711) @@ -383,8 +383,8 @@ /** * This method takes care of storing modified MetaData. It takes care - * whether we are trying to save "own" LinPHA MetaData or MetaData found - * in images (EXIF,IPTC,XMP) + * whether we are trying to save "own" LinPHA MetaData or MetaData + * to be stored in the image itself images (EXIF,IPTC,XMP) * @param none * @return none * @author flo, bzrudi @@ -404,61 +404,182 @@ } /** - * Write iptc data - * TODO rewrite! + * Write IPTC/XMP MetaData to file */ if(isset($_POST['linCmd']) - && $_POST['linCmd'] == 'linInsertMetaIptc' - && $GLOBALS['linpha']->sql->config->value['sys_image_iptc'] && isset ($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) { - global $iptc_array; - $iptc_array = $GLOBALS['_POST']; - + global $meta_array; + $meta_array = $GLOBALS['_POST']; + /** * Important! * Remove other POST data from this array, because we just * take all values and this will generate unexpected results!!! * We got problems because $_POST['linMetaField'] is an array. */ - unset ($iptc_array['linCmd']); - unset ($iptc_array['linMetaField']); - unset ($iptc_array['submit']); + unset ($meta_array['linCmd']); + unset ($meta_array['linMetaField']); + unset ($meta_array['submit']); /** - * if the backup went wrong, the saveModifiedMetaDataIptc() would most probably also fail + * Prevent notices from unset checkboxes and make sure to + * set to false if unset */ - if(LinFilesys::backupFile($GLOBALS['linpha']->imgview->src_file)) + if(!isset($meta_array['linDoBackup'])) + { + /** + * If user wants no backup, make at least sure file is + * writeable, or break later + */ + if(is_writable($GLOBALS['linpha']->imgview->src_file)) + { + $write_ok = true; + } + else + { + $write_ok = false; + } + $meta_array['linDoBackup'] = false; + } + if(!isset($meta_array['linMassUpdate'])) + { + $meta_array['linMassUpdate'] = false; + } + + + /** + * See if we should create file backup first. If it went wrong, + * exit with $write_ok = false + */ + if($meta_array['linDoBackup']) { - $parameter = "-overwrite_original "; + if(LinFilesys + ::backupFile($GLOBALS['linpha']->imgview->src_file)) + { + $write_ok = true; + } + else + { + $write_ok = false; + } + } - foreach($iptc_array AS $name => $value) - { - if(strlen(trim($value)) >= 1) - { - $name = str_replace("_", "-", $name); - $parameter .= "-iptc:$name='$value' "; - } - } - //echo '<pre>', print_r($iptc_array), '</pre>'; - + /** + * If the backup went wrong or file isn't writable, trying + * to write MetaData would most probably also fail, so skip it + */ + if($write_ok) + { + /** + * Fire up exiftool + */ LinMetaData::__construct(); $file = $GLOBALS['linpha']->imgview->src_file; $exiftool = $this->objMetaTool->exiftool; + /** + * Prevent exiftool from backing up file, as we do take + * care of it our own :-) + */ + $parameter = "-overwrite_original "; + + /** + * Update all images in folder with given MetaData, + * therefore we need to fake file to dirname instead + */ + if($meta_array['linMassUpdate']) + { + $file = dirname($GLOBALS['linpha']->imgview->src_file); + $parameter .= "-r "; // Recursive + } + + /** + * Apply IPTC MetaData also to XMP and vice versa + */ + if(!isset($meta_array['linViceVersa'])) + { + $vice_versa = false; + } + else + { + $vice_versa = true; + } + + unset ($meta_array['linDoBackup']); + unset ($meta_array['linMassUpdate']); + unset ($meta_array['linViceVersa']); + + + /** + * Go ahead write MetaData + */ + if($vice_versa) + { + $metaTag = array('iptc', 'xmp'); + } + elseif($_POST['linCmd'] == 'linInsertMetaIptc') + { + $metaTag = 'iptc'; + } + elseif($_POST['linCmd'] == 'linInsertMetaXmp') + { + $metaTag = 'xmp'; + } + + + if(is_array($metaTag)) // ViceVersa Request + { echo "VICE VERSA"; + foreach($metaTag AS $segment) + { + foreach($meta_array AS $name => $value) + { + if(strlen(trim($value)) >= 1) + { + $name = str_replace("_", "-", $name); + $parameter .= "-$segment:$name='$value' "; + } + } + } + } + else + { + foreach($meta_array AS $name => $value) + { + if(strlen(trim($value)) >= 1) + { + $name = str_replace("_", "-", $name); + $parameter .= "-$metaTag:$name='$value' "; + } + } + } + //echo '<pre>', print_r($meta_array), '</pre>'; + //echo "parm".$parameter; + + /** + * Finally fire up exiftool + * TODO: take care of response status + */ exec("$exiftool $parameter $file"); /** * force read data from file again if write was successful */ - unset ($iptc_array); - LinImport :: updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); + unset ($meta_array); + LinImport:: + updateEntry($GLOBALS['linpha']->template->idCurrent, + dirname($GLOBALS['linpha']->imgview->src_file), + basename($GLOBALS['linpha']->imgview->src_file)); } else { - linSysLog(sprintf(i18n("Error: Cannot create backup of: %s"), $GLOBALS['linpha']->imgview->src_file)); - linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Cannot create backup of:" . ' ' . $GLOBALS['linpha']->imgview->src_file); + linSysLog(sprintf(i18n("Error: Processing of: %s failed, " . + "please check write permissions"), + $GLOBALS['linpha']->imgview->src_file)); + linLog(LOG_TYPE_META, LOG_ERR, 'meta_data', "Error: " . + "Processing failed for: ".' ' . + $GLOBALS['linpha']->imgview->src_file); } } } Modified: trunk/linpha2/lib/include/metadata_iptc_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-21 12:41:45 UTC (rev 4710) +++ trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-21 15:43:38 UTC (rev 4711) @@ -24,6 +24,23 @@ */ if(!defined('LINPHA_DIR')) { exit(1); } +?> +<tr><td rwospan="2"> + <input type='checkbox' name='linDoBackup' checked> + <?php echo i18n("Backup Original File"); ?> + </td> +</tr> +<tr><td rwospan="2"> + <input type='checkbox' name='linViceVersa' checked> + <?php echo i18n("Apply MetaData Also To XMP Segment"); ?> + </td> +</tr> +<tr><td rwospan="2"> + <input type='checkbox' name='linMassUpdate'> + <?php echo i18n("Apply To All Images In Album"); ?> + </td> +</tr> +<?php include_once(LINPHA_DIR.'/lib/classes/pjmt/Unicode.php'); Modified: trunk/linpha2/lib/include/metadata_xmp_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-03-21 12:41:45 UTC (rev 4710) +++ trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-03-21 15:43:38 UTC (rev 4711) @@ -24,6 +24,23 @@ */ if(!defined('LINPHA_DIR')) { exit(1); } +?> +<tr><td rwospan="2"> + <input type='checkbox' name='linDoBackup' checked> + <?php echo i18n("Backup Original File"); ?> + </td> +</tr> +<tr><td rwospan="2"> + <input type='checkbox' name='linViceVersa' checked> + <?php echo i18n("Apply MetaData Also To IPTC Segment"); ?> + </td> +</tr> +<tr><td rwospan="2"> + <input type='checkbox' name='linMassUpdate'> + <?php echo i18n("Apply To All Images In Album"); ?> + </td> +</tr> +<?php $MetaData = new LinMetaData(); $MetaData->setMetaFields('xmp'); Modified: trunk/linpha2/templates/default/fragments.php =================================================================== --- trunk/linpha2/templates/default/fragments.php 2007-03-21 12:41:45 UTC (rev 4710) +++ trunk/linpha2/templates/default/fragments.php 2007-03-21 15:43:38 UTC (rev 4711) @@ -204,12 +204,12 @@ <img style="margin-left: 20px;" src="<?php echo LINPHA_CLIENT.'/get_thumb.php?linId='.$GLOBALS['linpha']->template->idCurrent; ?>" width="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>" height="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; - ?>" /> - + ?>" /> + <?php if($GLOBALS['linpha']->imgview->img_type!=0) { ?> <div id="linDivMetaIptc"> <?php if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { - echo '<br /><br />'; + echo '<br />'; if($meta_edit_possible) { ?> <form action="<?php echo $linTpl->URL_full; ?>" method="POST"> <table border="0"> @@ -245,6 +245,7 @@ <?php if($GLOBALS['linpha']->imgview->img_type!=0) { ?> <div id="linDivMetaXmp"> <?php if($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) { + echo '<br />'; if($meta_edit_possible) { ?> <form action="<?php echo $linTpl->URL_full; ?>" method="POST"> <table border="0"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-22 17:29:44
|
Revision: 4713 http://svn.sourceforge.net/linpha/?rev=4713&view=rev Author: bzrudi Date: 2007-03-22 10:28:37 -0700 (Thu, 22 Mar 2007) Log Message: ----------- improved MetaData write support (still buggy) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/exiftool/xmp2iptc.args trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/metadata_iptc_edit.php trunk/linpha2/lib/include/metadata_xmp_edit.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-21 16:00:41 UTC (rev 4712) +++ trunk/linpha2/ChangeLog 2007-03-22 17:28:37 UTC (rev 4713) @@ -1,3 +1,6 @@ +2007-03-22 bzrudi + * Improved MetaData write support and started field type detection + 2007-03-21 bzrudi * Prepared support for extracting the embedded thumbnail from the EXIF segment of the images as thumbnail. Currently disabled by default. Modified: trunk/linpha2/lib/classes/exiftool/xmp2iptc.args =================================================================== --- trunk/linpha2/lib/classes/exiftool/xmp2iptc.args 2007-03-21 16:00:41 UTC (rev 4712) +++ trunk/linpha2/lib/classes/exiftool/xmp2iptc.args 2007-03-22 17:28:37 UTC (rev 4713) @@ -25,6 +25,7 @@ -XMP-photoshop:State > IPTC:Province-State -XMP-photoshop:Country > IPTC:Country-PrimaryLocationName -XMP-photoshop:TransmissionReference > IPTC:OriginalTransmissionReference +-XMP-photoshop:Urgency > IPTC:Urgency -XMP-dc:Rights > IPTC:CopyrightNotice -XMP-dc:Description > IPTC:Caption-Abstract -XMP-photoshop:CaptionWriter > IPTC:Writer-Editor Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 16:00:41 UTC (rev 4712) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-22 17:28:37 UTC (rev 4713) @@ -116,8 +116,10 @@ $parameters = "-$metatype:all " . // Get all Tag Information "-s " . // Print tag names instead of descr. "-t " . // Use tab \t as delimiter - "-fast "; // Do not read to EOF - + "-fast " . // Do not read to EOF + "-n " . // Read numbers instead of words + "-m "; //Ignore minor errors + exec("$this->exiftool $parameters $filename", $meta, $return); //echo '<pre>', print_r($meta), '</pre>'; @@ -167,7 +169,8 @@ if(array_key_exists($key, $lowerDataArray)) { $str_columns .= str_replace("_", "-", $key) . ', '; - $str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; + $str_values .= "'".trim($lowerDataArray[$key])."', "; + //$str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; } } @@ -307,7 +310,7 @@ 'contributor' => 'Contributor', 'coverage' => 'Coverage', 'creator' => 'Creator', - 'date' => 'Date', + //'date' => 'Date', 'description' => 'Description', 'format' => 'Format', 'identifier' => 'Identifier', @@ -344,9 +347,10 @@ 'objecttypereference' => 'Object Type Reference', 'objectattributereference' => 'Object Attribute Reference', 'objectname' => 'Object Name', + 'objectcycle' => 'Object Cycle', 'editstatus' => 'Edit Status', 'subjectreference' => 'Subject Reference', - 'category' => 'Category', + //'category' => 'Category', 'supplementalcategories' => 'Supplemental Categories', 'keywords' => 'Keywords', 'specialinstructions' => 'Special Instructions', @@ -354,19 +358,21 @@ 'timecreated' => 'Time Created', 'by_line' => 'By-line', 'by_linetitle' => 'By-line Title', - 'city' => 'City', + //'city' => 'City', 'sub_location' => 'Sub-location', - 'provincestate' => 'Province-State', + 'province_state' => 'Province-State', 'country_primarylocationcode' => 'Country-Primary Location Code', 'country_primarylocationname' => 'Country-Primary Location Name', 'originaltransmissionreference' => 'Original Transmission Reference', - 'headline' => 'Headline', - 'credit' => 'Credit', - 'source' => 'Source', + //'headline' => 'Headline', + //'credit' => 'Credit', + //'source' => 'Source', 'copyrightnotice' => 'Copyright Notice', 'contact' => 'Contact', 'caption_abstract' => 'Caption-Abstract', - 'writer_editor' => 'Writer-Editor' + 'writer_editor' => 'Writer-Editor', + 'originatingprogram' => 'Originating Program', + 'releasedate' => 'Release Date' ), //EXIF schema tags Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-21 16:00:41 UTC (rev 4712) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-22 17:28:37 UTC (rev 4713) @@ -443,12 +443,16 @@ } $meta_array['linDoBackup'] = false; } - if(!isset($meta_array['linMassUpdate'])) + + if(!isset($meta_array['linRecursiveUpdate'])) { - $meta_array['linMassUpdate'] = false; - } + $recursive_update = false; + } + else + { + $recursive_update = true; + } - /** * See if we should create file backup first. If it went wrong, * exit with $write_ok = false @@ -483,107 +487,109 @@ * Prevent exiftool from backing up file, as we do take * care of it our own :-) */ - $parameter = "-overwrite_original "; + $parameter = "-overwrite_original -n "; /** * Update all images in folder with given MetaData, * therefore we need to fake file to dirname instead */ - if($meta_array['linMassUpdate']) + if($recursive_update) { $file = dirname($GLOBALS['linpha']->imgview->src_file); $parameter .= "-r " . // Recursive - "-ext jpeg -ext jpg -ext tif -ext tiff "; + "-ext jpeg " . // Filetype + "-ext jpg " . + "-ext tif " . + "-ext tiff "; } /** - * Apply IPTC MetaData also to XMP and vice versa + * Apply XMP MetaData to IPTC Segment */ - if(!isset($meta_array['linViceVersa'])) + if(!isset($meta_array['linXmp2Iptc'])) { - $vice_versa = false; + $xmp2iptc = false; } else { - $vice_versa = true; + $xmp2iptc = true; } unset ($meta_array['linDoBackup']); - unset ($meta_array['linMassUpdate']); - unset ($meta_array['linViceVersa']); + unset ($meta_array['linRecursiveUpdate']); + unset ($meta_array['linXmp2Iptc']); /** * Go ahead write MetaData */ - if($vice_versa) + if($_POST['linCmd'] == 'linInsertMetaIptc') { - $metaTag = array('iptc', 'xmp'); - } - elseif($_POST['linCmd'] == 'linInsertMetaIptc') - { $metaTag = 'iptc'; } elseif($_POST['linCmd'] == 'linInsertMetaXmp') { $metaTag = 'xmp'; } + + foreach($meta_array AS $name => $value) + { + if(strlen(trim($value)) >= 1) + { + $name = str_replace("_", "-", $name); + $parameter .= "-$metaTag:$name='$value' "; + } + } + } + //echo '<pre>', print_r($meta_array), '</pre>'; + //echo "PARA :".$parameter; + + /** + * Finally fire up exiftool + * TODO: take care of response status + */ + exec("$exiftool $parameter $file"); - - if(is_array($metaTag)) // ViceVersa Request - { - foreach($metaTag AS $segment) - { - foreach($meta_array AS $name => $value) - { - if(strlen(trim($value)) >= 1) - { - $name = str_replace("_", "-", $name); - $parameter .= "-$segment:$name='$value' "; - } - } - } - } - else - { - foreach($meta_array AS $name => $value) - { - if(strlen(trim($value)) >= 1) - { - $name = str_replace("_", "-", $name); - $parameter .= "-$metaTag:$name='$value' "; - } - } - } - //echo '<pre>', print_r($meta_array), '</pre>'; - //echo "parm".$parameter; - - /** - * Finally fire up exiftool - * TODO: take care of response status - */ - exec("$exiftool $parameter $file"); - - /** - * force read data from file again if write was successful - */ - unset ($meta_array); - LinImport:: - updateEntry($GLOBALS['linpha']->template->idCurrent, + /** + * Copy XMP to IPTC if needed + * $parameter tags copied from xmp2iptc.args file from the + * exiftool distribution + */ + if($xmp2iptc) + { + echo "MAKE COPY"; + $options = " -TagsFromFile "; + + if($recursive_update) + { + $options .= "-r " . + "-ext jpeg -ext jpg -ext tif -ext tiff "; + } + + $arguments = LINPHA_DIR.'/lib/classes/exiftool/xmp2iptc.args'; + + exec("$exiftool $options $file -@ $arguments $file"); + } + + /** + * force read data from file again if write was successful + */ + unset ($meta_array); + LinImport:: + updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); - } - else - { - linSysLog(sprintf(i18n("Error: Processing of: %s failed, " . - "please check write permissions"), - $GLOBALS['linpha']->imgview->src_file)); - linLog(LOG_TYPE_META, LOG_ERR, 'meta_data', "Error: " . - "Processing failed for: ".' ' . - $GLOBALS['linpha']->imgview->src_file); - } + } + else + { + linSysLog(sprintf(i18n("Error: Processing of: %s failed, " . + "please check write permissions"), + $GLOBALS['linpha']->imgview->src_file)); + linLog(LOG_TYPE_META, LOG_ERR, 'meta_data', "Error: " . + "Processing failed for: ".' ' . + $GLOBALS['linpha']->imgview->src_file); } - } + } } Modified: trunk/linpha2/lib/include/metadata_iptc_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-21 16:00:41 UTC (rev 4712) +++ trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-22 17:28:37 UTC (rev 4713) @@ -24,6 +24,7 @@ */ if(!defined('LINPHA_DIR')) { exit(1); } + ?> <tr><td rwospan="2"> <input type='checkbox' name='linDoBackup' checked> @@ -31,64 +32,152 @@ </td> </tr> <tr><td rwospan="2"> - <input type='checkbox' name='linViceVersa' checked> - <?php echo i18n("Apply MetaData Also To XMP Segment"); ?> + <input type='checkbox' name='linRecursiveUpdate'> + <?php echo i18n("Apply To All Images In Album"); ?> </td> </tr> +<?php +/* <tr><td rwospan="2"> - <input type='checkbox' name='linMassUpdate'> - <?php echo i18n("Apply To All Images In Album"); ?> + <input type='checkbox' name='linViceVersa' checked> + <?php echo i18n("Apply MetaData Also To XMP Segment"); ?> </td> </tr> -<?php - +*/ +/** + * We are going to save all IPTC data UTF8 encoded in database + */ include_once(LINPHA_DIR.'/lib/classes/pjmt/Unicode.php'); + $MetaData = new LinMetaData(); $MetaData->setMetaFields('iptc'); $file_data = $MetaData->objMetaTool->readMetaDataFromFile('iptc', $filename); +/** + * User may have selected all fields, so there are no available fields left + * create emtpy array to prevent notices... + */ $iptc_avail = $MetaData->available_fields['iptc']; if(!is_array($iptc_avail)){ $iptc_avail = array(); }; - +/** + * User may have selected not even a single field for now, so there are no + * selected fields, create emtpy array to prevent notices... + */ $iptc_defined = $MetaData->defined_fields['iptc']; if(!is_array($iptc_defined)){ $iptc_defined = array(); }; /** - * Merge arrays + * Merge both arrays to make all fields avail */ $iptc_array = $iptc_avail + $iptc_defined; -//var_dump($file_data); - /** * Now output the actual HTML form */ - foreach($iptc_array AS $name => $value) { $lower_array = array_change_key_case($file_data, CASE_LOWER); - $name = str_replace("_", "-", $name); - + if(isset($lower_array[$name])) { - $file_iptc = HTML_UTF8_Escape($lower_array[$name]); + $file_iptc = HTML_UTF8_Escape(trim($lower_array[$name])); } else { $file_iptc = ""; } - echo - "<tr>" . - "<td>$value</td>" . - "<td> ". - "<input size=55 class='linForms' name='$name' - type='text' value='".$file_iptc."'>" . - "</td>" . - "</tr>"; + /** + * We need to take care of some special fields, e.g. special length, + * special types (select field) and so on... + */ + //echo $name."<br>"; + //echo $file_iptc."<br>"; + switch($name) + { + case 'objectcycle': + $sel_a = ""; + $sel_b = ""; + $sel_c = ""; + + switch($file_iptc) + { + case 'a': + $sel_a = "selected"; + break; + case 'b': + $sel_b = "selected"; + break; + case 'c': + $sel_c = "selected"; + break; + } + echo + "<tr>" . + "<td>$value</td>" . + "<td> ". + "<select name='$name' style='width:350px; size='1' + class='linForms'>" . + "<option value='a' $sel_a>Morning</option>" . + "<option value='b' $sel_b>Afternoon</option>" . + "<option value='c' $sel_c>Evening</option>" . + "</td>" . + "</tr>"; + break; -} + case 'caption-abstract': + echo + "<tr>" . + "<td>$value</td>" . + "<td> ". + "<textarea style='width:350px; height:60px;' class='linForms' + name='$name'>$file_iptc</textarea>" . + "</td>" . + "</tr>"; + break; + + case 'urgency': + /** + * Fast easy init ;-) + */ + for($i = 0; $i <= 8; $i++) + { + $sel[$i] = " "; + } + $sel[$file_iptc] = "selected"; + + echo + "<tr>" . + "<td>$value</td>" . + "<td> ". + "<select name='$name' style='width:350px; size='1' + class='linForms'>" . + "<option value='0' $sel[0]>0: None</option>" . + "<option value='1' $sel[1]>1: High</option>" . + "<option value='2' $sel[2]>2: </option>" . + "<option value='3' $sel[3]>3: </option>" . + "<option value='4' $sel[4]>4: </option>" . + "<option value='5' $sel[5]>5: Normal</option>" . + "<option value='6' $sel[6]>6: </option>" . + "<option value='7' $sel[7]>7: </option>" . + "<option value='8' $sel[8]>8: Low</option>" . + "</td>" . + "</tr>"; + break; + + default: + echo + "<tr>" . + "<td>$value</td>" . + "<td> ". + "<input style='width:350' class='linForms' name='$name' + type='text' value='".$file_iptc."'>" . + "</td>" . + "</tr>"; + } +} +/* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/lib/include/metadata_xmp_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-03-21 16:00:41 UTC (rev 4712) +++ trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-03-22 17:28:37 UTC (rev 4713) @@ -31,12 +31,12 @@ </td> </tr> <tr><td rwospan="2"> - <input type='checkbox' name='linViceVersa' checked> + <input type='checkbox' name='linXmp2Iptc' checked> <?php echo i18n("Apply MetaData Also To IPTC Segment"); ?> </td> </tr> <tr><td rwospan="2"> - <input type='checkbox' name='linMassUpdate'> + <input type='checkbox' name='linRecursiveUpdate'> <?php echo i18n("Apply To All Images In Album"); ?> </td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-03-23 13:46:50
|
Revision: 4716 http://svn.sourceforge.net/linpha/?rev=4716&view=rev Author: bzrudi Date: 2007-03-23 06:46:42 -0700 (Fri, 23 Mar 2007) Log Message: ----------- minor cleanups and improvements, to be continued.... Modified Paths: -------------- trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/metadata_iptc_edit.php trunk/linpha2/lib/include/metadata_xmp_edit.php trunk/linpha2/templates/default/fragments.php Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-23 13:45:37 UTC (rev 4715) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-23 13:46:42 UTC (rev 4716) @@ -310,7 +310,7 @@ 'contributor' => 'Contributor', 'coverage' => 'Coverage', 'creator' => 'Creator', - //'date' => 'Date', + 'date' => 'Date', 'description' => 'Description', 'format' => 'Format', 'identifier' => 'Identifier', @@ -327,7 +327,7 @@ 'colormode' => 'Color Mode', 'country' => 'Country', 'credit' => 'Credit', - 'datecreated' => 'DateCreated', + //'datecreated' => 'DateCreated', 'headline' => 'Headline', 'iccprofilename' => 'ICC Profile Name', 'instructions' => 'Instructions', Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-23 13:45:37 UTC (rev 4715) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-23 13:46:42 UTC (rev 4716) @@ -444,6 +444,9 @@ $meta_array['linDoBackup'] = false; } + /** + * Apply MetaData to all files in folder + */ if(!isset($meta_array['linRecursiveUpdate'])) { $recursive_update = false; @@ -487,7 +490,8 @@ * Prevent exiftool from backing up file, as we do take * care of it our own :-) */ - $parameter = "-overwrite_original -n "; + $parameter = "-overwrite_original " . // No Backup + "-n "; // Read numbers /** * Update all images in folder with given MetaData, @@ -504,7 +508,7 @@ } /** - * Apply XMP MetaData to IPTC Segment + * Apply XMP MetaData to IPTC Segment? */ if(!isset($meta_array['linXmp2Iptc'])) { @@ -552,23 +556,14 @@ /** * Copy XMP to IPTC if needed - * $parameter tags copied from xmp2iptc.args file from the - * exiftool distribution */ if($xmp2iptc) { - echo "MAKE COPY"; - $options = " -TagsFromFile "; - - if($recursive_update) - { - $options .= "-r " . - "-ext jpeg -ext jpg -ext tif -ext tiff "; - } + $options = "-TagsFromFile "; + $arguments = + LINPHA_DIR.'/lib/classes/exiftool/xmp2iptc.args'; - $arguments = LINPHA_DIR.'/lib/classes/exiftool/xmp2iptc.args'; - - exec("$exiftool $options $file -@ $arguments $file"); + exec("$exiftool $options $file -@ $arguments $file"); } /** Modified: trunk/linpha2/lib/include/metadata_iptc_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-23 13:45:37 UTC (rev 4715) +++ trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-23 13:46:42 UTC (rev 4716) @@ -26,24 +26,24 @@ if(!defined('LINPHA_DIR')) { exit(1); } ?> -<tr><td rwospan="2"> - <input type='checkbox' name='linDoBackup' checked> - <?php echo i18n("Backup Original File"); ?> +<tr><td> + <img style="margin-left: 20px;" src="<?php echo LINPHA_CLIENT.'/get_thumb.php?linId='.$GLOBALS['linpha']->template->idCurrent; + ?>" width="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; + ?>" height="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; + ?>" /> </td> -</tr> -<tr><td rwospan="2"> + <td> + <input type='checkbox' name='linDoBackup' checked> + <?php echo i18n("Backup Original File"); ?><br /> + <input type='checkbox' name='linIptc2Xmp' disabled> + <?php echo i18n("Apply MetaData Also To XMP Segment"); ?><br /> <input type='checkbox' name='linRecursiveUpdate'> - <?php echo i18n("Apply To All Images In Album"); ?> + <?php echo i18n("Apply To All Images In Album"); ?><br /> </td> </tr> +<tr><td colspan = "3"><hr /></td></tr> <?php -/* -<tr><td rwospan="2"> - <input type='checkbox' name='linViceVersa' checked> - <?php echo i18n("Apply MetaData Also To XMP Segment"); ?> - </td> -</tr> -*/ + /** * We are going to save all IPTC data UTF8 encoded in database */ @@ -54,19 +54,29 @@ $MetaData->setMetaFields('iptc'); $file_data = $MetaData->objMetaTool->readMetaDataFromFile('iptc', $filename); + /** * User may have selected all fields, so there are no available fields left * create emtpy array to prevent notices... */ $iptc_avail = $MetaData->available_fields['iptc']; -if(!is_array($iptc_avail)){ $iptc_avail = array(); }; +if(!is_array($iptc_avail)) +{ + $iptc_avail = array(); +} + + /** * User may have selected not even a single field for now, so there are no * selected fields, create emtpy array to prevent notices... */ $iptc_defined = $MetaData->defined_fields['iptc']; -if(!is_array($iptc_defined)){ $iptc_defined = array(); }; +if(!is_array($iptc_defined)) +{ + $iptc_defined = array(); +} + /** * Merge both arrays to make all fields avail */ @@ -126,47 +136,30 @@ "</td>" . "</tr>"; break; - - case 'caption-abstract': + + case 'specialinstructions': echo "<tr>" . "<td>$value</td>" . "<td> ". - "<textarea style='width:350px; height:60px;' class='linForms' - name='$name'>$file_iptc</textarea>" . + "<textarea style='width:350px; height:50px;' class='linForms' + name='$name' maxlength='255'>$file_iptc</textarea>" . "</td>" . "</tr>"; break; - case 'urgency': - /** - * Fast easy init ;-) - */ - for($i = 0; $i <= 8; $i++) - { - $sel[$i] = " "; - } - $sel[$file_iptc] = "selected"; - + + case 'caption-abstract': echo "<tr>" . "<td>$value</td>" . "<td> ". - "<select name='$name' style='width:350px; size='1' - class='linForms'>" . - "<option value='0' $sel[0]>0: None</option>" . - "<option value='1' $sel[1]>1: High</option>" . - "<option value='2' $sel[2]>2: </option>" . - "<option value='3' $sel[3]>3: </option>" . - "<option value='4' $sel[4]>4: </option>" . - "<option value='5' $sel[5]>5: Normal</option>" . - "<option value='6' $sel[6]>6: </option>" . - "<option value='7' $sel[7]>7: </option>" . - "<option value='8' $sel[8]>8: Low</option>" . + "<textarea style='width:350px; height:60px;' class='linForms' + name='$name' maxlength='1999'>$file_iptc</textarea>" . "</td>" . "</tr>"; break; - + default: echo "<tr>" . Modified: trunk/linpha2/lib/include/metadata_xmp_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-03-23 13:45:37 UTC (rev 4715) +++ trunk/linpha2/lib/include/metadata_xmp_edit.php 2007-03-23 13:46:42 UTC (rev 4716) @@ -25,39 +25,53 @@ if(!defined('LINPHA_DIR')) { exit(1); } ?> -<tr><td rwospan="2"> +<tr><td> + <img style="margin-left: 20px;" src="<?php echo LINPHA_CLIENT.'/get_thumb.php?linId='.$GLOBALS['linpha']->template->idCurrent; + ?>" width="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; + ?>" height="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; + ?>" /> + </td> + <td> <input type='checkbox' name='linDoBackup' checked> - <?php echo i18n("Backup Original File"); ?> - </td> -</tr> -<tr><td rwospan="2"> + <?php echo i18n("Backup Original File"); ?><br /> <input type='checkbox' name='linXmp2Iptc' checked> - <?php echo i18n("Apply MetaData Also To IPTC Segment"); ?> - </td> -</tr> -<tr><td rwospan="2"> + <?php echo i18n("Apply MetaData Also To IPTC Segment"); ?><br /> <input type='checkbox' name='linRecursiveUpdate'> - <?php echo i18n("Apply To All Images In Album"); ?> + <?php echo i18n("Apply To All Images In Album"); ?><br /> </td> </tr> +<tr><td colspan = "3"><hr /></td></tr> <?php $MetaData = new LinMetaData(); $MetaData->setMetaFields('xmp'); $file_data = $MetaData->objMetaTool->readMetaDataFromFile('xmp', $filename); +/** + * User may have selected all fields, so there are no available fields left + * create emtpy array to prevent notices... + */ $xmp_avail = $MetaData->available_fields['xmp']; -if(!is_array($xmp_avail)){ $xmp_avail = array(); }; +if(!is_array($xmp_avail)) +{ + $xmp_avail = array(); +} +/** + * User may have selected not even a single field for now, so there are no + * selected fields, create emtpy array to prevent notices... + */ $xmp_defined = $MetaData->defined_fields['xmp']; -if(!is_array($xmp_defined)){ $xmp_defined = array(); }; +if(!is_array($xmp_defined)) +{ + $xmp_defined = array(); +} /** - * Merge arrays + * Merge both arrays to make all fields avail */ $xmp_array = $xmp_avail + $xmp_defined; -//var_dump($file_data); /** * Now output the actual HTML form @@ -75,15 +89,54 @@ $file_xmp = ""; } - echo - "<tr>" . - "<td>$value</td>" . - "<td> ". - "<input size=55 class='linForms' name='$name' - type='text' value='".$file_xmp."'>" . - "</td>" . - "</tr>"; - + /** + * We need to take care of some special fields, e.g. special length, + * special types (select field) and so on... + */ + //echo $name."<br>"; + //echo $file_iptc."<br>"; + switch($name) + { + case 'urgency': + /** + * Fast easy init ;-) + */ + for($i = 0; $i <= 8; $i++) + { + $sel[$i] = " "; + } + $sel[$file_xmp] = "selected"; + + echo + "<tr>" . + "<td>$value</td>" . + "<td> ". + "<select name='$name' style='width:350px; size='1' + class='linForms'>" . + "<option value='0' $sel[0]>0: None</option>" . + "<option value='1' $sel[1]>1: High</option>" . + "<option value='2' $sel[2]>2: </option>" . + "<option value='3' $sel[3]>3: </option>" . + "<option value='4' $sel[4]>4: </option>" . + "<option value='5' $sel[5]>5: Normal</option>" . + "<option value='6' $sel[6]>6: </option>" . + "<option value='7' $sel[7]>7: </option>" . + "<option value='8' $sel[8]>8: Low</option>" . + "</td>" . + "</tr>"; + break; + + default: + echo + "<tr>" . + "<td>$value</td>" . + "<td> ". + "<input name='$name' style='width:350px;' class='linForms' + type='text' value='".$file_xmp."'>" . + "</td>" . + "</tr>"; + break; + } } +/* vi: set ts=4 sw=4 sts=4 */ ?> - Modified: trunk/linpha2/templates/default/fragments.php =================================================================== --- trunk/linpha2/templates/default/fragments.php 2007-03-23 13:45:37 UTC (rev 4715) +++ trunk/linpha2/templates/default/fragments.php 2007-03-23 13:46:42 UTC (rev 4716) @@ -201,11 +201,6 @@ </form> </div> - <img style="margin-left: 20px;" src="<?php echo LINPHA_CLIENT.'/get_thumb.php?linId='.$GLOBALS['linpha']->template->idCurrent; - ?>" width="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; - ?>" height="<?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; - ?>" /> - <?php if($GLOBALS['linpha']->imgview->img_type!=0) { ?> <div id="linDivMetaIptc"> <?php if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2007-03-23 16:00:37
|
Revision: 4718 http://svn.sourceforge.net/linpha/?rev=4718&view=rev Author: fangehrn Date: 2007-03-23 09:00:31 -0700 (Fri, 23 Mar 2007) Log Message: ----------- 2007-03-23 flo * fixed bugs in MetaData - 'LIN_OS' -> LIN_OS - exec() -> LinFilesys::linExec() - i18n("test ". "test") -> i18n("test test") - enclose filenames with quotes * and yes, it works under windows! Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/docs/dev/important stuff.txt trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-23 13:51:32 UTC (rev 4717) +++ trunk/linpha2/ChangeLog 2007-03-23 16:00:31 UTC (rev 4718) @@ -1,3 +1,13 @@ + +2007-03-23 flo + * fixed bugs in MetaData + - 'LIN_OS' -> LIN_OS + - exec() -> LinFilesys::linExec() + - i18n("test ". + "test") -> i18n("test test") + - enclose filenames with quotes + * and yes, it works under windows! + 2007-03-22 bzrudi * Improved MetaData write support and started field type detection Modified: trunk/linpha2/docs/dev/important stuff.txt =================================================================== --- trunk/linpha2/docs/dev/important stuff.txt 2007-03-23 13:51:32 UTC (rev 4717) +++ trunk/linpha2/docs/dev/important stuff.txt 2007-03-23 16:00:31 UTC (rev 4718) @@ -6,7 +6,8 @@ exec($str, $array_output, $return_value); - windows apache may hang if exec() is used twice without session_write_close() before - don't know if this problem is still present + don't know if this problem is still present -> yes it is! (flo, 2007-03-23) + -> do not use exec, but use LinFilesys::linExec which takes care of this - filesize($tmp_file) may return zero if clearstatcache() is not executed! Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-23 13:51:32 UTC (rev 4717) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-23 16:00:31 UTC (rev 4718) @@ -37,15 +37,15 @@ { /** * Automagic set required exiftool depending on OS - * @todo mac/win Testing + * @todo mac detecting and testing */ - if('LIN_OS' != "win") + if(LIN_OS == "unix") { $this->exiftool = LINPHA_DIR.'/lib/classes/exiftool/exiftool'; } - elseif('LIN_OS' == "win") + elseif(LIN_OS == "win") { - $this->exiftool = LINPHA_DIR.'/lib/classes/exiftool/exiftool.exe'; + $this->exiftool = LINPHA_DIR.'\lib\classes\exiftool\exiftool.exe'; // forward slashes will not work } else // Macintosh { @@ -72,7 +72,7 @@ * Buffer output of passthru and save to $thumb var */ ob_start(); - passthru("$this->exiftool $parameters $filename"); + passthru($this->exiftool.' '.$parameters.' "'.$filename.'"'); $thumb = ob_get_contents(); ob_end_clean(); @@ -120,19 +120,21 @@ "-n " . // Read numbers instead of words "-m "; //Ignore minor errors - exec("$this->exiftool $parameters $filename", $meta, $return); - //echo '<pre>', print_r($meta), '</pre>'; + LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $meta, $return); + /*echo $this->exiftool.' '.$parameters.' "'.$filename.'"'; + echo '<pre>', print_r($meta), '</pre>'; + exit();*/ + /** * Create usable array information by cycling and splitting * all information */ - foreach($meta AS $value) + foreach($meta as $value) { $temp = explode("\t", $value); $metaArray[trim($temp['0'])] = @trim($temp['1']); } - //echo '<pre>', print_r($test), '</pre>'; return $metaArray; } @@ -205,7 +207,7 @@ "-exif:orientation " . // Get orientation tag "-s -n -t"; // Print tag name tab seper. - exec("$this->exiftool $parameters $filename", $meta, $return); + LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $meta, $return); if(is_array($meta)) { Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-23 13:51:32 UTC (rev 4717) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-23 16:00:31 UTC (rev 4718) @@ -544,46 +544,48 @@ $parameter .= "-$metaTag:$name='$value' "; } } - } - //echo '<pre>', print_r($meta_array), '</pre>'; - //echo "PARA :".$parameter; - - /** - * Finally fire up exiftool - * TODO: take care of response status - */ - exec("$exiftool $parameter $file"); - /** - * Copy XMP to IPTC if needed - */ - if($xmp2iptc) - { - $options = "-TagsFromFile "; - $arguments = - LINPHA_DIR.'/lib/classes/exiftool/xmp2iptc.args'; - - exec("$exiftool $options $file -@ $arguments $file"); - } - - /** - * force read data from file again if write was successful - */ - unset ($meta_array); - LinImport:: - updateEntry($GLOBALS['linpha']->template->idCurrent, - dirname($GLOBALS['linpha']->imgview->src_file), - basename($GLOBALS['linpha']->imgview->src_file)); - } - else - { - linSysLog(sprintf(i18n("Error: Processing of: %s failed, " . - "please check write permissions"), - $GLOBALS['linpha']->imgview->src_file)); - linLog(LOG_TYPE_META, LOG_ERR, 'meta_data', "Error: " . - "Processing failed for: ".' ' . - $GLOBALS['linpha']->imgview->src_file); - } + //echo '<pre>', print_r($meta_array), '</pre>'; + //echo "PARA :".$parameter; + + /** + * Finally fire up exiftool + * TODO: take care of response status + */ + $array_output = array(); $return_value = false; + LinFilesys::linExec($exiftool.' '.$parameter.' "'.$file.'"', $array_output, $return_value); + + /** + * Copy XMP to IPTC if needed + */ + if($xmp2iptc) + { + $options = "-TagsFromFile "; + $arguments = + LINPHA_DIR.'/lib/classes/exiftool/xmp2iptc.args'; + + $array_output = array(); $return_value = false; + LinFilesys::linExec($exiftool.' '.$options.' "'.$file.'" -@ '.$arguments.' "'.$file.'"', $array_output, $return_value); + } + + /** + * force read data from file again if write was successful + */ + unset ($meta_array); + LinImport:: + updateEntry($GLOBALS['linpha']->template->idCurrent, + dirname($GLOBALS['linpha']->imgview->src_file), + basename($GLOBALS['linpha']->imgview->src_file)); + } + else + { + linSysLog(sprintf(i18n("Error: Processing of: %s failed, please check write permissions"), + $GLOBALS['linpha']->imgview->src_file)); + linLog(LOG_TYPE_META, LOG_ERR, 'meta_data', "Error: " . + "Processing failed for: ".' ' . + $GLOBALS['linpha']->imgview->src_file); + } + } } } @@ -843,7 +845,7 @@ foreach ($array AS $key => $value) { $value = str_replace("-", "_", strtolower($value)); - $str .= LinSql::linAddslashes(strtolower($value))."VARCHAR(255), "; + $str .= LinSql::linAddslashes(strtolower($value))." VARCHAR(255), "; } $str .= "PRIMARY KEY (md5sum), "; $str .= "KEY (md5sum) )"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-07-04 09:57:59
|
Revision: 4723 http://svn.sourceforge.net/linpha/?rev=4723&view=rev Author: bzrudi Date: 2007-07-04 02:57:52 -0700 (Wed, 04 Jul 2007) Log Message: ----------- "add ignored files to read from db, fixed a couple of bugs regarding embedded thumbnails (exiftool stuff)" Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.import.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-07-04 08:42:36 UTC (rev 4722) +++ trunk/linpha2/ChangeLog 2007-07-04 09:57:52 UTC (rev 4723) @@ -1,3 +1,6 @@ +2007-07-03 bzrudi + * Added support for ignored filetypes stored in DB + * Some fixes to make embedded thumbnails work better using exiftool 2007-03-23 flo * fixed bugs in MetaData Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-07-04 08:42:36 UTC (rev 4722) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-07-04 09:57:52 UTC (rev 4723) @@ -64,7 +64,8 @@ */ public function getEmbeddedThumbnail($filename, $outfile) { - + $got_thumb = false; //prevent notice + $parameters = "-b " . // get binary data "-ThumbnailImage"; // get thumbnail from composite @@ -76,9 +77,11 @@ $thumb = ob_get_contents(); ob_end_clean(); - if(strlen($thumb)>10) + if(strlen($thumb) > 10) { - if(file_put_contents($outfile, $thumb)) + $fileobj = file_put_contents($outfile, $thumb); + + if($fileobj > 10) //$fileobj is number of bytes written { $got_thumb = true; } Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2007-07-04 08:42:36 UTC (rev 4722) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2007-07-04 09:57:52 UTC (rev 4723) @@ -392,17 +392,27 @@ include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); $objExifTool = new LinExifTool; - $objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file); + + /** + * Default fallback if image doesn't contain embedded thumb + */ + if(!$objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file)) + { + $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; + $this->imageTool->imgQuality = 75; + + $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); + } } else { - /** - * include the file which contains the imagemagick strings and exec() / gdlib instructions - */ - $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; - $this->imageTool->imgQuality = 75; + /** + * include the file which contains the imagemagick strings and exec() / gdlib instructions + */ + $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; + $this->imageTool->imgQuality = 75; - $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); + $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); } } Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2007-07-04 08:42:36 UTC (rev 4722) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2007-07-04 09:57:52 UTC (rev 4723) @@ -538,15 +538,17 @@ */ function getIgnoreFilelist() { - return Array( - 'CVS', // CVS - 'Thumbs.db', // Windows - 'ZbThumbnail.info', // ? - '_vti_cnf', // IIS - '_derived', // IIS - 'lost+found' // Linux - ); +$ignored_files = explode(",", str_replace(" ", "," ,$GLOBALS['linpha']->sql->config->value['sys_import_files_ignored'])); + if(is_array($ignored_files)) + { + return $ignored_files; + } + else + { + return array(); + } + } @@ -558,10 +560,17 @@ */ function getIgnoreFileext() { - return Array( - 'thm' // jpg thumbnails of videos on Canon cameras - //(this thumbnail is automatically taken as thumbnail of the video itself) - ); +$ignored_fileext = explode(",", str_replace(" ", "," ,$GLOBALS['linpha']->sql->config->value['sys_import_fileext_ignored'])); + + if(is_array($ignored_fileext)) + { + return $ignored_fileext; + } + else + { + return array(); + } + } } // end class linImport This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-07-04 15:52:23
|
Revision: 4725 http://svn.sourceforge.net/linpha/?rev=4725&view=rev Author: bzrudi Date: 2007-07-04 08:52:20 -0700 (Wed, 04 Jul 2007) Log Message: ----------- add error page support Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.sql.class.php Added Paths: ----------- trunk/linpha2/lib/graphics/linpha2.gif trunk/linpha2/lib/include/db_connect_error.html Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-07-04 15:04:54 UTC (rev 4724) +++ trunk/linpha2/ChangeLog 2007-07-04 15:52:20 UTC (rev 4725) @@ -1,6 +1,7 @@ 2007-07-03 bzrudi * Added support for ignored filetypes stored in DB * Some fixes to make embedded thumbnails work better using exiftool + * Added missing db_connect_error.html page and made it work as expected 2007-03-23 flo * fixed bugs in MetaData Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2007-07-04 15:04:54 UTC (rev 4724) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2007-07-04 15:52:20 UTC (rev 4725) @@ -55,6 +55,7 @@ } else { + error_reporting(0); include_once(LINPHA_DIR.'/lib/adodb/adodb-errorhandler.inc.php'); $sql_dir = ''; @@ -69,11 +70,9 @@ { linLog(LOG_TYPE_DB,LOG_EMERG,'db_connect',"Cannot connect to the database !!! Cannot get config file ./var/config.sql.php"); - echo "Cannot connect to the database, please contact admin!!!<br />"; - echo "Cannot get config file './var/config.sql.php'<br />"; + include(LINPHA_DIR."/lib/include/db_connect_error.html"); + echo "<br /><br /><b>ERROR MESSAGE: Failed to include config file './var/config.sql.php' is it missing?</b>"; - include(LINPHA_DIR."/include/db_connect_error.html"); - exit(1); } } @@ -146,11 +145,6 @@ { echo failed_msg().'<br />'; } - - if( isset($GLOBALS['linpha']->db) ) - { - echo $GLOBALS['linpha']->db->ErrorMsg().'<br />'; - } if( isset($_SESSION['installmode2']) ) { @@ -169,7 +163,10 @@ linLog(LOG_TYPE_DB,LOG_EMERG,'db_connect',"Cannot connect to database!"); } - include(LINPHA_DIR."/include/db_connect_error.html"); + include(LINPHA_DIR."/lib/include/db_connect_error.html"); + echo "<br /><br /><b>ERROR MESSAGE: Cannot connect Database: ".$GLOBALS['linpha']->db->ErrorMsg()." is it running?</b>"; + + } exit(1); } Added: trunk/linpha2/lib/graphics/linpha2.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/graphics/linpha2.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/include/db_connect_error.html =================================================================== --- trunk/linpha2/lib/include/db_connect_error.html (rev 0) +++ trunk/linpha2/lib/include/db_connect_error.html 2007-07-04 15:52:20 UTC (rev 4725) @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'> +<?php error_reporting(0); +?> +<html><head><title>LinPHA Database Error</title> +<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'> +</head> +<body> +<div align="center"> +<br> +<h2><u>Database Connection Error</u></h2> +<br><br> +<img src="<?php echo LINPHA_DIR; ?>/lib/graphics/linpha2.gif"> +<br><br> +<h2>Service should be back shortly</h2> +The LinPHA Team +</body></html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |