Thread: [Linpha-cvs] SF.net SVN: linpha: [4393] trunk/linpha2/lib
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-03-04 10:42:43
|
Revision: 4393 Author: fangehrn Date: 2006-03-04 02:42:36 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4393&view=rev Log Message: ----------- * working on basket Added Paths: ----------- trunk/linpha2/lib/classes/linpha.template_new.class.php trunk/linpha2/lib/modules/ Added: trunk/linpha2/lib/classes/linpha.template_new.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.template_new.class.php (rev 0) +++ trunk/linpha2/lib/classes/linpha.template_new.class.php 2006-03-04 10:42:36 UTC (rev 4393) @@ -0,0 +1,65 @@ +<?php + +class linTemplate +{ + public $template_name; + + private $body_name; + private $head_name; + private $css_name; + + function __construct() + { + $this->template_name = 'main'; + } + + /** + * include the file requested, take care of css, its not included! + */ + function includeFile($what) + { + switch($what) + { + case 'body': + $filename = LINPHA_DIR.'/templates/'.$this->template_name.'_html/'.$this->body_name.'.html.php'; + break; + case 'head': + $filename = LINPHA_DIR.'/templates/'.$this->template_name.'_html/'.$this->head_name.'.head.php'; + break; + case 'css': + echo LINPHA_DIR.'/templates/'.$this->template_name.'_css/'.$this->css_name.'.css'; + break; + } + + if($what != 'css' && file_exists($filename)) + { + include_once( $filename ); + } + } + + function setModuleName($name) + { + $this->body_name = $name; + $this->head_name = $name; + $this->css_name = $name; + } + + function overrideModule($what,$name) + { + switch($what) + { + case 'body': + $this->body_name = $name; + break; + case 'head': + $this->head_name = $name; + break; + case 'css': + $this->css_name = $name; + break; + } + } + +} // end class linTemplate + +?> \ 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...> - 2006-03-04 10:43:48
|
Revision: 4394 Author: fangehrn Date: 2006-03-04 02:43:35 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4394&view=rev Log Message: ----------- Added Paths: ----------- trunk/linpha2/lib/modules/module.albums.php trunk/linpha2/lib/modules/module.search.php Removed Paths: ------------- trunk/linpha2/lib/module.albums.php trunk/linpha2/lib/module.search.php Deleted: trunk/linpha2/lib/module.albums.php =================================================================== --- trunk/linpha2/lib/module.albums.php 2006-03-04 10:42:36 UTC (rev 4393) +++ trunk/linpha2/lib/module.albums.php 2006-03-04 10:43:35 UTC (rev 4394) @@ -1,66 +0,0 @@ -<?php -if(!defined('LINPHA_DIR')) { exit(1); } - -/** - * temporary set permission string and configs - */ -$_SESSION["user_groups"] = ';1;'; -$order_by = 'name ASC'; - -/** - * init - */ - include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); - $linpha = new linpha(); - $linpha->sql->startSession(); - - include_once(LINPHA_DIR . '/lib/classes/linpha.imgview.class.php'); - $linpha->imgview = new linImgview(); - -/** - * set some infos - */ - $linpha->imgview->link_url = LINPHA_DIR.'/?cat=alb'; - $linpha->imgview->setCurrentView(); - -/** - * do import - */ - if( $linpha->sql->config->value['sys_import_autoimport'] - && ($linpha->imgview->view == 'thumb_view' || $linpha->imgview->view == 'thumbdetail_view')) - { - linImport::updateDir( $linpha->imgview->id_parent, $recursive = false ); - } - -/** - * set navigation line - */ - $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $linpha->imgview->id_parent ); - $linpha->imgview->output['navigation'] = '<a href="'.LINPHA_DIR.'/?cat=alb&id=0">top</a> / '; - - foreach($array_files AS $key=>$value) - { - if($value != "") - { - $linpha->imgview->output['navigation'] .= '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$key.'">'.$value.'</a> / '; - } - } - - -/** - * get photos - * (in img_view only for prev/next) - * - * take folders first - */ - $array_folders = $GLOBALS['linpha']->db->GetAssoc("SELECT id, name, img_type, stats_numbers, time_add FROM ".PREFIX."photos " . - "WHERE img_type = '0' AND parent_id = '".$linpha->imgview->id_parent."' ORDER by ".$order_by); - - $array_files = $GLOBALS['linpha']->db->GetAssoc("SELECT id, name, img_type, stats_numbers, time_add FROM ".PREFIX."photos " . - "WHERE img_type <> '0' AND parent_id = '".$linpha->imgview->id_parent."' ORDER by ".$order_by); - - $linpha->imgview->photos = array_merge($array_folders,$array_files); - - -$linpha->imgview->buildImgView(); -?> \ No newline at end of file Deleted: trunk/linpha2/lib/module.search.php =================================================================== Copied: trunk/linpha2/lib/modules/module.albums.php (from rev 4384, trunk/linpha2/lib/module.albums.php) =================================================================== --- trunk/linpha2/lib/modules/module.albums.php (rev 0) +++ trunk/linpha2/lib/modules/module.albums.php 2006-03-04 10:43:35 UTC (rev 4394) @@ -0,0 +1,66 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +/** + * temporary set permission string and configs + */ +$_SESSION["user_groups"] = ';1;'; +$order_by = 'name ASC'; + +/** + * init + */ + include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); + $linpha = new linpha(); + $linpha->sql->startSession(); + + include_once(LINPHA_DIR . '/lib/classes/linpha.imgview.class.php'); + $linpha->imgview = new linImgview(); + +/** + * set some infos + */ + $linpha->imgview->link_url = LINPHA_DIR.'/?cat=alb'; + $linpha->imgview->setCurrentView(); + +/** + * do import + */ + if( $linpha->sql->config->value['sys_import_autoimport'] + && ($linpha->imgview->view == 'thumb_view' || $linpha->imgview->view == 'thumbdetail_view')) + { + linImport::updateDir( $linpha->imgview->id_parent, $recursive = false ); + } + +/** + * set navigation line + */ + $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $linpha->imgview->id_parent ); + $linpha->imgview->output['navigation'] = '<a href="'.LINPHA_DIR.'/?cat=alb&id=0">top</a> / '; + + foreach($array_files AS $key=>$value) + { + if($value != "") + { + $linpha->imgview->output['navigation'] .= '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$key.'">'.$value.'</a> / '; + } + } + + +/** + * get photos + * (in img_view only for prev/next) + * + * take folders first + */ + $array_folders = $GLOBALS['linpha']->db->GetAssoc("SELECT id, name, img_type, stats_numbers, time_add FROM ".PREFIX."photos " . + "WHERE img_type = '0' AND parent_id = '".$linpha->imgview->id_parent."' ORDER by ".$order_by); + + $array_files = $GLOBALS['linpha']->db->GetAssoc("SELECT id, name, img_type, stats_numbers, time_add FROM ".PREFIX."photos " . + "WHERE img_type <> '0' AND parent_id = '".$linpha->imgview->id_parent."' ORDER by ".$order_by); + + $linpha->imgview->photos = array_merge($array_folders,$array_files); + + +$linpha->imgview->buildImgView(); +?> \ No newline at end of file Property changes on: trunk/linpha2/lib/modules/module.albums.php ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: trunk/linpha2/lib/modules/module.search.php (from rev 4392, trunk/linpha2/lib/module.search.php) =================================================================== Property changes on: trunk/linpha2/lib/modules/module.search.php ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2006-03-17 09:19:28
|
Revision: 4415 Author: bzrudi Date: 2006-03-17 01:19:23 -0800 (Fri, 17 Mar 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4415&view=rev Log Message: ----------- Added Paths: ----------- trunk/linpha2/lib/lang/ trunk/linpha2/lib/lang/lang.German.php Added: trunk/linpha2/lib/lang/lang.German.php =================================================================== --- trunk/linpha2/lib/lang/lang.German.php (rev 0) +++ trunk/linpha2/lib/lang/lang.German.php 2006-03-17 09:19:23 UTC (rev 4415) @@ -0,0 +1,38 @@ +<?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. +*/ + +/** + * We make use of a large array for all tranlation stuff + * We have a function tr() which will take care of translating... + */ +$translate = array( +"Home" => "Startseite", +"Admin" => "Administrator", +"Login" => "Anmelden", +"Search" => "Suchen", +"Basket" => "Basket", +"View" => "Ansicht", +"Edit" => "Bearbeiten", +"Add Comment" => "Kommentar hinzufügen", +"Name" => "Name", +"Edit Image Imformation" => "Bildinformationen bearbeiten", +"Value" => "Wert" +); + +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2007-07-11 14:36:23
|
Revision: 4743 http://svn.sourceforge.net/linpha/?rev=4743&view=rev Author: bzrudi Date: 2007-07-11 07:36:12 -0700 (Wed, 11 Jul 2007) Log Message: ----------- moved pjmt Added Paths: ----------- trunk/linpha2/lib/pjmt/ trunk/linpha2/lib/pjmt/COPYING.txt trunk/linpha2/lib/pjmt/EXIF.php trunk/linpha2/lib/pjmt/EXIF_Makernote.php trunk/linpha2/lib/pjmt/EXIF_Tags.php trunk/linpha2/lib/pjmt/IPTC.php trunk/linpha2/lib/pjmt/JFIF.php trunk/linpha2/lib/pjmt/JPEG.php trunk/linpha2/lib/pjmt/Makernotes/ trunk/linpha2/lib/pjmt/Makernotes/Pentax.php trunk/linpha2/lib/pjmt/Makernotes/agfa.php trunk/linpha2/lib/pjmt/Makernotes/canon.php trunk/linpha2/lib/pjmt/Makernotes/casio.php trunk/linpha2/lib/pjmt/Makernotes/epson.php trunk/linpha2/lib/pjmt/Makernotes/fujifilm.php trunk/linpha2/lib/pjmt/Makernotes/konica_minolta.php trunk/linpha2/lib/pjmt/Makernotes/kyocera.php trunk/linpha2/lib/pjmt/Makernotes/nikon.php trunk/linpha2/lib/pjmt/Makernotes/olympus.php trunk/linpha2/lib/pjmt/Makernotes/panasonic.php trunk/linpha2/lib/pjmt/Makernotes/ricoh.php trunk/linpha2/lib/pjmt/Makernotes/sony.php trunk/linpha2/lib/pjmt/PIM.php trunk/linpha2/lib/pjmt/Photoshop_File_Info.php trunk/linpha2/lib/pjmt/Photoshop_IRB.php trunk/linpha2/lib/pjmt/PictureInfo.php trunk/linpha2/lib/pjmt/Toolkit_Version.php trunk/linpha2/lib/pjmt/Unicode.php trunk/linpha2/lib/pjmt/XML.php trunk/linpha2/lib/pjmt/XMP.php trunk/linpha2/lib/pjmt/pjmt_utils.php Added: trunk/linpha2/lib/pjmt/COPYING.txt =================================================================== --- trunk/linpha2/lib/pjmt/COPYING.txt (rev 0) +++ trunk/linpha2/lib/pjmt/COPYING.txt 2007-07-11 14:36:12 UTC (rev 4743) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Added: trunk/linpha2/lib/pjmt/EXIF.php =================================================================== --- trunk/linpha2/lib/pjmt/EXIF.php (rev 0) +++ trunk/linpha2/lib/pjmt/EXIF.php 2007-07-11 14:36:12 UTC (rev 4743) @@ -0,0 +1,2757 @@ +<?php + +/****************************************************************************** +* +* Filename: EXIF.php +* +* Description: Provides functions for reading and writing EXIF Information +* to/from an APP1 segment of a JPEG file +* Unfortunately, because EXIF data may be distributed anywhere +* throughout an image file, rather than just being in one block, +* it is impossible to pass just a string containing only the EXIF +* information. Hence it is neccessary to be able to seek to +* any point in the file. This causes the HTTP and FTP wrappers +* not to work - i.e. the EXIF functions will only work with local +* files. +* To work on an internet file, copy it locally to start with: +* +* $newfilename = tempnam ( $dir, "tmpexif" ); +* copy ( "http://whatever.com", $newfilename ); +* +* +* Author: Evan Hunter +* +* Date: 30/7/2004 +* +* Project: PHP JPEG Metadata Toolkit +* +* Revision: 1.11 +* +* Changes: 1.00 -> 1.10 : added function get_EXIF_TIFF to allow extracting EXIF from a TIFF file +* 1.10 -> 1.11 : added functionality to allow decoding of XMP and Photoshop IRB information +* embedded within the EXIF data +* added checks for http and ftp wrappers, as these are not supported +* changed interpret_IFD to allow thumbnail links to work when +* toolkit is portable across directories +* +* +* URL: http://electronics.ozhiker.com +* +* Copyright: Copyright Evan Hunter 2004 +* +* License: This file is part of the PHP JPEG Metadata Toolkit. +* +* The PHP JPEG Metadata Toolkit is free software; you can +* redistribute it and/or modify it under the terms of the +* GNU General Public License as published by the Free Software +* Foundation; either version 2 of the License, or (at your +* option) any later version. +* +* The PHP JPEG Metadata Toolkit is distributed in the hope +* that it will be useful, but WITHOUT ANY WARRANTY; without +* even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +* You should have received a copy of the GNU General Public +* License along with the PHP JPEG Metadata Toolkit; if not, +* write to the Free Software Foundation, Inc., 59 Temple +* Place, Suite 330, Boston, MA 02111-1307 USA +* +* If you require a different license for commercial or other +* purposes, please contact the author: ev...@oz... +* +******************************************************************************/ + + +// TODO : Thoroughly test the functions for writing EXIF segments +// TODO : Figure out a way to allow EXIF to function normally with HTTP and FTP wrappers +// TODO : Implement EXIF decoding of Device Setting Description field +// TODO : Implement EXIF decoding of SpatialFrequencyResponse field +// TODO : Implement EXIF decoding of OECF field +// TODO : Implement EXIF decoding of SubjectArea field +// TODO : Add a put_EXIF_TIFF function + +/****************************************************************************** +* +* Initialisation +* +******************************************************************************/ + + +if ( !isset( $GLOBALS['HIDE_UNKNOWN_TAGS'] ) ) $GLOBALS['HIDE_UNKNOWN_TAGS']= FALSE; +if ( !isset( $GLOBALS['SHOW_BINARY_DATA_HEX'] ) ) $GLOBALS['SHOW_BINARY_DATA_HEX'] = FALSE; +if ( !isset( $GLOBALS['SHOW_BINARY_DATA_TEXT'] ) ) $GLOBALS['SHOW_BINARY_DATA_TEXT'] = FALSE; + + +include_once 'EXIF_Tags.php'; +include_once 'EXIF_Makernote.php'; +include_once 'PIM.php'; +include_once 'Unicode.php'; +include_once 'JPEG.php'; +include_once 'IPTC.php'; +include_once 'Photoshop_IRB.php'; // Change: as of version 1.11 - Required for TIFF with embedded IRB +include_once 'XMP.php'; // Change: as of version 1.11 - Required for TIFF with embedded XMP +include_once 'pjmt_utils.php'; // Change: as of version 1.11 - Required for directory portability + + + + + + + + +/****************************************************************************** +* +* Function: get_EXIF_JPEG +* +* Description: Retrieves information from a Exchangeable Image File Format (EXIF) +* APP1 segment and returns it in an array. +* +* Parameters: filename - the filename of the JPEG image to process +* +* Returns: OutputArray - Array of EXIF records +* FALSE - If an error occured in decoding +* +******************************************************************************/ + +function get_EXIF_JPEG( $filename ) +{ + // Change: Added as of version 1.11 + // Check if a wrapper is being used - these are not currently supported (see notes at top of file) + if ( ( stristr ( $filename, "http://" ) != FALSE ) || ( stristr ( $filename, "ftp://" ) != FALSE ) ) + { + // A HTTP or FTP wrapper is being used - show a warning and abort + echo "HTTP and FTP wrappers are currently not supported with EXIF - See EXIF functionality documentation - a local file must be specified<br>"; + echo "To work on an internet file, copy it locally to start with:<br><br>\n"; + echo "\$newfilename = tempnam ( \$dir, \"tmpexif\" );<br>\n"; + echo "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n"; + return FALSE; + } + + // get the JPEG headers + $jpeg_header_data = get_jpeg_header_data( $filename ); + + + // Flag that an EXIF segment has not been found yet + $EXIF_Location = -1; + + //Cycle through the header segments + for( $i = 0; $i < count( $jpeg_header_data ); $i++ ) + { + // If we find an APP1 header, + if ( strcmp ( $jpeg_header_data[$i]['SegName'], "APP1" ) == 0 ) + { + // And if it has the EXIF label, + if ( ( strncmp ( $jpeg_header_data[$i]['SegData'], "Exif\x00\x00", 6) == 0 ) || + ( strncmp ( $jpeg_header_data[$i]['SegData'], "Exif\x00\xFF", 6) == 0 ) ) // For some reason, some files have a faulty EXIF name which has a 0xFF in it + { + // Save the location of the EXIF segment + $EXIF_Location = $i; + } + } + + } + + // Check if an EXIF segment was found + if ( $EXIF_Location == -1 ) + { + // Couldn't find any EXIF block to decode + return FALSE; + } + + $filehnd = @fopen($filename, 'rb'); + + // Check if the file opened successfully + if ( ! $filehnd ) + { + // Could't open the file - exit + echo "<p>Could not open file $filename</p>\n"; + return FALSE; + } + + fseek( $filehnd, $jpeg_header_data[$EXIF_Location]['SegDataStart'] + 6 ); + + // Decode the Exif segment into an array and return it + $exif_data = process_TIFF_Header( $filehnd, "TIFF" ); + + + + // Close File + fclose($filehnd); + return $exif_data; +} + +/****************************************************************************** +* End of Function: get_EXIF_JPEG +******************************************************************************/ + + + +/****************************************************************************** +* +* Function: put_EXIF_JPEG +* +* Description: Stores information into a Exchangeable Image File Format (EXIF) +* APP1 segment from an EXIF array. +* +* WARNING: Because the EXIF standard allows pointers to data +* outside the APP1 segment, if there are any such pointers in +* a makernote, this function will DAMAGE them since it will not +* be aware that there is an external pointer. This will often +* happen with Makernotes that include an embedded thumbnail. +* This damage could be prevented where makernotes can be decoded, +* but currently this is not implemented. +* +* +* Parameters: exif_data - The array of EXIF data to insert into the JPEG header +* jpeg_header_data - The JPEG header into which the EXIF data +* should be stored, as from get_jpeg_header_data +* +* Returns: jpeg_header_data - JPEG header array with the EXIF segment inserted +* FALSE - If an error occured +* +******************************************************************************/ + +function put_EXIF_JPEG( $exif_data, $jpeg_header_data ) +{ + // pack the EXIF data into its proper format for a JPEG file + $packed_data = get_TIFF_Packed_Data( $exif_data ); + if ( $packed_data === FALSE ) + { + return $jpeg_header_data; + } + + $packed_data = "Exif\x00\x00$packed_data"; + + //Cycle through the header segments + for( $i = 0; $i < count( $jpeg_header_data ); $i++ ) + { + // If we find an APP1 header, + if ( strcmp ( $jpeg_header_data[$i]['SegName'], "APP1" ) == 0 ) + { + // And if it has the EXIF label, + if ( ( strncmp ( $jpeg_header_data[$i]['SegData'], "Exif\x00\x00", 6) == 0 ) || + ( strncmp ( $jpeg_header_data[$i]['SegData'], "Exif\x00\xFF", 6) == 0 ) ) // For some reason, some files have a faulty EXIF name which has a 0xFF in it + { + // Found a preexisting EXIF block - Replace it with the new one and return. + $jpeg_header_data[$i]['SegData'] = $packed_data; + return $jpeg_header_data; + } + } + } + + // No preexisting segment segment found, insert a new one at the start of the header data. + + // Determine highest position of an APP segment at or below APP3, so we can put the + // new APP3 at this position + + + $highest_APP = -1; + + //Cycle through the header segments + for( $i = 0; $i < count( $jpeg_header_data ); $i++ ) + { + // Check if we have found an APP segment at or below APP3, + if ( ( $jpeg_header_data[$i]['SegType'] >= 0xE0 ) && ( $jpeg_header_data[$i]['SegType'] <= 0xE3 ) ) + { + // Found an APP segment at or below APP12 + $highest_APP = $i; + } + } + + // No preexisting EXIF block found, insert a new one at the start of the header data. + array_splice($jpeg_header_data, $highest_APP + 1 , 0, array( array( "SegType" => 0xE1, + "SegName" => "APP1", + "SegDesc" => $GLOBALS[ "JPEG_Segment_Descriptions" ][ 0xE1 ], + "SegData" => $packed_data ) ) ); + return $jpeg_header_data; + +} + +/****************************************************************************** +* End of Function: put_EXIF_JPEG +******************************************************************************/ + + + + +/****************************************************************************** +* +* Function: get_Meta_JPEG +* +* Description: Retrieves information from a Meta APP3 segment and returns it +* in an array. Uses information supplied by the +* get_jpeg_header_data function. +* The Meta segment has the same format as an EXIF segment, but +* uses different tags +* +* Parameters: filename - the filename of the JPEG image to process +* +* Returns: OutputArray - Array of Meta records +* FALSE - If an error occured in decoding +* +******************************************************************************/ + +function get_Meta_JPEG( $filename ) +{ + // Change: Added as of version 1.11 + // Check if a wrapper is being used - these are not currently supported (see notes at top of file) + if ( ( stristr ( $filename, "http://" ) != FALSE ) || ( stristr ( $filename, "ftp://" ) != FALSE ) ) + { + // A HTTP or FTP wrapper is being used - show a warning and abort + echo "HTTP and FTP wrappers are currently not supported with Meta - See EXIF/Meta functionality documentation - a local file must be specified<br>"; + echo "To work on an internet file, copy it locally to start with:<br><br>\n"; + echo "\$newfilename = tempnam ( \$dir, \"tmpmeta\" );<br>\n"; + echo "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n"; + return FALSE; + } + + // get the JPEG headers + $jpeg_header_data = get_jpeg_header_data( $filename ); + + + // Flag that an Meta segment has not been found yet + $Meta_Location = -1; + + //Cycle through the header segments + for( $i = 0; $i < count( $jpeg_header_data ); $i++ ) + { + // If we find an APP3 header, + if ( strcmp ( $jpeg_header_data[$i]['SegName'], "APP3" ) == 0 ) + { + // And if it has the Meta label, + if ( ( strncmp ( $jpeg_header_data[$i]['SegData'], "Meta\x00\x00", 6) == 0 ) || + ( strncmp ( $jpeg_header_data[$i]['SegData'], "META\x00\x00", 6) == 0 ) ) + { + // Save the location of the Meta segment + $Meta_Location = $i; + } + } + } + + // Check if an EXIF segment was found + if ( $Meta_Location == -1 ) + { + // Couldn't find any Meta block to decode + return FALSE; + } + + + $filehnd = @fopen($filename, 'rb'); + + // Check if the file opened successfully + if ( ! $filehnd ) + { + // Could't open the file - exit + echo "<p>Could not open file $filename</p>\n"; + return FALSE; + } + + fseek( $filehnd, $jpeg_header_data[$Meta_Location]['SegDataStart'] + 6 ); + + // Decode the Meta segment into an array and return it + $meta = process_TIFF_Header( $filehnd, "Meta" ); + + // Close File + fclose($filehnd); + + return $meta; +} + +/****************************************************************************** +* End of Function: get_Meta +******************************************************************************/ + + + + + + + +/****************************************************************************** +* +* Function: put_Meta_JPEG +* +* Description: Stores information into a Meta APP3 segment from a Meta array. +* +* +* WARNING: Because the Meta (EXIF) standard allows pointers to data +* outside the APP1 segment, if there are any such pointers in +* a makernote, this function will DAMAGE them since it will not +* be aware that there is an external pointer. This will often +* happen with Makernotes that include an embedded thumbnail. +* This damage could be prevented where makernotes can be decoded, +* but currently this is not implemented. +* +* +* Parameters: meta_data - The array of Meta data to insert into the JPEG header +* jpeg_header_data - The JPEG header into which the Meta data +* should be stored, as from get_jpeg_header_data +* +* Returns: jpeg_header_data - JPEG header array with the Meta segment inserted +* FALSE - If an error occured +* +******************************************************************************/ + +function put_Meta_JPEG( $meta_data, $jpeg_header_data ) +{ + // pack the Meta data into its proper format for a JPEG file + $packed_data = get_TIFF_Packed_Data( $meta_data ); + if ( $packed_data === FALSE ) + { + return $jpeg_header_data; + } + + $packed_data = "Meta\x00\x00$packed_data"; + + //Cycle through the header segments + for( $i = 0; $i < count( $jpeg_header_data ); $i++ ) + { + // If we find an APP1 header, + if ( strcmp ( $jpeg_header_data[$i]['SegName'], "APP3" ) == 0 ) + { + // And if it has the Meta label, + if ( ( strncmp ( $jpeg_header_data[$i]['SegData'], "Meta\x00\x00", 6) == 0 ) || + ( strncmp ( $jpeg_header_data[$i]['SegData'], "META\x00\x00", 6) == 0 ) ) + { + // Found a preexisting Meta block - Replace it with the new one and return. + $jpeg_header_data[$i]['SegData'] = $packed_data; + return $jpeg_header_data; + } + } + } + // No preexisting segment segment found, insert a new one at the start of the header data. + + // Determine highest position of an APP segment at or below APP3, so we can put the + // new APP3 at this position + + + $highest_APP = -1; + + //Cycle through the header segments + for( $i = 0; $i < count( $jpeg_header_data ); $i++ ) + { + // Check if we have found an APP segment at or below APP3, + if ( ( $jpeg_header_data[$i]['SegType'] >= 0xE0 ) && ( $jpeg_header_data[$i]['SegType'] <= 0xE3 ) ) + { + // Found an APP segment at or below APP12 + $highest_APP = $i; + } + } + + // No preexisting Meta block found, insert a new one at the start of the header data. + array_splice($jpeg_header_data, $highest_APP + 1 , 0, array( array( "SegType" => 0xE3, + "SegName" => "APP3", + "SegDesc" => $GLOBALS[ "JPEG_Segment_Descriptions" ][ 0xE1 ], + "SegData" => $packed_data ) ) ); + return $jpeg_header_data; + +} + +/****************************************************************************** +* End of Function: put_Meta_JPEG +******************************************************************************/ + + + +/****************************************************************************** +* +* Function: get_EXIF_TIFF +* +* Description: Retrieves information from a Exchangeable Image File Format (EXIF) +* within a TIFF file and returns it in an array. +* +* Parameters: filename - the filename of the TIFF image to process +* +* Returns: OutputArray - Array of EXIF records +* FALSE - If an error occured in decoding +* +******************************************************************************/ + +function get_EXIF_TIFF( $filename ) +{ + // Change: Added as of version 1.11 + // Check if a wrapper is being used - these are not currently supported (see notes at top of file) + if ( ( stristr ( $filename, "http://" ) != FALSE ) || ( stristr ( $filename, "ftp://" ) != FALSE ) ) + { + // A HTTP or FTP wrapper is being used - show a warning and abort + echo "HTTP and FTP wrappers are currently not supported with TIFF - See EXIF/TIFF functionality documentation - a local file must be specified<br>"; + echo "To work on an internet file, copy it locally to start with:<br><br>\n"; + echo "\$newfilename = tempnam ( \$dir, \"tmptiff\" );<br>\n"; + echo "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n"; + return FALSE; + } + + + $filehnd = @fopen($filename, 'rb'); + + // Check if the file opened successfully + if ( ! $filehnd ) + { + // Could't open the file - exit + echo "<p>Could not open file $filename</p>\n"; + return FALSE; + } + + // Decode the Exif segment into an array and return it + $exif_data = process_TIFF_Header( $filehnd, "TIFF" ); + + // Close File + fclose($filehnd); + return $exif_data; +} + +/****************************************************************************** +* End of Function: get_EXIF_TIFF +******************************************************************************/ + + + + +/****************************************************************************** +* +* Function: Interpret_EXIF_to_HTML +* +* Description: Generates html detailing the contents an APP1 EXIF array +* which was retrieved with a get_EXIF_.... function. +* Can also be used for APP3 Meta arrays. +* +* Parameters: Exif_array - the EXIF array,as read from get_EXIF_.... +* filename - the name of the Image file being processed ( used +* by scripts which displays EXIF thumbnails) +* +* Returns: output_str - A string containing the HTML +* +******************************************************************************/ + +function Interpret_EXIF_to_HTML( $Exif_array, $filename ) +{ + // Create the string to receive the html output + $output_str = ""; + + // Check if the array to process is valid + if ( $Exif_array === FALSE ) + { + // Exif Array is not valid - abort processing + return $output_str; + } + + // Ouput the heading according to what type of tags were used in processing + if ( $Exif_array[ 'Tags Name' ] == "TIFF" ) + { + $output_str .= "<h2 class=\"EXIF_Main_Heading\">Contains Exchangeable Image File Format (EXIF) Information</h2>\n"; + } + else if ( $Exif_array[ 'Tags Name' ] == "Meta" ) + { + $output_str .= "<h2 class=\"EXIF_Main_Heading\">Contains META Information (APP3)</h2>\n"; + } + else + { + $output_str .= "<h2 class=\"EXIF_Main_Heading\">Contains " . $Exif_array[ 'Tags Name' ] . " Information</h2>\n"; + } + + + // Check that there are actually items to process in the array + if ( count( $Exif_array ) < 1 ) + { + // No items to process in array - abort processing + return $output_str; + } + + // Output secondary heading + $output_str .= "<h3 class=\"EXIF_Secondary_Heading\">Main Image Information</h2>\n"; + + // Interpret the zeroth IFD to html + $output_str .= interpret_IFD( $Exif_array[0], $filename, $Exif_array['Byte_Align'] ); + + // Check if there is a first IFD to process + if ( array_key_exists( 1, $Exif_array ) ) + { + // There is a first IFD for a thumbnail + // Add a heading for it to the output + $output_str .= "<h3 class=\"EXIF_Secondary_Heading\">Thumbnail Information</h2>\n"; + + // Interpret the IFD to html and add it to the output + $output_str .= interpret_IFD( $Exif_array[1], $filename, $Exif_array['Byte_Align'] ); + } + + // Cycle through any other IFD's + $i = 2; + while ( array_key_exists( $i, $Exif_array ) ) + { + // Add a heading for the IFD + $output_str .= "<h3 class=\"EXIF_Secondary_Heading\">Image File Directory (IFD) $i Information</h2>\n"; + + // Interpret the IFD to html and add it to the output + $output_str .= interpret_IFD( $Exif_array[$i], $filename, $Exif_array['Byte_Align'] ); + $i++; + } + + // Return the resulting HTML + return $output_str; +} + +/****************************************************************************** +* End of Function: Interpret_EXIF_to_HTML +******************************************************************************/ + + + + + + + + + + + + + + + + +/****************************************************************************** +* +* INTERNAL FUNCTIONS +* +******************************************************************************/ + + + + + + + + + + + +/****************************************************************************** +* +* Internal Function: get_TIFF_Packed_Data +* +* Description: Packs TIFF IFD data from EXIF or Meta into a form ready for +* either a JPEG EXIF/Meta segment or a TIFF file +* This function attempts to protect the contents of an EXIF makernote, +* by ensuring that it remains in the same position relative to the +* TIFF header +* +* Parameters: tiff_data - the EXIF array,as read from get_EXIF_JPEG or get_Meta_JPEG +* +* Returns: packed_data - A string containing packed segment +* +******************************************************************************/ + +function get_TIFF_Packed_Data( $tiff_data ) +{ + // Check that the segment is valid + if ( $tiff_data === FALSE ) + { + return FALSE; + } + + // Get the byte alignment + $Byte_Align = $tiff_data['Byte_Align']; + + // Add the Byte Alignment to the Packed data + $packed_data = $Byte_Align; + + // Add the TIFF ID to the Packed Data + $packed_data .= put_IFD_Data_Type( 42, 3, $Byte_Align ); + + // Create a string for the makernote + $makernote = ""; + + // Check if the makernote exists + if ( $tiff_data[ 'Makernote_Tag' ] !== FALSE ) + { + // A makernote exists - We need to ensure that it stays in the same position as it was + // Put the Makernote before any of the IFD's by padding zeros to the correct offset + $makernote .= str_repeat("\x00",( $tiff_data[ 'Makernote_Tag' ][ 'Offset' ] - 8 ) ); + $makernote .= $tiff_data[ 'Makernote_Tag' ]['Data']; + } + + // Calculage where the zeroth ifd will be + $ifd_offset = strlen( $makernote ) + 8; + + // Add the Zeroth IFD pointer to the packed data + $packed_data .= put_IFD_Data_Type( $ifd_offset, 4, $Byte_Align ); + + // Add the makernote to the packed data (if there was one) + $packed_data .= $makernote; + + //Add the IFD's to the packed data + $packed_data .= get_IFD_Array_Packed_Data( $tiff_data, $ifd_offset, $Byte_Align ); + + // Return the result + return $packed_data; +} + +/****************************************************************************** +* End of Function: get_TIFF_Packed_Data +******************************************************************************/ + + + + +/****************************************************************************** +* +* Internal Function: get_IFD_Array_Packed_Data +* +* Description: Packs a chain of IFD's from EXIF or Meta segments into a form +* ready for either a JPEG EXIF/Meta segment or a TIFF file +* +* Parameters: ifd_data - the IFD chain array, as read from get_EXIF_JPEG or get_Meta_JPEG +* Zero_IFD_offset - The offset to the first IFD from the start of the TIFF header +* Byte_Align - the Byte alignment to use - "MM" or "II" +* +* Returns: packed_data - A string containing packed IFD's +* +******************************************************************************/ + +function get_IFD_Array_Packed_Data( $ifd_data, $Zero_IFD_offset, $Byte_Align ) +{ + // Create a string to receive the packed output + $packed_data = ""; + + // Count the IFDs + $ifd_count = 0; + foreach( $ifd_data as $key => $IFD ) + { + // Make sure we only count the IFD's, not other information keys + if ( is_numeric( $key ) ) + { + $ifd_count++; + } + } + + + // Cycle through each IFD, + for ( $ifdno = 0; $ifdno < $ifd_count; $ifdno++ ) + { + // Check if this IFD is the last one + if ( $ifdno == $ifd_count - 1 ) + { + // This IFD is the last one, get it's packed data + $packed_data .= get_IFD_Packed_Data( $ifd_data[ $ifdno ], $Zero_IFD_offset +strlen($packed_data), $Byte_Align, FALSE ); + } + else + { + // This IFD is NOT the last one, get it's packed data + $packed_data .= get_IFD_Packed_Data( $ifd_data[ $ifdno ], $Zero_IFD_offset +strlen($packed_data), $Byte_Align, TRUE ); + } + + } + + // Return the packed output + return $packed_data; +} + +/****************************************************************************** +* End of Function: get_IFD_Array_Packed_Data +******************************************************************************/ + + + +/****************************************************************************** +* +* Internal Function: get_IFD_Packed_Data +* +* Description: Packs an IFD from EXIF or Meta segments into a form +* ready for either a JPEG EXIF/Meta segment or a TIFF file +* +* Parameters: ifd_data - the IFD chain array, as read from get_EXIF_JPEG or get_Meta_JPEG +* IFD_offset - The offset to the IFD from the start of the TIFF header +* Byte_Align - the Byte alignment to use - "MM" or "II" +* Another_IFD - boolean - false if this is the last IFD in the chain +* - true if it is not the last +* +* Returns: packed_data - A string containing packed IFD's +* +******************************************************************************/ + +function get_IFD_Packed_Data( $ifd_data, $IFD_offset, $Byte_Align, $Another_IFD ) +{ + + $ifd_body_str = ""; + $ifd_data_str = ""; + + $Tag_Definitions_Name = $ifd_data[ 'Tags Name' ]; + + + // Count the Tags in this IFD + $tag_count = 0; + foreach( $ifd_data as $key => $tag ) + { + // Make sure we only count the Tags, not other information keys + if ( is_numeric( $key ) ) + { + $tag_count++; + } + } + + // Add the Tag count to the packed data + $packed_data = put_IFD_Data_Type( $tag_count, 3, $Byte_Align ); + + // Calculate the total length of the IFD (without the offset data) + $IFD_len = 2 + $tag_count * 12 + 4; + + + // Cycle through each tag + foreach( $ifd_data as $key => $tag ) + { + // Make sure this is a tag, not another information key + if ( is_numeric( $key ) ) + { + + // Add the tag number to the packed data + $ifd_body_str .= put_IFD_Data_Type( $tag[ 'Tag Number' ], 3, $Byte_Align ); + + // Add the Data type to the packed data + $ifd_body_str .= put_IFD_Data_Type( $tag['Data Type'], 3, $Byte_Align ); + + // Check if this is a Print Image Matching entry + if ( $tag['Type'] == "PIM" ) + { + // This is a Print Image Matching entry, + // encode it + $data = Encode_PIM( $tag, $Byte_Align ); + } + // Check if this is a IPTC/NAA Record within the EXIF IFD + else if ( ( ( $Tag_Definitions_Name == "EXIF" ) || ( $Tag_Definitions_Name == "TIFF" ) ) && + ( $tag[ 'Tag Number' ] == 33723 ) ) + { + // This is a IPTC/NAA Record, encode it + $data = put_IPTC( $tag['Data'] ); + } + // Change: Check for embedded XMP as of version 1.11 + // Check if this is a XMP Record within the EXIF IFD + else if ( ( ( $Tag_Definitions_Name == "EXIF" ) || ( $Tag_Definitions_Name == "TIFF" ) ) && + ( $tag[ 'Tag Number' ] == 700 ) ) + { + // This is a XMP Record, encode it + $data = write_XMP_array_to_text( $tag['Data'] ); + } + // Change: Check for embedded IRB as of version 1.11 + // Check if this is a Photoshop IRB Record within the EXIF IFD + else if ( ( ( $Tag_Definitions_Name == "EXIF" ) || ( $Tag_Definitions_Name == "TIFF" ) ) && + ( $tag[ 'Tag Number' ] == 34377 ) ) + { + // This is a Photoshop IRB Record, encode it + $data = pack_Photoshop_IRB_Data( $tag['Data'] ); + } + // Exif Thumbnail Offset + else if ( ( $tag[ 'Tag Number' ] == 513 ) && ( $Tag_Definitions_Name == "TIFF" ) ) + { + // The Exif Thumbnail Offset is a pointer but of type Long, not Unknown + // Hence we need to put the data into the packed string separately + // Calculate the thumbnail offset + $data_offset = $IFD_offset + $IFD_len + strlen($ifd_data_str); + + // Create the Offset for the IFD + $data = put_IFD_Data_Type( $data_offset, 4, $Byte_Align ); + + // Store the thumbnail + $ifd_data_str .= $tag['Data']; + } + // Exif Thumbnail Length + else if ( ( $tag[ 'Tag Number' ] == 514 ) && ( $Tag_Definitions_Name == "TIFF" ) ) + { + // Encode the Thumbnail Length + $data = put_IFD_Data_Type( strlen($ifd_data[513]['Data']), 4, $Byte_Align ); + } + // Sub-IFD + else if ( $tag['Type'] == "SubIFD" ) + { + // This is a Sub-IFD + // Calculate the offset to the start of the Sub-IFD + $data_offset = $IFD_offset + $IFD_len + strlen($ifd_data_str); + // Get the packed data for the IFD chain as the data for this tag + $data = get_IFD_Array_Packed_Data( $tag['Data'], $data_offset, $Byte_Align ); + } + else + { + // Not a special tag + + // Create a string to receive the data + $data = ""; + + // Check if this is a type Unknown tag + if ( $tag['Data Type'] != 7 ) + { + // NOT type Unknown + // Cycle through each data value and add it to the data string + foreach( $tag[ 'Data' ] as $data_val ) + { + $data .= put_IFD_Data_Type( $data_val, $tag['Data Type'], $Byte_Align ); + } + } + else + { + // This is a type Unknown - just add the data as is to the data string + $data .= $tag[ 'Data' ]; + } + } + + // Pad the data string out to at least 4 bytes + $data = str_pad ( $data, 4, "\x00" ); + + + // Check if the data type is an ASCII String or type Unknown + if ( ( $tag['Data Type'] == 2 ) || ( $tag['Data Type'] == 7 ) ) + { + // This is an ASCII String or type Unknown + // Add the Length of the string to the packed data as the Count + $ifd_body_str .= put_IFD_Data_Type( strlen($data), 4, $Byte_Align ); + } + else + { + // Add the array count to the packed data as the Count + $ifd_body_str .= put_IFD_Data_Type( count($tag[ 'Data' ]), 4, $Byte_Align ); + } + + + // Check if the data is over 4 bytes long + if ( strlen( $data ) > 4 ) + { + // Data is longer than 4 bytes - it needs to be offset + // Check if this entry is the Maker Note + if ( ( $Tag_Definitions_Name == "EXIF" ) && ( $tag[ 'Tag Number' ] == 37500 ) ) + { + // This is the makernote - It will have already been stored + // at its original offset to help preserve it + // all we need to do is add the Offset to the IFD packed data + $data_offset = $tag[ 'Offset' ]; + + $ifd_body_str .= put_IFD_Data_Type( $data_offset, 4, $Byte_Align ); + } + else + { + // This is NOT the makernote + // Calculate the data offset + $data_offset = $IFD_offset + $IFD_len + strlen($ifd_data_str); + + // Add the offset to the IFD packed data + $ifd_body_str .= put_IFD_Data_Type( $data_offset, 4, $Byte_Align ); + + // Add the data to the offset packed data + $ifd_data_str .= $data; + } + } + else + { + // Data is less than or equal to 4 bytes - Add it to the packed IFD data as is + ... [truncated message content] |
From: <bz...@us...> - 2008-01-30 17:40:30
|
Revision: 4838 http://linpha.svn.sourceforge.net/linpha/?rev=4838&view=rev Author: bzrudi Date: 2008-01-30 09:40:27 -0800 (Wed, 30 Jan 2008) Log Message: ----------- "add support for PJMT (I hate it ;-))" Modified Paths: -------------- 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/settings.maps.php Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-30 16:46:15 UTC (rev 4837) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-30 17:40:27 UTC (rev 4838) @@ -185,7 +185,7 @@ $dataArray = LinExifTool::readMetaDataFromFile($tag, $filename); - echo '<pre>', print_r($dataArray), '</pre>'; + //echo '<pre>', print_r($dataArray), '</pre>'; $str_columns = "md5sum, "; Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-30 16:46:15 UTC (rev 4837) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-30 17:40:27 UTC (rev 4838) @@ -748,7 +748,7 @@ * @return array with metadata information * @author bzrudi,flo */ - private function getDefaultMetaTags($type) + protected function getDefaultMetaTags($type) { switch($type) { @@ -939,32 +939,24 @@ AND img_type <> 9999999 AND geodata <> 1 "); - while ($data = $query->FetchRow()) + while($data = $query->FetchRow()) { $filename = LinSql::getFullImagePath($data['0']); $dataArray = $this->objMetaTool->readMetaDataFromFile('exif', $filename); - echo '<pre>', print_r($dataArray), '</pre>'; + //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)) + if(array_key_exists($value, $dataArray)) { - $str_columns .= str_replace("_", "-", $value) . ', '; - $str_values .= "'".trim($lowerDataArray[$value])."', "; + $str_values .= trim($dataArray[$value]).", "; } } /** Modified: trunk/linpha2/lib/classes/linpha.pjmt.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.pjmt.class.php 2008-01-30 16:46:15 UTC (rev 4837) +++ trunk/linpha2/lib/classes/linpha.pjmt.class.php 2008-01-30 17:40:27 UTC (rev 4838) @@ -36,6 +36,66 @@ } /** + * This method reads all available GeoData Information from image. + * @param string $metatype exi + * @param string $filename + * @return array Array with all available Tag informations + * @author bzrudi + * @todo respect exec return status, don't use filename as input (security) + */ + public function readMetaDataFromFile($metatype, $filename) + { + 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 + */ + 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 + * in the array + */ + $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'])) . "', "; + } + 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'])) . "' "; + } + break; + } + } + } + + return $dataArray; + } + } + + /** * Save all MetaData to database * @param string $filename filename to parse for MetaData * @param string $md5sum md5sum of file Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-30 16:46:15 UTC (rev 4837) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-30 17:40:27 UTC (rev 4838) @@ -24,8 +24,8 @@ */ if(!defined('LINPHA_DIR')) { exit(1); } - //$MetaData = new LinMetaData(); - //$MetaData->importGeoData(); + $MetaData = new LinMetaData(); + $MetaData->importGeoData(); /** * xml load/save stuff */ @@ -56,7 +56,7 @@ if( $data['albid'] != '0' ) { $query2 = $GLOBALS['linpha']->db->Execute("SELECT P.parent_id " . - "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 " . @@ -102,11 +102,11 @@ case 'saveMarker': - //error_log("SAVING MARKERS",'','0'); + error_log("SAVING MARKERS",'','0'); case 'editMarker': - //error_log("EDITING MARKERS",'','0'); + error_log("EDITING MARKERS",'','0'); header('Content-type: text/xml'); echo '<?xml version="1.0" ?>'."\n"; @@ -163,7 +163,7 @@ break; case 'deleteMarker': - //error_log("DELETING MARKERS",'','0'); + error_log("DELETING MARKERS",'','0'); header('Content-type: text/xml'); echo '<?xml version="1.0" ?>'."\n"; @@ -197,8 +197,9 @@ case 'assignAlbumChange': case 'assignAlbumDelete': - //error_log("ASSIGNING ALBUM MARKERS",'','0'); - header('Content-type: text/xml'); + error_log("ASSIGNING ALBUM MARKERS",'','0'); + + header('Content-type: text/xml'); echo '<?xml version="1.0" ?>'."\n"; echo '<root>'."\n"; @@ -233,11 +234,12 @@ break; case 'loadAlbums': - //error_log("LOADING ALBUMS",'','0'); - echo '{ "albums": [' . "\n"; + 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 " . + "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 " . @@ -246,7 +248,7 @@ echo '{"id": 0, "name": "'.i18n("All albums").'"},'."\n"; - if( !$query ) + if( $query->EOF ) { //echo "Error: Please enable EXIF GPS fields!"; } @@ -273,8 +275,9 @@ break; case 'loadImages': -// error_log("LOADING IMAGES",'','0'); - if( !isset($_REQUEST['albId']) ) { + error_log("LOADING IMAGES",'','0'); + + if( !isset($_REQUEST['albId']) ) { break; } @@ -288,7 +291,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 PM " . + "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 " . @@ -300,7 +303,7 @@ if( $query->EOF ) { - error_log("Error: Please enable EXIF GPS fields!",'',0); + error_log("Error: No geotagged images found",'',0); } else { @@ -382,6 +385,7 @@ { foreach(array('gpslatitude','gpslongitude') as $value) { + 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/settings.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/settings.maps.php 2008-01-30 16:46:15 UTC (rev 4837) +++ trunk/linpha2/lib/plugins/maps/settings.maps.php 2008-01-30 17:40:27 UTC (rev 4838) @@ -40,6 +40,7 @@ 'plugins_maps_google_key', 'plugins_maps_markerThumbSize', 'plugins_maps_enable_geotagged', + 'plugins_maps_geotagged_autoimport', )); } @@ -86,5 +87,14 @@ $LinAdmin->option_value_system['plugins_maps_enable_geotagged'] ); +if($GLOBALS['linpha']->sql->config->value['plugins_maps_enable_geotagged']) +{ + $LinAdmin->printAdminConfig( + 'radio', + i18n("Auto Import Geotagged Images"), + 'plugins_maps_geotagged_autoimport', + $LinAdmin->option_value_system['plugins_maps_geotagged_autoimport'] + ); +} ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2008-02-02 16:43:16
|
Revision: 4850 http://linpha.svn.sourceforge.net/linpha/?rev=4850&view=rev Author: bzrudi Date: 2008-02-02 08:43:14 -0800 (Sat, 02 Feb 2008) Log Message: ----------- add ele/alt attribute Modified Paths: -------------- trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/modules/module.geodata.php trunk/linpha2/lib/plugins/maps/xml_parser.class.php Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-02-02 15:05:22 UTC (rev 4849) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-02-02 16:43:14 UTC (rev 4850) @@ -29,8 +29,8 @@ */ class LinMetaData { - public $defined_fields, $available_fields; - protected $objMetaTool; + public $defined_fields, $available_fields, $objMetaTool; + private $cachedFieldNames, $cachedFieldIds, $cachedSelectedFieldNames; /** Modified: trunk/linpha2/lib/modules/module.geodata.php =================================================================== --- trunk/linpha2/lib/modules/module.geodata.php 2008-02-02 15:05:22 UTC (rev 4849) +++ trunk/linpha2/lib/modules/module.geodata.php 2008-02-02 16:43:14 UTC (rev 4850) @@ -24,7 +24,7 @@ $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 +$image_times = $GPXData->getImageTimeRange(6); //parent_id linpha_photos echo "<br>***OFFSET CHECKING***"; Modified: trunk/linpha2/lib/plugins/maps/xml_parser.class.php =================================================================== --- trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-02 15:05:22 UTC (rev 4849) +++ trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-02 16:43:14 UTC (rev 4850) @@ -435,7 +435,8 @@ $trkdata[$this->date2unixTime($value['time'])] = array("time" => $this->date2unixTime($value['time']), "lat" => $value['trkpt']['lat'], - "lon" => $value['trkpt']['lon']); + "lon" => $value['trkpt']['lon'], + "ele" => $value['ele']); } echo "<br>***CALLING TRACKPOINT RADAR***<br>"; @@ -477,7 +478,8 @@ $this->writeGpsData2File($image_filename, $trkdata[$image_time]['lat'], - $trkdata[$image_time]['lon']); + $trkdata[$image_time]['lon'], + $trkdata[$image_time]['ele']); return false; } @@ -490,7 +492,8 @@ $this->writeGpsData2File($image_filename, $trkdata[$image_time + $offset]['lat'], - $trkdata[$image_time + $offset]['lon']); + $trkdata[$image_time + $offset]['lon'], + $trkdata[$image_time + $offset]['ele']); return false; } @@ -502,7 +505,8 @@ "".$trkdata[$image_time - $offset]['lon']."<br><br>"; $this->writeGpsData2File($image_filename, $trkdata[$image_time - $offset]['lat'], - $trkdata[$image_time - $offset]['lon']); + $trkdata[$image_time - $offset]['lon'], + $trkdata[$image_time - $offset]['ele']); return false; } @@ -517,13 +521,14 @@ /** * Write GPS data to file */ - private function writeGpsData2File($filename, $lat, $lon) + private function writeGpsData2File($filename, $lat, $lon, $ele) { echo "Trying to write GPS data to files - ***SIMULATION***<br>"; echo "Trying file: ".$filename."<br>"; ($lon > 0) ? $lonref = "E" : $latref = "W"; ($lat > 0) ? $latref = "N" : $latref = "S"; + ($ele > 0) ? $eleref = "0" : $eleref = "1"; echo "Latref ".$latref." Longref ".$lonref."<br><br>"; @@ -532,12 +537,15 @@ $filename = LINPHA_DIR."/$filename"; $return = ""; $meta = ""; - $parameters = "-GPSLongitudeRef = ".$lonref." " . - "-GPSLongitude = ".$lon." " . - "-GPSLatitudeRef = ".$latref." " . - "-GPSLatitude = ".$lat." "; - - //LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $meta, $return); + $parameters = "-GPSLongitudeRef='$lonref' " . + "-GPSLongitude='$lon' " . + "-GPSLatitudeRef='$latref' " . + "-GPSLatitude='$lat' " . + "-GPSAltitudeRef='$eleref' " . + "-GPSAltitude='$ele' "; + + //exec(LINPHA_DIR.'/lib/exiftool/exiftool'." $parameters $filename"); + //LinFilesys::linExec($metaData->objMetaTool.' '.$parameters.' "'.$filename.'"', $meta, $return); } }// end class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2008-02-04 13:52:34
|
Revision: 4851 http://linpha.svn.sourceforge.net/linpha/?rev=4851&view=rev Author: bzrudi Date: 2008-02-04 05:52:22 -0800 (Mon, 04 Feb 2008) Log Message: ----------- fixe exiftool gps data import Modified Paths: -------------- trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/modules/module.geodata.php trunk/linpha2/lib/plugins/maps/xml_parser.class.php Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-02-02 16:43:14 UTC (rev 4850) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-02-04 13:52:22 UTC (rev 4851) @@ -950,17 +950,17 @@ /** * Lower array data to make it compareable to $metaTags */ - //$lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); + $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])."', "; } } /** @@ -1004,14 +1004,21 @@ if(is_array($dataArray)) { + /** + * Lower array data to make it compareable to $metaTags + */ + + $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); + 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])."', "; } } + /** * Remove last two signs (the comma and the space) which we add to much */ Modified: trunk/linpha2/lib/modules/module.geodata.php =================================================================== --- trunk/linpha2/lib/modules/module.geodata.php 2008-02-02 16:43:14 UTC (rev 4850) +++ trunk/linpha2/lib/modules/module.geodata.php 2008-02-04 13:52:22 UTC (rev 4851) @@ -21,6 +21,18 @@ if (!defined('LINPHA_DIR')) { exit (1); } include_once LINPHA_DIR.'/lib/plugins/maps/xml_parser.class.php'; +$urlFull = LINPHA_LINK.'&linCat=geodata'; + +$linpha->template->setModuleName('geodata'); +//$linpha->template->overrideModule('head','map'); +$linpha->template->URL_full = $urlFull; +$linpha->template->URL_base = $urlFull; +$linpha->template->output['title'] = i18n("Geodata"); +include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); + + + + $GPXData = new LinXmlParser('/tmp/sample.gpx'); $array_with_gpx = $GPXData->readXmlFile(); $track_times = $GPXData->getGpxTimeRange($array_with_gpx); Modified: trunk/linpha2/lib/plugins/maps/xml_parser.class.php =================================================================== --- trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-02 16:43:14 UTC (rev 4850) +++ trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-04 13:52:22 UTC (rev 4851) @@ -136,7 +136,7 @@ } /** - * This method checks for start and end date/time for the gpx file + * This method checks for start and end date/time from the gpx file * @param array with all trkpt informtion from file * @return array (starttime, endtime); * @author bzrudi @@ -174,7 +174,7 @@ } /** - * This method checks parses all images in folder and get's start and + * This method 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); @@ -410,7 +410,7 @@ } /** - * This method is mainly a wrapper function for trkptradar() which does + * 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 @@ -528,6 +528,8 @@ ($lon > 0) ? $lonref = "E" : $latref = "W"; ($lat > 0) ? $latref = "N" : $latref = "S"; + // 0 = Above Sea Level + // 1 = Below Sea Level ($ele > 0) ? $eleref = "0" : $eleref = "1"; echo "Latref ".$latref." Longref ".$lonref."<br><br>"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2008-02-07 20:22:40
|
Revision: 4855 http://linpha.svn.sourceforge.net/linpha/?rev=4855&view=rev Author: fangehrn Date: 2008-02-07 12:22:33 -0800 (Thu, 07 Feb 2008) Log Message: ----------- updated to adodb503 Modified Paths: -------------- trunk/linpha2/lib/adodb/adodb-active-record.inc.php trunk/linpha2/lib/adodb/adodb-csvlib.inc.php trunk/linpha2/lib/adodb/adodb-datadict.inc.php trunk/linpha2/lib/adodb/adodb-error.inc.php trunk/linpha2/lib/adodb/adodb-errorhandler.inc.php trunk/linpha2/lib/adodb/adodb-errorpear.inc.php trunk/linpha2/lib/adodb/adodb-exceptions.inc.php trunk/linpha2/lib/adodb/adodb-iterator.inc.php trunk/linpha2/lib/adodb/adodb-lib.inc.php trunk/linpha2/lib/adodb/adodb-pager.inc.php trunk/linpha2/lib/adodb/adodb-pear.inc.php trunk/linpha2/lib/adodb/adodb-perf.inc.php trunk/linpha2/lib/adodb/adodb-php4.inc.php trunk/linpha2/lib/adodb/adodb-time.inc.php trunk/linpha2/lib/adodb/adodb-xmlschema.inc.php trunk/linpha2/lib/adodb/adodb-xmlschema03.inc.php trunk/linpha2/lib/adodb/adodb.inc.php trunk/linpha2/lib/adodb/drivers/adodb-access.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ado.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ado5.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ado_access.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ado_mssql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-borland_ibase.inc.php trunk/linpha2/lib/adodb/drivers/adodb-csv.inc.php trunk/linpha2/lib/adodb/drivers/adodb-db2.inc.php trunk/linpha2/lib/adodb/drivers/adodb-fbsql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-firebird.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ibase.inc.php trunk/linpha2/lib/adodb/drivers/adodb-informix.inc.php trunk/linpha2/lib/adodb/drivers/adodb-informix72.inc.php trunk/linpha2/lib/adodb/drivers/adodb-ldap.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mssql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mssqlpo.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mysql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mysqli.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mysqlt.inc.php trunk/linpha2/lib/adodb/drivers/adodb-netezza.inc.php trunk/linpha2/lib/adodb/drivers/adodb-oci8.inc.php trunk/linpha2/lib/adodb/drivers/adodb-oci805.inc.php trunk/linpha2/lib/adodb/drivers/adodb-oci8po.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbc.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbc_db2.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbc_mssql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbc_oracle.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbtp.inc.php trunk/linpha2/lib/adodb/drivers/adodb-odbtp_unicode.inc.php trunk/linpha2/lib/adodb/drivers/adodb-oracle.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo_mssql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo_mysql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo_oci.inc.php trunk/linpha2/lib/adodb/drivers/adodb-pdo_pgsql.inc.php trunk/linpha2/lib/adodb/drivers/adodb-postgres.inc.php trunk/linpha2/lib/adodb/drivers/adodb-postgres64.inc.php trunk/linpha2/lib/adodb/drivers/adodb-postgres7.inc.php trunk/linpha2/lib/adodb/drivers/adodb-postgres8.inc.php trunk/linpha2/lib/adodb/drivers/adodb-proxy.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sapdb.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sqlanywhere.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sqlite.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sqlitepo.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sybase.inc.php trunk/linpha2/lib/adodb/drivers/adodb-sybase_ase.inc.php trunk/linpha2/lib/adodb/drivers/adodb-vfp.inc.php trunk/linpha2/lib/adodb/lang/adodb-ar.inc.php trunk/linpha2/lib/adodb/lang/adodb-bg.inc.php trunk/linpha2/lib/adodb/lang/adodb-bgutf8.inc.php trunk/linpha2/lib/adodb/lang/adodb-ca.inc.php trunk/linpha2/lib/adodb/lang/adodb-en.inc.php trunk/linpha2/lib/adodb/lang/adodb-pl.inc.php trunk/linpha2/lib/adodb/lang/adodb-pt-br.inc.php trunk/linpha2/lib/adodb/lang/adodb-ro.inc.php trunk/linpha2/lib/adodb/lang/adodb-uk1251.inc.php trunk/linpha2/lib/adodb/pivottable.inc.php trunk/linpha2/lib/adodb/rsfilter.inc.php trunk/linpha2/lib/adodb/server.php trunk/linpha2/lib/adodb/toexport.inc.php trunk/linpha2/lib/adodb/tohtml.inc.php trunk/linpha2/lib/classes/adodb-errorhandler.inc.php trunk/linpha2/lib/classes/linpha.sql.class.php Added Paths: ----------- trunk/linpha2/lib/adodb/adodb-memcache.lib.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mssql_n.inc.php trunk/linpha2/lib/adodb/drivers/adodb-mysqlpo.inc.php trunk/linpha2/lib/adodb/lang/adodb_th.inc.php trunk/linpha2/lib/classes/adodb-exceptions.inc.php Removed Paths: ------------- trunk/linpha2/lib/adodb/adodb-time.zip Modified: trunk/linpha2/lib/adodb/adodb-active-record.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-active-record.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-active-record.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,7 +1,7 @@ <?php /* -@version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. +@version V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. Latest version is available at http://adodb.sourceforge.net Released under both BSD license and Lesser GPL library license. @@ -10,7 +10,7 @@ Active Record implementation. Superset of Zend Framework's. - Version 0.04 + Version 0.08 See http://www-128.ibm.com/developerworks/java/library/j-cb03076/?ca=dgr-lnxw01ActiveRecord for info on Ruby on Rails Active Record implementation @@ -18,11 +18,14 @@ global $_ADODB_ACTIVE_DBS; global $ADODB_ACTIVE_CACHESECS; // set to true to enable caching of metadata such as field info +global $ACTIVE_RECORD_SAFETY; // set to false to disable safety checks +global $ADODB_ACTIVE_DEFVALS; // use default values of table definition when creating new active record. // array of ADODB_Active_DB's, indexed by ADODB_Active_Record->_dbat $_ADODB_ACTIVE_DBS = array(); +$ACTIVE_RECORD_SAFETY = true; +$ADODB_ACTIVE_DEFVALS = false; - class ADODB_Active_DB { var $db; // ADOConnection var $tables; // assoc array of ADODB_Active_Table objects, indexed by tablename @@ -41,11 +44,16 @@ global $_ADODB_ACTIVE_DBS; foreach($_ADODB_ACTIVE_DBS as $k => $d) { - if ($d->db == $db) return $k; + if (PHP_VERSION >= 5) { + if ($d->db === $db) return $k; + } else { + if ($d->db->_connectionID === $db->_connectionID && $db->database == $d->db->database) + return $k; + } } $obj = new ADODB_Active_DB(); - $obj->db =& $db; + $obj->db = $db; $obj->tables = array(); $_ADODB_ACTIVE_DBS[] = $obj; @@ -63,16 +71,24 @@ var $_lasterr = false; // last error message var $_original = false; // the original values loaded or inserted, refreshed on update + static function UseDefaultValues($bool=null) + { + global $ADODB_ACTIVE_DEFVALS; + if (isset($bool)) $ADODB_ACTIVE_DEFVALS = $bool; + return $ADODB_ACTIVE_DEFVALS; + } + // should be static - function SetDatabaseAdapter(&$db) + static function SetDatabaseAdapter(&$db) { return ADODB_SetDatabaseAdapter($db); } - // php4 constructor - function ADODB_Active_Record($table = false, $pkeyarr=false, $db=false) + + public function __set($name, $value) { - ADODB_Active_Record::__construct($table,$pkeyarr,$db); + $name = str_replace(' ', '_', $name); + $this->$name = $value; } // php5 constructor @@ -102,6 +118,12 @@ $this->UpdateActiveTable($pkeyarr); } + function __wakeup() + { + $class = get_class($this); + new $class; + } + function _pluralize($table) { $ut = strtoupper($table); @@ -129,20 +151,26 @@ function UpdateActiveTable($pkeys=false,$forceUpdate=false) { global $ADODB_ASSOC_CASE,$_ADODB_ACTIVE_DBS , $ADODB_CACHE_DIR, $ADODB_ACTIVE_CACHESECS; - - $activedb =& $_ADODB_ACTIVE_DBS[$this->_dbat]; + global $ADODB_ACTIVE_DEFVALS; + $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; + $table = $this->_table; $tables = $activedb->tables; $tableat = $this->_tableat; if (!$forceUpdate && !empty($tables[$tableat])) { - $tobj =& $tables[$tableat]; - foreach($tobj->flds as $name => $fld) + + $tobj = $tables[$tableat]; + foreach($tobj->flds as $name => $fld) { + if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) + $this->$name = $fld->default_value; + else $this->$name = null; + } return; } - $db =& $activedb->db; + $db = $activedb->db; $fname = $ADODB_CACHE_DIR . '/adodb_' . $db->databaseType . '_active_'. $table . '.cache'; if (!$forceUpdate && $ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR && file_exists($fname)) { $fp = fopen($fname,'r'); @@ -191,7 +219,10 @@ case 0: foreach($cols as $name => $fldobj) { $name = strtolower($name); - $this->$name = null; + if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) + $this->$name = $fldobj->default_value; + else + $this->$name = null; $attr[$name] = $fldobj; } foreach($pkeys as $k => $name) { @@ -202,7 +233,11 @@ case 1: foreach($cols as $name => $fldobj) { $name = strtoupper($name); - $this->$name = null; + + if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) + $this->$name = $fldobj->default_value; + else + $this->$name = null; $attr[$name] = $fldobj; } @@ -212,12 +247,16 @@ break; default: foreach($cols as $name => $fldobj) { - $name = ($name); - $this->$name = null; + $name = ($fldobj->name); + + if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) + $this->$name = $fldobj->default_value; + else + $this->$name = null; $attr[$name] = $fldobj; } foreach($pkeys as $k => $name) { - $keys[$name] = ($name); + $keys[$name] = $cols[$name]->name; } break; } @@ -250,7 +289,7 @@ if ($this->_dbat < 0) $db = false; else { $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; - $db =& $activedb->db; + $db = $activedb->db; } if (function_exists('adodb_throw')) { @@ -274,8 +313,17 @@ return $this->_lasterr; } + function ErrorNo() + { + if ($this->_dbat < 0) return -9999; // no database connection... + $db = $this->DB(); + + return (int) $db->ErrorNo(); + } + + // retrieve ADOConnection from _ADODB_Active_DBs - function &DB() + function DB() { global $_ADODB_ACTIVE_DBS; @@ -285,24 +333,26 @@ return $false; } $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; - $db =& $activedb->db; + $db = $activedb->db; return $db; } // retrieve ADODB_Active_Table - function &TableInfo() + function TableInfo() { global $_ADODB_ACTIVE_DBS; $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; - $table =& $activedb->tables[$this->_tableat]; + $table = $activedb->tables[$this->_tableat]; return $table; } // set a numeric array (using natural table field ordering) as object properties function Set(&$row) { - $db =& $this->DB(); + global $ACTIVE_RECORD_SAFETY; + + $db = $this->DB(); if (!$row) { $this->_saved = false; @@ -311,18 +361,34 @@ $this->_saved = true; - $table =& $this->TableInfo(); - if (sizeof($table->flds) != sizeof($row)) { + $table = $this->TableInfo(); + if ($ACTIVE_RECORD_SAFETY && sizeof($table->flds) != sizeof($row)) { + # <AP> + $bad_size = TRUE; + if (sizeof($row) == 2 * sizeof($table->flds)) { + // Only keep string keys + $keys = array_filter(array_keys($row), 'is_string'); + if (sizeof($keys) == sizeof($table->flds)) + $bad_size = FALSE; + } + if ($bad_size) { $this->Error("Table structure of $this->_table has changed","Load"); return false; } - - $cnt = 0; + # </AP> + } + else + $keys = array_keys($row); + # <AP> + reset($keys); + $this->_original = array(); foreach($table->flds as $name=>$fld) { - $this->$name = $row[$cnt]; - $cnt += 1; + $value = $row[current($keys)]; + $this->$name = $value; + $this->_original[] = $value; + next($keys); } - $this->_original = $row; + # </AP> return true; } @@ -383,7 +449,7 @@ function Load($where,$bindarr=false) { - $db =& $this->DB(); if (!$db) return false; + $db = $this->DB(); if (!$db) return false; $this->_where = $where; $save = $db->SetFetchMode(ADODB_FETCH_NUM); @@ -405,9 +471,9 @@ // false on error function Insert() { - $db =& $this->DB(); if (!$db) return false; + $db = $this->DB(); if (!$db) return false; $cnt = 0; - $table =& $this->TableInfo(); + $table = $this->TableInfo(); $valarr = array(); $names = array(); @@ -455,8 +521,8 @@ function Delete() { - $db =& $this->DB(); if (!$db) return false; - $table =& $this->TableInfo(); + $db = $this->DB(); if (!$db) return false; + $table = $this->TableInfo(); $where = $this->GenWhere($db,$table); $sql = 'DELETE FROM '.$this->_table.' WHERE '.$where; @@ -466,10 +532,10 @@ } // returns an array of active record objects - function &Find($whereOrderBy,$bindarr=false,$pkeysArr=false) + function Find($whereOrderBy,$bindarr=false,$pkeysArr=false) { - $db =& $this->DB(); if (!$db || empty($this->_table)) return false; - $arr =& $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr); + $db = $this->DB(); if (!$db || empty($this->_table)) return false; + $arr = $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr); return $arr; } @@ -478,8 +544,8 @@ { global $ADODB_ASSOC_CASE; - $db =& $this->DB(); if (!$db) return false; - $table =& $this->TableInfo(); + $db = $this->DB(); if (!$db) return false; + $table = $this->TableInfo(); $pkey = $table->keys; @@ -509,7 +575,7 @@ if ($ADODB_ASSOC_CASE == 0) foreach($pkey as $k => $v) $pkey[$k] = strtolower($v); - elseif ($ADODB_ASSOC_CASE == 0) + elseif ($ADODB_ASSOC_CASE == 1) foreach($pkey as $k => $v) $pkey[$k] = strtoupper($v); @@ -530,7 +596,7 @@ } } - $this->_original =& $valarr; + $this->_original = $valarr; } return $ok; } @@ -538,8 +604,8 @@ // returns 0 on error, 1 on update, -1 if no change in data (no update) function Update() { - $db =& $this->DB(); if (!$db) return false; - $table =& $this->TableInfo(); + $db = $this->DB(); if (!$db) return false; + $table = $this->TableInfo(); $where = $this->GenWhere($db, $table); @@ -584,7 +650,7 @@ $sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." WHERE ".$where; $ok = $db->Execute($sql,$valarr); if ($ok) { - $this->_original =& $neworig; + $this->_original = $neworig; return 1; } return 0; @@ -592,7 +658,7 @@ function GetAttributeNames() { - $table =& $this->TableInfo(); + $table = $this->TableInfo(); if (!$table) return false; return array_keys($table->flds); } Modified: trunk/linpha2/lib/adodb/adodb-csvlib.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-csvlib.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-csvlib.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -8,7 +8,7 @@ /* - V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt. @@ -54,7 +54,7 @@ $line = "====1,$tt,$sql\n"; if ($rs->databaseType == 'array') { - $rows =& $rs->_array; + $rows = $rs->_array; } else { $rows = array(); while (!$rs->EOF) { @@ -64,7 +64,7 @@ } for($i=0; $i < $max; $i++) { - $o =& $rs->FetchField($i); + $o = $rs->FetchField($i); $flds[] = $o; } @@ -90,7 +90,7 @@ * error occurred in sql INSERT/UPDATE/DELETE, * empty recordset is returned */ - function &csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array') + function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array') { $false = false; $err = false; @@ -261,6 +261,7 @@ /** * Save a file $filename and its $contents (normally for caching) with file locking + * Returns true if ok, false if fopen/fwrite error, 0 if rename error (eg. file is locked) */ function adodb_write_file($filename, $contents,$debug=false) { @@ -280,25 +281,29 @@ $mtime = substr(str_replace(' ','_',microtime()),2); // getmypid() actually returns 0 on Win98 - never mind! $tmpname = $filename.uniqid($mtime).getmypid(); - if (!($fd = @fopen($tmpname,'a'))) return false; - $ok = ftruncate($fd,0); - if (!fwrite($fd,$contents)) $ok = false; + if (!($fd = @fopen($tmpname,'w'))) return false; + if (fwrite($fd,$contents)) $ok = true; + else $ok = false; fclose($fd); - chmod($tmpname,0644); - // the tricky moment - @unlink($filename); - if (!@rename($tmpname,$filename)) { - unlink($tmpname); - $ok = false; + + if ($ok) { + chmod($tmpname,0644); + // the tricky moment + @unlink($filename); + if (!@rename($tmpname,$filename)) { + unlink($tmpname); + $ok = 0; + } + if (!$ok) { + if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); + } } - if (!$ok) { - if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); - } return $ok; } if (!($fd = @fopen($filename, 'a'))) return false; if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) { - $ok = fwrite( $fd, $contents ); + if (fwrite( $fd, $contents )) $ok = true; + else $ok = false; fclose($fd); chmod($filename,0644); }else { Modified: trunk/linpha2/lib/adodb/adodb-datadict.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-datadict.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-datadict.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,7 +1,7 @@ <?php /** - V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -216,8 +216,115 @@ } function MetaType($t,$len=-1,$fieldobj=false) - { - return ADORecordSet::MetaType($t,$len,$fieldobj); + { + static $typeMap = array( + 'VARCHAR' => 'C', + 'VARCHAR2' => 'C', + 'CHAR' => 'C', + 'C' => 'C', + 'STRING' => 'C', + 'NCHAR' => 'C', + 'NVARCHAR' => 'C', + 'VARYING' => 'C', + 'BPCHAR' => 'C', + 'CHARACTER' => 'C', + 'INTERVAL' => 'C', # Postgres + 'MACADDR' => 'C', # postgres + ## + 'LONGCHAR' => 'X', + 'TEXT' => 'X', + 'NTEXT' => 'X', + 'M' => 'X', + 'X' => 'X', + 'CLOB' => 'X', + 'NCLOB' => 'X', + 'LVARCHAR' => 'X', + ## + 'BLOB' => 'B', + 'IMAGE' => 'B', + 'BINARY' => 'B', + 'VARBINARY' => 'B', + 'LONGBINARY' => 'B', + 'B' => 'B', + ## + 'YEAR' => 'D', // mysql + 'DATE' => 'D', + 'D' => 'D', + ## + 'UNIQUEIDENTIFIER' => 'C', # MS SQL Server + ## + 'TIME' => 'T', + 'TIMESTAMP' => 'T', + 'DATETIME' => 'T', + 'TIMESTAMPTZ' => 'T', + 'T' => 'T', + 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql + ## + 'BOOL' => 'L', + 'BOOLEAN' => 'L', + 'BIT' => 'L', + 'L' => 'L', + ## + 'COUNTER' => 'R', + 'R' => 'R', + 'SERIAL' => 'R', // ifx + 'INT IDENTITY' => 'R', + ## + 'INT' => 'I', + 'INT2' => 'I', + 'INT4' => 'I', + 'INT8' => 'I', + 'INTEGER' => 'I', + 'INTEGER UNSIGNED' => 'I', + 'SHORT' => 'I', + 'TINYINT' => 'I', + 'SMALLINT' => 'I', + 'I' => 'I', + ## + 'LONG' => 'N', // interbase is numeric, oci8 is blob + 'BIGINT' => 'N', // this is bigger than PHP 32-bit integers + 'DECIMAL' => 'N', + 'DEC' => 'N', + 'REAL' => 'N', + 'DOUBLE' => 'N', + 'DOUBLE PRECISION' => 'N', + 'SMALLFLOAT' => 'N', + 'FLOAT' => 'N', + 'NUMBER' => 'N', + 'NUM' => 'N', + 'NUMERIC' => 'N', + 'MONEY' => 'N', + + ## informix 9.2 + 'SQLINT' => 'I', + 'SQLSERIAL' => 'I', + 'SQLSMINT' => 'I', + 'SQLSMFLOAT' => 'N', + 'SQLFLOAT' => 'N', + 'SQLMONEY' => 'N', + 'SQLDECIMAL' => 'N', + 'SQLDATE' => 'D', + 'SQLVCHAR' => 'C', + 'SQLCHAR' => 'C', + 'SQLDTIME' => 'T', + 'SQLINTERVAL' => 'N', + 'SQLBYTES' => 'B', + 'SQLTEXT' => 'X', + ## informix 10 + "SQLINT8" => 'I8', + "SQLSERIAL8" => 'I8', + "SQLNCHAR" => 'C', + "SQLNVCHAR" => 'C', + "SQLLVARCHAR" => 'X', + "SQLBOOL" => 'L' + ); + + if (!$this->connection->IsConnected()) { + $t = strtoupper($t); + if (isset($typeMap[$t])) return $typeMap[$t]; + return 'N'; + } + return $this->connection->MetaType($t,$len,$fieldobj); } function NameQuote($name = NULL,$allowBrackets=false) @@ -261,7 +368,7 @@ function ExecuteSQLArray($sql, $continueOnError = true) { $rez = 2; - $conn = &$this->connection; + $conn = $this->connection; $saved = $conn->debug; foreach($sql as $line) { @@ -277,7 +384,7 @@ return $rez; } - /* + /** Returns the actual type given a character code. C: varchar @@ -344,11 +451,19 @@ { $tabname = $this->TableName ($tabname); $sql = array(); - list($lines,$pkey) = $this->_GenFields($flds); + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; foreach($lines as $v) { $sql[] = $alter . $v; } + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + } return $sql; } @@ -367,11 +482,20 @@ { $tabname = $this->TableName ($tabname); $sql = array(); - list($lines,$pkey) = $this->_GenFields($flds); + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; foreach($lines as $v) { $sql[] = $alter . $v; } + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + + } return $sql; } @@ -389,7 +513,9 @@ { $tabname = $this->TableName ($tabname); if ($flds) { - list($lines,$pkey) = $this->_GenFields($flds); + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); list(,$first) = each($lines); list(,$column_def) = split("[\t ]+",$first,2); } @@ -429,22 +555,36 @@ return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname))); } - /* + /** Generate the SQL to create table. Returns an array of sql strings. */ - function CreateTableSQL($tabname, $flds, $tableoptions=false) + function CreateTableSQL($tabname, $flds, $tableoptions=array()) { - if (!$tableoptions) $tableoptions = array(); + list($lines,$pkey,$idxs) = $this->_GenFields($flds, true); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); - list($lines,$pkey) = $this->_GenFields($flds, true); - $taboptions = $this->_Options($tableoptions); $tabname = $this->TableName ($tabname); $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions); + // ggiunta - 2006/10/12 - KLUDGE: + // if we are on autoincrement, and table options includes REPLACE, the + // autoincrement sequence has already been dropped on table creation sql, so + // we avoid passing REPLACE to trigger creation code. This prevents + // creating sql that double-drops the sequence + if ($this->autoIncrement && isset($taboptions['REPLACE'])) + unset($taboptions['REPLACE']); $tsql = $this->_Triggers($tabname,$taboptions); foreach($tsql as $s) $sql[] = $s; + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + } + return $sql; } @@ -460,6 +600,9 @@ $f1 = array(); foreach($f0 as $token) { switch (strtoupper($token)) { + case 'INDEX': + $f1['INDEX'] = ''; + // fall through intentionally case 'CONSTRAINT': case 'DEFAULT': $hasparam = $token; @@ -471,6 +614,20 @@ break; } } + // 'index' token without a name means single column index: name it after column + if (array_key_exists('INDEX', $f1) && $f1['INDEX'] == '') { + $f1['INDEX'] = isset($f0['NAME']) ? $f0['NAME'] : $f0[0]; + // check if column name used to create an index name was quoted + if (($f1['INDEX'][0] == '"' || $f1['INDEX'][0] == "'" || $f1['INDEX'][0] == "`") && + ($f1['INDEX'][0] == substr($f1['INDEX'], -1))) { + $f1['INDEX'] = $f1['INDEX'][0].'idx_'.substr($f1['INDEX'], 1, -1).$f1['INDEX'][0]; + } + else + $f1['INDEX'] = 'idx_'.$f1['INDEX']; + } + // reset it, so we don't get next field 1st token as INDEX... + $hasparam = false; + $flds[] = $f1; } @@ -478,9 +635,10 @@ $this->autoIncrement = false; $lines = array(); $pkey = array(); + $idxs = array(); foreach($flds as $fld) { $fld = _array_change_key_case($fld); - + $fname = false; $fdefault = false; $fautoinc = false; @@ -494,6 +652,8 @@ $fconstraint = false; $fnotnull = false; $funsigned = false; + $findex = ''; + $funiqueindex = false; //----------------- // Parse attributes @@ -519,7 +679,8 @@ case 'AUTOINCREMENT': case 'AUTO': $fautoinc = true; $fnotnull = true; break; case 'KEY': - case 'PRIMARY': $fprimary = $v; $fnotnull = true; break; + // a primary key col can be non unique in itself (if key spans many cols...) + case 'PRIMARY': $fprimary = $v; $fnotnull = true; /*$funiqueindex = true;*/ break; case 'DEF': case 'DEFAULT': $fdefault = $v; break; case 'NOTNULL': $fnotnull = $v; break; @@ -527,6 +688,9 @@ case 'DEFDATE': $fdefdate = $v; break; case 'DEFTIMESTAMP': $fdefts = $v; break; case 'CONSTRAINT': $fconstraint = $v; break; + // let INDEX keyword create a 'very standard' index on column + case 'INDEX': $findex = $v; break; + case 'UNIQUE': $funiqueindex = true; break; } //switch } // foreach $fld @@ -556,6 +720,27 @@ // some databases do not allow blobs to have defaults if ($ty == 'X') $fdefault = false; + // build list of indexes + if ($findex != '') { + if (array_key_exists($findex, $idxs)) { + $idxs[$findex]['cols'][] = ($fname); + if (in_array('UNIQUE', $idxs[$findex]['opts']) != $funiqueindex) { + if ($this->debug) ADOConnection::outp("Index $findex defined once UNIQUE and once not"); + } + if ($funiqueindex && !in_array('UNIQUE', $idxs[$findex]['opts'])) + $idxs[$findex]['opts'][] = 'UNIQUE'; + } + else + { + $idxs[$findex] = array(); + $idxs[$findex]['cols'] = array($fname); + if ($funiqueindex) + $idxs[$findex]['opts'] = array('UNIQUE'); + else + $idxs[$findex]['opts'] = array(); + } + } + //-------------------- // CONSTRUCT FIELD SQL if ($fdefts) { @@ -570,24 +755,47 @@ } else { $fdefault = $this->connection->sysDate; } - } else if ($fdefault !== false && !$fnoquote) + } else if ($fdefault !== false && !$fnoquote) { if ($ty == 'C' or $ty == 'X' or - ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault))) + ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault))) { + + if (($ty == 'D' || $ty == 'T') && strtolower($fdefault) != 'null') { + // convert default date into database-aware code + if ($ty == 'T') + { + $fdefault = $this->connection->DBTimeStamp($fdefault); + } + else + { + $fdefault = $this->connection->DBDate($fdefault); + } + } + else if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ') $fdefault = trim($fdefault); else if (strtolower($fdefault) != 'null') $fdefault = $this->connection->qstr($fdefault); + } + } $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned); + // add index creation if ($widespacing) $fname = str_pad($fname,24); + + // check for field names appearing twice + if (array_key_exists($fid, $lines)) { + ADOConnection::outp("Field '$fname' defined twice"); + } + $lines[$fid] = $fname.' '.$ftype.$suffix; if ($fautoinc) $this->autoIncrement = true; } // foreach $flds - return array($lines,$pkey); + return array($lines,$pkey,$idxs); } - /* + + /** GENERATE THE SIZE PART OF THE DATATYPE $ftype is the actual type $ty is the type defined originally in the DDL @@ -680,7 +888,7 @@ return $sql; } - /* + /** GENERATE TRIGGERS IF NEEDED used when table has auto-incrementing field that is emulated using triggers */ @@ -689,7 +897,7 @@ return array(); } - /* + /** Sanitize options, so that array elements with no keys are promoted to keys */ function _Options($opts) @@ -703,7 +911,7 @@ return $newopts; } - /* + /** "Florian Buzin [ easywe ]" <florian.buzin#easywe.de> This function changes/adds new fields to your table. You don't @@ -760,7 +968,9 @@ // already exists, alter table instead - list($lines,$pkey) = $this->_GenFields($flds); + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); $alter = 'ALTER TABLE ' . $this->TableName($tablename); $sql = array(); @@ -770,8 +980,13 @@ $flds = Lens_ParseArgs($v,','); // We are trying to change the size of the field, if not allowed, simply ignore the request. - if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) continue; - + // $flds[1] holds the type, $flds[2] holds the size -postnuke addition + if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4) + && (isset($flds[0][2]) && is_numeric($flds[0][2]))) { + if ($this->debug) ADOConnection::outp(sprintf("<h3>%s cannot be changed to %s currently</h3>", $flds[0][0], $flds[0][1])); + #echo "<h3>$this->alterCol cannot be changed to $flds currently</h3>"; + continue; + } $sql[] = $alter . $this->alterCol . ' ' . $v; } else { $sql[] = $alter . $this->addCol . ' ' . $v; Modified: trunk/linpha2/lib/adodb/adodb-error.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-error.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-error.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,6 +1,6 @@ <?php /** - * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + * @version V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, * the BSD license will take precedence. @@ -92,14 +92,14 @@ { if (is_numeric($errormsg)) return (integer) $errormsg; static $error_regexps = array( - '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, - '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, - '/divide by zero$/' => DB_ERROR_DIVZERO, - '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, - '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, - '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, - '/referential integrity violation/' => DB_ERROR_CONSTRAINT, - '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/' + '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/i' => DB_ERROR_NOSUCHTABLE, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/i' => DB_ERROR_ALREADY_EXISTS, + '/divide by zero$/i' => DB_ERROR_DIVZERO, + '/pg_atoi: error in .*: can\'t parse /i' => DB_ERROR_INVALID_NUMBER, + '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/i' => DB_ERROR_NOSUCHFIELD, + '/parser: parse error at or near \"/i' => DB_ERROR_SYNTAX, + '/referential integrity violation/i' => DB_ERROR_CONSTRAINT, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/i' => DB_ERROR_ALREADY_EXISTS ); reset($error_regexps); Modified: trunk/linpha2/lib/adodb/adodb-errorhandler.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-errorhandler.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-errorhandler.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,6 +1,6 @@ <?php /** - * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + * @version V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, * the BSD license will take precedence. @@ -30,7 +30,6 @@ */ function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) { - echo 'hi'; if (error_reporting() == 0) return; // obey @ protocol switch($fn) { case 'EXECUTE': @@ -65,26 +64,16 @@ * and optionally, port number, of the socket receiving the debug information. * 3 message is appended to the file destination */ - /*if (defined('ADODB_ERROR_LOG_TYPE')) { + if (defined('ADODB_ERROR_LOG_TYPE')) { $t = date('Y-m-d H:i:s'); if (defined('ADODB_ERROR_LOG_DEST')) error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST); else error_log("($t) $s", ADODB_ERROR_LOG_TYPE); - }*/ + } - /** - * if adodb errorhandler is used, the function $db->ErrorMsg() does not work - * anymore - * -> output the error to screen - * -> no need anymore for : - * if(!$create) { echo $GLOBALS['db']->ErrorMsg().'<br />'; } - */ - echo $s.'<br />'; - - linLog(LOG_TYPE_DB,LOG_ERR,'db',$s); //print "<p>$s</p>"; - //trigger_error($s,ADODB_ERROR_HANDLER_TYPE); + trigger_error($s,ADODB_ERROR_HANDLER_TYPE); } ?> Modified: trunk/linpha2/lib/adodb/adodb-errorpear.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-errorpear.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-errorpear.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,6 +1,6 @@ <?php /** - * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + * @version V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -78,7 +78,7 @@ * Returns last PEAR_Error object. This error might be for an error that * occured several sql statements ago. */ -function &ADODB_PEAR_Error() +function ADODB_PEAR_Error() { global $ADODB_Last_PEAR_Error; Modified: trunk/linpha2/lib/adodb/adodb-exceptions.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-exceptions.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-exceptions.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,7 +1,7 @@ <?php /** - * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + * @version V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, * the BSD license will take precedence. Modified: trunk/linpha2/lib/adodb/adodb-iterator.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-iterator.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-iterator.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,7 +1,7 @@ <?php /* - V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -18,68 +18,13 @@ Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2 + + + Moved to adodb.inc.php to improve performance. */ - class ADODB_Iterator implements Iterator { - private $rs; - function __construct($rs) - { - $this->rs = $rs; - } - function rewind() - { - $this->rs->MoveFirst(); - } - function valid() - { - return !$this->rs->EOF; - } - - function key() - { - return $this->rs->_currentRow; - } - - function current() - { - return $this->rs->fields; - } - - function next() - { - $this->rs->MoveNext(); - } - - function __call($func, $params) - { - return call_user_func_array(array($this->rs, $func), $params); - } - - - function hasMore() - { - return !$this->rs->EOF; - } - -} - - -class ADODB_BASE_RS implements IteratorAggregate { - function getIterator() { - return new ADODB_Iterator($this); - } - - /* this is experimental - i don't really know what to return... */ - function __toString() - { - include_once(ADODB_DIR.'/toexport.inc.php'); - return _adodb_export($this,',',',',false,true); - } -} - - ?> \ No newline at end of file Modified: trunk/linpha2/lib/adodb/adodb-lib.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-lib.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-lib.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,5 +1,8 @@ <?php + + + // security - hide paths if (!defined('ADODB_DIR')) die(); @@ -7,7 +10,7 @@ $ADODB_INCLUDED_LIB = 1; /* - @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim\@natsoft.com.my). All rights reserved. + @version V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim\@natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. See License.txt. @@ -16,7 +19,106 @@ Less commonly used functions are placed here to reduce size of adodb.inc.php. */ +function adodb_strip_order_by($sql) +{ + $rez = preg_match('/(\sORDER\s+BY\s[^)]*)/is',$sql,$arr); + if ($arr) + if (strpos($arr[0],'(') !== false) { + $at = strpos($sql,$arr[0]); + $cntin = 0; + for ($i=$at, $max=strlen($sql); $i < $max; $i++) { + $ch = $sql[$i]; + if ($ch == '(') { + $cntin += 1; + } elseif($ch == ')') { + $cntin -= 1; + if ($cntin < 0) { + break; + } + } + } + $sql = substr($sql,0,$at).substr($sql,$i); + } else + $sql = str_replace($arr[0], '', $sql); + return $sql; + } +if (false) { + $sql = 'select * from (select a from b order by a(b),b(c) desc)'; + $sql = '(select * from abc order by 1)'; + die(adodb_strip_order_by($sql)); +} + +function adodb_probetypes(&$array,&$types,$probe=8) +{ +// probe and guess the type + $types = array(); + if ($probe > sizeof($array)) $max = sizeof($array); + else $max = $probe; + + + for ($j=0;$j < $max; $j++) { + $row = $array[$j]; + if (!$row) break; + $i = -1; + foreach($row as $v) { + $i += 1; + + if (isset($types[$i]) && $types[$i]=='C') continue; + + //print " ($i ".$types[$i]. "$v) "; + $v = trim($v); + + if (!preg_match('/^[+-]{0,1}[0-9\.]+$/',$v)) { + $types[$i] = 'C'; // once C, always C + + continue; + } + if ($j == 0) { + // If empty string, we presume is character + // test for integer for 1st row only + // after that it is up to testing other rows to prove + // that it is not an integer + if (strlen($v) == 0) $types[$i] = 'C'; + if (strpos($v,'.') !== false) $types[$i] = 'N'; + else $types[$i] = 'I'; + continue; + } + + if (strpos($v,'.') !== false) $types[$i] = 'N'; + + } + } + +} + +function adodb_transpose(&$arr, &$newarr, &$hdr, &$fobjs) +{ + $oldX = sizeof(reset($arr)); + $oldY = sizeof($arr); + + if ($hdr) { + $startx = 1; + $hdr = array('Fields'); + for ($y = 0; $y < $oldY; $y++) { + $hdr[] = $arr[$y][0]; + } + } else + $startx = 0; + + for ($x = $startx; $x < $oldX; $x++) { + if ($fobjs) { + $o = $fobjs[$x]; + $newarr[] = array($o->name); + } else + $newarr[] = array(); + + for ($y = 0; $y < $oldY; $y++) { + $newarr[$x-$startx][] = $arr[$y][$x]; + } + } +} + // Force key to upper. // See also http://www.php.net/manual/en/function.array-change-key-case.php function _array_change_key_case($an_array) @@ -42,7 +144,10 @@ $keyCol = array($keyCol); } foreach($fieldArray as $k => $v) { - if ($autoQuote && !is_numeric($v) and strncmp($v,"'",1) !== 0 and strcasecmp($v,'null')!=0) { + if ($v === null) { + $v = 'NULL'; + $fieldArray[$k] = $v; + } else if ($autoQuote && !is_numeric($v) /*and strncmp($v,"'",1) !== 0 -- sql injection risk*/ and strcasecmp($v,$zthis->null2null)!=0) { $v = $zthis->qstr($v); $fieldArray[$k] = $v; } @@ -297,15 +402,15 @@ { $qryRecs = 0; - if (preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) || + if (!empty($zthis->_nestedSQL) || preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) || preg_match('/\s+GROUP\s+BY\s+/is',$sql) || preg_match('/\s+UNION\s+/is',$sql)) { + + $rewritesql = adodb_strip_order_by($sql); + // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias // but this is only supported by oracle and postgresql... if ($zthis->dataProvider == 'oci8') { - - $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); - // Allow Oracle hints to be used for query optimization, Chris Wrye if (preg_match('#/\\*+.*?\\*\\/#', $sql, $hint)) { $rewritesql = "SELECT ".$hint[0]." COUNT(*) FROM (".$rewritesql.")"; @@ -313,33 +418,22 @@ $rewritesql = "SELECT COUNT(*) FROM (".$rewritesql.")"; } else if (strncmp($zthis->databaseType,'postgres',8) == 0) { - - $info = $zthis->ServerInfo(); - if (substr($info['version'],0,3) >= 7.1) { // good till version 999 - $rewritesql = preg_replace('/(\sORDER\s+BY\s[^)]*)/is','',$sql); - $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_"; - } + $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_"; + } else { + $rewritesql = "SELECT COUNT(*) FROM ($rewritesql)"; } } else { // now replace SELECT ... FROM with SELECT COUNT(*) FROM $rewritesql = preg_replace( '/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql); - - - // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails // with mssql, access and postgresql. Also a good speedup optimization - skips sorting! // also see http://phplens.com/lens/lensforum/msgs.php?id=12752 - if (preg_match('/\sORDER\s+BY\s*\(/i',$rewritesql)) - $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$rewritesql); - else - $rewritesql = preg_replace('/(\sORDER\s+BY\s[^)]*)/is','',$rewritesql); + $rewritesql = adodb_strip_order_by($rewritesql); } - - if (isset($rewritesql) && $rewritesql != $sql) { - if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[1]; + if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; if ($secs2cache) { // we only use half the time of secs2cache because the count can quickly @@ -361,7 +455,7 @@ if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; - $rstest = &$zthis->Execute($rewritesql,$inputarr); + $rstest = $zthis->Execute($rewritesql,$inputarr); if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr); if ($rstest) { @@ -383,7 +477,6 @@ $rstest->Close(); if ($qryRecs == -1) return 0; } - return $qryRecs; } @@ -396,7 +489,7 @@ data will get out of synch. use CachePageExecute() only with tables that rarely change. */ -function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, +function _adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) { $atfirstpage = false; @@ -432,9 +525,9 @@ // We get the data we want $offset = $nrows * ($page-1); if ($secs2cache > 0) - $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); + $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); else - $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); + $rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); // Before returning the RecordSet, we set the pagination properties we need @@ -450,7 +543,7 @@ } // Iv\xE1n Oliva version -function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) +function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) { $atfirstpage = false; @@ -466,16 +559,16 @@ // the last page number. $pagecounter = $page + 1; $pagecounteroffset = ($pagecounter * $nrows) - $nrows; - if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); - else $rstest = &$zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); + if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); + else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); if ($rstest) { while ($rstest && $rstest->EOF && $pagecounter>0) { $atlastpage = true; $pagecounter--; $pagecounteroffset = $nrows * ($pagecounter - 1); $rstest->Close(); - if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); - else $rstest = &$zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); + if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); + else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); } if ($rstest) $rstest->Close(); } @@ -487,8 +580,8 @@ // We get the data we want $offset = $nrows * ($page-1); - if ($secs2cache > 0) $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); - else $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); + if ($secs2cache > 0) $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); + else $rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); // Before returning the RecordSet, we set the pagination properties we need if ($rsreturn) { @@ -502,6 +595,8 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=2) { + global $ADODB_QUOTE_FIELDNAMES; + if (!$rs) { printf(ADODB_BAD_RS,'GetUpdateSQL'); return false; @@ -548,7 +643,7 @@ $type = 'C'; } - if (strpos($upperfname,' ') !== false) + if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; else $fnameq = $upperfname; @@ -558,7 +653,7 @@ //********************************************************// if (is_null($arrFields[$upperfname]) || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0) - || $arrFields[$upperfname] === 'null' + || $arrFields[$upperfname] === $zthis->null2null ) { switch ($force) { @@ -580,7 +675,7 @@ default: case 3: //Set the value that was given in array, so you can give both null and empty values - if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === 'null') { + if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) { $setFields .= $field->name . " = null, "; } else { $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq); @@ -662,6 +757,7 @@ static $cacheRS = false; static $cacheSig = 0; static $cacheCols; + global $ADODB_QUOTE_FIELDNAMES; $tableName = ''; $values = ''; @@ -680,10 +776,10 @@ //php can't do a $rsclass::MetaType() $rsclass = $zthis->rsPrefix.$zthis->databaseType; $recordSet = new $rsclass(-1,$zthis->fetchMode); - $recordSet->connection = &$zthis; + $recordSet->connection = $zthis; if (is_string($cacheRS) && $cacheRS == $rs) { - $columns =& $cacheCols; + $columns = $cacheCols; } else { $columns = $zthis->MetaColumns( $tableName ); $cacheRS = $tableName; @@ -691,7 +787,7 @@ } } else if (is_subclass_of($rs, 'adorecordset')) { if (isset($rs->insertSig) && is_integer($cacheRS) && $cacheRS == $rs->insertSig) { - $columns =& $cacheCols; + $columns = $cacheCols; } else { for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) $columns[] = $rs->FetchField($i); @@ -699,7 +795,7 @@ $cacheCols = $columns; $rs->insertSig = $cacheSig++; } - $recordSet =& $rs; + $recordSet = $rs; } else { printf(ADODB_BAD_RS,'GetInsertSQL'); @@ -711,7 +807,7 @@ $upperfname = strtoupper($field->name); if (adodb_key_exists($upperfname,$arrFields,$force)) { $bad = false; - if (strpos($upperfname,' ') !== false) + if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; else $fnameq = $upperfname; @@ -721,7 +817,7 @@ /********************************************************/ if (is_null($arrFields[$upperfname]) || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0) - || $arrFields[$upperfname] === 'null' + || $arrFields[$upperfname] === $zthis->null2null ) { switch ($force) { @@ -743,7 +839,7 @@ default: case 3: //Set the value that was given in array, so you can give both null and empty values - if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === 'null') { + if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) { $values .= "null, "; } else { $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq); @@ -904,9 +1000,21 @@ case "T": $val = $zthis->DBTimeStamp($arrFields[$fname]); break; + + case "N": + $val = $arrFields[$fname]; + if (!is_numeric($val)) $val = str_replace(',', '.', (float)$val); + break; + case "I": + case "R": + $val = $arrFields[$fname]; + if (!is_numeric($val)) $val = (integer) $val; + break; + + default: - $val = $arrFields[$fname]; + $val = str_replace(array("'"," ","("),"",$arrFields[$fname]); // basic sql injection defence if (empty($val)) $val = '0'; break; } @@ -926,7 +1034,8 @@ if ($inputarr) { foreach($inputarr as $kk=>$vv) { if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...'; - $ss .= "($kk=>'$vv') "; + if (is_null($vv)) $ss .= "($kk=>null) "; + else $ss .= "($kk=>'$vv') "; } $ss = "[ $ss ]"; } Added: trunk/linpha2/lib/adodb/adodb-memcache.lib.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-memcache.lib.inc.php (rev 0) +++ trunk/linpha2/lib/adodb/adodb-memcache.lib.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -0,0 +1,118 @@ +<?php + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +global $ADODB_INCLUDED_MEMCACHE; +$ADODB_INCLUDED_MEMCACHE = 1; + +/* + + V4.90 8 June 2006 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. + Released under both BSD license and Lesser GPL library license. + Whenever there is any discrepancy between the two licenses, + the BSD license will take precedence. See License.txt. + Set tabs to 4 for best viewing. + + Latest version is available at http://adodb.sourceforge.net + +*/ + + function getmemcache($key,&$err, $timeout=0, $host, $port) + { + $false = false; + $err = false; + + if (!function_exists('memcache_pconnect')) { + $err = 'Memcache module PECL extension not found!'; + return $false; + } + + $memcache = new Memcache; + if (!@$memcache->pconnect($host, $port)) { + $err = 'Can\'t connect to memcache server on: '.$host.':'.$port; + return $false; + } + + $rs = $memcache->get($key); + if (!$rs) { + $err = 'Item with such key doesn\'t exists on the memcached server.'; + return $false; + } + + $tdiff = intval($rs->timeCreated+$timeout - time()); + if ($tdiff <= 2) { + switch($tdiff) { + case 2: + if ((rand() & 15) == 0) { + $err = "Timeout 2"; + return $false; + } + break; + case 1: + if ((rand() & 3) == 0) { + $err = "Timeout 1"; + return $false; + } + break; + default: + $err = "Timeout 0"; + return $false; + } + } + return $rs; + } + + function putmemcache($key, $rs, $host, $port, $compress, $debug=false) + { + $false = false; + $true = true; + + if (!function_exists('memcache_pconnect')) { + if ($debug) ADOConnection::outp(" Memcache module PECL extension not found!<br>\n"); + return $false; + } + + $memcache = new Memcache; + if (!@$memcache->pconnect($host, $port)) { + if ($debug) ADOConnection::outp(" Can't connect to memcache server on: $host:$port<br>\n"); + return $false; + } + + $rs->timeCreated = time(); + if (!$memcache->set($key, $rs, $compress, 0)) { + if ($debug) ADOConnection::outp(" Failed to save data at the memcached server!<br>\n"); + return $false; + } + return $true; + } + + function flushmemcache($key=false, $host, $port, $debug=false) + { + if (!function_exists('memcache_pconnect')) { + if ($debug) ADOConnection::outp(" Memcache module PECL extension not found!<br>\n"); + return; + } + + $memcache = new Memcache; + if (!@$memcache->pconnect($host, $port)) { + if ($debug) ADOConnection::outp(" Can't connect to memcache server on: $host:$port<br>\n"); + return; + } + + if ($key) { + if (!$memcache->delete($key)) { + if ($debug) ADOConnection::outp("CacheFlush: $key entery doesn't exist on memcached server!<br>\n"); + } else { + if ($debug) ADOConnection::outp("CacheFlush: $key entery flushed from memcached server!<br>\n"); + } + } else { + if (!$memcache->flush()) { + if ($debug) ADOConnection::outp("CacheFlush: Failure flushing all enteries from memcached server!<br>\n"); + } else { + if ($debug) ADOConnection::outp("CacheFlush: All enteries flushed from memcached server!<br>\n"); + } + } + return; + } +?> Modified: trunk/linpha2/lib/adodb/adodb-pager.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-pager.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-pager.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,7 +1,7 @@ <?php /* - V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. @@ -247,12 +247,12 @@ $savec = $ADODB_COUNTRECS; if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true; if ($this->cache) - $rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page); + $rs = $this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page); else - $rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page); + $rs = $this->db->PageExecute($this->sql,$rows,$this->curr_page); $ADODB_COUNTRECS = $savec; - $this->rs = &$rs; + $this->rs = $rs; if (!$rs) { print "<h3>Query failed: $this->sql</h3>"; return; Modified: trunk/linpha2/lib/adodb/adodb-pear.inc.php =================================================================== --- trunk/linpha2/lib/adodb/adodb-pear.inc.php 2008-02-06 23:25:59 UTC (rev 4854) +++ trunk/linpha2/lib/adodb/adodb-pear.inc.php 2008-02-07 20:22:33 UTC (rev 4855) @@ -1,6 +1,6 @@ <?php /** - * @version V4.91 2 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. + * @version V5.03 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, * the BSD license will take precedence. @@ -109,11 +109,11 @@ * error */ - function &factory($type) + function factory($type) { include_once(ADODB_DIR."/drivers/adodb-$type.inc.php"); - $obj = &NewADOConnection($type); - if (!is_object($obj)) $obj =& new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); + $obj = NewADOConnection($type); + if (!is_object($obj)) $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); return $obj; } @@ -136,7 +136,7 @@ * @see DB::parseDSN * @see DB::isError */ - function &connect($dsn, $options = false) + function connect($dsn, $options = false) { if (is_array($dsn)) { $dsninfo = $dsn; @@ -157,9 +157,9 @@ @include_once("adodb-$type.inc.php"); } - @$obj =& NewADOConnection($type); + @$obj = NewADOConnection($type); if (!is_object($obj)) { - $obj =& new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); + $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); return $obj; } if (is_array($options)) { Modified: trunk/linpha2/lib/adodb/adodb-perf.inc.php ===========================================... [truncated message content] |
From: <bz...@us...> - 2008-02-12 18:00:13
|
Revision: 4869 http://linpha.svn.sourceforge.net/linpha/?rev=4869&view=rev Author: bzrudi Date: 2008-02-12 09:59:58 -0800 (Tue, 12 Feb 2008) Log Message: ----------- some minor geoimport improvements Modified Paths: -------------- trunk/linpha2/lib/modules/module.geodata.php trunk/linpha2/lib/plugins/maps/xml_parser.class.php Modified: trunk/linpha2/lib/modules/module.geodata.php =================================================================== --- trunk/linpha2/lib/modules/module.geodata.php 2008-02-12 13:35:55 UTC (rev 4868) +++ trunk/linpha2/lib/modules/module.geodata.php 2008-02-12 17:59:58 UTC (rev 4869) @@ -19,38 +19,112 @@ */ if (!defined('LINPHA_DIR')) { exit (1); } +if(!defined('TOP_DIR')) { define('TOP_DIR','../.'); } include_once LINPHA_DIR.'/lib/plugins/maps/xml_parser.class.php'; $urlFull = LINPHA_LINK.'&linCat=geodata'; -$linpha->template->setModuleName('geodata'); -//$linpha->template->overrideModule('head','map'); -$linpha->template->URL_full = $urlFull; -$linpha->template->URL_base = $urlFull; -$linpha->template->output['title'] = i18n("Geodata"); -include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); +echo '<h1 class="linStyle">'.i18n("GPX File Import Wizzard").'</h1><hr>'; +if(!isset($_POST['cmd'])) +{ + //$query = $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."plugins_maps_image_geodata "); + echo i18n("Please Select Folder With GPX File:")."<br />"; + echo "<form action='./?linCat=geodata' method='POST'> " . + "<select name='album_select[]' size='10' style='width: 500px;'>"; + linBuildAlbumSelect($with_all_albs_entry=false,$with_linebreaks=true); -$GPXData = new LinXmlParser('/tmp/sample.gpx'); -$array_with_gpx = $GPXData->readXmlFile(); -$track_times = $GPXData->getGpxTimeRange($array_with_gpx); -$image_times = $GPXData->getImageTimeRange(6); //parent_id linpha_photos + echo "</select><br />"; -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, $image_tmp=array()); + echo "<br /><input type='hidden' name='cmd' value='step2'> " . + "<input type='submit' name='submit' " . + "value=".i18n(LIN_STR_SUBMIT)."></form>"; } -else +elseif($_POST['cmd'] == 'step2') { - echo "<br>Time Range error - images time range is larger than track time"; - echo "ABORT"; + /** + * Backup for later use + */ + if(isset($_POST['album_select']) && is_array($_POST['album_select'])) + { + $parent_id = $_POST['album_select']['0']; + } + + /** + * Get GPX filename from db + */ + $album_path = LinSql::getFullImagePath($parent_id); + + $gpx_filename = $GLOBALS['linpha']->db->GetOne("SELECT name " . + "FROM ".LIN_PREFIX."photos " . + "WHERE parent_id = '".$parent_id."' " . + "AND img_type = '9999999' " . + "AND name LIKE '%.gpx' " . + "OR name LIKE '%.GPX' "); + + if(isset($gpx_filename)) + { + if(isset($gpx_filename)) + { + $gpx_filename = LINPHA_DIR.TOP_DIR."".$album_path."/".$gpx_filename.""; + } + + $GeoWizzard = new LinXmlParser($gpx_filename); + $gpxDataFromFile = $GeoWizzard->readXmlFile(); + $track_times = $GeoWizzard->getGpxTimeRange($gpxDataFromFile); + $image_times = $GeoWizzard->getImageTimeRange($parent_id); //parent_id linpha_photos + + if($GeoWizzard->compareTimeRanges($track_times, $image_times)) + { + $trackTimeDelta = $track_times['endtime']-$track_times['starttime']; + $imageTimeDelta = $image_times['endtime']-$image_times['starttime']; + + $imagetdwidth = round((($imageTimeDelta*100)/$trackTimeDelta),0); + $offsetleft = round(((($image_times['starttime'] - $track_times['starttime'])*100))/$trackTimeDelta,0); + //echo "imagedelta".$imageTimeDelta."<br>"; + /* echo "imagwitdh".$tdwidth; + echo "leftwidth".$tdleft;*/ + + + echo i18n("Performing a couple of required tests...")."<br />"; + echo "<b>Timedelta comparison GPX Track <-> Images:</b><br>"; + echo "<table width ='99%'><tr> " . + "<td width='50%' style='border-left: 2px solid;'> " . + "<b><-GPX Track start</b><br /> ".date("Y:m:d H:i:s", $track_times['starttime'])."</td> ". + "<td align='right' style='border-right: 2px solid;'> " . + "<b>GPX Track end-></b><br /><nobr> ".date("Y:m:d H:i:s", $track_times['endtime'])."</nobr></td></tr> " . + "<tr bgcolor='green'><td colspan='2'><br /><b>GPX Time Delta: </b>" . + "".date("H:i:s", $trackTimeDelta)."h<br /> ". + "</td></tr> " . + "<tr> " . + // "<td width='$tdleft' style='border-left: 2px solid;'> " . + // "<b><-Offset</b><br /> ".date("H:i:s", $image_times['starttime'] - $track_times['starttime'])."</td> ". + "<td width='$imagetdwidth%' bgcolor='green'> " . + "<b><br/>Images Time Delta</b><nobr> ".date("H:i:s", $imageTimeDelta)."h</nobr></td><td width='*%'>".$imagetdwidth."%</td> </tr> " . + "<br /> ". + "</table><br />"; + + + $GeoWizzard->fixImagesOffset($track_times, $image_times); + } + else + { + echo "<br>Time Range error - images time range is larger than track time"; + echo "ABORT"; + } + } + else + { + echo i18n("No GPX file found, consider running album import first"); + } + } + + + //echo "<pre>", print_r($array_with_gpx), "</pre>"; ?> \ No newline at end of file Modified: trunk/linpha2/lib/plugins/maps/xml_parser.class.php =================================================================== --- trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-12 13:35:55 UTC (rev 4868) +++ trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-12 17:59:58 UTC (rev 4869) @@ -101,6 +101,60 @@ return $this->xml_data; } + + + + + public function readFloXmlFile() + { + $handle = @fopen("/tmp/sample.gpx", "r"); + if($handle) + { + $part = 0; + $read = 4092; + while(!feof($handle)) { + $rbuf = fread($handle, $read); //2MB chunks + for($i=$read;$i > 0 || $n == chr(10);$i--) { + $n=substr($rbuf, $i, 1); + if($n == chr(10))break; + //If we are at the end of the file, just grab the rest and stop loop + elseif(feof($handle)) { + $i = $read; + $buf = substr($rbuf, 0, $i+1); + break; + } + + //This is the buffer we want to do stuff with, maybe thow to a function? + $buf = substr($rbuf, 0, $i+1); + + echo "buf".$buf."<br>"; + if(substr($buf, 0, 6) == '<trkpt') + { + //echo "TRACKHIT"; + } + //Point marker back to last \n point + $part = ftell($handle)-($read-($i+1)); + fseek($handle, $part); + } + } + + + /* while (!feof($handle)) + { + $buffer = ltrim(fgets($handle, 8192)); + error_log($buffer, 0); + if(substr($buffer, 0, 6) == '<trkpt') + { + echo "TRACKHIT"; + } + + //echo "LINE:".$buffer."<br>"; + }*/ + fclose($handle); + } + //return $this->xml_data;*/ + } + /** * This is just an helper/wrapper method for readXmlFile() and is called * for each trkpoint data entry from readXmlFile(). @@ -163,12 +217,12 @@ } } - 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>"; + /* 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); } @@ -217,13 +271,13 @@ } } } - echo "**IMAGE INFO**<br>"; - echo "min ".$date_min." -- "; - echo "max ".$date_max; - echo " length ".($date_max - $date_min)."<br>"; + /* 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>"; + 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); } @@ -278,12 +332,12 @@ } /** - * All images must be taken within track time range delta t. If we found + * 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 { /** @@ -294,7 +348,7 @@ if($images['starttime'] < $track['starttime']) { echo "Offset detected, images start earlier...<br>"; - + $number = count($images['geodata']); while(list($image_time, $filename) = each($images['geodata'])) @@ -345,7 +399,7 @@ echo "Rerunning offset test...<br>"; $this->fixImagesOffset($track, $image_tmp); } - + } elseif($images['endtime'] > $track['endtime']) { @@ -419,7 +473,7 @@ private function triggerImage2trkpt($images) { /** - * @todo mv to __constructor + * @todo mv to __constructor */ $gpx = $this->readXmlFile($this->filename); @@ -427,8 +481,8 @@ ksort($gpx); /** - * Create new array with all needed information sorted - */ + * Create new array with all needed information sorted + */ foreach($gpx AS $index => $value) { @@ -438,9 +492,9 @@ "lon" => $value['trkpt']['lon'], "ele" => $value['ele']); } - + 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>"; @@ -458,9 +512,9 @@ /** * Trackpoint radar. Try to find nearest trkpt for image - * We do this by adding an offset (positiv and negativ) of one second to + * 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 @@ -475,12 +529,12 @@ echo "<br>Connecting image ".$image_time." " . "<br>to LAT: ".$trkdata[$image_time]['lat']."<br>and LON: " . "".$trkdata[$image_time]['lon']."<br><br>"; - - $this->writeGpsData2File($image_filename, - $trkdata[$image_time]['lat'], - $trkdata[$image_time]['lon'], - $trkdata[$image_time]['ele']); - + + $this->writeGpsData2File($image_filename, + $trkdata[$image_time]['lat'], + $trkdata[$image_time]['lon'], + $trkdata[$image_time]['ele']); + return false; } elseif(array_key_exists(($image_time + $offset), $trkdata)) @@ -489,12 +543,12 @@ echo "<br>Connecting image ".$image_time." " . "<br>to LAT: ".$trkdata[$image_time + $offset]['lat']."<br>and LON: " . "".$trkdata[$image_time + $offset]['lon']."<br><br>"; - - $this->writeGpsData2File($image_filename, - $trkdata[$image_time + $offset]['lat'], - $trkdata[$image_time + $offset]['lon'], - $trkdata[$image_time + $offset]['ele']); - + + $this->writeGpsData2File($image_filename, + $trkdata[$image_time + $offset]['lat'], + $trkdata[$image_time + $offset]['lon'], + $trkdata[$image_time + $offset]['ele']); + return false; } elseif(array_key_exists(($image_time - $offset), $trkdata)) @@ -503,11 +557,11 @@ echo "<br>Connecting image ".$image_time." " . "<br>to LAT: ".$trkdata[$image_time - $offset]['lat']."<br>and LON: " . "".$trkdata[$image_time - $offset]['lon']."<br><br>"; - $this->writeGpsData2File($image_filename, - $trkdata[$image_time - $offset]['lat'], - $trkdata[$image_time - $offset]['lon'], - $trkdata[$image_time - $offset]['ele']); - + $this->writeGpsData2File($image_filename, + $trkdata[$image_time - $offset]['lat'], + $trkdata[$image_time - $offset]['lon'], + $trkdata[$image_time - $offset]['ele']); + return false; } else @@ -517,7 +571,7 @@ } } - + /** * Write GPS data to file */ @@ -525,16 +579,16 @@ { echo "Trying to write GPS data to files - ***SIMULATION***<br>"; echo "Trying file: ".$filename."<br>"; - + ($lon > 0) ? $lonref = "E" : $latref = "W"; ($lat > 0) ? $latref = "N" : $latref = "S"; // 0 = Above Sea Level // 1 = Below Sea Level ($ele > 0) ? $eleref = "0" : $eleref = "1"; - + echo "Latref ".$latref." Longref ".$lonref."<br><br>"; - - + + $filename = substr($filename, 2); $filename = LINPHA_DIR."/$filename"; $return = ""; @@ -545,9 +599,9 @@ "-GPSLatitude='$lat' " . "-GPSAltitudeRef='$eleref' " . "-GPSAltitude='$ele' "; - + //exec(LINPHA_DIR.'/lib/exiftool/exiftool'." $parameters $filename"); - //LinFilesys::linExec($metaData->objMetaTool.' '.$parameters.' "'.$filename.'"', $meta, $return); + //LinFilesys::linExec($metaData->objMetaTool.' '.$parameters.' "'.$filename.'"', $meta, $return); } }// end class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2008-02-20 18:38:02
|
Revision: 4882 http://linpha.svn.sourceforge.net/linpha/?rev=4882&view=rev Author: fangehrn Date: 2008-02-20 10:37:54 -0800 (Wed, 20 Feb 2008) Log Message: ----------- Added Paths: ----------- trunk/linpha2/lib/classes/func.watermark.php Removed Paths: ------------- trunk/linpha2/lib/plugins/watermark/func.watermark.php Copied: trunk/linpha2/lib/classes/func.watermark.php (from rev 4881, trunk/linpha2/lib/plugins/watermark/func.watermark.php) =================================================================== --- trunk/linpha2/lib/classes/func.watermark.php (rev 0) +++ trunk/linpha2/lib/classes/func.watermark.php 2008-02-20 18:37:54 UTC (rev 4882) @@ -0,0 +1,547 @@ +<?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('LINPHA_DIR')) { exit(1); } + +class LinWatermark +{ + +/** +* @author flo +* @todo adapt from linpha1 +*/ +static function needWatermark($imgid) +{ + if( $GLOBALS['linpha']->sql->config->value['plugins_active_wm'] + && $GLOBALS['linpha']->sql->config->value['plugins_wm_active'] + && !check_permissions('watermark',$imgid) ) + { + return true; + } else { + return false; + } +} + +/** + * returns array with all the configs and the default values, they are only defined here + */ +static function getWatermarkArray() +{ + return array ( + 'wm_active' => "0", + 'wm_watermark' => "0", + 'wm_text' => "Copyright 2007", + 'wm_font' => "", + 'wm_fontsize' => "20", + 'wm_fontcolor' => "white", + 'wm_align' => "southwest", + 'wm_horizontal' => "0", + 'wm_vertical' => "0", + 'wm_enable_shadow' => "1", + 'wm_shadow_size' => "1", + 'wm_shadow_fontsize' => "20", + 'wm_shadow_color' => "black", + 'wm_enable_rectangle' => "1", + 'wm_rectangle_color' => "darkgrey", + 'wm_height' => "30", + 'wm_width' => "145", + 'wm_img_img' => "", + 'wm_dissolve' => "75%", + 'wm_resize' => "30" + ); +} + +static function readWatermark() +{ + $arr_config = LinWatermark::getWatermarkArray(); + while(list($name,$value) = each($arr_config) ) + { + $arr_read[$name] = $GLOBALS['linpha']->sql->config->value['plugins_'.$name]; + } + return $arr_read; +} + +static function updateWatermark() +{ + $arr_config = LinWatermark::getWatermarkArray(); + while(list($name,$value) = each($arr_config) ) + { + $GLOBALS['linpha']->sql->config->updateConfig($name,$_POST[$name]); + } +} + +/** + * restore watermark settings to initial settings or to examples + */ +static function restoreWatermark() +{ + global $wm_restore_to; + + $arr_config = LinWatermark::getWatermarkArray(); + switch($_POST['setdefault']) + { + case 'initial': + break; + case 'settings1': + $arr_config['wm_watermark'] = 1; + $arr_config['wm_text'] = "(C) 2004 linpha.sf.net"; + $arr_config['wm_fontsize'] = "10"; + $arr_config['wm_fontcolor'] = "white"; + $arr_config['wm_align'] = "south"; + $arr_config['wm_horizontal'] = "0"; + $arr_config['wm_vertical'] = "0"; + $arr_config['wm_enable_rectangle'] = "1"; + $arr_config['wm_rectangle_color'] = "darkgrey"; + $arr_config['wm_enable_shadow'] = "2"; + $arr_config['wm_height'] = "20"; + $arr_config['wm_width'] = "2000"; + $arr_config['wm_resize'] = "no"; + break; + case 'settings2': + $arr_config['wm_watermark'] = 2; + $arr_config['wm_dissolve'] = "65%"; + $arr_config['wm_align'] = "southwest"; + $arr_config['wm_img_img'] = "linpha.png"; + $arr_config['wm_horizontal'] = "10"; + $arr_config['wm_vertical'] = "10"; + $arr_config['wm_resize'] = "30"; + + break; + case 'settings3': // maybe better for gd lib than for convert + $arr_config['wm_watermark'] = 1; + $arr_config['wm_dissolve'] = "100%"; + $arr_config['wm_align'] = "southwest"; + $arr_config['wm_text'] = "(C) 2004 linpha.sf.net"; + $arr_config['wm_fontsize'] = "20"; + $arr_config['wm_fontcolor'] = "white"; + $arr_config['wm_horizontal'] = "0"; + $arr_config['wm_vertical'] = "0"; + $arr_config['wm_enable_rectangle'] = "1"; + $arr_config['wm_rectangle_color'] = "darkgrey"; + $arr_config['wm_enable_shadow'] = "1"; + $arr_config['wm_shadow_size'] = "5"; + $arr_config['wm_shadow_fontsize'] = "2"; + $arr_config['wm_height'] = "30"; + $arr_config['wm_width'] = "260"; + $arr_config['wm_resize'] = "no"; + break; + } + while(list($name,$value) = each($arr_config) ) + { + $GLOBALS['linpha']->sql->config->updateConfig($name,$value); + } +} + +/** + * calcs the new height and width of the resized watermark + * $w, $h: size of the big image + * $org_width, $org_height: size of the watermark rectangle/image + * $resize: resize factor in percent + * + */ +static function wmArrResized($w,$h,$org_width,$org_height,$resize) +{ + $arr_resized['w'] = round($w * $resize/100); + $arr_resized['h'] = round($h * $resize/100); + + $no_increase = 0; + $array = LinImage::scaleToFit($org_height,$org_width,$arr_resized['h'],$arr_resized['w'],$no_increase); + + //error_log('w: '.$w.' h: '.$h.' arr_resized_w: '.$arr_resized['w'].' arr_resized_h: '.$arr_resized['h']. + // ' org_w: '.$org_width.' org_h: '.$org_height.' scaleToFit w: '.$array['w'].' h: '.$array['h']); + + return $array; +} + +/** + * list with many available colors + * http://mail.gnu.org/archive/html/emacs-diffs/2002-06/msg00158.html + * @uses getRgbFromAll() + */ +static $Colors = array( + 'aliceblue'=>'#f0f8ff', + 'antiquewhite'=>'#faebd7', + 'aquamarine'=>'#7fffd4', + 'azure'=>'#f0ffff', + 'beige'=>'#f5f5dc', + 'bisque'=>'#ffe4c4', + 'black'=>'#000000', + 'blanchedalmond'=>'#ffebcd', + 'blue'=>'#0000ff', + 'blueviolet'=>'#8a2be2', + 'brown'=>'#a52a2a', + 'burlywood'=>'#deb887', + 'cadetblue'=>'#5f9ea0', + 'chartreuse'=>'#7fff00', + 'chocolate'=>'#d2691e', + 'coral'=>'#ff7f50', + 'cornflowerblue'=>'#6495ed', + 'cornsilk'=>'#fff8dc', + 'cyan'=>'#00ffff', + 'darkblue'=>'#00008b', + 'darkcyan'=>'#008b8b', + 'darkgoldenrod'=>'#b886011', + 'darkgray'=>'#a9a9a9', + 'darkgreen'=>'#006400', + 'darkgrey'=>'#a9a9a9', + 'darkkhaki'=>'#bdb76b', + 'darkmagenta'=>'#8b008b', + 'darkolivegreen'=>'#556b2f', + 'darkorange'=>'#ff8c00', + 'darkorchid'=>'#9932cc', + 'darkred'=>'#8b0000', + 'darksalmon'=>'#e9967a', + 'darkseagreen'=>'#8fbc8f', + 'darkslateblue'=>'#483d8b', + 'darkslategray'=>'#2f4f4f', + 'darkslategrey'=>'#2f4f4f', + 'darkturquoise'=>'#00ced1', + 'darkviolet'=>'#9400d3', + 'deeppink'=>'#ff1493', + 'deepskyblue'=>'#00bfff', + 'dimgray'=>'#696969', + 'dimgrey'=>'#696969', + 'dodgerblue'=>'#1e90ff', + 'firebrick'=>'#b22222', + 'floralwhite'=>'#fffaf0', + 'forestgreen'=>'#228b22', + 'gainsboro'=>'#dcdcdc', + 'ghostwhite'=>'#f8f8ff', + 'gold'=>'#ffd700', + 'goldenrod'=>'#daa520', + 'gray'=>'#bebebe', + 'green'=>'#00ff00', + 'greenyellow'=>'#adff2f', + 'honeydew'=>'#f0fff0', + 'hotpink'=>'#ff69b4', + 'indianred'=>'#cd5c5c', + 'ivory'=>'#fffff0', + 'khaki'=>'#f0e68c', + 'lavender'=>'#e6e6fa', + 'lavenderblush'=>'#fff0f5', + 'lawngreen'=>'#7cfc00', + 'lemonchiffon'=>'#fffacd', + 'lightblue'=>'#add8e6', + 'lightcoral'=>'#f08080', + 'lightcyan'=>'#e0ffff', + 'lightgoldenrod'=>'#eedd82', + 'lightgoldenrodyellow'=>'#fafad2', + 'lightgray'=>'#d3d3d3', + 'lightgreen'=>'#90ee90', + 'lightgrey'=>'#d3d3d3', + 'lightpink'=>'#ffb6c1', + 'lightred'=>'#ffc8c8', + 'lightsalmon'=>'#ffa07a', + 'lightseagreen'=>'#20b2aa', + 'lightskyblue'=>'#87cefa', + 'lightslateblue'=>'#8470ff', + 'lightslategray'=>'#778899', + 'lightsteelblue'=>'#b0c4de', + 'lightyellow'=>'#ffffe0', + 'limegreen'=>'#32cd32', + 'linen'=>'#faf0e6', + 'magenta'=>'#ff00ff', + 'maroon'=>'#b03060', + 'mediumaquamarine'=>'#66cdaa', + 'mediumblue'=>'#0000cd', + 'mediumorchid'=>'#ba55d3', + 'mediumpurple'=>'#9370db', + 'mediumseagreen'=>'#3cb371', + 'mediumslateblue'=>'#7b68ee', + 'mediumspringgreen'=>'#00fa9a', + 'mediumturquoise'=>'#48d1cc', + 'mediumvioletred'=>'#c71585', + 'midnightblue'=>'#191970', + 'mintcream'=>'#f5fffa', + 'mistyrose'=>'#ffe4e1', + 'moccasin'=>'#ffe4b5', + 'navajowhite'=>'#ffdead', + 'navy'=>'#000080', + 'navyblue'=>'#000080', + 'oldlace'=>'#fdf5e6', + 'olivedrab'=>'#6b8e23', + 'orange'=>'#ffa500', + 'orangered'=>'#ff4500', + 'orchid'=>'#da70d6', + 'palegoldenrod'=>'#eee8aa', + 'palegreen'=>'#98fb98', + 'paleturquoise'=>'#afeeee', + 'palevioletred'=>'#db7093', + 'papayawhip'=>'#ffefd5', + 'peachpuff'=>'#ffdab9', + 'peru'=>'#cd853f', + 'pink'=>'#ffc0cb', + 'plum'=>'#dda0dd', + 'powderblue'=>'#b0e0e6', + 'purple'=>'#a020f0', + 'red'=>'#ff0000', + 'rosybrown'=>'#bc8f8f', + 'royalblue'=>'#4169e1', + 'saddlebrown'=>'#8b4513', + 'salmon'=>'#fa8072', + 'sandybrown'=>'#f4a460', + 'seagreen'=>'#2e8b57', + 'seashell'=>'#fff5ee', + 'sienna'=>'#a0522d', + 'skyblue'=>'#87ceeb', + 'slateblue'=>'#6a5acd', + 'slategray'=>'#708090', + 'slategrey'=>'#708090', + 'snow'=>'#fffafa', + 'springgreen'=>'#00ff7f', + 'steelblue'=>'#4682b4', + 'tan'=>'#d2b48c', + 'thistle'=>'#d8bfd8', + 'tomato'=>'#ff6347', + 'turquoise'=>'#40e0d0', + 'violet'=>'#ee82ee', + 'violetred'=>'#d02090', + 'wheat'=>'#f5deb3', + 'white'=>'#ffffff', + 'yellow'=>'#ffff00', + 'yellowgreen'=>'#9acd32' +); + +/** + * not used anymore + */ +static function getHtmlColorFromRgb($r,$g,$b) +{ + if(strlen(dechex($r))==1) { + $r = '0'.$r; + } else { + $r = dechex($r); + } + if(strlen(dechex($g))==1) { + $g = '0'.$g; + } else { + $g = dechex($g); + } + if(strlen(dechex($b))==1) { + $b = '0'.$b; + } else { + $b = dechex($b); + } + + return '#'.$r.$g.$b; +} + +/** + * used to check if it is a valid html color + * @uses isHtmlColor() + */ +static function everyCharIsHex($string) +{ + for($i=0;$i<strlen($string);$i++) + { + $char = substr($string,$i,1); + $valid_color = false; + + if($char == "0") { // zero makes problems... '== 0' and '== "0"' is not the same... + $valid_color = true; + } + for($n=1;$n<=9;$n++) + { + if($char == $n) { + $valid_color = true; + } + } + + for($n='a';$n<='f';$n++) + { + if($char === $n) { + $valid_color = true; + } + } + + for($n='A';$n<='F';$n++) + { + if($char === $n) { + $valid_color = true; + } + } + if(!$valid_color) { + return 0; + } + } + return 1; +} + +/** + * used to check if it is a valid html color + * @uses getRgbFromAll() + */ +static function isHtmlColor($string) +{ + switch(strlen($string)) + { + case 6: + if(LinWatermark::everyCharIsHex($string)) { + return 1; + } + break; + case 7: + if(substr($string,0,1)=="#") { + if(LinWatermark::everyCharIsHex(substr($string,1,6))) { + return 1; + } + } + break; + } + return 0; +} + +/** + * converts a html color to an array with the rgb values + * it doesn't matter if the html color is '#00FF00' or '00FF00' + * @uses getRgbFromAll() + */ +static function getRgbFromHtml($string) +{ + switch(strlen($string)) + { + case 6: + break; + case 7: + $string = substr($string,1,6); + break; + } + $r_hex = substr($string,0,2); + $g_hex = substr($string,2,2); + $b_hex = substr($string,4,2); + $arr['r'] = hexdec($r_hex); + $arr['g'] = hexdec($g_hex); + $arr['b'] = hexdec($b_hex); + return $arr; +} + +/** + * returns an array with the rgb values + * it doesn't matter if the argument is 'darkblue', '#00FF55' or '00FF55' + * if it isn't a correct color, the color (0,0,0) is returned + * + * @uses watermark_gd() + */ +static function getRgbFromAll($string) +{ + if( isset( LinWatermark::$Colors[$string]) ) + { + return LinWatermark::getRgbFromHtml( LinWatermark::$Colors[$string] ); + } + elseif(LinWatermark::isHtmlColor($string) ) + { + return LinWatermark::getRgbFromHtml( $string ); + } + else + { + array('r'=>0,'g'=>0,'b'=>0); + } +} + +/** + * return html color without '#' + * + * used in linpha2 - admin - settings_layout + */ +static function getHtmlFromAll($string) +{ + if(LinWatermark::isHtmlColor($string)) + { + if(substr($string,0,1)=="#") + { + return substr($string,1,6); + } + else + { + return $string; + } + } + else + { + if( isset( LinWatermark::$Colors[$string]) ) + { + return substr(LinWatermark::$Colors[$string],1,6); + } + else + { + return 'ffffff'; + } + } +} + +/** + * @uses watermark_gd() + * calcs the position in pixel with a given align + * src_w, src_h: width and height from the textfield (or the small watermark image) + * dst_w, dst_h: width and height from the image + * pos_x, pos_y: additional adjust for the image + * + */ +static function calcAlign($align, $src_w, $src_h, $dst_w, $dst_h, $pos_x, $pos_y) +{ + + switch($align) + { + case "center": + $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); + $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); + break; + case "east": + $arr_pos['x'] = $dst_w-$src_w+($pos_x); + $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); + break; + case "west": + $arr_pos['x'] = $pos_x; + $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); + break; + case "north": + $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); + $arr_pos['y'] = $pos_y; + break; + case "south": + $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); + $arr_pos['y'] = $dst_h-$src_h+($pos_y); + break; + case "northeast": + $arr_pos['x'] = $dst_w-$src_w+($pos_x); + $arr_pos['y'] = $pos_y; + break; + case "northwest": + $arr_pos['x'] = $pos_x; + $arr_pos['y'] = $pos_y; + break; + case "southwest": + $arr_pos['x'] = $pos_x; + $arr_pos['y'] = $dst_h-$src_h+($pos_y); + break; + case "southeast": + $arr_pos['x'] = $dst_w-$src_w+($pos_x); + $arr_pos['y'] = $dst_h-$src_h+($pos_y); + break; + default: + $arr_pos['x'] = $pos_x; + $arr_pos['y'] = $pos_y; + break; + + } + return $arr_pos; +} + +} +?> \ No newline at end of file Deleted: trunk/linpha2/lib/plugins/watermark/func.watermark.php =================================================================== --- trunk/linpha2/lib/plugins/watermark/func.watermark.php 2008-02-17 22:58:01 UTC (rev 4881) +++ trunk/linpha2/lib/plugins/watermark/func.watermark.php 2008-02-20 18:37:54 UTC (rev 4882) @@ -1,547 +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('LINPHA_DIR')) { exit(1); } - -class LinWatermark -{ - -/** -* @author flo -* @todo adapt from linpha1 -*/ -static function needWatermark($imgid) -{ - if( $GLOBALS['linpha']->sql->config->value['plugins_active_wm'] - && $GLOBALS['linpha']->sql->config->value['plugins_wm_active'] - && !check_permissions('watermark',$imgid) ) - { - return true; - } else { - return false; - } -} - -/** - * returns array with all the configs and the default values, they are only defined here - */ -static function getWatermarkArray() -{ - return array ( - 'wm_active' => "0", - 'wm_watermark' => "0", - 'wm_text' => "Copyright 2007", - 'wm_font' => "", - 'wm_fontsize' => "20", - 'wm_fontcolor' => "white", - 'wm_align' => "southwest", - 'wm_horizontal' => "0", - 'wm_vertical' => "0", - 'wm_enable_shadow' => "1", - 'wm_shadow_size' => "1", - 'wm_shadow_fontsize' => "20", - 'wm_shadow_color' => "black", - 'wm_enable_rectangle' => "1", - 'wm_rectangle_color' => "darkgrey", - 'wm_height' => "30", - 'wm_width' => "145", - 'wm_img_img' => "", - 'wm_dissolve' => "75%", - 'wm_resize' => "30" - ); -} - -static function readWatermark() -{ - $arr_config = LinWatermark::getWatermarkArray(); - while(list($name,$value) = each($arr_config) ) - { - $arr_read[$name] = $GLOBALS['linpha']->sql->config->value['plugins_'.$name]; - } - return $arr_read; -} - -static function updateWatermark() -{ - $arr_config = LinWatermark::getWatermarkArray(); - while(list($name,$value) = each($arr_config) ) - { - $GLOBALS['linpha']->sql->config->updateConfig($name,$_POST[$name]); - } -} - -/** - * restore watermark settings to initial settings or to examples - */ -static function restoreWatermark() -{ - global $wm_restore_to; - - $arr_config = LinWatermark::getWatermarkArray(); - switch($_POST['setdefault']) - { - case 'initial': - break; - case 'settings1': - $arr_config['wm_watermark'] = 1; - $arr_config['wm_text'] = "(C) 2004 linpha.sf.net"; - $arr_config['wm_fontsize'] = "10"; - $arr_config['wm_fontcolor'] = "white"; - $arr_config['wm_align'] = "south"; - $arr_config['wm_horizontal'] = "0"; - $arr_config['wm_vertical'] = "0"; - $arr_config['wm_enable_rectangle'] = "1"; - $arr_config['wm_rectangle_color'] = "darkgrey"; - $arr_config['wm_enable_shadow'] = "2"; - $arr_config['wm_height'] = "20"; - $arr_config['wm_width'] = "2000"; - $arr_config['wm_resize'] = "no"; - break; - case 'settings2': - $arr_config['wm_watermark'] = 2; - $arr_config['wm_dissolve'] = "65%"; - $arr_config['wm_align'] = "southwest"; - $arr_config['wm_img_img'] = "linpha.png"; - $arr_config['wm_horizontal'] = "10"; - $arr_config['wm_vertical'] = "10"; - $arr_config['wm_resize'] = "30"; - - break; - case 'settings3': // maybe better for gd lib than for convert - $arr_config['wm_watermark'] = 1; - $arr_config['wm_dissolve'] = "100%"; - $arr_config['wm_align'] = "southwest"; - $arr_config['wm_text'] = "(C) 2004 linpha.sf.net"; - $arr_config['wm_fontsize'] = "20"; - $arr_config['wm_fontcolor'] = "white"; - $arr_config['wm_horizontal'] = "0"; - $arr_config['wm_vertical'] = "0"; - $arr_config['wm_enable_rectangle'] = "1"; - $arr_config['wm_rectangle_color'] = "darkgrey"; - $arr_config['wm_enable_shadow'] = "1"; - $arr_config['wm_shadow_size'] = "5"; - $arr_config['wm_shadow_fontsize'] = "2"; - $arr_config['wm_height'] = "30"; - $arr_config['wm_width'] = "260"; - $arr_config['wm_resize'] = "no"; - break; - } - while(list($name,$value) = each($arr_config) ) - { - $GLOBALS['linpha']->sql->config->updateConfig($name,$value); - } -} - -/** - * calcs the new height and width of the resized watermark - * $w, $h: size of the big image - * $org_width, $org_height: size of the watermark rectangle/image - * $resize: resize factor in percent - * - */ -static function wmArrResized($w,$h,$org_width,$org_height,$resize) -{ - $arr_resized['w'] = round($w * $resize/100); - $arr_resized['h'] = round($h * $resize/100); - - $no_increase = 0; - $array = LinImage::scaleToFit($org_height,$org_width,$arr_resized['h'],$arr_resized['w'],$no_increase); - - //error_log('w: '.$w.' h: '.$h.' arr_resized_w: '.$arr_resized['w'].' arr_resized_h: '.$arr_resized['h']. - // ' org_w: '.$org_width.' org_h: '.$org_height.' scaleToFit w: '.$array['w'].' h: '.$array['h']); - - return $array; -} - -/** - * list with many available colors - * http://mail.gnu.org/archive/html/emacs-diffs/2002-06/msg00158.html - * @uses getRgbFromAll() - */ -static $Colors = array( - 'aliceblue'=>'#f0f8ff', - 'antiquewhite'=>'#faebd7', - 'aquamarine'=>'#7fffd4', - 'azure'=>'#f0ffff', - 'beige'=>'#f5f5dc', - 'bisque'=>'#ffe4c4', - 'black'=>'#000000', - 'blanchedalmond'=>'#ffebcd', - 'blue'=>'#0000ff', - 'blueviolet'=>'#8a2be2', - 'brown'=>'#a52a2a', - 'burlywood'=>'#deb887', - 'cadetblue'=>'#5f9ea0', - 'chartreuse'=>'#7fff00', - 'chocolate'=>'#d2691e', - 'coral'=>'#ff7f50', - 'cornflowerblue'=>'#6495ed', - 'cornsilk'=>'#fff8dc', - 'cyan'=>'#00ffff', - 'darkblue'=>'#00008b', - 'darkcyan'=>'#008b8b', - 'darkgoldenrod'=>'#b886011', - 'darkgray'=>'#a9a9a9', - 'darkgreen'=>'#006400', - 'darkgrey'=>'#a9a9a9', - 'darkkhaki'=>'#bdb76b', - 'darkmagenta'=>'#8b008b', - 'darkolivegreen'=>'#556b2f', - 'darkorange'=>'#ff8c00', - 'darkorchid'=>'#9932cc', - 'darkred'=>'#8b0000', - 'darksalmon'=>'#e9967a', - 'darkseagreen'=>'#8fbc8f', - 'darkslateblue'=>'#483d8b', - 'darkslategray'=>'#2f4f4f', - 'darkslategrey'=>'#2f4f4f', - 'darkturquoise'=>'#00ced1', - 'darkviolet'=>'#9400d3', - 'deeppink'=>'#ff1493', - 'deepskyblue'=>'#00bfff', - 'dimgray'=>'#696969', - 'dimgrey'=>'#696969', - 'dodgerblue'=>'#1e90ff', - 'firebrick'=>'#b22222', - 'floralwhite'=>'#fffaf0', - 'forestgreen'=>'#228b22', - 'gainsboro'=>'#dcdcdc', - 'ghostwhite'=>'#f8f8ff', - 'gold'=>'#ffd700', - 'goldenrod'=>'#daa520', - 'gray'=>'#bebebe', - 'green'=>'#00ff00', - 'greenyellow'=>'#adff2f', - 'honeydew'=>'#f0fff0', - 'hotpink'=>'#ff69b4', - 'indianred'=>'#cd5c5c', - 'ivory'=>'#fffff0', - 'khaki'=>'#f0e68c', - 'lavender'=>'#e6e6fa', - 'lavenderblush'=>'#fff0f5', - 'lawngreen'=>'#7cfc00', - 'lemonchiffon'=>'#fffacd', - 'lightblue'=>'#add8e6', - 'lightcoral'=>'#f08080', - 'lightcyan'=>'#e0ffff', - 'lightgoldenrod'=>'#eedd82', - 'lightgoldenrodyellow'=>'#fafad2', - 'lightgray'=>'#d3d3d3', - 'lightgreen'=>'#90ee90', - 'lightgrey'=>'#d3d3d3', - 'lightpink'=>'#ffb6c1', - 'lightred'=>'#ffc8c8', - 'lightsalmon'=>'#ffa07a', - 'lightseagreen'=>'#20b2aa', - 'lightskyblue'=>'#87cefa', - 'lightslateblue'=>'#8470ff', - 'lightslategray'=>'#778899', - 'lightsteelblue'=>'#b0c4de', - 'lightyellow'=>'#ffffe0', - 'limegreen'=>'#32cd32', - 'linen'=>'#faf0e6', - 'magenta'=>'#ff00ff', - 'maroon'=>'#b03060', - 'mediumaquamarine'=>'#66cdaa', - 'mediumblue'=>'#0000cd', - 'mediumorchid'=>'#ba55d3', - 'mediumpurple'=>'#9370db', - 'mediumseagreen'=>'#3cb371', - 'mediumslateblue'=>'#7b68ee', - 'mediumspringgreen'=>'#00fa9a', - 'mediumturquoise'=>'#48d1cc', - 'mediumvioletred'=>'#c71585', - 'midnightblue'=>'#191970', - 'mintcream'=>'#f5fffa', - 'mistyrose'=>'#ffe4e1', - 'moccasin'=>'#ffe4b5', - 'navajowhite'=>'#ffdead', - 'navy'=>'#000080', - 'navyblue'=>'#000080', - 'oldlace'=>'#fdf5e6', - 'olivedrab'=>'#6b8e23', - 'orange'=>'#ffa500', - 'orangered'=>'#ff4500', - 'orchid'=>'#da70d6', - 'palegoldenrod'=>'#eee8aa', - 'palegreen'=>'#98fb98', - 'paleturquoise'=>'#afeeee', - 'palevioletred'=>'#db7093', - 'papayawhip'=>'#ffefd5', - 'peachpuff'=>'#ffdab9', - 'peru'=>'#cd853f', - 'pink'=>'#ffc0cb', - 'plum'=>'#dda0dd', - 'powderblue'=>'#b0e0e6', - 'purple'=>'#a020f0', - 'red'=>'#ff0000', - 'rosybrown'=>'#bc8f8f', - 'royalblue'=>'#4169e1', - 'saddlebrown'=>'#8b4513', - 'salmon'=>'#fa8072', - 'sandybrown'=>'#f4a460', - 'seagreen'=>'#2e8b57', - 'seashell'=>'#fff5ee', - 'sienna'=>'#a0522d', - 'skyblue'=>'#87ceeb', - 'slateblue'=>'#6a5acd', - 'slategray'=>'#708090', - 'slategrey'=>'#708090', - 'snow'=>'#fffafa', - 'springgreen'=>'#00ff7f', - 'steelblue'=>'#4682b4', - 'tan'=>'#d2b48c', - 'thistle'=>'#d8bfd8', - 'tomato'=>'#ff6347', - 'turquoise'=>'#40e0d0', - 'violet'=>'#ee82ee', - 'violetred'=>'#d02090', - 'wheat'=>'#f5deb3', - 'white'=>'#ffffff', - 'yellow'=>'#ffff00', - 'yellowgreen'=>'#9acd32' -); - -/** - * not used anymore - */ -static function getHtmlColorFromRgb($r,$g,$b) -{ - if(strlen(dechex($r))==1) { - $r = '0'.$r; - } else { - $r = dechex($r); - } - if(strlen(dechex($g))==1) { - $g = '0'.$g; - } else { - $g = dechex($g); - } - if(strlen(dechex($b))==1) { - $b = '0'.$b; - } else { - $b = dechex($b); - } - - return '#'.$r.$g.$b; -} - -/** - * used to check if it is a valid html color - * @uses isHtmlColor() - */ -static function everyCharIsHex($string) -{ - for($i=0;$i<strlen($string);$i++) - { - $char = substr($string,$i,1); - $valid_color = false; - - if($char == "0") { // zero makes problems... '== 0' and '== "0"' is not the same... - $valid_color = true; - } - for($n=1;$n<=9;$n++) - { - if($char == $n) { - $valid_color = true; - } - } - - for($n='a';$n<='f';$n++) - { - if($char === $n) { - $valid_color = true; - } - } - - for($n='A';$n<='F';$n++) - { - if($char === $n) { - $valid_color = true; - } - } - if(!$valid_color) { - return 0; - } - } - return 1; -} - -/** - * used to check if it is a valid html color - * @uses getRgbFromAll() - */ -static function isHtmlColor($string) -{ - switch(strlen($string)) - { - case 6: - if(LinWatermark::everyCharIsHex($string)) { - return 1; - } - break; - case 7: - if(substr($string,0,1)=="#") { - if(LinWatermark::everyCharIsHex(substr($string,1,6))) { - return 1; - } - } - break; - } - return 0; -} - -/** - * converts a html color to an array with the rgb values - * it doesn't matter if the html color is '#00FF00' or '00FF00' - * @uses getRgbFromAll() - */ -static function getRgbFromHtml($string) -{ - switch(strlen($string)) - { - case 6: - break; - case 7: - $string = substr($string,1,6); - break; - } - $r_hex = substr($string,0,2); - $g_hex = substr($string,2,2); - $b_hex = substr($string,4,2); - $arr['r'] = hexdec($r_hex); - $arr['g'] = hexdec($g_hex); - $arr['b'] = hexdec($b_hex); - return $arr; -} - -/** - * returns an array with the rgb values - * it doesn't matter if the argument is 'darkblue', '#00FF55' or '00FF55' - * if it isn't a correct color, the color (0,0,0) is returned - * - * @uses watermark_gd() - */ -static function getRgbFromAll($string) -{ - if( isset( LinWatermark::$Colors[$string]) ) - { - return LinWatermark::getRgbFromHtml( LinWatermark::$Colors[$string] ); - } - elseif(LinWatermark::isHtmlColor($string) ) - { - return LinWatermark::getRgbFromHtml( $string ); - } - else - { - array('r'=>0,'g'=>0,'b'=>0); - } -} - -/** - * return html color without '#' - * - * used in linpha2 - admin - settings_layout - */ -static function getHtmlFromAll($string) -{ - if(LinWatermark::isHtmlColor($string)) - { - if(substr($string,0,1)=="#") - { - return substr($string,1,6); - } - else - { - return $string; - } - } - else - { - if( isset( LinWatermark::$Colors[$string]) ) - { - return substr(LinWatermark::$Colors[$string],1,6); - } - else - { - return 'ffffff'; - } - } -} - -/** - * @uses watermark_gd() - * calcs the position in pixel with a given align - * src_w, src_h: width and height from the textfield (or the small watermark image) - * dst_w, dst_h: width and height from the image - * pos_x, pos_y: additional adjust for the image - * - */ -static function calcAlign($align, $src_w, $src_h, $dst_w, $dst_h, $pos_x, $pos_y) -{ - - switch($align) - { - case "center": - $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); - $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); - break; - case "east": - $arr_pos['x'] = $dst_w-$src_w+($pos_x); - $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); - break; - case "west": - $arr_pos['x'] = $pos_x; - $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); - break; - case "north": - $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); - $arr_pos['y'] = $pos_y; - break; - case "south": - $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); - $arr_pos['y'] = $dst_h-$src_h+($pos_y); - break; - case "northeast": - $arr_pos['x'] = $dst_w-$src_w+($pos_x); - $arr_pos['y'] = $pos_y; - break; - case "northwest": - $arr_pos['x'] = $pos_x; - $arr_pos['y'] = $pos_y; - break; - case "southwest": - $arr_pos['x'] = $pos_x; - $arr_pos['y'] = $dst_h-$src_h+($pos_y); - break; - case "southeast": - $arr_pos['x'] = $dst_w-$src_w+($pos_x); - $arr_pos['y'] = $dst_h-$src_h+($pos_y); - break; - default: - $arr_pos['x'] = $pos_x; - $arr_pos['y'] = $pos_y; - break; - - } - return $arr_pos; -} - -} -?> \ 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-04-26 19:27:18
|
Revision: 4924 http://linpha.svn.sourceforge.net/linpha/?rev=4924&view=rev Author: fangehrn Date: 2008-04-26 12:27:15 -0700 (Sat, 26 Apr 2008) Log Message: ----------- 2008-04-26 flo * Search bug fixes * Menu bug fixes * Maps plugin bug fixes - set the thumbnail width to 250 (same width as the marker background) Modified Paths: -------------- trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/classes/linpha.view.album.class.php trunk/linpha2/lib/classes/linpha.view.image.class.php trunk/linpha2/lib/include/metadata_info_show.php trunk/linpha2/lib/js/LinYUIGlobal.js trunk/linpha2/lib/js/LinYUIPage.js trunk/linpha2/lib/modules/module.search.php trunk/linpha2/lib/plugins/maps/LinMaps.js trunk/linpha2/lib/plugins/maps/LinMapsYUI.js trunk/linpha2/lib/plugins/maps/class.googlemaps.YUI.js trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/lib/plugins/maps/sql/sql.data.php Added Paths: ----------- trunk/linpha2/lib/js/LinGlobal_old.js trunk/linpha2/lib/js/LinImage_old.js trunk/linpha2/lib/js/LinThumbnails_old.js Removed Paths: ------------- trunk/linpha2/lib/js/LinGlobal.js trunk/linpha2/lib/js/LinImage.js trunk/linpha2/lib/js/LinThumbnails.js Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2008-04-26 11:10:52 UTC (rev 4923) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2008-04-26 19:27:15 UTC (rev 4924) @@ -294,9 +294,9 @@ /** * check login and fill session */ - if( isset($_POST['cmd']) ) + if( isset($_POST['linCmd']) ) { - if($_POST['cmd']=='logout' && isset($_SESSION['user_name'])) // check for $_SESSION['user_name'] if the user reloads the page after logout + if($_POST['linCmd']=='logout' && isset($_SESSION['user_name'])) // check for $_SESSION['user_name'] if the user reloads the page after logout { linLog(LOG_TYPE_USER,LOG_NOTICE,'logout','User '.$_SESSION['user_name'].': logged out'); @@ -311,16 +311,16 @@ unset($_SESSION['user_groups']); unset($_SESSION['user_display_name']); - if(isset($_COOKIE['linpha_userid'])) { + if (isset($_COOKIE['linpha_userid'])) { setcookie('linpha_userid'); // delete cookie linpha_userid setcookie('linpha_password'); // delete cookie linpha_password } $sysLogMsg[] = i18n("Logged out."); } - elseif($_POST['cmd']=='login') + elseif ($_POST['linCmd']=='login') { - if( !isset($_POST['username']) OR !isset($_POST['password']) OR empty($_POST['username']) OR empty($_POST['password'])) + if ( !isset($_POST['linUsername']) || !isset($_POST['linPassword']) || empty($_POST['linUsername']) || empty($_POST['linPassword'])) { $sysLogMsg[] = i18n("Please Fill In All Fields!"); } @@ -330,38 +330,38 @@ * get user from DB */ $data = $GLOBALS['linpha']->db->GetRow("SELECT id, username, password, display_name FROM ".LIN_PREFIX."users ". - "WHERE username='".LinSql::linAddslashes($_POST['username'])."'"); + "WHERE username='".LinSql::linAddslashes($_POST['linUsername'])."'"); if ( isset($data['username']) && isset($data['password']) - && $_POST['username'] == $data['username'] - && $this->compareHash($data['id'], $_POST['password'], $data['password']) ) + && $_POST['linUsername'] == $data['username'] + && $this->compareHash($data['id'], $_POST['linPassword'], $data['password']) ) { /** * sucessfull login */ - linLog(LOG_TYPE_USER,LOG_NOTICE,'login','User '.$_POST['username'].': successfully logged in.'); + linLog(LOG_TYPE_USER,LOG_NOTICE,'login','User '.$_POST['linUsername'].': successfully logged in.'); $sysLogMsg[] = i18n("Successfully Logged In!"); - $this->setUserInformation($_POST['username'],$data['id'],$data['display_name']); + $this->setUserInformation($_POST['linUsername'],$data['id'],$data['display_name']); if ($GLOBALS['linpha']->sql->config->value['sys_session_autologin'] - && isset($_POST['rememberme'])) { + && isset($_POST['linRememberme'])) { $this->setLinphaCookie($data['id'], $data['password']); // this should be the updated hash (when needed) from compareHash() (call by reference) } /** * some security stuff */ - unset($_POST['password']); - unset($_REQUEST['password']); + unset($_POST['linPassword']); + unset($_REQUEST['linPassword']); } else { /** * failed login */ - linLog(LOG_TYPE_USER,LOG_WARNING,'login','User '.$_POST['username'].': login failed!'); + linLog(LOG_TYPE_USER,LOG_WARNING,'login','User '.$_POST['linUsername'].': login failed!'); $sysLogMsg[] = i18n("Login Failed!"); } } @@ -667,7 +667,7 @@ * $hash_secret not used at the moment * it has 2 main disadvantages: * - we would have to change require_once(config.sql.php) to require(config.sql.php) - * - if the admin deletes the file config.sql.php users will not never be able to authenticate + * - if the admin deletes the file config.sql.php users will not be able to authenticate * - it does not make sense to store the $hash_secret in the database instead of a file, * this would be no additional security! $sql_dir = ''; @@ -1026,6 +1026,13 @@ } } + function isPluginActive($plugin) + { + return isset($GLOBALS['linpha']->sql->config->value['plugins_'.$plugin.'_enable']) + && $GLOBALS['linpha']->sql->config->value['plugins_'.$plugin.'_enable']=='1'; + + } + } // end sub-class LinSqlConfig ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.view.album.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.view.album.class.php 2008-04-26 11:10:52 UTC (rev 4923) +++ trunk/linpha2/lib/classes/linpha.view.album.class.php 2008-04-26 19:27:15 UTC (rev 4924) @@ -1,4 +1,4 @@ -<?php +<?php /* * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> * Florian Angehrn Modified: trunk/linpha2/lib/classes/linpha.view.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.view.image.class.php 2008-04-26 11:10:52 UTC (rev 4923) +++ trunk/linpha2/lib/classes/linpha.view.image.class.php 2008-04-26 19:27:15 UTC (rev 4924) @@ -80,6 +80,7 @@ require_once(LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/tabs/gps.html.php'); break; case 'exif': + $this->getImageData('exif'); require_once(LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/tabs/exif.html.php'); break; case 'iptcXmp': @@ -191,7 +192,7 @@ * This should prevent all others from suffering performance issues * during import */ - if (isset($GLOBALS['linpha']->sql->config->value['plugins_maps_enable']) + if ($GLOBALS['linpha']->sql->config->isPluginActive('maps') && $GLOBALS['linpha']->sql->config->value['plugins_maps_enable_geotagged'] && $GLOBALS['linpha']->sql->config->value['plugins_maps_geotagged_autoimport']) { @@ -267,6 +268,19 @@ case 'videoInfo': $this->videoInfo = LinMetaData::readInformations($this->imgData, $flag_nr=11); break; + case 'exif': + $this->exifData = $GLOBALS['linpha']->db->GetRow("SELECT * FROM ".LIN_PREFIX."meta_exif " . + "WHERE md5sum = '".LinSql::linAddslashes($this->imgData['md5sum'])."'"); + unset($this->exifData['md5sum']); + + if ($GLOBALS['linpha']->sql->config->isPluginActive('maps') && $this->imgData['geodata']) + { + $this->gpsData = $GLOBALS['linpha']->db->GetRow("SELECT * FROM ".LIN_PREFIX."meta_exif " . + "WHERE md5sum = '".LinSql::linAddslashes($this->imgData['md5sum'])."'"); + unset($this->gpsData['md5sum']); + } + + break; } } Modified: trunk/linpha2/lib/include/metadata_info_show.php =================================================================== --- trunk/linpha2/lib/include/metadata_info_show.php 2008-04-26 11:10:52 UTC (rev 4923) +++ trunk/linpha2/lib/include/metadata_info_show.php 2008-04-26 19:27:15 UTC (rev 4924) @@ -25,7 +25,7 @@ */ if( !LinSql::photoIsAllowed( $GLOBALS['linpha']->template->idCurrent, $sql_perm_type = 'read' ) ) { - echo i18n("Access Denied!"); + echo LIN_STR_ACCESSDENIED; exit(); } @@ -39,7 +39,7 @@ if( ! isset($data['id']) ) { - echo i18n("Access Denied!"); + echo LIN_STR_ACCESSDENIED; exit(); } Deleted: trunk/linpha2/lib/js/LinGlobal.js =================================================================== --- trunk/linpha2/lib/js/LinGlobal.js 2008-04-26 11:10:52 UTC (rev 4923) +++ trunk/linpha2/lib/js/LinGlobal.js 2008-04-26 19:27:15 UTC (rev 4924) @@ -1,311 +0,0 @@ - -/** - * class and global definitions - */ -var LinGlobal = Class.create(); -var myLinGlobal; - -LinGlobal.prototype = -{ - /** - * initialize() - * Constructor runs on completion of the DOM loading. - */ - initialize: function() - { - this.menuNeedsUpdating = false; - - this.linInnerWidth = 0; - this.linInnerHeight = 0; - this.linPageXOffset = 0; - this.linPageYOffset = 0; - - this.tabs = new Array(); - - this.nofPopups = 0; - }, - - /** - * dynamically open syslog - * used in ajax context - */ - linSyslog: function(text) - { - if( typeof $('linDivSyslogText') != 'undefined' ) - { - if( $('linDivSyslogText').innerHTML == '' ) - { - $('linDivSyslogText').innerHTML += text; - } - else - { - $('linDivSyslogText').innerHTML += '<br />' + text; - } - - this.setScrollSize(); - $('linDivSyslog').style.top = (this.linPageYOffset + 15) + 'px'; - $('linDivSyslog').style.left = (this.linPageXOffset + 15) + 'px'; - Element.show('linDivSyslog'); - } - }, - closeSyslog: function() - { - $('linDivSyslogText').innerHTML = ''; - Element.hide('linDivSyslog'); - }, - - /** - * check ajax compatibilty - * will be on every page view until it was successfully - * then, the page will be reloaded - * - * use this on every page and not only on home page, because if user is linked directly to an image - * - * ajax may be disabled with ./?linCat=ajax&disable_ajax - * and may be re-enabled with ./?linCat=ajax&enable_ajax - * - * http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request - */ - checkAjaxCompatibility: function() - { - new Ajax.Request(LINPHA_LINK + '&linCat=ajax&use_js', {method:'get', asynchronous:true, onSuccess:myLinGlobal.checkAjaxCompatibilitySuccess} ); - }, - - /** - * reload page, now with ajax activated - * will be called if the request in checkAjaxCompatibility() was successfully - */ - checkAjaxCompatibilitySuccess: function(t) - { - if( t.responseText == 'use_js saved' ) - { - myLinGlobal.linSyslog('Ajax enabled'); - location.href = document.location; - } - }, - - AjaxPost: function(url, parameters, successFunction) - { - var opt = { - // Use POST - method: 'post', - // Send this lovely data - postBody: parameters - , - // asynchron, of course - asynchronous:true, - - // Handle successful response - onSuccess: successFunction, - - // Handle 404 - on404: function(t) { - alert('Error 404: ' + t.statusText); - }, - // Handle other errors - onFailure: function(t) { - alert('Error ' + t.status + ' -- ' + t.statusText); - } - } - - new Ajax.Request(url, opt); - }, - - /*reloadMenu: function() - { - if( this.menuNeedsUpdating ) - { - new Ajax.Updater('menu', LINPHA_LINK + '&linCat=ajax&reloadmenu&linId='+IdCurrent, {method: 'get', asynchronous:true, evalScripts:true}); - this.menuNeedsUpdating = false; - } - },*/ - - /** - * setWindowSize() - * - * sets two variables of the inner window width and height - * takes care of browser incompatibilities - */ - setWindowSize: function() - { - /** - * browser incompatibilities... - */ - if (window.innerHeight) // all except Explorer - { - this.linInnerWidth = self.innerWidth; - this.linInnerHeight = self.innerHeight; - } - else if (document.body && document.body.offsetWidth) - { - this.linInnerWidth = document.body.offsetWidth; - this.linInnerHeight = document.body.offsetHeight; - } - else - { - this.linInnerWidth = 500; - this.linInnerHeight = 300; - } - }, - - /** - * setMainHeight - * - * sets the height in thumb and image view of the "linDivMainOuter" - */ - setMainHeight: function() - { - this.setWindowSize(); - - var newHeight = this.linInnerHeight - $('linDivMain').offsetTop - 40; // 35 = 15 (bottom rounded corners) + 10 (margin-bottom) + 15 (??) - if(newHeight < 100) - { - newHeight = 100; - } - - $('linDivMain').style.height = newHeight + 'px'; - }, - - /** - * setScrollSize - * - * sets two variables with the scroll offset - * takes care of browser incompatibilites - * @uses linSyslog() - */ - setScrollSize: function() - { - if (self.pageYOffset) // all except Explorer - { - this.linPageXOffset = self.pageXOffset; - this.linPageYOffset = self.pageYOffset; - } - else if (document.documentElement && document.documentElement.scrollTop) - // Explorer 6 Strict - { - this.linPageXOffset = document.documentElement.scrollLeft; - this.linPageYOffset = document.documentElement.scrollTop; - } - else if (document.body) // all other Explorers - { - this.linPageXOffset = document.body.scrollLeft; - this.linPageYOffset = document.body.scrollTop; - } - }, - - fOnError: function(txt_message, url, line) { - var txt = "Error occured...\n\n"; - txt += "Message: " + txt_message + "\n"; - txt += "URL: " + url + "\n"; - txt += "Line: " + line; - alert(txt); - }, - - /** - * menu tab functions - - openTab: function( className, tabNr ) { - divElems = document.getElementsByTagName('div'); - for(i = 0, n = 0; i < divElems.length; i++) - { - if( divElems[i].className == className ) - { - if(n == tabNr && - typeof this.tabs[ className ]!='undefined' && - typeof this.tabs[ className ][ tabNr ]!='undefined' && - this.tabs[ className ][ tabNr ]!='disabled') - { - divElems[i].style.display = ''; - } else { - divElems[i].style.display = 'none'; - } - - n++; - } - } - }, - disableTab: function( className, tabNr, elemAId ) { - this.tabs[ className ][ tabNr ] = 'disabled'; - $(elemAId).style.color = 'gray'; - }, - enableTab: function( className, tabNr, elemAId ) { - //alert(className + ' ' + typeof this.tabs[ className ] + ' ' + this.tabs[ className ]); - //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! -} - -/** - * initLinGlobal() - * - * create the class object - */ -function initLinGlobal() -{ - myLinGlobal = new LinGlobal(); - - Event.observe(window, 'error', myLinGlobal.fOnError, false); - - /*if( checkAjaxCompatibility ) { - myLinGlobal.checkAjaxCompatibility(); - }*/ -} - -//Event.observe(window, 'load', initLinGlobal, false); -initLinGlobal(); - - -/** - * on resize functions - */ -function linEnableOnResize() -{ - Event.observe(window, 'resize', linOnResizeCreateTrigger, false); -} - -/** - * resizeWindow, use this wrapper function because internet explorer triggers the resize event to fast - * - * linOnResizeWrapper() must be defined where it's actually used (LinThumbnails.js, LinMapView.js) - */ -function linOnResizeCreateTrigger() -{ - clearTimeout(this.timerResize); - this.timerResize = setTimeout(linOnResizeWrapper,250); -} Copied: trunk/linpha2/lib/js/LinGlobal_old.js (from rev 4920, trunk/linpha2/lib/js/LinGlobal.js) =================================================================== --- trunk/linpha2/lib/js/LinGlobal_old.js (rev 0) +++ trunk/linpha2/lib/js/LinGlobal_old.js 2008-04-26 19:27:15 UTC (rev 4924) @@ -0,0 +1,311 @@ + +/** + * class and global definitions + */ +var LinGlobal = Class.create(); +var myLinGlobal; + +LinGlobal.prototype = +{ + /** + * initialize() + * Constructor runs on completion of the DOM loading. + */ + initialize: function() + { + this.menuNeedsUpdating = false; + + this.linInnerWidth = 0; + this.linInnerHeight = 0; + this.linPageXOffset = 0; + this.linPageYOffset = 0; + + this.tabs = new Array(); + + this.nofPopups = 0; + }, + + /** + * dynamically open syslog + * used in ajax context + */ + linSyslog: function(text) + { + if( typeof $('linDivSyslogText') != 'undefined' ) + { + if( $('linDivSyslogText').innerHTML == '' ) + { + $('linDivSyslogText').innerHTML += text; + } + else + { + $('linDivSyslogText').innerHTML += '<br />' + text; + } + + this.setScrollSize(); + $('linDivSyslog').style.top = (this.linPageYOffset + 15) + 'px'; + $('linDivSyslog').style.left = (this.linPageXOffset + 15) + 'px'; + Element.show('linDivSyslog'); + } + }, + closeSyslog: function() + { + $('linDivSyslogText').innerHTML = ''; + Element.hide('linDivSyslog'); + }, + + /** + * check ajax compatibilty + * will be on every page view until it was successfully + * then, the page will be reloaded + * + * use this on every page and not only on home page, because if user is linked directly to an image + * + * ajax may be disabled with ./?linCat=ajax&disable_ajax + * and may be re-enabled with ./?linCat=ajax&enable_ajax + * + * http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request + */ + checkAjaxCompatibility: function() + { + new Ajax.Request(LINPHA_LINK + '&linCat=ajax&use_js', {method:'get', asynchronous:true, onSuccess:myLinGlobal.checkAjaxCompatibilitySuccess} ); + }, + + /** + * reload page, now with ajax activated + * will be called if the request in checkAjaxCompatibility() was successfully + */ + checkAjaxCompatibilitySuccess: function(t) + { + if( t.responseText == 'use_js saved' ) + { + myLinGlobal.linSyslog('Ajax enabled'); + location.href = document.location; + } + }, + + AjaxPost: function(url, parameters, successFunction) + { + var opt = { + // Use POST + method: 'post', + // Send this lovely data + postBody: parameters + , + // asynchron, of course + asynchronous:true, + + // Handle successful response + onSuccess: successFunction, + + // Handle 404 + on404: function(t) { + alert('Error 404: ' + t.statusText); + }, + // Handle other errors + onFailure: function(t) { + alert('Error ' + t.status + ' -- ' + t.statusText); + } + } + + new Ajax.Request(url, opt); + }, + + /*reloadMenu: function() + { + if( this.menuNeedsUpdating ) + { + new Ajax.Updater('menu', LINPHA_LINK + '&linCat=ajax&reloadmenu&linId='+IdCurrent, {method: 'get', asynchronous:true, evalScripts:true}); + this.menuNeedsUpdating = false; + } + },*/ + + /** + * setWindowSize() + * + * sets two variables of the inner window width and height + * takes care of browser incompatibilities + */ + setWindowSize: function() + { + /** + * browser incompatibilities... + */ + if (window.innerHeight) // all except Explorer + { + this.linInnerWidth = self.innerWidth; + this.linInnerHeight = self.innerHeight; + } + else if (document.body && document.body.offsetWidth) + { + this.linInnerWidth = document.body.offsetWidth; + this.linInnerHeight = document.body.offsetHeight; + } + else + { + this.linInnerWidth = 500; + this.linInnerHeight = 300; + } + }, + + /** + * setMainHeight + * + * sets the height in thumb and image view of the "linDivMainOuter" + */ + setMainHeight: function() + { + this.setWindowSize(); + + var newHeight = this.linInnerHeight - $('linDivMain').offsetTop - 40; // 35 = 15 (bottom rounded corners) + 10 (margin-bottom) + 15 (??) + if(newHeight < 100) + { + newHeight = 100; + } + + $('linDivMain').style.height = newHeight + 'px'; + }, + + /** + * setScrollSize + * + * sets two variables with the scroll offset + * takes care of browser incompatibilites + * @uses linSyslog() + */ + setScrollSize: function() + { + if (self.pageYOffset) // all except Explorer + { + this.linPageXOffset = self.pageXOffset; + this.linPageYOffset = self.pageYOffset; + } + else if (document.documentElement && document.documentElement.scrollTop) + // Explorer 6 Strict + { + this.linPageXOffset = document.documentElement.scrollLeft; + this.linPageYOffset = document.documentElement.scrollTop; + } + else if (document.body) // all other Explorers + { + this.linPageXOffset = document.body.scrollLeft; + this.linPageYOffset = document.body.scrollTop; + } + }, + + fOnError: function(txt_message, url, line) { + var txt = "Error occured...\n\n"; + txt += "Message: " + txt_message + "\n"; + txt += "URL: " + url + "\n"; + txt += "Line: " + line; + alert(txt); + }, + + /** + * menu tab functions + + openTab: function( className, tabNr ) { + divElems = document.getElementsByTagName('div'); + for(i = 0, n = 0; i < divElems.length; i++) + { + if( divElems[i].className == className ) + { + if(n == tabNr && + typeof this.tabs[ className ]!='undefined' && + typeof this.tabs[ className ][ tabNr ]!='undefined' && + this.tabs[ className ][ tabNr ]!='disabled') + { + divElems[i].style.display = ''; + } else { + divElems[i].style.display = 'none'; + } + + n++; + } + } + }, + disableTab: function( className, tabNr, elemAId ) { + this.tabs[ className ][ tabNr ] = 'disabled'; + $(elemAId).style.color = 'gray'; + }, + enableTab: function( className, tabNr, elemAId ) { + //alert(className + ' ' + typeof this.tabs[ className ] + ' ' + this.tabs[ className ]); + //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! +} + +/** + * initLinGlobal() + * + * create the class object + */ +function initLinGlobal() +{ + myLinGlobal = new LinGlobal(); + + Event.observe(window, 'error', myLinGlobal.fOnError, false); + + /*if( checkAjaxCompatibility ) { + myLinGlobal.checkAjaxCompatibility(); + }*/ +} + +//Event.observe(window, 'load', initLinGlobal, false); +initLinGlobal(); + + +/** + * on resize functions + */ +function linEnableOnResize() +{ + Event.observe(window, 'resize', linOnResizeCreateTrigger, false); +} + +/** + * resizeWindow, use this wrapper function because internet explorer triggers the resize event to fast + * + * linOnResizeWrapper() must be defined where it's actually used (LinThumbnails.js, LinMapView.js) + */ +function linOnResizeCreateTrigger() +{ + clearTimeout(this.timerResize); + this.timerResize = setTimeout(linOnResizeWrapper,250); +} Deleted: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js 2008-04-26 11:10:52 UTC (rev 4923) +++ trunk/linpha2/lib/js/LinImage.js 2008-04-26 19:27:15 UTC (rev 4924) @@ -1,1186 +0,0 @@ - -/** - * class and global definitions - */ -var LinImage = Class.create(); -var myLinImage; - -LinImage.prototype = { - - /** - * initialize() - * - * Constructor runs on completion of the DOM loading. - */ - initialize: function() - { - /*this.imgInfoColorNotActive = $('linDivInfoLink').style.color; - this.imgInfoColorActive = $('linHrefInfoLink').style.color;*/ - this.imgInfoShowHide = 'hide'; - - - this.fullscreenActive = false; - this.fullscreenOldMaxWidth, this.fullscreenOldMaxHeight, this.previousBodyOverflow; - this.slideshowActive = false; - this.ssCurrentTimerID; - this.ssCurrentDelay = 5000; - this.ssRandom = false; - this.ssLoop = false; - - this.xmlDoc = new Array(); - this.nextThumbs = new Array(); - this.prevThumbs = new Array(); - this.preloadImageSrc = new Array(); // image array, will contain a lot of preloaded images - this.finishedPreloadedImages = new Array(); // set to true after preload completed - this.preloadXmlFinished = new Array(); - - this.currentFileType; // 1 = image, 2 = video, 3 = others - - this.curLocationHash; - //this.timerResize; - }, - - - // ----------------------------------------------------------------------------------- - // functions to load xml data of images - // ----------------------------------------------------------------------------------- - - loadImage: function(imgId) { - if(IdCurrent != imgId) - { - IdCurrent = imgId; - //myLinGlobal.menuNeedsUpdating = true; // IdCurrent changed, update menu on next hover of the menu - location.hash = 'idCurrent='+IdCurrent; - } - - this.curLocationHash = location.hash; // update current Hash, this value is periodically checked to reload the image if neccessary - - // do not load the data again if it is already cached - if(this.preloadXmlFinished[imgId] && typeof this.xmlDoc[imgId] != "undefined" ) // use typeof to work in IE - { - this.changeImage(); - } - else - { - this.loadImageXml(imgId); - } - }, - - loadImageXml: function(imgId) { - myLinGlobal.AjaxPost(linUrlBase + '&linId=' + imgId + '&xml', '', myLinImage.loadImageContinue); - }, - - loadImageContinue: function(t) { - var loadedimgid = t.responseXML.documentElement.getElementsByTagName('imgid').item(0).firstChild.data; - - // save xml data - myLinImage.xmlDoc[loadedimgid] = t.responseXML.documentElement; - myLinImage.preloadXmlFinished[loadedimgid] = true; - - if( loadedimgid == IdCurrent ) // coming from loadImage() - { - myLinImage.changeImage(); - } - else // coming from preloadImage() - { - myLinImage.preloadImage(loadedimgid); - } - }, - - - // ----------------------------------------------------------------------------------- - // Navigation functions - // ----------------------------------------------------------------------------------- - - movePrev: function() { - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - } - - if(this.prevThumbs[ this.prevThumbs.length - 1 ]) - { - Element.setOpacity('linSsImgPrev',0.7); - new Effect.Appear('linSsImgPrev', { duration: 0.5, from: 0.7, to: 1.0 }); - myLinImage.loadImage(this.prevThumbs[ this.prevThumbs.length - 1 ]); - - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - } - else // end reached, do nothing but enable keyboard navigation again - { - myLinImage.enableKeyboardNav(); - } - - if( this.slideshowActive ) - { - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - }, - moveNext: function() { - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - } - - if(this.nextThumbs[0]) - { - Element.setOpacity('linSsImgNext',0.7); - new Effect.Appear('linSsImgNext', { duration: 0.5, from: 0.7, to: 1.0 }); - myLinImage.loadImage(this.nextThumbs[0]); - } - else if( this.ssLoop ) - { - Element.setOpacity('linSsImgNext',0.7); - new Effect.Appear('linSsImgNext', { duration: 0.5, from: 0.7, to: 1.0 }); - this.moveFirst(); - } - else // end reached, do nothing but enable keyboard navigation again - { - myLinImage.enableKeyboardNav(); - } - - if( this.slideshowActive ) - { - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - }, - moveFirst: function() { - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - } - - Element.setOpacity('linSsImgFirst',0.7); - new Effect.Appear('linSsImgFirst', { duration: 0.5, from: 0.7, to: 1.0 }); - myLinImage.loadImage( firstImgId ); - - if( this.slideshowActive ) - { - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - }, - moveLast: function() { - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - } - - Element.setOpacity('linSsImgLast',0.7); - new Effect.Appear('linSsImgLast', { duration: 0.5, from: 0.7, to: 1.0 }); - myLinImage.loadImage( lastImgId ); - - if( this.slideshowActive ) - { - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - }, - - // ----------------------------------------------------------------------------------- - // Change image functions - // ----------------------------------------------------------------------------------- - - /** - * changeImage() - */ - changeImage: function() { - - /** - * set height of outer div to prevent the whole page getting smaller, and if the image is loaded getting bigger again - * but in fullscreen, we want no activities in background - */ - if(! this.fullscreenActive) { - $('linDivMainimage').style.height = $('linImgMainimage').style.height; - //$('linDivMain').style.height = $('linDivMain').offsetHeight; - //alert($('linDivMain').offsetHeight); - } - - /** - * hide elements during transition - */ - this.hideImgInfoNow(); // hide text info link immediately - Element.hide('linImgMainimage'); // hide mainimage while changing image to prevent flicker - Element.hide('linDivInfoLink'); - - this.currentFileType = this.xmlDoc[IdCurrent].getElementsByTagName('filetype').item(0).firstChild.data; - - switch( this.currentFileType ) - { - case '1': // image - - if(! this.finishedPreloadedImages[IdCurrent] ) - { - Element.show('linDivloading'); - } - - //$('linImgMainimage').style.marginLeft = 0; // restore left margin, set when viewing videos - - /** - * calc image width and height - */ - var orgWidth = this.xmlDoc[IdCurrent].getElementsByTagName('imgwidth').item(0).firstChild.data; - var orgHeight = this.xmlDoc[IdCurrent].getElementsByTagName('imgheight').item(0).firstChild.data; - var sizeArray = this.scaleToFit(orgWidth,orgHeight,maxImageWidth,maxImageHeight,1); - var imgWidth = sizeArray[0]; - var imgHeight = sizeArray[1]; - - /** - * preload image - */ - var currentImgSrc = imageSrc + IdCurrent + '&width=' + imgWidth + '&height=' + imgHeight; - imgPreloader = new Image(); - - /** - * once image is preloaded, resize image container - * - * pay attention with the other image preloader! - * if imgWidth and imgWidth was not set with trailing 'var' it got overlapping with the other variables - * and this caused the image not resized correctly in resizeImageContainer() !!! - */ - imgPreloader.onload=function(){ - myLinImage.finishedPreloadedImages[IdCurrent] = true; - $('linImgMainimage').src = currentImgSrc; - myLinImage.resizeImageContainer(imgWidth, imgHeight); - } - imgPreloader.src = currentImgSrc; - - break; - case '2': // video - - //$('linImgMainimage').style.marginLeft = 200; - - /** - * show video thumbnail - */ - $('linImgMainimage').src = thumbSrc + IdCurrent ; - $('linImgMainimage').style.width = 'auto'; - $('linImgMainimage').style.height = 'auto'; - - /** - * show image and set div height - */ - this.showImage(); - - break; - case '0': // others - break; - } - }, - - /** - * resizeImageContainer() - */ - resizeImageContainer: function( imgWidth, imgHeight) { - - // get current height and width - /*this.wCur = $('linImgMainimage').offsetWidth; - this.hCur = $('linImgMainimage').offsetHeight; - - // scalars based on change from old to new - this.xScale = ((imgWidth + (borderSize * 2)) / this.wCur) * 100; - this.yScale = ((imgHeight + (borderSize * 2)) / this.hCur) * 100; - - // calculate size difference between new and old image, and resize if necessary - wDiff = (this.wCur - borderSize * 2) - imgWidth; - hDiff = (this.hCur - borderSize * 2) - imgHeight; - - if(!( hDiff == 0)){ new Effect.Scale('linImgMainimage', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); } - if(!( wDiff == 0)){ new Effect.Scale('linImgMainimage', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); } - - // if new and old image are same size and no scaling transition is necessary, - // do a quick pause to prevent image flicker. - if((hDiff == 0) && (wDiff == 0)){ - if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} - }*/ - - $('linImgMainimage').style.width = imgWidth + 'px'; - $('linImgMainimage').style.height = imgHeight + 'px'; - - - /*Element.setHeight('prevLink', imgHeight); - Element.setHeight('nextLink', imgHeight); - Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2));*/ - - /** - * show panorama link - * the only reason why do this at this point is, because this is only done on images - * and we just know the width and height - */ - if( imgWidth/imgHeight >= 2 || imgHeight/imgWidth >= 2 ) - { - Element.show('linHrefPanoLink'); - } - - this.showImage(); - }, - - /** - * showImage() - * - * Display image and begin preloading next images. - */ - showImage: function(){ - Element.hide('linDivloading'); - - if( useEffects ) - { - new Effect.Appear('linImgMainimage', { duration: 0.2, afterFinish: function(){ myLinImage.setImageData(); } }); - } - else - { - Element.show('linImgMainimage'); - this.setImageData() - } - - if(! this.fullscreenActive) - { - $('linDivMainimage').style.height = $('linImgMainimage').style.height; // reset to correct height to prevent trouble if image is bigger or smaller - //$('linDivMain').style.height = 'auto'; - } - }, - - /** - * setImageData() - */ - setImageData: function() - { - this.enableKeyboardNav(); - - /** - * set title - */ - if( typeof $('linDivTitle') != 'undefined' ) - { - $('linDivTitle').innerHTML = this.xmlDoc[IdCurrent].getElementsByTagName('title').item(0).firstChild.data; - } - - /** - * update the menu - * - * replace the image ids in the menu - * replace( /linId=[0-9]* /g , "linId=" + IdCurrent ); - * its just an search/replace of 'linId=x' in the menu - * its very fast (about 0 - 15ms) and its executed every time the image changes - * - * but only in menuMore and menuAdmin, because we have in menuLogin - * linId='+IdCurrent, and ooh this will create very unexpected results..!! - */ - /*if( typeof $('linMenuAdmin') != 'undefined' ) - {*/ - //$('linMenuAdmin').innerHTML = $('linMenuAdmin').innerHTML.replace( /linId=[0-9]*/g , "linId=" + IdCurrent ); - /*}*/ - - /** - * menuMore - */ - /*if( typeof $('linMenuMore') != 'undefined' ) - {*/ - //$('linMenuMore').innerHTML = $('linMenuMore').innerHTML.replace( /linId=[0-9]*/g , "linId=" + IdCurrent ); - - // replace the width and height dimensions of the view at fullscreen link - //var orgWidth = this.xmlDoc[IdCurrent].getElementsByTagName('imgwidth').item(0).firstChild.data; - //var orgHeight = this.xmlDoc[IdCurrent].getElementsByTagName('imgheight').item(0).firstChild.data; - //$('linLiViewAtFullscreen').innerHTML = $('linLiViewAtFullscreen').innerHTML.replace( /width=[0-9]*/ , "width=" + orgWidth ); - //$('linLiViewAtFullscreen').innerHTML = $('linLiViewAtFullscreen').innerHTML.replace( /height=[0-9]*/ , "height=" + orgHeight ); - //$('linLiViewAtFullscreen').innerHTML = $('linLiViewAtFullscreen').innerHTML.replace( /[0-9]*x[0-9]*/ , orgWidth + "x" + orgHeight ); - /*}*/ - - /** - * set current thumb - */ - $('linDivThumbnavi_Current').innerHTML = '<a href="javascript:myLinImage.loadImage(' + IdCurrent + ')"><img class="linImgThumbnavi_Current" src="' + thumbSrc + IdCurrent + '" /></a>'; - - /** - * set prev thumbs - */ - $('linDivThumbnavi_Prev').innerHTML = ''; - this.prevThumbs = new Array(); - if(this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').length > 0) - { - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').length; i++) - { - var thumbId = this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').item(i).firstChild.data; - this.prevThumbs[i] = thumbId; - this.setPrevNextThumb(thumbId, 'linDivThumbnavi_Prev'); - } - } - - /** - * set next thumbs - */ - $('linDivThumbnavi_Next').innerHTML = ''; - this.nextThumbs = new Array(); - if(this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').length > 0) - { - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').length; i++) - { - var thumbId = this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').item(i).firstChild.data; - this.nextThumbs[i] = thumbId; - this.setPrevNextThumb(thumbId, 'linDivThumbnavi_Next'); - } - } - - /** - * set meta data - */ - $('linDivMeta').innerHTML = ''; - if(this.xmlDoc[IdCurrent].getElementsByTagName('meta').length > 0) - { - var table = Builder.node('table', {id: 'linTableMeta'} ); - var tbody = Builder.node('tbody'); - - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('meta').length; i++) - { - var meta = this.xmlDoc[IdCurrent].getElementsByTagName('meta').item(i); - var metaname = meta.getElementsByTagName('name').item(0).firstChild.data; - if(meta.getElementsByTagName('value').item(0).hasChildNodes()) { // prevent error in IE - var metavalue = meta.getElementsByTagName('value').item(0).firstChild.data; - } else { - var metavalue = ''; - } - - var tr = Builder.node('tr'); - var tdleft = Builder.node('td', {className: 'linTdMetaLeftColumn'}, metaname ); - var tdright = Builder.node('td', metavalue ); - - tr.appendChild(tdleft); - tr.appendChild(tdright); - tbody.appendChild(tr); - } - - table.appendChild(tbody); - - $('linDivMeta').appendChild(table); - - } - - /** - * file type specific meta data stuff - */ - switch( this.currentFileType ) - { - case '1': // image - this.setImageInfoLink(); // show the "info" link, must be called after Appear('linImgMainimage') - - //Element.hide('linDivVideoLink'); - //Element.show('linDivExifLink'); - //$('linAMetaExif').href = '#' + $('linAMetaExif').href; - //myLinGlobal.enableTab( 'linDivTab', 3, 'linAMetaExif' ); - - break; - case '2': // video - - //Element.show('linDivVideoLink'); - //Element.hide('linDivExifLink'); - //$('linAMetaExif').href = $('linAMetaExif').href.substring(1); - //$('linAMetaExif').href = '#' + $('linAMetaExif').href; - - //myLinGlobal.disableTab( 'linDivTab', 3, 'linAMetaExif' ); - - /*$('linDivMetaOuter').style.top = $('linImgMainimage').offsetTop + 'px'; - $('linDivMetaOuter').style.height = $('linImgMainimage').offsetHeight + 'px'; // 'auto' - Element.show('linDivMetaOuter');*/ - - break; - } - - this.initTextareaAddComment(); - this.setComments(); - - /** - * set image nr - * currently only in slideshow used - */ - $('linDivSlideshowImgNr').innerHTML = this.xmlDoc[IdCurrent].getElementsByTagName('imgnr').item(0).firstChild.data; - - - /** - * and at last, start preloading next and previous images - */ - this.preloadXml(); - - - }, - - /** - * setPrevNextThumb() - * - * code to generate a thumbnail with a <div><a><img> tag - */ - setPrevNextThumb: function(thumbId, divId) - { - var ElemImg = Builder.node('img', {id: 'thumb'+thumbId, className: 'linImgThumbnavi_PrevNext', src: thumbSrc + thumbId}); - var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + thumbId + ')'}); - var ElemDiv = Builder.node('div', {className: 'linDivThumbnavi_PrevNext'}); - - ElemA.appendChild( ElemImg ); - ElemDiv.appendChild( ElemA ); - $(divId).appendChild(ElemDiv); - - if(! this.finishedPreloadedImages[thumbId]) { - Element.setOpacity('thumb'+thumbId,0.5); - } - - }, - - - // ----------------------------------------------------------------------------------- - // Keyboard actions - // ----------------------------------------------------------------------------------- - - /** - * enableKeyboardNav() - */ - enableKeyboardNav: function() { - document.onkeydown = this.keyboardAction; - }, - - /** - * disableKeyboardNav() - */ - disableKeyboardNav: function() { - document.onkeydown = ''; - }, - - /** - * keyboardAction() - * - * very nice - * http://www.mediaevent.de/javascript/needful_tables.html - */ - keyboardAction: function(e) { - - if (e == null) { // ie - keycode = event.keyCode; - ctrlKey = event.ctrlKey; - } else { // mozilla - keycode = e.which; - ctrlKey = e.ctrlKey; - } - - /*if( ctrlKey ) - { - alert('ctrl pressed'); - return; - }*/ - - //alert(keycode); - - key = String.fromCharCode(keycode).toLowerCase(); - - //if ((keycode == 39) && (ctrlKey == true)) // ctrl + arrow right - if (keycode == 34) // page down - { - myLinImage.disableKeyboardNav(); - myLinImage.moveNext(); - return false; - } - //else if ((keycode == 37) && (ctrlKey == true)) // ctrl + arrow left - else if (keycode == 33) // page up - { - myLinImage.disableKeyboardNav(); - myLinImage.movePrev(); - return false; - } - else if ((keycode == 32) && (ctrlKey == true)) // ctrl + space - { - myLinImage.slideshowStartStop(); - } - else if ((keycode == 122)) // F11 - { - if( myLinImage.fullscreenActive ) { - $('linDivSlideshowExit').show(); // hide exit button to force exit again with F11 - myLinImage.fullscreenStop(); - } else { - $('linDivSlideshowExit').hide(); - myLinImage.fullscreenStart(); - } - } - else if ((keycode == 36) && (ctrlKey == true)) // ctrl + home - //else if (keycode == 36) // home - { - myLinImage.moveFirst(); - return false; - } - else if ((keycode == 35) && (ctrlKey == true)) // ctrl + end - //else if (keycode == 35) // end - { - myLinImage.moveLast(); - return false; - } - else if( myLinImage.fullscreenActive && ((key == 'f') || (key == 'x') || (key == 'o') || (key == 'c') ) ) // close fullscreen - { - myLinImage.fullscreenStop(); - } - else if(myLinImage.fullscreenActive && key == 's') // start/stop slideshow - { - myLinImage.slideshowStartStop(); - } - else if(myLinImage.fullscreenActive && key == 'p') // display previous image - { - myLinImage.disableKeyboardNav(); - myLinImage.movePrev(); - } - else if(myLinImage.fullscreenActive && key == 'n') // display next image - { - myLinImage.disableKeyboardNav(); - myLinImage.moveNext(); - } - }, - - - // ----------------------------------------------------------------------------------- - // Preload functions - // ----------------------------------------------------------------------------------- - - /** - * preloadXml() - * Preload previous and next images. - * - * normally, loadImageXml() will call also preloadImage() - * but we also need to call preloadImage() if the Xml data is preloaded, - * but not yet the image (this may occur if we change to fullscreen, - * then, the images need to be re preloaded all - */ - preloadXml: function() { - - // preload nextthumb from left to right - if(this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').length > 0) - { - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').length; i++) - { - var imgId = this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').item(i).firstChild.data; - - if(! this.preloadXmlFinished[imgId]) - { - this.loadImageXml(imgId); - } - else if(! this.finishedPreloadedImages[imgId] ) - { - this.preloadImage(imgId); - } - } - } - - // preload prevthumb from right to left - if(this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').length > 0) - { - for(var i = this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').length-1; i >= 0; i--) - { - var imgId = this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').item(i).firstChild.data; - - if(! this.preloadXmlFinished[imgId]) - { - this.loadImageXml(imgId); - } - else if(! this.finishedPreloadedImages[imgId] ) - { - this.preloadImage(imgId); - } - } - } - }, - - /** - * preloadImage() - * - * will be called after getting the xml data - */ - preloadImage: function(imgId) - { - if(! this.finishedPreloadedImages[imgId] ) - { - switch(this.xmlDoc[imgId].getElementsByTagName('filetype').item(0).firstChild.data) - { - case '1': // image - /** - * set image width and height - */ - var orgWidth = this.xmlDoc[imgId].getElementsByTagName('imgwidth').item(0).firstChild.data; - var orgHeight = this.xmlDoc[imgId].getElementsByTagName('imgheight').item(0).firstChild.data; - var sizeArray = this.scaleToFit(orgWidth,orgHeight,maxImageWidth,maxImageHeight,1); - var imgWidth = sizeArray[0]; - var imgHeight = sizeArray[1]; - - /** - * preload image - */ - this.preloadImageSrc[imgId] = new Image(); - - this.preloadImageSrc[imgId].onload=function(){ - myLinImage.preloadImageFinished(imgId); - } - this.preloadImageSrc[imgId].src = imageSrc + imgId + '&width=' + imgWidth + '&height=' + imgHeight; - - break; - case '2': // video - this.preloadImageFinished(imgId); - break; - case '0': // other - break; - } - } - }, - - preloadImageFinished: function(imgId) { - - this.finishedPreloadedImages[imgId] = true; - - if( $('thumb'+imgId) ) // maybe its not here anymore - { - new Effect.Appear('thumb'+imgId, { duration: 0.5, from: 0.5, to: 1.0 }); - } - - }, - - - // ----------------------------------------------------------------------------------- - // Slideshow functions - // ----------------------------------------------------------------------------------- - - fullscreenStart: function() - { - this.fullscreenActive = true; - - /** - * save old values to restore if slideshow ends - */ - this.fullscreenOldMaxWidth = maxImageWidth; - this.fullscreenOldMaxHeight = maxImageHeight; - - /** - * disable scrollbars - */ - this.previousBodyOverflow = document.getElementsByTagName("body")[0].style.overflow; - document.getElementsByTagName("body")[0].style.overflow='hidden'; - - /** - * start slideshow with some superduper effects - */ - Effect.Appear('linDivSlideshowOverlay', { queue: 'end', duration: 1.0, from: 0.0, to: 0.9 }); - Effect.BlindDown('linDivSlideshowControlsOuter', { queue: 'end'} ); - Element.show('linDivSlideshowImage'); - - /** - * steal the mainimage - */ - $('linDivMainimage').innerHTML = ''; - $('linDivSlideshowImage').innerHTML = '<img id="linImgMainimage" style="display: none;" class="linImgSlideshow">'; - - /** - * reload image with new position and size - */ - //this.resizeWindow(); - //linOnResizeCreateTrigger(); - linOnResizeWrapper(); - }, - fullscreenStop: function() - { - this.fullscreenActive = false; - - /** - * restore max image size - */ - maxImageWidth = this.fullscreenOldMaxWidth; - maxImageHeight = this.fullscreenOldMaxHeight; - - /** - * re-enable scrollbars - */ - document.getElementsByTagName("body")[0].style.overflow = this.previousBodyOverflow; - - /** - * delete preloaded images after stopping fullscreen - */ - this.finishedPreloadedImages = new Array(); - - /** - * end slideshow with some superduper effects - */ - Effect.Fold('linDivSlideshowControlsOuter', { queue: 'end'} ); - Effect.Fade('linDivSlideshowOverlay', { queue: 'end', duration: 0.5, from: 0.9, to: 0.0 } ); - Element.hide('linDivSlideshowImage'); - - /** - * give back the mainimage - */ - $('linDivSlideshowImage').innerHTML = ''; - $('linDivMainimage').innerHTML = '<img id="linImgMainimage" style="display: none;">'; - - /** - * reload image with old position and size - */ - this.loadImage( IdCurrent ); - }, - - slideshowStartStop: function() - { - // start Slideshow - if(! this.slideshowActive) - { - this.slideshowActive = true; - Element.setOpacity('linSsImgStart',0.7); - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - else // stop Slideshow - { - this.slideshowActive = false; - Element.setOpacity('linSsImgStart',1); - clearTimeout(this.ssCurrentTimerID); - } - }, - slideshowPlay: function() - { - if(this.nextThumbs[0] || this.ssLoop) - { - this.moveNext(); - //this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - else - { - // force stop slideshow - this.slideshowActive = true; - this.slideshowStartStop(); - } - }, - - slideshowChangeDelay: function() - { - this.ssCurrentDelay = $('linSsDelay').options[ $('linSsDelay').selectedIndex ].value * 1000; - //document.optionsForm.delay.options[document.optionsForm.delay.selectedIndex].value * 1000; - }, - slideshowChangeLoop: function() - { - if(! this.ssLoop) { - this.ssLoop = true; - Element.setOpacity('linSsImgLoop',0.7); - } else { - this.ssLoop = false; - Element.setOpacity('linSsImgLoop',1); - } - }, - slideshowChangeRandom: function() - { - if(! this.ssRandom) { - this.ssRandom = true; - Element.setOpacity('linSsImgRandom',0.7); - } else { - this.ssRandom = false; - Element.setOpacity('linSsImgRandom',1); - } - alert('This feature is currently not implemented, do we really need that?'); - }, - - - // ----------------------------------------------------------------------------------- - // Image info functions - // ----------------------------------------------------------------------------------- - - /** - * setImageInfoLink() - * - * positions the info link on bottom right of the image - * could only be done after image is not hidden anymore - * - * if this can be done without javascript, please tell me - */ - setImageInfoLink: function() - { - $('linDivInfoLink').style.top = ($('linImgMainimage').offsetTop + $('linImgMainimage').offsetHeight + 3) + 'px'; - $('linDivInfoLink').style.left = ($('linImgMainimage').offsetLeft + $('linImgMainimage').offsetWidth - 200) + 'px'; // 200: width of linDivInfoLink, value set view_img.css width = 200px; can't get width with javascript because element is hidden - Element.show('linDivInfoLink'); - }, - - /** - * DEPRECATED - * showImgInfo() - * - * fade out the image, show the meta infos, sets the color of the "Info" link to another - * - * idea: - * swap the colors of <a> and <div> tag (id 'linHrefInfoLink' and 'linDivInfoLink' - * so it is possible to set the colors in the css template (and not in javascript file) - - showImgInfo: function() - { - // make visible/invisible - if( this.imgInfoShowHide == 'hide' ) - { - this.imgInfoShowHide = 'show'; - - // set position - $('linDivMetaOuter').style.top = $('linImgMainimage').offsetTop + 'px'; - $('linDivMetaOuter').style.height = $('linImgMainimage').offsetHeight + 'px'; - - new Effect.Appear('linDivMetaOuter', { duration: 0.3 }); //, from: 0.0, to: 1.0 - new Effect.Fade('linDivMainimage', { duration: 0.3, from: 1.0, to: 0.2 }); - - $('linHrefInfoLink').style.color = this.imgInfoColorNotActive; - } - else - { - this.imgInfoShowHide = 'hide'; - - new Effect.Fade('linDivMetaOuter', { duration: 0.3 }); // , from: 1.0, to: 0.0 - new Effect.Appear('linDivMainimage', { duration: 0.3, from: 0.2, to: 1.0 }); - - $('linHrefInfoLink').style.color = this.imgInfoColorActive; - } - },*/ - hideImgInfoNow: function() - { - //Element.hide('linDivMetaOuter'); - Element.hide('linHrefPanoLink'); - Element.hide('linDivVideoLink'); - - //Element.setOpacity('linDivMainimage',1); - this.imgInfoShowHide = 'hide'; - - //$('linHrefInfoLink').style.color = this.imgInfoColorActive; - }, - - /** - * returns an array(width, height) with the correct size to fit - * in dst_w and dst_h - */ - scaleToFit: function(src_w,src_h,dst_w,dst_h,no_increase) - { - if(src_h == 0 || src_w == 0) - { - return new Array(0, 0); - } - - var 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) - { - var returnarray = new Array( Math.round(src_w), Math.round(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 - */ - - var 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 - { - var returnarray = new Array( Math.round(img_relation*dst_h), Math.round(dst_h) ); - } - else - { - var returnarray = new Array( Math.round(dst_w), Math.round(tmp_height) ); - } - } - - return returnarray; - }, - - - // ----------------------------------------------------------------------------------- - // Comments - // ----------------------------------------------------------------------------------- - - setComments: function() - { - $('linDivComments').innerHTML = ''; - - if(this.xmlDoc[IdCurrent].getElementsByTagName('comment').length > 0) - { - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('comment').length; i++) - { - var tagcomment = this.xmlDoc[IdCurrent].getElementsByTagName('comment').item(i); - var commenttime = document.createTextNode( tagcomment.getElementsByTagName('time').item(0).firstChild.data + ' by ' ); - var commentauthor = document.createTextNode( tagcomment.getElementsByTagName('author').item(0).firstChild.data ); -// var commenttext = document.createTextNode( tagcomment.getElementsByTagName('text').item(0).firstChild.data ); - - var commenttextdiv = Builder.node('div', {id: 'linComment'+i}); - - $('linDivComments').appendChild(commenttime); - $('linDivComments').appendChild(commentauthor); - $('linDivComments').appendChild( document.createElement("hr") ); - $('linDivComments').appendChild(commenttextdiv); - $('linDivComments').appendChild( document.createElement("br") ); - $('linDivComments').appendChild( document.createElement("br") ); - - $('linComment'+i).innerHTML = tagcomment.getElementsByTagName('text').item(0).firstChild.data; - } - } - }, - - saveComment: function(t) - { - // not use 'this.' doesnt work if call from ajax success function - - myLinImage.xmlDoc[IdCurrent] = t.responseXML.documentElement; - - if(myLinImage.xmlDoc[IdCurrent].getElementsByTagName('commentadded').length > 0) - { - myLinImage.initTextareaAddComment(); - myLinGlobal.linSyslog( myLinImage.xmlDoc[IdCurrent].getElementsByTagName('commentadded').item(0).firstChild.data ); - } - - //myLinImage.loadImage(IdCurrent); - myLinImage.setComments(); - }, - - /** - * openTextarea() - * - * opens the bigger textarea to enter longer image comments - * this function is defined in view_img_static.html.php too - */ - openTextarea: function() - { - Element.show('linDivAddCommentTextarea'); - Element.hide('linDivAddCommentText'); - - $('linInputAddCommentTextarea').value = $('linInputAddCommentText').value; - }, - - initTextareaAddComment: function() - { - Element.hide('linDivAddCommentTextarea'); - Element.show('linDivAddCommentText'); - - $('linInputAddCommentTextarea').value = ''; - $('linInputAddCommentText').value = ''; - }, - - - // ----------------------------------------------------------------------------------- - // Meta functions - // ----------------------------------------------------------------------------------- - - updateLinId: function(elemId) - { - elemId.href = elemId.href.replace( /linId=[0-9]*/g , "linId=" + IdCurrent ); - } - - - // ----------------------------------------------------------------------------------- - // Common used functions - // ----------------------------------------------------------------------------------- - - /** - * resizeWindow, use this wrapper function because internet explorer triggers the resize event to fast - */ - /*resizeWindow: function () - { - clearTimeout(this.timerResize); - this.timerResize = setTimeout(linImageWrapper,250); - }*/ -} - -/** - * linImageWrapper() - * - * use this wrapper function if called from setTimeout() - * because 'this.' would not work otherwise - */ -function linOnResizeWrapper() -{ - if(myLinImage.fullscreenActive) - { - /** - * delete preloaded images after starting fullscreen and resizing window - */ - myLinImage.finishedPreloadedImages = new Array(); - - myLinGlobal.setWindowSize(); - maxImageWidth = myLinGlobal.linInnerWidth - 70; - maxImageHeight = myLinGlobal.linInnerHeight - 120; - - myLinImage.loadImage( IdCurrent ); - } - else - { - myLinImage.setImageInfoLink(); - // myLinGlobal.setMainHeight(); - } -} - -/** - * init on finished page load - */ -function initLinImage() -{ - $('linDivMainimage').style.height = startImgHeight + 'px'; // initial sets correct height at begin and not after the image is loaded - myLinImage = new LinImage(); - - /** - * doing something very important! - * rebuild the browsers histroy back, forware and reload functions - * if we have a #idCurrent=xyz in the url use this as the id - */ - if( document.location.hash.indexOf('idCurrent') != -1 ) - { - IdCurrent = document.location.hash.substr(11); - } - - /** - * ... [truncated message content] |