[Linpha-cvs] SF.net SVN: linpha: [4476] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-04-02 21:02:47
|
Revision: 4476 Author: fangehrn Date: 2006-04-02 14:02:17 -0700 (Sun, 02 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4476&view=rev Log Message: ----------- * added select thumbnail feature * improving metadata Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/image_fields_define.php trunk/linpha2/admin/image_fields_define_post.php trunk/linpha2/admin/image_fields_select.php trunk/linpha2/index.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/install/sql/sql.mysql.php trunk/linpha2/install/sql/sql.postgres.php trunk/linpha2/install/sql/sql.sqlite.php trunk/linpha2/lib/classes/linpha.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/thumbnails.js trunk/linpha2/lib/modules/module.albums.php trunk/linpha2/lib/modules/module.browse.php trunk/linpha2/templates/default/view_thumb.html.php Added Paths: ----------- trunk/linpha2/docs/TODO.txt trunk/linpha2/lib/include/upgrade.php Removed Paths: ------------- trunk/linpha2/dev.txt Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/ChangeLog 2006-04-02 21:02:17 UTC (rev 4476) @@ -3,6 +3,8 @@ * updated documentation, added todo list * added a reset_database.php script which reloads the table entries maybe needs to be extended to recreate all tables, but not yet.. + * added select thumbnail feature + * improving metadata 2006-04-01 flo * update several folder paths Modified: trunk/linpha2/admin/image_fields_define.php =================================================================== --- trunk/linpha2/admin/image_fields_define.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/admin/image_fields_define.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -249,19 +249,6 @@ $MetaData = new MetaData(); $MetaData->setFields( $GLOBALS['cat3'] ); - switch($GLOBALS['cat3']) - { - case 'exif': - $defined_fields = 'defined_exif_fields'; - $available_fields = 'available_exif_fields'; - break; - case 'iptc': - $defined_fields = 'defined_iptc_fields'; - $available_fields = 'available_iptc_fields'; - break; - } - - /** * get enabled/disabled setting */ @@ -284,7 +271,7 @@ Selected fields<br /> <select id="selected_fields" name="selected_fields[]" size="25" style="width: 200px;" multiple="multiple"> <?php - foreach($MetaData->$defined_fields AS $key=>$value) + foreach($MetaData->defined_fields[$GLOBALS['cat3']] AS $key=>$value) { echo '<option value="'.$key.'">'.$value.'</option>'."\n"; } @@ -301,7 +288,7 @@ Available fields<br /> <select id="all_fields" name="builtin_fields" size="25" style="width: 200px;"> <?php - foreach($MetaData->$available_fields AS $key=>$value) + foreach($MetaData->available_fields[$GLOBALS['cat3']] AS $key=>$value) { echo '<option value="'.$key.'">'.$value.'</option>'; } Modified: trunk/linpha2/admin/image_fields_define_post.php =================================================================== --- trunk/linpha2/admin/image_fields_define_post.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/admin/image_fields_define_post.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -20,6 +20,9 @@ break; case 'add_new': + /** + * check for duplicates with the same name + */ $linpha->db->Execute("INSERT into ".PREFIX."meta_fields (name, field_type, flags) " . "VALUES ('".linSql::linAddslashes($_POST['new_name'])."', '".linSql::linAddslashes($_POST['new_type'])."', '7') "); break; Modified: trunk/linpha2/admin/image_fields_select.php =================================================================== --- trunk/linpha2/admin/image_fields_select.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/admin/image_fields_select.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -13,31 +13,46 @@ 'album' => Array('name' => 'Album', 'link' => 'imagefields_select_album') ); -if(isset($_POST['cmd'])) +print_admin_menu($array_menu,$cat3); + +switch($cat3) { - /** - * delete all existing entries in database - */ - $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_fields WHERE flags = '10'"); +case 'image': + printFieldsTable(10); + break; +case 'thumb': + printFieldsTable(13); + break; - /** - * write new entrys - */ - if(isset($_POST['select_image_fields'])) +case 'video': + + break; +} + + + +function printFieldsTable($flag_nr) +{ + if(isset($_POST['cmd']) && $_POST['cmd']=='select_image_fields') { - foreach($_POST['select_image_fields'] AS $value) + /** + * delete all existing entries in database + */ + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_fields WHERE flags = '".$flag_nr."'"); + + /** + * write new entrys + */ + if(isset($_POST['select_image_fields'])) { - $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_fields (name, flags)" . - " VALUES ('".linSql::linAddslashes($value)."','10')"); + foreach($_POST['select_image_fields'] AS $value) + { + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_fields (name, flags)" . + " VALUES ('".linSql::linAddslashes($value)."','".$flag_nr."')"); + } } } -} -print_admin_menu($array_menu,$cat3); - -switch($cat3) -{ -case 'image': /** * set exif/iptc fields */ @@ -54,7 +69,7 @@ Selected fields<br /> <select id="select_image_fields" name="select_image_fields[]" size="25" style="width: 200px;" multiple="multiple"> <?php - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE flags = '10' ORDER by id"); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE flags = '".$flag_nr."' ORDER by id"); while($data = $query->FetchRow()) { echo '<option value="'.$data['name'].'">'.$MetaData->getNameOfField($data['name'],true).'</option>'; @@ -74,14 +89,14 @@ <input type="button" name="builtin_shiftleft" value="<" onclick="copyElement('image_fields')" /> </td> <td> - Image fields<br /> + Image fields (builtin)<br /> <select id="image_fields" name="image_fields" size="7" style="width: 200px;"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields " . - "WHERE flags = '1'"); + "WHERE flags = '1' OR flags = '5'"); while($data = $query->FetchRow()) { - echo '<option value="id_'.$data['id'].'">'.$MetaData->array_special_fields[$data['name']].'</option>'; + echo '<option value="builtin_'.$data['name'].'">'.i18n( ucfirst( $data['name'] ) ).'</option>'; } ?> </select> @@ -92,11 +107,11 @@ <input type="button" name="own_shiftleft" value="<" onclick="copyElement('own_fields')" /> </td> <td> - Tag fields (<a href="./?cat=imagefields_define_own">define</a>)<br /> + Image fields (own) (<a href="./?cat=imagefields_define_own">define</a>)<br /> <select id="own_fields" name="own_fields" size="7" style="width: 200px;"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields " . - "WHERE flags = '5' OR flags = '7'"); + "WHERE flags = '7'"); while($data = $query->FetchRow()) { echo '<option value="id_'.$data['id'].'">'.$data['name'].'</option>'; @@ -120,7 +135,7 @@ ?> <select id="exif_fields" name="exif_fields" size="7" style="width: 200px;"<?php echo $str_disabled; ?>> <?php - foreach($MetaData->defined_exif_fields AS $key=>$value) + foreach($MetaData->defined_fields['exif'] AS $key=>$value) { echo '<option value="exif_'.$key.'">'.$value.'</option>'; } @@ -143,7 +158,7 @@ ?> <select id="iptc_fields" name="iptc_fields" size="7" style="width: 200px;"<?php echo $str_disabled; ?>> <?php - foreach($MetaData->defined_iptc_fields AS $key=>$value) + foreach($MetaData->defined_fields['iptc'] AS $key=>$value) { echo '<option value="iptc_'.$key.'">'.$value.'</option>'; } @@ -158,150 +173,137 @@ </div> </form> -<?php - break; -case 'thumb': - - break; - -case 'video': - ?> - - <?php - break; -} -?> - - - -<script type="text/javascript"> -/** - * http://www.babailiica.com/js/sorter/ - */ - -function selectAll() -{ - obj = document.getElementById('select_image_fields'); - for (var i=0; i<obj.length; i++) { - obj[i].selected = true; - } -} - - -function copyElement (coming_from) -{ - obj_from = document.getElementById(coming_from); - obj = document.getElementById('select_image_fields'); - - NewEntry = new Option( obj_from.options[ obj_from.selectedIndex ].text, obj_from.options[ obj_from.selectedIndex ].value, false, true ); - obj.options[ obj.options.length ] = NewEntry; - + <script type="text/javascript"> /** - * append ' (exif)' and ' (iptc)' + * http://www.babailiica.com/js/sorter/ */ - if(coming_from=='exif_fields') + + function selectAll() { - obj.options[ obj.options.length-1 ].text = obj.options[ obj.options.length-1 ].text + ' (exif)'; + obj = document.getElementById('select_image_fields'); + for (var i=0; i<obj.length; i++) { + obj[i].selected = true; + } } - if(coming_from=='iptc_fields') - { - obj.options[ obj.options.length-1 ].text = obj.options[ obj.options.length-1 ].text + ' (iptc)'; - } - - /** - * remove new selection on left side - */ - obj.options[ obj.options.length-1 ].selected = false; -} - -function addElement () -{ - obj = document.getElementById('select_image_fields'); - - NewEntry = new Option( document.form_image_fields.title_name.value, document.form_image_fields.title_name.value, false, true ); - NewEntry.className = "option_title"; - obj.options[obj.options.length] = NewEntry; - document.form_image_fields.title_name.value = ""; -} - -function deleteElement () -{ - obj = document.getElementById('select_image_fields'); - current_index = obj.selectedIndex; - obj.options[ current_index ] = null; - - /** - * set selectedIndex back to field above - */ - if( current_index == obj.length ) + function copyElement (coming_from) { - obj.selectedIndex = current_index - 1; + obj_from = document.getElementById(coming_from); + obj = document.getElementById('select_image_fields'); + + NewEntry = new Option( obj_from.options[ obj_from.selectedIndex ].text, obj_from.options[ obj_from.selectedIndex ].value, false, true ); + obj.options[ obj.options.length ] = NewEntry; + + /** + * append ' (exif)' and ' (iptc)' + */ + if(coming_from=='exif_fields') + { + 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)'; + } + + + /** + * remove new selection on left side + */ + obj.options[ obj.options.length-1 ].selected = false; } - else + + function addElement () { - obj.selectedIndex = current_index; + obj = document.getElementById('select_image_fields'); + + NewEntry = new Option( document.form_image_fields.title_name.value, document.form_image_fields.title_name.value, false, true ); + NewEntry.className = "option_title"; + obj.options[obj.options.length] = NewEntry; + document.form_image_fields.title_name.value = ""; } -} - -function moveupElement () -{ - obj = document.getElementById('select_image_fields'); - current_index = obj.selectedIndex; - if( current_index != 0 ) + function deleteElement () { - /** - * swap entries - */ - tmp_value = obj.options[ current_index ].value; - tmp_text = obj.options[ current_index ].text; - tmp_class = obj.options[ current_index ].className; + obj = document.getElementById('select_image_fields'); - obj.options[ current_index ].value = obj.options[ current_index - 1].value; - obj.options[ current_index ].text = obj.options[ current_index - 1].text; - obj.options[ current_index ].className = obj.options[ current_index - 1].className; - - obj.options[ current_index - 1].value = tmp_value; - obj.options[ current_index - 1].text = tmp_text; - obj.options[ current_index - 1].className = tmp_class; - + current_index = obj.selectedIndex; + obj.options[ current_index ] = null; + /** - * set selectedIndex back to swapped field + * set selectedIndex back to field above */ - obj.selectedIndex = current_index - 1; + if( current_index == obj.length ) + { + obj.selectedIndex = current_index - 1; + } + else + { + obj.selectedIndex = current_index; + } } -} - -function movedownElement () -{ - obj = document.getElementById('select_image_fields'); - current_index = obj.selectedIndex; - - if( current_index != ( obj.length - 1 ) ) + function moveupElement () { - /** - * swap entries - */ - tmp_value = obj.options[ current_index ].value; - tmp_text = obj.options[ current_index ].text; - tmp_class = obj.options[ current_index ].className; + obj = document.getElementById('select_image_fields'); - obj.options[ current_index ].value = obj.options[ current_index + 1].value; - obj.options[ current_index ].text = obj.options[ current_index + 1].text; - obj.options[ current_index ].className = obj.options[ current_index + 1].className; - - obj.options[ current_index + 1].value = tmp_value; - obj.options[ current_index + 1].text = tmp_text; - obj.options[ current_index + 1].className = tmp_class; + current_index = obj.selectedIndex; + if( current_index != 0 ) + { + /** + * swap entries + */ + tmp_value = obj.options[ current_index ].value; + tmp_text = obj.options[ current_index ].text; + tmp_class = obj.options[ current_index ].className; + + obj.options[ current_index ].value = obj.options[ current_index - 1].value; + obj.options[ current_index ].text = obj.options[ current_index - 1].text; + obj.options[ current_index ].className = obj.options[ current_index - 1].className; + + obj.options[ current_index - 1].value = tmp_value; + obj.options[ current_index - 1].text = tmp_text; + obj.options[ current_index - 1].className = tmp_class; + + /** + * set selectedIndex back to swapped field + */ + obj.selectedIndex = current_index - 1; + } + } + + function movedownElement () + { + obj = document.getElementById('select_image_fields'); - /** - * set selectedIndex back to swapped field - */ - obj.selectedIndex = current_index + 1; + current_index = obj.selectedIndex; + + if( current_index != ( obj.length - 1 ) ) + { + /** + * swap entries + */ + tmp_value = obj.options[ current_index ].value; + tmp_text = obj.options[ current_index ].text; + tmp_class = obj.options[ current_index ].className; + + obj.options[ current_index ].value = obj.options[ current_index + 1].value; + obj.options[ current_index ].text = obj.options[ current_index + 1].text; + obj.options[ current_index ].className = obj.options[ current_index + 1].className; + + obj.options[ current_index + 1].value = tmp_value; + obj.options[ current_index + 1].text = tmp_text; + obj.options[ current_index + 1].className = tmp_class; + + /** + * set selectedIndex back to swapped field + */ + obj.selectedIndex = current_index + 1; + } } + </script> +<?php } -</script> \ No newline at end of file +?> \ No newline at end of file Deleted: trunk/linpha2/dev.txt =================================================================== --- trunk/linpha2/dev.txt 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/dev.txt 2006-04-02 21:02:17 UTC (rev 4476) @@ -1,7 +0,0 @@ -ADODB_FETCH_ASSOC - -linSql::linAddslashes( ) - -$GLOBALS['linpha']->sql->config->value['']; - -<?php echo i18n(""); ?> \ No newline at end of file Added: trunk/linpha2/docs/TODO.txt =================================================================== --- trunk/linpha2/docs/TODO.txt (rev 0) +++ trunk/linpha2/docs/TODO.txt 2006-04-02 21:02:17 UTC (rev 4476) @@ -0,0 +1,121 @@ +############################################################################ +TODOS 2.0 +############################################################################ + + +## Small Todos +- Better Javascript detection + Currently the no-javscript site is loaded with a javascript location.href to the javascript enabled site + -> High Pageload, LinSysLog doesnt work + + +## Big Todos +- get_image.php (Image View, Image Cache) +- Slideshow (copy from linpha1) +- Search (copy from linpha1) +- Basket (finish) + - Support for the Icons + +- IPTC Image fields + - Write IPTC entries (see also https://sourceforge.net/forum/message.php?msg_id=3648731) + + +- User/Group System (copy from linpha1) + - Permissions + +- Filemanager (copy from linpha1) + - Add support for Write-Permissions + +- Plugins (copy from linpha1) + + + + + + + + + + + DONE + ==== + +- check automatically if a file was changed by an external program and update md5sum etc. +- check how much faster it is to have thumbnails stored on filesystem and not in db +- use of get_ride_of_magicquotes() in all files + + - use of templates (smarty? css? (http://www.csszengarden.com/tr/deutsch)) + use one css file for global settings + different css files for layout settings + different css files for colour settings + use css files like this: + // font settings + body, td, ..., ..., ... { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10pt; + color: #000033; + } + + // background color + body, td, .......... { + background-color: #002200; + } + + layout with header and footer written in css: + http://css.fractatulum.net/sample/layout7format.htm + + + - store thumbnails in /var/cache/thumb? + - id or md5sum based? + /* edit bzrudi */ + (as discussed it should be id based...) + + - allow unlimited subfolders + - allow permissions set to all files and folders + + - complete rewrite of the install scripts + more steps: + 1. check requirements + 2. select db type + 3. enter db user/pass + 4. check connection + 5. create database or not (not needed with sqlite) + 6. create tables + 7. further settings (thumbnail size, admin account) + + - new folder structure: + actions/ + admin/ + admin/actions + admin/lang + albums/ + docs/ + docs/lang + graphics/ + install/ + install/lang + lang/ + lib/ + lib/adodb ? + lib/classes + lib/functions + lib/include + plugins/ + styles/layout/ + styles/format/ + + sql/ ? evtl. auch "tmp" "cache" oder etwas besseres ? + +- db design: + linpha_photos(id, name, md5sum, type, date_added) + linpha_permissions(id, photos_id, permissions, read_write) + linpha_stats(md5sum, downloads, views) + + todo: create sql query where it is possible with only one query to select only images + where i have permission to read like we have it with linpha 1.0: + SELECT linpha_photos.prev_path AS prev_path, linpha_photos.filename AS filename + FROM linpha_photos, linpha_first_lev_album + WHERE linpha_photos.prev_path LIKE CONCAT(linpha_first_lev_album.path,'%') + AND (linpha_first_lev_album.groups LIKE '%;public;%') + AND (linpha_photos.id='612'); + \ No newline at end of file Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/index.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -11,6 +11,7 @@ $linpha->sql->startSession(); include_once(LINPHA_DIR.'/lib/include/integrity.php'); + include_once(LINPHA_DIR.'/lib/include/upgrade.php'); if(!isset($_GET['cat'])) { Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/install/sql/sql.data.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -25,7 +25,7 @@ * config table */ $options = array( - 'sys_db_version' => '1', + 'sys_db_version' => '2', 'sys_im_bracket_support' => $_SESSION['sys_im_bracket_support'], 'sys_im_convert_path' => $_SESSION['sys_im_convert_path'], 'sys_im_use_convert' => $_SESSION['sys_im_use_convert'], @@ -67,36 +67,54 @@ /** * metadata - */ -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(id, name, field_type, flags) VALUES (1, 'description', 1, 5)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(id, name, field_type, flags) VALUES (2, 'category', 2, 5)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(id, name, field_type, flags) VALUES (3, 'persons', 2, 5)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(id, name, field_type, flags) VALUES (4, 'date', 3, 5)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(id, name, field_type, flags) VALUES (6, 'filename', 0, 1)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(id, name, field_type, flags) VALUES (7, 'imagesize', 0, 1)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(id, name, field_type, flags) VALUES (8, 'dimension', 0, 1)"; + */ + /** + * special and builtin fields + */ + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('description', 1, 5)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('category', 2, 5)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('persons', 2, 5)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('date', 3, 5)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('filename', 0, 1)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('imagesize', 0, 1)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('dimension', 0, 1)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('thumbnail', 0, 1)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('id_6', 0, 10)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('id_7', 0, 10)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('id_8', 0, 10)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('id_1', 0, 10)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('id_2', 0, 10)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('id_3', 0, 10)"; -$sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('exif_datetimeoriginal', 0, 10)"; + /** + * preselected fields for image info + */ + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 10)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 10)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_dimension', 0, 10)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 10)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_category', 0, 10)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_persons', 0, 10)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('exif_datetimeoriginal', 0, 10)"; + /** + * preselected fields for thumbnails + */ + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 13)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 13)"; + $sql_queries[] = "INSERT INTO ".PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 13)"; + ?> Modified: trunk/linpha2/install/sql/sql.mysql.php =================================================================== --- trunk/linpha2/install/sql/sql.mysql.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/install/sql/sql.mysql.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -82,7 +82,8 @@ "isospeedratings varchar(255) default NULL, " . "flash varchar(255) default NULL, " . "focallength varchar(255) default NULL, " . - "fnumber varchar(255) default NULL, " . + "fnumber varchar(255) default NULL, " . + "jpegcomment VARCHAR(255) default NULL, " . "PRIMARY KEY (md5sum), " . "KEY md5sum (md5sum) " . ")", Modified: trunk/linpha2/install/sql/sql.postgres.php =================================================================== --- trunk/linpha2/install/sql/sql.postgres.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/install/sql/sql.postgres.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -75,7 +75,8 @@ "isospeedratings VARCHAR(255) default NULL, " . "flash VARCHAR(255) default NULL, " . "focallength VARCHAR(255) default NULL, " . - "fnumber VARCHAR(255) default NULL " . + "fnumber VARCHAR(255) default NULL, " . + "jpegcomment VARCHAR(255) default NULL " . ")", "CREATE TABLE ".$linpha_tables['meta_iptc']." ( ". "md5sum VARCHAR(32) NOT NULL default '' " . Modified: trunk/linpha2/install/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/install/sql/sql.sqlite.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/install/sql/sql.sqlite.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -76,7 +76,8 @@ "isospeedratings VARCHAR(255) default NULL, " . "flash VARCHAR(255) default NULL, " . "focallength VARCHAR(255) default NULL, " . - "fnumber VARCHAR(255) default NULL " . + "fnumber VARCHAR(255) default NULL, " . + "jpegcomment VARCHAR(255) default NULL " . ")", "CREATE TABLE ".$linpha_tables['meta_iptc']." ( ". "md5sum VARCHAR(32) NOT NULL default '' " . Modified: trunk/linpha2/lib/classes/linpha.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.class.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/lib/classes/linpha.class.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -49,6 +49,7 @@ include_once(LINPHA_DIR.'/lib/classes/linpha.filesys.class.php'); include_once(LINPHA_DIR.'/lib/classes/linpha.import.class.php'); include_once(LINPHA_DIR.'/lib/classes/linpha.identify.class.php'); +include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); include_once(LINPHA_DIR.'/lib/classes/linpha.functions.php'); /** Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -75,7 +75,7 @@ * check for valid id */ - if( isset($current_data) ) + if( isset($current_data['id']) ) { $this->img_type = $current_data['img_type']; $this->filename = $current_data['name']; @@ -397,7 +397,49 @@ $GLOBALS['linpha']->template->setModuleName('view_thumb'); $this->setSubFolders(); + + /** + * create thumbnail info text (filename, description, etc.) + */ + foreach($this->photos_filtered AS $key=>$photo_value) + { + $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']]['before'] = ''; + $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']]['after'] = ''; + + $filename = $photo_value['name']; + $md5sum = $photo_value['md5sum']; + $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $photo_value['id'] ); + $full_filename = LinSql::getPath('album').'/'.implode('/',$array_files); + $array_image_infos = MetaData::readInformations( $full_filename, $filename, $md5sum, $flag_nr=13 ); + + $index = 'before'; + foreach($array_image_infos AS $value) + { + /** + * got thumbnail, switch to index after + */ + if($value['value']=='thumbnail') + { + $index = 'after'; + } + else + { + if($index == 'before') + { + $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']][$index] .= $value['value'].'<br />'; + } + elseif($index == 'after') + { + $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']][$index] .= '<br />'.$value['value']; + } + } + } + + $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']]['title'] = $photo_value['name']; + } + + /** * switch between javascript */ @@ -423,13 +465,15 @@ { if( ( $GLOBALS['show_subfolders_separate'] && $value['img_type'] != 0 ) OR !$GLOBALS['show_subfolders_separate'] ) { - $GLOBALS['linpha']->template->output['files_db'] .= '{ id: "'.$value['id'].'", fn: "'.$value['name'].'" }, '; + $before = $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['before']; + $after = $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['after']; + $title = $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['title']; + + $array_files_db[] = '{ id: "'.$value['id'].'", before: "'.$before.'", after: "'.$after.'", title: "'.$title.'" }'; } } - /** - * remove last 2 signs (the comma and the space) - */ - $GLOBALS['linpha']->template->output['files_db'] = substr($GLOBALS['linpha']->template->output['files_db'],0,strlen($GLOBALS['linpha']->template->output['files_db'])-2); + + $GLOBALS['linpha']->template->output['files_db'] .= implode($array_files_db,", \n"); } $GLOBALS['linpha']->template->output['files_db'] .= "\n".'];'; @@ -445,6 +489,7 @@ /** * thumbnail view with javascript disabled + * @uses LinImgView::viewThumb_View() */ function viewThumb_View_nojs() { @@ -466,8 +511,10 @@ $this->writePageNumbers(); - - if($this->tot_photos > 0) // check if not all entries were folders + /** + * create array $this->photos_show which contains only the photos of the current page + */ + if($this->tot_photos > 0) // only if not all entries were folders { $img_nr = 1; $i = 0; @@ -745,55 +792,62 @@ $GLOBALS['linpha']->template->output['comment'] = $GLOBALS['linpha']->db->GetRow("SELECT id, time, author, comment FROM ".PREFIX."meta_comments"); } -/** - * setup image view - */ -function viewImg_view() +function viewImgCommon() { - $GLOBALS['linpha']->template->setModuleName('view_img'); - $this->viewImgSetPrevNextThumb(); - $this->viewImg_viewReadImageInformation(); + $this->viewImg_viewStoreImageInformation(); + include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); + $GLOBALS['linpha']->template->output['image_infos'] = MetaData::readInformations( $this->full_filename, $this->filename, $this->md5sum, $flag_nr=10 ); + if(isset($_GET['force_update'])) { LinImport::updateEntry( $this->id_current , dirname($this->full_filename) , $this->filename ); } +} +/** + * setup image view + */ +function viewImg_view() +{ + $GLOBALS['linpha']->template->setModuleName('view_img'); + + $this->viewImgCommon(); + /** * image comments */ - - /** - * save comment - */ - if( isset( $_POST['cmd'] ) && $_POST['cmd']=='add_comment') - { - if( !empty($_POST['comment_textarea'])) + /** + * save comment + */ + if( isset( $_POST['cmd'] ) && $_POST['cmd']=='add_comment') { - $comment = $_POST['comment_textarea']; + if( !empty($_POST['comment_textarea'])) + { + $comment = $_POST['comment_textarea']; + } + else + { + $comment = $_POST['comment_text']; + } + + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (time, md5sum, author, comment)" . + "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->md5sum."','".linSql::linAddslashes($_POST['author'])."'," . + "'".linSql::linAddslashes($comment)."')"); } - else - { - $comment = $_POST['comment_text']; - } - - $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (time, md5sum, author, comment)" . - "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->md5sum."','".linSql::linAddslashes($_POST['author'])."'," . - "'".linSql::linAddslashes($comment)."')"); - } - - /** - * get comments - */ - $GLOBALS['linpha']->template->output['image_comments'] = $GLOBALS['linpha']->db->Execute("SELECT id, time, author, comment FROM ".PREFIX."meta_comments " . - "WHERE md5sum = '".$GLOBALS['linpha']->imgview->md5sum."'"); + + /** + * get comments + */ + $GLOBALS['linpha']->template->output['image_comments'] = $GLOBALS['linpha']->db->Execute("SELECT id, time, author, comment FROM ".PREFIX."meta_comments " . + "WHERE md5sum = '".$GLOBALS['linpha']->imgview->md5sum."'"); } /** - * read image informations + * store image informations in database if not exists */ -function viewImg_viewReadImageInformation() +function viewImg_viewStoreImageInformation() { $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $this->id_current ); $this->full_filename = LinSql::getPath('album').'/'.implode('/',$array_files); @@ -842,78 +896,6 @@ $MetaData->saveIptcData( $this->full_filename,$this->md5sum); } } - - if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) { - $str_exif_fields = strtolower( implode(', ',$MetaData->defined_exif_fields) ); - $exif_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$str_exif_fields." FROM ".PREFIX."meta_exif WHERE md5sum = '".$this->md5sum."'"); - } - - if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { - $str_iptc_fields = strtolower( implode(', ',$MetaData->defined_iptc_fields) ); - $iptc_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$str_iptc_fields." FROM ".PREFIX."meta_iptc WHERE md5sum = '".$this->md5sum."'"); - } - - /** - * read image information from database - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."meta_fields WHERE flags = '10' ORDER by id"); - while($data = $query->FetchRow()) - { - $name = $MetaData->getNameOfField( $data['name'], false ); - $value = ''; - - $pos = strpos($data['name'],'_'); - $first_part = substr($data['name'],0,$pos); - $last_part = substr($data['name'],$pos+1); - switch($first_part) - { - case 'id': - $meta_data = $GLOBALS['linpha']->db->GetRow("SELECT name, field_type FROM ".PREFIX."meta_fields WHERE id = '".$last_part."'"); - if($meta_data['field_type']==0) // special fields like filename, dimension, imagesize - { - /** - * @todo maybe we could save this values in the db for speed improvements - */ - switch($meta_data['name']) - { - case 'filename': - $value = $this->filename; - break; - case 'imagesize': - $value = filesize( $this->full_filename ); - break; - case 'dimension': - $array = LinIdentify::linGetImageSize( $this->full_filename ); - $value = $array[0].'x'.$array[1]; - break; - } - } - else // builtin and own fields - { - $meta_data = $GLOBALS['linpha']->db->GetRow("SELECT meta_data FROM ".PREFIX."meta_data ". - "WHERE field_id = '".$last_part."' AND md5sum = '".$this->md5sum."'"); - if(isset($meta_data['meta_data'])) { - $value = $meta_data['meta_data']; - } - } - break; - case 'exif': - if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) { - $value = $exif_data[$last_part]; - } - break; - case 'iptc': - if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { - $value = $iptc_data[$last_part]; - } - break; - } - - if($value != '') - { - $GLOBALS['linpha']->template->output['image_infos'][$data['name']] = Array('name' => $name, 'value' => $value); - } - } } /** @@ -940,14 +922,8 @@ { $GLOBALS['linpha']->template->setModuleName('view_img'); - $this->viewImgSetPrevNextThumb(); - - $this->viewImg_viewReadImageInformation(); + $this->viewImgCommon(); - if(isset($_GET['force_update'])) { - LinImport::updateEntry( $this->id_current , dirname($this->full_filename) , $this->filename ); - } - /** * save metadata */ Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-04-02 13:50:15 UTC (rev 4475) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-04-02 21:02:17 UTC (rev 4476) @@ -21,35 +21,23 @@ /** * This class handles all the EXIF and IPTC stuff used in LinPHA * @package Metadata + * @author flo, bzrudi */ if(!defined('LINPHA_DIR')) { exit(1); } class MetaData { -public $all_exif_fields, $all_iptc_fields; -public $available_exif_fields, $available_iptc_fields; -public $defined_exif_fields, $defined_iptc_fields; +public $available_fields, $defined_fields; -private $current_all_fields, $current_available_fields, $current_defined_fields; function __construct() { - - /** - * should be replaced if language files are implemented... - */ - $this->array_special_fields = Array( - 'filename'=>'Filename', - 'imagesize'=>'Image Size', - 'dimension'=>'Dimension', - 'persons' => 'Persons', - 'description' => 'Description', - 'category' => 'Category', - 'date' => 'Date' - ); } +/** + * show nice name for exif, iptc, builtin and own fields, for example: convert "exif_datetimeoriginal" to "DateTime Original" + */ function getNameOfField( $key , $show_exifiptc_in_brackets) { $pos = strpos($key,'_'); @@ -57,22 +45,22 @@ $last_part = substr($key,$pos+1); switch($first_part) { - case 'id': // builtin and own fields and special fields like filename, imagesize and dimension + case 'builtin': // builtin and special fields like filename, imagesize and dimension + $value = i18n( ucfirst( $last_part ) ); + break; + + case 'id': // own fields $data2 = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."meta_fields WHERE id = '".$last_part."'"); - if(isset($this->array_special_fields[$data2['name']])) { - $value = $this->array_special_fields[$data2['name']]; - } else { - $value = $data2['name']; - } + $value = i18n( ucfirst( $data2['name'] ) ); break; case 'exif': - $value = $this->all_exif_fields[$last_part]; + $value = $GLOBALS['Tags_Exif'][$last_part]; if($show_exifiptc_in_brackets) { $value .= ' (exif)'; } break; case 'iptc': - $value = $this->all_iptc_fields[$last_part]; + $value = $GLOBALS['Tags_Iptc'][$last_part]; if($show_exifiptc_in_brackets) { $value .= ' (iptc)'; } @@ -82,189 +70,215 @@ return $value; } -function getDefaultExifFields() +/** + * read image information from database + */ +function readInformations($full_filename,$filename,$md5sum,$flag_nr) { - return Array - ( - 'datetimeoriginal', - 'make', - 'model', - 'artist', - 'copyright', - 'aperturevalue', - 'shutterspeedvalue', - 'exposuretime', - 'isospeedratings', - 'flash', - 'focallength', - 'fnumber' - ); + $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."meta_fields WHERE flags = '".$flag_nr."' ORDER by id"); + while($fields_data = $query->FetchRow()) + { + $name = MetaData::getNameOfField( $fields_data['name'], false ); + $value = ''; + + $pos = strpos($fields_data['name'],'_'); + $first_part = substr($fields_data['name'],0,$pos); + $last_part = substr($fields_data['name'],$pos+1); + switch($first_part) + { + case 'builtin': + /** + * @todo maybe we could save this values in the db for speed improvements + */ + switch($last_part) + { + case 'filename': + $value = $filename; + break; + case 'imagesize': + $value = filesize( $full_filename ); + break; + case 'dimension': + $array = LinIdentify::linGetImageSize( $full_filename ); + $value = $array[0].'x'.$array[1]; + break; + case 'thumbnail': + $value = 'thumbnail'; + break; + default: // field entries which are stored in linpha_meta_data + /** + * get field id + */ + $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."meta_fields WHERE name = '".$last_part."'"); + + $meta_data = $GLOBALS['linpha']->db->GetRow("SELECT meta_data FROM ".PREFIX."meta_data ". + "WHERE field_id = '".$data['id']."' AND md5sum = '".$md5sum."'"); + if(isset($meta_data['meta_data'])) { + $value = $meta_data['meta_data']; + } + } + case 'id': + $meta_data = $GLOBALS['linpha']->db->GetRow("SELECT meta_data FROM ".PREFIX."meta_data ". + "WHERE field_id = '".$last_part."' AND md5sum = '".$md5sum."'"); + if(isset($meta_data['meta_data'])) { + $value = $meta_data['meta_data']; + } + break; + case 'exif': + if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) { + $exif_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." FROM ".PREFIX."meta_exif WHERE md5sum = '".$md5sum."'"); + if(isset($exif_data[$last_part])) { + $value = $exif_data[$last_part]; + } + } + break; + case 'iptc': + if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { + $iptc_data = $GLOBALS['linpha']->db->GetRow("SELECT ".$last_part." FROM ".PREFIX."meta_iptc WHERE md5sum = '".$md5sum."'"); + if(isset($iptc_data[$last_part])) { + $value = $iptc_data[$last_part]; + } + } + break; + } + + if($value != '') + { + $output_array[$fields_data['name']] = Array('name' => $name, 'value' => $value); + } + } + + return $output_array; } +/** + * set available and defined fields + * @param string $what [exif,iptc] + */ function setFields($what) { - switch($what) - { - case 'exif': + /** + * create definedfields[] + */ + $this->defined_fields[$what] = $GLOBALS['linpha']->db->MetaColumns(PREFIX."meta_".$what); - $this->all_exif_fields = $this->getExifTranslationArray(); - /** - * modify array as needed - * change key to lowercase + * remove md5sum entry */ - foreach($this->all_exif_fields AS $key=>$value) + unset($this->defined_fields[$what]['MD5SUM']); + + /** + * change keys to lowercase + */ + foreach($this->defined_fields[$what] AS $key=>$value) { $new_key = strtolower($key); - unset($this->all_exif_fields[$key]); - $this->all_exif_fields[$new_key] = $key; + unset($this->defined_fields[$what][$key]); + $this->defined_fields[$what][$new_key] = $GLOBALS['Tags_'.ucfirst($what)][$new_key]; } - - $this->defined_exif_fields = $GLOBALS['linpha']->db->MetaColumns(PREFIX."meta_exif"); - - $this->current_defined_fields = $this->defined_exif_fields; - $this->current_available_fields = $this->available_exif_fields; - $this->current_all_fields = $this->all_exif_fields; - - break; - case 'iptc': - $this->all_iptc_fields = MetaData::getIptcTranslationArray(); - - $this->defined_iptc_fields = $GLOBALS['linpha']->db->MetaColumns(PREFIX."meta_iptc"); - $this->current_defined_fields = $this->defined_iptc_fields; - $this->current_available_fields = $this->available_iptc_fields; - $this->current_all_fields = $this->all_iptc_fields; - - break; - } - /** - * remove md5sum entry - */ - unset($this->current_defined_fields['MD5SUM']); - - - /** - * change keys to lowercase - */ - foreach($this->current_defined_fields AS $key=>$value) - { - $new_key = strtolower($key); - unset($this->current_defined_fields[$key]); - $this->current_defined_fields[$new_key] = $this->current_all_fields[$new_key]; - } - - /** * create available_fields */ - foreach($this->current_all_fields AS $key=>$value) - { - if( ! isset( $this->current_defined_fields[$key] )) + foreach($GLOBALS['Tags_'.ucfirst($what)] AS $key=>$value) { - $this->current_available_fields[$key] = $value; + if( ! isset( $this->defined_fields[$what][$key] )) + { + $this->available_fields[$what][$key] = $value; + } } - } - - switch($what) - { - case 'exif': - $this->defined_exif_fields = $this->current_defined_fields; - $this->available_exif_fields = $this->current_available_fields; - $this->all_exif_fields = $this->current_all_fields; - break; - case 'iptc': - $this->defined_iptc_fields = $this->current_defined_fields; - $this->available_iptc_fields = $this->current_available_fields; - $this->all_iptc_fields = $this->current_all_fields; - 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) - { - /** - * get exif info from file - */ - $exif_data = get_EXIF_JPEG( $filename ); - - /** - * get exif tags - */ - $exif_tags = $this->getExifTranslationArray(); - /** - * 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 - */ - $str_columns = "md5sum, "; - $str_values = "'".$md5sum."', "; - foreach($exif_tags AS $key=>$value) - { - if($value != "" && in_array($key,$this->defined_exif_fields)) - { - /** - * there are currently only entries at level deep 2 and 5 in the - * array - */ - $array_pieces = explode('/',$value); - switch(count($array_pieces)) - { - case 2: - if(isset($exif_data[ $array_pieces[0] ][ $array_pieces[1] ]['Text Value'])) - { - $str_columns .= strtolower($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 .= strtolower($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: ".$value; - break; - } - } - } - +/** + * save data in DB functions + */ + /** + * 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) + { + /** + * get exif info from file + */ + $exif_data = get_EXIF_JPEG( $filename ); + + /** + * get exif tags + */ + $exif_tags = $this->getExifTranslationArray(); + + /** + * 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 + */ + $str_columns = "md5sum, "; + $str_values = "'".$md5sum."', "; + foreach($exif_tags AS $key=>$value) + { + $key = strtolower($key); + + if($value != "" && isset($this->defined_fields['exif'][$key])) + { + /** + * there are currently only entries at level deep 2 and 5 in the + * array + */ + $array_pieces = explode('/',$value); + 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: ".$value; + break; + } + } + } + /** * add jpegcomment */ - if(in_array('jpegcomment',$this->defined_exif_fields)) + if(in_array('jpegcomment',$this->defined_fields['exif'])) { $jpeg_header_data = get_jpeg_header_data( $filename ); $comment = get_jpeg_Comment( $jpeg_header_data ); @@ -274,100 +288,100 @@ $str_values .= "'".linSql::linAddslashes(trim( $comment ))."', "; } } - - /** - * remove last two signs - */ - $str_columns = substr($str_columns,0,strlen($str_columns)-2); - $str_values = substr($str_values,0,strlen($str_values)-2); - - + + /** + * remove last two signs + */ + $str_columns = substr($str_columns,0,strlen($str_columns)-2); + $str_values = substr($str_values,0,strlen($str_values)-2); + + /** * no double entries */ - $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum FROM ".PREFIX."meta_exif ". - "WHERE md5sum = '".$md5sum."'"); - $num = $query->RecordCount(); - if($num == 0) - { + $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum FROM ".PREFIX."meta_exif ". + "WHERE md5sum = '".$md5sum."'"); + $num = $query->RecordCount(); + if($num == 0) + { $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_exif (".$str_columns.") ". "VALUES (".$str_values.")"); - } - } + } + } /** * esacape sql strings a clean way - + function cleansql($text) - { - $return=""; - $chars = preg_split('//', $text, -1, PREG_SPLIT_NO_EMPTY); + { + $return=""; + $chars = preg_split('//', $text, -1, PREG_SPLIT_NO_EMPTY); $count = count($chars); - for ($c=0; $c<$count; $c++) - { - $letter=$chars[$c]; - if (!preg_match("/[a-zA-Z0-9]/", $letter)) - { - $return .= "\\$letter"; - } - else - { - $return .= "$letter"; - } - } - return $return; + for ($c=0; $c<$count; $c++) + { + $letter=$chars[$c]; + if (!preg_match("/[a-zA-Z0-9]/", $letter)) + { + $return .= "\\$letter"; + } + else + { + $return .= "$letter"; + } + } + return $return; } - */ - /** - * store IPTC data in DB - */ - function saveIptcData($filename, $md5sum) - { - // 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)); - - // init values (prevent php notice msg if not set) - $caption = ""; - $object_name = ""; - $edit_status = ""; - $priority = ""; - $category = ""; - $supplemental_categorie = ""; - $job_id = ""; - $keywords = ""; - $date_released = ""; - $time_released = ""; - $instructions = ""; - $date_created = ""; - $time_created = ""; - $program = ""; - $object_cycle = ""; - $byline = ""; - $byline_title = ""; - $city = ""; - $sublocation = ""; - $state = ""; - $country_code = ""; - $country = ""; - $trans_reference = ""; - $headline = ""; - $credit = ""; - $source = ""; - $copyright = ""; - $caption_writer = ""; - - $IPTC_Meta = array(); - $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum FROM ".PREFIX."meta_iptc " . - "WHERE md5sum = '".$md5sum."' "); - $num = $query->RecordCount(); - - if($num == 0) - { + */ + /** + * store IPTC data in DB + */ + function saveIptcData($filename, $md5sum) + { + // 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)); + + // init values (prevent php notice msg if not set) + $caption = ""; + $object_name = ""; + $edit_status = ""; + $priority = ""; + $category = ""; + $supplemental_categorie = ""; + $job_id = ""; + $keywords = ""; + $date_released = ""; + $time_released = ""; + $instructions = ""; + $date_created = ""; + $time_created = ""; + $program = ""; + $object_cycle = ""; + $byline = ""; + $byline_title = ""; + $city = ""; + $sublocation = ""; + $state = ""; + $country_code = ""; + $country = ""; + $trans_reference = ""; + $headline = ""; + $credit = ""; + $source = ""; + $copyright = ""; + $caption_writer = ""; + + $IPTC_Meta = array(); + $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum FROM ".PREFIX."meta_iptc " . + "WHERE md5sum = '".$md5sum."' "); + $num = $query->RecordCount(); + + if($num == 0) + { if(is_array($IPTC_Info)) { // Cycle through each of the IPTC-NAA IIM records @@ -496,14 +510,14 @@ "edit_status, priority, object_cycle, job_id, program, " . "object_name, date_created, date_released, time_created, " . "time_released, city, sublocation, state, country, " . - "country_code, trans_reference, marked_ignored) " . + "country_code, trans_reference) " . "VALUES('".$md5sum."', '".$caption."', '".$caption_writer."', '".$headline."', " . "'".$instructions."', '".$keywords."', '".$category."', '".$supplemental_categorie."', " . "'".$copyright."', '".$byline."', '".$byline_title."', '".$credit."', '".$source."', " . "'".$edit_status."', '".$priority."', '".$object_cycle."', '".$job_id."', '".$program."', " . "'".$object_name."', '".$date_created."', '".$date_released."', '".$time_created."', " . "'".$time_released."', '".$city."', '".$sublocation."', '".$state."', '".$country."', " . - "'".$country_code."', '".$trans_reference."', '0')"); + "'".$country_code."', '".$trans_reference."')"); return true; } @@ -512,544 +526,500 @@ /** * save empty entry to prevent re-read on every page visit */ - $GLOBALS['linpha']->db->Execute("INSERT INTO ".PREFIX."meta_iptc ( " . - "md5sum, caption, caption_writer, headline, " . - "instructions, keywords, category, supplemental_categorie, " . - "copyright, byline, byline_title, credit, source, " . - "edit_status, priority, object_cycle, job_id, program, " . - "object_name, date_created, date_released, time_created, " . - "time_released, city, sublocation, state, country, " . - "country_code, trans_reference, marked_ignored) " . - "VALUES('".$md5sum."', '', '', '', '', '', '', '', '', '', '', '', '', " . - "'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '1')"); + $GLOBALS['linpha']->db->Execute("INSERT INTO ".PREFIX."meta_iptc " . + "(md5sum) VALUES('".$md5sum."')"); return false; } - } - } - else - { - return false; - } - } + } + } + else + { + return false; + } + } + + +/** + * edit iptc functions + */ /** - * generate "more EXIF details" link. Used if we have only IPTC data but - * also wonna have an option to display EXIF + * edit IPTC Data in HTML popup + */ + function editIptcData() + { + + } + + /** + * save modified IPTC data to DB */ - /*function showMoreDetailLink($meta) + function saveModIptcData() { - global $exif_less, $exif_more; - if($meta == "exif") - { - $link = "<a class='leftmenu' href='".$GLOBALS['img_view']->link_address."&imgid=".$_GET['imgid']."&exif="; - echo "<tr><td colspan='2' align='center'>".$link."2'>". - "<u><b>".$exif_more." (EXIF)</b></u></a></td></tr>"; + } - } - else - { - $link = "<a class='leftmenu' href='".$GLOBALS['img_view']->link_address."&imgid=".$_GET['imgid']."&iptc="; - echo "<tr><td colspan='2' align='center'>".$link."2'>". - "<u><b>".$exif_more." (IPTC)</b></u></a></td></tr>"; - } - }*/ - - /** - * prepare EXIF HTML output left menu (get from DB) - */ - /*function showExifData($md5sum) - { - global $exif_less, $exif_more, $str_search_all_images_taken; - $link = "<a class='leftmenu' href='".$GLOBALS['img_view']->link_address."&imgid=".$_GET['imgid']."&exif="; - switch(read_config("exif_level")) - { - case 'low': $exif_level = 1; break; - case 'medium': $exif_level = 2; break; - case 'high': $exif_level = 3; break; - } - - /** - * set exif setting in $_SESSION - - $show_exif = true; - - if(isset($_GET['exif']) && !isset($_GET['iptc'])) - { - $_SESSION['exif'] = $_GET['exif']; - - if($_GET['exif'] == 0) - { - $show_exif = false; - unset($_SESSION['exif']); - - } else { - $exif_level = $_GET['exif']; - } - } - elseif( isset($_SESSION['exif']) ) - { - ... [truncated message content] |