[Linpha-cvs] SF.net SVN: linpha: [4402] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-03-07 17:38:45
|
Revision: 4402 Author: fangehrn Date: 2006-03-07 09:38:22 -0800 (Tue, 07 Mar 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4402&view=rev Log Message: ----------- * working on image fields Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/image_fields.php trunk/linpha2/admin/image_fields_define.php trunk/linpha2/admin/image_fields_select.php trunk/linpha2/db_data.sql trunk/linpha2/get_thumb.php trunk/linpha2/install/sql/sql.mysql.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/metadata.class.php Added Paths: ----------- trunk/linpha2/admin/image_fields_define_post.php Removed Paths: ------------- trunk/linpha2/lib/classes/metadata.config.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/ChangeLog 2006-03-07 17:38:22 UTC (rev 4402) @@ -1,3 +1,6 @@ +2006-03-07 flo + * adding forced thumbnail recreation + * working on image fields 2006-03-04 flo * adding an admin menu Modified: trunk/linpha2/admin/image_fields.php =================================================================== --- trunk/linpha2/admin/image_fields.php 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/admin/image_fields.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -22,5 +22,66 @@ include_once('./image_fields_define.php'); break; } + +/** + * workaround.. + */ +$array_available_fields = Array(); +function get_selected_fields($what) +{ + include_once(LINPHA_DIR.'/lib/classes/metadata.class.php'); + + switch($what) + { + case 'exif': + + $GLOBALS['array_available_fields'] = MetaData::getExifTranslationArray(); + + /** + * modify array as needed + * change key to lowercase + */ + foreach($GLOBALS['array_available_fields'] AS $key=>$value) + { + $new_key = strtolower($key); + unset($GLOBALS['array_available_fields'][$key]); + $GLOBALS['array_available_fields'][$new_key] = $key; + } + + $array_selected_fields = $GLOBALS['linpha']->db->MetaColumns(PREFIX."meta_exif"); + + break; + case 'iptc': + $GLOBALS['array_available_fields'] = MetaData::getIptcTranslationArray(); + + $array_selected_fields = $GLOBALS['linpha']->db->MetaColumns(PREFIX."meta_iptc"); + break; + } + + /** + * change keys to lowercase + */ + foreach($array_selected_fields AS $key=>$value) + { + $new_key = strtolower($key); + unset($array_selected_fields[$key]); + $array_selected_fields[$new_key] = $GLOBALS['array_available_fields'][$new_key]; + } + + /** + * remove md5sum entry + */ + unset($array_selected_fields['md5sum']); + + /** + * remove selected_fields from available_fields + */ + foreach($array_selected_fields AS $key=>$value) + { + unset($GLOBALS['array_available_fields'][$key]); + } + + return $array_selected_fields; +} ?> Modified: trunk/linpha2/admin/image_fields_define.php =================================================================== --- trunk/linpha2/admin/image_fields_define.php 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/admin/image_fields_define.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -29,84 +29,26 @@ /** * parse POST data */ -if(isset($_POST['cmd'])) -{ - switch($_POST['cmd']) - { - case 'update_builtin': - - foreach($_POST['builtin'] AS $key=>$value) - { - $linpha->db->Execute("UPDATE ".PREFIX."meta_fields SET enabled = '".linSql::linAddslashes($value)."' ". - "WHERE id = '".linSql::linAddslashes($key)."'"); - } - - break; - case 'add_new': - $linpha->db->Execute("INSERT into ".PREFIX."meta_fields (name, field_type, builtin, enabled) " . - "VALUES ('".linSql::linAddslashes($_POST['new_name'])."', '".linSql::linAddslashes($_POST['new_type'])."', '0', '1') "); - break; - case 'change_field': - - $linpha->db->Execute("UPDATE ".PREFIX."meta_fields SET " . - "name = '".linSql::linAddslashes($_POST['new_name'])."', ". - "enabled = '".linSql::linAddslashes($_POST['builtin'][$_POST['id']])."' ". - "WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); - break; - case 'delete': - ?> - <h3>Delete selected field</h3> - Really sure? all will be lost... - <form action="./?cat=imagefields_define_own" method="POST"> - <input type="hidden" name="cmd" value="do_delete" /> - <input type="hidden" name="id" value="<?php echo $_POST['id']; ?>" /> - <input type="submit" name="delete" value="delete" /> - <a href="./?cat=imagefields_define_own">Cancel</a> - </form> - <br /><br /> - <?php - break; - case 'do_delete': - $linpha->db->Execute("DELETE FROM ".PREFIX."meta_fields WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); - break; - case 'add_new_category': - if(isset($_POST['isprivate'])) { - $isprivate = 1; - } else { - $isprivate = 0; - } - $linpha->db->Execute("INSERT into ".PREFIX."meta_category (field_id, name, isprivate) VALUES (" . - "'".linSql::linAddslashes($_POST['field_id'])."'," . - "'".linSql::linAddslashes($_POST['new_name'])."'," . - "'".$isprivate."')"); - - break; - case 'mod_category': - if(isset($_POST['isprivate'])) { - $isprivate = 1; - } else { - $isprivate = 0; - } - - $linpha->db->Execute("UPDATE ".PREFIX."meta_category SET " . - "name = '".linSql::linAddslashes($_POST['new_name'])."', ". - "isprivate = '".$isprivate."' ". - "WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); - - break; - case 'delete_category': - $linpha->db->Execute("DELETE FROM ".PREFIX."meta_category WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); - break; - case 'update_exifiptc': - $linpha->sql->config->updateConfig('sys_image_'.$cat3,$_POST['exifiptc_enable']); - $linpha->sql->config->reloadConfig(); - break; - } +if(isset($_POST['cmd'])) { + include_once(LINPHA_DIR.'/admin/image_fields_define_post.php'); } switch($cat3) { case 'own': + show_own_fields(); + break; +case 'adddata': + show_add_data(); + break; +case 'exif': +case 'iptc': + show_exif_iptc(); + break; +} + +function show_own_fields() +{ ?> <h3>Built-in fields</h3> <form name="builtin" action="./?cat=imagefields_define_own" method="POST"> @@ -119,13 +61,13 @@ </tr> <?php - $query = $linpha->db->Execute("SELECT id, name, field_type, enabled FROM ".PREFIX."meta_fields WHERE builtin = '1'"); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, enabled FROM ".PREFIX."meta_fields WHERE builtin = '1'"); while($data = $query->FetchRow()) { echo '<tr><td>'; echo $data['name']; echo '</td><td>'; - echo $array_field_types[$data['field_type']]; + echo $GLOBALS['array_field_types'][$data['field_type']]; echo '</td><td>'; echo '<input type="radio" name="builtin['.$data['id'].']" value="1"'. ( $data['enabled'] ? ' checked="checked"' : '') .' />'; @@ -155,7 +97,7 @@ <td> <select name="new_type" style="width: 200px;" > <?php - foreach($array_field_types AS $key=>$value) + foreach($GLOBALS['array_field_types'] AS $key=>$value) { echo '<option value="'.$key.'">'.$value.'</option>'; } @@ -170,7 +112,7 @@ <br /> <?php - $query = $linpha->db->Execute("SELECT id, name, field_type, enabled FROM ".PREFIX."meta_fields WHERE builtin = '0'"); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, enabled FROM ".PREFIX."meta_fields WHERE builtin = '0'"); if($query->RecordCount()>0) { ?> @@ -195,7 +137,7 @@ <td> <input type="text" name="new_name" value="<?php echo $data['name']; ?>" style="width: 150px;" maxlength="255" /> </td> - <td><?php echo $array_field_types[$data['field_type']]; ?></td> + <td><?php echo $GLOBALS['array_field_types'][$data['field_type']]; ?></td> <td> <?php echo '<input type="radio" name="builtin['.$data['id'].']" value="1"'. ( $data['enabled'] ? ' checked="checked"' : '') .' />'; @@ -228,10 +170,11 @@ </form> <?php } +} - break; -case 'adddata': - $query = $linpha->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '2'"); +function show_add_data() +{ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '2'"); while($data = $query->FetchRow()) { ?> @@ -244,7 +187,7 @@ <td> </td> </tr> <?php - $query2 = $linpha->db->Execute("SELECT id, name, isprivate FROM ".PREFIX."meta_category WHERE field_id = '".$data['id']."'"); + $query2 = $GLOBALS['linpha']->db->Execute("SELECT id, name, isprivate FROM ".PREFIX."meta_category WHERE field_id = '".$data['id']."'"); while($data2 = $query2->FetchRow()) { ?> @@ -292,34 +235,20 @@ </table> <?php } - break; -case 'exif': -case 'iptc': - switch($cat3) - { - case 'exif': - include_once(LINPHA_DIR.'/lib/classes/metadata.class.php'); - $array_available_fields = MetaData::getExifTranslationArray(); - - /** - * modify array as needed - */ - foreach($array_available_fields AS $key=>$value) - { - $array_available_fields[$key] = $key; - } - break; - case 'iptc': - include_once(LINPHA_DIR.'/lib/classes/metadata.config.php'); - $array_available_fields = getIptcTranslationArray(); - break; - } +} + +function show_exif_iptc() +{ + $array_selected_fields = get_selected_fields($GLOBALS['cat3']); - $enabled = $linpha->sql->config->value['sys_image_'.$cat3]; + /** + * get enabled/disabled setting + */ + $enabled = $GLOBALS['linpha']->sql->config->value['sys_image_'.$GLOBALS['cat3']]; ?> <div align="center"> - <form action="./?cat=imagefields_define_<?php echo $cat3; ?>" method="POST"> + <form action="./?cat=imagefields_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" /> @@ -327,15 +256,18 @@ </form> <br /><br /> + <form action="./?cat=imagefields_define_<?php echo $GLOBALS['cat3']; ?>" method="POST" onsubmit="selectAll()"> <table border="0"> <tr> <td valign="top" rowspan="3" align="center"> Selected fields<br /> - <select id="selected_fields" name="selected_fields" size="25" style="width: 200px;"> - <option value="element1">element1</option> - <option value="element2">element2</option> - <option value="element3">element3</option> - <option value="element4">element4</option> + <select id="selected_fields" name="selected_fields[]" size="25" style="width: 200px;" multiple="multiple"> + <?php + foreach($array_selected_fields AS $key=>$value) + { + echo '<option value="'.$key.'">'.$value.'</option>'."\n"; + } + ?> </select> <br /> </td> @@ -348,7 +280,7 @@ Available fields<br /> <select id="all_fields" name="builtin_fields" size="25" style="width: 200px;"> <?php - foreach($array_available_fields AS $key=>$value) + foreach($GLOBALS['array_available_fields'] AS $key=>$value) { echo '<option value="'.$key.'">'.$value.'</option>'; } @@ -357,15 +289,25 @@ </td> </tr> </table> - - </div> + <input type="hidden" name="cmd" value="create_exifiptc" /> + <input type="submit" name="name" value="Submit" /> </form> + </div> + <script type="text/javascript"> /** * http://www.babailiica.com/js/sorter/ */ + function selectAll() + { + obj = document.getElementById('selected_fields'); + for (var i=0; i<obj.length; i++) { + obj[i].selected = true; + } + } + function addElement () { obj_from = document.getElementById('all_fields'); @@ -384,27 +326,37 @@ function moveElement(obj_from, obj_to) { - NewEntry = new Option( obj_from.options[ obj_from.selectedIndex ].text, obj_from.options[ obj_from.selectedIndex ].value, false, true ); - obj_to.options[ obj_to.options.length] = NewEntry; + if(obj_from.selectedIndex != -1) + { + old_index = obj_from.selectedIndex; + + NewEntry = new Option( obj_from.options[ obj_from.selectedIndex ].text, obj_from.options[ obj_from.selectedIndex ].value, false, true ); + obj_to.options[ obj_to.options.length] = NewEntry; - current_index = obj_from.selectedIndex; - obj_from.options[ current_index ] = null; + obj_from.options[ obj_from.selectedIndex ] = null; - /** - * set selectedIndex back to field above - */ - /*if( current_index == document.form_image_fields.select_image_fields.length ) - { - document.form_image_fields.select_image_fields.selectedIndex = current_index - 1; + /** + * set selectedIndex back to field above + */ + obj_to.selectedIndex = obj_to.length - 1; + + if( obj_from.selectedIndex == obj_from.length ) + { + obj_from.selectedIndex = obj_from.selectedIndex - 1; + } + else + { + obj_from.selectedIndex = old_index; + } } else { - document.form_image_fields.select_image_fields.selectedIndex = current_index; - }*/ + alert('nothing selected'); + } } </script> -<?php - break; + <?php } + ?> \ No newline at end of file Added: trunk/linpha2/admin/image_fields_define_post.php =================================================================== --- trunk/linpha2/admin/image_fields_define_post.php (rev 0) +++ trunk/linpha2/admin/image_fields_define_post.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -0,0 +1,91 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +switch($_POST['cmd']) +{ +case 'update_builtin': + + foreach($_POST['builtin'] AS $key=>$value) + { + $linpha->db->Execute("UPDATE ".PREFIX."meta_fields SET enabled = '".linSql::linAddslashes($value)."' ". + "WHERE id = '".linSql::linAddslashes($key)."'"); + } + + break; +case 'add_new': + $linpha->db->Execute("INSERT into ".PREFIX."meta_fields (name, field_type, builtin, enabled) " . + "VALUES ('".linSql::linAddslashes($_POST['new_name'])."', '".linSql::linAddslashes($_POST['new_type'])."', '0', '1') "); + break; +case 'change_field': + + $linpha->db->Execute("UPDATE ".PREFIX."meta_fields SET " . + "name = '".linSql::linAddslashes($_POST['new_name'])."', ". + "enabled = '".linSql::linAddslashes($_POST['builtin'][$_POST['id']])."' ". + "WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); + break; +case 'delete': + ?> + <h3>Delete selected field</h3> + Really sure? all will be lost... + <form action="./?cat=imagefields_define_own" method="POST"> + <input type="hidden" name="cmd" value="do_delete" /> + <input type="hidden" name="id" value="<?php echo $_POST['id']; ?>" /> + <input type="submit" name="delete" value="delete" /> + <a href="./?cat=imagefields_define_own">Cancel</a> + </form> + <br /><br /> + <?php + break; +case 'do_delete': + $linpha->db->Execute("DELETE FROM ".PREFIX."meta_fields WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); + break; +case 'add_new_category': + if(isset($_POST['isprivate'])) { + $isprivate = 1; + } else { + $isprivate = 0; + } + $linpha->db->Execute("INSERT into ".PREFIX."meta_category (field_id, name, isprivate) VALUES (" . + "'".linSql::linAddslashes($_POST['field_id'])."'," . + "'".linSql::linAddslashes($_POST['new_name'])."'," . + "'".$isprivate."')"); + + break; +case 'mod_category': + if(isset($_POST['isprivate'])) { + $isprivate = 1; + } else { + $isprivate = 0; + } + + $linpha->db->Execute("UPDATE ".PREFIX."meta_category SET " . + "name = '".linSql::linAddslashes($_POST['new_name'])."', ". + "isprivate = '".$isprivate."' ". + "WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); + + break; +case 'delete_category': + $linpha->db->Execute("DELETE FROM ".PREFIX."meta_category WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); + break; +case 'update_exifiptc': + $linpha->sql->config->updateConfig('sys_image_'.$cat3,$_POST['exifiptc_enable']); + $linpha->sql->config->reloadConfig(); + break; +case 'create_exifiptc': + include_once(LINPHA_DIR.'/lib/classes/metadata.class.php'); + if( ! isset($_POST['selected_fields'])) + { + $_POST['selected_fields'] = Array(); + } + if($cat3 == 'exif') { + $linpha->db->Execute("DROP TABLE IF EXISTS ".PREFIX."meta_exif"); + $linpha->db->Execute( Metadata::createExifTable( $_POST['selected_fields'] ) ); + } elseif($cat3 == 'iptc') { + $linpha->db->Execute("DROP TABLE IF EXISTS ".PREFIX."meta_iptc"); + $linpha->db->Execute( Metadata::createIptcTable( $_POST['selected_fields'] ) ); + } + break; +} + + +?> \ No newline at end of file Modified: trunk/linpha2/admin/image_fields_select.php =================================================================== --- trunk/linpha2/admin/image_fields_select.php 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/admin/image_fields_select.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -11,19 +11,24 @@ 'video' => Array('name' => 'Video', 'link' => 'imagefields_select_video') ); +if(isset($_POST['cmd'])) +{ + print_r($_POST['select_image_fields']); +} + print_admin_menu($array_menu,$cat3); switch($cat3) { case 'image': ?> - <form name="form_image_fields"> + <form name="form_image_fields" method="POST" onsubmit="selectAll()"> <div align="center"> <table border="0"> <tr> - <td valign="top" rowspan="3" align="center"> + <td valign="top" rowspan="4" align="center"> Current image fields shown<br /> - <select name="select_image_fields" size="25" style="width: 200px;"> + <select id="select_image_fields" name="select_image_fields[]" size="25" style="width: 200px;" multiple="multiple"> <option value="element1">element1</option> <option value="element2">element2</option> <option value="element3">element3</option> @@ -32,20 +37,27 @@ <br /> <input type="button" name="shift_up" value="^" onclick="moveupElement()" /> <input type="button" name="shift_down" value="v" onclick="movedownElement()" /> + <br /><br /> + <input type="button" name="remove" value="delete selected" onclick="deleteElement()" /> + <br /><br /> + <input type="text" name="title_name" value="" /><br /> + <input type="button" name="add_title" value="add title" onclick="addElement()" /> </td> <td> <input type="button" name="builtin_shiftleft" value="<" onclick="copyElement('builtin_fields')" /> </td> <td> - Builtin fields<br /> + Builtin fields (<a href="./?cat=imagefields_define_own">define</a>)<br /> <select id="builtin_fields" name="builtin_fields" size="7" style="width: 200px;"> - <option value="builtin1">builtin1</option> - <option value="builtin2">builtin2</option> - <option value="builtin3">builtin3</option> - <option value="builtin4">builtin4</option> + <?php + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields " . + "WHERE builtin = '1' AND enabled = '1'"); + while($data = $query->FetchRow()) + { + echo '<option value="'.$data['id'].'">'.$data['name'].'</option>'; + } + ?> </select> - <br /> - <a href="./?cat=imagefields_define_own">define fields</a> </td> </tr> <tr> @@ -53,15 +65,17 @@ <input type="button" name="own_shiftleft" value="<" onclick="copyElement('own_fields')" /> </td> <td> - Own fields<br /> + Own fields (<a href="./?cat=imagefields_define_own">define</a>)<br /> <select id="own_fields" name="own_fields" size="7" style="width: 200px;"> - <option value="own1">own1</option> - <option value="own2">own2</option> - <option value="own3">own3</option> - <option value="own4">own4</option> + <?php + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields " . + "WHERE builtin = '0' AND enabled = '1'"); + while($data = $query->FetchRow()) + { + echo '<option value="'.$data['id'].'">'.$data['name'].'</option>'; + } + ?> </select> - <br /> - <a href="./?cat=imagefields_define_own">define fields</a> </td> </tr> <tr> @@ -69,41 +83,54 @@ <input type="button" name="exif_shiftleft" value="<" onclick="copyElement('exif_fields')" /> </td> <td> - Exif fields<br /> - <select id="exif_fields" name="exif_fields" size="7" style="width: 200px;"> - <option value="exif1">exif1</option> - <option value="exif2">exif2</option> - <option value="exif3">exif3</option> - <option value="exif4">exif4</option> + Exif fields (<a href="./?cat=imagefields_define_exif">define</a>)<br /> + <?php + if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) { + $str_disabled = ''; + } else { + $str_disabled = ' disabled="disabled"'; + } + ?> + <select id="exif_fields" name="exif_fields" size="7" style="width: 200px;"<?php echo $str_disabled; ?>> + <?php + $array_selected_fields = get_selected_fields('exif'); + foreach($array_selected_fields AS $key=>$value) + { + echo '<option value="'.$key.'">'.$value.'</option>'; + } + ?> </select> - <br /> - <a href="./?cat=imagefields_define_exif">define fields</a> </td> </tr> <tr> <td> - <input type="button" name="remove" value="delete selected" onclick="deleteElement()" /> - <br /><br /> - <input type="text" name="title_name" value="" /><br /> - <input type="button" name="add_title" value="add title" onclick="addElement()" /> - </td> - <td> <input type="button" name="iptc_shiftleft" value="<" onclick="copyElement('iptc_fields')" /> </td> <td> - IPTC fields<br /> - <select id="iptc_fields" name="iptc_fields" size="7" style="width: 200px;"> - <option value="iptc1">iptc1</option> - <option value="iptc2">iptc2</option> - <option value="iptc3">iptc3</option> - <option value="iptc4">iptc4</option> + IPTC fields (<a href="./?cat=imagefields_define_iptc">define</a>)<br /> + <?php + if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) { + $str_disabled = ''; + } else { + $str_disabled = ' disabled="disabled"'; + } + ?> + <select id="iptc_fields" name="iptc_fields" size="7" style="width: 200px;"<?php echo $str_disabled; ?>> + <?php + $array_selected_fields = get_selected_fields('iptc'); + foreach($array_selected_fields AS $key=>$value) + { + echo '<option value="'.$key.'">'.$value.'</option>'; + } + ?> </select> - <br /> - <a href="./?cat=imagefields_define_iptc">define fields</a> </td> </tr> </table> - + <br /> + <input type="hidden" name="cmd" value="select_image_fields" /> + <input type="submit" name="submit" value="submit" /> + </div> </form> <?php @@ -123,96 +150,115 @@ * 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 = document.getElementById(coming_from); + obj_from = document.getElementById(coming_from); + obj = document.getElementById('select_image_fields'); - NewEntry = new Option( obj.options[ obj.selectedIndex ].text, obj.options[ obj.selectedIndex ].value, false, true ); - document.form_image_fields.select_image_fields.options[document.form_image_fields.select_image_fields.options.length] = NewEntry; + 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; + + /** + * 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"; - document.form_image_fields.select_image_fields.options[document.form_image_fields.select_image_fields.options.length] = NewEntry; + obj.options[obj.options.length] = NewEntry; document.form_image_fields.title_name.value = ""; } function deleteElement () { - current_index = document.form_image_fields.select_image_fields.selectedIndex; - document.form_image_fields.select_image_fields.options[ current_index ] = null; + obj = document.getElementById('select_image_fields'); + + current_index = obj.selectedIndex; + obj.options[ current_index ] = null; /** * set selectedIndex back to field above */ - if( current_index == document.form_image_fields.select_image_fields.length ) + if( current_index == obj.length ) { - document.form_image_fields.select_image_fields.selectedIndex = current_index - 1; + obj.selectedIndex = current_index - 1; } else { - document.form_image_fields.select_image_fields.selectedIndex = current_index; + obj.selectedIndex = current_index; } } function moveupElement () { - current_index = document.form_image_fields.select_image_fields.selectedIndex; + obj = document.getElementById('select_image_fields'); + + current_index = obj.selectedIndex; if( current_index != 0 ) { /** * swap entries */ - obj = document.form_image_fields.select_image_fields.options; + tmp_value = obj.options[ current_index ].value; + tmp_text = obj.options[ current_index ].text; + tmp_class = obj.options[ current_index ].className; - tmp_value = obj[ current_index ].value; - tmp_text = obj[ current_index ].text; - tmp_class = obj[ current_index ].className; - - obj[ current_index ].value = obj[ current_index - 1].value; - obj[ current_index ].text = obj[ current_index - 1].text; - obj[ current_index ].className = obj[ current_index - 1].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[ current_index - 1].value = tmp_value; - obj[ current_index - 1].text = tmp_text; - obj[ current_index - 1].className = tmp_class; + 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 */ - document.form_image_fields.select_image_fields.selectedIndex = current_index - 1; + obj.selectedIndex = current_index - 1; } } function movedownElement () { - current_index = document.form_image_fields.select_image_fields.selectedIndex; + obj = document.getElementById('select_image_fields'); + + current_index = obj.selectedIndex; - if( current_index != ( document.form_image_fields.select_image_fields.length - 1 ) ) + if( current_index != ( obj.length - 1 ) ) { /** * swap entries */ - obj = document.form_image_fields.select_image_fields.options; + tmp_value = obj.options[ current_index ].value; + tmp_text = obj.options[ current_index ].text; + tmp_class = obj.options[ current_index ].className; - tmp_value = obj[ current_index ].value; - tmp_text = obj[ current_index ].text; - tmp_class = obj[ current_index ].className; - - obj[ current_index ].value = obj[ current_index + 1].value; - obj[ current_index ].text = obj[ current_index + 1].text; - obj[ current_index ].className = obj[ current_index + 1].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[ current_index + 1].value = tmp_value; - obj[ current_index + 1].text = tmp_text; - obj[ current_index + 1].className = tmp_class; + 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 */ - document.form_image_fields.select_image_fields.selectedIndex = current_index + 1; + obj.selectedIndex = current_index + 1; } } </script> \ No newline at end of file Modified: trunk/linpha2/db_data.sql =================================================================== --- trunk/linpha2/db_data.sql 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/db_data.sql 2006-03-07 17:38:22 UTC (rev 4402) @@ -43,4 +43,15 @@ -- -------------------------------------------------------- -TRUNCATE `linpha_photos`; \ No newline at end of file +TRUNCATE `linpha_photos`; + + +-- +-- Daten f\xFCr Tabelle `linpha_meta_fields` +-- + +TRUNCATE `linpha_meta_fields`; +INSERT INTO `linpha_meta_fields` VALUES (1, 'description', 1, 1, 1); +INSERT INTO `linpha_meta_fields` VALUES (2, 'category', 2, 1, 1); +INSERT INTO `linpha_meta_fields` VALUES (3, 'persons', 2, 1, 1); +INSERT INTO `linpha_meta_fields` VALUES (4, 'date', 3, 1, 1); Modified: trunk/linpha2/get_thumb.php =================================================================== --- trunk/linpha2/get_thumb.php 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/get_thumb.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -29,7 +29,13 @@ throw new Exception("not permitted!"); } - $output = linImage::createThumbnail($data['id'],$data['img_type'],$force=false); + if( isset($_GET['force'] ) ) { + $force = true; + } else { + $force = false; + } + + $output = linImage::createThumbnail($data['id'],$data['img_type'],$force); Header("Content-type: image/jpeg"); readfile( $output ); } Modified: trunk/linpha2/install/sql/sql.mysql.php =================================================================== --- trunk/linpha2/install/sql/sql.mysql.php 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/install/sql/sql.mysql.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -256,7 +256,6 @@ * create dynamically the linpha_meta_exif table */ include_once(LINPHA_DIR.'/lib/classes/metadata.class.php'); -$metadata = new MetaData; -$sql_tables[] = $metadata->createExifTable(); +$sql_tables[] = Metadata::createExifTable(); ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -66,8 +66,8 @@ * create new tmp folder */ $tmp_dir = $GLOBALS['linpha']->sql->config->value['sys_path_tmp_dir']; - for($i=0; file_exists(linFilesys::getFullPath($tmp_dir).'/thumb_folder_'.session_id().'_'.$i); $i++) { } - $tmp_folder = linFilesys::getFullPath($tmp_dir).'/thumb_folder_'.session_id().'_'.$i; + for($i=0; file_exists(linFilesys::getFullPath($tmp_dir).'thumb_folder_'.session_id().'_'.$i); $i++) { } + $tmp_folder = linFilesys::getFullPath($tmp_dir).'thumb_folder_'.session_id().'_'.$i; mkdir($tmp_folder,0700); /** Modified: trunk/linpha2/lib/classes/metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/metadata.class.php 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/lib/classes/metadata.class.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -23,8 +23,6 @@ if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','..'); } -include_once(LINPHA_DIR.'/lib/classes/metadata.config.php'); - class MetaData { var $trans_array; @@ -843,30 +841,26 @@ /** * $suffix required to create temporary table during upgrade on sqlite */ - function createExifTable($suffix='') + function createExifTable($array) { - if(!defined('PREFIX')): define('PREFIX', $_POST['db_prefix']); endif; - - $array = $this->getExifTranslationArray(); - if(DB_TYPE == "mysql") { - $str = "CREATE TABLE ".PREFIX."meta_exif".$suffix." (". + $str = "CREATE TABLE ".PREFIX."meta_exif (". "md5sum VARCHAR(32) NOT NULL, "; foreach($array AS $key=>$value) { - $str .= strtolower($key)." VARCHAR(255), "; + $str .= linSql::linAddslashes(strtolower($value))." VARCHAR(255), "; } $str .= "PRIMARY KEY (md5sum), "; $str .= "KEY (md5sum) )"; } elseif(DB_TYPE == "sqlite") { - $str = "CREATE TABLE ".PREFIX."meta_exif".$suffix." (". + $str = "CREATE TABLE ".PREFIX."meta_exif (". "md5sum VARCHAR(32) PRIMARY KEY NOT NULL, "; foreach($array AS $key=>$value) { - $str .= strtolower($key)." VARCHAR(255), "; + $str .= strtolower($value)." VARCHAR(255), "; } /** * remove last 2 signs (the comma and the space) @@ -875,12 +869,12 @@ } elseif(DB_TYPE == "postgres") { - $str = "CREATE TABLE ".PREFIX."meta_exif".$suffix." (". + $str = "CREATE TABLE ".PREFIX."meta_exif (". "md5sum VARCHAR(32) NOT NULL, "; foreach($array AS $key=>$value) { - $str .= strtolower($key)." VARCHAR(255), "; + $str .= strtolower($value)." VARCHAR(255), "; } /** @@ -890,6 +884,88 @@ } return $str; } + +/** + * get array with iptctags + */ +function getIptcTranslationArray() +{ + return array( + 'caption' => 'Caption', + 'caption_writer' => 'Caption Writer', + 'headline' => 'Headline', + 'instructions' => 'Special Instructions', + 'keywords' => 'Keywords', + 'category' => 'Category', + 'supplemental_categorie' => 'Supplemental Category', + 'copyright' => 'Copyright Notice', + 'byline' => 'By-Line (Author)', + 'byline_title' => 'By-Line Title', + 'credit' => 'Credit', + 'source' => 'Source', + 'edit_status' => 'Edit Status', + 'priority' => 'Priority', + 'object_cycle' => 'Object Cycle', + 'job_id' => 'Fixture Identifier', + 'program' => 'Originating Program', + 'object_name' => 'Object Name (Title)', + 'date_created' => 'Date Created', + 'date_released' => 'Release Date', + 'time_created' => 'Time Created', + 'time_released' => 'Release Time', + 'city' => 'City', + 'sublocation' => 'Sub-Location', + 'state' => 'Province/State', + 'country' => 'Country Name', + 'country_code' => 'Country Code', + 'trans_reference' => 'Transmission Reference' + ); } - + +function createIptcTable($array) +{ + if(DB_TYPE == "mysql") + { + $str = "CREATE TABLE ".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(DB_TYPE == "sqlite") + { + $str = "CREATE TABLE ".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(DB_TYPE == "postgres") + { + $str = "CREATE TABLE ".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; +} + +} // end class metadata ?> \ No newline at end of file Deleted: trunk/linpha2/lib/classes/metadata.config.php =================================================================== --- trunk/linpha2/lib/classes/metadata.config.php 2006-03-07 14:51:32 UTC (rev 4401) +++ trunk/linpha2/lib/classes/metadata.config.php 2006-03-07 17:38:22 UTC (rev 4402) @@ -1,128 +0,0 @@ -<?php - -/** - * 1 -> low, 2 -> medium, 3 -> high - */ -function getExifTagsByVerbosityLevel($level) -{ - $array[1] = Array( - 'DateTimeOriginal','Make','Model','Artist','Copyright' - ); - - $array[2] = Array( - 'DateTimeOriginal','Make','Model','Artist','Copyright' - ,'ApertureValue','ShutterSpeedValue','ExposureTime' - ); - - $array[3] = Array( - 'DateTimeOriginal','Make','Model','Artist','Copyright' - ,'ApertureValue','ShutterSpeedValue','ExposureTime' - ,'ISOSpeedRatings','Flash','FocalLength','FNumber' - ); - - if(isset($array[$level])) - { - return $array[$level]; - } - else - { - return $array[2]; - } -} - -/** - * 1 -> low, 2 -> medium, 3 -> high - */ -function getIptcTagsByVerbosityLevel($level) -{ - $array[1] = Array( - 'caption','caption_writer','headline','instructions', 'copyright' - ,'keywords', 'object_name' - ); - - $array[2] = Array( - 'caption','caption_writer','headline','instructions','copyright','byline' - ,'byline_title','object_name', 'keywords','category','supplemental_categorie' - ); - - $array[3] = Array( - 'caption','caption_writer','headline','instructions','copyright','byline' - ,'byline_title','object_name','keywords','category','supplemental_categorie' - ,'credit','source','date_created','time_created' - ); - - if(isset($array[$level])) - { - return $array[$level]; - } - else - { - return $array[2]; - } -} - -$iptc_search_tags = Array( - 'caption_writer','caption','keywords','headline','copyright','source','byline' - , 'object_name'); - -$exif_search_tags = Array( - 'DateTimeOriginal', 'ImageDescription','JpegComment','Artist','Copyright','Make','Model' - ); - -function getIptcTranslationArray() -{ - return array( - 'caption' => 'Caption', - 'caption_writer' => 'Caption Writer', - 'headline' => 'Headline', - 'instructions' => 'Special Instructions', - 'keywords' => 'Keywords', - 'category' => 'Category', - 'supplemental_categorie' => 'Supplemental Category', - 'copyright' => 'Copyright Notice', - 'byline' => 'By-Line (Author)', - 'byline_title' => 'By-Line Title', - 'credit' => 'Credit', - 'source' => 'Source', - 'edit_status' => 'Edit Status', - 'priority' => 'Priority', - 'object_cycle' => 'Object Cycle', - 'job_id' => 'Fixture Identifier', - 'program' => 'Originating Program', - 'object_name' => 'Object Name (Title)', - 'date_created' => 'Date Created', - 'date_released' => 'Release Date', - 'time_created' => 'Time Created', - 'time_released' => 'Release Time', - 'city' => 'City', - 'sublocation' => 'Sub-Location', - 'state' => 'Province/State', - 'country' => 'Country Name', - 'country_code' => 'Country Code', - 'trans_reference' => 'Transmission Reference' - ); -} - -/** - * Function used in search.php to translate iptc tags to human readable values - * if called with $arg == single. If called with $arg == array return the wholw - * thing for metadata.class.php (i.e. left_view ) - * @returns $array or single array value - */ -function translateIptcSearchTags($tag, $arg) -{ - $trans_array = getIptcTranslationArray(); - - /** - * return: either single value or whole array - */ - if($arg == "single") - { - return $trans_array[$tag]; - } - else - { - return $trans_array; - } -} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |