Thread: [Linpha-cvs] SF.net SVN: linpha: [4777] trunk/linpha2 (Page 9)
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2007-11-05 22:31:30
|
Revision: 4777 http://linpha.svn.sourceforge.net/linpha/?rev=4777&view=rev Author: fangehrn Date: 2007-11-05 14:31:27 -0800 (Mon, 05 Nov 2007) Log Message: ----------- 2007-11-05 flo * worked some more on the map plugin delete markers is now working Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/maintenance_import.php trunk/linpha2/lib/classes/linpha.class.php trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/modules/module.filemanager.php trunk/linpha2/lib/plugins/maps/LinMaps.js trunk/linpha2/lib/plugins/maps/class.googlemaps.js trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/templates/default/maps.html.php trunk/linpha2/templates/default/search.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/ChangeLog 2007-11-05 22:31:27 UTC (rev 4777) @@ -1,4 +1,9 @@ + +2007-11-05 flo + * worked some more on the map plugin + delete markers is now working + 2007-10-30 flo * working some more on the map plugin create markers is now working Modified: trunk/linpha2/admin/maintenance_import.php =================================================================== --- trunk/linpha2/admin/maintenance_import.php 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/admin/maintenance_import.php 2007-11-05 22:31:27 UTC (rev 4777) @@ -310,7 +310,7 @@ <br /> <form action="./?cat=maintenance_import" method="POST"> <select name="album_select[]" size="10" multiple="multiple" style="width: 500px;"> -<?php linBuildAlbumSelect($with_all_albs_entry=true); ?> +<?php linBuildAlbumSelect($with_all_albs_entry=true,$with_linebreaks=true); ?> </select> <br /><br /> Modified: trunk/linpha2/lib/classes/linpha.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.class.php 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/lib/classes/linpha.class.php 2007-11-05 22:31:27 UTC (rev 4777) @@ -118,8 +118,12 @@ * to keep the update language file routine working */ define('LIN_STR_SUBMIT', i18n("Submit") ); +define('LIN_STR_CONFIRMDELETE', i18n("Do you really want to delete %s?") ); + +define('LIN_STR_SUCCUPDATEDDATA', i18n("Successfully updated data") ); + define('LIN_STR_ACCESSDENIED', i18n("Error: Access denied") ); -define('LIN_STR_SUCCUPDATEDDATA', i18n("Successfully updated data") ); +define('LIN_STR_NOVALIDDATA', i18n("Error: No valid data") ); define('LIN_STR_CHKFILEPERM', i18n("Check file permissions") ); Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/lib/classes/linpha.functions.php 2007-11-05 22:31:27 UTC (rev 4777) @@ -263,26 +263,29 @@ /** * functions to create a html select form with all albums */ -function linBuildAlbumSelect($with_all_albs_entry) +function linBuildAlbumSelect($with_all_albs_entry,$with_linebreaks) { - ?> - - <?php + if($with_linebreaks) { + $ln = "\n"; + } else { + $ln = ""; + } + if($with_all_albs_entry) { if(!isset($_REQUEST['album_select']) OR $_REQUEST['album_select'][0]=='all') { $select = ' selected'; - $_REQUEST['album_select'] = Array('all'=>'all'); + $_REQUEST['album_select'] = array('all'=>'all'); } else { $select = ''; } - echo '<option value="all"'.$select.'>'.i18n("All Albums").'</option>'."\n"; + echo '<option value="all"'.$select.'>'.i18n("All Albums").'</option>'.$ln; } - linBuildAlbumSelectSubEntry(0,''); + linBuildAlbumSelectSubEntry(0,'',$ln); } -function linBuildAlbumSelectSubEntry($id,$text) +function linBuildAlbumSelectSubEntry($id,$text,$ln) { $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".LIN_PREFIX."photos WHERE parent_id = '".$id."' AND img_type = '0' ORDER by name"); while($data = $query->FetchRow()) @@ -295,9 +298,9 @@ } else { $select = ''; } - echo '<option value="'.$data['id'].'"'.$select.'>'.$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES).'</option>'."\n"; + echo '<option value="'.$data['id'].'"'.$select.'>'.$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES).'</option>'.$ln; - linBuildAlbumSelectSubEntry($data['id'],$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES)); + linBuildAlbumSelectSubEntry($data['id'],$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES),$ln); } } Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/lib/modules/module.filemanager.php 2007-11-05 22:31:27 UTC (rev 4777) @@ -182,7 +182,7 @@ <select name="movecopy_to" class="linForms"> <option value="0">/</option> <?php - linBuildAlbumSelect( $with_all_albs_entry=false ); + linBuildAlbumSelect( $with_all_albs_entry=false,$with_linebreaks=true ); ?> </selet> <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_REQUEST['checkedfiles']); ?>" /> Modified: trunk/linpha2/lib/plugins/maps/LinMaps.js =================================================================== --- trunk/linpha2/lib/plugins/maps/LinMaps.js 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/lib/plugins/maps/LinMaps.js 2007-11-05 22:31:27 UTC (rev 4777) @@ -18,7 +18,7 @@ this.defaultMarkerZoom = linMapsDefaultMarkerZoom; this.markersData = false; - this.markersObj = false; + this.markersObj = new Array(); }, /** @@ -45,7 +45,7 @@ myLinMapObject.removeMarker( myLinMaps.markersObj[i] ); } - myLinMaps.markersObj = false; + myLinMaps.markersObj = new Array(); } /** @@ -104,6 +104,33 @@ } }, + deleteMarker: function(markerId) + { + myLinGlobal.AjaxPost('cmd=deleteMarker&markerId='+markerId,myLinMaps.deleteMarkerFinish); + }, + deleteMarkerFinish: function(t) + { + xmlAnswer = t.responseXML.documentElement; + + if( xmlAnswer.getElementsByTagName('responseCode').item(0).firstChild.data == 'success' ) + { + var markerId = xmlAnswer.getElementsByTagName('responseData').item(0).firstChild.data; + + for( i = 0; i < myLinMaps.markersData.markers.length; i++ ) + { + if( myLinMaps.markersData.markers[i].id == markerId ) + { + myLinMapObject.removeMarker( myLinMaps.markersObj[i] ); + myLinMaps.markersObj[i] = false; + } + } + } + else + { + alert(xmlAnswer.getElementsByTagName('responseMsg').item(0).firstChild.data ); + } + }, + removeEditMarker: function() { myLinMapObject.removeMarker( this.editMarker ); @@ -116,12 +143,16 @@ assignAlbum: function(markerId,albId) { - alert( albId ); - myLinGlobal.AjaxPost('cmd=assignAlbum&albId='+albId,myLinMaps.assignAlbumFinish); + alert( markerId + ' ' + albId ); + myLinGlobal.AjaxPost('cmd=assignAlbum&markerId='+markerId+'&albId='+albId,myLinMaps.assignAlbumFinish); }, assignAlbumFinsih: function(t) { }, + deleteAssignedAlbum: function(markerId,albId) + { + + }, loadAlbums: function() { Modified: trunk/linpha2/lib/plugins/maps/class.googlemaps.js =================================================================== --- trunk/linpha2/lib/plugins/maps/class.googlemaps.js 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/lib/plugins/maps/class.googlemaps.js 2007-11-05 22:31:27 UTC (rev 4777) @@ -141,7 +141,7 @@ var marker = new GMarker(point, icon); GEvent.addListener(marker, "click", function() { - marker.openInfoWindowHtml( /*myLinMaps.getMarkerInfo( markerNode )*/ '<b>' + markerNode.name + '</b><br />' + markerNode.text ); + marker.openInfoWindowHtml( linGetMarkerHtml(markerNode) ); }); googlemap.addOverlay( marker ); Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2007-11-05 22:31:27 UTC (rev 4777) @@ -52,20 +52,24 @@ { $path = htmlspecialchars($data['albPath'],ENT_QUOTES); - if($allowed) { + /*if($allowed) { if( $data['albId'] != 0 ) { - $text = '<a href=\'javascript:myLinMaps.assignAlbumChange('.$data['id'].','.$data['albId'].')\'>'.i18n("Change Assigned Album").'</a>'; + $text = '<a href=\'javascript:myLinMaps.assignAlbumChange('.$data['id'].','.$data['albId'].')\'>'.i18n("Change Assigned Album").'</a>' . + '<br /><a href=\'javascript:myLinMaps.deleteAssignedAlbum('.$data['id'].','.$data['albId'].')\'>'.i18n("Delete Assigned Album").'</a>'; } else { $text = '<a href=\'javascript:myLinMaps.assignAlbum('.$data['id'].',0)\'>'.i18n("Assign Album").'</a>'; } + + $text .= '<br /><a href=\'javascript:if(confirm(\'test\')){myLinMaps.deleteMarker('.$data['id'].')}\'>'.i18n("Delete Marker").'</a>'; + } else { $text = $path; - } + }*/ echo '{"id": '.$data['id'].', "albId": '.$data['albId'].', "path": "'.$path.'", ' . '"name": "'.htmlspecialchars($data['markerName'],ENT_QUOTES).'", ' . '"lat": '.$data['markerLat'].', "lon": '.$data['markerLon'].', ' . - '"zoom": '.$data['markerZoom'].', "text": "'.$text.'"},'. "\n"; + '"zoom": '.$data['markerZoom'].'},'. "\n"; } /* ?> { "markers": [ @@ -134,6 +138,36 @@ echo '</root>'."\n"; break; + case 'deleteMarker': + + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + echo '<root>'."\n"; + + if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; + } + elseif( !isset($_REQUEST['markerId']) ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; + } + else + { + $markerId = intval($_REQUEST['markerId']); + $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."plugins_maps_markers " . + "WHERE id='".LinSql::linAddslashes($markerId)."'"); + + echo '<responseCode>success</responseCode>'."\n"; + echo '<responseData>'.$markerId.'</responseData>'."\n"; + } + + echo '</root>'."\n"; + + break; + case 'assignAlbum': header('Content-type: text/xml'); @@ -148,7 +182,7 @@ elseif( !isset($_REQUEST['markerId']) OR !isset($_REQUEST['albId']) ) { echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.i18n("Error: No valid data").'</responseMsg>'."\n"; + echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; } else { @@ -163,9 +197,7 @@ echo '</root>'."\n"; - break; - case 'loadAlbums': echo '{ "albums": [' . "\n"; Modified: trunk/linpha2/templates/default/maps.html.php =================================================================== --- trunk/linpha2/templates/default/maps.html.php 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/templates/default/maps.html.php 2007-11-05 22:31:27 UTC (rev 4777) @@ -36,18 +36,6 @@ <div style="display: none"> - <div id="linDivMapListOfAllAlbums"> - <form> - <select name="linInputAlbum" style="width: 250px;"> - <?php linBuildAlbumSelect($with_all_albs_entry=false); ?> - </select><br /> - <input type="button" value="<?php echo i18n("Assign Album"); ?>" onclick="myLinMaps.assignAlbum(this.form.linInputAlbum.value)"> - </form> - </div> - - - <br /> - <div> Legend:<br /> (red) current marker<br /> @@ -118,7 +106,38 @@ </fieldset> </form> </div> -<script type="text/javascript"> -//new Draggable('linDivEditMarker',{revert:false}); -</script> +<script language="JavaScript" type="text/javascript"> +function linGetMarkerHtml(markerNode) +{ + var htmlStr = '<b>' + markerNode.name + '</b><br />' + markerNode.path; + <?php + if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + { + ?> + htmlStr += '<br /><br /><form><select name="linInputAlbum" style="width: 250px;"><?php + linBuildAlbumSelect($with_all_albs_entry=false,$with_linebreaks=false); ?></select><br />'; + + if(markerNode.albId != 0) + { + htmlStr += '<input type="button" value="<?php echo i18n("Change Assigned Album"); + ?>" onclick="myLinMaps.assignAlbumChange(' + markerNode.id + ',this.form.linInputAlbum.value)">' + + '<br /><input type="button" value="<?php echo i18n("Delete Assigned Album"); + ?>" onclick="myLinMaps.deleteAssignedAlbum(' + markerNode.id + ',' + markerNode.albId + ')">'; + } else { + htmlStr += '<input type="button" value="<?php echo i18n("Assign Album"); + ?>" onclick="myLinMaps.assignAlbum(this.form.linInputAlbum.value)">'; + } + + htmlStr += '<input type="button" value="<?php echo i18n("Delete Marker"); ?>" onclick="if(confirm(\'<?php + echo sprintf(LIN_STR_CONFIRMDELETE, i18n("this marker")); + ?>\')){myLinMaps.deleteMarker(' + markerNode.id + ');}"></form>'; + <?php + } + ?> + + return htmlStr; +} + +</script> + Modified: trunk/linpha2/templates/default/search.html.php =================================================================== --- trunk/linpha2/templates/default/search.html.php 2007-10-30 22:19:50 UTC (rev 4776) +++ trunk/linpha2/templates/default/search.html.php 2007-11-05 22:31:27 UTC (rev 4777) @@ -115,7 +115,7 @@ <!-- select album //--> <b><?php echo i18n("Search In Album"); ?><b><br /> <select name="album_select[]" size="10" multiple="multiple" style="width: 200px;"> - <?php linBuildAlbumSelect($with_all_albs_entry=true); ?> + <?php linBuildAlbumSelect($with_all_albs_entry=true,$with_linebreaks=true); ?> </select><br /> <font size="-2">(<?php echo i18n("Multiple Select Use 'Ctrl'"); ?>)</font> <br /><br /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-11-06 11:48:34
|
Revision: 4778 http://linpha.svn.sourceforge.net/linpha/?rev=4778&view=rev Author: bzrudi Date: 2007-11-06 03:48:31 -0800 (Tue, 06 Nov 2007) Log Message: ----------- "move sql.data.php to /lib/include/ so we can savely delete the whole /install subfolder" Modified Paths: -------------- trunk/linpha2/install/manual_install.php trunk/linpha2/install/step9_createtables.php Added Paths: ----------- trunk/linpha2/lib/include/sql.data.php Modified: trunk/linpha2/install/manual_install.php =================================================================== --- trunk/linpha2/install/manual_install.php 2007-11-05 22:31:27 UTC (rev 4777) +++ trunk/linpha2/install/manual_install.php 2007-11-06 11:48:31 UTC (rev 4778) @@ -108,7 +108,7 @@ * insert data */ $str_query .= "\n\n"; - include_once(LINPHA_DIR.'/install/sql/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql.data.php'); foreach($sql_queries AS $value) { $str_query .= $value.";\n"; Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2007-11-05 22:31:27 UTC (rev 4777) +++ trunk/linpha2/install/step9_createtables.php 2007-11-06 11:48:31 UTC (rev 4778) @@ -125,7 +125,7 @@ * insert data */ echo "<br />".i18n_install("Inserting Table Data...").' '; - include_once(LINPHA_DIR.'/install/sql/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql.data.php'); foreach($sql_queries AS $value) { $result = $linpha->db->Execute($value); Added: trunk/linpha2/lib/include/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql.data.php (rev 0) +++ trunk/linpha2/lib/include/sql.data.php 2007-11-06 11:48:31 UTC (rev 4778) @@ -0,0 +1,344 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * linpha installer + * @package Installation + */ + +/** + * config table + */ +$options = array( + 'sys_db_version' => '3', + + 'sys_im_bracket_support' => $_SESSION['sys_im_bracket_support'], + 'sys_im_imagemagick_path' => $_SESSION['sys_im_convert_path'], + 'sys_im_use_imagemagick' => $_SESSION['sys_im_use_convert'], + 'sys_im_video_thumbnail' => '1', + + 'sys_import_autoimport' => '1', + 'sys_import_exif' => '1', + 'sys_import_exif_autorot' => '1', + 'sys_import_use_exiftool' => '0', + 'sys_import_use_emb_thumb' => '0', + 'sys_import_exiftool_avail' => '0', + 'sys_import_files_ignored' => 'Thumbs.db,ZbThumbnail.info,_vti_cnf,_derived,Picasa.ini,Cdlabel.alb', + 'sys_import_fileext_ignored' => 'thm,doc,txt', + + 'sys_image_exif' => '1', + 'sys_image_iptc' => '0', + 'sys_image_xmp' => '0', + 'sys_lang' => $_SESSION['language'], + 'sys_lang_autolang' => '1', + 'sys_path_album_dir' => $_SESSION['album_dir'], + 'sys_path_cache_dir' => $_SESSION['cache_dir'], + 'sys_path_tmp_dir' => $_SESSION['tmp_dir'], + + 'sys_basket_mail_max_size' => (1024*1024*2), + 'sys_basket_mail_smpthost' => 'localhost', + 'sys_basket_download_limit' => '0', + + 'sys_style_datetime_dates' => '%a %m/%d/%Y', + 'sys_style_datetime_times' => '%I:%M:%S %p', + + 'sys_style_home_showbrowsebydate' => '1', + 'sys_style_home_nrrandomimages' => '4', + 'sys_style_home_newimagesnr' => '4', + 'sys_style_home_newimagesage' => '7', + 'sys_style_home_showalbums' => '1', + 'sys_style_home_usedefaultwelcometext' => '1', + 'sys_style_home_firstsortorder' => 'nameasc', + + 'sys_style_thumb_size_max' => '200', + 'sys_style_thumb_size_display' => '150', + 'sys_style_thumb_showsubfoldersseparate' => '0', + 'sys_style_thumb_selectsizes' => '50,75,100,150,200,250,300,400,500', + 'sys_style_thumb_selectnrimages' => 'auto,10,25,50,100,200,all', + 'sys_style_thumb_nojsnrrows' => '3', + 'sys_style_thumb_nojsnrcols' => '4', + + 'sys_style_image_quality' => '75', + 'sys_style_image_width' => '700', + 'sys_style_image_height' => '525', + 'sys_style_image_nrprevnextthumbs' => '3', + 'sys_style_image_useeffects' => '1', + + 'sys_style_layout_color_bodybg' => 'DDDDDD', // the blue design + 'sys_style_layout_color_elembg' => '87CEFA', + 'sys_style_layout_color_font' => '000000', + 'sys_style_layout_color_albumsbg' => 'D5FCF4', + 'sys_style_layout_color_links' => '005388', + 'sys_style_layout_color_linkshover' => '666666', + 'sys_style_layout_color_fields' => 'CCCCCC', + + 'sys_style_layout_theme' => 'default', + 'sys_style_layout_template' => 'default', + 'sys_style_layout_title' => 'Linpha 2.0', + + 'sys_style_others_sortorder' => 'nameasc', + + 'sys_user_autologin' => '1', + + + 'plugins_log_filename' => 'var/linpha.log', + 'plugins_log_syslog_enable' => '0', + 'plugins_log_syslog_add_events' => '', + 'plugins_log_email_enable' => '0', + 'plugins_log_email_add_events' => '', + 'plugins_log_email_to' => 'LinPHA Logger<log@'.$_SERVER["HTTP_HOST"].'>', + 'plugins_log_email_headers' => 'From:LinPHA Logger<noreply@'.$_SERVER["HTTP_HOST"].'>', + 'plugins_log_email_subject' => 'Linpha Log', + + 'plugins_filemanager_enable' => '0', + 'plugins_filemanager_nruploads' => '5', + + 'plugins_maps_defaultMarkerZoom' => '10', + 'plugins_maps_mapType' => 'google', + 'plugins_maps_google_key' => 'ABQIAAAAAXCMfho4_sqSSh0VqMB80xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSfO_6bbb_ScfT_zPgcnJMKyGltOg', // key for http://localhost + +); + +$options_user_overrideable = Array( + 'sys_lang', + 'sys_lang_autolang', + 'sys_style_others_sortorder', + 'sys_style_template', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_nrrandomimages', + 'sys_style_home_showalbums', + 'sys_style_home_firstsortorder', + 'sys_style_thumb_size_display', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_style_thumb_nojsnrrows', + 'sys_style_thumb_nojsnrcols', + 'sys_style_image_width', + 'sys_style_image_height', + 'sys_style_image_nrprevnextthumbs' => '3', + 'sys_style_image_useeffects' => '1', + + 'sys_style_layout_color_bodybg' => 'DDDDDD', // the blue design + 'sys_style_layout_color_elembg' => '87CEFA', + 'sys_style_layout_color_font' => '000000', + 'sys_style_layout_color_albumsbg' => 'D5FCF4', + 'sys_style_layout_color_links' => '005388', + 'sys_style_layout_color_linkshover' => '666666', + 'sys_style_layout_color_fields' => 'CCCCCC', + + 'sys_style_layout_theme' => 'default', + 'sys_style_layout_template' => 'default', +); + +/** + * create sql executes for all option entries + */ +while( list($name, $value) = each($options) ) +{ + if(in_array($name,$options_user_overrideable)) { + $override = 1; + } else { + $override = 0; + } + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . + "VALUES ('".$name."', '".$value."', '".$override."', '0')"; +} + +/** + * groups + */ +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."groups (group_name) VALUES ('admin')"; + +/** + * permissions + */ +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (photos_id, perm_type, permission) " . + "VALUES (0, 'read', ';public;')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (photos_id, perm_type, permission) " . + "VALUES (0, 'write', ';;')"; + + +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('basket_print', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('basket_mail', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('basket_download', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('metadata_comments', ';public;')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('metadata_deletecomments', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('metadata_edit', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('watermark', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('stats', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('download', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('plugins_maps_setMarkers', '')"; + + +/** + * MetaData + * see http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields for the definition + */ + /** + * special fields + * flag_nr 1 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('filename', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('imagesize', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('dimension', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('thumbnail', 0, 1)"; + + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('time_add', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('time_mod', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('time_exif', 0, 1)"; + + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('stats_numbers', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('stats_views', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('stats_downloads', 0, 1)"; + + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('first_comment', 0, 1)"; + /** + * workaround for i18n + * they wouldn't get detected otherwise... + * some are defined in linpha.metadata.php + */ + i18n("Filename"); i18n("Imagesize"); i18n("Dimension"); i18n("Thumbnail"); + + + /** + * builtin fields + * flag_nr 5 (builtin enabled) + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('description', 1, 5)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('category', 2, 5)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('persons', 2, 5)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('date', 3, 5)"; + /** + * workaround for i18n + * they wouldn't get detected otherwise... + * some are defined in linpha.metadata.php + */ + i18n("Description"); i18n("Category"); i18n("Persons"); i18n("Date"); + + + /** + * image fields + * flag_nr 10 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_dimension', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_category', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_persons', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_time_exif', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_stats_views', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_stats_downloads', 0, 10)"; + + + /** + * video fields + * flag_nr 11 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('??', 0, 11)"; + + /** + * album fields + * flag_nr 12 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_time_add', 0, 12)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_stats_numbers', 0, 12)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 12)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_persons', 0, 12)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_first_comment', 0, 12)"; + + + /** + * thumbnails fields + * flag_nr 13 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 13)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 13)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 13)"; + + /** + * thumbnails in detail view fields + * flag_nr 14 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_dimension', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('exif_datetimeoriginal', 0, 14)"; + + /** + * slideshow fields + * flag_nr 15 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 15)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 15)"; + +?> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-11-06 16:34:37
|
Revision: 4779 http://linpha.svn.sourceforge.net/linpha/?rev=4779&view=rev Author: bzrudi Date: 2007-11-06 08:34:23 -0800 (Tue, 06 Nov 2007) Log Message: ----------- "fix path for moved sql.data.php" Modified Paths: -------------- trunk/linpha2/admin/maintenance_db.php trunk/linpha2/reset_database.php Modified: trunk/linpha2/admin/maintenance_db.php =================================================================== --- trunk/linpha2/admin/maintenance_db.php 2007-11-06 11:48:31 UTC (rev 4778) +++ trunk/linpha2/admin/maintenance_db.php 2007-11-06 16:34:23 UTC (rev 4779) @@ -1,307 +1,307 @@ -<?php - -/** - * check if each photo has a parent element - */ - echo '<h2>'.i18n("Checking photos table").'</h2>'; - echo '('.i18n("Checking intern consistency of the photos table. This means every entry must belong to a folder.").')<br /><br />'; - - $query = $GLOBALS['linpha']->db->Execute("SELECT id, parent_id, name FROM ".LIN_PREFIX."photos"); - $i = 0; - $i_tot = 0; - while($data = $query->FetchRow()) - { - if($data['parent_id'] != 0) - { - $query2 = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($data['parent_id'])."'"); - $data2 = $query2->FetchRow(); - if( isset($data2['id'])) - { - $i++; - } - else - { - echo i18n("Warning: This entry doesn't belongs to a folder:").' '.$data['name'].'<br />'; - - /** - * @todo there should be an option where we could really delete any obsolete entries - */ - echo i18n("Should delete it").'<br />'; - } - } - else - { - $i++; - } - - $i_tot++; - } - echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; - -/** - * check cached photos exists in filesystem and vice versa - */ - echo '<br /><h2>'.i18n("Checking image cache").'</h2>'; - - echo '<h3>'.i18n("Do all cache entries exists in the photos table?").'</h3>'; - - $query = $GLOBALS['linpha']->db->Execute("SELECT ".LIN_PREFIX."photos_cache.id, ".LIN_PREFIX."photos_cache.photo_id" . - " FROM ".LIN_PREFIX."photos_cache". - " LEFT OUTER JOIN ".LIN_PREFIX."photos ON ".LIN_PREFIX."photos.id = ".LIN_PREFIX."photos_cache.photo_id". - " WHERE ".LIN_PREFIX."photos.id IS NULL"); - - if( $query->EOF ) - { - echo '<font color="green">ok</font> '.i18n("There is no broken association.").'<br />'; - } - else - { - echo '<font color="red">failed</font><br />'; - while($data = $query->FetchRow() ) - { - echo i18n("Missing entry of:").' '.$data['photo_id'].' ('.i18n("Cache Id").': '.$data['id'].')<br />'; - } - echo '<br />'; - } - - - echo '<h3>'.i18n("Do all cache entries exists in the filesystem?").'</h3>'; - $query = $GLOBALS['linpha']->db->Execute("SELECT id, photo_id FROM ".LIN_PREFIX."photos_cache"); - $i = 0; - $i_tot = 0; - while($data = $query->FetchRow() ) - { - $filename = LinImage::getCachePath('img',$data['id'],'2'); - if( !file_exists($filename)) - { - echo i18n("Cached file doesn't exists:").' '.$filename.' ('.i18n("Photo Nr").': '.$data['photo_id'].')<br />'; - - /** - * @todo there should be an option where we could really delete any obsolete entries - */ - echo i18n("Should delete it").'<br />'; - } - else - { - if(filesize($filename) == 0) - { - echo i18n("Filesize is zero of:").' '.$filename.' ('.i18n("Photo Nr").': '.$data['photo_id'].')<br />'; - } - else - { - $i++; - } - } - - $i_tot++; - } - echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; - - - echo '<br /><h3>'.i18n("Are there obsolete cached images lying around?").'</h3>'; - $path = LinSql::getPath('cache'); - $i = 0; - $i_tot = 0; - $sub_dir_handle = opendir($path.'/img'); - while( ($sub_dir = readdir($sub_dir_handle)) !== false ) - { - if($sub_dir != "." && $sub_dir != "..") - { - $sub_file_handle = opendir($path.'/img/'.$sub_dir); - while( ($sub_file = readdir($sub_file_handle)) !== false ) - { - if($sub_file != "." && $sub_file != "..") - { - $filename_without_ext = LinFilesys::getFilenameWithoutFileExt($sub_file); - - /** - * need this pre check because mysql returns a result even if id is '107.' - * testquery: "SELECT * FROM linpha_photos WHERE id = '107.'" - */ - if(! preg_match('/^[0-9]*$/', $filename_without_ext)) - { - echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; - } - else - { - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE " . - "id = '".LinSql::linAddslashes( LinFilesys::getFilenameWithoutFileExt($sub_file) )."'"); - $data = $query->FetchRow(); - - if( isset($data['id'])) - { - $i++; - } - else - { - echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; - } - } - - $i_tot++; - } - } - - closedir($sub_file_handle); - } - } - closedir($sub_dir_handle); - echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; - - - echo '<br /><h3>'.i18n("Are there obsolete cached thumbnails lying around?").'</h3>'; - $path = LinSql::getPath('cache'); - $i = 0; - $i_tot = 0; - $sub_dir_handle = opendir($path.'/thumb'); - while( ($sub_dir = readdir($sub_dir_handle)) !== false ) - { - if($sub_dir != "." && $sub_dir != "..") - { - $sub_file_handle = opendir($path.'/thumb/'.$sub_dir); - while( ($sub_file = readdir($sub_file_handle)) !== false ) - { - if($sub_file != "." && $sub_file != "..") - { - $filename_without_ext = LinFilesys::getFilenameWithoutFileExt($sub_file); - - /** - * need this pre check because mysql returns a result even if id is '107.' - * testquery: "SELECT * FROM linpha_photos WHERE id = '107.'" - */ - if(! preg_match('/^[0-9]*$/', $filename_without_ext)) - { - echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; - } - else - { - $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".LIN_PREFIX."photos WHERE " . - "id = '".LinSql::linAddslashes( $filename_without_ext )."'"); - $data = $query->FetchRow(); - - if( isset($data['name'])) - { - $i++; - } - else - { - echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; - } - } - - $i_tot++; - } - } - - closedir($sub_file_handle); - } - } - closedir($sub_dir_handle); - echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; - -/** - * check comment/exif/iptc/xmp to photo association - */ - echo '<br /><h2>'.i18n("Checking MetaData").'</h2>'; - $array_meta = array('comments','data','exif','iptc'/*,'xmp'*/); - foreach($array_meta AS $value) - { - echo i18n("Checking table").' '.LIN_PREFIX."meta_".$value.' '; - $query = $GLOBALS['linpha']->db->Execute("SELECT ".LIN_PREFIX."meta_".$value.".md5sum FROM ".LIN_PREFIX."meta_".$value. - " LEFT OUTER JOIN ".LIN_PREFIX."photos ON ".LIN_PREFIX."photos.md5sum = ".LIN_PREFIX."meta_".$value.".md5sum". - " WHERE ".LIN_PREFIX."photos.id IS NULL"); - - if( $query->EOF ) - { - echo '<font color="green">ok</font>'.'<br />'; - } - else - { - echo '<font color="red">failed</font><br />'; - while($data = $query->FetchRow() ) - { - echo i18n("Missing entry with md5sum:").' '.$data['md5sum'].'<br />'; - } - echo '<br />'; - } - } - - -/** - * check permission entries - */ - $array_perms = array( - 'read', - 'write', - 'basket_print', - 'basket_mail', - 'basket_download', - 'metadata_comments', - 'metadata_deletecomments', - 'metadata_edit', - 'watermark', - 'stats', - 'download', - ); - - echo '<br /><h2>'.i18n("Checking permission entries").'</h2>'; - - foreach($array_perms AS $value) - { - $query = $GLOBALS['linpha']->db->Execute("SELECT permission FROM ".LIN_PREFIX."permissions " . - "WHERE photos_id = '0' AND perm_type = '".$value."'"); - $data = $query->FetchRow(); - - echo i18n("Checking").' "'.$value.'" '; - if( isset($data['permission']) ) - { - echo '<font color="green">'.i18n("ok").'</font>'; - } - else - { - echo '<font color="red">'.i18n("failed").'</font><br />'; - echo i18n("Please check the database, these entry is missing!").'<br />'; - } - echo '<br />'; - } - -/** - * checking config entries - */ - echo '<br /><h2>'.i18n("Checking config entries").'</h2>'; - - /** - * prevent some php notices - */ - $options = array(); - $_SESSION['sys_im_bracket_support'] = ''; - $_SESSION['sys_im_use_convert'] = ''; - $_SESSION['sys_im_convert_path'] = ''; - $_SESSION['language'] = ''; - $_SESSION['album_dir'] = ''; - $_SESSION['cache_dir'] = ''; - $_SESSION['tmp_dir'] = ''; - - include(LINPHA_DIR.'/install/sql/sql.data.php'); - foreach($options AS $key=>$value) - { - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."config " . - "WHERE option_name = '".$key."'"); - $data = $query->FetchRow(); - - echo i18n("Checking").' "'.$key.'" '; - if( isset($data['id']) ) - { - echo '<font color="green">'.i18n("ok").'</font>'; - } - else - { - echo '<font color="red">'.i18n("failed").'</font><br />'; - echo i18n("Please check the database, these entry is missing!").'<br />'; - } - echo '<br />'; - } - - +<?php + +/** + * check if each photo has a parent element + */ + echo '<h2>'.i18n("Checking photos table").'</h2>'; + echo '('.i18n("Checking intern consistency of the photos table. This means every entry must belong to a folder.").')<br /><br />'; + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, parent_id, name FROM ".LIN_PREFIX."photos"); + $i = 0; + $i_tot = 0; + while($data = $query->FetchRow()) + { + if($data['parent_id'] != 0) + { + $query2 = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($data['parent_id'])."'"); + $data2 = $query2->FetchRow(); + if( isset($data2['id'])) + { + $i++; + } + else + { + echo i18n("Warning: This entry doesn't belongs to a folder:").' '.$data['name'].'<br />'; + + /** + * @todo there should be an option where we could really delete any obsolete entries + */ + echo i18n("Should delete it").'<br />'; + } + } + else + { + $i++; + } + + $i_tot++; + } + echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; + +/** + * check cached photos exists in filesystem and vice versa + */ + echo '<br /><h2>'.i18n("Checking image cache").'</h2>'; + + echo '<h3>'.i18n("Do all cache entries exists in the photos table?").'</h3>'; + + $query = $GLOBALS['linpha']->db->Execute("SELECT ".LIN_PREFIX."photos_cache.id, ".LIN_PREFIX."photos_cache.photo_id" . + " FROM ".LIN_PREFIX."photos_cache". + " LEFT OUTER JOIN ".LIN_PREFIX."photos ON ".LIN_PREFIX."photos.id = ".LIN_PREFIX."photos_cache.photo_id". + " WHERE ".LIN_PREFIX."photos.id IS NULL"); + + if( $query->EOF ) + { + echo '<font color="green">ok</font> '.i18n("There is no broken association.").'<br />'; + } + else + { + echo '<font color="red">failed</font><br />'; + while($data = $query->FetchRow() ) + { + echo i18n("Missing entry of:").' '.$data['photo_id'].' ('.i18n("Cache Id").': '.$data['id'].')<br />'; + } + echo '<br />'; + } + + + echo '<h3>'.i18n("Do all cache entries exists in the filesystem?").'</h3>'; + $query = $GLOBALS['linpha']->db->Execute("SELECT id, photo_id FROM ".LIN_PREFIX."photos_cache"); + $i = 0; + $i_tot = 0; + while($data = $query->FetchRow() ) + { + $filename = LinImage::getCachePath('img',$data['id'],'2'); + if( !file_exists($filename)) + { + echo i18n("Cached file doesn't exists:").' '.$filename.' ('.i18n("Photo Nr").': '.$data['photo_id'].')<br />'; + + /** + * @todo there should be an option where we could really delete any obsolete entries + */ + echo i18n("Should delete it").'<br />'; + } + else + { + if(filesize($filename) == 0) + { + echo i18n("Filesize is zero of:").' '.$filename.' ('.i18n("Photo Nr").': '.$data['photo_id'].')<br />'; + } + else + { + $i++; + } + } + + $i_tot++; + } + echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; + + + echo '<br /><h3>'.i18n("Are there obsolete cached images lying around?").'</h3>'; + $path = LinSql::getPath('cache'); + $i = 0; + $i_tot = 0; + $sub_dir_handle = opendir($path.'/img'); + while( ($sub_dir = readdir($sub_dir_handle)) !== false ) + { + if($sub_dir != "." && $sub_dir != "..") + { + $sub_file_handle = opendir($path.'/img/'.$sub_dir); + while( ($sub_file = readdir($sub_file_handle)) !== false ) + { + if($sub_file != "." && $sub_file != "..") + { + $filename_without_ext = LinFilesys::getFilenameWithoutFileExt($sub_file); + + /** + * need this pre check because mysql returns a result even if id is '107.' + * testquery: "SELECT * FROM linpha_photos WHERE id = '107.'" + */ + if(! preg_match('/^[0-9]*$/', $filename_without_ext)) + { + echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; + } + else + { + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE " . + "id = '".LinSql::linAddslashes( LinFilesys::getFilenameWithoutFileExt($sub_file) )."'"); + $data = $query->FetchRow(); + + if( isset($data['id'])) + { + $i++; + } + else + { + echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; + } + } + + $i_tot++; + } + } + + closedir($sub_file_handle); + } + } + closedir($sub_dir_handle); + echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; + + + echo '<br /><h3>'.i18n("Are there obsolete cached thumbnails lying around?").'</h3>'; + $path = LinSql::getPath('cache'); + $i = 0; + $i_tot = 0; + $sub_dir_handle = opendir($path.'/thumb'); + while( ($sub_dir = readdir($sub_dir_handle)) !== false ) + { + if($sub_dir != "." && $sub_dir != "..") + { + $sub_file_handle = opendir($path.'/thumb/'.$sub_dir); + while( ($sub_file = readdir($sub_file_handle)) !== false ) + { + if($sub_file != "." && $sub_file != "..") + { + $filename_without_ext = LinFilesys::getFilenameWithoutFileExt($sub_file); + + /** + * need this pre check because mysql returns a result even if id is '107.' + * testquery: "SELECT * FROM linpha_photos WHERE id = '107.'" + */ + if(! preg_match('/^[0-9]*$/', $filename_without_ext)) + { + echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; + } + else + { + $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".LIN_PREFIX."photos WHERE " . + "id = '".LinSql::linAddslashes( $filename_without_ext )."'"); + $data = $query->FetchRow(); + + if( isset($data['name'])) + { + $i++; + } + else + { + echo i18n("Obsolete cached file:").' '.$path.'/img/'.$sub_dir.'/'.$sub_file.'<br />'; + } + } + + $i_tot++; + } + } + + closedir($sub_file_handle); + } + } + closedir($sub_dir_handle); + echo sprintf(i18n("%d of %d entries are <font color='green'>ok</font>."),$i,$i_tot).'<br />'; + +/** + * check comment/exif/iptc/xmp to photo association + */ + echo '<br /><h2>'.i18n("Checking MetaData").'</h2>'; + $array_meta = array('comments','data','exif','iptc'/*,'xmp'*/); + foreach($array_meta AS $value) + { + echo i18n("Checking table").' '.LIN_PREFIX."meta_".$value.' '; + $query = $GLOBALS['linpha']->db->Execute("SELECT ".LIN_PREFIX."meta_".$value.".md5sum FROM ".LIN_PREFIX."meta_".$value. + " LEFT OUTER JOIN ".LIN_PREFIX."photos ON ".LIN_PREFIX."photos.md5sum = ".LIN_PREFIX."meta_".$value.".md5sum". + " WHERE ".LIN_PREFIX."photos.id IS NULL"); + + if( $query->EOF ) + { + echo '<font color="green">ok</font>'.'<br />'; + } + else + { + echo '<font color="red">failed</font><br />'; + while($data = $query->FetchRow() ) + { + echo i18n("Missing entry with md5sum:").' '.$data['md5sum'].'<br />'; + } + echo '<br />'; + } + } + + +/** + * check permission entries + */ + $array_perms = array( + 'read', + 'write', + 'basket_print', + 'basket_mail', + 'basket_download', + 'metadata_comments', + 'metadata_deletecomments', + 'metadata_edit', + 'watermark', + 'stats', + 'download', + ); + + echo '<br /><h2>'.i18n("Checking permission entries").'</h2>'; + + foreach($array_perms AS $value) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT permission FROM ".LIN_PREFIX."permissions " . + "WHERE photos_id = '0' AND perm_type = '".$value."'"); + $data = $query->FetchRow(); + + echo i18n("Checking").' "'.$value.'" '; + if( isset($data['permission']) ) + { + echo '<font color="green">'.i18n("ok").'</font>'; + } + else + { + echo '<font color="red">'.i18n("failed").'</font><br />'; + echo i18n("Please check the database, these entry is missing!").'<br />'; + } + echo '<br />'; + } + +/** + * checking config entries + */ + echo '<br /><h2>'.i18n("Checking config entries").'</h2>'; + + /** + * prevent some php notices + */ + $options = array(); + $_SESSION['sys_im_bracket_support'] = ''; + $_SESSION['sys_im_use_convert'] = ''; + $_SESSION['sys_im_convert_path'] = ''; + $_SESSION['language'] = ''; + $_SESSION['album_dir'] = ''; + $_SESSION['cache_dir'] = ''; + $_SESSION['tmp_dir'] = ''; + + include(LINPHA_DIR.'/lib/include/sql.data.php'); + foreach($options AS $key=>$value) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."config " . + "WHERE option_name = '".$key."'"); + $data = $query->FetchRow(); + + echo i18n("Checking").' "'.$key.'" '; + if( isset($data['id']) ) + { + echo '<font color="green">'.i18n("ok").'</font>'; + } + else + { + echo '<font color="red">'.i18n("failed").'</font><br />'; + echo i18n("Please check the database, these entry is missing!").'<br />'; + } + echo '<br />'; + } + + ?> \ No newline at end of file Modified: trunk/linpha2/reset_database.php =================================================================== --- trunk/linpha2/reset_database.php 2007-11-06 11:48:31 UTC (rev 4778) +++ trunk/linpha2/reset_database.php 2007-11-06 16:34:23 UTC (rev 4779) @@ -81,7 +81,7 @@ * insert data */ echo "<br /><br />".tr("Inserting Table Data")."... "; - include_once(LINPHA_DIR.'/install/sql/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql.data.php'); foreach($sql_queries AS $value) { $result = $linpha->db->Execute($value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-11-06 17:20:37
|
Revision: 4781 http://linpha.svn.sourceforge.net/linpha/?rev=4781&view=rev Author: bzrudi Date: 2007-11-06 09:20:31 -0800 (Tue, 06 Nov 2007) Log Message: ----------- "sql.data.phpmove fixes" Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/include/sql.data.php trunk/linpha2/reset_database.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-11-06 17:16:52 UTC (rev 4780) +++ trunk/linpha2/ChangeLog 2007-11-06 17:20:31 UTC (rev 4781) @@ -1,5 +1,8 @@ +2007-11-06 bzrudi + * moved sql.data.php out of install folder into /lib/include to make sure we + can delete /install folder after installation. + * Add check for /install directory to integrity.php and abort if exist. - 2007-11-05 flo * worked some more on the map plugin delete markers is now working Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2007-11-06 17:16:52 UTC (rev 4780) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2007-11-06 17:20:31 UTC (rev 4781) @@ -754,12 +754,12 @@ } /** - * returns the correct path to the album, cache or tmp directory + * returns the correct path to the album, cache, install or tmp directory * pay attention to use this getPath and not access directly 'sys_path_album_dir' ! */ -function getPath($what) +function getPath($which) { - $path = $GLOBALS['linpha']->sql->config->value['sys_path_'.$what.'_dir']; + $path = $GLOBALS['linpha']->sql->config->value['sys_path_'.$which.'_dir']; return LinFilesys::getFullPath( $path ); } Modified: trunk/linpha2/lib/include/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql.data.php 2007-11-06 17:16:52 UTC (rev 4780) +++ trunk/linpha2/lib/include/sql.data.php 2007-11-06 17:20:31 UTC (rev 4781) @@ -50,6 +50,7 @@ 'sys_path_album_dir' => $_SESSION['album_dir'], 'sys_path_cache_dir' => $_SESSION['cache_dir'], 'sys_path_tmp_dir' => $_SESSION['tmp_dir'], + 'sys_path_install_dir' => 'install', 'sys_basket_mail_max_size' => (1024*1024*2), 'sys_basket_mail_smpthost' => 'localhost', Modified: trunk/linpha2/reset_database.php =================================================================== --- trunk/linpha2/reset_database.php 2007-11-06 17:16:52 UTC (rev 4780) +++ trunk/linpha2/reset_database.php 2007-11-06 17:20:31 UTC (rev 4781) @@ -135,4 +135,4 @@ { return $str; } -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-11-06 18:01:44
|
Revision: 4782 http://linpha.svn.sourceforge.net/linpha/?rev=4782&view=rev Author: bzrudi Date: 2007-11-06 10:01:42 -0800 (Tue, 06 Nov 2007) Log Message: ----------- "/install remove message" Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/install/step11_finish.php trunk/linpha2/lib/include/integrity.php Removed Paths: ------------- trunk/linpha2/install/sql/sql.data.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-11-06 17:20:31 UTC (rev 4781) +++ trunk/linpha2/ChangeLog 2007-11-06 18:01:42 UTC (rev 4782) @@ -1,7 +1,8 @@ 2007-11-06 bzrudi * moved sql.data.php out of install folder into /lib/include to make sure we can delete /install folder after installation. - * Add check for /install directory to integrity.php and abort if exist. + * Add check for /install directory to integrity.php and abort if exist. + (only print notice when linpha is installed public) 2007-11-05 flo * worked some more on the map plugin Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2007-11-06 17:20:31 UTC (rev 4781) +++ trunk/linpha2/docs/dev/TODO.txt 2007-11-06 18:01:42 UTC (rev 4782) @@ -55,10 +55,6 @@ - Installer - define final installer behaviour - - if installation is complete, the user must delete the install/ folder ? - (install/ignore_delete_install_msg.txt) - -> we need to move the sql scripts to the /lib folder because we need them - in the admin - maintenance - db part - user have to delete var/sql/config.sql.php before another installation can continue ? -> otherwise it would be possible to overwrite the current installation, (and to delete cache folders) - DONT add feature to drop tables if they already exists @@ -133,7 +129,11 @@ - what if the user specify wrongly the album folder as the cache folder...?? - what if a hacker gets access to the install and specify '/' as cache folder...?? -> only delete content of tmp, cache and sql folders if they are not changed (default values) - - take care of exiftool support +- if installation is complete, the user must delete the install/ folder ? + (install/ignore_delete_install_msg.txt) +- take care of exiftool support +- we need to move the sql scripts to the /lib folder because we need them + in the admin - maintenance - db part - Basket (finish) - Support for the Icons - Search (copy from linpha1) Deleted: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2007-11-06 17:20:31 UTC (rev 4781) +++ trunk/linpha2/install/sql/sql.data.php 2007-11-06 18:01:42 UTC (rev 4782) @@ -1,344 +0,0 @@ -<?php -/* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/** - * linpha installer - * @package Installation - */ - -/** - * config table - */ -$options = array( - 'sys_db_version' => '3', - - 'sys_im_bracket_support' => $_SESSION['sys_im_bracket_support'], - 'sys_im_imagemagick_path' => $_SESSION['sys_im_convert_path'], - 'sys_im_use_imagemagick' => $_SESSION['sys_im_use_convert'], - 'sys_im_video_thumbnail' => '1', - - 'sys_import_autoimport' => '1', - 'sys_import_exif' => '1', - 'sys_import_exif_autorot' => '1', - 'sys_import_use_exiftool' => '0', - 'sys_import_use_emb_thumb' => '0', - 'sys_import_exiftool_avail' => '0', - 'sys_import_files_ignored' => 'Thumbs.db,ZbThumbnail.info,_vti_cnf,_derived,Picasa.ini,Cdlabel.alb', - 'sys_import_fileext_ignored' => 'thm,doc,txt', - - 'sys_image_exif' => '1', - 'sys_image_iptc' => '0', - 'sys_image_xmp' => '0', - 'sys_lang' => $_SESSION['language'], - 'sys_lang_autolang' => '1', - 'sys_path_album_dir' => $_SESSION['album_dir'], - 'sys_path_cache_dir' => $_SESSION['cache_dir'], - 'sys_path_tmp_dir' => $_SESSION['tmp_dir'], - - 'sys_basket_mail_max_size' => (1024*1024*2), - 'sys_basket_mail_smpthost' => 'localhost', - 'sys_basket_download_limit' => '0', - - 'sys_style_datetime_dates' => '%a %m/%d/%Y', - 'sys_style_datetime_times' => '%I:%M:%S %p', - - 'sys_style_home_showbrowsebydate' => '1', - 'sys_style_home_nrrandomimages' => '4', - 'sys_style_home_newimagesnr' => '4', - 'sys_style_home_newimagesage' => '7', - 'sys_style_home_showalbums' => '1', - 'sys_style_home_usedefaultwelcometext' => '1', - 'sys_style_home_firstsortorder' => 'nameasc', - - 'sys_style_thumb_size_max' => '200', - 'sys_style_thumb_size_display' => '150', - 'sys_style_thumb_showsubfoldersseparate' => '0', - 'sys_style_thumb_selectsizes' => '50,75,100,150,200,250,300,400,500', - 'sys_style_thumb_selectnrimages' => 'auto,10,25,50,100,200,all', - 'sys_style_thumb_nojsnrrows' => '3', - 'sys_style_thumb_nojsnrcols' => '4', - - 'sys_style_image_quality' => '75', - 'sys_style_image_width' => '700', - 'sys_style_image_height' => '525', - 'sys_style_image_nrprevnextthumbs' => '3', - 'sys_style_image_useeffects' => '1', - - 'sys_style_layout_color_bodybg' => 'DDDDDD', // the blue design - 'sys_style_layout_color_elembg' => '87CEFA', - 'sys_style_layout_color_font' => '000000', - 'sys_style_layout_color_albumsbg' => 'D5FCF4', - 'sys_style_layout_color_links' => '005388', - 'sys_style_layout_color_linkshover' => '666666', - 'sys_style_layout_color_fields' => 'CCCCCC', - - 'sys_style_layout_theme' => 'default', - 'sys_style_layout_template' => 'default', - 'sys_style_layout_title' => 'Linpha 2.0', - - 'sys_style_others_sortorder' => 'nameasc', - - 'sys_user_autologin' => '1', - - - 'plugins_log_filename' => 'var/linpha.log', - 'plugins_log_syslog_enable' => '0', - 'plugins_log_syslog_add_events' => '', - 'plugins_log_email_enable' => '0', - 'plugins_log_email_add_events' => '', - 'plugins_log_email_to' => 'LinPHA Logger<log@'.$_SERVER["HTTP_HOST"].'>', - 'plugins_log_email_headers' => 'From:LinPHA Logger<noreply@'.$_SERVER["HTTP_HOST"].'>', - 'plugins_log_email_subject' => 'Linpha Log', - - 'plugins_filemanager_enable' => '0', - 'plugins_filemanager_nruploads' => '5', - - 'plugins_maps_defaultMarkerZoom' => '10', - 'plugins_maps_mapType' => 'google', - 'plugins_maps_google_key' => 'ABQIAAAAAXCMfho4_sqSSh0VqMB80xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSfO_6bbb_ScfT_zPgcnJMKyGltOg', // key for http://localhost - -); - -$options_user_overrideable = Array( - 'sys_lang', - 'sys_lang_autolang', - 'sys_style_others_sortorder', - 'sys_style_template', - 'sys_style_home_showbrowsebydate', - 'sys_style_home_nrrandomimages', - 'sys_style_home_showalbums', - 'sys_style_home_firstsortorder', - 'sys_style_thumb_size_display', - 'sys_style_thumb_showsubfoldersseparate', - 'sys_style_thumb_nojsnrrows', - 'sys_style_thumb_nojsnrcols', - 'sys_style_image_width', - 'sys_style_image_height', - 'sys_style_image_nrprevnextthumbs' => '3', - 'sys_style_image_useeffects' => '1', - - 'sys_style_layout_color_bodybg' => 'DDDDDD', // the blue design - 'sys_style_layout_color_elembg' => '87CEFA', - 'sys_style_layout_color_font' => '000000', - 'sys_style_layout_color_albumsbg' => 'D5FCF4', - 'sys_style_layout_color_links' => '005388', - 'sys_style_layout_color_linkshover' => '666666', - 'sys_style_layout_color_fields' => 'CCCCCC', - - 'sys_style_layout_theme' => 'default', - 'sys_style_layout_template' => 'default', -); - -/** - * create sql executes for all option entries - */ -while( list($name, $value) = each($options) ) -{ - if(in_array($name,$options_user_overrideable)) { - $override = 1; - } else { - $override = 0; - } - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . - "VALUES ('".$name."', '".$value."', '".$override."', '0')"; -} - -/** - * groups - */ -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."groups (group_name) VALUES ('admin')"; - -/** - * permissions - */ -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (photos_id, perm_type, permission) " . - "VALUES (0, 'read', ';public;')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (photos_id, perm_type, permission) " . - "VALUES (0, 'write', ';;')"; - - -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('basket_print', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('basket_mail', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('basket_download', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('metadata_comments', ';public;')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('metadata_deletecomments', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('metadata_edit', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('watermark', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('stats', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('download', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('plugins_maps_setMarkers', '')"; - - -/** - * MetaData - * see http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields for the definition - */ - /** - * special fields - * flag_nr 1 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('filename', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('imagesize', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('dimension', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('thumbnail', 0, 1)"; - - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('time_add', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('time_mod', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('time_exif', 0, 1)"; - - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('stats_numbers', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('stats_views', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('stats_downloads', 0, 1)"; - - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('first_comment', 0, 1)"; - /** - * workaround for i18n - * they wouldn't get detected otherwise... - * some are defined in linpha.metadata.php - */ - i18n("Filename"); i18n("Imagesize"); i18n("Dimension"); i18n("Thumbnail"); - - - /** - * builtin fields - * flag_nr 5 (builtin enabled) - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('description', 1, 5)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('category', 2, 5)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('persons', 2, 5)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('date', 3, 5)"; - /** - * workaround for i18n - * they wouldn't get detected otherwise... - * some are defined in linpha.metadata.php - */ - i18n("Description"); i18n("Category"); i18n("Persons"); i18n("Date"); - - - /** - * image fields - * flag_nr 10 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_filename', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_dimension', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_category', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_persons', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_time_exif', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_stats_views', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_stats_downloads', 0, 10)"; - - - /** - * video fields - * flag_nr 11 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('??', 0, 11)"; - - /** - * album fields - * flag_nr 12 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_time_add', 0, 12)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_stats_numbers', 0, 12)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 12)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_persons', 0, 12)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_first_comment', 0, 12)"; - - - /** - * thumbnails fields - * flag_nr 13 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 13)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_filename', 0, 13)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 13)"; - - /** - * thumbnails in detail view fields - * flag_nr 14 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_filename', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_dimension', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('exif_datetimeoriginal', 0, 14)"; - - /** - * slideshow fields - * flag_nr 15 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_filename', 0, 15)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 15)"; - -?> - Modified: trunk/linpha2/install/step11_finish.php =================================================================== --- trunk/linpha2/install/step11_finish.php 2007-11-06 17:20:31 UTC (rev 4781) +++ trunk/linpha2/install/step11_finish.php 2007-11-06 18:01:42 UTC (rev 4782) @@ -192,6 +192,12 @@ echo "<br /><br /><hr /><br />"; echo "<h2>".i18n_install("Congratulations")."</h2><br />"; echo i18n_install("Installation Finished!"); + +if($_POST['sys_public_installation']) +{ + echo "<b><br>".i18n_install("For security reasons you have to remove the /install directory before continuing!")."</b>"; +} + ?> <script language="JavaScript" type='text/javascript'> <!-- @@ -202,4 +208,4 @@ session_destroy(); include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file +?> Modified: trunk/linpha2/lib/include/integrity.php =================================================================== --- trunk/linpha2/lib/include/integrity.php 2007-11-06 17:20:31 UTC (rev 4781) +++ trunk/linpha2/lib/include/integrity.php 2007-11-06 18:01:42 UTC (rev 4782) @@ -30,12 +30,16 @@ * check folders */ $folders = array("install", "album", "tmp", "cache"); + $install_type_public = $GLOBALS['linpha']->sql->config->value['sys_public_installation']; foreach($folders AS $directory) { $dir = LinSql::getPath($directory); - - if( $directory == "install" && file_exists($dir) ) + + /** + * Install directory check only on public installation + */ + if( $directory == "install" && file_exists($dir) && $install_type_public == true) { throw new Exception(i18n("For security reasons, the LinPHA $dir " . "directory needs to be removed!")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-11-07 17:56:56
|
Revision: 4784 http://linpha.svn.sourceforge.net/linpha/?rev=4784&view=rev Author: bzrudi Date: 2007-11-07 09:56:52 -0800 (Wed, 07 Nov 2007) Log Message: ----------- "Security fixes" Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/lib.install.php trunk/linpha2/install/step10_postsettings.php trunk/linpha2/install/step11_finish.php trunk/linpha2/install/step1_license.php trunk/linpha2/install/step2_requirements.php trunk/linpha2/install/step3_dbtype.php trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step6_selectdatabase.php trunk/linpha2/install/step7_selectprefix.php trunk/linpha2/install/step8_testing.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/include/sql.data.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/ChangeLog 2007-11-07 17:56:52 UTC (rev 4784) @@ -1,3 +1,8 @@ +2007-12-06 bzrudi + * Installer: create random folder names for /cache and /tmp directory to + prevent direct access to image cache (security). + * linpha.log is now created as something like linpha-xH6gHH.log (security) + 2007-11-06 bzrudi * moved sql.data.php out of install folder into /lib/include to make sure we can delete /install folder after installation. Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/lib.install.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -419,4 +419,5 @@ } -?> \ No newline at end of file +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/install/step10_postsettings.php =================================================================== --- trunk/linpha2/install/step10_postsettings.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step10_postsettings.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -80,15 +80,15 @@ <?php echo "<h2>".i18n_install("Please Choose LinPHA2 Install Location")."</h2><hr>"; -echo i18n_install("Internet - Public Available Over The Internet.")."<br />"; -echo i18n_install("Intranet - Running In A Secure Local Network")."<br /><br />"; +echo i18n_install("<b>Internet</b> - Public Available Over The Internet.")."<br />"; +echo i18n_install("<b>Intranet</b> - Running In A Secure Local Network")."<br /><br />"; ?> <div align="center"> <div class="box4"> <input type='radio' name='sys_public_installation' value='1' checked=checked> - <?php echo i18n_install("Internet"); ?> + <?php echo i18n_install("<b>Internet</b>"); ?> <input type='radio' name='sys_public_installation' value='0' > - <?php echo i18n_install("Intranet"); ?> + <?php echo i18n_install("<b>Intranet</b>"); ?> </div> </div> @@ -182,4 +182,5 @@ ); $do_javascript_disable_button = true; include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/install/step11_finish.php =================================================================== --- trunk/linpha2/install/step11_finish.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step11_finish.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -195,7 +195,7 @@ if($_POST['sys_public_installation']) { - echo "<b><br>".i18n_install("For security reasons you have to remove the /install directory before continuing!")."</b>"; + echo "<span style='color: red;'><b><br />".i18n_install("For security reasons you have to remove the /install directory before continuing!")."</b></span>"; } ?> @@ -208,4 +208,6 @@ session_destroy(); include_once(LINPHA_DIR.'/install/footer.php'); + +/* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/install/step1_license.php =================================================================== --- trunk/linpha2/install/step1_license.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step1_license.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -38,4 +38,6 @@ $array_check = array('check01' => 'checkbox'); $do_javascript_disable_button = true; include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file + +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/install/step2_requirements.php =================================================================== --- trunk/linpha2/install/step2_requirements.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step2_requirements.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -410,7 +410,7 @@ /** * checking album and var folder are protected from outside */ - print_line_left( i18n_install("Album And System Folder Protected From Outside") ); + print_line_left( i18n_install("Album Folder Protection") ); $ret = installCheckProtectedFromOutside(); if( $ret == 1 ) @@ -418,7 +418,7 @@ print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); print_line_info( - i18n_install("The /albums and /var folders are protected from outside."). + i18n_install("The /albums folder is protected from outside."). i18n_install("Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details.") ); } @@ -427,7 +427,7 @@ print_line_middle( i18n_install("No") ); print_line_right(warning_msg()); print_line_info( - i18n_install("The /albums and /var folders are not protected from outside!"). + i18n_install("The /albums folder is not protected from outside!"). i18n_install("Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details.") ); } @@ -436,7 +436,7 @@ print_line_middle( i18n_install("Unknown") ); print_line_right(warning_msg()); print_line_info( - i18n_install("Cannot determine wether the /albums and /var folders are protected from outside!"). + i18n_install("Cannot determine wether the /albums folder is protected from outside!"). i18n_install("Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\" target=\"_blank\">here</a> for more details.") ); } @@ -533,4 +533,6 @@ </div> <?php } + +/* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/install/step3_dbtype.php =================================================================== --- trunk/linpha2/install/step3_dbtype.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step3_dbtype.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -133,4 +133,6 @@ <?php include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file + +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step4_selectdirectories.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -28,8 +28,8 @@ $album_dir = (isset($_SESSION['album_dir']) ? $_SESSION['album_dir'] : 'albums'); $sql_dir = (isset($_SESSION['sql_dir']) ? $_SESSION['sql_dir'] : 'var/sql'); -$cache_dir = (isset($_SESSION['cache_dir']) ? $_SESSION['cache_dir'] : 'var/cache'); -$tmp_dir = (isset($_SESSION['tmp_dir']) ? $_SESSION['tmp_dir'] : 'var/tmp'); +$cache_dir = (isset($_SESSION['cache_dir']) ? $_SESSION['cache_dir'] : 'var/'.random_password(12)); +$tmp_dir = (isset($_SESSION['tmp_dir']) ? $_SESSION['tmp_dir'] : 'var/'.random_password(12)); /** @@ -74,7 +74,7 @@ <br /><br /> <br /> -<h2 style="color: red;"><?php echo i18n_install("Warning: All Directories Below Will Be Deleted If Exists !"); ?></h2><hr> +<h2 style="color: red;"><?php echo i18n_install("Note: For security reasons folder names were named random!"); ?></h2><hr> <br /> <div class="boxalign"> @@ -113,4 +113,6 @@ ); $do_javascript_disable_button = true; include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file + +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step5_getlogin.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -147,4 +147,6 @@ $do_javascript_disable_button = true; include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file + +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/install/step6_selectdatabase.php =================================================================== --- trunk/linpha2/install/step6_selectdatabase.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step6_selectdatabase.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -60,10 +60,12 @@ } + echo "<h1>".i18n_install("Testing Server Connection")."</h1><hr /><br />"; + switch($_SESSION['sql_dbtype']) { case "mysql": - echo i18n_install("Testing Server Connection")."<br /><br />"; + echo i18n_install("Connecting MySQL-Server... "); $link = @mysql_connect($_SESSION['sql_hostname'].":".$_SESSION['sql_dbport'], @@ -104,6 +106,9 @@ case "oci8po": $_SESSION['allowed_to_create_db'] = false; break; +default: + $_SESSION['allowed_to_create_db'] = false; +break; // case "sqlite": sqlite goes directly to stage8 } @@ -232,4 +237,6 @@ } include_once(LINPHA_DIR.'/install/footer.php'); + +/* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/install/step7_selectprefix.php =================================================================== --- trunk/linpha2/install/step7_selectprefix.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step7_selectprefix.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -223,4 +223,6 @@ } include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file + +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/install/step8_testing.php =================================================================== --- trunk/linpha2/install/step8_testing.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step8_testing.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -307,4 +307,6 @@ echo '<br /><br />'; include_once(LINPHA_DIR.'/install/footer.php'); -?> \ No newline at end of file + +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/install/step9_createtables.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -233,4 +233,6 @@ } include_once(LINPHA_DIR.'/install/footer.php'); + +/* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/lib/classes/linpha.functions.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -910,4 +910,32 @@ return $accept_lang; } -?> \ No newline at end of file +/** + * generates a random string/password in given length + * @author bzrudi + * @param int length of random string to generate + * @return string random string + * @package functions + + */ +function random_string($len) +{ + $pass = ''; + $lchar = 0; + $char = 0; + for($i = 0; $i < $len; $i++) + { + while($char == $lchar) + { + $char = rand(48, 109); + if($char > 57) $char += 7; + if($char > 90) $char += 6; + } + $pass .= chr($char); + $lchar = $char; + } + return $pass; +} + +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/lib/include/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql.data.php 2007-11-06 18:05:36 UTC (rev 4783) +++ trunk/linpha2/lib/include/sql.data.php 2007-11-07 17:56:52 UTC (rev 4784) @@ -98,7 +98,7 @@ 'sys_user_autologin' => '1', - 'plugins_log_filename' => 'var/linpha.log', + 'plugins_log_filename' => 'var/linpha-'.random_string(6).'log', 'plugins_log_syslog_enable' => '0', 'plugins_log_syslog_add_events' => '', 'plugins_log_email_enable' => '0', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-11-10 16:19:48
|
Revision: 4794 http://linpha.svn.sourceforge.net/linpha/?rev=4794&view=rev Author: bzrudi Date: 2007-11-10 08:19:35 -0800 (Sat, 10 Nov 2007) Log Message: ----------- "fixed a couple if errors " Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/maintenance_import.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-11-10 15:50:29 UTC (rev 4793) +++ trunk/linpha2/ChangeLog 2007-11-10 16:19:35 UTC (rev 4794) @@ -1,3 +1,7 @@ +2007-11-10 bzrudi + * bump exiftool to latest 7.00 stable release + * fixed a couple of issues in installer and maintenance_import.php + 2007-11-08 bzrudi * more security related stuff Modified: trunk/linpha2/admin/maintenance_import.php =================================================================== --- trunk/linpha2/admin/maintenance_import.php 2007-11-10 15:50:29 UTC (rev 4793) +++ trunk/linpha2/admin/maintenance_import.php 2007-11-10 16:19:35 UTC (rev 4794) @@ -126,7 +126,7 @@ if($_REQUEST['index_thumbnails']!='no') { echo '<h3>'.i18n("Parsing All Directories...").'</h3><br />'; - $createthumbquery = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); + $createthumbquery = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos WHERE img_type <> '0' AND img_type <> '9999999'"); } } else // $all_albums == false -> not all directory selected @@ -139,9 +139,9 @@ $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".LIN_PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; - $sql = "SELECT id FROM ".LIN_PREFIX."photos WHERE " . + $sql = "SELECT id, img_type FROM ".LIN_PREFIX."photos WHERE " . "parent_id = '".LinSql::linAddslashes($value)."' AND " . - "img_type <> 0 AND img_type <> 9999999"; + "img_type <> '0' AND img_type <> '9999999' "; /** * delete thumbnails @@ -152,7 +152,7 @@ $query = $GLOBALS['linpha']->db->Execute($sql); while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - if( LinImage::deleteCachedThumbnail($data[0]) ) + if( LinImage::deleteCachedThumbnail($data[0], $data[1])) { echo " ".$data[0].","; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2007-11-18 22:20:11
|
Revision: 4799 http://linpha.svn.sourceforge.net/linpha/?rev=4799&view=rev Author: fangehrn Date: 2007-11-18 14:20:05 -0800 (Sun, 18 Nov 2007) Log Message: ----------- 2007-11-18 flo * installer - some UI improvements - added sys_public_installation to sql.data.php and update it only in step10_postsettings.php like the other settings * integrity.php fixed bug and readded bypass for install check with install/ignore_delete_install_msg.txt * created global class for inline popups - updated scriptaculous (1.8.0) and prototype (1.6.0) * maps plugin - fixed some annoying IE bugs (edit marker not working, ajax data not working) - using inline popup for help window Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/docs/dev/external_libraries.txt trunk/linpha2/install/ignore_delete_install_msg.txt trunk/linpha2/install/step10_postsettings.php trunk/linpha2/install/step11_finish.php trunk/linpha2/install/step3_dbtype.php trunk/linpha2/lib/include/integrity.php trunk/linpha2/lib/include/sql.data.php trunk/linpha2/lib/js/LinGlobal.js trunk/linpha2/lib/js/builder.js trunk/linpha2/lib/js/controls.js trunk/linpha2/lib/js/dragdrop.js trunk/linpha2/lib/js/effects.js trunk/linpha2/lib/js/prototype.js trunk/linpha2/lib/js/scriptaculous.js trunk/linpha2/lib/js/slider.js trunk/linpha2/lib/js/unittest.js trunk/linpha2/lib/plugins/maps/LinMaps.js trunk/linpha2/lib/plugins/maps/class.googlemaps.js trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/templates/default/maps.html.php trunk/linpha2/templates/default/themes/default/css/global.css Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/ChangeLog 2007-11-18 22:20:05 UTC (rev 4799) @@ -1,3 +1,16 @@ +2007-11-18 flo + * installer + - some UI improvements + - added sys_public_installation to sql.data.php and update it + only in step10_postsettings.php like the other settings + * integrity.php fixed bug and readded bypass for install check with + install/ignore_delete_install_msg.txt + * created global class for inline popups + - updated scriptaculous (1.8.0) and prototype (1.6.0) + * maps plugin + - fixed some annoying IE bugs (edit marker not working, ajax data not working) + - using inline popup for help window + 2007-11-10 bzrudi * bump exiftool to latest 7.00 stable release * fixed a couple of issues in installer and maintenance_import.php Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/docs/dev/TODO.txt 2007-11-18 22:20:05 UTC (rev 4799) @@ -24,7 +24,7 @@ - should enable browsers cache for the thumbnails and maybe also for the images -- fix error handler +- fix (adodb) error handler ## Big Todos Modified: trunk/linpha2/docs/dev/external_libraries.txt =================================================================== --- trunk/linpha2/docs/dev/external_libraries.txt 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/docs/dev/external_libraries.txt 2007-11-18 22:20:05 UTC (rev 4799) @@ -1,8 +1,8 @@ - csshover.htc V1.42.060206 -- scriptaculous 1.6.4 (contains prototype) -- prototype 1.5.0_rc1 +- scriptaculous 1.8.0 (contains prototype) +- prototype 1.6.0 - adodb Modified: trunk/linpha2/install/ignore_delete_install_msg.txt =================================================================== --- trunk/linpha2/install/ignore_delete_install_msg.txt 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/install/ignore_delete_install_msg.txt 2007-11-18 22:20:05 UTC (rev 4799) @@ -0,0 +1,2 @@ +If this file exists, the check for existing ./install directory is ignored. +This file must be remove in official releases. \ No newline at end of file Modified: trunk/linpha2/install/step10_postsettings.php =================================================================== --- trunk/linpha2/install/step10_postsettings.php 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/install/step10_postsettings.php 2007-11-18 22:20:05 UTC (rev 4799) @@ -85,10 +85,10 @@ ?> <div align="center"> <div class="box4"> - <input type='radio' name='sys_public_installation' value='1' checked=checked> - <?php echo i18n_install("<b>Internet</b>"); ?> - <input type='radio' name='sys_public_installation' value='0' > - <?php echo i18n_install("<b>Intranet</b>"); ?> + <input type='radio' id='linInputTypeInternet' name='sys_public_installation' value='1' checked=checked><label for="linInputTypeInternet"> + <?php echo i18n_install("<b>Internet</b>"); ?></label> + <input type='radio' id='linInputTypeIntranet' name='sys_public_installation' value='0' ><label for="linInputTypeIntranet"> + <?php echo i18n_install("<b>Intranet</b>"); ?></label> </div> </div> @@ -105,13 +105,13 @@ ?> <div align="center"> <div class="box2"> - <input type='radio' name='quality' value='1'>High Quality<br /> - <img src='./graphics/hqdemo.jpg' width="120" height="90" border="0""> + <input type='radio' id='linInputQualityHigh' name='quality' value='1'><label for="linInputQualityHigh">High Quality<br /> + <img src='./graphics/hqdemo.jpg' width="120" height="90" border="0""></label> </div> <div class="box2" style="float: none; "> - <input type='radio' name='quality' value='0' checked>Low Quality<br /> - <img src='./graphics/lqdemo.jpg' width="120" height="90" border="0""> + <input type='radio' id='linInputQualityLow' name='quality' value='0' checked><label for="linInputQualityLow">Low Quality<br /> + <img src='./graphics/lqdemo.jpg' width="120" height="90" border="0""></label> </div> </div> <?php @@ -126,21 +126,21 @@ <div align="center"> <div class="box3"> - <input type='radio' name='sys_style_tn_size' value='90'> + <input type='radio' id='linInputTNSize90' name='sys_style_tn_size' value='90'><label for="linInputTNSize90"> 90 pixel<br /> - <img src='./graphics/thumb90px.jpg' /> + <img src='./graphics/thumb90px.jpg' /></label> </div> <div class="box3"> - <input type='radio' name='sys_style_tn_size' value='120' checked="checked"> + <input type='radio' id='linInputTNSize120' name='sys_style_tn_size' value='120' checked="checked"><label for="linInputTNSize120"> 120 pixel<br /> - <img src='./graphics/thumb120px.jpg' /> + <img src='./graphics/thumb120px.jpg' /></label> </div> <div class="box3"> - <input type='radio' name='sys_style_tn_size' value='150'> + <input type='radio' id='linInputTNSize150' name='sys_style_tn_size' value='150'><label for="linInputTNSize150"> 150 pixel<br /> - <img src='./graphics/thumb150px.jpg'> + <img src='./graphics/thumb150px.jpg'></label> </div> </div> <br /> @@ -154,18 +154,18 @@ ?> <div align="center"> <div class="box4"> - <input type='radio' name='sys_import_use_exiftool' value='1'> + <input type='radio' id='linInputExifToolYes' name='sys_import_use_exiftool' value='1'><label for="linInputExifToolYes"> <?php echo i18n_install("Yes"); ?> - <input type='radio' name='sys_import_use_exiftool' value='0' checked=checked> + <input type='radio' id='linInputExifToolNo' name='sys_import_use_exiftool' value='0' checked=checked><label for="linInputExifToolNo"> <?php echo i18n_install("No"); ?> <?php echo i18n_install("Enable Exiftool"); ?> </div> <div class="box4"> - <input type='radio' name='sys_import_use_emb_thumb' value='1'> + <input type='radio' id='linInputEmbTNYes' name='sys_import_use_emb_thumb' value='1'><label for="linInputEmbTNYes"> <?php echo i18n_install("Yes"); ?> - <input type='radio' name='sys_import_use_emb_thumb' value='0' checked=checked> + <input type='radio' id='linInputEmbTNNo' name='sys_import_use_emb_thumb' value='0' checked=checked><label for="linInputEmbTNNo"> <?php echo i18n_install("No"); ?> <?php echo i18n_install("Extract Embedded Thumbnails"); ?> Modified: trunk/linpha2/install/step11_finish.php =================================================================== --- trunk/linpha2/install/step11_finish.php 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/install/step11_finish.php 2007-11-18 22:20:05 UTC (rev 4799) @@ -86,10 +86,9 @@ echo "<br />".i18n_install("Saving Install Type (Internet/Intranet) To Database...").' '; if( isset( $_POST['sys_public_installation'] ) ) { - $result = $linpha->db->Execute("INSERT INTO ".LIN_PREFIX."config " . - "(option_value, option_name) VALUES (" . - "'".LinSql::linAddslashes($_POST['sys_public_installation'])."', " . - "'".LinSql::linAddslashes('sys_public_installation')."')"); + $result = $linpha->db->Execute("UPDATE ".LIN_PREFIX."config " . + "SET option_value = '".LinSql::linAddslashes($_POST['sys_public_installation'])."' " . + "WHERE option_name = 'sys_public_installation'"); if(!$result) { echo failed_msg(); @@ -102,7 +101,7 @@ else { echo failed_msg(); - echo "<br />".i18n_install("Error - No Value Specified!"); + echo "<br />".i18n_install("Error: No Value Specified!"); $error_nr = 1; } @@ -115,20 +114,25 @@ $result = $linpha->db->Execute("UPDATE ".LIN_PREFIX."config " . "SET option_value = '".LinSql::linAddslashes($_POST['sys_style_tn_size'])."' " . "WHERE option_name = 'sys_style_thumb_size_max'"); - if(!$result) - { + if(!$result) { echo failed_msg(); + $error_nr = 1; } else { - $result = $linpha->db->Execute("UPDATE ".LIN_PREFIX."config " . + $result = $linpha->db->Execute("UPDATE ".LIN_PREFIX."config " . "SET option_value = '".LinSql::linAddslashes($_POST['sys_style_tn_size'])."' " . "WHERE option_name = 'sys_style_thumb_size_display'"); - echo success_msg(); + if(!$result) { + echo failed_msg(); + $error_nr = 1; + } else { + echo success_msg(); + } } } else { echo failed_msg(); - echo "<br />".i18n_install("Error - No Value Specified!"); + echo "<br />".i18n_install("Error: No Value Specified!"); $error_nr = 1; } Modified: trunk/linpha2/install/step3_dbtype.php =================================================================== --- trunk/linpha2/install/step3_dbtype.php 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/install/step3_dbtype.php 2007-11-18 22:20:05 UTC (rev 4799) @@ -125,11 +125,13 @@ <br /><br /> <h1><?php echo i18n_install("Select Installation Mode"); ?></h1><hr> -<input type='radio' name='install_mode' value='automatic' checked="checked"> -<?php echo i18n_install("Automatic mode"); ?> +<input type='radio' id='linInputModeAutomatic' name='install_mode' value='automatic' checked="checked"><?php +/* no linebreak between <input> and <label> tag */ ?><label for="linInputModeAutomatic"> +<?php echo i18n_install("Automatic mode"); ?></label> <br /> -<input type='radio' name='install_mode' value='manual'> -<?php echo i18n_install("Manual Mode (Experts Only)"); ?> +<input type='radio' id='linInputModeManual' name='install_mode' value='manual'><?php +/* no linebreak between <input> and <label> tag */ ?><label for="linInputModeManual"> +<?php echo i18n_install("Manual Mode (Experts Only)"); ?></label> <?php include_once(LINPHA_DIR.'/install/footer.php'); Modified: trunk/linpha2/lib/include/integrity.php =================================================================== --- trunk/linpha2/lib/include/integrity.php 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/lib/include/integrity.php 2007-11-18 22:20:05 UTC (rev 4799) @@ -29,46 +29,34 @@ /** * check folders */ - $folders = array("install", "album", "tmp", "cache"); - $install_type_public = $GLOBALS['linpha']->sql->config->value['sys_public_installation']; + /** + * Install directory check only on public installation + */ + $dir = LinSql::getPath('install'); + if( !file_exists($dir.'/ignore_delete_install_msg.txt') && file_exists($dir) && + $GLOBALS['linpha']->sql->config->value['sys_public_installation'] == true) + { + throw new Exception(i18n("For security reasons, the LinPHA ./install directory needs to be removed!")); + } - foreach($folders AS $directory) + $folders = array("album", "tmp", "cache"); + foreach($folders as $directory) { - $dir = LinSql::getPath($directory); - - /** - * Install directory check only on public installation - */ - if( $directory == "install" && file_exists($dir) && $install_type_public == true) - { - throw new Exception(i18n("For security reasons, the LinPHA $dir " . - "directory needs to be removed!")); - break; - } - else - { - break; - } + $dir = LinSql::getPath($directory); if( ! file_exists($dir) ) { - throw new Exception(i18n("Directory ".$dir." doesn't exist - " . - "Please make sure to create directory manually.")); - break; + throw new Exception( getErrorMsg(1,$dir)); } - if( ! is_writable($dir) && $directory != "album") + if( ! is_readable($dir) ) { - throw new Exception(i18n("Directory ".$dir." is not writable - " . - "Please change write permissions manually.")); - break; + throw new Exception( getErrorMsg(2,$dir)); } - - if( ! is_readable($dir) ) + + if( ! is_writable($dir) && $directory != "album") { - throw new Exception(i18n("Directory ".$dir." is not readable - " . - "Please change read permissions manually")); - break; + throw new Exception( getErrorMsg(3,$dir)); } } } @@ -77,5 +65,26 @@ die("Error: ".$error -> getMessage()); } +function getErrorMsg($type,$dir) { + switch($type) + { + case 1: + // Do not break strings inside i18n() function. + // Language translation would not work anymore! + return sprintf(i18n("Directory %s doesn't exist - Please make sure to create directory manually."),$dir); + break; + case 2: + // Do not break strings inside i18n() function. + // Language translation would not work anymore! + return sprintf(i18n("Directory %s is not readable - Please change read permissions manually"),$dir); + break; + case 3: + // Do not break strings inside i18n() function. + // Language translation would not work anymore! + return sprintf(i18n("Directory %s is not writable - Please change write permissions manually."),$dir); + break; + } +} + /* vi: set ts=4 sw=4 sts=4 */ -?> +?> \ No newline at end of file Modified: trunk/linpha2/lib/include/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql.data.php 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/lib/include/sql.data.php 2007-11-18 22:20:05 UTC (rev 4799) @@ -27,6 +27,7 @@ */ $options = array( 'sys_db_version' => '3', + 'sys_public_installation' => '1', 'sys_im_bracket_support' => $_SESSION['sys_im_bracket_support'], 'sys_im_imagemagick_path' => $_SESSION['sys_im_convert_path'], Modified: trunk/linpha2/lib/js/LinGlobal.js =================================================================== --- trunk/linpha2/lib/js/LinGlobal.js 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/lib/js/LinGlobal.js 2007-11-18 22:20:05 UTC (rev 4799) @@ -21,6 +21,8 @@ this.linPageYOffset = 0; this.tabs = new Array(); + + this.nofPopups = 0; }, /** @@ -231,7 +233,42 @@ //this.tabs[ className ][ tabNr ] = ''; //this.tabs.className.tabNr = ''; $(elemAId).style.color = ''; + }, + + /** + * popup functions + */ + createPopup: function( elemId ) { + this.divPopupWindow = Builder.node('div', {id: 'linPopup'+this.nofPopups, className: 'linPopupWindow'} ); + + var divClose = Builder.node('div', {className: 'linPopupClose'}); + var divCloseButton = Builder.node('input', {type: 'button', value: 'X', + onclick: 'myLinGlobal.closePopup(\'linPopup'+this.nofPopups+'\')', className: 'linPopupCloseButton'}); + divClose.appendChild(divCloseButton); + + var divTitleBar = Builder.node('div', {className: 'linPopupTitleBar'} ); + divTitleBar.appendChild(divClose); + + + var divText = $(elemId).cloneNode(true); + divText.className = 'linPopupText'; + Element.show(divText); + + this.divPopupWindow.appendChild(divTitleBar); + this.divPopupWindow.appendChild(divText); + + document.body.appendChild(this.divPopupWindow); + + new Draggable(this.divPopupWindow, {handle: 'linPopupTitleBar'}); + + this.nofPopups++; + }, + closePopup: function(elemId) { + document.body.removeChild($(elemId)); } + + + // no comma at last function. firefox works, but IE not! } /** Modified: trunk/linpha2/lib/js/builder.js =================================================================== --- trunk/linpha2/lib/js/builder.js 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/lib/js/builder.js 2007-11-18 22:20:05 UTC (rev 4799) @@ -1,8 +1,9 @@ -// script.aculo.us builder.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006 +// script.aculo.us builder.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007 -// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // -// See scriptaculous.js for full license. +// script.aculo.us is freely distributable under the terms of an MIT-style license. +// For details, see the script.aculo.us web site: http://script.aculo.us/ var Builder = { NODEMAP: { @@ -35,7 +36,7 @@ var element = parentElement.firstChild || null; // see if browser added wrapping tags - if(element && (element.tagName != elementName)) + if(element && (element.tagName.toUpperCase() != elementName)) element = element.getElementsByTagName(elementName)[0]; // fallback to createElement approach @@ -47,7 +48,8 @@ // attributes (or text) if(arguments[1]) if(this._isStringOrNumber(arguments[1]) || - (arguments[1] instanceof Array)) { + (arguments[1] instanceof Array) || + arguments[1].tagName) { this._children(element, arguments[1]); } else { var attrs = this._attributes(arguments[1]); @@ -63,9 +65,9 @@ for(attr in arguments[1]) element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; } - if(element.tagName != elementName) + if(element.tagName.toUpperCase() != elementName) element = parentElement.getElementsByTagName(elementName)[0]; - } + } } // text, or array of children @@ -77,14 +79,24 @@ _text: function(text) { return document.createTextNode(text); }, + + ATTR_MAP: { + 'className': 'class', + 'htmlFor': 'for' + }, + _attributes: function(attributes) { var attrs = []; for(attribute in attributes) - attrs.push((attribute=='className' ? 'class' : attribute) + - '="' + attributes[attribute].toString().escapeHTML() + '"'); + attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + + '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'"') + '"'); return attrs.join(" "); }, _children: function(element, children) { + if(children.tagName) { + element.appendChild(children); + return; + } if(typeof children=='object') { // array can hold nodes and text children.flatten().each( function(e) { if(typeof e=='object') @@ -94,12 +106,17 @@ element.appendChild(Builder._text(e)); }); } else - if(Builder._isStringOrNumber(children)) - element.appendChild(Builder._text(children)); + if(Builder._isStringOrNumber(children)) + element.appendChild(Builder._text(children)); }, _isStringOrNumber: function(param) { return(typeof param=='string' || typeof param=='number'); }, + build: function(html) { + var element = this.node('div'); + $(element).update(html.strip()); + return element.down(); + }, dump: function(scope) { if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope @@ -116,4 +133,4 @@ } }); } -} \ No newline at end of file +} Modified: trunk/linpha2/lib/js/controls.js =================================================================== --- trunk/linpha2/lib/js/controls.js 2007-11-11 09:48:23 UTC (rev 4798) +++ trunk/linpha2/lib/js/controls.js 2007-11-18 22:20:05 UTC (rev 4799) @@ -1,14 +1,15 @@ -// script.aculo.us controls.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006 +// script.aculo.us controls.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007 -// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) -// (c) 2005 Jon Tirsen (http://www.tirsen.com) +// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan) +// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com) // Contributors: // Richard Livsey // Rahul Bhargava // Rob Wills // -// See scriptaculous.js for full license. +// script.aculo.us is freely distributable under the terms of an MIT-style license. +// For details, see the script.aculo.us web site: http://script.aculo.us/ // Autocompleter.Base handles all the autocompletion functionality // that's independent of the data source for autocompletion. This @@ -38,22 +39,23 @@ if(typeof Effect == 'undefined') throw("controls.js requires including script.aculo.us' effects.js library"); -var Autocompleter = {} -Autocompleter.Base = function() {}; -Autocompleter.Base.prototype = { +var Autocompleter = { } +Autocompleter.Base = Class.create({ baseInitialize: function(element, update, options) { - this.element = $(element); + element = $(element) + this.element = element; this.update = $(update); this.hasFocus = false; this.changed = false; this.active = false; this.index = 0; this.entryCount = 0; + this.oldElementValue = this.element.value; if(this.setOptions) this.setOptions(options); else - this.options = options || {}; + this.options = options || { }; this.options.paramName = this.options.paramName || this.element.name; this.options.tokens = this.options.tokens || []; @@ -75,6 +77,9 @@ if(typeof(this.options.tokens) == 'string') this.options.tokens = new Array(this.options.tokens); + // Force carriage returns as token delimiters anyway + if (!this.options.tokens.include('\n')) + this.options.tokens.push('\n'); this.observer = null; @@ -82,15 +87,14 @@ Element.hide(this.update); - Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); - Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); + Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this)); + Event.observe(this.element, 'keypress', this.onKeyPress.bindAsEventListener(this)); }, show: function() { if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); if(!this.iefix && - (navigator.appVersion.indexOf('MSIE')>0) && - (navigator.userAgent.indexOf('Opera')<0) && + (Prototype.Browser.IE) && (Element.getStyle(this.update, 'position')=='absolute')) { new Insertion.After(this.update, '<iframe id="' + this.update.id + '_iefix" '+ @@ -140,17 +144,17 @@ case Event.KEY_UP: this.markPrevious(); this.render(); - if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); + if(Prototype.Browser.WebKit) Event.stop(event); return; case Event.KEY_DOWN: this.markNext(); this.render(); - if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); + if(Prototype.Browser.WebKit) Event.stop(event); return; } else if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || - (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return; + (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return; this.changed = true; this.hasFocus = true; @@ -196,7 +200,6 @@ this.index==i ? Element.addClassName(this.getEntry(i),"selected") : Element.removeClassName(this.getEntry(i),"selected"); - if(this.hasFocus) { this.show(); this.active = true; @@ -239,21 +242,22 @@ } var value = ''; if (this.options.select) { - var nodes = document.getElementsByClassName(this.options.select, selectedElement) || []; + var nodes = $(selectedElement).select('.' + this.options.select) || []; if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select); } else value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); - var lastTokenPos = this.findLastToken(); - if (lastTokenPos != -1) { - var newValue = this.element.value.substr(0, lastTokenPos + 1); - var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); + var bounds = this.getTokenBounds(); + if (bounds[0] != -1) { + var newValue = this.element.value.substr(0, bounds[0]); + var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/); if (whitespace) newValue += whitespace[0]; - this.element.value = newValue + value; + this.element.value = newValue + value + this.element.value.substr(bounds[1]); } else { this.element.value = value; } + this.oldElementValue = this.element.value; this.element.focus(); if (this.options.afterUpdateElement) @@ -264,11 +268,11 @@ if(!this.changed && this.hasFocus) { this.update.innerHTML = choices; Element.cleanWhitespace(this.update); - Element.cleanWhitespace(this.update.firstChild); + Element.cleanWhitespace(this.update.down()); - if(this.update.firstChild && this.update.firstChild.childNodes) { + if(this.update.firstChild && this.update.down().childNodes) { this.entryCount = - this.update.firstChild.childNodes.length; + this.update.down().childNodes.length; for (var i = 0; i < this.entryCount; i++) { var entry = this.getEntry(i); entry.autocompleteIndex = i; @@ -297,39 +301,48 @@ onObserverEvent: function() { this.changed = false; + this.tokenBounds = null; if(this.getToken().length>=this.options.minChars) { - this.startIndicator(); this.getUpdatedChoices(); } else { this.active = false; this.hide(); } + this.oldElementValue = this.element.value; }, getToken: function() { - var tokenPos = this.findLastToken(); - if (tokenPos != -1) - var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,''); - else - var ret = this.element.value; - - return /\n/.test(ret) ? '' : ret; + var bounds = this.getTokenBounds(); + return this.element.value.substring(bounds[0], bounds[1]).strip(); }, - findLastToken: function() { - var lastTokenPos = -1; - - for (var i=0; i<this.options.tokens.length; i++) { - var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]); - if (thisTokenPos > lastTokenPos) - lastTokenPos = thisTokenPos; + getTokenBounds: function() { + if (null != this.tokenBounds) return this.tokenBounds; + var value = this.element.value; + if (value.strip().empty()) return [-1, 0]; + var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue); + var offset = (diff == this.oldElementValue.length ? 1 : 0); + var prevTokenPos = -1, nextTokenPos = value.length; + var tp; + for (var index = 0, l = this.options.tokens.length; index < l; ++index) { + tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1); + if (tp > prevTokenPos) prevTokenPos = tp; + tp = value.indexOf(this.options.tokens[index], diff + offset); + if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp; } - return lastTokenPos; + return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]); } -} +}); -Ajax.Autocompleter = Class.create(); -Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { +Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) { + var boundary = Math.min(newS.length, oldS.length); + for (var index = 0; index < boundary; ++index) + if (newS[index] != oldS[index]) + return index; + return boundary; +}; + +Ajax.Autocompleter = Class.create(Autocompleter.Base, { initialize: function(element, update, url, options) { this.baseInitialize(element, update, options); this.options.asynchronous = true; @@ -339,7 +352,9 @@ }, getUpdatedChoices: function() { - entry = encodeURIComponent(this.options.paramName) + '=' + + this.startIndicator(); + + var entry = encodeURIComponent(this.options.paramName) + '=' + encodeURIComponent(this.getToken()); this.options.parameters = this.options.callback ? @@ -347,14 +362,13 @@ if(this.options.defaultParams) this.options.parameters += '&' + this.options.defaultParams; - + new Ajax.Request(this.url, this.options); }, onComplete: function(request) { this.updateChoices(request.responseText); } - }); // The local array autocompleter. Used when you'd prefer to @@ -392,8 +406,7 @@ // In that case, the other options above will not apply unless // you support them. -Autocompleter.Local = Class.create(); -Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), { +Autocompleter.Local = Class.create(Autocompleter.Base, { initialize: function(element, update, array, options) { this.baseInitialize(element, update, options); this.options.array = array; @@ -449,13 +462,12 @@ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length)) return "<ul>" + ret.join('') + "</ul>"; } - }, options || {}); + }, options || { }); } }); -// AJAX in-place editor -// -// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor +// AJAX in-place editor and collection editor +// Full rewrite by Christophe Porteneuve <td...@td...> (April 2007). // Use this if you notice weird scrolling problems on some browsers, // the DOM might be a bit confused when this gets called so do this @@ -466,352 +478,472 @@ }, 1); } -Ajax.InPlaceEditor = Class.create(); -Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99"; -Ajax.InPlaceEditor.prototype = { +Ajax.InPlaceEditor = Class.create({ initialize: function(element, url, options) { this.url = url; - this.element = $(element); - - this.options = Object.extend({ - okButton: true, - okText: "ok", - cancelLink: true, - cancelText: "cancel", - savingText: "Saving...", - clickToEditText: "Click to edit", - okText: "ok", - rows: 1, - onComplete: function(transport, element) { - new Effect.Highlight(element, {startcolor: this.options.highlightcolor}); - }, - onFailure: function(transport) { - alert("Error communicating with the server: " + transport.responseText.stripTags()); - }, - callback: function(form) { - return Form.serialize(form); - }, - handleLineBreaks: true, - loadingText: 'Loading...', - savingClassName: 'inplaceeditor-saving', - loadingClassName: 'inplaceeditor-loading', - formClassName: 'inplaceeditor-form', - highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor, - highlightendcolor: "#FFFFFF", - externalControl: null, - submitOnBlur: false, - ajaxOptions: {}, - evalScripts: false - }, options || {}); - - if(!this.options.formId && this.element.id) { - this.options.formId = this.element.id + "-inplaceeditor"; - if ($(this.options.formId)) { - // there's already a form with that name, don't specify an id - this.options.formId = null; - } + this.element = element = $(element); + this.prepareOptions(); + this._controls = { }; + arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!! + Object.extend(this.options, options || { }); + if (!this.options.formId && this.element.id) { + this.options.formId = this.element.id + '-inplaceeditor'; + if ($(this.options.formId)) + this.options.formId = ''; } - - if (this.options.externalControl) { + if (this.options.externalControl) this.options.externalControl = $(this.options.externalControl); - } - - this.originalBackground = Element.getStyle(this.element, 'background-color'); - if (!this.originalBackground) { - this.originalBackground = "transparent"; - } - + if (!this.options.externalControl) + this.options.externalControlOnly = false; + this._originalBackground = this.element.getStyle('background-color') || 'transparent'; this.element.title = this.options.clickToEditText; - - this.onclickListener = this.enterEditMode.bindAsEventListener(this); - this.mouseoverListener = this.enterHover.bindAsEventListener(this); - this.mouseoutListener = this.leaveHover.bindAsEventListener(this); - Event.observe(this.element, 'click', this.onclickListener); - Event.observe(this.element, 'mouseover', this.mouseoverListener); - Event.observe(this.element, 'mouseout', this.mouseoutListener); - if (this.options.externalControl) { - Event.observe(this.options.externalControl, 'click', this.onclickListener); - Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener); - Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener); - } + this._boundCancelHandler = this.handleFormCancellation.bind(this); + this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this); + this._boundFailureHandler = this.handleAJAXFailure.bind(this); + this._boundSubmitHandler = this.handleFormSubmission.bind(this); + this._boundWrapperHandler = this.wrapUp.bind(this); + this.registerListeners(); }, - enterEditMode: function(evt) { - if (this.saving) return; - if (this.editing) return; - this.editing = true; - this.onEnterEditMode(); - if (this.options.externalControl) { - Element.hide(this.options.externalControl); - } - Element.hide(this.element); - this.createForm(); - this.element.parentNode.insertBefore(this.form, this.element); - if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField); - // stop the event to avoid a page refresh in Safari - if (evt) { - Event.stop(evt); - } - return false; + checkForEscapeOrReturn: function(e) { + if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return; + if (Event.KEY_ESC == e.keyCode) + this.handleFormCancellation(e); + else if (Event.KEY_RETURN == e.keyCode) + this.handleFormSubmission(e); }, - createForm: function() { - this.form = document.createElement("form"); - this.form.id = this.options.formId; - Element.addClassName(this.form, this.options.formClassName) - this.form.onsubmit = this.onSubmit.bind(this); - - this.createEditField(); - - if (this.options.textarea) { - var br = document.createElement("br"); - this.form.appendChild(br); + createControl: function(mode, handler, extraClasses) { + var control = this.options[mode + 'Control']; + var text = this.options[mode + 'Text']; + if ('button' == control) { + var btn = document.createElement('input'); + btn.type = 'submit'; + btn.value = text; + btn.className = 'editor_' + mode + '_button'; + if ('cancel' == mode) + btn.onclick = this._boundCancelHandler; + this._form.appendChild(btn); + this._controls[mode] = btn; + } else if ('link' == control) { + var link = document.createElement('a'); + link.href = '#'; + link.appendChild(document.createTextNode(text)); + link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler; + link.className = 'editor_' + mode + '_link'; + if (extraClasses) + link.className += ' ' + extraClasses; + this._form.appendChild(link); + this._controls[mode] = link; } - - if (this.options.okButton) { - okButton = document.createElement("input"); - okButton.type = "submit"; - okButton.value = this.options.okText; - okButton.className = 'editor_ok_button'; - this.form.appendChild(okButton); - } - - if (this.options.cancelLink) { - cancelLink = document.createElement("a"); - cancelLink.href = "#"; - cancelLink.appendChild(document.createTextNode(this.options.cancelText)); - cancelLink.onclick = this.onclickCancel.bind(this); - cancelLink.className = 'editor_cancel'; - this.form.appendChild(cancelLink); - } }, - hasHTMLLineBreaks: function(string) { - if (!this.options.handleLineBreaks) return false; - return string.match(/<br/i) || string.match(/<p>/i); - }, - convertHTMLLineBreaks: function(string) { - return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, ""); - }, createEditField: function() { - var text; - if(this.options.loadTextURL) { - text = this.options.loadingText; - } else { - text = this.getText(); - } - - var obj = this; - - if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) { - this.options.textarea = false; - var textField = document.createElement("input"); - textField.obj = this; - textField.type = "text"; - textField.name = "value"; - textField.value = text; - textField.style.backgroundColor = this.options.highlightcolor; - textField.className = 'editor_field'; + var text = (this.options.loadTextURL ? this.options.loadingText : this.getText()); + var fld; + if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) { + fld = document.createElement('input'); + fld.type = 'text'; var size = this.options.size || this.options.cols || 0; - if (size != 0) textField.size = size; - if (this.options.submitOnBlur) - textField.onblur = this.onSubmit.bind(this); - this.editField = textField; + if (0 < size) fld.size = size; } else { - this.options.textarea = true; - var textArea = document.createElement("textarea"); - textArea.obj = this; - textArea.name = "value"; - textArea.value = this.convertHTMLLineBreaks(text); - textArea.rows = this.options.rows; - textArea.cols = this.options.cols || 40; - textArea.className = 'editor_field'; - if (this.options.submitOnBlur) - textArea.onblur = this.onSubmit.bind(this); - this.editField = textArea; + fld = document.createElement('textarea'); + fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows); + fld.cols = this.options.cols || 40; } - - if(this.options.loadTextURL) { + fld.name = this.options.paramName; + fld.value = text; // No HTML breaks conversion anymore + fld.className = 'editor_field'; + if (this.options.submitOnBlur) + fld.onblur = this._boundSubmitHandler; + this._controls.editor = fld; + if (this.options.loadTextURL) this.loadExternalText(); - } - this.form.appendChild(this.editField); + this._form.appendChild(this._controls.editor); }, - getText: function() { - return this.element.innerHTML; + createForm: function() { + var ipe = this; + function addText(mode, condition) { + var text = ipe.options['text' + mode + 'Controls']; + if (!text || condition === false) return; + ipe._form.appendChild(document.createTextNode(text)); + }; + this._form = $(document.createElement('form')); + this._form.id = this.options.formId; + this._form.addClassName(this.options.formClassName); + this._form.onsubmit = this._boundSubmitHandler; + this.createEditField(); + if ('textarea' == this._controls.editor.tagName.toLowerCase()) + this._form.appendChild(document.createElement('br')); + if (this.options.onFormCustomization) + this.options.onFormCustomization(this, this._form); + addText('Before', this.options.okControl || this.options.cancelControl); + this.createControl('ok', this._boundSubmitHandler); + addText('Between', this.options.okControl && this.options.cancelControl); + this.createControl('cancel', this._boundCancelHandler, 'editor_cancel'); + addText('After', this.options.okControl || this.options.cancelControl); }, - loadExternalText: function() { - Element.addClassName(this.form, this.options.loadingClassName); - this.editField.disabled = true; - new Ajax.Request( - this.options.loadTextURL, - Object.extend({ - asynchronous: true, - onComplete: this.onLoadedExternalText.bind(this) - }, this.options.ajaxOptions) - ); + destroy: function() { + if (this._oldInnerHTML) + this.element.innerHTML = this._oldInnerHTML; + this.leaveEditMode(); + this.unregisterListeners(); }, - onLoadedExternalText: function(transport) { - Element.removeClassName(this.form, this.options.loadingClassName); - this.editField.disabled = false; - this.editField.value = transport.responseText.stripTags(); - Field.scrollFreeActivate(this.editField); + enterEditMode: function(e) { + if (this._saving || this._editing) return; + this._editing = true; + this.triggerCallback('onEnterEditMode'); + if (this.options.externalControl) + this.options.externalControl.hide(); + this.element.hide(); + this.createForm(); + this.element.parentNode.insertBefore(this._form, this.element); + if (!this.options.loadTextURL) + this.postProcessEditField(); + if (e) Event.stop(e); }, - onclickCancel: function() { - this.onComplete(); - this.leaveEditMode(); - return false; + enterHover: function(e) { + if (this.options.hoverClassName) + this.element.addClassName(this.options.hoverClassName); + if (this._saving) return; + this.triggerCallback('onEnterHover'); }, - onFailure: function(transport) { - this.options.onFailure(transport); - if (this.oldInnerHTML) { - this.element.innerHTML = this.oldInnerHTML; - this.oldInnerHTML = null; + getText: function() { + return this.element.innerHTML; + }, + handleAJAXFailure: function(transport) { + this.triggerCallback('onFailure', transport); + if (this._oldInnerHTML) { + this.element.innerHTML = this._oldInnerHTML; + this._oldInnerHTML = null; } - return false; }, - onSubmit: function() { - // onLoading resets these so we need to save them away for the Ajax call - var form = this.form; - var value = this.editField.value; - - // do this first, sometimes the ajax call returns before we get a chance to switch on Saving... - // which means this will actually switch on Saving... *after* we've left edit mode causing Saving... - // to be displayed indefinitely - this.onLoading(); - - if (this.options.evalScripts) { - new Ajax.Request( - this.url, Object.extend({ - parameters: this.options.callback(form, value), - onComplete: this.onComplete.bind(this), - onFailure: this.onFailure.bind(this), - asynchronous:true, - evalScripts:true - }, this.options.ajaxOptions)); - } else { - new Ajax.Updater( - { success: this.element, - // don't update on failure (this could be an option) - failure: null }, - this.url, Object.extend({ - parameters: this.options.callback(form, value), - onComplete: this.onComplete.bind(this), - onFailure: this.onFailure.bind(this) - }, this.options.ajaxOptions)); + handleFormCancellation: function(e) { + this.wrapUp(); + if (e) Event.stop(e); + }, + handleFormSubmission: function(e) { + var form = this._form; + var value = $F(this._controls.editor); + this.prepareSubmission(); + var params = this.options.callback(form, value) || ''; + if (Object.isString(params)) + params = params.toQueryParams(); + params.editorId = this.element.id; + if (this.options.htmlResponse) { + var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions); + Object.extend(options, { + parameters: params, + onComplete: this._boundWrapperHandler, + onFailure: this._boundFailureHandler + }); + new Ajax.Updater({ success: this.element }, this.url, options); + } else { + var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); + Object.extend(options, { + parameters: params, + onComplete: this._boundWrapperHandler, + onFailure: this._boundFailureHandler + }); + new Ajax.Request(this.url, options); } - // stop the event to avoid a page refresh in Safari - if (arguments.length > 1) { - Event.stop(arguments[0]); - } - return false; + if (e) Event.stop(e); }, - onLoading: function() { - this.saving = true; + leaveEditMode: function() { + this.element.removeClassName(this.options.savingClassName); this.removeForm(); this.leaveHover(); + this.element.style.backgroundColor = this._originalBackground; + this.element.show(); + if (this.options.externalControl) + this.options.externalControl.show(); + this._saving = false; + this._editing = false; + this._oldInnerHTML = null; + this.triggerCallback('onLeaveEditMode'); + }, + leaveHover: function(e) { + if (this.options.hoverClassName) + this.element.removeClassName(this.options.hoverClassName); + if (this._saving) return; + this.triggerCallback('onLeaveHover'); + }, + loadExternalText: function() { + this._form.addClassName(this.options.loadingClassName); + this._controls.editor.disabled = true; + var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); + Object.extend(options, { + parameters: 'editorId=' + encodeURIComponent(this.element.id), + onComplete: Prototype.emptyFunction, + onSuccess: function(transport) { + this._form.removeClassName(this.options.loadingClassName); + var text = transport.responseText; + if (this.options.stripLoadedTextTags) + text = text.stripTags(); + this._controls.editor.value = text; + this._controls.editor.disabled = false; + this.postProcessEditField(); + }.bind(this), + onFailure: this._boundFailureHandler + }); + new Ajax.Request(this.options.loadTextURL, options); + }, + postProcessEditField: function() { + var fpc = this.options.fieldPostCreation; + if (fpc) + $(this._controls.editor)['focus' == fpc ? 'focus' : 'activate'](); + }, + prepareOptions: function() { + this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions); + Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks); + [this._extraDefaultOptions].flatten().compact().each(function(defs) { + Object.extend(this.options, defs); + }.bind(this)); + }, + prepareSubmission: function() { + this._saving = true; + this.removeForm(); + this.leaveHover(); this.showSaving(); }, + registerListeners: function() { + this._listeners = { }; + var listener; + $H(Ajax.InPlaceEditor.Listeners).each(function(pair) { + listener = this[pair.value].bind(this); + this._listeners[pair.key] = listener; + if (!this.options.externalControlOnly) + this.element.observe(pair.key, listener); + if (this.options.externalControl) + this.options.externalControl.observe(pair.key, listener); + }.bind(this)); + }, + removeForm: function() { + if (!this._form) return; + this._form.remove(); + this._form = null; + this._controls = { }; + }, showSaving: function() { - this.oldInnerHTML = this.element.innerHTML; + this._oldInnerHTML = this.element.innerHTML; this.element.innerHTML = this.options.savingText; - Element.addClassName(this.element, this.options.savingClassName); - this.element.style.backgroundColor = this.originalBackground; - Element.show(this.element); + this.element.addClassName(this.options.savingClassName); + this.element.style.backgroundColor = this._originalBackground; + this.element.show(); }, - removeForm: function() { - if(this.form) { - if (this.form.parentNode) Element.remove(this.form); - this.form = null; + triggerCallback: function(cbName, arg) { + if ('function' == typeof this.options[cbName]) { + this.options[cbName](this, arg); } }, - enterHover: function() { - if (this.saving) return; - this.element.style.backgroundColor = this.options.highlightcolor; - if (this.effect) { - this.effect.cancel(); - } - Element.addClassName(this.element, this.options.hoverClassName) + unregisterListeners: function() { + $H(this._listeners).each(function(pair) { + if (!this.options.externalControlOnly) + this.element.stopObserving(pair.key, pair.value); + if (this.options.externalControl) + this.options.externalControl.stopObserving(pair.key, pair.value); + }.bind(this)); }, - leaveHover: function() { - if (this.options.backgroundColor) { - this.element.style.backgroundColor = this.oldBackground; - } - Element.removeClassName(this.element, this.options.hoverClassName) - if (this.saving) return; - this.effect = new Effect.Highlight(this.element, { - startcolor: this.options.highlightcolor, - endcolor: this.options.highlightendcolor, - restorecolor: this.originalBackground + wrapUp: function(transport) { + this.leaveEditMode(); + // Can't use triggerCallback due to backward compatibility: requires + // binding + direct element + this._boundComplete(transport, this.element); + } +}); + +Object.extend(Ajax.InPlaceEditor.prototype, { + dispose: Ajax.InPlaceEditor.prototype.destroy +}); + +Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, { + initialize: function($super, element, url, options) { + this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions; + $super(element, url, options); + }, + + createEditField: function() { + var list = document.createElement('select'); + list.name = this.options.paramName; + list.size = 1; + this._controls.editor = list; + this._collection = this.options.collection || []; + if (this.options.loadCollectionURL) + this.loadCollection(); + else + this.checkForExternalText(); + this._form.appendChild(this._controls.editor); + }, + + loadCollection: function() { + this._form.addClassName(this.options.loadingClassName); + this.showLoadingText(this.options.loadingCollectionText); + var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); + Object.extend(options, { + parameters: 'editorId=' + encodeURIComponent(this.element.id), + onComplete: Prototype.emptyFunction, + onSuccess: function(transport) { + var js = transport.responseText.strip(); + if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check + throw 'Server returned an invalid collection representation.'; + this._collection = eval(js); + this.checkForExternalText(); + }.bind(this), + onFailure: this.onFailure }); + new Ajax.Request(this.options.loadCollectionURL, options); }, - leaveEditMode: function() { - Element.removeClassName(this.element, this.options.savingClassName); - this.removeForm(); - this.leaveHover(); - this.element.style.backgroundColor = this.originalBackground; - Element.show(this.element); - if (this.options.externalControl) { - Element.show(this.options.externalControl); + + showLoadingText: function(text) { + this._controls.editor.disabled = true; + var tempOption = this._controls.editor.firstChild; + if (!tempOption) { + tempOption = document.createElement('option'); + tempOption.value = ''; + this._controls.editor.appendChild(tempOption); + tempOption.selected = true; } - this.editing = false; - this.saving = false; - this.oldInnerHTML = null; - this.onLeaveEditMode(); + tempOption.update((text || '').stripScripts().stripTags()); }, - onComplete: function(transport) { - this.leaveEditMode(); - this.options.onComplete.bind(this)(transport, this.element); + + checkForExternalText: function() { + this._text = this.getText(); + if (this.options.loadTextURL) + this.loadExternalText(); + else + this.buildOptionList(); }, - onEnterEditMode: function() {}, - onLeaveEditMode: function() {}, - dispose: function() { - if (this.oldInnerHTML) { - this.element.innerHTML = this.oldInnerHTML; - } - this.leaveEditMode(); - Event.stopObserving(this.element, 'click', this.onclickListener); - Event.stopObserving(this.element, 'mouseover', this.mouseoverListener); - Event.stopObserving(this.element, 'mouseout', this.mouseoutListener); - if (this.options.externalControl) { - Event.stopObserving(this.options.externalControl, 'click', this.onclickListener); - Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener); - Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener); - } + + loadExternalText: function() { + this.showLoadingText(this.options.loadingText); + var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); + Object.extend(options, { + parameters: 'editorId=' + encodeURIComponent(this.element.id), + onComplete: Prototype.emptyFunction, + onSuccess: function(transport) { + this._text = transport.responseText.strip(); + this.buildOptionList(); + }.bind(this), + onFailure: this.onFailure + }); + new Ajax.Request(this.options.loadTextURL, options); + }, + + buildOptionList: function() { + this._form.removeClassName(this.options.loadingClassName); + this._collection = this._collection.map(function(entry) { + return 2 === entry.length ? entry : [entry, entry].flatten(); + }); + var marker = ('value' in this.options) ? this.options.value : this._text; + var textFound = this._collection.any(function(entry) { + return entry[0] == marker; + }.bind(this)); + this._controls.editor.update(''); + var option; + this._collection.each(function(entry, index) { + option = document.createElement('option'); + option.value = entry[0]; + option.selected = textFound ? entry[0] == marker : 0 == index; + option.appendChild(document.createTextNode(entry[1])); + this._controls.editor.appendChild(option); + }.bind(this)); + this._controls.editor.disabled = false; + Field.scrollFreeActivate(this._controls.editor); } +}); + +//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! **** +//**** This only exists for a while, in order to let **** +//**** users adapt to the new API. Read up on the new **** +//**** API and convert your code to it ASAP! **** + +Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) { + if (!options) return; + function fallback(name, expr) { + if (name in options || expr === undefined) return; + options[name] = expr; + }; + fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' : + options.cancelLink == options.cancelButton == false ? false : undefined))); + fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' : + options.okLink == options.okButton == false ? false : undefined))); + fallback('highlightColor', options.highlightcolor); + fallback('highlightEndColor', options.highlightendcolor); }; -Ajax.InPlaceCollectionEditor = Class.create(); -Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype); -Object.extend(Ajax.InPlaceCollectionEditor.prototype, { - createEditField: function() { - if (!this.cached_selectTag) { - var selectTag = document.createElement("select"); - var collection = this.options.collection || []; - var optionTag; - collection.each(function(e,i) { - optionTag = document.createElement("option"); - optionTag.value = (e instanceof Array) ? e[0] : e; - if((typeof this.options.value == 'undefined') && - ((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true; - if(this.options.value==optionTag.value) optionTag.selected = true; - optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e)); - selectTag.appendChild(optionTag); - }.bind(this)); - this.cached_selectTag = selectTag; +Object.extend(Ajax.InPlaceEditor, { + DefaultOptions: { + ajaxOptions: { }, + autoRows: 3, // Use when multi-line w/ rows == 1 + cancelControl: 'link', // 'link'|'button'|false + cancelText: 'cancel', + clickToEditText: 'Click to edit', + externalControl: null, // id|elt + externalControlOnly: false, + fieldPostCreation: 'activate', // 'activate'|'focus'|false + formClassName: 'inplaceeditor-form', + formId: null, // id|elt + highlightColor: '#ffff99', + highlightEndColor: '#ffffff', + hoverClassName: '', + htmlResponse: true, + loadingClassName: 'inplaceeditor-loading', + loadingText: 'Loading...', + okControl: 'button', // 'link'|'button'|false + okText: 'ok', + paramName: 'value', + rows: 1, // If 1 and multi-line, uses autoRows + savingClassName: 'inplaceeditor-saving', + savingText: 'Saving...', + size: 0, + stripLoadedTextTags: false, + submitOnBlur: false, + textAfterControls: '', + textBeforeControls: '', + textBetweenControls: '' + }, + DefaultCallbacks: { + callback: function(form) { + return Form.serialize(form); + }, + onComplete: function(transport, element) { + // For backward compatibility, this one is bound to the IPE, and passes + // the element directly. It was too often customized, so we don't break it. + new Effect.Highlight(element, { + startcolor: this.options.highlightColor, keepBackgroundImage: true }); + }, + onEnterEditMode: null, + onEnterHover: function(ipe) { + ipe.element.style.backgroundColor = ipe.options.highlightColor; + if (ipe._effect) + ipe._effect.cancel(); + }, + onFailure: function(transport, ipe) { + alert('Error communication with the server: ' + transport.responseText.stripTags()); + }, + onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls. + onLeaveEditMode: null, + onLeaveHover: function(ipe) { + ipe._effect = new Effect.Highlight(ipe.element, { + startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor, + restorecolor: ipe._originalBackground, keepBackgroundImage: true + }); } - - this.editField = this.cached_selectTag; - if(this.options.loadTextURL) this.loadExternalText(); - this.form.appendChild(this.editField); - this.options.callback = function(form, value) { - return "value=" + encodeURIComponent(value); - } + }, + Listeners: { + click: 'enterEditMode', + keydown: 'checkForEscapeOrReturn', + mouseover: 'enterHover',... [truncated message content] |
From: <fan...@us...> - 2007-11-18 22:29:30
|
Revision: 4800 http://linpha.svn.sourceforge.net/linpha/?rev=4800&view=rev Author: fangehrn Date: 2007-11-18 14:29:28 -0800 (Sun, 18 Nov 2007) Log Message: ----------- updated documentation Modified Paths: -------------- trunk/linpha2/docs/dev/TODO.txt Added Paths: ----------- trunk/linpha2/lib/js/prototype-1.6.0/ trunk/linpha2/lib/js/prototype-1.6.0/CHANGELOG trunk/linpha2/lib/js/prototype-1.6.0/LICENSE trunk/linpha2/lib/js/prototype-1.6.0/README trunk/linpha2/lib/js/prototype-1.6.0/Rakefile trunk/linpha2/lib/js/scriptaculous-js-1.8.0/ trunk/linpha2/lib/js/scriptaculous-js-1.8.0/CHANGELOG trunk/linpha2/lib/js/scriptaculous-js-1.8.0/MIT-LICENSE trunk/linpha2/lib/js/scriptaculous-js-1.8.0/README trunk/linpha2/lib/js/sound.js Removed Paths: ------------- trunk/linpha2/lib/js/prototype-1.5.0_rc1/ trunk/linpha2/lib/js/scriptaculous-js-1.6.4/ Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2007-11-18 22:20:05 UTC (rev 4799) +++ trunk/linpha2/docs/dev/TODO.txt 2007-11-18 22:29:28 UTC (rev 4800) @@ -26,6 +26,9 @@ - fix (adodb) error handler +- compress javascripts (prototype and scriptaculous) + they are now nearly 200KB big + ## Big Todos - Switch to strict mode Added: trunk/linpha2/lib/js/prototype-1.6.0/CHANGELOG =================================================================== --- trunk/linpha2/lib/js/prototype-1.6.0/CHANGELOG (rev 0) +++ trunk/linpha2/lib/js/prototype-1.6.0/CHANGELOG 2007-11-18 22:29:28 UTC (rev 4800) @@ -0,0 +1,873 @@ +*1.6.0* (November 6, 2007) + +* Fix Class#addMethods for "toString" and "valueOf" methods in Internet Explorer. Closes #9901. [sam] + +* Exclude Opera from using the sourceIndex approach in Element#descendantOf. [Tobie Langel, Andrew Dupont] + +* Ensure Element#hasClassName always returns a boolean. Closes #10075. [ronnylovtangen, Tobie Langel] + +* Ensure selectors of the form "[href]" (attribute token with no preceding tag name) work properly. Closes #8870. [chao, kangax, Andrew Dupont] + +* Performance optimizations for Element#descendantOf. Costliness should no longer be dependent on the difference in depth between the parent and the child. [Andrew Dupont] + +* Apply the workaround for the Firefox "blinking element" opacity=1 bug only to Firefox 1.5. [Thomas Fuchs] + +* Add event.stopped, a boolean that is set to `true` when Event#stop is called. [Andrew Dupont, sam] + +* Reset the browser's dimensions to their original settings after running the DOM viewport tests. [sam] + +* Fix the test runner for Firefox in Leopard. [sam] + +* Use String#include wherever possible. + +* In IE, allow opacity to be set on elements not yet attached to the document. Closes #9904. [Thomas Fuchs, dcpedit, Tobie Langel] + +* Avoid the try..catch block in Ajax.Response#_getResponseJSON unless required. [Tobie Langel] + +* Add more tests to Element.update. Closes #9327. [Tobie Langel] + +* Make the Ajax.Response#headerJSON property correctly decode unicode characters. Closes #9285. [Marius Feraru, Tobie Langel] + +* Make sure Event and Event.extend are defined before wrapping events and calling their handler. Prevents a known Firefox bug from throwing errors on page load/unload (cf.: https://bugzilla.mozilla.org/show_bug.cgi?id=361271). Closes #5393, #9421. [staaky, John Resig, sam, Tobie Langel] + +* Minor cosmetic changes to the display of unit tests in terminal. [Tobie Langel] + +* Make submitting forms work in Opera < 9.1. Closes #9917, #9463, #8260. [kangax] + +* Fix template evaluation with empty replacements. Closes #9692. [Ryan McGeary] + +* Hash#toTemplateReplacements is an alias for Hash#toObject so you can once again pass hashes to Template#evaluate and String#interpolate. [sam] + +* Fix Event#is(Left|Middle|Right)Click in IE. Closes #7520 (again). [Mislav Marohnić] + +*1.6.0_rc1* (October 16, 2007) + +* Ensure Event.* generic methods work in IE, even when the event is not extended. [Viktor Kojouharov, Andrew Dupont] + +* Don't translate "keypress" events into "keydown" events. [sam] + Note: "keypress" is broken in Safari <= 2.x, but Event#stop has no effect on "keydown" events. + +* Changed Element#makeClipping to remember the original overflow value, even if it's a non-inline style. [Andrew Dupont] + +* Cross-browser Event#isLeftClick with the addition of is(Middle|Right)Click. Closes #7520. [Christophe Porteneuve, Richard Quadling, Mislav Marohnić] + +* Changed Selector to use the non-XPath approach for Safari 3 because of bugs in its version of document.evaluate. [Andrew Dupont] + +* Changed the Selector regex that tests whether the selector can be expressed in XPath; added :checked, since XPath can't detect all scenarios in which an <input> is checked. Fixes #9776. [StelardActek, kangax, Andrew Dupont] + +* Changed Selector pattern match so that descendant combinators after pseudoclass tokens are properly handled. Fixes #9696. [wiktor, kangax, Andrew Dupont] + +* Make sure $w always returns an array. [Andrew Dupont, Tobie Langel] + +* Add more tests to Hash. [Mislav Marohnić] + +* Performance enhancements to $A. Closes #9464. [Samuel Lebeau] + +* Make Function#argumentNames work with named functions. Closes #9826. [Samuel Lebeau] + +* Add Object.isHash. [Tobie Langel] + +* Performance improvements to String#times. [Martin Ström] + +* Make Ajax.Response#getHeaderJSON and Ajax.Response#getResponseJSON pseudo private instance methods. [Tobie Langel] + +* Make ObjectRange use the new Class.create syntax. [Mislav Marohnić] + +* Fix a failing ClassCreate test case in IE. [Tobie Langel] + +* Complete rewrite of the Hash class. + + !! BACKWARDS COMPATIBILITY CHANGE !! This new version of Hash is NOT backwards compatible with the former Hash class. + + Properties are now hidden away in an private store to prevent the risk of collision with Hash's instance and mixed-in methods. + This implies that properties of the hash can no longer be set, accessed or deleted directly: use the new Hash#get(key), Hash#set(key, value) and Hash#unset(key) instance methods instead. + + - Make $H(object) equivalent to new Hash(object). Both now return a new (cloned) instance of Hash in all circumstances. + - Make Hash#merge non-destructive. + + - Add Hash#update (a destructive version of Hash#merge). + - Add Hash#clone (returns a new, cloned instance of Hash). + - Add Hash#toObject (returns a clone of the contained object). + - Add Hash#get(key) (returns the value of the specified property). + - Add Hash#set(key, value) (sets the value of the given property. returns the value). + - Add Hash#unset(key) (deletes the specified property and returns its value). + - Add Hash.from as a alias to $H for consistency with Array.from. + - Add Object.toQueryString. + + - Deprecate Hash.toQueryString (use Object.toQueryString or the instance method Hash#toQueryString instead). + + - Remove Hash#remove (use Hash#unset instead). + - Remove Hash.toJSON (use Object.toJSON or the instance method Hash#toJSON instead). [sam, Tobie Langel] + +* Element#wrap now returns the wrapper instead of the element being wrapped. [sam] + +* Namespace all custom event names to avoid conflicts with native DOM events. [sam] + - All custom event names MUST include a namespace. Prefix custom event names for observe, stopObserving, and fire with the namespace followed by a colon. E.g. document.fire("widget:activated") + - The "contentloaded" event is now "dom:loaded". + - The Event.DOMEvents array is no longer present. If an event name does not include a namespace, the event is treated as a native event. + +* Clean up the new class API. [sam, Tobie Langel] + - Add Class#addMethods for adding instance methods to classes. + - Remove Class.extend and Class.mixin. + - Class.create now takes a variable number of arguments: if the first argument is a class, the newly created class inherits from that class; all other arguments are treated as successive calls to addMethods. + +* Fix contentloaded event initialization in IE. Closes #9457, #9488, #9707. [Mislav Marohnić] + +* Deprecate document.getElementsByClassName and Element#getElementsByClassName since native versions return a NodeList and we can only return an Array. Please use $$ or Element#select instead. [sam] + For more information see https://bugzilla.mozilla.org/show_bug.cgi?id=390411 + +* Fix missing "var" in selector.js. Closes #9761. [Tobie Langel] + +* Date#toJSON now returns times in UTC for better compatibility with json.js. Closes #9332. [Tobie Langel] + +* Ensure document._getElementsByXPath extends the elements it returns; fixes $$ not returning extended elements in Opera 9.2. Closes #8843. [jdalton] + +* Update Prototype.Browser.MobileSafari for iPod touch compatibility. [sam] + +* Add tests for Object.extend and Object.clone. [Tobie Langel] + +* Add a test for Form.Observer. [Christoph Sturm] + +* Make sure setting opacity works on elements that have "no layout" in IE. [Thomas Fuchs] + +* Simplify Class.create by establishing a prototype chain when subclassing. Closes #9342. [Ben Newman] + +* Fix Ajax.PeriodicalUpdater for compatibility with Ajax.Response. Closes #9321. [kampers] + +* Ensure that classes always have an initialize method. [Mislav Marohnić] + +* Update Template, Selector, Ajax.*, and ObjectRange classes to use the new class system. [Mislav Marohnić] + +* Change Abstract.TimedObserver to subclass PeriodicalExecuter and tweak its subclasses to use new inheritance functionality. TimedObserver can now be stopped the same way as PeriodicalExecuter. Closes #8589. [Mislav Marohnić] + +* Fix Class.mixin to extend the class's prototype. [Mislav Marohnić] + +* Fix superclass method call breakage from [7337]. [Mislav Marohnić, sam] + +* Change Class.extend to allow for superclass method resolution and remove Class.inherit. Closes #9274. [Samuel Lebeau] + +* Event handlers are now bound to the observed element, not the event's target element. [Dan Webb] + +* Define Node constants conditionally after checking for Node.ELEMENT_NODE presence. Add unit test to check the values of all constants. Closes #7625. [Mislav Marohnić] + +* Make sure Enumerable#include doesn't do type comparision. [Mislav Marohnić] + +* Add contextmenu to Event.DOMEvents. [Thomas Fuchs] + +*1.6.0_rc0* (August 15, 2007) + +* Fix readAttribute-related failure in form.html in IE. [sam, Andrew Dupont] + +* Fix failing dom.html and selector.html tests in IE. [Tobie Langel, Andrew Dupont] + +* Make sure the WebKit redefinition of Element#cumulativeOffset uses Element._returnOffset. Closes #9245. [mdaines] + +* Make sure Element#observe and Element#stopObserving are always chainable. [sam] + +* Event.fire/Element#fire now returns the newly-fired event instead of the event's target element. [sam] + +* Restrict Event.DOMEvents to include only events that can be supported in all browsers. [sam] + +* Fix a failing test in base.html in Safari 2. [Tobie Langel] + +* Fix Element#positionedOffset and Element#getOffsetParent for static elements on IE. [Thomas Fuchs] + +* Make sure event handlers and their wrappers are removed from the cache by Event.stopObserving. [sam, Severin Heiniger] + +* Add line numbers to failures when unit testing in Firefox. Closes #9231. [John Resig] + +* Fix Function#argumentNames for Opera and IE. [Thomas Fuchs] + +* Add Object.isString, Object.isNumber, and Object.isUndefined, and clean up the source to make use of Object.isXXX where possible. [sam] + +* Add the document.viewport object for querying dimensions and scroll offsets of the browser viewport. [Andrew Dupont, Thomas Fuchs, sam] + Example: + document.viewport.getDimensions() // { width: 1149, height: 923 } + document.viewport.getWidth() // 1149 + document.viewport.getHeight() // 923 + document.viewport.getScrollOffsets() // { left: 0, top: 1592 } + +* Add support for brackets in quoted attribute value selectors. Closes #9157. [Ken Snyder] + +* Add some missing semicolons to the source tree. Closes #9140. [jdalton] + +* Fix event extensions and custom events firing for Safari 2.0. [Thomas Fuchs] + +* Add RegExp.escape for escaping regular expression strings. Closes #9094. [Ken Snyder] + +* Make the eventName and handler arguments to Event.stopObserving optional. If no handler is specified, all handlers for the given event are unregistered. If no event name is specified, all observed events on the element are unregistered. [sam] + +* Add cross-support for the DOMContentLoaded event through a Prototype custom event on document called "contentloaded". The DOMContentLoaded event fires before window.load, when the entire HTML document, but not necessarily its images, stylesheets or other assets, has loaded. Based on [6596]. [sam, Mislav Marohnić] + Example: + document.observe("contentloaded", function() { + $$("a").invoke("identify"); // give all <a> tags an ID + }); + +* Add Event.fire and Element.Methods.fire for firing custom events. Prototype custom events piggyback on a real DOM event ("ondataavailable"), so they bubble and cancel. You can fire custom events from any element, or fire global events on the document object. Observe custom events just as you'd observe a regular DOM event. [sam, Seth Dillingham] + +* Extend the event object with methods from Event.Methods and normalize it in IE. [sam, Mislav Marohnić] + +* Remove support for observing the capturing phase of DOM events, since we can't support it in all browsers. [sam] + +* Add Ajax.Response object which supports the following methods: responseJSON, headerJSON, getHeader, getAllHeaders and handles browser discrepancies in the other response methods. Add sanitizeJSON, evalJS and evalJSON to Ajax.Request. Closes #8122, #8006, #7295. [Tobie Langel] + +* Add an isRunningFromRake property to unit tests. [Tobie Langel] + +* Add support for Opera browser in jstest.rb. [Tobie Langel] + +* Inheritance branch merged to trunk; robust inheritance support for Class.create. Closes #5459. [Dean Edwards, Alex Arnell, Andrew Dupont, Mislav Mahronic] + - To access a method's superclass method, add "$super" as the first argument. (The naming is significant.) Works like Function#wrap. + - Class.create now takes two optional arguments. The first is an existing class to subclass; the second is an object literal defining the instance properties/methods. Either can be omitted. Backwards-compatible with old Class.create. + - Added Class.extend for dynamically adding methods to existing classes (while preserving inheritance chain). Can also be used for mixins. + - The 'constructor' property of a class instance always points back to the proper class. Class objects themselves have two special properties: 'superclass' and 'subclasses' (which default to 'null' and '[]', respectively). Allows for powerful introspection. + - Added Object.isFunction [sam] + +* Add Function#argumentNames, which returns an ordered array of the function's named arguments. [sam] + +* Prevent a crash in Safari 1.3 on String#stripScripts and String#extractScripts. Closes #8332. [grant, Tobie Langel] + +* Add Prototype.Browser.MobileSafari which evaluates to true on the iPhone's browser. [sam] + +* Optimize Selector#match and Element#match for simple selectors. Closes #9082. [Andrew Dupont] + +* Remove the dependency on Element.ClassNames from Element#addClassName/removeClassName/toggleClassName, and deprecate Element.ClassNames. Closes #9073. [Tobie Langel] + +* Make Element#wrap accept a second argument for setting attributes on the wrapper. Allow wrapping elements which are not part of the document. Closes #9071. [Tobie Langel] + +* Improvements for Element#replace, Element#update and Element#insert. Closes #7429, #9060. [Tobie Langel] + - Element#replace/update/insert uses the argument's toElement or toHTML method if present (toElement has precedence if both are present). + - Element#replace and Element#update now also accept DOM elements. + - Element#replace better handles table-related elements in IE and Opera. + +* Add Object.isArray and Object.isElement (returns true if the object is a DOM node of type 1). [Tobie Langel] + +* Add Object.toHTML (uses the object's toHTML method if present or else passes the object to String.interpret). [Tobie Langel] + +* Make Element#setStyle accept a string argument of CSS rules. Deprecate uncamelized style property names when setting styles using an object (for performance reasons). Closes #9059. [Tobie Langel] + Examples: + $('id').setStyle('font-size: 12px; float: left; opacity: 0.5'); + $('id').setStyle({fontSize: '12px', cssFloat: 'left', opacity: 0.5}); + + !! BACKWARDS COMPATIBILITY CHANGE !! + + If you have code that looks like this: + $('id').setStyle({'font-size': '12px'}); + You need to replace it with either of the following: + $('id').setStyle({fontSize: '12px'}); + $('id').setStyle('font-size: 12px;'); + +* Add Element#identify, which returns the element's ID if it exists, or sets and returns a unique, auto-generated ID (of the form "anonymous_element_" + auto-incremented digit) otherwise. Use this when you need to ensure an element has an ID. Closes #9012. [Jeff Watkins, sam, Tobie Langel] + +* Make Element#readAttribute work for cloned elements in IE. Closes #8481. [chem, Tobie Langel] + +* Template enhancements. Closes #8166. [Christophe Porteneuve] + - Added String#interpolate as a shortcut for new Template(...).evaluate(...). + - If you pass String#interpolate or Template#evaluate an object with a toTemplateReplacements() method, the return value of that method will be used as the replacement object. + - You can now substitute properties of template replacement values in template strings, using dot or bracket notation (or both). Example: + "#{name.last}, #{name.first[0]}. (#{location})".interpolate({ + name: { first: "Christophe", last: "Porteneuve" }, location: "Paris" + }) // "Porteneuve, C. (Paris)" + +* Extended grep semantics. The first argument to Enumerable#grep is now a "filter" (an object with a match() method) so you can now e.g. filter an array of DOM nodes by CSS selector. RegExp#match is now an alias to RegExp#test, so grep can still be used to filter an array of strings with a regular expression. Closes #7596. [Christophe Porteneuve, sam] + +* Make String#scan explicitly return a string. This prevents possible issues with methods expecting input data that is typeof == 'string'. Closes #6350. [AndrewRev, Tobie Langel] + +* Add Array#intersect for set intersection. Returns a new array containing all items common to the array and the argument, with duplicates removed (clone of the Ruby & method). [Thomas Fuchs] + Example: + [1,1,3,5].intersect([1,2,3]) -> [1,3] + +* Rename Element#getElementsBySelector to Element#select and add alias for Element#getElementsBySelector. [Thomas Fuchs] + +* Add Element#adjacent as a shortcut to selecting all adjacent nodes (and their children) that match a CSS selector. [Thomas Fuchs] + +* Enhance the Enumerable and Array APIs to more closely match those of JavaScript 1.6 as implemented in Firefox 1.5. Closes #6650, #8409. [Mislav Marohnić, Sylvain Zimmer] + - Add Array#lastIndexOf, and change Array#indexOf not to overwrite the native method. + - Make Enumerable use Array.prototype.forEach instead of _each when possible (slight speed increase). + - Add "filter", "entries", "every", and "some" Array aliases. + - All Enumerable methods now have an additional parameter, "context", which, if present, specifies the object to which the iterators' "this" is bound. + - Function#bind and #curry now return the receiving function if the binding object is undefined. + +* Temporary workaround for Prototype.BrowserFeatures.SpecificElementExtensions incorrectly evaluating to true on iPhone. (needs further investigation) [sam] + +* The action for Form#request defaults to the current URL if the "action" attribute is empty. (This is what most of the major browsers do.) Fixes #8483. [Tomas, Mislav Marohnić] + +* In form serialization, change the way submit buttons are handled. Previously all submit buttons were serialized; now Prototype serializes only the first one. Change Form#serialize and Form.serializeElements to accept a params hash. With the "hash: false" option, a serialized string is returned instead of the hash data object. With the "submit: 'foo'" option, only the submit button with the name "foo" is serialized. References #5031. [Mislav Marohnić] + Examples: + $('form').serialize({ submit: 'delete' }) + $('form').serialize({ hash: false }) //-> equivalent to $('form').serialize() + +* Form#findFirstElement respects HTML tabindexes. Closes #7595. [Christophe Porteneuve] + +* Added Form.Element#setValue method for setting values on various form controls. Checkboxes and radio buttons respond to a boolean and multiple select boxes expect an array of values. Closes #5902. [Jonathan Viney, Mislav Marohnić] + Examples: + $('text_input').setValue('hello world!') + $('remember_me').setValue(true) + $('attend_classes').setValue(['cheese rolling', 'evil chemistry']) + +* Make document.getElementsByClassName match a subset of the WHATWG Web Applications 1.0 specification which was adopted in Firefox 3 (http://www.whatwg.org/specs/web-apps/current-work/#getelementsbyclassname). It now supports multiple class names given as a whitespace-separated list in a string. Array argument is not supported. The method will only return the nodes that match all the class names. In browsers that implement the method natively it will not be overwritten. Closes #8401. [Mislav Marohnić] + Example: + document.getElementsByClassName('foo bar') + +* Fix a Safari rendering issue when floating elements could temporarily disappear when opacity was set to 1. Closes #7063. References #3044, #3813, #6706. [Thomas Fuchs, davidjrice] + +* Prevent a crash in Safari when calling String#evalJSON(true) on very large strings. Add String#isJSON. Closes #7834. [Tobie Langel] + +* Prevent a crash in Safari 1.3 on String#stripScripts and String#extractScripts. Closes #8332. [grant, Tobie Langel] + +* Allow JSON data to contain line breaks. Closes #8271. [pijyster, Tobie Langel] + +* Add Hash.prototype.index which returns the first found property that has a specific value. Closes #8528. [Thomas Fuchs, slusarz, Mislav Marohnić] + Examples: + var hash = $H({a:1,b:'2'}); + hash.index(1) // -> 'a' + hash.index('1') // -> undefined + +* Ensure HTMLElement exists before creating Element.extend. [Tobie Langel] + +* Add Number.prototype.round/ceil/floor/abs as an aliases to the respective methods in Math. Refactor to seperate number extensions from base.js. [Thomas Fuchs] + +* Make Element#absolutize and Element#relativize properly use Element#getStyle. Closes #8580. [Christophe Porteneuve] + +* Test library fixes: make rake dist work on Windows, only teardown if a browser is supported. Closes #8463, #8498. [Mislav Marohnić, grant] + +* Change Element.insert syntax to allow multiple positions. [Thomas Fuchs] + Examples: + Element.insert('foo', {top:'bar', bottom:'baz'}); + $('foo').insert({after: new Element('p').update('bar')}); + Element.insert('foo', new Element('p').update('bar')); // defaults to bottom + Element.insert('foo', 'bar'); // defaults to bottom + +* String.prototype.truncate now explicitly converts its return value into a string if no truncation takes place. This prevents possible issues with methods expecting input data that is typeof == 'string'. [Thomas Fuchs, Tobie Langel, Sam Stephenson] + +* Event.findElement behaves as expected when the element passed matches the given selector. Closes #8395. [Mislav Marohnić, Tobie Langel] + +* Element.setOpacity now calls removeAttribute on the filter style on IE if no more filters remain, which makes Cleartype work properly. Closes #8376. [alexdemi, Thomas Fuchs] + +* Event.findElement now uses Element#up (and as a result can take a CSS selector instead of just a tag name). [Tobie Langel] + +* Minor cleanup of the position methods [sam] + +* Fix Element#clonePosition to call viewportOffset. Closes #8372. [graemenelson, Christophe Porteneuve] + +* Prevent an error being thrown by $$ when #id does not exist in $$("div #id"). Closes #8325. [Tobie Langel, ecke] + +* Make Prototype.ScriptFragment behave when including Prototype inline. [Christophe Porteneuve] + +* Deprecate Position (kept for backwards compatibility). Add Element#cumulativeOffset, Element#positionedOffset, Element#absolutize, Element#relativize, Element#cumulativeScrollOffset, Element#getOffsetParent, Element#viewportOffset and Element#clonePosition. [Christophe Porteneuve] + +* Make Element#update and Element#insert work for SELECT tags in IE and Opera. [Tobie Langel] + +* Make Element#insert and Element#update better handle TABLE related elements in IE and Opera. Closes #7776, #8040, #7550, #7776, #7938. [Tobie Langel] + +* Make Element#readAttribute('title') work in Opera. [Tobie Langel] + +* Make Element#replace work with form elements in Firefox and Safari. Closes #8010, #7989. [dsl239, Tobie Langel] + +* Add Element#wrap which wraps the element inside a new one. Closes #5732. [P. Vande, Tobie Langel] + +* Make Element into a constructor: new Element(tagName, attributes). Add Element#writeAttribute which accepts a hash of attributes or a name/value pair. Closes #7476. [Mislav Marohnić, haraldmartin, Tobie Langel] + +* Insertion overhaul: Add Element.insert(content[, position = 'bottom']). Deprecate Insertion (kept for backwards compatibility). Make Ajax.Updater option.insertion accept both Insertion.Top or the now preferred 'top'. Closes #7907. [Tobie Langel] + +* Refactor Element.extend and eliminate Element.extend.cache. [sam] + +* Add Function#curry, Function#delay, Function#defer, and Function#wrap. Closes #8134. [Andrew Dupont, Tobie Langel, sam] + +*1.5.1* (May 1, 2007) + +* Don't duplicate the event argument in Function#bindAsEventListener. Closes #6497. [wiktor] + +* Fix Selector :not-clause chaining. [Andrew Dupont] + +*1.5.1_rc4* (April 27, 2007) + +* Fix $F breakage from [6598]. [sam] + +* Set window.$continue to an Error with a helpful message for anyone who may still be using "throw $continue". [sam] + +* Fix jstest.rb IE support so you don't have to close the IE window after each test (yay!). Closes #8207. [Ryan Schuft] + +* Fix jstest.rb Konqueror support. Closes #7140. [Christophe Porteneuve] + +* Fix regression in which no-argument calls to Element.addMethods() would not add the methods defined in Form.Methods and Form.Element.Methods. Closes #8206. [Tobie Langel, fwittekind] + +* Fix Element#readAttribute to work with the 'type' attribute in IE. Closes #8160. [Tobie Langel, Wiktor Ihárosi] + +*1.5.1_rc3* (April 24, 2007) + +* Add Element#childElements as an alias for Element#immediateDescendants. [Tobie Langel] + +* Optimize DOM navigation methods (Element#up, Element#down, Element#previous, Element#next) for no-argument calls. Closes #7848. [haraldmartin, sam] + +* Add Element#firstDescendant to retrieve the first non-text child node of an element. [sam] + +* Element.addMethods should add methods to Element as well as Element.Methods. Closes #7888. [Andrew Dupont] + +* Add support for per-request onCreate callbacks to Ajax.Request. Closes #8011. [Andrew Dupont] + +* Don't call evalResponse() when an Ajax response has no Content-type header. Closes #7827. [Tobie Langel] + +* Automatically strip security delimiter comments from JSON strings before evaling them. The default delimiter is '/*-secure- ... */' or you can specify your own with the Prototype.JSONFilter regular expression. If you wrap your JSON response bodies in this delimiter on the server side, rogue external sites can't hijack potentially sensitive data via <script> tags. Closes #7910. [Tobie Langel] + For more details on potential security problems, see: http://www.fortifysoftware.com/servlet/downloads/public/JavaScript_Hijacking.pdf + +* Add extra spacing so Array#toJSON and Hash#toJSON generate YAML-loadable JSON. Closes #7883. [Andrew Dupont] + +* Fix Form.request for forms containing an input element with name="action". Closes #8063. [Thomas Fuchs, Mislav Marohnić] + +* Make Event.element extend the returned element. Closes #7870. [Thomas Fuchs] + +* Prevent a crash on Safari on String.prototype.stripScripts and extractScripts with large <script> tags. [Thomas Fuchs] + +* Prevent linefeed normalisation in String.prototype.escapeHTML and unescapeHTML on IE for consistency with other browsers. Speed optimizations for Safari and IE. [Thomas Fuchs] + +* Make Hash.toQueryString serialize undefined values. Ensure consistency with String.prototype.toQueryParams. Closes #7806. [Mislav Marohnić] + Examples: + $H({a:'b',c:undefined}).toQueryString() -> 'a=b&c' + $H({a:'b',c:null}).toQueryString() -> 'a=b&c=' + $H('a=b&c'.toQueryParams()).toQueryString() -> 'a=b&c' + $H('a=b&c='.toQueryParams()).toQueryString() -> 'a=b&c=' + +* Fix issues with Selector an+b logic, :not support, attribute selector double quotes, plus performance improvements. Closes #7873, #7901. [Andrew Dupont] + +* Fix Form.disable to work again on non-form elements. Closes #6887. [Mislav Marohnić] + +* Fix an issue with String.prototype.endsWith. Closes #7822. [altblue] + +*1.5.1_rc2* (March 12, 2007) + +* Add a tab character via innerHTML to the selector whitespace test. [Christophe Porteneuve] + +* Add an attribution to YUI-Ext's DomQuery in selector.js. + +* Make Element.extend work on IE for Nodes with the same ID that where discarded. Closes #7497. [Mislav Marohnić, Thomas Fuchs] + +* Make Selector correctly extend the first element it returns on IE. [Thomas Fuchs] + +* Prevent a crash in Safari when using $A() on NodeList objects that contain text nodes. [Thomas Fuchs] + +* Fix Element.Methods.descendants() to properly extend elements on IE. [Thomas Fuchs] + +*1.5.1_rc1* (March 9, 2007) + +* Fix readAttribute for IE7. [Andrew Dupont] + +*1.5.1_rc0* (March 8, 2007) + +* Merge the selector branch into trunk, bringing vast performance improvements, bug fixes, and near-complete CSS3 compliance to $$ and Selector. Closes #7568. [Andrew Dupont] + Selector speed test: http://andrewdupont.net/test/double-dollar/ + +* Add support for JSON encoding and decoding. Closes #7427. [Tobie Langel] + +* Fix double escaping of query parameters in Hash.prototype.toQueryString, and prevent Safari from iterating over shadowed properties when creating hashes. Closes #7421. [Tobie Langel, Mislav Marohnić] + +* Fix simulated attribute reading for IE for "href", "src" and boolean attributes. [Mislav Marohnić, Thomas Fuchs] + +* Form.Element.disable() will now call blur(), removed blur() call from Form.Element.enable(). Closes #6034. [tdd] + +* Optimize document.getElementsByClassName and finalize DOM performance optimization refactoring. Closes #6696. [Mislav Marohnić] + +* Fix an issue with serializing empty array inputs. Closes #7516. [stakadush, Mislav Marohnić] + +* Add optional third parameter "camelized" to Element.setStyle, for optimized performance if style names are known to be camelCased. [Thomas Fuchs] + +* Fix a bug in the simulated hasAttribute for IE due to getAttributeNode sometimes returning null. [sam] + +* Optimize Element.getStyle and add new Element.getOpacity method. Special case IE and Opera getStyle methods. Closes #7648. [Tobie Langel, Thomas Fuchs] + +* Optimize Element.setStyle and add new Element.setOpacity method, special case IE and Gecko opacity methods. Closes #7585. [savetheclocktower] + +* Add unified Browser detection by providing Prototype.Browser.(IE|Gecko|WebKit|Opera) booleans. Closes #6800. [savetheclocktower] + +* Add String.prototype.empty and String.prototype.blank (tests if empty or whitespace-only). Closes #7016. [Jonathan Viney, Thomas Fuchs] + +* Update README to reflect new URLs, update LICENSE copyright years. Closes #7426. [Tobie Langel] + +* Array.prototype.uniq optimization. Closes #7417. [Christophe Porteneuve] + +* String.prototype.endsWith should not fail on multiple occurrences. Closes #7416. [Christophe Porteneuve] + +* Add Form.Methods.request as a convenience method for serializing and submitting a form via Ajax.Request to the URL in the form's action attribute. [sam] + + Options passed to request() are intelligently merged with the underlying Ajax.Request options: + - If the form has a method attribute, its value is used for the Ajax.Request method option. If a method option is passed to request(), it takes precedence over the form's method attribute. If neither is specified, method defaults to "post". + - Key/value pairs specified in the parameters option (either as a query string or as a hash) will be merged with (and take precedence over) the serialized form parameters. + +* Fix $(form).serialize() in Safari and add support for extending specific tags to Element.addMethods. Closes #7358. [Andrew Dupont] + +* Add String.prototype.startsWith, String.prototype.endsWith, and String.prototype.include. Closes #7075. [Tobie Langel] + +* Improve performance of String.prototype.escapeHTML by using a cached div and text node. Closes #6937. [altblue] + +* Make setStyle() with opacity: 0 in Internet Explorer work correctly. [Thomas Fuchs] + +* Form.Element.activate shouldn't raise an exception when the form or field is hidden. [sam] + +* Remove support for "throw $continue" in Enumerable. Use "return" instead. [sam] + +* Update HEADER to reflect new URL. [sam] + +*1.5.0* (January 18, 2007) + +* Add test to ensure Content-type header is set for simulated verbs. [sam] + +* Fix Content-Type header for HTTP methods simulated with POST not defaulting to application/x-www-form-urlencoded. [Thomas Fuchs] + +* Simplify form serialization and add support for fields with the same name as Hash methods. Closes #6649. [Mislav Marohnić] + +* Fix attribute selectors for IE. Closes #5170. [Tobie Langel, Andrew Dupont] + +* A slew of dom.js improvements. Closes #4217, #6589, #7001. [Tobie] + - Fix Element.getDimensions() for hidden elements, make Element.getHeight() use .getDimensions() + - Add Element.getWidth() + - Make Element.replace() call .toString() on the html argument (alike .update()) + - Fix an issue with Element.get/setStyle() and Safari with 'float' + - Add a bunch of missing unit tests + +* Fix an issue with Element.setStyle({opacity:''}) setting the opacity to 0 instead of removing the set inline opacity style. [Thomas Fuchs] + +* Ensure Ajax.Request's evalResponse is called before onComplete so that onComplete can reference any elements created during the response. Closes #6727. [jonathan] + +* Ensure the WEBrick test runner sets the correct Content-Type for tests and fixtures. [sam] + +* Form.serialize once again works with non-form elements. This is a temporary change to prevent the Rails link_to_remote regression described in #6898. Prototype 1.5.1 will introduce an API for working with collections of arbitrary form elements. References #6887. Closes #6898. [sam] + +* Make selectors match forms that have an element with name="id" correctly, fixes #5759 [mislav] + +* Remove support for HTTP authorization in Ajax calls introduced with #6366. Closes #6638 [jmecham] + +* Add Enumerable.size() to count elements in an enumerable and the corresponding Array.size() method, fixes #6710 [ZenCocoon] + +* Add String.succ() method to allow for String ranges, fixes #6037 [Cory Hudson, mislav] + Examples: + 'abcd'.succ(); -> 'abce' + $R('a','d').map(function(char){ return char; }); -> ['a','b','c','d'] + +* Make Element.scrollTo() correctly consider offsets of parent DOM nodes, fixes #6625 [ohader, savetheclocktower] + +* Fix Enumerable.inGroupsOf() to correctly work with fill values that evaluate to false, fixes #6782 [hawk] + +* Remove/cleanup redundant $() calls in dom.js, fixes #6817 [Tobie] + +* Don't cache files in automatic unit tests, fixes #6218 [voidlock] + +* Add $w() to easily create arrays from strings like Ruby's %w, fixes #5682 [glazedginger, brendon.aaron] + +* Add Element.toggleClassName() to toggle CSS classes on elements, fixes #6759 [Tobie] + +* Make Form.getInputs always return an array for consistency, fixes #6475 [Justin Gehtland, savetheclocktower] + +* Make TimedObserver work correctly for SELECT MULTIPLE elements, fixes #6593 [clemos, tdd] + +* Fix Template.prototype.evaluate to correctly interpret 0 and false values, add String.interpret() for safely interpreting and converting values to strings, fixes #6675 [hawk] + +* Make Element.getStyle() work with camelCased argument, fixes #6686 [Tobie] + +* Fix a redundant check in Array.prototype.compact, fixes #4739 [wlodarcz, mislav] + +* Fix $() to correctly pass back the results of document.getElementById(), notably returning "null" on elements not found, fixes #6582 [adsmart] + +* Change/add assertNull, assertUndefined, assertNullOrUndefined and not-* variants in unittest.js, fixes #6582 [adsmart] + +* Cleanup String.prototype.camelize, fix an issue with String.prototype.underscore, fixes #4714, #6685 [Tobie, Thomas Fuchs] + +* Add String.prototype.capitalize, which returns a string with the first character in upper case, fixes #6666 [Tobie] + +* Make Element.getStyle() and Element.setStyle() handle the CSS 'opacity' property transparently in IE, fixes #6093 [brandon.aaron, Tobie] + +* Fix handling of CSS 'float' property for Element.getStyle() and Element.setStyle(), fixes #4160 [Thomas Fuchs, ericf] + +* Fix that onComplete would be called twice with synchronous Ajax requests on Safari (provides units tests for #5756) [Thomas Fuchs] + +* Fix Form.Field.activate to not select text on buttons in IE, fixes #2653 [sutch, mislav, Thomas Fuchs] + +* Fix String.unescapeHTML() on Firefox for strings that are longer than 2048 bytes, fixes #5789 [Paul Moers, Thomas Fuchs] + +* Redefine Array.prototype.concat for Opera, as the native implemenation doesn't work correctly [Thomas Fuchs] + +* Add unit tests for Function.prototype.bind() [Thomas Fuchs] + +* Add String.prototype.underscore and String.prototype.dasherize [Thomas Fuchs] + Examples: + 'Hello_World'.dasherize() -> 'Hello-World' + 'borderBottomWidth'.underscore() -> 'border_bottom_width' + 'borderBottomWidth'.underscore().dasherize() -> 'border-bottom-width' + +*1.5.0_rc2* (November 11, 2006) + +* Ensure that existing DOM properties take precedence over extended element methods in all browsers. Closes #5115. [Sean Kleinjung, sam] + +* Add Element.Methods.readAttribute as a simple wrapper around getAttribute (which isn't a "real" function and doesn't have .apply or .call in Safari and IE). Useful in conjunction with Enumerable.invoke for extracting the values of a custom attribute from a collection of elements. [sam] + Example: + <div id="widgets"> + <div class="widget" widget_id="7">...</div> + <div class="widget" widget_id="8">...</div> + <div class="widget" widget_id="9">...</div> + </div> + + $$('div.widget').invoke('readAttribute', 'widget_id') + // ["7", "8", "9"] + +* Add Element.Methods.immediateDescendants, like $A($(element).childNodes) but without text nodes. [sam] + +* More consistency. Closes #6573. [Bob Silva] + +* String.prototype.toQueryParams and Hash.prototype.toQueryString now properly serialize arrays as multiple values. Closes #4436. [mislav, altblue, L`OcuS] + +* Fix Form.serialize for options with empty values. Closes #5033. [tdd, Thomas Fuchs, sam] + +* Add Element.Methods.Simulated for simulating HTMLElement methods in lesser browsers. Add hasAttribute as the first simulated method. [tdd, Thomas Fuchs, sam] + +* Add a "retry with throw" button for test error messages. [sam] + +* rake test now runs test/unit/*.html by default. Additionally, you can specify individual tests to run with the TESTS environment variable, and you can restrict the tests to particular browsers using the BROWSERS environment variable. [sam] + + Examples: + % BROWSERS=safari,firefox rake test + % TESTS=dom rake test + +* Element.hasClassName now bypasses the Element.ClassNames API for performance. [sam] + +* Pick some low-hanging performance and DRYness fruit. [sam] + - Inline length property accesses in for loops + - Enumerable-ize for loops where it makes sense + - Make better use of Element.Methods and Form.Methods/Form.Element.Methods + +* A slew of Ajax improvements. Closes #6366. [mislav, sam] + + Public-facing changes include: + - HTTP method can be specified in either lowercase or uppercase, and uppercase is always used when opening the XHR connection + - Added 'encoding' option (for POST) with a default of 'UTF-8' + - Ajax.Request now recognizes all the JavaScript MIME types we're aware of + - PUT body support with the 'postBody' option + - HTTP authentication support with the 'username' and 'password' options + - Query parameters can be passed as a string or as a hash + - Fixed both String.toQueryParams and Hash.toQueryString when handling empty values + - Request headers can now be specified as a hash with the 'requestHeaders' option + +* Improve performance of the common case where $ is called with a single argument. Closes #6347. [sam, rvermillion, mislav] + +* Fix Object.inspect to correctly distinguish between null and undefined, fixes #5941 [tdd, mislav] + +* Don't serialize disabled form elements, fixes #4586 [tdd] + +* Make HTML element classes extension mechanism for Safari not throw errors on WebKit beta versions [Thomas Fuchs] + +* Add support for using Element.update() with no or a non-string parameter [Thomas Fuchs] + + Example: + $('empty_me').update() -> clears the element + $('easy_as').update(123) -> set element content to '123' + +* Add unit tests for hashes, fixes #6344 [Tobie Langel] + +* Add clone() method to arrays, fixes #6338 [Tobie Langel] + +* Backing out of [5194] (Element.clear) because of issues with IE on certain elements, #6051 + +* Add Element.clear for easily emptying out elements, fixes #6051 [bra...@gm...] + +* Enumerable.each now returns the enumerable to allow for method chaining, fixes #6250 [eventualbuddha] + +* Make makeClipping and undoClipping always return their element to stay chainable + +* Fix an issue with certain Element chain calls not correctly extending elements with Prototype element methods on IE [Thomas Fuchs] + +* Add Enumerable.eachSlice and Enumerable.inGroupsOf, fixes #6046 [ra...@td..., Thomas Fuchs] + + Example: + [1,2,3,4,5].inGroupsOf(3) -> [[1,2,3],[4,5,null]] + [1,2,3].inGroupsOf(4,'x') -> [[1,2,3,'x']] + +* Complete unit tests for array.js and string.js [Thomas Fuchs] + +* Performance improvements for document.getElementsByClassName, including querying with XPath in supported browsers. [Andrew Dupont] + +* Make Form.getElements() return elements in the correct order, fix broken Form.serialize return, fixes #4249, #6172 [la...@pi..., Thomas Fuchs, john] + +* Add various DOM unit tests, fixes #6176, #6177 [tdd] + +* Split Form.serialize into Form.serialize and Form.serializeElements. The latter can be used stand-alone to serialize an array of elements you pass in, instead of the entire form [DHH] + +* Form.Element.disable() and .enable() will now work correctly, fixes #6034 [dre...@bu...] + +* Fix IE and Safari issues with Position.positionedOffset, add position.html unit tests, fixes #5621 [re...@ia...] + +* Fix an issue with Element.undoClipping and IE [Thomas Fuchs] + +* Element.cleanWhitespace now correctly removes consecutive empty text nodes, fixes #3209 [liv...@gm...] + +* Element.extend now does not try to extend text nodes, fixes #4642 [sie...@gm...] + +*1.5.0_rc1* (September 4, 2006) + +* bindAsEventListener now passes along any provided arguments after the event argument. Closes #5508. [tod...@re...] + +* Fix makeClipping and undoClipping with local overflow style values other than visible and hidden, fixes #3672 [Thomas Fuchs] + +* Add Element.up, Element.down, Element.previous, and Element.next for easily traversing the DOM. (Inspired by Thomas Fuchs' original implementation of Element.up: http://pastie.caboo.se/7702) [sam] + + Examples: + <div id="sidebar"> -> $('nav').up() or $('menu').up('div') + <ul id="nav"> -> $('sidebar').down() or $('sidebar').down('ul') or $('menu').previous() + <li>...</li> -> $('sidebar').down(1) or $('sidebar').down('li') + <li>...</li> -> $('sidebar').down(2) or $('sidebar').down('li', 2) or $('sidebar').down('li').next('li') + <li class="selected">...</li> -> $('sidebar').down('li.selected') + </ul> + <ul id="menu"> -> $('sidebar').down('ul').next() + ... + +* Refactor $$ and Element.getElementsBySelector into Selector.findChildElements. [sam] + +* Add Element.match, which takes a single CSS selector expression and returns true if it matches the element. [sam] + +* Add Element.ancestors, Element.descendants, Element.previousSiblings, Element.nextSiblings, and Element.siblings. [sam] + +* Add Element.inspect for better DOM debugging. [sam] + +* Add an optional boolean argument to String.prototype.inspect which, when true, makes the string double-quoted instead of single-quoted. [sam] + +* Add the uniq() method to Arrays, which returns a new Array with duplicates removed, fixes #3810 [secondlife] + +* Add stop() method to PeriodicalExecutor, fixes #4801 [Jon Evans] + +* Fix issues with Enumerable.any, ObjectRange.toArray, added unit tests, fixes #4419 [miyamuko, Thomas Fuchs] + +* Fix two instances of unneccesarily redeclared variables, fixes #5229 [Thomas Fuchs] + +* Fix a loop in Element.extend to properly use local variable, fixes #5128 [arrix] + +* Add constants for additional keys in Event, fixes #5411, #5795 [simone_b] + +* Workaround a DOM API bug in Opera in Position.page(), fixes #2407, #5848 [Thomas Fuchs] + +* Remove duplicate definition of Position.clone(), fixes #3765 [Thomas Fuchs] + +* Make destructive Element, Form, and Form.Element methods return their first argument, so that multiple calls can be chained together. [sam] + + ex. $("sidebar").addClassName("selected").show(); + + The following methods now return their first argument: Element.toggle, Element.hide, Element.show, Element.remove, Element.update, Element.replace, Element.addClassName, Element.removeClassName, Element.observe, Element.stopObserving, Element.cleanWhitespace, Element.scrollTo, Element.setStyle, Element.makePositioned, Element.undoPositioned, Element.makeClipping, Element.undoClipping, Form.reset, Form.disable, Form.enable, Form.focusFirstElement, Form.Element.focus, Form.Element.select, Form.Element.clear, Form.Element.activate, Form.Element.disable, Form.Element.enable. + +* For consistency, Element.toggle, Element.show, Element.hide, Field.clear, and Field.present no longer take an arbitrary number of arguments. [sam] + + !! BACKWARDS COMPATIBILITY CHANGE !! + + If you have code that looks like this: + Element.show('page', 'sidebar', 'content'); + You need to replace it with code like this: + ['page', 'sidebar', 'content'].each(Element.show); + +* Mix in Form and Form.Element methods to forms and form field elements with $() and $$(). Closes #4448. [Dan Webb, sam] + +* Add Object.clone [sam] + +* Add Form.Element.disable and Form.Element.enable. Closes #4943. [ja...@pr...] + +* Field is now simply an alias for Form.Element. [sam] + +* Add Element.Methods.getElementsByClassName and Element.Methods.getElementsBySelector. Closes #4669. [Andrew Dupont, DHH, sam] + +* Avoid race condition when stopping an Ajax.PeriodicalUpdater. Closes #4809. [e98...@gm...] + +* Improve support for synchronous requests. Closes #5916. [sam, jt...@gm...] + +* Add serialization and observation support for input type=search. Closes #4096. [rpn...@gm...] + +* Properly decode query components in String.prototype.toQueryParams. Closes #3487. [sam] + +* Add Array.prototype.reduce [sam]: + [1, 2].reduce() // [1, 2] + [1].reduce() // 1 + [].reduce() // undefined + +* Add Object.keys and Object.values [sam] + +* Simulate non-GET/POST requests by POSTing with a _method parameter set to the actual verb [DHH] + +* Make Element.update() handle TABLE-related elements with the DOM API because of IE's missing .innerHTML property on them [Thomas Fuchs, thx to Rick Olson] + +* Sync to script.aculo.us unittest.js library as of 2006/08/29 [Thomas Fuchs] + +* Add additional unit tests to test/unit/dom.html for testing Element.update and $().update in various enviroments [Thomas Fuchs] + +* Prevent possible exceptions on unloading the page in IE [Thomas Fuchs] + +*1.5.0_rc0* (April 5, 2006) + +* Modify HTMLElement.prototype and short-circuit Element.extend where possible. Closes #4477. [Thomas Fuchs] + +* Only observe window.onunload in IE for Mozilla bfcache support. Closes #3726. [Mike A. Owens] + +* Don't redefine Array.prototype.shift. Closes #4138. [leeo] + +* Prevent redefining Array.prototype.reverse more than once. Closes #3951. [bre...@gm...] + +* Fix Enumerable.min/Enumerable.max to recognize the value 0. Closes #3847, #4190. [rub...@br..., Martin Bialasinski] + +* Change Ajax.getTransport to prefer XMLHttpRequest in anticipation of IE 7. Closes #3688. [js...@ma..., sam] + +* Make Array.prototype.flatten more robust. Closes #3453. [Martin Bialasinski, sam] + +* Fix evalScripts from crashing Firefox if script includes 'var'. Closes #3288, #4165. [ra...@nt..., sam] + +* Scope iterators locally. Closes #4589. [sam] + +* Support Insertion.Before/Insertion.After for <tr> elements in IE. Closes #3925. [rai...@sn...] + +* Add a contentType option for overriding application/x-www-form-urlencoded in Ajax.Request. Closes #3564. [av...@ar..., sam] + +* Surround values in the X-JSON header in parenthesis for better compatibility with Firefox. Closes #4118. [big...@gm...] + +* Fix Form.serialize to properly encode option values in multiple selects in IE. Closes #3291. [rub...@br...] + +* Cache methods added to DOM elements with Element.extend to prevent memory leaks in IE. Closes #4465. [ja...@la..., sam] + +* 1.5.0_pre1* (March 26, 2006) + +* Add attribute selector support for Selector (and $$). Closes #4368. [dev...@gm...] + Example: + $$('form#foo input[type=text]').each(function(input) { + input.setStyle({color: 'red'}); + }); + +* Send Accept header containing 'text/javascript, text/html, application/xml, text/xml */*'' to inform Rails that we prefer RJS, but we'll take HTML or XML or whatever if you can't deliver the goods [DHH] + +* Make $$ work in IE. Closes #3715. [rub...@br...] + +* Add test/browser.html, which provides a simple object browser for the Prototype source (Firefox/Safari only). [sam] + +* Add Element.extend, which mixes Element methods into a single HTML element. This means you can now write $('foo').show() instead of Element.show('foo'). $, $$ and document.getElementsByClassName automatically call Element.extend on any returned elements. [sam] + +* Add Element.replace as a cross-browser implementation of the "outerHTML" property. References #3246. [to...@cr...] + +* Fix Enumerable.zip iterator behavior. [Marcin Kaszynski, sam] + +*1.5.0_pre0* (January 18, 2006) + +* Add String.prototype.truncate to complement the Action View truncate helper. [sam] + +* Add String.prototype.gsub, String.prototype.sub, and String.prototype.scan, all of which take a pattern and an iterator (or a pattern and a replacement template string in the case of gsub and sub). [sam] + +* Add a Template class for interpolating named keys from an object in a string. [sam] + +* Add the $$ function for finding DOM elements by simple CSS selector strings. [sam] + Example: Find all <img> elements inside <p> elements with class "summary", all inside + the <div> with id "page". Hide each matched <img> tag. + $$('div#page p.summary img').each(Element.hide) + +* Add a Selector class for matching elements by single CSS selector tokens. [sam] + +* Add Test.Unit.Assertions.assertEnumEqual for comparing Enumerables in tests. [sam] + +* Add Element.childOf(element, ancestor) which returns true when element is a child of ancestor. [sam] + +* Fix escaping in String.prototype.inspect. [sam] + +* Add String.prototype.strip to remove leading and trailing whitespace from a string. [sam] + +* Move Prototype to Rails SVN. [sam] + http://dev.rubyonrails.org/svn/rails/spinoffs/prototype/ + +* Make the console nicer. [sam] + +* Prune the source tree. [sam] Added: trunk/linpha2/lib/js/prototype-1.6.0/LICENSE =================================================================== --- trunk/linpha2/lib/js/prototype-1.6.0/LICENSE (rev 0) +++ trunk/linpha2/lib/js/prototype-1.6.0/LICENSE 2007-11-18 22:29:28 UTC (rev 4800) @@ -0,0 +1,16 @@ +Copyright (c) 2005-2007 Sam Stephenson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. Added: trunk/linpha2/lib/js/prototype-1.6.0/README =================================================================== --- trunk/linpha2/lib/js/prototype-1.6.0/README (rev 0) +++ trunk/linpha2/lib/js/prototype-1.6.0/README 2007-11-18 22:29:28 UTC (rev 4800) @@ -0,0 +1,55 @@ += Prototype +==== An object-oriented JavaScript framework + +Prototype is a JavaScript framework that aims to ease development of dynamic +web applications. It offers a familiar class-style OO framework, extensive +Ajax support, higher-order programming constructs, and easy DOM manipulation. + +=== Targeted platforms + +Prototype currently targets the following platforms: + +* Microsoft Internet Explorer for Windows, version 6.0 and higher +* Mozilla Firefox 1.0/Mozilla 1.7 and higher +* Apple Safari 1.2 and higher + +== Using Prototype + +To use Prototype in your application, download the latest release from the +Prototype web site (http://prototypejs.org/download) and copy +<tt>dist/prototype.js</tt> to a suitable location. Then include it in your HTML +like so: + + <script type="text/javascript" src="/path/to/prototype.js"></script> + +=== Building Prototype from source + +<tt>prototype.js</tt> is a composite file generated from many source files in +the <tt>src/</tt> directory. To build Prototype, you'll need: + +* a copy of the Prototype source tree, either from a distribution tarball or + from the Subversion repository (see below) +* Ruby 1.8.2 or higher (http://www.ruby-lang.org/) +* Rake -- Ruby Make (http://rake.rubyforge.org/) +* RDoc, if your Ruby distribution does not include it + +From the root Prototype directory, + +* <tt>rake dist</tt> will preprocess the Prototype source using ERB and + generate the composite <tt>dist/prototype.js</tt>. +* <tt>rake package</tt> will create a distribution tarball in the + <tt>pkg/</tt> directory. + +== Contributing to Prototype + +Check out the Prototype source with + $ svn co http://svn.rubyonrails.org/rails/spinoffs/prototype/trunk/ prototype + +Find out how to contribute: + http://prototypejs.org/contribute + +== Documentation + +Please see the online Prototype API: + http://prototypejs.org/api + Added: trunk/linpha2/lib/js/prototype-1.6.0/Rakefile =================================================================== --- trunk/linpha2/lib/js/prototype-1.6.0/Rakefile (rev 0) +++ trunk/linpha2/lib/js/prototype-1.6.0/Rakefile 2007-11-18 22:29:28 UTC (rev 4800) @@ -0,0 +1,59 @@ +require 'rake' +require 'rake/packagetask' + +PROTOTYPE_ROOT = File.expand_path(File.dirname(__FILE__)) +PROTOTYPE_SRC_DIR = File.join(PROTOTYPE_ROOT, 'src') +PROTOTYPE_DIST_DIR = File.join(PROTOTYPE_ROOT, 'dist') +PROTOTYPE_PKG_DIR = File.join(PROTOTYPE_ROOT, 'pkg') +PROTOTYPE_VERSION = '1.6.0' + +task :default => [:dist, :package, :clean_package_source] + +task :dist do + $:.unshift File.join(PROTOTYPE_ROOT, 'lib') + require 'protodoc' + + Dir.chdir(PROTOTYPE_SRC_DIR) do + File.open(File.join(PROTOTYPE_DIST_DIR, 'prototype.js'), 'w+') do |dist| + dist << Protodoc::Preprocessor.new('prototype.js') + end + end +end + +Rake::PackageTask.new('prototype', PROTOTYPE_VERSION) do |package| + package.need_tar_gz = true + package.package_dir = PROTOTYPE_PKG_DIR + package.package_files.include( + '[A-Z]*', + 'dist/prototype.js', + 'lib/**', + 'src/**', + 'test/**' + ) +end + +task :test => [:dist, :test_units] + +require 'test/lib/jstest' +desc "Runs all the JavaScript unit tests and collects the results" +JavaScriptTestTask.new(:test_units) do |t| + tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',') + browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',') + + t.mount("/dist") + t.mount("/test") + + Dir["test/unit/*.html"].sort.each do |test_file| + test_file = "/#{test_file}" + test_name = test_file[/.*\/(.+?)\.html/, 1] + t.run(test_file) unless tests_to_run && !tests_to_run.include?(test_name) + end + + %w( safari firefox ie konqueror opera ).each do |browser| + t.browser(browser.to_sym) unless browsers_to_test && !browsers_to_test.include?(browser) + end +end + +task :clean_package_source do + rm_rf File.join(PROTOTYPE_PKG_DIR, "prototype-#{PROTOTYPE_VERSION}") +end Added: trunk/linpha2/lib/js/scriptaculous-js-1.8.0/CHANGELOG =================================================================== --- trunk/linpha2/lib/js/scriptaculous-js-1.8.0/CHANGELOG (rev 0) +++ trunk/linpha2/lib/js/scriptaculous-js-1.8.0/CHANGELOG 2007-11-18 22:29:28 UTC (rev 4800) @@ -0,0 +1,1147 @@ +*V1.8.0* (November 6, 2007) + +* Update to Prototype 1.6.0 final + +* Ajax.InPlaceEditor now can deal with callbacks that return an object. Closes #10064. [tdd] + +* Fix a potential problem with the loader and Firefox 2.0 on the Mac. Closes #9951. [awaters] + +* Add duration and distance options to Effect.Shake. Closes #8637. [amiel, rmm5t] + +* Update code to use new Hash implemention in Prototype 1.6. Update InPlaceEditor to use new Class.create syntax. [tdd] + +*V1.8.0 preview 0* (October 12, 2007) + +* Update to new Class.create syntax in Prototype 1.6; update to latest Prototype 1.6 trunk. + +* Fix bottom CSS property reassignment and initialization in queues for Effect#SlideUp. Closes #7412, #7761. + +* Fix an issue with String#parseStyle that could sometimes cause errors on Safari 2. + +* Refactoring to use Prototype 1.6. Remove dependency of Effect.tagifyText from builder. Use Prototype code style rules more consistently. + +* Remove the deprecated Effect2 namespace. + +* Update to Prototype 1.6.0_rc0. + +* Some effect code refactoring to take advantage of new Prototype 1.6 features. + +* Effect.ScrollTo is now no longer a core effect (returns a Effect.Tween instance now). + +* Add Effect.Tween, a new core effect. This effect tweens between two values and sets a property or calls a method on an object (including DOM elements); or allows for a ca... [truncated message content] |
From: <fan...@us...> - 2007-11-20 22:04:24
|
Revision: 4801 http://linpha.svn.sourceforge.net/linpha/?rev=4801&view=rev Author: fangehrn Date: 2007-11-20 14:04:16 -0800 (Tue, 20 Nov 2007) Log Message: ----------- 2007-11-20 flo * finished basic part of the map plugin now working: - creating markers - deleting markers - assign albums to markers - change/delete assigned albums - load/show gps images - create thumbnail list - image navigation Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/include/sql.data.php trunk/linpha2/lib/plugins/maps/LinMaps.js trunk/linpha2/lib/plugins/maps/class.googlemaps.js trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/templates/default/maps.head.php trunk/linpha2/templates/default/maps.html.php trunk/linpha2/templates/default/themes/default/colorsettings.php trunk/linpha2/templates/default/themes/default/css/maps.css Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/ChangeLog 2007-11-20 22:04:16 UTC (rev 4801) @@ -1,3 +1,15 @@ + +2007-11-20 flo + * finished basic part of the map plugin + now working: + - creating markers + - deleting markers + - assign albums to markers + - change/delete assigned albums + - load/show gps images + - create thumbnail list + - image navigation + 2007-11-18 flo * installer - some UI improvements Modified: trunk/linpha2/lib/include/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql.data.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/lib/include/sql.data.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -114,6 +114,7 @@ 'plugins_maps_defaultMarkerZoom' => '10', 'plugins_maps_mapType' => 'google', 'plugins_maps_google_key' => 'ABQIAAAAAXCMfho4_sqSSh0VqMB80xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSfO_6bbb_ScfT_zPgcnJMKyGltOg', // key for http://localhost + 'plugins_maps_markerThumbSize' => '350', ); Modified: trunk/linpha2/lib/plugins/maps/LinMaps.js =================================================================== --- trunk/linpha2/lib/plugins/maps/LinMaps.js 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/lib/plugins/maps/LinMaps.js 2007-11-20 22:04:16 UTC (rev 4801) @@ -19,6 +19,7 @@ this.markersData = false; this.markersObj = new Array(); + this.imagesObj = new Array(); }, /** @@ -55,7 +56,7 @@ for( i = 0; i < myLinMaps.markersData.markers.length; i++ ) { - myLinMaps.markersObj[i] = myLinMapObject.createMarker( myLinMaps.markersData.markers[i] ); + myLinMaps.markersObj[i] = myLinMapObject.createMarker( myLinMaps.markersData.markers[i], false ); } /** @@ -134,15 +135,29 @@ assignAlbum: function(markerId,albId) { - alert( markerId + ' ' + albId ); myLinGlobal.AjaxPost('cmd=assignAlbum&markerId='+markerId+'&albId='+albId,myLinMaps.assignAlbumFinish); }, - assignAlbumFinsih: function(t) + assignAlbumChange: function(markerId,albId) { + myLinGlobal.AjaxPost('cmd=assignAlbumChange&markerId='+markerId+'&albId='+albId,myLinMaps.assignAlbumFinish); + }, + assignAlbumDelete: function(markerId,albId) { + myLinGlobal.AjaxPost('cmd=assignAlbumDelete&markerId='+markerId+'&albId='+albId,myLinMaps.assignAlbumFinish); }, - deleteAssignedAlbum: function(markerId,albId) + assignAlbumFinish: function(t) { + xmlAnswer = t.responseXML.documentElement; + // recreate marker on success + if( xmlAnswer.getElementsByTagName('responseCode').item(0).firstChild.data == 'success' ) + { + myLinMaps.loadMarkers(); + } + else + { + // print error message + alert(xmlAnswer.getElementsByTagName('responseMsg').item(0).firstChild.data ); + } }, loadAlbums: function() @@ -163,9 +178,16 @@ myLinGlobal.createPopup('linDivPopupAlbums'); }, - + + /** + * Thumbnail functions + */ loadImages: function(albId) { + this.startLoading(); + + myLinMapObject.closeMarkerWindows(); + if( !this.showNav ) { this.toggleNav(); } @@ -179,47 +201,49 @@ //myLinMaps.images = t.responseText.evalJSON(true); /** + * delete existing images + */ + $('linDivMapNav').innerHTML = ''; + if( myLinMaps.imagesObj ) + { + for( i = 0; i < myLinMaps.imagesObj.length; i++ ) + { + myLinMapObject.removeMarker( myLinMaps.imagesObj[i] ); + } + + myLinMaps.imagesObj = new Array(); + } + + + /** * draw new markers / create thumbnails list */ - $('linDivMapNav').innerHTML = ''; - //myLinMapObject.initBounds(); + myLinMapObject.initBounds(); for( i = 0; i < myLinMaps.imagesData.images.length; i++ ) { thumbId = myLinMaps.imagesData.images[i].id; - var ElemImg = Builder.node('img', {src: thumbSrc + thumbId, width: displayThumbSize, height: displayThumbSize}); - var ElemA = Builder.node('a', {href: 'javascript:myLinMaps.openImage(' + i + ')'}); + var ElemImg = Builder.node('img', {src: thumbSrc + thumbId, className: 'linImgMapThumb', width: displayThumbSize, height: displayThumbSize}); + var ElemA = Builder.node('a', {id: "thumb_"+thumbId, href: 'javascript:myLinMapObject.openImage(' + i + ')'}); var ElemDiv = Builder.node('div', {className: 'linDivMapsThumb'}); ElemA.appendChild( ElemImg ); ElemDiv.appendChild( ElemA ); $('linDivMapNav').appendChild(ElemDiv); - //myLinMaps.imagesObj[i] = myLinMapObject.createMarker( myLinMaps.imagesData.images[i] ); - + if( i == 0 ) + myLinMaps.imagesObj[i] = myLinMapObject.createMarker( myLinMaps.imagesData.images[i], true ); + else + myLinMaps.imagesObj[i] = myLinMapObject.createMarker( myLinMaps.imagesData.images[i], false ); } - //myLinMapObject.updateCenter(); + myLinMapObject.updateCenter(0); + + myLinMaps.stopLoading(); }, - - openImage: function(imgIndex) - { - alert( myLinMaps.imagesData.images[imgIndex].lat + ' ' + myLinMaps.imagesData.images[imgIndex].lon); - }, - -/* getMarkerInfo: function( markerNode ) // maybe use markerId oder markerIndex (but that could be unsafe) - { - var infoStr = '<b>' + markerNode.name + '</b><br />' + markerNode.text; - - return infoStr; - },*/ - - /** - * Thumbnail functions - */ toggleNav: function() { @@ -247,6 +271,15 @@ // update google map size myLinMapObject.checkResize(); + }, + + + + startLoading: function() { + Element.show('linDivLoadingOuter'); + }, + stopLoading: function() { + Element.hide('linDivLoadingOuter'); } Modified: trunk/linpha2/lib/plugins/maps/class.googlemaps.js =================================================================== --- trunk/linpha2/lib/plugins/maps/class.googlemaps.js 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/lib/plugins/maps/class.googlemaps.js 2007-11-20 22:04:16 UTC (rev 4801) @@ -89,7 +89,7 @@ googlemap.setCenter(this.bounds.getCenter(), zoom); }, - createMarker: function( markerNode ) + createMarker: function( markerNode, markerType, openMarker ) { /*var icon = new GIcon(); icon.image = image[0]; @@ -135,7 +135,24 @@ //alert( markerNode.id + ' ' + markerNode.name + ' ' + markerNode.lat + ' ' + markerNode.lon); var point = new GLatLng( markerNode.lat, markerNode.lon); - var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/blue-dot.png") + + switch(markerNode.type) { + case 'album': + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/blue-dot.png") + break; + case 'marker': + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/purple-dot.png") + break; + case 'albumWithImg': + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/green-dot.png") + break; + case 'images': + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/yellow-dot.png") + break; + default: + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/blue-dot.png") + break; + } icon.iconSize = new GSize(32, 32); var marker = new GMarker(point, icon); @@ -147,6 +164,10 @@ this.bounds.extend(point); + if( openMarker ) { + GEvent.trigger(marker, 'click'); + } + return marker; }, @@ -180,11 +201,20 @@ myLinMaps.updateEditMarker(); }, + closeMarkerWindows: function() { + googlemap.closeInfoWindow(); + }, + removeMarker: function( marker) { googlemap.removeOverlay( marker ); }, + openImage: function(imgIndex) + { + GEvent.trigger(myLinMaps.imagesObj[imgIndex], 'click'); + }, + checkResize: function() { //alert("typeof googlemap.checkResize: " + typeof googlemap.checkResize ); Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -50,23 +50,28 @@ while($data = $query->FetchRow()) { - $path = htmlspecialchars($data['albPath'],ENT_QUOTES); - - /*if($allowed) { - if( $data['albId'] != 0 ) { - $text = '<a href=\'javascript:myLinMaps.assignAlbumChange('.$data['id'].','.$data['albId'].')\'>'.i18n("Change Assigned Album").'</a>' . - '<br /><a href=\'javascript:myLinMaps.deleteAssignedAlbum('.$data['id'].','.$data['albId'].')\'>'.i18n("Delete Assigned Album").'</a>'; + if( $data['albId']!=0 ) { + + $query2 = $GLOBALS['linpha']->db->Execute("SELECT P.parent_id " . + "FROM ".LIN_PREFIX."meta_exif E INNER JOIN ".LIN_PREFIX."photos P on E.md5sum = P.md5sum " . + "WHERE gpslatituderef IS NOT NULL " . + "AND gpslatitude IS NOT NULL " . + "AND gpslongituderef IS NOT NULL " . + "AND gpslongitude IS NOT NULL " . + "AND P.parent_id = '".LinSql::linAddslashes($data['albId'])."'"); + if($query2->EOF) { + $type = 'album'; } else { - $text = '<a href=\'javascript:myLinMaps.assignAlbum('.$data['id'].',0)\'>'.i18n("Assign Album").'</a>'; + $type = 'albumWithImg'; } - - $text .= '<br /><a href=\'javascript:if(confirm(\'test\')){myLinMaps.deleteMarker('.$data['id'].')}\'>'.i18n("Delete Marker").'</a>'; - + } else { - $text = $path; - }*/ + $type = 'marker'; + } + + $path = htmlspecialchars($data['albPath'],ENT_QUOTES); - echo '{"id": '.$data['id'].', "albId": '.$data['albId'].', "path": "'.$path.'", ' . + echo '{"id": '.$data['id'].', "type": "'.$type.'", "albId": '.$data['albId'].', "path": "'.$path.'", ' . '"name": "'.htmlspecialchars($data['markerName'],ENT_QUOTES).'", ' . '"lat": '.$data['markerLat'].', "lon": '.$data['markerLon'].', ' . '"zoom": '.$data['markerZoom'].'}'; @@ -176,6 +181,8 @@ break; case 'assignAlbum': + case 'assignAlbumChange': + case 'assignAlbumDelete': header('Content-type: text/xml'); echo '<?xml version="1.0" ?>'."\n"; @@ -196,8 +203,12 @@ $markerId = intval($_REQUEST['markerId']); $albId = intval($_REQUEST['albId']); + $arrAlbPath = LinSql::getFullFilenameFromId($albId); + $albPath = implode('/',$arrAlbPath); + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."plugins_maps_markers " . - "SET albId = '".LinSql::linAddslashes($albId)."' WHERE id='".LinSql::linAddslashes($markerId)."'"); + "SET albId = '".LinSql::linAddslashes($albId)."', " . + "albPath = '".LinSql::linAddslashes($albPath)."' WHERE id='".LinSql::linAddslashes($markerId)."'"); echo '<responseCode>success</responseCode>'."\n"; } @@ -278,7 +289,7 @@ $latlon = getExifLatLon($data); echo '{"id": '.$data['id'].', "parent_id": '.$data['parent_id'].', ' . - '"name": "'.htmlspecialchars( $data['name'] ,ENT_QUOTES).'", ' . + '"type": "images", "text": "", "name": "'.htmlspecialchars( $data['name'] ,ENT_QUOTES).'", ' . '"lat": '.$latlon['gpslatitude'].', "lon": '.$latlon['gpslongitude'] . "}"; Modified: trunk/linpha2/templates/default/maps.head.php =================================================================== --- trunk/linpha2/templates/default/maps.head.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/templates/default/maps.head.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -9,6 +9,7 @@ var displayThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>; var linMapsDefaultMarkerZoom = <?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; ?>; +var linMapsMarkerThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_markerThumbSize']; ?>; </script> <?php Modified: trunk/linpha2/templates/default/maps.html.php =================================================================== --- trunk/linpha2/templates/default/maps.html.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/templates/default/maps.html.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -30,12 +30,17 @@ <div id="linDivPopupHelp" style="display: none"> <div> - Legend:<br /> - (red) current marker<br /> - (yellow) location marker<br /> - (blue) location marker with assigned albums<br /> - (green) location marker with assigned images (GPS)<br /> - (pink) images<br /> + <b><?php echo i18n("Legend:"); ?></b><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/red-dot.png" style="vertical-align:middle" alt="red" /> + <?php echo i18n("Current Marker"); ?><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/purple-dot.png" style="vertical-align:middle" alt="blue" /> + <?php echo i18n("Location Marker"); ?><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/blue-dot.png" style="vertical-align:middle" alt="purple" /> + <?php echo i18n("Location Marker With Assigned Albums"); ?><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/green-dot.png" style="vertical-align:middle" alt="green" /> + <?php echo i18n("Location Marker With Assigned Images (GPS)"); ?><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/yellow-dot.png" style="vertical-align:middle" alt="yellow" /> + <?php echo i18n("Images"); ?><br /><br /> </div> <?php @@ -44,27 +49,27 @@ ?> <br /> <div> - Create marker:<br /> + <b>Create marker:</b><br /> 1. Enter address or just press "Geocode"<br /> 2. Drag the marker to fine adjust<br /> 3. Check marker name<br /> 4. Press "Save"<br /> <br /> - Assign albums:<br /> + <b>Assign albums:</b><br /> 1. Click on a marker<br /> 2. Press "Assign album"<br /> 3. Choose album and press "Save"<br /> 4. Repeat for multiple albums<br /> <br /> - Assign images to an album marker:<br /> + <b>Assign images to an album marker:</b><br /> This is done automatically. But it's required that your images have the GPS information stored inside. You will need a GPS Data Logger to do this automatically. It is also possible do it manually. Robogeo is a tool, but - it is not free. + it is not free.<br /> </div> <div> - Not assigned images:<br /> + <b>Not assigned images:</b><br /> albums/album1 (22 images)<br /> </div> <?php @@ -95,34 +100,64 @@ </fieldset> </div> +<div id="linDivLoadingOuter" style="display: none;" class="linBackground"> + <?php echo $linTpl->divRoundCorners('top'); ?> + <div id="linDivLoading"> + <img src="<?php echo LINPHA_CLIENT; ?>/lib/graphics/loading.gif" /> + </div> + <?php echo $linTpl->divRoundCorners('bottom'); ?> +</div> + <script language="JavaScript" type="text/javascript"> function linGetMarkerHtml(markerNode) { - var htmlStr = '<b>' + markerNode.name + '</b><br />' + markerNode.path; - <?php - if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + var htmlStr = '<b>' + markerNode.name + '</b><br />'; + + if( markerNode.type == 'images' ) { - ?> - htmlStr += '<br /><br /><form><select name="linInputAlbum" style="width: 250px;"><?php - linBuildAlbumSelect($with_all_albs_entry=false,$with_linebreaks=false); ?></select><br />'; + htmlStr += '<img src="'+imageSrc+markerNode.id+'" width="' + + linMapsMarkerThumbSize+'" >' + markerNode.text; - if(markerNode.albId != 0) + $('thumb_'+markerNode.id).focus(); + } + else + { + + if( markerNode.albId != 0 ) { + htmlStr += '<?php echo i18n("Album"); ?>: ' + markerNode.path + '<br />'; + + if( markerNode.type == 'albumWithImg') { + htmlStr += '<a href="javascript:myLinMaps.loadImages('+ markerNode.albId +')"><?php + echo i18n("Open Images"); ?></a><br />'; + } + } + + <?php + if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) { - htmlStr += '<input type="button" value="<?php echo i18n("Change Assigned Album"); - ?>" onclick="myLinMaps.assignAlbumChange(' + markerNode.id + ',this.form.linInputAlbum.value)">' + - '<br /><input type="button" value="<?php echo i18n("Delete Assigned Album"); - ?>" onclick="myLinMaps.deleteAssignedAlbum(' + markerNode.id + ',' + markerNode.albId + ')">'; - } else { - htmlStr += '<input type="button" value="<?php echo i18n("Assign Album"); - ?>" onclick="myLinMaps.assignAlbum(this.form.linInputAlbum.value)">'; + ?> + htmlStr += '<br /><fieldset style="width: 350px;"><legend><?php + echo i18n("Edit Marker"); ?></legend><form><select name="linInputAlbum" style="width: 250px;"><?php + linBuildAlbumSelect($with_all_albs_entry=false,$with_linebreaks=false); ?></select><br />'; + + if(markerNode.albId != 0) + { + htmlStr += '<input type="button" value="<?php echo i18n("Change Assigned Album"); + ?>" onclick="myLinMaps.assignAlbumChange(' + markerNode.id + ',this.form.linInputAlbum.value)">' + + '<input type="button" value="<?php echo i18n("Delete"); + ?>" onclick="myLinMaps.assignAlbumDelete(' + markerNode.id + ',0)"><br /><br />'; + } else { + htmlStr += '<input type="button" value="<?php echo i18n("Assign Album"); + ?>" onclick="myLinMaps.assignAlbum(' + markerNode.id + ', this.form.linInputAlbum.value)">'; + } + + htmlStr += '<input type="button" value="<?php echo i18n("Delete Marker"); ?>" onclick="if(confirm(\'<?php + echo sprintf(LIN_STR_CONFIRMDELETE, i18n("this marker")); + ?>\')){myLinMaps.deleteMarker(' + markerNode.id + ');}"></form></fieldset>'; + <?php } - - htmlStr += '<input type="button" value="<?php echo i18n("Delete Marker"); ?>" onclick="if(confirm(\'<?php - echo sprintf(LIN_STR_CONFIRMDELETE, i18n("this marker")); - ?>\')){myLinMaps.deleteMarker(' + markerNode.id + ');}"></form>'; - <?php + ?> } - ?> return htmlStr; } Modified: trunk/linpha2/templates/default/themes/default/colorsettings.php =================================================================== --- trunk/linpha2/templates/default/themes/default/colorsettings.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/templates/default/themes/default/colorsettings.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -26,7 +26,7 @@ background-color: #<?php echo $_GET['bodybg']; ?>; } - #linDivMainOuter, #linDivMetaStaticOuter, #linDivNavigationOuter, .linButton, #linDivThumbnaviOuter, #linDivSlideshowControls, .roundAlphabottomInner { + #linDivMainOuter, #linDivMetaStaticOuter, #linDivNavigationOuter, .linButton, #linDivThumbnaviOuter, #linDivSlideshowControls, .roundAlphabottomInner, .linBackground { background-color: #<?php echo $_GET['bg']; ?>; } Modified: trunk/linpha2/templates/default/themes/default/css/maps.css =================================================================== --- trunk/linpha2/templates/default/themes/default/css/maps.css 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/templates/default/themes/default/css/maps.css 2007-11-20 22:04:16 UTC (rev 4801) @@ -1,3 +1,8 @@ + +form { + margin: 0; +} + #linDivMapMain { height: 675px; } @@ -39,12 +44,28 @@ background-color: white; } -#linDivEditMarker form { - margin: 0; -} .linInputEditMarker { display: block; float: left; width: 125px; -} \ No newline at end of file +} + +.linImgMapThumb { + border: 1px solid grey; +} + +#linDivLoadingOuter { + position: absolute; + top: 40%; + left: 40%; + z-index: 100; +} + +#linDivLoading { + width: 50px; + height: 30px; + + padding-top: 3px; + padding-left: 20px; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2007-12-01 15:58:53
|
Revision: 4802 http://linpha.svn.sourceforge.net/linpha/?rev=4802&view=rev Author: fangehrn Date: 2007-12-01 07:58:31 -0800 (Sat, 01 Dec 2007) Log Message: ----------- 2007-12-01 flo * creating plugin interface - moved whole install/sql folder to lib/include/sql we need still that files if we want to dynamically create the plugin tables Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/maintenance_db.php trunk/linpha2/admin/settings.php trunk/linpha2/lib/classes/linpha.admin.class.php Added Paths: ----------- trunk/linpha2/admin/settings_plugins.php trunk/linpha2/lib/include/sql/ trunk/linpha2/lib/include/sql/sql.data.php trunk/linpha2/lib/plugins/filemanager/ trunk/linpha2/lib/plugins/filemanager/settings.filemanager.php trunk/linpha2/lib/plugins/guestbook/ trunk/linpha2/lib/plugins/log/ trunk/linpha2/lib/plugins/log/settings.log.php trunk/linpha2/lib/plugins/maillist/ trunk/linpha2/lib/plugins/rss/ trunk/linpha2/lib/plugins/stats/ Removed Paths: ------------- trunk/linpha2/install/sql/ trunk/linpha2/lib/include/sql.data.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-11-20 22:04:16 UTC (rev 4801) +++ trunk/linpha2/ChangeLog 2007-12-01 15:58:31 UTC (rev 4802) @@ -1,4 +1,10 @@ +2007-12-01 flo + * creating plugin interface + - moved whole install/sql folder to lib/include/sql + we need still that files if we want to dynamically create the + plugin tables + 2007-11-20 flo * finished basic part of the map plugin now working: Modified: trunk/linpha2/admin/maintenance_db.php =================================================================== --- trunk/linpha2/admin/maintenance_db.php 2007-11-20 22:04:16 UTC (rev 4801) +++ trunk/linpha2/admin/maintenance_db.php 2007-12-01 15:58:31 UTC (rev 4802) @@ -1,6 +1,31 @@ <?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ /** + * This file updates the database + * @package DB + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +/** * check if each photo has a parent element */ echo '<h2>'.i18n("Checking photos table").'</h2>'; Modified: trunk/linpha2/admin/settings.php =================================================================== --- trunk/linpha2/admin/settings.php 2007-11-20 22:04:16 UTC (rev 4801) +++ trunk/linpha2/admin/settings.php 2007-12-01 15:58:31 UTC (rev 4802) @@ -9,6 +9,7 @@ $array_menu = array( 'layout' => array('name' => i18n("Layout"), 'link' => 'settings_layout'), 'features' => array('name' => i18n("Features"), 'link' => 'settings_features'), + 'plugins' => array('name' => i18n("Plugins"), 'link' => 'settings_plugins'), 'others' => array('name' => i18n("Others"), 'link' => 'settings_others'), 'all' => array('name' => i18n("All"), 'link' => 'settings_all') ); @@ -23,6 +24,9 @@ case 'features': include_once(LINPHA_DIR.'/admin/settings_features.php'); break; + case 'plugins': + include_once(LINPHA_DIR.'/admin/settings_plugins.php'); + break; case 'others': break; case 'all': Added: trunk/linpha2/admin/settings_plugins.php =================================================================== --- trunk/linpha2/admin/settings_plugins.php (rev 0) +++ trunk/linpha2/admin/settings_plugins.php 2007-12-01 15:58:31 UTC (rev 4802) @@ -0,0 +1,77 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +if(!isset($cat3)) +{ + $cat3 = 'enable'; +} + +$arrPlugins = explode(',',$LinAdmin->option_value_system['plugins_available']); + +/** + * save settings before showing menu + */ + if($cat3=='enable' && isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + foreach($arrPlugins as $value) + { + $arrPlugins2[] = 'plugins_'.$value.'_enable'; + } + + $LinAdmin->saveConfig($arrPlugins2); + + /** + * create database tables if necessary + */ + foreach($arrPlugins2 as $value) + { + if( isset($_POST[$value]) && $_POST[$value]=='1' ) + { + + } + } + } + +/** + * show menu + */ +$array_menu = array( + 'enable' => array('name' => i18n("Enable/Disable Plugins"), 'link' => 'settings_plugins_enable'), +); +foreach( $arrPlugins as $key=>$value) +{ + if($LinAdmin->option_value_system['plugins_'.$value.'_enable'] == '1') + { + $array_menu[$value] = array( + 'name' => $LinAdmin->description_array['plugins_'.$value], + 'link' => 'settings_plugins_'.$value + ); + } +} + +LinAdmin::printAdminMenu($array_menu,$cat3); +?> + +<form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_plugins_'.$cat3; ?>"> +<?php +if($cat3=='enable') +{ + foreach( $arrPlugins as $key=>$value) + { + $LinAdmin->printAdminConfig( + 'radio', + $LinAdmin->getDescriptionByOptionName('plugins_'.$value), + 'plugins_'.$value.'_enable', + $LinAdmin->option_value_system['plugins_'.$value.'_enable'] + ); + } +} +elseif(in_array($cat3,$arrPlugins)) // prevent including evil file +{ + $includeFile = LINPHA_DIR.'/lib/plugins/'.$cat3.'/settings.'.$cat3.'.php'; + if( file_exists($includeFile)) + { + include_once($includeFile); + } +} +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php 2007-11-20 22:04:16 UTC (rev 4801) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2007-12-01 15:58:31 UTC (rev 4802) @@ -77,6 +77,17 @@ 'sys_style_layout_color_links' => i18n("Links Color"), 'sys_style_layout_color_linkshover' => i18n("Links Hover Color"), 'sys_style_layout_color_fields' => i18n("Color Of Input and Select fields"), + + // plugin names + 'plugins_log' => i18n("Logging"), + 'plugins_filemanager' => i18n("Filemanager"), + 'plugins_maps' => i18n("Maps"), + 'plugins_guestbook' => i18n("Guestbook"), + 'plugins_stats' => i18n("Statistics"), + 'plugins_maillist' => i18n("Mailing List"), + 'plugins_rss' => i18n("RSS"), + 'plugins_watermark' => i18n("Watermark"), + 'plugins_log_filename' => i18n("Log to this filename"), 'plugins_log_syslog_enable' => i18n("Send important messages to syslog"), @@ -96,7 +107,7 @@ ?> <ul class="linUlMenu"> <?php - foreach($array_menu AS $key=>$value) + foreach($array_menu as $key=>$value) { if($value['link']=='linpha_home') { @@ -322,9 +333,17 @@ 'sys_style_thumb_showsubfoldersseparate', 'sys_style_image_useeffects', 'sys_user_autologin', + + 'plugins_filemanager_enable', + 'plugins_guestbook_enable', + 'plugins_log_enable', 'plugins_log_syslog_enable', 'plugins_log_email_enable', - 'plugins_filemanager_enable' + 'plugins_maps_enable', + 'plugins_maillist_enable', + 'plugins_rss_enable', + 'plugins_stats_enable', + 'plugins_watermark_enable', ); } Copied: trunk/linpha2/lib/include/sql (from rev 4798, trunk/linpha2/install/sql) Copied: trunk/linpha2/lib/include/sql/sql.data.php (from rev 4801, trunk/linpha2/lib/include/sql.data.php) =================================================================== --- trunk/linpha2/lib/include/sql/sql.data.php (rev 0) +++ trunk/linpha2/lib/include/sql/sql.data.php 2007-12-01 15:58:31 UTC (rev 4802) @@ -0,0 +1,358 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * linpha installer + * @package Installation + */ + +/** + * config table + */ +$options = array( + 'sys_db_version' => '3', + 'sys_public_installation' => '1', + + 'sys_im_bracket_support' => $_SESSION['sys_im_bracket_support'], + 'sys_im_imagemagick_path' => $_SESSION['sys_im_convert_path'], + 'sys_im_use_imagemagick' => $_SESSION['sys_im_use_convert'], + 'sys_im_video_thumbnail' => '1', + + 'sys_import_autoimport' => '1', + 'sys_import_exif' => '1', + 'sys_import_exif_autorot' => '1', + 'sys_import_use_exiftool' => '0', + 'sys_import_use_emb_thumb' => '0', + 'sys_import_exiftool_avail' => '0', + 'sys_import_files_ignored' => 'Thumbs.db,ZbThumbnail.info,_vti_cnf,_derived,Picasa.ini,Cdlabel.alb', + 'sys_import_fileext_ignored' => 'thm,doc,txt', + + 'sys_image_exif' => '1', + 'sys_image_iptc' => '0', + 'sys_image_xmp' => '0', + 'sys_lang' => $_SESSION['language'], + 'sys_lang_autolang' => '1', + 'sys_path_album_dir' => $_SESSION['album_dir'], + 'sys_path_cache_dir' => $_SESSION['cache_dir'], + 'sys_path_tmp_dir' => $_SESSION['tmp_dir'], + 'sys_path_install_dir' => 'install', + + 'sys_basket_mail_max_size' => (1024*1024*2), + 'sys_basket_mail_smpthost' => 'localhost', + 'sys_basket_download_limit' => '0', + + 'sys_style_datetime_dates' => '%a %m/%d/%Y', + 'sys_style_datetime_times' => '%I:%M:%S %p', + + 'sys_style_home_showbrowsebydate' => '1', + 'sys_style_home_nrrandomimages' => '4', + 'sys_style_home_newimagesnr' => '4', + 'sys_style_home_newimagesage' => '7', + 'sys_style_home_showalbums' => '1', + 'sys_style_home_usedefaultwelcometext' => '1', + 'sys_style_home_firstsortorder' => 'nameasc', + + 'sys_style_thumb_size_max' => '200', + 'sys_style_thumb_size_display' => '150', + 'sys_style_thumb_showsubfoldersseparate' => '0', + 'sys_style_thumb_selectsizes' => '50,75,100,150,200,250,300,400,500', + 'sys_style_thumb_selectnrimages' => 'auto,10,25,50,100,200,all', + 'sys_style_thumb_nojsnrrows' => '3', + 'sys_style_thumb_nojsnrcols' => '4', + + 'sys_style_image_quality' => '75', + 'sys_style_image_width' => '700', + 'sys_style_image_height' => '525', + 'sys_style_image_nrprevnextthumbs' => '3', + 'sys_style_image_useeffects' => '1', + + 'sys_style_layout_color_bodybg' => 'DDDDDD', // the blue design + 'sys_style_layout_color_elembg' => '87CEFA', + 'sys_style_layout_color_font' => '000000', + 'sys_style_layout_color_albumsbg' => 'D5FCF4', + 'sys_style_layout_color_links' => '005388', + 'sys_style_layout_color_linkshover' => '666666', + 'sys_style_layout_color_fields' => 'CCCCCC', + + 'sys_style_layout_theme' => 'default', + 'sys_style_layout_template' => 'default', + 'sys_style_layout_title' => 'Linpha 2.0', + + 'sys_style_others_sortorder' => 'nameasc', + + 'sys_user_autologin' => '1', + + + 'plugins_available' => 'filemanager,guestbook,log,maps,maillist,rss,stats,watermark', + + 'plugins_filemanager_enable' => '0', + 'plugins_filemanager_nruploads' => '5', + + 'plugins_guestbook_enable' => '0', + + 'plugins_log_enable' => '0', + 'plugins_log_filename' => 'var/linpha-'.random_string(6).'.log', + 'plugins_log_syslog_enable' => '0', + 'plugins_log_syslog_add_events' => '', + 'plugins_log_email_enable' => '0', + 'plugins_log_email_add_events' => '', + 'plugins_log_email_to' => 'LinPHA Logger<log@'.$_SERVER["HTTP_HOST"].'>', + 'plugins_log_email_headers' => 'From:LinPHA Logger<noreply@'.$_SERVER["HTTP_HOST"].'>', + 'plugins_log_email_subject' => 'Linpha Log', + + 'plugins_maps_enable' => '0', + 'plugins_maps_defaultMarkerZoom' => '10', + 'plugins_maps_mapType' => 'google', + 'plugins_maps_google_key' => 'ABQIAAAAAXCMfho4_sqSSh0VqMB80xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSfO_6bbb_ScfT_zPgcnJMKyGltOg', // key for http://localhost + 'plugins_maps_markerThumbSize' => '350', + + 'plugins_maillist_enable' => '0', + 'plugins_rss_enable' => '0', + 'plugins_stats_enable' => '0', + 'plugins_watermark_enable' => '0', + +); + +$options_user_overrideable = Array( + 'sys_lang', + 'sys_lang_autolang', + 'sys_style_others_sortorder', + 'sys_style_template', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_nrrandomimages', + 'sys_style_home_showalbums', + 'sys_style_home_firstsortorder', + 'sys_style_thumb_size_display', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_style_thumb_nojsnrrows', + 'sys_style_thumb_nojsnrcols', + 'sys_style_image_width', + 'sys_style_image_height', + 'sys_style_image_nrprevnextthumbs' => '3', + 'sys_style_image_useeffects' => '1', + + 'sys_style_layout_color_bodybg' => 'DDDDDD', // the blue design + 'sys_style_layout_color_elembg' => '87CEFA', + 'sys_style_layout_color_font' => '000000', + 'sys_style_layout_color_albumsbg' => 'D5FCF4', + 'sys_style_layout_color_links' => '005388', + 'sys_style_layout_color_linkshover' => '666666', + 'sys_style_layout_color_fields' => 'CCCCCC', + + 'sys_style_layout_theme' => 'default', + 'sys_style_layout_template' => 'default', +); + +/** + * create sql executes for all option entries + */ +while( list($name, $value) = each($options) ) +{ + if(in_array($name,$options_user_overrideable)) { + $override = 1; + } else { + $override = 0; + } + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . + "VALUES ('".$name."', '".$value."', '".$override."', '0')"; +} + +/** + * groups + */ +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."groups (group_name) VALUES ('admin')"; + +/** + * permissions + */ +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (photos_id, perm_type, permission) " . + "VALUES (0, 'read', ';public;')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (photos_id, perm_type, permission) " . + "VALUES (0, 'write', ';;')"; + + +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('basket_print', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('basket_mail', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('basket_download', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('metadata_comments', ';public;')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('metadata_deletecomments', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('metadata_edit', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('watermark', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('stats', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('download', '')"; +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . + "VALUES ('plugins_maps_setMarkers', '')"; + + +/** + * MetaData + * see http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields for the definition + */ + /** + * special fields + * flag_nr 1 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('filename', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('imagesize', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('dimension', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('thumbnail', 0, 1)"; + + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('time_add', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('time_mod', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('time_exif', 0, 1)"; + + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('stats_numbers', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('stats_views', 0, 1)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('stats_downloads', 0, 1)"; + + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('first_comment', 0, 1)"; + /** + * workaround for i18n + * they wouldn't get detected otherwise... + * some are defined in linpha.metadata.php + */ + i18n("Filename"); i18n("Imagesize"); i18n("Dimension"); i18n("Thumbnail"); + + + /** + * builtin fields + * flag_nr 5 (builtin enabled) + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('description', 1, 5)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('category', 2, 5)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('persons', 2, 5)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('date', 3, 5)"; + /** + * workaround for i18n + * they wouldn't get detected otherwise... + * some are defined in linpha.metadata.php + */ + i18n("Description"); i18n("Category"); i18n("Persons"); i18n("Date"); + + + /** + * image fields + * flag_nr 10 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_dimension', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_category', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_persons', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_time_exif', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_stats_views', 0, 10)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_stats_downloads', 0, 10)"; + + + /** + * video fields + * flag_nr 11 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('??', 0, 11)"; + + /** + * album fields + * flag_nr 12 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_time_add', 0, 12)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_stats_numbers', 0, 12)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 12)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_persons', 0, 12)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_first_comment', 0, 12)"; + + + /** + * thumbnails fields + * flag_nr 13 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 13)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 13)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 13)"; + + /** + * thumbnails in detail view fields + * flag_nr 14 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_dimension', 0, 14)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('exif_datetimeoriginal', 0, 14)"; + + /** + * slideshow fields + * flag_nr 15 + */ + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_filename', 0, 15)"; + $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . + "(name, field_type, flags) VALUES ('builtin_description', 0, 15)"; + +?> + Deleted: trunk/linpha2/lib/include/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql.data.php 2007-11-20 22:04:16 UTC (rev 4801) +++ trunk/linpha2/lib/include/sql.data.php 2007-12-01 15:58:31 UTC (rev 4802) @@ -1,347 +0,0 @@ -<?php -/* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/** - * linpha installer - * @package Installation - */ - -/** - * config table - */ -$options = array( - 'sys_db_version' => '3', - 'sys_public_installation' => '1', - - 'sys_im_bracket_support' => $_SESSION['sys_im_bracket_support'], - 'sys_im_imagemagick_path' => $_SESSION['sys_im_convert_path'], - 'sys_im_use_imagemagick' => $_SESSION['sys_im_use_convert'], - 'sys_im_video_thumbnail' => '1', - - 'sys_import_autoimport' => '1', - 'sys_import_exif' => '1', - 'sys_import_exif_autorot' => '1', - 'sys_import_use_exiftool' => '0', - 'sys_import_use_emb_thumb' => '0', - 'sys_import_exiftool_avail' => '0', - 'sys_import_files_ignored' => 'Thumbs.db,ZbThumbnail.info,_vti_cnf,_derived,Picasa.ini,Cdlabel.alb', - 'sys_import_fileext_ignored' => 'thm,doc,txt', - - 'sys_image_exif' => '1', - 'sys_image_iptc' => '0', - 'sys_image_xmp' => '0', - 'sys_lang' => $_SESSION['language'], - 'sys_lang_autolang' => '1', - 'sys_path_album_dir' => $_SESSION['album_dir'], - 'sys_path_cache_dir' => $_SESSION['cache_dir'], - 'sys_path_tmp_dir' => $_SESSION['tmp_dir'], - 'sys_path_install_dir' => 'install', - - 'sys_basket_mail_max_size' => (1024*1024*2), - 'sys_basket_mail_smpthost' => 'localhost', - 'sys_basket_download_limit' => '0', - - 'sys_style_datetime_dates' => '%a %m/%d/%Y', - 'sys_style_datetime_times' => '%I:%M:%S %p', - - 'sys_style_home_showbrowsebydate' => '1', - 'sys_style_home_nrrandomimages' => '4', - 'sys_style_home_newimagesnr' => '4', - 'sys_style_home_newimagesage' => '7', - 'sys_style_home_showalbums' => '1', - 'sys_style_home_usedefaultwelcometext' => '1', - 'sys_style_home_firstsortorder' => 'nameasc', - - 'sys_style_thumb_size_max' => '200', - 'sys_style_thumb_size_display' => '150', - 'sys_style_thumb_showsubfoldersseparate' => '0', - 'sys_style_thumb_selectsizes' => '50,75,100,150,200,250,300,400,500', - 'sys_style_thumb_selectnrimages' => 'auto,10,25,50,100,200,all', - 'sys_style_thumb_nojsnrrows' => '3', - 'sys_style_thumb_nojsnrcols' => '4', - - 'sys_style_image_quality' => '75', - 'sys_style_image_width' => '700', - 'sys_style_image_height' => '525', - 'sys_style_image_nrprevnextthumbs' => '3', - 'sys_style_image_useeffects' => '1', - - 'sys_style_layout_color_bodybg' => 'DDDDDD', // the blue design - 'sys_style_layout_color_elembg' => '87CEFA', - 'sys_style_layout_color_font' => '000000', - 'sys_style_layout_color_albumsbg' => 'D5FCF4', - 'sys_style_layout_color_links' => '005388', - 'sys_style_layout_color_linkshover' => '666666', - 'sys_style_layout_color_fields' => 'CCCCCC', - - 'sys_style_layout_theme' => 'default', - 'sys_style_layout_template' => 'default', - 'sys_style_layout_title' => 'Linpha 2.0', - - 'sys_style_others_sortorder' => 'nameasc', - - 'sys_user_autologin' => '1', - - - 'plugins_log_filename' => 'var/linpha-'.random_string(6).'.log', - 'plugins_log_syslog_enable' => '0', - 'plugins_log_syslog_add_events' => '', - 'plugins_log_email_enable' => '0', - 'plugins_log_email_add_events' => '', - 'plugins_log_email_to' => 'LinPHA Logger<log@'.$_SERVER["HTTP_HOST"].'>', - 'plugins_log_email_headers' => 'From:LinPHA Logger<noreply@'.$_SERVER["HTTP_HOST"].'>', - 'plugins_log_email_subject' => 'Linpha Log', - - 'plugins_filemanager_enable' => '0', - 'plugins_filemanager_nruploads' => '5', - - 'plugins_maps_defaultMarkerZoom' => '10', - 'plugins_maps_mapType' => 'google', - 'plugins_maps_google_key' => 'ABQIAAAAAXCMfho4_sqSSh0VqMB80xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSfO_6bbb_ScfT_zPgcnJMKyGltOg', // key for http://localhost - 'plugins_maps_markerThumbSize' => '350', - -); - -$options_user_overrideable = Array( - 'sys_lang', - 'sys_lang_autolang', - 'sys_style_others_sortorder', - 'sys_style_template', - 'sys_style_home_showbrowsebydate', - 'sys_style_home_nrrandomimages', - 'sys_style_home_showalbums', - 'sys_style_home_firstsortorder', - 'sys_style_thumb_size_display', - 'sys_style_thumb_showsubfoldersseparate', - 'sys_style_thumb_nojsnrrows', - 'sys_style_thumb_nojsnrcols', - 'sys_style_image_width', - 'sys_style_image_height', - 'sys_style_image_nrprevnextthumbs' => '3', - 'sys_style_image_useeffects' => '1', - - 'sys_style_layout_color_bodybg' => 'DDDDDD', // the blue design - 'sys_style_layout_color_elembg' => '87CEFA', - 'sys_style_layout_color_font' => '000000', - 'sys_style_layout_color_albumsbg' => 'D5FCF4', - 'sys_style_layout_color_links' => '005388', - 'sys_style_layout_color_linkshover' => '666666', - 'sys_style_layout_color_fields' => 'CCCCCC', - - 'sys_style_layout_theme' => 'default', - 'sys_style_layout_template' => 'default', -); - -/** - * create sql executes for all option entries - */ -while( list($name, $value) = each($options) ) -{ - if(in_array($name,$options_user_overrideable)) { - $override = 1; - } else { - $override = 0; - } - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . - "VALUES ('".$name."', '".$value."', '".$override."', '0')"; -} - -/** - * groups - */ -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."groups (group_name) VALUES ('admin')"; - -/** - * permissions - */ -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (photos_id, perm_type, permission) " . - "VALUES (0, 'read', ';public;')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (photos_id, perm_type, permission) " . - "VALUES (0, 'write', ';;')"; - - -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('basket_print', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('basket_mail', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('basket_download', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('metadata_comments', ';public;')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('metadata_deletecomments', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('metadata_edit', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('watermark', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('stats', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('download', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('plugins_maps_setMarkers', '')"; - - -/** - * MetaData - * see http://linpha.sourceforge.net/wiki/index.php/Tables_linpha_meta_fields for the definition - */ - /** - * special fields - * flag_nr 1 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('filename', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('imagesize', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('dimension', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('thumbnail', 0, 1)"; - - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('time_add', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('time_mod', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('time_exif', 0, 1)"; - - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('stats_numbers', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('stats_views', 0, 1)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('stats_downloads', 0, 1)"; - - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('first_comment', 0, 1)"; - /** - * workaround for i18n - * they wouldn't get detected otherwise... - * some are defined in linpha.metadata.php - */ - i18n("Filename"); i18n("Imagesize"); i18n("Dimension"); i18n("Thumbnail"); - - - /** - * builtin fields - * flag_nr 5 (builtin enabled) - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('description', 1, 5)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('category', 2, 5)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('persons', 2, 5)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('date', 3, 5)"; - /** - * workaround for i18n - * they wouldn't get detected otherwise... - * some are defined in linpha.metadata.php - */ - i18n("Description"); i18n("Category"); i18n("Persons"); i18n("Date"); - - - /** - * image fields - * flag_nr 10 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_filename', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_dimension', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_category', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_persons', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_time_exif', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_stats_views', 0, 10)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_stats_downloads', 0, 10)"; - - - /** - * video fields - * flag_nr 11 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('??', 0, 11)"; - - /** - * album fields - * flag_nr 12 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_time_add', 0, 12)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_stats_numbers', 0, 12)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 12)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_persons', 0, 12)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_first_comment', 0, 12)"; - - - /** - * thumbnails fields - * flag_nr 13 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 13)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_filename', 0, 13)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 13)"; - - /** - * thumbnails in detail view fields - * flag_nr 14 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_thumbnail', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_filename', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_imagesize', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_dimension', 0, 14)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('exif_datetimeoriginal', 0, 14)"; - - /** - * slideshow fields - * flag_nr 15 - */ - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_filename', 0, 15)"; - $sql_queries[] = "INSERT INTO ".LIN_PREFIX."meta_fields " . - "(name, field_type, flags) VALUES ('builtin_description', 0, 15)"; - -?> - Added: trunk/linpha2/lib/plugins/filemanager/settings.filemanager.php =================================================================== --- trunk/linpha2/lib/plugins/filemanager/settings.filemanager.php (rev 0) +++ trunk/linpha2/lib/plugins/filemanager/settings.filemanager.php 2007-12-01 15:58:31 UTC (rev 4802) @@ -0,0 +1,29 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * Settings for the admin section + * @package admin + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + + +?> \ No newline at end of file Added: trunk/linpha2/lib/plugins/log/settings.log.php =================================================================== --- trunk/linpha2/lib/plugins/log/settings.log.php (rev 0) +++ trunk/linpha2/lib/plugins/log/settings.log.php 2007-12-01 15:58:31 UTC (rev 4802) @@ -0,0 +1,65 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * Settings for the admin section + * @package admin + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +/** + * save settings + */ + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + $LinAdmin->saveConfig(Array( + 'plugins_log_filename', + 'plugins_log_syslog_enable', + 'plugins_log_syslog_add_events', + 'plugins_log_email_enable', + 'plugins_log_email_add_events', + 'plugins_log_email_to', + 'plugins_log_email_headers', + 'plugins_log_email_subject' + )); + } + +echo '<br /><h2 class="linStyle">'.i18n("Filename").'</h2>'; +$LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_filename'),'plugins_log_filename',$LinAdmin->option_value_system['plugins_log_filename']); + +echo '<br /><h2 class="linStyle">'.i18n("Syslog").'</h2>'; +echo i18n("(Event log in Windows)"); +$LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_log_syslog_enable'),'plugins_log_syslog_enable',$LinAdmin->option_value_system['plugins_log_syslog_enable']); + +$LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_syslog_add_events'),'plugins_log_syslog_add_events',$LinAdmin->option_value_system['plugins_log_syslog_add_events']); +echo i18n("Comma separated list. Valid events:")." login, logout, rotate, comments, guestbook, fm_others, fm_upload, fm_delete, fm_move, fm_copy, fm_rename, fm_create_folder, fm_perm"; +echo '<br />'; + +echo '<br /><h2 class="linStyle">'.i18n("Email").'</h2>'; +$LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_log_email_enable'),'plugins_log_email_enable',$LinAdmin->option_value_system['plugins_log_email_enable']); +$LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_to'),'plugins_log_email_to',$LinAdmin->option_value_system['plugins_log_email_to']); +$LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_subject'),'plugins_log_email_subject',$LinAdmin->option_value_system['plugins_log_email_subject']); +$LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_headers'),'plugins_log_email_headers',$LinAdmin->option_value_system['plugins_log_email_headers']); + +$LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_add_events'),'plugins_log_email_add_events',$LinAdmin->option_value_system['plugins_log_email_add_events']); +echo i18n("Comma separated list. Valid events:")." login, logout, rotate, comments, guestbook, fm_others, fm_upload, fm_delete, fm_move, fm_copy, fm_rename, fm_create_folder, fm_perm"; + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2007-12-01 17:14:19
|
Revision: 4803 http://linpha.svn.sourceforge.net/linpha/?rev=4803&view=rev Author: fangehrn Date: 2007-12-01 09:14:09 -0800 (Sat, 01 Dec 2007) Log Message: ----------- 2007-12-01 flo * creating plugin interface - create plugin tables only when plugin is enabled pay attention with oracles sequences and triggers any idea how to create them dynamically? Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/maintenance_db.php trunk/linpha2/admin/settings_plugins.php trunk/linpha2/install/manual_install.php trunk/linpha2/install/step8_testing.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/reset_database.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/ChangeLog 2007-12-01 17:14:09 UTC (rev 4803) @@ -4,6 +4,11 @@ - moved whole install/sql folder to lib/include/sql we need still that files if we want to dynamically create the plugin tables + and changed hopefully all paths + + - create plugin tables only when plugin is enabled + pay attention with oracles sequences and triggers + any idea how to create them dynamically? 2007-11-20 flo * finished basic part of the map plugin Modified: trunk/linpha2/admin/maintenance_db.php =================================================================== --- trunk/linpha2/admin/maintenance_db.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/admin/maintenance_db.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -308,7 +308,7 @@ $_SESSION['cache_dir'] = ''; $_SESSION['tmp_dir'] = ''; - include(LINPHA_DIR.'/lib/include/sql.data.php'); + include(LINPHA_DIR.'/lib/include/sql/sql.data.php'); foreach($options AS $key=>$value) { $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."config " . Modified: trunk/linpha2/admin/settings_plugins.php =================================================================== --- trunk/linpha2/admin/settings_plugins.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/admin/settings_plugins.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -15,21 +15,47 @@ { foreach($arrPlugins as $value) { - $arrPlugins2[] = 'plugins_'.$value.'_enable'; + $arrPluginsFullName[] = 'plugins_'.$value.'_enable'; } - $LinAdmin->saveConfig($arrPlugins2); - /** * create database tables if necessary + * !!! WARNING: SAME CODE ALSO IN install/step9_createtables.php !!! */ - foreach($arrPlugins2 as $value) + include(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); + foreach($linpha_tables AS $key=>$value) { - if( isset($_POST[$value]) && $_POST[$value]=='1' ) + $linpha_tables[$key] = LIN_PREFIX.$value; + } + include(LINPHA_DIR.'/lib/include/sql/sql.'.LIN_DB_TYPE.'.php'); + + // go through all plugins + foreach($arrPlugins as $value) + { + // if now enabled and before it was disabled + if( isset($_POST['plugins_'.$value.'_enable']) + && $_POST['plugins_'.$value.'_enable']=='1' + && $LinAdmin->option_value_system['plugins_'.$value.'_enable']=='0') { - + linSysLog(i18n("Creating tables for plugin: ").' '.$LinAdmin->description_array['plugins_'.$value]); + foreach($sql_tables as $sqlStr) + { + // if table starts with "CREATE TABLE linpha_plugins_$value" + $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_".$value; + if(substr($sqlStr,0,strlen($sqlStrSearch)) == $sqlStrSearch) + { + $result = $linpha->db->Execute($sqlStr); + + // it the table already exists, we get automatically a nice message like + // "Table 'linpha2_plugins_maps_markers' already exists" + if(!$result) { + linSysLog($linpha->db->ErrorMsg()); + } + } + } } } + $LinAdmin->saveConfig($arrPluginsFullName); } /** @@ -74,4 +100,5 @@ include_once($includeFile); } } + ?> \ No newline at end of file Modified: trunk/linpha2/install/manual_install.php =================================================================== --- trunk/linpha2/install/manual_install.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/install/manual_install.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -84,7 +84,7 @@ /** * get table names and add prefix */ - include_once(LINPHA_DIR.'/install/sql/sql.tables.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); foreach($linpha_tables AS $key=>$value) { $linpha_tables[$key] = LIN_PREFIX.$value; @@ -93,7 +93,7 @@ /** * include sql strings */ - include_once(LINPHA_DIR."/install/sql/sql.".LIN_DB_TYPE.".php"); + include_once(LINPHA_DIR."/lib/include/sql/sql.".LIN_DB_TYPE.".php"); /** * finally create tables @@ -108,7 +108,7 @@ * insert data */ $str_query .= "\n\n"; - include_once(LINPHA_DIR.'/lib/include/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.data.php'); foreach($sql_queries AS $value) { $str_query .= $value.";\n"; @@ -128,7 +128,7 @@ $donotchange = ' // change only with installer !!'; $comment[1] = $donotchange; -include_once(LINPHA_DIR.'/install/sql/config.dir.php'); +include_once(LINPHA_DIR.'/lib/include/sql/config.dir.php'); ?> <br /><br /> <?php echo i18n_install("Folders To Create:")."<br />"; ?> @@ -166,7 +166,7 @@ $comment[6] = $donotchange; $comment[7] = $changeme; -include_once(LINPHA_DIR.'/install/sql/config.sql.php'); +include_once(LINPHA_DIR.'/lib/include/sql/config.sql.php'); ?> <br /><br /> <?php echo i18n_install("Database Connection File")." <b>".$_SESSION['sql_dir']."/config.sql.php</b><br />"; ?> Modified: trunk/linpha2/install/step8_testing.php =================================================================== --- trunk/linpha2/install/step8_testing.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/install/step8_testing.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -94,12 +94,12 @@ } else { - include_once(LINPHA_DIR.'/install/sql/sql.tables.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); /** * add prefix */ - foreach($linpha_tables AS $key=>$value) + foreach($linpha_tables as $key=>$value) { $linpha_tables[$key] = $_SESSION['sql_prefix'].$value; } Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/install/step9_createtables.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -39,11 +39,12 @@ /** * create tables + * !!! WARNING: SAME CODE ALSO IN admin/settings_plugins.php !!! */ /** * get table names and add prefix */ - include_once(LINPHA_DIR.'/install/sql/sql.tables.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); foreach($linpha_tables AS $key=>$value) { $linpha_tables[$key] = LIN_PREFIX.$value; @@ -52,7 +53,7 @@ /** * include sql strings */ - include_once(LINPHA_DIR."/install/sql/sql.".LIN_DB_TYPE.".php"); + include_once(LINPHA_DIR.'/lib/include/sql/sql.'.LIN_DB_TYPE.'.php'); /** * finally create tables @@ -62,13 +63,20 @@ $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) { - $result = $linpha->db->Execute($query); - if(!$result) + /** + * ignore plugins_ tables + */ + $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_"; + if(substr($query,0,strlen($sqlStrSearch)) != $sqlStrSearch) { - echo LIN_PREFIX.$translation_array[$key].' '; - echo failed_msg(); - echo ' '.$linpha->db->ErrorMsg().'<br />'; - $error_nr = 1; + $result = $linpha->db->Execute($query); + if(!$result) + { + echo LIN_PREFIX.$translation_array[$key].' '; + echo failed_msg(); + echo ' '.$linpha->db->ErrorMsg().'<br />'; + $error_nr = 1; + } } } /** @@ -125,7 +133,7 @@ * insert data */ echo "<br />".i18n_install("Inserting Table Data...").' '; - include_once(LINPHA_DIR.'/lib/include/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.data.php'); foreach($sql_queries AS $value) { $result = $linpha->db->Execute($value); @@ -171,7 +179,7 @@ if($fp) { $comment[1] = ''; - include_once(LINPHA_DIR.'/install/sql/config.dir.php'); + include_once(LINPHA_DIR.'/lib/include/sql/config.dir.php'); fwrite( $fp, $str ); fclose($fp); @@ -209,7 +217,7 @@ $comment[6] = ''; $comment[7] = ''; - include_once(LINPHA_DIR.'/install/sql/config.sql.php'); + include_once(LINPHA_DIR.'/lib/include/sql/config.sql.php'); fwrite( $fp, $str ); fclose($fp); Modified: trunk/linpha2/reset_database.php =================================================================== --- trunk/linpha2/reset_database.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/reset_database.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -21,7 +21,7 @@ /** * get table names and add prefix */ - include_once(LINPHA_DIR.'/install/sql/sql.tables.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); foreach($linpha_tables AS $key=>$value) { $linpha_tables[$key] = LIN_PREFIX.$value; @@ -51,7 +51,7 @@ /** * include sql strings */ - include_once(LINPHA_DIR."/install/sql/sql.".LIN_DB_TYPE.".php"); + include_once(LINPHA_DIR."/lib/include/sql/sql.".LIN_DB_TYPE.".php"); /** * finally create tables @@ -61,13 +61,20 @@ $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) { - $result = $linpha->db->Execute($query); - if(!$result) + /** + * ignore plugins_ tables + */ + $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_"; + if(substr($query,0,strlen($sqlStrSearch)) != $sqlStrSearch) { - echo LIN_PREFIX.$translation_array[$key].' '; - echo failed_msg(); - echo ' '.$linpha->db->ErrorMsg().'<br />'; - $error_nr = 1; + $result = $linpha->db->Execute($query); + if(!$result) + { + echo LIN_PREFIX.$translation_array[$key].' '; + echo failed_msg(); + echo ' '.$linpha->db->ErrorMsg().'<br />'; + $error_nr = 1; + } } } if(!isset($error_nr)) @@ -81,7 +88,7 @@ * insert data */ echo "<br /><br />".tr("Inserting Table Data")."... "; - include_once(LINPHA_DIR.'/lib/include/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.data.php'); foreach($sql_queries AS $value) { $result = $linpha->db->Execute($value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2007-12-02 21:47:05
|
Revision: 4804 http://linpha.svn.sourceforge.net/linpha/?rev=4804&view=rev Author: fangehrn Date: 2007-12-02 13:46:57 -0800 (Sun, 02 Dec 2007) Log Message: ----------- 2007-12-02 flo * created settings and permissions section for plugins they are dynamically loaded with the files /lib/plugins/*/settings.*.php and /lib/plugins/*/permissions.*.php * decided to have for each plugin own sql files -> plugins are now nearly separated from the main linpha files -> if someone adds a new plugin, you don't have to update linpha itself, just copy the plugin folder to the plugin directory and it will automatically appear in the admin section where it can be enabled and the tables and config entries are automatically created -> this solves also the sequences and triggers problem with oracle * changed back the style of the form buttons i think buttons should still be buttons * filemanager - disallow change of the file extension a user could upload anEvilPhpScriptMaskedAsAnImage.jpg and rename it later to anEvilPhpScriptMaskedAsAnImage.php Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/permissions.php trunk/linpha2/admin/permissions_others.php trunk/linpha2/admin/permissions_readwrite.php trunk/linpha2/admin/settings_plugins.php trunk/linpha2/index.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/include/sql/sql.data.php trunk/linpha2/lib/include/sql/sql.mysql.php trunk/linpha2/lib/include/sql/sql.tables.php trunk/linpha2/lib/modules/module.settings.php trunk/linpha2/lib/plugins/filemanager/settings.filemanager.php trunk/linpha2/reset_database.php trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/themes/default/colorsettings.php trunk/linpha2/templates/default/themes/default/css/global.css Added Paths: ----------- trunk/linpha2/lib/plugins/example/ trunk/linpha2/lib/plugins/example/module.example.php trunk/linpha2/lib/plugins/example/permissions.example.php trunk/linpha2/lib/plugins/example/settings.example.php trunk/linpha2/lib/plugins/example/sql/ trunk/linpha2/lib/plugins/example/sql/sql.data.php trunk/linpha2/lib/plugins/example/sql/sql.mysql.php trunk/linpha2/lib/plugins/example/sql/sql.oci8po.php trunk/linpha2/lib/plugins/example/sql/sql.postgres.php trunk/linpha2/lib/plugins/example/sql/sql.sqlite.php trunk/linpha2/lib/plugins/filemanager/module.filemanager.php trunk/linpha2/lib/plugins/filemanager/sql/ trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php trunk/linpha2/lib/plugins/guestbook/permissions.guestbook.php trunk/linpha2/lib/plugins/guestbook/sql/ trunk/linpha2/lib/plugins/guestbook/sql/sql.data.php trunk/linpha2/lib/plugins/log/sql/ trunk/linpha2/lib/plugins/log/sql/sql.data.php trunk/linpha2/lib/plugins/maillist/sql/ trunk/linpha2/lib/plugins/maillist/sql/sql.data.php trunk/linpha2/lib/plugins/maps/permissions.maps.php trunk/linpha2/lib/plugins/maps/settings.maps.php trunk/linpha2/lib/plugins/maps/sql/ trunk/linpha2/lib/plugins/maps/sql/sql.data.php trunk/linpha2/lib/plugins/maps/sql/sql.mysql.php trunk/linpha2/lib/plugins/maps/sql/sql.oci8po.php trunk/linpha2/lib/plugins/maps/sql/sql.postgres.php trunk/linpha2/lib/plugins/maps/sql/sql.sqlite.php trunk/linpha2/lib/plugins/rss/sql/ trunk/linpha2/lib/plugins/rss/sql/sql.data.php trunk/linpha2/lib/plugins/stats/sql/ trunk/linpha2/lib/plugins/stats/sql/sql.data.php trunk/linpha2/lib/plugins/watermark/permissions.watermark.php trunk/linpha2/lib/plugins/watermark/sql/ trunk/linpha2/lib/plugins/watermark/sql/sql.data.php Removed Paths: ------------- trunk/linpha2/lib/modules/module.filemanager.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/ChangeLog 2007-12-02 21:46:57 UTC (rev 4804) @@ -1,4 +1,26 @@ +2007-12-02 flo + * created settings and permissions section for plugins + they are dynamically loaded with the files /lib/plugins/*/settings.*.php + and /lib/plugins/*/permissions.*.php + + * decided to have for each plugin own sql files + -> plugins are now nearly separated from the main linpha files + -> if someone adds a new plugin, you don't have to update linpha itself, + just copy the plugin folder to the plugin directory and it will + automatically appear in the admin section where it can be enabled + and the tables and config entries are automatically created + -> this solves also the sequences and triggers problem with oracle + + + * changed back the style of the form buttons + i think buttons should still be buttons + + * filemanager + - disallow change of the file extension + a user could upload anEvilPhpScriptMaskedAsAnImage.jpg and rename it later + to anEvilPhpScriptMaskedAsAnImage.php + 2007-12-01 flo * creating plugin interface - moved whole install/sql folder to lib/include/sql Modified: trunk/linpha2/admin/permissions.php =================================================================== --- trunk/linpha2/admin/permissions.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/admin/permissions.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -10,10 +10,11 @@ 'users' => array('name' => i18n("Users"), 'link' => 'permissions_users'), 'groups' => array('name' => i18n("Groups"), 'link' => 'permissions_groups'), 'usergroup' => array('name' => i18n("Group Memberships"), 'link' => 'permissions_usergroup'), - 'view' => array('name' => i18n("View"), 'link' => 'permissions_view'), - 'write' => array('name' => i18n("Write"), 'link' => 'permissions_write'), + 'view' => array('name' => i18n("Image View"), 'link' => 'permissions_view'), + 'write' => array('name' => i18n("Image Upload"), 'link' => 'permissions_write'), 'basket' => array('name' => i18n("Basket"), 'link' => 'permissions_basket'), 'metadata' => array('name' => i18n("MetaData"), 'link' => 'permissions_metadata'), + 'plugins' => array('name' => i18n("Plugins"), 'link' => 'permissions_plugins'), 'others' => array('name' => i18n("Others"), 'link' => 'permissions_others'), ); @@ -40,9 +41,14 @@ case 'basket': case 'metadata': +case 'plugins': case 'others': include_once('./permissions_others.php'); break; + +/*case 'plugins': + include_once(LINPHA_DIR.'/admin/permissions_plugins.php'); + break;*/ } ?> Modified: trunk/linpha2/admin/permissions_others.php =================================================================== --- trunk/linpha2/admin/permissions_others.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/admin/permissions_others.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -1,59 +1,16 @@ <?php if(!defined('LINPHA_DIR')) { exit(1); } -if(!isset($cat3)) -{ - $cat3 = ''; -} - -switch($cat2) -{ -case 'basket': - $array_menu = array( - 'print' => array('name' => i18n("Print"), 'link' => 'permissions_basket_print'), - 'mail' => array('name' => i18n("Mail"), 'link' => 'permissions_basket_mail'), - 'download' => array('name' => i18n("Download"), 'link' => 'permissions_basket_download'), - ); - break; -case 'metadata': - $array_menu = array( - 'comments' => array('name' => i18n("Write Comments"), 'link' => 'permissions_metadata_comments'), - 'deletecomments' => array('name' => i18n("Delete Comments"), 'link' => 'permissions_metadata_deletecomments'), - 'edit' => array('name' => i18n("Edit Image Informations"), 'link' => 'permissions_metadata_edit'), - ); - break; -case 'others': - $array_menu = array( - 'watermark' => array('name' => i18n("Watermark"), 'link' => 'permissions_others_watermark'), - 'stats' => array('name' => i18n("Statistics"), 'link' => 'permissions_others_stats'), - 'download' => array('name' => i18n("Download"), 'link' => 'permissions_others_download'), - ); - break; -} - -LinAdmin::printAdminMenu($array_menu,$cat3); - -if(!empty($cat3)) -{ - if($cat2 == 'basket' OR $cat2 == 'metadata') - { - $key = $cat2.'_'.$cat3; - } - elseif($cat2 == 'others') - { - $key = $cat3; - } - - /** - * save data - */ +/** + * save data + */ if(isset($_POST['cmd']) && $_POST['cmd'] == 'edit') { if($_POST['allowall'] == 'allowall') { $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."permissions " . "SET permission = ';public;' " . - "WHERE perm_type = '".LinSql::linAddslashes($key)."'"); + "WHERE perm_type = '".LinSql::linAddslashes($_POST['perm_type'])."'"); } else { @@ -68,38 +25,120 @@ $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."permissions " . "SET permission = '".LinSql::linAddslashes($str)."' " . - "WHERE perm_type = '".LinSql::linAddslashes($key)."'"); + "WHERE perm_type = '".LinSql::linAddslashes($_POST['perm_type'])."'"); } } + +switch($cat2) +{ +case 'basket': + printPermissions('basket_print',i18n("Basket Print")); + printPermissions('basket_mail',i18n("Basket Mail")); + printPermissions('basket_download',i18n("Basket Download")); + break; +case 'metadata': + printPermissions('metadata_comments',i18n("Write Comments")); + printPermissions('metadata_deletecomments',i18n("Delete Comments")); + printPermissions('metadata_edit',i18n("Edit Image Informations")); + break; +case 'others': + printPermissions('download',i18n("Download Single Images")); + break; +case 'plugins': + + $array_menu = array(); + $arrPlugins = LinAdmin::getPlugins(); + foreach( $arrPlugins as $key=>$value) + { + $includeFile = LINPHA_DIR.'/lib/plugins/'.$value.'/permissions.'.$value.'.php'; + if( isset($LinAdmin->option_value_system['plugins_'.$value.'_enable']) + && $LinAdmin->option_value_system['plugins_'.$value.'_enable']=='1' + && file_exists($includeFile) + ) + { + $array_menu[$value] = array( + 'name' => $LinAdmin->description_array['plugins_'.$value], + 'link' => 'permissions_plugins_'.$value + ); + } + } + if(!isset($cat3)) { + LinAdmin::printAdminMenu($array_menu,''); + } else { + LinAdmin::printAdminMenu($array_menu,$cat3); + } - echo '<b>'.i18n("Edit").': '.$array_menu[$cat3]['name'].'</b><br />'; + + if( isset($cat3) && in_array($cat3,$arrPlugins) + && $LinAdmin->option_value_system['plugins_'.$cat3.'_enable']=='1' ) + { + $includeFile = LINPHA_DIR.'/lib/plugins/'.$cat3.'/permissions.'.$cat3.'.php'; + if( file_exists($includeFile) ) + { + include_once($includeFile); + } + } + + break; +} + +?> + <script language="JavaScript" type="text/javascript"> + + function update_forms(formId) + { + if(formId.allowall[0].checked) + { + // use elements[2] for select name because it does not work with the name groups[] + formId.elements[2].disabled = true; + formId.elements[2].selectedIndex = -1; + } + + if(formId.allowall[1].checked) + { + formId.elements[2].disabled = false; + } + } + //update_forms(); + + </script> +<?php + +function printPermissions($key,$description) +{ + echo '<b>'.$description.'</b><br />'; + $data = $GLOBALS['linpha']->db->GetRow("SELECT permission FROM ".LIN_PREFIX."permissions " . "WHERE perm_type = '".LinSql::linAddslashes($key)."'"); + if( !$data ) { + echo "Warning: This permission does not exists: ".$key."<br />"; + return; + } + $array_permissions = linExplodeAndSlice(';',$data['permission']); if(in_array('public',$array_permissions)) { $allowall_checked = ' checked="checked"'; $allowgroups_checked = ''; + $groups_disabled = ' disabled="disabled"'; } else { $allowall_checked = ''; $allowgroups_checked = ' checked="checked"'; + $groups_disabled = ''; } -?> - <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_'.$cat2.'_'.$cat3; ?>"> - <br /> - <input type="radio" id="allowall" name="allowall" value="allowall"<?php echo $allowall_checked; ?>onClick="update_forms()" /> - <label for="allowall"><?php echo i18n("Allow All"); ?></label> - <br /><br /> - <input type="radio" id="allowgroups" name="allowall" value="allowgroups"<?php echo $allowgroups_checked; ?>onClick="update_forms()" /> - <label for="allowgroups"><?php echo i18n("Allow Only This Groups:"); ?></label> - <br /> + ?> + <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_'.$key; ?>"> + <label for="allowall<?php echo $key; ?>"><input type="radio" id="allowall<?php echo $key; ?>" name="allowall" value="allowall"<?php + echo $allowall_checked; ?> onclick="update_forms(this.form)" /> <?php echo i18n("Allow All"); ?></label><br /> + <label for="allowgroups<?php echo $key; ?>"><input type="radio" id="allowgroups<?php echo $key; ?>" name="allowall" value="allowgroups"<?php + echo $allowgroups_checked; ?>onclick="update_forms(this.form)" /> <?php echo i18n("Allow Only These Groups:"); ?></label><br /> - <select id="selectgroups" name="groups[]" size="5" style="width: 200;" multiple="multiple"> + <select id="selectgroups" name="groups[]" size="5" style="width: 200;" multiple="multiple"<?php echo $groups_disabled; ?>> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".LIN_PREFIX."groups ORDER by group_name"); while($data = $query->FetchRow()) @@ -116,35 +155,15 @@ echo '<option value="'.$data['id'].'"'.$checked.'>'.$data['group_name'].'</option>'; } ?> + + <input type="hidden" name="perm_type" value="<?php echo $key; ?>" /> <input type="hidden" name="cmd" value="edit" /> <br /> <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> </select> </form> + <br /> + <?php +} - <script language="JavaScript" type="text/javascript"> - - function update_forms() - { - var allowall = document.getElementById('allowall'); - var allowgroups = document.getElementById('allowgroups'); - var selectgroups = document.getElementById('selectgroups'); - - if(allowall.checked) - { - selectgroups.disabled = true; - selectgroups.selectedIndex = -1; - } - - if(allowgroups.checked) - { - selectgroups.disabled = false; - } - } - update_forms(); - - </script> - -<?php -} ?> \ No newline at end of file Modified: trunk/linpha2/admin/permissions_readwrite.php =================================================================== --- trunk/linpha2/admin/permissions_readwrite.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/admin/permissions_readwrite.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -17,12 +17,12 @@ { $LinAdmin->saveConfig( Array( - 'plugins_filemanager_enable' + 'plugins_filemanager_userEnable' ) ); } - $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_filemanager_enable'),'plugins_filemanager_enable',$LinAdmin->option_value_system['plugins_filemanager_enable']); + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_filemanager_userEnable'),'plugins_filemanager_userEnable',$LinAdmin->option_value_system['plugins_filemanager_userEnable']); ?> <input type="hidden" name="cmd" value="saveconfig" /> @@ -32,7 +32,7 @@ <?php } -if($cat2 == 'view' OR ($cat2 == 'write' AND $GLOBALS['linpha']->sql->config->value['plugins_filemanager_enable'] )) +if($cat2 == 'view' OR ($cat2 == 'write' AND $GLOBALS['linpha']->sql->config->value['plugins_filemanager_userEnable'] )) { /** Modified: trunk/linpha2/admin/settings_plugins.php =================================================================== --- trunk/linpha2/admin/settings_plugins.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/admin/settings_plugins.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -6,7 +6,7 @@ $cat3 = 'enable'; } -$arrPlugins = explode(',',$LinAdmin->option_value_system['plugins_available']); +$arrPlugins = LinAdmin::getPlugins(); /** * save settings before showing menu @@ -19,30 +19,29 @@ } /** - * create database tables if necessary - * !!! WARNING: SAME CODE ALSO IN install/step9_createtables.php !!! + * create database tables and insert config data if necessary */ - include(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); - foreach($linpha_tables AS $key=>$value) + foreach($arrPlugins as $value) // go through all plugins { - $linpha_tables[$key] = LIN_PREFIX.$value; - } - include(LINPHA_DIR.'/lib/include/sql/sql.'.LIN_DB_TYPE.'.php'); - - // go through all plugins - foreach($arrPlugins as $value) - { - // if now enabled and before it was disabled + // only if we enabled the plugin now and it didn't existed before if( isset($_POST['plugins_'.$value.'_enable']) && $_POST['plugins_'.$value.'_enable']=='1' - && $LinAdmin->option_value_system['plugins_'.$value.'_enable']=='0') + && !isset($LinAdmin->option_value_system['plugins_'.$value.'_enable']) ) { - linSysLog(i18n("Creating tables for plugin: ").' '.$LinAdmin->description_array['plugins_'.$value]); - foreach($sql_tables as $sqlStr) + $str1 = i18n("Enabling plugin \"%s\""); + linSysLog( sprintf($str1,$LinAdmin->description_array['plugins_'.$value]) ); + + /** + * create database tables + */ + $includeFile = LINPHA_DIR.'/lib/plugins/'.$value.'/sql/sql.'.LIN_DB_TYPE.'.php'; + if( file_exists($includeFile) ) { - // if table starts with "CREATE TABLE linpha_plugins_$value" - $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_".$value; - if(substr($sqlStr,0,strlen($sqlStrSearch)) == $sqlStrSearch) + $sql_tables = array(); + include($includeFile); + + linSysLog(i18n("Creating tables")); + foreach($sql_tables as $sqlStr) { $result = $linpha->db->Execute($sqlStr); @@ -51,10 +50,35 @@ if(!$result) { linSysLog($linpha->db->ErrorMsg()); } - } + } } + + /** + * insert config data + */ + $includeFile = LINPHA_DIR.'/lib/plugins/'.$value.'/sql/sql.data.php'; + if( file_exists($includeFile) ) // this file always exists (it wouldnt be a plugin otherwise) + { + $sql_queries = array(); + include($includeFile); + + linSysLog(i18n("Insert config data")); + foreach($sql_queries as $sqlStr) + { + $result = $linpha->db->Execute($sqlStr); + + // it the table already exists, we get automatically a nice message like + // "Table 'linpha2_plugins_maps_markers' already exists" + if(!$result) { + linSysLog($linpha->db->ErrorMsg()); + } + } + } + } - } + } + + // set plugins_*_enable to '1' $LinAdmin->saveConfig($arrPluginsFullName); } @@ -66,7 +90,9 @@ ); foreach( $arrPlugins as $key=>$value) { - if($LinAdmin->option_value_system['plugins_'.$value.'_enable'] == '1') + if(isset($LinAdmin->option_value_system['plugins_'.$value.'_enable']) + && $LinAdmin->option_value_system['plugins_'.$value.'_enable'] == '1' + ) { $array_menu[$value] = array( 'name' => $LinAdmin->description_array['plugins_'.$value], @@ -84,11 +110,17 @@ { foreach( $arrPlugins as $key=>$value) { + if(isset($LinAdmin->option_value_system['plugins_'.$value.'_enable'])) { + $optionValue = $LinAdmin->option_value_system['plugins_'.$value.'_enable']; + } else { + $optionValue = '0'; + } + $LinAdmin->printAdminConfig( 'radio', $LinAdmin->getDescriptionByOptionName('plugins_'.$value), 'plugins_'.$value.'_enable', - $LinAdmin->option_value_system['plugins_'.$value.'_enable'] + $optionValue ); } } Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/index.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -43,9 +43,9 @@ case 'browse': require_once(LINPHA_DIR.'/lib/modules/module.browse.php'); break; -case 'filemanager': +/*case 'filemanager': require_once(LINPHA_DIR.'/lib/modules/module.filemanager.php'); - break; + break;*/ case 'settings': require_once(LINPHA_DIR.'/lib/modules/module.settings.php'); break; @@ -72,17 +72,22 @@ break; -// plugins -case 'maps': - /** - * @todo check if plugin enabled - */ - require_once(LINPHA_DIR.'/lib/plugins/maps/module.maps.php'); - break; +default: + // include plugins + $plugindDir = LINPHA_DIR.'/lib/plugins'; + $includeFile = $plugindDir.'/'.$_GET['linCat'].'/module.'.$_GET['linCat'].'.php'; - -default: - require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); + if( is_dir($pluginDir) + && isset($GLOBALS['linpha']->sql->config->value['plugins_'.$_GET['linCat'].'_enable']) + && $GLOBALS['linpha']->sql->config->value['plugins_'.$_GET['linCat'].'_enable']=='1' + && file_exists($includeFile)) + { + require_once($includeFile); + } + else + { + require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); + } break; } Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/install/step9_createtables.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -39,13 +39,15 @@ /** * create tables - * !!! WARNING: SAME CODE ALSO IN admin/settings_plugins.php !!! */ /** * get table names and add prefix */ include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); - foreach($linpha_tables AS $key=>$value) + + // append LIN_PREFIX before each table + // but we also could do this directly in the sql.mysql.php file!? + foreach($linpha_tables as $key=>$value) { $linpha_tables[$key] = LIN_PREFIX.$value; } @@ -63,20 +65,13 @@ $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) { - /** - * ignore plugins_ tables - */ - $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_"; - if(substr($query,0,strlen($sqlStrSearch)) != $sqlStrSearch) + $result = $linpha->db->Execute($query); + if(!$result) { - $result = $linpha->db->Execute($query); - if(!$result) - { - echo LIN_PREFIX.$translation_array[$key].' '; - echo failed_msg(); - echo ' '.$linpha->db->ErrorMsg().'<br />'; - $error_nr = 1; - } + echo LIN_PREFIX.$translation_array[$key].' '; + echo failed_msg(); + echo ' '.$linpha->db->ErrorMsg().'<br />'; + $error_nr = 1; } } /** Modified: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -97,8 +97,6 @@ 'plugins_log_email_to' => i18n("Recipient"), 'plugins_log_email_headers' => i18n("Extra headers"), 'plugins_log_email_subject' => i18n("Subject"), - - 'plugins_filemanager_enable' => i18n("Enable Filemanager For Non-Admin Users"), ); } @@ -153,8 +151,10 @@ ?> </div> <div align="right"> - <input type="radio" id="<?php echo $id; ?>01" name="<?php echo $id; ?>" value="1"<?php echo $str_enabled; ?> /><label for="<?php echo $id; ?>01"><?php echo i18n("Enable"); ?></label> - <input type="radio" id="<?php echo $id; ?>02" name="<?php echo $id; ?>" value="0"<?php echo $str_disabled; ?>/><label for="<?php echo $id; ?>02"><?php echo i18n("Disable"); ?></label> + <label for="<?php echo $id; ?>01"><input type="radio" id="<?php echo $id; ?>01" name="<?php + echo $id; ?>" value="1"<?php echo $str_enabled; ?> /> <?php echo i18n("Enable"); ?></label> + <label for="<?php echo $id; ?>02"><input type="radio" id="<?php echo $id; ?>02" name="<?php + echo $id; ?>" value="0"<?php echo $str_disabled; ?> /> <?php echo i18n("Disable"); ?></label> <?php break; case 'text': @@ -174,7 +174,7 @@ <div align="right"> <select name="<?php echo $id; ?>" size="1"<?php echo (isset($settings['input_settings']) ? $settings['input_settings'] : '' ); ?> class="linForms"> <?php - foreach($settings['options'] AS $option_key=>$option_value) + foreach($settings['options'] as $option_key=>$option_value) { if($option_key == $value) { @@ -199,7 +199,14 @@ function saveConfig($array,$userid=0) { - foreach($array AS $value) + /** + * update config array once before + * need this for the plugins, the configs are not yet in array, only in the database + */ + $GLOBALS['linpha']->sql->config->reloadConfig(); + + + foreach($array as $value) { /** * does this config name exists? @@ -214,7 +221,7 @@ linSysLog(i18n("Settings saved.")); /** - * update config array + * update config array once after */ $GLOBALS['linpha']->sql->config->reloadConfig(); @@ -311,6 +318,10 @@ /** * a list of all settings which are enable/disable * to show radio buttons instead of text field + * not that bad if not uptodate + * + * @uses /admin/settings_all.php + * @uses /modules/module.settings.php */ function getRadioOptions() { @@ -358,24 +369,20 @@ function getTemplates() { $templatesdir = LINPHA_DIR."/templates"; - - $file_handle = opendir($templatesdir); - $all_themes = array(); - - while( ($file = readdir($file_handle)) !== false ) - { - if($file != "." && $file != ".." && $file != ".svn" && - is_dir($templatesdir.'/'.$file) && - file_exists($templatesdir.'/'.$file.'/global.html.php') && // do at least this check - file_exists($templatesdir.'/'.$file.'/themes') // do at least this check + $d = dir($templatesdir); + while ( ($entry = $d->read()) !== false ) { + if($entry != "." && $entry != ".." && $entry != ".svn" + && is_dir($templatesdir.'/'.$entry) + && file_exists($templatesdir.'/'.$entry.'/global.html.php') // do at least this check + && file_exists($templatesdir.'/'.$entry.'/themes') // do at least this check + ) { - $all_themes[$file] = $file; + $all_themes[$entry] = $entry; } } + $d->close(); - closedir($file_handle); - /* Sort theme files aphabetically */ asort($all_themes); @@ -385,26 +392,40 @@ function getThemes($template) { $templatesdir = LINPHA_DIR."/templates/".$template."/themes"; - - $file_handle = opendir($templatesdir); - $all_themes = array(); - - while( ($file = readdir($file_handle)) !== false ) - { - if($file != "." && $file != ".." && $file != ".svn" && is_dir($templatesdir.'/'.$file)) + $d = dir($templatesdir); + while ( ($entry = $d->read()) !== false ) { + if($entry != "." && $entry != ".." && $entry != ".svn" + && is_dir($templatesdir.'/'.$entry) ) { - $all_themes[$file] = $file; + $all_themes[$entry] = $entry; } } + $d->close(); - closedir($file_handle); - /* Sort theme files aphabetically */ asort($all_themes); return $all_themes; } +function getPlugins() +{ + $plugin_dir = LINPHA_DIR.'/lib/plugins'; + $d = dir($plugin_dir); + while ( ($entry = $d->read()) !== false ) { + if($entry != "." && $entry != ".." && $entry != ".svn" && $entry != "example" + && is_dir($plugin_dir.'/'.$entry) + && file_exists($plugin_dir.'/'.$entry.'/sql/sql.data.php') + ) + { + $arrPlugins[] = $entry; + } + } + $d->close(); + + return $arrPlugins; +} + } // end class LinAdmin ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -140,6 +140,7 @@ /** * create a unique tmp folder + * not really thread safe, but it should be enough for us */ public static function createTmpFolder($prefix) { Modified: trunk/linpha2/lib/include/sql/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.data.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/include/sql/sql.data.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -97,36 +97,6 @@ 'sys_style_others_sortorder' => 'nameasc', 'sys_user_autologin' => '1', - - - 'plugins_available' => 'filemanager,guestbook,log,maps,maillist,rss,stats,watermark', - - 'plugins_filemanager_enable' => '0', - 'plugins_filemanager_nruploads' => '5', - - 'plugins_guestbook_enable' => '0', - - 'plugins_log_enable' => '0', - 'plugins_log_filename' => 'var/linpha-'.random_string(6).'.log', - 'plugins_log_syslog_enable' => '0', - 'plugins_log_syslog_add_events' => '', - 'plugins_log_email_enable' => '0', - 'plugins_log_email_add_events' => '', - 'plugins_log_email_to' => 'LinPHA Logger<log@'.$_SERVER["HTTP_HOST"].'>', - 'plugins_log_email_headers' => 'From:LinPHA Logger<noreply@'.$_SERVER["HTTP_HOST"].'>', - 'plugins_log_email_subject' => 'Linpha Log', - - 'plugins_maps_enable' => '0', - 'plugins_maps_defaultMarkerZoom' => '10', - 'plugins_maps_mapType' => 'google', - 'plugins_maps_google_key' => 'ABQIAAAAAXCMfho4_sqSSh0VqMB80xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSfO_6bbb_ScfT_zPgcnJMKyGltOg', // key for http://localhost - 'plugins_maps_markerThumbSize' => '350', - - 'plugins_maillist_enable' => '0', - 'plugins_rss_enable' => '0', - 'plugins_stats_enable' => '0', - 'plugins_watermark_enable' => '0', - ); $options_user_overrideable = Array( @@ -200,13 +170,7 @@ $sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . "VALUES ('metadata_edit', '')"; $sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('watermark', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('stats', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . "VALUES ('download', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('plugins_maps_setMarkers', '')"; /** Modified: trunk/linpha2/lib/include/sql/sql.mysql.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.mysql.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/include/sql/sql.mysql.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -145,15 +145,5 @@ "meta_data VARCHAR(255) NOT NULL default '', " . "PRIMARY KEY (id) " . ")", - "CREATE TABLE ".$linpha_tables['plugins_maps_markers']." ( ". - "id INT NOT NULL AUTO_INCREMENT, " . - "albId INT NOT NULL default '0', " . - "albPath VARCHAR(255) NOT NULL default '', " . - "markerName VARCHAR(255) NOT NULL default '', " . - "markerLat VARCHAR(255) NOT NULL default '', " . - "markerLon VARCHAR(255) NOT NULL default '', " . - "markerZoom INT NOT NULL default '0', " . - "PRIMARY KEY (id) " . - ")" ); ?> Modified: trunk/linpha2/lib/include/sql/sql.tables.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.tables.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/include/sql/sql.tables.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -36,6 +36,6 @@ "meta_xmp" => "meta_xmp", "meta_comments" => "meta_comments", "meta_data" => "meta_data", - "plugins_maps_markers" => "plugins_maps_markers" + "plugins_maps_setMarkers" => "plugins_maps_markers", // still need the plugin entries; workaround for reset_database.php ); ?> Deleted: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/modules/module.filemanager.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -1,1216 +0,0 @@ -<?php -/* - * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> - * Florian Angehrn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/** - * Filemanager - * @package Modules - */ - -/** - * Short Permission Description - * If a user has write permission to folder A, it means that - * he can upload images to this folder, rename content, delete content - * But he cannot rename or delete the folder itself - * - * - * it doesnt make sense to give write permissions to the files itself - * - * - * @todo make an option with allowed filetypes to upload: images, images and videos, all - * default setting: images - * its very dangerous if users may upload php files etc.!! or even video files may be - * prepared with malicious code (there are known security holes in some video players!) - */ - -/** - * @todo update md5sum while renaming or moving a folder - * on a folder, the md5sum is based on $md5sum = md5($dirname.'/'.$filename); - */ - -if(!defined('LINPHA_DIR')) { exit(1); } - -/** - * some double used i18n entries - */ - $str_checkpermissions = i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)"); - $str_autoimportdisabled = i18n("Autoimport is disabled, you need now to start the manual import to make your changes appear, but you maybe don't have permissions to do that..."); - $str_nopermission = i18n("You don't have permissions to this folder!"); - $str_filealreadyexists = i18n("A File/Folder with the same name already exists!"); - -/** - * init stuff - */ - $parent_id = $linpha->template->idCurrent; - - /** - * check global permission - */ - if(! $linpha->sql->config->value['plugins_filemanager_enable'] - && !$linpha->sql->isAdmin()) - { - echo i18n("No Access!"); - exit(); - } - - if( ! $linpha->sql->photoIsAllowed( $parent_id, 'read' ) ) - { - echo i18n("No Access!"); - exit(); - } - - /** - * use this for child objects - */ - if( $linpha->sql->photoIsAllowed( $parent_id, 'write' ) ) - { - $isWriteAble = true; - } - else - { - $isWriteAble = false; - } - - - $i = 0; - $sum['size'] = 0; - $sum['files'] = 0; - - $use_posix = checkPosix(); - - if($use_posix) { - $uid = @posix_getuid(); // get user id of current process - } else { - $uid = 0; - } - - /** - * upload stuff - */ - include_once(LINPHA_DIR.'/lib/classes/archiver.class.php'); - $apps = new Archive_Applications(); - $apps->searchApps(); - - $appselect = '<option value="-">'. i18n("Extract Archive With"). '</option>'; - foreach($apps->found_apps AS $key=>$value) - { - $value = $key.' (.'.$apps->apps[$key]['file_ext'].')'; - $appselect .= '<option value="'.$key.'">'.$value.'</option>'; - } - -/** - * output buffering, to use in template - */ -ob_start(); - -/** - * parsing POST data - * - * cmd = file_action -> show forms - * cmd = do_file_action -> do actions - */ -if(isset($_REQUEST['cmd'])) -{ - try - { - switch($_REQUEST['cmd']) - { - case 'file_action': - if(!isset($_REQUEST['checkedfiles'])) - { - throw new Exception(i18n("No Files Selected")); - } - if(!isset($_REQUEST['file_action'])) - { - throw new Exception(i18n("No Action Selected")); - } - - ?> - <form method="POST" action="<?php echo LINPHA_LINK.'&linCat=filemanager&linId='.$parent_id; ?>"> - <?php - switch($_REQUEST['file_action']) - { - case 'rename': - $data = $linpha->db->GetRow("SELECT name, parent_id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($_REQUEST['checkedfiles'][0])."'"); - - echo '<b>'.i18n("Rename File/Folder").':</b><br />'; - ?> - <input type="text" name="new_name" value="<?php echo htmlspecialchars($data['name'],ENT_QUOTES); ?>" class="linForms" style="width: 300px;" /> - <input type="hidden" name="file_id" value="<?php echo $_REQUEST['checkedfiles'][0]; ?>" /> - <?php - break; - - case 'move': - case 'copy': - if( $_REQUEST['file_action'] == 'move') - { - echo i18n("Move These Files/Folders"); - } - elseif( $_REQUEST['file_action'] == 'copy') - { - echo i18n("Copy These Files/Folders"); - } - echo ':<br />'; - - foreach($_REQUEST['checkedfiles'] AS $value) - { - $data = $linpha->db->GetRow("SELECT name FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - echo htmlspecialchars($data['name'],ENT_QUOTES).', '; - } - echo '<br /><br />'; - echo i18n("To").':'; - echo '<br />'; - ?> - <select name="movecopy_to" class="linForms"> - <option value="0">/</option> - <?php - linBuildAlbumSelect( $with_all_albs_entry=false,$with_linebreaks=true ); - ?> - </selet> - <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_REQUEST['checkedfiles']); ?>" /> - <?php - break; - case 'delete': - echo i18n("Delete all the following files/folders including contents:").'<br />'; - foreach($_REQUEST['checkedfiles'] AS $value) - { - $data = $linpha->db->GetRow("SELECT name FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - echo htmlspecialchars($data['name'],ENT_QUOTES).', '; - } - echo '<br /><br />'; - echo i18n("Really Sure?"); - ?> - <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_REQUEST['checkedfiles']); ?>" /> - <?php - break; - case 'changeperm': - $full_filename = LinSql::getFullImagePath( $_REQUEST['checkedfiles'][0]); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - $perm = getReadableFileperms($full_filename); - - (substr($perm, 1, 1)!="-" ? $ur = 1 : ''); - (substr($perm, 2, 1)!="-" ? $uw = 1 : ''); - (substr($perm, 3, 1)!="-" ? $ux = 1 : ''); - (substr($perm, 4, 1)!="-" ? $gr = 1 : ''); - (substr($perm, 5, 1)!="-" ? $gw = 1 : ''); - (substr($perm, 6, 1)!="-" ? $gx = 1 : ''); - (substr($perm, 7, 1)!="-" ? $or = 1 : ''); - (substr($perm, 8, 1)!="-" ? $ow = 1 : ''); - (substr($perm, 9, 1)!="-" ? $ox = 1 : ''); - - echo i18n("Change Permission Of:").' '.htmlspecialchars($full_filename,ENT_QUOTES); - ?> - <br /> - <table border="1" cellpadding="0" cellspacing="0"> - <tr> - <td width="100"> </td> - <td class='admintable' width="75"><?php echo i18n("Read"); ?></td> - <td class='admintable' width="75"><?php echo i18n("Write"); ?></td> - <td class='admintable' width="75"><?php echo i18n("Execute"); ?></td> - </tr> - <tr> - <td class='admintable'><?php echo i18n("Owner"); ?></td> - <td><input name="ur" type="checkbox" value="4"<?=(isset($ur) ? ' checked' : '')?>></td> - <td><input name="uw" type="checkbox" value="2"<?=(isset($uw) ? ' checked' : '')?>></td> - <td><input name="ux" type="checkbox" value="1"<?=(isset($ux) ? ' checked' : '')?>></td> - </tr> - <tr> - <td class='admintable'><?php echo i18n("Group"); ?></td> - <td><input name="gr" type="checkbox" value="4"<?=(isset($gr) ? ' checked' : '')?>></td> - <td><input name="gw" type="checkbox" value="2"<?=(isset($gw) ? ' checked' : '')?>></td> - <td><input name="gx" type="checkbox" value="1"<?=(isset($gx) ? ' checked' : '')?>></td> - </tr> - <tr> - <td class='admintable'><?php echo i18n("All Others"); ?></td> - <td><input name="or" type="checkbox" value="4"<?=(isset($or) ? ' checked' : '')?>></td> - <td><input name="ow" type="checkbox" value="2"<?=(isset($ow) ? ' checked' : '')?>></td> - <td><input name="ox" type="checkbox" value="1"<?=(isset($ox) ? ' checked' : '')?>></td> - </tr> - </table> - <input type="hidden" name="file_id" value="<?php echo $_REQUEST['checkedfiles'][0]; ?>" /> - <?php - break; - } - ?> - <input type="hidden" name="cmd" value="do_file_action" /> - <input type="hidden" name="file_action" value="<?php echo $_REQUEST['file_action']; ?>" /> - <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="linButton" /> - </form> - <hr /><br /> - <?php - break; - - case 'do_file_action': - - switch($_POST['file_action']) - { - case 'rename': - $new_name = removeUnWantedChars( $_POST['new_name'] ); - - $full_filename = LinSql::getFullImagePath( $_POST['file_id'] ); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - $parent_dirname = dirname($full_filename); - - /** - * check write permission of parent folder - */ - $data = $linpha->db->GetRow("SELECT parent_id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($_POST['file_id'])."'"); - if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) - { - throw new Exception($str_nopermission); - } - - if( nameAlreadyExists( $new_name, $data['parent_id'] )) - { - throw new Exception($str_filealreadyexists); - } - - if( ! @rename( $full_filename , $parent_dirname."/".$new_name ) ) - { - throw new Exception(i18n("Rename File/Folder Failed!"). - htmlspecialchars($full_filename,ENT_QUOTES).' '.i18n("to").' '.htmlspecialchars($parent_dirname.'/'.$new_name,ENT_QUOTES). - LIN_NL.$str_checkpermissions - ); - } - - /** - * rename on filesys was successful - * -> rename also in db - */ - $linpha->db->Execute("UPDATE ".LIN_PREFIX."photos SET name = '".LinSql::linAddslashes($new_name)."' " . - "WHERE id = '".LinSql::linAddslashes($_POST['file_id'])."'"); - - linSysLog(i18n("Successfully Renamed!")); - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_rename',"renamed file (".$full_filename." to ".$parent_dirname."/".$new_name.")"); - break; - - case 'move': - case 'copy': - /** - * check write permission of target folder - * AND it will also check if it is a valid id (?) - */ - if( ! $linpha->sql->photoIsAllowed( $_POST['movecopy_to'], 'write') ) - { - throw new Exception($str_nopermission); - } - - /** - * get target name - */ - $full_destparentname = LinSql::getFullImagePath( $_POST['movecopy_to'] ); - - if( $full_destparentname == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_destparentname); - } - - /** - * check write permission of destination parent folder - */ - if( ! is_writable($full_destparentname) ) - { - throw new Exception( - sprintf( - i18n("Cannot Copy/Move to Folder \"%s\" because its not writable!"), - htmlspecialchars($full_destparentname,ENT_QUOTES) - ). - LIN_NL.$str_checkpermissions - ); - } - - - /** - * go through each folder - */ - $checkedfiles = explode(';',$_POST['checkedfiles']); - foreach($checkedfiles AS $value) - { - /** - * get full source name - */ - $full_sourcename = LinSql::getFullImagePath( $value ); - - if( $full_sourcename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - /** - * check read permission of source folder (not parent! ...) and content - */ - if( ! $linpha->sql->photoIsAllowed( $value, 'read') ) - { - throw new Exception($str_nopermission); - } - - /** - * check if destination is empty - */ - if( nameAlreadyExists( basename($full_sourcename), $_POST['movecopy_to'] )) - { - throw new Exception($str_filealreadyexists); - } - - /** - * move - */ - if( $_POST['file_action'] == 'move') - { - /** - * check write permission of parent source folder - */ - $data = $linpha->db->GetRow("SELECT parent_id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - if($_POST['file_action'] == 'move') - { - if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) - { - throw new Exception($str_nopermission); - } - } - - if( ! rename($full_sourcename, $full_destparentname.'/'.basename($full_sourcename) ) ) - { - linSysLog( - sprintf( - i18n("Error While Moving Files/Folders \"%s\" to \"%s\"!"), - htmlspecialchars($full_sourcename,ENT_QUOTES), - htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) - ) - ); - linSysLog($str_checkpermissions); - - linLog(LOG_TYPE_FILEMANAGER,LOG_ERR,'fm_move',"cannot moved file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); - } - else - { - $linpha->db->Execute("UPDATE ".LIN_PREFIX."photos " . - "SET parent_id = '".LinSql::linAddslashes($_POST['movecopy_to'])."' " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - - linSysLog( - sprintf( - i18n("Successfully Moved \"%s\" to \"%s\"!"), - htmlspecialchars($full_sourcename,ENT_QUOTES), - htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) - ) - ); - - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_move',"moved file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); - } - } - /** - * copy - */ - elseif( $_POST['file_action'] == 'copy') - { - /** - * copy files/folders (only which we have read permission) - */ - copy_r( $value, $full_sourcename, $full_destparentname); - - if( ! file_exists( $full_destparentname.'/'.basename($full_sourcename) )) - { - linSysLog( - sprintf( - i18n("Error While Copying Files/Folders \"%s\" to \"%s\"!"), - htmlspecialchars($full_sourcename,ENT_QUOTES), - htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) - ) - ); - linSysLog($str_checkpermissions); - - linLog(LOG_TYPE_FILEMANAGER,LOG_ERR,'fm_copy',"Cannot copy file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); - } - else - { - linSysLog( - sprintf( - i18n("Successfully Copied \"%s\" to \"%s\"!"), - $full_sourcename, - $full_destparentname.'/'.basename($full_sourcename) - ) - ); - - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_copy',"Copied file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); - } - } - } - - break; - - case 'delete': - $checkedfiles = explode(';',$_POST['checkedfiles']); - foreach($checkedfiles AS $value) - { - if( $value == 0 ) - { - throw new Exception(i18n("For security reasons, its not possible to delete the whole albums folder!")); - } - - $data = $linpha->db->GetRow("SELECT parent_id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - - if( !isset($data['parent_id']) ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' file id: '.$value); - } - - /** - * check write permission of parent folder - */ - if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) - { - throw new Exception($str_nopermission); - } - - $full_filename = LinSql::getFullImagePath( $value ); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - LinFilesys::rm_rf($full_filename); - - if(file_exists($full_filename)) - { - throw new Exception(i18n("Deleting Files/Folders Failed").": \"".htmlspecialchars($full_filename,ENT_QUOTES)."\"".LIN_NL.$str_checkpermissions); - } - - linSysLog(i18n("File/Folder deleted successfully!")); - LinImport::deleteEntry( $value, $full_filename); - - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_delete',"Deleted file/folder (".$full_filename.")"); - } - break; - - case 'create_folder': - /** - * check write permission of parent folder - */ - if( ! $linpha->sql->photoIsAllowed( $linpha->template->idCurrent, 'write') ) - { - throw new Exception($str_nopermission); - } - - $new_name = removeUnWantedChars( $_POST['folder_name'] ); - - if( nameAlreadyExists( $new_name, $linpha->template->idCurrent )) - { - throw new Exception($str_filealreadyexists); - } - - $full_filename = LinSql::getFullImagePath( $linpha->template->idCurrent ); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - if( empty( $new_name ) ) //catch empty folder create submit - { - throw new Exception(i18n("Create Folder Failed, No Folder Name given")); - } - elseif(! @mkdir( $full_filename .'/'. $new_name ) ) - { - throw new Exception(i18n("Create Folder Failed").": \"".htmlspecialchars($new_name,ENT_QUOTES)."\"".LIN_NL.$str_checkpermissions); - } - - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_create_folder',"Created folder (".$full_filename.'/'.$new_name.")"); - linSysLog(i18n("Folder Created Successfully!")); - - if( ! $linpha->sql->config->value['sys_import_autoimport'] ) - { - linSysLog($str_autoimportdisabled); - } - - break; - case 'changeperm': - $full_filename = LinSql::getFullImagePath( $_POST['file_id'] ); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - isset($_POST['ur']) ? $ur = $_POST['ur'] : $ur = 0; - isset($_POST['uw']) ? $uw = $_POST['uw'] : $uw = 0; - isset($_POST['ux']) ? $ux = $_POST['ux'] : $ux = 0; - isset($_POST['gr']) ? $gr = $_POST['gr'] : $gr = 0; - isset($_POST['gw']) ? $gw = $_POST['gw'] : $gw = 0; - isset($_POST['gx']) ? $gx = $_POST['gx'] : $gx = 0; - isset($_POST['or']) ? $or = $_POST['or'] : $or = 0; - isset($_POST['ow']) ? $ow = $_POST['ow'] : $ow = 0; - isset($_POST['ox']) ? $ox = $_POST['ox'] : $ox = 0; - - $u = $ur+$uw+$ux; - $g = $gr+$gw+$gx; - $o = $or+$ow+$ox; - - $mode = $u.$g.$o; - - if(! @chmod($full_filename,intval($mode,8))) - { - throw new Exception(i18n("Change Permissions Failed").": \"".htmlspecialchars($full_filename,ENT_QUOTES)."\" to ".$mode.LIN_NL.$str_checkpermissions); - } - - linSysLog(i18n("Permissions Changed Successfully!")); - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_perm',"changed permission of ".$full_filename." to ".$mode); - - break; - case 'upload': - $targetdir = LinSql::getFullImagePath( $linpha->template->idCurrent ); - - $full_filename = LinSql::getFullImagePath( $linpha->template->idCurrent ); - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - for($i = 0; $i < $linpha->sql->config->value['plugins_filemanager_nruploads']; $i++ ) - { - if( isset( $_FILES[ 'file' . $i ] ) && $_FILES[ 'file' . $i]['name'] ) // break loop as sson as 'name' is not set, to prevent a couple of warnings - { - $thisfile = $_FILES[ 'file' . $i ]; - - /** - * check errors - */ - if (isset($thisfile['error']) && $thisfile['error'] != 0 ) // ['error'] was added in PHP 4.2.0 - { - switch ( $thisfile['error'] ) - { - case 1: - throw new Exception( sprintf(i18n("Error: The uploaded file %s exceeds the upload_max_filesize directive in php.ini - %s"), - htmlspecialchars($thisfile['name'],ENT_QUOTES), ini_get('upload_max_filesize') ) ); - break; - case 2: - throw new Exception( sprintf(i18n("Error: Size of uploaded file %s exceeds the HTML FORM settings"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); - break; - case 3: - throw new Exception( sprintf(i18n("The uploaded file %s was only partially uploaded"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); - break; - } - } - - if ( $_POST[ 'app' . $i ] == '-' ) - { - list($org_width, $org_height, $org_type) = LinIdentify::linGetImageSize( $thisfile['tmp_name'] ); - if( !LinIdentify::isSupportedImage( $org_type ) && !LinIdentify::isVideo( $org_type ) ) - { - throw new Exception( i18n("This File Is Wether An Image Nor A Video").' ('.htmlspecialchars($thisfile['name'],ENT_QUOTES).')' ); - } - - if ( !move_uploaded_file( $thisfile['tmp_name'], "".$targetdir.'/'.$thisfile['name']."" ) ) - { - throw new Exception( sprintf(i18n("Unable To Move File (%s) To Directory (%s)"),htmlspecialchars($thisfile['name'],ENT_QUOTES),htmlspecialchars($targetdir,ENT_QUOTES ) ) ); - } - - $somethingUploaded = true; - } - /** - * extract archives - */ - else // $_POST[ 'app' . $i ] != '-' - { - $tmpfolder = LinFilesys::createTmpFolder('filemanager'); - - if ( !move_uploaded_file( $thisfile['tmp_name'], $tmpfolder . '/' . $thisfile['name'] ) ) - { - throw new Exception(sprintf( i18n("Unable To Move File (%s) To Directory (%s)"), htmlspecialchars($thisfile[ 'name' ],ENT_QUOTES), htmlspecialchars($targetdir,ENT_QUOTES) ) ); - } - - - $command = $apps->apps[$_POST['app'.$i]]['command_extract']; - $apps->searchApp($_POST['app'.$i]); - - $executable = $apps->found_apps[$_POST['app'.$i]].$apps->apps[$_POST['app'.$i]]['executable_extract']; - - $command = str_replace('{executable}',$executable,$command); - $command = str_replace('{archive_name}',linEscapeString($thisfile['name']),$command); - - $oldpwd = getcwd(); - if ( !chdir( $tmpfolder ) ) - { - throw new Exception( sprintf( i18n("Unable to switch (chdir) to %s directory. File being processed: %s"), $tmpfolder, $thisfile[ 'name' ] ) ); - } - - $output=array(); $return_value=''; // do not this directly in exec() ! - exec( $command, $output, $return_value ); - chdir( $oldpwd ); - - - echo '<textarea cols="80" rows="4"">' . - htmlspecialchars( $command . "\n". implode( "\n", $output ), ENT_QUOTES ) . - '</textarea><br />'; - - unset($output); - - /** - * move valid images and videos to target dir - * this will delete the archive file automatically... - * and also delete the tmpfolder - */ - moveValidEntries( $tmpfolder, $targetdir ); - - $somethingUploaded = true; - } - - linSysLog(i18n("File uploaded").": ".$thisfile['tmp_name']." ".$targetdir.'/'.$thisfile['name']); - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_upload',"Uploaded file (".$thisfile['tmp_name']." ".$targetdir.'/'.$thisfile['name'].")"); - } - } - - if(isset($somethingUploaded)) - { - if( ! $linpha->sql->config->value['sys_import_autoimport'] ) - { - linSysLog($str_autoimportdisabled); - } - } - break; - } // end switch($_POST['file_action']) - break; // end case 'do_file_action': - - } // end switch($_REQUEST['cmd']) - } // end try() - catch(Exception $error) - { - linSysLog("Error: ".str_replace(LIN_NL,"<br />",$error -> getMessage())); - linLog(LOG_TYPE_FILEMANAGER,LOG_ERR,'fm_'.$_REQUEST['file_action'],$error->getMessage()); - } - - /** - * print Syslog - */ - /*if( isset($linpha->template->output['sys_log']) ) - { - echo $linpha->template->output['sys_log']; - echo '<hr />'; - unset($linpha->template->output['sys_log']); - }*/ -} - -/** - * do import - */ - if( $linpha->sql->config->value['sys_import_autoimport'] ) - { - /** - * empty syslog - */ - //unset($linpha->template->output['sys_log']); - - LinImport::updateDir( $parent_id, $recursive = false, $dryrun = false ); - - /** - * print Syslog - */ - /*if( isset($linpha->template->output['sys_log']) ) - { - echo i18n("LinPHA Import:").'<br />'; - echo $linpha->template->output['sys_log']; - echo '<hr />'; - unset($linpha->template->output['sys_log']); - }*/ - } - -echo i18n("Current Folder:").' '.linSetNavigationLine( $parent_id, LINPHA_LINK.'&linCat=filemanager&linId=').'<br />'; -?> - -<form method="POST" action="<?php echo LINPHA_LINK.'&linCat=filemanager&linId='.$parent_id; ?>"> -<div id="linDivFilemanager"> -<table> - <tr> - <td width="20"> </td> - <td width="500"> - <?php - if($parent_id == 0) - { - echo ' '; - } - else - { - $data = $linpha->db->GetRow("SELECT name, parent_id FROM ".LIN_PREFIX."photos WHERE id = '".LinSql::linAddslashes($parent_id)."'"); - ?> - <a href="<?php echo LINPHA_LINK.'&linCat=filemanager&linId='.$data['parent_id']; ?>">..</a> - <?php - } - ?> - </td> - <td width="100"> </td> - <td width="150"> </td> - <td width="100"> </td> - </tr> - -<?php - -$query = $linpha->db->Execute("SELECT id, name, img_type FROM ".LIN_PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes($parent_id)."' ORDER by name"); -while($data = $query->FetchRow()) -{ - $full_filename = LinSql::getFullImagePath( $data['id'] ); - - /** - * show only if file exists and we have READ permissions - */ - if( file_exists( $full_filename ) && $linpha->sql->photoIsAllowed( $data['id'], 'read' ) ) - { - /** - * set file informations - */ - $filestat = stat($full_filename); - - /** - * size and nr files - */ - if( $data['img_type'] != 0 && $data['img_type'] != 9999999 ) - { - $sum['size'] += $filestat['size']; - $sum['files']++; - } - - /** - * owner and group name - */ - if($use_posix) { - $owner_info = @posix_getpwuid($filestat['uid']); // use @ because check_posix() can return true even if it fails... - $group_info = @posix_getgrgid($filestat['gid']); - } else { - $owner_info['name'] = ''; - $group_info['name'] = ''; - } - - /** - * file permissions - */ - if( LIN_OS == 'win' ) - { - $file_permissions = - '[' . - (is_readable($full_filename) ? '<font color="green">r</font>' : ' ') . - (is_writable($full_filename) ? '<font color="red">w</font>' : ' ') . - (function_exists('is_executable') ? - (is_executable($full_filename) ? '<font color="blue">x</font>' : ' ') - : - ' ' - ) . - ']'; - } else { - $perm = '['.getReadableFileperms($full_filename).']'; - - $perm = str_replace('r','<font color="green">r</font>',$perm); - $perm = str_replace('w','<font color="red">w</font>',$perm); - $perm = str_replace('x','<font color="blue">x</font>',$perm); - - if($uid == $filestat['uid']) - { - $file_permissions = '<a href="'.LINPHA_LINK.'&linCat=filemanager&cmd=file_action&file_action=changeperm&checkedfiles[]='.$data['id'].'">'. $perm . '</a>'; - } - else - { - $file_permissions = $perm; - } - } - - ?> - <tr> - <td> - <?php - if($isWriteAble) - { - if( isset($_REQUEST['checkedfiles']) - && is_array($_REQUEST['checkedfiles']) - && in_array($data['id'], $_REQUEST['checkedfiles']) ) - { - $str_checked = ' checked="checked"'; - } - else - { - $str_checked = ''; - } - ?> - <input type="checkbox" name="checkedfiles[]" value="<?php echo $data['id']; ?>"<?php echo $str_checked; ?> /> - <?php } else { ?> - - <?php } ?> - </td> - <td> - <?php - if($data['img_type']==0) - { - echo '<a href="'.LINPHA_LINK.'&linCat=filemanager&linId='.$data['id'].'">'.htmlspecialchars($data['name'],ENT_QUOTES).'</a>'; - } - else - { - echo htmlspecialchars($data['name'],ENT_QUOTES); - } - ?> - </td> - <td align="right"><?php echo $data['img_type']==0 ? ' ' : LinFilesys::niceFilesize($filestat['size'],1); ?></td> - <td align="center"><?php echo strftime(... [truncated message content] |
From: <bz...@us...> - 2007-12-09 13:15:36
|
Revision: 4805 http://linpha.svn.sourceforge.net/linpha/?rev=4805&view=rev Author: bzrudi Date: 2007-12-09 05:15:30 -0800 (Sun, 09 Dec 2007) Log Message: ----------- "fixed a couple of notices and warnings introduced by new plugin model" Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/classes/linpha.imgview.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-12-02 21:46:57 UTC (rev 4804) +++ trunk/linpha2/ChangeLog 2007-12-09 13:15:30 UTC (rev 4805) @@ -1,3 +1,6 @@ +2007-12-09 bzrudi + * fix for db_error.log file create + * fixed a couple of notices and warnings introduced by new plugin model 2007-12-02 flo * created settings and permissions section for plugins Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2007-12-02 21:46:57 UTC (rev 4804) +++ trunk/linpha2/lib/classes/linpha.functions.php 2007-12-09 13:15:30 UTC (rev 4805) @@ -602,55 +602,85 @@ */ if( !isset($GLOBALS['linpha']->sql->config->value) ) // database not connected! { - error_log("$time | $severity_msg | $type_msg | $ip | $user | $event | $text".LIN_NL, 3, LINPHA_DIR.'/var/db_error.log' ); + error_log("".time()." | $severity_msg | $type_msg | $ip | $user | $event | $text".LIN_NL, 3, LINPHA_DIR.'/var/db_error_tmp.log' ); } else { - /** - * filename - */ - error_log("$time | $severity_msg | $type_msg | $ip | $user | $event | $text".LIN_NL, 3, LinFilesys::getFullPath($GLOBALS['linpha']->sql->config->value['plugins_log_filename']) ); - - /** - * email - */ - if( $GLOBALS['linpha']->sql->config->value['plugins_log_email_enable'] ) - { - if( $severity <= LOG_WARNING OR - strpos($GLOBALS['linpha']->sql->config->value['plugins_log_email_add_events'], $event) !== false ) - { - mail( - $GLOBALS['linpha']->sql->config->value['plugins_log_email_to'], - $GLOBALS['linpha']->sql->config->value['plugins_log_email_subject'], - "$time | $severity_msg | $type_msg | $ip | $ip | $user | $text", - $GLOBALS['linpha']->sql->config->value['plugins_log_email_headers'] - ); - } - } - /** - * syslog + * Only if logging plugin is enabled */ - if( $GLOBALS['linpha']->sql->config->value['plugins_log_syslog_enable'] && - $severity <= LOG_WARNING ) - { - /** + if(isset($GLOBALS['linpha']->sql->config->value['plugins_log_enable']) && + $GLOBALS['linpha']->sql->config->value['plugins_log_enable'] == '1') + { + /** + * In case of database connection error a file named + * db_error_tmp.log is created. If the file exists, copy it's content + * over to the default filename defined in plugins_log_filename + * and delete it later for security reasons. We have to go this way, + * as a random filename would create a new file every time an error + * occured, and a defined filenname is not the best choice for + * security reasons. + * bzrudi + */ + if(file_exists(LINPHA_DIR.'/var/db_error_tmp.log')) + { + $fhandle = @file(LINPHA_DIR.'/var/db_error_tmp.log'); + if(is_array($fhandle)) + { + foreach($fhandle AS $line) + { + error_log("$line", 3, LinFilesys::getFullPath($GLOBALS['linpha']->sql->config->value['plugins_log_filename'])); + } + unlink(LINPHA_DIR.'/var/db_error_tmp.log'); + } + } + + /** + * filename + */ + error_log("$time | $severity_msg | $type_msg | $ip | $user | $event | $text".LIN_NL, 3, LinFilesys::getFullPath($GLOBALS['linpha']->sql->config->value['plugins_log_filename']) ); + + /** + * email + */ + if( $GLOBALS['linpha']->sql->config->value['plugins_log_email_enable'] ) + { + if( $severity <= LOG_WARNING OR + strpos($GLOBALS['linpha']->sql->config->value['plugins_log_email_add_events'], $event) !== false ) + { + mail( + $GLOBALS['linpha']->sql->config->value['plugins_log_email_to'], + $GLOBALS['linpha']->sql->config->value['plugins_log_email_subject'], + "$time | $severity_msg | $type_msg | $ip | $ip | $user | $text", + $GLOBALS['linpha']->sql->config->value['plugins_log_email_headers'] + ); + } + } + + /** + * syslog + */ + if( $GLOBALS['linpha']->sql->config->value['plugins_log_syslog_enable'] && + $severity <= LOG_WARNING ) + { + /** * In Windows NT, use the following values of priority: * 1 = error, * 2-5 = warning * 6 = info */ - - if( LIN_OS == 'win' ) - { - if( $severity <= LOG_ERR ) - { - $severity = 1; - } - } - - syslog($severity, "LinPHA $severity_msg | $type_msg | $ip | $user | $event | $text"); - } + + if( LIN_OS == 'win' ) + { + if( $severity <= LOG_ERR ) + { + $severity = 1; + } + } + + syslog($severity, "LinPHA $severity_msg | $type_msg | $ip | $user | $event | $text"); + } + } } } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-12-02 21:46:57 UTC (rev 4804) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2007-12-09 13:15:30 UTC (rev 4805) @@ -279,7 +279,9 @@ */ if($GLOBALS['linpha']->sql->isLoggedIn()) { - if( $GLOBALS['linpha']->sql->config->value['plugins_filemanager_enable'] OR $GLOBALS['linpha']->sql->isAdmin()) + if( isset($GLOBALS['linpha']->sql->config->value['plugins_filemanager_enable']) + && $GLOBALS['linpha']->sql->config->value['plugins_filemanager_enable'] == 1 + OR $GLOBALS['linpha']->sql->isAdmin()) { $GLOBALS['linpha']->template->output['menu_My Settings']['filemanager'] = array('name' => i18n("Filemanager"), 'value' => LINPHA_LINK.'&linCat=filemanager'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-12-09 13:48:22
|
Revision: 4806 http://linpha.svn.sourceforge.net/linpha/?rev=4806&view=rev Author: bzrudi Date: 2007-12-09 05:48:16 -0800 (Sun, 09 Dec 2007) Log Message: ----------- "removed logging tab from features within admin section, as it's now to be found under plugins. plus minor changes under features tab " Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/settings_features.php trunk/linpha2/admin/settings_layout.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-12-09 13:15:30 UTC (rev 4805) +++ trunk/linpha2/ChangeLog 2007-12-09 13:48:16 UTC (rev 4806) @@ -1,7 +1,9 @@ 2007-12-09 bzrudi * fix for db_error.log file create * fixed a couple of notices and warnings introduced by new plugin model - + * removed logging tab from features within admin section, as it's now to be + found under plugins. plus minor changes under features tab + 2007-12-02 flo * created settings and permissions section for plugins they are dynamically loaded with the files /lib/plugins/*/settings.*.php Modified: trunk/linpha2/admin/settings_features.php =================================================================== --- trunk/linpha2/admin/settings_features.php 2007-12-09 13:15:30 UTC (rev 4805) +++ trunk/linpha2/admin/settings_features.php 2007-12-09 13:48:16 UTC (rev 4806) @@ -3,11 +3,19 @@ if(!isset($cat3)) { - $cat3 = 'others'; + $cat3 = 'general'; } - +/** + * save settings + */ +if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') +{ + $LinAdmin->saveConfig($LinAdmin->options); +} + $array_menu = array( - 'log' => array('name' => i18n("Logging"), 'link' => 'settings_features_log'), + 'general' => array('name' => i18n("General"), 'link' => 'settings_features_general'), + 'import' => array('name' => i18n("Import"), 'link' => 'settings_features_import'), 'others' => array('name' => i18n("Others"), 'link' => 'settings_features_others'), ); @@ -20,47 +28,17 @@ switch($cat3) { -case 'log': +case 'general': - /** - * save settings - */ - if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') - { - $LinAdmin->saveConfig(Array( - 'plugins_log_filename', - 'plugins_log_syslog_enable', - 'plugins_log_syslog_add_events', - 'plugins_log_email_enable', - 'plugins_log_email_add_events', - 'plugins_log_email_to', - 'plugins_log_email_headers', - 'plugins_log_email_subject' - )); - } + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_lang_autolang'),'sys_lang_autolang',$LinAdmin->option_value_system['sys_lang_autolang']); + $LinAdmin->printAdminConfig('select',$LinAdmin->getDescriptionByOptionName('sys_lang'),'sys_lang',$LinAdmin->option_value_system['sys_lang'],array('options' => linGetAvailableLanguageFiles( 'lib/lang', $withEnglish = true ) ) ); - echo '<br /><h2 class="linStyle">'.i18n("Filename").'</h2>'; - $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_filename'),'plugins_log_filename',$LinAdmin->option_value_system['plugins_log_filename']); +break; - echo '<br /><h2 class="linStyle">'.i18n("Syslog").'</h2>'; - echo i18n("(Event log in Windows)"); - $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_log_syslog_enable'),'plugins_log_syslog_enable',$LinAdmin->option_value_system['plugins_log_syslog_enable']); +case 'import': + +break; - $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_syslog_add_events'),'plugins_log_syslog_add_events',$LinAdmin->option_value_system['plugins_log_syslog_add_events']); - echo i18n("Comma separated list. Valid events:")." login, logout, rotate, comments, guestbook, fm_others, fm_upload, fm_delete, fm_move, fm_copy, fm_rename, fm_create_folder, fm_perm"; - echo '<br />'; - - echo '<br /><h2 class="linStyle">'.i18n("Email").'</h2>'; - $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_log_email_enable'),'plugins_log_email_enable',$LinAdmin->option_value_system['plugins_log_email_enable']); - $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_to'),'plugins_log_email_to',$LinAdmin->option_value_system['plugins_log_email_to']); - $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_subject'),'plugins_log_email_subject',$LinAdmin->option_value_system['plugins_log_email_subject']); - $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_headers'),'plugins_log_email_headers',$LinAdmin->option_value_system['plugins_log_email_headers']); - - $LinAdmin->printAdminConfig('text',$LinAdmin->getDescriptionByOptionName('plugins_log_email_add_events'),'plugins_log_email_add_events',$LinAdmin->option_value_system['plugins_log_email_add_events']); - echo i18n("Comma separated list. Valid events:")." login, logout, rotate, comments, guestbook, fm_others, fm_upload, fm_delete, fm_move, fm_copy, fm_rename, fm_create_folder, fm_perm"; - - break; - case 'others': /** * save settings @@ -77,7 +55,11 @@ $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_image_exif'),'sys_image_exif',$LinAdmin->option_value_system['sys_image_exif']); $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_image_iptc'),'sys_image_iptc',$LinAdmin->option_value_system['sys_image_iptc']); $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_image_xmp'),'sys_image_xmp',$LinAdmin->option_value_system['sys_image_xmp']);*/ - break; +break; +default: +break; + + } ?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2007-12-09 13:15:30 UTC (rev 4805) +++ trunk/linpha2/admin/settings_layout.php 2007-12-09 13:48:16 UTC (rev 4806) @@ -108,9 +108,6 @@ $LinAdmin->printAdminConfig('select',$LinAdmin->getDescriptionByOptionName('sys_style_layout_template'),'sys_style_layout_template',$LinAdmin->option_value_system['sys_style_layout_template'],array('options' => LinAdmin::getTemplates())); $LinAdmin->printAdminConfig('select',$LinAdmin->getDescriptionByOptionName('sys_style_layout_theme'),'sys_style_layout_theme',$LinAdmin->option_value_system['sys_style_layout_theme'],array('options' => LinAdmin::getThemes($LinAdmin->option_value_system['sys_style_layout_template']))); - $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('sys_lang_autolang'),'sys_lang_autolang',$LinAdmin->option_value_system['sys_lang_autolang']); - $LinAdmin->printAdminConfig('select',$LinAdmin->getDescriptionByOptionName('sys_lang'),'sys_lang',$LinAdmin->option_value_system['sys_lang'],array('options' => linGetAvailableLanguageFiles( 'lib/lang', $withEnglish = true ) ) ); - echo '<br /><h2 class="linStyle">'.i18n("Colors").'</h2>'; ?> <script language="JavaScript" type="text/javascript"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2008-01-29 20:01:44
|
Revision: 4830 http://linpha.svn.sourceforge.net/linpha/?rev=4830&view=rev Author: fangehrn Date: 2008-01-29 12:01:16 -0800 (Tue, 29 Jan 2008) Log Message: ----------- updating some files Modified Paths: -------------- trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/docs/dev/external_libraries.txt trunk/linpha2/docs/dev/linpha2.specs.txt trunk/linpha2/lib/js/LinThumbnails.js Added Paths: ----------- trunk/linpha2/lib/js/prototype/ trunk/linpha2/lib/js/scriptaculous-js/ Removed Paths: ------------- trunk/linpha2/lib/js/prototype-1.6.0/ trunk/linpha2/lib/js/scriptaculous-js-1.8.0/ trunk/linpha2/linpha2.specs.txt Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2008-01-29 14:55:11 UTC (rev 4829) +++ trunk/linpha2/docs/dev/TODO.txt 2008-01-29 20:01:16 UTC (rev 4830) @@ -29,6 +29,11 @@ - compress javascripts (prototype and scriptaculous) they are now nearly 200KB big +- php session + limit the session cookie not only to domain, but also to full url path + we cannot use the same session in localhost/linpha1.0 and localhost/linpha2.0 + -> session_set_cookie_params() + ## Big Todos - Switch to strict mode @@ -82,9 +87,33 @@ - Bracket Support, enable by default, only if old version found, disable it, or require imagemagick > "6.1.4" +############################################################################ + Open questions +############################################################################ + +- thumbnail size, set a max size (for example 150px), to be able to switch + the size on fly + +- image cache plugin automatically turned on? + in normal image view, image is displayed javascript based the largest possible + -> we're going to have problems with the image cache, as size ever changes.. + -> we already have this problem in the slideshow + /* edit bzrudi */ + I think we should have the largest possible thumb on filesystem 300px? + smaller ones should be resized by browser. + + i'm thinking about a dynamic image cache + lets say i'm requesting an image between 800x600 and 1024x768 i will get the image 1024x768, + between 1024x768 and 1310x983 i will get an image with 1310x983 + we would have calculate a good value of the different image sizes handling thecompromise + between size of the image and difference in size + + + +############################################################################ DONE - ==== +############################################################################ - how to handle common language strings like "Successfully updated data.", "Submit", "Access denied", "Check file permissions" ?? i suggest using define('LIN_STR_SUBMIT', "Submit"); in the language file Modified: trunk/linpha2/docs/dev/external_libraries.txt =================================================================== --- trunk/linpha2/docs/dev/external_libraries.txt 2008-01-29 14:55:11 UTC (rev 4829) +++ trunk/linpha2/docs/dev/external_libraries.txt 2008-01-29 20:01:16 UTC (rev 4830) @@ -19,18 +19,6 @@ - ptviewer 3.1.2 (http://webuser.hs-furtwangen.de/~dersch/) -- gmapper 1.0 - - to avoid relative path problems: - marker(), otherMarker(), tabMarker(), linkMarker(), mapMarker(), directions(), geocode(): - replaced all - marker( ... , $img = "143.png" , ... ) - $dims = getimagesize($img); - echo "var image = new Array(\"$img\",$dims[0],$dims[1]);\n"; - with - marker( ... , $markerImage , ... ) - echo "var image = new Array(\"$markerImage[0]\",$markerImage[1],$markerImage[2]);\n"; - - increased the number of paragraphs "no image at this zoomlevel" used to auto zoom out - - PHP_JPEG_Metadata_Toolkit_1.11 CHANGES Modified: trunk/linpha2/docs/dev/linpha2.specs.txt =================================================================== --- trunk/linpha2/docs/dev/linpha2.specs.txt 2008-01-29 14:55:11 UTC (rev 4829) +++ trunk/linpha2/docs/dev/linpha2.specs.txt 2008-01-29 20:01:16 UTC (rev 4830) @@ -94,25 +94,3 @@ and use the admin login to get an impression, really cool ;-) - something simple: http://82.165.8.199/typo3cms/exotec-design.de/index.php?id=89 - -############################################################################ -Open questions -############################################################################ - -- thumbnail size, set a max size (for example 150px), to be able to switch - the size on fly - -- image cache plugin automatically turned on? - in normal image view, image is displayed javascript based the largest possible - -> we're going to have problems with the image cache, as size ever changes.. - -> we already have this problem in the slideshow - - /* edit bzrudi */ - I think we should have the largest possible thumb on filesystem 300px? - smaller ones should be resized by browser. - - i'm thinking about a dynamic image cache - lets say i'm requesting an image between 800x600 and 1024x768 i will get the image 1024x768, - between 1024x768 and 1310x983 i will get an image with 1310x983 - we would have calculate a good value of the different image sizes handling thecompromise - between size of the image and difference in size \ No newline at end of file Modified: trunk/linpha2/lib/js/LinThumbnails.js =================================================================== --- trunk/linpha2/lib/js/LinThumbnails.js 2008-01-29 14:55:11 UTC (rev 4829) +++ trunk/linpha2/lib/js/LinThumbnails.js 2008-01-29 20:01:16 UTC (rev 4830) @@ -3,7 +3,7 @@ * * check performance: var start = new Date().getTime(); - alert( (new Date().getTime() - start) ); + alert( (new Date().getTime() - start) + 'ms' ); * */ @@ -153,6 +153,23 @@ * see also http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation !! * * update: using the DOM functions with createElement etc. we would be at least 2 times slower!! + * + * this is the way to go: + var i, j, el, idx, html; + idx = 0; + html = []; + html[idx++] = "<table>"; + for (i = 0; i < 1000; i++) { + html[idx++] = "<tr>"; + for (j = 0; j < 5; j++) { + html[idx++] = "<td></td>"; + } + html[idx++] = "</tr>"; + } + html[idx++] = "</table>"; + el = document.createElement("div"); + document.body.appendChild(el); + el.innerHTML = html.join(""); */ if( (img_nr-1) % nr_cols == 0) { Copied: trunk/linpha2/lib/js/prototype (from rev 4811, trunk/linpha2/lib/js/prototype-1.6.0) Copied: trunk/linpha2/lib/js/scriptaculous-js (from rev 4811, trunk/linpha2/lib/js/scriptaculous-js-1.8.0) Deleted: trunk/linpha2/linpha2.specs.txt =================================================================== --- trunk/linpha2/linpha2.specs.txt 2008-01-29 14:55:11 UTC (rev 4829) +++ trunk/linpha2/linpha2.specs.txt 2008-01-29 20:01:16 UTC (rev 4830) @@ -1,118 +0,0 @@ -LinPHA2 Specs -11. Sept. 2005 by bzrudi - -Part 1: Overview -============================================================================== -These are my first ideas about LinPHA2. Things may (will) change as -days go by. The two most important things when talking about LinPHA2 are the -new XHTML/CSS layout for easier customization and the classed based rewrite. - - -Part 2: Features -============================================================================== - -Must Have: -- XHTML/CCS layout (even the menu?) - - don't think about wether to place the folder structure on the left or right side - -> make both (and a lot other) possible with css!!! -- new installer -- unlimited subfolders -- new permission framework (take care of subfolders too) -- option to have thumbs stored in FS rather than in DB (speed improvement) -- sort images by EXIF date -- make LinPHA "includeable" do no longer require to run as standalone app -- provide a clean plugin interface -- complete new, clean and fast DB design (incl. table structures) -- remove need to place images under /albums (windows users can't symlink) - In other words, don't hardcode -- port most of the 1.0 features - -Nice To Have: -- user upload directories -- auto rotate images by EXIF header -- and some of the features already in the RFEs - -Part 3: Coding -============================================================================== -- PHP >= 5.0 only (make use of the new OOP features, exceptions, protected - methods, new constuctor and so on) -- lang files as arrays, no longer just vars -- only class based -- phpDocumentor style documentation for *ALL* classes methods and headers - (this is required for an clean API documentation, which is very important!) -- all own methods get a "lin" prefix, class names start Uppercase -- would be nice if we can define some coding format - - wether to use single or doulbe quotes in html attributes (maybe..) - - which function to use to encode html data - all php output where quotes and other signs may break the html design - (except ids and md5sums) needs to be encoded - which function to use? - - urlencode() -> doesn't work in <a href="" title="<?php echo $title; ?>"> - - rawurlencode() - - htmlspecialchars() -> will use this: htmlspecialchars($str, ENT_QUOTES) - - htmlentities() - - smart_htmlspecialchars() from phpmeta used several times in forms in linpha1 - ? - - ? -- php session - limit the session cookie not only to domain, but also to full url path - we cannot use the same session in localhost/linpha1.0 and localhost/linpha2.0 - -> session_set_cookie_params() - -Part 4: External Libs -============================================================================== -- AdoDB DB Abstraction Layer (maybe we will switch to PHP 5.1 internal - abstraction layer later, so make sure not to use to much of AdoDB specific - features which will require a rewrite later ;-)) -- PHPmailer for all email stuff -- PHPmeta for all the EXIF/IPTC stuff -- getID3 for all Video stuff -- PHPThumb for all image related manipulation (needs testing!) - - Links: - CSS/ Javascript - - Rounded Corners http://kalsey.com/2003/07/rounded_corners_in_css/ - - Menu http://www.tanfa.co.uk/css/examples/menu/tutorial-h.asp - - CSS Zen Garden http://www.csszengarden.com/tr/deutsch - - Float Tutorial http://css.maxdesign.com.au/floatutorial/ - - CSS Layouts, sehr ausfuehrlich http://www.thestyleworks.de/tut-art/layout_div.shtml - - http://www.quirksmode.org/viewport/ !! - - min-/max-width in IE: http://www.cssplay.co.uk/boxes/minwidth.html - http://www.svendtofte.com/code/max_width_in_ie/ - - Fenster ueberwachen http://de.selfhtml.org/javascript/beispiele/fensterueberwachen.htm - - -Part 5. main menu -============================================================================ -- use a css only menu? -- use something like this: http://www.milonic.com/mfa/2004-February/003609.html ? - (looks really nice) - /* edit bzrudi */ - - looks pretty good but isn't under the terms of the GPL) - A good (well working) replacement may be the admin menu from the Joomla CMS, see - http://opensourcecms.com/index.php?option=com_content&task=view&id=2097 - and use the admin login to get an impression, really cool ;-) - -- something simple: http://82.165.8.199/typo3cms/exotec-design.de/index.php?id=89 - -############################################################################ -Open questions -############################################################################ - -- thumbnail size, set a max size (for example 150px), to be able to switch - the size on fly - -- image cache plugin automatically turned on? - in normal image view, image is displayed javascript based the largest possible - -> we're going to have problems with the image cache, as size ever changes.. - -> we already have this problem in the slideshow - - /* edit bzrudi */ - I think we should have the largest possible thumb on filesystem 300px? - smaller ones should be resized by browser. - - i'm thinking about a dynamic image cache - lets say i'm requesting an image between 800x600 and 1024x768 i will get the image 1024x768, - between 1024x768 and 1310x983 i will get an image with 1310x983 - we would have calculate a good value of the different image sizes handling thecompromise - between size of the image and difference in size \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2008-01-29 21:12:19
|
Revision: 4831 http://linpha.svn.sourceforge.net/linpha/?rev=4831&view=rev Author: fangehrn Date: 2008-01-29 13:12:02 -0800 (Tue, 29 Jan 2008) Log Message: ----------- 2008-01-29 flo * updated to latest protoype 1.6.0.2 and scriptaculous 1.8.1 * compressed javascript files with yui compresser 319KB -> 185KB Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/js/builder.js trunk/linpha2/lib/js/controls.js trunk/linpha2/lib/js/dragdrop.js trunk/linpha2/lib/js/effects.js trunk/linpha2/lib/js/prototype/CHANGELOG trunk/linpha2/lib/js/prototype/LICENSE trunk/linpha2/lib/js/prototype/README trunk/linpha2/lib/js/prototype.js trunk/linpha2/lib/js/scriptaculous-js/CHANGELOG trunk/linpha2/lib/js/scriptaculous.js trunk/linpha2/lib/js/slider.js trunk/linpha2/lib/js/sound.js trunk/linpha2/lib/js/unittest.js Added Paths: ----------- trunk/linpha2/lib/js/builder.yui.js trunk/linpha2/lib/js/controls.yui.js trunk/linpha2/lib/js/dragdrop.yui.js trunk/linpha2/lib/js/effects.yui.js trunk/linpha2/lib/js/prototype.yui.js trunk/linpha2/lib/js/scriptaculous.yui.js trunk/linpha2/lib/js/slider.yui.js trunk/linpha2/lib/js/sound.yui.js trunk/linpha2/lib/js/unittest.yui.js Removed Paths: ------------- trunk/linpha2/lib/js/prototype/Rakefile Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-29 20:01:16 UTC (rev 4830) +++ trunk/linpha2/ChangeLog 2008-01-29 21:12:02 UTC (rev 4831) @@ -1,3 +1,9 @@ + +2008-01-29 flo + * updated to latest protoype 1.6.0.2 and scriptaculous 1.8.1 + * compressed javascript files with yui compresser + 319KB -> 185KB + 2007-12-09 bzrudi * fix for db_error.log file create * fixed a couple of notices and warnings introduced by new plugin model Modified: trunk/linpha2/lib/js/builder.js =================================================================== --- trunk/linpha2/lib/js/builder.js 2008-01-29 20:01:16 UTC (rev 4830) +++ trunk/linpha2/lib/js/builder.js 2008-01-29 21:12:02 UTC (rev 4831) @@ -1,4 +1,4 @@ -// script.aculo.us builder.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007 +// script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Added: trunk/linpha2/lib/js/builder.yui.js =================================================================== --- trunk/linpha2/lib/js/builder.yui.js (rev 0) +++ trunk/linpha2/lib/js/builder.yui.js 2008-01-29 21:12:02 UTC (rev 4831) @@ -0,0 +1 @@ +var Builder={NODEMAP:{AREA:"map",CAPTION:"table",COL:"table",COLGROUP:"table",LEGEND:"fieldset",OPTGROUP:"select",OPTION:"select",PARAM:"object",TBODY:"table",TD:"table",TFOOT:"table",TH:"table",THEAD:"table",TR:"table"},node:function(A){A=A.toUpperCase();var F=this.NODEMAP[A]||"div";var B=document.createElement(F);try{B.innerHTML="<"+A+"></"+A+">"}catch(E){}var D=B.firstChild||null;if(D&&(D.tagName.toUpperCase()!=A)){D=D.getElementsByTagName(A)[0]}if(!D){D=document.createElement(A)}if(!D){return }if(arguments[1]){if(this._isStringOrNumber(arguments[1])||(arguments[1] instanceof Array)||arguments[1].tagName){this._children(D,arguments[1])}else{var C=this._attributes(arguments[1]);if(C.length){try{B.innerHTML="<"+A+" "+C+"></"+A+">"}catch(E){}D=B.firstChild||null;if(!D){D=document.createElement(A);for(attr in arguments[1]){D[attr=="class"?"className":attr]=arguments[1][attr]}}if(D.tagName.toUpperCase()!=A){D=B.getElementsByTagName(A)[0]}}}}if(arguments[2]){this._children(D,arguments[2])}return D},_text:function(A){return document.createTextNode(A)},ATTR_MAP:{className:"class",htmlFor:"for"},_attributes:function(A){var B=[];for(attribute in A){B.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+'="'+A[attribute].toString().escapeHTML().gsub(/"/,""")+'"')}return B.join(" ")},_children:function(B,A){if(A.tagName){B.appendChild(A);return }if(typeof A=="object"){A.flatten().each(function(C){if(typeof C=="object"){B.appendChild(C)}else{if(Builder._isStringOrNumber(C)){B.appendChild(Builder._text(C))}}})}else{if(Builder._isStringOrNumber(A)){B.appendChild(Builder._text(A))}}},_isStringOrNumber:function(A){return(typeof A=="string"||typeof A=="number")},build:function(B){var A=this.node("div");$(A).update(B.strip());return A.down()},dump:function(B){if(typeof B!="object"&&typeof B!="function"){B=window}var A=("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);A.each(function(C){B[C]=function(){return Builder.node.apply(Builder,[C].concat($A(arguments)))}})}}; \ No newline at end of file Modified: trunk/linpha2/lib/js/controls.js =================================================================== --- trunk/linpha2/lib/js/controls.js 2008-01-29 20:01:16 UTC (rev 4830) +++ trunk/linpha2/lib/js/controls.js 2008-01-29 21:12:02 UTC (rev 4831) @@ -1,4 +1,4 @@ -// script.aculo.us controls.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007 +// script.aculo.us controls.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan) @@ -88,7 +88,7 @@ Element.hide(this.update); Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this)); - Event.observe(this.element, 'keypress', this.onKeyPress.bindAsEventListener(this)); + Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this)); }, show: function() { @@ -144,12 +144,12 @@ case Event.KEY_UP: this.markPrevious(); this.render(); - if(Prototype.Browser.WebKit) Event.stop(event); + Event.stop(event); return; case Event.KEY_DOWN: this.markNext(); this.render(); - if(Prototype.Browser.WebKit) Event.stop(event); + Event.stop(event); return; } else Added: trunk/linpha2/lib/js/controls.yui.js =================================================================== --- trunk/linpha2/lib/js/controls.yui.js (rev 0) +++ trunk/linpha2/lib/js/controls.yui.js 2008-01-29 21:12:02 UTC (rev 4831) @@ -0,0 +1 @@ +if(typeof Effect=="undefined"){throw ("controls.js requires including script.aculo.us' effects.js library")}var Autocompleter={};Autocompleter.Base=Class.create({baseInitialize:function(B,C,A){B=$(B);this.element=B;this.update=$(C);this.hasFocus=false;this.changed=false;this.active=false;this.index=0;this.entryCount=0;this.oldElementValue=this.element.value;if(this.setOptions){this.setOptions(A)}else{this.options=A||{}}this.options.paramName=this.options.paramName||this.element.name;this.options.tokens=this.options.tokens||[];this.options.frequency=this.options.frequency||0.4;this.options.minChars=this.options.minChars||1;this.options.onShow=this.options.onShow||function(D,E){if(!E.style.position||E.style.position=="absolute"){E.style.position="absolute";Position.clone(D,E,{setHeight:false,offsetTop:D.offsetHeight})}Effect.Appear(E,{duration:0.15})};this.options.onHide=this.options.onHide||function(D,E){new Effect.Fade(E,{duration:0.15})};if(typeof (this.options.tokens)=="string"){this.options.tokens=new Array(this.options.tokens)}if(!this.options.tokens.include("\n")){this.options.tokens.push("\n")}this.observer=null;this.element.setAttribute("autocomplete","off");Element.hide(this.update);Event.observe(this.element,"blur",this.onBlur.bindAsEventListener(this));Event.observe(this.element,"keydown",this.onKeyPress.bindAsEventListener(this))},show:function(){if(Element.getStyle(this.update,"display")=="none"){this.options.onShow(this.element,this.update)}if(!this.iefix&&(Prototype.Browser.IE)&&(Element.getStyle(this.update,"position")=="absolute")){new Insertion.After(this.update,'<iframe id="'+this.update.id+'_iefix" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.update.id+"_iefix")}if(this.iefix){setTimeout(this.fixIEOverlapping.bind(this),50)}},fixIEOverlapping:function(){Position.clone(this.update,this.iefix,{setTop:(!this.update.style.height)});this.iefix.style.zIndex=1;this.update.style.zIndex=2;Element.show(this.iefix)},hide:function(){this.stopIndicator();if(Element.getStyle(this.update,"display")!="none"){this.options.onHide(this.element,this.update)}if(this.iefix){Element.hide(this.iefix)}},startIndicator:function(){if(this.options.indicator){Element.show(this.options.indicator)}},stopIndicator:function(){if(this.options.indicator){Element.hide(this.options.indicator)}},onKeyPress:function(A){if(this.active){switch(A.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();Event.stop(A);case Event.KEY_ESC:this.hide();this.active=false;Event.stop(A);return ;case Event.KEY_LEFT:case Event.KEY_RIGHT:return ;case Event.KEY_UP:this.markPrevious();this.render();Event.stop(A);return ;case Event.KEY_DOWN:this.markNext();this.render();Event.stop(A);return }}else{if(A.keyCode==Event.KEY_TAB||A.keyCode==Event.KEY_RETURN||(Prototype.Browser.WebKit>0&&A.keyCode==0)){return }}this.changed=true;this.hasFocus=true;if(this.observer){clearTimeout(this.observer)}this.observer=setTimeout(this.onObserverEvent.bind(this),this.options.frequency*1000)},activate:function(){this.changed=false;this.hasFocus=true;this.getUpdatedChoices()},onHover:function(B){var A=Event.findElement(B,"LI");if(this.index!=A.autocompleteIndex){this.index=A.autocompleteIndex;this.render()}Event.stop(B)},onClick:function(B){var A=Event.findElement(B,"LI");this.index=A.autocompleteIndex;this.selectEntry();this.hide()},onBlur:function(A){setTimeout(this.hide.bind(this),250);this.hasFocus=false;this.active=false},render:function(){if(this.entryCount>0){for(var A=0;A<this.entryCount;A++){this.index==A?Element.addClassName(this.getEntry(A),"selected"):Element.removeClassName(this.getEntry(A),"selected")}if(this.hasFocus){this.show();this.active=true}}else{this.active=false;this.hide()}},markPrevious:function(){if(this.index>0){this.index--}else{this.index=this.entryCount-1}this.getEntry(this.index).scrollIntoView(true)},markNext:function(){if(this.index<this.entryCount-1){this.index++}else{this.index=0}this.getEntry(this.index).scrollIntoView(false)},getEntry:function(A){return this.update.firstChild.childNodes[A]},getCurrentEntry:function(){return this.getEntry(this.index)},selectEntry:function(){this.active=false;this.updateElement(this.getCurrentEntry())},updateElement:function(F){if(this.options.updateElement){this.options.updateElement(F);return }var D="";if(this.options.select){var A=$(F).select("."+this.options.select)||[];if(A.length>0){D=Element.collectTextNodes(A[0],this.options.select)}}else{D=Element.collectTextNodesIgnoreClass(F,"informal")}var C=this.getTokenBounds();if(C[0]!=-1){var E=this.element.value.substr(0,C[0]);var B=this.element.value.substr(C[0]).match(/^\s+/);if(B){E+=B[0]}this.element.value=E+D+this.element.value.substr(C[1])}else{this.element.value=D}this.oldElementValue=this.element.value;this.element.focus();if(this.options.afterUpdateElement){this.options.afterUpdateElement(this.element,F)}},updateChoices:function(C){if(!this.changed&&this.hasFocus){this.update.innerHTML=C;Element.cleanWhitespace(this.update);Element.cleanWhitespace(this.update.down());if(this.update.firstChild&&this.update.down().childNodes){this.entryCount=this.update.down().childNodes.length;for(var A=0;A<this.entryCount;A++){var B=this.getEntry(A);B.autocompleteIndex=A;this.addObservers(B)}}else{this.entryCount=0}this.stopIndicator();this.index=0;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry();this.hide()}else{this.render()}}},addObservers:function(A){Event.observe(A,"mouseover",this.onHover.bindAsEventListener(this));Event.observe(A,"click",this.onClick.bindAsEventListener(this))},onObserverEvent:function(){this.changed=false;this.tokenBounds=null;if(this.getToken().length>=this.options.minChars){this.getUpdatedChoices()}else{this.active=false;this.hide()}this.oldElementValue=this.element.value},getToken:function(){var A=this.getTokenBounds();return this.element.value.substring(A[0],A[1]).strip()},getTokenBounds:function(){if(null!=this.tokenBounds){return this.tokenBounds}var E=this.element.value;if(E.strip().empty()){return[-1,0]}var F=arguments.callee.getFirstDifferencePos(E,this.oldElementValue);var H=(F==this.oldElementValue.length?1:0);var D=-1,C=E.length;var G;for(var B=0,A=this.options.tokens.length;B<A;++B){G=E.lastIndexOf(this.options.tokens[B],F+H-1);if(G>D){D=G}G=E.indexOf(this.options.tokens[B],F+H);if(-1!=G&&G<C){C=G}}return(this.tokenBounds=[D+1,C])}});Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos=function(C,A){var D=Math.min(C.length,A.length);for(var B=0;B<D;++B){if(C[B]!=A[B]){return B}}return D};Ajax.Autocompleter=Class.create(Autocompleter.Base,{initialize:function(C,D,B,A){this.baseInitialize(C,D,A);this.options.asynchronous=true;this.options.onComplete=this.onComplete.bind(this);this.options.defaultParams=this.options.parameters||null;this.url=B},getUpdatedChoices:function(){this.startIndicator();var A=encodeURIComponent(this.options.paramName)+"="+encodeURIComponent(this.getToken());this.options.parameters=this.options.callback?this.options.callback(this.element,A):A;if(this.options.defaultParams){this.options.parameters+="&"+this.options.defaultParams}new Ajax.Request(this.url,this.options)},onComplete:function(A){this.updateChoices(A.responseText)}});Autocompleter.Local=Class.create(Autocompleter.Base,{initialize:function(B,D,C,A){this.baseInitialize(B,D,A);this.options.array=C},getUpdatedChoices:function(){this.updateChoices(this.options.selector(this))},setOptions:function(A){this.options=Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false,selector:function(B){var D=[];var C=[];var H=B.getToken();var G=0;for(var E=0;E<B.options.array.length&&D.length<B.options.choices;E++){var F=B.options.array[E];var I=B.options.ignoreCase?F.toLowerCase().indexOf(H.toLowerCase()):F.indexOf(H);while(I!=-1){if(I==0&&F.length!=H.length){D.push("<li><strong>"+F.substr(0,H.length)+"</strong>"+F.substr(H.length)+"</li>");break}else{if(H.length>=B.options.partialChars&&B.options.partialSearch&&I!=-1){if(B.options.fullSearch||/\s/.test(F.substr(I-1,1))){C.push("<li>"+F.substr(0,I)+"<strong>"+F.substr(I,H.length)+"</strong>"+F.substr(I+H.length)+"</li>");break}}}I=B.options.ignoreCase?F.toLowerCase().indexOf(H.toLowerCase(),I+1):F.indexOf(H,I+1)}}if(C.length){D=D.concat(C.slice(0,B.options.choices-D.length))}return"<ul>"+D.join("")+"</ul>"}},A||{})}});Field.scrollFreeActivate=function(A){setTimeout(function(){Field.activate(A)},1)};Ajax.InPlaceEditor=Class.create({initialize:function(C,B,A){this.url=B;this.element=C=$(C);this.prepareOptions();this._controls={};arguments.callee.dealWithDeprecatedOptions(A);Object.extend(this.options,A||{});if(!this.options.formId&&this.element.id){this.options.formId=this.element.id+"-inplaceeditor";if($(this.options.formId)){this.options.formId=""}}if(this.options.externalControl){this.options.externalControl=$(this.options.externalControl)}if(!this.options.externalControl){this.options.externalControlOnly=false}this._originalBackground=this.element.getStyle("background-color")||"transparent";this.element.title=this.options.clickToEditText;this._boundCancelHandler=this.handleFormCancellation.bind(this);this._boundComplete=(this.options.onComplete||Prototype.emptyFunction).bind(this);this._boundFailureHandler=this.handleAJAXFailure.bind(this);this._boundSubmitHandler=this.handleFormSubmission.bind(this);this._boundWrapperHandler=this.wrapUp.bind(this);this.registerListeners()},checkForEscapeOrReturn:function(A){if(!this._editing||A.ctrlKey||A.altKey||A.shiftKey){return }if(Event.KEY_ESC==A.keyCode){this.handleFormCancellation(A)}else{if(Event.KEY_RETURN==A.keyCode){this.handleFormSubmission(A)}}},createControl:function(G,C,B){var E=this.options[G+"Control"];var F=this.options[G+"Text"];if("button"==E){var A=document.createElement("input");A.type="submit";A.value=F;A.className="editor_"+G+"_button";if("cancel"==G){A.onclick=this._boundCancelHandler}this._form.appendChild(A);this._controls[G]=A}else{if("link"==E){var D=document.createElement("a");D.href="#";D.appendChild(document.createTextNode(F));D.onclick="cancel"==G?this._boundCancelHandler:this._boundSubmitHandler;D.className="editor_"+G+"_link";if(B){D.className+=" "+B}this._form.appendChild(D);this._controls[G]=D}}},createEditField:function(){var C=(this.options.loadTextURL?this.options.loadingText:this.getText());var B;if(1>=this.options.rows&&!/\r|\n/.test(this.getText())){B=document.createElement("input");B.type="text";var A=this.options.size||this.options.cols||0;if(0<A){B.size=A}}else{B=document.createElement("textarea");B.rows=(1>=this.options.rows?this.options.autoRows:this.options.rows);B.cols=this.options.cols||40}B.name=this.options.paramName;B.value=C;B.className="editor_field";if(this.options.submitOnBlur){B.onblur=this._boundSubmitHandler}this._controls.editor=B;if(this.options.loadTextURL){this.loadExternalText()}this._form.appendChild(this._controls.editor)},createForm:function(){var B=this;function A(D,E){var C=B.options["text"+D+"Controls"];if(!C||E===false){return }B._form.appendChild(document.createTextNode(C))}this._form=$(document.createElement("form"));this._form.id=this.options.formId;this._form.addClassName(this.options.formClassName);this._form.onsubmit=this._boundSubmitHandler;this.createEditField();if("textarea"==this._controls.editor.tagName.toLowerCase()){this._form.appendChild(document.createElement("br"))}if(this.options.onFormCustomization){this.options.onFormCustomization(this,this._form)}A("Before",this.options.okControl||this.options.cancelControl);this.createControl("ok",this._boundSubmitHandler);A("Between",this.options.okControl&&this.options.cancelControl);this.createControl("cancel",this._boundCancelHandler,"editor_cancel");A("After",this.options.okControl||this.options.cancelControl)},destroy:function(){if(this._oldInnerHTML){this.element.innerHTML=this._oldInnerHTML}this.leaveEditMode();this.unregisterListeners()},enterEditMode:function(A){if(this._saving||this._editing){return }this._editing=true;this.triggerCallback("onEnterEditMode");if(this.options.externalControl){this.options.externalControl.hide()}this.element.hide();this.createForm();this.element.parentNode.insertBefore(this._form,this.element);if(!this.options.loadTextURL){this.postProcessEditField()}if(A){Event.stop(A)}},enterHover:function(A){if(this.options.hoverClassName){this.element.addClassName(this.options.hoverClassName)}if(this._saving){return }this.triggerCallback("onEnterHover")},getText:function(){return this.element.innerHTML},handleAJAXFailure:function(A){this.triggerCallback("onFailure",A);if(this._oldInnerHTML){this.element.innerHTML=this._oldInnerHTML;this._oldInnerHTML=null}},handleFormCancellation:function(A){this.wrapUp();if(A){Event.stop(A)}},handleFormSubmission:function(D){var B=this._form;var C=$F(this._controls.editor);this.prepareSubmission();var E=this.options.callback(B,C)||"";if(Object.isString(E)){E=E.toQueryParams()}E.editorId=this.element.id;if(this.options.htmlResponse){var A=Object.extend({evalScripts:true},this.options.ajaxOptions);Object.extend(A,{parameters:E,onComplete:this._boundWrapperHandler,onFailure:this._boundFailureHandler});new Ajax.Updater({success:this.element},this.url,A)}else{var A=Object.extend({method:"get"},this.options.ajaxOptions);Object.extend(A,{parameters:E,onComplete:this._boundWrapperHandler,onFailure:this._boundFailureHandler});new Ajax.Request(this.url,A)}if(D){Event.stop(D)}},leaveEditMode:function(){this.element.removeClassName(this.options.savingClassName);this.removeForm();this.leaveHover();this.element.style.backgroundColor=this._originalBackground;this.element.show();if(this.options.externalControl){this.options.externalControl.show()}this._saving=false;this._editing=false;this._oldInnerHTML=null;this.triggerCallback("onLeaveEditMode")},leaveHover:function(A){if(this.options.hoverClassName){this.element.removeClassName(this.options.hoverClassName)}if(this._saving){return }this.triggerCallback("onLeaveHover")},loadExternalText:function(){this._form.addClassName(this.options.loadingClassName);this._controls.editor.disabled=true;var A=Object.extend({method:"get"},this.options.ajaxOptions);Object.extend(A,{parameters:"editorId="+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(C){this._form.removeClassName(this.options.loadingClassName);var B=C.responseText;if(this.options.stripLoadedTextTags){B=B.stripTags()}this._controls.editor.value=B;this._controls.editor.disabled=false;this.postProcessEditField()}.bind(this),onFailure:this._boundFailureHandler});new Ajax.Request(this.options.loadTextURL,A)},postProcessEditField:function(){var A=this.options.fieldPostCreation;if(A){$(this._controls.editor)["focus"==A?"focus":"activate"]()}},prepareOptions:function(){this.options=Object.clone(Ajax.InPlaceEditor.DefaultOptions);Object.extend(this.options,Ajax.InPlaceEditor.DefaultCallbacks);[this._extraDefaultOptions].flatten().compact().each(function(A){Object.extend(this.options,A)}.bind(this))},prepareSubmission:function(){this._saving=true;this.removeForm();this.leaveHover();this.showSaving()},registerListeners:function(){this._listeners={};var A;$H(Ajax.InPlaceEditor.Listeners).each(function(B){A=this[B.value].bind(this);this._listeners[B.key]=A;if(!this.options.externalControlOnly){this.element.observe(B.key,A)}if(this.options.externalControl){this.options.externalControl.observe(B.key,A)}}.bind(this))},removeForm:function(){if(!this._form){return }this._form.remove();this._form=null;this._controls={}},showSaving:function(){this._oldInnerHTML=this.element.innerHTML;this.element.innerHTML=this.options.savingText;this.element.addClassName(this.options.savingClassName);this.element.style.backgroundColor=this._originalBackground;this.element.show()},triggerCallback:function(B,A){if("function"==typeof this.options[B]){this.options[B](this,A)}},unregisterListeners:function(){$H(this._listeners).each(function(A){if(!this.options.externalControlOnly){this.element.stopObserving(A.key,A.value)}if(this.options.externalControl){this.options.externalControl.stopObserving(A.key,A.value)}}.bind(this))},wrapUp:function(A){this.leaveEditMode();this._boundComplete(A,this.element)}});Object.extend(Ajax.InPlaceEditor.prototype,{dispose:Ajax.InPlaceEditor.prototype.destroy});Ajax.InPlaceCollectionEditor=Class.create(Ajax.InPlaceEditor,{initialize:function($super,C,B,A){this._extraDefaultOptions=Ajax.InPlaceCollectionEditor.DefaultOptions;$super(C,B,A)},createEditField:function(){var A=document.createElement("select");A.name=this.options.paramName;A.size=1;this._controls.editor=A;this._collection=this.options.collection||[];if(this.options.loadCollectionURL){this.loadCollection()}else{this.checkForExternalText()}this._form.appendChild(this._controls.editor)},loadCollection:function(){this._form.addClassName(this.options.loadingClassName);this.showLoadingText(this.options.loadingCollectionText);var options=Object.extend({method:"get"},this.options.ajaxOptions);Object.extend(options,{parameters:"editorId="+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(transport){var js=transport.responseText.strip();if(!/^\[.*\]$/.test(js)){throw"Server returned an invalid collection representation."}this._collection=eval(js);this.checkForExternalText()}.bind(this),onFailure:this.onFailure});new Ajax.Request(this.options.loadCollectionURL,options)},showLoadingText:function(B){this._controls.editor.disabled=true;var A=this._controls.editor.firstChild;if(!A){A=document.createElement("option");A.value="";this._controls.editor.appendChild(A);A.selected=true}A.update((B||"").stripScripts().stripTags())},checkForExternalText:function(){this._text=this.getText();if(this.options.loadTextURL){this.loadExternalText()}else{this.buildOptionList()}},loadExternalText:function(){this.showLoadingText(this.options.loadingText);var A=Object.extend({method:"get"},this.options.ajaxOptions);Object.extend(A,{parameters:"editorId="+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(B){this._text=B.responseText.strip();this.buildOptionList()}.bind(this),onFailure:this.onFailure});new Ajax.Request(this.options.loadTextURL,A)},buildOptionList:function(){this._form.removeClassName(this.options.loadingClassName);this._collection=this._collection.map(function(D){return 2===D.length?D:[D,D].flatten()});var B=("value" in this.options)?this.options.value:this._text;var A=this._collection.any(function(D){return D[0]==B}.bind(this));this._controls.editor.update("");var C;this._collection.each(function(E,D){C=document.createElement("option");C.value=E[0];C.selected=A?E[0]==B:0==D;C.appendChild(document.createTextNode(E[1]));this._controls.editor.appendChild(C)}.bind(this));this._controls.editor.disabled=false;Field.scrollFreeActivate(this._controls.editor)}});Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions=function(A){if(!A){return }function B(C,D){if(C in A||D===undefined){return }A[C]=D}B("cancelControl",(A.cancelLink?"link":(A.cancelButton?"button":A.cancelLink==A.cancelButton==false?false:undefined)));B("okControl",(A.okLink?"link":(A.okButton?"button":A.okLink==A.okButton==false?false:undefined)));B("highlightColor",A.highlightcolor);B("highlightEndColor",A.highlightendcolor)};Object.extend(Ajax.InPlaceEditor,{DefaultOptions:{ajaxOptions:{},autoRows:3,cancelControl:"link",cancelText:"cancel",clickToEditText:"Click to edit",externalControl:null,externalControlOnly:false,fieldPostCreation:"activate",formClassName:"inplaceeditor-form",formId:null,highlightColor:"#ffff99",highlightEndColor:"#ffffff",hoverClassName:"",htmlResponse:true,loadingClassName:"inplaceeditor-loading",loadingText:"Loading...",okControl:"button",okText:"ok",paramName:"value",rows:1,savingClassName:"inplaceeditor-saving",savingText:"Saving...",size:0,stripLoadedTextTags:false,submitOnBlur:false,textAfterControls:"",textBeforeControls:"",textBetweenControls:""},DefaultCallbacks:{callback:function(A){return Form.serialize(A)},onComplete:function(B,A){new Effect.Highlight(A,{startcolor:this.options.highlightColor,keepBackgroundImage:true})},onEnterEditMode:null,onEnterHover:function(A){A.element.style.backgroundColor=A.options.highlightColor;if(A._effect){A._effect.cancel()}},onFailure:function(B,A){alert("Error communication with the server: "+B.responseText.stripTags())},onFormCustomization:null,onLeaveEditMode:null,onLeaveHover:function(A){A._effect=new Effect.Highlight(A.element,{startcolor:A.options.highlightColor,endcolor:A.options.highlightEndColor,restorecolor:A._originalBackground,keepBackgroundImage:true})}},Listeners:{click:"enterEditMode",keydown:"checkForEscapeOrReturn",mouseover:"enterHover",mouseout:"leaveHover"}});Ajax.InPlaceCollectionEditor.DefaultOptions={loadingCollectionText:"Loading options..."};Form.Element.DelayedObserver=Class.create({initialize:function(B,A,C){this.delay=A||0.5;this.element=$(B);this.callback=C;this.timer=null;this.lastValue=$F(this.element);Event.observe(this.element,"keyup",this.delayedListener.bindAsEventListener(this))},delayedListener:function(A){if(this.lastValue==$F(this.element)){return }if(this.timer){clearTimeout(this.timer)}this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);this.lastValue=$F(this.element)},onTimerEvent:function(){this.timer=null;this.callback(this.element,$F(this.element))}}); \ No newline at end of file Modified: trunk/linpha2/lib/js/dragdrop.js =================================================================== --- trunk/linpha2/lib/js/dragdrop.js 2008-01-29 20:01:16 UTC (rev 4830) +++ trunk/linpha2/lib/js/dragdrop.js 2008-01-29 21:12:02 UTC (rev 4831) @@ -1,4 +1,4 @@ -// script.aculo.us dragdrop.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007 +// script.aculo.us dragdrop.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sa...@or...) Added: trunk/linpha2/lib/js/dragdrop.yui.js =================================================================== --- trunk/linpha2/lib/js/dragdrop.yui.js (rev 0) +++ trunk/linpha2/lib/js/dragdrop.yui.js 2008-01-29 21:12:02 UTC (rev 4831) @@ -0,0 +1 @@ +if(Object.isUndefined(Effect)){throw ("dragdrop.js requires including script.aculo.us' effects.js library")}var Droppables={drops:[],remove:function(A){this.drops=this.drops.reject(function(B){return B.element==$(A)})},add:function(B){B=$(B);var A=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});if(A.containment){A._containers=[];var C=A.containment;if(Object.isArray(C)){C.each(function(D){A._containers.push($(D))})}else{A._containers.push($(C))}}if(A.accept){A.accept=[A.accept].flatten()}Element.makePositioned(B);A.element=B;this.drops.push(A)},findDeepestChild:function(A){deepest=A[0];for(i=1;i<A.length;++i){if(Element.isParent(A[i].element,deepest.element)){deepest=A[i]}}return deepest},isContained:function(B,A){var C;if(A.tree){C=B.treeNode}else{C=B.parentNode}return A._containers.detect(function(D){return C==D})},isAffected:function(A,C,B){return((B.element!=C)&&((!B._containers)||this.isContained(C,B))&&((!B.accept)||(Element.classNames(C).detect(function(D){return B.accept.include(D)})))&&Position.within(B.element,A[0],A[1]))},deactivate:function(A){if(A.hoverclass){Element.removeClassName(A.element,A.hoverclass)}this.last_active=null},activate:function(A){if(A.hoverclass){Element.addClassName(A.element,A.hoverclass)}this.last_active=A},show:function(A,C){if(!this.drops.length){return }var B,D=[];this.drops.each(function(E){if(Droppables.isAffected(A,C,E)){D.push(E)}});if(D.length>0){B=Droppables.findDeepestChild(D)}if(this.last_active&&this.last_active!=B){this.deactivate(this.last_active)}if(B){Position.within(B.element,A[0],A[1]);if(B.onHover){B.onHover(C,B.element,Position.overlap(B.overlap,B.element))}if(B!=this.last_active){Droppables.activate(B)}}},fire:function(B,A){if(!this.last_active){return }Position.prepare();if(this.isAffected([Event.pointerX(B),Event.pointerY(B)],A,this.last_active)){if(this.last_active.onDrop){this.last_active.onDrop(A,this.last_active.element,B);return true}}},reset:function(){if(this.last_active){this.deactivate(this.last_active)}}};var Draggables={drags:[],observers:[],register:function(A){if(this.drags.length==0){this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.updateDrag.bindAsEventListener(this);this.eventKeypress=this.keyPress.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);Event.observe(document,"keypress",this.eventKeypress)}this.drags.push(A)},unregister:function(A){this.drags=this.drags.reject(function(B){return B==A});if(this.drags.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)}},activate:function(A){if(A.options.delay){this._timeout=setTimeout(function(){Draggables._timeout=null;window.focus();Draggables.activeDraggable=A}.bind(this),A.options.delay)}else{window.focus();this.activeDraggable=A}},deactivate:function(){this.activeDraggable=null},updateDrag:function(A){if(!this.activeDraggable){return }var B=[Event.pointerX(A),Event.pointerY(A)];if(this._lastPointer&&(this._lastPointer.inspect()==B.inspect())){return }this._lastPointer=B;this.activeDraggable.updateDrag(A,B)},endDrag:function(A){if(this._timeout){clearTimeout(this._timeout);this._timeout=null}if(!this.activeDraggable){return }this._lastPointer=null;this.activeDraggable.endDrag(A);this.activeDraggable=null},keyPress:function(A){if(this.activeDraggable){this.activeDraggable.keyPress(A)}},addObserver:function(A){this.observers.push(A);this._cacheObserverCallbacks()},removeObserver:function(A){this.observers=this.observers.reject(function(B){return B.element==A});this._cacheObserverCallbacks()},notify:function(B,A,C){if(this[B+"Count"]>0){this.observers.each(function(D){if(D[B]){D[B](B,A,C)}})}if(A.options[B]){A.options[B](A,C)}},_cacheObserverCallbacks:function(){["onStart","onEnd","onDrag"].each(function(A){Draggables[A+"Count"]=Draggables.observers.select(function(B){return B[A]}).length})}};var Draggable=Class.create({initialize:function(B){var C={handle:false,reverteffect:function(F,E,D){var G=Math.sqrt(Math.abs(E^2)+Math.abs(D^2))*0.02;new Effect.Move(F,{x:-D,y:-E,duration:G,queue:{scope:"_draggable",position:"end"}})},endeffect:function(E){var D=Object.isNumber(E._opacity)?E._opacity:1;new Effect.Opacity(E,{duration:0.2,from:0.7,to:D,queue:{scope:"_draggable",position:"end"},afterFinish:function(){Draggable._dragging[E]=false}})},zindex:1000,revert:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};if(!arguments[1]||Object.isUndefined(arguments[1].endeffect)){Object.extend(C,{starteffect:function(D){D._opacity=Element.getOpacity(D);Draggable._dragging[D]=true;new Effect.Opacity(D,{duration:0.2,from:D._opacity,to:0.7})}})}var A=Object.extend(C,arguments[1]||{});this.element=$(B);if(A.handle&&Object.isString(A.handle)){this.handle=this.element.down("."+A.handle,0)}if(!this.handle){this.handle=$(A.handle)}if(!this.handle){this.handle=this.element}if(A.scroll&&!A.scroll.scrollTo&&!A.scroll.outerHTML){A.scroll=$(A.scroll);this._isScrollChild=Element.childOf(this.element,A.scroll)}Element.makePositioned(this.element);this.options=A;this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Draggables.register(this)},destroy:function(){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);Draggables.unregister(this)},currentDelta:function(){return([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")])},initDrag:function(A){if(!Object.isUndefined(Draggable._dragging[this.element])&&Draggable._dragging[this.element]){return }if(Event.isLeftClick(A)){var C=Event.element(A);if((tag_name=C.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){return }var B=[Event.pointerX(A),Event.pointerY(A)];var D=Position.cumulativeOffset(this.element);this.offset=[0,1].map(function(E){return(B[E]-D[E])});Draggables.activate(this);Event.stop(A)}},startDrag:function(B){this.dragging=true;if(!this.delta){this.delta=this.currentDelta()}if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);this.element.style.zIndex=this.options.zindex}if(this.options.ghosting){this._clone=this.element.cloneNode(true);this.element._originallyAbsolute=(this.element.getStyle("position")=="absolute");if(!this.element._originallyAbsolute){Position.absolutize(this.element)}this.element.parentNode.insertBefore(this._clone,this.element)}if(this.options.scroll){if(this.options.scroll==window){var A=this._getWindowScroll(this.options.scroll);this.originalScrollLeft=A.left;this.originalScrollTop=A.top}else{this.originalScrollLeft=this.options.scroll.scrollLeft;this.originalScrollTop=this.options.scroll.scrollTop}}Draggables.notify("onStart",this,B);if(this.options.starteffect){this.options.starteffect(this.element)}},updateDrag:function(event,pointer){if(!this.dragging){this.startDrag(event)}if(!this.options.quiet){Position.prepare();Droppables.show(pointer,this.element)}Draggables.notify("onDrag",this,event);this.draw(pointer);if(this.options.change){this.options.change(this)}if(this.options.scroll){this.stopScrolling();var p;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height]}}else{p=Position.page(this.options.scroll);p[0]+=this.options.scroll.scrollLeft+Position.deltaX;p[1]+=this.options.scroll.scrollTop+Position.deltaY;p.push(p[0]+this.options.scroll.offsetWidth);p.push(p[1]+this.options.scroll.offsetHeight)}var speed=[0,0];if(pointer[0]<(p[0]+this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[0]+this.options.scrollSensitivity)}if(pointer[1]<(p[1]+this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[1]+this.options.scrollSensitivity)}if(pointer[0]>(p[2]-this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[2]-this.options.scrollSensitivity)}if(pointer[1]>(p[3]-this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[3]-this.options.scrollSensitivity)}this.startScrolling(speed)}if(Prototype.Browser.WebKit){window.scrollBy(0,0)}Event.stop(event)},finishDrag:function(B,E){this.dragging=false;if(this.options.quiet){Position.prepare();var D=[Event.pointerX(B),Event.pointerY(B)];Droppables.show(D,this.element)}if(this.options.ghosting){if(!this.element._originallyAbsolute){Position.relativize(this.element)}delete this.element._originallyAbsolute;Element.remove(this._clone);this._clone=null}var F=false;if(E){F=Droppables.fire(B,this.element);if(!F){F=false}}if(F&&this.options.onDropped){this.options.onDropped(this.element)}Draggables.notify("onEnd",this,B);var A=this.options.revert;if(A&&Object.isFunction(A)){A=A(this.element)}var C=this.currentDelta();if(A&&this.options.reverteffect){if(F==0||A!="failure"){this.options.reverteffect(this.element,C[1]-this.delta[1],C[0]-this.delta[0])}}else{this.delta=C}if(this.options.zindex){this.element.style.zIndex=this.originalZ}if(this.options.endeffect){this.options.endeffect(this.element)}Draggables.deactivate(this);Droppables.reset()},keyPress:function(A){if(A.keyCode!=Event.KEY_ESC){return }this.finishDrag(A,false);Event.stop(A)},endDrag:function(A){if(!this.dragging){return }this.stopScrolling();this.finishDrag(A,true);Event.stop(A)},draw:function(A){var F=Position.cumulativeOffset(this.element);if(this.options.ghosting){var C=Position.realOffset(this.element);F[0]+=C[0]-Position.deltaX;F[1]+=C[1]-Position.deltaY}var E=this.currentDelta();F[0]-=E[0];F[1]-=E[1];if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){F[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;F[1]-=this.options.scroll.scrollTop-this.originalScrollTop}var D=[0,1].map(function(G){return(A[G]-F[G]-this.offset[G])}.bind(this));if(this.options.snap){if(Object.isFunction(this.options.snap)){D=this.options.snap(D[0],D[1],this)}else{if(Object.isArray(this.options.snap)){D=D.map(function(G,H){return(G/this.options.snap[H]).round()*this.options.snap[H]}.bind(this))}else{D=D.map(function(G){return(G/this.options.snap).round()*this.options.snap}.bind(this))}}}var B=this.element.style;if((!this.options.constraint)||(this.options.constraint=="horizontal")){B.left=D[0]+"px"}if((!this.options.constraint)||(this.options.constraint=="vertical")){B.top=D[1]+"px"}if(B.visibility=="hidden"){B.visibility=""}},stopScrolling:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;Draggables._lastScrollPointer=null}},startScrolling:function(A){if(!(A[0]||A[1])){return }this.scrollSpeed=[A[0]*this.options.scrollSpeed,A[1]*this.options.scrollSpeed];this.lastScrolled=new Date();this.scrollInterval=setInterval(this.scroll.bind(this),10)},scroll:function(){var current=new Date();var delta=current-this.lastScrolled;this.lastScrolled=current;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){if(this.scrollSpeed[0]||this.scrollSpeed[1]){var d=delta/1000;this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1])}}}else{this.options.scroll.scrollLeft+=this.scrollSpeed[0]*delta/1000;this.options.scroll.scrollTop+=this.scrollSpeed[1]*delta/1000}Position.prepare();Droppables.show(Draggables._lastPointer,this.element);Draggables.notify("onDrag",this);if(this._isScrollChild){Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*delta/1000;Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*delta/1000;if(Draggables._lastScrollPointer[0]<0){Draggables._lastScrollPointer[0]=0}if(Draggables._lastScrollPointer[1]<0){Draggables._lastScrollPointer[1]=0}this.draw(Draggables._lastScrollPointer)}if(this.options.change){this.options.change(this)}},_getWindowScroll:function(w){var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft}}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}}return{top:T,left:L,width:W,height:H}}});Draggable._dragging={};var SortableObserver=Class.create({initialize:function(B,A){this.element=$(B);this.observer=A;this.lastValue=Sortable.serialize(this.element)},onStart:function(){this.lastValue=Sortable.serialize(this.element)},onEnd:function(){Sortable.unmark();if(this.lastValue!=Sortable.serialize(this.element)){this.observer(this.element)}}});var Sortable={SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,sortables:{},_findRootElement:function(A){while(A.tagName.toUpperCase()!="BODY"){if(A.id&&Sortable.sortables[A.id]){return A}A=A.parentNode}},options:function(A){A=Sortable._findRootElement($(A));if(!A){return }return Sortable.sortables[A.id]},destroy:function(A){var B=Sortable.options(A);if(B){Draggables.removeObserver(B.element);B.droppables.each(function(C){Droppables.remove(C)});B.draggables.invoke("destroy");delete Sortable.sortables[B.element.id]}},create:function(C){C=$(C);var B=Object.extend({element:C,tag:"li",dropOnEmpty:false,tree:false,treeTag:"ul",overlap:"vertical",constraint:"vertical",containment:C,handle:false,only:false,delay:0,hoverclass:null,ghosting:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:this.SERIALIZE_RULE,elements:false,handles:false,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction},arguments[1]||{});this.destroy(C);var A={revert:true,quiet:B.quiet,scroll:B.scroll,scrollSpeed:B.scrollSpeed,scrollSensitivity:B.scrollSensitivity,delay:B.delay,ghosting:B.ghosting,constraint:B.constraint,handle:B.handle};if(B.starteffect){A.starteffect=B.starteffect}if(B.reverteffect){A.reverteffect=B.reverteffect}else{if(B.ghosting){A.reverteffect=function(F){F.style.top=0;F.style.left=0}}}if(B.endeffect){A.endeffect=B.endeffect}if(B.zindex){A.zindex=B.zindex}var D={overlap:B.overlap,containment:B.containment,tree:B.tree,hoverclass:B.hoverclass,onHover:Sortable.onHover};var E={onHover:Sortable.onEmptyHover,overlap:B.overlap,containment:B.containment,hoverclass:B.hoverclass};Element.cleanWhitespace(C);B.draggables=[];B.droppables=[];if(B.dropOnEmpty||B.tree){Droppables.add(C,E);B.droppables.push(C)}(B.elements||this.findElements(C,B)||[]).each(function(H,F){var G=B.handles?$(B.handles[F]):(B.handle?$(H).select("."+B.handle)[0]:H);B.draggables.push(new Draggable(H,Object.extend(A,{handle:G})));Droppables.add(H,D);if(B.tree){H.treeNode=C}B.droppables.push(H)});if(B.tree){(Sortable.findTreeElements(C,B)||[]).each(function(F){Droppables.add(F,E);F.treeNode=C;B.droppables.push(F)})}this.sortables[C.id]=B;Draggables.addObserver(new SortableObserver(C,B.onUpdate))},findElements:function(B,A){return Element.findChildren(B,A.only,A.tree?true:false,A.tag)},findTreeElements:function(B,A){return Element.findChildren(B,A.only,A.tree?true:false,A.treeTag)},onHover:function(E,D,A){if(Element.isParent(D,E)){return }if(A>0.33&&A<0.66&&Sortable.options(D).tree){return }else{if(A>0.5){Sortable.mark(D,"before");if(D.previousSibling!=E){var B=E.parentNode;E.style.visibility="hidden";D.parentNode.insertBefore(E,D);if(D.parentNode!=B){Sortable.options(B).onChange(E)}Sortable.options(D.parentNode).onChange(E)}}else{Sortable.mark(D,"after");var C=D.nextSibling||null;if(C!=E){var B=E.parentNode;E.style.visibility="hidden";D.parentNode.insertBefore(E,C);if(D.parentNode!=B){Sortable.options(B).onChange(E)}Sortable.options(D.parentNode).onChange(E)}}}},onEmptyHover:function(E,G,H){var I=E.parentNode;var A=Sortable.options(G);if(!Element.isParent(G,E)){var F;var C=Sortable.findElements(G,{tag:A.tag,only:A.only});var B=null;if(C){var D=Element.offsetSize(G,A.overlap)*(1-H);for(F=0;F<C.length;F+=1){if(D-Element.offsetSize(C[F],A.overlap)>=0){D-=Element.offsetSize(C[F],A.overlap)}else{if(D-(Element.offsetSize(C[F],A.overlap)/2)>=0){B=F+1<C.length?C[F+1]:null;break}else{B=C[F];break}}}}G.insertBefore(E,B);Sortable.options(I).onChange(E);A.onChange(E)}},unmark:function(){if(Sortable._marker){Sortable._marker.hide()}},mark:function(B,A){var D=Sortable.options(B.parentNode);if(D&&!D.ghosting){return }if(!Sortable._marker){Sortable._marker=($("dropmarker")||Element.extend(document.createElement("DIV"))).hide().addClassName("dropmarker").setStyle({position:"absolute"});document.getElementsByTagName("body").item(0).appendChild(Sortable._marker)}var C=Position.cumulativeOffset(B);Sortable._marker.setStyle({left:C[0]+"px",top:C[1]+"px"});if(A=="after"){if(D.overlap=="horizontal"){Sortable._marker.setStyle({left:(C[0]+B.clientWidth)+"px"})}else{Sortable._marker.setStyle({top:(C[1]+B.clientHeight)+"px"})}}Sortable._marker.show()},_tree:function(E,B,F){var D=Sortable.findElements(E,B)||[];for(var C=0;C<D.length;++C){var A=D[C].id.match(B.format);if(!A){continue}var G={id:encodeURIComponent(A?A[1]:null),element:E,parent:F,children:[],position:F.children.length,container:$(D[C]).down(B.treeTag)};if(G.container){this._tree(G.container,B,G)}F.children.push(G)}return F},tree:function(D){D=$(D);var C=this.options(D);var B=Object.extend({tag:C.tag,treeTag:C.treeTag,only:C.only,name:D.id,format:C.format},arguments[1]||{});var A={id:null,parent:null,children:[],container:D,position:0};return Sortable._tree(D,B,A)},_constructIndex:function(B){var A="";do{if(B.id){A="["+B.position+"]"+A}}while((B=B.parent)!=null);return A},sequence:function(B){B=$(B);var A=Object.extend(this.options(B),arguments[1]||{});return $(this.findElements(B,A)||[]).map(function(C){return C.id.match(A.format)?C.id.match(A.format)[1]:""})},setSequence:function(B,C){B=$(B);var A=Object.extend(this.options(B),arguments[2]||{});var D={};this.findElements(B,A).each(function(E){if(E.id.match(A.format)){D[E.id.match(A.format)[1]]=[E,E.parentNode]}E.parentNode.removeChild(E)});C.each(function(E){var F=D[E];if(F){F[1].appendChild(F[0]);delete D[E]}})},serialize:function(C){C=$(C);var B=Object.extend(Sortable.options(C),arguments[1]||{});var A=encodeURIComponent((arguments[1]&&arguments[1].name)?arguments[1].name:C.id);if(B.tree){return Sortable.tree(C,arguments[1]).children.map(function(D){return[A+Sortable._constructIndex(D)+"[id]="+encodeURIComponent(D.id)].concat(D.children.map(arguments.callee))}).flatten().join("&")}else{return Sortable.sequence(C,arguments[1]).map(function(D){return A+"[]="+encodeURIComponent(D)}).join("&")}}};Element.isParent=function(B,A){if(!B.parentNode||B==A){return false}if(B.parentNode==A){return true}return Element.isParent(B.parentNode,A)};Element.findChildren=function(D,B,A,C){if(!D.hasChildNodes()){return null}C=C.toUpperCase();if(B){B=[B].flatten()}var E=[];$A(D.childNodes).each(function(G){if(G.tagName&&G.tagName.toUpperCase()==C&&(!B||(Element.classNames(G).detect(function(H){return B.include(H)})))){E.push(G)}if(A){var F=Element.findChildren(G,B,A,C);if(F){E.push(F)}}});return(E.length>0?E.flatten():[])};Element.offsetSize=function(A,B){return A["offset"+((B=="vertical"||B=="height")?"Height":"Width")]}; \ No newline at end of file Modified: trunk/linpha2/lib/js/effects.js =================================================================== --- trunk/linpha2/lib/js/effects.js 2008-01-29 20:01:16 UTC (rev 4830) +++ trunk/linpha2/lib/js/effects.js 2008-01-29 21:12:02 UTC (rev 4831) @@ -1,4 +1,4 @@ -// script.aculo.us effects.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007 +// script.aculo.us effects.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Contributors: @@ -1076,11 +1076,11 @@ Element.getStyles = function(element) { element = $(element); var css = element.currentStyle, styles; - styles = Element.CSS_PROPERTIES.inject({ }, function(hash, property) { - hash.set(property, css[property]); - return hash; + styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) { + results[property] = css[property]; + return results; }); - if (!styles.opacity) styles.set('opacity', element.getOpacity()); + if (!styles.opacity) styles.opacity = element.getOpacity(); return styles; }; }; Added: trunk/linpha2/lib/js/effects.yui.js =================================================================== --- trunk/linpha2/lib/js/effects.yui.js (rev 0) +++ trunk/linpha2/lib/js/effects.yui.js 2008-01-29 21:12:02 UTC (rev 4831) @@ -0,0 +1 @@ +String.prototype.parseColor=function(){var A="#";if(this.slice(0,4)=="rgb("){var C=this.slice(4,this.length-1).split(",");var B=0;do{A+=parseInt(C[B]).toColorPart()}while(++B<3)}else{if(this.slice(0,1)=="#"){if(this.length==4){for(var B=1;B<4;B++){A+=(this.charAt(B)+this.charAt(B)).toLowerCase()}}if(this.length==7){A=this.toLowerCase()}}}return(A.length==7?A:(arguments[0]||this))};Element.collectTextNodes=function(A){return $A($(A).childNodes).collect(function(B){return(B.nodeType==3?B.nodeValue:(B.hasChildNodes()?Element.collectTextNodes(B):""))}).flatten().join("")};Element.collectTextNodesIgnoreClass=function(A,B){return $A($(A).childNodes).collect(function(C){return(C.nodeType==3?C.nodeValue:((C.hasChildNodes()&&!Element.hasClassName(C,B))?Element.collectTextNodesIgnoreClass(C,B):""))}).flatten().join("")};Element.setContentZoom=function(A,B){A=$(A);A.setStyle({fontSize:(B/100)+"em"});if(Prototype.Browser.WebKit){window.scrollBy(0,0)}return A};Element.getInlineOpacity=function(A){return $(A).style.opacity||""};Element.forceRerendering=function(A){try{A=$(A);var C=document.createTextNode(" ");A.appendChild(C);A.removeChild(C)}catch(B){}};var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},Transitions:{linear:Prototype.K,sinoidal:function(A){return(-Math.cos(A*Math.PI)/2)+0.5},reverse:function(A){return 1-A},flicker:function(A){var A=((-Math.cos(A*Math.PI)/4)+0.75)+Math.random()/4;return A>1?1:A},wobble:function(A){return(-Math.cos(A*Math.PI*(9*A))/2)+0.5},pulse:function(B,A){A=A||5;return(((B%(1/A))*A).round()==0?((B*A*2)-(B*A*2).floor()):1-((B*A*2)-(B*A*2).floor()))},spring:function(A){return 1-(Math.cos(A*4.5*Math.PI)*Math.exp(-A*6))},none:function(A){return 0},full:function(A){return 1}},DefaultOptions:{duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"},tagifyText:function(A){var B="position:relative";if(Prototype.Browser.IE){B+=";zoom:1"}A=$(A);$A(A.childNodes).each(function(C){if(C.nodeType==3){C.nodeValue.toArray().each(function(D){A.insertBefore(new Element("span",{style:B}).update(D==" "?String.fromCharCode(160):D),C)});Element.remove(C)}})},multiple:function(B,C){var E;if(((typeof B=="object")||Object.isFunction(B))&&(B.length)){E=B}else{E=$(B).childNodes}var A=Object.extend({speed:0.1,delay:0},arguments[2]||{});var D=A.delay;$A(E).each(function(G,F){new C(G,Object.extend(A,{delay:F*A.speed+D}))})},PAIRS:{slide:["SlideDown","SlideUp"],blind:["BlindDown","BlindUp"],appear:["Appear","Fade"]},toggle:function(B,C){B=$(B);C=(C||"appear").toLowerCase();var A=Object.extend({queue:{position:"end",scope:(B.id||"global"),limit:1}},arguments[2]||{});Effect[B.visible()?Effect.PAIRS[C][1]:Effect.PAIRS[C][0]](B,A)}};Effect.DefaultOptions.transition=Effect.Transitions.sinoidal;Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){this.effects=[];this.interval=null},_each:function(A){this.effects._each(A)},add:function(B){var C=new Date().getTime();var A=Object.isString(B.options.queue)?B.options.queue:B.options.queue.position;switch(A){case"front":this.effects.findAll(function(D){return D.state=="idle"}).each(function(D){D.startOn+=B.finishOn;D.finishOn+=B.finishOn});break;case"with-last":C=this.effects.pluck("startOn").max()||C;break;case"end":C=this.effects.pluck("finishOn").max()||C;break}B.startOn+=C;B.finishOn+=C;if(!B.options.queue.limit||(this.effects.length<B.options.queue.limit)){this.effects.push(B)}if(!this.interval){this.interval=setInterval(this.loop.bind(this),15)}},remove:function(A){this.effects=this.effects.reject(function(B){return B==A});if(this.effects.length==0){clearInterval(this.interval);this.interval=null}},loop:function(){var C=new Date().getTime();for(var B=0,A=this.effects.length;B<A;B++){this.effects[B]&&this.effects[B].loop(C)}}});Effect.Queues={instances:$H(),get:function(A){if(!Object.isString(A)){return A}return this.instances.get(A)||this.instances.set(A,new Effect.ScopedQueue())}};Effect.Queue=Effect.Queues.get("global");Effect.Base=Class.create({position:null,start:function(options){function codeForEvent(options,eventName){return((options[eventName+"Internal"]?"this.options."+eventName+"Internal(this);":"")+(options[eventName]?"this.options."+eventName+"(this);":""))}if(options&&options.transition===false){options.transition=Effect.Transitions.linear}this.options=Object.extend(Object.extend({},Effect.DefaultOptions),options||{});this.currentFrame=0;this.state="idle";this.startOn=this.options.delay*1000;this.finishOn=this.startOn+(this.options.duration*1000);this.fromToDelta=this.options.to-this.options.from;this.totalTime=this.finishOn-this.startOn;this.totalFrames=this.options.fps*this.options.duration;eval('this.render = function(pos){ if (this.state=="idle"){this.state="running";'+codeForEvent(this.options,"beforeSetup")+(this.setup?"this.setup();":"")+codeForEvent(this.options,"afterSetup")+'};if (this.state=="running"){pos=this.options.transition(pos)*'+this.fromToDelta+"+"+this.options.from+";this.position=pos;"+codeForEvent(this.options,"beforeUpdate")+(this.update?"this.update(pos);":"")+codeForEvent(this.options,"afterUpdate")+"}}");this.event("beforeStart");if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).add(this)}},loop:function(C){if(C>=this.startOn){if(C>=this.finishOn){this.render(1);this.cancel();this.event("beforeFinish");if(this.finish){this.finish()}this.event("afterFinish");return }var B=(C-this.startOn)/this.totalTime,A=(B*this.totalFrames).round();if(A>this.currentFrame){this.render(B);this.currentFrame=A}}},cancel:function(){if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).remove(this)}this.state="finished"},event:function(A){if(this.options[A+"Internal"]){this.options[A+"Internal"](this)}if(this.options[A]){this.options[A](this)}},inspect:function(){var A=$H();for(property in this){if(!Object.isFunction(this[property])){A.set(property,this[property])}}return"#<Effect:"+A.inspect()+",options:"+$H(this.options).inspect()+">"}});Effect.Parallel=Class.create(Effect.Base,{initialize:function(A){this.effects=A||[];this.start(arguments[1])},update:function(A){this.effects.invoke("render",A)},finish:function(A){this.effects.each(function(B){B.render(1);B.cancel();B.event("beforeFinish");if(B.finish){B.finish(A)}B.event("afterFinish")})}});Effect.Tween=Class.create(Effect.Base,{initialize:function(C,F,E){C=Object.isString(C)?$(C):C;var B=$A(arguments),D=B.last(),A=B.length==5?B[3]:null;this.method=Object.isFunction(D)?D.bind(C):Object.isFunction(C[D])?C[D].bind(C):function(G){C[D]=G};this.start(Object.extend({from:F,to:E},A||{}))},update:function(A){this.method(A)}});Effect.Event=Class.create(Effect.Base,{initialize:function(){this.start(Object.extend({duration:0},arguments[0]||{}))},update:Prototype.emptyFunction});Effect.Opacity=Class.create(Effect.Base,{initialize:function(B){this.element=$(B);if(!this.element){throw (Effect._elementDoesNotExistError)}if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}var A=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});this.start(A)},update:function(A){this.element.setOpacity(A)}});Effect.Move=Class.create(Effect.Base,{initialize:function(B){this.element=$(B);if(!this.element){throw (Effect._elementDoesNotExistError)}var A=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});this.start(A)},setup:function(){this.element.makePositioned();this.originalLeft=parseFloat(this.element.getStyle("left")||"0");this.originalTop=parseFloat(this.element.getStyle("top")||"0");if(this.options.mode=="absolute"){this.options.x=this.options.x-this.originalLeft;this.options.y=this.options.y-this.originalTop}},update:function(A){this.element.setStyle({left:(this.options.x*A+this.originalLeft).round()+"px",top:(this.options.y*A+this.originalTop).round()+"px"})}});Effect.MoveBy=function(B,A,C){return new Effect.Move(B,Object.extend({x:C,y:A},arguments[3]||{}))};Effect.Scale=Class.create(Effect.Base,{initialize:function(B,C){this.element=$(B);if(!this.element){throw (Effect._elementDoesNotExistError)}var A=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:C},arguments[2]||{});this.start(A)},setup:function(){this.restoreAfterFinish=this.options.restoreAfterFinish||false;this.elementPositioning=this.element.getStyle("position");this.originalStyle={};["top","left","width","height","fontSize"].each(function(B){this.originalStyle[B]=this.element.style[B]}.bind(this));this.originalTop=this.element.offsetTop;this.originalLeft=this.element.offsetLeft;var A=this.element.getStyle("font-size")||"100%";["em","px","%","pt"].each(function(B){if(A.indexOf(B)>0){this.fontSize=parseFloat(A);this.fontSizeType=B}}.bind(this));this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;this.dims=null;if(this.options.scaleMode=="box"){this.dims=[this.element.offsetHeight,this.element.offsetWidth]}if(/^content/.test(this.options.scaleMode)){this.dims=[this.element.scrollHeight,this.element.scrollWidth]}if(!this.dims){this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]}},update:function(A){var B=(this.options.scaleFrom/100)+(this.factor*A);if(this.options.scaleContent&&this.fontSize){this.element.setStyle({fontSize:this.fontSize*B+this.fontSizeType})}this.setDimensions(this.dims[0]*B,this.dims[1]*B)},finish:function(A){if(this.restoreAfterFinish){this.element.setStyle(this.originalStyle)}},setDimensions:function(A,D){var E={};if(this.options.scaleX){E.width=D.round()+"px"}if(this.options.scaleY){E.height=A.round()+"px"}if(this.options.scaleFromCenter){var C=(A-this.dims[0])/2;var B=(D-this.dims[1])/2;if(this.elementPositioning=="absolute"){if(this.options.scaleY){E.top=this.originalTop-C+"px"}if(this.options.scaleX){E.left=this.originalLeft-B+"px"}}else{if(this.options.scaleY){E.top=-C+"px"}if(this.options.scaleX){E.left=-B+"px"}}}this.element.setStyle(E)}});Effect.Highlight=Class.create(Effect.Base,{initialize:function(B){this.element=$(B);if(!this.element){throw (Effect._elementDoesNotExistError)}var A=Object.extend({startcolor:"#ffff99"},arguments[1]||{});this.start(A)},setup:function(){if(this.element.getStyle("display")=="none"){this.cancel();return }this.oldStyle={};if(!this.options.keepBackgroundImage){this.oldStyle.backgroundImage=this.element.getStyle("background-image");this.element.setStyle({backgroundImage:"none"})}if(!this.options.endcolor){this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff")}if(!this.options.restorecolor){this.options.restorecolor=this.element.getStyle("ba... [truncated message content] |
From: <bz...@us...> - 2008-01-30 13:35:15
|
Revision: 4836 http://linpha.svn.sourceforge.net/linpha/?rev=4836&view=rev Author: bzrudi Date: 2008-01-30 05:35:12 -0800 (Wed, 30 Jan 2008) Log Message: ----------- "first try on spitting GPS geodata from images into maps plugin - expect it broken for all DB other than PostgreSQL" Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/sql/sql.mysql.php trunk/linpha2/lib/include/sql/sql.oci8po.php trunk/linpha2/lib/include/sql/sql.postgres.php trunk/linpha2/lib/include/sql/sql.sqlite.php trunk/linpha2/lib/include/sql/sql.tables.php trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/lib/plugins/maps/settings.maps.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/ChangeLog 2008-01-30 13:35:12 UTC (rev 4836) @@ -1,4 +1,11 @@ - +2008-01-30 bzrudi + * Split out GPS meta/geodata from meta_exif into a seperate relation within the + maps plugin. The relation is created when admin enables the maps plugin + and is called 'plugins_maps_image_geodata'. This is mostly done due to + expected performance issues and the mysql "big table" problem. + It should currently work partially with PostgresDB, other DB will follow + later. Needs "reset_database.php" to work and sys_import_use_exiftool=1 + 2008-01-29 flo * updated to latest protoype 1.6.0.2 and scriptaculous 1.8.1 * compressed javascript files with yui compresser Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -185,7 +185,8 @@ $dataArray = LinExifTool::readMetaDataFromFile($tag, $filename); - //echo '<pre>', print_r($dataArray), '</pre>'; + echo '<pre>', print_r($dataArray), '</pre>'; + $str_columns = "md5sum, "; $str_values = "'" . $md5sum . "', "; @@ -221,7 +222,6 @@ } } - /** * Simple method to return just exif date and orientation tag during * import as needed by linpha_photos, this is not used for any meta_x table. @@ -507,41 +507,7 @@ 'saturation' => 'Saturation', 'sharpness' => 'Sharpness', 'subjectdistancerange' => 'Subject Distance Range', - 'gamma' => 'Gamma', - - //GPS - 'gpsversionid' => 'GPS Version ID', - 'gpslatituderef' => 'GPS Latitude Ref', - 'gpslatitude' => 'GPS Latitude', - 'gpslongituderef' => 'GPS Longitude Ref', - 'gpslongitude' => 'GPS Longitude', - 'gpsaltituderef' => 'GPS Altitude Ref', - 'gpsaltitude' => 'GPS Altitude', - 'gpstimestamp' => 'GPS Time Stamp', - 'gpssatellites' => 'GPS Satellites', - 'gpsstatus' => 'GPS Status', - 'gpsmeasuremode' => 'GPS Measure Mode', - 'gpsdop' => 'GPS DOP', - 'gpsspeedref' => 'GPS Speed Ref', - 'gpsspeed' => 'GPS Speed', - 'gpstrackref' => 'GPS Track', - 'gpstrack' => 'GPS Track', - 'gpsimgdirectionref' => 'GPS Img Direction Ref', - 'gpsimgdirection' => 'GPS Img Direction', - 'gpsmapdatum' => 'GPS Map Datum', - 'gpsdestlatituderef' => 'GPS Dest Latitude Ref', - 'gpsdestlatitude' => 'GPS Dest Latitude', - 'gpsdestlongituderef' => 'GPS Dest Longitude Ref', - 'gpsdestlongitude' => 'GPS Dest Longitude', - 'gpsdestbearingref' => 'GPS Dest Bearing Ref', - 'gpsdestbearing' => 'GPS Dest Bearing', - 'gpsdestdistanceref' => 'GPS Dest Distance Ref', - 'gpsdestdistance' => 'GPS Dest Distance', - 'gpsprocessingmethod' => 'GPS Processing Method', - 'gpsareainformation' => 'GPS Area Information', - 'gpsdatestamp' => 'GPS Date Stamp', - 'gpsdatetime' => 'GPS Date Time', - 'gpsposition' => 'GPS Position' //not definied in exiftool!? + 'gamma' => 'Gamma' ) ); } Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -742,9 +742,10 @@ /** * This method is used to setup the initial most useful defaults for the - * MetaData tables EXIF/IPTC/XMP during creation - * @param string exif,iptc,xmp - * @return array initial metadata values used for table create + * MetaData tables EXIF/IPTC/XMP during creation and provides default + * Geodata (GPS) Tgas for the maps plugin + * @param string exif,iptc,xmp,gps + * @return array with metadata information * @author bzrudi,flo */ private function getDefaultMetaTags($type) @@ -801,6 +802,43 @@ 'supplementalcategories', ); break; + + case 'gps': + return array ( + 'gpsversionid', + 'gpslatituderef', + 'gpslatitude', + 'gpslongituderef', + 'gpslongitude', + 'gpsaltituderef', + 'gpsaltitude', + 'gpstimestamp', + 'gpssatellites', + 'gpsstatus', + 'gpsmeasuremode', + 'gpsdop', + 'gpsspeedref', + 'gpsspeed', + 'gpstrackref', + 'gpstrack', + 'gpsimgdirectionref', + 'gpsimgdirection', + 'gpsmapdatum', + 'gpsdestlatituderef', + 'gpsdestlatitude', + 'gpsdestlongituderef', + 'gpsdestlongitude', + 'gpsdestbearingref', + 'gpsdestbearing', + 'gpsdestdistanceref', + 'gpsdestdistance', + 'gpsprocessingmethod', + 'gpsareainformation', + 'gpsdatestamp', + 'gpsdatetime', + 'gpsposition', + ); + break; default: return array(); @@ -883,7 +921,67 @@ return $str; } + + /** + * Save all Image GeoData (GPS) to database. + * Used in maps plugin if enabled. We just get all information about images + * from the LIN_PREFIX.photos relation. For speed improvements a new value + * bool value "geodata" is altered to the photos relation to only parse all + * images once. + * + */ + function importGeoData() + { + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum + FROM ".LIN_PREFIX."photos + WHERE img_type <> 0 + AND img_type <> 9999999 + AND geodata <> 1 "); + + while ($data = $query->FetchRow()) + { + $filename = LinSql::getFullImagePath($data['0']); + $dataArray = $this->objMetaTool->readMetaDataFromFile('exif', $filename); + echo '<pre>', print_r($dataArray), '</pre>'; + + $str_columns = "md5sum, "; + $str_values = "'".$data['1']."', "; + + if(is_array($dataArray)) + { + /** + * Lower array data to make it compareable to $metaTags + */ + $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); + + echo '<pre>', print_r($lowerDataArray), '</pre>'; + + foreach($this->getDefaultMetaTags('gps') AS $key => $value) + { + if(array_key_exists($value, $lowerDataArray)) + { + + $str_columns .= str_replace("_", "-", $value) . ', '; + $str_values .= "'".trim($lowerDataArray[$value])."', "; + } + } + /** + * Remove last two signs (the comma and the space) which we add to much + */ + $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); + $str_values = substr($str_values, 0, strlen($str_values) - 2); + + $GLOBALS['linpha']->db->Execute("INSERT INTO ".LIN_PREFIX."plugins_maps_image_geodata " . + "(" . $str_columns . ") VALUES (" . $str_values . ")"); + + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos " . + "SET geodata='1' WHERE md5sum='".$data['1']."' "); + } + } + } + /** * Simple wrapper method for saveMetaData() * @param string $what meta type exif,iptc,xmp Modified: trunk/linpha2/lib/include/sql/sql.mysql.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.mysql.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.mysql.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -74,6 +74,7 @@ "stats_numbers INT NOT NULL default '0', " . "stats_views INT NOT NULL default '0', " . "stats_downloads INT NOT NULL default '0', " . + "geodata INT(1) default '0', " . "PRIMARY KEY (id) " . ")", "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". Modified: trunk/linpha2/lib/include/sql/sql.oci8po.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.oci8po.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.oci8po.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -69,6 +69,7 @@ "stats_numbers NUMBER(10) DEFAULT '0', " . "stats_views NUMBER(10) DEFAULT '0', " . "stats_downloads NUMBER(10) DEFAULT '0'" . + "geodata NUMBER(1) default '0' " . ")", "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". "id NUMBER PRIMARY KEY, " . Modified: trunk/linpha2/lib/include/sql/sql.postgres.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.postgres.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.postgres.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -68,7 +68,8 @@ "rotate INT NOT NULL default '0', " . "stats_numbers INT NOT NULL default '0', " . "stats_views INT NOT NULL default '0', " . - "stats_downloads INT NOT NULL default '0' " . + "stats_downloads INT NOT NULL default '0', " . + "geodata INT default '0' " . ")", "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". "id SERIAL PRIMARY KEY, " . Modified: trunk/linpha2/lib/include/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.sqlite.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.sqlite.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -68,7 +68,8 @@ "rotate INTEGER NOT NULL default '0', " . "stats_numbers INTEGER NOT NULL default '0', " . "stats_views INTEGER NOT NULL default '0', " . - "stats_downloads INTEGER NOT NULL default '0' " . + "stats_downloads INTEGER NOT NULL default '0', " . + "geodata INTEGER default '0' " . ")", "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". "id INTEGER PRIMARY KEY, " . Modified: trunk/linpha2/lib/include/sql/sql.tables.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.tables.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.tables.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -17,10 +17,18 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/** - * linpha installer - */ - +if(isset($GLOBALS['linpha']->sql->config->value['plugins_maps_enable'])) +{ + // still need the plugin entries; workaround for reset_database.php + $plugins_maps_image_geodata = 'plugins_maps_image_geodata => plugins_maps_image_geodata'; + $plugins_maps_markers = 'plugins_maps_markers => plugins_maps_markers'; +} +else +{ + $plugins_maps_image_geodata = ''; + $plugins_maps_markers = ''; +} + $linpha_tables = Array( "config" => "config", "users" => "users", @@ -36,6 +44,9 @@ "meta_xmp" => "meta_xmp", "meta_comments" => "meta_comments", "meta_data" => "meta_data", - "plugins_maps_setMarkers" => "plugins_maps_markers", // still need the plugin entries; workaround for reset_database.php + "plugins_maps_image_geodata" => "plugins_maps_image_geodata", + "plugins_maps_markers" => "plugins_maps_markers", + //$plugins_maps_image_geodata."", + //$plugins_maps_markers, ); ?> Modified: trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php =================================================================== --- trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -10,9 +10,4 @@ $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . "VALUES ('plugins_filemanager_nrUploads', '0', '0', '0')"; - - -//$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . -// "VALUES ('plugins_example', ';public;')"; - -?> \ No newline at end of file +?> Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -1,327 +1,346 @@ -<?php -/* - * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> - * Florian Angehrn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/** - * Google Maps - * @package Plugins - */ -if(!defined('LINPHA_DIR')) { exit(1); } - -/** - * xml load/save stuff - */ -if(isset($_GET['xml'])) -{ - if(isset($_REQUEST['cmd'])) // $_POST - { - switch($_REQUEST['cmd']) // $_POST - { - case 'loadMarkers': - - echo '{ "markers": [' . "\n"; - - $query = $GLOBALS['linpha']->db->Execute( - "SELECT id, albId, albPath, markerName, markerLat, markerLon, markerZoom " . - "FROM ".LIN_PREFIX."plugins_maps_markers" - ); - - if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) { - $allowed = true; - } else { - $allowed = false; - } - - while($data = $query->FetchRow()) - { - if( $data['albId']!=0 ) { - - $query2 = $GLOBALS['linpha']->db->Execute("SELECT P.parent_id " . - "FROM ".LIN_PREFIX."meta_exif E INNER JOIN ".LIN_PREFIX."photos P on E.md5sum = P.md5sum " . - "WHERE gpslatituderef IS NOT NULL " . - "AND gpslatitude IS NOT NULL " . - "AND gpslongituderef IS NOT NULL " . - "AND gpslongitude IS NOT NULL " . - "AND P.parent_id = '".LinSql::linAddslashes($data['albId'])."'"); - if($query2->EOF) { - $type = 'album'; - } else { - $type = 'albumWithImg'; - } - - } else { - $type = 'marker'; - } - - $path = htmlspecialchars($data['albPath'],ENT_QUOTES); - - echo '{"id": '.$data['id'].', "type": "'.$type.'", "albId": '.$data['albId'].', "path": "'.$path.'", ' . - '"name": "'.htmlspecialchars($data['markerName'],ENT_QUOTES).'", ' . - '"lat": '.$data['markerLat'].', "lon": '.$data['markerLon'].', ' . - '"zoom": '.$data['markerZoom'].'}'; - - // firefox ignores the last comma, but IE produces an error! grmpf - if( !$query->EOF ) { - echo ",\n"; - } else { - echo "\n"; - } - } - - /* ?> { "markers": [ - {"id": 1, "path": "../../asd", "name": "my sweet home 1", "lat": 47.487868258751625, "lon": 9.388654232025146, "zoom": 17}, - {"id": 2, "path": "../../asd2", "name": "my sweet home 2", "lat": 47.587868258751625, "lon": 9.388654232025146, "zoom": 10}, - {"id": 3, "path": "../../asd3", "name": "my sweet home 3", "lat": 47.687868258751625, "lon": 9.388654232025146, "zoom": 15}, - ] } <?php */ - - echo '] }' . "\n"; - - break; - - case 'saveMarker': - case 'editMarker': - - header('Content-type: text/xml'); - echo '<?xml version="1.0" ?>'."\n"; - echo '<root>'."\n"; - - if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; - } - elseif( !isset($_POST['linInputMarkerName']) OR empty($_POST['linInputMarkerName'])) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.i18n("Error: no title specified").'</responseMsg>'."\n"; - } - elseif( !isset($_POST['linInputLat']) OR empty($_POST['linInputLat']) - OR !isset($_POST['linInputLon']) OR empty($_POST['linInputLon'])) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.i18n("Error: Missing Lat/Lon values").'</responseMsg>'."\n"; - } - else - { - if( !isset($_POST['linInputZoom']) OR empty($_POST['linInputZoom']) ) - { - $_POST['linInputZoom'] = $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; - } - - if( $_POST['cmd'] == 'saveMarker' ) - { - $GLOBALS['linpha']->db->Execute("INSERT INTO ".LIN_PREFIX."plugins_maps_markers " . - "(markerName, markerLat, markerLon, markerZoom) " . - "VALUES (" . - "'".LinSql::linAddslashes($_POST['linInputMarkerName'])."', " . - "'".floatval($_POST['linInputLat'])."', " . - "'".floatval($_POST['linInputLon'])."', " . - "'".intval($_POST['linInputZoom'])."')" - ); - } - else // edit Marker - { - if( !isset($_POST['linInputMarkerId']) OR empty($_POST['linInputMarkerId']) ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.i18n("Error: No valid marker").'</responseMsg>'."\n"; - } - } - - echo '<responseCode>success</responseCode>'."\n"; - } - - echo '</root>'."\n"; - - break; - case 'deleteMarker': - - header('Content-type: text/xml'); - echo '<?xml version="1.0" ?>'."\n"; - echo '<root>'."\n"; - - if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; - } - elseif( !isset($_REQUEST['markerId']) ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; - } - else - { - $markerId = intval($_REQUEST['markerId']); - $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."plugins_maps_markers " . - "WHERE id='".LinSql::linAddslashes($markerId)."'"); - - echo '<responseCode>success</responseCode>'."\n"; - echo '<responseData>'.$markerId.'</responseData>'."\n"; - } - - echo '</root>'."\n"; - - break; - - case 'assignAlbum': - case 'assignAlbumChange': - case 'assignAlbumDelete': - - header('Content-type: text/xml'); - echo '<?xml version="1.0" ?>'."\n"; - echo '<root>'."\n"; - - if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; - } - elseif( !isset($_REQUEST['markerId']) OR !isset($_REQUEST['albId']) ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; - } - else - { - $markerId = intval($_REQUEST['markerId']); - $albId = intval($_REQUEST['albId']); - - $arrAlbPath = LinSql::getFullFilenameFromId($albId); - $albPath = implode('/',$arrAlbPath); - - $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."plugins_maps_markers " . - "SET albId = '".LinSql::linAddslashes($albId)."', " . - "albPath = '".LinSql::linAddslashes($albPath)."' WHERE id='".LinSql::linAddslashes($markerId)."'"); - - echo '<responseCode>success</responseCode>'."\n"; - } - - echo '</root>'."\n"; - - break; - case 'loadAlbums': - - echo '{ "albums": [' . "\n"; - - $query = $GLOBALS['linpha']->db->Execute("SELECT DISTINCT P.parent_id " . - "FROM ".LIN_PREFIX."meta_exif E INNER JOIN ".LIN_PREFIX."photos P on E.md5sum = P.md5sum " . - "WHERE gpslatituderef IS NOT NULL " . - "AND gpslatitude IS NOT NULL " . - "AND gpslongituderef IS NOT NULL " . - "AND gpslongitude IS NOT NULL "); - - echo '{"id": 0, "name": "'.i18n("All albums").'"},'."\n"; - - if( !$query ) - { - //echo "Error: Please enable EXIF GPS fields!"; - } - else - { - while($data = $query->FetchRow()) - { - echo '{"id": '.$data['parent_id'].', "name": "'. - htmlspecialchars( - implode( '/', LinSql::getFullFilenameFromId($data['parent_id']) ) - ,ENT_QUOTES).'"}'; - - // firefox ignores the last comma, but IE produces an error! grmpf - if( !$query->EOF ) { - echo ",\n"; - } else { - echo "\n"; - } - } - } - - echo '] }' . "\n"; - - break; - case 'loadImages': - - if( !isset($_REQUEST['albId']) ) { - break; - } - - $albId = intval($_REQUEST['albId']); - - if($albId == 0) { - $filterStr = ""; - } else { - $filterStr = "AND P.parent_id = '".$albId."'"; - } - - $query = $GLOBALS['linpha']->db->Execute("SELECT P.id, P.parent_id, P.name, gpslatituderef,gpslatitude,gpslongituderef,gpslongitude " . - "FROM ".LIN_PREFIX."meta_exif E INNER JOIN ".LIN_PREFIX."photos P on E.md5sum = P.md5sum " . - "WHERE gpslatituderef IS NOT NULL " . - "AND gpslatitude IS NOT NULL " . - "AND gpslongituderef IS NOT NULL " . - "AND gpslongitude IS NOT NULL " . - $filterStr); - - echo '{ "images": [' . "\n"; - - if( !$query ) - { - //echo "Error: Please enable EXIF GPS fields!"; - } - else - { - while($data = $query->FetchRow()) - { - $latlon = getExifLatLon($data); - - echo '{"id": '.$data['id'].', "parent_id": '.$data['parent_id'].', ' . - '"type": "images", "text": "", "name": "'.htmlspecialchars( $data['name'] ,ENT_QUOTES).'", ' . - '"lat": '.$latlon['gpslatitude'].', "lon": '.$latlon['gpslongitude'] . - "}"; - - // firefox ignores the last comma, but IE produces an error! grmpf - if( !$query->EOF ) { - echo ",\n"; - } else { - echo "\n"; - } - } - } - - echo '] }' . "\n"; - - break; - } - } - - exit(); -} - - -$urlFull = LINPHA_LINK.'&linCat=maps'; - -$linpha->template->setModuleName('maps'); -//$linpha->template->overrideModule('head','map'); -$linpha->template->URL_full = $urlFull; -$linpha->template->URL_base = $urlFull; -$linpha->template->output['title'] = i18n("Maps"); -include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); - - +<?php +/* + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * Google Maps + * @package Plugins + */ +if(!defined('LINPHA_DIR')) { exit(1); } + + //$MetaData = new LinMetaData(); + //$MetaData->importGeoData(); +/** + * xml load/save stuff + */ +if(isset($_GET['xml'])) +{ + if(isset($_REQUEST['cmd'])) // $_POST + { + switch($_REQUEST['cmd']) // $_POST + { + case 'loadMarkers': + error_log("LOADING MARKERS",'','0'); + + echo '{ "markers": [' . "\n"; + + $query = $GLOBALS['linpha']->db->Execute( + "SELECT id, albid, albpath, markername, markerlat, markerlon, markerzoom " . + "FROM ".LIN_PREFIX."plugins_maps_markers" + ); + + if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) { + $allowed = true; + } else { + $allowed = false; + } + + while($data = $query->FetchRow()) + { + if( $data['albid'] != '0' ) { + + $query2 = $GLOBALS['linpha']->db->Execute("SELECT P.parent_id " . + "FROM ".LIN_PREFIX."plugins_maps_image_geodata AS PM " . + "INNER JOIN ".LIN_PREFIX."photos P " . + "ON PM.md5sum = P.md5sum " . + "WHERE gpslatituderef IS NOT NULL " . + "AND gpslatitude IS NOT NULL " . + "AND gpslongituderef IS NOT NULL " . + "AND gpslongitude IS NOT NULL " . + "AND P.parent_id = '".LinSql::linAddslashes($data['albid'])."'"); + + if($query2->EOF) { + $type = 'album'; + } else { + $type = 'albumWithImg'; + } + + } else { + $type = 'marker'; + } + + $path = htmlspecialchars($data['albpath'],ENT_QUOTES); + + echo '{"id": '.$data['id'].', "type": "'.$type.'", "albid": '.$data['albid'].', "path": "'.$path.'", ' . + '"name": "'.htmlspecialchars($data['markername'],ENT_QUOTES).'", ' . + '"lat": '.$data['markerlat'].', "lon": '.$data['markerlon'].', ' . + '"zoom": '.$data['markerzoom'].'}'; + + // firefox ignores the last comma, but IE produces an error! grmpf + if( !$query->EOF ) { + echo ",\n"; + } else { + echo "\n"; + } + } + + /* ?> { "markers": [ + {"id": 1, "path": "../../asd", "name": "my sweet home 1", "lat": 47.487868258751625, "lon": 9.388654232025146, "zoom": 17}, + {"id": 2, "path": "../../asd2", "name": "my sweet home 2", "lat": 47.587868258751625, "lon": 9.388654232025146, "zoom": 10}, + {"id": 3, "path": "../../asd3", "name": "my sweet home 3", "lat": 47.687868258751625, "lon": 9.388654232025146, "zoom": 15}, + ] } <?php */ + + echo '] }' . "\n"; + + break; + + case 'saveMarker': + + //error_log("SAVING MARKERS",'','0'); + + case 'editMarker': + + //error_log("EDITING MARKERS",'','0'); + + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + echo '<root>'."\n"; + + if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; + } + elseif( !isset($_POST['linInputMarkerName']) OR empty($_POST['linInputMarkerName'])) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.i18n("Error: no title specified").'</responseMsg>'."\n"; + } + elseif( !isset($_POST['linInputLat']) OR empty($_POST['linInputLat']) + OR !isset($_POST['linInputLon']) OR empty($_POST['linInputLon'])) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.i18n("Error: Missing Lat/Lon values").'</responseMsg>'."\n"; + } + else + { + if( !isset($_POST['linInputZoom']) OR empty($_POST['linInputZoom']) ) + { + $_POST['linInputZoom'] = $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; + } + + if( $_POST['cmd'] == 'saveMarker' ) + { + $GLOBALS['linpha']->db->Execute("INSERT INTO ".LIN_PREFIX."plugins_maps_markers " . + "(markername, markerlat, markerlon, markerzoom) " . + "VALUES (" . + "'".LinSql::linAddslashes($_POST['linInputMarkerName'])."', " . + "'".floatval($_POST['linInputLat'])."', " . + "'".floatval($_POST['linInputLon'])."', " . + "'".intval($_POST['linInputZoom'])."')" + ); + } + else // edit Marker + { + if( !isset($_POST['linInputMarkerId']) OR empty($_POST['linInputMarkerId']) ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.i18n("Error: No valid marker").'</responseMsg>'."\n"; + } + } + + echo '<responseCode>success</responseCode>'."\n"; + } + + echo '</root>'."\n"; + + break; + case 'deleteMarker': + + //error_log("DELETING MARKERS",'','0'); + + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + echo '<root>'."\n"; + + if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; + } + elseif( !isset($_REQUEST['markerId']) ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; + } + else + { + $markerId = intval($_REQUEST['markerId']); + $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."plugins_maps_markers " . + "WHERE id='".LinSql::linAddslashes($markerId)."'"); + + echo '<responseCode>success</responseCode>'."\n"; + echo '<responseData>'.$markerId.'</responseData>'."\n"; + } + + echo '</root>'."\n"; + + break; + + case 'assignAlbum': + case 'assignAlbumChange': + case 'assignAlbumDelete': + + //error_log("ASSIGNING ALBUM MARKERS",'','0'); + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + echo '<root>'."\n"; + + if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; + } + elseif( !isset($_REQUEST['markerId']) OR !isset($_REQUEST['albId']) ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; + } + else + { + $markerId = intval($_REQUEST['markerId']); + $albid = intval($_REQUEST['albId']); + + $arralbpath = LinSql::getFullFilenameFromId($albid); + $albpath = implode('/',$arralbpath); + + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."plugins_maps_markers " . + "SET albid = '".LinSql::linAddslashes($albid)."', " . + "albpath = '".LinSql::linAddslashes($albpath)."' " . + "WHERE id='".LinSql::linAddslashes($markerId)."'"); + + echo '<responseCode>success</responseCode>'."\n"; + } + + echo '</root>'."\n"; + + break; + case 'loadAlbums': + + //error_log("LOADING ALBUMS",'','0'); + echo '{ "albums": [' . "\n"; + + $query = $GLOBALS['linpha']->db->Execute("SELECT DISTINCT P.parent_id " . + "FROM ".LIN_PREFIX."plugins_maps_image_geodata AS PM " . + "INNER JOIN ".LIN_PREFIX."photos P on PM.md5sum = P.md5sum " . + "WHERE gpslatituderef IS NOT NULL " . + "AND gpslatitude IS NOT NULL " . + "AND gpslongituderef IS NOT NULL " . + "AND gpslongitude IS NOT NULL "); + + echo '{"id": 0, "name": "'.i18n("All albums").'"},'."\n"; + + if( !$query ) + { + //echo "Error: Please enable EXIF GPS fields!"; + } + else + { + while($data = $query->FetchRow()) + { + echo '{"id": '.$data['parent_id'].', "name": "'. + htmlspecialchars( + implode( '/', LinSql::getFullFilenameFromId($data['parent_id']) ) + ,ENT_QUOTES).'"}'; + + // firefox ignores the last comma, but IE produces an error! grmpf + if( !$query->EOF ) { + echo ",\n"; + } else { + echo "\n"; + } + } + } + + echo '] }' . "\n"; + + break; + case 'loadImages': + +// error_log("LOADING IMAGES",'','0'); + if( !isset($_REQUEST['albId']) ) { + break; + } + + $albid = intval($_REQUEST['albId']); + + if($albid == 0) { + $filterStr = ""; + } else { + $filterStr = "AND P.parent_id = '".$albid."'"; + } + + $query = $GLOBALS['linpha']->db->Execute("SELECT P.id, P.parent_id, " . + "P.name, gpslatituderef, gpslatitude, gpslongituderef, gpslongitude " . + "FROM ".LIN_PREFIX."plugins_maps_image_geodata PM " . + "INNER JOIN ".LIN_PREFIX."photos P on PM.md5sum = P.md5sum " . + "WHERE gpslatituderef IS NOT NULL " . + "AND gpslatitude IS NOT NULL " . + "AND gpslongituderef IS NOT NULL " . + "AND gpslongitude IS NOT NULL " . + $filterStr); + + echo '{ "images": [' . "\n"; + + if( $query->EOF ) + { + error_log("Error: Please enable EXIF GPS fields!",'',0); + } + else + { + while($data = $query->FetchRow()) + { + $latlon = getExifLatLon($data); + echo '{"id": '.$data['id'].', "parent_id": '.$data['parent_id'].', ' . + '"type": "images", "text": "", "name": "'.htmlspecialchars( $data['name'] ,ENT_QUOTES).'", ' . + '"lat": '.$latlon['gpslatitude'].', "lon": '.$latlon['gpslongitude'] . + "}"; + + // firefox ignores the last comma, but IE produces an error! grmpf + if( !$query->EOF ) { + echo ",\n"; + } else { + echo "\n"; + } + } + } + + echo '] }' . "\n"; + + break; + } + } + + exit(); +} + + +$urlFull = LINPHA_LINK.'&linCat=maps'; + +$linpha->template->setModuleName('maps'); +//$linpha->template->overrideModule('head','map'); +$linpha->template->URL_full = $urlFull; +$linpha->template->URL_base = $urlFull; +$linpha->template->output['title'] = i18n("Maps"); +include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); + + function getExifLatLon(&$LatLon) { /*Array PJMT @@ -377,4 +396,4 @@ } return $return; } -?> \ No newline at end of file +?> Modified: trunk/linpha2/lib/plugins/maps/settings.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/settings.maps.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/plugins/maps/settings.maps.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -1,81 +1,90 @@ -<?php -/* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/** - * Settings for the admin section - * @package admin - */ - -if(!defined('LINPHA_DIR')) { exit(1); } - -echo '<a href="./?cat=permissions_plugins_maps_setMarkers">'.i18n("Set Edit Permissions For The Map Marker").'</a><br /><br />'; - - - -/** - * save settings - */ - if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') - { - $LinAdmin->saveConfig(Array( - 'plugins_maps_defaultMarkerZoom', - 'plugins_maps_mapType', - 'plugins_maps_google_key', - 'plugins_maps_markerThumbSize', - )); - } - -/** - * print options - */ -$LinAdmin->printAdminConfig( - 'text', - i18n("Default Zoom Level For Markers"), - 'plugins_maps_defaultMarkerZoom', - $LinAdmin->option_value_system['plugins_maps_defaultMarkerZoom'] -); -$LinAdmin->printAdminConfig( - 'text', - i18n("Marker Thumbnail Size"), - 'plugins_maps_markerThumbSize', - $LinAdmin->option_value_system['plugins_maps_markerThumbSize'] -); - -echo '<br /><br />'; - -$LinAdmin->printAdminConfig( - 'select', - i18n("Map Provider (Currently only google is implemented)"), - 'plugins_maps_mapType', - $LinAdmin->option_value_system['plugins_maps_mapType'], - array('options' => array('google','yahoo','openstreetmap')) -); -$LinAdmin->printAdminConfig( - 'text', - i18n("Key For Google Maps"), - 'plugins_maps_google_key', - $LinAdmin->option_value_system['plugins_maps_google_key'] -); -echo '<a href="http://code.google.com/apis/maps/signup.html">'.i18n("Sign Up for the Google Maps API Key").'</a><br />'; -echo i18n("The default key is only valid for the domain http://localhost").'<br /><br />'; - - - -?> \ No newline at end of file +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * Settings for the admin section + * @package admin + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +echo '<a href="./?cat=permissions_plugins_maps_setMarkers">'.i18n("Set Edit Permissions For The Map Marker").'</a><br /><br />'; + + + +/** + * save settings + */ + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + $LinAdmin->saveConfig(Array( + 'plugins_maps_defaultMarkerZoom', + 'plugins_maps_mapType', + 'plugins_maps_google_key', + 'plugins_maps_markerThumbSize', + 'plugins_maps_enable_geotagged', + + )); + } + +/** + * print options + */ +$LinAdmin->printAdminConfig( + 'text', + i18n("Default Zoom Level For Markers"), + 'plugins_maps_defaultMarkerZoom', + $LinAdmin->option_value_system['plugins_maps_defaultMarkerZoom'] +); +$LinAdmin->printAdminConfig( + 'text', + i18n("Marker Thumbnail Size"), + 'plugins_maps_markerThumbSize', + $LinAdmin->option_value_system['plugins_maps_markerThumbSize'] +); + +echo '<br /><br />'; + +$LinAdmin->printAdminConfig( + 'select', + i18n("Map Provider (Currently only google is implemented)"), + 'plugins_maps_mapType', + $LinAdmin->option_value_system['plugins_maps_mapType'], + array('options' => array('google','yahoo','openstreetmap')) +); +$LinAdmin->printAdminConfig( + 'text', + i18n("Key For Google Maps"), + 'plugins_maps_google_key', + $LinAdmin->option_value_system['plugins_maps_google_key'] +); + +echo '<a href="http://code.google.com/apis/maps/signup.html">'.i18n("Sign Up for the Google Maps API Key").'</a><br />'; +echo i18n("The default key is only valid for the domain http://localhost").'<br /><br />'; + +$LinAdmin->printAdminConfig( + 'radio', + i18n("Enable Support For Geotagged Images"), + 'plugins_maps_enable_geotagged', + $LinAdmin->option_value_system['plugins_maps_enable_geotagged'] +); + + +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2008-01-30 20:24:40
|
Revision: 4840 http://linpha.svn.sourceforge.net/linpha/?rev=4840&view=rev Author: bzrudi Date: 2008-01-30 12:24:33 -0800 (Wed, 30 Jan 2008) Log Message: ----------- "add support for other db than PG (hopefully)" Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.pjmt.class.php trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/lib/plugins/maps/sql/sql.data.php trunk/linpha2/lib/plugins/maps/sql/sql.mysql.php trunk/linpha2/lib/plugins/maps/sql/sql.oci8po.php trunk/linpha2/lib/plugins/maps/sql/sql.postgres.php trunk/linpha2/lib/plugins/maps/sql/sql.sqlite.php trunk/linpha2/templates/default/maps.head.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/ChangeLog 2008-01-30 20:24:33 UTC (rev 4840) @@ -5,6 +5,9 @@ expected performance issues and the mysql "big table" problem. It should currently work partially with PostgresDB, other DB will follow later. Needs "reset_database.php" to work and sys_import_use_exiftool=1 + * add support for PJMT + * add support for other db than PG (hopefully) + * still a lot to fix, so expect errors 2008-01-29 flo * updated to latest protoype 1.6.0.2 and scriptaculous 1.8.1 Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -951,12 +951,20 @@ if(is_array($dataArray)) { + /** + * Lower array data to make it compareable to $metaTags + */ + $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); + + //echo '<pre>', print_r($lowerDataArray), '</pre>'; + foreach($this->getDefaultMetaTags('gps') AS $key => $value) { - if(array_key_exists($value, $dataArray)) + if(array_key_exists($value, $lowerDataArray)) { + $str_columns .= str_replace("_", "-", $value) . ', '; - $str_values .= trim($dataArray[$value]).", "; + $str_values .= "'".trim($lowerDataArray[$value])."', "; } } /** Modified: trunk/linpha2/lib/classes/linpha.pjmt.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.pjmt.class.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/lib/classes/linpha.pjmt.class.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -74,24 +74,28 @@ case 2 : if(isset($exif_data[$ap[0]][$ap[1]]['Text Value'])) { - //echo "DATA:".$exif_data[$ap[0]][$ap[1]]['Text Value']."<br>"; + echo "DATA:".$exif_data[$ap[0]][$ap[1]]['Text Value']."<br>"; $dataArray[$value] = - "'" . LinSql :: linAddslashes(trim($exif_data[$ap[0]][$ap[1]]['Text Value'])) . "', "; + LinSql::linAddslashes(trim($exif_data[$ap[0]][$ap[1]]['Text Value'])); } break; case 5 : if(isset($exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value'])) { - //echo "DATA2".$exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value']; + echo "DATA2".$exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value']; $dataArray[$value] = - "'" . LinSql :: linAddslashes(trim($exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value'])) . "' "; + LinSql::linAddslashes(trim($exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value'])); } break; } } } - - return $dataArray; + if(is_array($dataArray)){ + return $dataArray; + }else { + return array(); + } + } } Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -240,7 +240,8 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT DISTINCT P.parent_id " . "FROM ".LIN_PREFIX."plugins_maps_image_geodata PM " . - "INNER JOIN ".LIN_PREFIX."photos P on PM.md5sum = P.md5sum " . + "INNER JOIN ".LIN_PREFIX."photos P ". + "ON PM.md5sum = P.md5sum " . "WHERE gpslatituderef IS NOT NULL " . "AND gpslatitude IS NOT NULL " . "AND gpslongituderef IS NOT NULL " . @@ -250,7 +251,8 @@ if( $query->EOF ) { - //echo "Error: Please enable EXIF GPS fields!"; + //echo "ERROR: Can't get data for albums"; + error_log("ERROR: Can't get data for albums",'',0); } else { @@ -291,7 +293,7 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT P.id, P.parent_id, " . "P.name, gpslatituderef, gpslatitude, gpslongituderef, gpslongitude " . - "FROM ".LIN_PREFIX."plugins_maps_image_geodata AS PM " . + "FROM ".LIN_PREFIX."plugins_maps_image_geodata PM " . "INNER JOIN ".LIN_PREFIX."photos P on PM.md5sum = P.md5sum " . "WHERE gpslatituderef IS NOT NULL " . "AND gpslatitude IS NOT NULL " . @@ -385,7 +387,7 @@ { foreach(array('gpslatitude','gpslongitude') as $value) { - error_log("USING PJMT",'','0'); + error_log("USING PJMT",'','0'); $arrHits = array(); // use '?' to be �non-greedy� (http://de.wikipedia.org/wiki/Regul%C3%A4rer_Ausdruck#Gieriges_Verhalten) Modified: trunk/linpha2/lib/plugins/maps/sql/sql.data.php =================================================================== --- trunk/linpha2/lib/plugins/maps/sql/sql.data.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/lib/plugins/maps/sql/sql.data.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -9,7 +9,7 @@ "VALUES ('plugins_maps_defaultMarkerZoom', '10', '0', '0')"; $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . - "VALUES ('plugins_maps_mapType', 'google', '0', '0')"; + "VALUES ('plugins_maps_mapType', '0', '0', '0')"; // google maps key for http://localhost $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . @@ -22,6 +22,9 @@ "VALUES ('plugins_maps_setMarkers', '')"; $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . - "VALUES ('plugins_maps_enable_geotagged', '0', '0', '0')"; + "VALUES ('plugins_maps_enable_geotagged', '0', '0', '0')"; + +$sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . + "VALUES ('plugins_maps_geotagged_autoimport', '1', '0', '0')"; ?> Modified: trunk/linpha2/lib/plugins/maps/sql/sql.mysql.php =================================================================== --- trunk/linpha2/lib/plugins/maps/sql/sql.mysql.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/lib/plugins/maps/sql/sql.mysql.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -10,5 +10,42 @@ "markerlon VARCHAR(255) NOT NULL default '', " . "markerzoom INT NOT NULL default '0', " . "PRIMARY KEY (id) )"; + +$sql_tables[] = "CREATE TABLE ".LIN_PREFIX."plugins_maps_image_geodata ( ". + "md5sum CHAR(32) NOT NULL default '', " . + "gpsversionid VARCHAR(255) DEFAULT '', " . + "gpslatituderef VARCHAR(255) DEFAULT '', " . + "gpslatitude VARCHAR(255) DEFAULT '', " . + "gpslongituderef VARCHAR(255) DEFAULT '', " . + "gpslongitude VARCHAR(255) DEFAULT '', " . + "gpsaltituderef VARCHAR(255) DEFAULT '', " . + "gpsaltitude VARCHAR(255) DEFAULT '', " . + "gpstimestamp VARCHAR(255) DEFAULT '', " . + "gpssatellites VARCHAR(255) DEFAULT '', " . + "gpsstatus VARCHAR(255) DEFAULT '', " . + "gpsmeasuremode VARCHAR(255) DEFAULT '', " . + "gpsdop VARCHAR(255) DEFAULT '', " . + "gpsspeedref VARCHAR(255) DEFAULT '', " . + "gpsspeed VARCHAR(255) DEFAULT '', " . + "gpstrackref VARCHAR(255) DEFAULT '', " . + "gpstrack VARCHAR(255) DEFAULT '', " . + "gpsimgdirectionref VARCHAR(255) DEFAULT '', " . + "gpsimgdirection VARCHAR(255) DEFAULT '', " . + "gpsmapdatum VARCHAR(255) DEFAULT '', " . + "gpsdestlatituderef VARCHAR(255) DEFAULT '', " . + "gpsdestlatitude VARCHAR(255) DEFAULT '', " . + "gpsdestlongituderef VARCHAR(255) DEFAULT '', " . + "gpsdestlongitude VARCHAR(255) DEFAULT '', " . + "gpsdestbearingref VARCHAR(255) DEFAULT '', " . + "gpsdestbearing VARCHAR(255) DEFAULT '', " . + "gpsdestdistanceref VARCHAR(255) DEFAULT '', " . + "gpsdestdistance VARCHAR(255) DEFAULT '', " . + "gpsprocessingmethod VARCHAR(255) DEFAULT '', " . + "gpsareainformation VARCHAR(255) DEFAULT '', " . + "gpsdatestamp VARCHAR(255) DEFAULT '', " . + "gpsdatetime VARCHAR(255) DEFAULT '', " . + "gpsposition VARCHAR(255) DEFAULT '', " . + "PRIMARY KEY (md5sum) )"; -?> \ No newline at end of file +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/lib/plugins/maps/sql/sql.oci8po.php =================================================================== --- trunk/linpha2/lib/plugins/maps/sql/sql.oci8po.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/lib/plugins/maps/sql/sql.oci8po.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -22,5 +22,44 @@ "BEGIN " . "SELECT ".LIN_PREFIX."plugins_maps_markers_seq.nextval INTO :new.id FROM DUAL; " . "END; "; - -?> \ No newline at end of file + + +$sql_tables[] = "CREATE TABLE ".LIN_PREFIX."plugins_maps_image_geodata ( ". + "md5sum CHAR(32) NOT NULL default '', " . + "gpsversionid VARCHAR(255) DEFAULT '', " . + "gpslatituderef VARCHAR(255) DEFAULT '', " . + "gpslatitude VARCHAR(255) DEFAULT '', " . + "gpslongituderef VARCHAR(255) DEFAULT '', " . + "gpslongitude VARCHAR(255) DEFAULT '', " . + "gpsaltituderef VARCHAR(255) DEFAULT '', " . + "gpsaltitude VARCHAR(255) DEFAULT '', " . + "gpstimestamp VARCHAR(255) DEFAULT '', " . + "gpssatellites VARCHAR(255) DEFAULT '', " . + "gpsstatus VARCHAR(255) DEFAULT '', " . + "gpsmeasuremode VARCHAR(255) DEFAULT '', " . + "gpsdop VARCHAR(255) DEFAULT '', " . + "gpsspeedref VARCHAR(255) DEFAULT '', " . + "gpsspeed VARCHAR(255) DEFAULT '', " . + "gpstrackref VARCHAR(255) DEFAULT '', " . + "gpstrack VARCHAR(255) DEFAULT '', " . + "gpsimgdirectionref VARCHAR(255) DEFAULT '', " . + "gpsimgdirection VARCHAR(255) DEFAULT '', " . + "gpsmapdatum VARCHAR(255) DEFAULT '', " . + "gpsdestlatituderef VARCHAR(255) DEFAULT '', " . + "gpsdestlatitude VARCHAR(255) DEFAULT '', " . + "gpsdestlongituderef VARCHAR(255) DEFAULT '', " . + "gpsdestlongitude VARCHAR(255) DEFAULT '', " . + "gpsdestbearingref VARCHAR(255) DEFAULT '', " . + "gpsdestbearing VARCHAR(255) DEFAULT '', " . + "gpsdestdistanceref VARCHAR(255) DEFAULT '', " . + "gpsdestdistance VARCHAR(255) DEFAULT '', " . + "gpsprocessingmethod VARCHAR(255) DEFAULT '', " . + "gpsareainformation VARCHAR(255) DEFAULT '', " . + "gpsdatestamp VARCHAR(255) DEFAULT '', " . + "gpsdatetime VARCHAR(255) DEFAULT '', " . + "gpsposition VARCHAR(255) DEFAULT '', " . + "PRIMARY KEY (md5sum) )"; + +/* vi: set ts=4 sw=4 sts=4 */ +?> + \ No newline at end of file Modified: trunk/linpha2/lib/plugins/maps/sql/sql.postgres.php =================================================================== --- trunk/linpha2/lib/plugins/maps/sql/sql.postgres.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/lib/plugins/maps/sql/sql.postgres.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -44,4 +44,8 @@ "gpsdatestamp VARCHAR(255) DEFAULT '', " . "gpsdatetime VARCHAR(255) DEFAULT '', " . "gpsposition VARCHAR(255) DEFAULT '' )"; + + +/* vi: set ts=4 sw=4 sts=4 */ ?> + Modified: trunk/linpha2/lib/plugins/maps/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/lib/plugins/maps/sql/sql.sqlite.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/lib/plugins/maps/sql/sql.sqlite.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -10,4 +10,40 @@ "markerlon VARCHAR(255) NOT NULL default '', " . "markerzoom INTEGER NOT NULL default '0' )"; -?> \ No newline at end of file +$sql_tables[] = "CREATE TABLE ".LIN_PREFIX."plugins_maps_image_geodata ( ". + "md5sum CHAR(32) PRIMARY KEY, " . + "gpsversionid VARCHAR(255) DEFAULT '', " . + "gpslatituderef VARCHAR(255) DEFAULT '', " . + "gpslatitude VARCHAR(255) DEFAULT '', " . + "gpslongituderef VARCHAR(255) DEFAULT '', " . + "gpslongitude VARCHAR(255) DEFAULT '', " . + "gpsaltituderef VARCHAR(255) DEFAULT '', " . + "gpsaltitude VARCHAR(255) DEFAULT '', " . + "gpstimestamp VARCHAR(255) DEFAULT '', " . + "gpssatellites VARCHAR(255) DEFAULT '', " . + "gpsstatus VARCHAR(255) DEFAULT '', " . + "gpsmeasuremode VARCHAR(255) DEFAULT '', " . + "gpsdop VARCHAR(255) DEFAULT '', " . + "gpsspeedref VARCHAR(255) DEFAULT '', " . + "gpsspeed VARCHAR(255) DEFAULT '', " . + "gpstrackref VARCHAR(255) DEFAULT '', " . + "gpstrack VARCHAR(255) DEFAULT '', " . + "gpsimgdirectionref VARCHAR(255) DEFAULT '', " . + "gpsimgdirection VARCHAR(255) DEFAULT '', " . + "gpsmapdatum VARCHAR(255) DEFAULT '', " . + "gpsdestlatituderef VARCHAR(255) DEFAULT '', " . + "gpsdestlatitude VARCHAR(255) DEFAULT '', " . + "gpsdestlongituderef VARCHAR(255) DEFAULT '', " . + "gpsdestlongitude VARCHAR(255) DEFAULT '', " . + "gpsdestbearingref VARCHAR(255) DEFAULT '', " . + "gpsdestbearing VARCHAR(255) DEFAULT '', " . + "gpsdestdistanceref VARCHAR(255) DEFAULT '', " . + "gpsdestdistance VARCHAR(255) DEFAULT '', " . + "gpsprocessingmethod VARCHAR(255) DEFAULT '', " . + "gpsareainformation VARCHAR(255) DEFAULT '', " . + "gpsdatestamp VARCHAR(255) DEFAULT '', " . + "gpsdatetime VARCHAR(255) DEFAULT '', " . + "gpsposition VARCHAR(255) DEFAULT '' )"; + +/* vi: set ts=4 sw=4 sts=4 */ +?> Modified: trunk/linpha2/templates/default/maps.head.php =================================================================== --- trunk/linpha2/templates/default/maps.head.php 2008-01-30 18:00:37 UTC (rev 4839) +++ trunk/linpha2/templates/default/maps.head.php 2008-01-30 20:24:33 UTC (rev 4840) @@ -1,47 +1,47 @@ -<script type="text/javascript" language="javascript" src="<?php echo LINPHA_CLIENT; ?>/lib/js/scriptaculous.js?load=effects,builder,dragdrop"></script> -<script language="JavaScript" type="text/javascript"> -var xmlUrl = '<?php echo linConvertAmp($linTpl->URL_base); ?>'; -var imageSrc = '<?php echo LINPHA_CLIENT.'/get_image.php?linId='; ?>'; -var thumbSrc = '<?php echo LINPHA_CLIENT.'/get_thumb.php?linId='; ?>'; -var maxImageWidth = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_width']; ?>; -var maxImageHeight = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_height']; ?>; -var maxThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; ?>; -var displayThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>; - -var linMapsDefaultMarkerZoom = <?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; ?>; -var linMapsMarkerThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_markerThumbSize']; ?>; -</script> - -<?php -if( $GLOBALS['linpha']->sql->config->value['plugins_maps_mapType'] == 'google' ) -{ - ?> - <script type="text/javascript" src="http://www.google.com/jsapi?key=<?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_google_key']; ?>"></script> - <script type="text/javascript" language="JavaScript" src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/maps/class.googlemaps.js"></script> - <?php - - /** - * @todo - * google recommends using this kind of html header: - * <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> - * but without strict mode we need this css stuff to get polylines also working - * http://www.google.com/apis/maps/documentation/#XHTML_and_VML - ?> - <style type="text/css"> - v\:* { - behavior:url(#default#VML); - } - </style> - <?php - */ -} -elseif( $linTpl->output['mapType'] == 'xyz' ) -{ - ?> - <script type="text/javascript" language="JavaScript" src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/maps/class.xyz.js"></script> - <?php -} -?> -<script type="text/javascript" language="JavaScript" src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/maps/LinMaps.js"></script> +<script type="text/javascript" language="javascript" src="<?php echo LINPHA_CLIENT; ?>/lib/js/scriptaculous.js?load=effects,builder,dragdrop"></script> +<script language="JavaScript" type="text/javascript"> +var xmlUrl = '<?php echo linConvertAmp($linTpl->URL_base); ?>'; +var imageSrc = '<?php echo LINPHA_CLIENT.'/get_image.php?linId='; ?>'; +var thumbSrc = '<?php echo LINPHA_CLIENT.'/get_thumb.php?linId='; ?>'; +var maxImageWidth = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_width']; ?>; +var maxImageHeight = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_height']; ?>; +var maxThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; ?>; +var displayThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>; + +var linMapsDefaultMarkerZoom = <?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; ?>; +var linMapsMarkerThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_markerThumbSize']; ?>; +</script> + +<?php +if( $GLOBALS['linpha']->sql->config->value['plugins_maps_mapType'] == '0' ) //0=google +{ + ?> + <script type="text/javascript" src="http://www.google.com/jsapi?key=<?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_google_key']; ?>"></script> + <script type="text/javascript" language="JavaScript" src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/maps/class.googlemaps.js"></script> + <?php + + /** + * @todo + * google recommends using this kind of html header: + * <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> + * but without strict mode we need this css stuff to get polylines also working + * http://www.google.com/apis/maps/documentation/#XHTML_and_VML + ?> + <style type="text/css"> + v\:* { + behavior:url(#default#VML); + } + </style> + <?php + */ +} +elseif( $linTpl->output['mapType'] == 'xyz' ) +{ + ?> + <script type="text/javascript" language="JavaScript" src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/maps/class.xyz.js"></script> + <?php +} +?> +<script type="text/javascript" language="JavaScript" src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/maps/LinMaps.js"></script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2008-01-30 21:09:04
|
Revision: 4841 http://linpha.svn.sourceforge.net/linpha/?rev=4841&view=rev Author: fangehrn Date: 2008-01-30 13:08:44 -0800 (Wed, 30 Jan 2008) Log Message: ----------- 2008-01-30 flo * installer - improved layout moved title down because of banner blindness - improved error handling in rm_rf() * linpha.filesys.class.php - improved error handling also in the same function here Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/header_html.php trunk/linpha2/install/layout.css trunk/linpha2/install/lib.install.php trunk/linpha2/install/look.css trunk/linpha2/install/step2_requirements.php trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step6_selectdatabase.php trunk/linpha2/lib/classes/linpha.filesys.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/ChangeLog 2008-01-30 21:08:44 UTC (rev 4841) @@ -1,3 +1,13 @@ + +2008-01-30 flo + * installer + - improved layout + moved title down because of banner blindness + - improved error handling in rm_rf() + + * linpha.filesys.class.php + - improved error handling also in the same function here + 2008-01-30 bzrudi * Split out GPS meta/geodata from meta_exif into a seperate relation within the maps plugin. The relation is created when admin enables the maps plugin Modified: trunk/linpha2/install/header_html.php =================================================================== --- trunk/linpha2/install/header_html.php 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/install/header_html.php 2008-01-30 21:08:44 UTC (rev 4841) @@ -23,132 +23,102 @@ * linpha installer * @package Installation */ + +$end = count($files)-1; +$step = $key+1; +$finalstep = $end+1; + +$strStep = i18n_install("Step %d of %d"); +$strStep = sprintf($strStep, $step, $finalstep); + +switch($step) +{ + case 1: + $icon = './graphics/start.png'; + $title = i18n_install("Welcome To LinPHA2 Installation Wizzard"); + break; + + case 2: + $icon = './graphics/gnu.png'; + $title = i18n_install("Accept The GNU General Public License GPL"); + break; + + case 3: + $icon = './graphics/important.png'; + $title = i18n_install("Checking For Required Software"); + break; + + case 4: + $icon = './graphics/phppg.png'; + $title = i18n_install("Select Type Of Database To Use"); + break; + + case 5: + $icon = './graphics/directories.png'; + $title = i18n_install("Define LinPHA Storage And Album Directories"); + break; + + case 6: + $icon = './graphics/login.png'; + $title = i18n_install("Directories Testing And Database Login"); + break; + + case 7: + $icon = './graphics/phppg.png'; + $title = i18n_install("Connection Test And Database Selection"); + break; + + case 8: + $icon = './graphics/phppg.png'; + $title = i18n_install("Database Table Prefix Selection"); + break; + + case 9: + $icon = './graphics/phppg.png'; + $title = i18n_install("Running Database Tests And Checking Permissions"); + break; + + case 10: + $icon = './graphics/createtables.png'; + $title = i18n_install("Creating Database Tables And Writing Config Files"); + break; + + case 11: + $icon = './graphics/settings.png'; + $title = i18n_install("Setup LinPHA Admin And Initial Settings"); + break; + + case 12: + $icon = './graphics/finish.png'; + $title = i18n_install("Finishing LinPHA2 Setup"); + break; +} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html lang="de"> +<html> <head> <title><?php echo i18n_install("LinPHA2 Install Wizzard"); ?></title> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> -<link rel="stylesheet" type="text/css" href="layout.css"> -<link rel="stylesheet" type="text/css" href="look.css"> +<link rel="stylesheet" type="text/css" href="layout.css" /> +<link rel="stylesheet" type="text/css" href="look.css" /> </head> <body> <div class="main"> -<div class="header"> + <div class="header"> + <div class="header_left"> + <img class='header_icons' src='./graphics/start.png' /> + </div> + <div class="header_right"> + <h1 class="header_title"><?php echo i18n_install("Linpha 2 Installation Wizzard"); ?></h1> + <p class='header_subinfo'><?php echo $strStep; ?></p> + </div> + </div> + <div class="leftside"> <?php -$end = count($files)-1; -$step = $key+1; -$finalstep = $end+1; -switch($step) -{ - case '1': - - echo "<img class='header_icons' src='./graphics/start.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Welcome To LinPHA2 Installation Wizzard"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '2': - echo "<img class='header_icons' src='./graphics/gnu.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Accept The GNU General Public License GPL"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '3': - echo "<img class='header_icons' src='./graphics/important.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Checking For Required Software"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '4': - echo "<img class='header_icons' src='./graphics/phppg.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Select Type Of Database To Use"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '5': - echo "<img class='header_icons' src='./graphics/directories.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Define LinPHA Storage And Album Directories"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '6': - echo "<img class='header_icons' src='./graphics/login.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Directories Testing And Database Login"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '7': - echo "<img class='header_icons' src='./graphics/phppg.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Connection Test And Database Selection"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '8': - echo "<img class='header_icons' src='./graphics/phppg.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Database Table Prefix Selection"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '9': - echo "<img class='header_icons' src='./graphics/phppg.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Running Database Tests And Checking Permissions"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '10': - echo "<img class='header_icons' src='./graphics/createtables.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Creating Database Tables And Writing Config Files"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '11': - echo "<img class='header_icons' src='./graphics/settings.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Setup LinPHA Admin And Initial Settings"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - case '12': - echo "<img class='header_icons' src='./graphics/finish.png'>"; - echo "<p class='header_info'>"; - echo i18n_install("Finishing LinPHA2 Setup"); - echo "</p><p class='header_subinfo'>"; - echo i18n_install("Step $step of $finalstep"); - echo "</p>"; - break; - -} -?> -</div> -<div class="leftside"> -<?php - for($i = 0; $i <= $end; $i++ ) { if($i == $key) @@ -190,7 +160,17 @@ </div> <div class="rightside"> - + + <div class="title_left"> + <img src="<?php echo $icon; ?>" /> + </div> + <div class="header_right"> + <br /> + <h1 class="title"><?php echo $title; ?></h1> + </div> + <div style="clear: both"></div> + <br /> + <?php if($show_next_button) Modified: trunk/linpha2/install/layout.css =================================================================== --- trunk/linpha2/install/layout.css 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/install/layout.css 2008-01-30 21:08:44 UTC (rev 4841) @@ -27,55 +27,60 @@ margin-right: auto; } -.header { +div.header { background-image: url('./graphics/header_bg.jpg'); - position: absolute; - width: 780px; height: 80px; - float: left; border: 1px solid #000000; margin: 0px; padding: 0px; - } +} -.header_icons { -float: left; - position: absolute; - margin-top: 8px; - margin-left: 45px; -} +div.header_left { + float: left; + width: 65px; + padding: 7px; +} -.header_info { - position: absolute; - margin-top: 8px; - margin-left: 160px; -} +div.header_right { + float: left; +} -.header_subinfo { - position: absolute; - margin-top: 45px; - margin-left: 160px; +h1.header_title { + margin-top: 3px; + margin-bottom: 3px; } +p.header_subinfo { +} + + +div.title_left { + float: left; + width: 65px; + padding: 0px; + margin-right: 5px; +} + + .leftside { - position: absolute; + position: relative; width: 150px; height: 430px; float: left; text-align: center; - margin-top: 82px; + /*margin-top: 82px;*/ padding: 5px; } .rightside { - position: absolute; - width: 610px; + position: relative; + width: 607px; min-height: 427px; height: expression( "427px" ); /* ie hack */ float: left; text-align: left; - margin-top: 82px; - margin-left: 160px; + /*margin-top: 82px;*/ + /*margin-left: 160px;*/ padding: 5px; padding-top: 8px; } Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/install/lib.install.php 2008-01-30 21:08:44 UTC (rev 4841) @@ -74,20 +74,22 @@ */ function installRm_rf($path,$followLinks=false) { - $dir = opendir($path) ; - while (false !== ($entry = readdir($dir))) - { - if ( is_file( "$path/$entry" ) || ((!$followLinks) && is_link("$path/$entry")) ) - { - unlink( "$path/$entry" ); - } - elseif ( is_dir( "$path/$entry" ) && $entry!='.' && $entry!='..' ) - { - installRm_rf( "$path/$entry" ); - } - } - closedir($dir) ; - return @rmdir($path); + $dir = @opendir($path); + if ($dir) { + while (false !== ($entry = @readdir($dir))) + { + if ( is_file( "$path/$entry" ) || ((!$followLinks) && is_link("$path/$entry")) ) + { + unlink( "$path/$entry" ); + } + elseif ( is_dir( "$path/$entry" ) && $entry!='.' && $entry!='..' ) + { + installRm_rf( "$path/$entry" ); + } + } + @closedir($dir) ; + } + return @rmdir($path); } /** @@ -330,7 +332,7 @@ { try { - $init_ok = true; + $init_ok = true; echo "<h1>".i18n_install("Checking Directory Permissions")."</h1><hr>"; /** @@ -348,20 +350,19 @@ { echo warning_msg(); //echo '<br /> ('.$_SESSION['album_dir'].' => '.installLinRealpath( $dirs['album'] ).')'; - echo "<br />".i18n_install("Album Directory Not Writable. Some Features May Not Work")."<br />"; + echo "<br /><strong>".i18n_install("Album Directory Not Writable. Some Features May Not Work")."</strong><br />"; } } else { - throw new Exception(failed_msg()."<br />".$_SESSION['album_dir']."<br />".i18n_install("No Valid Directory Found!")); + throw new Exception(failed_msg()."<br />".$_SESSION['album_dir']."<br /><strong>".i18n_install("No Valid Directory Found!")."</strong>"); } //echo "<br />"; //echo i18n_install("Creating Required Directories...").' '; - $array = array('sql','cache','tmp'); - foreach($array AS $value) + foreach( array('sql','cache','tmp') as $value) { echo "<br />".i18n_install("Checking Directory:")." ".$value."..."." "; @@ -371,7 +372,7 @@ * oh oh, pay attention, only try to delete the folder on default values! * if the users choose wrongly the albums folder, all images would be deleted.!!!! */ - if( $_SESSION[$value.'_dir'] == 'var/'.$value) + if( $_SESSION[$value.'_dir'] == $_SESSION['default_'.$value.'_dir']) { //echo warning_msg(); //echo "<br />".i18n_install("Directory Already Exists - Trying To Delete...").' '; @@ -381,12 +382,12 @@ } else { - throw new Exception(failed_msg()."<br />".i18n_install("Please Delete Folder Manually!")); + throw new Exception(failed_msg()."<br /><strong>".i18n_install("Please Delete Folder Manually!")."</strong>"); } } else { - throw new Exception(failed_msg()."<br />".i18n_install("Directory Allready Exists, Please Delete Folder Manually!")); + throw new Exception(failed_msg()."<br /><strong>".i18n_install("Directory Allready Exists, Please Delete Folder Manually!")."</strong>"); } } Modified: trunk/linpha2/install/look.css =================================================================== --- trunk/linpha2/install/look.css 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/install/look.css 2008-01-30 21:08:44 UTC (rev 4841) @@ -1,16 +1,17 @@ body { - font-size: 10pt; + font-size: 0.7em; color: #000000; text-decoration: none; + font-family: Verdana, Arial, Helvetica, sans-serif; } h1 { - font-size: 14pt; + font-size: 1.3em; font-weight: bold; } h2 { - font-size: 12pt; + font-size: 1.2em; font-weight: bold; } @@ -31,25 +32,35 @@ .main { } -.header_info { - font-size: 14pt; - font-weight: bold; +img.header_icon { +} + +h1.header_title { + font-size: 2em; + font-weight: bold; color: #CCCCCC; } -.header_subinfo { - font-size: 10pt; - font-weight: bold; +p.header_subinfo { + font-size: 1em; + font-weight: bold; color: #CCCCCC; } + + +h1.title { + font-size: 1.5em; +} + + .leftside { - background: #e2e2e2; + background: #F3F3F3; /*#e2e2e2;*/ border-right: 0px; } .rightside { - background: #eeeeee; + background: #F3F3F3; /*#eeeeee;*/ } .button { @@ -63,13 +74,15 @@ } .leftsidebox { - background: #cccccc; - color: #000033; + background: #DBEAF5; /*#ffffff;*/ + color: #000000; + font-weight: bold; } .leftsideboxactive { - background: #ffffff; - color: #0000ff; + background: #335DB3; /*#cccccc;*/ + color: #DBEAF5; /*#000033;*/ + font-weight: bold; } .box2 { Modified: trunk/linpha2/install/step2_requirements.php =================================================================== --- trunk/linpha2/install/step2_requirements.php 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/install/step2_requirements.php 2008-01-30 21:08:44 UTC (rev 4841) @@ -418,7 +418,7 @@ print_line_middle( i18n_install("Yes") ); print_line_right(success_msg()); print_line_info( - i18n_install("The /albums folder is protected from outside."). + i18n_install("The /albums folder is protected from outside.").' '. i18n_install("Please see <a href=\"http://linpha.sourceforge.net/wiki/index.php/Secure_LinPHA\">here</a> for more details.") ); } Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/install/step4_selectdirectories.php 2008-01-30 21:08:44 UTC (rev 4841) @@ -26,10 +26,16 @@ include_once(LINPHA_DIR.'/lib/include/common.php'); include_once(LINPHA_DIR.'/install/header.php'); +if (!isset($_SESSION['default_sql_dir']) ) { // save for later use in initInitialDirectories() + $_SESSION['default_sql_dir'] = 'var/sql-'.random_password(10); + $_SESSION['default_cache_dir'] = 'var/cache-'.random_password(10); + $_SESSION['default_tmp_dir'] = 'var/tmp-'.random_password(10); +} + $album_dir = (isset($_SESSION['album_dir']) ? $_SESSION['album_dir'] : 'albums'); -$sql_dir = (isset($_SESSION['sql_dir']) ? $_SESSION['sql_dir'] : 'var/sql-'.random_password(10)); -$cache_dir = (isset($_SESSION['cache_dir']) ? $_SESSION['cache_dir'] : 'var/cache-'.random_password(10)); -$tmp_dir = (isset($_SESSION['tmp_dir']) ? $_SESSION['tmp_dir'] : 'var/tmp-'.random_password(10)); +$sql_dir = (isset($_SESSION['sql_dir']) ? $_SESSION['sql_dir'] : $_SESSION['default_sql_dir']); +$cache_dir = (isset($_SESSION['cache_dir']) ? $_SESSION['cache_dir'] : $_SESSION['default_cache_dir']); +$tmp_dir = (isset($_SESSION['tmp_dir']) ? $_SESSION['tmp_dir'] : $_SESSION['default_tmp_dir']); /** @@ -64,9 +70,12 @@ include_once(LINPHA_DIR.'/install/header_html.php'); ?> +<div class="boxalign"> +<?php +echo '<b>'.i18n_install("For maximum security place all these folders outside of the www root!") . + '</b><br />('.i18n_install("Relative or absolute paths allowed.").')<br /><br />'; -<div class="boxalign"> -<?php echo i18n_install("Album Directory").":"; ?> +echo i18n_install("Album Directory").":"; ?> <input class="boxalignelement" type="text" id="check01" onKeyup="checkForm()" name="album_dir" size="30" value="<?php echo $album_dir; ?>"> </div> @@ -74,7 +83,10 @@ <br /><br /> <br /> -<h2 style="color: red;"><?php echo i18n_install("Note: For security reasons folders were named random!"); ?></h2><hr> +<h2 style="color: red;"><?php +echo i18n_install("Warning: All directories below will be deleted if they exist!").'<br />'; +?></h2> +<hr /> <br /> <div class="boxalign"> @@ -100,6 +112,12 @@ </div> (-> <?php echo installLinRealpath( installGetFullPath($tmp_dir) ); ?>) <br /><br /> + +<?php +echo i18n_install("For security reasons folders were named random."); +?> + + <input type="hidden" name="cmd_step4" value="save"> Modified: trunk/linpha2/install/step6_selectdatabase.php =================================================================== --- trunk/linpha2/install/step6_selectdatabase.php 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/install/step6_selectdatabase.php 2008-01-30 21:08:44 UTC (rev 4841) @@ -129,7 +129,7 @@ <hr> <br /> <?php -if($_SESSION['allowed_to_create_db'] == true) +if ($_SESSION['allowed_to_create_db'] == true) { /** * search a valid database name (which doesn't already exists) @@ -169,30 +169,45 @@ $checked_dontcreate = ''; } - echo i18n_install("Create A New Database (Recommended)"); - ?> - <br /> + echo i18n_install("Create A New Database (Recommended)").'<br />'; +} + +if ($_SESSION['allowed_to_create_db'] == true && isset($databases)) +{ + ?> + <label for="radio_db1"> <input type="radio" id="radio_db1" name="create_database" value="create"<?php echo $checked_create; ?>> + <?php +} - <?php echo i18n_install("New Database Name").": "; ?> +if ($_SESSION['allowed_to_create_db'] == true) +{ + echo i18n_install("New Database Name").": "; ?> + </label> <input type="text" name="sql_dbname_create" value="<?php echo isset($_SESSION['sql_dbname']) ? $_SESSION['sql_dbname'] : $dbname ; ?>" onKeyup="document.getElementById('radio_db1').checked = true;"> <br /><br /> - <?php echo i18n_install("Or").","; ?><br /> + <?php +} + +if ($_SESSION['allowed_to_create_db'] == true && isset($databases)) +{ +?> + <label for="radio_db2"><?php echo i18n_install("Or").","; ?><br /> <input type="radio" id="radio_db2" name="create_database" value="false"<?php echo $checked_dontcreate; ?>> <?php } -if(isset($databases)) +if (isset($databases)) { echo i18n_install("Install Into Existing Database:").' '; ?> - + </label> <select name="sql_dbname_installinto"<?php if($_SESSION['allowed_to_create_db'] == true) { Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2008-01-30 20:24:33 UTC (rev 4840) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2008-01-30 21:08:44 UTC (rev 4841) @@ -65,19 +65,22 @@ } else { - $dir = opendir($path) ; - while (false !== ($entry = readdir($dir))) + $dir = @opendir($path); + if ($dir) { - if ( is_file( "$path/$entry" ) || ((!$followLinks) && is_link("$path/$entry")) ) - { - @unlink( "$path/$entry" ); - } - elseif ( is_dir( "$path/$entry" ) && $entry!='.' && $entry!='..' ) - { - LinFilesys::rm_rf( "$path/$entry" ); - } - } - closedir($dir) ; + while (false !== ($entry = @readdir($dir))) + { + if ( is_file( "$path/$entry" ) || ((!$followLinks) && is_link("$path/$entry")) ) + { + @unlink( "$path/$entry" ); + } + elseif ( is_dir( "$path/$entry" ) && $entry!='.' && $entry!='..' ) + { + LinFilesys::rm_rf( "$path/$entry" ); + } + } + @closedir($dir); + } return @rmdir($path); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2008-01-31 12:36:16
|
Revision: 4842 http://linpha.svn.sourceforge.net/linpha/?rev=4842&view=rev Author: bzrudi Date: 2008-01-31 04:27:25 -0800 (Thu, 31 Jan 2008) Log Message: ----------- more improvements in maps plugin Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.pjmt.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/plugins/maps/module.maps.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-30 21:08:44 UTC (rev 4841) +++ trunk/linpha2/ChangeLog 2008-01-31 12:27:25 UTC (rev 4842) @@ -1,4 +1,12 @@ - +2008-01-31 bzrudi + * Maps plugin + - all DBs should work now (untestet) + - PJMT and exiftool should work now + - add admin options to enable/disable geodata and autoimport + - code cleanups + - still work in progress + - btw - installer looks fine + 2008-01-30 flo * installer - improved layout Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-30 21:08:44 UTC (rev 4841) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-31 12:27:25 UTC (rev 4842) @@ -173,14 +173,13 @@ return $metaArray; } - /** * Save all MetaData to database * @param string $filename filename to parse for MetaData * @param string $md5sum md5sum of file * @param string $tag save EXIF, IPTC or XMP MetaData */ - function saveMetaData($filename, $md5sum, $tag) + public function saveMetaData($filename, $md5sum, $tag) { $dataArray = LinExifTool::readMetaDataFromFile($tag, $filename); @@ -325,7 +324,6 @@ } } - /** * Define array with allowed IPTC/XMP tags and human readable translation * @param none Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2008-01-30 21:08:44 UTC (rev 4841) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2008-01-31 12:27:25 UTC (rev 4842) @@ -1,257 +1,257 @@ <?php /* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /** * This class provides a couple methods for image manipulation/creation * @package Image */ - + if(!defined('LINPHA_DIR')) { exit(1); } class LinImage { -public $error_msg; -public $output_file; + public $error_msg; + public $output_file; -public $photo_id, $cached_id; -public $isCached; -public $mode; -public $img_type, $org_width, $org_height, $rotate; + public $photo_id, $cached_id; + public $isCached; + public $mode; + public $img_type, $org_width, $org_height, $rotate; -private $src_file; -private $img_width, $img_height; -private $img_quality; -private $imageTool; + private $src_file; + private $img_width, $img_height; + private $img_quality; + private $imageTool; -/** - * constructor - */ -function __construct() -{ -} + /** + * constructor + */ + function __construct() + { + } -function setFileInformation() -{ - /** - * check for valid id - * and get img_type and rotate informations - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type, rotate, width, height " . + function setFileInformation() + { + /** + * check for valid id + * and get img_type and rotate informations + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type, rotate, width, height " . "FROM ".LIN_PREFIX."photos " . "WHERE id = '".LinSql::linAddslashes( $this->photo_id )."'"); - if( $query->EOF ) // not a single value returned - { - $this->error_msg = "wrong id supplied!"; - return false; - } - - $data = $query->FetchRow(); - - if( ! LinSql::photoIsAllowed( $data['id'] ) ) - { - $this->error_msg = "not permitted!"; - return false; - } - - if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['img_type'] ) ) - { - $this->error_msg = "only images possible!"; - return false; - } + if( $query->EOF ) // not a single value returned + { + $this->error_msg = "wrong id supplied!"; + return false; + } - /** - * checke force parameter - */ - if( isset($_GET['force'] ) ) { - $this->force = true; - } else { - $this->force = false; - } + $data = $query->FetchRow(); - /** - * set additional informations - */ - $this->rotate = $data['rotate']; - $this->img_type = $data['img_type']; - $this->org_width = $data['width']; - $this->org_height = $data['height']; - $this->setCachedInfos(); - - /** - * check if file already exists OR if forced - */ - if( file_exists( $this->output_file ) AND !$this->force ) - { - $this->isCached = true; - } - else // !file_exists() OR $this->force - { - $this->isCached = false; + if( ! LinSql::photoIsAllowed( $data['id'] ) ) + { + $this->error_msg = "not permitted!"; + return false; + } - /** - * create subfolder if needed - */ - if( ! file_exists( dirname($this->output_file) ) ) - { - if( ! @mkdir( dirname($this->output_file) ) ) - { - $this->error_msg = "Cannot create folder ".dirname($this->output_file)." check permissions!"; - return false; - } - } + if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['img_type'] ) ) + { + $this->error_msg = "only images possible!"; + return false; + } - /** - * use imagemagick or gdlib - */ - if($GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) - { - include_once(LINPHA_DIR.'/lib/classes/image/linpha.imagemagick.class.php'); - - $this->imageTool = new LinImageMagick(); - $this->imageTool->imagemagickPath = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path']; - } - else - { - include_once(LINPHA_DIR.'/lib/classes/image/linpha.gdlib.class.php'); - - $this->imageTool = new LinGDLib(); - $this->imageTool->imgType = $this->img_type; - } + /** + * checke force parameter + */ + if( isset($_GET['force'] ) ) { + $this->force = true; + } else { + $this->force = false; + } - $this->imageTool->imgQuality = $this->img_quality; - $this->imageTool->orgWidth = $this->org_width; - $this->imageTool->orgHeight = $this->org_height; - } - - return true; -} + /** + * set additional informations + */ + $this->rotate = $data['rotate']; + $this->img_type = $data['img_type']; + $this->org_width = $data['width']; + $this->org_height = $data['height']; + $this->setCachedInfos(); -/** - * set cached_id and output_file - * in image mode set also rotate, watermark, quality, ... - * and add an empty entry in the cache database - */ -function setCachedInfos() -{ - if($this->mode == 'thumb') - { - $this->cached_id = $this->photo_id; + /** + * check if file already exists OR if forced + */ + if( file_exists( $this->output_file ) AND !$this->force ) + { + $this->isCached = true; + } + else // !file_exists() OR $this->force + { + $this->isCached = false; - $this->output_file = LinImage::getCachePath($this->mode,$this->cached_id,$this->img_type); - } - elseif($this->mode == 'img') - { - /** - * check additional settings - */ - /** - * max_width and max_height - */ - if(isset($this->overrideSettings['max_width']) && isset($this->overrideSettings['max_height'])) - { - $this->max_width = $this->overrideSettings['max_width']; - $this->max_height = $this->overrideSettings['max_height']; - } - else - { - $this->max_width = $GLOBALS['linpha']->sql->config->value['sys_style_image_width']; - $this->max_height = $GLOBALS['linpha']->sql->config->value['sys_style_image_height']; - } - - /** - * update rotate (printing, ...) if applicable (no else() !! ) - * the rotate value from the database is read earlier - */ - if(isset($this->overrideSettings['rotate'])) - { - $this->rotate = $this->overrideSettings['rotate']; - } - - /** - * watermark (true|false) - */ - if(isset($this->overrideSettings['watermark'])) - { - $this->watermark = $this->overrideSettings['watermark']; - } - else - { - /** - * @todo place need_watermark() here - */ - $this->watermark = 0; - } - - /** - * quality - */ - if(isset($this->overrideSettings['quality'])) - { - $this->img_quality = intval($this->overrideSettings['quality']); // oh, do intval() for security, comes from $_GET and will be included in exec() commands - } - else - { - $this->img_quality = intval($GLOBALS['linpha']->sql->config->value['sys_style_image_quality']); - } + /** + * create subfolder if needed + */ + if( ! file_exists( dirname($this->output_file) ) ) + { + if( ! @mkdir( dirname($this->output_file) ) ) + { + $this->error_msg = "Cannot create folder ".dirname($this->output_file)." check permissions!"; + return false; + } + } - /** - * in image mode this is done earlier, because we need already org_width and org_height - * to determine if image is cached or not - * in thumb mode this can only be done later, because there are also folders and videos - */ - if( ! $this->setSourceFileInformation() ) - { - return false; - } + /** + * use imagemagick or gdlib + */ + if($GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) + { + include_once(LINPHA_DIR.'/lib/classes/image/linpha.imagemagick.class.php'); + + $this->imageTool = new LinImageMagick(); + $this->imageTool->imagemagickPath = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path']; + } + else + { + include_once(LINPHA_DIR.'/lib/classes/image/linpha.gdlib.class.php'); + + $this->imageTool = new LinGDLib(); + $this->imageTool->imgType = $this->img_type; + } - /** - * this results in fliped img_width and img_height for later photos_cache - * compare, we take care of it below... - */ - $array = $this->scaleToFit($this->org_width,$this->org_height,$this->max_width,$this->max_height); - $this->img_width = $array['w']; - $this->img_height = $array['h']; + $this->imageTool->imgQuality = $this->img_quality; + $this->imageTool->orgWidth = $this->org_width; + $this->imageTool->orgHeight = $this->org_height; + } - /** - * check if entry in linpha_photos_cache exists - */ - /** - * Take care of fliped img_width and img_height, or it will result in a - * cache hit miss (scaleToFit() (above) takes the width and height from - * photos table, where values are wrong for images which need rotate) - */ - $rot = $GLOBALS['linpha']->db->GetRow("SELECT is_rotated, img_width, img_height " . + return true; + } + + /** + * set cached_id and output_file + * in image mode set also rotate, watermark, quality, ... + * and add an empty entry in the cache database + */ + function setCachedInfos() + { + if($this->mode == 'thumb') + { + $this->cached_id = $this->photo_id; + + $this->output_file = LinImage::getCachePath($this->mode,$this->cached_id,$this->img_type); + } + elseif($this->mode == 'img') + { + /** + * check additional settings + */ + /** + * max_width and max_height + */ + if(isset($this->overrideSettings['max_width']) && isset($this->overrideSettings['max_height'])) + { + $this->max_width = $this->overrideSettings['max_width']; + $this->max_height = $this->overrideSettings['max_height']; + } + else + { + $this->max_width = $GLOBALS['linpha']->sql->config->value['sys_style_image_width']; + $this->max_height = $GLOBALS['linpha']->sql->config->value['sys_style_image_height']; + } + + /** + * update rotate (printing, ...) if applicable (no else() !! ) + * the rotate value from the database is read earlier + */ + if(isset($this->overrideSettings['rotate'])) + { + $this->rotate = $this->overrideSettings['rotate']; + } + + /** + * watermark (true|false) + */ + if(isset($this->overrideSettings['watermark'])) + { + $this->watermark = $this->overrideSettings['watermark']; + } + else + { + /** + * @todo place need_watermark() here + */ + $this->watermark = 0; + } + + /** + * quality + */ + if(isset($this->overrideSettings['quality'])) + { + $this->img_quality = intval($this->overrideSettings['quality']); // oh, do intval() for security, comes from $_GET and will be included in exec() commands + } + else + { + $this->img_quality = intval($GLOBALS['linpha']->sql->config->value['sys_style_image_quality']); + } + + /** + * in image mode this is done earlier, because we need already org_width and org_height + * to determine if image is cached or not + * in thumb mode this can only be done later, because there are also folders and videos + */ + if( ! $this->setSourceFileInformation() ) + { + return false; + } + + /** + * this results in fliped img_width and img_height for later photos_cache + * compare, we take care of it below... + */ + $array = $this->scaleToFit($this->org_width,$this->org_height,$this->max_width,$this->max_height); + $this->img_width = $array['w']; + $this->img_height = $array['h']; + + /** + * check if entry in linpha_photos_cache exists + */ + /** + * Take care of fliped img_width and img_height, or it will result in a + * cache hit miss (scaleToFit() (above) takes the width and height from + * photos table, where values are wrong for images which need rotate) + */ + $rot = $GLOBALS['linpha']->db->GetRow("SELECT is_rotated, img_width, img_height " . "FROM ".LIN_PREFIX."photos_cache " . "WHERE photo_id = '".$this->photo_id."' "); - if(isset($rot['is_rotated']) && $rot['is_rotated'] != 0) - { - - $dummy_height = $this->img_height; - $this->img_height = $this->img_width; - $this->img_width = $dummy_height; - linLog(LOG_TYPE_IMPORT,LOG_INFO,'debug',"Flipping width and height to get cache hit for image # ".$this->photo_id); - } - - $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE " . + if(isset($rot['is_rotated']) && $rot['is_rotated'] != 0) + { + + $dummy_height = $this->img_height; + $this->img_height = $this->img_width; + $this->img_width = $dummy_height; + linLog(LOG_TYPE_IMPORT,LOG_INFO,'debug',"Flipping width and height to get cache hit for image # ".$this->photo_id); + } + + $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE " . "photo_id = '".$this->photo_id."' AND " . "img_width = '".$this->img_width."' AND " . "img_height = '".$this->img_height."' AND " . @@ -259,411 +259,410 @@ "is_rotated = '".$this->rotate."' AND " . "has_watermark = '".$this->watermark."'"); - if(isset($data['id']) && !empty($data['id'])) - { - linLog(LOG_TYPE_IMPORT,LOG_INFO,'debug',"Cache HIT for image # ".$this->photo_id); + if(isset($data['id']) && !empty($data['id'])) + { + linLog(LOG_TYPE_IMPORT,LOG_INFO,'debug',"Cache HIT for image # ".$this->photo_id); - $this->cached_id = $data['id']; - $this->output_file = LinImage::getCachePath('img',$this->cached_id,$this->img_type); - } - else - { - linLog( LOG_TYPE_IMPORT,LOG_INFO,'image',"Cache MISS for image # ".$this->photo_id); - - - /** - * insert an empty entry and get cached_id - * we will update correct values only if create cached image has been successfull - */ - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."photos_cache " . + $this->cached_id = $data['id']; + $this->output_file = LinImage::getCachePath('img',$this->cached_id,$this->img_type); + } + else + { + linLog( LOG_TYPE_IMPORT,LOG_INFO,'image',"Cache MISS for image # ".$this->photo_id); + + + /** + * insert an empty entry and get cached_id + * we will update correct values only if create cached image has been successfull + */ + $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."photos_cache " . "(photo_id) VALUES ('".$this->photo_id."')"); - - $this->cached_id = $GLOBALS['linpha']->db->GetOne("SELECT MAX(id) " . + + $this->cached_id = $GLOBALS['linpha']->db->GetOne("SELECT MAX(id) " . "FROM ".LIN_PREFIX."photos_cache "); - $this->output_file = LinImage::getCachePath('img',$this->cached_id,$this->img_type); - - if(file_exists($this->output_file)) - { - /** - * o-oh, we're leaking old files in cache path, -> delete it - */ - unlink($this->output_file); - } - } - } + $this->output_file = LinImage::getCachePath('img',$this->cached_id,$this->img_type); + + if(file_exists($this->output_file)) + { + /** + * o-oh, we're leaking old files in cache path, -> delete it + */ + unlink($this->output_file); + } + } + } - -} -/** - * set source file informations - * - * @todo save values to database and read from there - */ -function setSourceFileInformation() -{ - if($this->img_type != 0 && $this->img_type != 9999999) - { - $this->src_file = LinSql::getFullImagePath( $this->photo_id ); + } - if(! file_exists($this->src_file)) - { - echo $this->src_file.' '; - echo i18n("File doesnt exist anymore").'. '; - echo i18n("You should consider start a re-import of your files/folders").'<br />'; - return false; - } - } - - return true; -} + /** + * set source file informations + * + * @todo save values to database and read from there + */ + function setSourceFileInformation() + { + if($this->img_type != 0 && $this->img_type != 9999999) + { + $this->src_file = LinSql::getFullImagePath( $this->photo_id ); + if(! file_exists($this->src_file)) + { + echo $this->src_file.' '; + echo i18n("File doesnt exist anymore").'. '; + echo i18n("You should consider start a re-import of your files/folders").'<br />'; + return false; + } + } -/** - * thumbnail functions - * - * @return true on success, false on failure (checks for valid id, valid image, valid permission!) - */ - function createThumbnail($photo_id) - { - $this->mode = 'thumb'; - $this->photo_id = $photo_id; + return true; + } - if( ! $this->setFileInformation() ) - { - return false; - } - - if( ! $this->isCached ) - { - if( ! $this->setSourceFileInformation() ) - { - return false; - } - - linLog(LOG_TYPE_IMPORT,LOG_INFO,'thumbnail',"Creating thumbnail ".$this->photo_id); + /** + * thumbnail functions + * + * @return true on success, false on failure (checks for valid id, valid image, valid permission!) + */ + function createThumbnail($photo_id) + { + $this->mode = 'thumb'; + $this->photo_id = $photo_id; - /** - * image thumbnail - */ - if( LinIdentify::isSupportedImage( $this->img_type ) ) - { - $this->createThumbnailImage(); - } - /** - * folder thumbnail - */ - elseif($this->img_type == 0) - { - if( ! $this->createThumbnailFolder() ) - { - $this->output_file = LINPHA_DIR.'/lib/graphics/subfolder_image.png'; - } - } - /** - * video thumbnail - */ - elseif( LinIdentify::isVideo( $this->img_type ) ) - { - $this->createThumbnailVideo(); - } + if( ! $this->setFileInformation() ) + { + return false; + } - if( ! file_exists( $this->output_file ) ) - { - $this->error_msg = "Output File Doesnt Exists"; - return false; - } - } - - return true; - } - - function createThumbnailImage() - { - /** - * Exiftool can be used to extract the embedded thumbnail within the - * EXIF segment of the image. Most cameras support it. - * It is usually 5-10 times faster than using convert and is perfect - * when low on memory or with older CPU, even so the thumbs didn't look - * that nice as the ones created with convert ;-) - */ - if($GLOBALS['linpha']->sql->config->value['sys_import_use_emb_thumb']) + if( ! $this->isCached ) { - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); - - $objExifTool = new LinExifTool; + if( ! $this->setSourceFileInformation() ) + { + return false; + } - /** - * Default fallback if image doesn't contain embedded thumb - */ - if(!$objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file)) - { - $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; - $this->imageTool->imgQuality = 75; + linLog(LOG_TYPE_IMPORT,LOG_INFO,'thumbnail',"Creating thumbnail ".$this->photo_id); - $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); - } + /** + * image thumbnail + */ + if( LinIdentify::isSupportedImage( $this->img_type ) ) + { + $this->createThumbnailImage(); + } + /** + * folder thumbnail + */ + elseif($this->img_type == 0) + { + if( ! $this->createThumbnailFolder() ) + { + $this->output_file = LINPHA_DIR.'/lib/graphics/subfolder_image.png'; + } + } + /** + * video thumbnail + */ + elseif( LinIdentify::isVideo( $this->img_type ) ) + { + $this->createThumbnailVideo(); + } + + if( ! file_exists( $this->output_file ) ) + { + $this->error_msg = "Output File Doesnt Exists"; + return false; + } } + + return true; + } + + function createThumbnailImage() + { + /** + * Exiftool can be used to extract the embedded thumbnail within the + * EXIF segment of the image. Most cameras support it. + * It is usually 5-10 times faster than using convert and is perfect + * when low on memory or with older CPU, even so the thumbs didn't look + * that nice as the ones created with convert ;-) + */ + if($GLOBALS['linpha']->sql->config->value['sys_import_use_emb_thumb']) + { + include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); + + $objExifTool = new LinExifTool; + + /** + * Default fallback if image doesn't contain embedded thumb + */ + if(!$objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file)) + { + $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; + $this->imageTool->imgQuality = 75; + + $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); + } + } else { /** - * include the file which contains the imagemagick strings and exec() / gdlib instructions - */ + * include the file which contains the imagemagick strings and exec() / gdlib instructions + */ $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; $this->imageTool->imgQuality = 75; $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); } - } - - function createThumbnailFolder() - { - /** - * check if we have already some thumbnails in this folder - * and create array_ids which holds 4 image ids - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".LIN_PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes( $this->photo_id )."'"); - $array_thumbs = Array(); - $i=0; - while($data = $query->FetchRow()) - { - if($i >= 4) - { - break; - } - - $file = LinImage::getCachePath('thumb',$data['id'],$data['img_type']); + } - if( file_exists( $file ) ) - { - if($data['1']=='0') { // folders are gif files, all others are jpg - $type = '1'; - } else { - $type = '2'; - } + function createThumbnailFolder() + { + /** + * check if we have already some thumbnails in this folder + * and create array_ids which holds 4 image ids + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".LIN_PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes( $this->photo_id )."'"); + $array_thumbs = Array(); + $i=0; + while($data = $query->FetchRow()) + { + if($i >= 4) + { + break; + } + + $file = LinImage::getCachePath('thumb',$data['id'],$data['img_type']); - $array_thumbs[] = array('id' => $data['id'],'file' => $file, 'type' => $type); - $i++; - } - } - - /** - * no images found in this folder - */ - if(count($array_thumbs) == 0) - { - return false; - } + if( file_exists( $file ) ) + { + if($data['1']=='0') { // folders are gif files, all others are jpg + $type = '1'; + } else { + $type = '2'; + } - $this->imageTool->createThumbnailFolder($this->output_file,$array_thumbs); - - if( !file_exists($this->output_file)) - { - return false; - } - else - { - return true; - } - } - - function createThumbnailVideo() - { - $dummy_thumbnail = LINPHA_DIR.'/lib/graphics/video.jpg'; - $this->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; - $this->img_quality = 75; - //$this->imageTool->orgWidth = 320; - //$this->imageTool->orgHeight = 240; + $array_thumbs[] = array('id' => $data['id'],'file' => $file, 'type' => $type); + $i++; + } + } + + /** + * no images found in this folder + */ + if(count($array_thumbs) == 0) + { + return false; + } + + $this->imageTool->createThumbnailFolder($this->output_file,$array_thumbs); + + if( !file_exists($this->output_file)) + { + return false; + } + else + { + return true; + } + } + + function createThumbnailVideo() + { + $dummy_thumbnail = LINPHA_DIR.'/lib/graphics/video.jpg'; + $this->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; + $this->img_quality = 75; + //$this->imageTool->orgWidth = 320; + //$this->imageTool->orgHeight = 240; $video_thumbnail_created = false; - - /** - * check if there exists a .thm file - * (video thumbnail of Canon videos) - */ - $pos = strrpos($this->src_file,'.'); - $start = substr($this->src_file,0,$pos); - $thm_file = $start.'.thm'; - - if(file_exists($thm_file)) - { - list($this->org_width, $this->org_height, $file_type) = - LinIdentify::linGetImageSize($thm_file); - + + /** + * check if there exists a .thm file + * (video thumbnail of Canon videos) + */ + $pos = strrpos($this->src_file,'.'); + $start = substr($this->src_file,0,$pos); + $thm_file = $start.'.thm'; + + if(file_exists($thm_file)) + { + list($this->org_width, $this->org_height, $file_type) = + LinIdentify::linGetImageSize($thm_file); + $this->src_file = $thm_file; - $this->imageTool->orgWidth = $this->org_width; - $this->imageTool->orgHeight = $this->org_height; - $this->imageTool->imgType = $file_type; - $this->imageTool->img_thumbsize = $this->img_thumbsize; - $this->imageTool->imgQuality = 75; - $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); - $video_thumbnail_created = true; - } - - if(!$video_thumbnail_created) - { - /** + $this->imageTool->orgWidth = $this->org_width; + $this->imageTool->orgHeight = $this->org_height; + $this->imageTool->imgType = $file_type; + $this->imageTool->img_thumbsize = $this->img_thumbsize; + $this->imageTool->imgQuality = 75; + $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); + $video_thumbnail_created = true; + } + + if(!$video_thumbnail_created) + { + /** * try getting thumbnail with exiftool if requested */ - if($GLOBALS['linpha']->sql->config->value['sys_im_video_thumbnail'] && - $GLOBALS['linpha']->sql->config->value['sys_import_exiftool_avail'] ) - { - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); + if($GLOBALS['linpha']->sql->config->value['sys_im_video_thumbnail'] && + $GLOBALS['linpha']->sql->config->value['sys_import_exiftool_avail'] ) + { + include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); $objExifTool = new LinExifTool(); if($objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file)) { /** * get width and height from thumb - - list($this->org_width, $this->org_height, $file_type) = - LinIdentify::linGetImageSize($this->src_file); - - $this->imageTool->orgWidth = $this->org_width; - $this->imageTool->orgHeight = $this->org_height; - */ - $video_thumbnail_created = true; + + list($this->org_width, $this->org_height, $file_type) = + LinIdentify::linGetImageSize($this->src_file); + + $this->imageTool->orgWidth = $this->org_width; + $this->imageTool->orgHeight = $this->org_height; + */ + $video_thumbnail_created = true; } else // try getting at least codec for imagemagick { - /** - * only if codec is mjpg, because otherwise we get an access - * violation message box on the servers desktop of convert.exe - * (already reported to imagemagick http://studio. imagemagick. - * org/magick/viewtopic.php?t=2868) - */ - $file_info = $objExifTool->readMetaDataFromFile("all", $this->src_file); - - if(isset($file_info['Codec']) && - $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) - { - $codec = strtolower($file_info['Codec']); - if(strpos($codec, "mjpeg") !== false - OR strpos($codec, "motion jpeg") !== false - OR strpos($codec, "motion jpg") !== false - OR strpos($codec, "mjpg") !== false) - { - $return_value = $this->imageTool->createThumbnailVideo($this->src_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize); - - if($return_value == 0 && file_exists($this->output_file)) /* && empty($array_output[0]) */ - { - $video_thumbnail_created = true; - } - else - { - $video_thumbnail_created = false; - } - } - } - else - { - $video_thumbnail_created = false; - } + /** + * only if codec is mjpg, because otherwise we get an access + * violation message box on the servers desktop of convert.exe + * (already reported to imagemagick http://studio. imagemagick. + * org/magick/viewtopic.php?t=2868) + */ + $file_info = $objExifTool->readMetaDataFromFile("all", $this->src_file); + + if(isset($file_info['Codec']) && + $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) + { + $codec = strtolower($file_info['Codec']); + if(strpos($codec, "mjpeg") !== false + OR strpos($codec, "motion jpeg") !== false + OR strpos($codec, "motion jpg") !== false + OR strpos($codec, "mjpg") !== false) + { + $return_value = $this->imageTool->createThumbnailVideo($this->src_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize); + + if($return_value == 0 && file_exists($this->output_file)) /* && empty($array_output[0]) */ + { + $video_thumbnail_created = true; + } + else + { + $video_thumbnail_created = false; + } + } + } + else + { + $video_thumbnail_created = false; + } } - } - else - { - $video_thumbnail_created = false; - } - } - - /** - * copy the video icon in the lower right corner - */ - if($video_thumbnail_created) - { - /** - * watermark currently broken - image scaling wrong and distorted - * also - so disable temporary (flo?) - */ - /* - include_once(LINPHA_DIR.'/lib/plugins/watermark/func.watermark.php'); - $this->imageTool->wm_config = Array( - 'wm_watermark' => 2, - 'wm_align' => 'southeast', - 'wm_dissolve' => 100, - 'wm_img_img' => $dummy_thumbnail, - 'wm_resize' => 'no', // use 'no' because the gdlib cannot handle transparent images with imagecopyresized() !! - 'wm_horizontal' => 5, - 'wm_vertical' => 5 - ); - */ - /** - * warning: session will be closed! - */ - //$this->imageTool->orgWidth = $this->img_thumbsize; // only used with gdlib - //$this->imageTool->orgHeight = $this->img_thumbsize; // only used with gdlib + } + else + { + $video_thumbnail_created = false; + } + } - //$this->imageTool->createImage($this->output_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize,$this->rotate,$watermark=1); - } - else - { - /** - * use default video icon - */ - $this->output_file = $dummy_thumbnail; - } - } + /** + * copy the video icon in the lower right corner + */ + if($video_thumbnail_created) + { + /** + * watermark currently broken - image scaling wrong and distorted + * also - so disable temporary (flo?) + */ + /* + include_once(LINPHA_DIR.'/lib/plugins/watermark/func.watermark.php'); + $this->imageTool->wm_config = Array( + 'wm_watermark' => 2, + 'wm_align' => 'southeast', + 'wm_dissolve' => 100, + 'wm_img_img' => $dummy_thumbnail, + 'wm_resize' => 'no', // use 'no' because the gdlib cannot handle transparent images with imagecopyresized() !! + 'wm_horizontal' => 5, + 'wm_vertical' => 5 + ); + */ + /** + * warning: session will be closed! + */ + //$this->imageTool->orgWidth = $this->img_thumbsize; // only used with gdlib + //$this->imageTool->orgHeight = $this->img_thumbsize; // only used with gdlib + //$this->imageTool->createImage($this->output_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize,$this->rotate,$watermark=1); + } + else + { + /** + * use default video icon + */ + $this->output_file = $dummy_thumbnail; + } + } -/** - * image functions - */ - function createImage($photo_id, $overrideSettings) - { - $this->mode = 'img'; - $this->photo_id = $photo_id; - - $this->overrideSettings = $overrideSettings; - if( ! $this->setFileInformation() ) // will also do setCachedInfos() and setSourceFileInformation() - { - return false; - } - - if( ! $this->isCached OR $this->force ) - { - linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Creating image ".$this->photo_id); - - /** - * include the create image script - */ - linStartTimer("createimage"); - - $this->imageTool->createImage($this->src_file,$this->output_file,$this->img_width,$this->img_height,$this->rotate,$this->watermark); + /** + * image functions + */ + function createImage($photo_id, $overrideSettings) + { + $this->mode = 'img'; + $this->photo_id = $photo_id; - $time = linStopTimer("createimage") * 1000000; - - //echo $time; exit(); + $this->overrideSettings = $overrideSettings; - if( ! file_exists( $this->output_file ) ) - { - $this->error_msg = "Output File Doesnt Exists"; - return false; - } + if( ! $this->setFileInformation() ) // will also do setCachedInfos() and setSourceFileInformation() + { + return false; + } - /** - * finish cache entry - */ - $filesize = filesize( $this->output_file ); - if($filesize <= 0) - { - $this->error_msg = "Incorrect filesize (".$filesize.")"; - return false; - } + if( ! $this->isCached OR $this->force ) + { + linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Creating image ".$this->photo_id); + + /** + * include the create image script + */ + linStartTimer("createimage"); + + $this->imageTool->createImage($this->src_file,$this->output_file,$this->img_width,$this->img_height,$this->rotate,$this->watermark); - /** - * If image needs rotating (by EXIF value) flip width and height - * to have the right values in photos_cache - */ - if($this->rotate != 0) - { - $dummy_height = $this->img_height; - $this->img_height = $this->img_width; - $this->img_width = $dummy_height; - linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Height/width flip during storage of image # ".$this->photo_id." in photos_cache" ); - - } - $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos_cache SET " . + $time = linStopTimer("createimage") * 1000000; + + //echo $time; exit(); + + if( ! file_exists( $this->output_file ) ) + { + $this->error_msg = "Output File Doesnt Exists"; + return false; + } + + /** + * finish cache entry + */ + $filesize = filesize( $this->output_file ); + if($filesize <= 0) + { + $this->error_msg = "Incorrect filesize (".$filesize.")"; + return false; + } + + /** + * If image needs rotating (by EXIF value) flip width and height + * to have the right values in photos_cache + */ + if($this->rotate != 0) + { + $dummy_height = $this->img_height; + $this->img_height = $this->img_width; + $this->img_width = $dummy_height; + linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Height/width flip during storage of image # ".$this->photo_id." in photos_cache" ); + + } + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos_cache SET " . "img_width = '".$this->img_width."', " . "img_height = '".$this->img_height."', " . "img_quality = '".$this->img_quality."', " . @@ -673,257 +672,255 @@ "time_add = '".time()."', " . "time_creating = '".$time."' " . "WHERE id = '".$this->cached_id."'"); - } - else - { - /** - * got a cached copy, increment counter and time_use - */ - $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos_cache " . + } + else + { + /** + * got a cached copy, increment counter and time_use + */ + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos_cache " . "SET hits = hits + 1, time_use = '".time()."' " . "WHERE id = '".$this->cached_id."'"); - } + } - return true; - } + return true; + } - -/** - * Rotates images when called from menu direction left/right. - * Insert rotation value into linpha_photos and flip image width - * and height in table. - * Later do a force recreate - * - * @param string $direction either 90 (right turn) or -90 (left turn) - * @param int $linID - * - */ - function rotateImageByMenuCall($direction, $linId) - { - /** - * Insert ration value in linpha_photos - */ - $rotate = $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos " . + /** + * Rotates images when called from menu direction left/right. + * Insert rotation value into linpha_photos and flip image width + * and height in table. + * Later do a force recreate + * + * @param string $direction either 90 (right turn) or -90 (left turn) + * @param int $linID + * + */ + function rotateImageByMenuCall($direction, $linId) + { + /** + * Insert ration value in linpha_photos + */ + $rotate = $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos " . "SET rotate='".LinSql::linAddslashes($direction)."' " . "WHERE id='".$linId."'"); - - /** - * Flip image width and height - */ - $imagedata = $GLOBALS['linpha']->db->GetRow("SELECT width AS width, height AS height " . + + /** + * Flip image width and height + */ + $imagedata = $GLOBALS['linpha']->db->GetRow("SELECT width AS width, height AS height " . "FROM ".LIN_PREFIX."photos " . "WHERE id='".LinSql::linAddslashes($linId)."' "); - - $flip = $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos SET " . + + $flip = $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos SET " . "width = '".LinSql::linAddslashes($imagedata['height'])."', " . "height = '".LinSql::linAddslashes($imagedata['width'])."' " . "WHERE id='".LinSql::linAddslashes($linId)."'"); - - /** - * force recreate with new values - */ - $thumbnail = new LinImage(); - $_GET['force'] = true; - $thumbnail->createThumbnail( $linId ); - } + /** + * force recreate with new values + */ + $thumbnail = new LinImage(); + $_GET['force'] = true; + $thumbnail->createThumbnail( $linId ); + } -/** - * returns the full path to the cached image - * in thumb mode, $id is the photoid - * in image mode, $id is the cached photoid - * - * @param string $what 'thumb' or 'img' - * @param int $id image id - * @return string full path to cached image - * - * @todo use img_type as parameter and decide in this function - * which file extension to use - */ -function getCachePath($what,$id,$img_type) -{ - /** - * thumbnails of folders are gif files, all others are (currently at least) jpg files - */ - if($what == 'thumb' && $img_type == '0') { - $ext = 'gif'; - } else { - $ext = 'jpg'; - } - - $path = LinSql::getPath('cache'); - - if(strlen($id)==1) - { - $subdir = $id.'0'; // dont use foldernames 1-9 because it would only contain one image per folder - } - else - { - $subdir = substr($id,0,2); - } - - return $path . '/' . $what . '/' . $subdir . '/' . $id . '.' . $ext; -} + /** + * returns the full path to the cached image + * in thumb mode, $id is the photoid + * in image mode, $id is the cached photoid + * + * @param string $what 'thumb' or 'img' + * @param int $id image id + * @return string full path to cached image + * + * @todo use img_type as parameter and decide in this function + * which file extension to use + */ + function getCachePath($what,$id,$img_type) + { + /** + * thumbnails of folders are gif files, all others are (currently at least) jpg files + */ + if($what == 'thumb' && $img_type == '0') { + $ext = 'gif'; + } else { + $ext = 'jpg'; + } -/** - * deleteCached thumbnail by id - * - * @param int $id id of thumb in database - * @return boolean false if there was no image, true if there was an image to delete - */ -function deleteCachedThumbnail($id,$img_type) -{ - $output = LinImage::getCachePath('thumb',$id,$img_type); - - if(file_exists($output)) - { - if( ! @unlink( $output ) ) - { - linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); - } - - return true; - } - else - { - return false; - } -} + $path = LinSql::getPath('cache'); -/** - * delete all cached images by this photo id - * (there can be more than one image with the same photo id in different sizes etc.) - * - * @param int $id id of image in database - */ -function deleteCachedImage($id,$img_type) -{ - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE photo_id = '".$id."'"); - while($data = $query->FetchRow(ADODB_FETCH_NUM)) - { - $output = LinImage::getCachePath('img',$data[0],$img_type); - - if(file_exists($output)) - { - if( ! @unlink( $output ) ) - { - linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); - } - } - } -} + if(strlen($id)==1) + { + $subdir = $id.'0'; // dont use foldernames 1-9 because it would only contain one image per folder + } + else + { + $subdir = substr($id,0,2); + } -/** - * This returns returns width and height of the scaled image - * to fit in $dst_h and $dst_w, it keeps the image ratio - * calculated from $src_h and $src_w - * if $no_increase is set, the image is only decreased - */ -function scaleToFit($src_w,$src_h,$dst_w,$dst_h,$no_increase=1) -{ - if($src_h == 0 OR $src_w == 0) - { - return array('w' => 0, 'h' => 0); - } + return $path . '/' . $what . '/' . $subdir . '/' . $id . '.' . $ext; + } - $img_relation = $src_w/$src_h; + /** + * deleteCached thumbnail by id + * + * @param int $id id of thumb in database + * @return boolean false if there was no image, true if there was an image to delete + */ + function deleteCachedThumbnail($id,$img_type) + { + $output = LinImage::getCachePath('thumb',$id,$img_type); - // Image is smaller than screen, no resize required - if (($src_w <= $dst_w) && ($src_h <= $dst_h) && $no_increase) - { - $array['w'] = $src_w; - $array['h'] = $src_h; - } - else - { - /* - The image is way bigger than the screen, resize maintaining aspect ratio + if(file_exists($output)) + { + if( ! @unlink( $output ) ) + { + linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); + } - $src_w, $src_h: original image sizes - $dst_w, $dst_h: screen width and height - $img_relation = $src_w/$src_h; - - Either $dst_w decisive or $dst_h, usually $dst_h - */ + return true; + } + else + { + return false; + } + } - $tmp_height = $dst_w / $img_relation; // calc the new height with screen width - if ($tmp_height > $dst_h) { // we were wrong, it's still widther than screen -> $dst_h is decisive - $array['w'] = round($img_relation*$dst_h); - $array['h'] = intval($dst_h); // oh, do intval() for security, comes from $_GET and will be included in exec() commands - } else { - $array['w'] = intval($dst_w); // oh, do intval() for security, comes from $_GET and will be included in exec() commands - $array['h'] = round($tmp_height); - } - } - - return $array; -} + /** + * delete all cached images by this photo id + * (there can be more than one image with the same photo id in different sizes etc.) + * + * @param int $id id of image in database + */ + function deleteCachedImage($id,$img_type) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE photo_id = '".$id."'"); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + $output = LinImage::getCachePath('img',$data[0],$img_type); -/** - * send correct header and file - */ -function printFileToScreen() -{ - if( $this->img_type == 0 ) // folder are gif images, all other are jpg - { - header("Content-type: image/gif"); - } - else - { - header("Content-type: image/jpeg"); - } - - /** - * show correct image filename wenn selecting "save as" in browser - * it works on firefox, but it does not on my IE - */ - header("Content-Disposition: inline; filename=".basename($this->src_file).";" ); - - readfile( $this->output_file ); -} + if(file_exists($output)) + { + if( ! @unlink( $output ) ) + { + linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); + } + } + } + } -/** - * rotates an image with a given angle using GDLib - * do nothing if imagerotate() doesn't exists - * - * - * @param imageressource $src_img pointer to the source image - * @param int $angle angle to rotate - * @author flo - */ -function GDimageRotate(& $src_img, $angle) -{ - if($angle != "0") - { - if(function_exists('imagerotate')) - { - /** - * flip $angle, because with this function, left means right, and right means left :-) - */ - $angle = 360 - $angle; - $angle = $angle % 360; - $src_img = imagerotate($src_img,$angle,0); - } - else - { - linLog(LOG_TYPE_META,LOG_WARNING,'rotate',"Cannot rotate image becuase the function imagerotate() doesnt exists, consider upgrading your php version"); - } - } -} + /** + * This returns returns width and height of the scaled image + * to fit in $dst_h and $dst_w, it keeps the image ratio + * calculated from $src_h and $src_w + * if $no_increase is set, the image is only decreased + */ + function scaleToFit($src_w,$src_h,$dst_w,$dst_h,$no_increase=1) + { + if($src_h == 0 OR $src_w == 0) + { + return array('w' => 0, 'h' => 0); + } -function &GDimageCreateFrom($src_file,$img_type) -{ - switch($img_type) - { - case 1: $src_image = imagecreatefromgif($src_file); break; - case 2: $src_image = imagecreatefromjpeg($src_file); break; - case 3: $src_image = imagecreatefrompng($src_file); break; - default: $foobar = false; return $foobar; break; - } - - return $src_image; -} - + $img_relation = $src_w/$src_h; + + // Image is smaller than screen, no resize required + if (($src_w <= $dst_w) && ($src_h <= $dst_h) && $no_increase) + { + $array['w'] = $src_w; + $array['h'] = $src_h; + } + else + { + /* + The image is way bigger than the screen, resize maintaining aspect ratio + + $src_w, $src_h: original image sizes + $dst_w, $dst_h: screen width and height + $img_relation = $src_w/$src_h; + + Either $dst_w decisive or $dst_h, usually $dst_h + */ + + $tmp_height = $dst_w / $img_relation; // calc the new height with screen width + if ($tmp_height > $dst_h) { // we were wrong, it's still widther than screen -> $dst_h is decisive + $array['w'] = round($img_relation*$dst_h); + $array['h'] = intval($dst_h); // oh, do intval() for security, comes from $_GET and will be included in exec() commands + } else { + $array['w'] = intval($dst_w); // oh, do intval() for security, comes from $_GET and will be included in exec() commands + $array['h'] = round($tmp_height); + } + } + + return $array; + } + + /** + * send correct header and file + */ + function printFileToScreen() + { + if( $this->img_type == 0 ) // folder are gif images, all other are jpg + { + header("Content-type: image/gif"); + } + else + { + header("Content-type: image/jpeg"); + } + + /** + * show correct image filename wenn selecting "save as" in browser + * it works on firefox, but it does not on my IE + */ + header("Content-Disposition: inline; filename=".basename($this->src_file).";" ); + + readfile( $this->output_file ); + } + + /** + * rotates an image with a given angle using GDLib + * do nothing if imagerotate() doesn't exists + * + * + * @param imageressource $src_img pointer to the source image + * @param int $angle angle to rotate + * @author flo + */ + function GDimageRotate(& $src_img, $angle) + { + if($angle != "0") + { + if(function_exists('imagerotate')) + { + /** + * flip $angle, because with this function, left means right, and right means left :-) + */ + $angle = 360 - $angle; + $angle = $angle % 360; + $src_img = imagerotate($src_img,$angle,0); + } + else + { + linLog(LOG_TYPE_META,LOG_WARNING,'rotate',"Cannot rotate image becuase the function imagerotate() doesnt exists, consider upgrading your php version"); + } + } + } + + function &GDimageCreateFrom($src_file,$img_type) + { + switch($img_type) + { + case 1: $src_image = imagecreatefromgif($src_file); break; + case 2: $src_image = imagecreatefromjpeg($src_file); break; + case 3: $src_image = imagecreatefrompng($src_file); break; + default: $foobar = false; return $foobar; break; + } + + return $src_image; + } + } // end class linImage ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2008-01-30 21:08:44 UTC (rev 4841) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2008-01-31 12:27:25 UTC (rev 4842) @@ -53,7 +53,6 @@ } - /** * set current view and set fileinfos of $GLOBALS['linpha']->template->idCurrent ($_GET['linId']) * @param string $modulname (album, browse, search, ...) @@ -152,7 +151,6 @@ } } - /** * main function to prepare desired layout view */ @@ -236,7 +234,6 @@ include_once(LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/global.html.php'); } - /** * filter out files and folders not permitted and escape filename * all other values dont have to be escaped @@ -268,7 +265,6 @@ unset($this->photos); } - /** * create optional top menu */ @@ -545,7 +541,6 @@ } } - /** * method for special admin commands, like rotating images, import stuff etc. * @uses LinImgview::buildImgView() @@ -613,9 +608,6 @@ } } - - - /** * define thumbnail view */ @@ -721,7 +713,6 @@ } } - /** * thumbnail view with javascript disabled (static) * @uses LinImgView::viewThumb() @@ -893,11 +884,6 @@ $GLOBALS['linpha']->template->setModuleName('view_thumbdetail'); } - - - - - /** * setup main/home view layout */ @@ -1062,10 +1048,6 @@ } } - - - - /** * setup basket view */ @@ -1150,9 +1132,6 @@ LinMetaData::saveModifiedMetaData(); } - - - /** * setup image view */ @@ -1306,7 +1285,7 @@ } /** - * store image informations in database if not exists + * store image informations in database if s */ function viewImgStoreImageInformation() { @@ -1325,6 +1304,21 @@ { $MetaData->saveData($value, $this->src_file, $this->md5sum ); } + + /** + * Read image geodata. This depends on the maps plugin. So we only + * run this additionally import if maps plugin is enabled and admin + * selected "autoimport". + * This should prevent a... [truncated message content] |
From: <bz...@us...> - 2008-01-31 19:54:36
|
Revision: 4844 http://linpha.svn.sourceforge.net/linpha/?rev=4844&view=rev Author: bzrudi Date: 2008-01-31 11:54:28 -0800 (Thu, 31 Jan 2008) Log Message: ----------- First draft for the XML parser class (xml_parser.class.php) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/plugins/maps/module.maps.php Added Paths: ----------- trunk/linpha2/lib/plugins/maps/xml_parser.class.php Removed Paths: ------------- trunk/linpha2/lib/plugins/maps/garmingpx_parser.class.php trunk/linpha2/lib/plugins/maps/gpx.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-31 13:01:02 UTC (rev 4843) +++ trunk/linpha2/ChangeLog 2008-01-31 19:54:28 UTC (rev 4844) @@ -6,7 +6,8 @@ - code cleanups - still work in progress - btw - installer looks fine - + * First draft for the XML parser class (xml_parser.class.php) + 2008-01-30 flo * installer - improved layout Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-31 13:01:02 UTC (rev 4843) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-31 19:54:28 UTC (rev 4844) @@ -29,7 +29,6 @@ */ class LinMetaData { - public $defined_fields, $available_fields; protected $objMetaTool; private $cachedFieldNames, $cachedFieldIds, $cachedSelectedFieldNames; @@ -1029,6 +1028,15 @@ } /** + * Parse GPX data from file + */ + public function parseGpxFile($filename) + { + $parser = new GpxParser($filename); + + } + + /** * Simple wrapper method for saveMetaData() * @param string $what meta type exif,iptc,xmp * @param string $filename filename @@ -1193,5 +1201,6 @@ return $rotate; } } + /* vi: set ts=4 sw=4 sts=4 */ ?> Deleted: trunk/linpha2/lib/plugins/maps/garmingpx_parser.class.php =================================================================== --- trunk/linpha2/lib/plugins/maps/garmingpx_parser.class.php 2008-01-31 13:01:02 UTC (rev 4843) +++ trunk/linpha2/lib/plugins/maps/garmingpx_parser.class.php 2008-01-31 19:54:28 UTC (rev 4844) @@ -1,84 +0,0 @@ -<?php -/* -* Copyright (c) 2004 Heiko Rutenbeck <bz...@tu...> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -if(!defined('TOP_DIR')) { define('TOP_DIR','../../'); } - -/** -* Class to parse Garmin GPX files and return values for -* latitiude, longitude, elevation, time and more. Makes use of libxml -* to read XML data -> requires php >= 4.2.0! -* -* @author bzrudi -*/ -class GpxParser -{ - -var $xmldata; //protected -var $parsedata; //protected -var $filename; //protected - -/** - * Constructor - */ -function GpxParser($filename) -{ - include_once(TOP_DIR.'/plugins/maps/libxml/IsterXmlSimpleXMLImpl.php'); - $xmlreader = new IsterXmlSimpleXMLImpl; - $this->xmldata = $xmlreader->load_file($filename); - $this->filename = $filename; -} - -/** - * This method checks whether file contains waypoints (wpt) or trackpoints - * (trkpt) or even routepoints (rtp) and takes good care of - * how we handle them. - * - * @param none - * @return array returns only XmlData and filetype - * @author bzrudi - */ -function getGpxFileType() -{ - $this->parsedata = file_get_contents($this->filename); - - if(strpos($this->parsedata, 'trkpt')) - { - echo "TRACKFILE DETECTED"; - return array($this->xmldata, 'trkpt'); - } - elseif(strpos($this->parsedata, 'rtept')) - { - echo "ROUTEFILE DETECTED"; - return array($this->xmldata, 'rtept'); - } - elseif(strpos($this->parsedata, 'wpt')) - { - echo "WAYFILE DETECTED"; - return array($this->xmldata, 'wpt'); - } - else - { - echo "CANNOT DETECT INPUT FILE FORMAT"; - return array('dummy', 'failed'); - } -} - -} // end class -?> - Deleted: trunk/linpha2/lib/plugins/maps/gpx.php =================================================================== --- trunk/linpha2/lib/plugins/maps/gpx.php 2008-01-31 13:01:02 UTC (rev 4843) +++ trunk/linpha2/lib/plugins/maps/gpx.php 2008-01-31 19:54:28 UTC (rev 4844) @@ -1,99 +0,0 @@ -<?php -/** - * This method parses an XML file (currently in Garmin GPX format) and saves - * all available information in the DB - * - * @param string filename - * @author bzrudi - */ -function parseXMLDataFile($filename) -{ - -$gpxparser = new GpxParser($filename); -list($xmldata, $filetype) = $gpxparser->getGpxFileType(); - - switch($filetype) - { - case "trkpt": - { - foreach( $xmldata->gpx->trk->trkseg->trkpt as $trkinfo) - { - $latlon = $trkinfo->attributes(); //array(lat,lon) - - $lat = $latlon['lat']; - $lon = $latlon['lon']; - $ele = $trkinfo->ele->CDATA(); - $time = $trkinfo->time->CDATA(); - - //echo"LAT:".$lat."LON:".$lon."ELE:".$ele."<br>"; - - $location = new Location($lat, $lon, '<div class="someCssClass">' . - 'LAT: '.$lat.'<br>' . - 'LON: '.$lon.'<br>' . - 'HÖHE: '.$ele.'m<br>' . - 'DATE: '.$time.'</div>'); - $this->cmap->addLocation($location); - } - break; - } - - case "rtept": - { - foreach( $xmldata->gpx->rte->rtept as $pointinfo) - { - $latlon = $pointinfo->attributes(); //array(lat,lon) - - $lat = $latlon['lat']; - $lon = $latlon['lon']; - //$ele = $pointinfo->ele->CDATA(); - //$name = $pointinfo->name->CDATA(); - - //echo"LAT:".$lat."LON:".$lon."ELE:".$ele."NAME:".$name."<br>"; - - $location = new Location($lat, $lon, '<div class="someCssClass">' . - 'LAT: '.$lat.'<br>' . - 'LON: '.$lon.'<br>' . - 'HÖHE: na<br>' . - 'Name: na</div>'); - $this->cmap->addLocation($location); - } - break; - } - - case "wpt": - { - foreach( $xmldata->gpx->wpt as $wpointinfo) - { - $latlon = $wpointinfo->attributes(); //array(lat,lon) - - $lat = $latlon['lat']; - $lon = $latlon['lon']; - $ele = $wpointinfo->ele->CDATA(); - $name = $wpointinfo->name->CDATA(); - $cmt = $wpointinfo->cmt->CDATA(); - //$desc = $wpointinfo->desc->CDATA(); - $sym = $wpointinfo->sym->CDATA(); - - //echo"LAT: ".$lat."LON: ".$lon."ELE: ".$ele."NAME: ".$name." " . - // "CMT: ".$cmt."SYMBOL: ".$sym."<br>"; - - $location = new Location($lat, $lon, '<div class="someCssClass">' . - 'LAT: '.$lat.'<br>' . - 'LON: '.$lon.'<br>' . - 'ELE: '.$ele.'m<br>' . - 'NAM: '.$name.'<br>' . - 'CMT: '.$cmt.'<br>' . - 'SYM: '.$sym.'<br></div>'); - $this->cmap->addLocation($location); - } - break; - } - case "failed": - { - echo "CANNOT DETECT INPUT FILE FORMAT"; - } - } -} - - - Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-31 13:01:02 UTC (rev 4843) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-31 19:54:28 UTC (rev 4844) @@ -23,10 +23,13 @@ * @package Plugins */ if(!defined('LINPHA_DIR')) { exit(1); } +include_once LINPHA_DIR.'/lib/plugins/maps/xml_parser.class.php'; -/* $MetaData = new LinMetaData(); - $MetaData->importGeoData();*/ -/** +$GPXData = new LinXmlParser(); +$array_with_gpx = $GPXData->readXmlFile('/tmp/sample.gpx'); +echo "<pre>", print_r($array_with_gpx), "</pre>"; + +/** * xml load/save stuff */ if(isset($_GET['xml'])) Copied: trunk/linpha2/lib/plugins/maps/xml_parser.class.php (from rev 4841, trunk/linpha2/lib/plugins/maps/garmingpx_parser.class.php) =================================================================== --- trunk/linpha2/lib/plugins/maps/xml_parser.class.php (rev 0) +++ trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-01-31 19:54:28 UTC (rev 4844) @@ -0,0 +1,137 @@ +<?php +/* + * Copyright (c) 2004 Heiko Rutenbeck <bz...@tu...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +if(!defined('TOP_DIR')) { define('TOP_DIR','../../'); } + +/** + * Class to parse Garmin GPX files and return values for + * latitiude, longitude, elevation, time and more. + * @author bzrudi + */ +class LinXmlParser +{ + private $data, $parser, $filename, $values, $index_array; + private $data_range, $gpx, $xml_data; + + function __construct() + { + + } + /** + * This method reads all trackpoints and related data from an xml file and + * returns them as an array, example: + * [685] => Array + * ( + * [trkpt] => Array + * ( + * [lon] => 7.715998599305749 + * [lat] => 50.1166464574635 + * ) + * + * [ele] => 191.92 + * [time] => 2007-12-23T13:31:50Z + * [extension] => + * [flags] => 0 + * ) + * + * @param string $filename + * @return array with all trackpoints + */ + public function readXmlFile($filename) + { + /** + * open and parse xml file for Track data + */ + $this->data = file_get_contents($filename); + $this->parser = xml_parser_create(); + + /** + * lowercase tags + */ + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); + xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1); + + /** + * This function returns two arrays, one for the index and one for + * the values. + */ + xml_parse_into_struct($this->parser, $this->data, $this->values, $this->index_array); + xml_parser_free($this->parser); + + /** + * Loop through index array to find all occurencies of "trkpt" + */ + foreach($this->index_array AS $key => $val) + { + if($key == "trkpt") // hit + { + $this->data_range = $val; + + for($i=0; $i < count($this->data_range); $i+=2) + { + $offset = $this->data_range[$i]; + $len = $this->data_range[$i + 1] - $offset; + $this->xml_data[] = $this->parseXmlArray(array_slice($this->values, $offset, $len)); + } + } + else + { + continue; + } + } + return $this->xml_data; + } + + /** + * This is just an helper/wrapper method for readXmlFile() and is called + * for each trkpoint data entry from readXmlFile(). + * + * @param array $sliced_arrav + * @return unknown + */ + private function parseXmlArray($sliced_array) + { + for($i=0; $i < count($sliced_array); $i++) + { + /** + * Trkpt data is somewhat other to handle than ele and time data, + * as the return is an array. + */ + if($sliced_array[$i]["tag"] == "trkpt") + { + $this->gpx[$sliced_array[$i]["tag"]] = @$sliced_array[$i]["attributes"]; + } + + /** + * This is anything beetween the <trkpt> and </trkpt> tag + */ + else + { + $this->gpx[$sliced_array[$i]["tag"]] = @$sliced_array[$i]["value"]; + } + } + + //return new LinXmlParser($this->gpx); + return $this->gpx; + + } +} + +/* vi: set ts=4 sw=4 sts=4 */ +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2008-02-01 13:37:06
|
Revision: 4846 http://linpha.svn.sourceforge.net/linpha/?rev=4846&view=rev Author: bzrudi Date: 2008-02-01 05:37:03 -0800 (Fri, 01 Feb 2008) Log Message: ----------- improved GPX file parsing support Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.pjmt.class.php trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/lib/plugins/maps/xml_parser.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-31 19:57:11 UTC (rev 4845) +++ trunk/linpha2/ChangeLog 2008-02-01 13:37:03 UTC (rev 4846) @@ -1,3 +1,9 @@ +2008-02-01 bzrudi + * More improvements to XML parser class. XML/GPX parsing works now, same + for getting all required timestamps (starttime/endtime) from xml file as + well as the image EXIF datetimeoriginal tag from all images in folder. + * Add some required new methods to LinMetaData() class + 2008-01-31 bzrudi * Maps plugin - all DBs should work now (untestet) Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-31 19:57:11 UTC (rev 4845) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-02-01 13:37:03 UTC (rev 4846) @@ -1,64 +1,64 @@ <?php /* -* Copyright (c) 2007 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * Copyright (c) 2007 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /** * This class handles all the IPTC/XMP stuff used in LinPHA. Currently - * we support IPTC/XMP, EXIF may follow as soon as we have tested ExifTool for - * speed, stability and portability. + * we support IPTC/XMP, EXIF may follow as soon as we have tested ExifTool for + * speed, stability and portability. * @package MetaData * @author bzrudi */ class LinExifTool extends LinMetaData { - -public $exiftool, $filename; + public $exiftool, $filename; + /** * Constructor */ - function __construct() + function __construct() { /** * Automagic set required exiftool depending on OS * @todo mac detecting and testing */ - if(LIN_OS == "unix") + if(LIN_OS == "unix") { - $this->exiftool = LINPHA_DIR.'/lib/exiftool/exiftool'; + $this->exiftool = LINPHA_DIR.'/lib/exiftool/exiftool'; } - elseif(LIN_OS == "win") + elseif(LIN_OS == "win") { - $this->exiftool = LINPHA_DIR.'\lib\exiftool\exiftool.exe'; // forward slashes will not work + $this->exiftool = LINPHA_DIR.'\lib\exiftool\exiftool.exe'; // forward slashes will not work } - else // Macintosh - Seems that exiftool will be installed into /usr/bin - // by default when using the install package *.dmg + else // Macintosh - Seems that exiftool will be installed into /usr/bin + // by default when using the install package *.dmg { - if(file_exists('/usr/bin/exiftool')) - { - $this->exiftool = '/usr/bin/exiftool'; - } - else // fallback to UNIX default - may work ! - { - $this->exiftool = LINPHA_DIR.'/lib/exiftool/exiftool'; - } - } + if(file_exists('/usr/bin/exiftool')) + { + $this->exiftool = '/usr/bin/exiftool'; + } + else // fallback to UNIX default - may work ! + { + $this->exiftool = LINPHA_DIR.'/lib/exiftool/exiftool'; + } + } } /** @@ -66,46 +66,46 @@ * Most modern Cameras should support it. * @param string $filename The filename of the Image * @param string $outfile The filename inkl. path to store thumb to - * @return bool + * @return bool * @author bzrudi */ public function getEmbeddedThumbnail($filename, $outfile) { $got_thumb = false; //prevent notice - - $parameters = "-b " . // get binary data + + $parameters = "-b " . // get binary data "-ThumbnailImage"; // get thumbnail from composite - + /** * Buffer output of passthru and save to $thumb var - */ - ob_start(); - passthru($this->exiftool.' '.$parameters.' "'.$filename.'"'); + */ + ob_start(); + passthru($this->exiftool.' '.$parameters.' "'.$filename.'"'); $thumb = ob_get_contents(); - ob_end_clean(); - - if(strlen($thumb) > 10) + ob_end_clean(); + + if(strlen($thumb) > 10) { $fileobj = file_put_contents($outfile, $thumb); - - if($fileobj > 10) //$fileobj is number of bytes written - { - $got_thumb = true; - } - else - { - $got_thumb = false; - } + + if($fileobj > 10) //$fileobj is number of bytes written + { + $got_thumb = true; + } + else + { + $got_thumb = false; + } } - - if($got_thumb) - { - return true; - } - else - { - return false; - } + + if($got_thumb) + { + return true; + } + else + { + return false; + } } /** @@ -121,20 +121,20 @@ $parameters = "-g ". //Group by Tags "-h "; //Enable HTML output - LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $return); - + LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $return); + foreach($return as $value) { echo $value; - } - + } + } - + /** * This method reads all available MetaData (Group) Information from image. * @param string $metatype iptc, xmp, exif, makernotes... * @param string $filename - * @return array Array with all available Tag informations + * @return array Array with all available Tag informations * @author bzrudi * @todo respect exec return status, don't use filename as input (security) */ @@ -143,7 +143,7 @@ $meta =""; $return=""; $metaArray = array(); - + $parameters = "-$metatype:all " . // Get all Tag Information "-s " . // Print tag names instead of descr. "-t " . // Use tab \t as delimiter @@ -151,42 +151,42 @@ "-a " . // Allow duplicates "-c %.10f " . // GPS formatting to float instead of words "-m "; // Ignore minor errors - + LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $meta, $return); - - + + /* - echo $this->exiftool.' '.$parameters.' "'.$filename.'"'; - echo '<pre>', print_r($meta), '</pre>'; - exit(); - */ + echo $this->exiftool.' '.$parameters.' "'.$filename.'"'; + echo '<pre>', print_r($meta), '</pre>'; + exit(); + */ /** - * Create usable array information by cycling and splitting + * Create usable array information by cycling and splitting * all information */ foreach($meta as $value) { - $temp = explode("\t", $value); + $temp = explode("\t", $value); $metaArray[trim($temp['0'])] = @trim($temp['1']); - } - - return $metaArray; + } + + return $metaArray; } /** * Save all MetaData to database * @param string $filename filename to parse for MetaData * @param string $md5sum md5sum of file - * @param string $tag save EXIF, IPTC or XMP MetaData + * @param string $tag save EXIF, IPTC or XMP MetaData */ public function saveMetaData($filename, $md5sum, $tag) { - + $dataArray = LinExifTool::readMetaDataFromFile($tag, $filename); - - //echo '<pre>', print_r($dataArray), '</pre>'; - + //echo '<pre>', print_r($dataArray), '</pre>'; + + $str_columns = "md5sum, "; $str_values = "'" . $md5sum . "', "; @@ -194,38 +194,38 @@ { /** * Lower array data to make it compareable to LinExifTool::$metaTags - */ + */ $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); - + /** - * Search for valid and filled tags + * Search for valid and filled tags */ foreach($this->defined_fields[$tag] AS $key => $value) { if(array_key_exists($key, $lowerDataArray)) - { - $str_columns .= str_replace("_", "-", $key) . ', '; - $str_values .= "'".trim($lowerDataArray[$key])."', "; - //$str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; + { + $str_columns .= str_replace("_", "-", $key) . ', '; + $str_values .= "'".trim($lowerDataArray[$key])."', "; + //$str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; } } - /** - * Remove last two signs (the comma and the space) which we add to much - */ - $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); - $str_values = substr($str_values, 0, strlen($str_values) - 2); + /** + * Remove last two signs (the comma and the space) which we add to much + */ + $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); + $str_values = substr($str_values, 0, strlen($str_values) - 2); - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_$tag " . + $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_$tag " . "(" . $str_columns . ") VALUES (" . $str_values . ")"); } } /** - * Simple method to return just exif date and orientation tag during - * import as needed by linpha_photos, this is not used for any meta_x table. + * Simple method to return just exif date and orientation tag during + * import as needed by linpha_photos, this is not used for any meta_x table. * example: 2004:02:14 18:24:19 and -90 - * + * * @param string $dirname, $filename * @return array $time_exif (unix timestamp) * $rotate (degrees to rotate) otherMarker @@ -233,15 +233,15 @@ **/ public function getBasicMeta($dirname, $filename) { - $return = ""; + $return = ""; $meta = ""; $filename = "".$dirname."/".$filename.""; - $parameters = "-exif:datetimeoriginal " . // Get date tag + $parameters = "-exif:datetimeoriginal " . // Get date tag "-exif:orientation " . // Get orientation tag "-s -n -t "; // Print tag name tab seper. - - LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $meta, $return); - + + LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $meta, $return); + if(is_array($meta)) { foreach($meta AS $value) @@ -249,7 +249,7 @@ $temp = explode("\t", $value); $metaArray[strtolower(trim($temp['0']))] = @trim($temp['1']); } - + } $date = $metaArray['datetimeoriginal']; @@ -267,7 +267,7 @@ { $time_exif = "0"; } - + if($metaArray['orientation']) { $rotate = $metaArray['orientation']; @@ -276,38 +276,38 @@ { $rotate = "0"; } - - return array($time_exif, $rotate); + + return array($time_exif, $rotate); } /** - * This method defines tags to index, e.g. create them in MetaData relation. - * And also sets available fields, e.g. those defined in $metaTags, but + * This method defines tags to index, e.g. create them in MetaData relation. + * And also sets available fields, e.g. those defined in $metaTags, but * not used in database yet. * @param string $metatype [exif,iptc,xmp] * @return array fileds already selected to be used (defined_fields) * and also available fields from $metaTags (available_fields) - * @author bzrudi,flo + * @author bzrudi,flo */ public function setMetaFields($metatype) { - + /** - * Create defined_fields var, use a new array with lowercase keys and + * Create defined_fields var, use a new array with lowercase keys and * without the md5sum entry. - * MetaColumns() returns the keys always uppercase independent + * MetaColumns() returns the keys always uppercase independent * of ADODB_ASSOC_CASE setting, so strtolower() them. */ $array = $GLOBALS['linpha']->db->MetaColumns(LIN_PREFIX."meta_".$metatype); $this->defined_fields[$metatype] = array (); - + foreach ($array AS $key => $value) { if ($key != 'MD5SUM') //todo check array_pop { $new_key = strtolower($key); - $this->defined_fields[$metatype][$new_key] = - LinExifTool::$metaTags[$metatype][$new_key]; + $this->defined_fields[$metatype][$new_key] = + LinExifTool::$metaTags[$metatype][$new_key]; } } @@ -325,22 +325,49 @@ } /** + * Just get DateTimeOriginal from EXIF header + * + * @param filename $filename + * @return DateTimeOriginal as unixtime + */ + public function getDateTimeOriginal($filename) + { + $return = ""; + $meta = ""; + $parameters = "-exif:datetimeoriginal " .// Get date tag + "-fast "; // hurry up ;-) + + LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $meta, $return); + + if(isset($meta['0'])) + { + /** + * Cut DateTimeOriginal + */ + $len = strlen($meta['0']); + $image_date = substr($meta['0'], ($len - 19)); + + } + return $image_date; + } + + /** * Define array with allowed IPTC/XMP tags and human readable translation * @param none - * @return none - * @author bzrudi + * @return none + * @author bzrudi */ public static $metaTags = array( 'xmp' => array( - - //Iptc4xmpCore schema tags + + //Iptc4xmpCore schema tags 'countrycode' => 'Country Code', 'intellectualgenre' => 'Intellectual Genre', 'location' => 'Location', 'scene' => 'Scene', 'subjectcode' => 'Subject Code', - //Dublin Core schema tags + //Dublin Core schema tags 'contributor' => 'Contributor', 'coverage' => 'Coverage', 'creator' => 'Creator', @@ -352,8 +379,8 @@ 'rights' => 'Rights', 'subject' => 'Subject', 'title' => 'Title', - - //Adobe Photoshop schema tags + + //Adobe Photoshop schema tags 'authorsposition' => 'Authors Position', 'captionwriter' => 'Caption Writer', 'category' => 'Category', @@ -361,7 +388,7 @@ 'colormode' => 'Color Mode', 'country' => 'Country', 'credit' => 'Credit', - //'datecreated' => 'DateCreated', + //'datecreated' => 'DateCreated', 'headline' => 'Headline', 'iccprofilename' => 'ICC Profile Name', 'instructions' => 'Instructions', @@ -408,10 +435,10 @@ 'originatingprogram' => 'Originating Program', 'releasedate' => 'Release Date' ), - + //EXIF schema tags 'exif' => array( - + //IFD0 'processingsoftware' => 'Processing Software', 'imagewidth' => 'Image Width', @@ -461,7 +488,7 @@ 'rating' => 'Rating', 'ratingpercent' => 'Rating Percent', 'copyright' => 'Copyright', - + //ExifIFD 'exposuretime' => 'Exposure Time', 'fnumber' => 'F Number', @@ -507,7 +534,7 @@ 'subjectdistancerange' => 'Subject Distance Range', 'gamma' => 'Gamma' ) - ); + ); } /* vi: set ts=4 sw=4 sts=4 */ Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-31 19:57:11 UTC (rev 4845) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-02-01 13:37:03 UTC (rev 4846) @@ -1200,6 +1200,19 @@ } return $rotate; } + + /** + * Wrapper method to get DateTimeOriginal from EXIF header depending on + * used Meta Toolkit + * + * @param filename $filename + * @return DateTimeOriginal as unixtime + */ + public function getDateTimeOriginal($filename) + { + $image_date = $this->objMetaTool->getDateTimeOriginal($filename); + return $image_date; + } } /* vi: set ts=4 sw=4 sts=4 */ Modified: trunk/linpha2/lib/classes/linpha.pjmt.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.pjmt.class.php 2008-01-31 19:57:11 UTC (rev 4845) +++ trunk/linpha2/lib/classes/linpha.pjmt.class.php 2008-02-01 13:37:03 UTC (rev 4846) @@ -1,45 +1,44 @@ <?php /* -* Copyright (c) 2007 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * Copyright (c) 2007 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /** * This class handles all the EXIF stuff using PJMT as fallback when exiftool - * can't be used in LinPHA for some reasons. + * can't be used in LinPHA for some reasons. * @package MetaData * @author bzrudi,flo */ class LinPjmtTool extends LinMetaData { - /** * Constructor */ function __construct() { - + } /** * This method reads all available GeoData Information from image. * @param string $metatype exi * @param string $filename - * @return array Array with all available Tag informations + * @return array Array with all available Tag informations * @author bzrudi * @todo respect exec return status, don't use filename as input (security) */ @@ -47,63 +46,63 @@ { include_once (LINPHA_DIR . '/lib/pjmt/JPEG.php'); include_once (LINPHA_DIR . '/lib/pjmt/EXIF.php'); - + /** * get exif info from file */ $exif_data = get_EXIF_JPEG($filename); - + if($exif_data) { /** - * search for valid tags + * search for valid tags */ foreach($this->getDefaultMetaTags('gps') AS $key => $value) { if(!empty(LinPjmtTool::$metaTags['exif'][$value]['pathvalue'])) { /** - * there are currently only entries at level deep 2 and 5 + * there are currently only entries at level deep 2 and 5 * in the array */ - $ap = explode('/', - LinPjmtTool::$metaTags['exif'][$value]['pathvalue']); - + $ap = explode('/', + LinPjmtTool::$metaTags['exif'][$value]['pathvalue']); + switch(count($ap)) { case 2 : if(isset($exif_data[$ap[0]][$ap[1]]['Text Value'])) { //echo "DATA:".$exif_data[$ap[0]][$ap[1]]['Text Value']."<br>"; - $dataArray[$value] = - LinSql::linAddslashes(trim($exif_data[$ap[0]][$ap[1]]['Text Value'])); + $dataArray[$value] = + LinSql::linAddslashes(trim($exif_data[$ap[0]][$ap[1]]['Text Value'])); } - break; + break; case 5 : if(isset($exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value'])) { //echo "DATA2".$exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value']; $dataArray[$value] = - LinSql::linAddslashes(trim($exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value'])); + LinSql::linAddslashes(trim($exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value'])); } - break; + break; } } } - if(is_array($dataArray)){ - return $dataArray; - }else { - return array(); + if(is_array($dataArray)){ + return $dataArray; + }else { + return array(); + } + } - - } } - + /** * Save all MetaData to database * @param string $filename filename to parse for MetaData * @param string $md5sum md5sum of file - * @param string $tag save IPTC or XMP MetaData + * @param string $tag save IPTC or XMP MetaData */ public function saveMetaData($filename, $md5sum, $metatype) { @@ -123,7 +122,7 @@ * special tags */ // Canon Owner Name append to Artist - if (isset ($exif_data['Makernote_Tag']['Decoded Data']) + 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'])) { @@ -140,19 +139,19 @@ } /** - * search for valid tags + * search for valid tags */ foreach($this->defined_fields['exif'] AS $key => $value) { if(!empty(LinPjmtTool::$metaTags['exif'][$key]['pathvalue'])) { /** - * there are currently only entries at level deep 2 and 5 + * there are currently only entries at level deep 2 and 5 * in the array */ - $ap = explode('/', - LinPjmtTool::$metaTags['exif'][$key]['pathvalue']); - + $ap = explode('/', + LinPjmtTool::$metaTags['exif'][$key]['pathvalue']); + switch(count($ap)) { case 2 : @@ -174,8 +173,8 @@ } break; default : - echo "Error no valid path for key: " . $key . " value: " . - LinPjmtTool::$metaTags['exif'][$key]['pathvalue'] . "<br />"; + echo "Error no valid path for key: " . $key . " value: " . + LinPjmtTool::$metaTags['exif'][$key]['pathvalue'] . "<br />"; break; } } @@ -202,12 +201,11 @@ $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); $str_values = substr($str_values, 0, strlen($str_values) - 2); - $GLOBALS['linpha']->db->Execute("INSERT INTO " . LIN_PREFIX . + $GLOBALS['linpha']->db->Execute("INSERT INTO " . LIN_PREFIX . "meta_exif (" . $str_columns . ") " . "VALUES (" . $str_values . ")"); } - /** * Define tags to index and set available fields * @param string $tag [exif] @@ -217,7 +215,7 @@ /** * create defined_fields * use a new array with lowercase keys without the md5sum entry - * MetaColumns() returns the keys always uppercase + * MetaColumns() returns the keys always uppercase * independent of ADODB_ASSOC_CASE */ $array = $GLOBALS['linpha']->db->MetaColumns(LIN_PREFIX."meta_".$tag); @@ -228,8 +226,8 @@ if ($key != 'MD5SUM') { $new_key = strtolower($key); - $this->defined_fields[$tag][$new_key] = - LinPjmtTool::$metaTags[$tag][$new_key]['name']; + $this->defined_fields[$tag][$new_key] = + LinPjmtTool::$metaTags[$tag][$new_key]['name']; } } @@ -245,15 +243,14 @@ } } - /** - * Simple method to return just exif date and orientation tag during - * import as needed by linpha_photos, this is not used for any meta_x table. + * Simple method to return just exif date and orientation tag during + * import as needed by linpha_photos, this is not used for any meta_x table. * example: 2004:02:14 18:24:19 and -90 - * + * * @param string $dirname, $filename * @return array $time_exif (unix timestamp) - * $rotate (degrees to rotate) + * $rotate (degrees to rotate) * @author bzrudi,flo **/ public function getBasicMeta($dirname, $filename) @@ -261,12 +258,12 @@ include_once( LINPHA_DIR.'/lib/pjmt/EXIF.php' ); $date = ""; $meta = get_EXIF_JPEG($dirname.'/'.$filename); - + if(isset($meta[0][34665]['Data'][0][36867]['Data'][0]) ) { $date = $meta[0][34665]['Data'][0][36867]['Data'][0]; } - + if(strlen($date) > 4) { $year = substr($date, 0, 4); @@ -279,29 +276,48 @@ } else { - $time_exif = "0"; + $time_exif = "0"; } - + if(isset($meta[0][274]['Data'][0])) { - $rotate = $meta[0][274]['Data'][0]; + $rotate = $meta[0][274]['Data'][0]; } else { - $rotate = "0"; + $rotate = "0"; } - - - return array($time_exif, $rotate); - + + + return array($time_exif, $rotate); + } /** + * Just get DateTimeOriginal from EXIF header + * + * @param filename $filename + * @return DateTimeOriginal as string + */ + public function getDateTimeOriginal($filename) + { + include_once( LINPHA_DIR.'/lib/pjmt/EXIF.php' ); + $date = ""; + $meta = @get_EXIF_JPEG($filename); + + if(isset($meta[0][34665]['Data'][0][36867]['Data'][0]) ) + { + $image_date = $meta[0][34665]['Data'][0][36867]['Data'][0]; + } + return $image_date; + } + + /** * Define array with allowed EXIF tags and human readable translation * @param none - * @return none - * @author flo - */ + * @return none + * @author flo + */ public static $metaTags = array ( 'exif' => array ( @@ -310,595 +326,595 @@ 'name' => 'Image Width', 'pathkey' => 'ImageWidth', 'pathvalue' => '' - ), + ), 'imagelength' => array ( 'name' => 'Image Length', 'pathkey' => 'ImageLength', 'pathvalue' => '' - ), + ), 'bitspersample' => array ( 'name' => 'Bits Per Sample', 'pathkey' => 'BitsPerSample', 'pathvalue' => '' - ), + ), 'compression' => array ( 'name' => 'Compression', 'pathkey' => 'Compression', 'pathvalue' => '' - ), + ), 'photometricinterpretation' => array ( 'name' => 'Photometric Interpretation', 'pathkey' => 'PhotometricInterpretation', 'pathvalue' => '' - ), + ), 'orientation' => array ( 'name' => 'Orientation', 'pathkey' => 'Orientation', 'pathvalue' => '0/274' - ), + ), 'samplesperpixel' => array ( 'name' => 'Samples Per Pixel', 'pathkey' => 'SamplesPerPixel', 'pathvalue' => '' - ), + ), 'planarconfiguration' => array ( 'name' => 'Planar Configuration', 'pathkey' => 'PlanarConfiguration', 'pathvalue' => '' - ), + ), 'ycbcrsubsampling' => array ( 'name' => 'YCbCr Sub Sampling', 'pathkey' => 'YCbCrSubSampling', 'pathvalue' => '' - ), + ), 'ycbcrpositioning' => array ( 'name' => 'YCbCr Positioning', 'pathkey' => 'YCbCrPositioning', 'pathvalue' => '0/531' - ), + ), 'xresolution' => array ( 'name' => 'X Resolution', 'pathkey' => 'XResolution', 'pathvalue' => '0/282' - ), + ), 'yresolution' => array ( 'name' => 'Y Resolution', 'pathkey' => 'YResolution', 'pathvalue' => '0/283' - ), + ), 'resolutionunit' => array ( 'name' => 'Resolution Unit', 'pathkey' => 'ResolutionUnit', 'pathvalue' => '0/296' - ), + ), 'stripoffsets' => array ( 'name' => 'Strip Offsets', 'pathkey' => 'StripOffsets', 'pathvalue' => '' - ), + ), 'rowsperstrip' => array ( 'name' => 'Rows Per Strip', 'pathkey' => 'RowsPerStrip', 'pathvalue' => '' - ), + ), 'stripbytecounts' => array ( 'name' => 'Strip Byte Counts', 'pathkey' => 'StripByteCounts', 'pathvalue' => '' - ), + ), 'jpeginterchangeformat' => array ( 'name' => 'JPEG Interchange Format', 'pathkey' => 'JPEGInterchangeFormat', 'pathvalue' => '' - ), + ), 'jpeginterchangeformatlength' => array ( 'name' => 'JPEG Interchange Format Length', 'pathkey' => 'JPEGInterchangeFormatLength', 'pathvalue' => '' - ), + ), 'transferfunction' => array ( 'name' => 'Transfer Function', 'pathkey' => 'TransferFunction', 'pathvalue' => '' - ), + ), 'whitepoint' => array ( 'name' => 'White Point', 'pathkey' => 'WhitePoint', 'pathvalue' => '' - ), + ), 'primarychromaticities' => array ( 'name' => 'Primary Chromaticities', 'pathkey' => 'PrimaryChromaticities', 'pathvalue' => '' - ), + ), 'ycbcrcoefficients' => array ( 'name' => 'YCbCr Coefficients', 'pathkey' => 'YCbCrCoefficients', 'pathvalue' => '' - ), + ), 'referenceblackwhite' => array ( 'name' => 'Reference Black White', 'pathkey' => 'ReferenceBlackWhite', 'pathvalue' => '' - ), + ), 'datetime' => array ( 'name' => 'Date Time', 'pathkey' => 'DateTime', 'pathvalue' => '0/306' - ), + ), 'imagedescription' => array ( 'name' => 'Image Description', 'pathkey' => 'ImageDescription', 'pathvalue' => '0/270' - ), + ), 'make' => array ( 'name' => 'Make', 'pathkey' => 'Make', 'pathvalue' => '0/271' - ), + ), 'model' => array ( 'name' => 'Model', 'pathkey' => 'Model', 'pathvalue' => '0/272' - ), + ), 'software' => array ( 'name' => 'Software', 'pathkey' => 'Software', 'pathvalue' => '0/305' - ), + ), 'artist' => array ( 'name' => 'Artist', 'pathkey' => 'Artist', 'pathvalue' => '0/315' - ), + ), 'copyright' => array ( 'name' => 'Copyright', 'pathkey' => 'Copyright', 'pathvalue' => '0/33432' - ), + ), 'exifversion' => array ( 'name' => 'Exif Version', 'pathkey' => 'ExifVersion', 'pathvalue' => '0/34665/Data/0/36864' - ), + ), 'flashpixversion' => array ( 'name' => 'FlashPix Version', 'pathkey' => 'FlashpixVersion', 'pathvalue' => '0/34665/Data/0/40960' - ), + ), 'colorspace' => array ( 'name' => 'Color Space', 'pathkey' => 'ColorSpace', 'pathvalue' => '0/34665/Data/0/40961' - ), + ), 'componentsconfiguration' => array ( 'name' => 'Components Configuration', 'pathkey' => 'ComponentsConfiguration', 'pathvalue' => '0/34665/Data/0/37121' - ), + ), 'compressedbitsperpixel' => array ( 'name' => 'Compressed Bits Per Pixel', 'pathkey' => 'CompressedBitsPerPixel', 'pathvalue' => '0/34665/Data/0/37122' - ), + ), 'pixelxdimension' => array ( 'name' => 'Pixel X Dimension', 'pathkey' => 'PixelXDimension', 'pathvalue' => '0/34665/Data/0/40962' - ), + ), 'pixelydimension' => array ( 'name' => 'Pixel Y Dimension', 'pathkey' => 'PixelYDimension', 'pathvalue' => '0/34665/Data/0/40963' - ), + ), 'usercomment' => array ( 'name' => 'User Comment', 'pathkey' => 'UserComment', 'pathvalue' => '0/34665/Data/0/37510' - ), + ), 'relatedsoundfile' => array ( 'name' => 'Related Sound File', 'pathkey' => 'RelatedSoundFile', 'pathvalue' => '' - ), + ), 'datetimeoriginal' => array ( 'name' => 'Date Time Original', 'pathkey' => 'DateTimeOriginal', 'pathvalue' => '0/34665/Data/0/36867' - ), + ), 'datetimedigitized' => array ( 'name' => 'Date Time Digitized', 'pathkey' => 'DateTimeDigitized', 'pathvalue' => '0/34665/Data/0/36868' - ), + ), 'subsectime' => array ( 'name' => 'Sub Sec Time', 'pathkey' => 'SubSecTime', 'pathvalue' => '' - ), + ), 'subsectimeoriginal' => array ( 'name' => 'Sub Sec Time Original', 'pathkey' => 'SubSecTimeOriginal', 'pathvalue' => '' - ), + ), 'subsectimedigitized' => array ( 'name' => 'Sub Sec Time Digitized', 'pathkey' => 'SubSecTimeDigitized', 'pathvalue' => '' - ), + ), 'exposuretime' => array ( 'name' => 'Exposure Time', 'pathkey' => 'ExposureTime', 'pathvalue' => '0/34665/Data/0/33434' - ), + ), 'fnumber' => array ( 'name' => 'F Number', 'pathkey' => 'FNumber', 'pathvalue' => '0/34665/Data/0/33437' - ), + ), 'exposureprogram' => array ( 'name' => 'Exposure Program', 'pathkey' => 'ExposureProgram', 'pathvalue' => '0/34665/Data/0/34850' - ), + ), 'spectralsensitivity' => array ( 'name' => 'Spectral Sensitivity', 'pathkey' => 'SpectralSensitivity', 'pathvalue' => '' - ), + ), 'isospeedratings' => array ( 'name' => 'ISO Speed Ratings', 'pathkey' => 'ISOSpeedRatings', 'pathvalue' => '0/34665/Data/0/34855' - ), + ), 'oecf' => array ( 'name' => 'OECF', 'pathkey' => 'OECF', 'pathvalue' => '' - ), + ), 'shutterspeedvalue' => array ( 'name' => 'Shutter Speed Value', 'pathkey' => 'ShutterSpeedValue', 'pathvalue' => '0/34665/Data/0/37377' - ), + ), 'aperturevalue' => array ( 'name' => 'Aperture Value', 'pathkey' => 'ApertureValue', 'pathvalue' => '0/34665/Data/0/37378' - ), + ), 'brightnessvalue' => array ( 'name' => 'Brightness Value', 'pathkey' => 'BrightnessValue', 'pathvalue' => '0/34665/Data/0/37379' - ), + ), 'exposurebiasvalue' => array ( 'name' => 'Exposure Bias Value', 'pathkey' => 'ExposureBiasValue', 'pathvalue' => '0/34665/Data/0/37380' - ), + ), 'maxaperturevalue' => array ( 'name' => 'MaxAperture Value', 'pathkey' => 'MaxApertureValue', 'pathvalue' => '0/34665/Data/0/37381' - ), + ), 'subjectdistance' => array ( 'name' => 'Subject Distance', 'pathkey' => 'SubjectDistance', 'pathvalue' => '0/34665/Data/0/37382' - ), + ), 'meteringmode' => array ( 'name' => 'Metering Mode', 'pathkey' => 'MeteringMode', 'pathvalue' => '0/34665/Data/0/37383' - ), + ), 'lightsource' => array ( 'name' => 'Light Source', 'pathkey' => 'LightSource', 'pathvalue' => '0/34665/Data/0/37384' - ), + ), 'flash' => array ( 'name' => 'Flash', 'pathkey' => 'Flash', 'pathvalue' => '0/34665/Data/0/37385' - ), + ), 'focallength' => array ( 'name' => 'Focal Length', 'pathkey' => 'FocalLength', 'pathvalue' => '0/34665/Data/0/37386' - ), + ), 'subjectarea' => array ( 'name' => 'Subject Area', 'pathkey' => 'SubjectArea', 'pathvalue' => '' - ), + ), 'flashenergy' => array ( 'name' => 'Flash Energy', 'pathkey' => 'FlashEnergy', 'pathvalue' => '' - ), + ), 'spatialfrequencyresponse' => array ( 'name' => 'Spatial Frequency Response', 'pathkey' => 'SpatialFrequencyResponse', 'pathvalue' => '' - ), + ), 'focalplanexresolution' => array ( 'name' => 'Focal Plane X Resolution', 'pathkey' => 'FocalPlaneXResolution', 'pathvalue' => '0/34665/Data/0/41486' - ), + ), 'focalplaneyresolution' => array ( 'name' => 'Foca Plane Y Resolution', 'pathkey' => 'FocalPlaneYResolution', 'pathvalue' => '0/34665/Data/0/41487' - ), + ), 'focalplaneresolutionunit' => array ( 'name' => 'Focal Plane Resolution Unit', 'pathkey' => 'FocalPlaneResolutionUnit', 'pathvalue' => '0/34665/Data/0/41488' - ), + ), 'subjectlocation' => array ( 'name' => 'Subject Location', 'pathkey' => 'SubjectLocation', 'pathvalue' => '' - ), + ), 'exposureindex' => array ( 'name' => 'Exposure Index', 'pathkey' => 'ExposureIndex', 'pathvalue' => '' - ), + ), 'sensingmethod' => array ( 'name' => 'Sensing Method', 'pathkey' => 'SensingMethod', 'pathvalue' => '0/34665/Data/0/41495' - ), + ), 'filesource' => array ( 'name' => 'File Source', 'pathkey' => 'FileSource', 'pathvalue' => '0/34665/Data/0/41728' - ), + ), 'scenetype' => array ( 'name' => 'Scene Type', 'pathkey' => 'SceneType', 'pathvalue' => '0/34665/Data/0/41729' - ), + ), 'cfapattern' => array ( 'name' => 'CFA Pattern', 'pathkey' => 'CFAPattern', 'pathvalue' => '' - ), + ), 'customrendered' => array ( 'name' => 'Custom Rendered', 'pathkey' => 'CustomRendered', 'pathvalue' => '0/34665/Data/0/41985' - ), + ), 'exposuremode' => array ( 'name' => 'Exposure Mode', 'pathkey' => 'ExposureMode', 'pathvalue' => '0/34665/Data/0/41986' - ), + ), 'whitebalance' => array ( 'name' => 'White Balance', 'pathkey' => 'WhiteBalance', 'pathvalue' => '0/34665/Data/0/41987' - ), + ), 'digitalzoomratio' => array ( 'name' => 'Digital Zoom Ratio', 'pathkey' => 'DigitalZoomRatio', 'pathvalue' => '0/34665/Data/0/41988' - ), + ), 'focallengthin35mmfilm' => array ( 'name' => 'Focal Length In 35mm Film', 'pathkey' => 'FocalLengthIn35mmFilm', 'pathvalue' => '' - ), + ), 'scenecapturetype' => array ( 'name' => 'Scene Capture Type', 'pathkey' => 'SceneCaptureType', 'pathvalue' => '0/34665/Data/0/41990' - ), + ), 'gaincontrol' => array ( 'name' => 'Gain Control', 'pathkey' => 'GainControl', 'pathvalue' => '0/34665/Data/0/41991' - ), + ), 'contrast' => array ( 'name' => 'Contrast', 'pathkey' => 'Contrast', 'pathvalue' => '0/34665/Data/0/41992' - ), + ), 'saturation' => array ( 'name' => 'Saturation', 'pathkey' => 'Saturation', 'pathvalue' => '0/34665/Data/0/41993' - ), + ), 'sharpness' => array ( 'name' => 'Sharpness', 'pathkey' => 'Sharpness', 'pathvalue' => '0/34665/Data/0/41994' - ), + ), 'devicesettingdescription' => array ( 'name' => 'Device Setting Description', 'pathkey' => 'DeviceSettingDescription', 'pathvalue' => '' - ), + ), 'subjectdistancerange' => array ( 'name' => 'Subject Distance Range', 'pathkey' => 'SubjectDistanceRange', 'pathvalue' => '' - ), + ), 'imageuniqueid' => array ( 'name' => 'Image Unique ID', 'pathkey' => 'ImageUniqueID', 'pathvalue' => '' - ), + ), 'gpsversionid' => array ( 'name' => 'GPS Version ID', 'pathkey' => 'GPSVersionID', 'pathvalue' => '0/34853/Data/0/0' - ), + ), 'gpslatituderef' => array ( 'name' => 'GPS Latitude Ref', 'pathkey' => 'GPSLatitudeRef', 'pathvalue' => '0/34853/Data/0/1' - ), + ), 'gpslatitude' => array ( 'name' => 'GPS Latitude', 'pathkey' => 'GPSLatitude', 'pathvalue' => '0/34853/Data/0/2' - ), + ), 'gpslongituderef' => array ( 'name' => 'GPS Longitude Ref', 'pathkey' => 'GPSLongitudeRef', 'pathvalue' => '0/34853/Data/0/3' - ), + ), 'gpslongitude' => array ( 'name' => 'GPS Longitude', 'pathkey' => 'GPSLongitude', 'pathvalue' => '0/34853/Data/0/4' - ), + ), 'gpsaltituderef' => array ( 'name' => 'GPS Altitude Ref', 'pathkey' => 'GPSAltitudeRef', 'pathvalue' => '0/34853/Data/0/5' - ), + ), 'gpsaltitude' => array ( 'name' => 'GPS Altitude', 'pathkey' => 'GPSAltitude', 'pathvalue' => '0/34853/Data/0/6' - ), + ), 'gpstimestamp' => array ( 'name' => 'GPS Timestamp', 'pathkey' => 'GPSTimeStamp', 'pathvalue' => '0/34853/Data/0/7' - ), + ), 'gpssatellites' => array ( 'name' => 'GPS Satellites', 'pathkey' => 'GPSSatellites', 'pathvalue' => '0/34853/Data/0/8' - ), + ), 'gpsstatus' => array ( 'name' => 'GPS Status', 'pathkey' => 'GPSStatus', 'pathvalue' => '0/34853/Data/0/9' - ), + ), 'gpsmeasuremode' => array ( 'name' => 'GPS Measure Mode', 'pathkey' => 'GPSMeasureMode', 'pathvalue' => '0/34853/Data/0/10' - ), + ), 'gpsdop' => array ( 'name' => 'GPS DOP', 'pathkey' => 'GPSDOP', 'pathvalue' => '0/34853/Data/0/11' - ), + ), 'gpsspeedref' => array ( 'name' => 'GPS Speed Ref', 'pathkey' => 'GPSSpeedRef', 'pathvalue' => '0/34853/Data/0/12' - ), + ), 'gpsspeed' => array ( 'name' => 'GPS Speed', 'pathkey' => 'GPSSpeed', 'pathvalue' => '0/34853/Data/0/13' - ), + ), 'gpstrackref' => array ( 'name' => 'GPS Track Ref', 'pathkey' => 'GPSTrackRef', 'pathvalue' => '0/34853/Data/0/14' - ), + ), 'gpstrack' => array ( 'name' => 'GPS Track', 'pathkey' => 'GPSTrack', 'pathvalue' => '0/34853/Data/0/15' - ), + ), 'gpsimgdirectionref' => array ( 'name' => 'GPS Img Direction Ref', 'pathkey' => 'GPSImgDirectionRef', 'pathvalue' => '0/34853/Data/0/16' - ), + ), 'gpsimgdirection' => array ( 'name' => 'GPS Img Direction', 'pathkey' => 'GPSImgDirection', 'pathvalue' => '0/34853/Data/0/17' - ), + ), 'gpsmapdatum' => array ( 'name' => 'GPS Map Datum', 'pathkey' => 'GPSMapDatum', 'pathvalue' => '0/34853/Data/0/18' - ), + ), 'gpsdestlatituderef' => array ( 'name' => 'GPS Dest Latitude Ref', 'pathkey' => 'GPSDestLatitudeRef', 'pathvalue' => '0/34853/Data/0/19' - ), + ), 'gpsdestlatitude' => array ( 'name' => 'GPS Dest Latitude', 'pathkey' => 'GPSDestLatitude', 'pathvalue' => '0/34853/Data/0/20' - ), + ), 'gpsdestlongituderef' => array ( 'name' => 'GPS Dest Longitude Ref', 'pathkey' => 'GPSDestLongitudeRef', 'pathvalue' => '0/34853/Data/0/21' - ), + ), 'gpsdestlongitude' => array ( 'name' => 'GPS Dest Longitude', 'pathkey' => 'GPSDestLongitude', 'pathvalue' => '0/34853/Data/0/22' - ), + ), 'gpsdestbearingref' => array ( 'name' => 'GPS Dest Bearing Ref', 'pathkey' => 'GPSDestBearingRef', 'pathvalue' => '0/34853/Data/0/23' - ), + ), 'gpsdestbearing' => array ( 'name' => 'GPS Dest Bearing', 'pathkey' => 'GPSDestBearing', 'pathvalue' => '0/34853/Data/0/24' - ), + ), 'gpsdestdistanceref' => array ( 'name' => 'GPS Dest Distance Ref', 'pathkey' => 'GPSDestDistanceRef', 'pathvalue' => '0/34853/Data/0/25' - ), + ), 'gpsdestdistance' => array ( 'name' => 'GPS Dest Distance', 'pathkey' => 'GPSDestDistance', 'pathvalue' => '0/34853/Data/0/26' - ), + ), 'gpsprocessingmethod' => array ( 'name' => 'GPS Processing Method', 'pathkey' => 'GPSProcessingMethod', 'pathvalue' => '0/34853/Data/0/27' - ), + ), 'gpsareainformation' => array ( 'name' => 'GPS Area Information', 'pathkey' => 'GPSAreaInformation', 'pathvalue' => '0/34853/Data/0/28' - ), + ), 'gpsdatestamp' => array ( 'name' => 'GPS DateStamp', 'pathkey' => 'GPSDateStamp', 'pathvalue' => '0/34853/Data/0/29' - ), + ), 'gpsdifferential' => array ( 'name' => 'GPS Differential', 'pathkey' => 'GPSDifferential', 'pathvalue' => '0/34853/Data/0/30' - ), + ), 'jpegcomment' => array ( 'name' => 'JPEG Comment', 'pathkey' => 'JpegComment', 'pathvalue' => '' - ), - - ), - - ); + ), + ), + + ); + } /* vi: set ts=4 sw=4 sts=4 */ ?> Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-31 19:57:11 UTC (rev 4845) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2008-02-01 13:37:03 UTC (rev 4846) @@ -24,11 +24,22 @@ */ if(!defined('LINPHA_DIR')) { exit(1); } include_once LINPHA_DIR.'/lib/plugins/maps/xml_parser.class.php'; -/* + $GPXData = new LinXmlParser(); $array_with_gpx = $GPXData->readXmlFile('/tmp/sample.gpx'); -echo "<pre>", print_r($array_with_gpx), "</pre>"; -*/ +$track_times = $GPXData->getGpxTimeRange($array_with_gpx); +$image_times = $GPXData->getImageTimeRange(19); +if($GPXData->compareTimeRanges($track_times, $image_times)) +{ + echo " ALL OK"; + } + else + { + echo "TRACK ERROR"; + } + +//echo "<pre>", print_r($array_with_gpx), "</pre>"; + /** * xml load/save stuff */ Modified: trunk/linpha2/lib/plugins/maps/xml_parser.class.php =================================================================== --- trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-01-31 19:57:11 UTC (rev 4845) +++ trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-01 13:37:03 UTC (rev 4846) @@ -18,7 +18,9 @@ */ if(!defined('TOP_DIR')) { define('TOP_DIR','../../'); } +//include_once LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'; + /** * Class to parse Garmin GPX files and return values for * latitiude, longitude, elevation, time and more. @@ -27,12 +29,13 @@ class LinXmlParser { private $data, $parser, $filename, $values, $index_array; - private $data_range, $gpx, $xml_data; + private $data_range, $gpx, $xml_data , $meta_data; function __construct() { } + /** * This method reads all trackpoints and related data from an xml file and * returns them as an array, example: @@ -131,7 +134,142 @@ return $this->gpx; } -} + /** + * This method checks for start and end date/time for the gpx file + * @param array with all trkpt informtion from file + * @return array (starttime, endtime); + * @author bzrudi + */ + public function getGpxTimeRange($gpx_data) + { + $date_min = '9999999999'; + $date_max = '0'; + + foreach($gpx_data AS $key => $value) + { + if(isset($value['time'])) + { + $current_time = $this->date2unixTime($value['time']); + + if($current_time < $date_min) + { + $date_min = $current_time; + } + elseif($current_time > $date_max) + { + $date_max = $current_time; + } + + } + } + echo "MIN ".$date_min." -- "; + echo "MAX ".$date_max; + echo " DIFF ".($date_max - $date_min)."<br>"; + echo "TRACK START AM:".date("Y-m-d, H-i-s", $date_min); + echo " TRACK ENDE UM:".date("Y-m-d, H-i-s", $date_max)."<br>"; + + return array("starttime" => $date_min, "endtime" => $date_max); + } + + + /** + * This method checks parses all images in folder and get's start and + * end date/time. + * @param int parent_id for images to parse + * @return array (starttime, endtime); + * @author bzrudi + */ + public function getImageTimeRange($parent_id) + { + $date_min = '9999999999'; + $date_max = '0'; + + $query = $GLOBALS['linpha']->db->Execute("SELECT id " . +... [truncated message content] |
From: <bz...@us...> - 2008-02-01 18:08:19
|
Revision: 4847 http://linpha.svn.sourceforge.net/linpha/?rev=4847&view=rev Author: bzrudi Date: 2008-02-01 10:08:14 -0800 (Fri, 01 Feb 2008) Log Message: ----------- Add new file modules.geodata.php Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/index.php trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/lib/plugins/maps/xml_parser.class.php Added Paths: ----------- trunk/linpha2/lib/modules/module.geodata.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-02-01 13:37:03 UTC (rev 4846) +++ trunk/linpha2/ChangeLog 2008-02-01 18:08:14 UTC (rev 4847) @@ -3,6 +3,8 @@ for getting all required timestamps (starttime/endtime) from xml file as well as the image EXIF datetimeoriginal tag from all images in folder. * Add some required new methods to LinMetaData() class + * Add new file modules.geodata.php for testing all geodata stuff + * some basic test work alright now 2008-01-31 bzrudi * Maps plugin Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2008-02-01 13:37:03 UTC (rev 4846) +++ trunk/linpha2/index.php 2008-02-01 18:08:14 UTC (rev 4847) @@ -64,6 +64,9 @@ case 'download': require_once(LINPHA_DIR.'/lib/modules/module.download.php'); break; +case 'geodata': + require_once(LINPHA_DIR.'/lib/modules/module.geodata.php'); + break; case 'empty': require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); break; Added: trunk/linpha2/lib/modules/module.geodata.php =================================================================== --- trunk/linpha2/lib/modules/module.geodata.php (rev 0) +++ trunk/linpha2/lib/modules/module.geodata.php 2008-02-01 18:08:14 UTC (rev 4847) @@ -0,0 +1,44 @@ +<?php +/* + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +if (!defined('LINPHA_DIR')) { exit (1); } +include_once LINPHA_DIR.'/lib/plugins/maps/xml_parser.class.php'; + +$GPXData = new LinXmlParser(); +$array_with_gpx = $GPXData->readXmlFile('/tmp/sample.gpx'); +$track_times = $GPXData->getGpxTimeRange($array_with_gpx); +$image_times = $GPXData->getImageTimeRange(41); //parent_id linpha_photos + +echo "<br>***OFFSET CHECKING***"; + +if($GPXData->compareTimeRanges($track_times, $image_times)) +{ + echo "<br>Time range OK, going checking offset<br>"; + $GPXData->fixImagesOffset($track_times, $image_times); +} +else +{ + echo "<br>Time Range error - images time range is larger than track time"; + echo "ABORT"; +} + + +//echo "<pre>", print_r($array_with_gpx), "</pre>"; +?> \ No newline at end of file Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2008-02-01 13:37:03 UTC (rev 4846) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2008-02-01 18:08:14 UTC (rev 4847) @@ -23,23 +23,7 @@ * @package Plugins */ if(!defined('LINPHA_DIR')) { exit(1); } -include_once LINPHA_DIR.'/lib/plugins/maps/xml_parser.class.php'; -$GPXData = new LinXmlParser(); -$array_with_gpx = $GPXData->readXmlFile('/tmp/sample.gpx'); -$track_times = $GPXData->getGpxTimeRange($array_with_gpx); -$image_times = $GPXData->getImageTimeRange(19); -if($GPXData->compareTimeRanges($track_times, $image_times)) -{ - echo " ALL OK"; - } - else - { - echo "TRACK ERROR"; - } - -//echo "<pre>", print_r($array_with_gpx), "</pre>"; - /** * xml load/save stuff */ @@ -146,7 +130,7 @@ { if( !isset($_POST['linInputZoom']) OR empty($_POST['linInputZoom']) ) { - $_POST['linInputZoom'] = $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; + //echo "<pre>", print_r($array_with_gpx), "</pre>"; $_POST['linInputZoom'] = $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; } if( $_POST['cmd'] == 'saveMarker' ) Modified: trunk/linpha2/lib/plugins/maps/xml_parser.class.php =================================================================== --- trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-01 13:37:03 UTC (rev 4846) +++ trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-01 18:08:14 UTC (rev 4847) @@ -163,19 +163,19 @@ } } - echo "MIN ".$date_min." -- "; - echo "MAX ".$date_max; - echo " DIFF ".($date_max - $date_min)."<br>"; - echo "TRACK START AM:".date("Y-m-d, H-i-s", $date_min); - echo " TRACK ENDE UM:".date("Y-m-d, H-i-s", $date_max)."<br>"; - + echo "**TRACK INFO**<br>"; + echo "min ".$date_min." -- "; + echo "max ".$date_max; + echo " length ".($date_max - $date_min)."<br>"; + echo "track starts from: ".date("Y:m:d H:i:s", $date_min); + echo " track ends at: ".date("Y:m:d H:i:s", $date_max)."<br><br>"; + return array("starttime" => $date_min, "endtime" => $date_max); } - - + /** - * This method checks parses all images in folder and get's start and - * end date/time. + * This method checks parses all images in folder and get's start and + * end date/time. * @param int parent_id for images to parse * @return array (starttime, endtime); * @author bzrudi @@ -201,6 +201,12 @@ $current_time = $metaData->getDateTimeOriginal($filename); $current_time = $this->date2unixTime($current_time); + /** + * Buffer data, so we don't need to read image header again + * and again + */ + $geodata[$current_time] = $filename; + if($current_time < $date_min) { $date_min = $current_time; @@ -211,14 +217,15 @@ } } } - echo "MIN ".$date_min." -- "; - echo "MAX ".$date_max; - echo "DIFF ".($date_max - $date_min)."<br>"; - - echo "IMAGE START AM:".date("Y-m-d, H-i-s", $date_min); - echo " IMAGE ENDE UM:".date("Y-m-d, H-i-s", $date_max); - - return array("starttime" => $date_min, "endtime" => $date_max); + echo "**IMAGE INFO**<br>"; + echo "min ".$date_min." -- "; + echo "max ".$date_max; + echo " length ".($date_max - $date_min)."<br>"; + + echo "images start from: ".date("Y:m:d H:i:s", $date_min); + echo " images end at: ".date("Y:m:d H:i:s", $date_max)."<br>"; + + return array("starttime" => $date_min, "endtime" => $date_max, "geodata" => $geodata); } /** @@ -235,7 +242,7 @@ * Example EXIF 2007:07:17 09:25:16 */ unset($time_unix); - + $year = substr($datetime, 0, 4); $month = substr($datetime, 5, 2); $day = substr($datetime, 8, 2); @@ -245,9 +252,9 @@ $time_unix = mktime($hour, $min, $sec, $month, $day, $year); return $time_unix; } - + /** - * Compare time ranges for track and images. E.g time range for images + * Compare time ranges for track and images. E.g time range for images * must be smaller than the range for tracks. * @param $array start/endtime track * @param $array start/endtime images @@ -258,7 +265,7 @@ { $time_track = ($track['endtime'] - $track['starttime']); $time_images = ($images['endtime'] - $images['starttime']); - + if($time_images <= $time_track) { return true; @@ -267,8 +274,84 @@ { return false; } - } + } + /** + * Check for offset. E.g. all images must be taken within track time range + * + */ + public function fixImagesOffset($track, $images) + { + /** + * Number off imges out of sync + */ + $no_offsync = '0'; + + if($images['starttime'] < $track['starttime']) + { + echo "Offset detected, images start earlier...<br>"; + print_r($images['geodata']); + } + elseif($images['endtime'] > $track['endtime']) + { + echo "Offset detected, images end later...<br>"; + + $number = count($images['geodata']); + + while(list($image_time, $filename) = each($images['geodata'])) + { + if($image_time > $track['endtime']) + { + $no_offsync++; + $files_offsync[] = $filename; + } + } + echo "$no_offsync "."out of ".$number ." images are out of sync...<br>"; + echo "We have an offset of ".($images['endtime']-$track['endtime'])." " . + "seconds, which is about ".(($images['endtime']-$track['endtime'])/3600)." hours"; + echo "<br>Calibrating...<br>"; + + if($no_offsync > '0') + { + $full_hour = round(($images['endtime']-$track['endtime'])/3600, '0'); + + if($full_hour != '0') + { + echo "Usually offset is because of wrong UTC/GMT settings, so " . + "trying full hours first<br>"; + echo "Setting full hour offset to ".$full_hour." h<br>"; + echo "Faking image times... new setting -$full_hour h<br>"; + + $offset = ($full_hour*3600); + + } + else + { + echo "Danm, looks like we have an time skew < 1h - not so good<br>"; + echo "Setting offset to 5 min...<br>"; + echo "Faking image times... new setting -5 min<br>"; + + $offset = '300'; + } + + foreach($images['geodata'] AS $image_time => $filename) + { + $geo_tmp[($image_time-$offset)] = $filename; + } + + $image_tmp = array("starttime" => ($images['starttime'] - $offset), + "endtime" => ($images['endtime'] - $offset), + "geodata" => $geo_tmp ); + + echo "Rerunning offset test...<br>"; + $this->fixImagesOffset($track, $image_tmp); + } + } + else + { + echo "***BINGO ALL IMAGES ARE NOW WITHIN TRACK TIME RANGE***<br>"; + } + } }// end class /* vi: set ts=4 sw=4 sts=4 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2008-02-02 13:11:43
|
Revision: 4848 http://linpha.svn.sourceforge.net/linpha/?rev=4848&view=rev Author: bzrudi Date: 2008-02-02 05:11:40 -0800 (Sat, 02 Feb 2008) Log Message: ----------- even more improvements to gpx stuff Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/modules/module.geodata.php trunk/linpha2/lib/plugins/maps/xml_parser.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-02-01 18:08:14 UTC (rev 4847) +++ trunk/linpha2/ChangeLog 2008-02-02 13:11:40 UTC (rev 4848) @@ -1,3 +1,9 @@ +2008-02-02 bzrudi + * It should now be possible to auto adjust images to fit tracks AND to auto + assign images to closest/nearest trackpoint in GPX file using some offset + logic. + - add some new methods for this + 2008-02-01 bzrudi * More improvements to XML parser class. XML/GPX parsing works now, same for getting all required timestamps (starttime/endtime) from xml file as @@ -4,7 +10,7 @@ well as the image EXIF datetimeoriginal tag from all images in folder. * Add some required new methods to LinMetaData() class * Add new file modules.geodata.php for testing all geodata stuff - * some basic test work alright now + * some basic tests work alright now 2008-01-31 bzrudi * Maps plugin Modified: trunk/linpha2/lib/modules/module.geodata.php =================================================================== --- trunk/linpha2/lib/modules/module.geodata.php 2008-02-01 18:08:14 UTC (rev 4847) +++ trunk/linpha2/lib/modules/module.geodata.php 2008-02-02 13:11:40 UTC (rev 4848) @@ -21,8 +21,8 @@ if (!defined('LINPHA_DIR')) { exit (1); } include_once LINPHA_DIR.'/lib/plugins/maps/xml_parser.class.php'; -$GPXData = new LinXmlParser(); -$array_with_gpx = $GPXData->readXmlFile('/tmp/sample.gpx'); +$GPXData = new LinXmlParser('/tmp/sample.gpx'); +$array_with_gpx = $GPXData->readXmlFile(); $track_times = $GPXData->getGpxTimeRange($array_with_gpx); $image_times = $GPXData->getImageTimeRange(41); //parent_id linpha_photos @@ -31,7 +31,7 @@ if($GPXData->compareTimeRanges($track_times, $image_times)) { echo "<br>Time range OK, going checking offset<br>"; - $GPXData->fixImagesOffset($track_times, $image_times); + $GPXData->fixImagesOffset($track_times, $image_times, $image_tmp=array()); } else { Modified: trunk/linpha2/lib/plugins/maps/xml_parser.class.php =================================================================== --- trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-01 18:08:14 UTC (rev 4847) +++ trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-02 13:11:40 UTC (rev 4848) @@ -31,9 +31,9 @@ private $data, $parser, $filename, $values, $index_array; private $data_range, $gpx, $xml_data , $meta_data; - function __construct() + function __construct($filename) { - + $this->filename = $filename; } /** @@ -56,12 +56,12 @@ * @param string $filename * @return array with all trackpoints */ - public function readXmlFile($filename) + public function readXmlFile() { /** * open and parse xml file for Track data */ - $this->data = file_get_contents($filename); + $this->data = file_get_contents($this->filename); $this->parser = xml_parser_create(); /** @@ -254,9 +254,10 @@ } /** - * Compare time ranges for track and images. E.g time range for images - * must be smaller than the range for tracks. - * @param $array start/endtime track + * Check for offset. E.g. all images must be taken within track time range + * Delta t for the first and last image must be smaller than delta t for + * the gpx track, this method takes care of it. + * @param $array $track start/endtime track * @param $array start/endtime images * @return bool true/false * @author bzrudi @@ -277,13 +278,16 @@ } /** - * Check for offset. E.g. all images must be taken within track time range - * - */ - public function fixImagesOffset($track, $images) + * All images must be taken within track time range delta t. If we found + * images taken earlier or later, fix it! + * @param $array $track start/endtime track + * @param $array start/endtime images + * @author bzrudi + */ + public function fixImagesOffset($track, $images) //, $image_tmp { /** - * Number off imges out of sync + * Number of images out of sync */ $no_offsync = '0'; @@ -297,7 +301,7 @@ echo "Offset detected, images end later...<br>"; $number = count($images['geodata']); - + //print_r($images['geodata']); while(list($image_time, $filename) = each($images['geodata'])) { if($image_time > $track['endtime']) @@ -314,26 +318,26 @@ if($no_offsync > '0') { $full_hour = round(($images['endtime']-$track['endtime'])/3600, '0'); - + if($full_hour != '0') { - echo "Usually offset is because of wrong UTC/GMT settings, so " . + echo "Usually offset is because of wrong UTC/GMT settings, so " . "trying full hours first<br>"; - echo "Setting full hour offset to ".$full_hour." h<br>"; - echo "Faking image times... new setting -$full_hour h<br>"; - - $offset = ($full_hour*3600); - + echo "Setting full hour offset to ".$full_hour." h<br>"; + echo "Faking image times... new setting -$full_hour h<br>"; + + $offset = ($full_hour*3600); + } else { - echo "Danm, looks like we have an time skew < 1h - not so good<br>"; - echo "Setting offset to 5 min...<br>"; - echo "Faking image times... new setting -5 min<br>"; - - $offset = '300'; + echo "Danm, looks like we have an time skew < 1h - not so good<br>"; + echo "Setting offset to 5 min...<br>"; + echo "Faking image times... new setting -5 min<br>"; + + $offset = '300'; } - + foreach($images['geodata'] AS $image_time => $filename) { $geo_tmp[($image_time-$offset)] = $filename; @@ -342,16 +346,108 @@ $image_tmp = array("starttime" => ($images['starttime'] - $offset), "endtime" => ($images['endtime'] - $offset), "geodata" => $geo_tmp ); - + echo "Rerunning offset test...<br>"; $this->fixImagesOffset($track, $image_tmp); } } else { - echo "***BINGO ALL IMAGES ARE NOW WITHIN TRACK TIME RANGE***<br>"; + echo "<br>***BINGO ALL IMAGES ARE NOW WITHIN TRACK TIME RANGE***<br>"; + $this->triggerImage2trkpt($images); } } + + /** + * This method is mainly a wrapper function for trkptradar() which does + * the main work when finding nearest trackpoint + * @param array $images with all data read from the files + * @author bzrudi + * @return none (yet) + */ + private function triggerImage2trkpt($images) + { + /** + * @todo mv to __constructor + */ + $gpx = $this->readXmlFile($this->filename); + + ksort($images['geodata']); + ksort($gpx); + + /** + * Create new array with all needed information sorted + */ + foreach($gpx AS $index => $value) + { + + $trkdata[$this->date2unixTime($value['time'])] = + array("time" => $this->date2unixTime($value['time']), + "lat" => $value['trkpt']['lat'], + "lon" => $value['trkpt']['lon']); + } + + echo "<br>***CALLING TRACKPOINT RADAR***<br>"; + + foreach($images['geodata'] AS $image_time => $image_filename) + { + echo "Trying to find match for: ".$image_time." ".$image_filename."<br>"; + + $offset = '1'; + $loop = true; + + while($loop === true) + { + $loop = $this->trkptRadar($trkdata, $image_time, $offset); + $offset++; + } + } + } + + /** + * Trackpoint radar. Try to find nearest trkpt for image + * We do this by adding an offset (positiv and negativ) of one second to + * the original image_time until we got key hit. + * + * @param array $trkdata array with time and lat lon from gpx track + * @param int $image_time current image timestamp + * @param int $offset current offset in seconds + * @author bzrudi + * @return bool + */ + private function trkptRadar($trkdata, $image_time, $offset) + { + if(array_key_exists($image_time, $trkdata)) + { + echo "Got hit after: 0 loops ".$image_time; + echo "<br>Connecting image ".$image_time." " . + "<br>to LAT: ".$trkdata[$image_time]['lat']."<br>and LON: " . + "".$trkdata[$image_time]['lon']."<br><br>"; + return false; + } + elseif(array_key_exists(($image_time + $offset), $trkdata)) + { + echo "Got hit after: +".$offset." loops ".$image_time; + echo "<br>Connecting image ".$image_time." " . + "<br>to LAT: ".$trkdata[$image_time + $offset]['lat']."<br>and LON: " . + "".$trkdata[$image_time + $offset]['lon']."<br><br>"; + return false; + } + elseif(array_key_exists(($image_time - $offset), $trkdata)) + { + echo "Got hit after: -".$offset." loops ".$image_time; + echo "<br>Connecting image ".$image_time." " . + "<br>to LAT: ".$trkdata[$image_time - $offset]['lat']."<br>and LON: " . + "".$trkdata[$image_time - $offset]['lon']."<br><br>"; + return false; + } + else + { + flush(); + return true; + } + + } }// end class /* vi: set ts=4 sw=4 sts=4 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |