[Linpha-cvs] SF.net SVN: linpha: [4707] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
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. |