From: Edward Z. Yang Date: Sat, 21 Nov 2009 00:52:41 +0000 (-0500) Subject: Wordpress 2.5.1 X-Git-Tag: wordpress-2.5.1 X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/commitdiff_plain/177fd6fefd2e3d5a0ea6591c71d660cabdb3c1a4 Wordpress 2.5.1 Signed-off-by: Edward Z. Yang --- diff --git a/license.txt b/license.txt index 88822058..b5fcfa6e 100644 --- a/license.txt +++ b/license.txt @@ -1,280 +1,280 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, 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 - + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, 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 + diff --git a/readme.html b/readme.html index 636def83..a60861c5 100644 --- a/readme.html +++ b/readme.html @@ -1,14 +1,14 @@ - WordPress › ReadMe + WordPress › ReadMe

WordPress -
Version 2.3 +
Version 2.5

Semantic Personal Publishing Platform

@@ -29,7 +29,7 @@

Upgrading

Before you upgrade anything, make sure you have backup copies of any files you may have modified such as index.php.

-

Upgrading from any previous WordPress to 2.3:

+

Upgrading from any previous WordPress to 2.5:

  1. Delete your old WP files, saving ones you've modified.
  2. Upload the new files.
  3. @@ -56,7 +56,7 @@

    System Recommendations

      -
    • PHP version 4.2 or higher.
    • +
    • PHP version 4.3 or higher.
    • MySQL version 4.0 or higher.
    • ... and a link to http://wordpress.org on your site.
    @@ -70,7 +70,7 @@

    Post via Email

    You can post from an email client! To set this up go to your "Writing" options screen and fill in the connection details for your secret POP3 account. Then you need to set up wp-mail.php to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your wp-mail.php URL.

    -

    Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address dicrete. The script will delete emails that are successfully posted.

    +

    Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address discrete. The script will delete emails that are successfully posted.

    User Roles

    We've eliminated user levels in order to make way for the much more flexible roles system introduced in 2.0. You can read more about Roles and Capabilities on the Codex.

    diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 013e3750..4e34333c 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1,61 +1,91 @@ "; - $r .= ""; - $r .= ""; - $r .= "
    "; - $r .= ""; - return $r; +if ( isset($_GET['action']) && 'ajax-tag-search' == $_GET['action'] ) { + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $s = $_GET['q']; // is this slashed already? + + if ( strstr( $s, ',' ) ) + die; // it's a multiple tag insert, we won't find anything + $results = $wpdb->get_col( "SELECT name FROM $wpdb->terms WHERE name LIKE ('%$s%')" ); + echo join( $results, "\n" ); + die; } -$id = (int) $_POST['id']; -switch ( $_POST['action'] ) : +$id = isset($_POST['id'])? (int) $_POST['id'] : 0; +switch ( $action = $_POST['action'] ) : case 'delete-comment' : + check_ajax_referer( "delete-comment_$id" ); if ( !$comment = get_comment( $id ) ) die('0'); if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) die('-1'); - if ( wp_delete_comment( $comment->comment_ID ) ) - die('1'); - else die('0'); + if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) + $r = wp_set_comment_status( $comment->comment_ID, 'spam' ); + else + $r = wp_delete_comment( $comment->comment_ID ); + + die( $r ? '1' : '0' ); break; -case 'delete-comment-as-spam' : - if ( !$comment = get_comment( $id ) ) - die('0'); - if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) +case 'delete-cat' : + check_ajax_referer( "delete-category_$id" ); + if ( !current_user_can( 'manage_categories' ) ) die('-1'); - if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) ) + if ( wp_delete_category( $id ) ) die('1'); else die('0'); break; -case 'delete-cat' : +case 'delete-tag' : + check_ajax_referer( "delete-tag_$id" ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); - if ( wp_delete_category( $id ) ) + if ( wp_delete_term($id, 'post_tag')) die('1'); else die('0'); break; +case 'delete-link-cat' : + check_ajax_referer( "delete-link-category_$id" ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $cat_name = get_term_field('name', $id, 'link_category'); + + // Don't delete the default cats. + if ( $id == get_option('default_link_category') ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $id, + 'data' => new WP_Error( 'default-link-cat', sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name) ) + ) ); + $x->send(); + } + + $r = wp_delete_term($id, 'link_category'); + if ( !$r ) + die('0'); + if ( is_wp_error($r) ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $id, + 'data' => $r + ) ); + $x->send(); + } + die('1'); + break; case 'delete-link' : + check_ajax_referer( "delete-bookmark_$id" ); if ( !current_user_can( 'manage_links' ) ) die('-1'); @@ -64,6 +94,7 @@ case 'delete-link' : else die('0'); break; case 'delete-meta' : + check_ajax_referer( "delete-meta_$id" ); if ( !$meta = get_post_meta_by_id( $id ) ) die('0'); if ( !current_user_can( 'edit_post', $meta->post_id ) ) @@ -73,14 +104,17 @@ case 'delete-meta' : die('0'); break; case 'delete-post' : + check_ajax_referer( "{$action}_$id" ); if ( !current_user_can( 'delete_post', $id ) ) die('-1'); if ( wp_delete_post( $id ) ) die('1'); - else die('0'); + else + die('0'); break; case 'delete-page' : + check_ajax_referer( "{$action}_$id" ); if ( !current_user_can( 'delete_page', $id ) ) die('-1'); @@ -97,88 +131,223 @@ case 'dim-comment' : die('-1'); if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) { + check_ajax_referer( "approve-comment_$id" ); if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) die('1'); } else { + check_ajax_referer( "unapprove-comment_$id" ); if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) die('1'); } die('0'); break; case 'add-category' : // On the Fly + check_ajax_referer( $action ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); $names = explode(',', $_POST['newcat']); + if ( 0 > $parent = (int) $_POST['newcat_parent'] ) + $parent = 0; + $post_category = isset($_POST['post_category'])? (array) $_POST['post_category'] : array(); + $checked_categories = array_map( 'absint', (array) $post_category ); + $x = new WP_Ajax_Response(); foreach ( $names as $cat_name ) { $cat_name = trim($cat_name); - if ( !$category_nicename = sanitize_title($cat_name) ) - die('0'); - if ( !$cat_id = category_exists( $cat_name ) ) - $cat_id = wp_create_category( $cat_name ); - $cat_name = wp_specialchars(stripslashes($cat_name)); + $category_nicename = sanitize_title($cat_name); + if ( '' === $category_nicename ) + continue; + $cat_id = wp_create_category( $cat_name, $parent ); + $checked_categories[] = $cat_id; + if ( $parent ) // Do these all at once in a second + continue; + $category = get_category( $cat_id ); + ob_start(); + wp_category_checklist( 0, $cat_id, $checked_categories ); + $data = ob_get_contents(); + ob_end_clean(); $x->add( array( 'what' => 'category', 'id' => $cat_id, - 'data' => "
  4. " + 'data' => $data, + 'position' => -1 ) ); } + if ( $parent ) { // Foncy - replace the parent and all its children + $parent = get_category( $parent ); + ob_start(); + dropdown_categories( 0, $parent ); + $data = ob_get_contents(); + ob_end_clean(); + $x->add( array( + 'what' => 'category', + 'id' => $parent->term_id, + 'old_id' => $parent->term_id, + 'data' => $data, + 'position' => -1 + ) ); + + } $x->send(); break; case 'add-link-category' : // On the Fly + check_ajax_referer( $action ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); $names = explode(',', $_POST['newcat']); $x = new WP_Ajax_Response(); foreach ( $names as $cat_name ) { $cat_name = trim($cat_name); - if ( !$slug = sanitize_title($cat_name) ) - die('0'); + $slug = sanitize_title($cat_name); + if ( '' === $slug ) + continue; if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) { $cat_id = wp_insert_term( $cat_name, 'link_category' ); - $cat_id = $cat_id['term_id']; } + $cat_id = $cat_id['term_id']; $cat_name = wp_specialchars(stripslashes($cat_name)); $x->add( array( 'what' => 'link-category', 'id' => $cat_id, - 'data' => "" + 'data' => "", + 'position' => -1 ) ); } $x->send(); break; case 'add-cat' : // From Manage->Categories + check_ajax_referer( 'add-category' ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); - if ( !$cat = wp_insert_category( $_POST ) ) - die('0'); - if ( !$cat = get_category( $cat ) ) + + if ( '' === trim($_POST['cat_name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => new WP_Error( 'cat_name', __('You did not enter a category name.') ) + ) ); + $x->send(); + } + + if ( category_exists( trim( $_POST['cat_name'] ) ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.'), array( 'form-field' => 'cat_name' ) ), + ) ); + $x->send(); + } + + $cat = wp_insert_category( $_POST, true ); + + if ( is_wp_error($cat) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => $cat + ) ); + $x->send(); + } + + if ( !$cat || (!$cat = get_category( $cat )) ) die('0'); + $level = 0; - $cat_full_name = $cat->cat_name; + $cat_full_name = $cat->name; $_cat = $cat; - while ( $_cat->category_parent ) { - $_cat = get_category( $_cat->category_parent ); - $cat_full_name = $_cat->cat_name . ' — ' . $cat_full_name; + while ( $_cat->parent ) { + $_cat = get_category( $_cat->parent ); + $cat_full_name = $_cat->name . ' — ' . $cat_full_name; $level++; } $cat_full_name = attribute_escape($cat_full_name); $x = new WP_Ajax_Response( array( 'what' => 'cat', - 'id' => $cat->cat_ID, + 'id' => $cat->term_id, 'data' => _cat_row( $cat, $level, $cat_full_name ), - 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category %s added' ), "cat-$cat->cat_ID", $cat_full_name)) + 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category %s added' ), "cat-$cat->term_id", $cat_full_name)) + ) ); + $x->send(); + break; +case 'add-link-cat' : // From Blogroll -> Categories + check_ajax_referer( 'add-link-category' ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + if ( '' === trim($_POST['name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'link-cat', + 'id' => new WP_Error( 'name', __('You did not enter a category name.') ) + ) ); + $x->send(); + } + + $r = wp_insert_term($_POST['name'], 'link_category', $_POST ); + if ( is_wp_error( $r ) ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $r + ) ); + $x->send(); + } + + extract($r, EXTR_SKIP); + + if ( !$link_cat = link_cat_row( $term_id ) ) + die('0'); + + $x = new WP_Ajax_Response( array( + 'what' => 'link-cat', + 'id' => $term_id, + 'data' => $link_cat + ) ); + $x->send(); + break; +case 'add-tag' : // From Manage->Tags + check_ajax_referer( 'add-tag' ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + if ( '' === trim($_POST['name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => new WP_Error( 'name', __('You did not enter a tag name.') ) + ) ); + $x->send(); + } + + $tag = wp_insert_term($_POST['name'], 'post_tag', $_POST ); + + if ( is_wp_error($tag) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => $tag + ) ); + $x->send(); + } + + if ( !$tag || (!$tag = get_term( $tag['term_id'], 'post_tag' )) ) + die('0'); + + $tag_full_name = $tag->name; + $tag_full_name = attribute_escape($tag_full_name); + + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => $tag->term_id, + 'data' => _tag_row( $tag ), + 'supplemental' => array('name' => $tag_full_name, 'show-link' => sprintf(__( 'Tag %s added' ), "tag-$tag->term_id", $tag_full_name)) ) ); $x->send(); break; case 'add-comment' : + check_ajax_referer( $action ); if ( !current_user_can( 'edit_post', $id ) ) die('-1'); $search = isset($_POST['s']) ? $_POST['s'] : false; - $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25; + $start = isset($_POST['page']) ? intval($_POST['page']) * 25 - 1: 24; + $status = isset($_POST['comment_status']) ? $_POST['comment_status'] : false; + $mode = isset($_POST['mode']) ? $_POST['mode'] : 'detail'; - list($comments, $total) = _wp_get_comment_list( $search, $start, 1 ); + list($comments, $total) = _wp_get_comment_list( $status, $search, $start, 1 ); if ( !$comments ) die('1'); @@ -186,7 +355,7 @@ case 'add-comment' : foreach ( (array) $comments as $comment ) { get_comment( $comment ); ob_start(); - _wp_comment_list_item( $comment->comment_ID ); + _wp_comment_row( $comment->comment_ID, $mode, false ); $comment_list_item = ob_get_contents(); ob_end_clean(); $x->add( array( @@ -198,96 +367,140 @@ case 'add-comment' : $x->send(); break; case 'add-meta' : - if ( !current_user_can( 'edit_post', $id ) ) - die('-1'); - if ( $id < 0 ) { - $now = current_time('timestamp', 1); - if ( $pid = wp_insert_post( array( - 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) - ) ) ) { - if ( is_wp_error( $pid ) ) - return $pid; - $mid = add_meta( $pid ); - } - else + check_ajax_referer( 'add-meta' ); + $c = 0; + $pid = (int) $_POST['post_id']; + if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) { + if ( !current_user_can( 'edit_post', $pid ) ) + die('-1'); + if ( '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) + die('1'); + if ( $pid < 0 ) { + $now = current_time('timestamp', 1); + if ( $pid = wp_insert_post( array( + 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) + ) ) ) { + if ( is_wp_error( $pid ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'data' => $pid + ) ); + $x->send(); + } + $mid = add_meta( $pid ); + } else { + die('0'); + } + } else if ( !$mid = add_meta( $pid ) ) { die('0'); - } else if ( !$mid = add_meta( $id ) ) { - die('0'); - } - - $meta = get_post_meta_by_id( $mid ); - $key = $meta->meta_key; - $value = $meta->meta_value; - $pid = (int) $meta->post_id; + } - $x = new WP_Ajax_Response( array( - 'what' => 'meta', - 'id' => $mid, - 'data' => wp_ajax_meta_row( $pid, $mid, $key, $value ), - 'supplemental' => array('postid' => $pid) - ) ); - $x->send(); - break; -case 'update-meta' : - $mid = (int) array_pop(array_keys($_POST['meta'])); - $key = $_POST['meta'][$mid]['key']; - $value = $_POST['meta'][$mid]['value']; - if ( !$meta = get_post_meta_by_id( $mid ) ) - die('0'); // if meta doesn't exist - if ( !current_user_can( 'edit_post', $meta->post_id ) ) - die('-1'); - if ( $u = update_meta( $mid, $key, $value ) ) { + $meta = get_post_meta_by_id( $mid ); + $pid = (int) $meta->post_id; + $meta = get_object_vars( $meta ); + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'id' => $mid, + 'data' => _list_meta_row( $meta, $c ), + 'position' => 1, + 'supplemental' => array('postid' => $pid) + ) ); + } else { + $mid = (int) array_pop(array_keys($_POST['meta'])); + $key = $_POST['meta'][$mid]['key']; + $value = $_POST['meta'][$mid]['value']; + if ( !$meta = get_post_meta_by_id( $mid ) ) + die('0'); // if meta doesn't exist + if ( !current_user_can( 'edit_post', $meta->post_id ) ) + die('-1'); + if ( !$u = update_meta( $mid, $key, $value ) ) + die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). $key = stripslashes($key); $value = stripslashes($value); $x = new WP_Ajax_Response( array( 'what' => 'meta', - 'id' => $mid, - 'data' => wp_ajax_meta_row( $meta->post_id, $mid, $key, $value ), + 'id' => $mid, 'old_id' => $mid, + 'data' => _list_meta_row( array( + 'meta_key' => $key, + 'meta_value' => $value, + 'meta_id' => $mid + ), $c ), + 'position' => 0, 'supplemental' => array('postid' => $meta->post_id) ) ); - $x->send(); } - die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). + $x->send(); break; case 'add-user' : - if ( !current_user_can('edit_users') ) + check_ajax_referer( $action ); + if ( !current_user_can('create_users') ) die('-1'); require_once(ABSPATH . WPINC . '/registration.php'); if ( !$user_id = add_user() ) die('0'); elseif ( is_wp_error( $user_id ) ) { - foreach( $user_id->get_error_messages() as $message ) - echo "

    $message

    "; - exit; + $x = new WP_Ajax_Response( array( + 'what' => 'user', + 'id' => $user_id + ) ); + $x->send(); } $user_object = new WP_User( $user_id ); + $x = new WP_Ajax_Response( array( 'what' => 'user', 'id' => $user_id, - 'data' => user_row( $user_object ), - 'supplemental' => array('show-link' => sprintf(__( 'User %s added' ), "user-$user_id", $user_object->user_login)) + 'data' => user_row( $user_object, '', $user_object->roles[0] ), + 'supplemental' => array( + 'show-link' => sprintf(__( 'User %s added' ), "user-$user_id", $user_object->user_login), + 'role' => $user_object->roles[0] + ) ) ); $x->send(); break; case 'autosave' : // The name of this action is hardcoded in edit_post() - $_POST['post_content'] = $_POST['content']; - $_POST['post_excerpt'] = $_POST['excerpt']; + $nonce_age = check_ajax_referer( 'autosave', 'autosavenonce'); + global $current_user; + $_POST['post_status'] = 'draft'; $_POST['post_category'] = explode(",", $_POST['catslist']); + $_POST['tags_input'] = explode(",", $_POST['tags_input']); if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) unset($_POST['post_category']); + $do_autosave = (bool) $_POST['autosave']; + $do_lock = true; + + $data = ''; + $message = sprintf( __('Draft Saved at %s.'), date( __('g:i:s a'), current_time( 'timestamp', true ) ) ); + + $supplemental = array(); + + $id = 0; if($_POST['post_ID'] < 0) { $_POST['temp_ID'] = $_POST['post_ID']; - $id = wp_write_post(); - if( is_wp_error($id) ) - die($id->get_error_message()); - else - die("$id"); + if ( $do_autosave ) { + $id = wp_write_post(); + $data = $message; + } } else { $post_ID = (int) $_POST['post_ID']; $_POST['ID'] = $post_ID; $post = get_post($post_ID); + + if ( $last = wp_check_post_lock( $post->ID ) ) { + $do_autosave = $do_lock = false; + + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); + $data = new WP_Error( 'locked', sprintf( + $_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ), + wp_specialchars( $last_user_name ) + ) ); + + $supplemental['disable_autosave'] = 'disable'; + } + if ( 'page' == $post->post_type ) { if ( !current_user_can('edit_page', $post_ID) ) die(__('You are not allowed to edit this page.')); @@ -295,11 +508,40 @@ case 'autosave' : // The name of this action is hardcoded in edit_post() if ( !current_user_can('edit_post', $post_ID) ) die(__('You are not allowed to edit this post.')); } - wp_update_post($_POST); + if ( $do_autosave ) { + $id = edit_post(); + $data = $message; + } else { + $id = $post->ID; + } } - die('0'); -break; + + if ( $do_lock && $id && is_numeric($id) ) + wp_set_post_lock( $id ); + + if ( $nonce_age == 2 ) { + $supplemental['replace-autosavenonce'] = wp_create_nonce('autosave'); + $supplemental['replace-getpermalinknonce'] = wp_create_nonce('getpermalink'); + $supplemental['replace-samplepermalinknonce'] = wp_create_nonce('samplepermalink'); + $supplemental['replace-closedpostboxesnonce'] = wp_create_nonce('closedpostboxes'); + if ( $id ) { + if ( $_POST['post_type'] == 'post' ) + $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id); + elseif ( $_POST['post_type'] == 'page' ) + $supplemental['replace-_wpnonce'] = wp_create_nonce('update-page_' . $id); + } + } + + $x = new WP_Ajax_Response( array( + 'what' => 'autosave', + 'id' => $id, + 'data' => $id ? $data : '', + 'supplemental' => $supplemental + ) ); + $x->send(); + break; case 'autosave-generate-nonces' : + check_ajax_referer( 'autosave', 'autosavenonce' ); $ID = (int) $_POST['post_ID']; if($_POST['post_type'] == 'post') { if(current_user_can('edit_post', $ID)) @@ -312,6 +554,30 @@ case 'autosave-generate-nonces' : } die('0'); break; +case 'closed-postboxes' : + check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); + $closed = isset( $_POST['closed'] )? $_POST['closed'] : ''; + $closed = explode( ',', $_POST['closed'] ); + $page = isset( $_POST['page'] )? $_POST['page'] : ''; + if ( !preg_match( '/^[a-z-]+$/', $page ) ) { + die(-1); + } + if (!is_array($closed)) break; + $current_user = wp_get_current_user(); + update_usermeta($current_user->ID, 'closedpostboxes_'.$page, $closed); +break; +case 'get-permalink': + check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); + $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; + die(add_query_arg(array('preview' => 'true'), get_permalink($post_id))); +break; +case 'sample-permalink': + check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); + $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; + $title = isset($_POST['new_title'])? $_POST['new_title'] : ''; + $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : ''; + die(get_sample_permalink_html($post_id, $title, $slug)); +break; default : do_action( 'wp_ajax_' . $_POST['action'] ); die('0'); diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index a96770b5..d5f129f3 100644 --- a/wp-admin/admin-footer.php +++ b/wp-admin/admin-footer.php @@ -1,10 +1,11 @@ - + + +

    diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 04b1b364..4a0d327b 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1,4 +1,5 @@ \ No newline at end of file +?> diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index a75fe7bb..0185a986 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -2,13 +2,23 @@ @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); if (!isset($_GET["page"])) require_once('admin.php'); if ( $editing ) { - wp_enqueue_script( array('dbx-admin-key?pagenow=' . attribute_escape($pagenow),'admin-custom-fields') ); - if ( current_user_can('manage_categories') ) - wp_enqueue_script( 'ajaxcat' ); if ( user_can_richedit() ) wp_enqueue_script( 'wp_tiny_mce' ); } +$min_width_pages = array( 'post.php', 'post-new.php', 'page.php', 'page-new.php', 'widgets.php', 'comment.php', 'link.php' ); +$the_current_page = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']); +$ie6_no_scrollbar = true; + +function add_minwidth($c) { + return $c . 'minwidth '; +} + +if ( in_array( $the_current_page, $min_width_pages ) ) { + $ie6_no_scrollbar = false; + add_filter( 'admin_body_class', 'add_minwidth' ); +} + get_admin_page_title(); ?> @@ -17,13 +27,21 @@ get_admin_page_title(); <?php bloginfo('name') ?> › <?php echo wp_specialchars( strip_tags( $title ) ); ?> — WordPress - + + - + +
    +
    -

    %s.'), $user_identity) ?> [, ]

    +

    %2$s!'), 'profile.php', $user_identity) ?> | | Help') ?> | Forums') ?>

    +
    diff --git a/wp-admin/admin.php b/wp-admin/admin.php index 0a6f22ae..16648207 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -19,8 +19,6 @@ nocache_headers(); update_category_cache(); -wp_get_current_user(); - $posts_per_page = get_option('posts_per_page'); $what_to_show = get_option('what_to_show'); $date_format = get_option('date_format'); @@ -28,7 +26,11 @@ $time_format = get_option('time_format'); wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback')); -wp_enqueue_script( 'fat' ); +wp_admin_css_color('classic', __('Classic'), get_option( 'siteurl' ) . "/wp-admin/css/colors-classic.css", array('#07273E', '#14568A', '#D54E21', '#2683AE')); +wp_admin_css_color('fresh', __('Fresh'), get_option( 'siteurl' ) . "/wp-admin/css/colors-fresh.css", array('#464646', '#CEE1EF', '#D54E21', '#2683AE')); + +wp_enqueue_script( 'common' ); +wp_enqueue_script( 'jquery-color' ); $editing = false; @@ -39,6 +41,8 @@ if (isset($_GET['page'])) { require(ABSPATH . 'wp-admin/menu.php'); +do_action('admin_init'); + // Handle plugin admin pages. if (isset($plugin_page)) { $page_hook = get_plugin_page_hook($plugin_page, $pagenow); @@ -54,7 +58,7 @@ if (isset($plugin_page)) { wp_die(__('Invalid plugin page')); } - if (! file_exists(ABSPATH . PLUGINDIR . "/$plugin_page")) + if (! ( file_exists(ABSPATH . PLUGINDIR . "/$plugin_page") && is_file( ABSPATH . PLUGINDIR . "/$plugin_page") ) ) wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); do_action('load-' . $plugin_page); diff --git a/wp-admin/async-upload.php b/wp-admin/async-upload.php new file mode 100644 index 00000000..1a37dceb --- /dev/null +++ b/wp-admin/async-upload.php @@ -0,0 +1,45 @@ +'.wp_specialchars($id->get_error_message()).'
    '; + exit; +} + +if ( $_REQUEST['short'] ) { + // short form response - attachment ID only + echo $id; +} +else { + // long form response - big chunk o html + $type = $_REQUEST['type']; + echo apply_filters("async_upload_{$type}", $id); +} + +?> diff --git a/wp-admin/bookmarklet.php b/wp-admin/bookmarklet.php index fca99e1f..8618458d 100644 --- a/wp-admin/bookmarklet.php +++ b/wp-admin/bookmarklet.php @@ -51,7 +51,10 @@ if ( !empty($content) ) { <?php bloginfo('name') ?> › Bookmarklet — WordPress - + '; if ($post_id = post_exists($post_title, $post_content, $post_date)) { - printf(__('Post %s already exists.'), stripslashes($post_title)); + printf(__('Post %s already exists.'), stripslashes($post_title)); } else { - printf(__('Importing post %s...'), stripslashes($post_title)); + printf(__('Importing post %s...'), stripslashes($post_title)); $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); $post_id = wp_insert_post($postdata); if ( is_wp_error( $post_id ) ) { @@ -141,7 +141,7 @@ class BW_Import { } if ( $num_comments ) { echo ' '; - printf(__('(%s comments)'), $num_comments); + printf( __ngettext('%s comment', '%s comments', $num_comments), $num_comments ); } echo ''; flush(); @@ -162,7 +162,7 @@ class BW_Import { if ( is_wp_error( $result ) ) return $result; wp_import_cleanup($file['id']); - + do_action('import_done', 'blogware'); echo '

    '; printf(__('All done. Have fun!'), get_option('home')); echo '

    '; @@ -197,5 +197,5 @@ class BW_Import { $blogware_import = new BW_Import(); -register_importer('blogware', __('Blogware'), __('Import posts from Blogware'), array ($blogware_import, 'dispatch')); +register_importer('blogware', __('Blogware'), __('Import posts from Blogware.'), array ($blogware_import, 'dispatch')); ?> diff --git a/wp-admin/import/btt.php b/wp-admin/import/btt.php index 76a02c32..4bd884c8 100644 --- a/wp-admin/import/btt.php +++ b/wp-admin/import/btt.php @@ -14,13 +14,13 @@ class BunnyTags_Import { function greet() { echo '
    '; - echo '

    '.__('Howdy! This imports tags from an existing Bunny’s Technorati Tags installation into this blog using the new WordPress native tagging structure.').'

    '; + echo '

    '.__('Howdy! This imports tags from Bunny’s Technorati Tags into WordPress tags.').'

    '; echo '

    '.__('This is suitable for Bunny’s Technorati Tags version 0.6.').'

    '; echo '

    '.__('All existing Bunny’s Technorati Tags will be removed after import.').'

    '; echo '

    '.__('Don’t be stupid - backup your database before proceeding!').'

    '; echo '
    '; wp_nonce_field('import-btt'); - echo '

    '; + echo '

    '; echo '
    '; echo '
    '; } @@ -29,7 +29,7 @@ class BunnyTags_Import { if ( empty($_GET['step']) ) $step = 0; else - $step = abs(intval($_GET['step'])); + $step = absint($_GET['step']); // load the header $this->header(); @@ -61,14 +61,14 @@ class BunnyTags_Import { echo '
    '; echo '

    '.__('Reading Bunny’s Technorati Tags…').'

    '; - // import Bunny's Keywords tags + // import Bunny's Keywords tags $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'"); if ( !is_array($metakeys)) { echo '

    ' . __('No Tags Found!') . '

    '; return false; } else { $count = count($metakeys); - echo '

    ' . sprintf( __('Done! %s posts with tags were read.'), $count ) . '

    '; + echo '

    ' . sprintf( __ngettext('Done! %s post with tags were read.', 'Done! %s posts with tags were read.', $count), $count ) . '

    '; echo '
      '; foreach ( $metakeys as $post_meta ) { if ( $post_meta->meta_value != '' ) { @@ -90,7 +90,7 @@ class BunnyTags_Import { echo '
      '; wp_nonce_field('import-btt'); - echo '

      '; + echo '

      '; echo '
      '; echo '
    '; } @@ -110,6 +110,6 @@ class BunnyTags_Import { $btt_import = new BunnyTags_Import(); // add it to the import page! -register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into the new native tagging structure.'), array($btt_import, 'dispatch')); +register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into WordPress tags.'), array($btt_import, 'dispatch')); ?> diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php index 1bf04860..16df934f 100644 --- a/wp-admin/import/dotclear.php +++ b/wp-admin/import/dotclear.php @@ -128,7 +128,7 @@ class Dotclear_Import { echo '
    '; wp_nonce_field('import-dotclear'); $this->db_form(); - echo '

    '; + echo '

    '; echo '
    '; } @@ -225,7 +225,7 @@ class Dotclear_Import { // Store category translation for future use add_option('dccat2wpcat',$dccat2wpcat); - echo '

    '.sprintf(__('Done! %1$s categories imported.'), $count).'

    '; + echo '

    '.sprintf(__ngettext('Done! %1$s category imported.', 'Done! %1$s categories imported.', $count), $count).'

    '; return true; } echo __('No Categories to Import!'); @@ -526,7 +526,7 @@ class Dotclear_Import { } add_option('dclinks2wplinks',$dclinks2wplinks); echo '

    '; - printf(__('Done! %s links or link categories imported'), $count); + printf(__ngettext('Done! %s link or link category imported.', 'Done! %s links or link categories imported.', $count), $count); echo '

    '; return true; } @@ -615,6 +615,7 @@ class Dotclear_Import { delete_option('dcname'); delete_option('dchost'); delete_option('dccharset'); + do_action('import_done', 'dotclear'); $this->tips(); } @@ -639,7 +640,7 @@ class Dotclear_Import { function db_form() { - echo ''; + echo '
    '; printf('', __('DotClear Database User:')); printf('', __('DotClear Database Password:')); printf('', __('DotClear Database Name:')); @@ -741,5 +742,5 @@ class Dotclear_Import { } $dc_import = new Dotclear_Import(); -register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog'), array ($dc_import, 'dispatch')); +register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog.'), array ($dc_import, 'dispatch')); ?> diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php index 6e92235d..92abc48b 100644 --- a/wp-admin/import/greymatter.php +++ b/wp-admin/import/greymatter.php @@ -36,7 +36,7 @@ class GM_Import {

    -

    +
    @@ -46,17 +46,14 @@ class GM_Import { - - - - +

    so you need to enter the number of the last GM post here.
    (if you don't know that number, just log into your FTP and look it out
    in the entries' folder)") ?>

    + so you need to enter the number of the last GM post here.
    (if you don't know that number, just log into your FTP and look it out
    in the entries' folder)") ?>

    -

    +

    -

     

    footer(); } @@ -272,17 +269,18 @@ class GM_Import { } if ($numAddedComments > 0) { echo ': '; - printf(__('imported %d comment(s)'), $numAddedComments); + printf( __ngettext('imported %s comment', 'imported %s comments', $numAddedComments) , $numAddedComments); } $preExisting = $numComments - numAddedComments; if ($preExisting > 0) { echo ' '; - printf(__('ignored %d pre-existing comments'), $preExisting); + printf( __ngettext( 'ignored %s pre-existing comment', 'ignored %s pre-existing comments', $preExisting ) , $preExisting); } } echo '... '.__('Done').''; } } + do_action('import_done', 'greymatter'); ?>

     

    @@ -318,5 +316,5 @@ class GM_Import { $gm_import = new GM_Import(); -register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog'), array ($gm_import, 'dispatch')); +register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog.'), array ($gm_import, 'dispatch')); ?> diff --git a/wp-admin/import/jkw.php b/wp-admin/import/jkw.php index 9f7b48ee..1bb0ad6d 100644 --- a/wp-admin/import/jkw.php +++ b/wp-admin/import/jkw.php @@ -14,17 +14,17 @@ class JeromesKeyword_Import { function greet() { echo '
    '; - echo '

    '.__('Howdy! This imports tags from an existing Jerome’s Keywords installation into this blog using the new WordPress native tagging structure.').'

    '; + echo '

    '.__('Howdy! This imports tags from Jerome’s Keywords into WordPress tags.').'

    '; echo '

    '.__('This is suitable for Jerome’s Keywords version 1.x and 2.0a.').'

    '; echo '

    '.__('All existing Jerome’s Keywords will be removed after import.').'

    '; echo '

    '.__('Don’t be stupid - backup your database before proceeding!').'

    '; echo '
    '; wp_nonce_field('import-jkw'); - echo '

    '; + echo '

    '; echo '
    '; echo '
    '; wp_nonce_field('import-jkw'); - echo '

    '; + echo '

    '; echo '
    '; echo '
    '; } @@ -33,7 +33,7 @@ class JeromesKeyword_Import { if ( empty($_GET['step']) ) $step = 0; else - $step = abs(intval($_GET['step'])); + $step = absint($_GET['step']); // load the header $this->header(); @@ -77,14 +77,14 @@ class JeromesKeyword_Import { echo '
    '; echo '

    '.__('Reading Jerome’s Keywords Tags…').'

    '; - // import Jerome's Keywords tags + // import Jerome's Keywords tags $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'keywords'"); if ( !is_array($metakeys)) { echo '

    ' . __('No Tags Found!') . '

    '; return false; } else { $count = count($metakeys); - echo '

    ' . sprintf( __('Done! %s posts with tags were read.'), $count ) . '

    '; + echo '

    ' . sprintf( __ngettext('Done! %s post with tags were read.', 'Done! %s posts with tags were read.', $count), $count ) . '

    '; echo '
      '; foreach ( $metakeys as $post_meta ) { if ( $post_meta->meta_value != '' ) { @@ -106,7 +106,7 @@ class JeromesKeyword_Import { echo '
      '; wp_nonce_field('import-jkw'); - echo '

      '; + echo '

      '; echo '
      '; echo '
    '; } @@ -117,7 +117,7 @@ class JeromesKeyword_Import { echo '
    '; echo '

    '.__('Reading Jerome’s Keywords Tags…').'

    '; - // import Jerome's Keywords tags + // import Jerome's Keywords tags $tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1); $metakeys = $wpdb->get_results("SELECT post_id, tag_name FROM $tablename"); if ( !is_array($metakeys) ) { @@ -125,7 +125,7 @@ class JeromesKeyword_Import { return false; } else { $count = count($metakeys); - echo '

    ' . sprintf( __('Done! %s tags were read.'), $count ) . '

    '; + echo '

    ' . sprintf( __ngettext('Done! %s tag were read.', 'Done! %s tags were read.', $count), $count ) . '

    '; echo '
      '; foreach ( $metakeys as $post_meta ) { $keyword = addslashes(trim($post_meta->tag_name)); @@ -139,7 +139,7 @@ class JeromesKeyword_Import { } echo '
      '; wp_nonce_field('import-jkw'); - echo '

      '; + echo '

      '; echo '
      '; echo '
    '; } @@ -173,6 +173,6 @@ class JeromesKeyword_Import { $jkw_import = new JeromesKeyword_Import(); // add it to the import page! -register_importer('jkw', 'Jerome’s Keywords', __('Import Jerome’s Keywords into the new native tagging structure.'), array($jkw_import, 'dispatch')); +register_importer('jkw', 'Jerome’s Keywords', __('Import Jerome’s Keywords into WordPress tags.'), array($jkw_import, 'dispatch')); ?> diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php index 81f0365a..bd8394ed 100644 --- a/wp-admin/import/livejournal.php +++ b/wp-admin/import/livejournal.php @@ -66,9 +66,9 @@ class LJ_Import { echo '
  5. '; if ($post_id = post_exists($post_title, $post_content, $post_date)) { - printf(__('Post %s already exists.'), stripslashes($post_title)); + printf(__('Post %s already exists.'), stripslashes($post_title)); } else { - printf(__('Importing post %s...'), stripslashes($post_title)); + printf(__('Importing post %s...'), stripslashes($post_title)); $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); $post_id = wp_insert_post($postdata); if ( is_wp_error( $post_id ) ) @@ -119,7 +119,7 @@ class LJ_Import { } if ( $num_comments ) { echo ' '; - printf(__('(%s comments)'), $num_comments); + printf(__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); } echo '
  6. '; } @@ -138,6 +138,7 @@ class LJ_Import { if ( is_wp_error( $result ) ) return $result; wp_import_cleanup($file['id']); + do_action('import_done', 'livejournal'); echo '

    '; printf(__('All done. Have fun!'), get_option('home')); @@ -174,5 +175,5 @@ class LJ_Import { $livejournal_import = new LJ_Import(); -register_importer('livejournal', __('LiveJournal'), __('Import posts from a LiveJournal XML export file'), array ($livejournal_import, 'dispatch')); +register_importer('livejournal', __('LiveJournal'), __('Import posts from a LiveJournal XML export file.'), array ($livejournal_import, 'dispatch')); ?> diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php index d18ef464..6ab2f79c 100644 --- a/wp-admin/import/mt.php +++ b/wp-admin/import/mt.php @@ -23,14 +23,16 @@ class MT_Import { ?>

    mt-export.txt in your /wp-content/ directory and then click "Import mt-export.txt"'); ?>

    +
    +

    mt-export.txt in your /wp-content/ directory'); ?>

    - +

    out of memory error try splitting up the import file into pieces.'); ?>

    @@ -61,7 +63,7 @@ class MT_Import { function checkauthor($author) { global $wpdb; //mtnames is an array with the names in the mt import file - $pass = 'changeme'; + $pass = wp_generate_password(); if (!(in_array($author, $this->mtnames))) { //a new mt author name is found ++ $this->j; $this->mtnames[$this->j] = $author; //add that new mt author name to an array @@ -152,8 +154,8 @@ class MT_Import {

    -

    italics. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?>

    -

    +

    italics. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?>

    +

    post_title, '', $post->post_date) ) { echo '
  7. '; - printf(__('Post %s already exists.'), stripslashes($post->post_title)); + printf(__('Post %s already exists.'), stripslashes($post->post_title)); } else { echo '
  8. '; - printf(__('Importing post %s...'), stripslashes($post->post_title)); + printf(__('Importing post %s...'), stripslashes($post->post_title)); if ( '' != trim( $post->extended ) ) $post->post_content .= "\n\n$post->extended"; $post->post_author = $this->checkauthor($post->post_author); //just so that if a post already exists, new users are not created by checkauthor $post_id = wp_insert_post($post); - if ( is_wp_error( $post_id ) ) + if ( is_wp_error( $post_id ) ) return $post_id; // Add categories. if ( 0 != count($post->categories) ) { wp_create_categories($post->categories, $post_id); } + + // Add tags or keywords + if ( 1 < strlen($post->post_keywords) ) { + // Keywords exist. + printf(__('
    Adding tags %s...'), stripslashes($post->post_keywords)); + wp_add_post_tags($post_id, $post->post_keywords); + } } $num_comments = 0; @@ -238,7 +247,7 @@ class MT_Import { } if ( $num_comments ) - printf(' '.__('(%s comments)'), $num_comments); + printf(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); $num_pings = 0; foreach ( $pings as $ping ) { @@ -255,7 +264,7 @@ class MT_Import { } if ( $num_pings ) - printf(' '.__('(%s pings)'), $num_pings); + printf(' '.__ngettext('(%s ping)', '(%s pings)', $num_pings), $num_pings); echo "
  9. "; //ob_flush();flush(); @@ -294,7 +303,7 @@ class MT_Import { // Finishing a post. $context = ''; $result = $this->save_post($post, $comments, $pings); - if ( is_wp_error( $result ) ) + if ( is_wp_error( $result ) ) return $result; $post = new StdClass; $comment = new StdClass(); @@ -326,7 +335,7 @@ class MT_Import { else if ( 'ping' == $context ) $ping->title = $title; } else if ( 0 === strpos($line, "STATUS:") ) { - $status = trim( substr($line, strlen("STATUS:")) ); + $status = trim( strtolower( substr($line, strlen("STATUS:")) ) ); if ( empty($status) ) $status = 'publish'; $post->post_status = $status; @@ -396,6 +405,8 @@ class MT_Import { $post->extended .= $line; } else if ( 'excerpt' == $context ) { $post->post_excerpt .= $line; + } else if ( 'keywords' == $context ) { + $post->post_keywords .= $line; } else if ( 'comment' == $context ) { $comment->comment_content .= $line; } else if ( 'ping' == $context ) { @@ -420,7 +431,7 @@ class MT_Import { $this->file = get_attached_file($this->id); $this->get_authors_from_post(); $result = $this->process_posts(); - if ( is_wp_error( $result ) ) + if ( is_wp_error( $result ) ) return $result; } @@ -454,5 +465,5 @@ class MT_Import { $mt_import = new MT_Import(); -register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or Typepad blog'), array ($mt_import, 'dispatch')); +register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or Typepad blog.'), array ($mt_import, 'dispatch')); ?> diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php index 11fc7702..60a44900 100644 --- a/wp-admin/import/rss.php +++ b/wp-admin/import/rss.php @@ -71,7 +71,7 @@ class RSS_Import { $cat_index++; } - preg_match('|(.*?)|is', $post, $guid); + preg_match('|(.*?)|is', $post, $guid); if ($guid) $guid = $wpdb->escape(trim($guid[1])); else @@ -141,6 +141,7 @@ class RSS_Import { if ( is_wp_error( $result ) ) return $result; wp_import_cleanup($file['id']); + do_action('import_done', 'rss'); echo '

    '; printf(__('All done. Have fun!'), get_option('home')); @@ -177,5 +178,5 @@ class RSS_Import { $rss_import = new RSS_Import(); -register_importer('rss', __('RSS'), __('Import posts from an RSS feed'), array ($rss_import, 'dispatch')); +register_importer('rss', __('RSS'), __('Import posts from an RSS feed.'), array ($rss_import, 'dispatch')); ?> diff --git a/wp-admin/import/stp.php b/wp-admin/import/stp.php index 9d5371cf..53b339a0 100644 --- a/wp-admin/import/stp.php +++ b/wp-admin/import/stp.php @@ -12,13 +12,13 @@ class STP_Import { function greet() { echo '
    '; - echo '

    '.__('Howdy! This imports tags from an existing Simple Tagging 1.6.2 installation into this blog using the new WordPress native tagging structure.').'

    '; + echo '

    '.__('Howdy! This imports tags from Simple Tagging 1.6.2 into WordPress tags.').'

    '; echo '

    '.__('This has not been tested on any other versions of Simple Tagging. Mileage may vary.').'

    '; echo '

    '.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 4-step program to help you kick that nasty Simple Tagging habit. Just keep clicking along and we will let you know when you are in the clear!').'

    '; echo '

    '.__('Don’t be stupid - backup your database before proceeding!').'

    '; echo '
    '; wp_nonce_field('import-stp'); - echo '

    '; + echo '

    '; echo '
    '; echo '
    '; } @@ -70,15 +70,15 @@ class STP_Import { if ( get_option('stpimp_posts') ) { delete_option('stpimp_posts'); } - + add_option('stpimp_posts', $posts); $count = count($posts); - echo '

    ' . sprintf( __('Done! %s tag to post relationships were read.'), $count ) . '

    '; + echo '

    ' . sprintf( __ngettext('Done! %s tag to post relationships were read.', 'Done! %s tags to post relationships were read.', $count), $count ) . '

    '; } echo '
    '; wp_nonce_field('import-stp'); - echo '

    '; + echo '

    '; echo '
    '; echo '

    '; } @@ -87,14 +87,14 @@ class STP_Import { function import_t2p ( ) { echo '
    '; echo '

    '.__('Adding Tags to Posts…').'

    '; - + // run that funky magic! $tags_added = $this->tag2post(); - - echo '

    ' . sprintf( __('Done! %s tags where added!'), $tags_added ) . '

    '; + + echo '

    ' . sprintf( __ngettext('Done! %s tag was added!', 'Done! %s tags were added!', $tags_added), $tags_added ) . '

    '; echo '
    '; wp_nonce_field('import-stp'); - echo '

    '; + echo '

    '; echo '
    '; echo '
    '; } @@ -151,5 +151,5 @@ class STP_Import { $stp_import = new STP_Import(); // add it to the import page! -register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into the new native tagging structure.'), array($stp_import, 'dispatch')); -?> \ No newline at end of file +register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into WordPress tags.'), array($stp_import, 'dispatch')); +?> diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php index 1fe54c8c..1c10015f 100644 --- a/wp-admin/import/textpattern.php +++ b/wp-admin/import/textpattern.php @@ -46,7 +46,7 @@ class Textpattern_Import { echo '
    '; wp_nonce_field('import-textpattern'); $this->db_form(); - echo '

    '; + echo '

    '; echo '
    '; echo '
    '; } @@ -177,7 +177,7 @@ class Textpattern_Import { // Store category translation for future use add_option('txpcat2wpcat',$txpcat2wpcat); - echo '

    '.sprintf(__('Done! %1$s categories imported.'), $count).'

    '; + echo '

    '.sprintf(__ngettext('Done! %1$s category imported.', 'Done! %1$s categories imported.', $count), $count).'

    '; return true; } echo __('No Categories to Import!'); @@ -462,7 +462,7 @@ class Textpattern_Import { } add_option('txplinks2wplinks',$txplinks2wplinks); echo '

    '; - printf(__('Done! %s Links imported'), $count); + printf(__ngettext('Done! %s link imported', 'Done! %s links imported', $count), $count); echo '

    '; return true; } @@ -481,7 +481,7 @@ class Textpattern_Import { echo '
    '; wp_nonce_field('import-textpattern'); - printf('', attribute_escape(__('Import Users'))); + printf('', attribute_escape(__('Import Users'))); echo '
    '; } @@ -494,7 +494,7 @@ class Textpattern_Import { echo '
    '; wp_nonce_field('import-textpattern'); - printf('', attribute_escape(__('Import Posts'))); + printf('', attribute_escape(__('Import Posts'))); echo '
    '; } @@ -508,7 +508,7 @@ class Textpattern_Import { echo '
    '; wp_nonce_field('import-textpattern'); - printf('', attribute_escape(__('Import Comments'))); + printf('', attribute_escape(__('Import Comments'))); echo '
    '; } @@ -520,7 +520,7 @@ class Textpattern_Import { echo '
    '; wp_nonce_field('import-textpattern'); - printf('', attribute_escape(__('Import Links'))); + printf('', attribute_escape(__('Import Links'))); echo '
    '; } @@ -533,7 +533,7 @@ class Textpattern_Import { echo '
    '; wp_nonce_field('import-textpattern'); - printf('', attribute_escape(__('Finish'))); + printf('', attribute_escape(__('Finish'))); echo '
    '; } @@ -550,6 +550,7 @@ class Textpattern_Import { delete_option('txppass'); delete_option('txpname'); delete_option('txphost'); + do_action('import_done', 'textpattern'); $this->tips(); } @@ -574,7 +575,7 @@ class Textpattern_Import { function db_form() { - echo ''; + echo '
    '; printf('', __('Textpattern Database User:')); printf('', __('Textpattern Database Password:')); printf('', __('Textpattern Database Name:')); @@ -645,7 +646,7 @@ class Textpattern_Import { break; case 3 : $result = $this->import_posts(); - if ( is_wp_error( $result ) ) + if ( is_wp_error( $result ) ) echo $result->get_error_message(); break; case 4 : @@ -669,5 +670,5 @@ class Textpattern_Import { } $txp_import = new Textpattern_Import(); -register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog'), array ($txp_import, 'dispatch')); +register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog.'), array ($txp_import, 'dispatch')); ?> diff --git a/wp-admin/import/utw.php b/wp-admin/import/utw.php index 120f50cb..759809ec 100644 --- a/wp-admin/import/utw.php +++ b/wp-admin/import/utw.php @@ -14,12 +14,12 @@ class UTW_Import { function greet() { echo '
    '; - echo '

    '.__('Howdy! This imports tags from an existing Ultimate Tag Warrior 3 installation into this blog using the new WordPress native tagging structure.').'

    '; + echo '

    '.__('Howdy! This imports tags from Ultimate Tag Warrior 3 into WordPress tags.').'

    '; echo '

    '.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'

    '; echo '

    '.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'

    '; echo '

    '.__('Don’t be stupid - backup your database before proceeding!').'

    '; echo '
    '; - echo '

    '; + echo '

    '; echo ''; echo '
    '; } @@ -84,7 +84,7 @@ class UTW_Import { $count = count($tags); - echo '

    ' . sprintf( __('Done! %s tags were read.'), $count ) . '

    '; + echo '

    ' . sprintf( __ngettext('Done! %s tag were read.', 'Done! %s tags were read.', $count), $count ) . '

    '; echo '

    ' . __('The following tags were found:') . '

    '; echo '
      '; @@ -106,7 +106,7 @@ class UTW_Import { echo '
      '; wp_nonce_field('import-utw'); - echo '

      '; + echo '

      '; echo ''; echo ''; } @@ -136,13 +136,13 @@ class UTW_Import { $count = count($posts); - echo '

      ' . sprintf( __('Done! %s tag to post relationships were read.'), $count ) . '

      '; + echo '

      ' . sprintf( __ngettext('Done! %s tag to post relationships were read.', 'Done! %s tags to post relationships were read.', $count), $count ) . '

      '; } echo '
      '; wp_nonce_field('import-utw'); - echo '

      '; + echo '

      '; echo ''; echo ''; @@ -157,11 +157,11 @@ class UTW_Import { // run that funky magic! $tags_added = $this->tag2post(); - echo '

      ' . sprintf( __('Done! %s tags were added!'), $tags_added ) . '

      '; + echo '

      ' . sprintf( __ngettext( 'Done! %s tag were added!', 'Done! %s tags were added!', $tags_added ), $tags_added ) . '

      '; echo '
      '; wp_nonce_field('import-utw'); - echo '

      '; + echo '

      '; echo ''; echo ''; @@ -271,6 +271,6 @@ class UTW_Import { $utw_import = new UTW_Import(); // add it to the import page! -register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into the new native tagging structure.'), array($utw_import, 'dispatch')); +register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into WordPress tags.'), array($utw_import, 'dispatch')); ?> diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index d15f3a43..03395bdb 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -2,14 +2,21 @@ class WP_Import { - var $posts = array (); - var $posts_processed = array (); - // Array of arrays. [[0] => XML fragment, [1] => New post ID] + var $post_ids_processed = array (); + var $orphans = array (); var $file; var $id; var $mtnames = array (); var $newauthornames = array (); + var $allauthornames = array (); + + var $author_ids = array (); + var $tags = array (); + var $categories = array (); + var $j = -1; + var $fetch_attachments = false; + var $url_remap = array (); function header() { echo '
      '; @@ -42,60 +49,48 @@ class WP_Import { return $return; } - function users_form($n) { - global $wpdb, $testing; - $users = $wpdb->get_results("SELECT user_login FROM $wpdb->users ORDER BY user_login"); -?> - mtnames))) { //a new mt author name is found - ++ $this->j; - $this->mtnames[$this->j] = $author; //add that new mt author name to an array - $user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user - if (!$user_id) { //banging my head against the desk now. - if ($this->newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname - $user_id = wp_create_user($author, $pass); - $this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank. - } else { - $user_id = wp_create_user($this->newauthornames[$this->j], $pass); - } - } else { - return $user_id; // return pre-existing wp username if it exists - } - } else { - $key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array - $user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames - } + function fopen($filename, $mode='r') { + if ( $this->has_gzip() ) + return gzopen($filename, $mode); + return fopen($filename, $mode); + } + + function feof($fp) { + if ( $this->has_gzip() ) + return gzeof($fp); + return feof($fp); + } + + function fgets($fp, $len=8192) { + if ( $this->has_gzip() ) + return gzgets($fp, $len); + return fgets($fp, $len); + } - return $user_id; + function fclose($fp) { + if ( $this->has_gzip() ) + return gzclose($fp); + return fclose($fp); } - function get_entries() { + function get_entries($process_post_func=NULL) { set_magic_quotes_runtime(0); - $this->posts = array(); - $this->categories = array(); - $this->tags = array(); - $num = 0; $doing_entry = false; + $is_wxr_file = false; - $fp = fopen($this->file, 'r'); + $fp = $this->fopen($this->file, 'r'); if ($fp) { - while ( !feof($fp) ) { - $importline = rtrim(fgets($fp)); + while ( !$this->feof($fp) ) { + $importline = rtrim($this->fgets($fp)); + + // this doesn't check that the file is perfectly valid but will at least confirm that it's not the wrong format altogether + if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) ) + $is_wxr_file = true; if ( false !== strpos($importline, '') ) { preg_match('|(.*?)|is', $importline, $category); @@ -108,44 +103,31 @@ class WP_Import { continue; } if ( false !== strpos($importline, '') ) { - $this->posts[$num] = ''; + $this->post = ''; $doing_entry = true; continue; } if ( false !== strpos($importline, '') ) { - $num++; $doing_entry = false; + if ($process_post_func) + call_user_func($process_post_func, $this->post); continue; } if ( $doing_entry ) { - $this->posts[$num] .= $importline . "\n"; + $this->post .= $importline . "\n"; } } - foreach ($this->posts as $post) { - $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); - if ($post_ID) { - $this->posts_processed[$post_ID][0] = &$post; - $this->posts_processed[$post_ID][1] = 0; - } - } - - fclose($fp); + $this->fclose($fp); } + + return $is_wxr_file; + } function get_wp_authors() { - $temp = array (); - $i = -1; - foreach ($this->posts as $post) { - if ('' != trim($post)) { - ++ $i; - $author = $this->get_tag( $post, 'dc:creator' ); - array_push($temp, "$author"); //store the extracted author names in a temporary array - } - } - // We need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting. + $temp = $this->allauthornames; $authors[0] = array_shift($temp); $y = count($temp) + 1; for ($x = 1; $x < $y; $x ++) { @@ -158,37 +140,50 @@ class WP_Import { } function get_authors_from_post() { - $formnames = array (); - $selectnames = array (); - - foreach ($_POST['user'] as $key => $line) { - $newname = trim(stripslashes($line)); - if ($newname == '') - $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form. - array_push($formnames, "$newname"); - } // $formnames is the array with the form entered names - - foreach ($_POST['userselect'] as $user => $key) { - $selected = trim(stripslashes($key)); - array_push($selectnames, "$selected"); - } + global $current_user; + + // this will populate $this->author_ids with a list of author_names => user_ids - $count = count($formnames); - for ($i = 0; $i < $count; $i ++) { - if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form - array_push($this->newauthornames, "$selectnames[$i]"); - } else { - array_push($this->newauthornames, "$formnames[$i]"); + foreach ( $_POST['author_in'] as $i => $in_author_name ) { + + if ( !empty($_POST['user_select'][$i]) ) { + // an existing user was selected in the dropdown list + $user = get_userdata( intval($_POST['user_select'][$i]) ); + if ( isset($user->ID) ) + $this->author_ids[$in_author_name] = $user->ID; + } + elseif ( $this->allow_create_users() ) { + // nothing was selected in the dropdown list, so we'll use the name in the text field + + $new_author_name = trim($_POST['user_create'][$i]); + // if the user didn't enter a name, assume they want to use the same name as in the import file + if ( empty($new_author_name) ) + $new_author_name = $in_author_name; + + $user_id = username_exists($new_author_name); + if ( !$user_id ) { + $user_id = wp_create_user($new_author_name, wp_generate_password()); + } + + $this->author_ids[$in_author_name] = $user_id; + } + + // failsafe: if the user_id was invalid, default to the current user + if ( empty($this->author_ids[$in_author_name]) ) { + $this->author_ids[$in_author_name] = intval($current_user->ID); } } + } function wp_authors_form() { ?>

      admins entries.'); ?>

      -

      - allow_create_users() ) { + echo '

      '.__('If a new user is created by WordPress, a password will be randomly generated. Manually change the user\'s details if necessary.')."

      \n"; + } $authors = $this->get_wp_authors(); @@ -198,31 +193,76 @@ class WP_Import { $j = -1; foreach ($authors as $author) { ++ $j; - echo '
    • '.__('Current author:').' '.$author.'
      '.sprintf(__('Create user %1$s or map to existing'), '
      '); - $this->users_form($j); + echo '
    • '.__('Import author:').' '.$author.'
      '; + $this->users_form($j, $author); echo '
    • '; } - echo ''.'
      '; + if ( $this->allow_fetch_attachments() ) { +?> + +

      +

      + + +

      + +'.'
      '; echo ''; - echo ''; } + function users_form($n, $author) { + + if ( $this->allow_create_users() ) { + printf(__('Create user %1$s or map to existing'), '
      '); + } + else { + echo __('Map to existing').'
      '; + } + + // keep track of $n => $author name + echo ''; + + $users = get_users_of_blog(); +?> + '.__('Sorry, there has been an error.').'

      '; - echo '

      ' . $file['error'] . '

      '; - return; + $is_wxr_file = $this->get_entries(array(&$this, 'process_author')); + if ( $is_wxr_file ) { + $this->wp_authors_form(); } - $this->file = $file['file']; - $this->id = (int) $file['id']; + else { + echo '

      '.__('Invalid file').'

      '; + echo '

      '.__('Please upload a valid WXR (WordPress eXtended RSS) export file.').'

      '; + } + } - $this->get_entries(); - $this->wp_authors_form(); + // fetch the user ID for a given author name, respecting the mapping preferences + function checkauthor($author) { + global $current_user; + + if ( !empty($this->author_ids[$author]) ) + return $this->author_ids[$author]; + + // failsafe: map to the current user + return $current_user->ID; } + + function process_categories() { global $wpdb; @@ -273,19 +313,22 @@ class WP_Import { } } + function process_author($post) { + $author = $this->get_tag( $post, 'dc:creator' ); + if ($author) + $this->allauthornames[] = $author; + } + function process_posts() { $i = -1; echo '
        '; - foreach ($this->posts as $post) { - $result = $this->process_post($post); - if ( is_wp_error( $result ) ) - return $result; - } + $this->get_entries(array(&$this, 'process_post')); echo '
      '; wp_import_cleanup($this->id); + do_action('import_done', 'wordpress'); echo '

      '.sprintf(__('All done.').' '.__('Have fun!').'', get_option('home')).'

      '; } @@ -294,8 +337,10 @@ class WP_Import { global $wpdb; $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); - if ( $post_ID && !empty($this->posts_processed[$post_ID][1]) ) // Processed already + if ( $post_ID && !empty($this->post_ids_processed[$post_ID]) ) // Processed already return 0; + + set_time_limit( 60 ); // There are only ever one of these $post_title = $this->get_tag( $post, 'title' ); @@ -308,6 +353,7 @@ class WP_Import { $post_parent = $this->get_tag( $post, 'wp:post_parent' ); $menu_order = $this->get_tag( $post, 'wp:menu_order' ); $post_type = $this->get_tag( $post, 'wp:post_type' ); + $post_password = $this->get_tag( $post, 'wp:post_password' ); $guid = $this->get_tag( $post, 'guid' ); $post_author = $this->get_tag( $post, 'dc:creator' ); @@ -334,35 +380,52 @@ class WP_Import { $cat_index++; } - if ($post_id = post_exists($post_title, '', $post_date)) { + $post_exists = post_exists($post_title, '', $post_date); + + if ( $post_exists ) { echo '
    • '; - printf(__('Post %s already exists.'), stripslashes($post_title)); + printf(__('Post %s already exists.'), stripslashes($post_title)); } else { // If it has parent, process parent first. $post_parent = (int) $post_parent; - if ($parent = $this->posts_processed[$post_parent]) { - if (!$parent[1]) { - $result = $this->process_post($parent[0]); // If not yet, process the parent first. - if ( is_wp_error( $result ) ) - return $result; + if ($post_parent) { + // if we already know the parent, map it to the local ID + if ( $parent = $this->post_ids_processed[$post_parent] ) { + $post_parent = $parent; // new ID of the parent + } + else { + // record the parent for later + $this->orphans[intval($post_ID)] = $post_parent; } - $post_parent = $parent[1]; // New ID of the parent; } echo '
    • '; - printf(__('Importing post %s...'), stripslashes($post_title)); $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor - $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type'); - $comment_post_ID = $post_id = wp_insert_post($postdata); + $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', 'menu_order', 'post_type', 'post_password'); + if ($post_type == 'attachment') { + $remote_url = $this->get_tag( $post, 'wp:attachment_url' ); + if ( !$remote_url ) + $remote_url = $guid; + + $comment_post_ID = $post_id = $this->process_attachment($postdata, $remote_url); + if ( !$post_id or is_wp_error($post_id) ) + return $post_id; + } + else { + printf(__('Importing post %s...'), stripslashes($post_title)); + $comment_post_ID = $post_id = wp_insert_post($postdata); + } + if ( is_wp_error( $post_id ) ) return $post_id; // Memorize old and new ID. - if ( $post_id && $post_ID && $this->posts_processed[$post_ID] ) - $this->posts_processed[$post_ID][1] = $post_id; // New ID. + if ( $post_id && $post_ID ) { + $this->post_ids_processed[intval($post_ID)] = intval($post_id); + } // Add categories. if (count($categories) > 0) { @@ -396,7 +459,7 @@ class WP_Import { $tag_id = wp_insert_term($tag, 'post_tag'); $tag_id = $tag_id['term_id']; } - $post_tags[] = $tag_id; + $post_tags[] = intval($tag_id); } wp_set_post_tags($post_id, $post_tags); } @@ -418,7 +481,8 @@ class WP_Import { $comment_type = $this->get_tag( $comment, 'wp:comment_type'); $comment_parent = $this->get_tag( $comment, 'wp:comment_parent'); - if ( !comment_exists($comment_author, $comment_date) ) { + // if this is a new post we can skip the comment_exists() check + if ( !$post_exists || !comment_exists($comment_author, $comment_date) ) { $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent'); wp_insert_comment($commentdata); $num_comments++; @@ -426,7 +490,7 @@ class WP_Import { } } if ( $num_comments ) - printf(' '.__('(%s comments)'), $num_comments); + printf(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); // Now for post meta preg_match_all('|(.*?)|is', $post, $postmeta); @@ -435,23 +499,217 @@ class WP_Import { $key = $this->get_tag( $p, 'wp:meta_key' ); $value = $this->get_tag( $p, 'wp:meta_value' ); $value = stripslashes($value); // add_post_meta() will escape. - add_post_meta( $post_id, $key, $value ); + + $this->process_post_meta($post_id, $key, $value); + } } + + do_action('import_post_added', $post_id); + print "
    • \n"; + } + + function process_post_meta($post_id, $key, $value) { + // the filter can return false to skip a particular metadata key + $_key = apply_filters('import_post_meta_key', $key); + if ( $_key ) { + add_post_meta( $post_id, $_key, $value ); + do_action('import_post_meta', $post_id, $_key, $value); + } + } + + function process_attachment($postdata, $remote_url) { + if ($this->fetch_attachments and $remote_url) { + printf( __('Importing attachment %s... '), htmlspecialchars($remote_url) ); + $upload = $this->fetch_remote_file($postdata, $remote_url); + if ( is_wp_error($upload) ) { + printf( __('Remote file error: %s'), htmlspecialchars($upload->get_error_message()) ); + return $upload; + } + else { + print '('.size_format(filesize($upload['file'])).')'; + } + + if ( $info = wp_check_filetype($upload['file']) ) { + $postdata['post_mime_type'] = $info['type']; + } + else { + print __('Invalid file type'); + return; + } + + $postdata['guid'] = $upload['url']; + + // as per wp-admin/includes/upload.php + $post_id = wp_insert_attachment($postdata, $upload['file']); + wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); + + // remap the thumbnail url. this isn't perfect because we're just guessing the original url. + if ( preg_match('@^image/@', $info['type']) && $thumb_url = wp_get_attachment_thumb_url($post_id) ) { + $parts = pathinfo($remote_url); + $ext = $parts['extension']; + $name = basename($parts['basename'], ".{$ext}"); + $this->url_remap[$parts['dirname'] . '/' . $name . '.thumbnail.' . $ext] = $thumb_url; + } + + return $post_id; + } + else { + printf( __('Skipping attachment %s'), htmlspecialchars($remote_url) ); + } + } + + function fetch_remote_file($post, $url) { + $upload = wp_upload_dir($post['post_date']); + + // extract the file name and extension from the url + $file_name = basename($url); + + // get placeholder file in the upload dir with a unique sanitized filename + $upload = wp_upload_bits( $file_name, 0, '', $post['post_date']); + if ( $upload['error'] ) { + echo $upload['error']; + return new WP_Error( 'upload_dir_error', $upload['error'] ); + } + + // fetch the remote url and write it to the placeholder file + $headers = wp_get_http($url, $upload['file']); + + // make sure the fetch was successful + if ( $headers['response'] != '200' ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', sprintf(__('Remote file returned error response %d'), intval($headers['response'])) ); + } + elseif ( isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length'] ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', __('Remote file is incorrect size') ); + } + + $max_size = $this->max_attachment_size(); + if ( !empty($max_size) and filesize($upload['file']) > $max_size ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', sprintf(__('Remote file is too large, limit is %s', size_format($max_size))) ); + } + + // keep track of the old and new urls so we can substitute them later + $this->url_remap[$url] = $upload['url']; + // if the remote url is redirected somewhere else, keep track of the destination too + if ( $headers['x-final-location'] != $url ) + $this->url_remap[$headers['x-final-location']] = $upload['url']; + + return $upload; + + } + + // sort by strlen, longest string first + function cmpr_strlen($a, $b) { + return strlen($b) - strlen($a); + } + + // update url references in post bodies to point to the new local files + function backfill_attachment_urls() { + + // make sure we do the longest urls first, in case one is a substring of another + uksort($this->url_remap, array(&$this, 'cmpr_strlen')); + + global $wpdb; + foreach ($this->url_remap as $from_url => $to_url) { + // remap urls in post_content + $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, '%s', '%s')", $from_url, $to_url) ); + // remap enclosure urls + $result = $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, '%s', '%s') WHERE meta_key='enclosure'", $from_url, $to_url) ); + } + } + + // update the post_parent of orphans now that we know the local id's of all parents + function backfill_parents() { + global $wpdb; + + foreach ($this->orphans as $child_id => $parent_id) { + $local_child_id = $this->post_ids_processed[$child_id]; + $local_parent_id = $this->post_ids_processed[$parent_id]; + if ($local_child_id and $local_parent_id) { + $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", $local_parent_id, $local_child_id)); + } + } + } + + function is_valid_meta_key($key) { + // skip _wp_attached_file metadata since we'll regenerate it from scratch + if ( $key == '_wp_attached_file' ) + return false; + return $key; + } + + // give the user the option of creating new users to represent authors in the import file? + function allow_create_users() { + return apply_filters('import_allow_create_users', true); + } + + // give the user the option of downloading and importing attached files + function allow_fetch_attachments() { + return apply_filters('import_allow_fetch_attachments', true); + } + + function max_attachment_size() { + // can be overridden with a filter - 0 means no limit + return apply_filters('import_attachment_size_limit', 0); + } + + function import_start() { + wp_defer_term_counting(true); + wp_defer_comment_counting(true); + do_action('import_start'); + } + + function import_end() { + do_action('import_end'); + + // clear the caches after backfilling + foreach ($this->post_ids_processed as $post_id) + clean_post_cache($post_id); + + wp_defer_term_counting(false); + wp_defer_comment_counting(false); + } + + function import($id, $fetch_attachments = false) { + $this->id = (int) $id; + $this->fetch_attachments = ($this->allow_fetch_attachments() && (bool) $fetch_attachments); + + add_filter('import_post_meta_key', array($this, 'is_valid_meta_key')); + $file = get_attached_file($this->id); + $this->import_file($file); } - function import() { - $this->id = (int) $_GET['id']; + function import_file($file) { + $this->file = $file; - $this->file = get_attached_file($this->id); + $this->import_start(); $this->get_authors_from_post(); $this->get_entries(); $this->process_categories(); $this->process_tags(); $result = $this->process_posts(); + $this->backfill_parents(); + $this->backfill_attachment_urls(); + $this->import_end(); + if ( is_wp_error( $result ) ) return $result; } + function handle_upload() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo '

      '.__('Sorry, there has been an error.').'

      '; + echo '

      ' . $file['error'] . '

      '; + return false; + } + $this->file = $file['file']; + $this->id = (int) $file['id']; + return true; + } + function dispatch() { if (empty ($_GET['step'])) $step = 0; @@ -465,11 +723,12 @@ class WP_Import { break; case 1 : check_admin_referer('import-upload'); - $this->select_authors(); + if ( $this->handle_upload() ) + $this->select_authors(); break; case 2: check_admin_referer('import-wordpress'); - $result = $this->import(); + $result = $this->import( $_GET['id'], $_POST['attachments'] ); if ( is_wp_error( $result ) ) echo $result->get_error_message(); break; @@ -484,6 +743,6 @@ class WP_Import { $wp_import = new WP_Import(); -register_importer('wordpress', 'WordPress', __('Import posts, comments, custom fields, pages, and categories from a WordPress export file'), array ($wp_import, 'dispatch')); +register_importer('wordpress', 'WordPress', __('Import posts, comments, custom fields, pages, and categories from a WordPress export file.'), array ($wp_import, 'dispatch')); ?> diff --git a/wp-admin/import/wp-cat2tag.php b/wp-admin/import/wp-cat2tag.php index d38e17a1..0f271cec 100644 --- a/wp-admin/import/wp-cat2tag.php +++ b/wp-admin/import/wp-cat2tag.php @@ -5,12 +5,12 @@ class WP_Categories_to_Tags { var $all_categories = array(); function header() { - print '
      '; - print '

      ' . __('Convert Categories to Tags') . '

      '; + echo '
      '; + echo '

      ' . __('Convert Categories to Tags') . '

      '; } function footer() { - print '
      '; + echo '
      '; } function populate_all_categories() { @@ -19,75 +19,101 @@ class WP_Categories_to_Tags { $categories = get_categories('get=all'); foreach ( $categories as $category ) { if ( !tag_exists($wpdb->escape($category->name)) ) - $this->all_categories[] = $category; + $this->all_categories[] = $category; } } function welcome() { $this->populate_all_categories(); - print '
      '; + echo '
      '; if (count($this->all_categories) > 0) { - print '

      ' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '

      '; - print '

      ' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '

      '; + echo '

      ' . __('Hey there. Here you can selectively converts existing categories to tags. To get started, check the categories you wish to be converted, then click the Convert button.') . '

      '; + echo '

      ' . __('Keep in mind that if you convert a category with child categories, the children become top-level orphans.') . '

      '; $this->categories_form(); } else { - print '

      '.__('You have no categories to convert!').'

      '; + echo '

      '.__('You have no categories to convert!').'

      '; } - print '
      '; + echo '
      '; } function categories_form() { - print '
      '; +?> + + +

      '; wp_nonce_field('import-cat2tag'); - print '
        '; + echo '
          '; $hier = _get_term_hierarchy('category'); foreach ($this->all_categories as $category) { $category = sanitize_term( $category, 'category', 'display' ); - + if ((int) $category->parent == 0) { - print '
        • '; + echo '
        • '; if (isset($hier[$category->term_id])) { $this->_category_children($category, $hier); } - print '
        • '; + echo ''; } } - print '
        '; + echo '
      '; + + echo '

      '; - print '

      '; - print ''; + echo ''; } function _category_children($parent, $hier) { - print '
        '; + echo '
          '; foreach ($hier[$parent->term_id] as $child_id) { $child =& get_category($child_id); - print '
        • '; + echo '
        • '; if (isset($hier[$child->term_id])) { $this->_category_children($child, $hier); } - print '
        • '; + echo ''; } - print '
        '; + echo '
      '; } function _category_exists($cat_id) { - global $wpdb; - $cat_id = (int) $cat_id; $maybe_exists = category_exists($cat_id); @@ -103,9 +129,9 @@ class WP_Categories_to_Tags { global $wpdb; if ( (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) && empty($this->categories_to_convert)) { - print '
      '; - print '

      ' . sprintf(__('Uh, oh. Something didn\'t work. Please try again.'), 'admin.php?import=wp-cat2tag') . '

      '; - print '
      '; + echo '
      '; + echo '

      ' . sprintf(__('Uh, oh. Something didn’t work. Please try again.'), 'admin.php?import=wp-cat2tag') . '

      '; + echo '
      '; return; } @@ -114,12 +140,12 @@ class WP_Categories_to_Tags { $this->categories_to_convert = $_POST['cats_to_convert']; $hier = _get_term_hierarchy('category'); - print '
        '; + echo '
          '; foreach ( (array) $this->categories_to_convert as $cat_id) { $cat_id = (int) $cat_id; - print '
        • ' . sprintf(__('Converting category #%s ... '), $cat_id); + echo '
        • ' . sprintf(__('Converting category #%s ... '), $cat_id); if (!$this->_category_exists($cat_id)) { _e('Category doesn\'t exist!'); @@ -128,7 +154,7 @@ class WP_Categories_to_Tags { if ( tag_exists($wpdb->escape($category->name)) ) { _e('Category is already a tag.'); - print '
        • '; + echo ''; continue; } @@ -138,7 +164,7 @@ class WP_Categories_to_Tags { $id = $id['term_taxonomy_id']; $posts = get_objects_in_term($category->term_id, 'category'); foreach ( $posts as $post ) { - if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") ) + if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") ) $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post', '$id')"); clean_post_cache($post); } @@ -166,10 +192,11 @@ class WP_Categories_to_Tags { _e('Converted successfully.'); } - print ''; + echo ''; } - print '
        '; + echo '
      '; + echo '

      ' . sprintf( __('We’re all done here, but you can always convert more.'), 'admin.php?import=wp-cat2tag' ) . '

      '; } function init() { @@ -179,9 +206,9 @@ class WP_Categories_to_Tags { $this->header(); if (!current_user_can('manage_categories')) { - print '
      '; - print '

      ' . __('Cheatin’ uh?') . '

      '; - print '
      '; + echo '
      '; + echo '

      ' . __('Cheatin’ uh?') . '

      '; + echo '
      '; } else { if ( $step > 1 ) check_admin_referer('import-cat2tag'); @@ -209,4 +236,4 @@ $wp_cat2tag_importer = new WP_Categories_to_Tags(); register_importer('wp-cat2tag', __('Categories to Tags Converter'), __('Convert existing categories to tags, selectively.'), array(&$wp_cat2tag_importer, 'init')); -?> +?> \ No newline at end of file diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php index fc50709a..9bd25136 100644 --- a/wp-admin/includes/admin.php +++ b/wp-admin/includes/admin.php @@ -4,6 +4,7 @@ require_once(ABSPATH . 'wp-admin/includes/bookmark.php'); require_once(ABSPATH . 'wp-admin/includes/comment.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/image.php'); +require_once(ABSPATH . 'wp-admin/includes/media.php'); require_once(ABSPATH . 'wp-admin/includes/import.php'); require_once(ABSPATH . 'wp-admin/includes/misc.php'); require_once(ABSPATH . 'wp-admin/includes/plugin.php'); diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php index 35cc9c9d..908d6b86 100644 --- a/wp-admin/includes/bookmark.php +++ b/wp-admin/includes/bookmark.php @@ -13,6 +13,8 @@ function edit_link( $link_id = '' ) { $_POST['link_name'] = wp_specialchars( $_POST['link_name'] ); $_POST['link_image'] = wp_specialchars( $_POST['link_image'] ); $_POST['link_rss'] = clean_url($_POST['link_rss']); + if ( 'N' != $_POST['link_visible'] ) + $_POST['link_visible'] = 'Y'; if ( !empty( $link_id ) ) { $_POST['link_id'] = $link_id; @@ -60,7 +62,7 @@ function wp_get_link_cats($link_id = 0) { } function get_link_to_edit( $link_id ) { - return get_link( $link_id, OBJECT, 'edit' ); + return get_bookmark( $link_id, OBJECT, 'edit' ); } function wp_insert_link($linkdata) { @@ -151,8 +153,6 @@ function wp_set_link_cats($link_id = 0, $link_categories = array()) { } // wp_set_link_cats() function wp_update_link($linkdata) { - global $wpdb; - $link_id = (int) $linkdata['link_id']; $link = get_link($link_id, ARRAY_A); diff --git a/wp-admin/includes/class-ftp-pure.php b/wp-admin/includes/class-ftp-pure.php new file mode 100644 index 00000000..5ef92bfd --- /dev/null +++ b/wp-admin/includes/class-ftp-pure.php @@ -0,0 +1,175 @@ +__construct($verb, $le); + } + + function __construct($verb=FALSE, $le=FALSE) { + parent::__construct(false, $verb, $le); + } + +// +// +// + + function _settimeout($sock) { + if(!@stream_set_timeout($sock, $this->_timeout)) { + $this->PushError('_settimeout','socket set send timeout'); + $this->_quit(); + return FALSE; + } + return TRUE; + } + + function _connect($host, $port) { + $this->SendMSG("Creating socket"); + $sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); + if (!$sock) { + $this->PushError('_connect','socket connect failed', $errstr." (".$errno.")"); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction, 'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@fgets($this->_ftp_control_sock, 512); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed'); + } else { + $this->_message.=$tmp; + if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false; + } + } while($go); + if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; + $this->_code=(int)$regs[1]; + return $result; + } + + function _exec($cmd, $fnction="_exec") { + if(!$this->_ready) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; + $status=@fputs($this->_ftp_control_sock, $cmd.CRLF); + if($status===false) { + $this->PushError($fnction,'socket write failed'); + return FALSE; + } + $this->_lastaction=time(); + if(!$this->_readmsg($fnction)) return FALSE; + return TRUE; + } + + function _data_prepare($mode=FTP_ASCII) { + if(!$this->_settype($mode)) return FALSE; + if($this->_passive) { + if(!$this->_exec("PASV", "pasv")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message)); + $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout); + if(!$this->_ftp_data_sock) { + $this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")"); + $this->_data_close(); + return FALSE; + } + else $this->_ftp_data_sock; + } else { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + return TRUE; + } + + function _data_read($mode=FTP_ASCII, $fp=NULL) { + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + while (!feof($this->_ftp_data_sock)) { + $block=fread($this->_ftp_data_sock, $this->_ftp_buff_size); + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); + if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); + else $out.=$block; + } + return $out; + } + + function _data_write($mode=FTP_ASCII, $fp=NULL) { + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + if(is_resource($fp)) { + while(!feof($fp)) { + $block=fread($fp, $this->_ftp_buff_size); + if(!$this->_data_write_block($mode, $block)) return false; + } + } elseif(!$this->_data_write_block($mode, $fp)) return false; + return TRUE; + } + + function _data_write_block($mode, $block) { + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); + do { + if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) { + $this->PushError("_data_write","Can't write to socket"); + return FALSE; + } + $block=substr($block, $t); + } while(!empty($block)); + return true; + } + + function _data_close() { + @fclose($this->_ftp_data_sock); + $this->SendMSG("Disconnected data from remote host"); + return TRUE; + } + + function _quit($force=FALSE) { + if($this->_connected or $force) { + @fclose($this->_ftp_control_sock); + $this->_connected=false; + $this->SendMSG("Socket closed"); + } + } +} +?> diff --git a/wp-admin/includes/class-ftp-sockets.php b/wp-admin/includes/class-ftp-sockets.php new file mode 100644 index 00000000..99b40505 --- /dev/null +++ b/wp-admin/includes/class-ftp-sockets.php @@ -0,0 +1,236 @@ +__construct($verb, $le); + } + + function __construct($verb=FALSE, $le=FALSE) { + parent::__construct(true, $verb, $le); + } + +// +// +// + + function _settimeout($sock) { + if(!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) { + $this->PushError('_connect','socket set receive timeout',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) { + $this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + return true; + } + + function _connect($host, $port) { + $this->SendMSG("Creating socket"); + if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) { + $this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock))); + return FALSE; + } + if(!$this->_settimeout($sock)) return FALSE; + $this->SendMSG("Connecting to \"".$host.":".$port."\""); + if (!($res = @socket_connect($sock, $host, $port))) { + $this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock))); + } else { + $this->_message.=$tmp; + $go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs); + } + } while($go); + if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; + $this->_code=(int)$regs[1]; + return $result; + } + + function _exec($cmd, $fnction="_exec") { + if(!$this->_ready) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; + $status=@socket_write($this->_ftp_control_sock, $cmd.CRLF); + if($status===false) { + $this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream))); + return FALSE; + } + $this->_lastaction=time(); + if(!$this->_readmsg($fnction)) return FALSE; + return TRUE; + } + + function _data_prepare($mode=FTP_ASCII) { + if(!$this->_settype($mode)) return FALSE; + $this->SendMSG("Creating data socket"); + $this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + if ($this->_ftp_data_sock < 0) { + $this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock))); + return FALSE; + } + if(!$this->_settimeout($this->_ftp_data_sock)) { + $this->_data_close(); + return FALSE; + } + if($this->_passive) { + if(!$this->_exec("PASV", "pasv")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message)); + $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + if(!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) { + $this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + else $this->_ftp_temp_sock=$this->_ftp_data_sock; + } else { + if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) { + $this->PushError("_data_prepare","can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_bind($this->_ftp_data_sock,$addr)){ + $this->PushError("_data_prepare","can't bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_listen($this->_ftp_data_sock)) { + $this->PushError("_data_prepare","can't listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) { + $this->PushError("_data_prepare","can't get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!$this->_exec('PORT '.str_replace('.',',',$this->_datahost.'.'.($this->_dataport>>8).'.'.($this->_dataport&0x00FF)), "_port")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + } + return TRUE; + } + + function _data_read($mode=FTP_ASCII, $fp=NULL) { + $NewLine=$this->_eol_code[$this->OS_local]; + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock); + if($this->_ftp_temp_sock===FALSE) { + $this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return FALSE; + } + } + + while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) { + if($block==="") break; + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); + if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); + else $out.=$block; + } + return $out; + } + + function _data_write($mode=FTP_ASCII, $fp=NULL) { + $NewLine=$this->_eol_code[$this->OS_local]; + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock); + if($this->_ftp_temp_sock===FALSE) { + $this->PushError("_data_write","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return false; + } + } + if(is_resource($fp)) { + while(!feof($fp)) { + $block=fread($fp, $this->_ftp_buff_size); + if(!$this->_data_write_block($mode, $block)) return false; + } + } elseif(!$this->_data_write_block($mode, $fp)) return false; + return true; + } + + function _data_write_block($mode, $block) { + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); + do { + if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) { + $this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return FALSE; + } + $block=substr($block, $t); + } while(!empty($block)); + return true; + } + + function _data_close() { + @socket_close($this->_ftp_temp_sock); + @socket_close($this->_ftp_data_sock); + $this->SendMSG("Disconnected data from remote host"); + return TRUE; + } + + function _quit() { + if($this->_connected) { + @socket_close($this->_ftp_control_sock); + $this->_connected=false; + $this->SendMSG("Socket closed"); + } + } +} +?> diff --git a/wp-admin/includes/class-ftp.php b/wp-admin/includes/class-ftp.php new file mode 100644 index 00000000..c10526bd --- /dev/null +++ b/wp-admin/includes/class-ftp.php @@ -0,0 +1,842 @@ +__construct($port_mode); + } + + function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) { + $this->LocalEcho=$le; + $this->Verbose=$verb; + $this->_lastaction=NULL; + $this->_error_array=array(); + $this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n"); + $this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY); + $this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS'); + $this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT"); + $this->_port_available=($port_mode==TRUE); + $this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support")); + $this->_connected=FALSE; + $this->_ready=FALSE; + $this->_can_restore=FALSE; + $this->_code=0; + $this->_message=""; + $this->_ftp_buff_size=4096; + $this->_curtype=NULL; + $this->SetUmask(0022); + $this->SetType(FTP_AUTOASCII); + $this->SetTimeout(30); + $this->Passive(!$this->_port_available); + $this->_login="anonymous"; + $this->_password="anon@ftp.com"; + $this->_features=array(); + $this->OS_local=FTP_OS_Unix; + $this->OS_remote=FTP_OS_Unix; + $this->features=array(); + if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows; + elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac; + } + +// +// +// + + function parselisting($line) { + $is_windows = ($this->OS_remote == FTP_OS_Windows); + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/",$line,$lucifer)) { + $b = array(); + if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix + $b['isdir'] = ($lucifer[7]==""); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount=count($lucifer); + if ($lcount<8) return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === "d"; + $b['islink'] = $lucifer[0]{0} === "l"; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ($lcount==8) { + sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); + sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); + $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); + $b['name'] = $lucifer[8]; + } + } + + return $b; + } + + function SendMSG($message = "", $crlf=true) { + if ($this->Verbose) { + echo $message.($crlf?CRLF:""); + flush(); + } + return TRUE; + } + + function SetType($mode=FTP_AUTOASCII) { + if(!in_array($mode, $this->AuthorizedTransferMode)) { + $this->SendMSG("Wrong type"); + return FALSE; + } + $this->_type=$mode; + $this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) ); + return TRUE; + } + + function _settype($mode=FTP_ASCII) { + if($this->_ready) { + if($mode==FTP_BINARY) { + if($this->_curtype!=FTP_BINARY) { + if(!$this->_exec("TYPE I", "SetType")) return FALSE; + $this->_curtype=FTP_BINARY; + } + } elseif($this->_curtype!=FTP_ASCII) { + if(!$this->_exec("TYPE A", "SetType")) return FALSE; + $this->_curtype=FTP_ASCII; + } + } else return FALSE; + return TRUE; + } + + function Passive($pasv=NULL) { + if(is_null($pasv)) $this->_passive=!$this->_passive; + else $this->_passive=$pasv; + if(!$this->_port_available and !$this->_passive) { + $this->SendMSG("Only passive connections available!"); + $this->_passive=TRUE; + return FALSE; + } + $this->SendMSG("Passive mode ".($this->_passive?"on":"off")); + return TRUE; + } + + function SetServer($host, $port=21, $reconnect=true) { + if(!is_long($port)) { + $this->verbose=true; + $this->SendMSG("Incorrect port syntax"); + return FALSE; + } else { + $ip=@gethostbyname($host); + $dns=@gethostbyaddr($host); + if(!$ip) $ip=$host; + if(!$dns) $dns=$host; + if(ip2long($ip) === -1) { + $this->SendMSG("Wrong host name/address \"".$host."\""); + return FALSE; + } + $this->_host=$ip; + $this->_fullhost=$dns; + $this->_port=$port; + $this->_dataport=$port-1; + } + $this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\""); + if($reconnect){ + if($this->_connected) { + $this->SendMSG("Reconnecting"); + if(!$this->quit(FTP_FORCE)) return FALSE; + if(!$this->connect()) return FALSE; + } + } + return TRUE; + } + + function SetUmask($umask=0022) { + $this->_umask=$umask; + umask($this->_umask); + $this->SendMSG("UMASK 0".decoct($this->_umask)); + return TRUE; + } + + function SetTimeout($timeout=30) { + $this->_timeout=$timeout; + $this->SendMSG("Timeout ".$this->_timeout); + if($this->_connected) + if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE; + return TRUE; + } + + function connect($server=NULL) { + if(!empty($server)) { + if(!$this->SetServer($server)) return false; + } + if($this->_ready) return true; + $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]); + if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) { + $this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\""); + return FALSE; + } + $this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting."); + do { + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + $this->_lastaction=time(); + } while($this->_code<200); + $this->_ready=true; + $syst=$this->systype(); + if(!$syst) $this->SendMSG("Can't detect remote OS"); + else { + if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows; + elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac; + elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix; + else $this->OS_remote=FTP_OS_Mac; + $this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]); + } + if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled"); + else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); + return TRUE; + } + + function quit($force=false) { + if($this->_ready) { + if(!$this->_exec("QUIT") and !$force) return FALSE; + if(!$this->_checkCode() and !$force) return FALSE; + $this->_ready=false; + $this->SendMSG("Session finished"); + } + $this->_quit(); + return TRUE; + } + + function login($user=NULL, $pass=NULL) { + if(!is_null($user)) $this->_login=$user; + else $this->_login="anonymous"; + if(!is_null($pass)) $this->_password=$pass; + else $this->_password="anon@anon.com"; + if(!$this->_exec("USER ".$this->_login, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code!=230) { + if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + $this->SendMSG("Authentication succeeded"); + if(empty($this->_features)) { + if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled"); + else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); + } + return TRUE; + } + + function pwd() { + if(!$this->_exec("PWD", "pwd")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return ereg_replace("^[0-9]{3} \"(.+)\".+", "\\1", $this->_message); + } + + function cdup() { + if(!$this->_exec("CDUP", "cdup")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return true; + } + + function chdir($pathname) { + if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rmdir($pathname) { + if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function mkdir($pathname) { + if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rename($from, $to) { + if(!$this->_exec("RNFR ".$from, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code==350) { + if(!$this->_exec("RNTO ".$to, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } else return FALSE; + return TRUE; + } + + function filesize($pathname) { + if(!isset($this->_features["SIZE"])) { + $this->PushError("filesize", "not supported by server"); + return FALSE; + } + if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); + } + + function abort() { + if(!$this->_exec("ABOR", "abort")) return FALSE; + if(!$this->_checkCode()) { + if($this->_code!=426) return FALSE; + if(!$this->_readmsg("abort")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + return true; + } + + function mdtm($pathname) { + if(!isset($this->_features["MDTM"])) { + $this->PushError("mdtm", "not supported by server"); + return FALSE; + } + if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); + $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); + $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); + return $timestamp; + } + + function systype() { + if(!$this->_exec("SYST", "systype")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $DATA = explode(" ", $this->_message); + return array($DATA[1], $DATA[3]); + } + + function delete($pathname) { + if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function site($command, $fnction="site") { + if(!$this->_exec("SITE ".$command, $fnction)) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function chmod($pathname, $mode) { + if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE; + return TRUE; + } + + function restore($from) { + if(!isset($this->_features["REST"])) { + $this->PushError("restore", "not supported by server"); + return FALSE; + } + if($this->_curtype!=FTP_BINARY) { + $this->PushError("restore", "can't restore in ASCII mode"); + return FALSE; + } + if(!$this->_exec("REST ".$from, "resore")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function features() { + if(!$this->_exec("FEAT", "features")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY); + $this->_features=array(); + foreach($f as $k=>$v) { + $v=explode(" ", trim($v)); + $this->_features[array_shift($v)]=$v;; + } + return true; + } + + function rawlist($pathname="", $arg="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist"); + } + + function nlist($pathname="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist"); + } + + function is_exists($pathname) { + return $this->file_exists($pathname); + } + + function file_exists($pathname) { + $exists=true; + if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE; + else { + if(!$this->_checkCode()) $exists=FALSE; + $this->abort(); + } + if($exists) $this->SendMSG("Remote file ".$pathname." exists"); + else $this->SendMSG("Remote file ".$pathname." does not exist"); + return $exists; + } + + function fget($fp, $remotefile,$rest=0) { + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function get($remotefile, $localfile=NULL, $rest=0) { + if(is_null($localfile)) $localfile=$remotefile; + if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten"); + $fp = @fopen($localfile, "w"); + if (!$fp) { + $this->PushError("get","can't open local file", "Cannot create \"".$localfile."\""); + return FALSE; + } + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function fput($remotefile, $fp) { + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + + function put($localfile, $remotefile=NULL, $rest=0) { + if(is_null($remotefile)) $remotefile=$localfile; + if (!file_exists($localfile)) { + $this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\""); + return FALSE; + } + $fp = @fopen($localfile, "r"); + + if (!$fp) { + $this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\""); + return FALSE; + } + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($localfile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + + function mput($local=".", $remote=NULL, $continious=false) { + $local=realpath($local); + if(!@file_exists($local)) { + $this->PushError("mput","can't open local folder", "Cannot stat folder \"".$local."\""); + return FALSE; + } + if(!is_dir($local)) return $this->put($local, $remote); + if(empty($remote)) $remote="."; + elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE; + if($handle = opendir($local)) { + $list=array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != "..") $list[]=$file; + } + closedir($handle); + } else { + $this->PushError("mput","can't open local folder", "Cannot read folder \"".$local."\""); + return FALSE; + } + if(empty($list)) return TRUE; + $ret=true; + foreach($list as $el) { + if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el); + else $t=$this->put($local."/".$el, $remote."/".$el); + if(!$t) { + $ret=FALSE; + if(!$continious) break; + } + } + return $ret; + + } + + function mget($remote, $local=".", $continious=false) { + $list=$this->rawlist($remote, "-lA"); + if($list===false) { + $this->PushError("mget","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return FALSE; + } + if(empty($list)) return true; + if(!@file_exists($local)) { + if(!@mkdir($local)) { + $this->PushError("mget","can't create local folder", "Cannot create folder \"".$local."\""); + return FALSE; + } + } + foreach($list as $k=>$v) { + $list[$k]=$this->parselisting($v); + if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); + } + $ret=true; + foreach($list as $el) { + if($el["type"]=="d") { + if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) { + $this->PushError("mget", "can't copy folder", "Can't copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } else { + if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) { + $this->PushError("mget", "can't copy file", "Can't copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } + @chmod($local."/".$el["name"], $el["perms"]); + $t=strtotime($el["date"]); + if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t); + } + return $ret; + } + + function mdel($remote, $continious=false) { + $list=$this->rawlist($remote, "-la"); + if($list===false) { + $this->PushError("mdel","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return false; + } + + foreach($list as $k=>$v) { + $list[$k]=$this->parselisting($v); + if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); + } + $ret=true; + + foreach($list as $el) { + if ( empty($el) ) + continue; + + if($el["type"]=="d") { + if(!$this->mdel($remote."/".$el["name"], $continious)) { + $ret=false; + if(!$continious) break; + } + } else { + if (!$this->delete($remote."/".$el["name"])) { + $this->PushError("mdel", "can't delete file", "Can't delete remote file \"".$remote."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } + } + + if(!$this->rmdir($remote)) { + $this->PushError("mdel", "can't delete folder", "Can't delete remote folder \"".$remote."/".$el["name"]."\""); + $ret=false; + } + return $ret; + } + + function mmkdir($dir, $mode = 0777) { + if(empty($dir)) return FALSE; + if($this->is_exists($dir) or $dir == "/" ) return TRUE; + if(!$this->mmkdir(dirname($dir), $mode)) return false; + $r=$this->mkdir($dir, $mode); + $this->chmod($dir,$mode); + return $r; + } + + function glob($pattern, $handle=NULL) { + $path=$output=null; + if(PHP_OS=='WIN32') $slash='\\'; + else $slash='/'; + $lastpos=strrpos($pattern,$slash); + if(!($lastpos===false)) { + $path=substr($pattern,0,-$lastpos-1); + $pattern=substr($pattern,$lastpos); + } else $path=getcwd(); + if(is_array($handle) and !empty($handle)) { + while($dir=each($handle)) { + if($this->glob_pattern_match($pattern,$dir)) + $output[]=$dir; + } + } else { + $handle=@opendir($path); + if($handle===false) return false; + while($dir=readdir($handle)) { + if($this->glob_pattern_match($pattern,$dir)) + $output[]=$dir; + } + closedir($handle); + } + if(is_array($output)) return $output; + return false; + } + + function glob_pattern_match($pattern,$string) { + $out=null; + $chunks=explode(';',$pattern); + foreach($chunks as $pattern) { + $escape=array('$','^','.','{','}','(',')','[',']','|'); + while(strpos($pattern,'**')!==false) + $pattern=str_replace('**','*',$pattern); + foreach($escape as $probe) + $pattern=str_replace($probe,"\\$probe",$pattern); + $pattern=str_replace('?*','*', + str_replace('*?','*', + str_replace('*',".*", + str_replace('?','.{1,1}',$pattern)))); + $out[]=$pattern; + } + if(count($out)==1) return($this->glob_regexp("^$out[0]$",$string)); + else { + foreach($out as $tester) + if($this->my_regexp("^$tester$",$string)) return true; + } + return false; + } + + function glob_regexp($pattern,$probe) { + $sensitive=(PHP_OS!='WIN32'); + return ($sensitive? + ereg($pattern,$probe): + eregi($pattern,$probe) + ); + } + + function dirlist($remote) { + $list=$this->rawlist($remote, "-la"); + if($list===false) { + $this->PushError("dirlist","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return false; + } + + $dirlist = array(); + foreach($list as $k=>$v) { + $entry=$this->parselisting($v); + if ( empty($entry) ) + continue; + + if($entry["name"]=="." or $entry["name"]=="..") + continue; + + $dirlist[$entry['name']] = $entry; + } + + return $dirlist; + } +// +// +// + function _checkCode() { + return ($this->_code<400 and $this->_code>0); + } + + function _list($arg="", $cmd="LIST", $fnction="_list") { + if(!$this->_data_prepare()) return false; + if(!$this->_exec($cmd.$arg, $fnction)) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=""; + if($this->_code<200) { + $out=$this->_data_read(); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($out === FALSE ) return FALSE; + $out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY); +// $this->SendMSG(implode($this->_eol_code[$this->OS_local], $out)); + } + return $out; + } + +// +// +// +// Gnre une erreur pour traitement externe la classe + function PushError($fctname,$msg,$desc=false){ + $error=array(); + $error['time']=time(); + $error['fctname']=$fctname; + $error['msg']=$msg; + $error['desc']=$desc; + if($desc) $tmp=' ('.$desc.')'; else $tmp=''; + $this->SendMSG($fctname.': '.$msg.$tmp); + return(array_push($this->_error_array,$error)); + } + +// Rcupre une erreur externe + function PopError(){ + if(count($this->_error_array)) return(array_pop($this->_error_array)); + else return(false); + } +} + +$mod_sockets=TRUE; +if (!extension_loaded('sockets')) { + $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : ''; + if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE; +} +require_once "class-ftp-".($mod_sockets?"sockets":"pure").".php"; +?> diff --git a/wp-admin/includes/class-pclzip.php b/wp-admin/includes/class-pclzip.php new file mode 100644 index 00000000..b4907444 --- /dev/null +++ b/wp-admin/includes/class-pclzip.php @@ -0,0 +1,5750 @@ +zipname = $p_zipname; + $this->zip_fd = 0; + $this->magic_quotes_status = -1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1); + return; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // create($p_filelist, $p_add_dir="", $p_remove_dir="") + // create($p_filelist, $p_option, $p_option_value, ...) + // Description : + // This method supports two different synopsis. The first one is historical. + // This method creates a Zip Archive. The Zip file is created in the + // filesystem. The files and directories indicated in $p_filelist + // are added in the archive. See the parameters description for the + // supported format of $p_filelist. + // When a directory is in the list, the directory and its content is added + // in the archive. + // In this synopsis, the function takes an optional variable list of + // options. See bellow the supported options. + // Parameters : + // $p_filelist : An array containing file or directory names, or + // a string containing one filename or one directory name, or + // a string containing a list of filenames and/or directory + // names separated by spaces. + // $p_add_dir : A path to add before the real path of the archived file, + // in order to have it memorized in the archive. + // $p_remove_dir : A path to remove from the real path of the file to archive, + // in order to have a shorter path memorized in the archive. + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir + // is removed first, before $p_add_dir is added. + // Options : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_COMMENT : + // PCLZIP_CB_PRE_ADD : + // PCLZIP_CB_POST_ADD : + // Return Values : + // 0 on failure, + // The list of the added files, with a status of the add action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function create($p_filelist) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Set default values + $v_options = array(); + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove from the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_ADD => 'optional', + PCLZIP_CB_POST_ADD => 'optional', + PCLZIP_OPT_NO_COMPRESSION => 'optional', + PCLZIP_OPT_COMMENT => 'optional' + //, PCLZIP_OPT_CRYPT => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; + } + else if ($v_size > 2) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Invalid number / type of arguments"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Init + $v_string_list = array(); + $v_att_list = array(); + $v_filedescr_list = array(); + $p_result_list = array(); + + // ----- Look if the $p_filelist is really an array + if (is_array($p_filelist)) { + + // ----- Look if the first element is also an array + // This will mean that this is a file description entry + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { + $v_att_list = $p_filelist; + } + + // ----- The list is a list of string names + else { + $v_string_list = $p_filelist; + } + } + + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) { + // ----- Create a list from the string + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); + } + + // ----- Invalid variable type for $p_filelist + else { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Reformat the string list + if (sizeof($v_string_list) != 0) { + foreach ($v_string_list as $v_string) { + if ($v_string != '') { + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename"); + } + } + } + + // ----- For each file in the list check the attributes + $v_supported_attributes + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' + ); + foreach ($v_att_list as $v_entry) { + $v_result = $this->privFileDescrParseAtt($v_entry, + $v_filedescr_list[], + $v_options, + $v_supported_attributes); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Expand the filelist (expand directories) + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Call the create fct + $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); + return $p_result_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // add($p_filelist, $p_add_dir="", $p_remove_dir="") + // add($p_filelist, $p_option, $p_option_value, ...) + // Description : + // This method supports two synopsis. The first one is historical. + // This methods add the list of files in an existing archive. + // If a file with the same name already exists, it is added at the end of the + // archive, the first one is still present. + // If the archive does not exist, it is created. + // Parameters : + // $p_filelist : An array containing file or directory names, or + // a string containing one filename or one directory name, or + // a string containing a list of filenames and/or directory + // names separated by spaces. + // $p_add_dir : A path to add before the real path of the archived file, + // in order to have it memorized in the archive. + // $p_remove_dir : A path to remove from the real path of the file to archive, + // in order to have a shorter path memorized in the archive. + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir + // is removed first, before $p_add_dir is added. + // Options : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_COMMENT : + // PCLZIP_OPT_ADD_COMMENT : + // PCLZIP_OPT_PREPEND_COMMENT : + // PCLZIP_CB_PRE_ADD : + // PCLZIP_CB_POST_ADD : + // Return Values : + // 0 on failure, + // The list of the added files, with a status of the add action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function add($p_filelist) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Set default values + $v_options = array(); + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove form the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_ADD => 'optional', + PCLZIP_CB_POST_ADD => 'optional', + PCLZIP_OPT_NO_COMPRESSION => 'optional', + PCLZIP_OPT_COMMENT => 'optional', + PCLZIP_OPT_ADD_COMMENT => 'optional', + PCLZIP_OPT_PREPEND_COMMENT => 'optional' + //, PCLZIP_OPT_CRYPT => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Init + $v_string_list = array(); + $v_att_list = array(); + $v_filedescr_list = array(); + $p_result_list = array(); + + // ----- Look if the $p_filelist is really an array + if (is_array($p_filelist)) { + + // ----- Look if the first element is also an array + // This will mean that this is a file description entry + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { + $v_att_list = $p_filelist; + } + + // ----- The list is a list of string names + else { + $v_string_list = $p_filelist; + } + } + + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) { + // ----- Create a list from the string + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); + } + + // ----- Invalid variable type for $p_filelist + else { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Reformat the string list + if (sizeof($v_string_list) != 0) { + foreach ($v_string_list as $v_string) { + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; + } + } + + // ----- For each file in the list check the attributes + $v_supported_attributes + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' + ); + foreach ($v_att_list as $v_entry) { + $v_result = $this->privFileDescrParseAtt($v_entry, + $v_filedescr_list[], + $v_options, + $v_supported_attributes); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Expand the filelist (expand directories) + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Call the create fct + $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); + return $p_result_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : listContent() + // Description : + // This public method, gives the list of the files and directories, with their + // properties. + // The properties of each entries in the list are (used also in other functions) : + // filename : Name of the file. For a create or add action it is the filename + // given by the user. For an extract function it is the filename + // of the extracted file. + // stored_filename : Name of the file / directory stored in the archive. + // size : Size of the stored file. + // compressed_size : Size of the file's data compressed in the archive + // (without the headers overhead) + // mtime : Last known modification date of the file (UNIX timestamp) + // comment : Comment associated with the file + // folder : true | false + // index : index of the file in the archive + // status : status of the action (depending of the action) : + // Values are : + // ok : OK ! + // filtered : the file / dir is not extracted (filtered by user) + // already_a_directory : the file can not be extracted because a + // directory with the same name already exists + // write_protected : the file can not be extracted because a file + // with the same name already exists and is + // write protected + // newer_exist : the file was not extracted because a newer file exists + // path_creation_fail : the file is not extracted because the folder + // does not exists and can not be created + // write_error : the file was not extracted because there was a + // error while writing the file + // read_error : the file was not extracted because there was a error + // while reading the file + // invalid_header : the file was not extracted because of an archive + // format error (bad file header) + // Note that each time a method can continue operating when there + // is an action error on a file, the error is only logged in the file status. + // Return Values : + // 0 on an unrecoverable failure, + // The list of the files in the archive. + // -------------------------------------------------------------------------------- + function listContent() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Call the extracting fct + $p_list = array(); + if (($v_result = $this->privList($p_list)) != 1) + { + unset($p_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // extract($p_path="./", $p_remove_path="") + // extract([$p_option, $p_option_value, ...]) + // Description : + // This method supports two synopsis. The first one is historical. + // This method extract all the files / directories from the archive to the + // folder indicated in $p_path. + // If you want to ignore the 'root' part of path of the memorized files + // you can indicate this in the optional $p_remove_path parameter. + // By default, if a newer file with the same name already exists, the + // file is not extracted. + // + // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions + // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append + // at the end of the path value of PCLZIP_OPT_PATH. + // Parameters : + // $p_path : Path where the files and directories are to be extracted + // $p_remove_path : First part ('root' part) of the memorized path + // (if any similar) to remove while extracting. + // Options : + // PCLZIP_OPT_PATH : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_CB_PRE_EXTRACT : + // PCLZIP_CB_POST_EXTRACT : + // Return Values : + // 0 or a negative value on failure, + // The list of the extracted files, with a status of the action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function extract() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); +// $v_path = "./"; + $v_path = ''; + $v_remove_path = ""; + $v_remove_all_path = false; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Default values for option + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + + // ----- Look for arguments + if ($v_size > 0) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_PATH => 'optional', + PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_EXTRACT => 'optional', + PCLZIP_CB_POST_EXTRACT => 'optional', + PCLZIP_OPT_SET_CHMOD => 'optional', + PCLZIP_OPT_BY_NAME => 'optional', + PCLZIP_OPT_BY_EREG => 'optional', + PCLZIP_OPT_BY_PREG => 'optional', + PCLZIP_OPT_BY_INDEX => 'optional', + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', + PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', + PCLZIP_OPT_REPLACE_NEWER => 'optional' + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_PATH])) { + $v_path = $v_options[PCLZIP_OPT_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + // ----- Check for '/' in last path char + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { + $v_path .= '/'; + } + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_remove_path = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); + + // ----- Call the extracting fct + $p_list = array(); + $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, + $v_remove_all_path, $v_options); + if ($v_result < 1) { + unset($p_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + + // -------------------------------------------------------------------------------- + // Function : + // extractByIndex($p_index, $p_path="./", $p_remove_path="") + // extractByIndex($p_index, [$p_option, $p_option_value, ...]) + // Description : + // This method supports two synopsis. The first one is historical. + // This method is doing a partial extract of the archive. + // The extracted files or folders are identified by their index in the + // archive (from 0 to n). + // Note that if the index identify a folder, only the folder entry is + // extracted, not all the files included in the archive. + // Parameters : + // $p_index : A single index (integer) or a string of indexes of files to + // extract. The form of the string is "0,4-6,8-12" with only numbers + // and '-' for range or ',' to separate ranges. No spaces or ';' + // are allowed. + // $p_path : Path where the files and directories are to be extracted + // $p_remove_path : First part ('root' part) of the memorized path + // (if any similar) to remove while extracting. + // Options : + // PCLZIP_OPT_PATH : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and + // not as files. + // The resulting content is in a new field 'content' in the file + // structure. + // This option must be used alone (any other options are ignored). + // PCLZIP_CB_PRE_EXTRACT : + // PCLZIP_CB_POST_EXTRACT : + // Return Values : + // 0 on failure, + // The list of the extracted files, with a status of the action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + //function extractByIndex($p_index, options...) + function extractByIndex($p_index) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ..."); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); +// $v_path = "./"; + $v_path = ''; + $v_remove_path = ""; + $v_remove_all_path = false; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Default values for option + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove form the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_PATH => 'optional', + PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_EXTRACT => 'optional', + PCLZIP_CB_POST_EXTRACT => 'optional', + PCLZIP_OPT_SET_CHMOD => 'optional', + PCLZIP_OPT_REPLACE_NEWER => 'optional' + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' + )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_PATH])) { + $v_path = $v_options[PCLZIP_OPT_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + // ----- Check for '/' in last path char + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { + $v_path .= '/'; + } + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; + } + if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set."); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set."); + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + + // ----- Get the first argument + $v_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_remove_path = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); + + // ----- Trick + // Here I want to reuse extractByRule(), so I need to parse the $p_index + // with privParseOptions() + $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); + $v_options_trick = array(); + $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, + array (PCLZIP_OPT_BY_INDEX => 'optional' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; + + // ----- Call the extracting fct + if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // delete([$p_option, $p_option_value, ...]) + // Description : + // This method removes files from the archive. + // If no parameters are given, then all the archive is emptied. + // Parameters : + // None or optional arguments. + // Options : + // PCLZIP_OPT_BY_INDEX : + // PCLZIP_OPT_BY_NAME : + // PCLZIP_OPT_BY_EREG : + // PCLZIP_OPT_BY_PREG : + // Return Values : + // 0 on failure, + // The list of the files which are still present in the archive. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function delete() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", ""); + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Set default values + $v_options = array(); + + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + + // ----- Look for arguments + if ($v_size > 0) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_BY_NAME => 'optional', + PCLZIP_OPT_BY_EREG => 'optional', + PCLZIP_OPT_BY_PREG => 'optional', + PCLZIP_OPT_BY_INDEX => 'optional' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + } + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Call the delete fct + $v_list = array(); + if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { + $this->privSwapBackMagicQuotes(); + unset($v_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list); + return $v_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : deleteByIndex() + // Description : + // ***** Deprecated ***** + // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. + // -------------------------------------------------------------------------------- + function deleteByIndex($p_index) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'"); + + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : properties() + // Description : + // This method gives the properties of the archive. + // The properties are : + // nb : Number of files in the archive + // comment : Comment associated with the archive file + // status : not_exist, ok + // Parameters : + // None + // Return Values : + // 0 on failure, + // An array with the archive properties. + // -------------------------------------------------------------------------------- + function properties() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", ""); + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Default properties + $v_prop = array(); + $v_prop['comment'] = ''; + $v_prop['nb'] = 0; + $v_prop['status'] = 'not_exist'; + + // ----- Look if file exists + if (@is_file($this->zipname)) + { + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0); + return 0; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Set the user attributes + $v_prop['comment'] = $v_central_dir['comment']; + $v_prop['nb'] = $v_central_dir['entries']; + $v_prop['status'] = 'ok'; + } + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop); + return $v_prop; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : duplicate() + // Description : + // This method creates an archive by copying the content of an other one. If + // the archive already exist, it is replaced by the new one without any warning. + // Parameters : + // $p_archive : The filename of a valid archive, or + // a valid PclZip object. + // Return Values : + // 1 on success. + // 0 or a negative value on error (error code). + // -------------------------------------------------------------------------------- + function duplicate($p_archive) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", ""); + $v_result = 1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Look if the $p_archive is a PclZip object + if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'"); + + // ----- Duplicate the archive + $v_result = $this->privDuplicate($p_archive->zipname); + } + + // ----- Look if the $p_archive is a string (so a filename) + else if (is_string($p_archive)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'"); + + // ----- Check that $p_archive is a valid zip file + // TBC : Should also check the archive format + if (!is_file($p_archive)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); + $v_result = PCLZIP_ERR_MISSING_FILE; + } + else { + // ----- Duplicate the archive + $v_result = $this->privDuplicate($p_archive); + } + } + + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : merge() + // Description : + // This method merge the $p_archive_to_add archive at the end of the current + // one ($this). + // If the archive ($this) does not exist, the merge becomes a duplicate. + // If the $p_archive_to_add archive does not exist, the merge is a success. + // Parameters : + // $p_archive_to_add : It can be directly the filename of a valid zip archive, + // or a PclZip object archive. + // Return Values : + // 1 on success, + // 0 or negative values on error (see below). + // -------------------------------------------------------------------------------- + function merge($p_archive_to_add) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", ""); + $v_result = 1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + + // ----- Look if the $p_archive_to_add is a PclZip object + if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object"); + + // ----- Merge the archive + $v_result = $this->privMerge($p_archive_to_add); + } + + // ----- Look if the $p_archive_to_add is a string (so a filename) + else if (is_string($p_archive_to_add)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename"); + + // ----- Create a temporary archive + $v_object_archive = new PclZip($p_archive_to_add); + + // ----- Merge the archive + $v_result = $this->privMerge($v_object_archive); + } + + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + + + // -------------------------------------------------------------------------------- + // Function : errorCode() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorCode() + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + return(PclErrorCode()); + } + else { + return($this->error_code); + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : errorName() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorName($p_with_code=false) + { + $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', + PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', + PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', + PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', + PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', + PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', + PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', + PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', + PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', + PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', + PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', + PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', + PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', + PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', + PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', + PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', + PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', + PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', + PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' + ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' + ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' + ); + + if (isset($v_name[$this->error_code])) { + $v_value = $v_name[$this->error_code]; + } + else { + $v_value = 'NoName'; + } + + if ($p_with_code) { + return($v_value.' ('.$this->error_code.')'); + } + else { + return($v_value); + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : errorInfo() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorInfo($p_full=false) + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + return(PclErrorString()); + } + else { + if ($p_full) { + return($this->errorName(true)." : ".$this->error_string); + } + else { + return($this->error_string." [code ".$this->error_code."]"); + } + } + } + // -------------------------------------------------------------------------------- + + +// -------------------------------------------------------------------------------- +// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS ***** +// ***** ***** +// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** +// -------------------------------------------------------------------------------- + + + + // -------------------------------------------------------------------------------- + // Function : privCheckFormat() + // Description : + // This method check that the archive exists and is a valid zip archive. + // Several level of check exists. (futur) + // Parameters : + // $p_level : Level of check. Default 0. + // 0 : Check the first bytes (magic codes) (default value)) + // 1 : 0 + Check the central directory (futur) + // 2 : 1 + Check each file header (futur) + // Return Values : + // true on success, + // false on error, the error code is set. + // -------------------------------------------------------------------------------- + function privCheckFormat($p_level=0) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", ""); + $v_result = true; + + // ----- Reset the file system cache + clearstatcache(); + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Look if the file exits + if (!is_file($this->zipname)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); + return(false); + } + + // ----- Check that the file is readeable + if (!is_readable($this->zipname)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); + return(false); + } + + // ----- Check the magic code + // TBC + + // ----- Check the central header + // TBC + + // ----- Check each file header + // TBC + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privParseOptions() + // Description : + // This internal methods reads the variable list of arguments ($p_options_list, + // $p_size) and generate an array with the options and values ($v_result_list). + // $v_requested_options contains the options that can be present and those that + // must be present. + // $v_requested_options is an array, with the option value as key, and 'optional', + // or 'mandatory' as value. + // Parameters : + // See above. + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", ""); + $v_result=1; + + // ----- Read the options + $i=0; + while ($i<$p_size) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'"); + + // ----- Check if the option is supported + if (!isset($v_requested_options[$p_options_list[$i]])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for next option + switch ($p_options_list[$i]) { + // ----- Look for options that request a path value + case PCLZIP_OPT_PATH : + case PCLZIP_OPT_REMOVE_PATH : + case PCLZIP_OPT_ADD_PATH : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if ( is_string($p_options_list[$i+1]) + && ($p_options_list[$i+1] != '')) { + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored."); + } + break; + + // ----- Look for options that request an array of string for value + case PCLZIP_OPT_BY_NAME : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; + } + else if (is_array($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request an EREG or PREG expression + case PCLZIP_OPT_BY_EREG : + case PCLZIP_OPT_BY_PREG : + //case PCLZIP_OPT_CRYPT : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that takes a string + case PCLZIP_OPT_COMMENT : + case PCLZIP_OPT_ADD_COMMENT : + case PCLZIP_OPT_PREPEND_COMMENT : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, + "Missing parameter value for option '" + .PclZipUtilOptionText($p_options_list[$i]) + ."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, + "Wrong parameter value for option '" + .PclZipUtilOptionText($p_options_list[$i]) + ."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request an array of index + case PCLZIP_OPT_BY_INDEX : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_work_list = array(); + if (is_string($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'"); + + // ----- Remove spaces + $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); + + // ----- Parse items + $v_work_list = explode(",", $p_options_list[$i+1]); + } + else if (is_integer($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'"); + $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; + } + else if (is_array($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array"); + $v_work_list = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Reduce the index list + // each index item in the list must be a couple with a start and + // an end value : [0,3], [5-5], [8-10], ... + // ----- Check the format of each item + $v_sort_flag=false; + $v_sort_value=0; + for ($j=0; $j= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + + // ----- Look for options that request a call-back + case PCLZIP_CB_PRE_EXTRACT : + case PCLZIP_CB_POST_EXTRACT : + case PCLZIP_CB_PRE_ADD : + case PCLZIP_CB_POST_ADD : + /* for futur use + case PCLZIP_CB_PRE_DELETE : + case PCLZIP_CB_POST_DELETE : + case PCLZIP_CB_PRE_LIST : + case PCLZIP_CB_POST_LIST : + */ + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Get the value + $v_function_name = $p_options_list[$i+1]; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'"); + + // ----- Check that the value is a valid existing function + if (!function_exists($v_function_name)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Set the attribute + $v_result_list[$p_options_list[$i]] = $v_function_name; + $i++; + break; + + default : + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Unknown parameter '" + .$p_options_list[$i]."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Next options + $i++; + } + + // ----- Look for mandatory options + if ($v_requested_options !== false) { + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { + // ----- Look for mandatory option + if ($v_requested_options[$key] == 'mandatory') { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); + // ----- Look if present + if (!isset($v_result_list[$key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privFileDescrParseAtt() + // Description : + // Parameters : + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", ""); + $v_result=1; + + // ----- For each file in the list check the attributes + foreach ($p_file_list as $v_key => $v_value) { + + // ----- Check if the option is supported + if (!isset($v_requested_options[$v_key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for attribute + switch ($v_key) { + case PCLZIP_ATT_FILE_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['filename'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + break; + + case PCLZIP_ATT_FILE_NEW_SHORT_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['new_short_name'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + break; + + case PCLZIP_ATT_FILE_NEW_FULL_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); + + if ($p_filedescr['new_full_name'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + break; + + default : + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Unknown parameter '".$v_key."'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for mandatory options + if ($v_requested_options !== false) { + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { + // ----- Look for mandatory option + if ($v_requested_options[$key] == 'mandatory') { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); + // ----- Look if present + if (!isset($p_file_list[$key])) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + } + + // end foreach + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privFileDescrExpand() + // Description : + // Parameters : + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privFileDescrExpand(&$p_filedescr_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", ""); + $v_result=1; + + // ----- Create a result list + $v_result_list = array(); + + // ----- Look each entry + for ($i=0; $iprivCalculateStoredFilename($v_descr, $p_options); + + // ----- Add the descriptor in result list + $v_result_list[sizeof($v_result_list)] = $v_descr; + + // ----- Look for folder + if ($v_descr['type'] == 'folder') { + // ----- List of items in folder + $v_dirlist_descr = array(); + $v_dirlist_nb = 0; + if ($v_folder_handler = @opendir($v_descr['filename'])) { + while (($v_item_handler = @readdir($v_folder_handler)) !== false) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory"); + + // ----- Skip '.' and '..' + if (($v_item_handler == '.') || ($v_item_handler == '..')) { + continue; + } + + // ----- Compose the full filename + $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; + + // ----- Look for different stored filename + // Because the name of the folder was changed, the name of the + // files/sub-folders also change + if ($v_descr['stored_filename'] != $v_descr['filename']) { + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; + } + + $v_dirlist_nb++; + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped."); + // TBC : unable to open folder in read mode + } + + // ----- Expand each element of the list + if ($v_dirlist_nb != 0) { + // ----- Expand + if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Concat the resulting list + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')"); + $v_result_list = array_merge($v_result_list, $v_dirlist_descr); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand."); + } + + // ----- Free local array + unset($v_dirlist_descr); + } + } + + // ----- Get the result list + $p_filedescr_list = $v_result_list; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCreate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCreate($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list"); + $v_result=1; + $v_list_detail = array(); + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the file in write mode + if (($v_result = $this->privOpenFd('wb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Add the list of files + $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); + + // ----- Close + $this->privCloseFd(); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAdd() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAdd($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list"); + $v_result=1; + $v_list_detail = array(); + + // ----- Look if the archive exists or is empty + if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it."); + + // ----- Do a create + $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = $v_central_dir['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Swap the file descriptor + // Here is a trick : I swap the temporary fd with the zip fd, in order to use + // the following methods on the temporary fil and not the real archive + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) + { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); + + // ----- Copy the block of file headers from the old archive + $v_size = $v_central_dir['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Create the Central Dir files header + for ($i=0, $v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_count++; + } + + // ----- Transform the header to a 'usable' info + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + // ----- Zip file comment + $v_comment = $v_central_dir['comment']; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { + $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; + } + if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($this->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) + { + // ----- Reset the file list + unset($v_header_list); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back the file descriptor + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Close + $this->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privOpenFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privOpenFd($p_mode) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode); + $v_result=1; + + // ----- Look if already open + if ($this->zip_fd != 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode'); + if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCloseFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privCloseFd() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", ""); + $v_result=1; + + if ($this->zip_fd != 0) + @fclose($this->zip_fd); + $this->zip_fd = 0; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddList() + // Description : + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is + // different from the real path of the file. This is usefull if you want to have PclTar + // running in any directory, and memorize relative path from an other directory. + // Parameters : + // $p_list : An array containing the file or directory names to add in the tar + // $p_result_list : list of added files with their properties (specially the status field) + // $p_add_dir : Path to add in the filename path archived + // $p_remove_dir : Path to remove in the filename path archived + // Return Values : + // -------------------------------------------------------------------------------- +// function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) + function privAddList($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list"); + $v_result=1; + + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + + // ----- Create the Central Dir files header + for ($i=0,$v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_count++; + } + + // ----- Transform the header to a 'usable' info + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + // ----- Zip file comment + $v_comment = ''; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($this->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) + { + // ----- Reset the file list + unset($v_header_list); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFileList() + // Description : + // Parameters : + // $p_filedescr_list : An array containing the file description + // or directory names to add in the zip + // $p_result_list : list of added files with their properties (specially the status field) + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list"); + $v_result=1; + $v_header = array(); + + // ----- Recuperate the current number of elt in list + $v_nb = sizeof($p_result_list); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements"); + + // ----- Loop on the files + for ($j=0; ($jprivAddFile($p_filedescr_list[$j], $v_header, + $p_options); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the file infos + $p_result_list[$v_nb++] = $v_header; + } + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFile() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFile($p_filedescr, &$p_header, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'"); + $v_result=1; + + // ----- Working variable + $p_filename = $p_filedescr['filename']; + + // TBC : Already done in the fileAtt check ... ? + if ($p_filename == "") { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Look for a stored different filename + if (isset($p_filedescr['stored_filename'])) { + $v_stored_filename = $p_filedescr['stored_filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"'); + } + else { + $v_stored_filename = $p_filedescr['stored_filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same'); + } + + // ----- Set the file properties + clearstatcache(); + $p_header['version'] = 20; + $p_header['version_extracted'] = 10; + $p_header['flag'] = 0; + $p_header['compression'] = 0; + $p_header['mtime'] = filemtime($p_filename); + $p_header['crc'] = 0; + $p_header['compressed_size'] = 0; + $p_header['size'] = filesize($p_filename); + $p_header['filename_len'] = strlen($p_filename); + $p_header['extra_len'] = 0; + $p_header['comment_len'] = 0; + $p_header['disk'] = 0; + $p_header['internal'] = 0; +// $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); + $p_header['external'] = (is_file($p_filename)?0x00000000:0x00000010); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'"); + $p_header['offset'] = 0; + $p_header['filename'] = $p_filename; + $p_header['stored_filename'] = $v_stored_filename; + $p_header['extra'] = ''; + $p_header['comment'] = ''; + $p_header['status'] = 'ok'; + $p_header['index'] = -1; + + // ----- Look for pre-add callback + if (isset($p_options[PCLZIP_CB_PRE_ADD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_header, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_header['status'] = "skipped"; + $v_result = 1; + } + + // ----- Update the informations + // Only some fields can be modified + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { + $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'"); + } + } + + // ----- Look for empty stored filename + if ($p_header['stored_filename'] == "") { + $p_header['status'] = "filtered"; + } + + // ----- Check the path length + if (strlen($p_header['stored_filename']) > 0xFF) { + $p_header['status'] = 'filename_too_long'; + } + + // ----- Look if no error, or file not skipped + if ($p_header['status'] == 'ok') { + + // ----- Look for a file + if (is_file($p_filename)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file"); + // ----- Open the source file + if (($v_file = @fopen($p_filename, "rb")) == 0) { + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed"); + // ----- Read the file content + $v_content_compressed = @fread($v_file, $p_header['size']); + + // ----- Calculate the CRC + $p_header['crc'] = @crc32($v_content_compressed); + + // ----- Set header parameters + $p_header['compressed_size'] = $p_header['size']; + $p_header['compression'] = 0; + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed"); + // ----- Read the file content + $v_content = @fread($v_file, $p_header['size']); + + // ----- Calculate the CRC + $p_header['crc'] = @crc32($v_content); + + // ----- Compress the file + $v_content_compressed = @gzdeflate($v_content); + + // ----- Set header parameters + $p_header['compressed_size'] = strlen($v_content_compressed); + $p_header['compression'] = 8; + } + + // ----- Look for encryption + /* + if ((isset($p_options[PCLZIP_OPT_CRYPT])) + && ($p_options[PCLZIP_OPT_CRYPT] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ...."); + + // Should be a random header + $v_header = 'xxxxxxxxxxxx'; + $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed, + $p_header['compressed_size'], + $v_header, + $p_header['crc'], + "test"); + + $p_header['compressed_size'] += 12; + $p_header['flag'] = 1; + + // ----- Add the header to the data + $v_content_compressed = $v_header.$v_content_compressed; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed).""); + } + */ + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { + @fclose($v_file); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Write the compressed (or not) content + @fwrite($this->zip_fd, + $v_content_compressed, $p_header['compressed_size']); + + // ----- Close the file + @fclose($v_file); + } + + // ----- Look for a directory + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder"); + // ----- Look for directory last '/' + if (@substr($p_header['stored_filename'], -1) != '/') { + $p_header['stored_filename'] .= '/'; + } + + // ----- Set the file properties + $p_header['size'] = 0; + //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked + $p_header['external'] = 0x00000010; // Value for a folder : to be checked + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + + // ----- Look for post-add callback + if (isset($p_options[PCLZIP_CB_POST_ADD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_header, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);'); + if ($v_result == 0) { + // ----- Ignored + $v_result = 1; + } + + // ----- Update the informations + // Nothing can be modified + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCalculateStoredFilename() + // Description : + // Based on file descriptor properties and global options, this method + // calculate the filename that will be stored in the archive. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCalculateStoredFilename(&$p_filedescr, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'"); + $v_result=1; + + // ----- Working variables + $p_filename = $p_filedescr['filename']; + if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { + $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; + } + else { + $p_add_dir = ''; + } + if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { + $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; + } + else { + $p_remove_dir = ''; + } + if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + else { + $p_remove_all_dir = 0; + } + + // ----- Look for full name change + if (isset($p_filedescr['new_full_name'])) { + $v_stored_filename = $p_filedescr['new_full_name']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'"); + } + + // ----- Look for path and/or short name change + else { + + // ----- Look for short name change + if (isset($p_filedescr['new_short_name'])) { + $v_path_info = pathinfo($p_filename); + $v_dir = ''; + if ($v_path_info['dirname'] != '') { + $v_dir = $v_path_info['dirname'].'/'; + } + $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'"); + } + else { + // ----- Calculate the stored filename + $v_stored_filename = $p_filename; + } + + // ----- Look for all path to remove + if ($p_remove_all_dir) { + $v_stored_filename = basename($p_filename); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'"); + } + // ----- Look for partial path remove + else if ($p_remove_dir != "") { + if (substr($p_remove_dir, -1) != '/') + $p_remove_dir .= "/"; + + if ( (substr($p_filename, 0, 2) == "./") + || (substr($p_remove_dir, 0, 2) == "./")) { + + if ( (substr($p_filename, 0, 2) == "./") + && (substr($p_remove_dir, 0, 2) != "./")) { + $p_remove_dir = "./".$p_remove_dir; + } + if ( (substr($p_filename, 0, 2) != "./") + && (substr($p_remove_dir, 0, 2) == "./")) { + $p_remove_dir = substr($p_remove_dir, 2); + } + } + + $v_compare = PclZipUtilPathInclusion($p_remove_dir, + $v_stored_filename); + if ($v_compare > 0) { + if ($v_compare == 2) { + $v_stored_filename = ""; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'"); + $v_stored_filename = substr($v_stored_filename, + strlen($p_remove_dir)); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'"); + } + } + } + // ----- Look for path to add + if ($p_add_dir != "") { + if (substr($p_add_dir, -1) == "/") + $v_stored_filename = $p_add_dir.$v_stored_filename; + else + $v_stored_filename = $p_add_dir."/".$v_stored_filename; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'"); + } + } + + // ----- Filename (reduce the path of stored name) + $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); + $p_filedescr['stored_filename'] = $v_stored_filename; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename'])); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); + $v_result=1; + + // ----- Store the offset position of the file + $p_header['offset'] = ftell($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']); + + // ----- Transform UNIX mtime to DOS format mdate/mtime + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + $v_date = getdate($p_header['mtime']); + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; + + // ----- Packed data + $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, + $p_header['version_extracted'], $p_header['flag'], + $p_header['compression'], $v_mtime, $v_mdate, + $p_header['crc'], $p_header['compressed_size'], + $p_header['size'], + strlen($p_header['stored_filename']), + $p_header['extra_len']); + + // ----- Write the first 148 bytes of the header in the archive + fputs($this->zip_fd, $v_binary_data, 30); + + // ----- Write the variable fields + if (strlen($p_header['stored_filename']) != 0) + { + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); + } + if ($p_header['extra_len'] != 0) + { + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); + $v_result=1; + + // TBC + //for(reset($p_header); $key = key($p_header); next($p_header)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]); + //} + + // ----- Transform UNIX mtime to DOS format mdate/mtime + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + $v_date = getdate($p_header['mtime']); + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; + + // ----- Packed data + $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, + $p_header['version'], $p_header['version_extracted'], + $p_header['flag'], $p_header['compression'], + $v_mtime, $v_mdate, $p_header['crc'], + $p_header['compressed_size'], $p_header['size'], + strlen($p_header['stored_filename']), + $p_header['extra_len'], $p_header['comment_len'], + $p_header['disk'], $p_header['internal'], + $p_header['external'], $p_header['offset']); + + // ----- Write the 42 bytes of the header in the zip file + fputs($this->zip_fd, $v_binary_data, 46); + + // ----- Write the variable fields + if (strlen($p_header['stored_filename']) != 0) + { + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); + } + if ($p_header['extra_len'] != 0) + { + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); + } + if ($p_header['comment_len'] != 0) + { + fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteCentralHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"'); + $v_result=1; + + // ----- Packed data + $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, + $p_nb_entries, $p_size, + $p_offset, strlen($p_comment)); + + // ----- Write the 22 bytes of the header in the zip file + fputs($this->zip_fd, $v_binary_data, 22); + + // ----- Write the variable fields + if (strlen($p_comment) != 0) + { + fputs($this->zip_fd, $p_comment, strlen($p_comment)); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privList() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privList(&$p_list) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list"); + $v_result=1; + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of Central Dir + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_central_dir['offset'])) + { + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Read each entry + for ($i=0; $i<$v_central_dir['entries']; $i++) + { + // ----- Read the file header + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $v_header['index'] = $i; + + // ----- Get the only interesting attributes + $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); + unset($v_header); + } + + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privConvertHeader2FileInfo() + // Description : + // This function takes the file informations from the central directory + // entries and extract the interesting parameters that will be given back. + // The resulting file infos are set in the array $p_info + // $p_info['filename'] : Filename with full path. Given by user (add), + // extracted in the filesystem (extract). + // $p_info['stored_filename'] : Stored filename in the archive. + // $p_info['size'] = Size of the file. + // $p_info['compressed_size'] = Compressed size of the file. + // $p_info['mtime'] = Last modification date of the file. + // $p_info['comment'] = Comment associated with the file. + // $p_info['folder'] = true/false : indicates if the entry is a folder or not. + // $p_info['status'] = status of the action on the file. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privConvertHeader2FileInfo($p_header, &$p_info) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'"); + $v_result=1; + + // ----- Get the interesting attributes + $p_info['filename'] = $p_header['filename']; + $p_info['stored_filename'] = $p_header['stored_filename']; + $p_info['size'] = $p_header['size']; + $p_info['compressed_size'] = $p_header['compressed_size']; + $p_info['mtime'] = $p_header['mtime']; + $p_info['comment'] = $p_header['comment']; + $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); + $p_info['index'] = $p_header['index']; + $p_info['status'] = $p_header['status']; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractByRule() + // Description : + // Extract a file or directory depending of rules (by index, by name, ...) + // Parameters : + // $p_file_list : An array where will be placed the properties of each + // extracted file + // $p_path : Path to add while writing the extracted files + // $p_remove_path : Path to remove (from the file memorized path) while writing the + // extracted files. If the path does not match the file path, + // the file is extracted with its memorized path. + // $p_remove_path does not apply to 'list' mode. + // $p_path and $p_remove_path are commulative. + // Return Values : + // 1 on success,0 or less on error (see error code list) + // -------------------------------------------------------------------------------- + function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); + $v_result=1; + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Check the path + if ( ($p_path == "") + || ( (substr($p_path, 0, 1) != "/") + && (substr($p_path, 0, 3) != "../") + && (substr($p_path,1,2)!=":/"))) + $p_path = "./".$p_path; + + // ----- Reduce the path last (and duplicated) '/' + if (($p_path != "./") && ($p_path != "/")) + { + // ----- Look for the path end '/' + while (substr($p_path, -1) == "/") + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'"); + $p_path = substr($p_path, 0, strlen($p_path)-1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]"); + } + } + + // ----- Look for path to remove format (should end by /) + if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) + { + $p_remove_path .= '/'; + } + $p_remove_path_size = strlen($p_remove_path); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result = $this->privOpenFd('rb')) != 1) + { + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + + // ----- Read each entry + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'"); + + // ----- Read next Central dir entry + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_pos_entry)) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Store the index + $v_header['index'] = $i; + + // ----- Store the file position + $v_pos_entry = ftell($this->zip_fd); + + // ----- Look for the specific extract rules + $v_extract = false; + + // ----- Look for extract by name rule + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); + + // ----- Look if the filename is in the list + for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) + && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); + $v_extract = true; + } + } + // ----- Look for a filename + elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); + $v_extract = true; + } + } + } + + // ----- Look for extract by ereg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_extract = true; + } + } + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); + + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_extract = true; + } + } + + // ----- Look for extract by index rule + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); + + // ----- Look if the index is in the list + for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); + $v_extract = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); + $j_start = $j+1; + } + + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); + break; + } + } + } + + // ----- Look for no rule, which means extract all the archive + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)"); + $v_extract = true; + } + + // ----- Check compression method + if ( ($v_extract) + && ( ($v_header['compression'] != 8) + && ($v_header['compression'] != 0))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")"); + $v_header['status'] = 'unsupported_compression'; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, + "Filename '".$v_header['stored_filename']."' is " + ."compressed by an unsupported compression " + ."method (".$v_header['compression'].") "); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Check encrypted files + if (($v_extract) && (($v_header['flag'] & 1) == 1)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption"); + $v_header['status'] = 'unsupported_encryption'; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, + "Unsupported encryption for " + ." filename '".$v_header['stored_filename'] + ."'"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look for real extraction + if (($v_extract) && ($v_header['status'] != 'ok')) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract"); + $v_result = $this->privConvertHeader2FileInfo($v_header, + $p_file_list[$v_nb_extracted++]); + if ($v_result != 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $v_extract = false; + } + + // ----- Look for real extraction + if ($v_extract) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'"); + + // ----- Go to the file position + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_header['offset'])) + { + // ----- Close the zip file + $this->privCloseFd(); + + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Look for extraction as string + if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { + + // ----- Extracting the file + $v_result1 = $this->privExtractFileAsString($v_header, $v_string); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Set the file content + $p_file_list[$v_nb_extracted]['content'] = $v_string; + + // ----- Next extracted file + $v_nb_extracted++; + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + // ----- Look for extraction in standard output + elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) + && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { + // ----- Extracting the file in standard output + $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + // ----- Look for normal extraction + else { + // ----- Extracting the file + $v_result1 = $this->privExtractFile($v_header, + $p_path, $p_remove_path, + $p_remove_all_path, + $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + } + } + + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFile() + // Description : + // Parameters : + // Return Values : + // + // 1 : ... ? + // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback + // -------------------------------------------------------------------------------- + function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); + $v_result=1; + + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for all path to remove + if ($p_remove_all_path == true) { + // ----- Look for folder entry that not need to be extracted + if (($p_entry['external']&0x00000010)==0x00000010) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered"); + + $p_entry['status'] = "filtered"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed"); + // ----- Get the basename of the path + $p_entry['filename'] = basename($p_entry['filename']); + } + + // ----- Look for path to remove + else if ($p_remove_path != "") + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove"); + if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'"); + + // ----- Change the file status + $p_entry['status'] = "filtered"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $p_remove_path_size = strlen($p_remove_path); + if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'"); + + // ----- Remove the path + $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'"); + } + } + + // ----- Add the path + if ($p_path != '') { + $p_entry['filename'] = $p_path."/".$p_entry['filename']; + } + + // ----- Check a base_dir_restriction + if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction"); + $v_inclusion + = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], + $p_entry['filename']); + if ($v_inclusion == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction"); + + PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, + "Filename '".$p_entry['filename']."' is " + ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Look for specific actions while the file exist + if (file_exists($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists"); + + // ----- Look if file is a directory + if (is_dir($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory"); + + // ----- Change the file status + $p_entry['status'] = "already_a_directory"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, + "Filename '".$p_entry['filename']."' is " + ."already used by an existing directory"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + // ----- Look if file is write protected + else if (!is_writeable($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected"); + + // ----- Change the file status + $p_entry['status'] = "write_protected"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, + "Filename '".$p_entry['filename']."' exists " + ."and is write protected"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Look if the extracted file is older + else if (filemtime($p_entry['filename']) > $p_entry['mtime']) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); + // ----- Change the file status + if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) + && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced"); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced"); + $p_entry['status'] = "newer_exist"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); + + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, + "Newer version of '".$p_entry['filename']."' exists " + ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); + } + } + + // ----- Check the directory availability and create it if necessary + else { + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) + $v_dir_to_check = $p_entry['filename']; + else if (!strstr($p_entry['filename'], "/")) + $v_dir_to_check = ""; + else + $v_dir_to_check = dirname($p_entry['filename']); + + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'"); + + // ----- Change the file status + $p_entry['status'] = "path_creation_fail"; + + // ----- Return + ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + //return $v_result; + $v_result = 1; + } + } + } + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) + { + // ----- Look for not compressed file + if ($p_entry['compression'] == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); + + // ----- Change the file status + $p_entry['status'] = "write_error"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes"); + + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks + $v_size = $p_entry['compressed_size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes"); + $v_buffer = @fread($this->zip_fd, $v_read_size); + /* Try to speed up the code + $v_binary_data = pack('a'.$v_read_size, $v_buffer); + @fwrite($v_dest_file, $v_binary_data, $v_read_size); + */ + @fwrite($v_dest_file, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Closing the destination file + fclose($v_dest_file); + + // ----- Change the file mtime + touch($p_entry['filename'], $p_entry['mtime']); + + + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")"); + // ----- TBC + // Need to be finished + if (($p_entry['flag'] & 1) == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted"); + /* + // ----- Read the encryption header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes"); + $v_encryption_header = @fread($this->zip_fd, 12); + + // ----- Read the encrypted & compressed file in a buffer + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes"); + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12); + + // ----- Decrypt the buffer + $this->privDecrypt($v_encryption_header, $v_buffer, + $p_entry['compressed_size']-12, $p_entry['crc']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Buffer is '".$v_buffer."'"); + */ + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes"); + // ----- Read the compressed file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + } + + // ----- Decompress the file + $v_file_content = @gzinflate($v_buffer); + unset($v_buffer); + if ($v_file_content === FALSE) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file"); + + // ----- Change the file status + // TBC + $p_entry['status'] = "error"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); + + // ----- Change the file status + $p_entry['status'] = "write_error"; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Write the uncompressed data + @fwrite($v_dest_file, $v_file_content, $p_entry['size']); + unset($v_file_content); + + // ----- Closing the destination file + @fclose($v_dest_file); + + // ----- Change the file mtime + @touch($p_entry['filename'], $p_entry['mtime']); + } + + // ----- Look for chmod option + if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'"); + + // ----- Change the mode of the file + @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileInOutput() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileInOutput(&$p_entry, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', ""); + $v_result=1; + + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) { + // ----- Look for not compressed file + if ($p_entry['compressed_size'] == $p_entry['size']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); + + // ----- Read the file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Send the file to the output + echo $v_buffer; + unset($v_buffer); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes"); + + // ----- Read the compressed file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + $v_file_content = gzinflate($v_buffer); + unset($v_buffer); + + // ----- Send the file to the output + echo $v_file_content; + unset($v_file_content); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); + + // ----- Look for abort result + if ($v_result == 2) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileAsString() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileAsString(&$p_entry, &$p_string) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'"); + $v_result=1; + + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) + { + // ----- Look for not compressed file +// if ($p_entry['compressed_size'] == $p_entry['size']) + if ($p_entry['compression'] == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); + + // ----- Reading the file + $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')"); + + // ----- Reading the file + $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + if (($p_string = @gzinflate($v_data)) === FALSE) { + // TBC + } + } + + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + else { + // TBC : error : can not extract a folder in a string + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", ""); + $v_result=1; + + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] != 0x04034b50) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the first 42 bytes of the header + $v_binary_data = fread($this->zip_fd, 26); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 26) + { + $p_header['filename'] = ""; + $p_header['status'] = "invalid_header"; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'"); + $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); + + // ----- Get filename + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']); + $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\''); + + // ----- Get extra_fields + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']); + if ($v_data['extra_len'] != 0) { + $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); + } + else { + $p_header['extra'] = ''; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\''); + + // ----- Extract properties + $p_header['version_extracted'] = $v_data['version']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); + $p_header['compression'] = $v_data['compression']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\''); + $p_header['size'] = $v_data['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\''); + $p_header['compressed_size'] = $v_data['compressed_size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\''); + $p_header['crc'] = $v_data['crc']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\''); + $p_header['flag'] = $v_data['flag']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\''); + $p_header['filename_len'] = $v_data['filename_len']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\''); + + // ----- Recuperate date in UNIX format + $p_header['mdate'] = $v_data['mdate']; + $p_header['mtime'] = $v_data['mtime']; + if ($p_header['mdate'] && $p_header['mtime']) + { + // ----- Extract time + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; + $v_seconde = ($p_header['mtime'] & 0x001F)*2; + + // ----- Extract date + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; + $v_day = $p_header['mdate'] & 0x001F; + + // ----- Get UNIX date format + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + else + { + $p_header['mtime'] = time(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + + // TBC + //for(reset($v_data); $key = key($v_data); next($v_data)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]); + //} + + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + + // ----- Set the status field + $p_header['status'] = "ok"; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadCentralFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", ""); + $v_result=1; + + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] != 0x02014b50) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read the first 42 bytes of the header + $v_binary_data = fread($this->zip_fd, 42); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 42) + { + $p_header['filename'] = ""; + $p_header['status'] = "invalid_header"; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'"); + $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); + + // ----- Get filename + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']); + if ($p_header['filename_len'] != 0) + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); + else + $p_header['filename'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\''); + + // ----- Get extra + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']); + if ($p_header['extra_len'] != 0) + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); + else + $p_header['extra'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\''); + + // ----- Get comment + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']); + if ($p_header['comment_len'] != 0) + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); + else + $p_header['comment'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\''); + + // ----- Extract properties + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\''); + + // ----- Recuperate date in UNIX format + if ($p_header['mdate'] && $p_header['mtime']) + { + // ----- Extract time + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; + $v_seconde = ($p_header['mtime'] & 0x001F)*2; + + // ----- Extract date + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; + $v_day = $p_header['mdate'] & 0x001F; + + // ----- Get UNIX date format + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + else + { + $p_header['mtime'] = time(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + + // ----- Set default status to ok + $p_header['status'] = 'ok'; + + // ----- Look if it is a directory + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')'); + if (substr($p_header['filename'], -1) == '/') { + //$p_header['external'] = 0x41FF0010; + $p_header['external'] = 0x00000010; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\''); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCheckFileHeaders() + // Description : + // Parameters : + // Return Values : + // 1 on success, + // 0 on error; + // -------------------------------------------------------------------------------- + function privCheckFileHeaders(&$p_local_header, &$p_central_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", ""); + $v_result=1; + + // ----- Check the static values + // TBC + if ($p_local_header['filename'] != $p_central_header['filename']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed'); + } + if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed'); + } + if ($p_local_header['flag'] != $p_central_header['flag']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed'); + } + if ($p_local_header['compression'] != $p_central_header['compression']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed'); + } + if ($p_local_header['mtime'] != $p_central_header['mtime']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed'); + } + if ($p_local_header['filename_len'] != $p_central_header['filename_len']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed'); + } + + // ----- Look for flag bit 3 + if (($p_local_header['flag'] & 8) == 8) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !'); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header'); + $p_local_header['size'] = $p_central_header['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\''); + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\''); + $p_local_header['crc'] = $p_central_header['crc']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\''); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadEndCentralDir() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadEndCentralDir(&$p_central_dir) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", ""); + $v_result=1; + + // ----- Go to the end of the zip file + $v_size = filesize($this->zipname); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size"); + @fseek($this->zip_fd, $v_size); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\''); + if (@ftell($this->zip_fd) != $v_size) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- First try : look if this is an archive with no commentaries (most of the time) + // in this case the end of central dir is at 22 bytes of the file end + $v_found = 0; + if ($v_size > 26) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment'); + @fseek($this->zip_fd, $v_size-22); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\''); + if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Read for bytes + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = @unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + + // ----- Check signature + if ($v_data['id'] == 0x06054b50) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position."); + $v_found = 1; + } + + $v_pos = ftell($this->zip_fd); + } + + // ----- Go back to the maximum possible size of the Central Dir End Record + if (!$v_found) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir'); + $v_maximum_size = 65557; // 0xFFFF + 22; + if ($v_maximum_size > $v_size) + $v_maximum_size = $v_size; + @fseek($this->zip_fd, $v_size-$v_maximum_size); + if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\''); + + // ----- Read byte per byte in order to find the signature + $v_pos = ftell($this->zip_fd); + $v_bytes = 0x00000000; + while ($v_pos < $v_size) + { + // ----- Read a byte + $v_byte = @fread($this->zip_fd, 1); + + // ----- Add the byte + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); + + // ----- Compare the bytes + if ($v_bytes == 0x504b0506) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\''); + $v_pos++; + break; + } + + $v_pos++; + } + + // ----- Look if not found end of central dir + if ($v_pos == $v_size) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature"); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Read the first 18 bytes of the header + $v_binary_data = fread($this->zip_fd, 18); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 18) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Extract the values + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'"); + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'"); + $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); + + // ----- Check the global size + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']); + if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive."); + + // ----- Removed in release 2.2 see readme file + // The check of the file size is a little too strict. + // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. + // While decrypted, zip has training 0 bytes + if (0) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, + 'The central dir is not at the end of the archive.' + .' Some trailing bytes exists after the archive.'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + + // ----- Get comment + if ($v_data['comment_size'] != 0) + $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); + else + $p_central_dir['comment'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\''); + + $p_central_dir['entries'] = $v_data['entries']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\''); + $p_central_dir['disk_entries'] = $v_data['disk_entries']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\''); + $p_central_dir['offset'] = $v_data['offset']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\''); + $p_central_dir['size'] = $v_data['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\''); + $p_central_dir['disk'] = $v_data['disk']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\''); + $p_central_dir['disk_start'] = $v_data['disk_start']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\''); + + // TBC + //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]); + //} + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDeleteByRule() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDeleteByRule(&$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", ""); + $v_result=1; + $v_list_detail = array(); + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + + // ----- Scan all the files + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_pos_entry)) + { + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read each entry + $v_header_list = array(); + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')"); + + // ----- Read the file header + $v_header_list[$v_nb_extracted] = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'"); + + // ----- Store the index + $v_header_list[$v_nb_extracted]['index'] = $i; + + // ----- Look for the specific extract rules + $v_found = false; + + // ----- Look for extract by name rule + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); + + // ----- Look if the filename is in the list + for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) + && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); + $v_found = true; + } + elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ + && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory"); + $v_found = true; + } + } + // ----- Look for a filename + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); + $v_found = true; + } + } + } + + // ----- Look for extract by ereg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_found = true; + } + } + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); + + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_found = true; + } + } + + // ----- Look for extract by index rule + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); + + // ----- Look if the index is in the list + for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); + $v_found = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); + $j_start = $j+1; + } + + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); + break; + } + } + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file"); + $v_found = true; + } + + // ----- Look for deletion + if ($v_found) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted"); + unset($v_header_list[$v_nb_extracted]); + } + else + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted"); + $v_nb_extracted++; + } + } + + // ----- Look if something need to be deleted + if ($v_nb_extracted > 0) { + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Creates a temporary zip archive + $v_temp_zip = new PclZip($v_zip_temp_name); + + // ----- Open the temporary zip file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode"); + if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { + $this->privCloseFd(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look which file need to be kept + for ($i=0; $izip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + + // ----- Read the file header + $v_local_header = array(); + if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Check that local file header is same as central file header + if ($this->privCheckFileHeaders($v_local_header, + $v_header_list[$i]) != 1) { + // TBC + } + unset($v_local_header); + + // ----- Write the file header + if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'"); + + // ----- Read/write the data block + if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($v_temp_zip->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset"); + + // ----- Re-Create the Central Dir files header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory"); + for ($i=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Transform the header to a 'usable' info + $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer"); + + // ----- Zip file comment + $v_comment = ''; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { + // ----- Reset the file list + unset($v_header_list); + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Close + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Destroy the temporary archive + unset($v_temp_zip); + } + + // ----- Remove every files : reset the file + else if ($v_central_dir['entries'] != 0) { + $this->privCloseFd(); + + if (($v_result = $this->privOpenFd('wb')) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + $this->privCloseFd(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDirCheck() + // Description : + // Check if a directory exists, if not it creates it and all the parents directory + // which may be useful. + // Parameters : + // $p_dir : Directory path to check. + // Return Values : + // 1 : OK + // -1 : Unable to create directory + // -------------------------------------------------------------------------------- + function privDirCheck($p_dir, $p_is_dir=false) + { + $v_result = 1; + + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'"); + + // ----- Remove the final '/' + if (($p_is_dir) && (substr($p_dir, -1)=='/')) + { + $p_dir = substr($p_dir, 0, strlen($p_dir)-1); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'"); + + // ----- Check the directory availability + if ((is_dir($p_dir)) || ($p_dir == "")) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory"); + return 1; + } + + // ----- Extract parent directory + $p_parent_dir = dirname($p_dir); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'"); + + // ----- Just a check + if ($p_parent_dir != $p_dir) + { + // ----- Look for parent directory + if ($p_parent_dir != "") + { + if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + + // ----- Create the directory + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'"); + if (!@mkdir($p_dir, 0777)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created"); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privMerge() + // Description : + // If $p_archive_to_add does not exist, the function exit with a success result. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privMerge(&$p_archive_to_add) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'"); + $v_result=1; + + // ----- Look if the archive_to_add exists + if (!is_file($p_archive_to_add->zipname)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge."); + + // ----- Nothing to merge, so merge is a success + $v_result = 1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if the archive exists + if (!is_file($this->zipname)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add."); + + // ----- Do a duplicate + $v_result = $this->privDuplicate($p_archive_to_add->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); + + // ----- Open the archive_to_add file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode"); + if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) + { + $this->privCloseFd(); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir_to_add = array(); + if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); + @rewind($p_archive_to_add->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = $v_central_dir['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Copy the files from the archive_to_add into the temporary file + $v_size = $v_central_dir_to_add['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($v_zip_temp_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); + + // ----- Copy the block of file headers from the old archive + $v_size = $v_central_dir['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Copy the block of file headers from the archive_to_add + $v_size = $v_central_dir_to_add['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Merge the file comments + $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; + + // ----- Calculate the size of the (new) central header + $v_size = @ftell($v_zip_temp_fd)-$v_offset; + + // ----- Swap the file descriptor + // Here is a trick : I swap the temporary fd with the zip fd, in order to use + // the following methods on the temporary fil and not the real archive fd + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + @fclose($v_zip_temp_fd); + $this->zip_fd = null; + + // ----- Reset the file list + unset($v_header_list); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back the file descriptor + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Close + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDuplicate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDuplicate($p_archive_filename) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'"); + $v_result=1; + + // ----- Look if the $p_archive_filename exists + if (!is_file($p_archive_filename)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate."); + + // ----- Nothing to duplicate, so duplicate is a success. + $v_result = 1; + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('wb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) + { + $this->privCloseFd(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = filesize($p_archive_filename); + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes"); + $v_buffer = fread($v_zip_temp_fd, $v_read_size); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Close + $this->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privErrorLog() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privErrorLog($p_error_code=0, $p_error_string='') + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + PclError($p_error_code, $p_error_string); + } + else { + $this->error_code = $p_error_code; + $this->error_string = $p_error_string; + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privErrorReset() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privErrorReset() + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + PclErrorReset(); + } + else { + $this->error_code = 0; + $this->error_string = ''; + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDecrypt() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size.""); + $v_result=1; + + // ----- To Be Modified ;-) + $v_pwd = "test"; + + $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header, + $p_crc, $v_pwd); + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDisableMagicQuotes() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDisableMagicQuotes() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', ""); + $v_result=1; + + // ----- Look if function exists + if ( (!function_exists("get_magic_quotes_runtime")) + || (!function_exists("set_magic_quotes_runtime"))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if already done + if ($this->magic_quotes_status != -1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Get and memorize the magic_quote value + $this->magic_quotes_status = @get_magic_quotes_runtime(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'"); + + // ----- Disable magic_quotes + if ($this->magic_quotes_status == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes"); + @set_magic_quotes_runtime(0); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privSwapBackMagicQuotes() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privSwapBackMagicQuotes() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', ""); + $v_result=1; + + // ----- Look if function exists + if ( (!function_exists("get_magic_quotes_runtime")) + || (!function_exists("set_magic_quotes_runtime"))) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Look if something to do + if ($this->magic_quotes_status != -1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + + // ----- Swap back magic_quotes + if ($this->magic_quotes_status == 1) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes"); + @set_magic_quotes_runtime($this->magic_quotes_status); + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + } + // End of class + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathReduction() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilPathReduction($p_dir) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'"); + $v_result = ""; + + // ----- Look for not empty path + if ($p_dir != "") { + // ----- Explode path by directory names + $v_list = explode("/", $p_dir); + + // ----- Study directories from last to first + $v_skip = 0; + for ($i=sizeof($v_list)-1; $i>=0; $i--) { + // ----- Look for current path + if ($v_list[$i] == ".") { + // ----- Ignore this directory + // Should be the first $i=0, but no check is done + } + else if ($v_list[$i] == "..") { + $v_skip++; + } + else if ($v_list[$i] == "") { + // ----- First '/' i.e. root slash + if ($i == 0) { + $v_result = "/".$v_result; + if ($v_skip > 0) { + // ----- It is an invalid path, so the path is not modified + // TBC + $v_result = $p_dir; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged"); + $v_skip = 0; + } + } + // ----- Last '/' i.e. indicates a directory + else if ($i == (sizeof($v_list)-1)) { + $v_result = $v_list[$i]; + } + // ----- Double '/' inside the path + else { + // ----- Ignore only the double '//' in path, + // but not the first and last '/' + } + } + else { + // ----- Look for item to skip + if ($v_skip > 0) { + $v_skip--; + } + else { + $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); + } + } + } + + // ----- Look for skip + if ($v_skip > 0) { + while ($v_skip > 0) { + $v_result = '../'.$v_result; + $v_skip--; + } + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathInclusion() + // Description : + // This function indicates if the path $p_path is under the $p_dir tree. Or, + // said in an other way, if the file or sub-dir $p_path is inside the dir + // $p_dir. + // The function indicates also if the path is exactly the same as the dir. + // This function supports path with duplicated '/' like '//', but does not + // support '.' or '..' statements. + // Parameters : + // Return Values : + // 0 if $p_path is not inside directory $p_dir + // 1 if $p_path is inside directory $p_dir + // 2 if $p_path is exactly the same as $p_dir + // -------------------------------------------------------------------------------- + function PclZipUtilPathInclusion($p_dir, $p_path) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'"); + $v_result = 1; + + // ----- Look for path beginning by ./ + if ( ($p_dir == '.') + || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { + $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'"); + } + if ( ($p_path == '.') + || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { + $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'"); + } + + // ----- Explode dir and path by directory separator + $v_list_dir = explode("/", $p_dir); + $v_list_dir_size = sizeof($v_list_dir); + $v_list_path = explode("/", $p_path); + $v_list_path_size = sizeof($v_list_path); + + // ----- Study directories paths + $i = 0; + $j = 0; + while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'"); + + // ----- Look for empty dir (path reduction) + if ($v_list_dir[$i] == '') { + $i++; + continue; + } + if ($v_list_path[$j] == '') { + $j++; + continue; + } + + // ----- Compare the items + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different"); + $v_result = 0; + } + + // ----- Next items + $i++; + $j++; + } + + // ----- Look if everything seems to be the same + if ($v_result) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break"); + // ----- Skip all the empty items + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'"); + + if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { + // ----- There are exactly the same + $v_result = 2; + } + else if ($i < $v_list_dir_size) { + // ----- The path is shorter than the dir + $v_result = 0; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilCopyBlock() + // Description : + // Parameters : + // $p_mode : read/write compression mode + // 0 : src & dest normal + // 1 : src gzip, dest normal + // 2 : src normal, dest gzip + // 3 : src & dest gzip + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode"); + $v_result = 1; + + if ($p_mode==0) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src))); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest))); + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src))); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest))); + } + else if ($p_mode==1) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @gzread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==2) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==3) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @gzread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilRename() + // Description : + // This function tries to do a simple rename() function. If it fails, it + // tries to copy the $p_src file in a new $p_dest file and then unlink the + // first one. + // Parameters : + // $p_src : Old filename + // $p_dest : New filename + // Return Values : + // 1 on success, 0 on failure. + // -------------------------------------------------------------------------------- + function PclZipUtilRename($p_src, $p_dest) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest"); + $v_result = 1; + + // ----- Try to rename the files + if (!@rename($p_src, $p_dest)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink"); + + // ----- Try to copy & unlink the src + if (!@copy($p_src, $p_dest)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file"); + $v_result = 0; + } + else if (!@unlink($p_src)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename"); + $v_result = 0; + } + } + + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilOptionText() + // Description : + // Translate option value in text. Mainly for debug purpose. + // Parameters : + // $p_option : the option value. + // Return Values : + // The option text value. + // -------------------------------------------------------------------------------- + function PclZipUtilOptionText($p_option) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'"); + + $v_list = get_defined_constants(); + for (reset($v_list); $v_key = key($v_list); next($v_list)) { + $v_prefix = substr($v_key, 0, 10); + if (( ($v_prefix == 'PCLZIP_OPT') + || ($v_prefix == 'PCLZIP_CB_') + || ($v_prefix == 'PCLZIP_ATT')) + && ($v_list[$v_key] == $p_option)) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key); + return $v_key; + } + } + + $v_result = 'Unknown'; + + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilTranslateWinPath() + // Description : + // Translate windows path by replacing '\' by '/' and optionally removing + // drive letter. + // Parameters : + // $p_path : path to translate. + // $p_remove_disk_letter : true | false + // Return Values : + // The path translated. + // -------------------------------------------------------------------------------- + function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) + { + if (stristr(php_uname(), 'windows')) { + // ----- Look for potential disk letter + if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { + $p_path = substr($p_path, $v_position+1); + } + // ----- Change potential windows directory separator + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { + $p_path = strtr($p_path, '\\', '/'); + } + } + return $p_path; + } + // -------------------------------------------------------------------------------- + + +?> diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php new file mode 100644 index 00000000..45972a38 --- /dev/null +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -0,0 +1,336 @@ +errors = new WP_Error(); + $this->permission = umask(); + } + function connect(){ + return true; + } + function setDefaultPermissions($perm){ + $this->permission = $perm; + } + function find_base_dir($base = '.', $echo = false){ + return str_replace('\\','/',ABSPATH); + } + function get_base_dir($base = '.', $echo = false){ + return $this->find_base_dir($base, $echo); + } + function get_contents($file){ + return @file_get_contents($file); + } + function get_contents_array($file){ + return @file($file); + } + function put_contents($file,$contents,$mode=false,$type=''){ + if ( ! ($fp = @fopen($file,'w'.$type)) ) + return false; + @fwrite($fp,$contents); + @fclose($fp); + $this->chmod($file,$mode); + return true; + } + function cwd(){ + return @getcwd(); + } + function chdir($dir){ + return @chdir($dir); + } + function chgrp($file,$group,$recursive=false){ + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chgrp($file,$group); + if( ! $this->is_dir($file) ) + return @chgrp($file,$group); + //Is a directory, and we want recursive + $file = trailingslashit($file); + $filelist = $this->dirlist($file); + foreach($filelist as $filename) + $this->chgrp($file . $filename, $group, $recursive); + + return true; + } + function chmod($file,$mode=false,$recursive=false){ + if( ! $mode ) + $mode = $this->permission; + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chmod($file,$mode); + if( ! $this->is_dir($file) ) + return @chmod($file,$mode); + //Is a directory, and we want recursive + $file = trailingslashit($file); + $filelist = $this->dirlist($file); + foreach($filelist as $filename) + $this->chmod($file . $filename, $mode, $recursive); + + return true; + } + function chown($file,$owner,$recursive=false){ + if( ! $this->exists($file) ) + return false; + if( ! $recursive ) + return @chown($file,$owner); + if( ! $this->is_dir($file) ) + return @chown($file,$owner); + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chown($file.'/'.$filename,$owner,$recursive); + } + return true; + } + function owner($file){ + $owneruid = @fileowner($file); + if( ! $owneruid ) + return false; + if( !function_exists('posix_getpwuid') ) + return $owneruid; + $ownerarray = posix_getpwuid($owneruid); + return $ownerarray['name']; + } + function getchmod($file){ + return @fileperms($file); + } + function gethchmod($file){ + //From the PHP.net page for ...? + $perms = $this->getchmod($file); + if (($perms & 0xC000) == 0xC000) { + // Socket + $info = 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info = 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info = '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info = 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info = 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info = 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info = 'p'; + } else { + // Unknown + $info = 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + return $info; + } + function getnumchmodfromh($mode) { + $realmode = ""; + $legal = array("","w","r","x","-"); + $attarray = preg_split("//",$mode); + for($i=0;$i'0','r'=>'4','w'=>'2','x'=>'1'); + $mode = strtr($mode,$trans); + $newmode = ''; + $newmode .= $mode[0]+$mode[1]+$mode[2]; + $newmode .= $mode[3]+$mode[4]+$mode[5]; + $newmode .= $mode[6]+$mode[7]+$mode[8]; + return $newmode; + } + function group($file){ + $gid = @filegroup($file); + if( ! $gid ) + return false; + if( !function_exists('posix_getgrgid') ) + return $gid; + $grouparray = posix_getgrgid($gid); + return $grouparray['name']; + } + + function copy($source,$destination,$overwrite=false){ + if( ! $overwrite && $this->exists($destination) ) + return false; + return copy($source,$destination); + } + + function move($source,$destination,$overwrite=false){ + //Possible to use rename()? + if( $this->copy($source,$destination,$overwrite) && $this->exists($destination) ){ + $this->delete($source); + return true; + } else { + return false; + } + } + + function delete($file, $recursive=false){ + $file = str_replace('\\','/',$file); //for win32, occasional problems deleteing files otherwise + + if( $this->is_file($file) ) + return @unlink($file); + if( !$recursive && $this->is_dir($file) ) + return @rmdir($file); + + //At this point its a folder, and we're in recursive mode + $file = trailingslashit($file); + $filelist = $this->dirlist($file, true); + + $retval = true; + if( is_array($filelist) ) //false if no files, So check first. + foreach($filelist as $filename=>$fileinfo) + if( ! $this->delete($file . $filename, $recursive) ) + $retval = false; + + if( ! @rmdir($file) ) + return false; + return $retval; + } + + function exists($file){ + return @file_exists($file); + } + + function is_file($file){ + return @is_file($file); + } + + function is_dir($path){ + return @is_dir($path); + } + + function is_readable($file){ + return @is_readable($file); + } + + function is_writable($file){ + return @is_writable($file); + } + + function atime($file){ + return @fileatime($file); + } + + function mtime($file){ + return @filemtime($file); + } + function size($file){ + return @filesize($file); + } + + function touch($file, $time = 0, $atime = 0){ + if($time == 0) + $time = time(); + if($atime == 0) + $atime = time(); + return @touch($file,$time,$atime); + } + + function mkdir($path, $chmod = false, $chown = false, $chgrp = false){ + if( ! $chmod) + $chmod = $this->permission; + + if( !@mkdir($path,$chmod) ) + return false; + if( $chown ) + $this->chown($path,$chown); + if( $chgrp ) + $this->chgrp($path,$chgrp); + return true; + } + + function rmdir($path,$recursive=false){ + //Currently unused and untested, Use delete() instead. + if( ! $recursive ) + return @rmdir($path); + //recursive: + $filelist = $this->dirlist($path); + foreach($filelist as $filename=>$det){ + if ( '/' == substr($filename,-1,1) ) + $this->rmdir($path.'/'.$filename,$recursive); + @rmdir($filename); + } + return @rmdir($path); + } + + function dirlist($path,$incdot=false,$recursive=false){ + if( $this->is_file($path) ){ + $limitFile = basename($path); + $path = dirname($path); + } else { + $limitFile = false; + } + if( ! $this->is_dir($path) ) + return false; + + $ret = array(); + $dir = dir($path); + while (false !== ($entry = $dir->read())) { + $struc = array(); + $struc['name'] = $entry; + + if( '.' == $struc['name'] || '..' == $struc['name'] ) + continue; //Do not care about these folders. + if( '.' == $struc['name'][0] && !$incdot) + continue; + if( $limitFile && $struc['name'] != $limitFile) + continue; + + $struc['perms'] = $this->gethchmod($path.'/'.$entry); + $struc['permsn'] = $this->getnumchmodfromh($struc['perms']); + $struc['number'] = false; + $struc['owner'] = $this->owner($path.'/'.$entry); + $struc['group'] = $this->group($path.'/'.$entry); + $struc['size'] = $this->size($path.'/'.$entry); + $struc['lastmodunix']= $this->mtime($path.'/'.$entry); + $struc['lastmod'] = date('M j',$struc['lastmodunix']); + $struc['time'] = date('h:i:s',$struc['lastmodunix']); + $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; + + if ('d' == $struc['type'] ){ + if( $recursive ) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'], $incdot, $recursive); + else + $struc['files'] = array(); + } + + $ret[ $struc['name'] ] = $struc; + } + $dir->close(); + unset($dir); + return $ret; + } + + function __destruct(){ + return; + } +} +?> diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php new file mode 100644 index 00000000..32ccd07d --- /dev/null +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -0,0 +1,507 @@ +FTP_ASCII, + 'css'=>FTP_ASCII, + 'txt'=>FTP_ASCII, + 'js'=>FTP_ASCII, + 'html'=>FTP_ASCII, + 'htm'=>FTP_ASCII, + 'xml'=>FTP_ASCII, + + 'jpg'=>FTP_BINARY, + 'png'=>FTP_BINARY, + 'gif'=>FTP_BINARY, + 'bmp'=>FTP_BINARY + ); + + function WP_Filesystem_FTPext($opt='') { + $this->errors = new WP_Error(); + + //Check if possible to use ftp functions. + if ( ! extension_loaded('ftp') ) { + $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available')); + return false; + } + + // Set defaults: + if ( empty($opt['port']) ) + $this->options['port'] = 21; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('FTP hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + if ( isset($opt['base']) && ! empty($opt['base']) ) + $this->wp_base = $opt['base']; + + // Check if the options provided are OK. + if ( empty ($opt['username']) ) + $this->errors->add('empty_username', __('FTP username is required')); + else + $this->options['username'] = $opt['username']; + + if ( empty ($opt['password']) ) + $this->errors->add('empty_password', __('FTP password is required')); + else + $this->options['password'] = $opt['password']; + + $this->options['ssl'] = ( !empty($opt['ssl']) ); + } + + function connect(){ + if ( $this->options['ssl'] && function_exists('ftp_ssl_connect') ) { + $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout); + } else { + $this->link = @ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout); + } + + if ( ! $this->link ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + + if ( ! @ftp_login($this->link,$this->options['username'], $this->options['password']) ) { + $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); + return false; + } + + return true; + } + + function setDefaultPermissions($perm){ + $this->permission = $perm; + } + + function find_base_dir($base = '.',$echo = false, $loop = false) { + //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. + $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. + if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter + if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) + $abspath = $mat[1]; + } + + //Set up the base directory (Which unless specified, is the current one) + if( empty( $base ) || '.' == $base ) $base = $this->cwd(); + $base = trailingslashit($base); + + //Can we see the Current directory as part of the ABSPATH? + $location = strpos($abspath, $base); + if( false !== $location ) { + $newbase = path_join($base, substr($abspath, $location + strlen($base))); + + if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly. + if($echo) printf( __('Changing to %s') . '
      ', $newbase ); + //Check to see if it exists in that folder. + if( $this->exists($newbase . 'wp-settings.php') ){ + if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php
      ' ); + return $newbase; + } + } + } + + //Ok, Couldnt do a magic location from that particular folder level + + //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture. + $files = $this->dirlist($base); + + $arrPath = explode('/', $abspath); + foreach($arrPath as $key){ + //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, + // If its found, change into it and follow through looking for it. + // If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on. + // If it reaches the end, and still cant find it, it'll return false for the entire function. + if( isset($files[ $key ]) ){ + //Lets try that folder: + $folder = path_join($base, $key); + if($echo) printf( __('Changing to %s') . '
      ', $folder ); + $ret = $this->find_base_dir( $folder, $echo, $loop); + if( $ret ) + return $ret; + } + } + //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take. + if(isset( $files[ 'wp-settings.php' ]) ){ + if($echo) printf( __('Found %s'), $base . 'wp-settings.php
      ' ); + return $base; + } + if( $loop ) + return false;//Prevent tihs function looping again. + //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups. + return $this->find_base_dir('/', $echo, true); + } + + function get_base_dir($base = '.', $echo = false){ + if( defined('FTP_BASE') ) + $this->wp_base = FTP_BASE; + if( empty($this->wp_base) ) + $this->wp_base = $this->find_base_dir($base,$echo); + return $this->wp_base; + } + function get_contents($file,$type='',$resumepos=0){ + if( empty($type) ){ + $extension = substr(strrchr($file, "."), 1); + $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; + } + $temp = tmpfile(); + if ( ! $temp ) + return false; + if( ! @ftp_fget($this->link,$temp,$file,$type,$resumepos) ) + return false; + fseek($temp, 0); //Skip back to the start of the file being written to + $contents = ''; + while (!feof($temp)) { + $contents .= fread($temp, 8192); + } + fclose($temp); + return $contents; + } + function get_contents_array($file){ + return explode("\n",$this->get_contents($file)); + } + function put_contents($file,$contents,$type=''){ + if( empty($type) ){ + $extension = substr(strrchr($file, "."), 1); + $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; + } + $temp = tmpfile(); + if ( ! $temp ) + return false; + fwrite($temp,$contents); + fseek($temp, 0); //Skip back to the start of the file being written to + $ret = @ftp_fput($this->link,$file,$temp,$type); + fclose($temp); + return $ret; + } + function cwd(){ + $cwd = ftp_pwd($this->link); + if( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; + } + function chdir($dir){ + return @ftp_chdir($dir); + } + function chgrp($file,$group,$recursive=false){ + return false; + } + function chmod($file,$mode=false,$recursive=false){ + if( ! $mode ) + $mode = $this->permission; + if( ! $mode ) + return false; + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive || ! $this->is_dir($file) ){ + if (!function_exists('ftp_chmod')) + return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); + return @ftp_chmod($this->link,$mode,$file); + } + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chmod($file.'/'.$filename,$mode,$recursive); + } + return true; + } + function chown($file,$owner,$recursive=false){ + return false; + } + function owner($file){ + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + function getchmod($file){ + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + function gethchmod($file){ + //From the PHP.net page for ...? + $perms = $this->getchmod($file); + if (($perms & 0xC000) == 0xC000) { + // Socket + $info = 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info = 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info = '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info = 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info = 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info = 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info = 'p'; + } else { + // Unknown + $info = 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + return $info; + } + function getnumchmodfromh($mode) { + $realmode = ""; + $legal = array("","w","r","x","-"); + $attarray = preg_split("//",$mode); + for($i=0;$i'0','r'=>'4','w'=>'2','x'=>'1'); + $mode = strtr($mode,$trans); + $newmode = ''; + $newmode .= $mode[0]+$mode[1]+$mode[2]; + $newmode .= $mode[3]+$mode[4]+$mode[5]; + $newmode .= $mode[6]+$mode[7]+$mode[8]; + return $newmode; + } + function group($file){ + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + function copy($source,$destination,$overwrite=false){ + if( ! $overwrite && $this->exists($destination) ) + return false; + $content = $this->get_contents($source); + if( false === $content) + return false; + return $this->put_contents($destination,$content); + } + function move($source,$destination,$overwrite=false){ + return ftp_rename($this->link,$source,$destination); + } + + function delete($file,$recursive=false) { + if ( $this->is_file($file) ) + return @ftp_delete($this->link,$file); + if ( !$recursive ) + return @ftp_rmdir($this->link,$file); + $filelist = $this->dirlist($file); + foreach ((array) $filelist as $filename => $fileinfo) { + $this->delete($file.'/'.$filename,$recursive); + } + return @ftp_rmdir($this->link,$file); + } + + function exists($file){ + $list = ftp_rawlist($this->link,$file,false); + if( ! $list ) + return false; + return count($list) == 1 ? true : false; + } + function is_file($file){ + return $this->is_dir($file) ? false : true; + } + function is_dir($path){ + $cwd = $this->cwd(); + $result = @ftp_chdir($this->link, $path); + if( $result && $path == $this->cwd() || + $this->cwd() != $cwd ) { + @ftp_chdir($this->link, $cwd); + return true; + } + return false; + } + function is_readable($file){ + //Get dir list, Check if the file is writable by the current user?? + return true; + } + function is_writable($file){ + //Get dir list, Check if the file is writable by the current user?? + return true; + } + function atime($file){ + return false; + } + function mtime($file){ + return ftp_mdtm($this->link, $file); + } + function size($file){ + return ftp_size($this->link, $file); + } + function touch($file,$time=0,$atime=0){ + return false; + } + function mkdir($path,$chmod=false,$chown=false,$chgrp=false){ + if( !@ftp_mkdir($this->link, $path) ) + return false; + if( $chmod ) + $this->chmod($path, $chmod); + if( $chown ) + $this->chown($path, $chown); + if( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + function rmdir($path,$recursive=false){ + if( ! $recursive ) + return @ftp_rmdir($this->link, $path); + + //TODO: Recursive Directory delete, Have to delete files from the folder first. + //$dir = $this->dirlist($path); + //foreach($dir as $file) + + } + + function parselisting($line) { + $is_windows = ($this->OS_remote == FTP_OS_Windows); + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/",$line,$lucifer)) { + $b = array(); + if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix + $b['isdir'] = ($lucifer[7]==""); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount=count($lucifer); + if ($lcount<8) return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === "d"; + $b['islink'] = $lucifer[0]{0} === "l"; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ($lcount==8) { + sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); + sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); + $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); + $b['name'] = $lucifer[8]; + } + } + + return $b; + } + + function dirlist($path='.',$incdot=false,$recursive=false){ + if( $this->is_file($path) ){ + $limitFile = basename($path); + $path = dirname($path) . '/'; + } else { + $limitFile = false; + } + + $list = @ftp_rawlist($this->link , '-a ' . $path, false); + + if ( $list === false ) + return false; + + $dirlist = array(); + foreach ( $list as $k => $v ) { + $entry = $this->parselisting($v); + if ( empty($entry) ) + continue; + + if ( $entry["name"]=="." or $entry["name"]==".." ) + continue; + + $dirlist[$entry['name']] = $entry; + } + + if ( ! $dirlist ) + return false; + if ( empty($dirlist) ) + return array(); + + $ret = array(); + foreach ( $dirlist as $struc ) { + + if ( 'd' == $struc['type'] ) { + $struc['files'] = array(); + + if ( $incdot ){ + //We're including the doted starts + if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } else { //No dots + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } + //File + $ret[$struc['name']] = $struc; + } + return $ret; + } + + function __destruct(){ + if( $this->link ) + ftp_close($this->link); + } +} + +?> diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php new file mode 100644 index 00000000..53656236 --- /dev/null +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -0,0 +1,450 @@ +FTP_ASCII, + 'css'=>FTP_ASCII, + 'txt'=>FTP_ASCII, + 'js'=>FTP_ASCII, + 'html'=>FTP_ASCII, + 'htm'=>FTP_ASCII, + 'xml'=>FTP_ASCII, + + 'jpg'=>FTP_BINARY, + 'png'=>FTP_BINARY, + 'gif'=>FTP_BINARY, + 'bmp'=>FTP_BINARY + ); + + function WP_Filesystem_ftpsockets($opt='') { + $this->errors = new WP_Error(); + + //Check if possible to use ftp functions. + if( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) + return false; + $this->ftp = new ftp(); + + //Set defaults: + if ( empty($opt['port']) ) + $this->options['port'] = 21; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('FTP hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + if ( isset($opt['base']) && ! empty($opt['base']) ) + $this->wp_base = $opt['base']; + + // Check if the options provided are OK. + if ( empty ($opt['username']) ) + $this->errors->add('empty_username', __('FTP username is required')); + else + $this->options['username'] = $opt['username']; + + if ( empty ($opt['password']) ) + $this->errors->add('empty_password', __('FTP password is required')); + else + $this->options['password'] = $opt['password']; + } + + function connect() { + if ( ! $this->ftp ) + return false; + + //$this->ftp->Verbose = true; + + if ( ! $this->ftp->SetServer($this->options['hostname'], $this->options['port']) ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + if ( ! $this->ftp->connect() ) { + $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); + return false; + } + + if ( ! $this->ftp->login($this->options['username'], $this->options['password']) ) { + $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); + return false; + } + + $this->ftp->SetType(FTP_AUTOASCII); + $this->ftp->Passive(true); + return true; + } + + function setDefaultPermissions($perm) { + $this->permission = $perm; + } + + function find_base_dir($base = '.',$echo = false, $loop = false) { + //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. + $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. + if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter + if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) + $abspath = $mat[1]; + } + + //Set up the base directory (Which unless specified, is the current one) + if( empty( $base ) || '.' == $base ) $base = $this->cwd(); + $base = trailingslashit($base); + + //Can we see the Current directory as part of the ABSPATH? + $location = strpos($abspath, $base); + if( false !== $location ) { + $newbase = path_join($base, substr($abspath, $location + strlen($base))); + + if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly. + if($echo) printf( __('Changing to %s') . '
      ', $newbase ); + //Check to see if it exists in that folder. + if( $this->exists($newbase . 'wp-settings.php') ){ + if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php
      ' ); + return $newbase; + } + } + } + + //Ok, Couldnt do a magic location from that particular folder level + + //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture. + $files = $this->dirlist($base); + + $arrPath = explode('/', $abspath); + foreach($arrPath as $key){ + //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, + // If its found, change into it and follow through looking for it. + // If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on. + // If it reaches the end, and still cant find it, it'll return false for the entire function. + if( isset($files[ $key ]) ){ + //Lets try that folder: + $folder = path_join($base, $key); + if($echo) printf( __('Changing to %s') . '
      ', $folder ); + $ret = $this->find_base_dir( $folder, $echo, $loop); + if( $ret ) + return $ret; + } + } + //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take. + if(isset( $files[ 'wp-settings.php' ]) ){ + if($echo) printf( __('Found %s'), $base . 'wp-settings.php
      ' ); + return $base; + } + if( $loop ) + return false;//Prevent tihs function looping again. + //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups. + return $this->find_base_dir('/', $echo, true); + } + + function get_base_dir($base = '.', $echo = false){ + if( defined('FTP_BASE') ) + $this->wp_base = FTP_BASE; + if( empty($this->wp_base) ) + $this->wp_base = $this->find_base_dir($base, $echo); + return $this->wp_base; + } + + function get_contents($file,$type='',$resumepos=0){ + if( ! $this->exists($file) ) + return false; + + if( empty($type) ){ + $extension = substr(strrchr($file, "."), 1); + $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII; + } + $this->ftp->SetType($type); + $temp = tmpfile(); + if ( ! $temp ) + return false; + if ( ! $this->ftp->fget($temp, $file) ) { + fclose($temp); + return ''; //Blank document, File does exist, Its just blank. + } + fseek($temp, 0); //Skip back to the start of the file being written to + $contents = ''; + while ( !feof($temp) ) + $contents .= fread($temp, 8192); + fclose($temp); + return $contents; + } + + function get_contents_array($file){ + return explode("\n",$this->get_contents($file)); + } + + function put_contents($file,$contents,$type=''){ + if( empty($type) ){ + $extension = substr(strrchr($file, "."), 1); + $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; + } + $this->ftp->SetType($type); + + $temp = tmpfile(); + if ( ! $temp ) + return false; + fwrite($temp,$contents); + fseek($temp, 0); //Skip back to the start of the file being written to + $ret = $this->ftp->fput($file, $temp); + fclose($temp); + return $ret; + } + + function cwd(){ + $cwd = $this->ftp->pwd(); + if( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; + } + + function chdir($file){ + return $this->ftp->chdir($file); + } + + function chgrp($file,$group,$recursive=false){ + return false; + } + + function chmod($file,$mode=false,$recursive=false){ + if( ! $mode ) + $mode = $this->permission; + if( ! $mode ) + return false; + //if( ! $this->exists($file) ) + // return false; + if( ! $recursive || ! $this->is_dir($file) ){ + return $this->ftp->chmod($file,$mode); + } + //Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach($filelist as $filename){ + $this->chmod($file.'/'.$filename,$mode,$recursive); + } + return true; + } + + function chown($file,$owner,$recursive=false){ + return false; + } + + function owner($file){ + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + + function getchmod($file){ + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + + function gethchmod($file){ + //From the PHP.net page for ...? + $perms = $this->getchmod($file); + if (($perms & 0xC000) == 0xC000) { + // Socket + $info = 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info = 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info = '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info = 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info = 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info = 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info = 'p'; + } else { + // Unknown + $info = 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + return $info; + } + + function getnumchmodfromh($mode) { + $realmode = ""; + $legal = array("","w","r","x","-"); + $attarray = preg_split("//",$mode); + for($i=0;$i'0','r'=>'4','w'=>'2','x'=>'1'); + $mode = strtr($mode,$trans); + $newmode = ''; + $newmode .= $mode[0]+$mode[1]+$mode[2]; + $newmode .= $mode[3]+$mode[4]+$mode[5]; + $newmode .= $mode[6]+$mode[7]+$mode[8]; + return $newmode; + } + + function group($file){ + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + + function copy($source,$destination,$overwrite=false){ + if( ! $overwrite && $this->exists($destination) ) + return false; + + $content = $this->get_contents($source); + if ( false === $content ) + return false; + + return $this->put_contents($destination,$content); + } + + function move($source,$destination,$overwrite=false){ + return $this->ftp->rename($source,$destination); + } + + function delete($file,$recursive=false) { + if ( $this->is_file($file) ) + return $this->ftp->delete($file); + if ( !$recursive ) + return $this->ftp->rmdir($file); + + return $this->ftp->mdel($file); + } + + function exists($file){ + return $this->ftp->is_exists($file); + } + + function is_file($file){ + return $this->is_dir($file) ? false : true; + } + + function is_dir($path){ + $cwd = $this->cwd(); + if ( $this->chdir($path) ) { + $this->chdir($cwd); + return true; + } + return false; + } + + function is_readable($file){ + //Get dir list, Check if the file is writable by the current user?? + return true; + } + + function is_writable($file){ + //Get dir list, Check if the file is writable by the current user?? + return true; + } + + function atime($file){ + return false; + } + + function mtime($file){ + return $this->ftp->mdtm($file); + } + + function size($file){ + return $this->ftp->filesize($file); + } + + function touch($file,$time=0,$atime=0){ + return false; + } + + function mkdir($path,$chmod=false,$chown=false,$chgrp=false){ + if( ! $this->ftp->mkdir($path) ) + return false; + if( $chmod ) + $this->chmod($path, $chmod); + if( $chown ) + $this->chown($path, $chown); + if( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + + function rmdir($path,$recursive=false){ + if( ! $recursive ) + return $this->ftp->rmdir($path); + + return $this->ftp->mdel($path); + } + + function dirlist($path='.',$incdot=false,$recursive=false){ + if( $this->is_file($path) ){ + $limitFile = basename($path); + $path = dirname($path) . '/'; + } else { + $limitFile = false; + } + + $list = $this->ftp->dirlist($path); + if( ! $list ) + return false; + if( empty($list) ) + return array(); + + $ret = array(); + foreach ( $list as $struc ) { + + if ( 'd' == $struc['type'] ) { + $struc['files'] = array(); + + if ( $incdot ){ + //We're including the doted starts + if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } else { //No dots + if ($recursive) + $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); + } + } + //File + $ret[$struc['name']] = $struc; + } + return $ret; + } + + function __destruct(){ + $this->ftp->quit(); + } +} +?> diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php index ae0d1d96..0f2aa614 100644 --- a/wp-admin/includes/comment.php +++ b/wp-admin/includes/comment.php @@ -8,9 +8,7 @@ function comment_exists($comment_author, $comment_date) { } function edit_comment() { - global $user_ID; - $comment_ID = (int) $_POST['comment_ID']; $comment_post_ID = (int) $_POST['comment_post_ID']; if (!current_user_can( 'edit_post', $comment_post_ID )) @@ -23,6 +21,14 @@ function edit_comment() { $_POST['comment_content'] = $_POST['content']; $_POST['comment_ID'] = (int) $_POST['comment_ID']; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; @@ -60,9 +66,50 @@ function get_comment_to_edit( $id ) { function get_pending_comments_num( $post_id ) { global $wpdb; - $post_id = (int) $post_id; - $pending = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '0'" ); - return $pending; + + $single = false; + if ( !is_array($post_id) ) { + $post_id = (array) $post_id; + $single = true; + } + $post_id = array_map('intval', $post_id); + $post_id = "'" . implode("', '", $post_id) . "'"; + + $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_N ); + + if ( empty($pending) ) + return 0; + + if ( $single ) + return $pending[0][1]; + + $pending_keyed = array(); + foreach ( $pending as $pend ) + $pending_keyed[$pend[0]] = $pend[1]; + + return $pending_keyed; +} + +// Add avatars to relevant places in admin, or try to + +function floated_admin_avatar( $name ) { + global $comment; + + $id = $avatar = false; + if ( $comment->comment_author_email ) + $id = $comment->comment_author_email; + if ( $comment->user_id ) + $id = $comment->user_id; + + if ( $id ) + $avatar = get_avatar( $id, 32 ); + + return "$avatar $name"; +} + +if ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) { + if ( get_option('show_avatars') ) + add_filter( 'comment_author', 'floated_admin_avatar' ); } -?> \ No newline at end of file +?> diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php new file mode 100644 index 00000000..9ce9db91 --- /dev/null +++ b/wp-admin/includes/dashboard.php @@ -0,0 +1,541 @@ + 'WordPress Dashboard', + 'id' => 'wp_dashboard', + 'before_widget' => "\t
      \n\n\t\t
      \n\n", + 'after_widget' => "\t\t
      \n\n\t
      \n\n", + 'before_title' => "\t\t\t

      ", + 'after_title' => "

      \n\n" + ) ); + + + /* Register Widgets and Controls */ + + // Recent Comments Widget + if ( current_user_can( 'moderate_comments' ) && $mod_comments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'") ) { + $notice = sprintf( __ngettext( '%d comment awaiting moderation', '%d comments awaiting moderation', $mod_comments ), $mod_comments ); + $notice = "$notice"; + } else { + $notice = ''; + } + wp_register_sidebar_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments', + array( 'all_link' => 'edit-comments.php', 'notice' => $notice, 'width' => 'half' ) + ); + + // Incoming Links Widget + if ( !isset( $widget_options['dashboard_incoming_links'] ) ) { + $update = true; + $widget_options['dashboard_incoming_links'] = array( + 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'url' => apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'items' => 5, + 'show_date' => 0 + ); + } + wp_register_sidebar_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_empty', + array( 'all_link' => $widget_options['dashboard_incoming_links']['link'], 'feed_link' => $widget_options['dashboard_incoming_links']['url'], 'width' => 'half' ), + 'wp_dashboard_cached_rss_widget', 'wp_dashboard_incoming_links_output' + ); + wp_register_widget_control( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_rss_control', array(), + array( 'widget_id' => 'dashboard_incoming_links', 'form_inputs' => array( 'title' => false, 'show_summary' => false, 'show_author' => false ) ) + ); + + + // WP Plugins Widget + wp_register_sidebar_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_empty', + array( 'all_link' => 'http://wordpress.org/extend/plugins/', 'feed_link' => 'http://wordpress.org/extend/plugins/rss/topics/', 'width' => 'half' ), + 'wp_dashboard_cached_rss_widget', 'wp_dashboard_plugins_output', + array( 'http://wordpress.org/extend/plugins/rss/browse/popular/', 'http://wordpress.org/extend/plugins/rss/browse/new/', 'http://wordpress.org/extend/plugins/rss/browse/updated/' ) + ); + + // Primary feed (Dev Blog) Widget + if ( !isset( $widget_options['dashboard_primary'] ) ) { + $update = true; + $widget_options['dashboard_primary'] = array( + 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/development/' ) ), + 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/development/feed/' ) ), + 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Development Blog' ) ), + 'items' => 2, + 'show_summary' => 1, + 'show_author' => 0, + 'show_date' => 1 + ); + } + wp_register_sidebar_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_empty', + array( 'all_link' => $widget_options['dashboard_primary']['link'], 'feed_link' => $widget_options['dashboard_primary']['url'], 'width' => 'half', 'class' => 'widget_rss' ), + 'wp_dashboard_cached_rss_widget', 'wp_dashboard_rss_output' + ); + wp_register_widget_control( 'dashboard_primary', __( 'Primary Feed' ), 'wp_dashboard_rss_control', array(), + array( 'widget_id' => 'dashboard_primary' ) + ); + + + // Secondary Feed (Planet) Widget + if ( !isset( $widget_options['dashboard_secondary'] ) ) { + $update = true; + $widget_options['dashboard_secondary'] = array( + 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), + 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), + 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), + 'items' => 15 + ); + } + wp_register_sidebar_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_empty', + array( 'all_link' => $widget_options['dashboard_secondary']['link'], 'feed_link' => $widget_options['dashboard_secondary']['url'], 'width' => 'full' ), + 'wp_dashboard_cached_rss_widget', 'wp_dashboard_secondary_output' + ); + wp_register_widget_control( 'dashboard_secondary', __( 'Secondary Feed' ), 'wp_dashboard_rss_control', array(), + array( 'widget_id' => 'dashboard_secondary', 'form_inputs' => array( 'show_summary' => false, 'show_author' => false, 'show_date' => false ) ) + ); + + + /* Dashboard Widget Template + wp_register_sidebar_widget( $widget_id (unique slug) , $widget_title, $output_callback, + array( + 'all_link' => full url for "See All" link, + 'feed_link' => full url for "RSS" link, + 'width' => 'fourth', 'third', 'half', 'full' (defaults to 'half'), + 'height' => 'single', 'double' (defaults to 'single'), + ), + $wp_dashboard_empty_callback (only needed if using 'wp_dashboard_empty' as your $output_callback), + $arg, $arg, $arg... (further args passed to callbacks) + ); + + // optional: if you want users to be able to edit the settings of your widget, you need to register a widget_control + wp_register_widget_control( $widget_id, $widget_control_title, $control_output_callback, + array(), // leave an empty array here: oddity in widget code + array( + 'widget_id' => $widget_id, // Yes - again. This is required: oddity in widget code + 'arg' => an arg to pass to the $control_output_callback, + 'another' => another arg to pass to the $control_output_callback, + ... + ) + ); + */ + + // Hook to register new widgets + do_action( 'wp_dashboard_setup' ); + + // Hard code the sidebar's widgets and order + $dashboard_widgets = array(); + $dashboard_widgets[] = 'dashboard_recent_comments'; + $dashboard_widgets[] = 'dashboard_incoming_links'; + $dashboard_widgets[] = 'dashboard_primary'; + if ( current_user_can( 'activate_plugins' ) ) + $dashboard_widgets[] = 'dashboard_plugins'; + $dashboard_widgets[] = 'dashboard_secondary'; + + // Filter widget order + $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', $dashboard_widgets ); + + $wp_dashboard_sidebars = array( 'wp_dashboard' => $dashboard_widgets, 'array_version' => 3.5 ); + + add_filter( 'dynamic_sidebar_params', 'wp_dashboard_dynamic_sidebar_params' ); + + if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { + ob_start(); // hack - but the same hack wp-admin/widgets.php uses + wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); + ob_end_clean(); + wp_redirect( remove_query_arg( 'edit' ) ); + exit; + } + + if ( $update ) + update_option( 'dashboard_widget_options', $widget_options ); +} + +// Echoes out the dashboard +function wp_dashboard() { + echo "
      \n\n"; + + // We're already filtering dynamic_sidebar_params obove + add_filter( 'option_sidebars_widgets', 'wp_dashboard_sidebars_widgets' ); // here there be hackery + dynamic_sidebar( 'wp_dashboard' ); + remove_filter( 'option_sidebars_widgets', 'wp_dashboard_sidebars_widgets' ); + + echo "
      \n
      \n\n\n"; +} + +// Makes sidebar_widgets option reflect the dashboard settings +function wp_dashboard_sidebars_widgets() { // hackery + return $GLOBALS['wp_dashboard_sidebars']; +} + +// Modifies sidbar params on the fly to set up ids, class names, titles for each widget (called once per widget) +// Switches widget to edit mode if $_GET['edit'] +function wp_dashboard_dynamic_sidebar_params( $params ) { + global $wp_registered_widgets, $wp_registered_widget_controls; + + $sidebar_defaults = array('widget_id' => 0, 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => ''); + extract( $sidebar_defaults, EXTR_PREFIX_ALL, 'sidebar' ); + extract( $params[0], EXTR_PREFIX_ALL, 'sidebar' ); + + if ( !isset($wp_registered_widgets[$sidebar_widget_id]) || !is_array($wp_registered_widgets[$sidebar_widget_id]) ) { + return $params; + } + $widget_defaults = array('id' => '', 'width' => '', 'height' => '', 'class' => '', 'feed_link' => '', 'all_link' => '', 'notice' => false, 'error' => false); + extract( $widget_defaults, EXTR_PREFIX_ALL, 'widget' ); + extract( $wp_registered_widgets[$sidebar_widget_id], EXTR_PREFIX_ALL, 'widget' ); + + $the_classes = array(); + if ( in_array($widget_width, array( 'third', 'fourth', 'full' ) ) ) + $the_classes[] = $widget_width; + + if ( 'double' == $widget_height ) + $the_classes[] = 'double'; + + if ( $widget_class ) + $the_classes[] = $widget_class; + + // Add classes to the widget holder + if ( $the_classes ) + $sidebar_before_widget = str_replace( "
      ' . __( 'See All' ) . ''; + + $content_class = 'dashboard-widget-content'; + if ( current_user_can( 'edit_dashboard' ) && isset($wp_registered_widget_controls[$widget_id]) && is_callable($wp_registered_widget_controls[$widget_id]['callback']) ) { + // Switch this widget to edit mode + if ( isset($_GET['edit']) && $_GET['edit'] == $widget_id ) { + $content_class .= ' dashboard-widget-control'; + $wp_registered_widgets[$widget_id]['callback'] = 'wp_dashboard_empty'; + $sidebar_widget_name = $wp_registered_widget_controls[$widget_id]['name']; + $params[1] = 'wp_dashboard_trigger_widget_control'; + $sidebar_before_widget .= '
      '; + $sidebar_after_widget = "
      $sidebar_after_widget"; + $links[] = '' . __( 'Cancel' ) . ''; + } else { + $links[] = '' . __( 'Edit' ) . ''; + } + } + + if ( $widget_feed_link ) + $links[] = '' . __( 'rss icon' ) . ' ' . __( 'RSS' ) . ''; + + $links = apply_filters( "wp_dashboard_widget_links_$widget_id", $links ); + + // Add links to widget's title bar + if ( $links ) { + $sidebar_before_title .= ''; + $sidebar_after_title = '' . join( ' | ', $links ) . "
      $sidebar_after_title"; + } + + // Could have put this in widget-content. Doesn't really matter + if ( $widget_notice ) + $sidebar_after_title .= "\t\t\t
      $widget_notice
      \n\n"; + + if ( $widget_error ) + $sidebar_after_title .= "\t\t\t
      $widget_error
      \n\n"; + + $sidebar_after_title .= "\t\t\t
      \n\n"; + + $sidebar_after_widget .= "\t\t\t
      \n\n"; + + foreach( array_keys( $params[0] ) as $key ) + $$key = ${'sidebar_' . $key}; + + $params[0] = compact( array_keys( $params[0] ) ); + + return $params; +} + + +/* Dashboard Widgets */ + +function wp_dashboard_recent_comments( $sidebar_args ) { + global $comment; + extract( $sidebar_args, EXTR_SKIP ); + + echo $before_widget; + + echo $before_title; + echo $widget_name; + echo $after_title; + + $lambda = create_function( '', 'return 5;' ); + add_filter( 'option_posts_per_rss', $lambda ); // hack - comments query doesn't accept per_page parameter + $comments_query = new WP_Query('feed=rss2&withcomments=1'); + remove_filter( 'option_posts_per_rss', $lambda ); + + $is_first = true; + + if ( $comments_query->have_comments() ) { + while ( $comments_query->have_comments() ) { $comments_query->the_comment(); + + $comment_post_url = get_permalink( $comment->comment_post_ID ); + $comment_post_title = get_the_title( $comment->comment_post_ID ); + $comment_post_link = "$comment_post_title"; + $comment_link = '#'; + $comment_meta = sprintf( __( 'From %1$s on %2$s %3$s' ), get_comment_author(), $comment_post_link, $comment_link ); + + if ( $is_first ) : $is_first = false; +?> +

      +

      +comment_count > 1 ) : ?> +
        + + +
      • +comment_count > 1 ) : ?> +
      +items) && 1 < count($rss->items) ) {// Technorati returns a 1-item feed when it has no results + + echo "
        \n"; + + $rss->items = array_slice($rss->items, 0, $items); + foreach ( $rss->items as $item ) { + $publisher = ''; + $site_link = ''; + $link = ''; + $content = ''; + $date = ''; + $link = clean_url( strip_tags( $item['link'] ) ); + + if ( isset( $item['author_uri'] ) ) + $site_link = clean_url( strip_tags( $item['author_uri'] ) ); + + if ( !$publisher = wp_specialchars( strip_tags( isset($item['dc']['publisher']) ? $item['dc']['publisher'] : $item['author_name'] ) ) ) + $publisher = __( 'Somebody' ); + if ( $site_link ) + $publisher = "$publisher"; + else + $publisher = "$publisher"; + + if ( isset($item['description']) ) + $content = $item['description']; + elseif ( isset($item['summary']) ) + $content = $item['summary']; + elseif ( isset($item['atom_content']) ) + $content = $item['atom_content']; + else + $content = __( 'something' ); + $content = wp_html_excerpt($content, 50) . ' ...'; + if ( $link ) + $text = _c( '%1$s linked here saying, "%3$s"|feed_display' ); + else + $text = _c( '%1$s linked here saying, "%3$s"|feed_display' ); + + if ( $show_date ) { + if ( $show_author || $show_summary ) + $text .= _c( ' on %4$s|feed_display' ); + $date = wp_specialchars( strip_tags( isset($item['pubdate']) ? $item['pubdate'] : $item['published'] ) ); + $date = strtotime( $date ); + $date = gmdate( get_option( 'date_format' ), $date ); + } + + echo "\t
      • " . sprintf( _c( "$text|feed_display" ), $publisher, $link, $content, $date ) . "
      • \n"; + } + + echo "
      \n"; + + } else { + echo '

      ' . __('This dashboard widget queries Google Blog Search so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "

      \n"; + } +} + +// $sidebar_args are handled by wp_dashboard_empty() +function wp_dashboard_rss_output( $widget_id ) { + $widgets = get_option( 'dashboard_widget_options' ); + wp_widget_rss_output( $widgets[$widget_id] ); +} + +// $sidebar_args are handled by wp_dashboard_empty() +function wp_dashboard_secondary_output() { + $widgets = get_option( 'dashboard_widget_options' ); + @extract( @$widgets['dashboard_secondary'], EXTR_SKIP ); + $rss = @fetch_rss( $url ); + if ( !isset($rss->items) || 0 == count($rss->items) ) + return false; + + echo "
        \n"; + + $rss->items = array_slice($rss->items, 0, $items); + foreach ($rss->items as $item ) { + $title = wp_specialchars($item['title']); + $author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] ); + $post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] ); + $link = clean_url($item['link']); + + echo "\t
      • $post$author
      • \n"; + } + + echo "
      \n
      \n"; +} + +// $sidebar_args are handled by wp_dashboard_empty() +function wp_dashboard_plugins_output() { + $popular = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/popular/' ); + $new = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/new/' ); + $updated = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/updated/' ); + + foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) { + if ( !isset($$feed->items) || 0 == count($$feed->items) ) + continue; + + $$feed->items = array_slice($$feed->items, 0, 5); + $item_key = array_rand($$feed->items); + + // Eliminate some common badly formed plugin descriptions + while ( ( null !== $item_key = array_rand($$feed->items) ) && false !== strpos( $$feed->items[$item_key]['description'], 'Plugin Name:' ) ) + unset($$feed->items[$item_key]); + + if ( !isset($$feed->items[$item_key]) ) + continue; + + $item = $$feed->items[$item_key]; + + // current bbPress feed item titles are: user on "topic title" + if ( preg_match( '/"(.*)"/s', $item['title'], $matches ) ) + $title = $matches[1]; + else // but let's make it forward compatible if things change + $title = $item['title']; + $title = wp_specialchars( $title ); + + $description = wp_specialchars( strip_tags(html_entity_decode($item['description'], ENT_QUOTES)) ); + + list($link, $frag) = explode( '#', $item['link'] ); + + $link = clean_url($link); + $dlink = rtrim($link, '/') . '/download/'; + + echo "

      $label

      \n"; + echo "
      $title
       (" . __( 'Download' ) . ")\n"; + echo "

      $description

      \n"; + } +} + +// Checks to see if all of the feed url in $check_urls are cached. +// If $check_urls is empty, look for the rss feed url found in the dashboard widget optios of $widget_id. +// If cached, call $callback, a function that echoes out output for this widget. +// If not cache, echo a "Loading..." stub which is later replaced by AJAX call (see top of /wp-admin/index.php) +function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { + $loading = '

      ' . __( 'Loading…' ) . '

      '; + + if ( empty($check_urls) ) { + $widgets = get_option( 'dashboard_widget_options' ); + if ( empty($widgets[$widget_id]['url']) ) { + echo $loading; + return false; + } + $check_urls = array( $widgets[$widget_id]['url'] ); + } + + + require_once( ABSPATH . WPINC . '/rss.php' ); + init(); // initialize rss constants + + $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); + + foreach ( $check_urls as $check_url ) { + $status = $cache->check_cache( $check_url ); + if ( 'HIT' !== $status ) { + echo $loading; + return false; + } + } + + if ( $callback && is_callable( $callback ) ) { + $args = array_slice( func_get_args(), 2 ); + array_unshift( $args, $widget_id ); + call_user_func_array( $callback, $args ); + } + + return true; +} + +// Empty widget used for JS/AJAX created output. +// Callback inserts content between before_widget and after_widget. Used when widget is in edit mode. Can also be used for custom widgets. +function wp_dashboard_empty( $sidebar_args, $callback = false ) { + extract( $sidebar_args, EXTR_SKIP ); + + echo $before_widget; + + echo $before_title; + echo $widget_name; + echo $after_title; + + // When in edit mode, the callback passed to this function is the widget_control callback + if ( $callback && is_callable( $callback ) ) { + $args = array_slice( func_get_args(), 2 ); + array_unshift( $args, $widget_id ); + call_user_func_array( $callback, $args ); + } + + echo $after_widget; +} + +/* Dashboard Widgets Controls. Ssee also wp_dashboard_empty() */ + +// Calls widget_control callback +function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { + global $wp_registered_widget_controls; + if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_registered_widget_controls[$widget_control_id]) && is_callable($wp_registered_widget_controls[$widget_control_id]['callback']) ) + call_user_func_array( $wp_registered_widget_controls[$widget_control_id]['callback'], $wp_registered_widget_controls[$widget_control_id]['params'] ); +} + +// Sets up $args to be used as input to wp_widget_rss_form(), handles POST data from RSS-type widgets +function wp_dashboard_rss_control( $args ) { + extract( $args ); + if ( !$widget_id ) + return false; + + if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) + $widget_options = array(); + + if ( !isset($widget_options[$widget_id]) ) + $widget_options[$widget_id] = array(); + + $number = 1; // Hack to use wp_widget_rss_form() + $widget_options[$widget_id]['number'] = $number; + + if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { + $_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] ); + $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); + // title is optional. If black, fill it if possible + if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { + require_once(ABSPATH . WPINC . '/rss.php'); + $rss = fetch_rss($widget_options[$widget_id]['url']); + $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->channel['title'])); + } + update_option( 'dashboard_widget_options', $widget_options ); + } + + wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); +} + +?> diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php new file mode 100644 index 00000000..96239af9 --- /dev/null +++ b/wp-admin/includes/export.php @@ -0,0 +1,255 @@ +get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); + +$categories = (array) get_categories('get=all'); +$tags = (array) get_tags('get=all'); + +function wxr_missing_parents($categories) { + if ( !is_array($categories) || empty($categories) ) + return array(); + + foreach ( $categories as $category ) + $parents[$category->term_id] = $category->parent; + + $parents = array_unique(array_diff($parents, array_keys($parents))); + + if ( $zero = array_search('0', $parents) ) + unset($parents[$zero]); + + return $parents; +} + +while ( $parents = wxr_missing_parents($categories) ) { + $found_parents = get_categories("include=" . join(', ', $parents)); + if ( is_array($found_parents) && count($found_parents) ) + $categories = array_merge($categories, $found_parents); + else + break; +} + +// Put them in order to be inserted with no child going before its parent +$pass = 0; +$passes = 1000 + count($categories); +while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) { + if ( $cat->parent == 0 || isset($cats[$cat->parent]) ) { + $cats[$cat->term_id] = $cat; + } else { + $categories[] = $cat; + } +} +unset($categories); + +function wxr_cdata($str) { + if ( seems_utf8($str) == false ) + $str = utf8_encode($str); + + // $str = ent2ncr(wp_specialchars($str)); + + $str = ""; + + return $str; +} + +function wxr_site_url() { + global $current_site; + + // mu: the base url + if ( isset($current_site->domain) ) { + return 'http://'.$current_site->domain.$current_site->path; + } + // wp: the blog url + else { + return get_bloginfo_rss('url'); + } +} + +function wxr_cat_name($c) { + if ( empty($c->name) ) + return; + + echo '' . wxr_cdata($c->name) . ''; +} + +function wxr_category_description($c) { + if ( empty($c->description) ) + return; + + echo '' . wxr_cdata($c->description) . ''; +} + +function wxr_tag_name($t) { + if ( empty($t->name) ) + return; + + echo '' . wxr_cdata($t->name) . ''; +} + +function wxr_tag_description($t) { + if ( empty($t->description) ) + return; + + echo '' . wxr_cdata($t->description) . ''; +} + +function wxr_post_taxonomy() { + $categories = get_the_category(); + $tags = get_the_tags(); + $the_list = ''; + $filter = 'rss'; + + if ( !empty($categories) ) foreach ( (array) $categories as $category ) { + $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); + // for backwards compatibility + $the_list .= "\n\t\t\n"; + // forwards compatibility: use a unique identifier for each cat to avoid clashes + // http://trac.wordpress.org/ticket/5447 + $the_list .= "\n\t\tslug}\">\n"; + } + + if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { + $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); + $the_list .= "\n\t\t\n"; + // forwards compatibility as above + $the_list .= "\n\t\tslug}\">\n"; + } + + echo $the_list; +} + +echo '\n"; + +?> + + + + + + + + + + + + + + + + + + + + + <?php bloginfo_rss('name'); ?> + + + + http://wordpress.org/?v= + + + + + + slug; ?>parent ? $cats[$c->parent]->name : ''; ?> + + + slug; ?> + + + in_the_loop = true; // Fake being in the loop. + // fetch 20 posts at a time rather than loading the entire table into memory + while ( $next_posts = array_splice($post_ids, 0, 20) ) { + $where = "WHERE ID IN (".join(',', $next_posts).")"; + $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); + foreach ($posts as $post) { + setup_postdata($post); ?> + +<?php echo apply_filters('the_title_rss', $post->post_title); ?> + + + + + + + +post_content) ); ?> +ID; ?> +post_date; ?> +post_date_gmt; ?> +comment_status; ?> +ping_status; ?> +post_name; ?> +post_status; ?> +post_parent; ?> +menu_order; ?> +post_type; ?> +post_password; ?> +post_type == 'attachment') { ?> +ID); ?> + +get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); +if ( $postmeta ) { +?> + + +meta_key; ?> +meta_value; ?> + + + +get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID"); +if ( $comments ) { foreach ( $comments as $c ) { ?> + +comment_ID; ?> +comment_author); ?> +comment_author_email; ?> +comment_author_url; ?> +comment_author_IP; ?> +comment_date; ?> +comment_date_gmt; ?> +comment_content) ?> +comment_approved; ?> +comment_type; ?> +comment_parent; ?> +user_id; ?> + + + + + + + \ No newline at end of file diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index c201359b..575a6782 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -1,6 +1,6 @@ __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ), +$wp_file_descriptions = array ('index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'rtl.css' => __( 'RTL Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'searchform.php' => __( 'Search Form' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'link.php' => __( 'Links Template' ), 'functions.php' => __( 'Theme Functions' ), 'attachment.php' => __( 'Attachment Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ), // Deprecated files 'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' )); function get_file_description( $file ) { @@ -42,6 +42,20 @@ function get_real_file_to_edit( $file ) { return $real_file; } +function get_temp_dir() { + if ( defined('WP_TEMP_DIR') ) + return trailingslashit(WP_TEMP_DIR); + + $temp = ABSPATH . 'wp-content/'; + if ( is_dir($temp) && is_writable($temp) ) + return $temp; + + if ( function_exists('sys_get_temp_dir') ) + return trailingslashit(sys_get_temp_dir()); + + return '/tmp/'; +} + function validate_file( $file, $allowed_files = '' ) { if ( false !== strpos( $file, '..' )) return 1; @@ -112,6 +126,7 @@ function wp_handle_upload( &$file, $overrides = false ) { // If you override this, you must provide $ext and $type!!!! $test_type = true; + $mimes = false; // Install user overrides. Did we mention that this voids your warranty? if ( is_array( $overrides ) ) @@ -144,37 +159,22 @@ function wp_handle_upload( &$file, $overrides = false ) { if ( !$ext ) $ext = ltrim(strrchr($file['name'], '.'), '.'); + + if ( !$type ) + $type = $file['type']; } // A writable uploads dir will pass this test. Again, there's no point overriding this one. if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) return $upload_error_handler( $file, $uploads['error'] ); - // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. - if ( isset( $unique_filename_callback ) && function_exists( $unique_filename_callback ) ) { - $filename = $unique_filename_callback( $uploads['path'], $file['name'] ); - } else { - $number = ''; - $filename = str_replace( '#', '_', $file['name'] ); - $filename = str_replace( array( '\\', "'" ), '', $filename ); - if ( empty( $ext) ) - $ext = ''; - else - $ext = ".$ext"; - while ( file_exists( $uploads['path'] . "/$filename" ) ) { - if ( '' == "$number$ext" ) - $filename = $filename . ++$number . $ext; - else - $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); - } - $filename = str_replace( $ext, '', $filename ); - $filename = sanitize_title_with_dashes( $filename ) . $ext; - } + $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); // Move the file to the uploads dir $new_file = $uploads['path'] . "/$filename"; - if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) - wp_die( printf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] )); + if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) { + return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) ); + } // Set correct file permissions $stat = stat( dirname( $new_file )); @@ -189,4 +189,148 @@ function wp_handle_upload( &$file, $overrides = false ) { return $return; } +/** +* Downloads a url to a local file using the Snoopy HTTP Class +* +* @param string $url the URL of the file to download +* @return mixed WP_Error on failure, string Filename on success. +*/ +function download_url( $url ) { + //WARNING: The file is not automatically deleted, The script must unlink() the file. + if( ! $url ) + return new WP_Error('http_no_url', __('Invalid URL Provided')); + + $tmpfname = tempnam(get_temp_dir(), 'wpupdate'); + if( ! $tmpfname ) + return new WP_Error('http_no_file', __('Could not create Temporary file')); + + $handle = @fopen($tmpfname, 'w'); + if( ! $handle ) + return new WP_Error('http_no_file', __('Could not create Temporary file')); + + require_once( ABSPATH . 'wp-includes/class-snoopy.php' ); + $snoopy = new Snoopy(); + $snoopy->fetch($url); + + if( $snoopy->status != '200' ){ + fclose($handle); + unlink($tmpfname); + return new WP_Error('http_404', trim($snoopy->response_code)); + } + fwrite($handle, $snoopy->results); + fclose($handle); + + return $tmpfname; +} + +function unzip_file($file, $to) { + global $wp_filesystem; + + if ( ! $wp_filesystem || !is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + $fs =& $wp_filesystem; + + require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php'); + + $archive = new PclZip($file); + + // Is the archive valid? + if ( false == ($archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING)) ) + return new WP_Error('incompatible_archive', __('Incompatible archive'), $archive->errorInfo(true)); + + if ( 0 == count($archive_files) ) + return new WP_Error('empty_archive', __('Empty archive')); + + $to = trailingslashit($to); + $path = explode('/', $to); + $tmppath = ''; + for ( $j = 0; $j < count($path) - 1; $j++ ) { + $tmppath .= $path[$j] . '/'; + if ( ! $fs->is_dir($tmppath) ) + $fs->mkdir($tmppath, 0755); + } + + foreach ($archive_files as $file) { + $path = explode('/', $file['filename']); + $tmppath = ''; + + // Loop through each of the items and check that the folder exists. + for ( $j = 0; $j < count($path) - 1; $j++ ) { + $tmppath .= $path[$j] . '/'; + if ( ! $fs->is_dir($to . $tmppath) ) + if ( !$fs->mkdir($to . $tmppath, 0755) ) + return new WP_Error('mkdir_failed', __('Could not create directory')); + } + + // We've made sure the folders are there, so let's extract the file now: + if ( ! $file['folder'] ) + if ( !$fs->put_contents( $to . $file['filename'], $file['content']) ) + return new WP_Error('copy_failed', __('Could not copy file')); + $fs->chmod($to . $file['filename'], 0644); + } + + return true; +} + +function copy_dir($from, $to) { + global $wp_filesystem; + + $dirlist = $wp_filesystem->dirlist($from); + + $from = trailingslashit($from); + $to = trailingslashit($to); + + foreach ( (array) $dirlist as $filename => $fileinfo ) { + if ( 'f' == $fileinfo['type'] ) { + if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) ) + return false; + $wp_filesystem->chmod($to . $filename, 0644); + } elseif ( 'd' == $fileinfo['type'] ) { + if ( !$wp_filesystem->mkdir($to . $filename, 0755) ) + return false; + if ( !copy_dir($from . $filename, $to . $filename) ) + return false; + } + } + + return true; +} + +function WP_Filesystem( $args = false, $preference = false ) { + global $wp_filesystem; + + $method = get_filesystem_method($preference); + if ( ! $method ) + return false; + + require_once('class-wp-filesystem-'.$method.'.php'); + $method = "WP_Filesystem_$method"; + + $wp_filesystem = new $method($args); + + if ( $wp_filesystem->errors->get_error_code() ) + return false; + + if ( !$wp_filesystem->connect() ) + return false; //There was an erorr connecting to the server. + + return true; +} + +function get_filesystem_method() { + $tempFile = tempnam(get_temp_dir(), 'WPU'); + + if ( getmyuid() == fileowner($tempFile) ) { + unlink($tempFile); + return 'direct'; + } else { + unlink($tempFile); + } + + if ( extension_loaded('ftp') ) return 'ftpext'; + if ( extension_loaded('sockets') || function_exists('fsockopen') ) return 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread + return false; +} + ?> diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index ec4466e5..7699f986 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -1,110 +1,46 @@ 4 / 3 ) - return array( 128, (int) ($height / $width * 128 )); - else - return array( (int) ($width / $height * 96 ), 96 ); -} - -function wp_create_thumbnail( $file, $max_side, $effect = '' ) { - - // 1 = GIF, 2 = JPEG, 3 = PNG - - if ( file_exists( $file ) ) { - $type = getimagesize( $file ); - - // if the associated function doesn't exist - then it's not - // handle. duh. i hope. - - if (!function_exists( 'imagegif' ) && $type[2] == 1 ) { - $error = __( 'Filetype not supported. Thumbnail not created.' ); - } - elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) { - $error = __( 'Filetype not supported. Thumbnail not created.' ); - } - elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) { - $error = __( 'Filetype not supported. Thumbnail not created.' ); - } else { - - // create the initial copy from the original file - if ( $type[2] == 1 ) { - $image = imagecreatefromgif( $file ); - } - elseif ( $type[2] == 2 ) { - $image = imagecreatefromjpeg( $file ); - } - elseif ( $type[2] == 3 ) { - $image = imagecreatefrompng( $file ); - } - - if ( function_exists( 'imageantialias' )) - imageantialias( $image, TRUE ); - - $image_attr = getimagesize( $file ); - - // figure out the longest side - - if ( $image_attr[0] > $image_attr[1] ) { - $image_width = $image_attr[0]; - $image_height = $image_attr[1]; - $image_new_width = $max_side; - - $image_ratio = $image_width / $image_new_width; - $image_new_height = $image_height / $image_ratio; - //width is > height - } else { - $image_width = $image_attr[0]; - $image_height = $image_attr[1]; - $image_new_height = $max_side; - - $image_ratio = $image_height / $image_new_height; - $image_new_width = $image_width / $image_ratio; - //height > width - } - - $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height); - @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] ); - - // If no filters change the filename, we'll do a default transformation. - if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) ) - $thumb = preg_replace( '!(\.[^.]+)?$!', '.thumbnail' . '$1', basename( $file ), 1 ); - - $thumbpath = str_replace( basename( $file ), $thumb, $file ); - - // move the thumbnail to its final destination - if ( $type[2] == 1 ) { - if (!imagegif( $thumbnail, $thumbpath ) ) { - $error = __( "Thumbnail path invalid" ); - } - } - elseif ( $type[2] == 2 ) { - if (!imagejpeg( $thumbnail, $thumbpath ) ) { - $error = __( "Thumbnail path invalid" ); - } - } - elseif ( $type[2] == 3 ) { - if (!imagepng( $thumbnail, $thumbpath ) ) { - $error = __( "Thumbnail path invalid" ); - } - } - - } - } else { - $error = __( 'File not found' ); - } - - if (!empty ( $error ) ) { - return $error; - } else { - return apply_filters( 'wp_create_thumbnail', $thumbpath ); - } +/** + * File contains all the administration image manipulation functions. + * + * @package WordPress + */ + +/** + * wp_create_thumbnail() - Create a thumbnail from an Image given a maximum side size. + * + * @package WordPress + * @param mixed $file Filename of the original image, Or attachment id + * @param int $max_side Maximum length of a single side for the thumbnail + * @return string Thumbnail path on success, Error string on failure + * + * This function can handle most image file formats which PHP supports. + * If PHP does not have the functionality to save in a file of the same format, the thumbnail will be created as a jpeg. + */ +function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) { + + $thumbpath = image_resize( $file, $max_side, $max_side ); + return apply_filters( 'wp_create_thumbnail', $thumbpath ); } +/** + * wp_crop_image() - Crop an Image to a given size. + * + * @package WordPress + * @internal Missing Long Description + * @param int $src_file The source file + * @param int $src_x The start x position to crop from + * @param int $src_y The start y position to crop from + * @param int $src_w The width to crop + * @param int $src_h The height to crop + * @param int $dst_w The destination width + * @param int $dst_h The destination height + * @param int $src_abs If the source crop points are absolute + * @param int $dst_file The destination file to write to + * @return string New filepath on success, String error message on failure + * + */ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { - if ( ctype_digit( $src_file ) ) // Handle int as attachment ID + if ( is_numeric( $src_file ) ) // Handle int as attachment ID $src_file = get_attached_file( $src_file ); $src = wp_load_image( $src_file ); @@ -124,8 +60,10 @@ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_ imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); - if ( !$dst_file ) - $dst_file = str_replace( basename( $src_file ), 'cropped-'.basename( $src_file ), $src_file ); + imagedestroy( $src ); // Free up memory + + if ( ! $dst_file ) + $dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file ); $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file ); @@ -135,44 +73,69 @@ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_ return false; } +/** + * wp_generate_attachment_metadata() - Generate post Image attachment Metadata + * + * @package WordPress + * @internal Missing Long Description + * @param int $attachment_id Attachment Id to process + * @param string $file Filepath of the Attached image + * @return mixed Metadata for attachment + * + */ function wp_generate_attachment_metadata( $attachment_id, $file ) { $attachment = get_post( $attachment_id ); $metadata = array(); - if ( preg_match('!^image/!', get_post_mime_type( $attachment )) ) { - $imagesize = getimagesize($file); - $metadata['width'] = $imagesize['0']; - $metadata['height'] = $imagesize['1']; - list($uwidth, $uheight) = get_udims($metadata['width'], $metadata['height']); + if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) { + $imagesize = getimagesize( $file ); + $metadata['width'] = $imagesize[0]; + $metadata['height'] = $imagesize[1]; + list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']); $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'"; $metadata['file'] = $file; - $max = apply_filters( 'wp_thumbnail_creation_size_limit', 3 * 1024 * 1024, $attachment_id, $file ); - - if ( $max < 0 || $metadata['width'] * $metadata['height'] < $max ) { - $max_side = apply_filters( 'wp_thumbnail_max_side_length', 128, $attachment_id, $file ); - $thumb = wp_create_thumbnail( $file, $max_side ); - - if ( @file_exists($thumb) ) - $metadata['thumb'] = basename($thumb); + // make thumbnails and other intermediate sizes + $sizes = array('thumbnail', 'medium'); + $sizes = apply_filters('intermediate_image_sizes', $sizes); + + foreach ($sizes as $size) { + $resized = image_make_intermediate_size( $file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") ); + if ( $resized ) + $metadata['sizes'][$size] = $resized; } + + // fetch additional metadata from exif/iptc + $image_meta = wp_read_image_metadata( $file ); + if ($image_meta) + $metadata['image_meta'] = $image_meta; + } return apply_filters( 'wp_generate_attachment_metadata', $metadata ); } +/** + * wp_load_image() - Load an image which PHP Supports. + * + * @package WordPress + * @internal Missing Long Description + * @param string $file Filename of the image to load + * @return resource The resulting image resource on success, Error string on failure. + * + */ function wp_load_image( $file ) { - if ( ctype_digit( $file ) ) + if ( is_numeric( $file ) ) $file = get_attached_file( $file ); - if ( !file_exists( $file ) ) + if ( ! file_exists( $file ) ) return sprintf(__("File '%s' doesn't exist?"), $file); if ( ! function_exists('imagecreatefromstring') ) return __('The GD image library is not installed.'); - $contents = file_get_contents( $file ); - - $image = imagecreatefromstring( $contents ); + // Set artificially high because GD uses uncompressed images in memory + @ini_set('memory_limit', '256M'); + $image = imagecreatefromstring( file_get_contents( $file ) ); if ( !is_resource( $image ) ) return sprintf(__("File '%s' is not an image."), $file); @@ -180,13 +143,140 @@ function wp_load_image( $file ) { return $image; } +/** + * get_udims() - Calculated the new dimentions for downsampled images + * + * @package WordPress + * @internal Missing Description + * @see wp_shrink_dimensions() + * @param int $width Current width of the image + * @param int $height Current height of the image + * @return mixed Array(height,width) of shrunk dimensions. + * + */ +function get_udims( $width, $height) { + return wp_shrink_dimensions( $width, $height ); +} +/** + * wp_shrink_dimensions() - Calculates the new dimentions for a downsampled image. + * + * @package WordPress + * @internal Missing Long Description + * @param int $width Current width of the image + * @param int $height Current height of the image + * @param int $wmax Maximum wanted width + * @param int $hmax Maximum wanted height + * @return mixed Array(height,width) of shrunk dimensions. + * + */ function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) { - if ( $height <= $hmax && $width <= $wmax ) - return array( $width, $height); - elseif ( $width / $height > $wmax / $hmax ) - return array( $wmax, (int) ($height / $width * $wmax )); + return wp_constrain_dimensions( $width, $height, $wmax, $hmax ); +} + +// convert a fraction string to a decimal +function wp_exif_frac2dec($str) { + @list( $n, $d ) = explode( '/', $str ); + if ( !empty($d) ) + return $n / $d; + return $str; +} + +// convert the exif date format to a unix timestamp +function wp_exif_date2ts($str) { + // seriously, who formats a date like 'YYYY:MM:DD hh:mm:ss'? + @list( $date, $time ) = explode( ' ', trim($str) ); + @list( $y, $m, $d ) = explode( ':', $date ); + + return strtotime( "{$y}-{$m}-{$d} {$time}" ); +} + +// get extended image metadata, exif or iptc as available +function wp_read_image_metadata( $file ) { + if ( !file_exists( $file ) ) + return false; + + list(,,$sourceImageType) = getimagesize( $file ); + + // exif contains a bunch of data we'll probably never need formatted in ways that are difficult to use. + // We'll normalize it and just extract the fields that are likely to be useful. Fractions and numbers + // are converted to floats, dates to unix timestamps, and everything else to strings. + $meta = array( + 'aperture' => 0, + 'credit' => '', + 'camera' => '', + 'caption' => '', + 'created_timestamp' => 0, + 'copyright' => '', + 'focal_length' => 0, + 'iso' => 0, + 'shutter_speed' => 0, + 'title' => '', + ); + + // read iptc first, since it might contain data not available in exif such as caption, description etc + if ( is_callable('iptcparse') ) { + getimagesize($file, $info); + if ( !empty($info['APP13']) ) { + $iptc = iptcparse($info['APP13']); + if ( !empty($iptc['2#110'][0]) ) // credit + $meta['credit'] = trim( $iptc['2#110'][0] ); + elseif ( !empty($iptc['2#080'][0]) ) // byline + $meta['credit'] = trim( $iptc['2#080'][0] ); + if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created datee and time + $meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]); + if ( !empty($iptc['2#120'][0]) ) // caption + $meta['caption'] = trim( $iptc['2#120'][0] ); + if ( !empty($iptc['2#116'][0]) ) // copyright + $meta['copyright'] = trim( $iptc['2#116'][0] ); + if ( !empty($iptc['2#005'][0]) ) // title + $meta['title'] = trim( $iptc['2#005'][0] ); + } + } + + // fetch additional info from exif if available + if ( is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)) ) ) { + $exif = @exif_read_data( $file ); + if (!empty($exif['FNumber'])) + $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 ); + if (!empty($exif['Model'])) + $meta['camera'] = trim( $exif['Model'] ); + if (!empty($exif['DateTimeDigitized'])) + $meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']); + if (!empty($exif['FocalLength'])) + $meta['focal_length'] = wp_exif_frac2dec( $exif['FocalLength'] ); + if (!empty($exif['ISOSpeedRatings'])) + $meta['iso'] = $exif['ISOSpeedRatings']; + if (!empty($exif['ExposureTime'])) + $meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] ); + } + // FIXME: try other exif libraries if available + + return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType ); + +} + +// is the file a real image file? +function file_is_valid_image($path) { + $size = @getimagesize($path); + return !empty($size); +} + +// is the file an image suitable for displaying within a web page? +function file_is_displayable_image($path) { + $info = @getimagesize($path); + if ( empty($info) ) + $result = false; + elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) ) + // only gif, jpeg and png images can reliably be displayed + $result = false; + elseif ( $info['channels'] > 0 && $info['channels'] != 3 ) { + // some web browsers can't display cmyk or grayscale jpegs + $result = false; + } else - return array( (int) ($width / $height * $hmax ), $hmax ); + $result = true; + + return apply_filters('file_is_displayable_image', $result, $path); } ?> diff --git a/wp-admin/includes/import.php b/wp-admin/includes/import.php index 9835bb14..35fd141b 100644 --- a/wp-admin/includes/import.php +++ b/wp-admin/includes/import.php @@ -2,7 +2,8 @@ function get_importers() { global $wp_importers; - uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); + if ( is_array($wp_importers) ) + uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); return $wp_importers; } @@ -19,6 +20,7 @@ function wp_import_cleanup( $id ) { function wp_import_handle_upload() { $overrides = array( 'test_form' => false, 'test_type' => false ); + $_FILES['import']['name'] .= '.import'; $file = wp_handle_upload( $_FILES['import'], $overrides ); if ( isset( $file['error'] ) ) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php new file mode 100644 index 00000000..1000d15b --- /dev/null +++ b/wp-admin/includes/media.php @@ -0,0 +1,1210 @@ + __('Choose File'), // handler action suffix => tab text + 'gallery' => __('Gallery'), + 'library' => __('Media Library'), + ); + + return apply_filters('media_upload_tabs', $_default_tabs); +} + +function update_gallery_tab($tabs) { + global $wpdb; + if ( !isset($_REQUEST['post_id']) ) { + unset($tabs['gallery']); + return $tabs; + } + if ( intval($_REQUEST['post_id']) ) + $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']))); + + $tabs['gallery'] = sprintf(__('Gallery (%s)'), "$attachments"); + + return $tabs; +} +add_filter('media_upload_tabs', 'update_gallery_tab'); + +function the_media_upload_tabs() { + $tabs = media_upload_tabs(); + + if ( !empty($tabs) ) { + echo "
        \n"; + if ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) + $current = $_GET['tab']; + else { + $keys = array_keys($tabs); + $current = array_shift($keys); + } + foreach ( $tabs as $callback => $text ) { + $class = ''; + if ( $current == $callback ) + $class = " class='current'"; + $href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false)); + $link = "$text"; + echo "\t
      • $link
      • \n"; + } + echo "
      \n"; + } +} + +function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { + + $html = get_image_tag($id, $alt, $title, $align, $size); + + $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; + + if ( $url ) + $html = "$html"; + + $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size ); + + return $html; +} + +function media_send_to_editor($html) { + ?> + + false); + $file = wp_handle_upload($_FILES[$file_id], $overrides); + + if ( isset($file['error']) ) + return new wp_error( 'upload_error', $file['error'] ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $title = preg_replace('/\.[^.]+$/', '', basename($file)); + $content = ''; + + // use image exif/iptc data for title and caption defaults if possible + if ( $image_meta = @wp_read_image_metadata($file) ) { + if ( trim($image_meta['title']) ) + $title = $image_meta['title']; + if ( trim($image_meta['caption']) ) + $content = $image_meta['caption']; + } + + // Construct the attachment array + $attachment = array_merge( array( + 'post_mime_type' => $type, + 'guid' => $url, + 'post_parent' => $post_id, + 'post_title' => $title, + 'post_content' => $content, + ), $post_data ); + + // Save the data + $id = wp_insert_attachment($attachment, $file, $post_parent); + if ( !is_wp_error($id) ) { + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + } + + return $id; + +} + + +// wrap iframe content (produced by $content_func) in a doctype, html head/body etc +// any additional function args will be passed to content_func +function wp_iframe($content_func /* ... */) { +?> + + > + + +<?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — <?php _e('WordPress'); ?> + + + + +> + + + +$image_title + $video_title + $audio_title + $media_title + +EOF; + printf($context, $out); +} +add_action( 'media_buttons', 'media_buttons' ); + +function media_buttons_head() { +$siteurl = get_option('siteurl'); +echo "\n"; +} + +add_action( 'admin_print_scripts', 'media_buttons_head' ); + +function media_admin_css() { + wp_admin_css('css/media'); +} + +add_action('media_upload_media', 'media_upload_handler'); + +function media_upload_form_handler() { + check_admin_referer('media-form'); + + if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { + $post = $_post = get_post($attachment_id, ARRAY_A); + if ( isset($attachment['post_content']) ) + $post['post_content'] = $attachment['post_content']; + if ( isset($attachment['post_title']) ) + $post['post_title'] = $attachment['post_title']; + if ( isset($attachment['post_excerpt']) ) + $post['post_excerpt'] = $attachment['post_excerpt']; + + $post = apply_filters('attachment_fields_to_save', $post, $attachment); + + if ( isset($post['errors']) ) { + $errors[$attachment_id] = $post['errors']; + unset($post['errors']); + } + + if ( $post != $_post ) + wp_update_post($post); + + foreach ( get_attachment_taxonomies($post) as $t ) + if ( isset($attachment[$t]) ) + wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); + } + + if ( isset($_POST['insert-gallery']) ) + return media_send_to_editor('[gallery]'); + + if ( isset($_POST['send']) ) { + $keys = array_keys($_POST['send']); + $send_id = (int) array_shift($keys); + $attachment = $_POST['attachments'][$send_id]; + $html = $attachment['post_title']; + if ( !empty($attachment['url']) ) { + if ( strpos($attachment['url'], 'attachment_id') || false !== strpos($attachment['url'], get_permalink($_POST['post_id'])) ) + $rel = " rel='attachment wp-att-".attribute_escape($send_id)."'"; + $html = "$html"; + } + $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); + return media_send_to_editor($html); + } + + return $errors; +} + +function media_upload_image() { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $src = $_POST['insertonly']['src']; + if ( !empty($src) && !strpos($src, '://') ) + $src = "http://$src"; + $alt = attribute_escape($_POST['insertonly']['alt']); + if ( isset($_POST['insertonly']['align']) ) { + $align = attribute_escape($_POST['insertonly']['align']); + $class = " class='align$align'"; + } + if ( !empty($src) ) + $html = "$alt"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_POST['save']) ) + $errors['upload_notice'] = __('Saved.'); + + return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); +} + +function media_upload_audio() { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !empty($href) && !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_POST['save']) ) + $errors['upload_notice'] = __('Saved.'); + + return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id ); +} + +function media_upload_video() { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !empty($href) && !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_POST['save']) ) + $errors['upload_notice'] = __('Saved.'); + + return wp_iframe( 'media_upload_type_form', 'video', $errors, $id ); +} + +function media_upload_file() { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $href = $_POST['insertonly']['href']; + if ( !empty($href) && !strpos($href, '://') ) + $href = "http://$href"; + $title = attribute_escape($_POST['insertonly']['title']); + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; + return media_send_to_editor($html); + } + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_POST['save']) ) + $errors['upload_notice'] = __('Saved.'); + + return wp_iframe( 'media_upload_type_form', 'file', $errors, $id ); +} + +function media_upload_gallery() { + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_gallery_form', $errors ); +} + +function media_upload_library() { + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_library_form', $errors ); +} + +function image_attachment_fields_to_edit($form_fields, $post) { + if ( substr($post->post_mime_type, 0, 5) == 'image' ) { + $form_fields['post_title']['required'] = true; + $form_fields['post_excerpt']['label'] = __('Caption'); + $form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"'); + + $form_fields['post_content']['label'] = __('Description'); + + $thumb = wp_get_attachment_thumb_url($post->ID); + + $form_fields['align'] = array( + 'label' => __('Alignment'), + 'input' => 'html', + 'html' => " + + + + + + + + \n", + ); + $form_fields['image-size'] = array( + 'label' => __('Size'), + 'input' => 'html', + 'html' => " + " . ( $thumb ? " + + " : '' ) . " + + + ", + ); + } + return $form_fields; +} + +add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2); + +function media_single_attachment_fields_to_edit( $form_fields, $post ) { + unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']); + return $form_fields; +} + +function image_attachment_fields_to_save($post, $attachment) { + if ( substr($post['post_mime_type'], 0, 5) == 'image' ) { + if ( strlen(trim($post['post_title'])) == 0 ) { + $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid'])); + $post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.'); + } + } + + return $post; +} + +add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2); + +function image_media_send_to_editor($html, $attachment_id, $attachment) { + $post =& get_post($attachment_id); + if ( substr($post->post_mime_type, 0, 5) == 'image' ) { + $url = $attachment['url']; + + if ( isset($attachment['align']) ) + $align = $attachment['align']; + else + $align = 'none'; + + if ( !empty($attachment['image-size']) ) + $size = $attachment['image-size']; + else + $size = 'medium'; + + $rel = ( $url == get_attachment_link($attachment_id) ); + + return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size); + } + + return $html; +} + +add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3); + +function get_attachment_fields_to_edit($post, $errors = null) { + if ( is_int($post) ) + $post =& get_post($post); + if ( is_array($post) ) + $post = (object) $post; + + $edit_post = sanitize_post($post, 'edit'); + $file = wp_get_attachment_url($post->ID); + $link = get_attachment_link($post->ID); + + $form_fields = array( + 'post_title' => array( + 'label' => __('Title'), + 'value' => $edit_post->post_title, + ), + 'post_excerpt' => array( + 'label' => __('Caption'), + 'value' => $edit_post->post_excerpt, + ), + 'post_content' => array( + 'label' => __('Description'), + 'value' => $edit_post->post_content, + 'input' => 'textarea', + ), + 'url' => array( + 'label' => __('Link URL'), + 'input' => 'html', + 'html' => " +
      + + + + \n", + 'helps' => __('Enter a link URL or click above for presets.'), + ), + ); + + foreach ( get_attachment_taxonomies($post) as $taxonomy ) { + $t = (array) get_taxonomy($taxonomy); + if ( empty($t['label']) ) + $t['label'] = $taxonomy; + if ( empty($t['args']) ) + $t['args'] = array(); + + $terms = get_object_term_cache($post->ID, $taxonomy); + if ( empty($terms) ) + $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); + + $values = array(); + + foreach ( $terms as $term ) + $values[] = $term->name; + $t['value'] = join(', ', $values); + + $form_fields[$taxonomy] = $t; + } + + // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default + // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) + $form_fields = array_merge_recursive($form_fields, (array) $errors); + + $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); + + return $form_fields; +} + +function get_media_items( $post_id, $errors ) { + if ( $post_id ) { + $post = get_post($post_id); + if ( $post && $post->post_type == 'attachment' ) + $attachments = array($post->ID => $post); + else + $attachments = get_children("post_parent=$post_id&post_type=attachment&orderby=menu_order ASC, ID&order=DESC"); + } else { + if ( is_array($GLOBALS['wp_the_query']->posts) ) + foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) + $attachments[$attachment->ID] = $attachment; + } + + if ( empty($attachments) ) + return ''; + + foreach ( $attachments as $id => $attachment ) + if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) + $output .= "\n
      $item\n
      "; + + return $output; +} + +function get_media_item( $attachment_id, $args = null ) { + $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true ); + $args = wp_parse_args( $args, $default_args ); + extract( $args, EXTR_SKIP ); + + global $post_mime_types; + if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) ) + $thumb_url = $thumb_url[0]; + else + return false; + + $title_label = __('Title'); + $description_label = __('Description'); + $tags_label = __('Tags'); + + $toggle_on = __('Show'); + $toggle_off = __('Hide'); + + $post = get_post($attachment_id); + + $filename = basename($post->guid); + $title = attribute_escape($post->post_title); + $description = attribute_escape($post->post_content); + if ( $_tags = get_the_tags($attachment_id) ) { + foreach ( $_tags as $tag ) + $tags[] = $tag->name; + $tags = attribute_escape(join(', ', $tags)); + } + + if ( isset($post_mime_types) ) { + $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type)); + $type = array_shift($keys); + $type = ""; + } + + $form_fields = get_attachment_fields_to_edit($post, $errors); + + if ( $toggle ) { + $class = empty($errors) ? 'startclosed' : 'startopen'; + $toggle_links = " + $toggle_on + $toggle_off"; + } else { + $class = 'form-table'; + $toggle_links = ''; + } + + $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case + + $item = " + $type + $toggle_links +
      $display_title
      +
    + + + + + + + + + + \n"; + + $defaults = array( + 'input' => 'text', + 'required' => false, + 'value' => '', + 'extra_rows' => array(), + ); + + $delete_href = wp_nonce_url("post.php?action=delete-post&post=$attachment_id", 'delete-post_' . $attachment_id); + if ( $send ) + $send = ""; + if ( $delete ) + $delete = "" . __('Delete') . ""; + if ( ( $send || $delete ) && !isset($form_fields['buttons']) ) + $form_fields['buttons'] = array('tr' => "\t\t\n"); + + $hidden_fields = array(); + + foreach ( $form_fields as $id => $field ) { + if ( $id{0} == '_' ) + continue; + + if ( !empty($field['tr']) ) { + $item .= $field['tr']; + continue; + } + + $field = array_merge($defaults, $field); + $name = "attachments[$attachment_id][$id]"; + + if ( $field['input'] == 'hidden' ) { + $hidden_fields[$name] = $field['value']; + continue; + } + + $required = $field['required'] ? '*' : ''; + $class = $id; + $class .= $field['required'] ? ' form-required' : ''; + + $item .= "\t\t\n\t\t\t\n\t\t\t\n\t\t\n"; + + $extra_rows = array(); + + if ( !empty($field['errors']) ) + foreach ( array_unique((array) $field['errors']) as $error ) + $extra_rows['error'][] = $error; + + if ( !empty($field['extra_rows']) ) + foreach ( $field['extra_rows'] as $class => $rows ) + foreach ( (array) $rows as $html ) + $extra_rows[$class][] = $html; + + foreach ( $extra_rows as $class => $rows ) + foreach ( $rows as $html ) + $item .= "\t\t\n"; + } + + if ( !empty($form_fields['_final']) ) + $item .= "\t\t\n"; + $item .= "\t\n"; + $item .= "\t
    $filename
    $post->post_mime_type
    " . mysql2date($post->post_date, get_option('time_format')) . "
    " . apply_filters('media_meta', '', $post) . "
    $send $delete
    "; + if ( !empty($field[$field['input']]) ) + $item .= $field[$field['input']]; + elseif ( $field['input'] == 'textarea' ) { + $item .= ""; + } else { + $item .= ""; + } + if ( !empty($field['helps']) ) + $item .= "

    " . join( "

    \n

    ", array_unique((array) $field['helps']) ) . '

    '; + $item .= "
    $html
    {$form_fields['_final']}
    \n"; + + foreach ( $hidden_fields as $name => $value ) + $item .= "\t\n"; + + return $item; +} + +function media_upload_header() { + ?> + +
    + +
    + + +
    + + + +
    +
    + + get_error_message(); ?> + +
    + + + + +
    +

    +

    +
    + + + +
    +

    + +

    + +
    + +

    + +
    + + +
    + + +

    + + + + +
    + +
    + + + + +
    +

    +

    +
    + +
    +
    + +
    +
    + + + + + + + + + +
    + +
    + + + + + +
    + + +
    + + + + + +
    + + +
    + +

    +

    +

    + +
    + + add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'total' => ceil($wp_query->found_posts / 10), + 'current' => $_GET['paged'] +)); + +if ( $page_links ) + echo "
    $page_links
    "; +?> + +
    +posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; + +$arc_result = $wpdb->get_results( $arc_query ); + +$month_count = count($arc_result); + +if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> + + + + + +
    + +
    +
    +
    + +
    + + + + + + +
    + +
    + + +
    + + + + + * + + + + + + + * + + + + ' . __('Alternate text, e.g. "The Mona Lisa"') . ' + + + + + + + + + + + + + + + + + + + + +'; +} + +function type_form_audio() { + return ' + + + + + + + + + + + + + + +
    + + * +
    + + * +
    ' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . '
    + +
    +'; +} + +function type_form_video() { + return ' + + + + + + + + + + + + + + +
    + + * +
    + + * +
    ' . __('Link text, e.g. "Lucy on YouTube"') . '
    + +
    +'; +} + +function type_form_file() { + return ' + + + + + + + + + + + + + + +
    + + * +
    + + * +
    ' . __('Link text, e.g. "Ransom Demands (PDF)"') . '
    + +
    +'; +} + +add_filter('async_upload_image', 'get_media_item', 10, 2); +add_filter('async_upload_audio', 'get_media_item', 10, 2); +add_filter('async_upload_video', 'get_media_item', 10, 2); +add_filter('async_upload_file', 'get_media_item', 10, 2); + +add_action('media_upload_image', 'media_upload_image'); +add_action('media_upload_audio', 'media_upload_audio'); +add_action('media_upload_video', 'media_upload_video'); +add_action('media_upload_file', 'media_upload_file'); +add_action('admin_head_media_upload_type_form', 'media_admin_css'); + +add_filter('media_upload_gallery', 'media_upload_gallery'); +add_action('admin_head_media_upload_gallery_form', 'media_admin_css'); + +add_filter('media_upload_library', 'media_upload_library'); +add_action('admin_head_media_upload_library_form', 'media_admin_css'); + +?> diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 5902c4e8..fcc3fe55 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -1,18 +1,8 @@ flush_rules(); - // Clear cookies for old paths. - wp_clearcookie(); - // Set cookies for new paths. - wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' )); } add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index e5911bda..a862c510 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -31,7 +31,7 @@ function get_plugin_data( $plugin_file ) { return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version); } -function get_plugins() { +function get_plugins($plugin_folder = '') { global $wp_plugins; if ( isset( $wp_plugins ) ) { @@ -40,6 +40,8 @@ function get_plugins() { $wp_plugins = array (); $plugin_root = ABSPATH . PLUGINDIR; + if( !empty($plugin_folder) ) + $plugin_root .= $plugin_folder; // Files in wp-content/plugins directory $plugins_dir = @ opendir( $plugin_root); @@ -86,6 +88,117 @@ function get_plugins() { return $wp_plugins; } +function is_plugin_active($plugin){ + return in_array($plugin, get_option('active_plugins')); +} + +function activate_plugin($plugin, $redirect = '') { + $current = get_option('active_plugins'); + $plugin = trim($plugin); + + $valid = validate_plugin($plugin); + if ( is_wp_error($valid) ) + return $valid; + + if ( !in_array($plugin, $current) ) { + if ( !empty($redirect) ) + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error + ob_start(); + @include(ABSPATH . PLUGINDIR . '/' . $plugin); + $current[] = $plugin; + sort($current); + update_option('active_plugins', $current); + do_action('activate_' . $plugin); + ob_end_clean(); + } + + return null; +} + +function deactivate_plugins($plugins, $silent= false) { + $current = get_option('active_plugins'); + + if ( !is_array($plugins) ) + $plugins = array($plugins); + + foreach ( $plugins as $plugin ) { + if( ! is_plugin_active($plugin) ) + continue; + array_splice($current, array_search( $plugin, $current), 1 ); // Fixed Array-fu! + if ( ! $silent ) //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. + do_action('deactivate_' . trim( $plugin )); + } + + update_option('active_plugins', $current); +} + +function deactivate_all_plugins() { + $current = get_option('active_plugins'); + if ( empty($current) ) + return; + + deactivate_plugins($current); + + update_option('deactivated_plugins', $current); +} + +function reactivate_all_plugins($redirect = '') { + $plugins = get_option('deactivated_plugins'); + + if ( empty($plugins) ) + return; + + if ( !empty($redirect) ) + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); + + $errors = array(); + foreach ( (array) $plugins as $plugin ) { + $result = activate_plugin($plugin); + if ( is_wp_error($result) ) + $errors[$plugin] = $result; + } + + delete_option('deactivated_plugins'); + + if ( !empty($errors) ) + return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors); + + return true; +} + +function validate_active_plugins() { + $check_plugins = get_option('active_plugins'); + + // Sanity check. If the active plugin list is not an array, make it an + // empty array. + if ( !is_array($check_plugins) ) { + update_option('active_plugins', array()); + return; + } + + // If a plugin file does not exist, remove it from the list of active + // plugins. + foreach ( $check_plugins as $check_plugin ) { + if ( !file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin) ) { + $current = get_option('active_plugins'); + $key = array_search($check_plugin, $current); + if ( false !== $key && NULL !== $key ) { + unset($current[$key]); + update_option('active_plugins', $current); + } + } + } +} + +function validate_plugin($plugin) { + if ( validate_file($plugin) ) + return new WP_Error('plugin_invalid', __('Invalid plugin.')); + if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) + return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); + + return 0; +} + // // Menu // @@ -111,7 +224,6 @@ function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $fi global $menu; global $_wp_real_parent_file; global $_wp_submenu_nopriv; - global $_wp_menu_nopriv; $file = plugin_basename( $file ); @@ -287,10 +399,8 @@ function get_admin_page_title() { } function get_plugin_page_hook( $plugin_page, $parent_page ) { - global $wp_filter; - $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); - if ( isset( $wp_filter[$hook] )) + if ( has_action($hook) ) return $hook; else return null; diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index e27482c5..aa1e833b 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -2,7 +2,6 @@ // Update an existing post with values provided in $_POST. function edit_post() { - global $user_ID; $post_ID = (int) $_POST['post_ID']; @@ -19,8 +18,7 @@ function edit_post() { $post =& get_post( $post_ID ); $now = time(); $then = strtotime($post->post_date_gmt . ' +0000'); - // Keep autosave_interval in sync with autosave-js.php. - $delta = apply_filters( 'autosave_interval', 120 ) / 2; + $delta = AUTOSAVE_INTERVAL / 2; if ( ($now - $then) < $delta ) return $post_ID; } @@ -29,7 +27,7 @@ function edit_post() { $_POST['ID'] = (int) $_POST['post_ID']; $_POST['post_content'] = $_POST['content']; $_POST['post_excerpt'] = $_POST['excerpt']; - $_POST['post_parent'] = $_POST['parent_id']; + $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : ''; $_POST['to_ping'] = $_POST['trackback_url']; if (!empty ( $_POST['post_author_override'] ) ) { @@ -53,20 +51,20 @@ function edit_post() { } // What to do based on which button they pressed - if ('' != $_POST['saveasdraft'] ) + if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] ) $_POST['post_status'] = 'draft'; - if ('' != $_POST['saveasprivate'] ) + if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] ) $_POST['post_status'] = 'private'; - if ('' != $_POST['publish'] ) + if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) ) $_POST['post_status'] = 'publish'; - if ('' != $_POST['advanced'] ) + if ( isset($_POST['advanced']) && '' != $_POST['advanced'] ) $_POST['post_status'] = 'draft'; if ( 'page' == $_POST['post_type'] ) { - if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' )) + if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' )) $_POST['post_status'] = 'pending'; } else { - if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' )) + if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' )) $_POST['post_status'] = 'pending'; } @@ -76,6 +74,13 @@ function edit_post() { if (!isset( $_POST['ping_status'] )) $_POST['ping_status'] = 'closed'; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; @@ -92,12 +97,12 @@ function edit_post() { } // Meta Stuff - if ( $_POST['meta'] ) { + if ( isset($_POST['meta']) && $_POST['meta'] ) { foreach ( $_POST['meta'] as $key => $value ) update_meta( $key, $value['key'], $value['value'] ); } - if ( $_POST['deletemeta'] ) { + if ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) { foreach ( $_POST['deletemeta'] as $key => $value ) delete_meta( $key ); } @@ -115,6 +120,8 @@ function edit_post() { // Now that we have an ID we can fix any attachment anchor hrefs _fix_attachment_links( $post_ID ); + wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID ); + return $post_ID; } @@ -129,6 +136,7 @@ function get_default_post_to_edit() { $post_title = ''; } + $post_content = ''; if ( !empty( $_REQUEST['content'] ) ) $post_content = wp_specialchars( stripslashes( $_REQUEST['content'] )); else if ( !empty( $post_title ) ) { @@ -143,7 +151,14 @@ function get_default_post_to_edit() { else $post_excerpt = ''; + $post->ID = 0; + $post->post_name = ''; + $post->post_author = ''; + $post->post_date = ''; $post->post_status = 'draft'; + $post->post_type = 'post'; + $post->to_ping = ''; + $post->pinged = ''; $post->comment_status = get_option( 'default_comment_status' ); $post->ping_status = get_option( 'default_ping_status' ); $post->post_pingback = get_option( 'default_pingback_flag' ); @@ -158,6 +173,12 @@ function get_default_post_to_edit() { return $post; } +function get_default_page_to_edit() { + $page = get_default_post_to_edit(); + $page->post_type = 'page'; + return $page; +} + // Get an existing post and format it for editing. function get_post_to_edit( $id ) { @@ -218,7 +239,7 @@ function wp_write_post() { // Rename. $_POST['post_content'] = $_POST['content']; $_POST['post_excerpt'] = $_POST['excerpt']; - $_POST['post_parent'] = $_POST['parent_id']; + $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : ''; $_POST['to_ping'] = $_POST['trackback_url']; if (!empty ( $_POST['post_author_override'] ) ) { @@ -244,13 +265,13 @@ function wp_write_post() { } // What to do based on which button they pressed - if ('' != $_POST['saveasdraft'] ) + if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] ) $_POST['post_status'] = 'draft'; - if ('' != $_POST['saveasprivate'] ) + if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] ) $_POST['post_status'] = 'private'; - if ('' != $_POST['publish'] ) + if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) ) $_POST['post_status'] = 'publish'; - if ('' != $_POST['advanced'] ) + if ( isset($_POST['advanced']) && '' != $_POST['advanced'] ) $_POST['post_status'] = 'draft'; if ( 'page' == $_POST['post_type'] ) { @@ -267,6 +288,13 @@ function wp_write_post() { if (!isset( $_POST['ping_status'] )) $_POST['ping_status'] = 'closed'; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; @@ -309,6 +337,8 @@ function wp_write_post() { // Now that we have an ID we can fix any attachment anchor hrefs _fix_attachment_links( $post_ID ); + wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID ); + return $post_ID; } @@ -348,11 +378,13 @@ function add_meta( $post_ID ) { if ( in_array($metakey, $protected) ) return false; - $result = $wpdb->query( " - INSERT INTO $wpdb->postmeta - (post_id,meta_key,meta_value ) - VALUES ('$post_ID','$metakey','$metavalue' ) - " ); + wp_cache_delete($post_ID, 'post_meta'); + + $wpdb->query( " + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value ) + VALUES ('$post_ID','$metakey','$metavalue' ) + " ); return $wpdb->insert_id; } return false; @@ -362,6 +394,9 @@ function delete_meta( $mid ) { global $wpdb; $mid = (int) $mid; + $post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = '$mid'"); + wp_cache_delete($post_id, 'post_meta'); + return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" ); } @@ -408,6 +443,9 @@ function update_meta( $mid, $mkey, $mvalue ) { if ( in_array($mkey, $protected) ) return false; + $post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = '$mid'"); + wp_cache_delete($post_id, 'post_meta'); + $mvalue = maybe_serialize( stripslashes( $mvalue )); $mvalue = $wpdb->escape( $mvalue ); $mid = (int) $mid; @@ -420,7 +458,6 @@ function update_meta( $mid, $mkey, $mvalue ) { // Replace hrefs of attachment anchors with up-to-date permalinks. function _fix_attachment_links( $post_ID ) { - global $wp_rewrite; $post = & get_post( $post_ID, ARRAY_A ); @@ -468,4 +505,190 @@ function _relocate_children( $old_ID, $new_ID ) { return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" ); } -?> \ No newline at end of file +function get_available_post_statuses($type = 'post') { + $stati = wp_count_posts($type); + + return array_keys(get_object_vars($stati)); +} + +function wp_edit_posts_query( $q = false ) { + global $wpdb; + if ( false === $q ) + $q = $_GET; + $q['m'] = (int) $q['m']; + $q['cat'] = (int) $q['cat']; + $post_stati = array( // array( adj, noun ) + 'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')), + 'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')), + 'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')), + 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')), + 'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private (%s)', 'Private (%s)')), + ); + + $post_stati = apply_filters('post_stati', $post_stati); + + $avail_post_stati = get_available_post_statuses('post'); + + $post_status_q = ''; + if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) { + $post_status_q = '&post_status=' . $q['post_status']; + $post_status_q .= '&perm=readable'; + } + + if ( 'pending' === $q['post_status'] ) { + $order = 'ASC'; + $orderby = 'modified'; + } elseif ( 'draft' === $q['post_status'] ) { + $order = 'DESC'; + $orderby = 'modified'; + } else { + $order = 'DESC'; + $orderby = 'date'; + } + + wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby"); + + return array($post_stati, $avail_post_stati); +} + +function get_available_post_mime_types($type = 'attachment') { + global $wpdb; + + $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type)); + return $types; +} + +function wp_edit_attachments_query( $q = false ) { + global $wpdb; + if ( false === $q ) + $q = $_GET; + $q['m'] = (int) $q['m']; + $q['cat'] = (int) $q['cat']; + $q['post_type'] = 'attachment'; + $q['post_status'] = 'any'; + $q['posts_per_page'] = 15; + $post_mime_types = array( // array( adj, noun ) + 'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image (%s)', 'Images (%s)')), + 'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio (%s)', 'Audio (%s)')), + 'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video (%s)', 'Video (%s)')), + ); + $post_mime_types = apply_filters('post_mime_types', $post_mime_types); + + $avail_post_mime_types = get_available_post_mime_types('attachment'); + + if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) + unset($q['post_mime_type']); + + wp($q); + + return array($post_mime_types, $avail_post_mime_types); +} + +function postbox_classes( $id, $page ) { + $current_user = wp_get_current_user(); + if ( $closed = get_usermeta( $current_user->ID, 'closedpostboxes_'.$page ) ) { + if ( !is_array( $closed ) ) return ''; + return in_array( $id, $closed )? 'if-js-closed' : ''; + } else { + if ( 'tagsdiv' == $id || 'categorydiv' == $id ) return ''; + else return 'if-js-closed'; + } +} + +function get_sample_permalink($id, $title=null, $name = null) { + $post = &get_post($id); + if (!$post->ID) { + return array('', ''); + } + $original_status = $post->post_status; + $original_date = $post->post_date; + $original_name = $post->post_name; + + // Hack: get_permalink would return ugly permalink for + // drafts, so we will fake, that our post is published + if (in_array($post->post_status, array('draft', 'pending'))) { + $post->post_status = 'publish'; + $post->post_date = date('Y-m-d H:i:s'); + $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID); + } + + // If the user wants to set a new name -- override the current one + // Note: if empty name is supplied -- use the title instead, see #6072 + if (!is_null($name)) { + $post->post_name = sanitize_title($name? $name : $title, $post->ID); + } + + $permalink = get_permalink($post, true); + + // Handle page hierarchy + if ( 'page' == $post->post_type ) { + $uri = get_page_uri($post->ID); + $uri = untrailingslashit($uri); + $uri = strrev( stristr( strrev( $uri ), '/' ) ); + $uri = untrailingslashit($uri); + if ( !empty($uri) ) + $uri .='/'; + $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink); + } + + $permalink = array($permalink, $post->post_name); + $post->post_status = $original_status; + $post->post_date = $original_date; + $post->post_name = $original_name; + $post->post_title = $original_title; + return $permalink; +} + +function get_sample_permalink_html($id, $new_title=null, $new_slug=null) { + $post = &get_post($id); + list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); + if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) { + return ''; + } + $title = __('Click to edit this part of the permalink'); + if (strlen($post_name) > 30) { + $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14); + } else { + $post_name_abridged = $post_name; + } + $post_name_html = ''.$post_name_abridged.''.$post_name.''; + $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); + $return = '' . __('Permalink:') . "\n" . '' . $display_link . "\n"; + $return .= '' . __('Edit') . "\n"; + return $return; +} + +// false: not locked or locked by current user +// int: user ID of user with lock +function wp_check_post_lock( $post_id ) { + global $current_user; + + if ( !$post = get_post( $post_id ) ) + return false; + + $lock = get_post_meta( $post->ID, '_edit_lock', true ); + $last = get_post_meta( $post->ID, '_edit_last', true ); + + $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); + + if ( $lock && $lock > time() - $time_window && $last != $current_user->ID ) + return $last; + return false; +} + +function wp_set_post_lock( $post_id ) { + global $current_user; + if ( !$post = get_post( $post_id ) ) + return false; + if ( !$current_user || !$current_user->ID ) + return false; + + $now = time(); + + if ( !add_post_meta( $post->ID, '_edit_lock', $now, true ) ) + update_post_meta( $post->ID, '_edit_lock', $now ); + if ( !add_post_meta( $post->ID, '_edit_last', $current_user->ID, true ) ) + update_post_meta( $post->ID, '_edit_last', $current_user->ID ); +} + +?> diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 0ccf674a..b8c7e2cb 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -3,7 +3,10 @@ $charset_collate = ''; -if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { +// Declare these as global in case schema.php is included from a function. +global $wpdb, $wp_queries; + +if ( $wpdb->supports_collation() ) { if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; if ( ! empty($wpdb->collate) ) @@ -31,6 +34,7 @@ CREATE TABLE $wpdb->term_taxonomy ( CREATE TABLE $wpdb->term_relationships ( object_id bigint(20) NOT NULL default 0, term_taxonomy_id bigint(20) NOT NULL default 0, + term_order int(11) NOT NULL default 0, PRIMARY KEY (object_id,term_taxonomy_id), KEY term_taxonomy_id (term_taxonomy_id) ) $charset_collate; @@ -45,14 +49,16 @@ CREATE TABLE $wpdb->comments ( comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', comment_content text NOT NULL, comment_karma int(11) NOT NULL default '0', - comment_approved enum('0','1','spam') NOT NULL default '1', + comment_approved varchar(20) NOT NULL default '1', comment_agent varchar(255) NOT NULL default '', comment_type varchar(20) NOT NULL default '', comment_parent bigint(20) NOT NULL default '0', user_id bigint(20) NOT NULL default '0', PRIMARY KEY (comment_ID), KEY comment_approved (comment_approved), - KEY comment_post_ID (comment_post_ID) + KEY comment_post_ID (comment_post_ID), + KEY comment_approved_date_gmt (comment_approved,comment_date_gmt), + KEY comment_date_gmt (comment_date_gmt) ) $charset_collate; CREATE TABLE $wpdb->links ( link_id bigint(20) NOT NULL auto_increment, @@ -62,7 +68,7 @@ CREATE TABLE $wpdb->links ( link_target varchar(25) NOT NULL default '', link_category bigint(20) NOT NULL default '0', link_description varchar(255) NOT NULL default '', - link_visible enum('Y','N') NOT NULL default 'Y', + link_visible varchar(20) NOT NULL default 'Y', link_owner int(11) NOT NULL default '1', link_rating int(11) NOT NULL default '0', link_updated datetime NOT NULL default '0000-00-00 00:00:00', @@ -78,7 +84,7 @@ CREATE TABLE $wpdb->options ( blog_id int(11) NOT NULL default '0', option_name varchar(64) NOT NULL default '', option_value longtext NOT NULL, - autoload enum('yes','no') NOT NULL default 'yes', + autoload varchar(20) NOT NULL default 'yes', PRIMARY KEY (option_id,blog_id,option_name), KEY option_name (option_name) ) $charset_collate; @@ -100,9 +106,9 @@ CREATE TABLE $wpdb->posts ( post_title text NOT NULL, post_category int(4) NOT NULL default '0', post_excerpt text NOT NULL, - post_status enum('publish','draft','private','static','object','attachment','inherit','future', 'pending') NOT NULL default 'publish', - comment_status enum('open','closed','registered_only') NOT NULL default 'open', - ping_status enum('open','closed') NOT NULL default 'open', + post_status varchar(20) NOT NULL default 'publish', + comment_status varchar(20) NOT NULL default 'open', + ping_status varchar(20) NOT NULL default 'open', post_password varchar(20) NOT NULL default '', post_name varchar(200) NOT NULL default '', to_ping text NOT NULL, @@ -224,7 +230,7 @@ function populate_options() { } // 2.0.3 - add_option('secret', md5(uniqid(microtime()))); + add_option('secret', wp_generate_password(64)); // 2.1 add_option('blog_public', '1'); @@ -234,8 +240,18 @@ function populate_options() { // 2.2 add_option('tag_base'); + // 2.5 + add_option('show_avatars', '1'); + add_option('avatar_rating', 'G'); + add_option('upload_url_path', ''); + add_option('thumbnail_size_w', 150); + add_option('thumbnail_size_h', 150); + add_option('thumbnail_crop', 1); + add_option('medium_size_w', 300); + add_option('medium_size_h', 300); + // Delete unused options - $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing'); + $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval'); foreach ($unusedoptions as $option) : delete_option($option); endforeach; @@ -251,17 +267,24 @@ function populate_roles() { populate_roles_160(); populate_roles_210(); populate_roles_230(); + populate_roles_250(); } function populate_roles_160() { - global $wp_roles; - // Add roles - add_role('administrator', __('Administrator')); - add_role('editor', __('Editor')); - add_role('author', __('Author')); - add_role('contributor', __('Contributor')); - add_role('subscriber', __('Subscriber')); + + // Dummy gettext calls to get strings in the catalog. + _c('Administrator|User role'); + _c('Editor|User role'); + _c('Author|User role'); + _c('Contributor|User role'); + _c('Subscriber|User role'); + + add_role('administrator', 'Administrator|User role'); + add_role('editor', 'Editor|User role'); + add_role('author', 'Author|User role'); + add_role('contributor', 'Contributor|User role'); + add_role('subscriber', 'Subscriber|User role'); // Add caps for Administrator role $role = get_role('administrator'); @@ -392,4 +415,12 @@ function populate_roles_230() { } } +function populate_roles_250() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'edit_dashboard' ); + } +} + ?> diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php index 3f70f45b..b490ed63 100644 --- a/wp-admin/includes/taxonomy.php +++ b/wp-admin/includes/taxonomy.php @@ -16,11 +16,11 @@ function get_category_to_edit( $id ) { return $category; } -function wp_create_category($cat_name) { +function wp_create_category( $cat_name, $parent = 0 ) { if ( $id = category_exists($cat_name) ) return $id; - return wp_insert_category( array('cat_name' => $cat_name) ); + return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) ); } function wp_create_categories($categories, $post_id = '') { @@ -40,8 +40,6 @@ function wp_create_categories($categories, $post_id = '') { } function wp_delete_category($cat_ID) { - global $wpdb; - $cat_ID = (int) $cat_ID; $default = get_option('default_category'); @@ -52,13 +50,17 @@ function wp_delete_category($cat_ID) { return wp_delete_term($cat_ID, 'category', "default=$default"); } -function wp_insert_category($catarr) { - global $wpdb; - +function wp_insert_category($catarr, $wp_error = false) { + $cat_defaults = array('cat_ID' => 0, 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => ''); + $cat_arr = wp_parse_args($cat_arr, $cat_defaults); extract($catarr, EXTR_SKIP); - if ( trim( $cat_name ) == '' ) - return 0; + if ( trim( $cat_name ) == '' ) { + if ( ! $wp_error ) + return 0; + else + return new WP_Error( 'cat_name', __('You did not enter a category name.') ); + } $cat_ID = (int) $cat_ID; @@ -74,6 +76,9 @@ function wp_insert_category($catarr) { $parent = $category_parent; $parent = (int) $parent; + if ( $parent < 0 ) + $parent = 0; + if ( empty($parent) || !category_exists( $parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $parent) ) ) $parent = 0; @@ -84,15 +89,17 @@ function wp_insert_category($catarr) { else $cat_ID = wp_insert_term($cat_name, 'category', $args); - if ( is_wp_error($cat_ID) ) - return 0; + if ( is_wp_error($cat_ID) ) { + if ( $wp_error ) + return $cat_ID; + else + return 0; + } return $cat_ID['term_id']; } function wp_update_category($catarr) { - global $wpdb; - $cat_ID = (int) $catarr['cat_ID']; if ( $cat_ID == $catarr['category_parent'] ) @@ -115,8 +122,6 @@ function wp_update_category($catarr) { // function get_tags_to_edit( $post_id ) { - global $wpdb; - $post_id = (int) $post_id; if ( !$post_id ) return false; @@ -145,4 +150,4 @@ function wp_create_tag($tag_name) { return wp_insert_term($tag_name, 'post_tag'); } -?> \ No newline at end of file +?> diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 71bf387c..db80bf80 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -6,8 +6,12 @@ // Dandy new recursive multiple category stuff. function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { - if ( !$categories ) - $categories = get_categories( 'hide_empty=0' ); + if ( !$categories ) { + $args = array('hide_empty' => 0); + if ( !empty($_GET['s']) ) + $args['search'] = $_GET['s']; + $categories = get_categories( $args ); + } $children = _get_term_hierarchy('category'); @@ -34,112 +38,177 @@ function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { function _cat_row( $category, $level, $name_override = false ) { global $class; + $category = get_category( $category ); + $pad = str_repeat( '— ', $level ); + $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); if ( current_user_can( 'manage_categories' ) ) { - $edit = "".__( 'Edit' ).""; - $default_cat_id = (int) get_option( 'default_category' ); - $default_link_cat_id = (int) get_option( 'default_link_category' ); - - if ( $category->term_id != $default_cat_id ) - $edit .= "term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' ).""; - else - $edit .= "".__( "Default" ); - } else - $edit = ''; + $edit = "name)) . "'>$name"; + } else { + $edit = $name; + } - $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; + $class = " class='alternate'" == $class ? '' : " class='alternate'"; $category->count = number_format_i18n( $category->count ); $posts_count = ( $category->count > 0 ) ? "$category->count" : $category->count; $output = " - $category->term_id - " . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . " - $category->description - $posts_count - $edit\n\t\n"; + "; + if ( absint(get_option( 'default_category' ) ) != $category->term_id ) { + $output .= ""; + } else { + $output .= " "; + } + $output .= " + $edit + $category->description + $posts_count\n\t\n"; return apply_filters('cat_row', $output); } +function link_cat_row( $category ) { + global $class; + + if ( !$category = get_term( $category, 'link_category' ) ) + return false; + if ( is_wp_error( $category ) ) + return $category; + + $name = ( $name_override ? $name_override : $category->name ); + if ( current_user_can( 'manage_categories' ) ) { + $edit = "name)) . "' class='edit'>$name"; + $default_cat_id = (int) get_option( 'default_link_category' ); + } else { + $edit = $name; + } + + $class = " class='alternate'" == $class ? '' : " class='alternate'"; + + $category->count = number_format_i18n( $category->count ); + $count = ( $category->count > 0 ) ? "$category->count" : $category->count; + $output = " + "; + if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) { + $output .= ""; + } else { + $output .= " "; + } + $output .= " + $edit + $category->description + $count"; + + return apply_filters( 'link_cat_row', $output ); +} + function checked( $checked, $current) { if ( $checked == $current) echo ' checked="checked"'; } -// TODO: Remove? -function documentation_link( $for ) { - return; -} - function selected( $selected, $current) { if ( $selected == $current) echo ' selected="selected"'; } // -// Nasty Category Stuff +// Category Checklists // -function sort_cats( $cat1, $cat2 ) { - if ( $cat1['checked'] || $cat2['checked'] ) - return ( $cat1['checked'] && !$cat2['checked'] ) ? -1 : 1; - else - return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] ); +// Deprecated. Use wp_link_category_checklist +function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) { + global $post_ID; + wp_category_checklist($post_ID); } -function get_nested_categories( $default = 0, $parent = 0 ) { - global $post_ID, $mode, $wpdb, $checked_categories; +class Walker_Category_Checklist extends Walker { + var $tree_type = 'category'; + var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this - if ( empty($checked_categories) ) { - if ( $post_ID ) { - $checked_categories = wp_get_post_categories($post_ID); + function start_lvl(&$output, $depth, $args) { + $indent = str_repeat("\t", $depth); + $output .= "$indent
      \n"; + } - if ( count( $checked_categories ) == 0 ) { - // No selected categories, strange - $checked_categories[] = $default; - } - } else { - $checked_categories[] = $default; - } + function end_lvl(&$output, $depth, $args) { + $indent = str_repeat("\t", $depth); + $output .= "$indent
    \n"; } - $cats = get_categories("parent=$parent&hide_empty=0&fields=ids"); + function start_el(&$output, $category, $depth, $args) { + extract($args); - $result = array (); - if ( is_array( $cats ) ) { - foreach ( $cats as $cat) { - $result[$cat]['children'] = get_nested_categories( $default, $cat); - $result[$cat]['cat_ID'] = $cat; - $result[$cat]['checked'] = in_array( $cat, $checked_categories ); - $result[$cat]['cat_name'] = get_the_category_by_ID( $cat); - } + $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; + $output .= "\n
  10. " . ''; } - $result = apply_filters('get_nested_categories', $result); - usort( $result, 'sort_cats' ); - - return $result; + function end_el(&$output, $category, $depth, $args) { + $output .= "
  11. \n"; + } } -function write_nested_categories( $categories ) { - foreach ( $categories as $category ) { - echo '
  12. "; +function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false ) { + $walker = new Walker_Category_Checklist; + $descendants_and_self = (int) $descendants_and_self; - if ( $category['children'] ) { - echo "
      \n"; - write_nested_categories( $category['children'] ); - echo "
    \n"; - } + $args = array(); + + if ( $post_id ) + $args['selected_cats'] = wp_get_post_categories($post_id); + else + $args['selected_cats'] = array(); + if ( is_array( $selected_cats ) ) + $args['selected_cats'] = $selected_cats; + $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); + if ( $descendants_and_self ) { + $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" ); + $self = get_category( $descendants_and_self ); + array_unshift( $categories, $self ); + } else { + $categories = get_categories('get=all'); } + + $args = array($categories, 0, $args); + $output = call_user_func_array(array(&$walker, 'walk'), $args); + + echo $output; } -function dropdown_categories( $default = 0 ) { - write_nested_categories( get_nested_categories( $default) ); +function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) { + global $post_ID; + if ( $post_ID ) + $checked_categories = wp_get_post_categories($post_ID); + else + $checked_categories = array(); + $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); + + $popular_ids = array(); + foreach ( (array) $categories as $category ) { + $popular_ids[] = $category->term_id; + $id = "popular-category-$category->term_id"; + ?> + + + + count ); + $count = ( $count > 0 ) ? "$count" : $count; - if (! $pages ) - return false; + $name = apply_filters( 'term_name', $tag->name ); + $out = ''; + $out .= ''; + $out .= ' '; + $out .= '' . + $name . ''; + + $out .= "$count"; + $out .= ''; + + return $out; +} + +// Outputs appropriate rows for the Nth page of the Tag Management screen, +// assuming M tags displayed at a time on the page +// Returns the number of tags displayed +function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { + + // Get a page worth of tags + $start = ($page - 1) * $pagesize; + + $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0); + + if ( !empty( $searchterms ) ) { + $args['search'] = $searchterms; + } + + $tags = get_terms( 'post_tag', $args ); + + // convert it to table rows + $out = ''; + $class = ''; + $count = 0; + foreach( $tags as $tag ) + $out .= _tag_row( $tag, ++$count % 2 ? ' class="alternate"' : '' ); + + // filter and send to screen + $out = apply_filters('tag_rows', $out); + echo $out; + return $count; +} + +// define the columns to display, the syntax is 'internal name' => 'display name' +function wp_manage_posts_columns() { + $posts_columns = array(); + $posts_columns['cb'] = ''; + if ( 'draft' === $_GET['post_status'] ) + $posts_columns['modified'] = __('Modified'); + elseif ( 'pending' === $_GET['post_status'] ) + $posts_columns['modified'] = __('Submitted'); + else + $posts_columns['date'] = __('Date'); + $posts_columns['title'] = __('Title'); + $posts_columns['author'] = __('Author'); + $posts_columns['categories'] = __('Categories'); + $posts_columns['tags'] = __('Tags'); + if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) + $posts_columns['comments'] = '
    Comments
    '; + $posts_columns['status'] = __('Status'); + $posts_columns = apply_filters('manage_posts_columns', $posts_columns); + + return $posts_columns; +} - foreach ( $pages as $post) { - setup_postdata( $post); - if ( $hierarchy && ($post->post_parent != $parent) ) - continue; +// define the columns to display, the syntax is 'internal name' => 'display name' +function wp_manage_media_columns() { + $posts_columns = array(); + $posts_columns['cb'] = ''; + $posts_columns['icon'] = ''; + $posts_columns['media'] = _c('Media|media column header'); + $posts_columns['desc'] = _c('Description|media column header'); + $posts_columns['date'] = _c('Date Added|media column header'); + $posts_columns['parent'] = _c('Appears with|media column header'); + $posts_columns['comments'] = '
    Comments
    '; + $posts_columns['location'] = _c('Location|media column header'); + $posts_columns = apply_filters('manage_media_columns', $posts_columns); + + return $posts_columns; +} - $post->post_title = wp_specialchars( $post->post_title ); - $pad = str_repeat( '— ', $level ); - $id = (int) $post->ID; - $class = ('alternate' == $class ) ? '' : 'alternate'; +function wp_manage_pages_columns() { + $posts_columns = array(); + $posts_columns['cb'] = ''; + if ( 'draft' === $_GET['post_status'] ) + $posts_columns['modified'] = __('Modified'); + elseif ( 'pending' === $_GET['post_status'] ) + $posts_columns['modified'] = __('Submitted'); + else + $posts_columns['date'] = __('Date'); + $posts_columns['title'] = __('Title'); + $posts_columns['author'] = __('Author'); + if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) + $posts_columns['comments'] = '
    '; + $posts_columns['status'] = __('Status'); + $posts_columns = apply_filters('manage_pages_columns', $posts_columns); + + return $posts_columns; +} + +/* + * display one row if the page doesn't have any children + * otherwise, display the row and its children in subsequent rows + */ +function display_page_row( $page, &$children_pages, $level = 0 ) { + global $post; + static $class; + + $post = $page; + setup_postdata($page); + + $page->post_title = wp_specialchars( $page->post_title ); + $pad = str_repeat( '— ', $level ); + $id = (int) $page->ID; + $class = ('alternate' == $class ) ? '' : 'alternate'; + $posts_columns = wp_manage_pages_columns(); + $title = get_the_title(); + if ( empty($title) ) + $title = __('(no title)'); ?> - ID; ?> - - - - - post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?> - - " . __( 'Edit' ) . ""; } ?> - " . __( 'Delete' ) . ""; } ?> - + + + $column_display_name) { + + switch ($column_name) { + + case 'cb': + ?> + + post_date && 'date' == $column_name ) { + $t_time = $h_time = __('Unpublished'); + } else { + if ( 'modified' == $column_name ) { + $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); + $m_time = $page->post_modified; + $time = get_post_modified_time('G', true); + } else { + $t_time = get_the_time(__('Y/m/d g:i:s A')); + $m_time = $page->post_date; + $time = get_post_time('G', true); + } + if ( ( abs(time() - $time) ) < 86400 ) { + if ( ( 'future' == $page->post_status) ) + $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); + else + $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); + } else { + $h_time = mysql2date(__('Y/m/d'), $m_time); + } + } + ?> + + + "> + post_status) _e(' — Private'); ?> + +
    + ID ); + $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); + if ( $left ) + echo ''; + comments_number("" . __('0') . '', "" . __('1') . '', "" . __('%') . ''); + if ( $left ) + echo ''; + ?> +
    + + + + + " rel="permalink"> + post_status ) { + case 'publish' : + case 'private' : + _e('Published'); + break; + case 'future' : + _e('Scheduled'); + break; + case 'pending' : + _e('Pending Review'); + break; + case 'draft' : + _e('Unpublished'); + break; + } + ?> + + + + + + + post_parent == $id ) { + array_splice($children_pages, $i, 1); + display_page_row($child, $children_pages, $level+1); + $i = -1; //as numeric keys in $children_pages are not preserved after splice + } + } +} + +/* + * displays pages in hierarchical order + */ +function page_rows( $pages ) { + if ( ! $pages ) + $pages = get_pages( 'sort_column=menu_order' ); + + if ( ! $pages ) + return false; + + // splice pages into two parts: those without parent and those with parent + + $top_level_pages = array(); + $children_pages = array(); + + foreach ( $pages as $page ) { + + // catch and repair bad pages + if ( $page->post_parent == $page->ID ) { + $page->post_parent = 0; + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) ); + clean_page_cache( $page->ID ); + } + + if ( 0 == $page->post_parent ) + $top_level_pages[] = $page; + else + $children_pages[] = $page; } + + foreach ( $top_level_pages as $page ) + display_page_row($page, $children_pages, 0); + + /* + * display the remaining children_pages which are orphans + * having orphan requires parental attention + */ + if ( count($children_pages) > 0 ) { + $empty_array = array(); + foreach ( $children_pages as $orphan_page ) { + clean_page_cache( $orphan_page->ID); + display_page_row( $orphan_page, $empty_array, 0 ); + } + } } -function user_row( $user_object, $style = '' ) { - if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) +function user_row( $user_object, $style = '', $role = '' ) { + global $wp_roles; + + $current_user = wp_get_current_user(); + + if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) $user_object = new WP_User( (int) $user_object ); $email = $user_object->user_email; $url = $user_object->user_url; @@ -212,33 +546,50 @@ function user_row( $user_object, $style = '' ) { if ( strlen( $short_url ) > 35 ) $short_url = substr( $short_url, 0, 32 ).'...'; $numposts = get_usernumposts( $user_object->ID ); + if ( current_user_can( 'edit_user', $user_object->ID ) ) { + if ($current_user->ID == $user_object->ID) { + $edit = 'profile.php'; + } else { + $edit = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); + } + $edit = "$user_object->user_login"; + } else { + $edit = $user_object->user_login; + } + $role_name = translate_with_context($wp_roles->role_names[$role]); $r = " - - - + + $edit + $user_object->first_name $user_object->last_name $email - $short_url"; - $r .= "\n\t\t"; + $role_name"; + $r .= "\n\t\t"; if ( $numposts > 0 ) { $r .= ""; - $r .= sprintf(__ngettext( 'View %s post', 'View %s posts', $numposts ), $numposts); + $r .= $numposts; $r .= ''; - } - $r .= "\n\t\t"; - if ( current_user_can( 'edit_user', $user_object->ID ) ) { - $edit_link = add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ); - $r .= "".__( 'Edit' ).""; + } else { + $r .= 0; } $r .= "\n\t"; return $r; } -function _wp_get_comment_list( $s = false, $start, $num ) { +function _wp_get_comment_list( $status = '', $s = false, $start, $num ) { global $wpdb; $start = abs( (int) $start ); $num = (int) $num; + if ( 'moderated' == $status ) + $approved = "comment_approved = '0'"; + elseif ( 'approved' == $status ) + $approved = "comment_approved = '1'"; + elseif ( 'spam' == $status ) + $approved = "comment_approved = 'spam'"; + else + $approved = "( comment_approved = '0' OR comment_approved = '1' )"; + if ( $s ) { $s = $wpdb->escape($s); $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE @@ -247,10 +598,10 @@ function _wp_get_comment_list( $s = false, $start, $num ) { comment_author_url LIKE ('%$s%') OR comment_author_IP LIKE ('%$s%') OR comment_content LIKE ('%$s%') ) AND - comment_approved != 'spam' - ORDER BY comment_date DESC LIMIT $start, $num"); + $approved + ORDER BY comment_date_gmt DESC LIMIT $start, $num"); } else { - $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" ); + $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments USE INDEX (comment_date_gmt) WHERE $approved ORDER BY comment_date_gmt DESC LIMIT $start, $num" ); } update_comment_cache($comments); @@ -260,46 +611,95 @@ function _wp_get_comment_list( $s = false, $start, $num ) { return array($comments, $total); } -function _wp_comment_list_item( $id, $alt = 0 ) { - global $authordata, $comment, $wpdb; - $id = (int) $id; - $comment =& get_comment( $id ); - $class = ''; +function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true ) { + global $comment, $post; + $comment = get_comment( $comment_id ); $post = get_post($comment->comment_post_ID); $authordata = get_userdata($post->post_author); - $comment_status = wp_get_comment_status($comment->comment_ID); - if ( 'unapproved' == $comment_status ) - $class .= ' unapproved'; - if ( $alt % 2 ) - $class .= ' alternate'; - echo "
  13. "; -?> -

    comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | |

    + $the_comment_status = wp_get_comment_status($comment->comment_ID); + $class = ('unapproved' == $the_comment_status) ? 'unapproved' : ''; - + if ( current_user_can( 'edit_post', $post->ID ) ) { + $post_link = ""; -

    — [ -comment_post_ID) ) { - echo " " . __('Edit') . ''; - echo ' | comment_author)) . "', theCommentList );\">" . __('Delete') . ' '; - if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { - echo ' | ' . __('Unapprove') . ' '; - echo ' | ' . __('Approve') . ' '; + $post_link .= get_the_title($comment->comment_post_ID) . ''; + + $edit_link_start = ""; + $edit_link_end = ''; + } else { + $post_link = get_the_title($comment->comment_post_ID); + $edit_link_start = $edit_link_end =''; } - echo " | comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . " "; -} -$post = get_post($comment->comment_post_ID, OBJECT, 'display'); -$post_title = wp_specialchars( $post->post_title, 'double' ); -$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; + + $author_url = get_comment_author_url(); + if ( 'http://' == $author_url ) + $author_url = ''; + $author_url_display = $author_url; + if ( strlen($author_url_display) > 50 ) + $author_url_display = substr($author_url_display, 0, 49) . '...'; + + $ptime = date('G', strtotime( $comment->comment_date ) ); + if ( ( abs(time() - $ptime) ) < 86400 ) + $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); + else + $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); + + $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); + $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); + $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); + $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); + ?> - ] —

    -
  14. + + + comment_post_ID) ) { ?> + + +


    + + | + + ID ) ) : ?> + comment_author_email) ): ?> + | + + + +

    + +

    + + + comment_ID:unapproved:e7e7d3:e7e7d3' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . ' | '; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ' | '; + + // we're looking at list of only approved or only unapproved comments + if ( 'moderated' == $comment_status ) { + $actions['approve'] = "" . __( 'Approve' ) . ' | '; + unset($actions['unapprove']); + } elseif ( 'approved' == $comment_status ) { + $actions['unapprove'] = "" . __( 'Unapprove' ) . ' | '; + unset($actions['approve']); + } + + if ( current_user_can('edit_post', $comment->comment_post_ID) ) { + $actions['spam'] = "" . __( 'Spam' ) . ' | '; + $actions['delete'] = "" . __('Delete') . ''; + foreach ( $actions as $action => $link ) + echo "$link"; + } + ?> + + +  '; //TBODY needed for list-manipulation JS + echo ' '; //TBODY needed for list-manipulation JS return; } $count = 0; @@ -336,43 +735,53 @@ function list_meta( $meta ) { + "; - foreach ( $meta as $entry ) { - ++ $count; - if ( $count % 2 ) - $style = 'alternate'; - else - $style = ''; - if ('_' == $entry['meta_key'] { 0 } ) - $style .= ' hidden'; - - if ( is_serialized( $entry['meta_value'] ) ) { - if ( is_serialized_string( $entry['meta_value'] ) ) { - // this is a serialized string, so we should display it - $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); - } else { - // this is a serialized array/object so we should NOT display it - --$count; - continue; - } - } + foreach ( $meta as $entry ) + echo _list_meta_row( $entry, $count ); + echo "\n\t"; +} + +function _list_meta_row( $entry, &$count ) { + static $update_nonce = false; + if ( !$update_nonce ) + $update_nonce = wp_create_nonce( 'add-meta' ); - $key_js = js_escape( $entry['meta_key'] ); - $entry['meta_key'] = attribute_escape($entry['meta_key']); - $entry['meta_value'] = attribute_escape($entry['meta_value']); - $entry['meta_id'] = (int) $entry['meta_id']; - $r .= "\n\t"; - $r .= "\n\t\t"; - $r .= "\n\t\t"; - $r .= "\n\t\t
    "; - $r .= "\n\t\t"; - $r .= "\n\t"; + $r = ''; + ++ $count; + if ( $count % 2 ) + $style = 'alternate'; + else + $style = ''; + if ('_' == $entry['meta_key'] { 0 } ) + $style .= ' hidden'; + + if ( is_serialized( $entry['meta_value'] ) ) { + if ( is_serialized_string( $entry['meta_value'] ) ) { + // this is a serialized string, so we should display it + $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); + } else { + // this is a serialized array/object so we should NOT display it + --$count; + return; + } } - echo $r; - echo "\n\t"; + + $entry['meta_key'] = attribute_escape($entry['meta_key']); + $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a "; + $r .= "\n\t\t
    "; + $r .= "\n\t\t"; + $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); + $r .= "\n\t"; + return $r; } function meta_form() { @@ -388,14 +797,14 @@ function meta_form() { if ( $keys ) natcasesort($keys); ?> -

    +

    - - +
    +
    + + +
    -

    post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true; - + $tab_index_attribute = ''; if ( (int) $tab_index > 0 ) $tab_index_attribute = " tabindex=\"$tab_index\""; - echo '
    '; + // echo '
    '; $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 ); $post_date = ($for_post) ? $post->post_date : $comment->comment_date; @@ -440,28 +851,27 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) { $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj ); $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj ); - echo "\n"; for ( $i = 1; $i < 13; $i = $i +1 ) { - echo "\t\t\t\n"; - } -?> - - /> - /> @ - /> : - /> - -get_month( $mm ), $jj, $aa, $hh, $mn ); + $month .= ' selected="selected"'; + $month .= '>' . $wp_locale->get_month( $i ) . "\n"; } + $month .= ''; + + $day = ''; + $year = ''; + $hour = ''; + $minute = ''; + printf(_c('%1$s%2$s, %3$s
    @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute); + echo "\n\n"; + foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) + echo '' . "\n"; ?> -
    - " size="2" maxlength="2" /> +Browse Happy

    + Browse Happy '; } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) - add_action( 'admin_footer', 'browse_happy' ); + add_action( 'in_admin_footer', 'browse_happy' ); function the_attachment_links( $id = false ) { $id = (int) $id; @@ -558,11 +968,13 @@ function the_attachment_links( $id = false ) { function wp_dropdown_roles( $default = false ) { global $wp_roles; $r = ''; - foreach( $wp_roles->role_names as $role => $name ) + foreach( $wp_roles->role_names as $role => $name ) { + $name = translate_with_context($name); if ( $default == $role ) // Make default first in list $p = "\n\t"; else $r .= "\n\t"; + } echo $p . $r; } @@ -586,10 +998,15 @@ function wp_convert_bytes_to_hr( $bytes ) { return $size . $units[$power]; } -function wp_import_upload_form( $action ) { +function wp_max_upload_size() { $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); - $bytes = apply_filters( 'import_upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); + $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); + return $bytes; +} + +function wp_import_upload_form( $action ) { + $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); $size = wp_convert_bytes_to_hr( $bytes ); ?>
    @@ -601,7 +1018,7 @@ function wp_import_upload_form( $action ) {

    - +

    '; } +/** + * add_meta_box() - Add a meta box to an edit form + * + * @since 2.5 + * + * @param string $id String for use in the 'id' attribute of tags. + * @param string $title Title of the meta box + * @param string $callback Function that fills the box with the desired content. The function should echo its output. + * @param string $page The type of edit page on which to show the box (post, page, link) + * @param string $context The context within the page where the boxes should show ('normal', 'advanced') + */ +function add_meta_box($id, $title, $callback, $page, $context = 'advanced') { + global $wp_meta_boxes; + + if ( !isset($wp_meta_boxes) ) + $wp_meta_boxes = array(); + if ( !isset($wp_meta_boxes[$page]) ) + $wp_meta_boxes[$page] = array(); + if ( !isset($wp_meta_boxes[$page][$context]) ) + $wp_meta_boxes[$page][$context] = array(); + + $wp_meta_boxes[$page][$context][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); +} + +function do_meta_boxes($page, $context, $object) { + global $wp_meta_boxes; + + if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) + return; + + foreach ( (array) $wp_meta_boxes[$page][$context] as $box ) { + echo '
    ' . "\n"; + echo "

    {$box['title']}

    \n"; + echo '
    ' . "\n"; + call_user_func($box['callback'], $object, $box); + echo "
    \n"; + echo "
    \n"; + } +} + ?> diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index bd39dea2..7dae5beb 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -14,6 +14,7 @@ function current_theme_info() { $ct->screenshot = $themes[$current_theme]['Screenshot']; $ct->description = $themes[$current_theme]['Description']; $ct->author = $themes[$current_theme]['Author']; + $ct->tags = $themes[$current_theme]['Tags']; return $ct; } diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index 41945d2b..0a31531c 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -1,8 +1,8 @@ response ) { case 'development' : - return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please stay updated.' ), $GLOBALS['wp_version'], 'http://wordpress.org/download/svn/' ); + return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please stay updated.' ), $GLOBALS['wp_version'], $cur->url, $cur->current ); break; case 'upgrade' : - return sprintf( '| '.__( 'Your WordPress %s is out of date. Please update.' ).'', $GLOBALS['wp_version'], $cur->url ); - break; + if ( current_user_can('manage_options') ) { + return sprintf( '| '.__( 'Get Version %3$s' ).'', $GLOBALS['wp_version'], $cur->url, $cur->current ); + break; + } case 'latest' : default : - return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] ); + return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'], $cur->url, $cur->current ); break; } } @@ -32,14 +34,25 @@ function update_nag() { return false; if ( current_user_can('manage_options') ) - $msg = sprintf( __('A new version of WordPress is available! Please update now.'), $cur->url ); + $msg = sprintf( __('WordPress %2$s is available! Please update now.'), $cur->url, $cur->current ); else - $msg = __('A new version of WordPress is available! Please notify the site administrator.'); + $msg = sprintf( __('WordPress %2$s is available! Please notify the site administrator.'), $cur->url, $cur->current ); echo "
    $msg
    "; } add_action( 'admin_notices', 'update_nag', 3 ); +// Called directly from dashboard +function update_right_now_message() { + $cur = get_option( 'update_core' ); + + $msg = sprintf( __('This is WordPress version %s.'), $GLOBALS['wp_version'] ); + if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('manage_options') ) + $msg .= " " . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . ''; + + echo "$msg"; +} + function wp_update_plugins() { global $wp_version; @@ -62,7 +75,7 @@ function wp_update_plugins() { continue; } - if ( $current->checked[ $file ] != $p['Version'] ) + if ( strval($current->checked[ $file ]) !== strval($p['Version']) ) $plugin_changed = true; } @@ -114,9 +127,122 @@ function wp_plugin_update_row( $file ) { $r = $current->response[ $file ]; echo ""; - printf( __('There is a new version of %s available. Download version %s here.'), $plugin_data['Name'], $r->url, $r->new_version ); + if ( !current_user_can('edit_plugins') ) + printf( __('There is a new version of %1$s available. Download version %3$s here.'), $plugin_data['Name'], $r->url, $r->new_version); + else if ( empty($r->package) ) + printf( __('There is a new version of %1$s available. Download version %3$s here automatic upgrade unavailable for this plugin.'), $plugin_data['Name'], $r->url, $r->new_version); + else + printf( __('There is a new version of %1$s available. Download version %3$s here or upgrade automatically.'), $plugin_data['Name'], $r->url, $r->new_version, wp_nonce_url("update.php?action=upgrade-plugin&plugin=$file", 'upgrade-plugin_' . $file) ); + echo ""; } add_action( 'after_plugin_row', 'wp_plugin_update_row' ); +function wp_update_plugin($plugin, $feedback = '') { + global $wp_filesystem; + + if ( !empty($feedback) ) + add_filter('update_feedback', $feedback); + + // Is an update available? + $current = get_option( 'update_plugins' ); + if ( !isset( $current->response[ $plugin ] ) ) + return new WP_Error('up_to_date', __('The plugin is at the latest version.')); + + // Is a filesystem accessor setup? + if ( ! $wp_filesystem || !is_object($wp_filesystem) ) + WP_Filesystem(); + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); + + //Get the Base folder + $base = $wp_filesystem->get_base_dir(); + + if ( empty($base) ) + return new WP_Error('fs_nowordpress', __('Unable to locate WordPress directory.')); + + // Get the URL to the zip file + $r = $current->response[ $plugin ]; + + if ( empty($r->package) ) + return new WP_Error('no_package', __('Upgrade package not available.')); + + // Download the package + $package = $r->package; + apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package)); + $file = download_url($package); + + if ( is_wp_error($file) ) + return new WP_Error('download_failed', __('Download failed.'), $file->get_error_message()); + + $working_dir = $base . 'wp-content/upgrade/' . basename($plugin, '.php'); + + // Clean up working directory + if ( $wp_filesystem->is_dir($working_dir) ) + $wp_filesystem->delete($working_dir, true); + + apply_filters('update_feedback', __('Unpacking the update')); + // Unzip package to working directory + $result = unzip_file($file, $working_dir); + if ( is_wp_error($result) ) { + unlink($file); + $wp_filesystem->delete($working_dir, true); + return $result; + } + + // Once extracted, delete the package + unlink($file); + + if ( is_plugin_active($plugin) ) { + //Deactivate the plugin silently, Prevent deactivation hooks from running. + apply_filters('update_feedback', __('Deactivating the plugin')); + deactivate_plugins($plugin, true); + } + + // Remove the existing plugin. + apply_filters('update_feedback', __('Removing the old version of the plugin')); + $plugin_dir = dirname($base . PLUGINDIR . "/$plugin"); + $plugin_dir = trailingslashit($plugin_dir); + + // If plugin is in its own directory, recursively delete the directory. + if ( strpos($plugin, '/') && $plugin_dir != $base . PLUGINDIR . '/' ) //base check on if plugin includes directory seperator AND that its not the root plugin folder + $deleted = $wp_filesystem->delete($plugin_dir, true); + else + $deleted = $wp_filesystem->delete($base . PLUGINDIR . "/$plugin"); + + if ( !$deleted ) { + $wp_filesystem->delete($working_dir, true); + return new WP_Error('delete_failed', __('Could not remove the old plugin')); + } + + apply_filters('update_feedback', __('Installing the latest version')); + // Copy new version of plugin into place. + if ( !copy_dir($working_dir, $base . PLUGINDIR) ) { + //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails. + return new WP_Error('install_failed', __('Installation failed')); + } + + //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin + $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); + + // Remove working directory + $wp_filesystem->delete($working_dir, true); + + // Force refresh of plugin update information + delete_option('update_plugins'); + + if( empty($filelist) ) + return false; //We couldnt find any files in the working dir + + $folder = $filelist[0]; + $plugin = get_plugins('/' . $folder); //Pass it with a leading slash, search out the plugins in the folder, + $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list + + return $folder . '/' . $pluginfiles[0]; //Pass it without a leading slash as WP requires +} + ?> diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 402e65cc..4985aacb 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -6,7 +6,7 @@ require_once(ABSPATH . 'wp-admin/includes/admin.php'); require_once(ABSPATH . 'wp-admin/includes/schema.php'); if ( !function_exists('wp_install') ) : -function wp_install($blog_title, $user_name, $user_email, $public, $meta='') { +function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') { global $wp_rewrite; wp_check_mysql_version(); @@ -35,7 +35,7 @@ function wp_install($blog_title, $user_name, $user_email, $public, $meta='') { // being shared among blogs. Just set the role in that case. $user_id = username_exists($user_name); if ( !$user_id ) { - $random_password = substr(md5(uniqid(microtime())), 0, 6); + $random_password = wp_generate_password(); $user_id = wp_create_user($user_name, $random_password, $user_email); } else { $random_password = __('User already exists. Password inherited.'); @@ -62,13 +62,13 @@ function wp_install_defaults($user_id) { // Default category $cat_name = $wpdb->escape(__('Uncategorized')); - $cat_slug = sanitize_title(__('Uncategorized')); + $cat_slug = sanitize_title(_c('Uncategorized|Default category slug')); $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')"); $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('1', 'category', '', '0', '1')"); // Default link category $cat_name = $wpdb->escape(__('Blogroll')); - $cat_slug = sanitize_title(__('Blogroll')); + $cat_slug = sanitize_title(_c('Blogroll|Default link category slug')); $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')"); $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('2', 'link_category', '', '0', '7')"); @@ -98,14 +98,15 @@ function wp_install_defaults($user_id) { $now = date('Y-m-d H:i:s'); $now_gmt = gmdate('Y-m-d H:i:s'); $first_post_guid = get_option('home') . '/?p=1'; - $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '$first_post_guid', '1', '', '', '')"); + $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(_c('hello-world|Default post slug'))."', '$now', '$now_gmt', '$first_post_guid', '1', '', '', '')"); $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (1, 1)" ); // Default comment $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.
    To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.'))."')"); // First Page - $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')"); + $first_post_guid = get_option('home') . '/?page_id=2'; + $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(_c('about|Default page slug'))."', '$now', '$now_gmt','$first_post_guid', 'publish', 'page', '', '', '')"); } endif; @@ -198,6 +199,12 @@ function upgrade_all() { if ( $wp_current_db_version < 6124 ) upgrade_230_old_tables(); + if ( $wp_current_db_version < 7499 ) + upgrade_250(); + + if ( $wp_current_db_version < 7796 ) + upgrade_251(); + maybe_disable_automattic_widgets(); $wp_rewrite->flush_rules(); @@ -716,6 +723,22 @@ function upgrade_old_slugs() { } +function upgrade_250() { + global $wp_current_db_version; + + if ( $wp_current_db_version < 6689 ) { + populate_roles_250(); + } + +} + +function upgrade_251() { + global $wp_current_db_version; + + // Make the secret longer + update_option('secret', wp_generate_password(64)); +} + // The functions we use to actually do stuff // General @@ -1244,12 +1267,10 @@ function translate_level_to_role($level) { } function wp_check_mysql_version() { - global $wp_version; - - // Make sure the server has MySQL 4.0 - $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info()); - if ( version_compare($mysql_version, '4.0.0', '<') ) - die(sprintf(__('ERROR: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version)); + global $wpdb; + $result = $wpdb->check_database_version(); + if ( is_wp_error( $result ) ) + die( $result->get_error_message() ); } function maybe_disable_automattic_widgets() { diff --git a/wp-admin/includes/upload.php b/wp-admin/includes/upload.php deleted file mode 100644 index 0f37db78..00000000 --- a/wp-admin/includes/upload.php +++ /dev/null @@ -1,358 +0,0 @@ -post_content )); - - $class = 'text'; - $innerHTML = get_attachment_innerHTML( $id, false, $dims ); - if ( $image_src = get_attachment_icon_src() ) { - $image_rel = wp_make_link_relative($image_src); - $innerHTML = ' ' . str_replace($image_src, $image_rel, $innerHTML); - $class = 'image'; - } - - $src_base = wp_get_attachment_url(); - $src = wp_make_link_relative( $src_base ); - $src_base = str_replace($src, '', $src_base); - - if ( !trim($post_title) ) - $post_title = basename($src); - - $r = ''; - - if ( $href ) - $r .= "\n"; - if ( $href || $image_src ) - $r .= "\t\t\t$innerHTML"; - if ( $href ) - $r .= "\n"; - $size = @filesize($filesystem_path); - if ( !empty($size) ) - $r .= "\t\t\t\t".size_format($size)."\n"; - $r .= "\n\t\t
    \n\t\t\t

    \n"; - $r .= "\t\t\t\t\n"; - $r .= "\t\t\t\t\n"; - - if ( !$thumb_base = wp_get_attachment_thumb_url() ) - $thumb_base = wp_mime_type_icon(); - if ( $thumb_base ) { - $thumb_rel = wp_make_link_relative( $thumb_base ); - $thumb_base = str_replace( $thumb_rel, '', $thumb_base ); - $r .= "\t\t\t\t\n"; - $r .= "\t\t\t\t\n"; - } - - $r .= "\t\t\t\t\n"; - - if ( isset($width) ) { - $r .= "\t\t\t\t\n"; - $r .= "\t\t\t\t\n"; - } - $r .= "\t\t\t\t\n"; - $r .= "\t\t\t\t\n"; - $r .= "\t\t\t\t\n"; - $r .= "\t\t\t

    \n\t\t
    \n"; - return $r; -} - -function wp_upload_view() { - global $style, $post_id, $style; - $id = get_the_ID(); - $attachment_data = wp_get_attachment_metadata( $id ); -?> -
    -
    -

    "; - the_title(); - if ( !isset($attachment_data['width']) && 'inline' != $style ) - echo ''; - ?>

    - ' . __('view') . ''; - echo ' | '; - echo '' . __('edit') . ''; - echo ' | '; - echo '' . __('cancel') . ''; - echo ' ]'; ?> -
    - -
    -"; - echo wp_upload_display( array(171, 128) ); - if ( isset($attachment_data['width']) && 'inline' != $style ) - echo ''; ?> -
    - -
    -\n"; -} - -function wp_upload_form() { - $id = get_the_ID(); - global $post_id, $tab, $style; - $enctype = $id ? '' : ' enctype="multipart/form-data"'; - $post_id = (int) $post_id; -?> - id="upload-file" method="post" action=""> - -
    -

    "; - the_title(); - if ( !isset($attachment_data['width']) && 'inline' != $style ) - echo ''; - ?>

    - ' . __('view') . ''; - echo ' | '; - echo '' . __('links') . ''; - echo ' | '; - echo '' . __('cancel') . ''; - echo ' ]'; ?> -
    - -
    -"; - echo wp_upload_display( array(171, 128) ); - if ( isset($attachment_data['width']) && 'inline' != $style ) - echo ''; ?> -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - -
    - -
    -
    - -" - . __('Browse Files') . '' - ); - - $overrides = array('action'=>'upload'); - - $file = wp_handle_upload($_FILES['image'], $overrides); - - if ( isset($file['error']) ) - wp_die($file['error'] . "
    " . __('Back to Image Uploading') . '' - ); - - $url = $file['url']; - $type = $file['type']; - $file = $file['file']; - $filename = basename($file); - - // Construct the attachment array - $attachment = array( - 'post_title' => $post_title, - 'post_content' => $post_content, - 'post_type' => 'attachment', - 'post_parent' => $post_id, - 'post_mime_type' => $type, - 'guid' => $url - ); - - // Save the data - $id = wp_insert_attachment($attachment, $file, $post_id); - - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); - - wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id"); - die; - break; - - case 'save' : - global $from_tab, $post_id, $style; - if ( !$from_tab ) - $from_tab = 'upload'; - check_admin_referer( 'inlineuploading' ); - - wp_update_post($_POST); - wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id"); - die; - break; - - case 'delete' : - global $ID, $post_id, $from_tab, $style; - if ( !$from_tab ) - $from_tab = 'upload'; - - check_admin_referer( 'inlineuploading' ); - - if ( !current_user_can('edit_post', (int) $ID) ) - wp_die( __('You are not allowed to delete this attachment.') - . " " - . __('Go back') . '' - ); - - wp_delete_attachment($ID); - - wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id" ); - die; - break; - - endswitch; -} - -add_action( 'upload_files_upload', 'wp_upload_tab_upload_action' ); - -function wp_upload_grab_attachments( $obj ) { - $obj->is_attachment = true; -} - -function wp_upload_posts_where( $where ) { - global $post_id; - return $where . " AND post_parent = '" . (int) $post_id . "'"; -} - -function wp_upload_tab_browse() { - global $action, $paged; - $old_vars = compact( 'paged' ); - - switch ( $action ) : - case 'edit' : - case 'view' : - global $ID; - $attachments = query_posts("attachment_id=$ID"); - if ( have_posts() ) : while ( have_posts() ) : the_post(); - 'edit' == $action ? wp_upload_form() : wp_upload_view(); - endwhile; endif; - break; - default : - global $tab, $post_id, $style; - add_action( 'pre_get_posts', 'wp_upload_grab_attachments' ); - if ( 'browse' == $tab && $post_id ) - add_filter( 'posts_where', 'wp_upload_posts_where' ); - $attachments = query_posts("what_to_show=posts&post_status=any&posts_per_page=10&paged=$paged"); - - echo "
      \n"; - if ( have_posts() ) : while ( have_posts() ) : the_post(); - $href = wp_specialchars( add_query_arg( array( - 'action' => 'inline' == $style ? 'view' : 'edit', - 'ID' => get_the_ID()) - ), 1 ); - - echo "\t
    • \n"; - echo wp_upload_display( array(128,128), $href ); - echo "\t
    • \n"; - endwhile; - else : - echo "\t
    • " . __('There are no attachments to show.') . "
    • \n"; - endif; - echo "
    \n\n"; - - echo "
    \n"; - break; - endswitch; - - extract($old_vars); -} - - -function wp_upload_tab_browse_action() { - global $style; - if ( 'inline' == $style ) - wp_enqueue_script('upload'); -} - -add_action( 'upload_files_browse', 'wp_upload_tab_browse_action' ); -add_action( 'upload_files_browse-all', 'wp_upload_tab_browse_action' ); - -function wp_upload_admin_head() { - wp_admin_css( 'css/upload' ); - if ( 'inline' == @$_GET['style'] ) { - echo ""; - } -} - -?> diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index ccf1fb09..743c70cb 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -73,6 +73,13 @@ function edit_user( $user_id = 0 ) { else $user->rich_editing = 'false'; + if ( !$update ) + $user->admin_color = 'fresh'; // Default to fresh for new users. + else if ( isset( $_POST['admin_color'] ) ) + $user->admin_color = $_POST['admin_color']; + else + $user->admin_color = 'fresh'; + $errors = new WP_Error(); /* checking that username has been typed */ @@ -82,37 +89,41 @@ function edit_user( $user_id = 0 ) { /* checking the password has been typed twice */ do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 )); - if (!$update ) { - if ( $pass1 == '' || $pass2 == '' ) - $errors->add( 'pass', __( 'ERROR: Please enter your password twice.' )); + if ( $update ) { + if ( empty($pass1) && !empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: You entered your new password only once.' ), array( 'form-field' => 'pass1' ) ); + elseif ( !empty($pass1) && empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: You entered your new password only once.' ), array( 'form-field' => 'pass2' ) ); } else { - if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) ) - $errors->add( 'pass', __( "ERROR: you typed your new password only once." )); + if ( empty($pass1) ) + $errors->add( 'pass', __( 'ERROR: Please enter your password.' ), array( 'form-field' => 'pass1' ) ); + elseif ( empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: Please enter your password twice.' ), array( 'form-field' => 'pass2' ) ); } /* Check for "\" in password */ if( strpos( " ".$pass1, "\\" ) ) - $errors->add( 'pass', __( 'ERROR: Passwords may not contain the character "\\".' )); + $errors->add( 'pass', __( 'ERROR: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); /* checking the password has been typed twice the same */ if ( $pass1 != $pass2 ) - $errors->add( 'pass', __( 'ERROR: Please type the same password in the two password fields.' )); + $errors->add( 'pass', __( 'ERROR: Please enter the same password in the two password fields.' ), array( 'form-field' => 'pass1' ) ); if (!empty ( $pass1 )) $user->user_pass = $pass1; if ( !$update && !validate_username( $user->user_login ) ) - $errors->add( 'user_login', __( 'ERROR: This username is invalid. Please enter a valid username.' )); + $errors->add( 'user_login', __( 'ERROR: This username is invalid. Please enter a valid username.' )); if (!$update && username_exists( $user->user_login )) - $errors->add( 'user_login', __( 'ERROR: This username is already registered, please choose another one.' )); + $errors->add( 'user_login', __( 'ERROR: This username is already registered. Please choose another one.' )); /* checking e-mail address */ if ( empty ( $user->user_email ) ) { - $errors->add( 'user_email', __( "ERROR: please type an e-mail address" )); + $errors->add( 'user_email', __( 'ERROR: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); } else if (!is_email( $user->user_email ) ) { - $errors->add( 'user_email', __( "ERROR: the email address isn't correct" )); + $errors->add( 'user_email', __( "ERROR: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); } if ( $errors->get_error_codes() ) @@ -183,8 +194,6 @@ function get_nonauthor_user_ids() { function get_others_unpublished_posts($user_id, $type='any') { global $wpdb; - $user = get_userdata( $user_id ); - $level_key = $wpdb->prefix . 'user_level'; $editable = get_editable_user_ids( $user_id ); @@ -242,7 +251,6 @@ function wp_delete_user($id, $reassign = 'novalue') { global $wpdb; $id = (int) $id; - $user = get_userdata($id); if ($reassign == 'novalue') { $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); @@ -268,6 +276,7 @@ function wp_delete_user($id, $reassign = 'novalue') { wp_cache_delete($id, 'users'); wp_cache_delete($user->user_login, 'userlogins'); + wp_cache_delete($user->user_email, 'useremail'); return true; } @@ -279,4 +288,108 @@ function wp_revoke_user($id) { $user->remove_all_caps(); } +// WP_User_Search class +// by Mark Jaquith + +if ( !class_exists('WP_User_Search') ) : +class WP_User_Search { + var $results; + var $search_term; + var $page; + var $role; + var $raw_page; + var $users_per_page = 50; + var $first_user; + var $last_user; + var $query_limit; + var $query_sort; + var $query_from_where; + var $total_users_for_query = 0; + var $too_many_total_users = false; + var $search_errors; + + function WP_User_Search ($search_term = '', $page = '', $role = '') { // constructor + $this->search_term = $search_term; + $this->raw_page = ( '' == $page ) ? false : (int) $page; + $this->page = (int) ( '' == $page ) ? 1 : $page; + $this->role = $role; + + $this->prepare_query(); + $this->query(); + $this->prepare_vars_for_template_usage(); + $this->do_paging(); + } + + function prepare_query() { + global $wpdb; + $this->first_user = ($this->page - 1) * $this->users_per_page; + $this->query_limit = ' LIMIT ' . $this->first_user . ',' . $this->users_per_page; + $this->query_sort = ' ORDER BY user_login'; + $search_sql = ''; + if ( $this->search_term ) { + $searches = array(); + $search_sql = 'AND ('; + foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) + $searches[] = $col . " LIKE '%$this->search_term%'"; + $search_sql .= implode(' OR ', $searches); + $search_sql .= ')'; + } + + $this->query_from_where = "FROM $wpdb->users"; + if ( $this->role ) + $this->query_from_where .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE '%$this->role%'"; + else + $this->query_from_where .= " WHERE 1=1"; + $this->query_from_where .= " $search_sql"; + + } + + function query() { + global $wpdb; + $this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_sort . $this->query_limit); + + if ( $this->results ) + $this->total_users_for_query = $wpdb->get_var('SELECT COUNT(ID) ' . $this->query_from_where); // no limit + else + $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); + } + + function prepare_vars_for_template_usage() { + $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone + } + + function do_paging() { + if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results + $this->paging_text = paginate_links( array( + 'total' => ceil($this->total_users_for_query / $this->users_per_page), + 'current' => $this->page, + 'base' => 'users.php?%_%', + 'format' => 'userspage=%#%', + 'add_args' => array( 'usersearch' => urlencode($this->search_term) ) + ) ); + } + } + + function get_results() { + return (array) $this->results; + } + + function page_links() { + echo $this->paging_text; + } + + function results_are_paged() { + if ( $this->paging_text ) + return true; + return false; + } + + function is_search() { + if ( $this->search_term ) + return true; + return false; + } +} +endif; + ?> \ No newline at end of file diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php new file mode 100644 index 00000000..da8b8227 --- /dev/null +++ b/wp-admin/includes/widgets.php @@ -0,0 +1,290 @@ + + +
      + $widget ) : + if ( 'all' == $show && in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget + continue; + + if ( $search_terms ) { + $hit = false; + // Simple case-insensitive search. Boolean OR. + $search_text = preg_replace( '/[^\w]/', '', $widget['name'] ); + if ( isset($widget['description']) ) + $search_text .= preg_replace( '/[^\w]/', '', $widget['description'] ); + + foreach ( $search_terms as $search_term ) { + if ( stristr( $search_text, $search_term ) ) { + $hit = true; + break; + } + } + if ( !$hit ) + continue; + } + + $sidebar = is_active_widget( $widget['callback'], $widget['id'] ); + + if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) ) + continue; + + ob_start(); + $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) ); + $sidebar_args = call_user_func_array( 'wp_widget_control', $args ); + $widget_control_template = ob_get_contents(); + ob_end_clean(); + + $widget_id = $widget['id']; // save this for later in case we mess with $widget['id'] + + $is_multi = false !== strpos( $widget_control_template, '%i%' ); + if ( !$sidebar || $is_multi ) { + $add_query = array( + 'sidebar' => $sidebar, + 'key' => false, + 'edit' => false + ); + if ( 'all' == $show && $is_multi ) { + // it's a multi-widget. We only need to show it in the list once. + $already_shown[] = $widget['callback']; + $num = (int) array_pop( explode( '-', $widget['id'] ) ); + $id_base = $wp_registered_widget_controls[$widget['id']]['id_base']; + // so that we always add a new one when clicking "add" + while ( isset($wp_registered_widgets["$id_base-$num"]) ) + $num++; + $widget['id'] = "$id_base-$num"; + $add_query['base'] = $id_base; + $add_query['key'] = $num; + $add_query['sidebar'] = $GLOBALS['sidebar']; + } + $add_query['add'] = $widget['id']; + $action = 'add'; + $add_url = wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" ); + } else { + $action = 'edit'; + $edit_url = clean_url( add_query_arg( array( + 'sidebar' => $sidebar, + 'edit' => $widget['id'], + 'key' => array_search( $widget['id'], $sidebars_widgets[$sidebar] ), + ) ) ); + + $widget_control_template = ''; + } + + $widget_control_template = $sidebar_args['before_widget'] . $widget_control_template . $sidebar_args['after_widget']; + + $no_widgets_shown = false; + + + if ( 'all' != $show && $sidebar_args['_widget_title'] ) + $widget_title = $sidebar_args['_widget_title']; + else + $widget_title = $widget['name']; + ?> + +
    • +

      + + + + + + + + + + + + + +

      + + +
        + + + +
      + + + + +
      + +
      + +
      + +
    • + + + +
    • + + + +
    + + +
      + + "; ?> + +
    + +\n"; + $params[0]['after_widget'] = ""; + $params[0]['before_title'] = "%BEG_OF_TITLE%"; + $params[0]['after_title'] = "%END_OF_TITLE%"; + if ( is_callable( $wp_registered_widgets[$widget_id]['callback'] ) ) { + $wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback']; + $wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control'; + } + return $params; +} + +/* + * Meta widget used to display the control form for a widget. Called from dynamic_sidebar() + */ +function wp_widget_control( $sidebar_args ) { + global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets, $edit_widget; + $widget_id = $sidebar_args['widget_id']; + $sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false; + + $control = $wp_registered_widget_controls[$widget_id]; + $widget = $wp_registered_widgets[$widget_id]; + + $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : 'no-key'; // position of widget in sidebar + + $edit = -1 < $edit_widget && is_numeric($key) && $edit_widget === $key; // (bool) are we currently editing this widget + + $id_format = $widget['id']; + // We aren't showing a widget control, we're outputing a template for a mult-widget control + if ( 'all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) { + // number == -1 implies a template where id numbers are replaced by a generic '%i%' + $control['params'][0]['number'] = -1; + // if given, id_base means widget id's should be constructed like {$id_base}-{$id_number} + if ( isset($control['id_base']) ) + $id_format = $control['id_base'] . '-%i%'; + } + + $widget_title = ''; + // We grab the normal widget output to find the widget's title + if ( ( 'all' != $sidebar_args['_show'] || 'template' != $sidebar_args['_display'] ) && is_callable( $widget['_callback'] ) ) { + ob_start(); + $args = func_get_args(); + call_user_func_array( $widget['_callback'], $args ); + $widget_title = ob_get_clean(); + $widget_title = wp_widget_control_ob_filter( $widget_title ); + } + $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; + unset($wp_registered_widgets[$widget_id]['_callback']); + + if ( $widget_title && $widget_title != $sidebar_args['widget_name'] ) + $widget_title = sprintf( _c('%1$s: %2$s|1: widget name, 2: widget title' ), $sidebar_args['widget_name'], $widget_title ); + else + $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) ); + + $sidebar_args['_widget_title'] = $widget_title; + + if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] ) + echo $sidebar_args['before_widget']; +?> +

    + + + + + + + + + + + +

    + +
    > + + ' . __('There are no options for this widget.') . '

    '; + ?> + + + + +
    + + + + + + + + "> +
    +
    +
    + diff --git a/wp-admin/index-extra.php b/wp-admin/index-extra.php index 31f2a581..3b77d104 100644 --- a/wp-admin/index-extra.php +++ b/wp-admin/index-extra.php @@ -1,5 +1,6 @@ items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results -?> -

    -
      -items = array_slice($rss->items, 0, 10); -foreach ($rss->items as $item ) { -?> -
    • - -
    -items) && 0 != count($rss->items) ) { -?> -

    -items = array_slice($rss->items, 0, 3); -foreach ($rss->items as $item ) { -?> -

    '>

    -

    - - -items) && 0 != count($rss->items) ) { -?> -

    -
      -items = array_slice($rss->items, 0, 20); -foreach ($rss->items as $item ) { -$title = wp_specialchars($item['title']); -$author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] ); -$post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] ); -?> -
    • '>
    • - -
    -

    - \ No newline at end of file +?> diff --git a/wp-admin/index.php b/wp-admin/index.php index 2447e2fe..15bc950c 100644 --- a/wp-admin/index.php +++ b/wp-admin/index.php @@ -1,19 +1,36 @@ -

    +

    -
    -

    +
    +

    + - + + + + + +
    +

    get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5"); -$numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); +$num_posts = wp_count_posts( 'post' ); +$num_pages = wp_count_posts( 'page' ); -if ( $comments || $numcomments ) : -?> -
    -

    »' ), 'edit-comments.php' ); ?>

    +$num_cats = wp_count_terms('category'); - -

    - +$num_tags = wp_count_terms('post_tag'); - -
    - -get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) : -?> -
    -

    »' ), 'edit.php' ); ?>

    -
      -post_title == '') - $post->post_title = sprintf(__('Post #%s'), $post->ID); - echo "
    • "; - the_title(); - echo '
    • '; +if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) { + $pending_text = sprintf( __ngettext( 'There is %2$s post pending your review.', 'There are %2$s posts pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) ); +} else { + $pending_text = ''; } -?> -
    -
    - -get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'future' ORDER BY post_date ASC") ) : -?> -
    -

    -
      -post_title == '') - $post->post_title = sprintf(__('Post #%s'), $post->ID); - echo "
    • " . sprintf(__('%1$s in %2$s'), "$post->post_title", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') )) . "
    • "; +$cats_text = sprintf( __ngettext( '%s category', '%s categories', $num_cats ), number_format_i18n( $num_cats ) ); +$tags_text = sprintf( __ngettext( '%s tag', '%s tags', $num_tags ), number_format_i18n( $num_tags ) ); +if ( current_user_can( 'manage_categories' ) ) { + $cats_text = "$cats_text"; + $tags_text = "$tags_text"; } -?> -
    -
    - -
    -

    +$post_type_text = implode(', ', $post_type_texts); + +// There is always a category +$sentence = sprintf( __( 'You have %1$s, contained within %2$s and %3$s. %4$s' ), $post_type_text, $cats_text, $tags_text, $pending_text ); +$sentence = apply_filters( 'dashboard_count_sentence', $sentence, $post_type_text, $cats_text, $tags_text, $pending_text ); + +?> +

    get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"); -$numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); -$numcats = wp_count_terms('category'); -$numtags = wp_count_terms('post_tag'); - -$post_str = sprintf(__ngettext('%1$s post', '%1$s posts', $numposts), number_format_i18n($numposts), 'edit.php'); -$comm_str = sprintf(__ngettext('%1$s comment', '%1$s comments', $numcomms), number_format_i18n($numcomms), 'edit-comments.php'); -$cat_str = sprintf(__ngettext('%1$s category', '%1$s categories', $numcats), number_format_i18n($numcats), 'categories.php'); -$tag_str = sprintf(__ngettext('%1$s tag', '%1$s tags', $numtags), number_format_i18n($numtags)); +$ct = current_theme_info(); +$sidebars_widgets = wp_get_sidebars_widgets(); +$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ) ); +$widgets_text = sprintf( __ngettext( '%d widget', '%d widgets', $num_widgets ), $num_widgets ); +if ( $can_switch_themes = current_user_can( 'switch_themes' ) ) + $widgets_text = "$widgets_text"; ?> +

    + title, $widgets_text ); ?> + + + + +

    -

    -
    + + +
    - -
    +
    -

    +
    -
      - -
    • - -
    • - -
    • - - -
    • - -
    -

    documentation or visit the support forums."); ?>

    + -
    -
    +
    -
      -
    -
    -

    + - + diff --git a/wp-admin/install-helper.php b/wp-admin/install-helper.php index b53376eb..d124b1a3 100644 --- a/wp-admin/install-helper.php +++ b/wp-admin/install-helper.php @@ -16,7 +16,7 @@ function maybe_create_table($table_name, $create_ddl) { } } //didn't find it try to create it. - $q = $wpdb->query($create_ddl); + $wpdb->query($create_ddl); // we cannot directly tell that whether this succeeded! foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { if ($table == $table_name) { @@ -41,7 +41,7 @@ function maybe_add_column($table_name, $column_name, $create_ddl) { } } //didn't find it try to create it. - $q = $wpdb->query($create_ddl); + $wpdb->query($create_ddl); // we cannot directly tell that whether this succeeded! foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { if ($column == $column_name) { @@ -63,7 +63,7 @@ function maybe_drop_column($table_name, $column_name, $drop_ddl) { foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { if ($column == $column_name) { //found it try to drop it. - $q = $wpdb->query($drop_ddl); + $wpdb->query($drop_ddl); // we cannot directly tell that whether this succeeded! foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { if ($column == $column_name) { diff --git a/wp-admin/install.php b/wp-admin/install.php index 6f4d7e3e..84011430 100644 --- a/wp-admin/install.php +++ b/wp-admin/install.php @@ -3,7 +3,7 @@ define('WP_INSTALLING', true); if (!file_exists('../wp-config.php')) { require_once('../wp-includes/compat.php'); require_once('../wp-includes/functions.php'); - wp_die("There doesn't seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.", "WordPress › Error"); + wp_die("There doesn't seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.

    Create a Configuration File", "WordPress › Error"); } require_once('../wp-config.php'); @@ -39,28 +39,27 @@ switch($step) { ?>

    ReadMe documentation at your leisure. Otherwise, just fill in the information below and you\'ll be on your way to using the most extendable and powerful personal publishing platform in the world.'), '../readme.html'); ?>

    - +

    - +
    - + - - + + - - +

    +
     
    -

    -

    +
    error) ) wp_die($wpdb->error->get_error_message()); - display_header(); + display_header(); // Fill in the data we gathered $weblog_title = stripslashes($_POST['weblog_title']); $admin_email = stripslashes($_POST['admin_email']); @@ -77,10 +76,10 @@ switch($step) { // check e-mail address if (empty($admin_email)) { // TODO: poka-yoke - die(__("ERROR: you must provide an e-mail address")); + die('

    '.__("ERROR: you must provide an e-mail address.").'

    '); } else if (!is_email($admin_email)) { // TODO: poka-yoke - die(__('ERROR: that isn\'t a valid e-mail address. E-mail addresses look like: username@example.com')); + die('

    '.__('ERROR: that isn’t a valid e-mail address. E-mail addresses look like: username@example.com').'

    '); } $wpdb->show_errors(); @@ -90,24 +89,26 @@ switch($step) {

    -

    log in with the username "admin" and password "%2$s".'), '../wp-login.php', $password); ?>

    -

    Note that password carefully! It is a random password that was generated just for you.'); ?>

    +

    -
    -
    -
    admin
    -
    -
    -
    -
    wp-login.php
    -
    -

    + + + + + + + + + +
    admin

    + '.__('Note that password carefully! It is a random password that was generated just for you.').'

    '; ?>
    + +

    - -

    + - \ No newline at end of file + diff --git a/wp-admin/js/cat.js b/wp-admin/js/cat.js index e697e9b4..4a64994a 100644 --- a/wp-admin/js/cat.js +++ b/wp-admin/js/cat.js @@ -1,11 +1,5 @@ -addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;}); -addLoadEvent(newCatAddIn); -function newCatAddIn() { - var jaxcat = $('jaxcat'); - if ( !jaxcat ) - return false; - // These multiple blank hidden inputs are needed: https://bugzilla.mozilla.org/show_bug.cgi?id=377815 , #3895 , #4664 - Element.update(jaxcat,'' + catL10n.how + ''); - $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); }; - $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); }; -} +jQuery( function($) { + var myConfirm = function() { return '' !== $('#newcat').val(); }; + $('#jaxcat').prepend('' + catL10n.how + '') + $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); +} ); diff --git a/wp-admin/js/categories.js b/wp-admin/js/categories.js index 3cee6c68..a3273380 100644 --- a/wp-admin/js/categories.js +++ b/wp-admin/js/categories.js @@ -1,16 +1,23 @@ -addLoadEvent(function() { - if (!theList.theList) return false; - document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; - theList.addComplete = function(what, where, update, transport) { - var name = getNodeValue(transport.responseXML, 'name').unescapeHTML(); - var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id'); - var options = document.forms['addcat'].category_parent.options; +jQuery(function($) { + var options = false + if ( document.forms['addcat'].category_parent ) + options = document.forms['addcat'].category_parent.options; + + var addAfter = function( r, settings ) { + var name = $("" + $('name', r).text() + "").html(); + var id = $('cat', r).attr('id'); options[options.length] = new Option(name, id); - }; - theList.delComplete = function(what, id) { - var options = document.forms['addcat'].category_parent.options; + } + + var delAfter = function( r, settings ) { + var id = $('cat', r).attr('id'); for ( var o = 0; o < options.length; o++ ) if ( id == options[o].value ) options[o] = null; - }; + } + + if ( options ) + $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); + else + $('#the-list').wpList(); }); diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js new file mode 100644 index 00000000..11a36276 --- /dev/null +++ b/wp-admin/js/comment.js @@ -0,0 +1,26 @@ +jQuery(document).ready( function() { + add_postbox_toggles('comment'); + + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + + jQuery('.edit-timestamp').click(function () { + if (jQuery('#timestampdiv').is(":hidden")) { + jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(commentL10n.cancel); + } else { + jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(commentL10n.edit); + } + return false; + }); +}); \ No newline at end of file diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js new file mode 100644 index 00000000..6559d7d2 --- /dev/null +++ b/wp-admin/js/common.js @@ -0,0 +1,45 @@ +jQuery(document).ready( function() { + // pulse + jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); + + // Reveal + jQuery('.wp-no-js-hidden').removeClass( 'wp-no-js-hidden' ); + + // Basic form validation + if ( ( 'undefined' != typeof wpAjax ) && jQuery.isFunction( wpAjax.validateForm ) ) { + jQuery('form.validate').submit( function() { return wpAjax.validateForm( jQuery(this) ); } ); + } +}); + +(function(JQ) { + JQ.fn.tTips = function() { + + JQ('body').append('

    '); + var TT = JQ('#tTips'); + + this.each(function() { + var el = JQ(this), txt; + + if ( txt = el.attr('title') ) el.attr('tip', txt).removeAttr('title'); + else return; + el.find('img').removeAttr('alt'); + + el.mouseover(function(e) { + txt = el.attr('tip'), o = el.offset();; + + clearTimeout(TT.sD); + TT.find('p').html(txt); + + TT.css({'top': o.top - 43, 'left': o.left - 5}); + TT.sD = setTimeout(function(){TT.fadeIn(150);}, 100); + }); + + el.mouseout(function() { + clearTimeout(TT.sD); + TT.css({display : 'none'}); + }) + }); + } +}(jQuery)); + +jQuery(function(){jQuery('#media-buttons a').tTips();}); diff --git a/wp-admin/js/custom-fields.js b/wp-admin/js/custom-fields.js index ad7a2db1..8f2b1a59 100644 --- a/wp-admin/js/custom-fields.js +++ b/wp-admin/js/custom-fields.js @@ -1,26 +1,33 @@ -function customFieldsOnComplete( what, where, update, transport ) { - var pidEl = $('post_ID'); - pidEl.name = 'post_ID'; - pidEl.value = getNodeValue(transport.responseXML, 'postid'); - var aEl = $('hiddenaction') - if ( aEl.value == 'post' ) aEl.value = 'postajaxpost'; -} -addLoadEvent(customFieldsAddIn); -function customFieldsAddIn() { - theList.showLink=0; - theList.addComplete = customFieldsOnComplete; - if (!theList.theList) return false; - inputs = theList.theList.getElementsByTagName('input'); - for ( var i=0; i < inputs.length; i++ ) { - if ('text' == inputs[i].type) { - inputs[i].setAttribute('autocomplete', 'off'); - inputs[i].onkeypress = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.name.slice(5),10) + '");', e); }; - } - if ('updatemeta' == inputs[i].className) { - inputs[i].onclick = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.parentNode.parentNode.id.slice(5),10) + '");', e); }; - } +jQuery( function($) { + var before = function() { + var nonce = $('#newmeta [@name=_ajax_nonce]').val(); + var postId = $('#post_ID').val(); + if ( !nonce || !postId ) { return false; } + return [nonce,postId]; } - $('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+$("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); }; - $('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+$("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); }; -} + var addBefore = function( s ) { + var b = before(); + if ( !b ) { return false; } + s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1]; + return s; + }; + + var addAfter = function( r, s ) { + var postId = $('postid', r).text(); + if ( !postId ) { return; } + $('#post_ID').attr( 'name', 'post_ID' ).val( postId ); + var h = $('#hiddenaction'); + if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); } + }; + + var delBefore = function( s ) { + var b = before(); if ( !b ) return false; + s.data._ajax_nonce = b[0]; s.data.post_id = b[1]; + return s; + } + + $('#the-list') + .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } ) + .find('.updatemeta, .deletemeta').attr( 'type', 'button' ); +} ); diff --git a/wp-admin/js/dbx-admin-key.js b/wp-admin/js/dbx-admin-key.js deleted file mode 100644 index 3b3f7af1..00000000 --- a/wp-admin/js/dbx-admin-key.js +++ /dev/null @@ -1,47 +0,0 @@ -addLoadEvent( function() {var manager = new dbxManager( dbxL10n.manager );} ); - -addLoadEvent( function() -{ - //create new docking boxes group - var meta = new dbxGroup( - 'grabit', // container ID [/-_a-zA-Z0-9/] - 'vertical', // orientation ['vertical'|'horizontal'] - '10', // drag threshold ['n' pixels] - 'no', // restrict drag movement to container axis ['yes'|'no'] - '10', // animate re-ordering [frames per transition, or '0' for no effect] - 'yes', // include open/close toggle buttons ['yes'|'no'] - 'closed', // default state ['open'|'closed'] - dbxL10n.open, // word for "open", as in "open this box" - dbxL10n.close, // word for "close", as in "close this box" - dbxL10n.moveMouse, // sentence for "move this box" by mouse - dbxL10n.toggleMouse, // pattern-match sentence for "(open|close) this box" by mouse - dbxL10n.moveKey, // sentence for "move this box" by keyboard - dbxL10n.toggleKey, // pattern-match sentence-fragment for "(open|close) this box" by keyboard - '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts - ); - - // Boxes are closed by default. Open the Category box if the cookie isn't already set. - var catdiv = document.getElementById('categorydiv'); - if ( catdiv ) { - var button = catdiv.getElementsByTagName('A')[0]; - if ( dbx.cookiestate == null && /dbx\-toggle\-closed/.test(button.className) ) - meta.toggleBoxState(button, true); - } - - var advanced = new dbxGroup( - 'advancedstuff', - 'vertical', - '10', - 'yes', // restrict drag movement to container axis ['yes'|'no'] - '10', - 'yes', - 'closed', - dbxL10n.open, - dbxL10n.close, - dbxL10n.moveMouse, - dbxL10n.toggleMouse, - dbxL10n.moveKey, - dbxL10n.toggleKey, - '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts - ); -}); diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index e1fc68fe..f2bf8f82 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -1,59 +1,70 @@ -addLoadEvent(function() { - theCommentList = new listMan('the-comment-list'); - if ( !theCommentList ) - return false; +var theList; var theExtraList; +jQuery(function($) { - theExtraCommentList = new listMan('the-extra-comment-list'); - if ( theExtraCommentList ) { - theExtraCommentList.showLink = 0; - theExtraCommentList.altOffset = 1; - if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes ) - var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; - else - var commentNum = 0; - var urlQ = document.location.href.split('?'); - var params = urlQ[1] ? urlQ[1].toQueryParams() : []; - var search = params['s'] ? params['s'] : ''; - var page = params['apage'] ? params['apage'] : 1; - } - - theCommentList.dimComplete = function(what,id,dimClass) { - var m = document.getElementById('awaitmod'); - if ( document.getElementById(what + '-' + id).className.match(dimClass) ) - m.innerHTML = parseInt(m.innerHTML,10) + 1; - else - m.innerHTML = parseInt(m.innerHTML,10) - 1; - } +var dimAfter = function( r, settings ) { + $('li span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); + if ( n < 0 ) { n = 0; } + a.html( n.toString() ); + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); + }); + $('.post-com-count span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + var t = parseInt(a.parent().attr('title'), 10); + if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment + n = n - 1; + t = t + 1; + } else { // we approved a formerly unapproved comment + n = n + 1; + t = t - 1; + } + if ( n < 0 ) { n = 0; } + if ( t < 0 ) { t = 0; } + if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); } + if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); } + a.html( n.toString() ); + }); +} - theCommentList.delComplete = function(what,id) { - var m = document.getElementById('awaitmod'); - what = what.split('-')[0]; - if ( document.getElementById(what + '-' + id).className.match('unapproved') ) - m.innerHTML = parseInt(m.innerHTML,10) - 1; - if ( theExtraCommentList && commentNum ) { - var theMover = theExtraCommentList.theList.childNodes[0]; - Element.removeClassName(theMover,'alternate'); - theCommentList.theList.appendChild(theMover); - theExtraCommentList.inputData += '&page=' + page; - if ( search ) - theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box - theExtraCommentList.addComplete = function() { - if ( theExtraCommentList.theList.childNodes ) - var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; - else - var commentNum = 0; - } - theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request +var delAfter = function( r, settings ) { + $('li span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment + n = n - 1; + } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" + n = n + 1; } + if ( n < 0 ) { n = 0; } + a.html( n.toString() ); + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); + }); + $('.post-com-count span.comment-count').each( function() { + var a = $(this); + if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment + var t = parseInt(a.parent().attr('title'), 10); + if ( t < 1 ) { return; } + t = t - 1; + a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); + if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); } + return; + } + var n = parseInt(a.html(),10) - 1; + a.html( n.toString() ); + }); + + if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { + return; } - if ( theList ) // the post list: edit.php - theList.delComplete = function() { - var comments = document.getElementById('comments'); - var commdel = encloseFunc(function(a){a.parentNode.removeChild(a);},comments); - var listdel = encloseFunc(function(a){a.parentNode.removeChild(a);},theCommentList.theList); - setTimeout(commdel,705); - setTimeout(listdel,705); - } -}); + theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() ); + $('#get-extra-comments').submit(); +} + +theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); +theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ); +} ); diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js new file mode 100644 index 00000000..50955c70 --- /dev/null +++ b/wp-admin/js/editor.js @@ -0,0 +1,177 @@ +wpEditorInit = function() { + // Activate tinyMCE if it's the user's default editor + if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor ) { + document.getElementById('editorcontainer').style.padding = '0px'; + tinyMCE.execCommand("mceAddControl", false, "content"); + } else { + var H; + if ( H = tinymce.util.Cookie.getHash("TinyMCE_content_size") ) + document.getElementById('content').style.height = H.ch - 30 + 'px'; + } +}; + +switchEditors = { + + saveCallback : function(el, content, body) { + + document.getElementById(el).style.color = '#fff'; + if ( tinyMCE.activeEditor.isHidden() ) + content = document.getElementById(el).value; + else + content = this.pre_wpautop(content); + + return content; + }, + + pre_wpautop : function(content) { + // We have a TON of cleanup to do. Line breaks are already stripped. + + // Protect pre|script tags + content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { + a = a.replace(/
    [\r\n]*/g, ''); + return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, ''); + }); + + // Pretty it up for the source editor + var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p'; + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); + content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); + + // Mark

    if it has any attributes. + content = content.replace(new RegExp('(

    ]+>.*?)

    ', 'mg'), '$1'); + + // Sepatate
    containing

    + content = content.replace(new RegExp(']*)>\\s*

    ', 'mgi'), '\n\n'); + + // Remove

    and
    + content = content.replace(new RegExp('\\s*

    ', 'mgi'), ''); + content = content.replace(new RegExp('\\s*

    \\s*', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\s*
    \\s*', 'gi'), '\n'); + + // Fix some block element newline issues + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '
    \n'); + + var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; + content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); + content = content.replace(new RegExp(']*)>', 'g'), '\t'); + + if ( content.indexOf(']*)>\\s*', 'mg'), ""); + content = content.replace(new RegExp('\\s*\\s*', 'mg'), ''); + } + + // Unmark special paragraph closing tags + content = content.replace(new RegExp('', 'g'), '

    \n'); + content = content.replace(new RegExp('\\s*(

    ]+>.*

    )', 'mg'), '\n$1'); + + // Trim whitespace + content = content.replace(new RegExp('^\\s*', ''), ''); + content = content.replace(new RegExp('\\s*$', ''), ''); + + // put back the line breaks in pre|script + content = content.replace(//g, '\n'); + + // Hope. + return content; + }, + + go : function(id) { + var ed = tinyMCE.get(id); + var qt = document.getElementById('quicktags'); + var H = document.getElementById('edButtonHTML'); + var P = document.getElementById('edButtonPreview'); + var ta = document.getElementById(id); + var ec = document.getElementById('editorcontainer'); + + if ( ! ed || ed.isHidden() ) { + ta.style.color = '#fff'; + + this.edToggle(P, H); + edCloseAllTags(); // :-( + + qt.style.display = 'none'; + ec.style.padding = '0px'; + ta.style.padding = '0px'; + + ta.value = this.wpautop(ta.value); + + if ( ed ) ed.show(); + else tinyMCE.execCommand("mceAddControl", false, id); + + this.wpSetDefaultEditor('tinymce'); + } else { + this.edToggle(H, P); + ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px'; + + ed.hide(); + qt.style.display = 'block'; + + if ( tinymce.isIE6 ) { + ta.style.width = '98%'; + ec.style.padding = '0px'; + ta.style.padding = '6px'; + } else { + ta.style.width = '100%'; + ec.style.padding = '6px'; + } + + ta.style.color = ''; + this.wpSetDefaultEditor('html'); + } + }, + + edToggle : function(A, B) { + A.className = 'active'; + B.className = ''; + + B.onclick = A.onclick; + A.onclick = null; + }, + + wpSetDefaultEditor : function(editor) { + try { + editor = escape( editor.toString() ); + } catch(err) { + editor = 'tinymce'; + } + + var userID = document.getElementById('user-id'); + var date = new Date(); + date.setTime(date.getTime()+(10*365*24*60*60*1000)); + document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString(); + }, + + wpautop : function(pee) { + var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]'; + + pee = pee + "\n\n"; + pee = pee.replace(new RegExp('
    \\s*
    ', 'gi'), "\n\n"); + pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1"); + pee = pee.replace(new RegExp('()', 'gi'), "$1\n\n"); + pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n"); + pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n"); + pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "

    $1

    \n"); + pee = pee.replace(new RegExp('

    \\s*?

    ', 'gi'), ''); + pee = pee.replace(new RegExp('

    \\s*(]*>)\\s*

    ', 'gi'), "$1"); + pee = pee.replace(new RegExp("

    (", 'gi'), "$1"); + pee = pee.replace(new RegExp('

    \\s*]*)>', 'gi'), "

    "); + pee = pee.replace(new RegExp('\\s*

    ', 'gi'), '

    '); + pee = pee.replace(new RegExp('

    \\s*(]*>)', 'gi'), "$1"); + pee = pee.replace(new RegExp('(]*>)\\s*

    ', 'gi'), "$1"); + pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "
    \n"); + pee = pee.replace(new RegExp('(]*>)\\s*
    ', 'gi'), "$1"); + pee = pee.replace(new RegExp('
    (\\s*)', 'gi'), '$1'); + // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); + + // Fix the pre|script tags + pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { + a = a.replace(/
    [\r\n]*/g, '\n'); + return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n'); + }); + + return pee; + } +} diff --git a/wp-admin/js/forms.js b/wp-admin/js/forms.js new file mode 100644 index 00000000..b1d8ce27 --- /dev/null +++ b/wp-admin/js/forms.js @@ -0,0 +1,31 @@ +function checkAll(form) { + for (i = 0, n = form.elements.length; i < n; i++) { + if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) { + if(form.elements[i].checked == true) + form.elements[i].checked = false; + else + form.elements[i].checked = true; + } + } +} + +function getNumChecked(form) { + var num = 0; + for (i = 0, n = form.elements.length; i < n; i++) { + if (form.elements[i].type == "checkbox") { + if (form.elements[i].checked == true) + num++; + } + } + return num; +} + +function checkAllUsers(role) { + var checkboxs = document.getElementsByTagName('input'); + for(var i = 0, inp; inp = checkboxs[i]; i++) + if(inp.type.toLowerCase() == 'checkbox' && inp.className == role) + if(inp.checked == false) + inp.checked = true; + else + inp.checked = false; +} \ No newline at end of file diff --git a/wp-admin/js/link-cat.js b/wp-admin/js/link-cat.js deleted file mode 100644 index a0775ce1..00000000 --- a/wp-admin/js/link-cat.js +++ /dev/null @@ -1,10 +0,0 @@ -addLoadEvent(function(){linkcatList=new listMan('linkcategorychecklist');linkcatList.ajaxRespEl='jaxcat';linkcatList.topAdder=1;linkcatList.alt=0;linkcatList.showLink=0;}); -addLoadEvent(newLinkCatAddIn); -function newLinkCatAddIn() { - var jaxcat = $('jaxcat'); - if ( !jaxcat ) - return false; - Element.update(jaxcat,'' + linkcatL10n.how + ''); - $('newcat').onkeypress = function(e) { return killSubmit("linkcatList.ajaxAdder('link-category','jaxcat');", e); }; - $('catadd').onclick = function() { linkcatList.ajaxAdder('link-category', 'jaxcat'); }; -} diff --git a/wp-admin/js/link.js b/wp-admin/js/link.js new file mode 100644 index 00000000..cfc0f949 --- /dev/null +++ b/wp-admin/js/link.js @@ -0,0 +1,48 @@ +jQuery(document).ready( function() { + jQuery('#link_name').focus(); + // postboxes + add_postbox_toggles('link'); + + // category tabs + var categoryTabs = jQuery('#category-tabs').tabs(); + + // Ajax Cat + var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } ); + jQuery('#category-add-sumbit').click( function() { newCat.focus(); } ); + var noSyncChecks = false; // prophylactic. necessary? + var syncChecks = function() { + if ( noSyncChecks ) + return; + noSyncChecks = true; + var th = jQuery(this); + var c = th.is(':checked'); + var id = th.val().toString(); + jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); + noSyncChecks = false; + }; + var catAddAfter = function( r, s ) { + jQuery(s.what + ' response_data', r).each( function() { + var t = jQuery(jQuery(this).text()); + t.find( 'label' ).each( function() { + var th = jQuery(this); + var val = th.find('input').val(); + var id = th.find('input')[0].id + jQuery('#' + id).change( syncChecks ); + var name = jQuery.trim( th.text() ); + var o = jQuery( '' ).text( name ); + } ); + } ); + }; + jQuery('#categorychecklist').wpList( { + alt: '', + what: 'link-category', + response: 'category-ajax-response', + addAfter: catAddAfter + } ); + jQuery('#category-add-toggle').click( function() { + jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' ); + categoryTabs.tabsClick( 1 ); + return false; + } ); + jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); +}); diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js new file mode 100644 index 00000000..b8c615d4 --- /dev/null +++ b/wp-admin/js/media-upload.js @@ -0,0 +1,12 @@ +// send html to the post editor +function send_to_editor(h) { + var win = window.opener ? window.opener : window.dialogArguments; + if ( !win ) + win = top; + tinyMCE = win.tinyMCE; + if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.getInstanceById('content') ) && !ed.isHidden() ) { + tinyMCE.selectedInstance.getWin().focus(); + tinyMCE.execCommand('mceInsertContent', false, h); + } else + win.edInsertContent(win.edCanvas, h); +} \ No newline at end of file diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js new file mode 100644 index 00000000..2a91e339 --- /dev/null +++ b/wp-admin/js/page.js @@ -0,0 +1,32 @@ +jQuery(document).ready( function() { + add_postbox_toggles('page'); + make_slugedit_clickable(); + + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + + // hide advanced slug field + jQuery('#pageslugdiv').hide(); + + jQuery('.edit-timestamp').click(function () { + if (jQuery('#timestampdiv').is(":hidden")) { + jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(postL10n.cancel); + } else { + jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(postL10n.edit); + } + return false; + }); +}); \ No newline at end of file diff --git a/wp-admin/js/password-strength-meter.js b/wp-admin/js/password-strength-meter.js new file mode 100644 index 00000000..e90c3e04 --- /dev/null +++ b/wp-admin/js/password-strength-meter.js @@ -0,0 +1,80 @@ +// Password strength meter +// This jQuery plugin is written by firas kassem [2007.04.05] +// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com +// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/ + +var shortPass = pwsL10n.short +var badPass = pwsL10n.bad +var goodPass = pwsL10n.good +var strongPass = pwsL10n.strong + + +function passwordStrength(password,username) { + score = 0 + + //password < 4 + if (password.length < 4 ) { return shortPass } + + //password == username + if (password.toLowerCase()==username.toLowerCase()) return badPass + + //password length + score += password.length * 4 + score += ( checkRepetition(1,password).length - password.length ) * 1 + score += ( checkRepetition(2,password).length - password.length ) * 1 + score += ( checkRepetition(3,password).length - password.length ) * 1 + score += ( checkRepetition(4,password).length - password.length ) * 1 + + //password has 3 numbers + if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5 + + //password has 2 sybols + if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5 + + //password has Upper and Lower chars + if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10 + + //password has number and chars + if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15 + // + //password has number and symbol + if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15 + + //password has char and symbol + if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15 + + //password is just a nubers or chars + if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10 + + //verifing 0 < score < 100 + if ( score < 0 ) score = 0 + if ( score > 100 ) score = 100 + + if (score < 34 ) return badPass + if (score < 68 ) return goodPass + return strongPass +} + + +// checkRepetition(1,'aaaaaaabcbc') = 'abcbc' +// checkRepetition(2,'aaaaaaabcbc') = 'aabc' +// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd' + +function checkRepetition(pLen,str) { + res = "" + for ( i=0; iX ' + val + ' '; + jQuery( '#tagchecklist' ).append( txt ); + jQuery( '#tag-check-' + key ).click( new_tag_remove_tag ); + shown = true; + } + }); + if ( shown ) + jQuery( '#tagchecklist' ).prepend( ''+postL10n.tagsUsed+'
    ' ); +} + +function tag_flush_to_text() { + var newtags = jQuery('#tags-input').val() + ',' + jQuery('#newtag').val(); + // massage + newtags = newtags.replace( /\s+,+\s*/g, ',' ).replace( /,+/g, ',' ).replace( /,+\s+,+/g, ',' ).replace( /,+\s*$/g, '' ).replace( /^\s*,+/g, '' ); + jQuery('#tags-input').val( newtags ); + tag_update_quickclicks(); + jQuery('#newtag').val(''); + jQuery('#newtag').focus(); + return false; +} + +function tag_save_on_publish() { + if ( jQuery('#newtag').val() != postL10n.addTag ) + tag_flush_to_text(); +} + +function tag_press_key( e ) { + if ( 13 == e.keyCode ) { + tag_flush_to_text(); + return false; + } +} + +jQuery(document).ready( function() { + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + + // postboxes + add_postbox_toggles('post'); + + // Editable slugs + make_slugedit_clickable(); + + // hide advanced slug field + jQuery('#slugdiv').hide(); + + jQuery('#tags-input').hide(); + tag_update_quickclicks(); + // add the quickadd form + jQuery('#jaxtag').prepend(''+postL10n.separate+''); + jQuery('#tagadd').click( tag_flush_to_text ); + jQuery('#newtag').focus(function() { + if ( this.value == postL10n.addTag ) + jQuery(this).val( '' ).removeClass( 'form-input-tip' ); + }); + jQuery('#newtag').blur(function() { + if ( this.value == '' ) + jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); + }); + + // auto-save tags on post save/publish + jQuery('#publish').click( tag_save_on_publish ); + jQuery('#save-post').click( tag_save_on_publish ); + + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + + // auto-suggest stuff + jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } ); + jQuery('#newtag').keypress( tag_press_key ); + + // category tabs + var categoryTabs =jQuery('#category-tabs').tabs(); + + // Ajax Cat + var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } ); + jQuery('#category-add-sumbit').click( function() { newCat.focus(); } ); + var newCatParent = false; + var newCatParentOption = false; + var noSyncChecks = false; // prophylactic. necessary? + var syncChecks = function() { + if ( noSyncChecks ) + return; + noSyncChecks = true; + var th = jQuery(this); + var c = th.is(':checked'); + var id = th.val().toString(); + jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); + noSyncChecks = false; + }; + var catAddBefore = function( s ) { + s.data += '&' + jQuery( '#categorychecklist :checked' ).serialize(); + return s; + }; + var catAddAfter = function( r, s ) { + if ( !newCatParent ) newCatParent = jQuery('#newcat_parent'); + if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' ); + jQuery(s.what + ' response_data', r).each( function() { + var t = jQuery(jQuery(this).text()); + t.find( 'label' ).each( function() { + var th = jQuery(this); + var val = th.find('input').val(); + var id = th.find('input')[0].id + jQuery('#' + id).change( syncChecks ).change(); + if ( newCatParent.find( 'option[value=' + val + ']' ).size() ) + return; + var name = jQuery.trim( th.text() ); + var o = jQuery( '' ).text( name ); + newCatParent.prepend( o ); + } ); + newCatParentOption.attr( 'selected', true ); + } ); + }; + jQuery('#categorychecklist').wpList( { + alt: '', + response: 'category-ajax-response', + addBefore: catAddBefore, + addAfter: catAddAfter + } ); + jQuery('#category-add-toggle').click( function() { + jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' ); + categoryTabs.tabsClick( 1 ); + jQuery('#newcat').focus(); + return false; + } ); + jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change(); + + jQuery('.edit-timestamp').click(function () { + if (jQuery('#timestampdiv').is(":hidden")) { + jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(postL10n.cancel); + } else { + jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(postL10n.edit); + } + return false; + + }); + + // Custom Fields + jQuery('#the-list').wpList( { addAfter: function( xml, s ) { + if ( jQuery.isFunction( autosave_update_post_ID ) ) { + autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); + } + } }); +}); diff --git a/wp-admin/js/postbox.js b/wp-admin/js/postbox.js new file mode 100644 index 00000000..a512f4bc --- /dev/null +++ b/wp-admin/js/postbox.js @@ -0,0 +1,14 @@ +function add_postbox_toggles(page) { + jQuery('.postbox h3').prepend('+ '); + jQuery('.postbox h3').click( function() { jQuery(jQuery(this).parent().get(0)).toggleClass('closed'); save_postboxes_state(page); } ); +} + +function save_postboxes_state(page) { + var closed = jQuery('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','); + jQuery.post(postboxL10n.requestFile, { + action: 'closed-postboxes', + closed: closed, + closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(), + page: page + }); +} diff --git a/wp-admin/js/slug.js b/wp-admin/js/slug.js new file mode 100644 index 00000000..f26a5f20 --- /dev/null +++ b/wp-admin/js/slug.js @@ -0,0 +1,48 @@ +function edit_permalink(post_id) { + var i, c = 0; + var e = jQuery('#editable-post-name'); + var revert_e = e.html(); + var real_slug = jQuery('#post_name'); + var revert_slug = real_slug.html(); + var b = jQuery('#edit-slug-buttons'); + var revert_b = b.html(); + var full = jQuery('#editable-post-name-full').html(); + + b.html(''+slugL10n.save+' '+slugL10n.cancel+''); + b.children('.save').click(function() { + var new_slug = e.children('input').val(); + jQuery.post(slugL10n.requestFile, { + action: 'sample-permalink', + post_id: post_id, + new_slug: new_slug, + new_title: jQuery('#title').val(), + samplepermalinknonce: jQuery('#samplepermalinknonce').val()}, function(data) { + jQuery('#edit-slug-box').html(data); + b.html(revert_b); + real_slug.attr('value', new_slug); + make_slugedit_clickable(); + }); + return false; + }); + jQuery('#edit-slug-buttons .cancel').click(function() { + e.html(revert_e); + b.html(revert_b); + real_slug.attr('value', revert_slug); + return false; + }); + for(i=0; i < full.length; ++i) { + if ('%' == full.charAt(i)) c++; + } + slug_value = (c > full.length/4)? '' : full; + e.html('').children('input').keypress(function(e){ + var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; + // on enter, just save the new slug, don't save the post + if (13 == key) {b.children('.save').click();return false;} + if (27 == key) {b.children('.cancel').click();return false;} + real_slug.attr('value', this.value)}).focus(); +} + +function make_slugedit_clickable() { + jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()}); +} + diff --git a/wp-admin/js/tags.js b/wp-admin/js/tags.js new file mode 100644 index 00000000..37182dfc --- /dev/null +++ b/wp-admin/js/tags.js @@ -0,0 +1,21 @@ +jQuery(function($) { + var options = false + + var addAfter = function( r, settings ) { + var name = $("" + $('name', r).text() + "").html(); + var id = $('tag', r).attr('id'); + options[options.length] = new Option(name, id); + } + + var delAfter = function( r, settings ) { + var id = $('tag', r).attr('id'); + for ( var o = 0; o < options.length; o++ ) + if ( id == options[o].value ) + options[o] = null; + } + + if ( options ) + $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); + else + $('#the-list').wpList(); +}); diff --git a/wp-admin/js/upload.js b/wp-admin/js/upload.js index d38cdcb0..f60f1138 100644 --- a/wp-admin/js/upload.js +++ b/wp-admin/js/upload.js @@ -1,21 +1,51 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { theFileList = { currentImage: {ID: 0}, nonce: '', tab: '', postID: 0, - toQueryParams: function(qryStrOrig) { - var params = new Object(); - var qryStr = qryStrOrig; - var i = 0; - do { - params[qryStr.split("=")[0].replace(/&/, "")] = ( qryStr.split("=")[1] ) ? qryStr.split("=")[1].split(/&|$/)[0] : ''; - qryStr = ( qryStr.split("=")[1] ) ? qryStr.split(qryStr.split("=")[1].split(/&|$/)[0])[1] : ''; - i++; - } - while(i < (qryStrOrig.split("=").length - 1)); - return params; + // cookie create and read functions adapted from http://www.quirksmode.org/js/cookies.html + createCookie: function(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; + }, + + readCookie: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + assignCookieOnChange: function() { + jQuery(this).bind("change", function(){ + theFileList.createCookie(jQuery(this).attr('name'),jQuery(this).attr('id'),365); + }); + }, + + checkCookieSetting: function(name, defaultSetting) { + return this.readCookie(name) ? this.readCookie(name) : defaultSetting; + }, + + toQueryParams: function( s ) { + var r = {}; if ( !s ) { return r; } + var q = s.split('?'); if ( q[1] ) { s = q[1]; } + var pp = s.split('&'); + for ( var i in pp ) { + var p = pp[i].split('='); + r[p[0]] = p[1]; + } + return r; }, toQueryString: function(params) { @@ -116,12 +146,12 @@ addLoadEvent( function() { h += "
    "; h += ""; var display = []; - var checked = 'display-title'; + var checkedDisplay = 'display-title'; if ( 1 == this.currentImage.isImage ) { - checked = 'display-full'; + checkedDisplay = 'display-full'; if ( this.currentImage.thumb ) { display.push("
    "); - checked = 'display-thumb'; + checkedDisplay = 'display-thumb'; } display.push(""); } else if ( this.currentImage.thumb ) { @@ -134,9 +164,9 @@ addLoadEvent( function() { h += ""; } - h += ""; @@ -148,7 +178,12 @@ addLoadEvent( function() { h += ""; jQuery(h).prependTo('#upload-content'); - jQuery('#' + checked).attr('checked','checked'); + jQuery("input[@name='display']").each(theFileList.assignCookieOnChange); + jQuery("input[@name='link']").each(theFileList.assignCookieOnChange); + checkedDisplay = this.checkCookieSetting('display', checkedDisplay); + checkedLink = this.checkCookieSetting('link', checkedLink); + jQuery('#' + checkedDisplay).attr('checked','checked'); + jQuery('#' + checkedLink).attr('checked','checked'); if (e) return e.stopPropagation(); return false; }, @@ -288,7 +323,7 @@ addLoadEvent( function() { }; - for ( var property in uploadL10n ) + for ( var property in uploadL10n ) theFileList[property] = uploadL10n[property]; theFileList.initializeVars(); theFileList.initializeLinks(); diff --git a/wp-admin/js/users.js b/wp-admin/js/users.js index f249f65f..522cbadf 100644 --- a/wp-admin/js/users.js +++ b/wp-admin/js/users.js @@ -1,21 +1 @@ -addLoadEvent(function() { - theListEls = document.getElementsByTagName('tbody'); - theUserLists = new Array(); - for ( var l = 0; l < theListEls.length; l++ ) { - if ( theListEls[l].id ) - theUserLists[theListEls[l].id] = new listMan(theListEls[l].id); - } - addUserInputs = document.getElementById('adduser').getElementsByTagName('input'); - for ( var i = 0; i < addUserInputs.length; i++ ) { - addUserInputs[i].onkeypress = function(e) { return killSubmit('addUserSubmit();', e); } - } - document.getElementById('addusersub').onclick = function(e) { return killSubmit('addUserSubmit();', e); } -} -); - -function addUserSubmit() { - var roleEl = document.getElementById('role'); - var role = roleEl.options[roleEl.selectedIndex].value; - if ( !theUserLists['role-' + role] ) return true; - return theUserLists['role-' + role].ajaxAdder('user', 'adduser'); -} +jQuery( function($) { $('#users').wpList(); } ); diff --git a/wp-admin/js/widgets.js b/wp-admin/js/widgets.js new file mode 100644 index 00000000..4eb37ee7 --- /dev/null +++ b/wp-admin/js/widgets.js @@ -0,0 +1,136 @@ +jQuery(function($) { + $('.noscript-action').remove(); + + var increment = 1; + + // Open or close widget control form + var toggleWidget = function( li, disableFields ) { + var width = li.find('input.widget-width').val(); + + // it seems IE chokes on these animations because of the positioning/floating + var widgetAnim = $.browser.msie ? function() { + var t = $(this); + if ( t.is(':visible') ) { + if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } + li.css( 'marginLeft', 0 ); + t.siblings('h4').children('a').text( widgetsL10n.edit ); + } else { + t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open + if ( width > 250 ) + li.css( 'marginLeft', ( width - 250 ) * -1 ); + t.siblings('h4').children('a').text( widgetsL10n.cancel ); + } + t.toggle(); + } : function() { + var t = $(this); + + if ( t.is(':visible') ) { + if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } + if ( width > 250 ) + li.animate( { marginLeft: 0 } ); + t.siblings('h4').children('a').text( widgetsL10n.edit ); + } else { + t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open + if ( width > 250 ) + li.animate( { marginLeft: ( width - 250 ) * -1 } ); + t.siblings('h4').children('a').text( widgetsL10n.cancel ); + } + t.animate( { height: 'toggle' } ); + }; + + return li.children('div.widget-control').each( widgetAnim ).end(); + }; + + // onclick for edit/cancel links + var editClick = function() { + var q = wpAjax.unserialize( this.href ); + // if link is in available widgets list, make sure it points to the current sidebar + if ( ( q.sidebar && q.sidebar == $('#sidebar').val() ) || q.add ) { + var w = q.edit || q.add; + toggleWidget( $('#current-sidebar .widget-control-list input[@name^="widget-id"][@value=' + w + ']').parents('li:first'), false ).blur(); + return false; + } else if ( q.sidebar ) { // otherwise, redirect to correct page + return true; + } + + // If link is in current widgets list, just open the form + toggleWidget( $(this).parents('li:first'), true ).blur(); + return false; + }; + + // onclick for add links + var addClick = function() { + var oldLi = $(this).parents('li:first').find('ul.widget-control-info li'); + var newLi = oldLi.clone(); + + if ( newLi.html().match( /%i%/ ) ) { + // supplid form is a template, replace %i% by unique id + var i = $('#generated-time').val() + increment.toString(); + increment++; + newLi.html( newLi.html().replace( /%i%/g, i ) ); + } else { + $(this).text( widgetsL10n.edit ).unbind().click( editClick ); + // save form content in textarea so we don't have any conflicting HTML ids + oldLi.html( '' ); + } + + // add event handlers + addWidgetControls( newLi ); + + // add widget to sidebar sortable + widgetSortable.append( newLi ).SortableAddItem( newLi[0] ); + + // increment widget counter + var n = parseInt( $('#widget-count').text(), 10 ) + 1; + $('#widget-count').text( n.toString() ) + + return false; + }; + + // add event handlers to all links found in context + var addWidgetControls = function( context ) { + if ( !context ) + context = document; + + $('a.widget-control-edit', context).click( editClick ); + + // onclick for save links + $('a.widget-control-save', context).click( function() { + toggleWidget( $(this).parents('li:first'), false ).blur() + return false; + } ); + + // onclick for remove links + $('a.widget-control-remove', context).click( function() { + var w = $(this).parents('li:first').find('input[@name^="widget-id"]').val(); + $(this).parents('li:first').remove(); + var t = $('#widget-list ul#widget-control-info-' + w + ' textarea'); + t.parent().html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action') + .show().text( widgetsL10n.add ).unbind().click( addClick ); + var n = parseInt( $('#widget-count').text(), 10 ) - 1; + $('#widget-count').text( n.toString() ) + return false; + } ); + } + + addWidgetControls(); + + $('a.widget-control-add').click( addClick ); + + var widgetSortable; + var widgetSortableInit = function() { + try { // a hack to make sortables work in jQuery 1.2+ and IE7 + $('#current-sidebar .widget-control-list').SortableDestroy(); + } catch(e) {} + widgetSortable = $('#current-sidebar .widget-control-list').Sortable( { + accept: 'widget-sortable', + helperclass: 'sorthelper', + handle: 'h4.widget-title', + onStop: widgetSortableInit + } ); + } + + // initialize sortable + widgetSortableInit(); + +}); diff --git a/wp-admin/link-add.php b/wp-admin/link-add.php index 2b06d8ec..be3f0403 100644 --- a/wp-admin/link-add.php +++ b/wp-admin/link-add.php @@ -3,7 +3,7 @@ require_once('admin.php'); $title = __('Add Link'); $this_file = 'link-manager.php'; -$parent_file = 'link-manager.php'; +$parent_file = 'post-new.php'; wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', @@ -11,9 +11,10 @@ wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]')); -wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') ); -if ( current_user_can( 'manage_categories' ) ) - wp_enqueue_script( 'ajaxlinkcat' ); +wp_enqueue_script('link'); +wp_enqueue_script('xfn'); +wp_enqueue_script('thickbox'); + require('admin-header.php'); ?> @@ -22,16 +23,8 @@ require('admin-header.php'); - - +$link = get_default_link_to_edit(); +include('edit-link-form.php'); - +?> \ No newline at end of file diff --git a/wp-admin/link-category.php b/wp-admin/link-category.php index 42058928..a67cf2b6 100644 --- a/wp-admin/link-category.php +++ b/wp-admin/link-category.php @@ -35,14 +35,22 @@ case 'delete': wp_delete_term($cat_ID, 'link_category'); - wp_redirect('edit-link-categories.php?message=2'); + $location = 'edit-link-categories.php'; + if ( $referer = wp_get_original_referer() ) { + if ( false !== strpos($referer, 'edit-link-categories.php') ) + $location = $referer; + } + + $location = add_query_arg('message', 2, $location); + + wp_redirect($location); exit; break; case 'edit': $title = __('Categories'); - $parent_file = 'link-manager.php'; + $parent_file = 'edit.php'; $submenu_file = 'edit-link-categories.php'; require_once ('admin-header.php'); $cat_ID = (int) $_GET['cat_ID']; @@ -59,11 +67,18 @@ case 'editedcat': if ( !current_user_can('manage_categories') ) wp_die(__('Cheatin’ uh?')); + $location = 'edit-link-categories.php'; + if ( $referer = wp_get_original_referer() ) { + if ( false !== strpos($referer, 'edit-link-categories.php') ) + $location = $referer; + } + if ( wp_update_term($cat_ID, 'link_category', $_POST) ) - wp_redirect('edit-link-categories.php?message=3'); + $location = add_query_arg('message', 3, $location); else - wp_redirect('edit-link-categories.php?message=5'); + $location = add_query_arg('message', 5, $location); + wp_redirect($location); exit; break; } diff --git a/wp-admin/link-import.php b/wp-admin/link-import.php index 92753173..f2183f6b 100644 --- a/wp-admin/link-import.php +++ b/wp-admin/link-import.php @@ -3,9 +3,8 @@ // Copyright (C) 2002 Mike Little -- mike@zed1.com require_once('admin.php'); -$parent_file = 'link-manager.php'; +$parent_file = 'edit.php'; $title = __('Import Blogroll'); -$this_file = 'link-import.php'; $step = $_POST['step']; if (!$step) $step = 0; @@ -30,12 +29,12 @@ switch ($step) {
    -
    +

    -
    +

    @@ -54,7 +53,7 @@ foreach ($categories as $category) { ?>

    -

    +

    @@ -123,7 +122,7 @@ else } // end else if ( ! $blogrolling ) - apply_filters( 'wp_delete_file', $opml_url); + do_action( 'wp_delete_file', $opml_url); @unlink($opml_url); ?>
    diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index ade31431..42ec2017 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -1,12 +1,30 @@ - -

    '; $deleted = (int) $_GET['deleted']; printf(__ngettext('%s link deleted.', '%s links deleted', $deleted), $deleted); echo '

    '; + $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']); } ?>
    -

    -

    add links to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it’s called a “blogroll.”'); ?>

    -
    -

    +

    add new)' ), 'link-add.php' ); ?>

    + +

    + + +

    + +
    + +
    + +
    + +\n"; -$select_cat .= '\n"; +$select_cat .= '\n"; foreach ((array) $categories as $cat) $select_cat .= '\n"; $select_cat .= "\n"; $select_order = "\n"; -printf(__('Currently showing %1$s links ordered by %2$s'), $select_cat, $select_order); +echo $select_cat; +echo $select_order; + ?> -

    - + + +
    + +
    +
    + +
    + '
    ', + 'name' => '', 'url' => '', 'categories' => '', 'rel' => '', 'visible' => '', - 'action' => '', ); $link_columns = apply_filters('manage_link_columns', $link_columns); ?> @@ -109,26 +130,24 @@ $link_columns = apply_filters('manage_link_columns', $link_columns); $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0); +if ( !empty($_GET['s']) ) + $args['search'] = $_GET['s']; +$links = get_bookmarks( $args ); if ( $links ) { ?> - - - - -
    " + this.link + ""; - h += "
    "; - h += "
    "; + var checkedLink = 'link-file'; + h += "
    " + this.link + ""; + h += "
    "; h += "
    "; h += ""; h += "
    ' . __('Name') . '' . __('Name') . '' . __('URL') . '' . __('Categories') . '' . __('rel') . '' . __('Visible') . '' . __('Action') . '
    + - - + >'; foreach($link_columns as $column_name=>$column_display_name) { switch($column_name) { case 'name': - ?>"; break; case 'url': @@ -173,11 +194,7 @@ if ( $links ) { ?>'.__('Edit').''; - echo ''; + ?> @@ -187,19 +204,23 @@ if ( $links ) { } } - echo ''; echo "\n \n"; } ?>
    + +

    + + +
    -

    ')" />

    - +
    +
    +
    - diff --git a/wp-admin/link.php b/wp-admin/link.php index 1d7e4d6a..bc593f56 100644 --- a/wp-admin/link.php +++ b/wp-admin/link.php @@ -83,10 +83,11 @@ switch ($action) { break; case 'edit' : - wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') ); - if ( current_user_can( 'manage_categories' ) ) - wp_enqueue_script( 'ajaxlinkcat' ); - $parent_file = 'link-manager.php'; + wp_enqueue_script('link'); + wp_enqueue_script('xfn'); + wp_enqueue_script('thickbox'); + + $parent_file = 'edit.php'; $submenu_file = 'link-manager.php'; $title = __('Edit Link'); diff --git a/wp-admin/media-upload.php b/wp-admin/media-upload.php new file mode 100644 index 00000000..e7561669 --- /dev/null +++ b/wp-admin/media-upload.php @@ -0,0 +1,41 @@ + diff --git a/wp-admin/media.php b/wp-admin/media.php new file mode 100644 index 00000000..25088108 --- /dev/null +++ b/wp-admin/media.php @@ -0,0 +1,112 @@ +

    $message

    \n"; + +?> + +
    + +

    + +
    +
    +
    + false, 'send' => false, 'delete' => false, 'errors' => $errors ) ); ?> +
    +
    + +

    + + + + + + +

    + + +
    + + diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php index bbdfe1a7..b9c1dde9 100644 --- a/wp-admin/menu-header.php +++ b/wp-admin/menu-header.php @@ -1,11 +1,46 @@ -
      + +
        + $item ) { + if ( 3 < $key ) // get each menu item before 3 + continue; + $class = ''; + // 0 = name, 1 = capability, 2 = file + if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; + + if ( !empty($submenu[$item[2]]) ) { + $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. + $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) + echo "\n\t
      • {$item[0]}
      • "; + else + echo "\n\t
      • {$item[0]}
      • "; + } else if ( current_user_can($item[1]) ) { + $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) ) + echo "\n\t
      • {$item[0]}
      • "; + else + echo "\n\t
      • {$item[0]}
      • "; + } +} +do_action( 'dashmenu' ); +?> +
      + +
        + $item ) { + if ( 5 > $key || $key > 25 ) // get each menu item before 3 + continue; + $class = ''; // 0 = name, 1 = capability, 2 = file @@ -19,16 +54,77 @@ foreach ($menu as $item) { else echo "\n\t
      • {$item[0]}
      • "; } else if ( current_user_can($item[1]) ) { - if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") ) + $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) ) echo "\n\t
      • {$item[0]}
      • "; else echo "\n\t
      • {$item[0]}
      • "; } } +foreach ( $menu as $key => $item ) { + if ( $key < 41 ) // there is a more efficient way to do this! + continue; + + $class = ''; + + // 0 = name, 1 = capability, 2 = file + if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; + + if ( !empty($submenu[$item[2]]) ) { + $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. + $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) + echo "\n\t
      • {$item[0]}
      • "; + else + echo "\n\t
      • {$item[0]}
      • "; + } else if ( current_user_can($item[1]) ) { + $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) ) + echo "\n\t
      • {$item[0]}
      • "; + else + echo "\n\t
      • {$item[0]}
      • "; + } +} + +do_action( 'adminmenu' ); ?>
      +
        + $item ) { + if ( 26 > $key || $key > 40 ) + continue; + + $class = ''; + + // 0 = name, 1 = capability, 2 = file + if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; + + if ( !empty($submenu[$item[2]]) ) { + $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. + $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) + $side_items[] = "\n\t
      • {$item[0]}"; + else + $side_items[] = "\n\t
      • {$item[0]}"; + } else if ( current_user_can($item[1]) ) { + $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) ) + $side_items[] = "\n\t
      • {$item[0]}"; + else + $side_items[] = "\n\t
      • {$item[0]}"; + } +} +echo implode('
      • ', $side_items) . ''; +unset($side_items); +do_action( 'sidemenu' ); +?> +
      + + moderated; +$menu[15] = array(__('Design'), 'switch_themes', 'themes.php'); +$menu[20] = array( sprintf( __('Comments %s'), "$awaiting_mod" ), 'edit_posts', 'edit-comments.php'); +$menu[30] = array(__('Settings'), 'manage_options', 'options-general.php'); +$menu[35] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); if ( current_user_can('edit_users') ) - $menu[35] = array(__('Users'), 'edit_users', 'users.php'); + $menu[40] = array(__('Users'), 'edit_users', 'users.php'); else - $menu[35] = array(__('Profile'), 'read', 'profile.php'); -$menu[40] = array(__('Options'), 'manage_options', 'options-general.php'); - + $menu[40] = array(__('Profile'), 'read', 'profile.php'); $_wp_real_parent_file['post.php'] = 'post-new.php'; // Back-compat -$submenu['post-new.php'][5] = array(__('Write Post'), 'edit_posts', 'post-new.php'); -$submenu['post-new.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php'); +$submenu['post-new.php'][5] = array(__('Post'), 'edit_posts', 'post-new.php'); +$submenu['post-new.php'][10] = array(__('Page'), 'edit_pages', 'page-new.php'); +$submenu['post-new.php'][15] = array(__('Link'), 'manage_links', 'link-add.php'); $submenu['edit-comments.php'][5] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); -$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); -$submenu['edit-comments.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), "$awaiting_mod"), 'edit_posts', 'moderation.php'); - $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php'); $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); -$submenu['edit.php'][12] = array(__('Uploads'), 'upload_files', 'upload.php'); -$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php'); -$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php'); -$submenu['edit.php'][35] = array(__('Import'), 'import', 'import.php'); -$submenu['edit.php'][40] = array(__('Export'), 'import', 'export.php'); - -$submenu['link-manager.php'][5] = array(__('Manage Blogroll'), 'manage_links', 'link-manager.php'); -$submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php'); -$submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php'); -$submenu['link-manager.php'][30] = array(__('Categories'), 'manage_links', 'edit-link-categories.php'); +$submenu['edit.php'][15] = array(__('Links'), 'manage_links', 'link-manager.php'); +$submenu['edit.php'][20] = array(__('Categories'), 'manage_categories', 'categories.php'); +$submenu['edit.php'][25] = array(__('Tags'), 'manage_categories', 'edit-tags.php'); +$submenu['edit.php'][30] = array(__('Link Categories'), 'manage_categories', 'edit-link-categories.php'); +$submenu['edit.php'][35] = array(__('Media Library'), 'upload_files', 'upload.php'); +$submenu['edit.php'][40] = array(__('Import'), 'import', 'import.php'); +$submenu['edit.php'][45] = array(__('Export'), 'import', 'export.php'); if ( current_user_can('edit_users') ) { $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php. $submenu['users.php'][5] = array(__('Authors & Users'), 'edit_users', 'users.php'); $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php'); } else { + $_wp_real_parent_file['users.php'] = 'profile.php'; $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); } @@ -137,6 +138,7 @@ unset($id); uksort($menu, "strnatcasecmp"); // make it all pretty if (! user_can_access_admin_page()) { + do_action('admin_page_access_denied'); wp_die( __('You do not have sufficient permissions to access this page.') ); } diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php index fc46917c..6750ac32 100644 --- a/wp-admin/moderation.php +++ b/wp-admin/moderation.php @@ -1,226 +1,4 @@ $v ) { - $comment[intval( $k )] = $v; - } -} - -if ( $action == 'update' ) { - check_admin_referer( 'moderate-comments' ); - - if ( !current_user_can( 'moderate_comments' ) ) { - wp_die( __( 'Your level is not high enough to moderate comments.' ) ); - } - - $item_ignored = 0; - $item_deleted = 0; - $item_approved = 0; - $item_spam = 0; - - foreach ( $comment as $k => $v ) { - if ( $feelinglucky && $v == 'later' ) { - $v = 'delete'; - } - - switch ( $v ) { - case 'later' : - $item_ignored++; - break; - - case 'delete' : - wp_set_comment_status( $k, 'delete' ); - $item_deleted++; - break; - - case 'spam' : - wp_set_comment_status( $k, 'spam' ); - $item_spam++; - break; - - case 'approve' : - wp_set_comment_status( $k, 'approve' ); - - if ( get_option( 'comments_notify' ) == true ) { - wp_notify_postauthor( $k ); - } - - $item_approved++; - break; - } - } - - wp_redirect( basename( __FILE__ ) . '?ignored=' . $item_ignored . '&deleted=' . $item_deleted . '&approved=' . $item_approved . '&spam=' . $item_spam ); - exit; -} - -require_once './admin-header.php'; - -if ( !current_user_can( 'moderate_comments' ) ) { - echo '

      ' . __( 'Your level is not high enough to moderate comments.' ) . '

      '; - include_once './admin-footer.php'; - exit; -} - -if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) { - $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; - $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; - $spam = isset( $_GET['ignored'] ) ? (int) $_GET['spam'] : 0; - - if ( $approved > 0 || $deleted > 0 || $spam > 0 ) { - echo '

      '; - - if ( $approved > 0 ) { - printf( __ngettext( '%s comment approved.', '%s comments approved.', $approved ), $approved ); - echo '
      '; - } - - if ( $deleted > 0 ) { - printf( __ngettext( '%s comment deleted', '%s comments deleted.', $deleted ), $deleted ); - echo '
      '; - } - - if ( $spam > 0 ) { - printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); - echo '
      '; - } - - echo '

      '; - } -} - +require_once('../wp-config.php'); +wp_redirect('edit-comments.php?comment_status=moderated'); ?> -
      -get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'" ); - -if ( !$comments ) { - echo '

      ' . __( 'Currently there are no comments for you to moderate.' ) . '

      '; - include_once './admin-footer.php'; - exit; -} - -$total = count( $comments ); -$per = 100; - -if ( isset( $_GET['paged'] ) ) { - $page = (int) $_GET['paged']; -} else { - $page = 1; -} - -$start = ( $page * $per ) - $per; -$stop = $start + $per; - -$page_links = paginate_links( array( - 'base' => add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'total' => ceil( $total / $per ), - 'current' => $page, - 'prev_text' => '«', - 'next_text' => '»' -) ); - -$comments = array_slice( $comments, $start, $stop ); - -?> -

      - - ' . $page_links . '

      '; - } - ?> - - - - -
        - -
      1. -

        - - comment_author_email ) ) { ?>| - comment_author_url ) && $comment->comment_author_url != 'http://' ) { ?>| - | -

        - -

        - -

        - -

        - — - [ | - ', theCommentList );"> ] — - comment_post_ID ) ); ?> -

        - -

        - -   -   -   - -

        -
      2. - -
      - - ' . $page_links . '

      '; - } - ?> - -
      - - - -

      - -

      - - - - - \ No newline at end of file diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php index 78deefdd..69c0bbd3 100644 --- a/wp-admin/options-discussion.php +++ b/wp-admin/options-discussion.php @@ -1,84 +1,122 @@
      -

      +

      -

      -
      -('.__('These settings may be overridden for individual articles.').')'; ?> -
        -
      • + + + + + + + + + + + + + + + + + + + + + +
        - -
      • +
        -
      • -
      • +
        -
      • - - -
        - -
          -
        • +
          + +
        - -
      • +
        -
      • - - -
        - -
          -
        • +
        - -
      • -
      • - - -
        - +
        + +
        + +

        ' ) ?>

        -

        moderation queue. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?>

        +

        moderation queue. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?>

        - +

        - -
        - +

        - +

        - +
        + +

        + +

        Gravatars — short for Globally Recognized Avatars — for the pictures that show up next to comments. Plugins may override this.'); ?>

        + + + + + + + + + + + + + +
        + __("Don’t show Avatars"), 1 => __('Show Avatars')); + foreach ( $yesorno as $key => $value) { + $selected = (get_option('show_avatars') == $key) ? 'checked="checked"' : ''; + echo "\n\t
        "; + } +?> +
        + + __('G — Suitable for all audiences'), 'PG' => __('PG — Possibly offensive, usually for audiences 13 and above'), 'R' => __('R — Intended for adult audiences above 17'), 'X' => __('X — Even more mature than above')); +foreach ($ratings as $key => $rating) : + $selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : ''; + echo "\n\t
        "; +endforeach; +?> + +
        + +

        - - + +

      diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 3e6ce862..680f7ae9 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -1,44 +1,43 @@
      -

      +

      -

      - +
      - + - + - + - + - + + - + - + -

      " />
      " />
      to be different from the directory you installed WordPress.'); ?>

      -

      @@ -49,40 +48,57 @@ include('./admin-header.php');
      -
      - - - - - - - - + + - + - + - - - - +
      +Documentation on date formatting. Click "Save Changes" to update sample output.') ?> - +
      UTC time is:') ?>
      - (-6 for Central Time.'); ?>) + +
      +UTC time is %s'), gmdate(__('Y-m-d G:i:s'))); ?>
      +%2$s'), $current_offset_name, gmdate(__('Y-m-d G:i:s'), current_time('timestamp'))); ?>
      + +


      -
       Documentation on date formatting. Click "Update options" to update sample output.') ?>
      -
      -

      +

      diff --git a/wp-admin/options-head.php b/wp-admin/options-head.php index 11d82e87..779edca4 100644 --- a/wp-admin/options-head.php +++ b/wp-admin/options-head.php @@ -1,5 +1,5 @@ -

      +

      \ No newline at end of file diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php index ec429659..6cf0c154 100644 --- a/wp-admin/options-misc.php +++ b/wp-admin/options-misc.php @@ -1,7 +1,7 @@
      -

      +

      -

      -
      - - +

      +
      - + + + + + + + - - + +
      :
      wp-content/uploads'); ?>
      +
      + +
      + +

      +

      + + + + + + + + +
      + + + +
      +/> + +
      + + + +
      -
      -

      /> -

      -

      - -

      + + + + + + + + + + + + +
      + +
      + +

      - - + +

      diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 01919feb..38144a3b 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -1,7 +1,7 @@
      -

      URLs which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A number of tags are available, and here are some examples to get you started.'); ?>

      -

      -

      - -

      -

      - -

      -

      - -

      -

      - -
      -

      -

      :

      +

      + + + + + + + + + + + + + + + + + + + + + +
      /?p=123
      /archives/123
      + + + +

      -

      URLs here. For example, using /topics/ as your category base would make your category links like http://example.org/topics/uncategorized/. If you leave these blank the defaults will be used.') ?>

      +

      URLs here. For example, using /topics/ as your category base would make your category links like http://example.org/topics/uncategorized/. If you leave these blank the defaults will be used.') ?>

      -

      URLs here. For example, using /topics/ as your category base would make your category links like http://example.org/index.php/topics/uncategorized/. If you leave these blank the defaults will be used.') ?>

      +

      URLs here. For example, using /topics/ as your category base would make your category links like http://example.org/index.php/topics/uncategorized/. If you leave these blank the defaults will be used.') ?>

      -

      - : -

      -

      - : -

      -

      - -

      + + + + + + + + + + +
      +

      -

      .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.') ?>

      +

      .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.') ?>

      diff --git a/wp-admin/options-privacy.php b/wp-admin/options-privacy.php index ac6810b3..b493fc9d 100644 --- a/wp-admin/options-privacy.php +++ b/wp-admin/options-privacy.php @@ -1,19 +1,19 @@
      -

      +

      - +
      - +

      />

      @@ -24,7 +24,7 @@ include('./admin-header.php');
      -

      +

      diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php index 3a7f80e7..82c5049a 100644 --- a/wp-admin/options-reading.php +++ b/wp-admin/options-reading.php @@ -1,23 +1,20 @@
      -

      +

      -

      + -
      - -
      - + -

      - - -
      - - - + -
      -
      - -
      - - - + - + -


      -

      <!--more--> feature, it will cut off posts in RSS feeds.'); ?>

      -
      - + - +

      recommended)') ?>
      -

      - -

      - +

      - \ No newline at end of file + diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php index e8979c45..645bfc79 100644 --- a/wp-admin/options-writing.php +++ b/wp-admin/options-writing.php @@ -1,25 +1,25 @@
      -

      +

      -

      - + +
      - - + - + - + - +
      +
      -
      - -

      %s, %s, %s.'), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5)) ?>

      +

      +

      %s, %s, %s.'), wp_generate_password(), wp_generate_password(), wp_generate_password()) ?>

      - +
      - + - + - + - +
      - +
      -
      -
      - +

      @@ -107,18 +104,16 @@ endforeach; -

      Update Services because of your blog\'s privacy settings.'), 'options-privacy.php'); ?> +

      Update Services because of your blog\'s privacy settings.'), 'options-privacy.php'); ?>

      -
      -

      - +

      - \ No newline at end of file + diff --git a/wp-admin/options.php b/wp-admin/options.php index 7fa05bbf..88ee29ae 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -1,7 +1,7 @@
      -

      +

      -

      - +
      get_results("SELECT * FROM $wpdb->options ORDER BY option_name"); @@ -74,7 +73,7 @@ foreach ( (array) $options as $option) : } echo " - +
      $option->option_name "; if (strpos($value, "\n") !== false) echo ""; @@ -86,7 +85,7 @@ endforeach; ?>
      -

      +

      diff --git a/wp-admin/page-new.php b/wp-admin/page-new.php index ff86155b..f09d6578 100644 --- a/wp-admin/page-new.php +++ b/wp-admin/page-new.php @@ -3,21 +3,24 @@ require_once('admin.php'); $title = __('New Page'); $parent_file = 'post-new.php'; $editing = true; -wp_enqueue_script('prototype'); -wp_enqueue_script('interface'); wp_enqueue_script('autosave'); +wp_enqueue_script('page'); +if ( user_can_richedit() ) + wp_enqueue_script('editor'); +wp_enqueue_script('thickbox'); +wp_enqueue_script('media-upload'); + require_once('admin-header.php'); ?> -

      |

      +

      |

      post_type = 'page'; + $post = get_default_page_to_edit(); include('edit-page-form.php'); } diff --git a/wp-admin/page.php b/wp-admin/page.php index c6baadde..b10fa727 100644 --- a/wp-admin/page.php +++ b/wp-admin/page.php @@ -6,6 +6,51 @@ $submenu_file = 'edit-pages.php'; wp_reset_vars(array('action')); +function redirect_page($page_ID) { + $referredby = ''; + if ( !empty($_POST['referredby']) ) { + $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); + $referredby = remove_query_arg('_wp_original_http_referer', $referredby); + } + $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); + + if ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) { + $location = $_POST['referredby']; + } elseif ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) { + $location = 'sidebar.php?a=b'; + } elseif ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) { + if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page-new.php') === false ) + $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "page.php?action=edit&post=$page_ID&message=1" ); + else + $location = "page.php?action=edit&post=$page_ID&message=4"; + } elseif ($_POST['addmeta']) { + $location = add_query_arg( 'message', 2, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif ($_POST['deletemeta']) { + $location = add_query_arg( 'message', 3, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif (!empty($referredby) && $referredby != $referer) { + $location = $_POST['referredby']; + $location = remove_query_arg('_wp_original_http_referer', $location); + if ( $_POST['referredby'] == 'redo' ) + $location = get_permalink( $page_ID ); + elseif ( false !== strpos($location, 'edit-pages.php') ) + $location = add_query_arg('posted', $page_ID, $location); + elseif ( false !== strpos($location, 'wp-admin') ) + $location = "page-new.php?posted=$page_ID"; + } elseif ( isset($_POST['publish']) ) { + $location = "page-new.php?posted=$page_ID"; + } elseif ($action == 'editattachment') { + $location = 'attachments.php'; + } else { + $location = "page.php?action=edit&post=$page_ID&message=4"; + } + + wp_redirect($location); +} + if (isset($_POST['deletepost'])) { $action = "delete"; } @@ -15,27 +60,8 @@ case 'post': check_admin_referer('add-page'); $page_ID = write_post(); - // Redirect. - if (!empty($_POST['mode'])) { - switch($_POST['mode']) { - case 'bookmarklet': - $location = $_POST['referredby']; - break; - case 'sidebar': - $location = 'sidebar.php?a=b'; - break; - default: - $location = 'page-new.php'; - break; - } - } else { - $location = "page-new.php?posted=$page_ID"; - } - - if ( isset($_POST['save']) ) - $location = "page.php?action=edit&post=$page_ID"; + redirect_page($page_ID); - wp_redirect($location); exit(); break; @@ -52,11 +78,25 @@ case 'edit': exit(); } - if($post->post_status == 'draft') { - wp_enqueue_script('prototype'); - wp_enqueue_script('interface'); - wp_enqueue_script('autosave'); + wp_enqueue_script('page'); + if ( user_can_richedit() ) + wp_enqueue_script('editor'); + wp_enqueue_script('thickbox'); + wp_enqueue_script('media-upload'); + + if ( current_user_can('edit_page', $page_ID) ) { + if ( $last = wp_check_post_lock( $post->ID ) ) { + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); + $message = sprintf( __( 'Warning: %s is currently editing this page' ), wp_specialchars( $last_user_name ) ); + $message = str_replace( "'", "\'", "

      $message

      " ); + add_action('admin_notices', create_function( '', "echo '$message';" ) ); + } else { + wp_set_post_lock( $post->ID ); + wp_enqueue_script('autosave'); + } } + require_once('admin-header.php'); if ( !current_user_can('edit_page', $page_ID) ) @@ -85,43 +125,7 @@ case 'editpost': $page_ID = edit_post(); - if ( 'post' == $_POST['originalaction'] ) { - if (!empty($_POST['mode'])) { - switch($_POST['mode']) { - case 'bookmarklet': - $location = $_POST['referredby']; - break; - case 'sidebar': - $location = 'sidebar.php?a=b'; - break; - default: - $location = 'page-new.php'; - break; - } - } else { - $location = "page-new.php?posted=$page_ID"; - } - - if ( isset($_POST['save']) ) - $location = "page.php?action=edit&post=$page_ID"; - } else { - if ($_POST['save']) { - $location = "page.php?action=edit&post=$page_ID"; - } elseif ($_POST['updatemeta']) { - $location = wp_get_referer() . '&message=2#postcustom'; - } elseif ($_POST['deletemeta']) { - $location = wp_get_referer() . '&message=3#postcustom'; - } elseif (!empty($_POST['referredby']) && $_POST['referredby'] != wp_get_referer()) { - $location = $_POST['referredby']; - if ( $_POST['referredby'] == 'redo' ) - $location = get_permalink( $page_ID ); - } elseif ($action == 'editattachment') { - $location = 'attachments.php'; - } else { - $location = 'page-new.php'; - } - } - wp_redirect($location); // Send user on their way while we keep working + redirect_page($page_ID); exit(); break; diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index b25b3d45..a9c534c5 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -6,12 +6,16 @@ $parent_file = 'plugins.php'; wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file')); +add_action( 'admin_head', 'theme_editor_css' ); +function theme_editor_css(){ + wp_admin_css( 'css/theme-editor' ); +} + $plugins = get_plugins(); $plugin_files = array_keys($plugins); -if (empty($file)) { +if (empty($file)) $file = $plugin_files[0]; -} $file = validate_file_to_edit($file, $plugin_files); $real_file = get_real_file_to_edit( PLUGINDIR . "/$file"); @@ -26,27 +30,23 @@ case 'update': wp_die('

      '.__('You do not have sufficient permissions to edit templates for this blog.').'

      '); $newcontent = stripslashes($_POST['newcontent']); - if (is_writeable($real_file)) { + if ( is_writeable($real_file) ) { $f = fopen($real_file, 'w+'); fwrite($f, $newcontent); fclose($f); // Deactivate so we can test it. - $current = get_option('active_plugins'); - if ( in_array($file, $current) || isset($_POST['phperror']) ) { - if ( in_array($file, $current) ) { - array_splice($current, array_search( $file, $current), 1 ); // Array-fu! - update_option('active_plugins', $current); - } + if ( is_plugin_active($file) || isset($_POST['phperror']) ) { + if ( is_plugin_active($file) ) + deactivate_plugins($file, true); wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1")); - exit(); + exit; } wp_redirect("plugin-editor.php?file=$file&a=te"); } else { wp_redirect("plugin-editor.php?file=$file"); } - - exit(); + exit; break; @@ -55,73 +55,75 @@ default: if ( !current_user_can('edit_plugins') ) wp_die('

      '.__('You do not have sufficient permissions to edit plugins for this blog.').'

      '); - if ( $_GET['liveupdate'] ) { + if ( isset($_GET['liveupdate']) ) { check_admin_referer('edit-plugin-test_' . $file); - $current = get_option('active_plugins'); - $plugin = $file; - if ( validate_file($plugin) ) - wp_die(__('Invalid plugin.')); - if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) - wp_die(__('Plugin file does not exist.')); - if (!in_array($plugin, $current)) { - wp_redirect("plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error - @include(ABSPATH . PLUGINDIR . '/' . $plugin); - $current[] = $plugin; - sort($current); - update_option('active_plugins', $current); - } + + $error = validate_plugin($file); + if( is_wp_error($error) ) + wp_die( $error ); + + if ( ! is_plugin_active($file) ) + activate_plugin($file, "plugin-editor.php?file=$file&phperror=1");// we'll override this later if the plugin can be included without fatal error + wp_redirect("plugin-editor.php?file=$file&a=te"); + exit; } require_once('admin-header.php'); update_recently_edited(PLUGINDIR . "/$file"); - if (!is_file($real_file)) + if ( ! is_file($real_file) ) $error = 1; - if (!$error) { - $f = fopen($real_file, 'r'); - $content = fread($f, filesize($real_file)); - $content = htmlspecialchars($content); - } + if ( ! $error ) + $content = htmlspecialchars(file_get_contents($real_file)); ?>

      -

      fatal error.') ?>

      +

      fatal error.') ?>

      + + + +
      - ' . sprintf(__('Editing %s (active)'), $file) . ''; - } else { - echo '

      ' . sprintf(__('Browsing %s (active)'), $file) . '

      '; - } +
      +

      +
      +
      +
      +%s (active)'), $file); + else + echo sprintf(__('Browsing %s (active)'), $file); } else { - if (is_writeable($real_file)) { - echo '

      ' . sprintf(__('Editing %s (inactive)'), $file) . '

      '; - } else { - echo '

      ' . sprintf(__('Browsing %s (inactive)'), $file) . '

      '; - } + if ( is_writeable($real_file) ) + echo sprintf(__('Editing %s (inactive)'), $file); + else + echo sprintf(__('Browsing %s (inactive)'), $file); } - ?> + ?>
      +
      +
      +
      +
      -

      +

      - +

        - -
      • ">
      • - + +
      • +
      - -
      - +
      +
      @@ -135,13 +137,13 @@ if ($plugin_files) :

      "; + echo ""; else - echo ""; + echo ""; ?>

      -

      +

      the Codex for more information.'); ?>

       
      +include("admin-footer.php") ?> \ No newline at end of file diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index b9e6e7b2..f0b75ad5 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -2,100 +2,67 @@ require_once('admin.php'); if ( isset($_GET['action']) ) { - if ('activate' == $_GET['action']) { - check_admin_referer('activate-plugin_' . $_GET['plugin']); - $current = get_option('active_plugins'); + if ( isset($_GET['plugin']) ) $plugin = trim($_GET['plugin']); - if ( validate_file($plugin) ) - wp_die(__('Invalid plugin.')); - if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) - wp_die(__('Plugin file does not exist.')); - if (!in_array($plugin, $current)) { - wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), 'plugins.php?error=true&plugin=' . $plugin)); // we'll override this later if the plugin can be included without fatal error - ob_start(); - @include(ABSPATH . PLUGINDIR . '/' . $plugin); - $current[] = $plugin; - sort($current); - update_option('active_plugins', $current); - do_action('activate_' . $plugin); - ob_end_clean(); - } + + if ( 'activate' == $_GET['action'] ) { + check_admin_referer('activate-plugin_' . $_GET['plugin']); + $result = activate_plugin($_GET['plugin'], 'plugins.php?error=true&plugin=' . $plugin); + if ( is_wp_error( $result ) ) + wp_die( $result->get_error_message() ); wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above - } elseif ('error_scrape' == $_GET['action']) { - $plugin = trim($_GET['plugin']); + } elseif ( 'error_scrape' == $_GET['action'] ) { check_admin_referer('plugin-activation-error_' . $plugin); - if ( validate_file($plugin) ) - wp_die(__('Invalid plugin.')); - if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) - wp_die(__('Plugin file does not exist.')); + $valid = validate_plugin($plugin); + if ( is_wp_error($valid) ) + wp_die($valid); + error_reporting( E_ALL ^ E_NOTICE ); + @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. include(ABSPATH . PLUGINDIR . '/' . $plugin); - } elseif ('deactivate' == $_GET['action']) { + } elseif ( 'deactivate' == $_GET['action'] ) { check_admin_referer('deactivate-plugin_' . $_GET['plugin']); - $current = get_option('active_plugins'); - array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu! - update_option('active_plugins', $current); - do_action('deactivate_' . trim( $_GET['plugin'] )); + deactivate_plugins($_GET['plugin']); wp_redirect('plugins.php?deactivate=true'); - } elseif ($_GET['action'] == 'deactivate-all') { + } elseif ( 'deactivate-all' == $_GET['action'] ) { check_admin_referer('deactivate-all'); - $current = get_option('active_plugins'); - - foreach ($current as $plugin) { - array_splice($current, array_search($plugin, $current), 1); - do_action('deactivate_' . $plugin); - } - - update_option('active_plugins', array()); + deactivate_all_plugins(); wp_redirect('plugins.php?deactivate-all=true'); + } elseif ('reactivate-all' == $_GET['action']) { + check_admin_referer('reactivate-all'); + reactivate_all_plugins('plugins.php?errors=true'); + wp_redirect('plugins.php?reactivate-all=true'); // overrides the ?error=true one above } + exit; } $title = __('Manage Plugins'); require_once('admin-header.php'); -// Clean up options -// If any plugins don't exist, axe 'em +validate_active_plugins(); -$check_plugins = get_option('active_plugins'); - -// Sanity check. If the active plugin list is not an array, make it an -// empty array. -if ( !is_array($check_plugins) ) { - $check_plugins = array(); - update_option('active_plugins', $check_plugins); -} - -// If a plugin file does not exist, remove it from the list of active -// plugins. -foreach ($check_plugins as $check_plugin) { - if (!file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin)) { - $current = get_option('active_plugins'); - $key = array_search($check_plugin, $current); - if ( false !== $key && NULL !== $key ) { - unset($current[$key]); - update_option('active_plugins', $current); - } - } -} ?>

      fatal error.') ?>

      + if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
      + +

      fatal error.') ?>

      activated.') ?>

      deactivated.') ?>

      deactivated.'); ?>

      + +

      reactivated.'); ?>

      @@ -103,9 +70,6 @@ foreach ($check_plugins as $check_plugin) {

      '; } else { ?> - + +
      +
      + + + + + +
      +
      +
      + +
      + +
      - + - + + + $plugin_data) { - $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate'; + $action_links = array(); + + $style = ''; - if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { - $toggle = "".__('Deactivate').""; - $plugin_data['Title'] = "{$plugin_data['Title']}"; - $style .= $style == 'alternate' ? ' active' : 'active'; + if ( is_plugin_active($plugin_file) ) { + $action_links[] = "".__('Deactivate').""; + $style = 'active'; } else { - $toggle = "".__('Activate').""; + $action_links[] = "".__('Activate').""; } + if ( current_user_can('edit_plugins') && is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) ) + $action_links[] = "".__('Edit').""; $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); @@ -144,37 +133,35 @@ if (empty($plugins)) { $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags); $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags); $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags); + $author = ( empty($plugin_data['Author']) ) ? '' : ' ' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.'; if ( $style != '' ) - $style = 'class="' . $style . '"'; - if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) ) - $edit = "".__('Edit').""; - else - $edit = ''; + $style = ' class="' . $style . '"'; - $author = ( empty($plugin_data['Author']) ) ? '' : ' ' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.'; + $action_links = apply_filters('plugin_action_links', $action_links, $plugin_file, $plugin_info); echo " - + - "; - if ( current_user_can('edit_plugins') ) - echo " - "; - echo" + + "; do_action( 'after_plugin_row', $plugin_file ); } ?> - - - - - - +
      >
      {$plugin_data['Title']} {$plugin_data['Version']}

      {$plugin_data['Description']}$author

      $toggle$edit"; + if ( is_plugin_active($plugin_file) ) + echo __('Active'); + else + _e('Inactive'); + echo "
       
      + diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index c6b709b8..263783a3 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -3,9 +3,13 @@ require_once('admin.php'); $title = __('Create New Post'); $parent_file = 'post-new.php'; $editing = true; -wp_enqueue_script('prototype'); -wp_enqueue_script('interface'); wp_enqueue_script('autosave'); +wp_enqueue_script('post'); +if ( user_can_richedit() ) + wp_enqueue_script('editor'); +wp_enqueue_script('thickbox'); +wp_enqueue_script('media-upload'); + require_once ('./admin-header.php'); if ( ! current_user_can('edit_posts') ) { ?> @@ -20,109 +24,18 @@ When you’re promoted, just reload this page and you’ll be able to bl exit(); } -if ( isset($_GET['posted']) && $_GET['posted'] ) : ?> -

      +if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> +

      |

      '; - - foreach ( $nag_posts as $nag ) { - if ( ${$nag[0]} ) { - echo '

      ' . wp_specialchars($nag[1]) . ' '; - $i = 0; - foreach ( ${$nag[0]} as $post ) { - $i++; - if ( $i > $nag_posts_limit ) - break; - echo ''; - ( '' == the_title('', '', FALSE) ) ? printf( __('Post #%s'), $post->ID ) : the_title(); - echo ''; - if ( $i < min($nag[3], $nag_posts_limit) ) - echo ', '; - } - if ( $nag[3] > $nag_posts_limit ) - printf(__(', and %d more'), $nag[2], $nag[3] - $nag_posts_limit); - echo '.

      '; - } - } - echo "
      \n"; -} -?> - - - -
      -

      -

      -

      - - - - - - -
      -
      -
      - - - - - - -

      -
      - - - diff --git a/wp-admin/post.php b/wp-admin/post.php index 680f8abe..b9400b71 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -6,48 +6,75 @@ $submenu_file = 'edit.php'; wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder')); +function redirect_post($post_ID = '') { + global $action; + + $referredby = ''; + if ( !empty($_POST['referredby']) ) { + $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); + $referredby = remove_query_arg('_wp_original_http_referer', $referredby); + } + $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); + + if ( !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) { + $location = $_POST['referredby']; + } elseif ( !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) { + $location = 'sidebar.php?a=b'; + } elseif ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) { + if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post-new.php') === false ) + $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "post.php?action=edit&post=$post_ID&message=1" ); + else + $location = "post.php?action=edit&post=$post_ID&message=4"; + } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) { + $location = add_query_arg( 'message', 2, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) { + $location = add_query_arg( 'message', 3, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif (!empty($referredby) && $referredby != $referer) { + $location = $_POST['referredby']; + $location = remove_query_arg('_wp_original_http_referer', $location); + if ( $_POST['referredby'] == 'redo' ) + $location = get_permalink( $post_ID ); + elseif ( false !== strpos($location, 'edit.php') ) + $location = add_query_arg('posted', $post_ID, $location); + elseif ( false !== strpos($location, 'wp-admin') ) + $location = "post-new.php?posted=$post_ID"; + } elseif ( isset($_POST['publish']) ) { + $location = "post-new.php?posted=$post_ID"; + } elseif ($action == 'editattachment') { + $location = 'attachments.php'; + } else { + $location = "post.php?action=edit&post=$post_ID&message=4"; + } + + wp_redirect( $location ); +} + if ( isset( $_POST['deletepost'] ) ) $action = 'delete'; switch($action) { case 'postajaxpost': case 'post': - $parent_file = 'post-new.php'; - $submenu_file = 'post-new.php'; check_admin_referer('add-post'); $post_ID = 'post' == $action ? write_post() : edit_post(); - // Redirect. - if (!empty($_POST['mode'])) { - switch($_POST['mode']) { - case 'bookmarklet': - $location = $_POST['referredby']; - break; - case 'sidebar': - $location = 'sidebar.php?a=b'; - break; - default: - $location = 'post-new.php'; - break; - } - } else { - $location = "post-new.php?posted=$post_ID"; - } - - if ( isset($_POST['save']) ) - $location = "post.php?action=edit&post=$post_ID"; - - if ( empty($post_ID) ) - $location = 'post-new.php'; - - wp_redirect($location); + redirect_post($post_ID); exit(); break; case 'edit': $title = __('Edit'); $editing = true; + + if ( empty( $_GET['post'] ) ) { + wp_redirect("post.php"); + exit(); + } $post_ID = $p = (int) $_GET['post']; $post = get_post($post_ID); @@ -58,10 +85,25 @@ case 'edit': exit(); } - if($post->post_status == 'draft') { - wp_enqueue_script('prototype'); - wp_enqueue_script('autosave'); + wp_enqueue_script('post'); + if ( user_can_richedit() ) + wp_enqueue_script('editor'); + wp_enqueue_script('thickbox'); + wp_enqueue_script('media-upload'); + + if ( current_user_can('edit_post', $post_ID) ) { + if ( $last = wp_check_post_lock( $post->ID ) ) { + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); + $message = sprintf( __( 'Warning: %s is currently editing this post' ), wp_specialchars( $last_user_name ) ); + $message = str_replace( "'", "\'", "

      $message

      " ); + add_action('admin_notices', create_function( '', "echo '$message';" ) ); + } else { + wp_set_post_lock( $post->ID ); + wp_enqueue_script('autosave'); + } } + require_once('admin-header.php'); if ( !current_user_can('edit_post', $post_ID) ) @@ -94,49 +136,7 @@ case 'editpost': $post_ID = edit_post(); - if ( 'post' == $_POST['originalaction'] ) { - if (!empty($_POST['mode'])) { - switch($_POST['mode']) { - case 'bookmarklet': - $location = $_POST['referredby']; - break; - case 'sidebar': - $location = 'sidebar.php?a=b'; - break; - default: - $location = 'post-new.php'; - break; - } - } else { - $location = "post-new.php?posted=$post_ID"; - } - - if ( isset($_POST['save']) ) - $location = "post.php?action=edit&post=$post_ID"; - } else { - $referredby = ''; - if ( !empty($_POST['referredby']) ) - $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); - $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); - - if ($_POST['save']) { - $location = "post.php?action=edit&post=$post_ID"; - } elseif ($_POST['updatemeta']) { - $location = wp_get_referer() . '&message=2#postcustom'; - } elseif ($_POST['deletemeta']) { - $location = wp_get_referer() . '&message=3#postcustom'; - } elseif (!empty($referredby) && $referredby != $referer) { - $location = $_POST['referredby']; - if ( $_POST['referredby'] == 'redo' ) - $location = get_permalink( $post_ID ); - } elseif ($action == 'editattachment') { - $location = 'attachments.php'; - } else { - $location = 'post-new.php'; - } - } - - wp_redirect($location); // Send user on their way while we keep working + redirect_post($post_ID); // Send user on their way while we keep working exit(); break; diff --git a/wp-admin/profile-update.php b/wp-admin/profile-update.php deleted file mode 100644 index c74621b4..00000000 --- a/wp-admin/profile-update.php +++ /dev/null @@ -1,30 +0,0 @@ -get_error_messages() as $message ) - echo "$message
      "; - exit; -} - -do_action('personal_options_update'); - -if ( 'profile' == $_POST['from'] ) - $to = 'profile.php?updated=true'; -else - $to = 'profile.php?updated=true'; - -wp_redirect( $to ); -exit; - -?> diff --git a/wp-admin/profile.php b/wp-admin/profile.php index 1759e51a..685d46c1 100644 --- a/wp-admin/profile.php +++ b/wp-admin/profile.php @@ -1,150 +1,4 @@ - - -
      -

      -
      - - -
      -

      -
      - -

      - - -

      - -

      - - -

      - - - - -

      - -
      - -

      - -

      - -

      - -

      - -

      -
      - -
      - - -

      - -

      - -

      - -

      - -

      -

      -
      -
      -
      - -

      -

      -
      - - -
      - -

      -

      -

      -
      - - - - -
      - - - caps) > count($profileuser->roles)): - ?> - - - - - -
      caps as $cap => $value) { - if(!$wp_roles->is_role($cap)) { - if($output != '') $output .= ', '; - $output .= $value ? $cap : "Denied: {$cap}"; - } - } - echo $output; - ?>
      -

      -
      - -
      - - diff --git a/wp-admin/rtl.css b/wp-admin/rtl.css index 07612a66..196a9b09 100644 --- a/wp-admin/rtl.css +++ b/wp-admin/rtl.css @@ -1,133 +1,320 @@ -html, -.dbx-handle, -#post_name, -input[name=link_url], -input[name=link_image], -input[name=opml_url], -input[name=file], -input#rss_uri, -#template #newcontent, -#devnews, -#planetnews, -#content, -body.login #login a, -#newcomment_author_url, -#email { +html,#edit-slug-box,#trackback,#category_nicename,#slug,#dbuser,#dbpass,#dbname,#dbhost,#dbprefix,#dccharset,input[name=gmpath],input[name=archivespath],input[name=lastentry],input[name=email],input[name=url],input[name=aim],input[name=yim],input[name=jabber],#newcontent,#email,#newcomment_author_url,#pass1,#pass2,#siteurl,#home,#admin_email,#date_format,#time_format,#mailserver_url,#mailserver_login,#mailserver_pass,#ping_sites,#blog_charset,#moderation_keys,#blacklist_keys,#permalink_structure,#category_base,#tag_base,#upload_path,#upload_url_path,#insertonly[src],#insertonly[href],#mailserver_port,#thumbnail_size_w,#thumbnail_size_h,#medium_size_w,#medium_size_h,#posts_per_page,#posts_per_rss,#comment_max_links,#insertonly[src],#link_url,#link_image,#rss_uri,#user_login,#key +{ + direction:ltr; + text-align:left +} + +body, td { + font-family: Tahoma,Verdana,sans-serif; +} + +#wpwrap,#footer,#TB_title,.media-upload-form,#media-upload-header +{ + direction:rtl!important; + text-align:right!important +} + +#user_info +{ + left:15px; + right:auto +} + +#wphead h1 +{ + margin:0 0 0 15%; + padding:11px 15px 16px 170px +} + +#wphead #viewsite +{ + margin-left:0; + margin-right:10px +} + +#sidemenu +{ + float:left; + margin:-30px 315px 0 15px; + padding-left:0; + padding-right:10px +} + +#dashmenu +{ + font-size:11px; + left:auto; + padding-left:0; + padding-right:9px; + right:0 +} + +#dashmenu a +{ + margin-left:8px; + margin-right:8px; +} + +#adminmenu +{ + height:32px; + padding:5px 8px 0 0 +} + +#adminmenu li a +{ + display:block; + float:right; + font:700 16px/100% "Times New Roman", Times, serif; + margin:0 0 0 10px; + padding:5px 7px 9px +} + +#adminmenu li a.current +{ + font-weight:700 +} + +#adminmenu li a #awaiting-mod +{ + background:url(images/comment-stalk-rtl.gif) -309px bottom !important; + font-family: Tahoma, Verdana, sans-serif; + margin-left:-45px; + margin-right:.2em; + margin-top:-5px +} + +#adminmenu li a:hover #awaiting-mod +{ + background-position: -229px bottom !important; +} + +#adminmenu li a #awaiting-mod span +{ + left:0; + right:auto +} + +#submenu li a +{ + display:block; + float:right; + margin:0 10px 10px 0; + padding:2px 4px +} + +p#post-search +{ + left:0; + right:auto +} + +.tablenav div +{ + float:right!important +} + +.tablenav .delete +{ + margin-left: 40px; + margin-right: 0; +} + +ul.view-switch +{ + float:left; + margin:-28px 0 -2px 5px +} + +#currenttheme img +{ + float:right; + margin-left:1em; + margin-right:0 +} + +form#themeselector +{ + float:left +} + +.form-table input.tog +{ + float:right; + margin-right:0; + margin-left:2px; +} + +.curtime +{ + background-position:right 2px; + padding-left:0; + padding-right:18px; +} + +#poststuff #edButtonPreview,#poststuff #edButtonHTML +{ + float:left; + margin-left:8px; + margin-right:0 +} + +#poststuff #media-buttons +{ direction: ltr; - } -#adminmenu, -#submenu, -#minisub, -.wrap, -.updated, -.confirm, -#devnews h3, -#planetnews h3, -#wphead, -#user_info, -body.login, -#login_error { - direction: rtl; - } -p.submit, -.dbx-handle { - text-align: left; - } -html *, -select, -input, -table * { - font-family: tahoma, Tahoma, "Times New Roman", Times, serif; - } -#wphead { - padding: .8em 2em .8em 19em; - } -#user_info { - right: auto; - left: 1em; - } -#adminmenu { - padding: .2em 2em .3em .2em; - height: 28px; - } -* html #adminmenu { - padding-bottom: 0; - } -#adminmenu a { - margin: 0 0 0 10px; - display: block; - float: right; - font: 700 16px/130% "Times New Roman", Times, serif; - } -#adminmenu a.current { - border-right: 0; - border-left: 2px solid #4f96c8; - } -#submenu, #minisub { - padding: 1px 3em 0 2em; - } -#submenu { - height: 28px; - } -#submenu a { - margin: 0 0 0 10px; - display: block; + float:left; + margin-left:20px; + margin-right:0 +} + +#poststuff #media-buttons a +{ + margin-left:8px; + margin-right:0; + padding: 0 5px 2px 2px; +} + +#poststuff .togbox +{ + margin-left:0; + margin-right:-19px +} + +#categorydiv ul#category-tabs,#linkcategorydiv ul#category-tabs +{ + float:right; + margin:0 0 0 -120px; + text-align:left +} + +ul#category-tabs li.ui-tabs-selected,#poststuff .togbox +{ + -khtml-border-bottom-left-radius:0; + -khtml-border-bottom-right-radius:3px; + -khtml-border-top-left-radius:0; + -khtml-border-top-right-radius:3px; + -moz-border-radius-bottomleft:0; + -moz-border-radius-bottomright:3px; + -moz-border-radius-topleft:0; + -moz-border-radius-topright:3px; + -webkit-border-bottom-left-radius:0; + -webkit-border-bottom-right-radius:3px; + -webkit-border-top-left-radius:0; + -webkit-border-top-right-radius:3px; + border-bottom-left-radius:0; + border-bottom-right-radius:3px; + border-top-left-radius:0; + border-top-right-radius:3px +} + +div.ui-tabs-panel +{ + margin:0 120px 0 0 +} + +#tagchecklist span +{ + float:right; + margin-left:25px; + margin-right:0 +} + +#tagchecklist span a { + margin: 6px -9px 0 0; float: right; - line-height: 155%; - } -#submenu .current { - border-right: 0; - border-left: 2px solid #045290; - } -.dbx-content input, .dbx-content select { - margin-right: 8px; - } -#newcat { - width: 100px; - } -.updated, .confirm { - background-position: 98.5%; - padding: 0 3em 0 1em; - } -.page-numbers { - margin-right: auto; - margin-left: 3px; - } -.wrap ul { - margin-right: 45%; - margin-left: 0; - } -* html .wrap ul { - margin-right: 50%; - } +} + + +.tablenav .tablenav-pages +{ + float:left !important; + width:200px +} + +.tablenav-pages .page-numbers +{ + display:block; + float:right +} + +.side-info ul +{ + padding-left:0; + padding-right:18px +} + +.form-table table.color-palette { + float:right; +} + +#pass-strength-result +{ + float:right; + margin-right:0; + margin-left:5px; +} + +td.comment p.comment-author img.avatar +{ + float:right !important; + margin-right:0 !important; + margin-left:8px !important; +} + +#footer +{ + padding:10px 0 0 +} + +#footer p +{ + height:35px; + margin-right:20px; + padding:12px 40px 0 0; +} + +#submenu,#wpbody +{ + clear:both; +} + +#submenu li,ul.subsubsub li a +{ + padding:0; +} + +table.widefat th,.form-table th +{ + text-align:right +} + +.widefat th input { + margin: 0 8px 0 0; + padding: 0; +} + +.available-theme,#tagchecklist span a +{ + float:right +} +#template div { + margin-right:0; + margin-left:190px; +} +.submitbox .submit { + text-align:right; +} + +#editorcontainer { + border:1px solid; +} + .wrap h2 { - font-family: "Times New Roman", Times, serif; - } -#zeitgeist { - margin-right: 1em; - } -#zeitgeist ul { - margin: 0 .6em .3em 0; - padding: 0 .6em 0 0; - } -#categorydiv ul { - margin-left: auto; - margin-right: 10px; - } -a.view-link { - left: 6%; - right: auto; - margin-right: auto; - } -#postdiv #quicktags { - padding-right: 0; - padding-left: 6px; - margin-right: 0; - } -.options ul { - margin-right: 0; - } -*form#template > div > textarea#newcontent { - margin-right: -300px; - width: 107%; - } \ No newline at end of file + margin: 5px -4px 0 0; + padding-right: 0px; + padding-left: 280px; +} + +div#message { + clear: both; +} \ No newline at end of file diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php index b4dae209..e2c39147 100644 --- a/wp-admin/setup-config.php +++ b/wp-admin/setup-config.php @@ -1,5 +1,8 @@ -WordPress › Setup Configuration File -

      WordPress

      @@ -102,17 +55,18 @@ switch($step) {
    • Table prefix (if you want to run more than one WordPress in a single database)

If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open wp-config-sample.php in a text editor, fill in your information, and save it as wp-config.php.

-

In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready, let’s go!

+

In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…

+ +

Let’s go!

-

Below you should enter your database connection details. If you're not sure about these, contact your host.

- +
@@ -140,7 +94,7 @@ switch($step) {
Database Name

- +

error) ) wp_die($wpdb->error->get_error_message()); @@ -190,14 +144,15 @@ switch($step) { } fclose($handle); chmod('../wp-config.php', 0666); - + display_header(); ?> -

All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to run the install!

+

All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…

+ +

Run the install

- diff --git a/wp-admin/sidebar.php b/wp-admin/sidebar.php index 4b160aff..f04eb75d 100644 --- a/wp-admin/sidebar.php +++ b/wp-admin/sidebar.php @@ -11,13 +11,16 @@ if ('b' == $_GET['a']) { ?> -WordPress › Posted - +<?php _e('WordPress › Posted'); ?> + -

Posted !

-

Click here to post again.

+

+

Click here to post again.'), 'sidebar.php'); ?>

-WordPress › Sidebar - +<?php _e('WordPress › Sidebar'); ?> + - - $sidebar ) { - $cols[] = '\'' . $index . '\''; - } - $cols = implode( ', ', $cols ); +$title = __( 'Widgets' ); +$parent_file = 'themes.php'; - $widgets = array(); - foreach ( $wp_registered_widgets as $name => $widget ) { - $widgets[] = '\'' . $widget['id'] . '\''; - } - $widgets = implode( ', ', $widgets ); +// $sidebar = What sidebar are we editing? +if ( isset($_GET['sidebar']) && isset($wp_registered_sidebars[$_GET['sidebar']]) ) { + $sidebar = attribute_escape( $_GET['sidebar'] ); +} elseif ( is_array($wp_registered_sidebars) && !empty($wp_registered_sidebars) ) { + // By default we look at the first defined sidebar + $sidebar = array_shift( $keys = array_keys($wp_registered_sidebars) ); +} else { + // If no sidebars, die. + require_once( 'admin-header.php' ); ?> - + +
+

+
+ +
+

follow these instructions.' ); /* TODO: article on codex */; ?>

+
+ $control ) { + if ( in_array( $control['callback'], $already_done ) ) + continue; + + if ( is_callable( $control['callback'] ) ) { + call_user_func_array( $control['callback'], $control['params'] ); + $control_output = ob_get_contents(); + if ( false !== strpos( $control_output, '%i%' ) ) // if it's a multi-widget, only call control function once. + $already_done[] = $control['callback']; + } + + ob_clean(); + } + ob_end_clean(); - $sanitized_name = sanitize_title( $wp_registered_widgets[$name]['id'] ); - $link_title = __( 'Configure' ); - $popper = ( isset( $wp_registered_widget_controls[$name] ) ) - ? '
' - : ''; + // Prophylactic. Take out empty ids. + foreach ( (array) $_POST['widget-id'] as $key => $val ) + if ( !$val ) + unset($_POST['widget-id'][$key]); - $output = '
  • %2$s
  • '; + // Reset the key numbering and store + $new_sidebar = isset( $_POST['widget-id'] ) && is_array( $_POST['widget-id'] ) ? array_values( $_POST['widget-id'] ) : array(); + $sidebars_widgets[$_POST['sidebar']] = $new_sidebar; + wp_set_sidebars_widgets( $sidebars_widgets ); - printf( $output, $sanitized_name, $wp_registered_widgets[$name]['name'] . $popper ); + wp_redirect( add_query_arg( 'message', 'updated' ) ); + exit; } -$title = __( 'Widgets' ); -$parent_file = 'themes.php'; -require_once 'admin-header.php'; -if ( count( $wp_registered_sidebars ) < 1 ) { -?> -
    -

    -

    follow these instructions.' ); /* TODO: article on codex */; ?>

    -
    - +
    +

    +
    +
    + +
      +
    • +

      +
      + +
      + + + + + +
      +
      +
    • +
    +
    +
    + $sidebar_widget_count", $wp_registered_sidebars[$sidebar]['name'] ); - case 'save_widget_order' : - $sidebars_widgets = array(); +$page = isset($_GET['apage']) ? abs( (int) $_GET['apage'] ) : 1; - foreach ( $wp_registered_sidebars as $index => $sidebar ) { - $postindex = $index . 'order'; +/* TODO: Paginate widgets list +$page_links = paginate_links( array( + 'base' => add_query_arg( 'apage', '%#%' ), + 'format' => '', + 'total' => ceil(($total = 105 )/ 10), + 'current' => $page +)); +*/ +$page_links = ' '; - parse_str( $_POST[$postindex], $order ); +// Unsanitized! +$widget_search = isset($_GET['s']) ? $_GET['s'] : false; - $new_order = $order[$index]; +// Not entirely sure what all should be here +$show_values = array( + '' => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ), + 'unused' => __( 'Show unused widgets' ), + 'used' => __( 'Show used widgets' ) +); - if ( is_array( $new_order ) ) { - foreach ( $new_order as $sanitized_name ) { - foreach ( $wp_registered_widgets as $name => $widget ) { - if ( $sanitized_name == $widget['id'] ) { - $sidebars_widgets[$index][] = $name; - } - } - } - } - } +$show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false; - wp_set_sidebars_widgets( $sidebars_widgets ); - break; - } -} -ksort( $wp_registered_widgets ); +$messages = array( + 'updated' => __('Changes saved.') +); -$inactive_widgets = array(); +require_once( 'admin-header.php' ); -foreach ( $wp_registered_widgets as $name => $widget ) { - $is_active = false; +if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) : ?> - foreach ( $wp_registered_sidebars as $index => $sidebar ) { - if ( is_array( $sidebars_widgets[$index] ) && in_array( $name, $sidebars_widgets[$index] ) ) { - $is_active = true; - break; - } - } +

    - if ( !$is_active ) { - $inactive_widgets[] = $name; - } -} + -$containers = array( 'palette' ); +
    -foreach ( $wp_registered_sidebars as $index => $sidebar ) { - $containers[] = $index; -} +
    -$c_string = ''; +

    + -foreach ( $containers as $container ) { - $c_string .= '"' . $container . '",'; -} +
    +
    +

    + +
    +
    -$c_string = substr( $c_string, 0, -1 ); +
    +

    + + -if ( isset( $_POST['action'] ) ) { -?> -
    -

    View site »' ), get_bloginfo( 'url' ) . '/' ); ?>

    - -
    -

    -

    + -
    -

    - -

    -
    - $sidebar ) { - ?> - - -
    -

    - -
    - -

    - -
    -
    +
    -
      - -
    -
    - +
    + + + +
    +
    -
    -

    + -
      - -
    -
    +
    - - -

    - - - -

    + -
    - $widget ) { ?> - - -
    - +
    + +
    +
    + + + +
    -
    +

    + + + + +

    -
    + + +
    + + + +
    - + - diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index a3ecba2a..7a9283ca 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -1,210 +1,22 @@ -* html #poststuff { - height: 100%; /* kill peekaboo bug in IE */ -} - -/* This is the Holly Hack \*/ -* html .wrap { height: 1% } -/* For Win IE's eyes only */ - -body { - border: none; -} -a { - border-bottom: 1px solid #69c; - color: #00019b; - text-decoration: none; -} - -a.delete:hover { - background: #c00; - color: #fff; -} - -#devnews h4 { - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 18px; - font-weight: normal; -} - -#planetnews ul { - list-style: none; - margin: 0; - padding: 0; -} - -#planetnews li { - width: 17%; - margin: 1%; - float: left; -} - -#planetnews li a { - display: block; - padding: .5em; - background: #ddd; - height: 6em; - overflow: hidden; -} - -#planetnews cite { - font-size: 11px; -} - -#planetnews li .post { - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 18px; - display: block; - height: 60px; - overflow: hidden; -} - -#planetnews .hidden { - display: none; -} - -.readmore { - clear: both; - text-align: right; - margin-right: 5em; -} - -.widefat { - width: 100%; -} - -.widefat td, .widefat th { - padding: 5px 6px; -} - -.widefat th { - text-align: left; +#plugins .name { + font-weight: bold; } -.plugins p { - margin: 4px; +#plugins p { + margin: 0 4px; padding: 0; } -.plugins .name { - font-size: 16px; +#plugins .togl { + width: 150px; + border-right-width: 1px; + border-right-style: solid; } .import-system { font-size: 16px; } -thead, .thead { - background: #dfdfdf -} - -#import-upload-form { - margin: auto; - background: #eee; - padding: 1em; -} - -a.view, a.edit, a.delete, a.view:hover, a.edit:hover, a.delete:hover { - border-bottom: none; - display: block; - padding: 5px 0; - text-align: center; -} - -a.view:hover, a.edit:hover { - background: #ccc; - color: #036; -} - -a:visited { - color: #004; -} - -a:hover { - color: #069; -} - -body { - background: #f9fcfe; - color: #000; - margin: 0; - padding: 0; -} - -body, td { - font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; -} - -fieldset { - border: none; - padding: 3px; -} - -fieldset label.selectit { - display: block; - font-size: 11px; - padding: 0 2px; -} - -fieldset label.selectit:hover { - background: #e9e9e9; -} - -fieldset legend { - padding: .1em .3em; -} - -fieldset.options { - padding: 1em; -} - -fieldset.options legend { - font-size: 1.5em; - font-weight: bold; - font-family: Georgia, "Times New Roman", Times, serif; -} - -form, label input { - margin: 0; - padding: 0; -} - -h2 { - color: #333; - font: normal 32px Georgia, "Times New Roman", Times, serif; - margin: 5px 10px; - background: url( images/heading-bg.gif ) repeat-x bottom; -} - -img { - border: 0; -} - -input:focus, textarea:focus, label:focus { - background: #fff; - border: 1px solid #686868; -} - -label { - cursor: pointer; -} - -li, dd { - margin-bottom: 6px; -} - -p, li, dl, dd, dt { - line-height: 140%; -} - -textarea, input, select { - background: #f4f4f4; - border: 1px solid #b2b2b2; - color: #000; - font: 13px Verdana, Arial, Helvetica, sans-serif; - margin: 1px; - padding: 3px; -} - #uploading { border-style: none; padding: 0; @@ -221,6 +33,12 @@ form#upload #post_content, form#upload #post_title { width: 250px; } +.form-invalid input { + border-width: 1px !important; + border-style: solid !important; +} + + form#upload #post_content { height: 50px; } @@ -230,18 +48,6 @@ form#upload #post_content { text-align: center; } -.alignleft { - float: left -} - -.alignright { - float: right; -} - -.alternate { - background: #f1f1f1; -} - .anchors { margin: 10px 20px 10px 20px; } @@ -260,14 +66,10 @@ form#upload #post_content { height: 200px; display: block; margin: auto; - background: #f1f1f1; - border: 1px solid #ccc; margin-bottom: 10px; overflow: hidden; -} - -.available-theme a.screenshot:hover { -/* border: 1px solid #666;*/ + border-width: 1px; + border-style: solid; } .available-theme img { @@ -275,7 +77,6 @@ form#upload #post_content { } .checkbox { - background: #fff; border: none; margin: 0; padding: 0; @@ -286,9 +87,10 @@ form#upload #post_content { } .commentlist li { - border-bottom: 1px solid #ccc; padding: 1em 1em .2em; margin: 0; + border-bottom-width: 1px; + border-bottom-style: solid; } .commentlist li li { @@ -301,95 +103,81 @@ form#upload #post_content { margin: 0 0 .8em; } -.clear { - clear: both; - height: 2px; -} - -.hidden { - display: none; -} - -.navigation { - display: block; - text-align: center; - margin-top: 10px; - margin-bottom: 30px; -} - .post-categories { display: inline; margin: 0; padding: 0; } -.post-categories li, #ed_toolbar { +.post-categories li { display: inline; } .quicktags, .search { - background: #ccc; - color: #000; font: 12px Georgia, "Times New Roman", Times, serif; } -.submit input, .submit input:focus, .button, .button:focus { - background: url( images/fade-butt.png ); - border: 3px double #999; - border-left-color: #ccc; - border-top-color: #ccc; - color: #333; - padding: 0.25em; -} - -.submit input:active, .button:active { - background: #f4f4f4; - border: 3px double #ccc; - border-left-color: #999; - border-top-color: #999; -} - -.button, .button:focus { - padding: 0.15em; -} - -* html .button { - padding: 0; -} - -.submit, .editform th, #postcustomsubmit { - text-align: right; -} - -.optiontable { - width: 100%; +.submit { + border-top: 1px solid #ccc; + padding: 1.5em 0 0 0; + margin: 10px 0 0 0; + -moz-border-radius-bottomleft: 3px; + -khtml-border-bottom-left-radius: 3px; + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; + -moz-border-radius-bottomright: 3px; + -khtml-border-bottom-right-radius: 3px; + -webkit-border-bottom-right-radius: 3px; + border-bottom-right-radius: 3px; +} + +.side-info { + margin: 0; + padding: 4px; + font-size: 11px; } -.optiontable td, .optiontable th { - padding: .5em; +.side-info h5 { + padding-bottom: 7px; + font-size: 14px; + margin: 12px 2px 5px; + border-bottom-width: 1px; + border-bottom-style: solid; } -.optiontable th { - width: 33%; - text-align: right; - font-size: 1.3em; - font-weight: normal; +.side-info ul { + margin: 0; + padding-left: 18px; + list-style: square; } -.unapproved { - color: #888; +.submit input, .button, .button-secondary, .button-highlighted { + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 3px 5px; + font-size: 12px; + line-height: 1.5em; + border-width: 1px; + border-style: solid; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + cursor: pointer; + text-decoration: none; } -.unapproved a:link { - color: #b9bcff; +.button-highlighted { + font-weight: bold; } -.unapproved a:visited { - color: #696dff; -} +#wpcontent select { + font: 12px/20px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 2px; -.unapproved a:hover { - color: #009ef0; + border-width: 1px; + border-style: solid; + height: 2em; + vertical-align:top; } .approve { @@ -400,49 +188,25 @@ form#upload #post_content { display: inline; } -.unapproved .unapprove { - display: none; -} - -.updated, .confirm { - background: #CFEBF7 url(images/notice.gif) no-repeat 1em; - border: 1px solid #2580B2; - margin: 1em 5% 10px; - padding: 0 1em 0 3em; +.updated a { + border-bottom-width: 1px; + border-bottom-style: solid; } -.error { - background: #FFEFF7; - border: 1px solid #c69; - margin: 1em 5% 10px; - padding: 0 1em 0 1em; -} -.wrap { - background: #fff; - border: 1px solid #ccc; - clear: both; - margin: 15px 5%; - padding: 1em; +.unapproved .unapprove { + display: none; } .narrow { - width: 450px; - margin: auto; + width: 70%; + margin-bottom: 40px; } .narrow p { line-height: 150%; } -.wrap h2 { - margin: 0 0 .5em; - clear: both; -} - -* html .wrap h2 { - margin-top: 1em; -} table .vers { text-align: center; @@ -452,96 +216,15 @@ textarea.all-options, input.all-options { width: 250px; } -input.disabled, textarea.disabled { - background: #ccc; -} - -#adminmenu { - background: #83B4D8; - border-top: 3px solid #448abd; - margin: 0; - padding: .2em .2em .3em 2em; -} - -#adminmenu .current, #submenu .current { - font-weight: bold; - text-decoration: none; -} - -#adminmenu a { - color: #000; - font-size: 14px; - font-weight: normal; - margin: 0; - padding: 3px 5px; - border-bottom: none; -} - -#adminmenu a:hover, #adminmenu a.current { - background: #ddeaf4; - color: #333; -} - -#adminmenu li, #submenu li { - display: inline; - line-height: 200%; - list-style: none; - text-align: center; - white-space: nowrap; -} - -#adminmenu a.current { - background: #0d324f; - border-right: 2px solid #4f96c8; - border-top: 1px solid #96c0de; - color: #fff; - padding-bottom: 8px; -} - -#submenu, #minisub { - background: #0d324f; - border-bottom: none; - margin: 0; - padding: 3px 2em 0 3em; -} - -#minisub { - height: 6px; -} - -#submenu .current { - background: #f9fcfe; - border-top: 1px solid #045290; - border-right: 2px solid #045290; - color: #000; -} - -#submenu a { - border: none; - color: #fff; - font-size: 12px; - padding: .3em .4em .4em; -} - -#submenu a:hover { - background: #ddeaf4; - color: #393939; -} - -#submenu li { - line-height: 180%; - height: 25px; -} - -#categorydiv input, #poststatusdiv input, #commentstatusdiv input, #pingstatusdiv input { - border: none; -} - -#postdiv, #titlediv, #guiddiv, #tagdiv { +#postdiv, #titlediv, #guiddiv, #poststuff .stuffbox { margin: 0 8px 0 0; padding: 0; } +#titlediv, #namediv, #poststuff #namediv { + margin-top: 10px; +} + #postdivrich { margin: 0; padding: 0; @@ -552,56 +235,43 @@ input.disabled, textarea.disabled { width: 100%; } -#postdivrich #content { - padding: 5px; - line-height: 140%; +#editorcontainer #content { + padding: 0; + line-height: 150%; + border: 0 none; + outline: none; } -#titlediv input, #guiddiv input, #tagdiv input { - margin: 0; - width: 100%; +#editorcontainer { + padding: 6px; + border-style: none solid solid; + border-width: 1px; + border-collapse: separate; } #currenttheme img { float: left; - border: 1px solid #666; margin-right: 1em; margin-bottom: 1.5em; width: 300px; + border-width: 1px; + border-style: solid; } -input.delete:hover { - background: #ce0000; - color: #fff; -} - -#deletebookmarks:hover { - background: #ce0000; - color: #fff; -} - -#postdivrich #quicktags { - background: #f0f0ee; +#quicktags { padding: 0; - border: 1px solid #ccc; - border-bottom: none; -} - -#postdiv #quicktags { - padding-right: 6px; -} - -#postdivrich #quicktags { - display: none; + border: 0 none; } #quicktags #ed_toolbar { - padding: 0 2px; + padding: 2px 4px; } #ed_toolbar input { - background: #fff url( images/fade-butt.png ) repeat-x 0 -2px; margin: 3px 2px 2px; + padding: 2px 4px; + line-height: 18px; + display: inline-block; } #quicktags #ed_strong { @@ -609,7 +279,6 @@ input.delete:hover { } #quicktags #ed_link { - color: blue; text-decoration: underline; } @@ -623,17 +292,10 @@ input.delete:hover { #quicktags #ed_code { font-family: "Courier New", Courier, mono; - margin-bottom: 3px; -} - -#title { - font-size: 1.7em; - padding: 4px 3px; + font-size: 1.1em; + vertical-align: top; } -#postexcerpt div, #attachmentlinks div { - margin-right: 8px; -} #attachmentlinks textarea { width: 100%; @@ -641,710 +303,1164 @@ input.delete:hover { margin-bottom: 6px; } -* html #postexcerpt .dbx-toggle-open, * html #postexcerpt .dbx-toggle-open { - padding-right: 8px; -} - #excerpt, .attachmentlinks { margin: 0; height: 4em; + width: 98%; +} + +.plugins p { +} + +#login .fullwidth { + width: 320px; +} + +#searchform fieldset { + float: left; + margin: 0 1.5ex 1em 0; + padding: 0; +} + +#searchform fieldset legend { + padding: 0 0 .2em 1px; +} + +#searchform #s { + padding: 4px 3px; +} + +#searchform #post-query-submit { + float: left; + margin: 14px 0 1em; + position: relative; + top: .35em; +} + +#postcustomstuff .updatemeta, #postcustomstuff .deletemeta { + margin: auto; +} + +#postcustomstuff table { + margin: 0; width: 100%; + border-width: 1px; + border-style: solid; } -#footer { - clear: both; - height: 35px; - padding-left: 40px; - margin: 15px 5%; - background: url('images/logo-ghost.png') no-repeat top left; +#postcustomstuff table input, #postcustomstuff table textarea { + width: 95%; } -#footer p { +#postcustomstuff table #addmetasub { + width: auto; +} + +#poststuff #post-body { + margin-right: 230px; +} + +#save { + width: 15em; +} + +#template div { + margin-right: 190px; +} + +* html #template div { + margin-right: 0; +} + +#template, #template div, #editcat, #addcat { + zoom: 1; +} + +/* A handy div class for hiding controls. +Some browsers will disable them when you +set display:none; */ +.zerosize { + height: 0; + width: 0; margin: 0; - padding: 5px 0; + border: 0; + padding: 0; + overflow: hidden; + position: absolute; } -#login { - position: relative; - background: url('images/login-bkg-tile.gif') no-repeat top center; - color: #fff; - margin: 5em auto 1em; - padding: 20px 0 0; - width: 425px; - _width: 390px; -} - -#login form { - background: url('images/login-bkg-bottom.gif') no-repeat bottom center; - padding: 0 50px 25px; - _width: 325px; - _margin: 0 auto; - min-height: 200px; - height: auto !important; /* min-height fast hack */ - height: 200px; +* html #themeselect { + padding: 0 3px; + height: 22px; +} + +#your-profile fieldset { + border-width: 1px; + border-style: solid; + float: left; + width: 40%; + padding: .5em 2em 1em; + margin: 1em 1em 1em 0; } -#login #login_error { - background: #0e3350; - border: 1px solid #2571ab; - color: #ebcd4e; +#your-profile fieldset input { + width: 100%; + font-size: 20px; + padding: 2px; +} + +#your-profile fieldset textarea { + width: 100%; + padding: 2px; +} + +#your-profile legend { + font-family: Georgia, "Times New Roman", Times, serif; + font-size: 22px; +} + +#your-profile #rich_editing { + border: none; +} + +#howto { font-size: 11px; + margin: 0 5px; + display: block; +} + +#ajax-response.alignleft { + margin-left: 2em; +} + + +div.nav { + height: 2em; + padding: 7px 10px; + vertical-align: text-top; + margin: 5px 0; +} + +.nav .button-secondary { + padding: 2px 4px; +} + +.page-numbers { + padding: 2px 4px; + margin-right: 3px; + border-width: 1px; + border-style: solid; +} + +.page-numbers.current { font-weight: bold; - padding: .6em; - width: 310px; - margin: 0 50px; - text-align: center; + border-width: 1px; + border-style: solid; } -#login p { - font-size: 12px; +p.pagenav { + margin: 0; + display: inline; } -#login p.message { - width: 310px; - margin: 0 auto 1em; +.pagenav span { + font-weight: bold; + margin: 0 6px; } -#login #login_error a { - color: #ebcd4e; - border-color: #ebcd4e; +.row-title { + font-size: 12px !important; + font-weight: bold; } -#login #send { - color: #fff; - text-align: left; - font-weight: normal; - font-size: 1.1em; - _width: 325px; - _margin: 0 auto 15px; +.comment-column { + margin-left: 5px; } -#login h1 a { - margin: 0 auto; - height: 88px; - width: 320px; +.tablenav a.button-secondary { display: block; - border-bottom: none; - text-indent: -9999px; + margin: 1px 8px 0 0; +} + +.tablenav .button-secondary { + padding: 2px 4px; + vertical-align: top; } -#login .message { - font-size: 10pt; +.tablenav .tablenav-pages a.next, .tablenav .tablenav-pages a.prev { + text-decoration: underline; +} + +.tablenav { + height: 2em; + padding: 7px 10px; + clear: both; + margin-bottom: -10px; + margin-top: 8px; + vertical-align: text-top; +} + +.tablenav .tablenav-pages { + float: right; + height: 18px; + padding-top: 6px; + font-size: 11px; +} + +.tablenav .tablenav-pages a { + text-decoration: none; +} + +td.media-icon { + vertical-align: middle; text-align: center; } -#login .register { - font-size: 20px; +td.media-icon img { + max-width: 80px; + max-height: 60px; } -#login input { - padding: 4px; +#update-nag, .plugin-update { + line-height: 29px; + font-size: 12px; + text-align: center; + border-bottom-width: 1px; + border-bottom-style: solid; + border-top-width: 1px; + border-top-style: solid; } -.login ul, #protected #login .bottom { - list-style: none; - width: 325px; - margin: 0 auto; - padding: 0; - line-height: 1.2; +#update-nag a, .plugin-update a { + font-size: 1.1em; +} + +#pass-strength-result { + padding: 3px 5px 3px 5px; + margin-top: 3px; + text-align: center; + border-width: 1px; + border-style: solid; } -.login ul li { +a.view-comment-post-link { + position: absolute; + text-decoration:underline; +} + +/* Admin Header */ + +#user_info { + position: absolute; + right: 15px; + top: 11px; font-size: 11px; } -.login ul li a { - color: #0d324f; - border: none; +#user_info p { + margin: 0; + padding: 0; } -#login ul li a:hover { - color: #fff; +#wphead { + border-top-width: 30px; + border-top-style: solid; } -#login .input { - font-size: 1.8em; - margin-top: 3px; - width: 97%; +#wphead a, #dashmenu a, #adminmenu a, #submenu a, #sidemenu a { + text-decoration: none; +} + +#wphead #viewsite { + position: absolute; + margin-top: 12px; + margin-left: 10px; +} +#wphead #viewsite a { + font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 3px 4px; + display: block; + letter-spacing: normal; + border-width: 1px; + border-style: solid; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +#wphead h1 { + font: normal 36px Georgia, "Times New Roman", Times, serif; + padding: 11px 170px 16px 12px; + margin: 0; + margin-right: 15%; } -#login p label { +/* menu stuff */ + +#dashmenu { + margin: 0; + list-style: none; + position: absolute; + top: 7px; + left: 0; font-size: 11px; + padding-left: 9px; +} + +#dashmenu a { + padding: 5px 6px; + line-height: 220%; + margin-right: 8px; +} + +#dashmenu a.current { + border: none; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-topright: 3px; + -khtml-border-top-right-radius: 3px; + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; } -#login #submit { +#adminmenu { margin: 0; - font-size: 15px; + list-style: none; + padding-left: 11px; + border-bottom-width: 1px; + border-bottom-style: solid; } -.plugins p { +#adminmenu a { + font-size: 16px; + padding: 5px 7px; + line-height: 30px; } -#login .fullwidth { - width: 320px; +#adminmenu a.current, #sidemenu a.current { + font-weight: normal; + padding-left: 6px; + padding-right: 6px; + -moz-border-radius-topleft: 4px; + -khtml-border-top-left-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topright: 4px; + -khtml-border-top-right-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + border-width: 1px; + border-style: solid; } -#searchform fieldset { +#adminmenu a.current { + border-bottom-width: 2px; +} + +#sidemenu { + margin: -30px 15px 0 315px; + list-style: none; + position: relative; + float: right; + padding-left: 10px; + font-size:12px; +} + +#sidemenu a { + padding: 0 7px; + display: block; float: left; - margin: 0 1.5ex 1em 0; + line-height: 28px; + border-top-width: 1px; + border-top-style: solid; + border-bottom-width: 1px; + border-bottom-style: solid; +} + +#dashmenu li, #adminmenu li, #submenu li, #sidemenu li { + display: inline; + line-height: 200%; + list-style: none; + text-align: center; + white-space: nowrap; + margin: 0; padding: 0; } -#searchform fieldset legend { - padding: 0 0 .2em 1px; +#submenu li { + padding: 0 0 8px 17px; } - -#searchform #s { - padding: 4px 3px; + +#adminmenu li a #awaiting-mod { + position: absolute; + margin-left: -0.4em; + margin-top: 0.2em; + font-size: 0.7em; + background-repeat: no-repeat; + background-position: 0 bottom; + height: 0.9em; + width: 1em; } -#searchform #post-query-submit { - float: left; - margin: 14px 0 1em; - position: relative; - top: .35em; +#adminmenu li a .count-0 { + display: none; } -#postcustom .updatemeta, #postcustom .deletemeta { - margin: auto; +.post-com-count-wrapper { + min-width: 22px; +} + +.post-com-count { + height: 1.3em; + line-height: 1.1em; + display: block; + text-decoration: none; + padding: 0 0 6px; + cursor: pointer; + background-position: center -80px; + background-repeat: no-repeat; +} + +.post-com-count span { + height: 1.3em; + line-height: 1.2em; + padding: 0 0.5em; + background-color: #bbb; + display: inline-block; + cursor: pointer; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +strong .post-com-count { + background-position: center -55px; +} + +.post-com-count:hover { + background-position: center -3px; +} + +#adminmenu li a:hover #awaiting-mod { + background-position: -80px bottom; +} + +#adminmenu li a #awaiting-mod span { + top: -0.8em; + right: 0; + position: absolute; + display: block; + height: 1.3em; + line-height: 1.3em; + padding: 0 0.6em; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +#submenu { + margin: 0; + list-style: none; + padding: 6px 0 3px 0; +} + +#submenu li { + font-size: 14px; +} + +#minisub { /* for empty submenus */ + height: 15px; } -#postcustom table { - border: 1px solid #ccc; +/* end menu stuff */ + +/* Admin Footer */ + +html, body { + height:100%; +} +#wpwrap { + position: relative; + min-height: 100%; +} +#wpcontent{ + padding-bottom: 95px; +} +#footer { + clear: both; + height: 65px; + padding: 10px 0 0 60px; margin: 0; + position: relative; + margin-top: -75px; + font-size: 12px; +} + +#footer p { + margin: 0; + padding: 7px 0; +} + +#footer p a { + text-decoration: none; +} + +#footer p a:hover { + text-decoration: underline; +} + +/* Tables used on comment.php and option/setting pages */ + +.form-table { + border-collapse: collapse; + margin-top: 1em; width: 100%; + margin-bottom: -8px; } -#postcustom table input, #postcustom table textarea { - width: 95%; +.form-table td { + margin-bottom: 9px; + padding: 10px; + line-height: 20px; + border-bottom-width: 8px; + border-bottom-style: solid; + font-size: 11px; } -#poststuff { - margin-right: 16em; +.form-table th { + vertical-align: top; + text-align: left; + padding: 10px; + width: 150px; + border-bottom-width: 8px; + border-bottom-style: solid; } -#save { - width: 15em; +.form-table th.th-full { + width: auto; } -#template div { - margin-right: 190px; +.form-table input, .form-table textarea { + border-width: 1px; + border-style: solid; +} + +.form-table div.color-option { + display: block; + clear: both; +} + +.form-table input.tog { + margin-top: 2px; + margin-right: 2px; + float: left; +} + +.form-table table.color-palette { + vertical-align: bottom; + float: left; + margin: -3px 3px 8px; +} + +.form-table .color-palette td { + border-bottom: none; + border: 1px solid #fff; + font-size: 1px; + line-height: 1px; +} + +#profile-page .form-table textarea { + width: 500px; + margin-bottom: 6px; +} + +#profile-page .form-table input[type=text] { + width: 300px; +} + +#pass-strength-result { + width: 197px; + float: left; + margin-right: 5px; + border: 1px solid #ccc !important; +} + +#profile-page .form-table #rich_editing { + margin-right: 5px +} + +/* Post Screen */ + +#tagsdiv #newtag { + margin-right: 5px; + width: 16em; } -* html #template div { - margin-right: 0; +#tagchecklist { + margin-left: 10px; + + font-size: 12px; + overflow: auto; } -#template, #template div, #editcat, #addcat { - zoom: 1; +#tagchecklist strong { + margin-left: -8px; + position: absolute; } -#template textarea { - font: small 'Courier New', Courier, monospace; - width: 97%; +#tagchecklist span { + margin-right: 25px; + display: block; + float: left; + font-size: 11px; + line-height: 1.8em; + white-space: nowrap; + cursor: default; } -#templateside { - float: right; - width: 170px; +#tagchecklist span a { + margin: 6px 0pt 0pt -9px; + cursor: pointer; + width: 10px; + height: 10px; + display: block; + float: left; + text-indent: -9999px; overflow: hidden; + position: absolute; } -#templateside h3, #postcustom p.submit { - margin: 0; +.howto { + font-style: italic; + display: block; } -#templateside ol, #templateside ul { - list-style: none; - margin: .5em; +.ac_results { padding: 0; -} - -#user_info { + margin: 0; + list-style: none; position: absolute; - right: 1em; - top: 0; - color: #fff; - font-size: .9em; + z-index: 10000; + display: none; + border-width: 1px; + border-style: solid; } -#user_info a { - color: #fff; +.ac_results li { + padding: 2px 5px; + white-space: nowrap; + text-align: left; } -#wphead { - background: #14568a; - padding: .8em 19em .8em 2em; - color: #c3def1; +.ac_over { + cursor: pointer; } -#wphead a { - color: #fff; +.ac_match { + text-decoration: underline; } -#wphead h1 { - font-size: 2.5em; - font-weight: normal; - letter-spacing: -.05em; - margin: 0; - font-family: Georgia, "Times New Roman", Times, serif; +#poststuff h2 { + margin-top: 20px; + font-size: 1.5em; + margin-bottom: 15px; + padding: 0 0 3px; } -#wphead h1 span#viewsite { - font-size: .4em; - letter-spacing: 0; +#poststuff h3 { + font-size: 14px; + font-weight: bold; + padding: 7px; + margin: 0 0 10px; } -#zeitgeist { - background: #eee; - border: 1px solid #c5c5c5; - float: right; - font-size: 90%; - margin-bottom: .5em; - margin-left: 1em; - margin-top: .5em; - padding: 1em; - width: 40%; +#poststuff .postbox, #poststuff .stuffbox { + margin-left: 20px; + padding: 2px; + margin-bottom: 20px; + margin-right: 8px; + border-width: 1px; + border-style: solid; } -#zeitgeist h2, fieldset legend a { - background: none; +#titlediv, #poststuff .postarea { + margin-left: 20px; + margin-bottom: 20px; + margin-right: 8px; } -* html #zeitgeist h2 { - padding-top: 10px; +#titlediv { + margin-bottom: 20px; } -#zeitgeist h3 { - border-bottom: 1px solid #ccc; - font-size: 16px; - margin: 1em 0 0; +#titlediv div.inside { + margin: 0; } -#zeitgeist h3 cite { - font-size: 12px; - font-style: normal; +#titlediv #title { + border: 0; + padding: 0; + font-size: 1.7em; + width: 100%; + outline: none; } -#zeitgeist li, #zeitgeist p { - margin: .2em 0; +#poststuff #titlewrap { + padding: 2px 3px; + border-width: 1px; + border-style: solid; } -#zeitgeist ul { - margin: 0 0 .3em .6em; - padding: 0 0 0 .6em; +#poststuff .inside { + margin: 0 12px 12px; + font-size: 11px; } -.active td { - background: #BEB; +#link_name, #link_url, #link_description { + font-size: 1.7em; + padding: 4px 3px; + width: 98%; } -.active .name { - background: #9C9; + +#edit-slug-box { + margin-top: 8px; } -.alternate.active td { - background: #ADA; + +#editable-post-name-full {display: none;} + +#editable-post-name input {width: 16em;} + +#edit-slug-buttons a.save { + padding: 6px 4px; + margin-right: 4px; + text-decoration: none; + border-width: 1px; + border-style: solid; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + font-weight: bold; } -.alternate.active .name { - background: #8B8; + +#poststuff #editor-toolbar { + position: relative; + height: 30px; + margin-top: -41px; } -#namediv, #emaildiv, #uridiv { - float: left; +#poststuff #edButtonPreview, #poststuff #edButtonHTML { + display: block; + height: 20px; + padding: 5px 5px 1px; + margin: 5px 8px 0 0; + float: right; + cursor: pointer; } -#ajax-response { - padding: .5em; +#poststuff #editor-toolbar .active { + font-weight: bold; + -moz-border-radius-topright: 3px; + -khtml-border-top-right-radius: 3px; + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; } -/* A handy div class for hiding controls. -Some browsers will disable them when you -set display:none; */ -.zerosize { - height: 0; - width: 0; - margin: 0; - border: 0; - padding: 0; - overflow: hidden; - position: absolute; +#poststuff #media-buttons { + float: right; + margin-right: 20px; + margin-top: 8px; + cursor: default; + line-height: 1; + height: 1.1em; } -/* Box stuff */ -.dbx-clone { - position: absolute; - visibility: hidden; +#poststuff #media-buttons a { + cursor: pointer; + padding: 0 5px 2px 2px; } -.dbx-clone, .dbx-clone .dbx-handle-cursor { - cursor: move !important; + +#poststuff #media-buttons img { + vertical-align: middle; } -.dbx-dummy { + +#poststuff .togbox { + background-position: -10px 16px; + background-repeat: no-repeat; display: block; - width: 0; - height: 0; + height: 37px; + margin-left: -21px; + margin-top: -10px; overflow: hidden; -} -.dbx-group, .dbx-box, .dbx-handle { - position: relative; - display: block; + position: absolute; + text-indent: -9999px; + width: 12px; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-bottomleft: 3px; + -khtml-border-bottom-left-radius: 3px; + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; +} + +#poststuff .closed .inside { + display: none; } -#grabit { - width: 188px; +#poststuff .closed h3 { + margin: 0; } -* html #themeselect { - padding: 0 3px; - height: 22px; +#poststuff .closed .togbox { + background-position: 4px 15px; } -/**************************************************************** -avoid padding, margins or borders on dbx-box, -to reduce visual discrepancies between it and the clone. -overall, dbx-box is best left as visually unstyled as possible -*****************************************************************/ -.dbx-box { - margin: 0; - padding: 0; - border: none; +.submitbox { + width: 220px; + float: right; } -/* Can change this */ -#moremeta fieldset, #advancedstuff fieldset { - margin-bottom: 1em; -} -#moremeta fieldset div { - margin: 2px 0 0 0; - padding: 7px; -} -#moremeta { - line-height: 130%; - margin-right: 15px; - position: absolute; - right: 5%; - width: 14.5em; +.submitbox .inside strong { + font-size: 14px; } -#moremeta select { - width: 96%; + +.submitbox .submitdelete { + border-bottom-width: 1px; + border-bottom-style: solid; + text-decoration: none; + margin-left: 8px; + padding-bottom: 1px; } -#slugdiv input, #passworddiv input, #authordiv select, #thumbdiv input, #parentdiv input { - margin-top: .5em; - width: 90%; + +.submitbox #previewview { + padding: 15px 10px; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-topright: 3px; + -khtml-border-top-right-radius: 3px; + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; } -#moremeta h3, #advancedstuff h3 { - padding: 3px; +.submitbox #previewview a { + padding: 6px; + text-decoration: none; font-weight: normal; - font-size: 13px; + border-bottom: none; + font-size: 14px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; } -#advancedstuff div { - margin-top: .5em; +.submitbox .submit { + text-align: left; + padding: 12px 10px 10px 10px; + font-size: 11px; } -#categorydiv ul { - list-style: none; - padding: 0; - margin-left: 10px; +.submitbox .submit a:hover { + border-bottom-width: 1px; + border-bottom-style: solid; } -#categorychecklist { - height: 12em; - overflow: auto; - margin-top: 8px; +.submitbox .submit input { + margin-bottom: 8px; + margin-right: 3px; + padding: 6px 4px; + border: none; } -#categorychecklist li { - margin: 0; - padding: 0; +.submitbox #autosave .error { + margin-top: 10px; } -#ajaxcat input { - border: 1px solid #ccc; -} +/* Categories */ -#your-profile #rich_editing { - border: none; - background: #fff; +#categorydiv #category-adder { + margin-left: 120px; + padding: 4px 0; } -#your-profile fieldset { - border: 1px solid #ccc; - float: left; - width: 40%; - padding: .5em 2em 1em; - margin: 1em 1em 1em 0; +#category-add input, #category-add select { + width: 30%; } -#your-profile fieldset input { - width: 100%; - font-size: 20px; - padding: 2px; +#category-add input#category-add-sumbit { + width: auto; } -#your-profile fieldset textarea { - width: 100%; - padding: 2px; +#categorydiv ul#category-tabs { + float: left; + width: 120px; + text-align: right; + /* Negative margin for the sake of those without JS: all tabs display */ + margin: 0 -120px 0 0; + padding: 0; } -#your-profile legend { - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 22px; +ul#category-tabs li { + padding: 8px; } -/* default box styles */ - -/* toggle state of inner content area */ -.dbx-box-open .dbx-content { - display: block; -} -.dbx-box-closed .dbx-content { - display: none; +ul#category-tabs li.ui-tabs-selected { + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-bottomleft: 3px; + -khtml-border-bottom-left-radius: 3px; + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; } -#moremeta .dbx-content { - background: url(images/box-butt.gif) no-repeat bottom right; - padding-bottom: 15px; - padding-right: 2px; +ul#category-tabs li.ui-tabs-selected a { + color: #333; + font-weight: bold; + text-decoration: none; } -#moremeta fieldset.dbx-box-closed { - background: url(images/box-butt.gif) no-repeat bottom; - padding-bottom: 9px; +div.ui-tabs-panel { + margin: 0 5px 0 120px; + padding: .5em .9em; + height: 10em; + overflow: auto; + border-width: 4px; + border-style: solid; } -/* handles */ - -.dbx-handle { - background: #2685af; - padding: 6px 1em 2px; - font-size: 12px; +#categorydiv ul { + list-style: none; + padding: 0; margin: 0; - color: #E3EFF5; } -#moremeta .dbx-handle { - padding: 6px 1em 2px; - font-size: 12px; - background: #2685af url(images/box-head.gif) no-repeat right; +#categorydiv ul.categorychecklist ul { + margin-left: 18px; } -#moremeta .dbx-box { - background: url(images/box-bg.gif) repeat-y right; +ul.categorychecklist li { + margin: 0; + padding: 0; + line-height: 19px; } -#advancedstuff h3.dbx-handle { - margin-left: 7px; - margin-bottom: -7px; - padding: 6px 1em 0 3px; - height: 19px; - font-size: 12px; - background: #2685af url(images/box-head-right.gif) no-repeat top right; +#linkcategorydiv #category-adder { + margin-left: 120px; + padding: 4px 0; } -#advancedstuff div.dbx-h-andle-wrapper { - margin: 0 0 0 -7px; - background: #fff url(images/box-head-left.gif) no-repeat top left; +#category-adder h4 { + margin: 0; } -#advancedstuff div.dbx-content { - margin-left: 8px; - background: url(images/box-bg-right.gif) repeat-y right; - padding: 10px 10px 15px 0; +#linkcategorydiv ul#category-tabs { + float: left; + width: 120px; + text-align: right; + /* Negative margin for the sake of those without JS: all tabs display */ + margin: 0 -120px 0 0; + padding: 0; } -#postexcerpt div.dbx-content { - margin-right: 0; - padding-right: 17px; +#linkcategorydiv ul { + list-style: none; + padding: 0; + margin: 0; } -#advancedstuff div.dbx-c-ontent-wrapper { - margin-left: -7px; - margin-right: 0; - background: url(images/box-bg-left.gif) repeat-y left; +#linkcategorydiv ul.categorychecklist ul { + margin-left: 18px; } -#advancedstuff fieldset.dbx-box { - padding-bottom: 9px; - margin-left: 6px; - background: url(images/box-butt-right.gif) no-repeat bottom right; +/* pasitioning etc. */ +form#tags-filter { + position: relative; } -#advancedstuff div.dbx-b-ox-wrapper { - background: url(images/box-butt-left.gif) no-repeat bottom left; +p#tag-search { + position: absolute; + right: 0; + top: 0; + margin: 0; } -#advancedstuff .dbx-box-closed div.dbx-c-ontent-wrapper { - padding-bottom: 2px; - background: url(images/box-butt-left.gif) no-repeat bottom left; +form#posts-filter { + position: relative; } -#advancedstuff .dbx-box { - background: url(images/box-butt-right.gif) no-repeat bottom right; +p#post-search { + position: absolute; + right: 0; + top: 0; + margin: 0; } -/* handle cursors */ -.dbx-handle-cursor { - cursor: move; +#post-search .button, #widget-search .button { + padding: 3px; + font-size: 13px; } -/* toggle images */ -a.dbx-toggle, a.dbx-toggle:visited { - display: block; - overflow: hidden; - background-image: url( images/toggle.gif ); - position: absolute; - top: 0; - right: 0; - background-repeat: no-repeat; - border: 0; - margin: 0; +#posts-filter fieldset { + float: left; + margin: 0 1.5ex 1em 0; padding: 0; } -#moremeta a.dbx-toggle, #moremeta a.dbx-toggle-open:visited { - height: 25px; - width: 27px; - background-position: 0 0; -} - -#moremeta a.dbx-toggle-open, #moremeta a.dbx-toggle-open:visited { - height: 25px; - width: 27px; - background-position: 0 -25px; +#posts-filter fieldset legend { + padding: 0 0 .2em 1px; } -#advancedstuff a.dbx-toggle, #advancedstuff a.dbx-toggle-open:visited { - height: 22px; - width: 22px; - top: 3px; - right: 5px; - background-position: 0 -3px; +.bordertitle { + padding-bottom: 5px; + border-bottom-width: 1px; + border-bottom-style: solid; } -#advancedstuff a.dbx-toggle-open, #advancedstuff a.dbx-toggle-open:visited { - height: 22px; - width: 22px; - top: 3px; - right: 5px; - background-position: 0 -28px; -} +/* Global classes */ +.wp-hidden-children .wp-hidden-child { display: none; } +.wp-no-js-hidden { display: none; } +.ui-tabs-hide { display: none; } -#categorychecklist { - margin-right: 6px; +.commentlist .avatar { + vertical-align:text-top; } -/* additional clone styles */ -.dbx-clone { - opacity: 0.8; - -moz-opacity: 0.8; - -khtml-opacity: 0.8; - filter: alpha(opacity=80); +body.minwidth { + min-width: 808px; } -#newcat { - width: 120px; - margin-right: 5px; +ul.view-switch { + float: right; + list-style: none; + margin: -23px 5px -2px 0; + position: relative; } -input #catadd { - background: #a4a4a4; - border-bottom: 1px solid #898989; - border-left: 1px solid #bcbcbc; - border-right: 1px solid #898989; - border-top: 1px solid #bcbcbc; - color: #fff; - font-size: 10px; - padding: 0; +ul.view-switch li { + float: left; margin: 0; + font-size: 11px; + padding: 4px 6px; font-weight: bold; - height: 20px; - margin-bottom: 2px; - text-align: center; - width: 37px; } -#howto { - font-size: 11px; - margin: 0 5px; - display: block; +ul.view-switch a { + text-decoration: none; } -#jaxcat { - margin: 0; - padding: 0; +ul.view-switch li.current { + border: none; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-topright: 3px; + -khtml-border-top-right-radius: 3px; + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; } -#ajax-response.alignleft { - margin-left: 2em; + +#the-comment-list .comment a { + padding-bottom: 1px; + text-decoration: none; + border-bottom-width: 1px; + border-bottom-style: solid; } -#postdivrich #edButtons { - padding-left: 3px; + +#the-comment-list td.comment p.comment-author { + margin-top: 0; + margin-left: 0 ; } -#postdivrich #content, #postdivrich #content:active { - border: 1px solid #ccc; +#the-comment-list p.comment-author img { + float: left; + margin-right: 8px; } -#edButtons input, #edButtons input:active { - margin: 0 2px -1px; +#the-comment-list p.comment-author strong a { + border: none; } -#edButtons input.edButtonFore, #edButtons input.edButtonFore:active { - background: #f0f0ee; - border-bottom: 1px solid #f0f0ee; +#the-comment-list td { + vertical-align: top; } -#edButtons input.edButtonBack, #edButtons input.edButtonBack:active { - background: #fff url( images/fade-butt.png ) repeat-x 0 15px; - border-bottom: 1px solid #ccc; +#the-comment-list td.comment { + width: 65%; + max-width: 460px; + word-wrap: break-word; } -.page-numbers { - padding: 4px 7px; - border: 1px solid #fff; - margin-right: 3px; +#the-comment-list td.comment p { + margin-left: 8px; } -a.page-numbers { - border: 1px solid #ccc; +#the-comment-list .check-column { + padding-top: 8px; } -a.page-numbers:hover { - border: 1px solid #999; +#templateside ul li a { + text-decoration: none; } -.page-numbers.current { - border: 1px solid #999; - font-weight: bold; +.curtime { + background-image: url(images/date-button.gif); + background-repeat: no-repeat; + background-position: left 2px; + padding-left: 18px; } -.pagenav span { - font-weight: bold; - margin: 0 6px; +.tablenav .delete { + margin-right: 20px; } -a.view-link { +#tTips { + display: none; position: absolute; - right: 5%; - margin-right: 220px; - text-decoration:underline; + margin: 0; + padding: 0 0 8px 0; + background-image: url(images/tail.gif); + background-repeat: no-repeat; + background-position: 15px bottom; + background-color: transparent; } -#update-nag, .plugin-update { - border-bottom: 1px solid #ccc; - border-top: 1px solid #ccc; - background: #fffeeb; - line-height: 29px; - font-size: 12px; - color: #555; +#tTips p#tTips_inside { + margin: 0; + padding: 8px 12px; text-align: center; + -moz-border-radius: 8px; + -khtml-border-radius: 8px; + -webkit-border-radius: 8px; + border-radius: 8px; +} + +td.action-links, th.action-links { + text-align: right; +} + +#poststuff h3, #poststuff .closed h3 { + cursor: pointer; } -#update-nag a, .plugin-update a { - font-size: 1.1em; +.hide-if-no-js { + display: none; } -#update-nag a:link, .plugin-update a:link { - color: #036; -} \ No newline at end of file diff --git a/wp-app.php b/wp-app.php index e0fdaf32..52ce7b73 100644 --- a/wp-app.php +++ b/wp-app.php @@ -12,6 +12,7 @@ define('APP_REQUEST', true); require_once('./wp-config.php'); require_once(ABSPATH . WPINC . '/post-template.php'); require_once(ABSPATH . WPINC . '/atomlib.php'); +require_once(ABSPATH . WPINC . '/feed.php'); $_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] ); @@ -67,7 +68,6 @@ class AtomServer { var $MEDIA_SINGLE_PATH = "attachment"; var $params = array(); - var $script_name = "wp-app.php"; var $media_content_types = array('image/*','audio/*','video/*'); var $atom_content_types = array('application/atom+xml'); @@ -79,6 +79,10 @@ class AtomServer { function AtomServer() { $this->script_name = array_pop(explode('/',$_SERVER['SCRIPT_NAME'])); + $this->app_base = get_bloginfo('url') . '/' . $this->script_name . '/'; + if ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) { + $this->app_base = preg_replace( '/^http:\/\//', 'https://', $this->app_base ); + } $this->selectors = array( '@/service$@' => @@ -160,7 +164,7 @@ class AtomServer { function get_service() { log_app('function','get_service()'); - if( !current_user_can( 'edit_posts' ) ) + if( !current_user_can( 'edit_posts' ) ) $this->auth_required( __( 'Sorry, you do not have the right to access this blog.' ) ); $entries_url = attribute_escape($this->get_entries_url()); @@ -170,17 +174,18 @@ class AtomServer { $accepted_media_types = $accepted_media_types . "" . $med . ""; } $atom_prefix="atom"; + $atom_blogname=get_bloginfo('name'); $service_doc = << - <$atom_prefix:title>WordPress Workspace + <$atom_prefix:title>$atom_blogname Workspace - <$atom_prefix:title>WordPress Posts + <$atom_prefix:title>$atom_blogname Posts $this->ATOM_CONTENT_TYPE;type=entry - <$atom_prefix:title>WordPress Media + <$atom_prefix:title>$atom_blogname Media $accepted_media_types @@ -194,7 +199,7 @@ EOD; function get_categories_xml() { log_app('function','get_categories_xml()'); - if( !current_user_can( 'edit_posts' ) ) + if( !current_user_can( 'edit_posts' ) ) $this->auth_required( __( 'Sorry, you do not have the right to access this blog.' ) ); $home = attribute_escape(get_bloginfo_rss('home')); @@ -218,7 +223,7 @@ EOD; * Create Post (No arguments) */ function create_post() { - global $blog_id, $wpdb; + global $blog_id, $user_ID; $this->get_accepted_content_type($this->atom_content_types); $parser = new AtomParser(); @@ -252,11 +257,11 @@ EOD; $blog_ID = (int ) $blog_id; $post_status = ($publish) ? 'publish' : 'draft'; - $post_author = (int) $user->ID; + $post_author = (int) $user_ID; $post_title = $entry->title[1]; $post_content = $entry->content[1]; $post_excerpt = $entry->summary[1]; - $pubtimes = $this->get_publish_time($entry); + $pubtimes = $this->get_publish_time($entry->published); $post_date = $pubtimes[0]; $post_date_gmt = $pubtimes[1]; @@ -272,9 +277,8 @@ EOD; if ( is_wp_error( $postID ) ) $this->internal_error($postID->get_error_message()); - if (!$postID) { + if (!$postID) $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); - } // getting warning here about unable to set headers // because something in the cache is printing to the buffer @@ -292,7 +296,7 @@ EOD; global $entry; if( !current_user_can( 'edit_post', $postID ) ) - $this->auth_required( __( 'Sorry, you do not have the right to access this post.' ) ); + $this->auth_required( __( 'Sorry, you do not have the right to access this post.' ) ); $this->set_current_entry($postID); $output = $this->get_entry($postID); @@ -302,8 +306,6 @@ EOD; } function put_post($postID) { - global $wpdb; - // checked for valid content-types (atom+xml) // quick check and exit $this->get_accepted_content_type($this->atom_content_types); @@ -319,7 +321,6 @@ EOD; // check for not found global $entry; - $entry = $GLOBALS['entry']; $this->set_current_entry($postID); if(!current_user_can('edit_post', $entry['ID'])) @@ -332,9 +333,12 @@ EOD; $post_title = $parsed->title[1]; $post_content = $parsed->content[1]; $post_excerpt = $parsed->summary[1]; - $pubtimes = $this->get_publish_time($entry); + $pubtimes = $this->get_publish_time($entry->published); $post_date = $pubtimes[0]; $post_date_gmt = $pubtimes[1]; + $pubtimes = $this->get_publish_time($parsed->updated); + $post_modified = $pubtimes[0]; + $post_modified_gmt = $pubtimes[1]; // let's not go backwards and make something draft again. if(!$publish && $post_status == 'draft') { @@ -343,7 +347,7 @@ EOD; $post_status = 'publish'; } - $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_date', 'post_date_gmt'); + $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt'); $this->escape($postdata); $result = wp_update_post($postdata); @@ -383,7 +387,7 @@ EOD; function get_attachment($postID = NULL) { if( !current_user_can( 'upload_files' ) ) - $this->auth_required( __( 'Sorry, you do not have the right to file uploads on this blog.' ) ); + $this->auth_required( __( 'Sorry, you do not have permission to upload files.' ) ); if (!isset($postID)) { $this->get_attachments(); @@ -396,7 +400,6 @@ EOD; } function create_attachment() { - global $wp, $wpdb, $wp_query, $blog_id; $type = $this->get_accepted_content_type(); @@ -417,7 +420,7 @@ EOD; $slug = sanitize_file_name( $_SERVER['HTTP_TITLE'] ); elseif ( empty( $slug ) ) // just make a random name $slug = substr( md5( uniqid( microtime() ) ), 0, 7); - $ext = preg_replace( '|.*/([a-z]+)|', '$1', $_SERVER['CONTENT_TYPE'] ); + $ext = preg_replace( '|.*/([a-z0-9]+)|', '$1', $_SERVER['CONTENT_TYPE'] ); $slug = "$slug.$ext"; $file = wp_upload_bits( $slug, NULL, $bits); @@ -425,9 +428,8 @@ EOD; $url = $file['url']; $file = $file['file']; - $filename = basename($file); - $header = apply_filters('wp_create_file_in_uploads', $file); // replicate + do_action('wp_create_file_in_uploads', $file); // replicate // Construct the attachment array $attachment = array( @@ -440,11 +442,10 @@ EOD; ); // Save the data - $postID = wp_insert_attachment($attachment, $file, $post); + $postID = wp_insert_attachment($attachment, $file); - if (!$postID) { + if (!$postID) $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); - } $output = $this->get_entry($postID, 'attachment'); @@ -453,8 +454,6 @@ EOD; } function put_attachment($postID) { - global $wpdb; - // checked for valid content-types (atom+xml) // quick check and exit $this->get_accepted_content_type($this->atom_content_types); @@ -473,14 +472,15 @@ EOD; if(!current_user_can('edit_post', $entry['ID'])) $this->auth_required(__('Sorry, you do not have the right to edit this post.')); - $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true; - extract($entry); $post_title = $parsed->title[1]; $post_content = $parsed->content[1]; + $pubtimes = $this->get_publish_time($parsed->updated); + $post_modified = $pubtimes[0]; + $post_modified_gmt = $pubtimes[1]; - $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); + $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_modified', 'post_modified_gmt'); $this->escape($postdata); $result = wp_update_post($postdata); @@ -557,8 +557,6 @@ EOD; function put_file($postID) { - $type = $this->get_accepted_content_type(); - // first check if user can upload if(!current_user_can('upload_files')) $this->auth_required(__('You do not have permission to upload files.')); @@ -587,11 +585,14 @@ EOD; fclose($localfp); $ID = $entry['ID']; - $pubtimes = $this->get_publish_time($entry); + $pubtimes = $this->get_publish_time($entry->published); $post_date = $pubtimes[0]; $post_date_gmt = $pubtimes[1]; + $pubtimes = $this->get_publish_time($parsed->updated); + $post_modified = $pubtimes[0]; + $post_modified_gmt = $pubtimes[1]; - $post_data = compact('ID', 'post_date', 'post_date_gmt'); + $post_data = compact('ID', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt'); $result = wp_update_post($post_data); if (!$result) { @@ -608,7 +609,7 @@ EOD; } else { $path = $this->ENTRIES_PATH; } - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $path; + $url = $this->app_base . $path; if(isset($page) && is_int($page)) { $url .= "/$page"; } @@ -616,21 +617,19 @@ EOD; } function the_entries_url($page = NULL) { - $url = $this->get_entries_url($page); - echo $url; + echo $this->get_entries_url($page); } - function get_categories_url($page = NULL) { - return get_bloginfo('url') . '/' . $this->script_name . '/' . $this->CATEGORIES_PATH; + function get_categories_url($deprecated = '') { + return $this->app_base . $this->CATEGORIES_PATH; } function the_categories_url() { - $url = $this->get_categories_url(); - echo $url; + echo $this->get_categories_url(); } function get_attachments_url($page = NULL) { - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_PATH; + $url = $this->app_base . $this->MEDIA_PATH; if(isset($page) && is_int($page)) { $url .= "/$page"; } @@ -638,46 +637,43 @@ EOD; } function the_attachments_url($page = NULL) { - $url = $this->get_attachments_url($page); - echo $url; + echo $this->get_attachments_url($page); } function get_service_url() { - return get_bloginfo('url') . '/' . $this->script_name . '/' . $this->SERVICE_PATH; + return $this->app_base . $this->SERVICE_PATH; } function get_entry_url($postID = NULL) { if(!isset($postID)) { global $post; - $postID = (int) $GLOBALS['post']->ID; + $postID = (int) $post->ID; } - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->ENTRY_PATH . "/$postID"; + $url = $this->app_base . $this->ENTRY_PATH . "/$postID"; log_app('function',"get_entry_url() = $url"); return $url; } function the_entry_url($postID = NULL) { - $url = $this->get_entry_url($postID); - echo $url; + echo $this->get_entry_url($postID); } function get_media_url($postID = NULL) { if(!isset($postID)) { global $post; - $postID = (int) $GLOBALS['post']->ID; + $postID = (int) $post->ID; } - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_SINGLE_PATH ."/file/$postID"; + $url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID"; log_app('function',"get_media_url() = $url"); return $url; } function the_media_url($postID = NULL) { - $url = $this->get_media_url($postID); - echo $url; + echo $this->get_media_url($postID); } function set_current_entry($postID) { @@ -711,7 +707,7 @@ EOD; } function get_feed($page = 1, $post_type = 'post') { - global $post, $wp, $wp_query, $posts, $wpdb, $blog_id, $post_cache; + global $post, $wp, $wp_query, $posts, $wpdb, $blog_id; log_app('function',"get_feed($page, '$post_type')"); ob_start(); @@ -722,7 +718,7 @@ EOD; $count = get_option('posts_per_rss'); - wp('what_to_show=posts&posts_per_page=' . $count . '&offset=' . ($count * ($page-1) )); + wp('what_to_show=posts&posts_per_page=' . $count . '&offset=' . ($count * ($page-1) . '&orderby=modified')); $post = $GLOBALS['post']; $posts = $GLOBALS['posts']; @@ -730,7 +726,6 @@ EOD; $wp_query = $GLOBALS['wp_query']; $wpdb = $GLOBALS['wpdb']; $blog_id = (int) $GLOBALS['blog_id']; - $post_cache = $GLOBALS['post_cache']; log_app('function',"query_posts(# " . print_r($wp_query, true) . "#)"); log_app('function',"total_count(# $wp_query->max_num_pages #)"); @@ -754,7 +749,7 @@ EOD; Copyright -WordPress.com Atom API + ATOM_NS ?>" xmlns:app="ATOMPUB_NS ?>" xml:lang=""> ID); ?> -prep_content(get_the_title()); ?> + <?php echo $content ?> @@ -820,7 +814,7 @@ EOD; post_content ) ) : -list($content_type, $content) = $this->prep_content(get_the_content()); ?> +list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?> @@ -828,37 +822,11 @@ list($content_type, $content) = $this->prep_content(get_the_content()); ?> -prep_content(get_the_excerpt()); ?> + ' . $data . '
    ', true); - $code = xml_get_error_code($parser); - xml_parser_free($parser); - - if (!$code) { - if (strpos($data, '<') === false) { - return array('text', $data); - } else { - $data = "
    $data
    "; - return array('xhtml', $data); - } - } - - if (strpos($data, ']]>') == false) { - return array('html', ""); - } else { - return array('html', htmlspecialchars($data)); - } - } - function ok() { log_app('Status','200: OK'); header('Content-Type: text/plain'); @@ -959,7 +927,7 @@ EOD; $ctloc = $this->get_entry_url($post_ID); break; case 'attachment': - $edit = get_bloginfo('url') . '/' . $this->script_name . "/attachments/$post_ID"; + $edit = $this->app_base . "attachments/$post_ID"; break; } header("Content-Type: $this->ATOM_CONTENT_TYPE"); @@ -1140,9 +1108,9 @@ EOD; return strtotime($match[1] . " " . $match[2] . " " . $match[3]); } - function get_publish_time($entry) { + function get_publish_time($published) { - $pubtime = $this->rfc3339_str2time($entry->published); + $pubtime = $this->rfc3339_str2time($published); if(!$pubtime) { return array(current_time('mysql'),current_time('mysql',1)); diff --git a/wp-blog-header.php b/wp-blog-header.php index 00d3ccd5..ff81b46c 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -8,7 +8,7 @@ if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { require_once( dirname(__FILE__) . '/wp-includes/classes.php'); require_once( dirname(__FILE__) . '/wp-includes/functions.php'); require_once( dirname(__FILE__) . '/wp-includes/plugin.php'); - wp_die("There doesn't seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.", "WordPress › Error"); + wp_die("There doesn't seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.

    Create a Configuration File", "WordPress › Error"); } $wp_did_header = true; @@ -16,7 +16,6 @@ $wp_did_header = true; require_once( dirname(__FILE__) . '/wp-config.php'); wp(); -gzip_compression(); require_once(ABSPATH . WPINC . '/template-loader.php'); diff --git a/wp-comments-post.php b/wp-comments-post.php index 56374595..f7d7c4f5 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -16,7 +16,7 @@ $status = $wpdb->get_row("SELECT post_status, comment_status FROM $wpdb->posts W if ( empty($status->comment_status) ) { do_action('comment_id_not_found', $comment_post_ID); exit; -} elseif ( 'closed' == $status->comment_status ) { +} elseif ( !comments_open($comment_post_ID) ) { do_action('comment_closed', $comment_post_ID); wp_die( __('Sorry, comments are closed for this item.') ); } elseif ( in_array($status->post_status, array('draft', 'pending') ) ) { diff --git a/wp-config-sample.php b/wp-config-sample.php index 26bf086f..b59fd048 100644 --- a/wp-config-sample.php +++ b/wp-config-sample.php @@ -7,6 +7,11 @@ define('DB_HOST', 'localhost'); // 99% chance you won't need to change this v define('DB_CHARSET', 'utf8'); define('DB_COLLATE', ''); +// Change SECRET_KEY to a unique phrase. You won't have to remember it later, +// so make it long and complicated. You can visit http://api.wordpress.org/secret-key/1.0/ +// to get a secret key generated for you, or just make something up. +define('SECRET_KEY', 'put your unique phrase here'); // Change this to a unique phrase. + // You can have multiple installations in one database if you give each a unique prefix $table_prefix = 'wp_'; // Only numbers, letters, and underscores please! diff --git a/wp-content/plugins/akismet/akismet.php b/wp-content/plugins/akismet/akismet.php index 3a434767..e774fdae 100644 --- a/wp-content/plugins/akismet/akismet.php +++ b/wp-content/plugins/akismet/akismet.php @@ -3,7 +3,7 @@ Plugin Name: Akismet Plugin URI: http://akismet.com/ Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a WordPress.com API key to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <?php akismet_counter(); ?> in your template. See also: WP Stats plugin. -Version: 2.1.3 +Version: 2.1.4 Author: Matt Mullenweg Author URI: http://photomatt.net/ */ @@ -32,10 +32,14 @@ if ( !function_exists('wp_nonce_field') ) { $akismet_nonce = 'akismet-update-key'; } +if ( !function_exists('number_format_i18n') ) { + function number_format_i18n( $number, $decimals = null ) { return number_format( $number, $decimals ); } +} + function akismet_config_page() { if ( function_exists('add_submenu_page') ) add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf'); - + } function akismet_conf() { @@ -147,7 +151,7 @@ function akismet_verify_key( $key ) { if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) { function akismet_warning() { echo " -

    ".__('Akismet is almost ready.')." ".sprintf(__('You must enter your WordPress.com API key for it to work.'), "plugins.php?page=akismet-key-config")."

    +

    ".__('Akismet is almost ready.')." ".sprintf(__('You must enter your WordPress.com API key for it to work.'), "plugins.php?page=akismet-key-config")."

    "; } add_action('admin_notices', 'akismet_warning'); @@ -226,6 +230,7 @@ function akismet_delete_old() { function akismet_submit_nonspam_comment ( $comment_id ) { global $wpdb, $akismet_api_host, $akismet_api_port; + $comment_id = (int) $comment_id; $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'"); if ( !$comment ) // it was deleted @@ -239,6 +244,7 @@ function akismet_submit_nonspam_comment ( $comment_id ) { function akismet_submit_spam_comment ( $comment_id ) { global $wpdb, $akismet_api_host, $akismet_api_port; + $comment_id = (int) $comment_id; $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'"); if ( !$comment ) // it was deleted @@ -257,14 +263,67 @@ add_action('wp_set_comment_status', 'akismet_submit_spam_comment'); add_action('edit_comment', 'akismet_submit_spam_comment'); add_action('preprocess_comment', 'akismet_auto_check_comment', 1); -function akismet_spam_count() { - global $wpdb, $comments; - $count = wp_cache_get( 'akismet_spam_count', 'widget' ); - if ( false === $count ) { - $count = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'"); - wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 ); +// Total spam in queue +// get_option( 'akismet_spam_count' ) is the total caught ever +function akismet_spam_count( $type = false ) { + global $wpdb; + + if ( !$type ) { // total + $count = wp_cache_get( 'akismet_spam_count', 'widget' ); + if ( false === $count ) { + if ( function_exists('wp_count_comments') ) { + $count = wp_count_comments(); + $count = $count->spam; + } else { + $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'"); + } + wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 ); + } + return $count; + } elseif ( 'comments' == $type || 'comment' == $type ) { // comments + $type = ''; + } else { // pingback, trackback, ... + $type = $wpdb->escape( $type ); + } + + return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'"); +} + +function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) { + global $wpdb; + + $page = (int) $page; + if ( $page < 2 ) + $page = 1; + + $per_page = (int) $per_page; + if ( $per_page < 1 ) + $per_page = 50; + + $start = ( $page - 1 ) * $per_page; + $end = $start + $per_page; + + if ( $type ) { + if ( 'comments' == $type || 'comment' == $type ) + $type = ''; + else + $type = $wpdb->escape( $type ); + return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end"); } - return $count; + + // All + return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end"); +} + +// Totals for each comment type +// returns array( type => count, ... ) +function akismet_spam_totals() { + global $wpdb; + $totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" ); + $return = array(); + foreach ( $totals as $total ) + $return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc; + return $return; } function akismet_manage_page() { @@ -283,7 +342,7 @@ function akismet_caught() { check_admin_referer( $akismet_nonce ); if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) die(__('You do not have sufficient permission to moderate comments.')); - + $i = 0; foreach ($_POST['not_spam'] as $comment): $comment = (int) $comment; @@ -303,7 +362,7 @@ function akismet_caught() { if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) die(__('You do not have sufficient permission to moderate comments.')); - $delete_time = addslashes( $_POST['display_time'] ); + $delete_time = $wpdb->escape( $_POST['display_time'] ); $nuked = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" ); wp_cache_delete( 'akismet_spam_count', 'widget' ); $to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] ); @@ -370,14 +429,13 @@ else $count = get_option( 'akismet_spam_count' ); if ( $count ) { ?> -

    %1$s spam for you since you first installed it.'), number_format($count) ); ?>

    +

    %1$s spam for you since you first installed it.'), number_format_i18n($count) ); ?>

    get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'" ); +$spam_count = akismet_spam_count(); - -if ( 0 == $gotspam ) { +if ( 0 == $spam_count ) { echo '

    '.__('You have no spam currently in the queue. Must be your lucky day. :)').'

    '; echo '
    '; } else { @@ -387,7 +445,7 @@ if ( 0 == $gotspam ) {
    -    +   
    @@ -418,34 +476,30 @@ if ( isset( $_POST['s'] ) ) { if ( $page < 2 ) $page = 1; - $start = ( $page - 1 ) * 50; - $end = $start + 50; - - $where = ''; - if ( isset( $_GET['ctype'] ) ) { - $type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] ); - if ( 'comments' == $type ) - $type = ''; - $where = " AND comment_type = '$type' "; - } - - $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' $where ORDER BY comment_date DESC LIMIT $start, $end"); - $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam' $where" ); + $current_type = false; + if ( isset( $_GET['ctype'] ) ) + $current_type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] ); - $totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" ); + $comments = akismet_spam_comments( $current_type ); + $total = akismet_spam_count( $current_type ); + $totals = akismet_spam_totals(); ?>
    • >
    • comment_type ) $type->comment_type = 'comments'; - $show = ucwords( $type->comment_type ); - $type->cc = number_format( $type->cc ); - $extra = ( $_GET['ctype'] == $type->comment_type ) ? ' class="active"' : ''; - echo "
    • $show ($type->cc)
    • "; +foreach ( $totals as $type => $type_count ) { + if ( 'comment' == $type ) { + $type = 'comments'; + $show = __('Comments'); + } else { + $show = ucwords( $type ); + } + $type_count = number_format_i18n( $type_count ); + $extra = $current_type === $type ? ' class="active"' : ''; + echo "
    • $show ($type_count)
    • "; } do_action( 'akismet_tabs' ); // so plugins can add more tabs easily -?> +?>
    " id="akismetsearch"> -

    +

    50 ) { @@ -501,7 +555,7 @@ foreach($comments as $comment) { $post_title = $post->post_title; if ($i % 2) $class = 'class="alternate"'; else $class = ''; - echo "\n\t
  • "; + echo "\n\t
  • "; ?>

    comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | |

    @@ -510,7 +564,7 @@ foreach($comments as $comment) {

    — [ + — [ comment_post_ID); $post_title = wp_specialchars( $post->post_title, 'double' ); @@ -554,7 +608,7 @@ if ( ( $page ) * 50 < $total || -1 == $total ) { echo "

    $r

    "; } ?> -

    +

    @@ -580,9 +634,11 @@ echo "

    $r

    "; add_action('admin_menu', 'akismet_manage_page'); +// WP < 2.5 function akismet_stats() { - $count = get_option('akismet_spam_count'); - if ( !$count ) + if ( !function_exists('did_action') || did_action( 'rightnow_end' ) ) // We already displayed this info in the "Right Now" section + return; + if ( !$count = get_option('akismet_spam_count') ) return; $path = plugin_basename(__FILE__); echo '

    '.__('Spam').'

    '; @@ -591,12 +647,47 @@ function akismet_stats() { $link = 'edit-comments.php'; else $link = 'edit.php'; - echo '

    '.sprintf(__('Akismet has protected your site from %3$s spam comments.'), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format($count) ).'

    '; + echo '

    '.sprintf(__('Akismet has protected your site from %3$s spam comments.'), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'

    '; } add_action('activity_box_end', 'akismet_stats'); +// WP 2.5+ +function akismet_rightnow() { + global $submenu; + if ( isset( $submenu['edit-comments.php'] ) ) + $link = 'edit-comments.php'; + else + $link = 'edit.php'; + + if ( $count = get_option('akismet_spam_count') ) { + $intro = sprintf( __ngettext( + 'Akismet has protected your site from %2$s spam comment already,', + 'Akismet has protected your site from %2$s spam comments already,', + $count + ), 'http://akismet.com/', number_format_i18n( $count ) ); + } else { + $intro = sprintf( __('Akismet blocks spam from getting to your blog,'), 'http://akismet.com/' ); + } + + if ( $queue_count = akismet_spam_count() ) { + $queue_text = sprintf( __ngettext( + 'and there\'s %1$s comment in your spam queue right now.', + 'and there are %1$s comments in your spam queue right now.', + $queue_count + ), number_format_i18n( $queue_count ), clean_url("$link?page=akismet-admin") ); + } else { + $queue_text = sprintf( __( "but there's nothing in your spam queue at the moment." ), clean_url("$link?page=akismet-admin") ); + } + + $text = sprintf( _c( '%1$s %2$s|akismet_rightnow' ), $intro, $queue_text ); + + echo "

    $text

    \n"; +} + +add_action('rightnow_end', 'akismet_rightnow'); +// For WP <= 2.3.x if ( 'moderation.php' == $pagenow ) { function akismet_recheck_button( $page ) { global $submenu; @@ -613,6 +704,16 @@ if ( 'moderation.php' == $pagenow ) { ob_start( 'akismet_recheck_button' ); } +// For WP >= 2.5 +function akismet_check_for_spam_button($comment_status) { + if ( 'moderated' != $comment_status ) + return; + $count = wp_count_comments(); + if ( !empty($count->moderated ) ) + echo "" . __('Check for Spam') . ""; +} +add_action('manage_comments_nav', 'akismet_check_for_spam_button'); + function akismet_recheck_queue() { global $wpdb, $akismet_api_host, $akismet_api_port; @@ -625,12 +726,12 @@ function akismet_recheck_queue() { $c['user_agent'] = $c['comment_agent']; $c['referrer'] = ''; $c['blog'] = get_option('home'); - $id = $c['comment_ID']; - + $id = (int) $c['comment_ID']; + $query_string = ''; foreach ( $c as $key => $data ) $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; - + $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); if ( 'true' == $response[1] ) { $wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'spam' WHERE comment_ID = $id" ); @@ -653,11 +754,11 @@ function akismet_check_db_comment( $id ) { $c['referrer'] = ''; $c['blog'] = get_option('home'); $id = $c['comment_ID']; - + $query_string = ''; foreach ( $c as $key => $data ) $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; - + $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); return $response[1]; } @@ -672,8 +773,7 @@ function widget_akismet_register() { function widget_akismet($args) { extract($args); $options = get_option('widget_akismet'); - $count = number_format(get_option('akismet_spam_count')); - $text = __('%d spam comments have been blocked by Akismet.'); + $count = number_format_i18n(get_option('akismet_spam_count')); ?> @@ -681,7 +781,7 @@ function widget_akismet_register() { "; diff --git a/wp-content/themes/classic/comments-popup.php b/wp-content/themes/classic/comments-popup.php index e7f68766..4e0a6057 100644 --- a/wp-content/themes/classic/comments-popup.php +++ b/wp-content/themes/classic/comments-popup.php @@ -57,7 +57,7 @@ if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH
    -

    '.$user_identity.''); ?>

    +

    '.$user_identity.''); ?>

    @@ -102,7 +102,7 @@ endwhile; -

    Powered by Wordpress"),__("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?>

    +

    Powered by WordPress"),__("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?>

    \n"; - echo $javascript; -} + if (empty ($file)) { + $wpcommentspopupfile = ''; // Use the index. + } else { + $wpcommentspopupfile = $file; + } -function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { - global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb; + $wpcommentsjavascript = 1; + $javascript = "\n"; + echo $javascript; +} + +/** + * comments_popup_link() - Displays the link to the comments popup window for the current post ID. + * + * Is not meant to be displayed on single posts and pages. Should be used on the lists of posts + * + * @since 0.71 + * @uses $id + * @uses $wpcommentspopupfile + * @uses $wpcommentsjavascript + * @uses $post + * + * @param string $zero The string to display when no comments + * @param string $one The string to display when only one comment is available + * @param string $more The string to display when there are more than one comment + * @param string $css_class The CSS class to use for comments + * @param string $none The string to display when comments have been turned off + * @return null Returns null on single posts and pages. + */ +function comments_popup_link( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $css_class = '', $none = 'Comments Off' ) { + global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post; if ( is_single() || is_page() ) return; - $number = get_comments_number($id); + $number = get_comments_number( $id ); if ( 0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status ) { - echo '' . $none . ''; + echo '' . $none . ''; return; } if ( !empty($post->post_password) ) { // if there's a password - if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie - echo(__('Enter your password to view comments')); + if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) || $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie + echo __('Enter your password to view comments'); return; } } echo ''; - comments_number($zero, $one, $more, $number); + $title = attribute_escape( get_the_title() ); + + echo apply_filters( 'comments_popup_link_attributes', '' ); + + echo ' title="' . sprintf( __('Comment on %s'), $title ) . '">'; + comments_number( $zero, $one, $more, $number ); echo ''; } -?> +?> \ No newline at end of file diff --git a/wp-includes/comment.php b/wp-includes/comment.php index f4411054..63e6b1b3 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -1,5 +1,27 @@ get_var("SELECT link_id FROM $wpdb->links WHERE link_url LIKE ('%$domain%') LIMIT 1") || $domain == $home_domain ) + if ( $wpdb->get_var($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_url LIKE (%s) LIMIT 1", '%'.$domain.'%')) || $domain == $home_domain ) return true; else return false; } elseif ( $author != '' && $email != '' ) { + // expected_slashed ($author, $email) $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1"); if ( ( 1 == $ok_to_comment ) && ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) @@ -59,17 +82,32 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $ return true; } - +/** + * get_approved_comments() - Returns the approved comments for post $post_id + * + * @since 2.0 + * @uses $wpdb + * + * @param int $post_id The ID of the post + * @return array $comments The approved comments + */ function get_approved_comments($post_id) { global $wpdb; - - $post_id = (int) $post_id; - return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1' ORDER BY comment_date"); + return $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id)); } - -// Retrieves comment data given a comment ID or comment object. -// Handles comment caching. +/** + * get_comment() - Retrieves comment data given a comment ID or comment object. + * + * {@internal Missing Long Description}} + * + * @since 2.0 + * @uses $wpdb + * + * @param object|string|int $comment {@internal Missing Description}} + * @param string $output OBJECT or ARRAY_A or ARRAY_N constants + * @return object|array|null Depends on $output value. + */ function &get_comment(&$comment, $output = OBJECT) { global $wpdb; @@ -82,11 +120,10 @@ function &get_comment(&$comment, $output = OBJECT) { wp_cache_add($comment->comment_ID, $comment, 'comment'); $_comment = $comment; } else { - $comment = (int) $comment; if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) { $_comment = & $GLOBALS['comment']; } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) { - $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1"); + $_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment)); wp_cache_add($_comment->comment_ID, $_comment, 'comment'); } } @@ -104,12 +141,31 @@ function &get_comment(&$comment, $output = OBJECT) { } } - -// Deprecate in favor of get_comment()? +/** + * get_commentdata() - Returns an array of comment data about comment $comment_ID + * + * get_comment() technically does the same thing as this function. This function also + * appears to reference variables and then not use them or not update them when needed. + * It is advised to switch to get_comment(), since this function might be deprecated in + * favor of using get_comment(). + * + * @deprecated Use get_comment() + * @see get_comment() + * @since 0.71 + * + * @uses $postc Comment cache, might not be used any more + * @uses $id + * @uses $wpdb Database Object + * + * @param int $comment_ID The ID of the comment + * @param int $no_cache Whether to use the cache or not (casted to bool) + * @param bool $include_unapproved Whether to include unapproved comments or not + * @return array The comment data + */ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { // less flexible, but saves DB queries - global $postc, $id, $commentdata, $wpdb; + global $postc, $wpdb; if ( $no_cache ) { - $query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'"; + $query = $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d", $comment_ID); if ( false == $include_unapproved ) $query .= " AND comment_approved = '1'"; $myrow = $wpdb->get_row($query, ARRAY_A); @@ -129,32 +185,109 @@ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = fals return $myrow; } - +/** + * get_lastcommentmodified() - The date the last comment was modified + * + * {@internal Missing Long Description}} + * + * @since 1.5.0 + * @uses $wpdb + * @global array $cache_lastcommentmodified + * + * @param string $timezone Which timezone to use in reference to 'gmt', 'blog', or 'server' locations + * @return string Last comment modified date + */ function get_lastcommentmodified($timezone = 'server') { - global $cache_lastcommentmodified, $pagenow, $wpdb; - $add_seconds_blog = get_option('gmt_offset') * 3600; + global $cache_lastcommentmodified, $wpdb; + + if ( isset($cache_lastcommentmodified[$timezone]) ) + return $cache_lastcommentmodified[$timezone]; + $add_seconds_server = date('Z'); - $now = current_time('mysql', 1); - if ( !isset($cache_lastcommentmodified[$timezone]) ) { - switch ( strtolower($timezone)) { - case 'gmt': - $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= '$now' AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); + + switch ( strtolower($timezone)) { + case 'gmt': + $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); + break; + case 'blog': + $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); + break; + case 'server': + $lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server)); + break; + } + + $cache_lastcommentmodified[$timezone] = $lastcommentmodified; + + return $lastcommentmodified; +} + +/** + * get_comment_count() - The amount of comments in a post or total comments + * + * {@internal Missing Long Description}} + * + * @since 2.0.0 + * @uses $wpdb + * + * @param int $post_id Optional. Comment amount in post if > 0, else total com +ments blog wide + * @return array The amount of spam, approved, awaiting moderation, and total + */ +function get_comment_count( $post_id = 0 ) { + global $wpdb; + + $post_id = (int) $post_id; + + $where = ''; + if ( $post_id > 0 ) { + $where = "WHERE comment_post_ID = {$post_id}"; + } + + $totals = (array) $wpdb->get_results(" + SELECT comment_approved, COUNT( * ) AS total + FROM {$wpdb->comments} + {$where} + GROUP BY comment_approved + ", ARRAY_A); + + $comment_count = array( + "approved" => 0, + "awaiting_moderation" => 0, + "spam" => 0, + "total_comments" => 0 + ); + + foreach ( $totals as $row ) { + switch ( $row['comment_approved'] ) { + case 'spam': + $comment_count['spam'] = $row['total']; + $comment_count["total_comments"] += $row['total']; break; - case 'blog': - $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_date_gmt <= '$now' AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); + case 1: + $comment_count['approved'] = $row['total']; + $comment_count['total_comments'] += $row['total']; break; - case 'server': - $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->comments WHERE comment_date_gmt <= '$now' AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); + case 0: + $comment_count['awaiting_moderation'] = $row['total']; + $comment_count['total_comments'] += $row['total']; + break; + default: break; } - $cache_lastcommentmodified[$timezone] = $lastcommentmodified; - } else { - $lastcommentmodified = $cache_lastcommentmodified[$timezone]; } - return $lastcommentmodified; -} + return $comment_count; +} +/** + * sanitize_comment_cookies() - {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.0.4 + * + */ function sanitize_comment_cookies() { if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]); @@ -177,12 +310,25 @@ function sanitize_comment_cookies() { } } - +/** + * wp_allow_comment() - Validates whether this comment is allowed to be made or not + * + * {@internal Missing Long Description}} + * + * @since 2.0.0 + * @uses $wpdb + * @uses apply_filters() Calls 'pre_comment_approved' hook on the type of comment + * @uses do_action() Calls 'check_comment_flood' hook on $comment_author_IP, $comment_author_email, and $comment_date_gmt + * + * @param array $commentdata Contains information on the comment + * @return mixed Signifies the approval status (0|1|'spam') + */ function wp_allow_comment($commentdata) { global $wpdb; extract($commentdata, EXTR_SKIP); // Simple duplicate check + // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' "; if ( $comment_author_email ) $dupe .= "OR comment_author_email = '$comment_author_email' "; @@ -195,7 +341,7 @@ function wp_allow_comment($commentdata) { if ( $user_id ) { $userdata = get_userdata($user_id); $user = new WP_User($user_id); - $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1"); + $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID)); } if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) { @@ -215,8 +361,24 @@ function wp_allow_comment($commentdata) { return $approved; } +/** + * check_comment_flood_db() - {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.3.0 + * @uses $wpdb + * @uses apply_filters() {@internal Missing Description}} + * @uses do_action() {@internal Missing Description}} + * + * @param string $ip {@internal Missing Description}} + * @param string $email {@internal Missing Description}} + * @param unknown_type $date {@internal Missing Description}} + */ function check_comment_flood_db( $ip, $email, $date ) { global $wpdb; + if ( current_user_can( 'manage_options' ) ) + return; // don't throttle admins if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) { $time_lastcomment = mysql2date('U', $lasttime); $time_newcomment = mysql2date('U', $date); @@ -228,9 +390,23 @@ function check_comment_flood_db( $ip, $email, $date ) { } } +/** + * wp_blacklist_check() - Does comment contain blacklisted characters or words + * + * {@internal Missing Long Description}} + * + * @since 1.5.0 + * @uses do_action() Calls 'wp_blacklist_check' hook for all parameters + * + * @param string $author The author of the comment + * @param string $email The email of the comment + * @param string $url The url used in the comment + * @param string $comment The comment content + * @param string $user_ip The comment author IP address + * @param string $user_agent The author's browser user agent + * @return bool True if comment contains blacklisted content, false if comment does not + */ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) { - global $wpdb; - do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) { @@ -272,7 +448,47 @@ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_age return false; } +function wp_count_comments() { + global $wpdb; + + $count = wp_cache_get('comments', 'counts'); + + if ( false !== $count ) + return $count; + + $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} GROUP BY comment_approved", ARRAY_A ); + + $stats = array( ); + $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam'); + foreach( (array) $count as $row_num => $row ) { + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; + } + foreach ( $approved as $key ) { + if ( empty($stats[$key]) ) + $stats[$key] = 0; + } + + $stats = (object) $stats; + wp_cache_set('comments', $stats, 'counts'); + + return $stats; +} + +/** + * wp_delete_comment() - Removes comment ID and maybe updates post comment count + * + * The post comment count will be updated if the comment was approved and has a post + * ID available. + * + * @since 2.0.0 + * @uses $wpdb + * @uses do_action() Calls 'delete_comment' hook on comment ID + * @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter + * + * @param int $comment_id Comment ID + * @return bool False if delete comment query failure, true on success + */ function wp_delete_comment($comment_id) { global $wpdb; do_action('delete_comment', $comment_id); @@ -292,10 +508,15 @@ function wp_delete_comment($comment_id) { return true; } - +/** + * wp_get_comment_status() - The status of a comment by ID + * + * @since 1.0.0 + * + * @param int $comment_id Comment ID + * @return string|bool Status might be 'deleted', 'approved', 'unapproved', 'spam'. False on failure + */ function wp_get_comment_status($comment_id) { - global $wpdb; - $comment = get_comment($comment_id); if ( !$comment ) return false; @@ -314,7 +535,18 @@ function wp_get_comment_status($comment_id) { return false; } - +/** + * wp_get_current_commenter() - Get current commenter's name, email, and URL + * + * Expects cookies content to already be sanitized. User of this function + * might wish to recheck the returned array for validity. + * + * @see sanitize_comment_cookies() Use to sanitize cookies + * + * @since 2.0.4 + * + * @return array Comment author, email, url respectively + */ function wp_get_current_commenter() { // Cookies should already be sanitized. @@ -333,13 +565,23 @@ function wp_get_current_commenter() { return compact('comment_author', 'comment_author_email', 'comment_author_url'); } - +/** + * wp_insert_comment() - Inserts a comment to the database + * + * {@internal Missing Long Description}} + * + * @since 2.0.0 + * @uses $wpdb + * + * @param array $commentdata Contains information on the comment + * @return int The new comment's id + */ function wp_insert_comment($commentdata) { global $wpdb; extract($commentdata, EXTR_SKIP); if ( ! isset($comment_author_IP) ) - $comment_author_IP = preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] ); + $comment_author_IP = ''; if ( ! isset($comment_date) ) $comment_date = current_time('mysql'); if ( ! isset($comment_date_gmt) ) @@ -365,7 +607,25 @@ function wp_insert_comment($commentdata) { return $id; } - +/** + * wp_filter_comment() - Parses and returns comment information + * + * Sets the comment data 'filtered' field to true when finished. This + * can be checked as to whether the comment should be filtered and to + * keep from filtering the same comment more than once. + * + * @since 2.0.0 + * @uses apply_filters() Calls 'pre_user_id' hook on comment author's user ID + * @uses apply_filters() Calls 'pre_comment_user_agent' hook on comment author's user agent + * @uses apply_filters() Calls 'pre_comment_author_name' hook on comment author's name + * @uses apply_filters() Calls 'pre_comment_content' hook on the comment's content + * @uses apply_filters() Calls 'pre_comment_user_ip' hook on comment author's IP + * @uses apply_filters() Calls 'pre_comment_author_url' hook on comment author's URL + * @uses apply_filters() Calls 'pre_comment_author_email' hook on comment author's email address + * + * @param array $commentdata Contains information on the comment + * @return array Parsed comment information + */ function wp_filter_comment($commentdata) { $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', $commentdata['comment_agent']); @@ -378,7 +638,18 @@ function wp_filter_comment($commentdata) { return $commentdata; } - +/** + * wp_throttle_comment_flood() - {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.1.0 + * + * @param unknown_type $block {@internal Missing Description}} + * @param unknown_type $time_lastcomment {@internal Missing Description}} + * @param unknown_type $time_newcomment {@internal Missing Description}} + * @return unknown {@internal Missing Description}} + */ function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { if ( $block ) // a plugin has already blocked... we'll let that decision stand return $block; @@ -387,14 +658,28 @@ function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) return false; } - +/** + * wp_new_comment() - Parses and adds a new comment to the database + * + * {@internal Missing Long Description}} + * + * @since 1.5.0 + * @uses apply_filters() Calls 'preprocess_comment' hook on $commentdata parameter array before processing + * @uses do_action() Calls 'comment_post' hook on $comment_ID returned from adding the comment and if the comment was approved. + * @uses wp_filter_comment() Used to filter comment before adding comment + * @uses wp_allow_comment() checks to see if comment is approved. + * @uses wp_insert_comment() Does the actual comment insertion to the database + * + * @param array $commentdata Contains information on the comment + * @return int The ID of the comment after adding. + */ function wp_new_comment( $commentdata ) { $commentdata = apply_filters('preprocess_comment', $commentdata); $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; $commentdata['user_ID'] = (int) $commentdata['user_ID']; - $commentdata['comment_author_IP'] = preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] ); + $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] ); $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT']; $commentdata['comment_date'] = current_time('mysql'); @@ -421,7 +706,17 @@ function wp_new_comment( $commentdata ) { return $comment_ID; } - +/** + * wp_set_comment_status() - Sets the status of comment ID + * + * {@internal Missing Long Description}} + * + * @since 1.0.0 + * + * @param int $comment_id Comment ID + * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'delete' + * @return bool False on failure or deletion and true on success. + */ function wp_set_comment_status($comment_id, $comment_status) { global $wpdb; @@ -454,7 +749,17 @@ function wp_set_comment_status($comment_id, $comment_status) { return true; } - +/** + * wp_update_comment() - Parses and updates an existing comment in the database + * + * {@internal Missing Long Description}} + * + * @since 2.0.0 + * @uses $wpdb + * + * @param array $commentarr Contains information on the comment + * @return int Comment was updated if value is 1, or was not updated if value is 0. + */ function wp_update_comment($commentarr) { global $wpdb; @@ -477,7 +782,7 @@ function wp_update_comment($commentarr) { $comment_date_gmt = get_gmt_from_date($comment_date); - $result = $wpdb->query( + $wpdb->query( "UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author', @@ -496,9 +801,85 @@ function wp_update_comment($commentarr) { return $rval; } +/** + * wp_defer_comment_counting() - Whether to defer comment counting + * + * When setting $defer to true, all post comment counts will not be updated + * until $defer is set to false. When $defer is set to false, then all + * previously deferred updated post comment counts will then be automatically + * updated without having to call wp_update_comment_count() after. + * + * @since 2.5 + * @staticvar bool $_defer + * + * @param bool $defer + * @return unknown + */ +function wp_defer_comment_counting($defer=null) { + static $_defer = false; + + if ( is_bool($defer) ) { + $_defer = $defer; + // flush any deferred counts + if ( !$defer ) + wp_update_comment_count( null, true ); + } + + return $_defer; +} + +/** + * wp_update_comment_count() - Updates the comment count for post(s) + * + * When $do_deferred is false (is by default) and the comments have been + * set to be deferred, the post_id will be added to a queue, which will + * be updated at a later date and only updated once per post ID. + * + * If the comments have not be set up to be deferred, then the post will + * be updated. When $do_deferred is set to true, then all previous deferred + * post IDs will be updated along with the current $post_id. + * + * @since 2.1.0 + * @see wp_update_comment_count_now() For what could cause a false return value + * + * @param int $post_id Post ID + * @param bool $do_deferred Whether to process previously deferred post comment counts + * @return bool True on success, false on failure + */ +function wp_update_comment_count($post_id, $do_deferred=false) { + static $_deferred = array(); + + if ( $do_deferred ) { + $_deferred = array_unique($_deferred); + foreach ( $_deferred as $i => $_post_id ) { + wp_update_comment_count_now($_post_id); + unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */ + } + } + + if ( wp_defer_comment_counting() ) { + $_deferred[] = $post_id; + return true; + } + elseif ( $post_id ) { + return wp_update_comment_count_now($post_id); + } + +} -function wp_update_comment_count($post_id) { - global $wpdb, $comment_count_cache; +/** + * wp_update_comment_count_now() - Updates the comment count for the post + * + * @since 2.5 + * @uses $wpdb + * @uses do_action() Calls 'wp_update_comment_count' hook on $post_id, $new, and $old + * @uses do_action() Calls 'edit_posts' hook on $post_id and $post + * + * @param int $post_id Post ID + * @return bool False on '0' $post_id or if post with ID does not exist. True on success. + */ +function wp_update_comment_count_now($post_id) { + global $wpdb; $post_id = (int) $post_id; if ( !$post_id ) return false; @@ -508,7 +889,6 @@ function wp_update_comment_count($post_id) { $old = (int) $post->comment_count; $new = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'"); $wpdb->query("UPDATE $wpdb->posts SET comment_count = '$new' WHERE ID = '$post_id'"); - $comment_count_cache[$post_id] = $new; if ( 'page' == $post->post_type ) clean_page_cache( $post_id ); @@ -521,11 +901,22 @@ function wp_update_comment_count($post_id) { return true; } - // // Ping and trackback functions. // +/** + * discover_pingback_server_uri() - Finds a pingback server URI based on the given URL + * + * {@internal Missing Long Description}} + * + * @since 1.5.0 + * @uses $wp_version + * + * @param string $url URL to ping + * @param int $timeout_bytes Number of bytes to timeout at. Prevents big file downloads, default is 2048. + * @return bool|string False on failure, string containing URI on success. + */ function discover_pingback_server_uri($url, $timeout_bytes = 2048) { global $wp_version; @@ -535,7 +926,6 @@ function discover_pingback_server_uri($url, $timeout_bytes = 2048) { $pingback_str_dquote = 'rel="pingback"'; $pingback_str_squote = 'rel=\'pingback\''; $x_pingback_str = 'x-pingback: '; - $pingback_href_original_pos = 27; extract(parse_url($url), EXTR_SKIP); @@ -607,7 +997,14 @@ function discover_pingback_server_uri($url, $timeout_bytes = 2048) { return false; } - +/** + * do_all_pings() - {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.1.0 + * @uses $wpdb + */ function do_all_pings() { global $wpdb; @@ -624,16 +1021,25 @@ function do_all_pings() { } // Do Trackbacks - $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); - if ( is_array($trackbacks) ) { + $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'"); + if ( is_array($trackbacks) ) foreach ( $trackbacks as $trackback ) - do_trackbacks($trackback->ID); - } + do_trackbacks($trackback); //Do Update Services/Generic Pings generic_ping(); } +/** + * do_trackbacks() - {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 1.5.0 + * @uses $wpdb + * + * @param int $post_id Post ID to do trackbacks on + */ function do_trackbacks($post_id) { global $wpdb; @@ -650,11 +1056,7 @@ function do_trackbacks($post_id) { else $excerpt = apply_filters('the_excerpt', $post->post_excerpt); $excerpt = str_replace(']]>', ']]>', $excerpt); - $excerpt = strip_tags($excerpt); - if ( function_exists('mb_strcut') ) // For international trackbacks - $excerpt = mb_strcut($excerpt, 0, 252, get_option('blog_charset')) . '...'; - else - $excerpt = substr($excerpt, 0, 252) . '...'; + $excerpt = wp_html_excerpt($excerpt, 252) . '...'; $post_title = apply_filters('the_title', $post->post_title); $post_title = strip_tags($post_title); @@ -672,23 +1074,43 @@ function do_trackbacks($post_id) { } } - +/** + * generic_ping() - {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 1.2.0 + * + * @param int $post_id Post ID. Not actually used. + * @return int Same as Post ID from parameter + */ function generic_ping($post_id = 0) { $services = get_option('ping_sites'); - $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines - $services = trim($services); - if ( '' != $services ) { - $services = explode("\n", $services); - foreach ( (array) $services as $service ) + + $services = explode("\n", $services); + foreach ( (array) $services as $service ) { + $service = trim($service); + if ( '' != $service ) weblog_ping($service); } return $post_id; } - +/** + * pingback() - Pings back the links found in a post + * + * {@internal Missing Long Description}} + * + * @since 0.71 + * @uses $wp_version + * @uses IXR_Client + * + * @param string $content {@internal Missing Description}} + * @param int $post_ID {@internal Missing Description}} + */ function pingback($content, $post_ID) { - global $wp_version, $wpdb; + global $wp_version; include_once(ABSPATH . WPINC . '/class-IXR.php'); // original code by Mort (http://mort.mine.nu:8080) @@ -752,7 +1174,16 @@ function pingback($content, $post_ID) { } } - +/** + * privacy_ping_filter() - {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.1.0 + * + * @param unknown_type $sites {@internal Missing Description}} + * @return unknown {@internal Missing Description}} + */ function privacy_ping_filter($sites) { if ( '0' != get_option('blog_public') ) return $sites; @@ -760,7 +1191,21 @@ function privacy_ping_filter($sites) { return ''; } -// Send a Trackback +/** + * trackback() - Send a Trackback + * + * {@internal Missing Long Description}} + * + * @since 0.71 + * @uses $wpdb + * @uses $wp_version WordPress version + * + * @param string $trackback_url {@internal Missing Description}} + * @param string $title {@internal Missing Description}} + * @param string $excerpt {@internal Missing Description}} + * @param int $ID {@internal Missing Description}} + * @return unknown {@internal Missing Description}} + */ function trackback($trackback_url, $title, $excerpt, $ID) { global $wpdb, $wp_version; @@ -792,7 +1237,18 @@ function trackback($trackback_url, $title, $excerpt, $ID) { return $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = '$ID'"); } - +/** + * weblog_ping() - {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 1.2.0 + * @uses $wp_version + * @uses IXR_Client + * + * @param unknown_type $server + * @param unknown_type $path + */ function weblog_ping($server = '', $path = '') { global $wp_version; include_once(ABSPATH . WPINC . '/class-IXR.php'); @@ -813,12 +1269,34 @@ function weblog_ping($server = '', $path = '') { // Cache // +/** + * clean_comment_cache() - Removes comment ID from the comment cache + * + * @since 2.3.0 + * @package WordPress + * @subpackage Cache + * + * @param int $id Comment ID to remove from cache + */ function clean_comment_cache($id) { wp_cache_delete($id, 'comment'); } +/** + * update_comment_cache() - Updates the comment cache of given comments + * + * Will add the comments in $comments to the cache. If comment ID already + * exists in the comment cache then it will not be updated. + * + * The comment is added to the cache using the comment group with the key + * using the ID of the comments. + * + * @since 2.3.0 + * + * @param array $comments Array of comment row objects + */ function update_comment_cache($comments) { - foreach ( $comments as $comment ) + foreach ( (array) $comments as $comment ) wp_cache_add($comment->comment_ID, $comment, 'comment'); } diff --git a/wp-includes/compat.php b/wp-includes/compat.php index a4914b56..9eb18d4d 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -1,102 +1,12 @@ - if (get_class($object) == strtolower($class)) { - return true; - } else { - return is_subclass_of($object, $class); - } - } -} - -if (!function_exists('ob_clean')) { - function ob_clean() { - // by Aidan Lister - if (@ob_end_clean()) { - return ob_start(); - } - return false; - } -} - - -/* Added in PHP 4.3.0 */ - -function printr($var, $do_not_echo = false) { - // from php.net/print_r user contributed notes - ob_start(); - print_r($var); - $code = htmlentities(ob_get_contents()); - ob_clean(); - if (!$do_not_echo) { - echo "
    $code
    "; - } - ob_end_clean(); - return $code; -} - -/* compatibility with PHP versions older than 4.3 */ -if ( !function_exists('file_get_contents') ) { - function file_get_contents( $file ) { - $file = file($file); - return !$file ? false : implode('', $file); - } -} - -if (!defined('CASE_LOWER')) { - define('CASE_LOWER', 0); -} - -if (!defined('CASE_UPPER')) { - define('CASE_UPPER', 1); -} - - /** - * Replace array_change_key_case() + * WordPress implementation for PHP functions missing from older PHP versions. * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_change_key_case - * @author Stephan Schmidt - * @author Aidan Lister - * @version $Revision: 6070 $ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (user_error) + * @package PHP + * @access private */ -if (!function_exists('array_change_key_case')) { - function array_change_key_case($input, $case = CASE_LOWER) - { - if (!is_array($input)) { - user_error('array_change_key_case(): The argument should be an array', - E_USER_WARNING); - return false; - } - - $output = array (); - $keys = array_keys($input); - $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; - - foreach ($keys as $key) { - $output[$casefunc($key)] = $input[$key]; - } - - return $output; - } -} + +// Added in PHP 5.0 if (!function_exists('http_build_query')) { function http_build_query($data, $prefix=null, $sep=null) { @@ -140,11 +50,50 @@ if ( !function_exists('_') ) { } } -// Added in PHP 5.0 if (!function_exists('stripos')) { function stripos($haystack, $needle, $offset = 0) { return strpos(strtolower($haystack), strtolower($needle), $offset); } } +if ( ! function_exists('hash_hmac') ): +function hash_hmac($algo, $data, $key, $raw_output = false) { + $packs = array('md5' => 'H32', 'sha1' => 'H40'); + + if ( !isset($packs[$algo]) ) + return false; + + $pack = $packs[$algo]; + + if (strlen($key) > 64) + $key = pack($pack, $algo($key)); + else if (strlen($key) < 64) + $key = str_pad($key, 64, chr(0)); + + $ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64)); + $opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64)); + + return $algo($opad . pack($pack, $algo($ipad . $data))); +} +endif; + +if ( ! function_exists('mb_strcut') ): + function mb_strcut( $str, $start, $length=null, $encoding=null ) { + return _mb_strcut($str, $start, $length, $encoding); + } +endif; + +function _mb_strcut( $str, $start, $length=null, $encoding=null ) { + // the solution below, works only for utf-8, so in case of a different + // charset, just use built-in substr + $charset = get_option( 'blog_charset' ); + if ( !in_array( $charset, array('utf8', 'utf-8', 'UTF8', 'UTF-8') ) ) { + return is_null( $length )? substr( $str, $start ) : substr( $str, $start, $length); + } + // use the regex unicode support to separate the UTF-8 characters into an array + preg_match_all( '/./us', $str, $match ); + $chars = is_null( $length )? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length ); + return implode( '', $chars ); +} + ?> diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 3fc94e87..857de94d 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -1,4 +1,16 @@ posts + */ $tableposts = $wpdb->posts; + +/** + * The name of the Users table + * @global string $tableusers + * @deprecated Use $wpdb->users + */ $tableusers = $wpdb->users; + +/** + * The name of the Categories table + * @global string $tablecategories + * @deprecated Use $wpdb->categories + */ $tablecategories = $wpdb->categories; + +/** + * The name of the post to category table + * @global string $tablepost2cat + * @deprecated Use $wpdb->post2cat; + */ $tablepost2cat = $wpdb->post2cat; + +/** + * The name of the comments table + * @global string $tablecomments + * @deprecated Use $wpdb->comments; + */ $tablecomments = $wpdb->comments; + +/** + * The name of the links table + * @global string $tablelinks + * @deprecated Use $wpdb->links; + */ $tablelinks = $wpdb->links; + +/** + * @global string $tablelinkcategories + * @deprecated Not used anymore; + */ $tablelinkcategories = 'linkcategories_is_gone'; + +/** + * The name of the options table + * @global string $tableoptions + * @deprecated Use $wpdb->options; + */ $tableoptions = $wpdb->options; + +/** + * The name of the postmeta table + * @global string $tablepostmeta + * @deprecated Use $wpdb->postmeta; + */ $tablepostmeta = $wpdb->postmeta; /* * Deprecated functions come here to die. */ -// Use get_post(). +/** + * get_postdata() - Entire Post data + * + * @since 0.71 + * @deprecated Use get_post() + * @see get_post() + * + * @param int $postid + * @return array + */ function get_postdata($postid) { + _deprecated_function(__FUNCTION__, '0.0', 'get_post()'); + $post = &get_post($postid); $postdata = array ( @@ -43,17 +111,36 @@ function get_postdata($postid) { return $postdata; } -// Use the new post loop. +/** + * start_wp() - Sets up the WordPress Loop + * + * @since 1.0.1 + * @deprecated Since 1.5 - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop} + */ function start_wp() { global $wp_query, $post; + _deprecated_function(__FUNCTION__, '1.5', __('new WordPress Loop') ); + // Since the old style loop is being used, advance the query iterator here. $wp_query->next_post(); setup_postdata($post); } +/** + * the_category_ID() - Return or Print Category ID + * + * @since 0.71 + * @deprecated use get_the_category() + * @see get_the_category() + * + * @param bool $echo + * @return null|int + */ function the_category_ID($echo = true) { + _deprecated_function(__FUNCTION__, '0.0', 'get_the_category()'); + // Grab the first cat in the list. $categories = get_the_category(); $cat = $categories[0]->term_id; @@ -64,8 +151,21 @@ function the_category_ID($echo = true) { return $cat; } +/** + * the_category_head() - Print category with optional text before and after + * + * @since 0.71 + * @deprecated use get_the_category_by_ID() + * @see get_the_category_by_ID() + * + * @param string $before + * @param string $after + */ function the_category_head($before='', $after='') { global $currentcat, $previouscat; + + _deprecated_function(__FUNCTION__, '0.0', 'get_the_category_by_ID()'); + // Grab the first cat in the list. $categories = get_the_category(); $currentcat = $categories[0]->category_id; @@ -77,9 +177,24 @@ function the_category_head($before='', $after='') { } } -// Use previous_post_link(). +/** + * previous_post() - Prints link to the previous post + * + * @since 1.5 + * @deprecated Use previous_post_link() + * @see previous_post_link() + * + * @param string $format + * @param string $previous + * @param string $title + * @param string $in_same_cat + * @param int $limitprev + * @param string $excluded_categories + */ function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { + _deprecated_function(__FUNCTION__, '0.0', 'previous_post_link()'); + if ( empty($in_same_cat) || 'no' == $in_same_cat ) $in_same_cat = false; else @@ -98,8 +213,22 @@ function previous_post($format='%', $previous='previous post: ', $title='yes', $ echo $format; } -// Use next_post_link(). +/** + * next_post() - Prints link to the next post + * + * @since 0.71 + * @deprecated Use next_post_link() + * @see next_post_link() + * + * @param string $format + * @param string $previous + * @param string $title + * @param string $in_same_cat + * @param int $limitprev + * @param string $excluded_categories + */ function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { + _deprecated_function(__FUNCTION__, '0.0', 'next_post_link()'); if ( empty($in_same_cat) || 'no' == $in_same_cat ) $in_same_cat = false; @@ -119,24 +248,59 @@ function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat= echo $format; } -// -// Use current_user_can() for these. -// - -/* returns true if $user_id can create a new post */ +/** + * user_can_create_post() - Whether user can create a post + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $blog_id Not Used + * @param int $category_id Not Used + * @return bool + */ function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { + _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()'); + $author_data = get_userdata($user_id); return ($author_data->user_level > 1); } -/* returns true if $user_id can create a new post */ +/** + * user_can_create_draft() - Whether user can create a post + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $blog_id Not Used + * @param int $category_id Not Used + * @return bool + */ function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { + _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()'); + $author_data = get_userdata($user_id); return ($author_data->user_level >= 1); } -/* returns true if $user_id can edit $post_id */ +/** + * user_can_edit_post() - Whether user can edit a post + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool + */ function user_can_edit_post($user_id, $post_id, $blog_id = 1) { + _deprecated_function(__FUNCTION__, '0', 'current_user_can()'); + $author_data = get_userdata($user_id); $post = get_post($post_id); $post_author_data = get_userdata($post->post_author); @@ -150,37 +314,118 @@ function user_can_edit_post($user_id, $post_id, $blog_id = 1) { } } -/* returns true if $user_id can delete $post_id */ +/** + * user_can_delete_post() - Whether user can delete a post + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool + */ function user_can_delete_post($user_id, $post_id, $blog_id = 1) { + _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()'); + // right now if one can edit, one can delete return user_can_edit_post($user_id, $post_id, $blog_id); } -/* returns true if $user_id can set new posts' dates on $blog_id */ +/** + * user_can_set_post_date() - Whether user can set new posts' dates + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $blog_id Not Used + * @param int $category_id Not Used + * @return bool + */ function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { + _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()'); + $author_data = get_userdata($user_id); return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); } /* returns true if $user_id can edit $post_id's date */ +/** + * user_can_edit_post_date() - Whether user can delete a post + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool + */ function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { + _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()'); + $author_data = get_userdata($user_id); return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); } /* returns true if $user_id can edit $post_id's comments */ +/** + * user_can_edit_post_comments() - Whether user can delete a post + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool + */ function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { + _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()'); + // right now if one can edit a post, one can edit comments made on it return user_can_edit_post($user_id, $post_id, $blog_id); } /* returns true if $user_id can delete $post_id's comments */ +/** + * user_can_delete_post_comments() - Whether user can delete a post + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool + */ function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { + _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()'); + // right now if one can edit comments, one can delete comments return user_can_edit_post_comments($user_id, $post_id, $blog_id); } +/** + * user_can_edit_user() - Can user can edit other user + * + * @since 1.5 + * @deprecated Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $other_user + * @return bool + */ function user_can_edit_user($user_id, $other_user) { + _deprecated_function(__FUNCTION__, '0.0', 'current_user_can()'); + $user = get_userdata($user_id); $other = get_userdata($other_user); if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) @@ -189,51 +434,54 @@ function user_can_edit_user($user_id, $other_user) { return false; } -/** function get_linksbyname() - ** Gets the links associated with category 'cat_name'. - ** Parameters: - ** cat_name (default 'noname') - The category name to use. If no - ** match is found uses all - ** before (default '') - the html to output before the link - ** after (default '
    ') - the html to output after the link - ** between (default ' ') - the html to output between the link/image - ** and it's description. Not used if no image or show_images == true - ** show_images (default true) - whether to show images (if defined). - ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', - ** 'url', 'description' or 'rating'. Or maybe owner. If you start the - ** name with an underscore the order will be reversed. - ** You can also specify 'rand' as the order which will return links in a - ** random order. - ** show_description (default true) - whether to show the description if - ** show_images=false/not defined - ** show_rating (default false) - show rating stars/chars - ** limit (default -1) - Limit to X entries. If not specified, all entries - ** are shown. - ** show_updated (default 0) - whether to show last updated timestamp - */ -function get_linksbyname($cat_name = "noname", $before = '', $after = '
    ', - $between = " ", $show_images = true, $orderby = 'id', - $show_description = true, $show_rating = false, - $limit = -1, $show_updated = 0) { - global $wpdb; - $cat_id = -1; - $cat = get_term_by('name', $cat_name, 'link_category'); - if ( $cat ) - $cat_id = $cat->term_id; - - get_links($cat_id, $before, $after, $between, $show_images, $orderby, - $show_description, $show_rating, $limit, $show_updated); -} - -/** function wp_get_linksbyname() - ** Gets the links associated with the named category. - ** Parameters: - ** category (no default) - The category to use. - **/ -function wp_get_linksbyname($category, $args = '') { - global $wpdb; +/** + * get_linksbyname() - Gets the links associated with category $cat_name. + * + * @since 0.71 + * @deprecated Use get_links() + * @see get_links() + * + * @param string $cat_name Optional. The category name to use. If no match is found uses all. + * @param string $before Optional. The html to output before the link. + * @param string $after Optional. The html to output after the link. + * @param string $between Optional. The html to output between the link/image and it's description. Not used if no image or $show_images is true. + * @param bool $show_images Optional. Whether to show images (if defined). + * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner. + * If you start the name with an underscore the order will be reversed. You can also specify 'rand' as the order which will return links in a + * random order. + * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. + * @param bool $show_rating Optional. Show rating stars/chars. + * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. + * @param int $show_updated Optional. Whether to show last updated timestamp + */ +function get_linksbyname($cat_name = "noname", $before = '', $after = '
    ', $between = " ", $show_images = true, $orderby = 'id', + $show_description = true, $show_rating = false, + $limit = -1, $show_updated = 0) { + _deprecated_function(__FUNCTION__, '0.0', 'get_links()'); + $cat_id = -1; $cat = get_term_by('name', $cat_name, 'link_category'); + if ( $cat ) + $cat_id = $cat->term_id; + + get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); +} + +/** + * wp_get_linksbyname() - Gets the links associated with the named category. + * + * @since 1.0.1 + * @deprecated Use wp_get_links() + * @see wp_get_links() + * + * @param string $category The category to use. + * @param string $args + * @return bool|null + */ +function wp_get_linksbyname($category, $args = '') { + _deprecated_function(__FUNCTION__, '0.0', 'wp_get_links()'); + + $cat = get_term_by('name', $category, 'link_category'); if ( !$cat ) return false; $cat_id = $cat->term_id; @@ -242,161 +490,206 @@ function wp_get_linksbyname($category, $args = '') { wp_get_links($args); } -/** function get_linkobjectsbyname() - ** Gets an array of link objects associated with category 'cat_name'. - ** Parameters: - ** cat_name (default 'noname') - The category name to use. If no - ** match is found uses all - ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', - ** 'url', 'description', or 'rating'. Or maybe owner. If you start the - ** name with an underscore the order will be reversed. - ** You can also specify 'rand' as the order which will return links in a - ** random order. - ** limit (default -1) - Limit to X entries. If not specified, all entries - ** are shown. - ** - ** Use this like: - ** $links = get_linkobjectsbyname('fred'); - ** foreach ($links as $link) { - ** echo '
  • '.$link->link_name.'
  • '; - ** } - **/ +/** + * get_linkobjectsbyname() - Gets an array of link objects associated with category $cat_name. + * + * + * $links = get_linkobjectsbyname('fred'); + * foreach ($links as $link) { + * echo '
  • '.$link->link_name.'
  • '; + * } + *
    + * + * @since 1.0.1 + * @deprecated Use get_linkobjects() + * @see get_linkobjects() + * + * @param string $cat_name The category name to use. If no match is found uses all. + * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 'description', or 'rating'. + * Or maybe owner. If you start the name with an underscore the order will be reversed. You can also + * specify 'rand' as the order which will return links in a random order. + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @return unknown + */ function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { - global $wpdb; - $cat_id = -1; - $cat = get_term_by('name', $cat_name, 'link_category'); - if ( $cat ) - $cat_id = $cat->term_id; - - return get_linkobjects($cat_id, $orderby, $limit); -} - -/** function get_linkobjects() - ** Gets an array of link objects associated with category n. - ** Parameters: - ** category (default -1) - The category to use. If no category supplied - ** uses all - ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', - ** 'url', 'description', or 'rating'. Or maybe owner. If you start the - ** name with an underscore the order will be reversed. - ** You can also specify 'rand' as the order which will return links in a - ** random order. - ** limit (default -1) - Limit to X entries. If not specified, all entries - ** are shown. - ** - ** Use this like: - ** $links = get_linkobjects(1); - ** if ($links) { - ** foreach ($links as $link) { - ** echo '
  • '.$link->link_name.'
    '.$link->link_description.'
  • '; - ** } - ** } - ** Fields are: - ** link_id - ** link_url - ** link_name - ** link_image - ** link_target - ** link_category - ** link_description - ** link_visible - ** link_owner - ** link_rating - ** link_updated - ** link_rel - ** link_notes - **/ -// Deprecate in favor of get_linkz(). + _deprecated_function(__FUNCTION__, '0.0', 'get_linkobjects()'); + + $cat_id = -1; + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( $cat ) + $cat_id = $cat->term_id; + + return get_linkobjects($cat_id, $orderby, $limit); +} + +/** + * get_linkobjects() - Gets an array of link objects associated with category n. + * + * Usage: + * + * $links = get_linkobjects(1); + * if ($links) { + * foreach ($links as $link) { + * echo '
  • '.$link->link_name.'
    '.$link->link_description.'
  • '; + * } + * } + *
    + * + * Fields are: + *
      + *
    1. link_id
    2. + *
    3. link_url
    4. + *
    5. link_name
    6. + *
    7. link_image
    8. + *
    9. link_target
    10. + *
    11. link_category
    12. + *
    13. link_description
    14. + *
    15. link_visible
    16. + *
    17. link_owner
    18. + *
    19. link_rating
    20. + *
    21. link_updated
    22. + *
    23. link_rel
    24. + *
    25. link_notes
    26. + *
    + * + * @since 1.0.1 + * @deprecated Use get_bookmarks() + * @see get_bookmarks() + * + * @param int $category The category to use. If no category supplied uses all + * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', + * 'description', or 'rating'. Or maybe owner. If you start the name with an + * underscore the order will be reversed. You can also specify 'rand' as the + * order which will return links in a random order. + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @return unknown + */ function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { - global $wpdb; + _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()'); - $links = get_bookmarks("category=$category&orderby=$orderby&limit=$limit"); + $links = get_bookmarks("category=$category&orderby=$orderby&limit=$limit"); - $links_array = array(); - foreach ($links as $link) { - $links_array[] = $link; - } + $links_array = array(); + foreach ($links as $link) + $links_array[] = $link; + + return $links_array; +} - return $links_array; -} - -/** function get_linksbyname_withrating() - ** Gets the links associated with category 'cat_name' and display rating stars/chars. - ** Parameters: - ** cat_name (default 'noname') - The category name to use. If no - ** match is found uses all - ** before (default '') - the html to output before the link - ** after (default '
    ') - the html to output after the link - ** between (default ' ') - the html to output between the link/image - ** and it's description. Not used if no image or show_images == true - ** show_images (default true) - whether to show images (if defined). - ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', - ** 'url' or 'description'. Or maybe owner. If you start the - ** name with an underscore the order will be reversed. - ** You can also specify 'rand' as the order which will return links in a - ** random order. - ** show_description (default true) - whether to show the description if - ** show_images=false/not defined - ** limit (default -1) - Limit to X entries. If not specified, all entries - ** are shown. - ** show_updated (default 0) - whether to show last updated timestamp - */ -function get_linksbyname_withrating($cat_name = "noname", $before = '', - $after = '
    ', $between = " ", - $show_images = true, $orderby = 'id', - $show_description = true, $limit = -1, $show_updated = 0) { - - get_linksbyname($cat_name, $before, $after, $between, $show_images, - $orderby, $show_description, true, $limit, $show_updated); -} - -/** function get_links_withrating() - ** Gets the links associated with category n and display rating stars/chars. - ** Parameters: - ** category (default -1) - The category to use. If no category supplied - ** uses all - ** before (default '') - the html to output before the link - ** after (default '
    ') - the html to output after the link - ** between (default ' ') - the html to output between the link/image - ** and it's description. Not used if no image or show_images == true - ** show_images (default true) - whether to show images (if defined). - ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', - ** 'url' or 'description'. Or maybe owner. If you start the - ** name with an underscore the order will be reversed. - ** You can also specify 'rand' as the order which will return links in a - ** random order. - ** show_description (default true) - whether to show the description if - ** show_images=false/not defined . - ** limit (default -1) - Limit to X entries. If not specified, all entries - ** are shown. - ** show_updated (default 0) - whether to show last updated timestamp - */ -function get_links_withrating($category = -1, $before = '', $after = '
    ', - $between = " ", $show_images = true, - $orderby = 'id', $show_description = true, - $limit = -1, $show_updated = 0) { - - get_links($category, $before, $after, $between, $show_images, $orderby, - $show_description, true, $limit, $show_updated); -} - -/** function get_get_autotoggle() - ** Gets the auto_toggle setting of category n. - ** Parameters: id (default 0) - The category to get. If no category supplied - ** uses 0 +/** + * get_linksbyname_withrating() - Gets the links associated with category 'cat_name' and display rating stars/chars. + * + * @since 0.71 + * @deprecated Use get_bookmarks() + * @see get_bookmarks() + * + * @param string $cat_name The category name to use. If no match is found uses all + * @param string $before The html to output before the link + * @param string $after The html to output after the link + * @param string $between The html to output between the link/image and it's description. Not used if no image or show_images is true + * @param bool $show_images Whether to show images (if defined). + * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', + * 'description', or 'rating'. Or maybe owner. If you start the name with an + * underscore the order will be reversed. You can also specify 'rand' as the + * order which will return links in a random order. + * @param bool $show_description Whether to show the description if show_images=false/not defined + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @param int $show_updated Whether to show last updated timestamp + */ +function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '
    ', $between = " ", + $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { + _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()'); + + get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); +} + +/** + * get_links_withrating() - Gets the links associated with category n and display rating stars/chars. + * + * @since 0.71 + * @deprecated Use get_bookmarks() + * @see get_bookmarks() + * + * @param int $category The category to use. If no category supplied uses all + * @param string $before The html to output before the link + * @param string $after The html to output after the link + * @param string $between The html to output between the link/image and it's description. Not used if no image or show_images == true + * @param bool $show_images Whether to show images (if defined). + * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', + * 'description', or 'rating'. Or maybe owner. If you start the name with an + * underscore the order will be reversed. You can also specify 'rand' as the + * order which will return links in a random order. + * @param bool $show_description Whether to show the description if show_images=false/not defined. + * @param string $limit Limit to X entries. If not specified, all entries are shown. + * @param int $show_updated Whether to show last updated timestamp + */ +function get_links_withrating($category = -1, $before = '', $after = '
    ', $between = " ", $show_images = true, + $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { + _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()'); + + get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); +} + +/** + * get_autotoggle() - Gets the auto_toggle setting + * + * @since 0.71 + * @deprecated No alternative function available + * + * @param int $id The category to get. If no category supplied uses 0 + * @return int Only returns 0. */ function get_autotoggle($id = 0) { + _deprecated_function(__FUNCTION__, '0.0' ); return 0; } -// Use wp_list_cats(). -function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) { +/** + * @since 0.71 + * @deprecated Use wp_list_categories() + * @see wp_list_categories() + * + * @param int $optionall + * @param string $all + * @param string $sort_column + * @param string $sort_order + * @param string $file + * @param bool $list + * @param int $optiondates + * @param int $optioncount + * @param int $hide_empty + * @param int $use_desc_for_title + * @param bool $children + * @param int $child_of + * @param int $categories + * @param int $recurse + * @param string $feed + * @param string $feed_image + * @param string $exclude + * @param bool $hierarchical + * @return unknown + */ +function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, + $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, + $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) { + _deprecated_function(__FUNCTION__, '0.0', 'wp_list_categories()'); + $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical'); return wp_list_cats($query); } +/** + * @since 1.2 + * @deprecated Use wp_list_categories() + * @see wp_list_categories() + * + * @param string|array $args + * @return unknown + */ function wp_list_cats($args = '') { + _deprecated_function(__FUNCTION__, '0.0', 'wp_list_categories()'); + $r = wp_parse_args( $args ); // Map to new names. @@ -417,9 +710,27 @@ function wp_list_cats($args = '') { return wp_list_categories($r); } +/** + * @since 0.71 + * @deprecated Use wp_dropdown_categories() + * @see wp_dropdown_categories() + * + * @param int $optionall + * @param string $all + * @param string $orderby + * @param string $order + * @param int $show_last_update + * @param int $show_count + * @param int $hide_empty + * @param bool $optionnone + * @param int $selected + * @param int $exclude + * @return unknown + */ function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', - $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = FALSE, + $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false, $selected = 0, $exclude = 0) { + _deprecated_function(__FUNCTION__, '0.0', 'wp_dropdown_categories()'); $show_option_all = ''; if ( $optionall ) @@ -435,32 +746,103 @@ function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = ' return wp_dropdown_categories($query); } -// Use wp_print_scripts() or WP_Scripts. +/** + * @since 2.1 + * @deprecated Use wp_print_scripts() or WP_Scripts. + * @see wp_print_scripts() + * @see WP_Scripts + */ function tinymce_include() { + _deprecated_function(__FUNCTION__, '0.0', 'wp_print_scripts()/WP_Scripts'); + wp_print_script('wp_tiny_mce'); } +/** + * @since 1.2 + * @deprecated Use wp_list_authors() + * @see wp_list_authors() + * + * @param bool $optioncount + * @param bool $exclude_admin + * @param bool $show_fullname + * @param bool $hide_empty + * @param string $feed + * @param string $feed_image + * @return unknown + */ function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { + _deprecated_function(__FUNCTION__, '0.0', 'wp_list_authors()'); + $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image'); return wp_list_authors($args); } +/** + * @since 1.0.1 + * @deprecated Use wp_get_post_categories() + * @see wp_get_post_categories() + * + * @param int $blogid Not Used + * @param int $post_ID + * @return unknown + */ function wp_get_post_cats($blogid = '1', $post_ID = 0) { + _deprecated_function(__FUNCTION__, '0.0', 'wp_get_post_categories()'); return wp_get_post_categories($post_ID); } +/** + * wp_set_post_cats() - Sets the categories that the post id belongs to. + * + * @since 1.0.1 + * @deprecated Use wp_set_post_categories() + * @see wp_set_post_categories() + * + * @param int $blogid Not used + * @param int $post_ID + * @param array $post_categories + * @return unknown + */ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { + _deprecated_function(__FUNCTION__, '0.0', 'wp_set_post_categories()'); return wp_set_post_categories($post_ID, $post_categories); } -// Use wp_get_archives(). +/** + * @since 0.71 + * @deprecated Use wp_get_archives() + * @see wp_get_archives() + * + * @param string $type + * @param string $limit + * @param string $format + * @param string $before + * @param string $after + * @param bool $show_post_count + * @return unknown + */ function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { + _deprecated_function(__FUNCTION__, '0.0', 'wp_get_archives()'); $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); return wp_get_archives($args); } -// Use get_author_posts_url(). +/** + * get_author_link() - Returns or Prints link to the author's posts + * + * @since 1.2 + * @deprecated Use get_author_posts_url() + * @see get_author_posts_url() + * + * @param bool $echo Optional. + * @param int $author_id Required. + * @param string $author_nicename Optional. + * @return string|null + */ function get_author_link($echo = false, $author_id, $author_nicename = '') { + _deprecated_function(__FUNCTION__, '0.0', 'get_author_posts_url()'); + $link = get_author_posts_url($author_id, $author_nicename); if ( $echo ) @@ -468,36 +850,85 @@ function get_author_link($echo = false, $author_id, $author_nicename = '') { return $link; } -// Use wp_link_pages(). -function link_pages($before='
    ', $after='
    ', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') { +/** + * link_pages() - Print list of pages based on arguments + * + * @since 0.71 + * @deprecated Use wp_link_pages() + * @see wp_link_pages() + * + * @param string $before + * @param string $after + * @param string $next_or_number + * @param string $nextpagelink + * @param string $previouspagelink + * @param string $pagelink + * @param string $more_file + * @return string + */ +function link_pages($before='
    ', $after='
    ', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', + $pagelink='%', $more_file='') { + _deprecated_function(__FUNCTION__, '0.0', 'wp_link_pages()'); + $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); return wp_link_pages($args); } -// Use get_option(). +/** + * get_settings() - Get value based on option + * + * @since 0.71 + * @deprecated Use get_option() + * @see get_option() + * + * @param string $option + * @return string + */ function get_settings($option) { + _deprecated_function(__FUNCTION__, '0.0', 'get_option()'); + return get_option($option); } -// Use the_permalink(). +/** + * permalink_link() - Print the permalink of the current post in the loop + * + * @since 0.71 + * @deprecated Use the_permalink() + * @see the_permalink() + */ function permalink_link() { + _deprecated_function(__FUNCTION__, '0.0', 'the_permalink()'); the_permalink(); } -// Use the_permalink_rss() -function permalink_single_rss($file = '') { +/** + * permalink_single_rss() - Print the permalink to the RSS feed + * + * @since 0.71 + * @deprecated Use the_permalink_rss() + * @see the_permalink_rss() + * + * @param string $file + */ +function permalink_single_rss($deprecated = '') { + _deprecated_function(__FUNCTION__, '0.0', 'the_permalink_rss()'); the_permalink_rss(); } -/** function wp_get_links() - ** Gets the links associated with category n. - ** Parameters: - ** category (no default) - The category to use. - ** or: - ** a query string - **/ +/** + * wp_get_links() - Gets the links associated with category. + * + * @see get_links() for argument information that can be used in $args + * @since 1.0.1 + * @deprecated Use get_bookmarks() + * @see get_bookmarks() + * + * @param string $args a query string + * @return null|string + */ function wp_get_links($args = '') { - global $wpdb; + _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()'); if ( strpos( $args, '=' ) === false ) { $cat_id = $args; @@ -517,44 +948,35 @@ function wp_get_links($args = '') { extract( $r, EXTR_SKIP ); return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); -} // end wp_get_links - -/** function get_links() - ** Gets the links associated with category n. - ** Parameters: - ** category (default -1) - The category to use. If no category supplied - ** uses all - ** before (default '') - the html to output before the link - ** after (default '
    ') - the html to output after the link - ** between (default ' ') - the html to output between the link/image - ** and its description. Not used if no image or show_images == true - ** show_images (default true) - whether to show images (if defined). - ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', - ** 'url', 'description', or 'rating'. Or maybe owner. If you start the - ** name with an underscore the order will be reversed. - ** You can also specify 'rand' as the order which will return links in a - ** random order. - ** show_description (default true) - whether to show the description if - ** show_images=false/not defined . - ** show_rating (default false) - show rating stars/chars - ** limit (default -1) - Limit to X entries. If not specified, all entries - ** are shown. - ** show_updated (default 0) - whether to show last updated timestamp - ** echo (default true) - whether to echo the results, or return them instead - */ -function get_links($category = -1, - $before = '', - $after = '
    ', - $between = ' ', - $show_images = true, - $orderby = 'name', - $show_description = true, - $show_rating = false, - $limit = -1, - $show_updated = 1, - $echo = true) { - - global $wpdb; +} + +/** + * get_links() - Gets the links associated with category by id. + * + * @since 0.71 + * @deprecated Use get_bookmarks() + * @see get_bookmarks() + * + * @param int $category The category to use. If no category supplied uses all + * @param string $before the html to output before the link + * @param string $after the html to output after the link + * @param string $between the html to output between the link/image and its description. + * Not used if no image or show_images == true + * @param bool $show_images whether to show images (if defined). + * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', + * 'description', or 'rating'. Or maybe owner. If you start the name with an + * underscore the order will be reversed. You can also specify 'rand' as the order + * which will return links in a random order. + * @param bool $show_description whether to show the description if show_images=false/not defined. + * @param bool $show_rating show rating stars/chars + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @param int $show_updated whether to show last updated timestamp + * @param bool $echo whether to echo the results, or return them instead + * @return null|string + */ +function get_links($category = -1, $before = '', $after = '
    ', $between = ' ', $show_images = true, $orderby = 'name', + $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) { + _deprecated_function(__FUNCTION__, '0.0', 'get_bookmarks()'); $order = 'ASC'; if ( substr($orderby, 0, 1) == '_' ) { @@ -633,20 +1055,24 @@ function get_links($category = -1, echo $output; } -/* - * function get_links_list() - * - * added by Dougal +/** + * get_links_list() - Output entire list of links by category * * Output a list of all links, listed by category, using the * settings in $wpdb->linkcategories and output it as a nested * HTML unordered list. * - * Parameters: - * order (default 'name') - Sort link categories by 'name' or 'id' - * hide_if_empty (default true) - Supress listing empty link categories + * @author Dougal + * @since 1.0.1 + * @deprecated Use get_categories() + * @see get_categories() + * + * @param string $order Sort link categories by 'name' or 'id' + * @param string $$deprecated Not Used */ -function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { +function get_links_list($order = 'name', $deprecated = '') { + _deprecated_function(__FUNCTION__, '0.0', 'get_categories()'); + $order = strtolower($order); // Handle link category sorting @@ -677,18 +1103,24 @@ function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { } } - -/** function links_popup_script() - ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/ - ** Show the link to the links popup and the number of links - ** Parameters: - ** text (default Links) - the text of the link - ** width (default 400) - the width of the popup window - ** height (default 400) - the height of the popup window - ** file (default linkspopup.php) - the page to open in the popup window - ** count (default true) - the number of links in the db +/** + * links_popup_script() - Show the link to the links popup and the number of links + * + * @author Fullo + * @link http://sprite.csr.unibo.it/fullo/ + * + * @since 0.71 + * @deprecated {@internal Use function instead is unknown}} + * + * @param string $text the text of the link + * @param int $width the width of the popup window + * @param int $height the height of the popup window + * @param string $file the page to open in the popup window + * @param bool $count the number of links in the db */ function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { + _deprecated_function(__FUNCTION__, '0.0' ); + if ( $count ) $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links"); @@ -702,17 +1134,32 @@ function links_popup_script($text = 'Links', $width=400, $height=400, $file='lin echo $javascript; } - +/** + * @since 1.0.1 + * @deprecated Use sanitize_bookmark_field() + * @see sanitize_bookmark_field() + * + * @param object $link + * @return unknown + */ function get_linkrating($link) { + _deprecated_function(__FUNCTION__, '0.0', 'sanitize_bookmark_field()'); return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); } -/** function get_linkcatname() - ** Gets the name of category n. - ** Parameters: id (default 0) - The category to get. If no category supplied - ** uses 0 +/** + * get_linkcatname() - Gets the name of category by id. + * + * @since 0.71 + * @deprecated Use get_category() + * @see get_category() + * + * @param int $id The category to get. If no category supplied uses 0 + * @return string */ function get_linkcatname($id = 0) { + _deprecated_function(__FUNCTION__, '0.0', 'get_category()'); + $id = (int) $id; if ( empty($id) ) @@ -729,4 +1176,111 @@ function get_linkcatname($id = 0) { return $cat->name; } +/** + * comment_rss_link() - Print RSS comment feed link + * + * @since 1.0.1 + * @deprecated Use post_comments_feed_link() + * @see post_comments_feed_link() + * + * @param string $link_text + * @param string $deprecated Not used + */ +function comments_rss_link($link_text = 'Comments RSS', $deprecated = '') { + _deprecated_function(__FUNCTION__, '0.0', 'post_comments_feed_link()'); + post_comments_feed_link($link_text); +} + +/** + * get_category_rss_link() - Print/Return link to category RSS2 feed + * + * @since 1.2 + * @deprecated Use get_category_feed_link() + * @see get_category_feed_link() + * + * @param bool $echo + * @param int $cat_ID + * @param string $deprecated Not used + * @return string|null + */ +function get_category_rss_link($echo = false, $cat_ID = 1, $deprecated = '') { + _deprecated_function(__FUNCTION__, '0.0', 'get_category_feed_link()'); + + $link = get_category_feed_link($cat_ID, 'rss2'); + + if ( $echo ) + echo $link; + return $link; +} + +/** + * get_author_rss_link() - Print/Return link to author RSS feed + * + * @since 1.2 + * @deprecated Use get_author_feed_link() + * @see get_author_feed_link() + * + * @param bool $echo + * @param int $author_id + * @param string $deprecated Not used + * @return string|null + */ +function get_author_rss_link($echo = false, $author_id = 1, $deprecated = '') { + _deprecated_function(__FUNCTION__, '0.0', 'get_author_feed_link()'); + + $link = get_author_feed_link($author_id); + if ( $echo ) + echo $link; + return $link; +} + +/** + * comments_rss() - Return link to the post RSS feed + * + * @since 1.5 + * @deprecated Use get_post_comments_feed_link() + * @see get_post_comments_feed_link() + * + * @param string $deprecated Not used + * @return string + */ +function comments_rss($deprecated = '') { + _deprecated_function(__FUNCTION__, '2.2', 'get_post_comments_feed_link()'); + return get_post_comments_feed_link(); +} + +/** + * create_user() - An alias of wp_create_user(). + * @param string $username The user's username. + * @param string $password The user's password. + * @param string $email The user's email (optional). + * @return int The new user's ID. + * @deprecated Use wp_create_user() + * @see wp_create_user() + */ +function create_user($username, $password, $email) { + _deprecated_function( __FUNCTION__, '2.0', 'wp_create_user()' ); + return wp_create_user($username, $password, $email); +} + +/** + * documentation_link() - Unused Admin function + * @since 2.0 + * @param string $deprecated Unknown + * @deprecated 2.5 + */ +function documentation_link( $deprecated = '' ) { + _deprecated_function( __FUNCTION__, '2.5', '' ); + return; +} + +/** + * gzip_compression() - Unused function + * + * @deprecated 2.5 +*/ + +function gzip_compression() { + return false; +} ?> \ No newline at end of file diff --git a/wp-includes/feed-atom-comments.php b/wp-includes/feed-atom-comments.php index ee9a73b4..e7c3c7cb 100644 --- a/wp-includes/feed-atom-comments.php +++ b/wp-includes/feed-atom-comments.php @@ -1,4 +1,10 @@ '; ?> @@ -11,18 +17,28 @@ echo '' if ( is_singular() ) printf(__('Comments on: %s'), get_the_title_rss()); elseif ( is_search() ) - printf(__('Comments for %s searching on %s'), get_bloginfo_rss( 'name' ), attribute_escape($wp_query->query_vars['s'])); + printf(__('Comments for %1$s searching on %2$s'), get_bloginfo_rss( 'name' ), attribute_escape(get_search_query())); else printf(__('Comments for %s'), get_bloginfo_rss( 'name' ) . get_wp_title_rss()); ?> - WordPress + + + + + + + + + + + - WordPress + - + @@ -42,6 +48,9 @@ $more = 1; + + + diff --git a/wp-includes/feed-rdf.php b/wp-includes/feed-rdf.php index 1f92b239..9be83012 100644 --- a/wp-includes/feed-rdf.php +++ b/wp-includes/feed-rdf.php @@ -1,10 +1,15 @@ '; ?> - - + hourly 1 2000-01-01T12:00+00:00 diff --git a/wp-includes/feed-rss.php b/wp-includes/feed-rss.php index 469e4bc8..fdeeed87 100644 --- a/wp-includes/feed-rss.php +++ b/wp-includes/feed-rss.php @@ -1,10 +1,16 @@ '; ?> - + <?php bloginfo_rss('name'); wp_title_rss(); ?> diff --git a/wp-includes/feed-rss2-comments.php b/wp-includes/feed-rss2-comments.php index 7bd5ae29..f75a792c 100644 --- a/wp-includes/feed-rss2-comments.php +++ b/wp-includes/feed-rss2-comments.php @@ -1,12 +1,18 @@ '; ?> - <?php @@ -17,10 +23,11 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; else printf(__('Comments for %s'), get_bloginfo_rss( 'name' ) . get_wp_title_rss()); ?> + - http://wordpress.org/?v= + - + post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) : ?> ]]> diff --git a/wp-includes/feed-rss2.php b/wp-includes/feed-rss2.php index 21d9b8e5..3274583d 100644 --- a/wp-includes/feed-rss2.php +++ b/wp-includes/feed-rss2.php @@ -1,24 +1,31 @@ '; ?> - > <?php bloginfo_rss('name'); wp_title_rss(); ?> + - http://wordpress.org/?v= + @@ -41,7 +48,7 @@ $more = 1; ]]> - + diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 8f9219c5..4cf5e676 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -2,12 +2,15 @@ function get_bloginfo_rss($show = '') { $info = strip_tags(get_bloginfo($show)); - return apply_filters('get_bloginfo_rss', convert_chars($info)); + return apply_filters('get_bloginfo_rss', convert_chars($info), $show); } - function bloginfo_rss($show = '') { - echo apply_filters('bloginfo_rss', get_bloginfo_rss($show)); + echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show); +} + +function get_default_feed() { + return apply_filters('default_feed', 'rss2'); } function get_wp_title_rss($sep = '»') { @@ -76,80 +79,40 @@ function the_permalink_rss() { } +function comment_guid() { + echo get_comment_guid(); +} + +function get_comment_guid() { + global $comment; + + if ( !is_object($comment) ) + return false; + + return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID; +} + function comment_link() { echo get_comment_link(); } - function get_comment_author_rss() { return apply_filters('comment_author_rss', get_comment_author() ); } - function comment_author_rss() { echo get_comment_author_rss(); } - function comment_text_rss() { $comment_text = get_comment_text(); $comment_text = apply_filters('comment_text_rss', $comment_text); echo $comment_text; } - -function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'nolongerused') { - $url = get_post_comments_feed_link(); - echo "$link_text"; -} - - -function comments_rss($commentsrssfilename = 'nolongerused') { - return get_post_comments_feed_link(); -} - - -function get_author_rss_link($echo = false, $author_id, $author_nicename) { - $auth_ID = (int) $author_id; - $permalink_structure = get_option('permalink_structure'); - - if ( '' == $permalink_structure ) { - $link = get_option('home') . '?feed=rss2&author=' . $author_id; - } else { - $link = get_author_posts_url($author_id, $author_nicename); - $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); - } - - $link = apply_filters('author_feed_link', $link); - - if ( $echo ) - echo $link; - return $link; -} - - -function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { - $permalink_structure = get_option('permalink_structure'); - - if ( '' == $permalink_structure ) { - $link = get_option('home') . '?feed=rss2&cat=' . $cat_ID; - } else { - $link = get_category_link($cat_ID); - $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); - } - - $link = apply_filters('category_feed_link', $link); - - if ( $echo ) - echo $link; - return $link; -} - - function get_the_category_rss($type = 'rss') { $categories = get_the_category(); $tags = get_the_tags(); - $home = get_bloginfo_rss('home'); $the_list = ''; $cat_names = array(); @@ -179,37 +142,10 @@ function get_the_category_rss($type = 'rss') { return apply_filters('the_category_rss', $the_list, $type); } - function the_category_rss($type = 'rss') { echo get_the_category_rss($type); } -function get_tag_feed_link($tag_id, $feed = 'rss2') { - $tag_id = (int) $tag_id; - - $tag = get_tag($tag_id); - - if ( empty($tag) || is_wp_error($tag) ) - return false; - - $permalink_structure = get_option('permalink_structure'); - - if ( '' == $permalink_structure ) { - $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug; - } else { - $link = get_tag_link($tag->term_id); - if ( 'rss2' == $feed ) - $feed_link = 'feed'; - else - $feed_link = "feed/$feed"; - $link = $link . user_trailingslashit($feed_link, 'feed'); - } - - $link = apply_filters('tag_feed_link', $link, $feed); - - return $link; -} - function html_type_rss() { $type = get_bloginfo('html_type'); if (strpos($type, 'xhtml') !== false) @@ -221,8 +157,8 @@ function html_type_rss() { function rss_enclosure() { - global $id, $post; - if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) + global $post; + if ( !empty($post->post_password) && (!isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) return; foreach (get_post_custom() as $key => $val) { @@ -236,7 +172,7 @@ function rss_enclosure() { } function atom_enclosure() { - global $id, $post; + global $post; if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) return; @@ -250,4 +186,66 @@ function atom_enclosure() { } } +/** + * prep_atom_text_construct() - Determine the type of a given string of data + * + * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1. + * + * In the case of WordPress, text is defined as containing no markup, + * xhtml is defined as "well formed", and html as tag soup (i.e., the rest). + * + * Container div tags are added to xhtml values, per section 3.1.1.3. + * + * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1 + * + * @package WordPress + * @subpackage Feed + * @since 2.5 + * + * @param string $data input string + * @return array $result array(type, value) + */ +function prep_atom_text_construct($data) { + if (strpos($data, '<') === false && strpos($data, '&') === false) { + return array('text', $data); + } + + $parser = xml_parser_create(); + xml_parse($parser, '
    ' . $data . '
    ', true); + $code = xml_get_error_code($parser); + xml_parser_free($parser); + + if (!$code) { + if (strpos($data, '<') === false) { + return array('text', $data); + } else { + $data = "
    $data
    "; + return array('xhtml', $data); + } + } + + if (strpos($data, ']]>') == false) { + return array('html', ""); + } else { + return array('html', htmlspecialchars($data)); + } +} + +/** + * self_link() - Generate a correct link for the atom:self elemet + * + * Echo the link for the currently displayed feed in a XSS safe way. + * + * @package WordPress + * @subpackage Feed + * @since 2.5 + * + */ +function self_link() { + echo 'http' + . ( $_SERVER['https'] == 'on' ? 's' : '' ) . '://' + . $_SERVER['HTTP_HOST'] + . wp_specialchars(stripslashes($_SERVER['REQUEST_URI']), 1); +} + ?> diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 76f41d85..052445d1 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -5,7 +5,7 @@ function wptexturize($text) { $next = true; $output = ''; $curl = ''; - $textarr = preg_split('/(<.*>)/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); $stop = count($textarr); // if a plugin has provided an autocorrect array, use it @@ -26,7 +26,7 @@ function wptexturize($text) { for ( $i = 0; $i < $stop; $i++ ) { $curl = $textarr[$i]; - if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag + if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next) { // If it's not a tag // static strings $curl = str_replace($static_characters, $static_replacements, $curl); // regular expressions @@ -67,6 +67,10 @@ function wpautop($pee, $br = 1) { $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); $pee = preg_replace('!()!', "$1\n\n", $pee); $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines + if ( strpos($pee, ']*)>\s*|', "", $pee); // no pee inside object/embed + $pee = preg_replace('|\s*\s*|', '', $pee); + } $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "

    $1

    \n", $pee); // make paragraphs, including one at the end $pee = preg_replace('|

    \s*?

    |', '', $pee); // under certain strange conditions it could create a P of entirely whitespace @@ -79,7 +83,7 @@ function wpautop($pee, $br = 1) { $pee = preg_replace('!

    \s*(]*>)!', "$1", $pee); $pee = preg_replace('!(]*>)\s*

    !', "$1", $pee); if ($br) { - $pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "", "\\0")', $pee); + $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "", $matches[0]);'), $pee); $pee = preg_replace('|(?)\s*\n|', "
    \n", $pee); // optionally make line breaks $pee = str_replace('', "\n", $pee); } @@ -88,13 +92,15 @@ function wpautop($pee, $br = 1) { if (strpos($pee, ')(.*?)!is', 'clean_pre', $pee ); $pee = preg_replace( "|\n

    $|", '

    ', $pee ); + $pee = preg_replace('/

    \s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone return $pee; } function seems_utf8($Str) { # by bmorel at ssi dot fr - for ($i=0; $i $length ) ) + if ( $length && ( $unicode_length >= $length ) ) break; $unicode .= chr($value); + $unicode_length++; } else { if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3; $values[] = $value; - if ( $length && ( (strlen($unicode) + ($num_octets * 3)) > $length ) ) + if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length ) break; if ( count( $values ) == $num_octets ) { if ($num_octets == 3) { $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]); + $unicode_length += 9; } else { $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]); + $unicode_length += 6; } $values = array(); @@ -323,9 +334,8 @@ function sanitize_title($title, $fallback_title = '') { $title = strip_tags($title); $title = apply_filters('sanitize_title', $title); - if (empty($title)) { + if ( '' === $title || false === $title ) $title = $fallback_title; - } return $title; } @@ -357,7 +367,16 @@ function sanitize_title_with_dashes($title) { return $title; } -function convert_chars($content, $flag = 'obsolete') { +// ensures a string is a valid SQL order by clause like: post_name ASC, ID DESC +// accepts one or more columns, with or without ASC/DESC, and also accepts RAND() +function sanitize_sql_orderby( $orderby ){ + preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches); + if ( !$obmatches ) + return false; + return $orderby; +} + +function convert_chars($content, $deprecated = '') { // Translation of invalid Unicode references range to valid range $wp_htmltranswinuni = array( '€' => '€', // the Euro sign @@ -554,7 +573,6 @@ function format_to_edit($content, $richedit = false) { } function format_to_post($content) { - global $wpdb; $content = apply_filters('format_to_post', $content); return $content; } @@ -623,21 +641,32 @@ function antispambot($emailaddy, $mailto=0) { } function _make_url_clickable_cb($matches) { + $ret = ''; $url = $matches[2]; $url = clean_url($url); if ( empty($url) ) return $matches[0]; - return $matches[1] . "$url"; + // removed trailing [.,;:] from URL + if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) { + $ret = substr($url, -1); + $url = substr($url, 0, strlen($url)-1); + } + return $matches[1] . "$url" . $ret; } function _make_web_ftp_clickable_cb($matches) { + $ret = ''; $dest = $matches[2]; $dest = 'http://' . $dest; $dest = clean_url($dest); if ( empty($dest) ) return $matches[0]; - - return $matches[1] . "$dest"; + // removed trailing [,;:] from URL + if ( in_array(substr($dest, -1), array('.', ',', ';', ':')) === true ) { + $ret = substr($dest, -1); + $dest = substr($dest, 0, strlen($dest)-1); + } + return $matches[1] . "$dest" . $ret; } function _make_email_clickable_cb($matches) { @@ -675,7 +704,7 @@ function wp_rel_nofollow_callback( $matches ) { function convert_smilies($text) { global $wp_smiliessearch, $wp_smiliesreplace; $output = ''; - if (get_option('use_smilies')) { + if ( get_option('use_smilies') && !empty($wp_smiliessearch) && !empty($wp_smiliesreplace) ) { // HTML loop taken from texturize function, could possible be consolidated $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between $stop = count($textarr);// loop stuff @@ -794,7 +823,7 @@ function human_time_diff( $from, $to = '' ) { } else if (($diff <= 86400) && ($diff > 3600)) { $hours = round($diff / 3600); if ($hours <= 1) { - $hour = 1; + $hours = 1; } $since = sprintf(__ngettext('%s hour', '%s hours', $hours), $hours); } elseif ($diff >= 86400) { @@ -808,7 +837,6 @@ function human_time_diff( $from, $to = '' ) { } function wp_trim_excerpt($text) { // Fakes an excerpt if needed - global $post; if ( '' == $text ) { $text = get_the_content(''); $text = apply_filters('the_content', $text); @@ -1104,11 +1132,18 @@ function wp_richedit_pre($text) { return apply_filters('richedit_pre', $output); } +function wp_htmledit_pre($output) { + if ( !empty($output) ) + $output = htmlspecialchars($output, ENT_NOQUOTES); // convert only < > & + + return apply_filters('htmledit_pre', $output); +} + function clean_url( $url, $protocols = null, $context = 'display' ) { $original_url = $url; if ('' == $url) return $url; - $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@]|i', '', $url); + $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@()]|i', '', $url); $strip = array('%0d', '%0a'); $url = str_replace($strip, '', $url); $url = str_replace(';//', '://', $url); @@ -1158,6 +1193,22 @@ function attribute_escape($text) { return apply_filters('attribute_escape', $safe_text, $text); } +// Escape a HTML tag name +function tag_escape($tag_name) { + $safe_tag = strtolower( preg_replace('[^a-zA-Z_:]', '', $tag_name) ); + return apply_filters('tag_escape', $safe_tag, $tag_name); +} + +/** + * Escapes text for SQL LIKE special characters % and _ + * + * @param string text the text to be escaped + * @return string text, safe for inclusion in LIKE query + */ +function like_escape($text) { + return str_replace(array("%", "_"), array("\\%", "\\_"), $text); +} + function wp_make_link_relative( $link ) { return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link ); } @@ -1254,4 +1305,115 @@ function wp_pre_kses_less_than_callback( $matches ) { return $matches[0]; } +/** + * wp_sprintf() - sprintf() with filters + */ +function wp_sprintf( $pattern ) { + $args = func_get_args( ); + $len = strlen($pattern); + $start = 0; + $result = ''; + $arg_index = 0; + while ( $len > $start ) { + // Last character: append and break + if ( strlen($pattern) - 1 == $start ) { + $result .= substr($pattern, -1); + break; + } + + // Literal %: append and continue + if ( substr($pattern, $start, 2) == '%%' ) { + $start += 2; + $result .= '%'; + continue; + } + + // Get fragment before next % + $end = strpos($pattern, '%', $start + 1); + if ( false === $end ) + $end = $len; + $fragment = substr($pattern, $start, $end - $start); + + // Fragment has a specifier + if ( $pattern{$start} == '%' ) { + // Find numbered arguments or take the next one in order + if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) { + $arg = isset($args[$matches[1]]) ? $args[$matches[1]] : ''; + $fragment = str_replace("%{$matches[1]}$", '%', $fragment); + } else { + ++$arg_index; + $arg = isset($args[$arg_index]) ? $args[$arg_index] : ''; + } + + // Apply filters OR sprintf + $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); + if ( $_fragment != $fragment ) + $fragment = $_fragment; + else + $fragment = sprintf($fragment, strval($arg) ); + } + + // Append to result and move to next fragment + $result .= $fragment; + $start = $end; + } + return $result; +} + +/** + * wp_sprintf_l - List specifier %l for wp_sprintf + * + * @param unknown_type $pattern + * @param unknown_type $args + * @return unknown + */ +function wp_sprintf_l($pattern, $args) { + // Not a match + if ( substr($pattern, 0, 2) != '%l' ) + return $pattern; + + // Nothing to work with + if ( empty($args) ) + return ''; + + // Translate and filter the delimiter set (avoid ampersands and entities here) + $l = apply_filters('wp_sprintf_l', array( + 'between' => _c(', |between list items'), + 'between_last_two' => _c(', and |between last two list items'), + 'between_only_two' => _c(' and |between only two list items'), + )); + + $args = (array) $args; + $result = array_shift($args); + if ( count($args) == 1 ) + $result .= $l['between_only_two'] . array_shift($args); + // Loop when more than two args + while ( count($args) ) { + $arg = array_shift($args); + if ( $i == 1 ) + $result .= $l['between_last_two'] . $arg; + else + $result .= $l['between'] . $arg; + } + return $result . substr($pattern, 2); +} + +/** + * Safely extracts not more than the first $count characters from html string + * + * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* be + * counted as one character. For example & will be counted as 4, < as 3, etc. + * + * @param integer $str String to get the excerpt from + * @param integer $count Maximum number of characters to take + * @eaturn string the excerpt + */ +function wp_html_excerpt( $str, $count ) { + $str = strip_tags( $str ); + $str = mb_strcut( $str, 0, $count ); + // remove part of an entity at the end + $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str ); + return $str; +} + ?> diff --git a/wp-includes/functions.php b/wp-includes/functions.php index c07069c1..e011d340 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1,11 +1,18 @@ month) && !empty($wp_locale->weekday) && $translate ) { - $datemonth = $wp_locale->get_month(date('m', $i)); - $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth); - $dateweekday = $wp_locale->get_weekday(date('w', $i)); - $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday); - $datemeridiem = $wp_locale->get_meridiem(date('a', $i)); - $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i)); - $dateformatstring = ' '.$dateformatstring; - $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])a/", "\\1".backslashit($datemeridiem), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])A/", "\\1".backslashit($datemeridiem_capital), $dateformatstring); - - $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); - } - $j = @date($dateformatstring, $i); - if ( !$j ) { - // for debug purposes - // echo $i." ".$mysqlstring; - } + if ( !empty( $wp_locale->month ) && !empty( $wp_locale->weekday ) && $translate ) { + $datemonth = $wp_locale->get_month( date( 'm', $i ) ); + $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); + $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); + $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); + $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); + $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); + $dateformatstring = ' ' . $dateformatstring; + $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring ); + + $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); + } + $j = @date( $dateformatstring, $i ); + + /* + if ( !$j ) // for debug purposes + echo $i." ".$mysqlstring; + */ + return $j; } -function current_time($type, $gmt = 0) { - switch ($type) { + +function current_time( $type, $gmt = 0 ) { + switch ( $type ) { case 'mysql': - if ( $gmt ) $d = gmdate('Y-m-d H:i:s'); - else $d = gmdate('Y-m-d H:i:s', (time() + (get_option('gmt_offset') * 3600))); - return $d; + return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) ); break; case 'timestamp': - if ( $gmt ) $d = time(); - else $d = time() + (get_option('gmt_offset') * 3600); - return $d; + return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 ); break; } } -function date_i18n($dateformatstring, $unixtimestamp) { + +function date_i18n( $dateformatstring, $unixtimestamp ) { global $wp_locale; $i = $unixtimestamp; - if ( (!empty($wp_locale->month)) && (!empty($wp_locale->weekday)) ) { - $datemonth = $wp_locale->get_month(date('m', $i)); - $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth); - $dateweekday = $wp_locale->get_weekday(date('w', $i)); - $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday); - $datemeridiem = $wp_locale->get_meridiem(date('a', $i)); - $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i)); + if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { + $datemonth = $wp_locale->get_month( date( 'm', $i ) ); + $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); + $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); + $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); + $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); + $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); $dateformatstring = ' '.$dateformatstring; - $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])a/", "\\1".backslashit($datemeridiem), $dateformatstring); - $dateformatstring = preg_replace("/([^\\\])A/", "\\1".backslashit($datemeridiem_capital), $dateformatstring); - - $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); + $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring ); + $dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring ); + + $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); } - $j = @date($dateformatstring, $i); + $j = @date( $dateformatstring, $i ); return $j; } -function number_format_i18n($number, $decimals = null) { + +function number_format_i18n( $number, $decimals = null ) { global $wp_locale; // let the user override the precision only - $decimals = is_null($decimals)? $wp_locale->number_format['decimals'] : intval($decimals); + $decimals = ( is_null( $decimals ) ) ? $wp_locale->number_format['decimals'] : intval( $decimals ); - return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']); + return number_format( $number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] ); } -function size_format($bytes, $decimals = null) { + +function size_format( $bytes, $decimals = null ) { // technically the correct unit names for powers of 1024 are KiB, MiB etc // see http://en.wikipedia.org/wiki/Byte $quant = array( - 'TB' => pow(1024, 4), - 'GB' => pow(1024, 3), - 'MB' => pow(1024, 2), - 'kB' => pow(1024, 1), - 'B' => pow(1024, 0), + // ========================= Origin ==== + 'TB' => 1099511627776, // pow( 1024, 4) + 'GB' => 1073741824, // pow( 1024, 3) + 'MB' => 1048576, // pow( 1024, 2) + 'kB' => 1024, // pow( 1024, 1) + 'B ' => 1, // pow( 1024, 0) ); - foreach ($quant as $unit => $mag) - if ( intval($bytes) >= $mag ) - return number_format_i18n($bytes / $mag, $decimals) . ' ' . $unit; + foreach ( $quant as $unit => $mag ) + if ( doubleval($bytes) >= $mag ) + return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit; + + return false; } -function get_weekstartend($mysqlstring, $start_of_week) { - $my = substr($mysqlstring,0,4); - $mm = substr($mysqlstring,8,2); - $md = substr($mysqlstring,5,2); - $day = mktime(0,0,0, $md, $mm, $my); - $weekday = date('w',$day); + +function get_weekstartend( $mysqlstring, $start_of_week = '' ) { + $my = substr( $mysqlstring, 0, 4 ); + $mm = substr( $mysqlstring, 8, 2 ); + $md = substr( $mysqlstring, 5, 2 ); + $day = mktime( 0, 0, 0, $md, $mm, $my ); + $weekday = date( 'w', $day ); $i = 86400; + if( !is_numeric($start_of_week) ) + $start_of_week = get_option( 'start_of_week' ); - if ( $weekday < get_option('start_of_week') ) - $weekday = 7 - (get_option('start_of_week') - $weekday); + if ( $weekday < $start_of_week ) + $weekday = 7 - $start_of_week - $weekday; - while ($weekday > get_option('start_of_week')) { - $weekday = date('w',$day); - if ( $weekday < get_option('start_of_week') ) - $weekday = 7 - (get_option('start_of_week') - $weekday); + while ( $weekday > $start_of_week ) { + $weekday = date( 'w', $day ); + if ( $weekday < $start_of_week ) + $weekday = 7 - $start_of_week - $weekday; - $day = $day - 86400; + $day -= 86400; $i = 0; } $week['start'] = $day + 86400 - $i; - // $week['end'] = $day - $i + 691199; $week['end'] = $week['start'] + 604799; return $week; } -function maybe_unserialize($original) { - if ( is_serialized($original) ) // don't attempt to unserialize data that wasn't serialized going in - if ( false !== $gm = @ unserialize($original) ) + +function maybe_unserialize( $original ) { + if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in + if ( false !== $gm = @unserialize( $original ) ) return $gm; return $original; } -function is_serialized($data) { + +function is_serialized( $data ) { // if it isn't a string, it isn't serialized - if ( !is_string($data) ) + if ( !is_string( $data ) ) return false; - $data = trim($data); + $data = trim( $data ); if ( 'N;' == $data ) return true; - if ( !preg_match('/^([adObis]):/', $data, $badions) ) + if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) return false; - switch ( $badions[1] ) : - case 'a' : - case 'O' : - case 's' : - if ( preg_match("/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data) ) - return true; - break; - case 'b' : - case 'i' : - case 'd' : - if ( preg_match("/^{$badions[1]}:[0-9.E-]+;\$/", $data) ) - return true; - break; - endswitch; + switch ( $badions[1] ) { + case 'a' : + case 'O' : + case 's' : + if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) + return true; + break; + case 'b' : + case 'i' : + case 'd' : + if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) + return true; + break; + } return false; } -function is_serialized_string($data) { + +function is_serialized_string( $data ) { // if it isn't a string, it isn't a serialized string - if ( !is_string($data) ) + if ( !is_string( $data ) ) return false; - $data = trim($data); - if ( preg_match('/^s:[0-9]+:.*;$/s',$data) ) // this should fetch all serialized strings + $data = trim( $data ); + if ( preg_match( '/^s:[0-9]+:.*;$/s', $data ) ) // this should fetch all serialized strings return true; return false; } + /* Options functions */ // expects $setting to already be SQL-escaped -function get_option($setting) { +function get_option( $setting ) { global $wpdb; // Allow plugins to short-circuit options. @@ -185,30 +203,31 @@ function get_option($setting) { return $pre; // prevent non-existent options from triggering multiple queries - $notoptions = wp_cache_get('notoptions', 'options'); - if ( isset($notoptions[$setting]) ) + $notoptions = wp_cache_get( 'notoptions', 'options' ); + if ( isset( $notoptions[$setting] ) ) return false; $alloptions = wp_load_alloptions(); - if ( isset($alloptions[$setting]) ) { + if ( isset( $alloptions[$setting] ) ) { $value = $alloptions[$setting]; } else { - $value = wp_cache_get($setting, 'options'); + $value = wp_cache_get( $setting, 'options' ); if ( false === $value ) { - if ( defined('WP_INSTALLING') ) - $show = $wpdb->hide_errors(); - $row = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1"); - if ( defined('WP_INSTALLING') ) - $wpdb->show_errors($show); - - if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values + if ( defined( 'WP_INSTALLING' ) ) + $supress = $wpdb->suppress_errors(); + // expected_slashed ($setting) + $row = $wpdb->get_row( "SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1" ); + if ( defined( 'WP_INSTALLING' ) ) + $wpdb->suppress_errors($suppress); + + if ( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values $value = $row->option_value; - wp_cache_add($setting, $value, 'options'); + wp_cache_add( $setting, $value, 'options' ); } else { // option does not exist, so we must cache its non-existence $notoptions[$setting] = true; - wp_cache_set('notoptions', $notoptions, 'options'); + wp_cache_set( 'notoptions', $notoptions, 'options' ); return false; } } @@ -216,280 +235,268 @@ function get_option($setting) { // If home is not set use siteurl. if ( 'home' == $setting && '' == $value ) - return get_option('siteurl'); + return get_option( 'siteurl' ); - if ( in_array($setting, array('siteurl', 'home', 'category_base', 'tag_base')) ) - $value = untrailingslashit($value); + if ( in_array( $setting, array('siteurl', 'home', 'category_base', 'tag_base') ) ) + $value = untrailingslashit( $value ); - return apply_filters( 'option_' . $setting, maybe_unserialize($value) ); + return apply_filters( 'option_' . $setting, maybe_unserialize( $value ) ); } -function wp_protect_special_option($option) { - $protected = array('alloptions', 'notoptions'); - if ( in_array($option, $protected) ) - die(sprintf(__('%s is a protected WP option and may not be modified'), wp_specialchars($option))); + +function wp_protect_special_option( $option ) { + $protected = array( 'alloptions', 'notoptions' ); + if ( in_array( $option, $protected ) ) + die( sprintf( __( '%s is a protected WP option and may not be modified' ), wp_specialchars( $option ) ) ); } -function form_option($option) { - echo attribute_escape(get_option($option)); +function form_option( $option ) { + echo attribute_escape (get_option( $option ) ); } function get_alloptions() { global $wpdb, $wp_queries; $show = $wpdb->hide_errors(); - if ( !$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) { - $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); - } + if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) + $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); $wpdb->show_errors($show); - foreach ($options as $option) { + foreach ( $options as $option ) { // "When trying to design a foolproof system, // never underestimate the ingenuity of the fools :)" -- Dougal - if ( 'siteurl' == $option->option_name ) - $option->option_value = preg_replace('|/+$|', '', $option->option_value); - if ( 'home' == $option->option_name ) - $option->option_value = preg_replace('|/+$|', '', $option->option_value); - if ( 'category_base' == $option->option_name ) - $option->option_value = preg_replace('|/+$|', '', $option->option_value); - $value = maybe_unserialize($option->option_value); - $all_options->{$option->option_name} = apply_filters('pre_option_' . $option->option_name, $value); + if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base' ) ) ) + $option->option_value = untrailingslashit( $option->option_value ); + $value = maybe_unserialize( $option->option_value ); + $all_options->{$option->option_name} = apply_filters( 'pre_option_' . $option->option_name, $value ); } - return apply_filters('all_options', $all_options); + return apply_filters( 'all_options', $all_options ); } + function wp_load_alloptions() { global $wpdb; - $alloptions = wp_cache_get('alloptions', 'options'); + $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( !$alloptions ) { - $show = $wpdb->hide_errors(); - if ( !$alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) - $alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); - $wpdb->show_errors($show); + $suppress = $wpdb->suppress_errors(); + if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) + $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); + $wpdb->suppress_errors($suppress); $alloptions = array(); foreach ( (array) $alloptions_db as $o ) $alloptions[$o->option_name] = $o->option_value; - wp_cache_add('alloptions', $alloptions, 'options'); + wp_cache_add( 'alloptions', $alloptions, 'options' ); } return $alloptions; } + // expects $option_name to NOT be SQL-escaped -function update_option($option_name, $newvalue) { +function update_option( $option_name, $newvalue ) { global $wpdb; - wp_protect_special_option($option_name); - - $safe_option_name = $wpdb->escape($option_name); - $newvalue = sanitize_option($option_name, $newvalue); + wp_protect_special_option( $option_name ); - if ( is_string($newvalue) ) - $newvalue = trim($newvalue); + $safe_option_name = $wpdb->escape( $option_name ); + $newvalue = sanitize_option( $option_name, $newvalue ); // If the new and old values are the same, no need to update. - $oldvalue = get_option($safe_option_name); - if ( $newvalue === $oldvalue ) { + $oldvalue = get_option( $safe_option_name ); + if ( $newvalue === $oldvalue ) return false; - } if ( false === $oldvalue ) { - add_option($option_name, $newvalue); + add_option( $option_name, $newvalue ); return true; } - $notoptions = wp_cache_get('notoptions', 'options'); - if ( is_array($notoptions) && isset($notoptions[$option_name]) ) { - unset($notoptions[$option_name]); - wp_cache_set('notoptions', $notoptions, 'options'); + $notoptions = wp_cache_get( 'notoptions', 'options' ); + if ( is_array( $notoptions ) && isset( $notoptions[$option_name] ) ) { + unset( $notoptions[$option_name] ); + wp_cache_set( 'notoptions', $notoptions, 'options' ); } $_newvalue = $newvalue; - $newvalue = maybe_serialize($newvalue); + $newvalue = maybe_serialize( $newvalue ); $alloptions = wp_load_alloptions(); - if ( isset($alloptions[$option_name]) ) { + if ( isset( $alloptions[$option_name] ) ) { $alloptions[$option_name] = $newvalue; - wp_cache_set('alloptions', $alloptions, 'options'); + wp_cache_set( 'alloptions', $alloptions, 'options' ); } else { - wp_cache_set($option_name, $newvalue, 'options'); + wp_cache_set( $option_name, $newvalue, 'options' ); } - $newvalue = $wpdb->escape($newvalue); - $option_name = $wpdb->escape($option_name); - $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'"); + $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->options SET option_value = %s WHERE option_name = %s", $newvalue, $option_name ) ); if ( $wpdb->rows_affected == 1 ) { - do_action("update_option_{$option_name}", $oldvalue, $_newvalue); + do_action( "update_option_{$option_name}", $oldvalue, $_newvalue ); return true; } return false; } + // thx Alex Stapleton, http://alex.vort-x.net/blog/ // expects $name to NOT be SQL-escaped -function add_option($name, $value = '', $deprecated = '', $autoload = 'yes') { +function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) { global $wpdb; - wp_protect_special_option($name); - $safe_name = $wpdb->escape($name); + wp_protect_special_option( $name ); + $safe_name = $wpdb->escape( $name ); + $value = sanitize_option( $name, $value ); // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query - $notoptions = wp_cache_get('notoptions', 'options'); - if ( !is_array($notoptions) || !isset($notoptions[$name]) ) - if ( false !== get_option($safe_name) ) + $notoptions = wp_cache_get( 'notoptions', 'options' ); + if ( !is_array( $notoptions ) || !isset( $notoptions[$name] ) ) + if ( false !== get_option( $safe_name ) ) return; - $value = maybe_serialize($value); + $value = maybe_serialize( $value ); $autoload = ( 'no' === $autoload ) ? 'no' : 'yes'; if ( 'yes' == $autoload ) { $alloptions = wp_load_alloptions(); $alloptions[$name] = $value; - wp_cache_set('alloptions', $alloptions, 'options'); + wp_cache_set( 'alloptions', $alloptions, 'options' ); } else { - wp_cache_set($name, $value, 'options'); + wp_cache_set( $name, $value, 'options' ); } // This option exists now - $notoptions = wp_cache_get('notoptions', 'options'); // yes, again... we need it to be fresh - if ( is_array($notoptions) && isset($notoptions[$name]) ) { - unset($notoptions[$name]); - wp_cache_set('notoptions', $notoptions, 'options'); + $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh + if ( is_array( $notoptions ) && isset( $notoptions[$name] ) ) { + unset( $notoptions[$name] ); + wp_cache_set( 'notoptions', $notoptions, 'options' ); } - $name = $wpdb->escape($name); - $value = $wpdb->escape($value); - $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES ('$name', '$value', '$autoload')"); + $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES (%s, %s, %s)", $name, $value, $autoload ) ); + do_action( "add_option_{$name}", $name, $value ); return; } -function delete_option($name) { + +function delete_option( $name ) { global $wpdb; - wp_protect_special_option($name); + wp_protect_special_option( $name ); // Get the ID, if no ID then return - $option = $wpdb->get_row("SELECT option_id, autoload FROM $wpdb->options WHERE option_name = '$name'"); - if ( !$option->option_id ) return false; - $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'"); + // expected_slashed ($name) + $option = $wpdb->get_row( "SELECT option_id, autoload FROM $wpdb->options WHERE option_name = '$name'" ); + if ( is_null($option) || !$option->option_id ) + return false; + // expected_slashed ($name) + $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name = '$name'" ); if ( 'yes' == $option->autoload ) { $alloptions = wp_load_alloptions(); - if ( isset($alloptions[$name]) ) { - unset($alloptions[$name]); - wp_cache_set('alloptions', $alloptions, 'options'); + if ( isset( $alloptions[$name] ) ) { + unset( $alloptions[$name] ); + wp_cache_set( 'alloptions', $alloptions, 'options' ); } } else { - wp_cache_delete($name, 'options'); + wp_cache_delete( $name, 'options' ); } return true; } -function maybe_serialize($data) { - if ( is_string($data) ) - $data = trim($data); - elseif ( is_array($data) || is_object($data) ) - return serialize($data); - if ( is_serialized($data) ) - return serialize($data); + +function maybe_serialize( $data ) { + if ( is_string( $data ) ) + $data = trim( $data ); + elseif ( is_array( $data ) || is_object( $data ) ) + return serialize( $data ); + if ( is_serialized( $data ) ) + return serialize( $data ); return $data; } -function gzip_compression() { - if ( !get_option( 'gzipcompression' ) ) { - return false; - } - - if ( ( ini_get( 'zlib.output_compression' ) == 'On' || ini_get( 'zlib.output_compression_level' ) > 0 ) || ini_get( 'output_handler' ) == 'ob_gzhandler' ) { - return false; - } - - if ( extension_loaded( 'zlib' ) ) { - ob_start( 'ob_gzhandler' ); - } -} -function make_url_footnote($content) { - preg_match_all('/(.+?)<\/a>/', $content, $matches); +function make_url_footnote( $content ) { + preg_match_all( '/(.+?)<\/a>/', $content, $matches ); $j = 0; - for ($i=0; $i(.+?)<\/title>/is', $content, $matchtitle) ) { + if ( preg_match( '/(.+?)<\/title>/is', $content, $matchtitle ) ) { $post_title = $matchtitle[0]; - $post_title = preg_replace('/<title>/si', '', $post_title); - $post_title = preg_replace('/<\/title>/si', '', $post_title); + $post_title = preg_replace( '/<title>/si', '', $post_title ); + $post_title = preg_replace( '/<\/title>/si', '', $post_title ); } else { $post_title = $post_default_title; } return $post_title; } -function xmlrpc_getpostcategory($content) { + +function xmlrpc_getpostcategory( $content ) { global $post_default_category; - if ( preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat) ) { - $post_category = trim($matchcat[1], ','); - $post_category = explode(',', $post_category); + if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) { + $post_category = trim( $matchcat[1], ',' ); + $post_category = explode( ',', $post_category ); } else { $post_category = $post_default_category; } return $post_category; } -function xmlrpc_removepostdata($content) { - $content = preg_replace('/<title>(.+?)<\/title>/si', '', $content); - $content = preg_replace('/<category>(.+?)<\/category>/si', '', $content); - $content = trim($content); + +function xmlrpc_removepostdata( $content ) { + $content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content ); + $content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content ); + $content = trim( $content ); return $content; } -function debug_fopen($filename, $mode) { + +function debug_fopen( $filename, $mode ) { global $debug; - if ( $debug == 1 ) { - $fp = fopen($filename, $mode); + if ( 1 == $debug ) { + $fp = fopen( $filename, $mode ); return $fp; } else { return false; } } -function debug_fwrite($fp, $string) { + +function debug_fwrite( $fp, $string ) { global $debug; - if ( $debug == 1 ) { - fwrite($fp, $string); - } + if ( 1 == $debug ) + fwrite( $fp, $string ); } -function debug_fclose($fp) { + +function debug_fclose( $fp ) { global $debug; - if ( $debug == 1 ) { - fclose($fp); - } + if ( 1 == $debug ) + fclose( $fp ); } function do_enclose( $content, $post_ID ) { - global $wp_version, $wpdb; - include_once (ABSPATH . WPINC . '/class-IXR.php'); + global $wpdb; + include_once( ABSPATH . WPINC . '/class-IXR.php' ); - $log = debug_fopen(ABSPATH . 'enclosures.log', 'a'); + $log = debug_fopen( ABSPATH . 'enclosures.log', 'a' ); $post_links = array(); - debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); + debug_fwrite( $log, 'BEGIN ' . date( 'YmdHis', time() ) . "\n" ); $pung = get_enclosed( $post_ID ); @@ -498,38 +505,41 @@ function do_enclose( $content, $post_ID ) { $punc = '.:?\-'; $any = $ltrs . $gunk . $punc; - preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); + preg_match_all( "{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp ); - debug_fwrite($log, 'Post contents:'); - debug_fwrite($log, $content."\n"); + debug_fwrite( $log, 'Post contents:' ); + debug_fwrite( $log, $content . "\n" ); - foreach($post_links_temp[0] as $link_test) : - if ( !in_array($link_test, $pung) ) : // If we haven't pung it already - $test = parse_url($link_test); - if ( isset($test['query']) ) + foreach ( $post_links_temp[0] as $link_test ) { + if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already + $test = parse_url( $link_test ); + if ( isset( $test['query'] ) ) $post_links[] = $link_test; - elseif (($test['path'] != '/') && ($test['path'] != '')) + elseif ( $test['path'] != '/' && $test['path'] != '' ) $post_links[] = $link_test; - endif; - endforeach; + } + } - foreach ($post_links as $url) : - if ( $url != '' && !$wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE post_id = '$post_ID' AND meta_key = 'enclosure' AND meta_value LIKE ('$url%')") ) { + foreach ( $post_links as $url ) { + if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) { if ( $headers = wp_get_http_headers( $url) ) { $len = (int) $headers['content-length']; $type = $wpdb->escape( $headers['content-type'] ); $allowed_types = array( 'video', 'audio' ); if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { $meta_value = "$url\n$len\n$type\n"; - $wpdb->query( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` ) - VALUES ( '$post_ID', 'enclosure' , '$meta_value')" ); + $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` ) + VALUES ( %d, 'enclosure' , %s)", $post_ID, $meta_value ) ); } } } - endforeach; + } } -function wp_get_http_headers( $url, $red = 1 ) { +// perform a HTTP HEAD or GET request +// if $file_path is a writable filename, this will do a GET request and write the file to that path +// returns a list of HTTP headers +function wp_get_http( $url, $file_path = false, $red = 1 ) { global $wp_version; @set_time_limit( 60 ); @@ -537,14 +547,19 @@ function wp_get_http_headers( $url, $red = 1 ) { return false; $parts = parse_url( $url ); - $file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : ''); + $file = $parts['path'] . ( ( $parts['query'] ) ? '?' . $parts['query'] : '' ); $host = $parts['host']; if ( !isset( $parts['port'] ) ) $parts['port'] = 80; - $head = "HEAD $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n"; + if ( $file_path ) + $request_type = 'GET'; + else + $request_type = 'HEAD'; + + $head = "$request_type $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n"; - $fp = @fsockopen($host, $parts['port'], $err_num, $err_msg, 3); + $fp = @fsockopen( $host, $parts['port'], $err_num, $err_msg, 3 ); if ( !$fp ) return false; @@ -552,37 +567,68 @@ function wp_get_http_headers( $url, $red = 1 ) { fputs( $fp, $head ); while ( !feof( $fp ) && strpos( $response, "\r\n\r\n" ) == false ) $response .= fgets( $fp, 2048 ); - fclose( $fp ); - preg_match_all('/(.*?): (.*)\r/', $response, $matches); - $count = count($matches[1]); - for ( $i = 0; $i < $count; $i++) { - $key = strtolower($matches[1][$i]); + preg_match_all( '/(.*?): (.*)\r/', $response, $matches ); + $count = count( $matches[1] ); + for ( $i = 0; $i < $count; $i++ ) { + $key = strtolower( $matches[1][$i] ); $headers["$key"] = $matches[2][$i]; } - preg_match('/.*([0-9]{3}).*/', $response, $return); + preg_match( '/.*([0-9]{3}).*/', $response, $return ); $headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404 $code = $headers['response']; - if ( ('302' == $code || '301' == $code) && isset($headers['location']) ) - return wp_get_http_headers( $headers['location'], ++$red ); + if ( ( '302' == $code || '301' == $code ) && isset( $headers['location'] ) ) { + fclose($fp); + return wp_get_http( $headers['location'], $file_path, ++$red ); + } + + // make a note of the final location, so the caller can tell if we were redirected or not + $headers['x-final-location'] = $url; + + // HEAD request only + if ( !$file_path ) { + fclose($fp); + return $headers; + } + + // GET request - fetch and write it to the supplied filename + $content_length = $headers['content-length']; + $got_bytes = 0; + $out_fp = fopen($file_path, 'w'); + while ( !feof($fp) ) { + $buf = fread( $fp, 4096 ); + fwrite( $out_fp, $buf ); + $got_bytes += strlen($buf); + // don't read past the content-length + if ($content_length and $got_bytes >= $content_length) + break; + } + fclose($out_fp); + fclose($fp); return $headers; } +function wp_get_http_headers( $url, $red = 1 ) { + return wp_get_http( $url, false, $red ); +} + + function is_new_day() { global $day, $previousday; - if ( $day != $previousday ) { - return(1); - } else { - return(0); - } + if ( $day != $previousday ) + return 1; + else + return 0; } -function build_query($data) { - return _http_build_query($data, NULL, '&', '', false); + +function build_query( $data ) { + return _http_build_query( $data, NULL, '&', '', false ); } + /* add_query_arg: Returns a modified querystring by adding a single key & value or an associative array. @@ -595,40 +641,40 @@ add_query_arg(associative_array, oldquery_or_uri) */ function add_query_arg() { $ret = ''; - if ( is_array(func_get_arg(0)) ) { - if ( @func_num_args() < 2 || false === @func_get_arg(1) ) + if ( is_array( func_get_arg(0) ) ) { + if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) ) $uri = $_SERVER['REQUEST_URI']; else - $uri = @func_get_arg(1); + $uri = @func_get_arg( 1 ); } else { - if ( @func_num_args() < 3 || false === @func_get_arg(2) ) + if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) ) $uri = $_SERVER['REQUEST_URI']; else - $uri = @func_get_arg(2); + $uri = @func_get_arg( 2 ); } - if ( $frag = strstr($uri, '#') ) - $uri = substr($uri, 0, -strlen($frag)); + if ( $frag = strstr( $uri, '#' ) ) + $uri = substr( $uri, 0, -strlen( $frag ) ); else $frag = ''; - if ( preg_match('|^https?://|i', $uri, $matches) ) { + if ( preg_match( '|^https?://|i', $uri, $matches ) ) { $protocol = $matches[0]; - $uri = substr($uri, strlen($protocol)); + $uri = substr( $uri, strlen( $protocol ) ); } else { $protocol = ''; } - if (strpos($uri, '?') !== false) { - $parts = explode('?', $uri, 2); - if ( 1 == count($parts) ) { + if ( strpos( $uri, '?' ) !== false ) { + $parts = explode( '?', $uri, 2 ); + if ( 1 == count( $parts ) ) { $base = '?'; $query = $parts[0]; } else { $base = $parts[0] . '?'; $query = $parts[1]; } - } elseif (!empty($protocol) || strpos($uri, '=') === false ) { + } elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) { $base = $uri . '?'; $query = ''; } else { @@ -636,28 +682,29 @@ function add_query_arg() { $query = $uri; } - wp_parse_str($query, $qs); - $qs = urlencode_deep($qs); // this re-URL-encodes things that were already in the query string - if ( is_array(func_get_arg(0)) ) { - $kayvees = func_get_arg(0); - $qs = array_merge($qs, $kayvees); + wp_parse_str( $query, $qs ); + $qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string + if ( is_array( func_get_arg( 0 ) ) ) { + $kayvees = func_get_arg( 0 ); + $qs = array_merge( $qs, $kayvees ); } else { - $qs[func_get_arg(0)] = func_get_arg(1); + $qs[func_get_arg( 0 )] = func_get_arg( 1 ); } foreach ( $qs as $k => $v ) { if ( $v === false ) - unset($qs[$k]); + unset( $qs[$k] ); } - $ret = build_query($qs); - $ret = trim($ret, '?'); - $ret = preg_replace('#=(&|$)#', '$1', $ret); + $ret = build_query( $qs ); + $ret = trim( $ret, '?' ); + $ret = preg_replace( '#=(&|$)#', '$1', $ret ); $ret = $protocol . $base . $ret . $frag; - $ret = rtrim($ret, '?'); + $ret = rtrim( $ret, '?' ); return $ret; } + /* remove_query_arg: Returns a modified querystring by removing a single key or an array of keys. @@ -668,23 +715,24 @@ remove_query_arg(removekey, [oldquery_or_uri]) or remove_query_arg(removekeyarray, [oldquery_or_uri]) */ -function remove_query_arg($key, $query=FALSE) { - if ( is_array($key) ) { // removing multiple keys +function remove_query_arg( $key, $query=FALSE ) { + if ( is_array( $key ) ) { // removing multiple keys foreach ( (array) $key as $k ) - $query = add_query_arg($k, FALSE, $query); + $query = add_query_arg( $k, FALSE, $query ); return $query; } - return add_query_arg($key, FALSE, $query); + return add_query_arg( $key, FALSE, $query ); } -function add_magic_quotes($array) { + +function add_magic_quotes( $array ) { global $wpdb; - foreach ($array as $k => $v) { - if ( is_array($v) ) { - $array[$k] = add_magic_quotes($v); + foreach ( $array as $k => $v ) { + if ( is_array( $v ) ) { + $array[$k] = add_magic_quotes( $v ); } else { - $array[$k] = $wpdb->escape($v); + $array[$k] = $wpdb->escape( $v ); } } return $array; @@ -692,54 +740,55 @@ function add_magic_quotes($array) { function wp_remote_fopen( $uri ) { $timeout = 10; - $parsed_url = @parse_url($uri); + $parsed_url = @parse_url( $uri ); - if ( !$parsed_url || !is_array($parsed_url) ) + if ( !$parsed_url || !is_array( $parsed_url ) ) return false; - if ( !isset($parsed_url['scheme']) || !in_array($parsed_url['scheme'], array('http','https')) ) + if ( !isset( $parsed_url['scheme'] ) || !in_array( $parsed_url['scheme'], array( 'http','https' ) ) ) $uri = 'http://' . $uri; - if ( ini_get('allow_url_fopen') ) { + if ( ini_get( 'allow_url_fopen' ) ) { $fp = @fopen( $uri, 'r' ); if ( !$fp ) return false; //stream_set_timeout($fp, $timeout); // Requires php 4.3 $linea = ''; - while( $remote_read = fread($fp, 4096) ) + while ( $remote_read = fread( $fp, 4096 ) ) $linea .= $remote_read; - fclose($fp); + fclose( $fp ); return $linea; - } else if ( function_exists('curl_init') ) { + } elseif ( function_exists( 'curl_init' ) ) { $handle = curl_init(); - curl_setopt ($handle, CURLOPT_URL, $uri); - curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1); - curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1); - curl_setopt ($handle, CURLOPT_TIMEOUT, $timeout); - $buffer = curl_exec($handle); - curl_close($handle); + curl_setopt( $handle, CURLOPT_URL, $uri); + curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 ); + curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); + curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout ); + $buffer = curl_exec( $handle ); + curl_close( $handle ); return $buffer; } else { return false; } } -function wp($query_vars = '') { - global $wp, $wp_query, $wp_the_query; - $wp->main($query_vars); +function wp( $query_vars = '' ) { + global $wp, $wp_query, $wp_the_query; + $wp->main( $query_vars ); if( !isset($wp_the_query) ) $wp_the_query = $wp_query; } + function get_status_header_desc( $code ) { global $wp_header_to_desc; - $code = (int) $code; + $code = absint( $code ); - if ( !isset($wp_header_to_desc) ) { + if ( !isset( $wp_header_to_desc ) ) { $wp_header_to_desc = array( 100 => 'Continue', 101 => 'Switching Protocols', @@ -787,13 +836,13 @@ function get_status_header_desc( $code ) { ); } - if ( isset( $wp_header_to_desc[$code] ) ) { + if ( isset( $wp_header_to_desc[$code] ) ) return $wp_header_to_desc[$code]; - } else { + else return ''; - } } + function status_header( $header ) { $text = get_status_header_desc( $header ); @@ -801,87 +850,99 @@ function status_header( $header ) { return false; $protocol = $_SERVER["SERVER_PROTOCOL"]; - if ( ('HTTP/1.1' != $protocol) && ('HTTP/1.0' != $protocol) ) + if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0'; $status_header = "$protocol $header $text"; - if ( function_exists('apply_filters') ) - $status_header = apply_filters('status_header', $status_header, $header, $text, $protocol); + if ( function_exists( 'apply_filters' ) ) + $status_header = apply_filters( 'status_header', $status_header, $header, $text, $protocol ); - if ( version_compare( phpversion(), '4.3.0', '>=' ) ) { + if ( version_compare( phpversion(), '4.3.0', '>=' ) ) return @header( $status_header, true, $header ); - } else { + else return @header( $status_header ); - } } + function nocache_headers() { - @ header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); - @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - @ header('Cache-Control: no-cache, must-revalidate, max-age=0'); - @ header('Pragma: no-cache'); + // why are these @-silenced when other header calls aren't? + @header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); + @header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); + @header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); + @header( 'Pragma: no-cache' ); } + function cache_javascript_headers() { $expiresOffset = 864000; // 10 days - header("Content-Type: text/javascript; charset=" . get_bloginfo('charset')); - header("Vary: Accept-Encoding"); // Handle proxies - header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT"); + header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) ); + header( "Vary: Accept-Encoding" ); // Handle proxies + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" ); } + function get_num_queries() { global $wpdb; return $wpdb->num_queries; } + function bool_from_yn( $yn ) { return ( strtolower( $yn ) == 'y' ); } + function do_feed() { global $wp_query; - $feed = get_query_var('feed'); + $feed = get_query_var( 'feed' ); // Remove the pad, if present. - $feed = preg_replace('/^_+/', '', $feed); + $feed = preg_replace( '/^_+/', '', $feed ); if ( $feed == '' || $feed == 'feed' ) - $feed = 'rss2'; + $feed = get_default_feed(); $hook = 'do_feed_' . $feed; - do_action($hook, $wp_query->is_comment_feed); + if ( !has_action($hook) ) { + $message = sprintf( __( 'ERROR: %s is not a valid feed template' ), wp_specialchars($feed)); + wp_die($message); + } + + do_action( $hook, $wp_query->is_comment_feed ); } + function do_feed_rdf() { - load_template(ABSPATH . WPINC . '/feed-rdf.php'); + load_template( ABSPATH . WPINC . '/feed-rdf.php' ); } + function do_feed_rss() { - load_template(ABSPATH . WPINC . '/feed-rss.php'); + load_template( ABSPATH . WPINC . '/feed-rss.php' ); } -function do_feed_rss2($for_comments) { - if ( $for_comments ) { - load_template(ABSPATH . WPINC . '/feed-rss2-comments.php'); - } else { - load_template(ABSPATH . WPINC . '/feed-rss2.php'); - } + +function do_feed_rss2( $for_comments ) { + if ( $for_comments ) + load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' ); + else + load_template( ABSPATH . WPINC . '/feed-rss2.php' ); } -function do_feed_atom($for_comments) { - if ($for_comments) { - load_template(ABSPATH . WPINC . '/feed-atom-comments.php'); - } else { - load_template(ABSPATH . WPINC . '/feed-atom.php'); - } + +function do_feed_atom( $for_comments ) { + if ($for_comments) + load_template( ABSPATH . WPINC . '/feed-atom-comments.php'); + else + load_template( ABSPATH . WPINC . '/feed-atom.php' ); } function do_robots() { - header('Content-Type: text/plain; charset=utf-8'); + header( 'Content-Type: text/plain; charset=utf-8' ); - do_action('do_robotstxt'); + do_action( 'do_robotstxt' ); - if ( '0' == get_option('blog_public') ) { + if ( '0' == get_option( 'blog_public' ) ) { echo "User-agent: *\n"; echo "Disallow: /\n"; } else { @@ -890,172 +951,269 @@ function do_robots() { } } + function is_blog_installed() { global $wpdb; - $show = $wpdb->hide_errors(); - $installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'"); - $wpdb->show_errors($show); - $install_status = !empty( $installed ) ? TRUE : FALSE; - return $install_status; + // Check cache first. If options table goes away and we have true cached, oh well. + if ( wp_cache_get('is_blog_installed') ) + return true; + + $suppress = $wpdb->suppress_errors(); + $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); + $wpdb->suppress_errors($suppress); + + $installed = !empty( $installed ) ? true : false; + wp_cache_set('is_blog_installed', $installed); + + return $installed; } -function wp_nonce_url($actionurl, $action = -1) { - $actionurl = str_replace('&', '&', $actionurl); - return wp_specialchars(add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl)); + +function wp_nonce_url( $actionurl, $action = -1 ) { + $actionurl = str_replace( '&', '&', $actionurl ); + return wp_specialchars( add_query_arg( '_wpnonce', wp_create_nonce( $action ), $actionurl ) ); } -function wp_nonce_field($action = -1, $name = "_wpnonce", $referer = true) { - $name = attribute_escape($name); - echo '<input type="hidden" name="' . $name . '" value="' . wp_create_nonce($action) . '" />'; + +function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) { + $name = attribute_escape( $name ); + $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; + if ( $echo ) + echo $nonce_field; + if ( $referer ) - wp_referer_field(); + wp_referer_field( $echo, 'previous' ); + + return $nonce_field; } -function wp_referer_field() { - $ref = attribute_escape($_SERVER['REQUEST_URI']); - echo '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />'; - if ( wp_get_original_referer() ) { - $original_ref = attribute_escape(stripslashes(wp_get_original_referer())); - echo '<input type="hidden" name="_wp_original_http_referer" value="'. $original_ref . '" />'; - } + +function wp_referer_field( $echo = true) { + $ref = attribute_escape( $_SERVER['REQUEST_URI'] ); + $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />'; + + if ( $echo ) + echo $referer_field; + return $referer_field; } -function wp_original_referer_field() { - echo '<input type="hidden" name="_wp_original_http_referer" value="' . attribute_escape(stripslashes($_SERVER['REQUEST_URI'])) . '" />'; +function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) { + $jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; + $ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to; + $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . attribute_escape( stripslashes( $ref ) ) . '" />'; + if ( $echo ) + echo $orig_referer_field; + return $orig_referer_field; } + function wp_get_referer() { - foreach ( array($_REQUEST['_wp_http_referer'], $_SERVER['HTTP_REFERER']) as $ref ) - if ( !empty($ref) ) - return $ref; + if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) + $ref = $_REQUEST['_wp_http_referer']; + else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) + $ref = $_SERVER['HTTP_REFERER']; + + if ( $ref !== $_SERVER['REQUEST_URI'] ) + return $ref; return false; } + function wp_get_original_referer() { - if ( !empty($_REQUEST['_wp_original_http_referer']) ) + if ( !empty( $_REQUEST['_wp_original_http_referer'] ) ) return $_REQUEST['_wp_original_http_referer']; return false; } -function wp_mkdir_p($target) { + +function wp_mkdir_p( $target ) { // from php.net/mkdir user contributed notes - if (file_exists($target)) { - if (! @ is_dir($target)) - return false; - else - return true; - } + $target = str_replace( '//', '/', $target ); + if ( file_exists( $target ) ) + return @is_dir( $target ); // Attempting to create the directory may clutter up our display. - if (@ mkdir($target)) { - $stat = @ stat(dirname($target)); + if ( @mkdir( $target ) ) { + $stat = @stat( dirname( $target ) ); $dir_perms = $stat['mode'] & 0007777; // Get the permission bits. - @ chmod($target, $dir_perms); + @chmod( $target, $dir_perms ); return true; - } else { - if ( is_dir(dirname($target)) ) + } elseif ( is_dir( dirname( $target ) ) ) { return false; } // If the above failed, attempt to create the parent node, then try again. - if (wp_mkdir_p(dirname($target))) - return wp_mkdir_p($target); + if ( wp_mkdir_p( dirname( $target ) ) ) + return wp_mkdir_p( $target ); return false; } +// Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows') +function path_is_absolute( $path ) { + // this is definitive if true but fails if $path does not exist or contains a symbolic link + if ( realpath($path) == $path ) + return true; + + if ( strlen($path) == 0 || $path{0} == '.' ) + return false; + + // windows allows absolute paths like this + if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) + return true; + + // a path starting with / or \ is absolute; anything else is relative + return (bool) preg_match('#^[/\\\\]#', $path); +} + +// Join two filesystem paths together (e.g. 'give me $path relative to $base') +function path_join( $base, $path ) { + if ( path_is_absolute($path) ) + return $path; + + return rtrim($base, '/') . '/' . ltrim($path, '/'); +} + // Returns an array containing the current upload directory's path and url, or an error message. -function wp_upload_dir() { - $siteurl = get_option('siteurl'); - //prepend ABSPATH to $dir and $siteurl to $url if they're not already there - $path = str_replace(ABSPATH, '', trim(get_option('upload_path'))); - $dir = ABSPATH . $path; - $url = trailingslashit($siteurl) . $path; - - if ( $dir == ABSPATH ) { //the option was empty - $dir = ABSPATH . 'wp-content/uploads'; - } +function wp_upload_dir( $time = NULL ) { + $siteurl = get_option( 'siteurl' ); + $upload_path = get_option( 'upload_path' ); + if ( trim($upload_path) === '' ) + $upload_path = 'wp-content/uploads'; + $dir = $upload_path; + + // $dir is absolute, $path is (maybe) relative to ABSPATH + $dir = path_join( ABSPATH, $upload_path ); + $path = str_replace( ABSPATH, '', trim( $upload_path ) ); + + if ( !$url = get_option( 'upload_url_path' ) ) + $url = trailingslashit( $siteurl ) . $path; if ( defined('UPLOADS') ) { $dir = ABSPATH . UPLOADS; - $url = trailingslashit($siteurl) . UPLOADS; + $url = trailingslashit( $siteurl ) . UPLOADS; } - if ( get_option('uploads_use_yearmonth_folders')) { + $subdir = ''; + if ( get_option( 'uploads_use_yearmonth_folders' ) ) { // Generate the yearly and monthly dirs - $time = current_time( 'mysql' ); + if ( !$time ) + $time = current_time( 'mysql' ); $y = substr( $time, 0, 4 ); $m = substr( $time, 5, 2 ); - $dir = $dir . "/$y/$m"; - $url = $url . "/$y/$m"; + $subdir = "/$y/$m"; } + $dir .= $subdir; + $url .= $subdir; + // Make sure we have an uploads dir if ( ! wp_mkdir_p( $dir ) ) { - $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $dir); - return array('error' => $message); + $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $dir ); + return array( 'error' => $message ); } - $uploads = array('path' => $dir, 'url' => $url, 'error' => false); - return apply_filters('upload_dir', $uploads); + $uploads = array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'error' => false ); + return apply_filters( 'upload_dir', $uploads ); } -function wp_upload_bits($name, $type, $bits) { - if ( empty($name) ) - return array('error' => __("Empty filename")); +// return a filename that is sanitized and unique for the given directory +function wp_unique_filename( $dir, $filename, $unique_filename_callback = NULL ) { + $filename = strtolower( $filename ); + // separate the filename into a name and extension + $info = pathinfo($filename); + $ext = $info['extension']; + $name = basename($filename, ".{$ext}"); + + // edge case: if file is named '.ext', treat as an empty name + if( $name === ".$ext" ) + $name = ''; - $wp_filetype = wp_check_filetype($name); + // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. + if ( $unique_filename_callback && function_exists( $unique_filename_callback ) ) { + $filename = $unique_filename_callback( $dir, $name ); + } else { + $number = ''; + + if ( empty( $ext ) ) + $ext = ''; + else + $ext = strtolower( ".$ext" ); + + $filename = str_replace( $ext, '', $filename ); + // Strip % so the server doesn't try to decode entities. + $filename = str_replace('%', '', sanitize_title_with_dashes( $filename ) ) . $ext; + + while ( file_exists( $dir . "/$filename" ) ) { + if ( '' == "$number$ext" ) + $filename = $filename . ++$number . $ext; + else + $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); + } + } + + return $filename; +} + +function wp_upload_bits( $name, $deprecated, $bits, $time = NULL ) { + if ( empty( $name ) ) + return array( 'error' => __( "Empty filename" ) ); + + $wp_filetype = wp_check_filetype( $name ); if ( !$wp_filetype['ext'] ) - return array('error' => __("Invalid file type")); + return array( 'error' => __( "Invalid file type" ) ); - $upload = wp_upload_dir(); + $upload = wp_upload_dir( $time ); if ( $upload['error'] !== false ) return $upload; - $number = ''; - $filename = $name; - $path_parts = pathinfo($filename); - $ext = $path_parts['extension']; - if ( empty($ext) ) - $ext = ''; - else - $ext = ".$ext"; - while ( file_exists($upload['path'] . "/$filename") ) { - if ( '' == "$number$ext" ) - $filename = $filename . ++$number . $ext; - else - $filename = str_replace("$number$ext", ++$number . $ext, $filename); - } + $filename = wp_unique_filename( $upload['path'], $name ); $new_file = $upload['path'] . "/$filename"; - if ( ! wp_mkdir_p( dirname($new_file) ) ) { - $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); - return array('error' => $message); + if ( ! wp_mkdir_p( dirname( $new_file ) ) ) { + $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), dirname( $new_file ) ); + return array( 'error' => $message ); } - $ifp = @ fopen($new_file, 'wb'); + $ifp = @ fopen( $new_file, 'wb' ); if ( ! $ifp ) - return array('error' => sprintf(__('Could not write file %s'), $new_file)); + return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ); - $success = @ fwrite($ifp, $bits); - fclose($ifp); + @fwrite( $ifp, $bits ); + fclose( $ifp ); // Set correct file permissions - $stat = @ stat(dirname($new_file)); + $stat = @ stat( dirname( $new_file ) ); $perms = $stat['mode'] & 0007777; $perms = $perms & 0000666; - @ chmod($new_file, $perms); + @ chmod( $new_file, $perms ); // Compute the URL $url = $upload['url'] . "/$filename"; - return array('file' => $new_file, 'url' => $url, 'error' => false); + return array( 'file' => $new_file, 'url' => $url, 'error' => false ); } -function wp_check_filetype($filename, $mimes = null) { +function wp_ext2type( $ext ) { + $ext2type = apply_filters('ext2type', array( + 'audio' => array('aac','ac3','aif','aiff','mp1','mp2','mp3','m3a','m4a','m4b','ogg','ram','wav','wma'), + 'video' => array('asf','avi','divx','dv','mov','mpg','mpeg','mp4','mpv','ogm','qt','rm','vob','wmv'), + 'document' => array('doc','pages','odt','rtf','pdf'), + 'spreadsheet' => array('xls','numbers','ods'), + 'interactive' => array('ppt','key','odp','swf'), + 'text' => array('txt'), + 'archive' => array('tar','bz2','gz','cab','dmg','rar','sea','sit','sqx','zip'), + 'code' => array('css','html','php','js'), + )); + foreach ( $ext2type as $type => $exts ) + if ( in_array($ext, $exts) ) + return $type; +} + +function wp_check_filetype( $filename, $mimes = null ) { // Accepted MIME types are set here as PCRE unless provided. - $mimes = is_array($mimes) ? $mimes : apply_filters('upload_mimes', array ( + $mimes = ( is_array( $mimes ) ) ? $mimes : apply_filters( 'upload_mimes', array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', @@ -1065,12 +1223,12 @@ function wp_check_filetype($filename, $mimes = null) { 'asf|asx|wax|wmv|wmx' => 'video/asf', 'avi' => 'video/avi', 'mov|qt' => 'video/quicktime', - 'mpeg|mpg|mpe' => 'video/mpeg', + 'mpeg|mpg|mpe|mp4' => 'video/mpeg', 'txt|c|cc|h' => 'text/plain', 'rtx' => 'text/richtext', 'css' => 'text/css', 'htm|html' => 'text/html', - 'mp3|mp4' => 'audio/mpeg', + 'mp3|m4a' => 'audio/mpeg', 'ra|ram' => 'audio/x-realaudio', 'wav' => 'audio/wav', 'ogg' => 'audio/ogg', @@ -1099,127 +1257,110 @@ function wp_check_filetype($filename, $mimes = null) { 'odc' => 'application/vnd.oasis.opendocument.chart', 'odb' => 'application/vnd.oasis.opendocument.database', 'odf' => 'application/vnd.oasis.opendocument.formula', - - )); + ) + ); $type = false; $ext = false; - foreach ($mimes as $ext_preg => $mime_match) { + foreach ( $mimes as $ext_preg => $mime_match ) { $ext_preg = '!\.(' . $ext_preg . ')$!i'; - if ( preg_match($ext_preg, $filename, $ext_matches) ) { + if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { $type = $mime_match; $ext = $ext_matches[1]; break; } } - return compact('ext', 'type'); + return compact( 'ext', 'type' ); } -function wp_explain_nonce($action) { - if ( $action !== -1 && preg_match('/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches) ) { +function wp_explain_nonce( $action ) { + if ( $action !== -1 && preg_match( '/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches ) ) { $verb = $matches[1]; $noun = $matches[2]; $trans = array(); - $trans['update']['attachment'] = array(__('Are you sure you want to edit this attachment: "%s"?'), 'get_the_title'); - - $trans['add']['category'] = array(__('Are you sure you want to add this category?'), false); - $trans['delete']['category'] = array(__('Are you sure you want to delete this category: "%s"?'), 'get_catname'); - $trans['update']['category'] = array(__('Are you sure you want to edit this category: "%s"?'), 'get_catname'); - - $trans['delete']['comment'] = array(__('Are you sure you want to delete this comment: "%s"?'), 'use_id'); - $trans['unapprove']['comment'] = array(__('Are you sure you want to unapprove this comment: "%s"?'), 'use_id'); - $trans['approve']['comment'] = array(__('Are you sure you want to approve this comment: "%s"?'), 'use_id'); - $trans['update']['comment'] = array(__('Are you sure you want to edit this comment: "%s"?'), 'use_id'); - $trans['bulk']['comments'] = array(__('Are you sure you want to bulk modify comments?'), false); - $trans['moderate']['comments'] = array(__('Are you sure you want to moderate comments?'), false); - - $trans['add']['bookmark'] = array(__('Are you sure you want to add this link?'), false); - $trans['delete']['bookmark'] = array(__('Are you sure you want to delete this link: "%s"?'), 'use_id'); - $trans['update']['bookmark'] = array(__('Are you sure you want to edit this link: "%s"?'), 'use_id'); - $trans['bulk']['bookmarks'] = array(__('Are you sure you want to bulk modify links?'), false); - - $trans['add']['page'] = array(__('Are you sure you want to add this page?'), false); - $trans['delete']['page'] = array(__('Are you sure you want to delete this page: "%s"?'), 'get_the_title'); - $trans['update']['page'] = array(__('Are you sure you want to edit this page: "%s"?'), 'get_the_title'); - - $trans['edit']['plugin'] = array(__('Are you sure you want to edit this plugin file: "%s"?'), 'use_id'); - $trans['activate']['plugin'] = array(__('Are you sure you want to activate this plugin: "%s"?'), 'use_id'); - $trans['deactivate']['plugin'] = array(__('Are you sure you want to deactivate this plugin: "%s"?'), 'use_id'); - - $trans['add']['post'] = array(__('Are you sure you want to add this post?'), false); - $trans['delete']['post'] = array(__('Are you sure you want to delete this post: "%s"?'), 'get_the_title'); - $trans['update']['post'] = array(__('Are you sure you want to edit this post: "%s"?'), 'get_the_title'); - - $trans['add']['user'] = array(__('Are you sure you want to add this user?'), false); - $trans['delete']['users'] = array(__('Are you sure you want to delete users?'), false); - $trans['bulk']['users'] = array(__('Are you sure you want to bulk modify users?'), false); - $trans['update']['user'] = array(__('Are you sure you want to edit this user: "%s"?'), 'get_author_name'); - $trans['update']['profile'] = array(__('Are you sure you want to modify the profile for: "%s"?'), 'get_author_name'); - - $trans['update']['options'] = array(__('Are you sure you want to edit your settings?'), false); - $trans['update']['permalink'] = array(__('Are you sure you want to change your permalink structure to: %s?'), 'use_id'); - $trans['edit']['file'] = array(__('Are you sure you want to edit this file: "%s"?'), 'use_id'); - $trans['edit']['theme'] = array(__('Are you sure you want to edit this theme file: "%s"?'), 'use_id'); - $trans['switch']['theme'] = array(__('Are you sure you want to switch to this theme: "%s"?'), 'use_id'); - - if ( isset($trans[$verb][$noun]) ) { - if ( !empty($trans[$verb][$noun][1]) ) { + $trans['update']['attachment'] = array( __( 'Your attempt to edit this attachment: "%s" has failed.' ), 'get_the_title' ); + + $trans['add']['category'] = array( __( 'Your attempt to add this category has failed.' ), false ); + $trans['delete']['category'] = array( __( 'Your attempt to delete this category: "%s" has failed.' ), 'get_catname' ); + $trans['update']['category'] = array( __( 'Your attempt to edit this category: "%s" has failed.' ), 'get_catname' ); + + $trans['delete']['comment'] = array( __( 'Your attempt to delete this comment: "%s" has failed.' ), 'use_id' ); + $trans['unapprove']['comment'] = array( __( 'Your attempt to unapprove this comment: "%s" has failed.' ), 'use_id' ); + $trans['approve']['comment'] = array( __( 'Your attempt to approve this comment: "%s" has failed.' ), 'use_id' ); + $trans['update']['comment'] = array( __( 'Your attempt to edit this comment: "%s" has failed.' ), 'use_id' ); + $trans['bulk']['comments'] = array( __( 'Your attempt to bulk modify comments has failed.' ), false ); + $trans['moderate']['comments'] = array( __( 'Your attempt to moderate comments has failed.' ), false ); + + $trans['add']['bookmark'] = array( __( 'Your attempt to add this link has failed.' ), false ); + $trans['delete']['bookmark'] = array( __( 'Your attempt to delete this link: "%s" has failed.' ), 'use_id' ); + $trans['update']['bookmark'] = array( __( 'Your attempt to edit this link: "%s" has failed.' ), 'use_id' ); + $trans['bulk']['bookmarks'] = array( __( 'Your attempt to bulk modify links has failed.' ), false ); + + $trans['add']['page'] = array( __( 'Your attempt to add this page has failed.' ), false ); + $trans['delete']['page'] = array( __( 'Your attempt to delete this page: "%s" has failed.' ), 'get_the_title' ); + $trans['update']['page'] = array( __( 'Your attempt to edit this page: "%s" has failed.' ), 'get_the_title' ); + + $trans['edit']['plugin'] = array( __( 'Your attempt to edit this plugin file: "%s" has failed.' ), 'use_id' ); + $trans['activate']['plugin'] = array( __( 'Your attempt to activate this plugin: "%s" has failed.' ), 'use_id' ); + $trans['deactivate']['plugin'] = array( __( 'Your attempt to deactivate this plugin: "%s" has failed.' ), 'use_id' ); + $trans['upgrade']['plugin'] = array( __( 'Your attempt to upgrade this plugin: "%s" has failed.' ), 'use_id' ); + + $trans['add']['post'] = array( __( 'Your attempt to add this post has failed.' ), false ); + $trans['delete']['post'] = array( __( 'Your attempt to delete this post: "%s" has failed.' ), 'get_the_title' ); + $trans['update']['post'] = array( __( 'Your attempt to edit this post: "%s" has failed.' ), 'get_the_title' ); + + $trans['add']['user'] = array( __( 'Your attempt to add this user has failed.' ), false ); + $trans['delete']['users'] = array( __( 'Your attempt to delete users has failed.' ), false ); + $trans['bulk']['users'] = array( __( 'Your attempt to bulk modify users has failed.' ), false ); + $trans['update']['user'] = array( __( 'Your attempt to edit this user: "%s" has failed.' ), 'get_author_name' ); + $trans['update']['profile'] = array( __( 'Your attempt to modify the profile for: "%s" has failed.' ), 'get_author_name' ); + + $trans['update']['options'] = array( __( 'Your attempt to edit your settings has failed.' ), false ); + $trans['update']['permalink'] = array( __( 'Your attempt to change your permalink structure to: %s has failed.' ), 'use_id' ); + $trans['edit']['file'] = array( __( 'Your attempt to edit this file: "%s" has failed.' ), 'use_id' ); + $trans['edit']['theme'] = array( __( 'Your attempt to edit this theme file: "%s" has failed.' ), 'use_id' ); + $trans['switch']['theme'] = array( __( 'Your attempt to switch to this theme: "%s" has failed.' ), 'use_id' ); + + if ( isset( $trans[$verb][$noun] ) ) { + if ( !empty( $trans[$verb][$noun][1] ) ) { $lookup = $trans[$verb][$noun][1]; $object = $matches[4]; if ( 'use_id' != $lookup ) - $object = call_user_func($lookup, $object); - return sprintf($trans[$verb][$noun][0], $object); + $object = call_user_func( $lookup, $object ); + return sprintf( $trans[$verb][$noun][0], wp_specialchars($object) ); } else { return $trans[$verb][$noun][0]; } } } - return apply_filters( 'explain_nonce_' . $verb . '-' . $noun, __('Are you sure you want to do this?'), $matches[4] ); + return apply_filters( 'explain_nonce_' . $verb . '-' . $noun, __( 'Are you sure you want to do this?' ), $matches[4] ); } -function wp_nonce_ays($action) { - global $pagenow, $menu, $submenu, $parent_file, $submenu_file; - $adminurl = get_option('siteurl') . '/wp-admin'; +function wp_nonce_ays( $action ) { + $title = __( 'WordPress Failure Notice' ); + $html = wp_specialchars( wp_explain_nonce( $action ) ) . '</p>'; if ( wp_get_referer() ) - $adminurl = clean_url(wp_get_referer()); - - $title = __('WordPress Confirmation'); - // Remove extra layer of slashes. - $_POST = stripslashes_deep($_POST ); - if ( $_POST ) { - $q = http_build_query($_POST); - $q = explode( ini_get('arg_separator.output'), $q); - $html .= "\t<form method='post' action='" . attribute_escape($pagenow) . "'>\n"; - foreach ( (array) $q as $a ) { - $v = substr(strstr($a, '='), 1); - $k = substr($a, 0, -(strlen($v)+1)); - $html .= "\t\t<input type='hidden' name='" . attribute_escape(urldecode($k)) . "' value='" . attribute_escape(urldecode($v)) . "' />\n"; - } - $html .= "\t\t<input type='hidden' name='_wpnonce' value='" . wp_create_nonce($action) . "' />\n"; - $html .= "\t\t<div id='message' class='confirm fade'>\n\t\t<p>" . wp_specialchars(wp_explain_nonce($action)) . "</p>\n\t\t<p><a href='$adminurl'>" . __('No') . "</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t\t</div>\n\t</form>\n"; - } else { - $html .= "\t<div id='message' class='confirm fade'>\n\t<p>" . wp_specialchars(wp_explain_nonce($action)) . "</p>\n\t<p><a href='$adminurl'>" . __('No') . "</a> <a href='" . clean_url(add_query_arg( '_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'] )) . "'>" . __('Yes') . "</a></p>\n\t</div>\n"; - } - $html .= "</body>\n</html>"; - wp_die($html, $title); + $html .= "<p><a href='" . remove_query_arg( 'updated', clean_url( wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>"; + wp_die( $html, $title); } + function wp_die( $message, $title = '' ) { global $wp_locale; if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { - if ( empty($title) ) { + if ( empty( $title ) ) { $error_data = $message->get_error_data(); - if ( is_array($error_data) && isset($error_data['title']) ) + if ( is_array( $error_data ) && isset( $error_data['title'] ) ) $title = $error_data['title']; } $errors = $message->get_error_messages(); - switch ( count($errors) ) : + switch ( count( $errors ) ) : case 0 : $message = ''; break; @@ -1230,105 +1371,90 @@ function wp_die( $message, $title = '' ) { $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>"; break; endswitch; - } elseif ( is_string($message) ) { + } elseif ( is_string( $message ) ) { $message = "<p>$message</p>"; } - if ( defined('WP_SITEURL') && '' != WP_SITEURL ) - $admin_dir = WP_SITEURL.'/wp-admin/'; - elseif (function_exists('get_bloginfo') && '' != get_bloginfo('wpurl')) - $admin_dir = get_bloginfo('wpurl').'/wp-admin/'; - elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) + if ( defined( 'WP_SITEURL' ) && '' != WP_SITEURL ) + $admin_dir = WP_SITEURL . '/wp-admin/'; + elseif ( function_exists( 'get_bloginfo' ) && '' != get_bloginfo( 'wpurl' ) ) + $admin_dir = get_bloginfo( 'wpurl' ) . '/wp-admin/'; + elseif ( strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) !== false ) $admin_dir = ''; else $admin_dir = 'wp-admin/'; - if ( !function_exists('did_action') || !did_action('admin_head') ) : + if ( !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ) : if( !headers_sent() ){ - status_header(500); + status_header( 500 ); nocache_headers(); - header('Content-Type: text/html; charset=utf-8'); + header( 'Content-Type: text/html; charset=utf-8' ); } - if ( empty($title) ){ - if( function_exists('__') ) - $title = __('WordPress › Error'); + if ( empty($title) ) { + if ( function_exists( '__' ) ) + $title = __( 'WordPress › Error' ); else $title = 'WordPress › Error'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists('language_attributes') ) language_attributes(); ?>> +<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>> <head> - <title><?php echo $title ?> + <?php echo $title ?> text_direction) ) : ?> +if ( ( $wp_locale ) && ( 'rtl' == $wp_locale->text_direction ) ) : ?> - + -

    WordPress

    - text_direction) { - echo 'directionality : "rtl" ,'; - echo 'theme_advanced_toolbar_align : "right" ,'; - } + return $url; } -function _mce_load_rtl_plugin($input) { - global $wp_locale; - - if ('rtl' == $wp_locale->text_direction) - $input[] = 'directionality'; - - return $input; -} -function _mce_add_direction_buttons($input) { +function _mce_set_direction( $input ) { global $wp_locale; - if ('rtl' == $wp_locale->text_direction) { - $new_buttons = array('separator', 'ltr', 'rtl'); - $input = array_merge($input, $new_buttons); + if ( 'rtl' == $wp_locale->text_direction ) { + $input['directionality'] = 'rtl'; + $input['plugins'] .= ',directionality'; + $input['theme_advanced_buttons1'] .= ',ltr'; } return $input; } + function smilies_init() { global $wpsmiliestrans, $wp_smiliessearch, $wp_smiliesreplace; // don't bother setting up smilies if they are disabled - if ( !get_option('use_smilies') ) + if ( !get_option( 'use_smilies' ) ) return; - if (!isset($wpsmiliestrans)) { + if ( !isset( $wpsmiliestrans ) ) { $wpsmiliestrans = array( ':mrgreen:' => 'icon_mrgreen.gif', ':neutral:' => 'icon_neutral.gif', @@ -1377,48 +1503,67 @@ function smilies_init() { ); } - $siteurl = get_option('siteurl'); + $siteurl = get_option( 'siteurl' ); foreach ( (array) $wpsmiliestrans as $smiley => $img ) { - $wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'(\s|$)/'; - $smiley_masked = htmlspecialchars(trim($smiley), ENT_QUOTES); + $wp_smiliessearch[] = '/(\s|^)' . preg_quote( $smiley, '/' ) . '(\s|$)/'; + $smiley_masked = attribute_escape( trim( $smiley ) ); $wp_smiliesreplace[] = " $smiley_masked "; } } + function wp_parse_args( $args, $defaults = '' ) { - if ( is_object($args) ) - $r = get_object_vars($args); - else if ( is_array( $args ) ) + if ( is_object( $args ) ) + $r = get_object_vars( $args ); + elseif ( is_array( $args ) ) $r =& $args; else wp_parse_str( $args, $r ); if ( is_array( $defaults ) ) return array_merge( $defaults, $r ); - else - return $r; + return $r; } + function wp_maybe_load_widgets() { if ( !function_exists( 'dynamic_sidebar' ) ) { - require_once ABSPATH . WPINC . '/widgets.php'; + require_once( ABSPATH . WPINC . '/widgets.php' ); add_action( '_admin_menu', 'wp_widgets_add_menu' ); } } + function wp_widgets_add_menu() { global $submenu; $submenu['themes.php'][7] = array( __( 'Widgets' ), 'switch_themes', 'widgets.php' ); - ksort($submenu['themes.php'], SORT_NUMERIC); + ksort( $submenu['themes.php'], SORT_NUMERIC ); } + // For PHP 5.2, make sure all output buffers are flushed // before our singletons our destroyed. -function wp_ob_end_flush_all() -{ +function wp_ob_end_flush_all() { while ( @ob_end_flush() ); } + +/* + * require_wp_db() - require_once the correct database class file. + * + * This function is used to load the database class file either at runtime or by wp-admin/setup-config.php + * We must globalise $wpdb to ensure that it is defined globally by the inline code in wp-db.php + * + * @global $wpdb + */ +function require_wp_db() { + global $wpdb; + if ( file_exists( ABSPATH . 'wp-content/db.php' ) ) + require_once( ABSPATH . 'wp-content/db.php' ); + else + require_once( ABSPATH . WPINC . '/wp-db.php' ); +} + function dead_db() { global $wpdb; @@ -1440,8 +1585,9 @@ function dead_db() { > + Database Error - +

    Error establishing a database connection

    @@ -1451,4 +1597,156 @@ function dead_db() { die(); } +/** + * Converts input to an absolute integer + * @param mixed $maybeint data you wish to have convered to an absolute integer + * @return int an absolute integer + */ +function absint( $maybeint ) { + return abs( intval( $maybeint ) ); +} + +/** + * Determines if the blog can be accessed over SSL + * @return bool whether of not SSL access is available + */ +function url_is_accessable_via_ssl($url) +{ + if (in_array('curl', get_loaded_extensions())) { + $ssl = preg_replace( '/^http:\/\//', 'https://', $url ); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $ssl); + curl_setopt($ch, CURLOPT_FAILONERROR, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + + curl_exec($ch); + + $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close ($ch); + + if ($status == 200 || $status == 401) { + return true; + } + } + return false; +} + +function atom_service_url_filter($url) +{ + if ( url_is_accessable_via_ssl($url) ) + return preg_replace( '/^http:\/\//', 'https://', $url ); + else + return $url; +} + +/** + * _deprecated_function() - Marks a function as deprecated and informs when it has been used. + * + * There is a hook deprecated_function_run that will be called that can be used to get the backtrace + * up to what file and function called the deprecated function. + * + * The current behavior is to trigger an user error if WP_DEBUG is defined and is true. + * + * This function is to be used in every function in depreceated.php + * + * @package WordPress + * @package Debug + * @since 2.5 + * @access private + * + * @uses do_action() Calls 'deprecated_function_run' and passes the function name and what to use instead. + * @uses apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do trigger or false to not trigger error. + * + * @param string $function The function that was called + * @param string $version The version of WordPress that depreceated the function + * @param string $replacement Optional. The function that should have been called + */ +function _deprecated_function($function, $version, $replacement=null) { + + do_action('deprecated_function_run', $function, $replacement); + + // Allow plugin to filter the output error trigger + if( defined('WP_DEBUG') && ( true === WP_DEBUG ) && apply_filters( 'deprecated_function_trigger_error', true )) { + if( !is_null($replacement) ) + trigger_error( printf( __("%1$s is deprecated since version %2$s! Use %3$s instead."), $function, $version, $replacement ) ); + else + trigger_error( printf( __("%1$s is deprecated since version %2$s with no alternative available."), $function, $version ) ); + } +} + +/** + * _deprecated_file() - Marks a file as deprecated and informs when it has been used. + * + * There is a hook deprecated_file_included that will be called that can be used to get the backtrace + * up to what file and function included the deprecated file. + * + * The current behavior is to trigger an user error if WP_DEBUG is defined and is true. + * + * This function is to be used in every file that is depreceated + * + * @package WordPress + * @package Debug + * @since 2.5 + * @access private + * + * @uses do_action() Calls 'deprecated_file_included' and passes the file name and what to use instead. + * @uses apply_filters() Calls 'deprecated_file_trigger_error' and expects boolean value of true to do trigger or false to not trigger error. + * + * @param string $file The file that was included + * @param string $version The version of WordPress that depreceated the function + * @param string $replacement Optional. The function that should have been called + */ +function _deprecated_file($file, $version, $replacement=null) { + + do_action('deprecated_file_included', $file, $replacement); + + // Allow plugin to filter the output error trigger + if( defined('WP_DEBUG') && ( true === WP_DEBUG ) && apply_filters( 'deprecated_file_trigger_error', true )) { + if( !is_null($replacement) ) + trigger_error( printf( __("%1$s is deprecated since version %2$s! Use %3$s instead."), $file, $version, $replacement ) ); + else + trigger_error( printf( __("%1$s is deprecated since version %2$s with no alternative available."), $file, $version ) ); + } +} + +/** + * is_lighttpd_before_150() - Is the server running earlier than 1.5.0 version of lighttpd + * + * @return bool Whether the server is running lighttpd < 1.5.0 + */ +function is_lighttpd_before_150() { + $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' ); + $server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : ''; + return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ); +} + +/** + * apache_mod_loaded() - Does the specified module exist in the apache config? + * + * @param string $mod e.g. mod_rewrite + * @param bool $default The default return value if the module is not found + * @return bool + */ +function apache_mod_loaded($mod, $default = false) { + global $is_apache; + + if ( !$is_apache ) + return false; + + if ( function_exists('apache_get_modules') ) { + $mods = apache_get_modules(); + if ( in_array($mod, $mods) ) + return true; + } elseif ( function_exists('phpinfo') ) { + ob_start(); + phpinfo(8); + $phpinfo = ob_get_clean(); + if ( false !== strpos($phpinfo, $mod) ) + return true; + } + return $default; +} + ?> diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 33263f34..1b1baf30 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -20,9 +20,11 @@ function get_footer() { } -function get_sidebar() { +function get_sidebar( $name = null ) { do_action( 'get_sidebar' ); - if ( file_exists( TEMPLATEPATH . '/sidebar.php') ) + if ( isset($name) && file_exists( TEMPLATEPATH . "/sidebar-{$name}.php") ) + load_template( TEMPLATEPATH . "/sidebar-{$name}.php"); + elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') ) load_template( TEMPLATEPATH . '/sidebar.php'); else load_template( ABSPATH . 'wp-content/themes/default/sidebar.php'); @@ -31,9 +33,9 @@ function get_sidebar() { function wp_loginout() { if ( ! is_user_logged_in() ) - $link = '' . __('Login') . ''; + $link = '' . __('Log in') . ''; else - $link = '' . __('Logout') . ''; + $link = '' . __('Log out') . ''; echo apply_filters('loginout', $link); } @@ -159,13 +161,11 @@ function get_bloginfo($show = '', $filter = 'raw') { } -function wp_title($sep = '»', $display = true) { +function wp_title($sep = '»', $display = true, $seplocation = '') { global $wpdb, $wp_locale, $wp_query; $cat = get_query_var('cat'); $tag = get_query_var('tag_id'); - $p = get_query_var('p'); - $name = get_query_var('name'); $category_name = get_query_var('category_name'); $author = get_query_var('author'); $author_name = get_query_var('author_name'); @@ -195,7 +195,7 @@ function wp_title($sep = '»', $display = true) { if ( !empty($tag) ) { $tag = get_term($tag, 'post_tag', OBJECT, 'display'); - if ( is_wp_error( $tag ) ) + if ( is_wp_error( $tag ) ) return $tag; if ( ! empty($tag->name) ) $title = apply_filters('single_tag_title', $tag->name); @@ -208,7 +208,7 @@ function wp_title($sep = '»', $display = true) { } if ( !empty($author_name) ) { // We do a direct query here because we don't cache by nicename. - $title = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE user_nicename = '$author_name'"); + $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name)); } // If there's a month @@ -237,7 +237,12 @@ function wp_title($sep = '»', $display = true) { if ( !empty($title) ) $prefix = " $sep "; - $title = $prefix . $title; + // Determines position of the separator + if ( 'right' == $seplocation ) + $title = $title . $prefix; + else + $title = $prefix . $title; + $title = apply_filters('wp_title', $title, $sep); // Send it out @@ -245,6 +250,7 @@ function wp_title($sep = '»', $display = true) { echo $title; else return $title; + } @@ -255,7 +261,7 @@ function single_post_title($prefix = '', $display = true) { if ( intval($p) || '' != $name ) { if ( !$p ) - $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'"); + $p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name)); $post = & get_post($p); $title = $post->post_title; $title = apply_filters('single_post_title', $title); @@ -291,7 +297,7 @@ function single_tag_title($prefix = '', $display = true ) { if ( !empty($tag_id) ) { $my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display'); - if ( is_wp_error( $my_tag ) ) + if ( is_wp_error( $my_tag ) ) return false; $my_tag_name = apply_filters('single_tag_title', $my_tag->name); if ( !empty($my_tag_name) ) { @@ -363,7 +369,7 @@ function wp_get_archives($args = '') { $type = 'monthly'; if ( '' != $limit ) { - $limit = (int) $limit; + $limit = absint($limit); $limit = ' LIMIT '.$limit; } @@ -386,15 +392,21 @@ function wp_get_archives($args = '') { $archive_week_end_date_format = get_option('date_format'); } - $add_hours = intval(get_option('gmt_offset')); - $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours)); - //filters $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); $join = apply_filters('getarchives_join', "", $r); if ( 'monthly' == $type ) { - $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); + $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit"; + $key = md5($query); + $cache = wp_cache_get( 'wp_get_archives' , 'general'); + if ( !isset( $cache[ $key ] ) ) { + $arcresults = $wpdb->get_results($query); + $cache[ $key ] = $arcresults; + wp_cache_add( 'wp_get_archives', $cache, 'general' ); + } else { + $arcresults = $cache[ $key ]; + } if ( $arcresults ) { $afterafter = $after; foreach ( $arcresults as $arcresult ) { @@ -406,7 +418,16 @@ function wp_get_archives($args = '') { } } } elseif ('yearly' == $type) { - $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit); + $query = "SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit"; + $key = md5($query); + $cache = wp_cache_get( 'wp_get_archives' , 'general'); + if ( !isset( $cache[ $key ] ) ) { + $arcresults = $wpdb->get_results($query); + $cache[ $key ] = $arcresults; + wp_cache_add( 'wp_get_archives', $cache, 'general' ); + } else { + $arcresults = $cache[ $key ]; + } if ($arcresults) { $afterafter = $after; foreach ($arcresults as $arcresult) { @@ -418,7 +439,16 @@ function wp_get_archives($args = '') { } } } elseif ( 'daily' == $type ) { - $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit); + $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit"; + $key = md5($query); + $cache = wp_cache_get( 'wp_get_archives' , 'general'); + if ( !isset( $cache[ $key ] ) ) { + $arcresults = $wpdb->get_results($query); + $cache[ $key ] = $arcresults; + wp_cache_add( 'wp_get_archives', $cache, 'general' ); + } else { + $arcresults = $cache[ $key ]; + } if ( $arcresults ) { $afterafter = $after; foreach ( $arcresults as $arcresult ) { @@ -432,7 +462,16 @@ function wp_get_archives($args = '') { } } elseif ( 'weekly' == $type ) { $start_of_week = get_option('start_of_week'); - $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit); + $query = "SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC $limit"; + $key = md5($query); + $cache = wp_cache_get( 'wp_get_archives' , 'general'); + if ( !isset( $cache[ $key ] ) ) { + $arcresults = $wpdb->get_results($query); + $cache[ $key ] = $arcresults; + wp_cache_add( 'wp_get_archives', $cache, 'general' ); + } else { + $arcresults = $cache[ $key ]; + } $arc_w_last = ''; $afterafter = $after; if ( $arcresults ) { @@ -453,7 +492,16 @@ function wp_get_archives($args = '') { } } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC "; - $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"); + $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; + $key = md5($query); + $cache = wp_cache_get( 'wp_get_archives' , 'general'); + if ( !isset( $cache[ $key ] ) ) { + $arcresults = $wpdb->get_results($query); + $cache[ $key ] = $arcresults; + wp_cache_add( 'wp_get_archives', $cache, 'general' ); + } else { + $arcresults = $cache[ $key ]; + } if ( $arcresults ) { foreach ( $arcresults as $arcresult ) { if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { @@ -479,7 +527,7 @@ function calendar_week_mod($num) { function get_calendar($initial = true) { - global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts; + global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; $key = md5( $m . $monthnum . $year ); if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) { @@ -502,8 +550,6 @@ function get_calendar($initial = true) { // week_begins = 0 stands for Sunday $week_begins = intval(get_option('start_of_week')); - $add_hours = intval(get_option('gmt_offset')); - $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours)); // Let's figure out when we are if ( !empty($monthnum) && !empty($year) ) { @@ -515,7 +561,6 @@ function get_calendar($initial = true) { $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); } elseif ( !empty($m) ) { - $calendar = substr($m, 0, 6); $thisyear = ''.intval(substr($m, 0, 4)); if ( strlen($m) < 6 ) $thismonth = '01'; @@ -544,7 +589,7 @@ function get_calendar($initial = true) { LIMIT 1"); echo ' - + '; @@ -710,7 +755,7 @@ function the_date_xml() { function the_date($d='', $before='', $after='', $echo = true) { - global $id, $post, $day, $previousday; + global $post, $day, $previousday; $the_date = ''; if ( $day != $previousday ) { $the_date .= $before; @@ -797,7 +842,7 @@ function get_post_modified_time( $d = 'U', $gmt = false ) { // returns timestamp function the_weekday() { - global $wp_locale, $id, $post; + global $wp_locale, $post; $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date)); $the_weekday = apply_filters('the_weekday', $the_weekday); echo $the_weekday; @@ -805,7 +850,7 @@ function the_weekday() { function the_weekday_date($before='',$after='') { - global $wp_locale, $id, $post, $day, $previousweekday; + global $wp_locale, $post, $day, $previousweekday; $the_weekday_date = ''; if ( $day != $previousweekday ) { $the_weekday_date .= $before; @@ -826,12 +871,12 @@ function wp_footer() { } function rsd_link() { - echo ' \n"; + echo '\n"; } function wlwmanifest_link() { - echo ' '; + echo ' ' . "\n"; } function noindex() { @@ -864,95 +909,88 @@ function user_can_richedit() { return apply_filters('user_can_richedit', $wp_rich_edit); } -function the_editor($content, $id = 'content', $prev_id = 'title') { +function wp_default_editor() { + $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults + if ( $user = wp_get_current_user() ) { // look for cookie + if ( isset($_COOKIE['wordpress_editor_' . $user->ID]) && in_array($_COOKIE['wordpress_editor_' . $user->ID], array('tinymce', 'html', 'test') ) ) + $r = $_COOKIE['wordpress_editor_' . $user->ID]; + } + return apply_filters( 'wp_default_editor', $r ); // filter +} + +function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) { $rows = get_option('default_post_edit_rows'); if (($rows < 3) || ($rows > 100)) $rows = 12; - $rows = "rows='$rows'"; - - if ( user_can_richedit() ) : - add_filter('the_editor_content', 'wp_richedit_pre'); + $rows = "rows='$rows'"; ?> +
    + +
    + + + + + + + - - - - - +
    - -
    \n"); + + + + \n"); $the_editor_content = apply_filters('the_editor_content', $content); printf($the_editor, $the_editor_content); ?> - - + // '); + + // If tinyMCE is defined. + if ( typeof tinyMCE != 'undefined' ) { + // This code is meant to allow tabbing from Title to Post (TinyMCE). + document.getElementById('').onkeydown = function (e) { + e = e || window.event; + if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { + if ( tinyMCE.activeEditor ) { + if ( (jQuery("#post_ID").val() < 1) && (jQuery("#title").val().length > 0) ) { autosave(); } + e = null; + if ( tinyMCE.activeEditor.isHidden() ) return true; + tinyMCE.activeEditor.focus(); + return false; + } + return true; + } + } + } + + // ]]> + + $name, 'url' => $url, 'colors' => $colors); +} + function wp_admin_css_uri( $file = 'wp-admin' ) { - if ( defined('WP_INSTALLING') ) - { - $_file = add_query_arg( 'version', get_bloginfo( 'version' ), "./$file.css" ); + if ( defined('WP_INSTALLING') ) { + $_file = "./$file.css"; } else { - $_file = add_query_arg( 'version', get_bloginfo( 'version' ), get_option( 'siteurl' ) . "/wp-admin/$file.css" ); + if ( 'css/colors' == $file || 'css/colors-rtl' == $file ) { + global $_wp_admin_css_colors; + $color = get_user_option('admin_color'); + if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) + $color = 'fresh'; + $color = $_wp_admin_css_colors[$color]; + $_file = $color->url; + $_file = ('css/colors-rtl' == $file) ? str_replace('.css','-rtl.css',$_file) : $_file; + } else { + $_file = get_option( 'siteurl' ) . "/wp-admin/$file.css"; + } } + $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file ); + return apply_filters( 'wp_admin_css_uri', $_file, $file ); } function wp_admin_css( $file = 'wp-admin' ) { + echo apply_filters( 'wp_admin_css', "\n", $file ); if ( 'rtl' == get_bloginfo( 'text_direction' ) ) { $rtl = ( 'wp-admin' == $file ) ? 'rtl' : "$file-rtl"; @@ -1075,4 +1140,50 @@ function wp_admin_css( $file = 'wp-admin' ) { } } +/** + * Outputs the XHTML generator that is generated on the wp_head hook. + */ +function wp_generator() +{ + the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) ); +} + +/** + * Outputs the generator XML or Comment for RSS, ATOM, etc. + * @param {String} $type The type of generator to return. + */ +function the_generator ( $type ) { + echo apply_filters('the_generator',get_the_generator($type),$type) . "\n"; +} + +/** + * Creates the generator XML or Comment for RSS, ATOM, etc. + * @param {String} $type The type of generator to return. + */ +function get_the_generator ( $type ) { + switch ($type) { + case 'html': + $gen = '' . "\n"; + break; + case 'xhtml': + $gen = '' . "\n"; + break; + case 'atom': + $gen = 'WordPress'; + break; + case 'rss2': + $gen = 'http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . ''; + break; + case 'rdf': + $gen = ''; + break; + case 'comment': + $gen = ''; + break; + case 'export': + $gen = ''; + break; + } + return apply_filters( "get_the_generator_{$type}", $gen, $type ); +} ?> diff --git a/wp-includes/gettext.php b/wp-includes/gettext.php index 5b78127c..48e98b31 100644 --- a/wp-includes/gettext.php +++ b/wp-includes/gettext.php @@ -1,5 +1,11 @@ . Copyright (c) 2005 Nico Kaiser @@ -391,4 +397,4 @@ class gettext_reader { } -?> +?> \ No newline at end of file diff --git a/wp-includes/images/audio.png b/wp-includes/images/audio.png new file mode 100644 index 00000000..7b2a854e Binary files /dev/null and b/wp-includes/images/audio.png differ diff --git a/wp-includes/images/crystal/archive.png b/wp-includes/images/crystal/archive.png new file mode 100644 index 00000000..670648a2 Binary files /dev/null and b/wp-includes/images/crystal/archive.png differ diff --git a/wp-includes/images/crystal/audio.png b/wp-includes/images/crystal/audio.png new file mode 100644 index 00000000..5a3d4d3a Binary files /dev/null and b/wp-includes/images/crystal/audio.png differ diff --git a/wp-includes/images/crystal/code.png b/wp-includes/images/crystal/code.png new file mode 100644 index 00000000..b67c6005 Binary files /dev/null and b/wp-includes/images/crystal/code.png differ diff --git a/wp-includes/images/crystal/default.png b/wp-includes/images/crystal/default.png new file mode 100644 index 00000000..b1bbbc7b Binary files /dev/null and b/wp-includes/images/crystal/default.png differ diff --git a/wp-includes/images/crystal/document.png b/wp-includes/images/crystal/document.png new file mode 100644 index 00000000..3295ccd3 Binary files /dev/null and b/wp-includes/images/crystal/document.png differ diff --git a/wp-includes/images/crystal/interactive.png b/wp-includes/images/crystal/interactive.png new file mode 100644 index 00000000..fd6de7d7 Binary files /dev/null and b/wp-includes/images/crystal/interactive.png differ diff --git a/wp-includes/images/crystal/license.txt b/wp-includes/images/crystal/license.txt new file mode 100644 index 00000000..cdabd2fd --- /dev/null +++ b/wp-includes/images/crystal/license.txt @@ -0,0 +1,9 @@ +Crystal Project Icons +by Everaldo Coelho +http://everaldo.com + +Released under LGPL + +Modified February 2008 +for WordPress +http://wordpress.org \ No newline at end of file diff --git a/wp-includes/images/crystal/spreadsheet.png b/wp-includes/images/crystal/spreadsheet.png new file mode 100644 index 00000000..f2c4d309 Binary files /dev/null and b/wp-includes/images/crystal/spreadsheet.png differ diff --git a/wp-includes/images/crystal/text.png b/wp-includes/images/crystal/text.png new file mode 100644 index 00000000..feaed5b4 Binary files /dev/null and b/wp-includes/images/crystal/text.png differ diff --git a/wp-includes/images/crystal/video.png b/wp-includes/images/crystal/video.png new file mode 100644 index 00000000..e1b879d6 Binary files /dev/null and b/wp-includes/images/crystal/video.png differ diff --git a/wp-includes/images/css.png b/wp-includes/images/css.png new file mode 100644 index 00000000..038e34de Binary files /dev/null and b/wp-includes/images/css.png differ diff --git a/wp-includes/images/default.png b/wp-includes/images/default.png new file mode 100644 index 00000000..c551227f Binary files /dev/null and b/wp-includes/images/default.png differ diff --git a/wp-includes/images/doc.png b/wp-includes/images/doc.png new file mode 100644 index 00000000..e4e62a1d Binary files /dev/null and b/wp-includes/images/doc.png differ diff --git a/wp-includes/images/exe.png b/wp-includes/images/exe.png new file mode 100644 index 00000000..d9942655 Binary files /dev/null and b/wp-includes/images/exe.png differ diff --git a/wp-includes/images/html.png b/wp-includes/images/html.png new file mode 100644 index 00000000..ed81af15 Binary files /dev/null and b/wp-includes/images/html.png differ diff --git a/wp-includes/images/js.png b/wp-includes/images/js.png new file mode 100644 index 00000000..e0862d35 Binary files /dev/null and b/wp-includes/images/js.png differ diff --git a/wp-includes/images/pdf.png b/wp-includes/images/pdf.png new file mode 100644 index 00000000..b4d5f9c0 Binary files /dev/null and b/wp-includes/images/pdf.png differ diff --git a/wp-includes/images/swf.png b/wp-includes/images/swf.png new file mode 100644 index 00000000..156e3e4a Binary files /dev/null and b/wp-includes/images/swf.png differ diff --git a/wp-includes/images/tar.png b/wp-includes/images/tar.png new file mode 100644 index 00000000..0468ef83 Binary files /dev/null and b/wp-includes/images/tar.png differ diff --git a/wp-includes/images/text.png b/wp-includes/images/text.png new file mode 100644 index 00000000..10bcf5e9 Binary files /dev/null and b/wp-includes/images/text.png differ diff --git a/wp-includes/images/video.png b/wp-includes/images/video.png new file mode 100644 index 00000000..f822ac4a Binary files /dev/null and b/wp-includes/images/video.png differ diff --git a/wp-includes/images/wlw/WpComments.png b/wp-includes/images/wlw/WpComments.png deleted file mode 100644 index 981b1af5..00000000 Binary files a/wp-includes/images/wlw/WpComments.png and /dev/null differ diff --git a/wp-includes/images/wlw/WpIcon.png b/wp-includes/images/wlw/WpIcon.png deleted file mode 100644 index cd94ee3b..00000000 Binary files a/wp-includes/images/wlw/WpIcon.png and /dev/null differ diff --git a/wp-includes/images/wlw/WpWatermark.png b/wp-includes/images/wlw/WpWatermark.png deleted file mode 100644 index c312a725..00000000 Binary files a/wp-includes/images/wlw/WpWatermark.png and /dev/null differ diff --git a/wp-includes/images/zip.png b/wp-includes/images/zip.png new file mode 100644 index 00000000..d1eaf1ee Binary files /dev/null and b/wp-includes/images/zip.png differ diff --git a/wp-includes/js/autosave.js b/wp-includes/js/autosave.js index ae2c1054..b0a2fa56 100644 --- a/wp-includes/js/autosave.js +++ b/wp-includes/js/autosave.js @@ -1,158 +1,215 @@ var autosaveLast = ''; var autosavePeriodical; +var autosaveOldMessage = ''; + +jQuery(function($) { + autosaveLast = $('#post #title').val()+$('#post #content').val(); + autosavePeriodical = $.schedule({time: autosaveL10n.autosaveInterval * 1000, func: function() { autosave(); }, repeat: true, protect: true}); -function autosave_start_timer() { - var form = $('post'); - autosaveLast = form.post_title.value+form.content.value; - // Keep autosave_interval in sync with edit_post(). - autosavePeriodical = new PeriodicalExecuter(autosave, autosaveL10n.autosaveInterval); //Disable autosave after the form has been submitted - if(form.addEventListener) { - form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false); - } - if(form.attachEvent) { - form.save ? form.save.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null; - form.submit ? form.submit.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null; - form.publish ? form.publish.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null; - form.deletepost ? form.deletepost.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null; + $("#post").submit(function() { $.cancel(autosavePeriodical); }); +}); + +function autosave_parse_response(response) { + var res = wpAjax.parseAjaxResponse(response, 'autosave'); // parse the ajax response + var message = ''; + + if ( res && res.responses && res.responses.length ) { + message = res.responses[0].data; // The saved message or error. + // someone else is editing: disable autosave, set errors + if ( res.responses[0].supplemental ) { + if ( 'disable' == res.responses[0].supplemental['disable_autosave'] ) { + autosave = function() {}; + res = { errors: true }; + } + jQuery.each(res.responses[0].supplemental, function(selector, value) { + if ( selector.match(/^replace-/) ) { + jQuery('#'+selector.replace('replace-', '')).val(value); + } + }); + } + + // if no errors: add preview link and slug UI + if ( !res.errors ) { + var postID = parseInt( res.responses[0].id ); + if ( !isNaN(postID) && postID > 0 ) { + autosave_update_preview_link(postID); + autosave_update_slug(postID); + } + } } + if ( message ) { jQuery('#autosave').html(message); } // update autosave message + else if ( autosaveOldMessage && res ) { jQuery('#autosave').html( autosaveOldMessage ); } + return res; } -addLoadEvent(autosave_start_timer) -function autosave_cur_time() { - var now = new Date(); - return "" + ((now.getHours() >12) ? now.getHours() -12 : now.getHours()) + - ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes() + - ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds(); +// called when autosaving pre-existing post +function autosave_saved(response) { + autosave_parse_response(response); // parse the ajax response + autosave_enable_buttons(); // re-enable disabled form buttons } -function autosave_update_nonce() { - var response = nonceAjax.response; - document.getElementsByName('_wpnonce')[0].value = response; +// called when autosaving new post +function autosave_saved_new(response) { + var res = autosave_parse_response(response); // parse the ajax response + // if no errors: update post_ID from the temporary value, grab new save-nonce for that new ID + if ( res && res.responses.length && !res.errors ) { + var tempID = jQuery('#post_ID').val(); + var postID = parseInt( res.responses[0].id ); + autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here + if ( tempID < 0 && postID > 0) // update media buttons + jQuery('#media-buttons a').each(function(){ + this.href = this.href.replace(tempID, postID); + }); + } else { + autosave_enable_buttons(); // re-enable disabled form buttons + } } -function autosave_update_post_ID() { - var response = autosaveAjax.response; - var res = parseInt(response); - var message; - - if(isNaN(res)) { - message = autosaveL10n.errorText.replace(/%response%/g, response); - } else { - message = autosaveL10n.saveText.replace(/%time%/g, autosave_cur_time()); - $('post_ID').name = "post_ID"; - $('post_ID').value = res; +function autosave_update_post_ID( postID ) { + if ( !isNaN(postID) && postID > 0 ) { + if ( postID == parseInt(jQuery('#post_ID').val()) ) { return; } // no need to do this more than once + jQuery('#post_ID').attr({name: "post_ID"}); + jQuery('#post_ID').val(postID); // We need new nonces - nonceAjax = new sack(); - nonceAjax.element = null; - nonceAjax.setVar("action", "autosave-generate-nonces"); - nonceAjax.setVar("post_ID", res); - nonceAjax.setVar("cookie", document.cookie); - nonceAjax.setVar("post_type", $('post_type').value); - nonceAjax.requestFile = autosaveL10n.requestFile; - nonceAjax.onCompletion = autosave_update_nonce; - nonceAjax.method = "POST"; - nonceAjax.runAJAX(); - $('hiddenaction').value = 'editpost'; + jQuery.post(autosaveL10n.requestFile, { + action: "autosave-generate-nonces", + post_ID: postID, + autosavenonce: jQuery('#autosavenonce').val(), + post_type: jQuery('#post_type').val() + }, function(html) { + jQuery('#_wpnonce').val(html); + autosave_enable_buttons(); // re-enable disabled form buttons + }); + jQuery('#hiddenaction').val('editpost'); } - $('autosave').innerHTML = message; - autosave_enable_buttons(); } -function autosave_loading() { - $('autosave').innerHTML = autosaveL10n.savingText; +function autosave_update_preview_link(post_id) { + // Add preview button if not already there + if ( !jQuery('#previewview > *').size() ) { + var post_type = jQuery('#post_type').val(); + var previewText = 'page' == post_type ? autosaveL10n.previewPageText : autosaveL10n.previewPostText; + jQuery.post(autosaveL10n.requestFile, { + action: "get-permalink", + post_id: post_id, + getpermalinknonce: jQuery('#getpermalinknonce').val() + }, function(permalink) { + jQuery('#previewview').html(''+previewText+''); + }); + } } -function autosave_saved() { - var response = autosaveAjax.response; - var res = parseInt(response); - var message; - - if(isNaN(res)) { - message = autosaveL10n.errorText.replace(/%response%/g, response); - } else { - message = autosaveL10n.saveText.replace(/%time%/g, autosave_cur_time()); +function autosave_update_slug(post_id) { + // create slug area only if not already there + if ( jQuery.isFunction(make_slugedit_clickable) && !jQuery('#edit-slug-box > *').size() ) { + jQuery.post( + slugL10n.requestFile, + { + action: 'sample-permalink', + post_id: post_id, + new_title: jQuery('#title').val(), + samplepermalinknonce: jQuery('#samplepermalinknonce').val() + }, + function(data) { + jQuery('#edit-slug-box').html(data); + make_slugedit_clickable(); + } + ); } - $('autosave').innerHTML = message; - autosave_enable_buttons(); } -function autosave_disable_buttons() { - var form = $('post'); - form.save ? form.save.disabled = 'disabled' : null; - form.submit ? form.submit.disabled = 'disabled' : null; - form.publish ? form.publish.disabled = 'disabled' : null; - form.deletepost ? form.deletepost.disabled = 'disabled' : null; - setTimeout('autosave_enable_buttons();', 1000); // Re-enable 1 sec later. Just gives autosave a head start to avoid collisions. +function autosave_loading() { + jQuery('#autosave').html(autosaveL10n.savingText); } function autosave_enable_buttons() { - var form = $('post'); - form.save ? form.save.disabled = '' : null; - form.submit ? form.submit.disabled = '' : null; - form.publish ? form.publish.disabled = '' : null; - form.deletepost ? form.deletepost.disabled = '' : null; + jQuery("#submitpost :button:disabled, #submitpost :submit:disabled").attr('disabled', ''); } -function autosave() { - var form = $('post'); - var rich = ((typeof tinyMCE != "undefined") && tinyMCE.getInstanceById('content')) ? true : false; +function autosave_disable_buttons() { + jQuery("#submitpost :button:enabled, #submitpost :submit:enabled").attr('disabled', 'disabled'); + setTimeout(autosave_enable_buttons, 5000); // Re-enable 5 sec later. Just gives autosave a head start to avoid collisions. +} - autosaveAjax = new sack(); +var autosave = function() { + // (bool) is rich editor enabled and active + var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); + var post_data = { + action: "autosave", + post_ID: jQuery("#post_ID").val() || 0, + post_title: jQuery("#title").val() || "", + autosavenonce: jQuery('#autosavenonce').val(), + tags_input: jQuery("#tags-input").val() || "", + post_type: jQuery('#post_type').val() || "", + autosave: 1 + }; + + // We always send the ajax request in order to keep the post lock fresh. + // This (bool) tells whether or not to write the post to the DB during the ajax request. + var doAutoSave = true; + + // No autosave while thickbox is open (media buttons) + if ( jQuery("#TB_window").css('display') == 'block' ) + doAutoSave = false; /* Gotta do this up here so we can check the length when tinyMCE is in use */ - if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 || rich == false ) { - autosaveAjax.setVar("content", form.content.value); - } else { - // Don't run while the TinyMCE spellcheck is on. - if(tinyMCE.selectedInstance.spellcheckerOn) return; - tinyMCE.wpTriggerSave(); - autosaveAjax.setVar("content", form.content.value); - } + if ( rich ) { tinyMCE.triggerSave(); } - if(form.post_title.value.length==0 || form.content.value.length==0 || form.post_title.value+form.content.value == autosaveLast) - return; + post_data["content"] = jQuery("#content").val(); + if ( jQuery('#post_name').val() ) + post_data["post_name"] = jQuery('#post_name').val(); + + // Nothing to save or no change. + if( (post_data["post_title"].length==0 && post_data["content"].length==0) || post_data["post_title"] + post_data["content"] == autosaveLast) { + doAutoSave = false + } autosave_disable_buttons(); - autosaveLast = form.post_title.value+form.content.value; + var origStatus = jQuery('#original_post_status').val(); + if ( 'draft' != origStatus ) // autosave currently only turned on for drafts + doAutoSave = false; - cats = document.getElementsByName("post_category[]"); + autosaveLast = jQuery("#title").val()+jQuery("#content").val(); goodcats = ([]); - for(i=0;i '; + cp_contents += ''; if ( ((i+1)>=total) || (((i+1) % width) == 0)) { cp_contents += ""; } @@ -690,11 +690,11 @@ function ColorPicker() { if (document.getElementById) { var width1 = Math.floor(width/2); var width2 = width = width1; - cp_contents += ""; + cp_contents += ""; } cp_contents += "
    ' . $wp_locale->get_month($thismonth) . ' ' . date('Y', $unixmonth) . '' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '
     
     #FFFFFF
     #FFFFFF
    "; if (windowMode) { - cp_contents += ""; + cp_contents += ""; } // end populate code diff --git a/wp-includes/js/dbx.js b/wp-includes/js/dbx.js deleted file mode 100644 index 8e89c5af..00000000 --- a/wp-includes/js/dbx.js +++ /dev/null @@ -1,6 +0,0 @@ -// DBX2.05 :: Docking Boxes (dbx) -// ***************************************************** -// DOM scripting by brothercake -- http://www.brothercake.com/ -// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html -//****************************************************** -var dbx;function dbxManager(sid){dbx = this;if(!/^[-_a-z0-9]+$/i.test(sid)) { alert('Error from dbxManager:\n"' + sid + '" is an invalid session ID'); return; }this.supported = !(document.getElementsByTagName('*').length == 0 || (navigator.vendor == 'KDE' && typeof window.sidebar == 'undefined'));if(!this.supported) { return; }this.etype = typeof document.addEventListener != 'undefined' ? 'addEventListener' : typeof document.attachEvent != 'undefined' ? 'attachEvent' : 'none';this.eprefix = (this.etype == 'attachEvent' ? 'on' : '');if(typeof window.opera != 'undefined' && parseFloat(navigator.userAgent.toLowerCase().split(/opera[\/ ]/)[1].split(' ')[0], 10) < 7.5){this.etype = 'none';}if(this.etype == 'none') { this.supported = false; return; }this.running = 0;this.sid = sid;this.savedata = {};this.cookiestate = this.getCookieState();};dbxManager.prototype.setCookieState = function(){var now = new Date();now.setTime(now.getTime() + (365*24*60*60*1000));var str = '';for(j in this.savedata){if(typeof this.savedata[j]!='function'){str += j + '=' + this.savedata[j] + '&'}}this.state = str.replace(/^(.+)&$/, '$1');this.cookiestring = this.state.replace(/,/g, '|');this.cookiestring = this.cookiestring.replace(/=/g, ':');if(typeof this.onstatechange == 'undefined' || this.onstatechange()){document.cookie = 'dbx-' + this.sid + '='+ this.cookiestring+ '; expires=' + now.toGMTString()+ '; path=/';}};dbxManager.prototype.getCookieState = function(){this.cookiestate = null;if(document.cookie){if(document.cookie.indexOf('dbx-' + this.sid)!=-1){this.cookie = document.cookie.split('dbx-' + this.sid + '=')[1].split(';')[0].split('&');for(var i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookie[i] = this.cookie[i].replace(/\|/g, ',');this.cookie[i]= this.cookie[i].replace(/:/g, '=');this.cookie[i] = this.cookie[i].split('=');this.cookie[i][1] = this.cookie[i][1].split(',');}}this.cookiestate = {};for(i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookiestate[this.cookie[i][0]] = this.cookie[i][1];}}}}return this.cookiestate;};dbxManager.prototype.addDataMember = function(gid, order){this.savedata[gid] = order;};dbxManager.prototype.createElement = function(tag){return typeof document.createElementNS != 'undefined' ? document.createElementNS('http://www.w3.org/1999/xhtml', tag) : document.createElement(tag);};dbxManager.prototype.getTarget = function(e, pattern, node){if(typeof node != 'undefined'){var target = node;}else{target = typeof e.target != 'undefined' ? e.target : e.srcElement;}var regex = new RegExp(pattern, '');while(!regex.test(target.className)){target = target.parentNode;}return target;};function dbxGroup(gid, dir, thresh, fix, ani, togs, def, open, close, move, toggle, kmove, ktoggle, syntax){if(!/^[-_a-z0-9]+$/i.test(gid)) { alert('Error from dbxGroup:\n"' + gid + '" is an invalid container ID'); return; }this.container = document.getElementById(gid);if(this.container == null || !dbx.supported) { return; }var self = this;this.gid = gid;this.dragok = false;this.box = null;this.vertical = dir == 'vertical';this.threshold = parseInt(thresh, 10);this.restrict = fix == 'yes';this.resolution = parseInt(ani, 10);this.toggles = togs == 'yes';this.defopen = def != 'closed';this.vocab = {'open' : open,'close' : close,'move' : move,'toggle' : toggle,'kmove' : kmove,'ktoggle' : ktoggle,'syntax' : syntax};this.container.style.position = 'relative';this.container.style.display = 'block';if(typeof window.opera != 'undefined'){this.container.style.display = 'run-in';}this.boxes = [];this.buttons = [];this.order = [];this.eles = this.container.getElementsByTagName('*');for(var i=0; i 0)){var sibling = this.boxes[positions[i + (positive ? 1 : -1)][0]];if(this.resolution > 0){var visipos = { 'x' : parent.offsetLeft, 'y' : parent.offsetTop };var siblingpos = { 'x' : sibling.offsetLeft, 'y' : sibling.offsetTop };}var obj = { 'insert' : (positive ? sibling : parent), 'before' : (positive ? parent : sibling) };this.container.insertBefore(obj.insert, obj.before);if(this.resolution > 0){var animators ={'sibling' : new dbxAnimator(this, sibling, siblingpos, this.resolution, true, anchor),'parent' : new dbxAnimator(this, parent, visipos, this.resolution, true, anchor)};}else{anchor.focus();}break;}}}this.getBoxOrder();}};dbxGroup.prototype.compare = function(a, b){return a[1] - b[1];};dbxGroup.prototype.createTooltip = function(isopen, anchor){if(this.keydown){this.tooltip = this.container.appendChild(dbx.createElement('span'));this.tooltip.style.visibility = 'hidden';this.tooltip.className = 'dbx-tooltip';if(isopen != null){this.tooltip.appendChild(document.createTextNode(this.vocab.kmove + this.vocab.ktoggle.replace('%toggle%', isopen ? this.vocab.close : this.vocab.open)));}else{this.tooltip.appendChild(document.createTextNode(this.vocab.kmove));}var parent = dbx.getTarget(null, 'dbx\-box', anchor);this.tooltip.style.left = parent.offsetLeft + 'px';this.tooltip.style.top = parent.offsetTop + 'px';var tooltip = this.tooltip;window.setTimeout(function(){if(tooltip != null) { tooltip.style.visibility = 'visible'; }}, 500);}};dbxGroup.prototype.removeTooltip = function(){if(this.tooltip != null){this.tooltip.parentNode.removeChild(this.tooltip);this.tooltip = null;}};dbxGroup.prototype.mousedown = function(e, box){var node = typeof e.target != 'undefined' ? e.target : e.srcElement;if(node.nodeName == '#text') { node = node.parentNode; }if(!/dbx\-(toggle|box|group)/i.test(node.className)){while(!/dbx\-(handle|box|group)/i.test(node.className)){node = node.parentNode;}}if(/dbx\-handle/i.test(node.className)){this.removeTooltip();this.released = false;this.initial = { 'x' : e.clientX, 'y' : e.clientY };this.current = { 'x' : 0, 'y' : 0 };this.createCloneBox(box);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return false; }}}};dbxGroup.prototype.mousemove = function(e){if(this.dragok && this.box != null){this.positive = this.vertical ? (e.clientY > this.current.y ? true : false) : (e.clientX > this.current.x ? true : false);this.current = { 'x' : e.clientX, 'y' : e.clientY };var overall = { 'x' : this.current.x - this.initial.x, 'y' : this.current.y - this.initial.y };if(((overall.x >= 0 && overall.x <= this.threshold) || (overall.x <= 0 && overall.x >= 0 - this.threshold))&&((overall.y >= 0 && overall.y <= this.threshold) || (overall.y <= 0 && overall.y >= 0 - this.threshold))){this.current.x -= overall.x;this.current.y -= overall.y;}if(this.released || overall.x > this.threshold || overall.x < (0 - this.threshold) || overall.y > this.threshold || overall.y < (0 - this.threshold)){dbx.group = this.container;dbx.box = this.box;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){this.released = true;if(!this.restrict || !this.vertical) { this.boxclone.style.left = (this.current.x - this.difference.x) + 'px'; }if(!this.restrict || this.vertical) { this.boxclone.style.top = (this.current.y - this.difference.y) + 'px'; }this.moveOriginalToPosition(this.current.x, this.current.y);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }}}}return true;};dbxGroup.prototype.mouseup = function(e){if(this.box != null){this.moveOriginalToPosition(e.clientX, e.clientY);this.removeCloneBox();this.getBoxOrder();if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return true; }}}this.dragok = false;};dbxGroup.prototype.keypress = function(e, anchor){if(/^(3[7-9])|(40)$/.test(e.keyCode)){this.removeTooltip();if((this.vertical && /^(38|40)$/.test(e.keyCode)) || (!this.vertical && /^(37|39)$/.test(e.keyCode))){this.shiftBoxPosition(e, anchor, /^[3][78]$/.test(e.keyCode) ? false : true);if(typeof e.preventDefault != 'undefined') { e.preventDefault(); }else { return false; }typeof e.stopPropagation != 'undefined' ? e.stopPropagation() : e.cancelBubble = true;this.keydown = false;}}return true;};dbxGroup.prototype.getBoxOrder = function(){this.order = [];var len = this.eles.length;for(var j=0; j boxprops.xy && cloneprops.xy < boxprops.xy)||(!this.positive && cloneprops.xy < boxprops.xy && cloneprops.xy + cloneprops.wh > boxprops.xy)){if(this.boxes[i] == this.box) { return; }var sibling = this.box.nextSibling;while(sibling.className == null || !/dbx\-box/.test(sibling.className)){sibling = sibling.nextSibling;}if(this.boxes[i] == sibling) { return; }if(this.resolution > 0){if(this.box[this.vertical ? 'offsetTop' : 'offsetLeft'] < boxprops.xy){var visibox = this.boxes[i].previousSibling;while(visibox.className == null || !/dbx\-box/.test(visibox.className)){visibox = visibox.previousSibling;}}else{visibox = this.boxes[i];}var visipos = { 'x' : visibox.offsetLeft, 'y' : visibox.offsetTop };}var prepos = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.container.insertBefore(this.box, this.boxes[i]);this.initial.x += (this.box.offsetLeft - prepos.x);this.initial.y += (this.box.offsetTop - prepos.y);if(this.resolution > 0 && visibox != this.box){var animator = new dbxAnimator(this, visibox, visipos, this.resolution, false, null);}else{}break;}}};function dbxAnimator(caller, box, pos, res, kbd, anchor){this.caller = caller;this.box = box;this.timer = null;var before = pos[this.caller.vertical ? 'y' : 'x'];var after = this.box[this.caller.vertical ? 'offsetTop' : 'offsetLeft'];if(before != after){if(dbx.running > this.caller.boxes.length - 1) { return; }var clone = this.caller.createClone(this.box, 29999, arguments[2]);clone.style.visibility = 'visible';this.box.style.visibility = 'hidden';this.animateClone(clone,before,after > before ? after - before : 0 - (before - after),this.caller.vertical ? 'top' : 'left',res,kbd,anchor);}};dbxAnimator.prototype.animateClone = function(clone, current, change, dir, res, kbd, anchor){var self = this;var count = 0;dbx.running ++;this.timer = window.setInterval(function(){count ++;current += change / res;clone.style[dir] = current + 'px';if(count == res){window.clearTimeout(self.timer);self.timer = null;dbx.running --;self.caller.container.removeChild(clone);self.box.style.visibility = 'visible';if(kbd){if(anchor != null && anchor.parentNode.style.visibility != 'hidden'){anchor.focus();}else if(self.caller.toggles){var button = self.caller.buttons[parseInt(self.box.className.split('dbxid')[1],10)];if(button != null && typeof button.isactive != 'undefined'){button.focus();}}}}}, 20);};if(typeof window.attachEvent != 'undefined'){window.attachEvent('onunload', function(){var ev = ['mousedown', 'mousemove', 'mouseup', 'mouseout', 'click', 'keydown', 'keyup', 'focus', 'blur', 'selectstart', 'statechange', 'boxdrag', 'boxopen', 'boxclose'];var el = ev.length;var dl = document.all.length;for(var i=0; i35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('k.f2={2r:u(M){E q.1E(u(){if(!M.aR||!M.aZ)E;D el=q;el.2l={aq:M.aq||cO,aR:M.aR,aZ:M.aZ,8e:M.8e||\'fV\',aJ:M.aJ||\'fV\',2Y:M.2Y&&2g M.2Y==\'u\'?M.2Y:I,3i:M.2Y&&2g M.3i==\'u\'?M.3i:I,7U:M.7U&&2g M.7U==\'u\'?M.7U:I,as:k(M.aR,q),8f:k(M.aZ,q),H:M.H||8J,67:M.67||0};el.2l.8f.2G().B(\'W\',\'9R\').eq(0).B({W:el.2l.aq+\'U\',19:\'2B\'}).2T();el.2l.as.1E(u(2N){q.7X=2N}).gC(u(){k(q).2R(el.2l.aJ)},u(){k(q).4i(el.2l.aJ)}).1J(\'5h\',u(e){if(el.2l.67==q.7X)E;el.2l.as.eq(el.2l.67).4i(el.2l.8e).2T().eq(q.7X).2R(el.2l.8e).2T();el.2l.8f.eq(el.2l.67).5w({W:0},el.2l.H,u(){q.14.19=\'1o\';if(el.2l.3i){el.2l.3i.1D(el,[q])}}).2T().eq(q.7X).1Y().5w({W:el.2l.aq},el.2l.H,u(){q.14.19=\'2B\';if(el.2l.2Y){el.2l.2Y.1D(el,[q])}}).2T();if(el.2l.7U){el.2l.7U.1D(el,[q,el.2l.8f.K(q.7X),el.2l.as.K(el.2l.67),el.2l.8f.K(el.2l.67)])}el.2l.67=q.7X}).eq(0).2R(el.2l.8e).2T();k(q).B(\'W\',k(q).B(\'W\')).B(\'2U\',\'2K\')})}};k.fn.gN=k.f2.2r;k.aA={2r:u(M){E q.1E(u(){D el=q;D 7E=2*18.2Q/f1;D an=2*18.2Q;if(k(el).B(\'Y\')!=\'2s\'&&k(el).B(\'Y\')!=\'1P\'){k(el).B(\'Y\',\'2s\')}el.1l={1R:k(M.1R,q),2F:M.2F,6q:M.6q,aD:M.aD,an:an,1N:k.1a.2o(q),Y:k.1a.3w(q),26:18.2Q/2,bi:M.bi,8p:M.6r,6r:[],aG:I,7E:2*18.2Q/f1};el.1l.fB=(el.1l.1N.w-el.1l.2F)/2;el.1l.7D=(el.1l.1N.h-el.1l.6q-el.1l.6q*el.1l.8p)/2;el.1l.2D=2*18.2Q/el.1l.1R.1N();el.1l.ba=el.1l.1N.w/2;el.1l.b9=el.1l.1N.h/2-el.1l.6q*el.1l.8p;D ak=1h.3F(\'22\');k(ak).B({Y:\'1P\',3I:1,Q:0,O:0});k(el).1S(ak);el.1l.1R.1E(u(2N){a6=k(\'1T\',q).K(0);W=T(el.1l.6q*el.1l.8p);if(k.3a.4t){3E=1h.3F(\'1T\');k(3E).B(\'Y\',\'1P\');3E.2J=a6.2J;3E.14.5E=\'gE 9n:9w.9y.cC(1G=60, 14=1, gB=0, gA=0, gv=0, gF=0)\'}P{3E=1h.3F(\'3E\');if(3E.fD){4L=3E.fD("2d");3E.14.Y=\'1P\';3E.14.W=W+\'U\';3E.14.Z=el.1l.2F+\'U\';3E.W=W;3E.Z=el.1l.2F;4L.gu();4L.gO(0,W);4L.gk(1,-1);4L.gp(a6,0,0,el.1l.2F,W);4L.6H();4L.gm="gG-4l";D ap=4L.hy(0,0,0,W);ap.fs(1,"fr(1V, 1V, 1V, 1)");ap.fs(0,"fr(1V, 1V, 1V, 0.6)");4L.hx=ap;if(hA.hB.3J(\'hw\')!=-1){4L.hv()}P{4L.hu(0,0,el.1l.2F,W)}}}el.1l.6r[2N]=3E;k(ak).1S(3E)}).1J(\'9z\',u(e){el.1l.aG=1b;el.1l.H=el.1l.7E*0.1*el.1l.H/18.3S(el.1l.H);E I}).1J(\'8B\',u(e){el.1l.aG=I;E I});k.aA.7T(el);el.1l.H=el.1l.7E*0.2;el.1l.ht=1X.6V(u(){el.1l.26+=el.1l.H;if(el.1l.26>an)el.1l.26=0;k.aA.7T(el)},20);k(el).1J(\'8B\',u(){el.1l.H=el.1l.7E*0.2*el.1l.H/18.3S(el.1l.H)}).1J(\'3D\',u(e){if(el.1l.aG==I){1s=k.1a.4a(e);fz=el.1l.1N.w-1s.x+el.1l.Y.x;el.1l.H=el.1l.bi*el.1l.7E*(el.1l.1N.w/2-fz)/(el.1l.1N.w/2)}})})},7T:u(el){el.1l.1R.1E(u(2N){b8=el.1l.26+2N*el.1l.2D;x=el.1l.fB*18.5H(b8);y=el.1l.7D*18.83(b8);f9=T(2a*(el.1l.7D+y)/(2*el.1l.7D));fk=(el.1l.7D+y)/(2*el.1l.7D);Z=T((el.1l.2F-el.1l.aD)*fk+el.1l.aD);W=T(Z*el.1l.6q/el.1l.2F);q.14.Q=el.1l.b9+y-W/2+"U";q.14.O=el.1l.ba+x-Z/2+"U";q.14.Z=Z+"U";q.14.W=W+"U";q.14.3I=f9;el.1l.6r[2N].14.Q=T(el.1l.b9+y+W-1-W/2)+"U";el.1l.6r[2N].14.O=T(el.1l.ba+x-Z/2)+"U";el.1l.6r[2N].14.Z=Z+"U";el.1l.6r[2N].14.W=T(W*el.1l.8p)+"U"})}};k.fn.hI=k.aA.2r;k.23({G:{c8:u(p,n,1W,1H,1m){E((-18.5H(p*18.2Q)/2)+0.5)*1H+1W},hK:u(p,n,1W,1H,1m){E 1H*(n/=1m)*n*n+1W},fl:u(p,n,1W,1H,1m){E-1H*((n=n/1m-1)*n*n*n-1)+1W},hm:u(p,n,1W,1H,1m){if((n/=1m/2)<1)E 1H/2*n*n*n*n+1W;E-1H/2*((n-=2)*n*n*n-2)+1W},8l:u(p,n,1W,1H,1m){if((n/=1m)<(1/2.75)){E 1H*(7.aB*n*n)+1W}P if(n<(2/2.75)){E 1H*(7.aB*(n-=(1.5/2.75))*n+.75)+1W}P if(n<(2.5/2.75)){E 1H*(7.aB*(n-=(2.25/2.75))*n+.gY)+1W}P{E 1H*(7.aB*(n-=(2.h2/2.75))*n+.gX)+1W}},cr:u(p,n,1W,1H,1m){if(k.G.8l)E 1H-k.G.8l(p,1m-n,0,1H,1m)+1W;E 1W+1H},gW:u(p,n,1W,1H,1m){if(k.G.cr&&k.G.8l)if(n<1m/2)E k.G.cr(p,n*2,0,1H,1m)*.5+1W;E k.G.8l(p,n*2-1m,0,1H,1m)*.5+1H*.5+1W;E 1W+1H},gQ:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m)==1)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}E-(a*18.6b(2,10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p))+1W},gT:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m/2)==2)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}E a*18.6b(2,-10*n)*18.83((n*1m-s)*(2*18.2Q)/p)+1H+1W},gV:u(p,n,1W,1H,1m){D a,s;if(n==0)E 1W;if((n/=1m/2)==2)E 1W+1H;a=1H*0.3;p=1m*.3;if(a<18.3S(1H)){a=1H;s=p/4}P{s=p/(2*18.2Q)*18.cb(1H/a)}if(n<1){E-.5*(a*18.6b(2,10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p))+1W}E a*18.6b(2,-10*(n-=1))*18.83((n*1m-s)*(2*18.2Q)/p)*.5+1H+1W}}});k.6n={2r:u(M){E q.1E(u(){D el=q;el.1F={1R:k(M.1R,q),1Z:k(M.1Z,q),1M:k.1a.3w(q),2F:M.2F,ax:M.ax,7Y:M.7Y,ge:M.ge,51:M.51,6x:M.6x};k.6n.aH(el,0);k(1X).1J(\'gU\',u(){el.1F.1M=k.1a.3w(el);k.6n.aH(el,0);k.6n.7T(el)});k.6n.7T(el);el.1F.1R.1J(\'9z\',u(){k(el.1F.ax,q).K(0).14.19=\'2B\'}).1J(\'8B\',u(){k(el.1F.ax,q).K(0).14.19=\'1o\'});k(1h).1J(\'3D\',u(e){D 1s=k.1a.4a(e);D 5s=0;if(el.1F.51&&el.1F.51==\'cv\')D aI=1s.x-el.1F.1M.x-(el.4c-el.1F.2F*el.1F.1R.1N())/2-el.1F.2F/2;P if(el.1F.51&&el.1F.51==\'2L\')D aI=1s.x-el.1F.1M.x-el.4c+el.1F.2F*el.1F.1R.1N();P D aI=1s.x-el.1F.1M.x;D fP=18.6b(1s.y-el.1F.1M.y-el.5W/2,2);el.1F.1R.1E(u(2N){45=18.ez(18.6b(aI-2N*el.1F.2F,2)+fP);45-=el.1F.2F/2;45=45<0?0:45;45=45>el.1F.7Y?el.1F.7Y:45;45=el.1F.7Y-45;bB=el.1F.6x*45/el.1F.7Y;q.14.Z=el.1F.2F+bB+\'U\';q.14.O=el.1F.2F*2N+5s+\'U\';5s+=bB});k.6n.aH(el,5s)})})},aH:u(el,5s){if(el.1F.51)if(el.1F.51==\'cv\')el.1F.1Z.K(0).14.O=(el.4c-el.1F.2F*el.1F.1R.1N())/2-5s/2+\'U\';P if(el.1F.51==\'O\')el.1F.1Z.K(0).14.O=-5s/el.1F.1R.1N()+\'U\';P if(el.1F.51==\'2L\')el.1F.1Z.K(0).14.O=(el.4c-el.1F.2F*el.1F.1R.1N())-5s/2+\'U\';el.1F.1Z.K(0).14.Z=el.1F.2F*el.1F.1R.1N()+5s+\'U\'},7T:u(el){el.1F.1R.1E(u(2N){q.14.Z=el.1F.2F+\'U\';q.14.O=el.1F.2F*2N+\'U\'})}};k.fn.hi=k.6n.2r;k.N={1c:S,8R:S,3A:S,2I:S,4y:S,cl:S,1d:S,2h:S,1R:S,5o:u(){k.N.8R.5o();if(k.N.3A){k.N.3A.2G()}},4w:u(){k.N.1R=S;k.N.2h=S;k.N.4y=k.N.1d.2y;if(k.N.1c.B(\'19\')==\'2B\'){if(k.N.1d.1f.fx){3m(k.N.1d.1f.fx.1u){1e\'c6\':k.N.1c.7a(k.N.1d.1f.fx.1m,k.N.5o);1r;1e\'1z\':k.N.1c.fq(k.N.1d.1f.fx.1m,k.N.5o);1r;1e\'a7\':k.N.1c.g3(k.N.1d.1f.fx.1m,k.N.5o);1r}}P{k.N.1c.2G()}if(k.N.1d.1f.3i)k.N.1d.1f.3i.1D(k.N.1d,[k.N.1c,k.N.3A])}P{k.N.5o()}1X.bH(k.N.2I)},dQ:u(){D 1d=k.N.1d;D 4d=k.N.aY(1d);if(1d&&4d.3o!=k.N.4y&&4d.3o.1g>=1d.1f.aL){k.N.4y=4d.3o;k.N.cl=4d.3o;81={2n:k(1d).1p(\'hj\')||\'2n\',2y:4d.3o};k.hl({1u:\'hk\',81:k.hf(81),he:u(fZ){1d.1f.4e=k(\'3o\',fZ);1N=1d.1f.4e.1N();if(1N>0){D 5p=\'\';1d.1f.4e.1E(u(2N){5p+=\'<8P 4I="\'+k(\'2y\',q).3g()+\'" 8K="\'+2N+\'" 14="9b: ad;">\'+k(\'3g\',q).3g()+\'\'});if(1d.1f.aU){D 3M=k(\'2y\',1d.1f.4e.K(0)).3g();1d.2y=4d.3j+3M+1d.1f.3N+4d.66;k.N.6J(1d,4d.3o.1g!=3M.1g?(4d.3j.1g+4d.3o.1g):3M.1g,4d.3o.1g!=3M.1g?(4d.3j.1g+3M.1g):3M.1g)}if(1N>0){k.N.cj(1d,5p)}P{k.N.4w()}}P{k.N.4w()}},5N:1d.1f.aN})}},cj:u(1d,5p){k.N.8R.3x(5p);k.N.1R=k(\'8P\',k.N.8R.K(0));k.N.1R.9z(k.N.di).1J(\'5h\',k.N.dj);D Y=k.1a.3w(1d);D 1N=k.1a.2o(1d);k.N.1c.B(\'Q\',Y.y+1N.hb+\'U\').B(\'O\',Y.x+\'U\').2R(1d.1f.aM);if(k.N.3A){k.N.3A.B(\'19\',\'2B\').B(\'Q\',Y.y+1N.hb+\'U\').B(\'O\',Y.x+\'U\').B(\'Z\',k.N.1c.B(\'Z\')).B(\'W\',k.N.1c.B(\'W\'))}k.N.2h=0;k.N.1R.K(0).3l=1d.1f.7H;k.N.8Q(1d,1d.1f.4e.K(0),\'7J\');if(k.N.1c.B(\'19\')==\'1o\'){if(1d.1f.bV){D cp=k.1a.aT(1d,1b);D cm=k.1a.6U(1d,1b);k.N.1c.B(\'Z\',1d.4c-(k.dF?(cp.l+cp.r+cm.l+cm.r):0)+\'U\')}if(1d.1f.fx){3m(1d.1f.fx.1u){1e\'c6\':k.N.1c.7f(1d.1f.fx.1m);1r;1e\'1z\':k.N.1c.fo(1d.1f.fx.1m);1r;1e\'a7\':k.N.1c.gb(1d.1f.fx.1m);1r}}P{k.N.1c.1Y()}if(k.N.1d.1f.2Y)k.N.1d.1f.2Y.1D(k.N.1d,[k.N.1c,k.N.3A])}},dO:u(){D 1d=q;if(1d.1f.4e){k.N.4y=1d.2y;k.N.cl=1d.2y;D 5p=\'\';1d.1f.4e.1E(u(2N){2y=k(\'2y\',q).3g().6c();fY=1d.2y.6c();if(2y.3J(fY)==0){5p+=\'<8P 4I="\'+k(\'2y\',q).3g()+\'" 8K="\'+2N+\'" 14="9b: ad;">\'+k(\'3g\',q).3g()+\'\'}});if(5p!=\'\'){k.N.cj(1d,5p);q.1f.9x=1b;E}}1d.1f.4e=S;q.1f.9x=I},6J:u(2n,26,2T){if(2n.b1){D 6t=2n.b1();6t.hp(1b);6t.dI("ck",26);6t.ha("ck",-2T+26);6t.8C()}P if(2n.aF){2n.aF(26,2T)}P{if(2n.5q){2n.5q=26;2n.dN=2T}}2n.6K()},f0:u(2n){if(2n.5q)E 2n.5q;P if(2n.b1){D 6t=1h.6J.dZ();D eX=6t.h9();E 0-eX.dI(\'ck\',-h6)}},aY:u(2n){D 4P={2y:2n.2y,3j:\'\',66:\'\',3o:\'\'};if(2n.1f.aQ){D 8N=I;D 5q=k.N.f0(2n)||0;D 4T=4P.2y.7C(2n.1f.3N);24(D i=0;i<4T.1g;i++){if((4P.3j.1g+4T[i].1g>=5q||5q==0)&&!8N){if(4P.3j.1g<=5q)4P.3o=4T[i];P 4P.66+=4T[i]+(4T[i]!=\'\'?2n.1f.3N:\'\');8N=1b}P if(8N){4P.66+=4T[i]+(4T[i]!=\'\'?2n.1f.3N:\'\')}if(!8N){4P.3j+=4T[i]+(4T.1g>1?2n.1f.3N:\'\')}}}P{4P.3o=4P.2y}E 4P},bU:u(e){1X.bH(k.N.2I);D 1d=k.N.aY(q);D 3K=e.7L||e.7K||-1;if(/13|27|35|36|38|40|9/.48(3K)&&k.N.1R){if(1X.2k){1X.2k.bT=1b;1X.2k.c0=I}P{e.aP();e.aW()}if(k.N.2h!=S)k.N.1R.K(k.N.2h||0).3l=\'\';P k.N.2h=-1;3m(3K){1e 9:1e 13:if(k.N.2h==-1)k.N.2h=0;D 2h=k.N.1R.K(k.N.2h||0);D 3M=2h.5C(\'4I\');q.2y=1d.3j+3M+q.1f.3N+1d.66;k.N.4y=1d.3o;k.N.6J(q,1d.3j.1g+3M.1g+q.1f.3N.1g,1d.3j.1g+3M.1g+q.1f.3N.1g);k.N.4w();if(q.1f.68){4u=T(2h.5C(\'8K\'))||0;k.N.8Q(q,q.1f.4e.K(4u),\'68\')}if(q.7W)q.7W(I);E 3K!=13;1r;1e 27:q.2y=1d.3j+k.N.4y+q.1f.3N+1d.66;q.1f.4e=S;k.N.4w();if(q.7W)q.7W(I);E I;1r;1e 35:k.N.2h=k.N.1R.1N()-1;1r;1e 36:k.N.2h=0;1r;1e 38:k.N.2h--;if(k.N.2h<0)k.N.2h=k.N.1R.1N()-1;1r;1e 40:k.N.2h++;if(k.N.2h==k.N.1R.1N())k.N.2h=0;1r}k.N.8Q(q,q.1f.4e.K(k.N.2h||0),\'7J\');k.N.1R.K(k.N.2h||0).3l=q.1f.7H;if(k.N.1R.K(k.N.2h||0).7W)k.N.1R.K(k.N.2h||0).7W(I);if(q.1f.aU){D aK=k.N.1R.K(k.N.2h||0).5C(\'4I\');q.2y=1d.3j+aK+q.1f.3N+1d.66;if(k.N.4y.1g!=aK.1g)k.N.6J(q,1d.3j.1g+k.N.4y.1g,1d.3j.1g+aK.1g)}E I}k.N.dO.1D(q);if(q.1f.9x==I){if(1d.3o!=k.N.4y&&1d.3o.1g>=q.1f.aL)k.N.2I=1X.9T(k.N.dQ,q.1f.54);if(k.N.1R){k.N.4w()}}E 1b},8Q:u(2n,3o,1u){if(2n.1f[1u]){D 81={};ar=3o.f3(\'*\');24(i=0;i\');k.N.3A=k(\'#ds\')}k(\'2e\',1h).1S(\'<22 id="dr" 14="Y: 1P; Q: 0; O: 0; z-cZ: h3; 19: 1o;"><9h 14="6w: 0;8F: 0; h1-14: 1o; z-cZ: h0;">&7k;\');k.N.1c=k(\'#dr\');k.N.8R=k(\'9h\',k.N.1c)}E q.1E(u(){if(q.4Y!=\'ch\'&&q.5C(\'1u\')!=\'3g\')E;q.1f={};q.1f.aN=M.aN;q.1f.aL=18.3S(T(M.aL)||1);q.1f.aM=M.aM?M.aM:\'\';q.1f.7H=M.7H?M.7H:\'\';q.1f.68=M.68&&M.68.1K==2A?M.68:S;q.1f.2Y=M.2Y&&M.2Y.1K==2A?M.2Y:S;q.1f.3i=M.3i&&M.3i.1K==2A?M.3i:S;q.1f.7J=M.7J&&M.7J.1K==2A?M.7J:S;q.1f.bV=M.bV||I;q.1f.aQ=M.aQ||I;q.1f.3N=q.1f.aQ?(M.3N||\', \'):\'\';q.1f.aU=M.aU?1b:I;q.1f.54=18.3S(T(M.54)||aC);if(M.fx&&M.fx.1K==7M){if(!M.fx.1u||!/c6|1z|a7/.48(M.fx.1u)){M.fx.1u=\'1z\'}if(M.fx.1u==\'1z\'&&!k.fx.1z)E;if(M.fx.1u==\'a7\'&&!k.fx.61)E;M.fx.1m=18.3S(T(M.fx.1m)||8J);if(M.fx.1m>q.1f.54){M.fx.1m=q.1f.54-2a}q.1f.fx=M.fx}q.1f.4e=S;q.1f.9x=I;k(q).1p(\'bU\',\'eN\').6K(u(){k.N.1d=q;k.N.4y=q.2y}).dH(k.N.eJ).6y(k.N.bU).5B(u(){k.N.2I=1X.9T(k.N.4w,hM)})})}};k.fn.hR=k.N.2r;k.1y={2I:S,4Q:S,29:S,2D:10,26:u(el,4J,2D,eG){k.1y.4Q=el;k.1y.29=4J;k.1y.2D=T(2D)||10;k.1y.2I=1X.6V(k.1y.eF,T(eG)||40)},eF:u(){24(i=0;i0&&k.1y.29[i].2X.y+k.1y.29[i].2X.t>69.y){k.1y.29[i].3d-=k.1y.2D}P if(k.1y.29[i].2X.t<=k.1y.29[i].2X.h&&k.1y.29[i].2X.t+k.1y.29[i].2X.hb<69.y+69.hb){k.1y.29[i].3d+=k.1y.2D}if(k.1y.29[i].2X.l>0&&k.1y.29[i].2X.x+k.1y.29[i].2X.l>69.x){k.1y.29[i].3c-=k.1y.2D}P if(k.1y.29[i].2X.l<=k.1y.29[i].2X.hP&&k.1y.29[i].2X.l+k.1y.29[i].2X.1C<69.x+69.1C){k.1y.29[i].3c+=k.1y.2D}}},8o:u(){1X.5T(k.1y.2I);k.1y.4Q=S;k.1y.29=S;24(i in k.1y.29){k.1y.29[i].2X=S}}};k.11={1c:S,F:S,4U:u(){E q.1E(u(){if(q.9I){q.A.5e.3q(\'5v\',k.11.bN);q.A=S;q.9I=I;if(k.3a.4t){q.bE="eN"}P{q.14.hq=\'\';q.14.e1=\'\';q.14.e7=\'\'}}})},bN:u(e){if(k.11.F!=S){k.11.9A(e);E I}D C=q.3U;k(1h).1J(\'3D\',k.11.bX).1J(\'5P\',k.11.9A);C.A.1s=k.1a.4a(e);C.A.4B=C.A.1s;C.A.7q=I;C.A.ho=q!=q.3U;k.11.F=C;if(C.A.5i&&q!=q.3U){bS=k.1a.3w(C.31);bQ=k.1a.2o(C);bR={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};dx=C.A.4B.x-bS.x-bQ.1C/2-bR.x;dy=C.A.4B.y-bS.y-bQ.hb/2-bR.y;k.3b.5c(C,[dx,dy])}E k.7n||I},ea:u(e){D C=k.11.F;C.A.7q=1b;D 9G=C.14;C.A.7V=k.B(C,\'19\');C.A.4n=k.B(C,\'Y\');if(!C.A.cz)C.A.cz=C.A.4n;C.A.2c={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};C.A.9B=0;C.A.ai=0;if(k.3a.4t){D bW=k.1a.6U(C,1b);C.A.9B=bW.l||0;C.A.ai=bW.t||0}C.A.1B=k.23(k.1a.3w(C),k.1a.2o(C));if(C.A.4n!=\'2s\'&&C.A.4n!=\'1P\'){9G.Y=\'2s\'}k.11.1c.5o();D 5g=C.fI(1b);k(5g).B({19:\'2B\',O:\'2P\',Q:\'2P\'});5g.14.5K=\'0\';5g.14.5z=\'0\';5g.14.5k=\'0\';5g.14.5j=\'0\';k.11.1c.1S(5g);D 3Y=k.11.1c.K(0).14;if(C.A.bD){3Y.Z=\'9F\';3Y.W=\'9F\'}P{3Y.W=C.A.1B.hb+\'U\';3Y.Z=C.A.1B.1C+\'U\'}3Y.19=\'2B\';3Y.5K=\'2P\';3Y.5z=\'2P\';3Y.5k=\'2P\';3Y.5j=\'2P\';k.23(C.A.1B,k.1a.2o(5g));if(C.A.2V){if(C.A.2V.O){C.A.2c.x+=C.A.1s.x-C.A.1B.x-C.A.2V.O;C.A.1B.x=C.A.1s.x-C.A.2V.O}if(C.A.2V.Q){C.A.2c.y+=C.A.1s.y-C.A.1B.y-C.A.2V.Q;C.A.1B.y=C.A.1s.y-C.A.2V.Q}if(C.A.2V.2L){C.A.2c.x+=C.A.1s.x-C.A.1B.x-C.A.1B.hb+C.A.2V.2L;C.A.1B.x=C.A.1s.x-C.A.1B.1C+C.A.2V.2L}if(C.A.2V.4D){C.A.2c.y+=C.A.1s.y-C.A.1B.y-C.A.1B.hb+C.A.2V.4D;C.A.1B.y=C.A.1s.y-C.A.1B.hb+C.A.2V.4D}}C.A.2v=C.A.2c.x;C.A.2q=C.A.2c.y;if(C.A.8s||C.A.2p==\'94\'){8U=k.1a.6U(C.31,1b);C.A.1B.x=C.8t+(k.3a.4t?0:k.3a.7I?-8U.l:8U.l);C.A.1B.y=C.8G+(k.3a.4t?0:k.3a.7I?-8U.t:8U.t);k(C.31).1S(k.11.1c.K(0))}if(C.A.2p){k.11.c5(C);C.A.5t.2p=k.11.ce}if(C.A.5i){k.3b.ct(C)}3Y.O=C.A.1B.x-C.A.9B+\'U\';3Y.Q=C.A.1B.y-C.A.ai+\'U\';3Y.Z=C.A.1B.1C+\'U\';3Y.W=C.A.1B.hb+\'U\';k.11.F.A.9E=I;if(C.A.gx){C.A.5t.6a=k.11.c7}if(C.A.3I!=I){k.11.1c.B(\'3I\',C.A.3I)}if(C.A.1G){k.11.1c.B(\'1G\',C.A.1G);if(1X.71){k.11.1c.B(\'5E\',\'8V(1G=\'+C.A.1G*2a+\')\')}}if(C.A.7O){k.11.1c.2R(C.A.7O);k.11.1c.K(0).7c.14.19=\'1o\'}if(C.A.4o)C.A.4o.1D(C,[5g,C.A.2c.x,C.A.2c.y]);if(k.1x&&k.1x.8D>0){k.1x.ed(C)}if(C.A.46==I){9G.19=\'1o\'}E I},c5:u(C){if(C.A.2p.1K==b0){if(C.A.2p==\'94\'){C.A.28=k.23({x:0,y:0},k.1a.2o(C.31));D 8S=k.1a.6U(C.31,1b);C.A.28.w=C.A.28.1C-8S.l-8S.r;C.A.28.h=C.A.28.hb-8S.t-8S.b}P if(C.A.2p==\'1h\'){D bY=k.1a.bm();C.A.28={x:0,y:0,w:bY.w,h:bY.h}}}P if(C.A.2p.1K==7F){C.A.28={x:T(C.A.2p[0])||0,y:T(C.A.2p[1])||0,w:T(C.A.2p[2])||0,h:T(C.A.2p[3])||0}}C.A.28.dx=C.A.28.x-C.A.1B.x;C.A.28.dy=C.A.28.y-C.A.1B.y},9H:u(F){if(F.A.8s||F.A.2p==\'94\'){k(\'2e\',1h).1S(k.11.1c.K(0))}k.11.1c.5o().2G().B(\'1G\',1);if(1X.71){k.11.1c.B(\'5E\',\'8V(1G=2a)\')}},9A:u(e){k(1h).3q(\'3D\',k.11.bX).3q(\'5P\',k.11.9A);if(k.11.F==S){E}D F=k.11.F;k.11.F=S;if(F.A.7q==I){E I}if(F.A.44==1b){k(F).B(\'Y\',F.A.4n)}D 9G=F.14;if(F.5i){k.11.1c.B(\'9b\',\'8j\')}if(F.A.7O){k.11.1c.4i(F.A.7O)}if(F.A.6N==I){if(F.A.fx>0){if(!F.A.1O||F.A.1O==\'4j\'){D x=12 k.fx(F,{1m:F.A.fx},\'O\');x.1L(F.A.2c.x,F.A.8y)}if(!F.A.1O||F.A.1O==\'49\'){D y=12 k.fx(F,{1m:F.A.fx},\'Q\');y.1L(F.A.2c.y,F.A.8v)}}P{if(!F.A.1O||F.A.1O==\'4j\')F.14.O=F.A.8y+\'U\';if(!F.A.1O||F.A.1O==\'49\')F.14.Q=F.A.8v+\'U\'}k.11.9H(F);if(F.A.46==I){k(F).B(\'19\',F.A.7V)}}P if(F.A.fx>0){F.A.9E=1b;D dh=I;if(k.1x&&k.1t&&F.A.44){dh=k.1a.3w(k.1t.1c.K(0))}k.11.1c.5w({O:dh?dh.x:F.A.1B.x,Q:dh?dh.y:F.A.1B.y},F.A.fx,u(){F.A.9E=I;if(F.A.46==I){F.14.19=F.A.7V}k.11.9H(F)})}P{k.11.9H(F);if(F.A.46==I){k(F).B(\'19\',F.A.7V)}}if(k.1x&&k.1x.8D>0){k.1x.eO(F)}if(k.1t&&F.A.44){k.1t.fC(F)}if(F.A.2Z&&(F.A.8y!=F.A.2c.x||F.A.8v!=F.A.2c.y)){F.A.2Z.1D(F,F.A.b3||[0,0,F.A.8y,F.A.8v])}if(F.A.3T)F.A.3T.1D(F);E I},c7:u(x,y,dx,dy){if(dx!=0)dx=T((dx+(q.A.gx*dx/18.3S(dx))/2)/q.A.gx)*q.A.gx;if(dy!=0)dy=T((dy+(q.A.gy*dy/18.3S(dy))/2)/q.A.gy)*q.A.gy;E{dx:dx,dy:dy,x:0,y:0}},ce:u(x,y,dx,dy){dx=18.3L(18.3r(dx,q.A.28.dx),q.A.28.w+q.A.28.dx-q.A.1B.1C);dy=18.3L(18.3r(dy,q.A.28.dy),q.A.28.h+q.A.28.dy-q.A.1B.hb);E{dx:dx,dy:dy,x:0,y:0}},bX:u(e){if(k.11.F==S||k.11.F.A.9E==1b){E}D F=k.11.F;F.A.4B=k.1a.4a(e);if(F.A.7q==I){45=18.ez(18.6b(F.A.1s.x-F.A.4B.x,2)+18.6b(F.A.1s.y-F.A.4B.y,2));if(450){k.1x.al(F)}E I},2r:u(o){if(!k.11.1c){k(\'2e\',1h).1S(\'<22 id="e8">\');k.11.1c=k(\'#e8\');D el=k.11.1c.K(0);D 4J=el.14;4J.Y=\'1P\';4J.19=\'1o\';4J.9b=\'8j\';4J.eu=\'1o\';4J.2U=\'2K\';if(1X.71){el.bE="e4"}P{4J.gi=\'1o\';4J.e7=\'1o\';4J.e1=\'1o\'}}if(!o){o={}}E q.1E(u(){if(q.9I||!k.1a)E;if(1X.71){q.gh=u(){E I};q.gj=u(){E I}}D el=q;D 5e=o.3v?k(q).gf(o.3v):k(q);if(k.3a.4t){5e.1E(u(){q.bE="e4"})}P{5e.B(\'-gI-7R-8C\',\'1o\');5e.B(\'7R-8C\',\'1o\');5e.B(\'-gH-7R-8C\',\'1o\')}q.A={5e:5e,6N:o.6N?1b:I,46:o.46?1b:I,44:o.44?o.44:I,5i:o.5i?o.5i:I,8s:o.8s?o.8s:I,3I:o.3I?T(o.3I)||0:I,1G:o.1G?2m(o.1G):I,fx:T(o.fx)||S,6R:o.6R?o.6R:I,5t:{},1s:{},4o:o.4o&&o.4o.1K==2A?o.4o:I,3T:o.3T&&o.3T.1K==2A?o.3T:I,2Z:o.2Z&&o.2Z.1K==2A?o.2Z:I,1O:/49|4j/.48(o.1O)?o.1O:I,6M:o.6M?T(o.6M)||0:0,2V:o.2V?o.2V:I,bD:o.bD?1b:I,7O:o.7O||I};if(o.5t&&o.5t.1K==2A)q.A.5t.7R=o.5t;if(o.4m&&o.4m.1K==2A)q.A.4m=o.4m;if(o.2p&&((o.2p.1K==b0&&(o.2p==\'94\'||o.2p==\'1h\'))||(o.2p.1K==7F&&o.2p.1g==4))){q.A.2p=o.2p}if(o.2O){q.A.2O=o.2O}if(o.6a){if(2g o.6a==\'gz\'){q.A.gx=T(o.6a)||1;q.A.gy=T(o.6a)||1}P if(o.6a.1g==2){q.A.gx=T(o.6a[0])||1;q.A.gy=T(o.6a[1])||1}}if(o.3H&&o.3H.1K==2A){q.A.3H=o.3H}q.9I=1b;5e.1E(u(){q.3U=el});5e.1J(\'5v\',k.11.bN)})}};k.fn.23({aS:k.11.4U,7t:k.11.2r});k.1x={du:u(5J,5G,7Q,7S){E 5J<=k.11.F.A.2v&&(5J+7Q)>=(k.11.F.A.2v+k.11.F.A.1B.w)&&5G<=k.11.F.A.2q&&(5G+7S)>=(k.11.F.A.2q+k.11.F.A.1B.h)?1b:I},cV:u(5J,5G,7Q,7S){E!(5J>(k.11.F.A.2v+k.11.F.A.1B.w)||(5J+7Q)(k.11.F.A.2q+k.11.F.A.1B.h)||(5G+7S)k.11.F.A.4B.x&&5Gk.11.F.A.4B.y?1b:I},5r:I,3Q:{},8D:0,3P:{},ed:u(C){if(k.11.F==S){E}D i;k.1x.3Q={};D bJ=I;24(i in k.1x.3P){if(k.1x.3P[i]!=S){D 1j=k.1x.3P[i].K(0);if(k(k.11.F).is(\'.\'+1j.1i.a)){if(1j.1i.m==I){1j.1i.p=k.23(k.1a.7G(1j),k.1a.74(1j));1j.1i.m=1b}if(1j.1i.ac){k.1x.3P[i].2R(1j.1i.ac)}k.1x.3Q[i]=k.1x.3P[i];if(k.1t&&1j.1i.s&&k.11.F.A.44){1j.1i.el=k(\'.\'+1j.1i.a,1j);C.14.19=\'1o\';k.1t.cT(1j);1j.1i.ay=k.1t.8x(k.1p(1j,\'id\')).7l;C.14.19=C.A.7V;bJ=1b}if(1j.1i.9i){1j.1i.9i.1D(k.1x.3P[i].K(0),[k.11.F])}}}}if(bJ){k.1t.26()}},dS:u(){k.1x.3Q={};24(i in k.1x.3P){if(k.1x.3P[i]!=S){D 1j=k.1x.3P[i].K(0);if(k(k.11.F).is(\'.\'+1j.1i.a)){1j.1i.p=k.23(k.1a.7G(1j),k.1a.74(1j));if(1j.1i.ac){k.1x.3P[i].2R(1j.1i.ac)}k.1x.3Q[i]=k.1x.3P[i];if(k.1t&&1j.1i.s&&k.11.F.A.44){1j.1i.el=k(\'.\'+1j.1i.a,1j);C.14.19=\'1o\';k.1t.cT(1j);C.14.19=C.A.7V}}}}},al:u(e){if(k.11.F==S){E}k.1x.5r=I;D i;D bK=I;D eQ=0;24(i in k.1x.3Q){D 1j=k.1x.3Q[i].K(0);if(k.1x.5r==I&&k.1x[1j.1i.t](1j.1i.p.x,1j.1i.p.y,1j.1i.p.1C,1j.1i.p.hb)){if(1j.1i.hc&&1j.1i.h==I){k.1x.3Q[i].2R(1j.1i.hc)}if(1j.1i.h==I&&1j.1i.7x){bK=1b}1j.1i.h=1b;k.1x.5r=1j;if(k.1t&&1j.1i.s&&k.11.F.A.44){k.1t.1c.K(0).3l=1j.1i.eV;k.1t.al(1j)}eQ++}P if(1j.1i.h==1b){if(1j.1i.7y){1j.1i.7y.1D(1j,[e,k.11.1c.K(0).7c,1j.1i.fx])}if(1j.1i.hc){k.1x.3Q[i].4i(1j.1i.hc)}1j.1i.h=I}}if(k.1t&&!k.1x.5r&&k.11.F.44){k.1t.1c.K(0).14.19=\'1o\'}if(bK){k.1x.5r.1i.7x.1D(k.1x.5r,[e,k.11.1c.K(0).7c])}},eO:u(e){D i;24(i in k.1x.3Q){D 1j=k.1x.3Q[i].K(0);if(1j.1i.ac){k.1x.3Q[i].4i(1j.1i.ac)}if(1j.1i.hc){k.1x.3Q[i].4i(1j.1i.hc)}if(1j.1i.s){k.1t.7s[k.1t.7s.1g]=i}if(1j.1i.9l&&1j.1i.h==1b){1j.1i.h=I;1j.1i.9l.1D(1j,[e,1j.1i.fx])}1j.1i.m=I;1j.1i.h=I}k.1x.3Q={}},4U:u(){E q.1E(u(){if(q.9j){if(q.1i.s){id=k.1p(q,\'id\');k.1t.5L[id]=S;k(\'.\'+q.1i.a,q).aS()}k.1x.3P[\'d\'+q.c2]=S;q.9j=I;q.f=S}})},2r:u(o){E q.1E(u(){if(q.9j==1b||!o.3C||!k.1a||!k.11){E}q.1i={a:o.3C,ac:o.9J||I,hc:o.a5||I,eV:o.58||I,9l:o.gq||o.9l||I,7x:o.7x||o.dC||I,7y:o.7y||o.fO||I,9i:o.9i||I,t:o.6I&&(o.6I==\'du\'||o.6I==\'cV\')?o.6I:\'1s\',fx:o.fx?o.fx:I,m:I,h:I};if(o.cQ==1b&&k.1t){id=k.1p(q,\'id\');k.1t.5L[id]=q.1i.a;q.1i.s=1b;if(o.2Z){q.1i.2Z=o.2Z;q.1i.ay=k.1t.8x(id).7l}}q.9j=1b;q.c2=T(18.6o()*c9);k.1x.3P[\'d\'+q.c2]=k(q);k.1x.8D++})}};k.fn.23({dR:k.1x.4U,do:k.1x.2r});k.gD=k.1x.dS;k.3B={1c:S,8L:u(){3g=q.2y;if(!3g)E;14={dz:k(q).B(\'dz\')||\'\',4A:k(q).B(\'4A\')||\'\',8Z:k(q).B(\'8Z\')||\'\',dP:k(q).B(\'dP\')||\'\',dT:k(q).B(\'dT\')||\'\',dU:k(q).B(\'dU\')||\'\',c3:k(q).B(\'c3\')||\'\',dY:k(q).B(\'dY\')||\'\'};k.3B.1c.B(14);3x=k.3B.dX(3g);3x=3x.4E(12 bb("\\\\n","g"),"
    ");k.3B.1c.3x(\'gL\');ci=k.3B.1c.K(0).4c;k.3B.1c.3x(3x);Z=k.3B.1c.K(0).4c+ci;if(q.6l.2M&&Z>q.6l.2M[0]){Z=q.6l.2M[0]}q.14.Z=Z+\'U\';if(q.4Y==\'cf\'){W=k.3B.1c.K(0).5W+ci;if(q.6l.2M&&W>q.6l.2M[1]){W=q.6l.2M[1]}q.14.W=W+\'U\'}},dX:u(3g){cg={\'&\':\'&gK;\',\'<\':\'&gJ;\',\'>\':\'>\',\'"\':\'&gs;\'};24(i in cg){3g=3g.4E(12 bb(i,\'g\'),cg[i])}E 3g},2r:u(2M){if(k.3B.1c==S){k(\'2e\',1h).1S(\'<22 id="dE" 14="Y: 1P; Q: 0; O: 0; 3n: 2K;">\');k.3B.1c=k(\'#dE\')}E q.1E(u(){if(/cf|ch/.48(q.4Y)){if(q.4Y==\'ch\'){dB=q.5C(\'1u\');if(!/3g|gr/.48(dB)){E}}if(2M&&(2M.1K==bn||(2M.1K==7F&&2M.1g==2))){if(2M.1K==bn)2M=[2M,2M];P{2M[0]=T(2M[0])||8J;2M[1]=T(2M[1])||8J}q.6l={2M:2M}}k(q).5B(k.3B.8L).6y(k.3B.8L).dH(k.3B.8L);k.3B.8L.1D(q)}})}};k.fn.kc=k.3B.2r;k.4K=u(e){if(/^kd$|^ke$|^ka$|^6L$|^k9$|^k5$|^k4$|^k6$|^k7$|^2e$|^k8$|^kf$|^kg$|^kn$|^ko$|^kp$|^kq$/i.48(e.9N))E I;P E 1b};k.fx.a0=u(e,65){D c=e.7c;D cs=c.14;cs.Y=65.Y;cs.5K=65.3G.t;cs.5j=65.3G.l;cs.5k=65.3G.b;cs.5z=65.3G.r;cs.Q=65.Q+\'U\';cs.O=65.O+\'U\';e.31.ew(c,e);e.31.km(e)};k.fx.9P=u(e){if(!k.4K(e))E I;D t=k(e);D es=e.14;D 73=I;if(t.B(\'19\')==\'1o\'){5Y=t.B(\'3n\');t.B(\'3n\',\'2K\').1Y();73=1b}D V={};V.Y=t.B(\'Y\');V.1q=k.1a.2o(e);V.3G=k.1a.cy(e);D co=e.4Z?e.4Z.ei:t.B(\'hU\');V.Q=T(t.B(\'Q\'))||0;V.O=T(t.B(\'O\'))||0;D eo=\'kl\'+T(18.6o()*c9);D 6u=1h.3F(/^1T$|^br$|^kh$|^hr$|^8C$|^kj$|^8T$|^3A$|^kk$|^k3$|^k2$|^9h$|^dl$|^jM$/i.48(e.9N)?\'22\':e.9N);k.1p(6u,\'id\',eo);D jN=k(6u).2R(\'jO\');D 4h=6u.14;D Q=0;D O=0;if(V.Y==\'2s\'||V.Y==\'1P\'){Q=V.Q;O=V.O}4h.Q=Q+\'U\';4h.O=O+\'U\';4h.Y=V.Y!=\'2s\'&&V.Y!=\'1P\'?\'2s\':V.Y;4h.W=V.1q.hb+\'U\';4h.Z=V.1q.1C+\'U\';4h.5K=V.3G.t;4h.5z=V.3G.r;4h.5k=V.3G.b;4h.5j=V.3G.l;4h.2U=\'2K\';if(k.3a.4t){4h.ei=co}P{4h.jK=co}if(k.3a=="4t"){es.5E="8V(1G="+0.ex*2a+")"}es.1G=0.ex;e.31.ew(6u,e);6u.jF(e);es.5K=\'2P\';es.5z=\'2P\';es.5k=\'2P\';es.5j=\'2P\';es.Y=\'1P\';es.eu=\'1o\';es.Q=\'2P\';es.O=\'2P\';if(73){t.2G();es.3n=5Y}E{V:V,3p:k(6u)}};k.fx.8E={jE:[0,1V,1V],jG:[eD,1V,1V],jH:[e6,e6,jI],jP:[0,0,0],ks:[0,0,1V],jY:[dv,42,42],jZ:[0,1V,1V],k0:[0,0,7w],k1:[0,7w,7w],jX:[cn,cn,cn],jS:[0,2a,0],jR:[jT,jU,eb],jV:[7w,0,7w],kr:[85,eb,47],kP:[1V,eA,0],kN:[kO,50,kx],kF:[7w,0,0],kD:[ku,f8,kt],ky:[kH,0,9C],kL:[1V,0,1V],kM:[1V,kJ,0],kv:[0,6C,0],kA:[75,0,kE],kC:[eD,eB,eA],kG:[kI,kB,eB],kw:[e0,1V,1V],kz:[eL,kK,eL],kQ:[9C,9C,9C],jC:[1V,iy,iz],iA:[1V,1V,e0],iB:[0,1V,0],ix:[1V,0,1V],iv:[6C,0,0],iq:[0,0,6C],ip:[6C,6C,0],ir:[1V,dv,0],it:[1V,ah,iu],iC:[6C,0,6C],iD:[1V,0,0],iK:[ah,ah,ah],iL:[1V,1V,1V],iM:[1V,1V,0]};k.fx.6D=u(4x,dm){if(k.fx.8E[4x])E{r:k.fx.8E[4x][0],g:k.fx.8E[4x][1],b:k.fx.8E[4x][2]};P if(2W=/^6Y\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)$/.a4(4x))E{r:T(2W[1]),g:T(2W[2]),b:T(2W[3])};P if(2W=/6Y\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)$/.a4(4x))E{r:2m(2W[1])*2.55,g:2m(2W[2])*2.55,b:2m(2W[3])*2.55};P if(2W=/^#([a-fA-79-9])([a-fA-79-9])([a-fA-79-9])$/.a4(4x))E{r:T("77"+2W[1]+2W[1]),g:T("77"+2W[2]+2W[2]),b:T("77"+2W[3]+2W[3])};P if(2W=/^#([a-fA-79-9]{2})([a-fA-79-9]{2})([a-fA-79-9]{2})$/.a4(4x))E{r:T("77"+2W[1]),g:T("77"+2W[2]),b:T("77"+2W[3])};P E dm==1b?I:{r:1V,g:1V,b:1V}};k.fx.dD={5Q:1,5b:1,5O:1,4S:1,4D:1,4A:1,W:1,O:1,c3:1,iI:1,5k:1,5j:1,5z:1,5K:1,8b:1,6x:1,8c:1,av:1,1G:1,iE:1,iF:1,5n:1,4X:1,5U:1,5M:1,2L:1,jD:1,Q:1,Z:1,3I:1};k.fx.dA={7i:1,iG:1,iH:1,io:1,im:1,4x:1,i2:1};k.fx.8A=[\'i3\',\'i4\',\'i5\',\'i1\'];k.fx.cc={\'cd\':[\'2E\',\'dK\'],\'a8\':[\'2E\',\'bh\'],\'6w\':[\'6w\',\'\'],\'8F\':[\'8F\',\'\']};k.fn.23({5w:u(5X,H,G,J){E q.1w(u(){D a1=k.H(H,G,J);D e=12 k.dM(q,a1,5X)})},c4:u(H,J){E q.1w(u(){D a1=k.H(H,J);D e=12 k.c4(q,a1)})},8o:u(2D){E q.1E(u(){if(q.6d)k.by(q,2D)})},i0:u(2D){E q.1E(u(){if(q.6d)k.by(q,2D);if(q.1w&&q.1w[\'fx\'])q.1w.fx=[]})}});k.23({c4:u(2f,M){D z=q,3t;z.2D=u(){if(k.fQ(M.21))M.21.1D(2f)};z.2I=6V(u(){z.2D()},M.1m);2f.6d=z},G:{c8:u(p,n,1W,1H,1m){E((-18.5H(p*18.2Q)/2)+0.5)*1H+1W}},dM:u(2f,M,5X){D z=q,3t;D y=2f.14;D fR=k.B(2f,"2U");D 72=k.B(2f,"19");D 2j={};z.9O=(12 7g()).7z();M.G=M.G&&k.G[M.G]?M.G:\'c8\';z.ag=u(2w,43){if(k.fx.dD[2w]){if(43==\'1Y\'||43==\'2G\'||43==\'3R\'){if(!2f.6v)2f.6v={};D r=2m(k.6E(2f,2w));2f.6v[2w]=r&&r>-c9?r:(2m(k.B(2f,2w))||0);43=43==\'3R\'?(72==\'1o\'?\'1Y\':\'2G\'):43;M[43]=1b;2j[2w]=43==\'1Y\'?[0,2f.6v[2w]]:[2f.6v[2w],0];if(2w!=\'1G\')y[2w]=2j[2w][0]+(2w!=\'3I\'&&2w!=\'8Z\'?\'U\':\'\');P k.1p(y,"1G",2j[2w][0])}P{2j[2w]=[2m(k.6E(2f,2w)),2m(43)||0]}}P if(k.fx.dA[2w])2j[2w]=[k.fx.6D(k.6E(2f,2w)),k.fx.6D(43)];P if(/^6w$|8F$|2E$|a8$|cd$/i.48(2w)){D m=43.4E(/\\s+/g,\' \').4E(/6Y\\s*\\(\\s*/g,\'6Y(\').4E(/\\s*,\\s*/g,\',\').4E(/\\s*\\)/g,\')\').d5(/([^\\s]+)/g);3m(2w){1e\'6w\':1e\'8F\':1e\'cd\':1e\'a8\':m[3]=m[3]||m[1]||m[0];m[2]=m[2]||m[0];m[1]=m[1]||m[0];24(D i=0;iM.1m+z.9O){5T(z.2I);z.2I=S;24(p in 2j){if(p=="1G")k.1p(y,"1G",2j[p][1]);P if(2g 2j[p][1]==\'8T\')y[p]=\'6Y(\'+2j[p][1].r+\',\'+2j[p][1].g+\',\'+2j[p][1].b+\')\';P y[p]=2j[p][1]+(p!=\'3I\'&&p!=\'8Z\'?\'U\':\'\')}if(M.2G||M.1Y)24(D p in 2f.6v)if(p=="1G")k.1p(y,p,2f.6v[p]);P y[p]="";y.19=M.2G?\'1o\':(72!=\'1o\'?72:\'2B\');y.2U=fR;2f.6d=S;if(k.fQ(M.21))M.21.1D(2f)}P{D n=t-q.9O;D 8w=n/M.1m;24(p in 2j){if(2g 2j[p][1]==\'8T\'){y[p]=\'6Y(\'+T(k.G[M.G](8w,n,2j[p][0].r,(2j[p][1].r-2j[p][0].r),M.1m))+\',\'+T(k.G[M.G](8w,n,2j[p][0].g,(2j[p][1].g-2j[p][0].g),M.1m))+\',\'+T(k.G[M.G](8w,n,2j[p][0].b,(2j[p][1].b-2j[p][0].b),M.1m))+\')\'}P{D bz=k.G[M.G](8w,n,2j[p][0],(2j[p][1]-2j[p][0]),M.1m);if(p=="1G")k.1p(y,"1G",bz);P y[p]=bz+(p!=\'3I\'&&p!=\'8Z\'?\'U\':\'\')}}}};z.2I=6V(u(){z.2D()},13);2f.6d=z},by:u(2f,2D){if(2D)2f.6d.9O-=iO;P{1X.5T(2f.6d.2I);2f.6d=S;k.2H(2f,"fx")}}});k.bl=u(5Z){D 5f={};if(2g 5Z==\'4V\'){5Z=5Z.6c().7C(\';\');24(D i=0;i<5Z.1g;i++){6X=5Z[i].7C(\':\');if(6X.1g==2){5f[k.g6(6X[0].4E(/\\-(\\w)/g,u(m,c){E c.jo()}))]=k.g6(6X[1])}}}E 5f};k.fn.23({g3:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'4F\',G)})},gb:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'4r\',G)})},jl:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'fJ\',G)})},jk:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'O\',G)})},jg:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'2L\',G)})},jf:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.61(q,H,J,\'fh\',G)})}});k.fx.61=u(e,H,J,2S,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.1N=k.1a.2o(e);z.G=2g J==\'4V\'?J:G||S;if(!e.4s)e.4s=z.el.B(\'19\');if(2S==\'fJ\'){2S=z.el.B(\'19\')==\'1o\'?\'4r\':\'4F\'}P if(2S==\'fh\'){2S=z.el.B(\'19\')==\'1o\'?\'2L\':\'O\'}z.el.1Y();z.H=H;z.J=2g J==\'u\'?J:S;z.fx=k.fx.9P(e);z.2S=2S;z.21=u(){if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}if(z.2S==\'4r\'||z.2S==\'2L\'){z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s)}P{z.el.2G()}k.fx.a0(z.fx.3p.K(0),z.fx.V);k.2H(z.el.K(0),\'1n\')};3m(z.2S){1e\'4F\':63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');63.1L(z.fx.V.1q.hb,0);1r;1e\'4r\':z.fx.3p.B(\'W\',\'9R\');z.el.1Y();63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');63.1L(0,z.fx.V.1q.hb);1r;1e\'O\':63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');63.1L(z.fx.V.1q.1C,0);1r;1e\'2L\':z.fx.3p.B(\'Z\',\'9R\');z.el.1Y();63=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');63.1L(0,z.fx.V.1q.1C);1r}};k.fn.ji=u(5D,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D e=12 k.fx.f4(q,5D,J);e.bp()})};k.fx.f4=u(e,5D,J){D z=q;z.el=k(e);z.el.1Y();z.J=J;z.5D=T(5D)||40;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=T(z.el.B(\'Q\'))||0;z.V.O=T(z.el.B(\'O\'))||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.3V=5;z.5y=1;z.bp=u(){z.5y++;z.e=12 k.fx(z.el.K(0),{1m:jj,21:u(){z.e=12 k.fx(z.el.K(0),{1m:80,21:u(){z.5D=T(z.5D/2);if(z.5y<=z.3V)z.bp();P{z.el.B(\'Y\',z.V.Y).B(\'Q\',z.V.Q+\'U\').B(\'O\',z.V.O+\'U\');k.2H(z.el.K(0),\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}}}},\'Q\');z.e.1L(z.V.Q-z.5D,z.V.Q)}},\'Q\');z.e.1L(z.V.Q,z.V.Q-z.5D)}};k.fn.23({jy:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'4l\',G)})},jz:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'in\',G)})},jA:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4r\',\'3R\',G)})},jB:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'4l\',G)})},jx:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'in\',G)})},jw:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'4F\',\'3R\',G)})},js:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'4l\',G)})},jt:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'in\',G)})},ju:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'O\',\'3R\',G)})},jv:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'4l\',G)})},je:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'in\',G)})},jd:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.4f(q,H,J,\'2L\',\'3R\',G)})}});k.fx.4f=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=z.el.B(\'Q\');z.V.O=z.el.B(\'O\');if(!e.4s)e.4s=z.el.B(\'19\');if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'in\':\'4l\'}z.el.1Y();if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.1u=1u;J=2g J==\'u\'?J:S;8H=1;3m(2S){1e\'4F\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Q\');z.62=2m(z.V.Q)||0;z.9K=z.fG;8H=-1;1r;1e\'4r\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Q\');z.62=2m(z.V.Q)||0;z.9K=z.fG;1r;1e\'2L\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'O\');z.62=2m(z.V.O)||0;z.9K=z.fy;1r;1e\'O\':z.e=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'O\');z.62=2m(z.V.O)||0;z.9K=z.fy;8H=-1;1r}z.e2=12 k.fx(z.el.K(0),k.H(H,z.G,u(){z.el.B(z.V);if(z.1u==\'4l\'){z.el.B(\'19\',\'1o\')}P z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s);k.2H(z.el.K(0),\'1n\')}),\'1G\');if(1u==\'in\'){z.e.1L(z.62+2a*8H,z.62);z.e2.1L(0,1)}P{z.e.1L(z.62,z.62+2a*8H);z.e2.1L(1,0)}};k.fn.23({j0:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'fp\',G)})},iW:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'9M\',G)})},iV:u(H,W,J,G){E q.1w(\'1n\',u(){12 k.fx.9L(q,H,W,J,\'3R\',G)})}});k.fx.9L=u(e,H,W,J,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'9M\':\'fp\'}z.H=H;z.W=W&&W.1K==bn?W:20;z.fx=k.fx.9P(e);z.1u=1u;z.21=u(){if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}if(z.1u==\'9M\'){z.el.1Y()}P{z.el.2G()}k.fx.a0(z.fx.3p.K(0),z.fx.V);k.2H(z.el.K(0),\'1n\')};if(z.1u==\'9M\'){z.el.1Y();z.fx.3p.B(\'W\',z.W+\'U\').B(\'Z\',\'9R\');z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,u(){z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'W\');z.ef.1L(z.W,z.fx.V.1q.hb)}),\'Z\');z.ef.1L(0,z.fx.V.1q.1C)}P{z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,u(){z.ef=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G,z.21),\'Z\');z.ef.1L(z.fx.V.1q.1C,0)}),\'W\');z.ef.1L(z.fx.V.1q.hb,z.W)}};k.fn.iR=u(H,4x,J,G){E q.1w(\'fv\',u(){q.6W=k(q).1p("14")||\'\';G=2g J==\'4V\'?J:G||S;J=2g J==\'u\'?J:S;D 9S=k(q).B(\'7i\');D 8I=q.31;7d(9S==\'cu\'&&8I){9S=k(8I).B(\'7i\');8I=8I.31}k(q).B(\'7i\',4x);if(2g q.6W==\'8T\')q.6W=q.6W["9X"];k(q).5w({\'7i\':9S},H,G,u(){k.2H(q,\'fv\');if(2g k(q).1p("14")==\'8T\'){k(q).1p("14")["9X"]="";k(q).1p("14")["9X"]=q.6W}P{k(q).1p("14",q.6W)}if(J)J.1D(q)})})};k.fn.23({iT:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'49\',\'6g\',G)})},iU:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'4j\',\'6g\',G)})},j1:u(H,J,G){E q.1w(\'1n\',u(){if(k.B(q,\'19\')==\'1o\'){12 k.fx.5m(q,H,J,\'4j\',\'6Z\',G)}P{12 k.fx.5m(q,H,J,\'4j\',\'6g\',G)}})},j2:u(H,J,G){E q.1w(\'1n\',u(){if(k.B(q,\'19\')==\'1o\'){12 k.fx.5m(q,H,J,\'49\',\'6Z\',G)}P{12 k.fx.5m(q,H,J,\'49\',\'6g\',G)}})},j9:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'49\',\'6Z\',G)})},ja:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.5m(q,H,J,\'4j\',\'6Z\',G)})}});k.fx.5m=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;D 73=I;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;z.1u=1u;z.H=H;z.2i=k.1a.2o(e);z.V={};z.V.Y=z.el.B(\'Y\');z.V.19=z.el.B(\'19\');if(z.V.19==\'1o\'){5Y=z.el.B(\'3n\');z.el.1Y();73=1b}z.V.Q=z.el.B(\'Q\');z.V.O=z.el.B(\'O\');if(73){z.el.2G();z.el.B(\'3n\',5Y)}z.V.Z=z.2i.w+\'U\';z.V.W=z.2i.h+\'U\';z.V.2U=z.el.B(\'2U\');z.2i.Q=T(z.V.Q)||0;z.2i.O=T(z.V.O)||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.el.B(\'2U\',\'2K\').B(\'W\',1u==\'6Z\'&&2S==\'49\'?1:z.2i.h+\'U\').B(\'Z\',1u==\'6Z\'&&2S==\'4j\'?1:z.2i.w+\'U\');z.21=u(){z.el.B(z.V);if(z.1u==\'6g\')z.el.2G();P z.el.1Y();k.2H(z.el.K(0),\'1n\')};3m(2S){1e\'49\':z.eh=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'W\');z.et=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');if(z.1u==\'6g\'){z.eh.1L(z.2i.h,0);z.et.1L(z.2i.Q,z.2i.Q+z.2i.h/2)}P{z.eh.1L(0,z.2i.h);z.et.1L(z.2i.Q+z.2i.h/2,z.2i.Q)}1r;1e\'4j\':z.eh=12 k.fx(z.el.K(0),k.H(H-15,z.G,J),\'Z\');z.et=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');if(z.1u==\'6g\'){z.eh.1L(z.2i.w,0);z.et.1L(z.2i.O,z.2i.O+z.2i.w/2)}P{z.eh.1L(0,z.2i.w);z.et.1L(z.2i.O+z.2i.w/2,z.2i.O)}1r}};k.fn.bg=u(H,3V,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D fx=12 k.fx.bg(q,H,3V,J);fx.bf()})};k.fx.bg=u(el,H,3V,J){D z=q;z.3V=3V;z.5y=1;z.el=el;z.H=H;z.J=J;k(z.el).1Y();z.bf=u(){z.5y++;z.e=12 k.fx(z.el,k.H(z.H,u(){z.ef=12 k.fx(z.el,k.H(z.H,u(){if(z.5y<=z.3V)z.bf();P{k.2H(z.el,\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el)}}}),\'1G\');z.ef.1L(0,1)}),\'1G\');z.e.1L(1,0)}};k.fn.23({jb:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,1,2a,1b,J,\'fa\',G)})},jc:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,2a,1,1b,J,\'b4\',G)})},j8:u(H,J,G){E q.1w(\'1n\',u(){D G=G||\'fl\';12 k.fx.6G(q,H,2a,f8,1b,J,\'6h\',G)})},6G:u(H,57,30,6H,J,G){E q.1w(\'1n\',u(){12 k.fx.6G(q,H,57,30,6H,J,\'6G\',G)})}});k.fx.6G=u(e,H,57,30,6H,J,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.57=T(57)||2a;z.30=T(30)||2a;z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;z.1m=k.H(H).1m;z.6H=6H||S;z.2i=k.1a.2o(e);z.V={Z:z.el.B(\'Z\'),W:z.el.B(\'W\'),4A:z.el.B(\'4A\')||\'2a%\',Y:z.el.B(\'Y\'),19:z.el.B(\'19\'),Q:z.el.B(\'Q\'),O:z.el.B(\'O\'),2U:z.el.B(\'2U\'),4S:z.el.B(\'4S\'),5O:z.el.B(\'5O\'),5Q:z.el.B(\'5Q\'),5b:z.el.B(\'5b\'),5M:z.el.B(\'5M\'),5U:z.el.B(\'5U\'),5n:z.el.B(\'5n\'),4X:z.el.B(\'4X\')};z.Z=T(z.V.Z)||e.4c||0;z.W=T(z.V.W)||e.5W||0;z.Q=T(z.V.Q)||0;z.O=T(z.V.O)||0;1q=[\'em\',\'U\',\'j7\',\'%\'];24(i in 1q){if(z.V.4A.3J(1q[i])>0){z.fg=1q[i];z.4A=2m(z.V.4A)}if(z.V.4S.3J(1q[i])>0){z.fc=1q[i];z.bw=2m(z.V.4S)||0}if(z.V.5O.3J(1q[i])>0){z.fe=1q[i];z.bc=2m(z.V.5O)||0}if(z.V.5Q.3J(1q[i])>0){z.fL=1q[i];z.bA=2m(z.V.5Q)||0}if(z.V.5b.3J(1q[i])>0){z.g8=1q[i];z.bt=2m(z.V.5b)||0}if(z.V.5M.3J(1q[i])>0){z.g4=1q[i];z.bx=2m(z.V.5M)||0}if(z.V.5U.3J(1q[i])>0){z.g9=1q[i];z.bv=2m(z.V.5U)||0}if(z.V.5n.3J(1q[i])>0){z.gc=1q[i];z.bj=2m(z.V.5n)||0}if(z.V.4X.3J(1q[i])>0){z.fK=1q[i];z.b7=2m(z.V.4X)||0}}if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.el.B(\'2U\',\'2K\');z.1u=1u;3m(z.1u){1e\'fa\':z.4b=z.Q+z.2i.h/2;z.5a=z.Q;z.4k=z.O+z.2i.w/2;z.59=z.O;1r;1e\'b4\':z.5a=z.Q+z.2i.h/2;z.4b=z.Q;z.59=z.O+z.2i.w/2;z.4k=z.O;1r;1e\'6h\':z.5a=z.Q-z.2i.h/4;z.4b=z.Q;z.59=z.O-z.2i.w/4;z.4k=z.O;1r}z.be=I;z.t=(12 7g).7z();z.4w=u(){5T(z.2I);z.2I=S};z.2D=u(){if(z.be==I){z.el.1Y();z.be=1b}D t=(12 7g).7z();D n=t-z.t;D p=n/z.1m;if(t>=z.1m+z.t){9T(u(){o=1;if(z.1u){t=z.5a;l=z.59;if(z.1u==\'6h\')o=0}z.bs(z.30,l,t,1b,o)},13);z.4w()}P{o=1;if(!k.G||!k.G[z.G]){s=((-18.5H(p*18.2Q)/2)+0.5)*(z.30-z.57)+z.57}P{s=k.G[z.G](p,n,z.57,(z.30-z.57),z.1m)}if(z.1u){if(!k.G||!k.G[z.G]){t=((-18.5H(p*18.2Q)/2)+0.5)*(z.5a-z.4b)+z.4b;l=((-18.5H(p*18.2Q)/2)+0.5)*(z.59-z.4k)+z.4k;if(z.1u==\'6h\')o=((-18.5H(p*18.2Q)/2)+0.5)*(-0.9Y)+0.9Y}P{t=k.G[z.G](p,n,z.4b,(z.5a-z.4b),z.1m);l=k.G[z.G](p,n,z.4k,(z.59-z.4k),z.1m);if(z.1u==\'6h\')o=k.G[z.G](p,n,0.9Y,-0.9Y,z.1m)}}z.bs(s,l,t,I,o)}};z.2I=6V(u(){z.2D()},13);z.bs=u(4q,O,Q,fM,1G){z.el.B(\'W\',z.W*4q/2a+\'U\').B(\'Z\',z.Z*4q/2a+\'U\').B(\'O\',O+\'U\').B(\'Q\',Q+\'U\').B(\'4A\',z.4A*4q/2a+z.fg);if(z.bw)z.el.B(\'4S\',z.bw*4q/2a+z.fc);if(z.bc)z.el.B(\'5O\',z.bc*4q/2a+z.fe);if(z.bA)z.el.B(\'5Q\',z.bA*4q/2a+z.fL);if(z.bt)z.el.B(\'5b\',z.bt*4q/2a+z.g8);if(z.bx)z.el.B(\'5M\',z.bx*4q/2a+z.g4);if(z.bv)z.el.B(\'5U\',z.bv*4q/2a+z.g9);if(z.bj)z.el.B(\'5n\',z.bj*4q/2a+z.gc);if(z.b7)z.el.B(\'4X\',z.b7*4q/2a+z.fK);if(z.1u==\'6h\'){if(1X.71)z.el.K(0).14.5E="8V(1G="+1G*2a+")";z.el.K(0).14.1G=1G}if(fM){if(z.6H){z.el.B(z.V)}if(z.1u==\'b4\'||z.1u==\'6h\'){z.el.B(\'19\',\'1o\');if(z.1u==\'6h\'){if(1X.71)z.el.K(0).14.5E="8V(1G="+2a+")";z.el.K(0).14.1G=1}}P z.el.B(\'19\',\'2B\');if(z.J)z.J.1D(z.el.K(0));k.2H(z.el.K(0),\'1n\')}}};k.fn.23({9U:u(H,1O,G){o=k.H(H);E q.1w(\'1n\',u(){12 k.fx.9U(q,o,1O,G)})},j6:u(H,1O,G){E q.1E(u(){k(\'a[@3h*="#"]\',q).5h(u(e){fW=q.3h.7C(\'#\');k(\'#\'+fW[1]).9U(H,1O,G);E I})})}});k.fx.9U=u(e,o,1O,G){D z=q;z.o=o;z.e=e;z.1O=/fT|gd/.48(1O)?1O:I;z.G=G;p=k.1a.3w(e);s=k.1a.6z();z.4w=u(){5T(z.2I);z.2I=S;k.2H(z.e,\'1n\')};z.t=(12 7g).7z();s.h=s.h>s.ih?(s.h-s.ih):s.h;s.w=s.w>s.iw?(s.w-s.iw):s.w;z.5a=p.y>s.h?s.h:p.y;z.59=p.x>s.w?s.w:p.x;z.4b=s.t;z.4k=s.l;z.2D=u(){D t=(12 7g).7z();D n=t-z.t;D p=n/z.o.1m;if(t>=z.o.1m+z.t){z.4w();9T(u(){z.d3(z.5a,z.59)},13)}P{if(!z.1O||z.1O==\'fT\'){if(!k.G||!k.G[z.G]){9V=((-18.5H(p*18.2Q)/2)+0.5)*(z.5a-z.4b)+z.4b}P{9V=k.G[z.G](p,n,z.4b,(z.5a-z.4b),z.o.1m)}}P{9V=z.4b}if(!z.1O||z.1O==\'gd\'){if(!k.G||!k.G[z.G]){9W=((-18.5H(p*18.2Q)/2)+0.5)*(z.59-z.4k)+z.4k}P{9W=k.G[z.G](p,n,z.4k,(z.59-z.4k),z.o.1m)}}P{9W=z.4k}z.d3(9V,9W)}};z.d3=u(t,l){1X.j4(l,t)};z.2I=6V(u(){z.2D()},13)};k.fn.cY=u(3V,J){E q.1w(\'1n\',u(){if(!k.4K(q)){k.2H(q,\'1n\');E I}D e=12 k.fx.cY(q,3V,J);e.cG()})};k.fx.cY=u(e,3V,J){D z=q;z.el=k(e);z.el.1Y();z.3V=T(3V)||3;z.J=J;z.5y=1;z.V={};z.V.Y=z.el.B(\'Y\');z.V.Q=T(z.el.B(\'Q\'))||0;z.V.O=T(z.el.B(\'O\'))||0;if(z.V.Y!=\'2s\'&&z.V.Y!=\'1P\'){z.el.B(\'Y\',\'2s\')}z.cG=u(){z.5y++;z.e=12 k.fx(z.el.K(0),{1m:60,21:u(){z.e=12 k.fx(z.el.K(0),{1m:60,21:u(){z.e=12 k.fx(e,{1m:60,21:u(){if(z.5y<=z.3V)z.cG();P{z.el.B(\'Y\',z.V.Y).B(\'Q\',z.V.Q+\'U\').B(\'O\',z.V.O+\'U\');k.2H(z.el.K(0),\'1n\');if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}}}},\'O\');z.e.1L(z.V.O-20,z.V.O)}},\'O\');z.e.1L(z.V.O+20,z.V.O-20)}},\'O\');z.e.1L(z.V.O,z.V.O+20)}};k.fn.23({fo:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'in\',G)})},fq:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'4l\',G)})},iY:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4F\',\'3R\',G)})},iX:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'in\',G)})},jr:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'4l\',G)})},jq:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'4r\',\'3R\',G)})},jp:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'in\',G)})},jn:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'4l\',G)})},jm:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'O\',\'3R\',G)})},iP:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'in\',G)})},ic:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'4l\',G)})},ib:u(H,J,G){E q.1w(\'1n\',u(){12 k.fx.1z(q,H,J,\'2L\',\'3R\',G)})}});k.fx.1z=u(e,H,J,2S,1u,G){if(!k.4K(e)){k.2H(e,\'1n\');E I}D z=q;z.el=k(e);z.G=2g J==\'4V\'?J:G||S;z.J=2g J==\'u\'?J:S;if(1u==\'3R\'){1u=z.el.B(\'19\')==\'1o\'?\'in\':\'4l\'}if(!e.4s)e.4s=z.el.B(\'19\');z.el.1Y();z.H=H;z.fx=k.fx.9P(e);z.1u=1u;z.2S=2S;z.21=u(){if(z.1u==\'4l\')z.el.B(\'3n\',\'2K\');k.fx.a0(z.fx.3p.K(0),z.fx.V);if(z.1u==\'in\'){z.el.B(\'19\',z.el.K(0).4s==\'1o\'?\'2B\':z.el.K(0).4s)}P{z.el.B(\'19\',\'1o\');z.el.B(\'3n\',\'dd\')}if(z.J&&z.J.1K==2A){z.J.1D(z.el.K(0))}k.2H(z.el.K(0),\'1n\')};3m(z.2S){1e\'4F\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');z.7v=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G),\'W\');if(z.1u==\'in\'){z.ef.1L(-z.fx.V.1q.hb,0);z.7v.1L(0,z.fx.V.1q.hb)}P{z.ef.1L(0,-z.fx.V.1q.hb);z.7v.1L(z.fx.V.1q.hb,0)}1r;1e\'4r\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'Q\');if(z.1u==\'in\'){z.ef.1L(z.fx.V.1q.hb,0)}P{z.ef.1L(0,z.fx.V.1q.hb)}1r;1e\'O\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');z.7v=12 k.fx(z.fx.3p.K(0),k.H(z.H,z.G),\'Z\');if(z.1u==\'in\'){z.ef.1L(-z.fx.V.1q.1C,0);z.7v.1L(0,z.fx.V.1q.1C)}P{z.ef.1L(0,-z.fx.V.1q.1C);z.7v.1L(z.fx.V.1q.1C,0)}1r;1e\'2L\':z.ef=12 k.fx(z.el.K(0),k.H(z.H,z.G,z.21),\'O\');if(z.1u==\'in\'){z.ef.1L(z.fx.V.1q.1C,0)}P{z.ef.1L(0,z.fx.V.1q.1C)}1r}};k.3f=S;k.fn.ig=u(o){E q.1w(\'1n\',u(){12 k.fx.dG(q,o)})};k.fx.dG=u(e,o){if(k.3f==S){k(\'2e\',1h).1S(\'<22 id="3f">\');k.3f=k(\'#3f\')}k.3f.B(\'19\',\'2B\').B(\'Y\',\'1P\');D z=q;z.el=k(e);if(!o||!o.30){E}if(o.30.1K==b0&&1h.9e(o.30)){o.30=1h.9e(o.30)}P if(!o.30.dq){E}if(!o.1m){o.1m=g5}z.1m=o.1m;z.30=o.30;z.8r=o.3l;z.21=o.21;if(z.8r){k.3f.2R(z.8r)}z.a3=0;z.a2=0;if(k.dF){z.a3=(T(k.3f.B(\'5b\'))||0)+(T(k.3f.B(\'5O\'))||0)+(T(k.3f.B(\'4X\'))||0)+(T(k.3f.B(\'5U\'))||0);z.a2=(T(k.3f.B(\'4S\'))||0)+(T(k.3f.B(\'5Q\'))||0)+(T(k.3f.B(\'5M\'))||0)+(T(k.3f.B(\'5n\'))||0)}z.26=k.23(k.1a.3w(z.el.K(0)),k.1a.2o(z.el.K(0)));z.2T=k.23(k.1a.3w(z.30),k.1a.2o(z.30));z.26.1C-=z.a3;z.26.hb-=z.a2;z.2T.1C-=z.a3;z.2T.hb-=z.a2;z.J=o.21;k.3f.B(\'Z\',z.26.1C+\'U\').B(\'W\',z.26.hb+\'U\').B(\'Q\',z.26.y+\'U\').B(\'O\',z.26.x+\'U\').5w({Q:z.2T.y,O:z.2T.x,Z:z.2T.1C,W:z.2T.hb},z.1m,u(){if(z.8r)k.3f.4i(z.8r);k.3f.B(\'19\',\'1o\');if(z.21&&z.21.1K==2A){z.21.1D(z.el.K(0),[z.30])}k.2H(z.el.K(0),\'1n\')})};k.1v={M:{2E:10,ec:\'1Q/iJ.eZ\',e3:\'<1T 2J="1Q/6g.da" />\',eW:0.8,d8:\'iN a6\',dc:\'57\',3W:8J},jQ:I,jW:I,6j:S,8m:I,8k:I,d1:u(2k){if(!k.1v.8k||k.1v.8m)E;D 3K=2k.7L||2k.7K||-1;3m(3K){1e 35:if(k.1v.6j)k.1v.26(S,k(\'a[@4I=\'+k.1v.6j+\']:jJ\').K(0));1r;1e 36:if(k.1v.6j)k.1v.26(S,k(\'a[@4I=\'+k.1v.6j+\']:jL\').K(0));1r;1e 37:1e 8:1e 33:1e 80:1e kb:D 9p=k(\'#87\');if(9p.K(0).53!=S){9p.K(0).53.1D(9p.K(0))}1r;1e 38:1r;1e 39:1e 34:1e 32:1e gl:1e 78:D 9k=k(\'#88\');if(9k.K(0).53!=S){9k.K(0).53.1D(9k.K(0))}1r;1e 40:1r;1e 27:k.1v.au();1r}},7q:u(M){if(M)k.23(k.1v.M,M);if(1X.2k){k(\'2e\',1h).1J(\'6y\',k.1v.d1)}P{k(1h).1J(\'6y\',k.1v.d1)}k(\'a\').1E(u(){el=k(q);en=el.1p(\'4I\')||\'\';e9=el.1p(\'3h\')||\'\';ev=/\\.da|\\.gw|\\.8X|\\.eZ|\\.gn/g;if(e9.6c().d5(ev)!=S&&en.6c().3J(\'eU\')==0){el.1J(\'5h\',k.1v.26)}});if(k.3a.4t){3A=1h.3F(\'3A\');k(3A).1p({id:\'cN\',2J:\'ek:I;\',ej:\'cD\',ep:\'cD\'}).B({19:\'1o\',Y:\'1P\',Q:\'0\',O:\'0\',5E:\'9n:9w.9y.cC(1G=0)\'});k(\'2e\').1S(3A)}8n=1h.3F(\'22\');k(8n).1p(\'id\',\'cP\').B({Y:\'1P\',19:\'1o\',Q:\'0\',O:\'0\',1G:0}).1S(1h.8M(\' \')).1J(\'5h\',k.1v.au);6A=1h.3F(\'22\');k(6A).1p(\'id\',\'eK\').B({4X:k.1v.M.2E+\'U\'}).1S(1h.8M(\' \'));cE=1h.3F(\'22\');k(cE).1p(\'id\',\'dg\').B({4X:k.1v.M.2E+\'U\',5n:k.1v.M.2E+\'U\'}).1S(1h.8M(\' \'));cF=1h.3F(\'a\');k(cF).1p({id:\'gg\',3h:\'#\'}).B({Y:\'1P\',2L:k.1v.M.2E+\'U\',Q:\'0\'}).1S(k.1v.M.e3).1J(\'5h\',k.1v.au);7m=1h.3F(\'22\');k(7m).1p(\'id\',\'cM\').B({Y:\'2s\',cA:\'O\',6w:\'0 9F\',3I:1}).1S(6A).1S(cE).1S(cF);2b=1h.3F(\'1T\');2b.2J=k.1v.M.ec;k(2b).1p(\'id\',\'eM\').B({Y:\'1P\'});4G=1h.3F(\'a\');k(4G).1p({id:\'87\',3h:\'#\'}).B({Y:\'1P\',19:\'1o\',2U:\'2K\',ey:\'1o\'}).1S(1h.8M(\' \'));4M=1h.3F(\'a\');k(4M).1p({id:\'88\',3h:\'#\'}).B({Y:\'1P\',2U:\'2K\',ey:\'1o\'}).1S(1h.8M(\' \'));1Z=1h.3F(\'22\');k(1Z).1p(\'id\',\'eE\').B({19:\'1o\',Y:\'2s\',2U:\'2K\',cA:\'O\',6w:\'0 9F\',Q:\'0\',O:\'0\',3I:2}).1S([2b,4G,4M]);6F=1h.3F(\'22\');k(6F).1p(\'id\',\'ao\').B({19:\'1o\',Y:\'1P\',2U:\'2K\',Q:\'0\',O:\'0\',cA:\'cv\',7i:\'cu\',hC:\'0\'}).1S([1Z,7m]);k(\'2e\').1S(8n).1S(6F)},26:u(e,C){el=C?k(C):k(q);9t=el.1p(\'4I\');D 6B,4u,4G,4M;if(9t!=\'eU\'){k.1v.6j=9t;8Y=k(\'a[@4I=\'+9t+\']\');6B=8Y.1N();4u=8Y.cZ(C?C:q);4G=8Y.K(4u-1);4M=8Y.K(4u+1)}89=el.1p(\'3h\');6A=el.1p(\'4g\');3O=k.1a.6z();8n=k(\'#cP\');if(!k.1v.8k){k.1v.8k=1b;if(k.3a.4t){k(\'#cN\').B(\'W\',18.3r(3O.ih,3O.h)+\'U\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\').1Y()}8n.B(\'W\',18.3r(3O.ih,3O.h)+\'U\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\').1Y().fX(cO,k.1v.M.eW,u(){k.1v.cw(89,6A,3O,6B,4u,4G,4M)});k(\'#ao\').B(\'Z\',18.3r(3O.iw,3O.w)+\'U\')}P{k(\'#87\').K(0).53=S;k(\'#88\').K(0).53=S;k.1v.cw(89,6A,3O,6B,4u,4G,4M)}E I},cw:u(89,gP,3O,6B,4u,4G,4M){k(\'#cW\').bk();aX=k(\'#87\');aX.2G();aO=k(\'#88\');aO.2G();2b=k(\'#eM\');1Z=k(\'#eE\');6F=k(\'#ao\');7m=k(\'#cM\').B(\'3n\',\'2K\');k(\'#eK\').3x(6A);k.1v.8m=1b;if(6B)k(\'#dg\').3x(k.1v.M.d8+\' \'+(4u+1)+\' \'+k.1v.M.dc+\' \'+6B);if(4G){aX.K(0).53=u(){q.5B();k.1v.26(S,4G);E I}}if(4M){aO.K(0).53=u(){q.5B();k.1v.26(S,4M);E I}}2b.1Y();82=k.1a.2o(1Z.K(0));56=18.3r(82.1C,2b.K(0).Z+k.1v.M.2E*2);6f=18.3r(82.hb,2b.K(0).W+k.1v.M.2E*2);2b.B({O:(56-2b.K(0).Z)/2+\'U\',Q:(6f-2b.K(0).W)/2+\'U\'});1Z.B({Z:56+\'U\',W:6f+\'U\'}).1Y();dw=k.1a.bm();6F.B(\'Q\',3O.t+(dw.h/15)+\'U\');if(6F.B(\'19\')==\'1o\'){6F.1Y().7f(k.1v.M.3W)}6k=12 9s;k(6k).1p(\'id\',\'cW\').1J(\'hJ\',u(){56=6k.Z+k.1v.M.2E*2;6f=6k.W+k.1v.M.2E*2;2b.2G();1Z.5w({W:6f},82.hb!=6f?k.1v.M.3W:1,u(){1Z.5w({Z:56},82.1C!=56?k.1v.M.3W:1,u(){1Z.bG(6k);k(6k).B({Y:\'1P\',O:k.1v.M.2E+\'U\',Q:k.1v.M.2E+\'U\'}).7f(k.1v.M.3W,u(){db=k.1a.2o(7m.K(0));if(4G){aX.B({O:k.1v.M.2E+\'U\',Q:k.1v.M.2E+\'U\',Z:56/2-k.1v.M.2E*3+\'U\',W:6f-k.1v.M.2E*2+\'U\'}).1Y()}if(4M){aO.B({O:56/2+k.1v.M.2E*2+\'U\',Q:k.1v.M.2E+\'U\',Z:56/2-k.1v.M.2E*3+\'U\',W:6f-k.1v.M.2E*2+\'U\'}).1Y()}7m.B({Z:56+\'U\',Q:-db.hb+\'U\',3n:\'dd\'}).5w({Q:-1},k.1v.M.3W,u(){k.1v.8m=I})})})})});6k.2J=89},au:u(){k(\'#cW\').bk();k(\'#ao\').2G();k(\'#cM\').B(\'3n\',\'2K\');k(\'#cP\').fX(cO,0,u(){k(q).2G();if(k.3a.4t){k(\'#cN\').2G()}});k(\'#87\').K(0).53=S;k(\'#88\').K(0).53=S;k.1v.6j=S;k.1v.8k=I;k.1v.8m=I;E I}};k.R={1A:S,41:S,F:S,1s:S,1q:S,Y:S,9a:u(e){k.R.F=(q.d0)?q.d0:q;k.R.1s=k.1a.4a(e);k.R.1q={Z:T(k(k.R.F).B(\'Z\'))||0,W:T(k(k.R.F).B(\'W\'))||0};k.R.Y={Q:T(k(k.R.F).B(\'Q\'))||0,O:T(k(k.R.F).B(\'O\'))||0};k(1h).1J(\'3D\',k.R.cR).1J(\'5P\',k.R.cK);if(2g k.R.F.1k.g2===\'u\'){k.R.F.1k.g2.1D(k.R.F)}E I},cK:u(e){k(1h).3q(\'3D\',k.R.cR).3q(\'5P\',k.R.cK);if(2g k.R.F.1k.fN===\'u\'){k.R.F.1k.fN.1D(k.R.F)}k.R.F=S},cR:u(e){if(!k.R.F){E}1s=k.1a.4a(e);7p=k.R.Y.Q-k.R.1s.y+1s.y;7r=k.R.Y.O-k.R.1s.x+1s.x;7p=18.3r(18.3L(7p,k.R.F.1k.8g-k.R.1q.W),k.R.F.1k.7h);7r=18.3r(18.3L(7r,k.R.F.1k.8h-k.R.1q.Z),k.R.F.1k.70);if(2g k.R.F.1k.4m===\'u\'){D 8a=k.R.F.1k.4m.1D(k.R.F,[7r,7p]);if(2g 8a==\'hh\'&&8a.1g==2){7r=8a[0];7p=8a[1]}}k.R.F.14.Q=7p+\'U\';k.R.F.14.O=7r+\'U\';E I},26:u(e){k(1h).1J(\'3D\',k.R.8j).1J(\'5P\',k.R.8o);k.R.1A=q.1A;k.R.41=q.41;k.R.1s=k.1a.4a(e);k.R.1q={Z:T(k(q.1A).B(\'Z\'))||0,W:T(k(q.1A).B(\'W\'))||0};k.R.Y={Q:T(k(q.1A).B(\'Q\'))||0,O:T(k(q.1A).B(\'O\'))||0};if(k.R.1A.1k.4o){k.R.1A.1k.4o.1D(k.R.1A,[q])}E I},8o:u(){k(1h).3q(\'3D\',k.R.8j).3q(\'5P\',k.R.8o);if(k.R.1A.1k.3T){k.R.1A.1k.3T.1D(k.R.1A,[k.R.41])}k.R.1A=S;k.R.41=S},6i:u(dx,az){E 18.3L(18.3r(k.R.1q.Z+dx*az,k.R.1A.1k.av),k.R.1A.1k.6x)},6m:u(dy,az){E 18.3L(18.3r(k.R.1q.W+dy*az,k.R.1A.1k.8c),k.R.1A.1k.8b)},fb:u(W){E 18.3L(18.3r(W,k.R.1A.1k.8c),k.R.1A.1k.8b)},8j:u(e){if(k.R.1A==S){E}1s=k.1a.4a(e);dx=1s.x-k.R.1s.x;dy=1s.y-k.R.1s.y;1I={Z:k.R.1q.Z,W:k.R.1q.W};2z={Q:k.R.Y.Q,O:k.R.Y.O};3m(k.R.41){1e\'e\':1I.Z=k.R.6i(dx,1);1r;1e\'fj\':1I.Z=k.R.6i(dx,1);1I.W=k.R.6m(dy,1);1r;1e\'w\':1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1r;1e\'5F\':1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1I.W=k.R.6m(dy,1);1r;1e\'76\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1I.Z=k.R.6i(dx,-1);2z.O=k.R.Y.O-1I.Z+k.R.1q.Z;1r;1e\'n\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1r;1e\'at\':1I.W=k.R.6m(dy,-1);2z.Q=k.R.Y.Q-1I.W+k.R.1q.W;1I.Z=k.R.6i(dx,1);1r;1e\'s\':1I.W=k.R.6m(dy,1);1r}if(k.R.1A.1k.4v){if(k.R.41==\'n\'||k.R.41==\'s\')4p=1I.W*k.R.1A.1k.4v;P 4p=1I.Z;4W=k.R.fb(4p*k.R.1A.1k.4v);4p=4W/k.R.1A.1k.4v;3m(k.R.41){1e\'n\':1e\'76\':1e\'at\':2z.Q+=1I.W-4W;1r}3m(k.R.41){1e\'76\':1e\'w\':1e\'5F\':2z.O+=1I.Z-4p;1r}1I.W=4W;1I.Z=4p}if(2z.Qk.R.1A.1k.8g){1I.W=k.R.1A.1k.8g-2z.Q;if(k.R.1A.1k.4v){1I.Z=1I.W/k.R.1A.1k.4v}}if(2z.O+1I.Z>k.R.1A.1k.8h){1I.Z=k.R.1A.1k.8h-2z.O;if(k.R.1A.1k.4v){1I.W=1I.Z*k.R.1A.1k.4v}}D 6p=I;if(k.R.1A.1k.f7){6p=k.R.1A.1k.f7.1D(k.R.1A,[1I,2z]);if(6p){if(6p.1q){k.23(1I,6p.1q)}if(6p.Y){k.23(2z,6p.Y)}}}8d=k.R.1A.14;8d.O=2z.O+\'U\';8d.Q=2z.Q+\'U\';8d.Z=1I.Z+\'U\';8d.W=1I.W+\'U\';E I},2r:u(M){if(!M||!M.3Z||M.3Z.1K!=7M){E}E q.1E(u(){D el=q;el.1k=M;el.1k.av=M.av||10;el.1k.8c=M.8c||10;el.1k.6x=M.6x||6P;el.1k.8b=M.8b||6P;el.1k.7h=M.7h||-aC;el.1k.70=M.70||-aC;el.1k.8h=M.8h||6P;el.1k.8g=M.8g||6P;d6=k(el).B(\'Y\');if(!(d6==\'2s\'||d6==\'1P\')){el.14.Y=\'2s\'}fS=/n|at|e|fj|s|5F|w|76/g;24(i in el.1k.3Z){if(i.6c().d5(fS)!=S){if(el.1k.3Z[i].1K==b0){3v=k(el.1k.3Z[i]);if(3v.1N()>0){el.1k.3Z[i]=3v.K(0)}}if(el.1k.3Z[i].4Y){el.1k.3Z[i].1A=el;el.1k.3Z[i].41=i;k(el.1k.3Z[i]).1J(\'5v\',k.R.26)}}}if(el.1k.5S){if(2g el.1k.5S===\'4V\'){aV=k(el.1k.5S);if(aV.1N()>0){aV.1E(u(){q.d0=el});aV.1J(\'5v\',k.R.9a)}}P if(el.1k.5S==1b){k(q).1J(\'5v\',k.R.9a)}}})},4U:u(){E q.1E(u(){D el=q;24(i in el.1k.3Z){el.1k.3Z[i].1A=S;el.1k.3Z[i].41=S;k(el.1k.3Z[i]).3q(\'5v\',k.R.26)}if(el.1k.5S){if(2g el.1k.5S===\'4V\'){3v=k(el.1k.5S);if(3v.1N()>0){3v.3q(\'5v\',k.R.9a)}}P if(el.1k.5S==1b){k(q).3q(\'5v\',k.R.9a)}}el.1k=S})}};k.fn.23({hz:k.R.2r,hs:k.R.4U});k.2C=S;k.7n=I;k.3k=S;k.7o=[];k.9v=u(e){D 3K=e.7L||e.7K||-1;if(3K==17||3K==16){k.7n=1b}};k.9u=u(e){k.7n=I};k.dL=u(e){q.f.1s=k.1a.4a(e);q.f.1M=k.23(k.1a.3w(q),k.1a.2o(q));q.f.3e=k.1a.6z(q);q.f.1s.x-=q.f.1M.x;q.f.1s.y-=q.f.1M.y;k(q).1S(k.2C.K(0));if(q.f.hc)k.2C.2R(q.f.hc).B(\'19\',\'2B\');k.2C.B({19:\'2B\',Z:\'2P\',W:\'2P\'});if(q.f.o){k.2C.B(\'1G\',q.f.o)}k.3k=q;k.96=I;k.7o=[];q.f.el.1E(u(){q.1M={x:q.8t+(q.4Z&&!k.3a.7I?T(q.4Z.5b)||0:0)+(k.3k.3c||0),y:q.8G+(q.4Z&&!k.3a.7I?T(q.4Z.4S)||0:0)+(k.3k.3d||0),1C:q.4c,hb:q.5W};if(q.s==1b){if(k.7n==I){q.s=I;k(q).4i(k.3k.f.7j)}P{k.96=1b;k.7o[k.7o.1g]=k.1p(q,\'id\')}}});k.am.1D(q,[e]);k(1h).1J(\'3D\',k.am).1J(\'5P\',k.cX);E I};k.am=u(e){if(!k.3k)E;k.fd.1D(k.3k,[e])};k.fd=u(e){if(!k.3k)E;D 1s=k.1a.4a(e);D 3e=k.1a.6z(k.3k);1s.x+=3e.l-q.f.3e.l-q.f.1M.x;1s.y+=3e.t-q.f.3e.t-q.f.1M.y;D 93=18.3L(1s.x,q.f.1s.x);D 5F=18.3L(18.3S(1s.x-q.f.1s.x),18.3S(q.f.3e.w-93));D 99=18.3L(1s.y,q.f.1s.y);D 9g=18.3L(18.3S(1s.y-q.f.1s.y),18.3S(q.f.3e.h-99));if(q.3d>0&&1s.y-20q.3d+q.f.1M.h){D 3X=18.3L(q.f.3e.h-q.3d,10);q.3d+=3X;if(q.3d!=3e.t)9g+=3X}if(q.3c>0&&1s.x-20q.3c+q.f.1M.w){D 3X=18.3L(q.f.3e.w-q.3c,10);q.3c+=3X;if(q.3c!=3e.l)5F+=3X}k.2C.B({O:93+\'U\',Q:99+\'U\',Z:5F+\'U\',W:9g+\'U\'});k.2C.l=93+q.f.3e.l;k.2C.t=99+q.f.3e.t;k.2C.r=k.2C.l+5F;k.2C.b=k.2C.t+9g;k.96=I;q.f.el.1E(u(){aw=k.7o.3J(k.1p(q,\'id\'));if(!(q.1M.x>k.2C.r||(q.1M.x+q.1M.1C)k.2C.b||(q.1M.y+q.1M.hb)0){h+=\'&\'}h+=s+\'[]=\'+k.1p(q,\'id\');o[o.1g]=k.1p(q,\'id\')}})}E{7l:h,o:o}};k.fn.gZ=u(o){if(!k.2C){k(\'2e\',1h).1S(\'<22 id="2C">\').1J(\'7B\',k.9v).1J(\'6y\',k.9u);k.2C=k(\'#2C\');k.2C.B({Y:\'1P\',19:\'1o\'});if(1X.2k){k(\'2e\',1h).1J(\'7B\',k.9v).1J(\'6y\',k.9u)}P{k(1h).1J(\'7B\',k.9v).1J(\'6y\',k.9u)}}if(!o){o={}}E q.1E(u(){if(q.eP)E;q.eP=1b;q.f={a:o.3C,o:o.1G?2m(o.1G):I,7j:o.eS?o.eS:I,hc:o.58?o.58:I,98:o.98?o.98:I,9d:o.9d?o.9d:I};q.f.el=k(\'.\'+o.3C);k(q).1J(\'5v\',k.dL).B(\'Y\',\'2s\')})};k.3b={bM:1,eH:u(3t){D 3t=3t;E q.1E(u(){q.4z.6s.1E(u(ab){k.3b.5c(q,3t[ab])})})},K:u(){D 3t=[];q.1E(u(cL){if(q.bI){3t[cL]=[];D C=q;D 1q=k.1a.2o(q);q.4z.6s.1E(u(ab){D x=q.8t;D y=q.8G;92=T(x*2a/(1q.w-q.4c));91=T(y*2a/(1q.h-q.5W));3t[cL][ab]=[92||0,91||0,x||0,y||0]})}});E 3t},ct:u(C){C.A.fu=C.A.28.w-C.A.1B.1C;C.A.fw=C.A.28.h-C.A.1B.hb;if(C.9r.4z.bC){9Z=C.9r.4z.6s.K(C.bF+1);if(9Z){C.A.28.w=(T(k(9Z).B(\'O\'))||0)+C.A.1B.1C;C.A.28.h=(T(k(9Z).B(\'Q\'))||0)+C.A.1B.hb}9Q=C.9r.4z.6s.K(C.bF-1);if(9Q){D cU=T(k(9Q).B(\'O\'))||0;D cH=T(k(9Q).B(\'O\'))||0;C.A.28.x+=cU;C.A.28.y+=cH;C.A.28.w-=cU;C.A.28.h-=cH}}C.A.g7=C.A.28.w-C.A.1B.1C;C.A.eC=C.A.28.h-C.A.1B.hb;if(C.A.2O){C.A.gx=((C.A.28.w-C.A.1B.1C)/C.A.2O)||1;C.A.gy=((C.A.28.h-C.A.1B.hb)/C.A.2O)||1;C.A.fU=C.A.g7/C.A.2O;C.A.fH=C.A.eC/C.A.2O}C.A.28.dx=C.A.28.x-C.A.2c.x;C.A.28.dy=C.A.28.y-C.A.2c.y;k.11.1c.B(\'9b\',\'ad\')},3H:u(C,x,y){if(C.A.2O){fE=T(x/C.A.fU);92=fE*2a/C.A.2O;ft=T(y/C.A.fH);91=ft*2a/C.A.2O}P{92=T(x*2a/C.A.fu);91=T(y*2a/C.A.fw)}C.A.b3=[92||0,91||0,x||0,y||0];if(C.A.3H)C.A.3H.1D(C,C.A.b3)},eI:u(2k){3K=2k.7L||2k.7K||-1;3m(3K){1e 35:k.3b.5c(q.3U,[ae,ae]);1r;1e 36:k.3b.5c(q.3U,[-ae,-ae]);1r;1e 37:k.3b.5c(q.3U,[-q.3U.A.gx||-1,0]);1r;1e 38:k.3b.5c(q.3U,[0,-q.3U.A.gy||-1]);1r;1e 39:k.3b.5c(q.3U,[q.3U.A.gx||1,0]);1r;1e 40:k.11.5c(q.3U,[0,q.3U.A.gy||1]);1r}},5c:u(C,Y){if(!C.A){E}C.A.1B=k.23(k.1a.3w(C),k.1a.2o(C));C.A.2c={x:T(k.B(C,\'O\'))||0,y:T(k.B(C,\'Q\'))||0};C.A.4n=k.B(C,\'Y\');if(C.A.4n!=\'2s\'&&C.A.4n!=\'1P\'){C.14.Y=\'2s\'}k.11.c5(C);k.3b.ct(C);dx=T(Y[0])||0;dy=T(Y[1])||0;2v=C.A.2c.x+dx;2q=C.A.2c.y+dy;if(C.A.2O){3y=k.11.c7.1D(C,[2v,2q,dx,dy]);if(3y.1K==7M){dx=3y.dx;dy=3y.dy}2v=C.A.2c.x+dx;2q=C.A.2c.y+dy}3y=k.11.ce.1D(C,[2v,2q,dx,dy]);if(3y&&3y.1K==7M){dx=3y.dx;dy=3y.dy}2v=C.A.2c.x+dx;2q=C.A.2c.y+dy;if(C.A.5i&&(C.A.3H||C.A.2Z)){k.3b.3H(C,2v,2q)}2v=!C.A.1O||C.A.1O==\'4j\'?2v:C.A.2c.x||0;2q=!C.A.1O||C.A.1O==\'49\'?2q:C.A.2c.y||0;C.14.O=2v+\'U\';C.14.Q=2q+\'U\'},2r:u(o){E q.1E(u(){if(q.bI==1b||!o.3C||!k.1a||!k.11||!k.1x){E}5x=k(o.3C,q);if(5x.1N()==0){E}D 4N={2p:\'94\',5i:1b,3H:o.3H&&o.3H.1K==2A?o.3H:S,2Z:o.2Z&&o.2Z.1K==2A?o.2Z:S,3v:q,1G:o.1G||I};if(o.2O&&T(o.2O)){4N.2O=T(o.2O)||1;4N.2O=4N.2O>0?4N.2O:1}if(5x.1N()==1)5x.7t(4N);P{k(5x.K(0)).7t(4N);4N.3v=S;5x.7t(4N)}5x.7B(k.3b.eI);5x.1p(\'bM\',k.3b.bM++);q.bI=1b;q.4z={};q.4z.er=4N.er;q.4z.2O=4N.2O;q.4z.6s=5x;q.4z.bC=o.bC?1b:I;bZ=q;bZ.4z.6s.1E(u(2N){q.bF=2N;q.9r=bZ});if(o.3t&&o.3t.1K==7F){24(i=o.3t.1g-1;i>=0;i--){if(o.3t[i].1K==7F&&o.3t[i].1g==2){el=q.4z.6s.K(i);if(el.4Y){k.3b.5c(el,o.3t[i])}}}}})}};k.fn.23({hN:k.3b.2r,hS:k.3b.eH,hG:k.3b.K});k.2u={5I:[],eg:u(){q.5B();X=q.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}1z=X.L.3u+1;if(X.L.1Q.1g<1z){1z=1}1Q=k(\'1T\',X.L.5u);X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},dp:u(){q.5B();X=q.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}1z=X.L.3u-1;1Q=k(\'1T\',X.L.5u);if(1z<1){1z=X.L.1Q.1g}X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},2I:u(c){X=1h.9e(c);if(X.L.6o){1z=X.L.3u;7d(1z==X.L.3u){1z=1+T(18.6o()*X.L.1Q.1g)}}P{1z=X.L.3u+1;if(X.L.1Q.1g<1z){1z=1}}1Q=k(\'1T\',X.L.5u);X.L.3u=1z;if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}},go:u(o){D X;if(o&&o.1K==7M){if(o.2b){X=1h.9e(o.2b.X);5N=1X.hn.3h.7C("#");o.2b.6S=S;if(5N.1g==2){1z=T(5N[1]);1Y=5N[1].4E(1z,\'\');if(k.1p(X,\'id\')!=1Y){1z=1}}P{1z=1}}if(o.90){o.90.5B();X=o.90.31.31;id=k.1p(X,\'id\');if(k.2u.5I[id]!=S){1X.5T(k.2u.5I[id])}5N=o.90.3h.7C("#");1z=T(5N[1]);1Y=5N[1].4E(1z,\'\');if(k.1p(X,\'id\')!=1Y){1z=1}}if(X.L.1Q.1g<1z||1z<1){1z=1}X.L.3u=1z;52=k.1a.2o(X);dt=k.1a.aT(X);d9=k.1a.6U(X);if(X.L.3z){X.L.3z.o.B(\'19\',\'1o\')}if(X.L.3s){X.L.3s.o.B(\'19\',\'1o\')}if(X.L.2b){y=T(dt.t)+T(d9.t);if(X.L.1U){if(X.L.1U.5A==\'Q\'){y+=X.L.1U.4C.hb}P{52.h-=X.L.1U.4C.hb}}if(X.L.2x){if(X.L.2x&&X.L.2x.6Q==\'Q\'){y+=X.L.2x.4C.hb}P{52.h-=X.L.2x.4C.hb}}if(!X.L.c1){X.L.df=o.2b?o.2b.W:(T(X.L.2b.B(\'W\'))||0);X.L.c1=o.2b?o.2b.Z:(T(X.L.2b.B(\'Z\'))||0)}X.L.2b.B(\'Q\',y+(52.h-X.L.df)/2+\'U\');X.L.2b.B(\'O\',(52.1C-X.L.c1)/2+\'U\');X.L.2b.B(\'19\',\'2B\')}1Q=k(\'1T\',X.L.5u);if(1Q.1N()>0){1Q.7a(X.L.3W,k.2u.95)}P{aj=k(\'a\',X.L.1U.o).K(1z-1);k(aj).2R(X.L.1U.5R);D 1T=12 9s();1T.X=k.1p(X,\'id\');1T.1z=1z-1;1T.2J=X.L.1Q[X.L.3u-1].2J;if(1T.21){1T.6S=S;k.2u.19.1D(1T)}P{1T.6S=k.2u.19}if(X.L.2x){X.L.2x.o.3x(X.L.1Q[1z-1].6L)}}}},95:u(){X=q.31.31;X.L.5u.B(\'19\',\'1o\');if(X.L.1U.5R){aj=k(\'a\',X.L.1U.o).4i(X.L.1U.5R).K(X.L.3u-1);k(aj).2R(X.L.1U.5R)}D 1T=12 9s();1T.X=k.1p(X,\'id\');1T.1z=X.L.3u-1;1T.2J=X.L.1Q[X.L.3u-1].2J;if(1T.21){1T.6S=S;k.2u.19.1D(1T)}P{1T.6S=k.2u.19}if(X.L.2x){X.L.2x.o.3x(X.L.1Q[X.L.3u-1].6L)}},19:u(){X=1h.9e(q.X);if(X.L.3z){X.L.3z.o.B(\'19\',\'1o\')}if(X.L.3s){X.L.3s.o.B(\'19\',\'1o\')}52=k.1a.2o(X);y=0;if(X.L.1U){if(X.L.1U.5A==\'Q\'){y+=X.L.1U.4C.hb}P{52.h-=X.L.1U.4C.hb}}if(X.L.2x){if(X.L.2x&&X.L.2x.6Q==\'Q\'){y+=X.L.2x.4C.hb}P{52.h-=X.L.2x.4C.hb}}hg=k(\'.ca\',X);y=y+(52.h-q.W)/2;x=(52.1C-q.Z)/2;X.L.5u.B(\'Q\',y+\'U\').B(\'O\',x+\'U\').3x(\'<1T 2J="\'+q.2J+\'" />\');X.L.5u.7f(X.L.3W);3s=X.L.3u+1;if(3s>X.L.1Q.1g){3s=1}3z=X.L.3u-1;if(3z<1){3z=X.L.1Q.1g}X.L.3s.o.B(\'19\',\'2B\').B(\'Q\',y+\'U\').B(\'O\',x+2*q.Z/3+\'U\').B(\'Z\',q.Z/3+\'U\').B(\'W\',q.W+\'U\').1p(\'4g\',X.L.1Q[3s-1].6L);X.L.3s.o.K(0).3h=\'#\'+3s+k.1p(X,\'id\');X.L.3z.o.B(\'19\',\'2B\').B(\'Q\',y+\'U\').B(\'O\',x+\'U\').B(\'Z\',q.Z/3+\'U\').B(\'W\',q.W+\'U\').1p(\'4g\',X.L.1Q[3z-1].6L);X.L.3z.o.K(0).3h=\'#\'+3z+k.1p(X,\'id\')},2r:u(o){if(!o||!o.1Z||k.2u.5I[o.1Z])E;D 1Z=k(\'#\'+o.1Z);D el=1Z.K(0);if(el.14.Y!=\'1P\'&&el.14.Y!=\'2s\'){el.14.Y=\'2s\'}el.14.2U=\'2K\';if(1Z.1N()==0)E;el.L={};el.L.1Q=o.1Q?o.1Q:[];el.L.6o=o.6o&&o.6o==1b||I;97=el.f3(\'hL\');24(i=0;i<97.1g;i++){7Z=el.L.1Q.1g;el.L.1Q[7Z]={2J:97[i].2J,6L:97[i].4g||97[i].hD||\'\'}}if(el.L.1Q.1g==0){E}el.L.4n=k.23(k.1a.3w(el),k.1a.2o(el));el.L.b5=k.1a.aT(el);el.L.bu=k.1a.6U(el);t=T(el.L.b5.t)+T(el.L.bu.t);b=T(el.L.b5.b)+T(el.L.bu.b);k(\'1T\',el).bk();el.L.3W=o.3W?o.3W:g5;if(o.5A||o.9f||o.5R){el.L.1U={};1Z.1S(\'<22 6T="g1">\');el.L.1U.o=k(\'.g1\',el);if(o.9f){el.L.1U.9f=o.9f;el.L.1U.o.2R(o.9f)}if(o.5R){el.L.1U.5R=o.5R}el.L.1U.o.B(\'Y\',\'1P\').B(\'Z\',el.L.4n.w+\'U\');if(o.5A&&o.5A==\'Q\'){el.L.1U.5A=\'Q\';el.L.1U.o.B(\'Q\',t+\'U\')}P{el.L.1U.5A=\'4D\';el.L.1U.o.B(\'4D\',b+\'U\')}el.L.1U.aE=o.aE?o.aE:\' \';24(D i=0;i\'+7Z+\'\'+(7Z!=el.L.1Q.1g?el.L.1U.aE:\'\'))}k(\'a\',el.L.1U.o).1J(\'5h\',u(){k.2u.go({90:q})});el.L.1U.4C=k.1a.2o(el.L.1U.o.K(0))}if(o.6Q||o.9c){el.L.2x={};1Z.1S(\'<22 6T="dn">&7k;\');el.L.2x.o=k(\'.dn\',el);if(o.9c){el.L.2x.9c=o.9c;el.L.2x.o.2R(o.9c)}el.L.2x.o.B(\'Y\',\'1P\').B(\'Z\',el.L.4n.w+\'U\');if(o.6Q&&o.6Q==\'Q\'){el.L.2x.6Q=\'Q\';el.L.2x.o.B(\'Q\',(el.L.1U&&el.L.1U.5A==\'Q\'?el.L.1U.4C.hb+t:t)+\'U\')}P{el.L.2x.6Q=\'4D\';el.L.2x.o.B(\'4D\',(el.L.1U&&el.L.1U.5A==\'4D\'?el.L.1U.4C.hb+b:b)+\'U\')}el.L.2x.4C=k.1a.2o(el.L.2x.o.K(0))}if(o.9D){el.L.3s={9D:o.9D};1Z.1S(\'&7k;\');el.L.3s.o=k(\'.eY\',el);el.L.3s.o.B(\'Y\',\'1P\').B(\'19\',\'1o\').B(\'2U\',\'2K\').B(\'4A\',\'eR\').2R(el.L.3s.9D);el.L.3s.o.1J(\'5h\',k.2u.eg)}if(o.9o){el.L.3z={9o:o.9o};1Z.1S(\'&7k;\');el.L.3z.o=k(\'.ee\',el);el.L.3z.o.B(\'Y\',\'1P\').B(\'19\',\'1o\').B(\'2U\',\'2K\').B(\'4A\',\'eR\').2R(el.L.3z.9o);el.L.3z.o.1J(\'5h\',k.2u.dp)}1Z.bG(\'<22 6T="ca">\');el.L.5u=k(\'.ca\',el);el.L.5u.B(\'Y\',\'1P\').B(\'Q\',\'2P\').B(\'O\',\'2P\').B(\'19\',\'1o\');if(o.2b){1Z.bG(\'<22 6T="dW" 14="19: 1o;"><1T 2J="\'+o.2b+\'" />\');el.L.2b=k(\'.dW\',el);el.L.2b.B(\'Y\',\'1P\');D 1T=12 9s();1T.X=o.1Z;1T.2J=o.2b;if(1T.21){1T.6S=S;k.2u.go({2b:1T})}P{1T.6S=u(){k.2u.go({2b:q})}}}P{k.2u.go({1Z:el})}if(o.cS){fi=T(o.cS)*aC}k.2u.5I[o.1Z]=o.cS?1X.6V(\'k.2u.2I(\\\'\'+o.1Z+\'\\\')\',fi):S}};k.X=k.2u.2r;k.1t={7s:[],5L:{},1c:I,7u:S,26:u(){if(k.11.F==S){E}D 4O,3G,c,cs;k.1t.1c.K(0).3l=k.11.F.A.6R;4O=k.1t.1c.K(0).14;4O.19=\'2B\';k.1t.1c.1B=k.23(k.1a.3w(k.1t.1c.K(0)),k.1a.2o(k.1t.1c.K(0)));4O.Z=k.11.F.A.1B.1C+\'U\';4O.W=k.11.F.A.1B.hb+\'U\';3G=k.1a.cy(k.11.F);4O.5K=3G.t;4O.5z=3G.r;4O.5k=3G.b;4O.5j=3G.l;if(k.11.F.A.46==1b){c=k.11.F.fI(1b);cs=c.14;cs.5K=\'2P\';cs.5z=\'2P\';cs.5k=\'2P\';cs.5j=\'2P\';cs.19=\'2B\';k.1t.1c.5o().1S(c)}k(k.11.F).f5(k.1t.1c.K(0));k.11.F.14.19=\'1o\'},fC:u(e){if(!e.A.44&&k.1x.5r.cQ){if(e.A.3T)e.A.3T.1D(F);k(e).B(\'Y\',e.A.cz||e.A.4n);k(e).aS();k(k.1x.5r).f6(e)}k.1t.1c.4i(e.A.6R).3x(\'&7k;\');k.1t.7u=S;D 4O=k.1t.1c.K(0).14;4O.19=\'1o\';k.1t.1c.f5(e);if(e.A.fx>0){k(e).7f(e.A.fx)}k(\'2e\').1S(k.1t.1c.K(0));D 86=[];D 8q=I;24(D i=0;i0){8q(86)}},al:u(e,o){if(!k.11.F)E;D 6e=I;D i=0;if(e.1i.el.1N()>0){24(i=e.1i.el.1N();i>0;i--){if(e.1i.el.K(i-1)!=k.11.F){if(!e.5V.b2){if((e.1i.el.K(i-1).1M.y+e.1i.el.K(i-1).1M.hb/2)>k.11.F.A.2q){6e=e.1i.el.K(i-1)}P{1r}}P{if((e.1i.el.K(i-1).1M.x+e.1i.el.K(i-1).1M.1C/2)>k.11.F.A.2v&&(e.1i.el.K(i-1).1M.y+e.1i.el.K(i-1).1M.hb/2)>k.11.F.A.2q){6e=e.1i.el.K(i-1)}}}}}if(6e&&k.1t.7u!=6e){k.1t.7u=6e;k(6e).h5(k.1t.1c.K(0))}P if(!6e&&(k.1t.7u!=S||k.1t.1c.K(0).31!=e)){k.1t.7u=S;k(e).1S(k.1t.1c.K(0))}k.1t.1c.K(0).14.19=\'2B\'},cT:u(e){if(k.11.F==S){E}e.1i.el.1E(u(){q.1M=k.23(k.1a.74(q),k.1a.7G(q))})},8x:u(s){D i;D h=\'\';D o={};if(s){if(k.1t.5L[s]){o[s]=[];k(\'#\'+s+\' .\'+k.1t.5L[s]).1E(u(){if(h.1g>0){h+=\'&\'}h+=s+\'[]=\'+k.1p(q,\'id\');o[s][o[s].1g]=k.1p(q,\'id\')})}P{24(a in s){if(k.1t.5L[s[a]]){o[s[a]]=[];k(\'#\'+s[a]+\' .\'+k.1t.5L[s[a]]).1E(u(){if(h.1g>0){h+=\'&\'}h+=s[a]+\'[]=\'+k.1p(q,\'id\');o[s[a]][o[s[a]].1g]=k.1p(q,\'id\')})}}}}P{24(i in k.1t.5L){o[i]=[];k(\'#\'+i+\' .\'+k.1t.5L[i]).1E(u(){if(h.1g>0){h+=\'&\'}h+=i+\'[]=\'+k.1p(q,\'id\');o[i][o[i].1g]=k.1p(q,\'id\')})}}E{7l:h,o:o}},fF:u(e){if(!e.dq){E}E q.1E(u(){if(!q.5V||!k(e).is(\'.\'+q.5V.3C))k(e).2R(q.5V.3C);k(e).7t(q.5V.A)})},4U:u(){E q.1E(u(){k(\'.\'+q.5V.3C).aS();k(q).dR();q.5V=S;q.fm=S})},2r:u(o){if(o.3C&&k.1a&&k.11&&k.1x){if(!k.1t.1c){k(\'2e\',1h).1S(\'<22 id="e5">&7k;\');k.1t.1c=k(\'#e5\');k.1t.1c.K(0).14.19=\'1o\'}q.do({3C:o.3C,9J:o.9J?o.9J:I,a5:o.a5?o.a5:I,58:o.58?o.58:I,7x:o.7x||o.dC,7y:o.7y||o.fO,cQ:1b,2Z:o.2Z||o.ia,fx:o.fx?o.fx:I,46:o.46?1b:I,6I:o.6I?o.6I:\'cV\'});E q.1E(u(){D A={6N:o.6N?1b:I,ff:6P,1G:o.1G?2m(o.1G):I,6R:o.58?o.58:I,fx:o.fx?o.fx:I,44:1b,46:o.46?1b:I,3v:o.3v?o.3v:S,2p:o.2p?o.2p:S,4o:o.4o&&o.4o.1K==2A?o.4o:I,4m:o.4m&&o.4m.1K==2A?o.4m:I,3T:o.3T&&o.3T.1K==2A?o.3T:I,1O:/49|4j/.48(o.1O)?o.1O:I,6M:o.6M?T(o.6M)||0:I,2V:o.2V?o.2V:I};k(\'.\'+o.3C,q).7t(A);q.fm=1b;q.5V={3C:o.3C,6N:o.6N?1b:I,ff:6P,1G:o.1G?2m(o.1G):I,6R:o.58?o.58:I,fx:o.fx?o.fx:I,44:1b,46:o.46?1b:I,3v:o.3v?o.3v:S,2p:o.2p?o.2p:S,b2:o.b2?1b:I,A:A}})}}};k.fn.23({j3:k.1t.2r,f6:k.1t.fF,iS:k.1t.4U});k.iZ=k.1t.8x;k.2t={6O:S,7b:I,9m:S,6K:u(e){k.2t.7b=1b;k.2t.1Y(e,q,1b)},cq:u(e){if(k.2t.6O!=q)E;k.2t.7b=I;k.2t.2G(e,q)},1Y:u(e,el,7b){if(k.2t.6O!=S)E;if(!el){el=q}k.2t.6O=el;1M=k.23(k.1a.3w(el),k.1a.2o(el));8u=k(el);4g=8u.1p(\'4g\');3h=8u.1p(\'3h\');if(4g){k.2t.9m=4g;8u.1p(\'4g\',\'\');k(\'#eT\').3x(4g);if(3h)k(\'#bL\').3x(3h.4E(\'jh://\',\'\'));P k(\'#bL\').3x(\'\');1c=k(\'#8z\');if(el.4H.3l){1c.K(0).3l=el.4H.3l}P{1c.K(0).3l=\'\'}bo=k.1a.2o(1c.K(0));ga=7b&&el.4H.Y==\'bO\'?\'4D\':el.4H.Y;3m(ga){1e\'Q\':2q=1M.y-bo.hb;2v=1M.x;1r;1e\'O\':2q=1M.y;2v=1M.x-bo.1C;1r;1e\'2L\':2q=1M.y;2v=1M.x+1M.1C;1r;1e\'bO\':k(\'2e\').1J(\'3D\',k.2t.3D);1s=k.1a.4a(e);2q=1s.y+15;2v=1s.x+15;1r;ad:2q=1M.y+1M.hb;2v=1M.x;1r}1c.B({Q:2q+\'U\',O:2v+\'U\'});if(el.4H.54==I){1c.1Y()}P{1c.7f(el.4H.54)}if(el.4H.2Y)el.4H.2Y.1D(el);8u.1J(\'8B\',k.2t.2G).1J(\'5B\',k.2t.cq)}},3D:u(e){if(k.2t.6O==S){k(\'2e\').3q(\'3D\',k.2t.3D);E}1s=k.1a.4a(e);k(\'#8z\').B({Q:1s.y+15+\'U\',O:1s.x+15+\'U\'})},2G:u(e,el){if(!el){el=q}if(k.2t.7b!=1b&&k.2t.6O==el){k.2t.6O=S;k(\'#8z\').7a(1);k(el).1p(\'4g\',k.2t.9m).3q(\'8B\',k.2t.2G).3q(\'5B\',k.2t.cq);if(el.4H.3i)el.4H.3i.1D(el);k.2t.9m=S}},2r:u(M){if(!k.2t.1c){k(\'2e\').1S(\'<22 id="8z"><22 id="eT"><22 id="bL">\');k(\'#8z\').B({Y:\'1P\',3I:6P,19:\'1o\'});k.2t.1c=1b}E q.1E(u(){if(k.1p(q,\'4g\')){q.4H={Y:/Q|4D|O|2L|bO/.48(M.Y)?M.Y:\'4D\',3l:M.3l?M.3l:I,54:M.54?M.54:I,2Y:M.2Y&&M.2Y.1K==2A?M.2Y:I,3i:M.3i&&M.3i.1K==2A?M.3i:I};D el=k(q);el.1J(\'9z\',k.2t.1Y);el.1J(\'6K\',k.2t.6K)}})}};k.fn.hO=k.2t.2r;k.84={bq:u(e){3K=e.7L||e.7K||-1;if(3K==9){if(1X.2k){1X.2k.bT=1b;1X.2k.c0=I}P{e.aP();e.aW()}if(q.b1){1h.6J.dZ().3g="\\t";q.dV=u(){q.6K();q.dV=S}}P if(q.aF){26=q.5q;2T=q.dN;q.2y=q.2y.hd(0,26)+"\\t"+q.2y.h8(2T);q.aF(26+1,26+1);q.6K()}E I}},4U:u(){E q.1E(u(){if(q.7P&&q.7P==1b){k(q).3q(\'7B\',k.84.bq);q.7P=I}})},2r:u(){E q.1E(u(){if(q.4Y==\'cf\'&&(!q.7P||q.7P==I)){k(q).1J(\'7B\',k.84.bq);q.7P=1b}})}};k.fn.23({j5:k.84.2r,hH:k.84.4U});k.1a={3w:u(e){D x=0;D y=0;D es=e.14;D bP=I;if(k(e).B(\'19\')==\'1o\'){D 5Y=es.3n;D 9q=es.Y;bP=1b;es.3n=\'2K\';es.19=\'2B\';es.Y=\'1P\'}D el=e;7d(el){x+=el.8t+(el.4Z&&!k.3a.7I?T(el.4Z.5b)||0:0);y+=el.8G+(el.4Z&&!k.3a.7I?T(el.4Z.4S)||0:0);el=el.dJ}el=e;7d(el&&el.4Y&&el.4Y.6c()!=\'2e\'){x-=el.3c||0;y-=el.3d||0;el=el.31}if(bP==1b){es.19=\'1o\';es.Y=9q;es.3n=5Y}E{x:x,y:y}},7G:u(el){D x=0,y=0;7d(el){x+=el.8t||0;y+=el.8G||0;el=el.dJ}E{x:x,y:y}},2o:u(e){D w=k.B(e,\'Z\');D h=k.B(e,\'W\');D 1C=0;D hb=0;D es=e.14;if(k(e).B(\'19\')!=\'1o\'){1C=e.4c;hb=e.5W}P{D 5Y=es.3n;D 9q=es.Y;es.3n=\'2K\';es.19=\'2B\';es.Y=\'1P\';1C=e.4c;hb=e.5W;es.19=\'1o\';es.Y=9q;es.3n=5Y}E{w:w,h:h,1C:1C,hb:hb}},74:u(el){E{1C:el.4c||0,hb:el.5W||0}},bm:u(e){D h,w,de;if(e){w=e.8W;h=e.8O}P{de=1h.5d;w=1X.d4||aa.d4||(de&&de.8W)||1h.2e.8W;h=1X.cB||aa.cB||(de&&de.8O)||1h.2e.8O}E{w:w,h:h}},6z:u(e){D t=0,l=0,w=0,h=0,iw=0,ih=0;if(e&&e.9N.6c()!=\'2e\'){t=e.3d;l=e.3c;w=e.d7;h=e.d2;iw=0;ih=0}P{if(1h.5d){t=1h.5d.3d;l=1h.5d.3c;w=1h.5d.d7;h=1h.5d.d2}P if(1h.2e){t=1h.2e.3d;l=1h.2e.3c;w=1h.2e.d7;h=1h.2e.d2}iw=aa.d4||1h.5d.8W||1h.2e.8W||0;ih=aa.cB||1h.5d.8O||1h.2e.8O||0}E{t:t,l:l,w:w,h:h,iw:iw,ih:ih}},cy:u(e,7N){D el=k(e);D t=el.B(\'5K\')||\'\';D r=el.B(\'5z\')||\'\';D b=el.B(\'5k\')||\'\';D l=el.B(\'5j\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)};P E{t:t,r:r,b:b,l:l}},aT:u(e,7N){D el=k(e);D t=el.B(\'5M\')||\'\';D r=el.B(\'5U\')||\'\';D b=el.B(\'5n\')||\'\';D l=el.B(\'4X\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)};P E{t:t,r:r,b:b,l:l}},6U:u(e,7N){D el=k(e);D t=el.B(\'4S\')||\'\';D r=el.B(\'5O\')||\'\';D b=el.B(\'5Q\')||\'\';D l=el.B(\'5b\')||\'\';if(7N)E{t:T(t)||0,r:T(r)||0,b:T(b)||0,l:T(l)||0};P E{t:t,r:r,b:b,l:l}},4a:u(2k){D x=2k.hT||(2k.gM+(1h.5d.3c||1h.2e.3c))||0;D y=2k.ki||(2k.iQ+(1h.5d.3d||1h.2e.3d))||0;E{x:x,y:y}},cI:u(4R,cx){cx(4R);4R=4R.7c;7d(4R){k.1a.cI(4R,cx);4R=4R.hQ}},h7:u(4R){k.1a.cI(4R,u(el){24(D 1p in el){if(2g el[1p]===\'u\'){el[1p]=S}}})},hV:u(el,1O){D 5l=k.1a.6z();D b6=k.1a.2o(el);if(!1O||1O==\'49\')k(el).B({Q:5l.t+((18.3r(5l.h,5l.ih)-5l.t-b6.hb)/2)+\'U\'});if(!1O||1O==\'4j\')k(el).B({O:5l.l+((18.3r(5l.w,5l.iw)-5l.l-b6.1C)/2)+\'U\'})},hW:u(el,dk){D 1Q=k(\'1T[@2J*="8X"]\',el||1h),8X;1Q.1E(u(){8X=q.2J;q.2J=dk;q.14.5E="9n:9w.9y.hE(2J=\'"+8X+"\')"})}};[].3J||(7F.hF.3J=u(v,n){n=(n==S)?0:n;D m=q.1g;24(D i=n;i35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('A.cP={2l:C(c){G B.1y(C(){if(!c.8Y||!c.8P)G;F b=B;b.2a={9M:c.9M||bz,8Y:c.8Y,8P:c.8P,7R:c.7R||\'du\',9c:c.9c||\'du\',2K:c.2K&&28 c.2K==\'C\'?c.2K:H,2V:c.2K&&28 c.2V==\'C\'?c.2V:H,6D:c.6D&&28 c.6D==\'C\'?c.6D:H,8A:A(c.8Y,B),8a:A(c.8P,B),1l:c.1l||7n,5w:c.5w||0};b.2a.8a.2x().E(\'S\',\'9e\').eq(0).E({S:b.2a.9M+\'Q\',11:\'2v\'}).3m();b.2a.8A.1y(C(a){B.6L=a}).ht(C(){A(B).2H(b.2a.9c)},C(){A(B).3S(b.2a.9c)}).1C(\'4U\',C(e){if(b.2a.5w==B.6L)G;b.2a.8A.eq(b.2a.5w).3S(b.2a.7R).3m().eq(B.6L).2H(b.2a.7R).3m();b.2a.8a.eq(b.2a.5w).4S({S:0},b.2a.1l,C(){B.Y.11=\'1k\';if(b.2a.2V){b.2a.2V.1x(b,[B])}}).3m().eq(B.6L).1S().4S({S:b.2a.9M},b.2a.1l,C(){B.Y.11=\'2v\';if(b.2a.2K){b.2a.2K.1x(b,[B])}}).3m();if(b.2a.6D){b.2a.6D.1x(b,[B,b.2a.8a.I(B.6L),b.2a.8A.I(b.2a.5w),b.2a.8a.I(b.2a.5w)])}b.2a.5w=B.6L}).eq(0).2H(b.2a.7R).3m();A(B).E(\'S\',A(B).E(\'S\')).E(\'2N\',\'2B\')})}};A.fn.fe=A.cP.2l;A.8p={2l:C(h){G B.1y(C(){F c=B;F d=2*Z.2F/eD;F f=2*Z.2F;if(A(c).E(\'T\')!=\'2i\'&&A(c).E(\'T\')!=\'1J\'){A(c).E(\'T\',\'2i\')}c.1i={1M:A(h.1M,B),2y:h.2y,61:h.61,9l:h.9l,iu:f,1N:A.12.2f(B),T:A.12.3a(B),2b:Z.2F/2,b4:h.b4,7K:h.5U,5U:[],93:H,7G:2*Z.2F/eD};c.1i.d8=(c.1i.1N.w-c.1i.2y)/2;c.1i.6Y=(c.1i.1N.h-c.1i.61-c.1i.61*c.1i.7K)/2;c.1i.3f=2*Z.2F/c.1i.1M.1N();c.1i.aS=c.1i.1N.w/2;c.1i.aR=c.1i.1N.h/2-c.1i.61*c.1i.7K;F g=1c.3x(\'1W\');A(g).E({T:\'1J\',3j:1,O:0,M:0});A(c).1L(g);c.1i.1M.1y(C(a){8G=A(\'3O\',B).I(0);S=R(c.1i.61*c.1i.7K);if(A.2R.46){3u=1c.3x(\'3O\');A(3u).E(\'T\',\'1J\');3u.2E=8G.2E;3u.Y.4X=\'fu 9x:9C.9E.a6(1E=60, Y=1, fc=0, f9=0, f5=0, f3=0)\'}L{3u=1c.3x(\'3u\');if(3u.bZ){4j=3u.bZ("2d");3u.Y.T=\'1J\';3u.Y.S=S+\'Q\';3u.Y.V=c.1i.2y+\'Q\';3u.S=S;3u.V=c.1i.2y;4j.eR();4j.eM(0,S);4j.eJ(1,-1);4j.jm(8G,0,0,c.1i.2y,S);4j.bL();4j.jl="jh-3U";F b=4j.jf(0,0,0,S);b.es(1,"eg(1O, 1O, 1O, 1)");b.es(0,"eg(1O, 1O, 1O, 0.6)");4j.j9=b;if(j7.j5.3o(\'iX\')!=-1){4j.iV()}L{4j.iS(0,0,c.1i.2y,S)}}}c.1i.5U[a]=3u;A(g).1L(3u)}).1C(\'9r\',C(e){c.1i.93=14;c.1i.1l=c.1i.7G*0.1*c.1i.1l/Z.3B(c.1i.1l);G H}).1C(\'86\',C(e){c.1i.93=H;G H});A.8p.6z(c);c.1i.1l=c.1i.7G*0.2;c.1i.it=1P.5Y(C(){c.1i.2b+=c.1i.1l;if(c.1i.2b>f)c.1i.2b=0;A.8p.6z(c)},20);A(c).1C(\'86\',C(){c.1i.1l=c.1i.7G*0.2*c.1i.1l/Z.3B(c.1i.1l)}).1C(\'3t\',C(e){if(c.1i.93==H){1A=A.12.3W(e);dr=c.1i.1N.w-1A.x+c.1i.T.x;c.1i.1l=c.1i.b4*c.1i.7G*(c.1i.1N.w/2-dr)/(c.1i.1N.w/2)}})})},6z:C(b){b.1i.1M.1y(C(a){b8=b.1i.2b+a*b.1i.3f;x=b.1i.d8*Z.51(b8);y=b.1i.6Y*Z.7L(b8);do=R(1Y*(b.1i.6Y+y)/(2*b.1i.6Y));dm=(b.1i.6Y+y)/(2*b.1i.6Y);V=R((b.1i.2y-b.1i.9l)*dm+b.1i.9l);S=R(V*b.1i.61/b.1i.2y);B.Y.O=b.1i.aR+y-S/2+"Q";B.Y.M=b.1i.aS+x-V/2+"Q";B.Y.V=V+"Q";B.Y.S=S+"Q";B.Y.3j=do;b.1i.5U[a].Y.O=R(b.1i.aR+y+S-1-S/2)+"Q";b.1i.5U[a].Y.M=R(b.1i.aS+x-V/2)+"Q";b.1i.5U[a].Y.V=V+"Q";b.1i.5U[a].Y.S=R(S*b.1i.7K)+"Q"})}};A.fn.hL=A.8p.2l;A.1U({1e:{b1:C(p,n,a,b,c){G((-Z.51(p*Z.2F)/2)+0.5)*b+a},ho:C(p,n,a,b,c){G b*(n/=c)*n*n+a},d2:C(p,n,a,b,c){G-b*((n=n/c-1)*n*n*n-1)+a},hh:C(p,n,a,b,c){if((n/=c/2)<1)G b/2*n*n*n*n+a;G-b/2*((n-=2)*n*n*n-2)+a},7D:C(p,n,a,b,c){if((n/=c)<(1/2.75)){G b*(7.8W*n*n)+a}L if(n<(2/2.75)){G b*(7.8W*(n-=(1.5/2.75))*n+.75)+a}L if(n<(2.5/2.75)){G b*(7.8W*(n-=(2.25/2.75))*n+.gV)+a}L{G b*(7.8W*(n-=(2.gR/2.75))*n+.gN)+a}},aQ:C(p,n,a,b,c){if(A.1e.7D)G b-A.1e.7D(p,c-n,0,b,c)+a;G a+b},gE:C(p,n,a,b,c){if(A.1e.aQ&&A.1e.7D)if(ng.1z.6q?g.1z.6q:3J;3J=g.1z.6q-3J;bc=g.1z.5R*3J/g.1z.6q;B.Y.V=g.1z.2y+bc+\'Q\';B.Y.M=g.1z.2y*a+c+\'Q\';c+=bc});A.5K.8F(g,c)})})},8F:C(a,b){if(a.1z.4I)if(a.1z.4I==\'az\')a.1z.2q.I(0).Y.M=(a.3P-a.1z.2y*a.1z.1M.1N())/2-b/2+\'Q\';L if(a.1z.4I==\'M\')a.1z.2q.I(0).Y.M=-b/a.1z.1M.1N()+\'Q\';L if(a.1z.4I==\'2D\')a.1z.2q.I(0).Y.M=(a.3P-a.1z.2y*a.1z.1M.1N())-b/2+\'Q\';a.1z.2q.I(0).Y.V=a.1z.2y*a.1z.1M.1N()+b+\'Q\'},6z:C(b){b.1z.1M.1y(C(a){B.Y.V=b.1z.2y+\'Q\';B.Y.M=b.1z.2y*a+\'Q\'})}};A.fn.fz=A.5K.2l;A.K={18:P,7W:P,3q:P,2A:P,4b:P,af:P,2r:P,2h:P,1M:P,58:C(){A.K.7W.58();if(A.K.3q){A.K.3q.2x()}},4i:C(){A.K.1M=P;A.K.2h=P;A.K.4b=A.K.2r.2m;if(A.K.18.E(\'11\')==\'2v\'){if(A.K.2r.1a.fx){2X(A.K.2r.1a.fx.1K){19\'a4\':A.K.18.6d(A.K.2r.1a.fx.1H,A.K.58);1n;19\'1u\':A.K.18.c6(A.K.2r.1a.fx.1H,A.K.58);1n;19\'8o\':A.K.18.c3(A.K.2r.1a.fx.1H,A.K.58);1n}}L{A.K.18.2x()}if(A.K.2r.1a.2V)A.K.2r.1a.2V.1x(A.K.2r,[A.K.18,A.K.3q])}L{A.K.58()}1P.a2(A.K.2A)},c1:C(){F e=A.K.2r;F f=A.K.8C(e);if(e&&f.3w!=A.K.4b&&f.3w.1b>=e.1a.8N){A.K.4b=f.3w;A.K.af=f.3w;9V={bR:A(e).1m(\'eS\')||\'bR\',2m:f.3w};A.eQ({1K:\'eN\',9V:A.eL(9V),eK:C(b){e.1a.3X=A(\'3w\',b);1N=e.1a.3X.1N();if(1N>0){F c=\'\';e.1a.3X.1y(C(a){c+=\'<7b 4o="\'+A(\'2m\',B).3D()+\'" 8h="\'+a+\'" Y="7z: 8T;">\'+A(\'3D\',B).3D()+\'\'});if(e.1a.9K){F d=A(\'2m\',e.1a.3X.I(0)).3D();e.2m=f.30+d+e.1a.3y+f.5m;A.K.64(e,f.3w.1b!=d.1b?(f.30.1b+f.3w.1b):d.1b,f.3w.1b!=d.1b?(f.30.1b+d.1b):d.1b)}if(1N>0){A.K.aU(e,c)}L{A.K.4i()}}L{A.K.4i()}},5v:e.1a.96})}},aU:C(a,b){A.K.7W.3i(b);A.K.1M=A(\'7b\',A.K.7W.I(0));A.K.1M.9r(A.K.en).1C(\'4U\',A.K.ed);F c=A.12.3a(a);F d=A.12.2f(a);A.K.18.E(\'O\',c.y+d.hb+\'Q\').E(\'M\',c.x+\'Q\').2H(a.1a.9D);if(A.K.3q){A.K.3q.E(\'11\',\'2v\').E(\'O\',c.y+d.hb+\'Q\').E(\'M\',c.x+\'Q\').E(\'V\',A.K.18.E(\'V\')).E(\'S\',A.K.18.E(\'S\'))}A.K.2h=0;A.K.1M.I(0).2Z=a.1a.72;A.K.7I(a,a.1a.3X.I(0),\'6H\');if(A.K.18.E(\'11\')==\'1k\'){if(a.1a.bv){F e=A.12.9y(a,14);F f=A.12.6b(a,14);A.K.18.E(\'V\',a.3P-(A.e0?(e.l+e.r+f.l+f.r):0)+\'Q\')}if(a.1a.fx){2X(a.1a.fx.1K){19\'a4\':A.K.18.6U(a.1a.fx.1H);1n;19\'1u\':A.K.18.dR(a.1a.fx.1H);1n;19\'8o\':A.K.18.dP(a.1a.fx.1H);1n}}L{A.K.18.1S()}if(A.K.2r.1a.2K)A.K.2r.1a.2K.1x(A.K.2r,[A.K.18,A.K.3q])}},dM:C(){F b=B;if(b.1a.3X){A.K.4b=b.2m;A.K.af=b.2m;F c=\'\';b.1a.3X.1y(C(a){2m=A(\'2m\',B).3D().5u();dH=b.2m.5u();if(2m.3o(dH)==0){c+=\'<7b 4o="\'+A(\'2m\',B).3D()+\'" 8h="\'+a+\'" Y="7z: 8T;">\'+A(\'3D\',B).3D()+\'\'}});if(c!=\'\'){A.K.aU(b,c);B.1a.9s=14;G}}b.1a.3X=P;B.1a.9s=H},64:C(a,b,c){if(a.9q){F d=a.9q();d.iJ(14);d.dC("bh",b);d.iE("bh",-c+b);d.7Q()}L if(a.9m){a.9m(b,c)}L{if(a.88){a.88=b;a.dA=c}}a.6a()},dw:C(a){if(a.88)G a.88;L if(a.9q){F b=1c.64.dv();F c=b.il();G 0-c.dC(\'bh\',-ij)}},8C:C(a){F b={2m:a.2m,30:\'\',5m:\'\',3w:\'\'};if(a.1a.9k){F c=H;F d=A.K.dw(a)||0;F e=b.2m.6W(a.1a.3y);1V(F i=0;i=d||d==0)&&!c){if(b.30.1b<=d)b.3w=e[i];L b.5m+=e[i]+(e[i]!=\'\'?a.1a.3y:\'\');c=14}L if(c){b.5m+=e[i]+(e[i]!=\'\'?a.1a.3y:\'\')}if(!c){b.30+=e[i]+(e.1b>1?a.1a.3y:\'\')}}}L{b.3w=b.2m}G b},b9:C(e){1P.a2(A.K.2A);F a=A.K.8C(B);F b=e.6S||e.6R||-1;if(/13|27|35|36|38|40|9/.3M(b)&&A.K.1M){if(1P.3N){1P.3N.b6=14;1P.3N.b5=H}L{e.9b();e.99()}if(A.K.2h!=P)A.K.1M.I(A.K.2h||0).2Z=\'\';L A.K.2h=-1;2X(b){19 9:19 13:if(A.K.2h==-1)A.K.2h=0;F c=A.K.1M.I(A.K.2h||0);F d=c.4Z(\'4o\');B.2m=a.30+d+B.1a.3y+a.5m;A.K.4b=a.3w;A.K.64(B,a.30.1b+d.1b+B.1a.3y.1b,a.30.1b+d.1b+B.1a.3y.1b);A.K.4i();if(B.1a.5p){4E=R(c.4Z(\'8h\'))||0;A.K.7I(B,B.1a.3X.I(4E),\'5p\')}if(B.6O)B.6O(H);G b!=13;1n;19 27:B.2m=a.30+A.K.4b+B.1a.3y+a.5m;B.1a.3X=P;A.K.4i();if(B.6O)B.6O(H);G H;1n;19 35:A.K.2h=A.K.1M.1N()-1;1n;19 36:A.K.2h=0;1n;19 38:A.K.2h--;if(A.K.2h<0)A.K.2h=A.K.1M.1N()-1;1n;19 40:A.K.2h++;if(A.K.2h==A.K.1M.1N())A.K.2h=0;1n}A.K.7I(B,B.1a.3X.I(A.K.2h||0),\'6H\');A.K.1M.I(A.K.2h||0).2Z=B.1a.72;if(A.K.1M.I(A.K.2h||0).6O)A.K.1M.I(A.K.2h||0).6O(H);if(B.1a.9K){F f=A.K.1M.I(A.K.2h||0).4Z(\'4o\');B.2m=a.30+f+B.1a.3y+a.5m;if(A.K.4b.1b!=f.1b)A.K.64(B,a.30.1b+A.K.4b.1b,a.30.1b+f.1b)}G H}A.K.dM.1x(B);if(B.1a.9s==H){if(a.3w!=A.K.4b&&a.3w.1b>=B.1a.8N)A.K.2A=1P.97(A.K.c1,B.1a.4w);if(A.K.1M){A.K.4i()}}G 14},7I:C(a,b,c){if(a.1a[c]){F d={};94=b.dj(\'*\');1V(i=0;i<94.1b;i++){d[94[i].4D]=94[i].6M.hG}a.1a[c].1x(a,[d])}},en:C(e){if(A.K.1M){if(A.K.2h!=P)A.K.1M.I(A.K.2h||0).2Z=\'\';A.K.1M.I(A.K.2h||0).2Z=\'\';A.K.2h=R(B.4Z(\'8h\'))||0;A.K.1M.I(A.K.2h||0).2Z=A.K.2r.1a.72}},ed:C(a){1P.a2(A.K.2A);a=a||A.3N.hD(1P.3N);a.9b();a.99();F b=A.K.8C(A.K.2r);F c=B.4Z(\'4o\');A.K.2r.2m=b.30+c+A.K.2r.1a.3y+b.5m;A.K.4b=B.4Z(\'4o\');A.K.64(A.K.2r,b.30.1b+c.1b+A.K.2r.1a.3y.1b,b.30.1b+c.1b+A.K.2r.1a.3y.1b);A.K.4i();if(A.K.2r.1a.5p){4E=R(B.4Z(\'8h\'))||0;A.K.7I(A.K.2r,A.K.2r.1a.3X.I(4E),\'5p\')}G H},dh:C(e){6K=e.6S||e.6R||-1;if(/13|27|35|36|38|40/.3M(6K)&&A.K.1M){if(1P.3N){1P.3N.b6=14;1P.3N.b5=H}L{e.9b();e.99()}G H}},2l:C(a){if(!a.96||!A.12){G}if(!A.K.18){if(A.2R.46){A(\'23\',1c).1L(\'<3q Y="11:1k;T:1J;4X:9x:9C.9E.a6(1E=0);" id="df" 2E="dc:H;" da="0" d7="b0">\');A.K.3q=A(\'#df\')}A(\'23\',1c).1L(\'<1W id="d4" Y="T: 1J; O: 0; M: 0; z-aY: hj; 11: 1k;"><90 Y="5X: 0;7E: 0; h9-Y: 1k; z-aY: h8;">&6G;\');A.K.18=A(\'#d4\');A.K.7W=A(\'90\',A.K.18)}G B.1y(C(){if(B.4D!=\'aV\'&&B.4Z(\'1K\')!=\'3D\')G;B.1a={};B.1a.96=a.96;B.1a.8N=Z.3B(R(a.8N)||1);B.1a.9D=a.9D?a.9D:\'\';B.1a.72=a.72?a.72:\'\';B.1a.5p=a.5p&&a.5p.1F==2w?a.5p:P;B.1a.2K=a.2K&&a.2K.1F==2w?a.2K:P;B.1a.2V=a.2V&&a.2V.1F==2w?a.2V:P;B.1a.6H=a.6H&&a.6H.1F==2w?a.6H:P;B.1a.bv=a.bv||H;B.1a.9k=a.9k||H;B.1a.3y=B.1a.9k?(a.3y||\', \'):\'\';B.1a.9K=a.9K?14:H;B.1a.4w=Z.3B(R(a.4w)||8V);if(a.fx&&a.fx.1F==6E){if(!a.fx.1K||!/a4|1u|8o/.3M(a.fx.1K)){a.fx.1K=\'1u\'}if(a.fx.1K==\'1u\'&&!A.fx.1u)G;if(a.fx.1K==\'8o\'&&!A.fx.5l)G;a.fx.1H=Z.3B(R(a.fx.1H)||7n);if(a.fx.1H>B.1a.4w){a.fx.1H=B.1a.4w-1Y}B.1a.fx=a.fx}B.1a.3X=P;B.1a.9s=H;A(B).1m(\'b9\',\'cW\').6a(C(){A.K.2r=B;A.K.4b=B.2m}).cV(A.K.dh).5Q(A.K.b9).4W(C(){A.K.2A=1P.97(A.K.4i,gM)})})}};A.fn.gJ=A.K.2l;A.1t={2A:P,4k:P,1X:P,3f:10,2b:C(a,b,c,d){A.1t.4k=a;A.1t.1X=b;A.1t.3f=R(c)||10;A.1t.2A=1P.5Y(A.1t.cR,R(d)||40)},cR:C(){1V(i=0;i0&&A.1t.1X[i].2J.y+A.1t.1X[i].2J.t>5a.y){A.1t.1X[i].2T-=A.1t.3f}L if(A.1t.1X[i].2J.t<=A.1t.1X[i].2J.h&&A.1t.1X[i].2J.t+A.1t.1X[i].2J.hb<5a.y+5a.hb){A.1t.1X[i].2T+=A.1t.3f}if(A.1t.1X[i].2J.l>0&&A.1t.1X[i].2J.x+A.1t.1X[i].2J.l>5a.x){A.1t.1X[i].2P-=A.1t.3f}L if(A.1t.1X[i].2J.l<=A.1t.1X[i].2J.gf&&A.1t.1X[i].2J.l+A.1t.1X[i].2J.1D<5a.x+5a.1D){A.1t.1X[i].2P+=A.1t.3f}}},7w:C(){1P.5h(A.1t.2A);A.1t.4k=P;A.1t.1X=P;1V(i in A.1t.1X){A.1t.1X[i].2J=P}}};A.X={18:P,1g:P,4v:C(){G B.1y(C(){if(B.8L){B.D.cM.3h(\'4R\',A.X.aM);B.D=P;B.8L=H;if(A.2R.46){B.aI="cW"}L{B.Y.g0=\'\';B.Y.cJ=\'\';B.Y.cH=\'\'}}})},aM:C(e){if(A.X.1g!=P){A.X.8I(e);G H}F a=B.3H;A(1c).1C(\'3t\',A.X.aE).1C(\'5n\',A.X.8I);a.D.1A=A.12.3W(e);a.D.4d=a.D.1A;a.D.6g=H;a.D.fY=B!=B.3H;A.X.1g=a;if(a.D.4P&&B!=B.3H){aC=A.12.3a(a.2S);aZ=A.12.2f(a);ay={x:R(A.E(a,\'M\'))||0,y:R(A.E(a,\'O\'))||0};dx=a.D.4d.x-aC.x-aZ.1D/2-ay.x;dy=a.D.4d.y-aC.y-aZ.hb/2-ay.y;A.2Q.4s(a,[dx,dy])}G A.6J||H},cD:C(e){F a=A.X.1g;a.D.6g=14;F b=a.Y;a.D.6o=A.E(a,\'11\');a.D.49=A.E(a,\'T\');if(!a.D.av)a.D.av=a.D.49;a.D.22={x:R(A.E(a,\'M\'))||0,y:R(A.E(a,\'O\'))||0};a.D.8z=0;a.D.8y=0;if(A.2R.46){F c=A.12.6b(a,14);a.D.8z=c.l||0;a.D.8y=c.t||0}a.D.1w=A.1U(A.12.3a(a),A.12.2f(a));if(a.D.49!=\'2i\'&&a.D.49!=\'1J\'){b.T=\'2i\'}A.X.18.58();F d=A(a).cA(14).I(0);A(d).E({11:\'2v\',M:\'2G\',O:\'2G\'});d.Y.4M=\'0\';d.Y.53=\'0\';d.Y.4L=\'0\';d.Y.4K=\'0\';A.X.18.1L(d);F f=A.X.18.I(0).Y;if(a.D.ar){f.V=\'8x\';f.S=\'8x\'}L{f.S=a.D.1w.hb+\'Q\';f.V=a.D.1w.1D+\'Q\'}f.11=\'2v\';f.4M=\'2G\';f.53=\'2G\';f.4L=\'2G\';f.4K=\'2G\';A.1U(a.D.1w,A.12.2f(d));if(a.D.2M){if(a.D.2M.M){a.D.22.x+=a.D.1A.x-a.D.1w.x-a.D.2M.M;a.D.1w.x=a.D.1A.x-a.D.2M.M}if(a.D.2M.O){a.D.22.y+=a.D.1A.y-a.D.1w.y-a.D.2M.O;a.D.1w.y=a.D.1A.y-a.D.2M.O}if(a.D.2M.2D){a.D.22.x+=a.D.1A.x-a.D.1w.x-a.D.1w.hb+a.D.2M.2D;a.D.1w.x=a.D.1A.x-a.D.1w.1D+a.D.2M.2D}if(a.D.2M.4e){a.D.22.y+=a.D.1A.y-a.D.1w.y-a.D.1w.hb+a.D.2M.4e;a.D.1w.y=a.D.1A.y-a.D.1w.hb+a.D.2M.4e}}a.D.2n=a.D.22.x;a.D.2j=a.D.22.y;if(a.D.7V||a.D.2e==\'7X\'){7Z=A.12.6b(a.2S,14);a.D.1w.x=a.7Y+(A.2R.46?0:A.2R.6l?-7Z.l:7Z.l);a.D.1w.y=a.7t+(A.2R.46?0:A.2R.6l?-7Z.t:7Z.t);A(a.2S).1L(A.X.18.I(0))}if(a.D.2e){A.X.ah(a);a.D.4V.2e=A.X.ae}if(a.D.4P){A.2Q.ad(a)}f.M=a.D.1w.x-a.D.8z+\'Q\';f.O=a.D.1w.y-a.D.8y+\'Q\';f.V=a.D.1w.1D+\'Q\';f.S=a.D.1w.hb+\'Q\';A.X.1g.D.8w=H;if(a.D.gx){a.D.4V.5y=A.X.a9}if(a.D.3j!=H){A.X.18.E(\'3j\',a.D.3j)}if(a.D.1E){A.X.18.E(\'1E\',a.D.1E);if(1P.6j){A.X.18.E(\'4X\',\'7s(1E=\'+a.D.1E*1Y+\')\')}}if(a.D.6i){A.X.18.2H(a.D.6i);A.X.18.I(0).6M.Y.11=\'1k\'}if(a.D.4c)a.D.4c.1x(a,[d,a.D.22.x,a.D.22.y]);if(A.1s&&A.1s.7p>0){A.1s.ck(a)}if(a.D.3L==H){b.11=\'1k\'}G H},ah:C(a){if(a.D.2e.1F==8t){if(a.D.2e==\'7X\'){a.D.1Z=A.1U({x:0,y:0},A.12.2f(a.2S));F b=A.12.6b(a.2S,14);a.D.1Z.w=a.D.1Z.1D-b.l-b.r;a.D.1Z.h=a.D.1Z.hb-b.t-b.b}L if(a.D.2e==\'1c\'){F c=A.12.a5();a.D.1Z={x:0,y:0,w:c.w,h:c.h}}}L if(a.D.2e.1F==6h){a.D.1Z={x:R(a.D.2e[0])||0,y:R(a.D.2e[1])||0,w:R(a.D.2e[2])||0,h:R(a.D.2e[3])||0}}a.D.1Z.dx=a.D.1Z.x-a.D.1w.x;a.D.1Z.dy=a.D.1Z.y-a.D.1w.y},8r:C(a){if(a.D.7V||a.D.2e==\'7X\'){A(\'23\',1c).1L(A.X.18.I(0))}A.X.18.58().2x().E(\'1E\',1);if(1P.6j){A.X.18.E(\'4X\',\'7s(1E=1Y)\')}},8I:C(e){A(1c).3h(\'3t\',A.X.aE).3h(\'5n\',A.X.8I);if(A.X.1g==P){G}F a=A.X.1g;A.X.1g=P;if(a.D.6g==H){G H}if(a.D.3I==14){A(a).E(\'T\',a.D.49)}F b=a.Y;if(a.4P){A.X.18.E(\'7z\',\'7g\')}if(a.D.6i){A.X.18.3S(a.D.6i)}if(a.D.5B==H){if(a.D.fx>0){if(!a.D.2g||a.D.2g==\'3Z\'){F x=W A.fx(a,{1H:a.D.fx},\'M\');x.1G(a.D.22.x,a.D.7i)}if(!a.D.2g||a.D.2g==\'3K\'){F y=W A.fx(a,{1H:a.D.fx},\'O\');y.1G(a.D.22.y,a.D.7k)}}L{if(!a.D.2g||a.D.2g==\'3Z\')a.Y.M=a.D.7i+\'Q\';if(!a.D.2g||a.D.2g==\'3K\')a.Y.O=a.D.7k+\'Q\'}A.X.8r(a);if(a.D.3L==H){A(a).E(\'11\',a.D.6o)}}L if(a.D.fx>0){a.D.8w=14;F c=H;if(A.1s&&A.1p&&a.D.3I){c=A.12.3a(A.1p.18.I(0))}A.X.18.4S({M:c?c.x:a.D.1w.x,O:c?c.y:a.D.1w.y},a.D.fx,C(){a.D.8w=H;if(a.D.3L==H){a.Y.11=a.D.6o}A.X.8r(a)})}L{A.X.8r(a);if(a.D.3L==H){A(a).E(\'11\',a.D.6o)}}if(A.1s&&A.1s.7p>0){A.1s.c8(a)}if(A.1p&&a.D.3I){A.1p.c7(a)}if(a.D.2I&&(a.D.7i!=a.D.22.x||a.D.7k!=a.D.22.y)){a.D.2I.1x(a,a.D.aa||[0,0,a.D.7i,a.D.7k])}if(a.D.3C)a.D.3C.1x(a);G H},a9:C(x,y,a,b){if(a!=0)a=R((a+(B.D.gx*a/Z.3B(a))/2)/B.D.gx)*B.D.gx;if(b!=0)b=R((b+(B.D.gy*b/Z.3B(b))/2)/B.D.gy)*B.D.gy;G{dx:a,dy:b,x:0,y:0}},ae:C(x,y,a,b){a=Z.3k(Z.3g(a,B.D.1Z.dx),B.D.1Z.w+B.D.1Z.dx-B.D.1w.1D);b=Z.3k(Z.3g(b,B.D.1Z.dy),B.D.1Z.h+B.D.1Z.dy-B.D.1w.hb);G{dx:a,dy:b,x:0,y:0}},aE:C(e){if(A.X.1g==P||A.X.1g.D.8w==14){G}F a=A.X.1g;a.D.4d=A.12.3W(e);if(a.D.6g==H){3J=Z.cB(Z.5j(a.D.1A.x-a.D.4d.x,2)+Z.5j(a.D.1A.y-a.D.4d.y,2));if(3J0){A.1s.8n(a)}G H},2l:C(o){if(!A.X.18){A(\'23\',1c).1L(\'<1W id="bX">\');A.X.18=A(\'#bX\');F c=A.X.18.I(0);F d=c.Y;d.T=\'1J\';d.11=\'1k\';d.7z=\'7g\';d.bV=\'1k\';d.2N=\'2B\';if(1P.6j){c.aI="bU"}L{d.eZ=\'1k\';d.cH=\'1k\';d.cJ=\'1k\'}}if(!o){o={}}G B.1y(C(){if(B.8L||!A.12)G;if(1P.6j){B.eX=C(){G H};B.eW=C(){G H}}F a=B;F b=o.3c?A(B).eV(o.3c):A(B);if(A.2R.46){b.1y(C(){B.aI="bU"})}L{b.E(\'-eU-6f-7Q\',\'1k\');b.E(\'6f-7Q\',\'1k\');b.E(\'-eT-6f-7Q\',\'1k\')}B.D={cM:b,5B:o.5B?14:H,3L:o.3L?14:H,3I:o.3I?o.3I:H,4P:o.4P?o.4P:H,7V:o.7V?o.7V:H,3j:o.3j?R(o.3j)||0:H,1E:o.1E?2c(o.1E):H,fx:R(o.fx)||P,5z:o.5z?o.5z:H,4V:{},1A:{},4c:o.4c&&o.4c.1F==2w?o.4c:H,3C:o.3C&&o.3C.1F==2w?o.3C:H,2I:o.2I&&o.2I.1F==2w?o.2I:H,2g:/3K|3Z/.3M(o.2g)?o.2g:H,5D:o.5D?R(o.5D)||0:0,2M:o.2M?o.2M:H,ar:o.ar?14:H,6i:o.6i||H};if(o.4V&&o.4V.1F==2w)B.D.4V.6f=o.4V;if(o.4h&&o.4h.1F==2w)B.D.4h=o.4h;if(o.2e&&((o.2e.1F==8t&&(o.2e==\'7X\'||o.2e==\'1c\'))||(o.2e.1F==6h&&o.2e.1b==4))){B.D.2e=o.2e}if(o.2C){B.D.2C=o.2C}if(o.5y){if(28 o.5y==\'eO\'){B.D.gx=R(o.5y)||1;B.D.gy=R(o.5y)||1}L if(o.5y.1b==2){B.D.gx=R(o.5y[0])||1;B.D.gy=R(o.5y[1])||1}}if(o.3n&&o.3n.1F==2w){B.D.3n=o.3n}B.8L=14;b.1y(C(){B.3H=a});b.1C(\'4R\',A.X.aM)})}};A.fn.1U({8j:A.X.4v,6r:A.X.2l});A.1s={bP:C(a,b,c,d){G a<=A.X.1g.D.2n&&(a+c)>=(A.X.1g.D.2n+A.X.1g.D.1w.w)&&b<=A.X.1g.D.2j&&(b+d)>=(A.X.1g.D.2j+A.X.1g.D.1w.h)?14:H},9S:C(a,b,c,d){G!(a>(A.X.1g.D.2n+A.X.1g.D.1w.w)||(a+c)(A.X.1g.D.2j+A.X.1g.D.1w.h)||(b+d)A.X.1g.D.4d.x&&bA.X.1g.D.4d.y?14:H},4T:H,3z:{},7p:0,3p:{},ck:C(a){if(A.X.1g==P){G}F i;A.1s.3z={};F b=H;1V(i in A.1s.3p){if(A.1s.3p[i]!=P){F c=A.1s.3p[i].I(0);if(A(A.X.1g).is(\'.\'+c.1f.a)){if(c.1f.m==H){c.1f.p=A.1U(A.12.6x(c),A.12.6w(c));c.1f.m=14}if(c.1f.ac){A.1s.3p[i].2H(c.1f.ac)}A.1s.3z[i]=A.1s.3p[i];if(A.1p&&c.1f.s&&A.X.1g.D.3I){c.1f.el=A(\'.\'+c.1f.a,c);a.Y.11=\'1k\';A.1p.bM(c);c.1f.9P=A.1p.8g(A.1m(c,\'id\')).6A;a.Y.11=a.D.6o;b=14}if(c.1f.9O){c.1f.9O.1x(A.1s.3p[i].I(0),[A.X.1g])}}}}if(b){A.1p.2b()}},eF:C(){A.1s.3z={};1V(i in A.1s.3p){if(A.1s.3p[i]!=P){F a=A.1s.3p[i].I(0);if(A(A.X.1g).is(\'.\'+a.1f.a)){a.1f.p=A.1U(A.12.6x(a),A.12.6w(a));if(a.1f.ac){A.1s.3p[i].2H(a.1f.ac)}A.1s.3z[i]=A.1s.3p[i];if(A.1p&&a.1f.s&&A.X.1g.D.3I){a.1f.el=A(\'.\'+a.1f.a,a);bJ.Y.11=\'1k\';A.1p.bM(a);bJ.Y.11=bJ.D.6o}}}}},8n:C(e){if(A.X.1g==P){G}A.1s.4T=H;F i;F a=H;F b=0;1V(i in A.1s.3z){F c=A.1s.3z[i].I(0);if(A.1s.4T==H&&A.1s[c.1f.t](c.1f.p.x,c.1f.p.y,c.1f.p.1D,c.1f.p.hb)){if(c.1f.hc&&c.1f.h==H){A.1s.3z[i].2H(c.1f.hc)}if(c.1f.h==H&&c.1f.76){a=14}c.1f.h=14;A.1s.4T=c;if(A.1p&&c.1f.s&&A.X.1g.D.3I){A.1p.18.I(0).2Z=c.1f.eC;A.1p.8n(c)}b++}L if(c.1f.h==14){if(c.1f.6C){c.1f.6C.1x(c,[e,A.X.18.I(0).6M,c.1f.fx])}if(c.1f.hc){A.1s.3z[i].3S(c.1f.hc)}c.1f.h=H}}if(A.1p&&!A.1s.4T&&A.X.1g.3I){A.1p.18.I(0).Y.11=\'1k\'}if(a){A.1s.4T.1f.76.1x(A.1s.4T,[e,A.X.18.I(0).6M])}},c8:C(e){F i;1V(i in A.1s.3z){F a=A.1s.3z[i].I(0);if(a.1f.ac){A.1s.3z[i].3S(a.1f.ac)}if(a.1f.hc){A.1s.3z[i].3S(a.1f.hc)}if(a.1f.s){A.1p.73[A.1p.73.1b]=i}if(a.1f.9I&&a.1f.h==14){a.1f.h=H;a.1f.9I.1x(a,[e,a.1f.fx])}a.1f.m=H;a.1f.h=H}A.1s.3z={}},4v:C(){G B.1y(C(){if(B.8S){if(B.1f.s){id=A.1m(B,\'id\');A.1p.54[id]=P;A(\'.\'+B.1f.a,B).8j()}A.1s.3p[\'d\'+B.bG]=P;B.8S=H;B.f=P}})},2l:C(o){G B.1y(C(){if(B.8S==14||!o.3r||!A.12||!A.X){G}B.1f={a:o.3r,ac:o.9F||H,hc:o.8X||H,eC:o.4G||H,9I:o.je||o.9I||H,76:o.76||o.ev||H,6C:o.6C||o.er||H,9O:o.9O||H,t:o.5T&&(o.5T==\'bP\'||o.5T==\'9S\')?o.5T:\'1A\',fx:o.fx?o.fx:H,m:H,h:H};if(o.bC==14&&A.1p){id=A.1m(B,\'id\');A.1p.54[id]=B.1f.a;B.1f.s=14;if(o.2I){B.1f.2I=o.2I;B.1f.9P=A.1p.8g(id).6A}}B.8S=14;B.bG=R(Z.63()*aW);A.1s.3p[\'d\'+B.bG]=A(B);A.1s.7p++})}};A.fn.1U({ei:A.1s.4v,ee:A.1s.2l});A.jd=A.1s.eF;A.3l={18:P,89:C(){3D=B.2m;if(!3D)G;Y={eb:A(B).E(\'eb\')||\'\',4a:A(B).E(\'4a\')||\'\',87:A(B).E(\'87\')||\'\',e9:A(B).E(\'e9\')||\'\',e8:A(B).E(\'e8\')||\'\',e7:A(B).E(\'e7\')||\'\',bx:A(B).E(\'bx\')||\'\',e6:A(B).E(\'e6\')||\'\'};A.3l.18.E(Y);3i=A.3l.e5(3D);3i=3i.48(W bw("\\\\n","g"),"
    ");A.3l.18.3i(\'j6\');b3=A.3l.18.I(0).3P;A.3l.18.3i(3i);V=A.3l.18.I(0).3P+b3;if(B.66.65&&V>B.66.65[0]){V=B.66.65[0]}B.Y.V=V+\'Q\';if(B.4D==\'bs\'){S=A.3l.18.I(0).5r+b3;if(B.66.65&&S>B.66.65[1]){S=B.66.65[1]}B.Y.S=S+\'Q\'}},e5:C(a){bq={\'&\':\'&j1;\',\'<\':\'&j0;\',\'>\':\'>\',\'"\':\'&iZ;\'};1V(i in bq){a=a.48(W bw(i,\'g\'),bq[i])}G a},2l:C(a){if(A.3l.18==P){A(\'23\',1c).1L(\'<1W id="dX" Y="T: 1J; O: 0; M: 0; 2W: 2B;">\');A.3l.18=A(\'#dX\')}G B.1y(C(){if(/bs|aV/.3M(B.4D)){if(B.4D==\'aV\'){dT=B.4Z(\'1K\');if(!/3D|iW/.3M(dT)){G}}if(a&&(a.1F==bm||(a.1F==6h&&a.1b==2))){if(a.1F==bm)a=[a,a];L{a[0]=R(a[0])||7n;a[1]=R(a[1])||7n}B.66={65:a}}A(B).4W(A.3l.89).5Q(A.3l.89).cV(A.3l.89);A.3l.89.1x(B)}})}};A.fn.iU=A.3l.2l;A.fn.1U({c3:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.5l(B,a,b,\'4l\',c)})},dP:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.5l(B,a,b,\'41\',c)})},iQ:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.5l(B,a,b,\'dG\',c)})},iM:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.5l(B,a,b,\'M\',c)})},iL:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.5l(B,a,b,\'2D\',c)})},iK:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.5l(B,a,b,\'dF\',c)})}});A.fx.5l=C(e,a,b,c,d){if(!A.4n(e)){A.2z(e,\'1j\');G H}F z=B;z.el=A(e);z.1N=A.12.2f(e);z.1e=28 b==\'4B\'?b:d||P;if(!e.4f)e.4f=z.el.E(\'11\');if(c==\'dG\'){c=z.el.E(\'11\')==\'1k\'?\'41\':\'4l\'}L if(c==\'dF\'){c=z.el.E(\'11\')==\'1k\'?\'2D\':\'M\'}z.el.1S();z.1l=a;z.29=28 b==\'C\'?b:P;z.fx=A.fx.9u(e);z.6T=c;z.1T=C(){if(z.29&&z.29.1F==2w){z.29.1x(z.el.I(0))}if(z.6T==\'41\'||z.6T==\'2D\'){z.el.E(\'11\',z.el.I(0).4f==\'1k\'?\'2v\':z.el.I(0).4f)}L{z.el.2x()}A.fx.9n(z.fx.2Y.I(0),z.fx.U);A.2z(z.el.I(0),\'1j\')};2X(z.6T){19\'4l\':5q=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e,z.1T),\'S\');5q.1G(z.fx.U.1o.hb,0);1n;19\'41\':z.fx.2Y.E(\'S\',\'9e\');z.el.1S();5q=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e,z.1T),\'S\');5q.1G(0,z.fx.U.1o.hb);1n;19\'M\':5q=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e,z.1T),\'V\');5q.1G(z.fx.U.1o.1D,0);1n;19\'2D\':z.fx.2Y.E(\'V\',\'9e\');z.el.1S();5q=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e,z.1T),\'V\');5q.1G(0,z.fx.U.1o.1D);1n}};A.fn.iA=C(a,b){G B.1r(\'1j\',C(){if(!A.4n(B)){A.2z(B,\'1j\');G H}F e=W A.fx.eu(B,a,b);e.bE()})};A.fx.eu=C(e,a,b){F z=B;z.el=A(e);z.el.1S();z.29=b;z.8e=R(a)||40;z.U={};z.U.T=z.el.E(\'T\');z.U.O=R(z.el.E(\'O\'))||0;z.U.M=R(z.el.E(\'M\'))||0;if(z.U.T!=\'2i\'&&z.U.T!=\'1J\'){z.el.E(\'T\',\'2i\')}z.74=5;z.52=1;z.bE=C(){z.52++;z.e=W A.fx(z.el.I(0),{1H:io,1T:C(){z.e=W A.fx(z.el.I(0),{1H:80,1T:C(){z.8e=R(z.8e/2);if(z.52<=z.74)z.bE();L{z.el.E(\'T\',z.U.T).E(\'O\',z.U.O+\'Q\').E(\'M\',z.U.M+\'Q\');A.2z(z.el.I(0),\'1j\');if(z.29&&z.29.1F==2w){z.29.1x(z.el.I(0))}}}},\'O\');z.e.1G(z.U.O-z.8e,z.U.O)}},\'O\');z.e.1G(z.U.O,z.U.O-z.8e)}};A.fn.1U({im:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'41\',\'3U\',c)})},ik:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'41\',\'in\',c)})},ii:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'41\',\'3E\',c)})},ig:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'4l\',\'3U\',c)})},ie:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'4l\',\'in\',c)})},ic:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'4l\',\'3E\',c)})},ib:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'M\',\'3U\',c)})},ia:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'M\',\'in\',c)})},i9:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'M\',\'3E\',c)})},i8:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'2D\',\'3U\',c)})},i7:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'2D\',\'in\',c)})},i6:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.3Y(B,a,b,\'2D\',\'3E\',c)})}});A.fx.3Y=C(e,a,b,c,d,f){if(!A.4n(e)){A.2z(e,\'1j\');G H}F z=B;z.el=A(e);z.1e=28 b==\'4B\'?b:f||P;z.U={};z.U.T=z.el.E(\'T\');z.U.O=z.el.E(\'O\');z.U.M=z.el.E(\'M\');if(!e.4f)e.4f=z.el.E(\'11\');if(d==\'3E\'){d=z.el.E(\'11\')==\'1k\'?\'in\':\'3U\'}z.el.1S();if(z.U.T!=\'2i\'&&z.U.T!=\'1J\'){z.el.E(\'T\',\'2i\')}z.1K=d;b=28 b==\'C\'?b:P;7N=1;2X(c){19\'4l\':z.e=W A.fx(z.el.I(0),A.1l(a-15,z.1e,b),\'O\');z.5x=2c(z.U.O)||0;z.9i=z.dt;7N=-1;1n;19\'41\':z.e=W A.fx(z.el.I(0),A.1l(a-15,z.1e,b),\'O\');z.5x=2c(z.U.O)||0;z.9i=z.dt;1n;19\'2D\':z.e=W A.fx(z.el.I(0),A.1l(a-15,z.1e,b),\'M\');z.5x=2c(z.U.M)||0;z.9i=z.ds;1n;19\'M\':z.e=W A.fx(z.el.I(0),A.1l(a-15,z.1e,b),\'M\');z.5x=2c(z.U.M)||0;z.9i=z.ds;7N=-1;1n}z.e2=W A.fx(z.el.I(0),A.1l(a,z.1e,C(){z.el.E(z.U);if(z.1K==\'3U\'){z.el.E(\'11\',\'1k\')}L z.el.E(\'11\',z.el.I(0).4f==\'1k\'?\'2v\':z.el.I(0).4f);A.2z(z.el.I(0),\'1j\')}),\'1E\');if(d==\'in\'){z.e.1G(z.5x+1Y*7N,z.5x);z.e2.1G(0,1)}L{z.e.1G(z.5x,z.5x+1Y*7N);z.e2.1G(1,0)}};A.fn.1U({i5:C(a,b,c,d){G B.1r(\'1j\',C(){W A.fx.9h(B,a,b,c,\'dq\',d)})},i4:C(a,b,c,d){G B.1r(\'1j\',C(){W A.fx.9h(B,a,b,c,\'9g\',d)})},i3:C(a,b,c,d){G B.1r(\'1j\',C(){W A.fx.9h(B,a,b,c,\'3E\',d)})}});A.fx.9h=C(e,a,b,c,d,f){if(!A.4n(e)){A.2z(e,\'1j\');G H}F z=B;z.el=A(e);z.1e=28 c==\'4B\'?c:f||P;z.29=28 c==\'C\'?c:P;if(d==\'3E\'){d=z.el.E(\'11\')==\'1k\'?\'9g\':\'dq\'}z.1l=a;z.S=b&&b.1F==bm?b:20;z.fx=A.fx.9u(e);z.1K=d;z.1T=C(){if(z.29&&z.29.1F==2w){z.29.1x(z.el.I(0))}if(z.1K==\'9g\'){z.el.1S()}L{z.el.2x()}A.fx.9n(z.fx.2Y.I(0),z.fx.U);A.2z(z.el.I(0),\'1j\')};if(z.1K==\'9g\'){z.el.1S();z.fx.2Y.E(\'S\',z.S+\'Q\').E(\'V\',\'9e\');z.ef=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e,C(){z.ef=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e,z.1T),\'S\');z.ef.1G(z.S,z.fx.U.1o.hb)}),\'V\');z.ef.1G(0,z.fx.U.1o.1D)}L{z.ef=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e,C(){z.ef=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e,z.1T),\'V\');z.ef.1G(z.fx.U.1o.1D,0)}),\'S\');z.ef.1G(z.fx.U.1o.hb,z.S)}};A.fn.i2=C(c,d,e,f){G B.1r(\'dp\',C(){B.6Q=A(B).1m("Y")||\'\';f=28 e==\'4B\'?e:f||P;e=28 e==\'C\'?e:P;F a=A(B).E(\'6P\');F b=B.2S;6k(a==\'b7\'&&b){a=A(b).E(\'6P\');b=b.2S}A(B).E(\'6P\',d);if(28 B.6Q==\'7M\')B.6Q=B.6Q["9d"];A(B).4S({\'6P\':a},c,f,C(){A.2z(B,\'dp\');if(28 A(B).1m("Y")==\'7M\'){A(B).1m("Y")["9d"]="";A(B).1m("Y")["9d"]=B.6Q}L{A(B).1m("Y",B.6Q)}if(e)e.1x(B)})})};A.4n=C(e){if(/^i1$|^i0$|^hZ$|^5W$|^hY$|^hX$|^hW$|^hV$|^hU$|^23$|^hT$|^hS$|^hR$|^hQ$|^hP$|^hO$|^hN$/i.3M(e.98))G H;L G 14};A.fx.9n=C(e,a){F c=e.6M;F b=c.Y;b.T=a.T;b.4M=a.3s.t;b.4K=a.3s.l;b.4L=a.3s.b;b.53=a.3s.r;b.O=a.O+\'Q\';b.M=a.M+\'Q\';e.2S.dn(c,e);e.2S.hM(e)};A.fx.9u=C(e){if(!A.4n(e))G H;F t=A(e);F a=e.Y;F b=H;if(t.E(\'11\')==\'1k\'){95=t.E(\'2W\');t.E(\'2W\',\'2B\').1S();b=14}F c={};c.T=t.E(\'T\');c.1o=A.12.2f(e);c.3s=A.12.b2(e);F d=e.4u?e.4u.dk:t.E(\'hK\');c.O=R(t.E(\'O\'))||0;c.M=R(t.E(\'M\'))||0;F f=\'hJ\'+R(Z.63()*aW);F g=1c.3x(/^3O$|^br$|^hI$|^hr$|^7Q$|^hH$|^7M$|^3q$|^hF$|^hE$|^hC$|^90$|^dl$|^hB$/i.3M(e.98)?\'1W\':e.98);A.1m(g,\'id\',f);F h=A(g).2H(\'hA\');F i=g.Y;F j=0;F k=0;if(c.T==\'2i\'||c.T==\'1J\'){j=c.O;k=c.M}i.O=j+\'Q\';i.M=k+\'Q\';i.T=c.T!=\'2i\'&&c.T!=\'1J\'?\'2i\':c.T;i.S=c.1o.hb+\'Q\';i.V=c.1o.1D+\'Q\';i.4M=c.3s.t;i.53=c.3s.r;i.4L=c.3s.b;i.4K=c.3s.l;i.2N=\'2B\';if(A.2R.46){i.dk=d}L{i.hz=d}if(A.2R=="46"){a.4X="7s(1E="+0.dg*1Y+")"}a.1E=0.dg;e.2S.dn(g,e);g.hy(e);a.4M=\'2G\';a.53=\'2G\';a.4L=\'2G\';a.4K=\'2G\';a.T=\'1J\';a.bV=\'1k\';a.O=\'2G\';a.M=\'2G\';if(b){t.2x();a.2W=95}G{U:c,2Y:A(g)}};A.fx.7H={hx:[0,1O,1O],hw:[dd,1O,1O],hv:[db,db,hu],hs:[0,0,0],hq:[0,0,1O],hp:[d6,42,42],hn:[0,1O,1O],hm:[0,0,6N],hl:[0,6N,6N],hk:[aX,aX,aX],hi:[0,1Y,0],hg:[hf,he,cZ],hd:[6N,0,6N],ha:[85,cZ,47],h7:[1O,cY,0],h6:[h5,50,h4],h3:[6N,0,0],h2:[h1,cX,h0],gZ:[gY,0,8U],gX:[1O,0,1O],gW:[1O,gU,0],gT:[0,67,0],gS:[75,0,gQ],gP:[dd,cU,cY],gO:[gL,gK,cU],gI:[cT,1O,1O],gH:[cS,gG,cS],gF:[8U,8U,8U],gD:[1O,gC,gB],gA:[1O,1O,cT],gw:[0,1O,0],gv:[1O,0,1O],gu:[67,0,0],gs:[0,0,67],gr:[67,67,0],gq:[1O,d6,0],gp:[1O,8R,gn],gm:[67,0,67],gl:[1O,0,0],gk:[8R,8R,8R],gj:[1O,1O,1O],gi:[1O,1O,0]};A.fx.5L=C(a,b){if(A.fx.7H[a])G{r:A.fx.7H[a][0],g:A.fx.7H[a][1],b:A.fx.7H[a][2]};L if(2L=/^6v\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)$/.8Q(a))G{r:R(2L[1]),g:R(2L[2]),b:R(2L[3])};L if(2L=/6v\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)$/.8Q(a))G{r:2c(2L[1])*2.55,g:2c(2L[2])*2.55,b:2c(2L[3])*2.55};L if(2L=/^#([a-fA-6t-9])([a-fA-6t-9])([a-fA-6t-9])$/.8Q(a))G{r:R("6s"+2L[1]+2L[1]),g:R("6s"+2L[2]+2L[2]),b:R("6s"+2L[3]+2L[3])};L if(2L=/^#([a-fA-6t-9]{2})([a-fA-6t-9]{2})([a-fA-6t-9]{2})$/.8Q(a))G{r:R("6s"+2L[1]),g:R("6s"+2L[2]),b:R("6s"+2L[3])};L G b==14?H:{r:1O,g:1O,b:1O}};A.fx.cQ={5d:1,4y:1,5i:1,4x:1,4e:1,4a:1,S:1,M:1,bx:1,gh:1,4L:1,4K:1,53:1,4M:1,7y:1,5R:1,7x:1,8O:1,1E:1,ge:1,gc:1,4Q:1,4F:1,5g:1,5b:1,2D:1,gb:1,O:1,V:1,3j:1};A.fx.cN={6P:1,ga:1,g9:1,g8:1,g7:1,g6:1,g5:1};A.fx.7v=[\'g4\',\'g3\',\'g2\',\'g1\'];A.fx.aL={\'aK\':[\'2u\',\'cK\'],\'8E\':[\'2u\',\'aH\'],\'5X\':[\'5X\',\'\'],\'7E\':[\'7E\',\'\']};A.fn.1U({4S:C(b,c,d,f){G B.1r(C(){F a=A.1l(c,d,f);F e=W A.cI(B,a,b)})},aG:C(b,c){G B.1r(C(){F a=A.1l(b,c);F e=W A.aG(B,a)})},7w:C(a){G B.1y(C(){if(B.5e)A.aF(B,a)})},fZ:C(a){G B.1y(C(){if(B.5e)A.aF(B,a);if(B.1r&&B.1r[\'fx\'])B.1r.fx=[]})}});A.1U({aG:C(a,b){F z=B,5f;z.3f=C(){if(A.cF(b.1T))b.1T.1x(a)};z.2A=5Y(C(){z.3f()},b.1H);a.5e=z},1e:{b1:C(p,n,a,b,c){G((-Z.51(p*Z.2F)/2)+0.5)*b+a}},cI:C(f,g,h){F z=B,5f;F y=f.Y;F k=A.E(f,"2N");F l=A.E(f,"11");F o={};z.9a=(W 6p()).6y();g.1e=g.1e&&A.1e[g.1e]?g.1e:\'b1\';z.8H=C(a,b){if(A.fx.cQ[a]){if(b==\'1S\'||b==\'2x\'||b==\'3E\'){if(!f.5I)f.5I={};F r=2c(A.5S(f,a));f.5I[a]=r&&r>-aW?r:(2c(A.E(f,a))||0);b=b==\'3E\'?(l==\'1k\'?\'1S\':\'2x\'):b;g[b]=14;o[a]=b==\'1S\'?[0,f.5I[a]]:[f.5I[a],0];if(a!=\'1E\')y[a]=o[a][0]+(a!=\'3j\'&&a!=\'87\'?\'Q\':\'\');L A.1m(y,"1E",o[a][0])}L{o[a]=[2c(A.5S(f,a)),2c(b)||0]}}L if(A.fx.cN[a])o[a]=[A.fx.5L(A.5S(f,a)),A.fx.5L(b)];L if(/^5X$|7E$|2u$|8E$|aK$/i.3M(a)){F m=b.48(/\\s+/g,\' \').48(/6v\\s*\\(\\s*/g,\'6v(\').48(/\\s*,\\s*/g,\',\').48(/\\s*\\)/g,\')\').aD(/([^\\s]+)/g);2X(a){19\'5X\':19\'7E\':19\'aK\':19\'8E\':m[3]=m[3]||m[1]||m[0];m[2]=m[2]||m[0];m[1]=m[1]||m[0];1V(F i=0;ig.1H+z.9a){5h(z.2A);z.2A=P;1V(p in o){if(p=="1E")A.1m(y,"1E",o[p][1]);L if(28 o[p][1]==\'7M\')y[p]=\'6v(\'+o[p][1].r+\',\'+o[p][1].g+\',\'+o[p][1].b+\')\';L y[p]=o[p][1]+(p!=\'3j\'&&p!=\'87\'?\'Q\':\'\')}if(g.2x||g.1S)1V(F p in f.5I)if(p=="1E")A.1m(y,p,f.5I[p]);L y[p]="";y.11=g.2x?\'1k\':(l!=\'1k\'?l:\'2v\');y.2N=k;f.5e=P;if(A.cF(g.1T))g.1T.1x(f)}L{F n=t-B.9a;F a=n/g.1H;1V(p in o){if(28 o[p][1]==\'7M\'){y[p]=\'6v(\'+R(A.1e[g.1e](a,n,o[p][0].r,(o[p][1].r-o[p][0].r),g.1H))+\',\'+R(A.1e[g.1e](a,n,o[p][0].g,(o[p][1].g-o[p][0].g),g.1H))+\',\'+R(A.1e[g.1e](a,n,o[p][0].b,(o[p][1].b-o[p][0].b),g.1H))+\')\'}L{F b=A.1e[g.1e](a,n,o[p][0],(o[p][1]-o[p][0]),g.1H);if(p=="1E")A.1m(y,"1E",b);L y[p]=b+(p!=\'3j\'&&p!=\'87\'?\'Q\':\'\')}}}};z.2A=5Y(C(){z.3f()},13);f.5e=z},aF:C(a,b){if(b)a.5e.9a-=fJ;L{1P.5h(a.5e.2A);a.5e=P;A.2z(a,"fx")}}});A.ax=C(a){F b={};if(28 a==\'4B\'){a=a.5u().6W(\';\');1V(F i=0;i0){z.cy=1o[i];z.4a=2c(z.U.4a)}if(z.U.4x.3o(1o[i])>0){z.cx=1o[i];z.aq=2c(z.U.4x)||0}if(z.U.5i.3o(1o[i])>0){z.cw=1o[i];z.ap=2c(z.U.5i)||0}if(z.U.5d.3o(1o[i])>0){z.cv=1o[i];z.ao=2c(z.U.5d)||0}if(z.U.4y.3o(1o[i])>0){z.cu=1o[i];z.an=2c(z.U.4y)||0}if(z.U.5b.3o(1o[i])>0){z.ct=1o[i];z.am=2c(z.U.5b)||0}if(z.U.5g.3o(1o[i])>0){z.cr=1o[i];z.al=2c(z.U.5g)||0}if(z.U.4Q.3o(1o[i])>0){z.cq=1o[i];z.ak=2c(z.U.4Q)||0}if(z.U.4F.3o(1o[i])>0){z.cp=1o[i];z.aj=2c(z.U.4F)||0}}if(z.U.T!=\'2i\'&&z.U.T!=\'1J\'){z.el.E(\'T\',\'2i\')}z.el.E(\'2N\',\'2B\');z.1K=m;2X(z.1K){19\'cz\':z.3V=z.O+z.26.h/2;z.4H=z.O;z.3Q=z.M+z.26.w/2;z.4r=z.M;1n;19\'as\':z.4H=z.O+z.26.h/2;z.3V=z.O;z.4r=z.M+z.26.w/2;z.3Q=z.M;1n;19\'5c\':z.4H=z.O-z.26.h/4;z.3V=z.O;z.4r=z.M-z.26.w/4;z.3Q=z.M;1n}z.ai=H;z.t=(W 6p).6y();z.4i=C(){5h(z.2A);z.2A=P};z.3f=C(){if(z.ai==H){z.el.1S();z.ai=14}F t=(W 6p).6y();F n=t-z.t;F p=n/z.1H;if(t>=z.1H+z.t){97(C(){o=1;if(z.1K){t=z.4H;l=z.4r;if(z.1K==\'5c\')o=0}z.ag(z.3v,l,t,14,o)},13);z.4i()}L{o=1;if(!A.1e||!A.1e[z.1e]){s=((-Z.51(p*Z.2F)/2)+0.5)*(z.3v-z.6m)+z.6m}L{s=A.1e[z.1e](p,n,z.6m,(z.3v-z.6m),z.1H)}if(z.1K){if(!A.1e||!A.1e[z.1e]){t=((-Z.51(p*Z.2F)/2)+0.5)*(z.4H-z.3V)+z.3V;l=((-Z.51(p*Z.2F)/2)+0.5)*(z.4r-z.3Q)+z.3Q;if(z.1K==\'5c\')o=((-Z.51(p*Z.2F)/2)+0.5)*(-0.9B)+0.9B}L{t=A.1e[z.1e](p,n,z.3V,(z.4H-z.3V),z.1H);l=A.1e[z.1e](p,n,z.3Q,(z.4r-z.3Q),z.1H);if(z.1K==\'5c\')o=A.1e[z.1e](p,n,0.9B,-0.9B,z.1H)}}z.ag(s,l,t,H,o)}};z.2A=5Y(C(){z.3f()},13);z.ag=C(a,b,c,d,e){z.el.E(\'S\',z.S*a/1Y+\'Q\').E(\'V\',z.V*a/1Y+\'Q\').E(\'M\',b+\'Q\').E(\'O\',c+\'Q\').E(\'4a\',z.4a*a/1Y+z.cy);if(z.aq)z.el.E(\'4x\',z.aq*a/1Y+z.cx);if(z.ap)z.el.E(\'5i\',z.ap*a/1Y+z.cw);if(z.ao)z.el.E(\'5d\',z.ao*a/1Y+z.cv);if(z.an)z.el.E(\'4y\',z.an*a/1Y+z.cu);if(z.am)z.el.E(\'5b\',z.am*a/1Y+z.ct);if(z.al)z.el.E(\'5g\',z.al*a/1Y+z.cr);if(z.ak)z.el.E(\'4Q\',z.ak*a/1Y+z.cq);if(z.aj)z.el.E(\'4F\',z.aj*a/1Y+z.cp);if(z.1K==\'5c\'){if(1P.6j)z.el.I(0).Y.4X="7s(1E="+e*1Y+")";z.el.I(0).Y.1E=e}if(d){if(z.bL){z.el.E(z.U)}if(z.1K==\'as\'||z.1K==\'5c\'){z.el.E(\'11\',\'1k\');if(z.1K==\'5c\'){if(1P.6j)z.el.I(0).Y.4X="7s(1E="+1Y+")";z.el.I(0).Y.1E=1}}L z.el.E(\'11\',\'2v\');if(z.29)z.29.1x(z.el.I(0));A.2z(z.el.I(0),\'1j\')}}};A.fn.1U({9A:C(a,b,c){o=A.1l(a);G B.1r(\'1j\',C(){W A.fx.9A(B,o,b,c)})},ft:C(a,b,c){G B.1y(C(){A(\'a[@2U*="#"]\',B).4U(C(e){co=B.2U.6W(\'#\');A(\'#\'+co[1]).9A(a,b,c);G H})})}});A.fx.9A=C(e,o,a,b){F z=B;z.o=o;z.e=e;z.2g=/cn|cm/.3M(a)?a:H;z.1e=b;p=A.12.3a(e);s=A.12.5O();z.4i=C(){5h(z.2A);z.2A=P;A.2z(z.e,\'1j\')};z.t=(W 6p).6y();s.h=s.h>s.ih?(s.h-s.ih):s.h;s.w=s.w>s.iw?(s.w-s.iw):s.w;z.4H=p.y>s.h?s.h:p.y;z.4r=p.x>s.w?s.w:p.x;z.3V=s.t;z.3Q=s.l;z.3f=C(){F t=(W 6p).6y();F n=t-z.t;F p=n/z.o.1H;if(t>=z.o.1H+z.t){z.4i();97(C(){z.ab(z.4H,z.4r)},13)}L{if(!z.2g||z.2g==\'cn\'){if(!A.1e||!A.1e[z.1e]){8v=((-Z.51(p*Z.2F)/2)+0.5)*(z.4H-z.3V)+z.3V}L{8v=A.1e[z.1e](p,n,z.3V,(z.4H-z.3V),z.o.1H)}}L{8v=z.3V}if(!z.2g||z.2g==\'cm\'){if(!A.1e||!A.1e[z.1e]){8u=((-Z.51(p*Z.2F)/2)+0.5)*(z.4r-z.3Q)+z.3Q}L{8u=A.1e[z.1e](p,n,z.3Q,(z.4r-z.3Q),z.o.1H)}}L{8u=z.3Q}z.ab(8v,8u)}};z.ab=C(t,l){1P.fs(l,t)};z.2A=5Y(C(){z.3f()},13)};A.fn.a8=C(a,b){G B.1r(\'1j\',C(){if(!A.4n(B)){A.2z(B,\'1j\');G H}F e=W A.fx.a8(B,a,b);e.a7()})};A.fx.a8=C(e,a,b){F z=B;z.el=A(e);z.el.1S();z.74=R(a)||3;z.29=b;z.52=1;z.U={};z.U.T=z.el.E(\'T\');z.U.O=R(z.el.E(\'O\'))||0;z.U.M=R(z.el.E(\'M\'))||0;if(z.U.T!=\'2i\'&&z.U.T!=\'1J\'){z.el.E(\'T\',\'2i\')}z.a7=C(){z.52++;z.e=W A.fx(z.el.I(0),{1H:60,1T:C(){z.e=W A.fx(z.el.I(0),{1H:60,1T:C(){z.e=W A.fx(e,{1H:60,1T:C(){if(z.52<=z.74)z.a7();L{z.el.E(\'T\',z.U.T).E(\'O\',z.U.O+\'Q\').E(\'M\',z.U.M+\'Q\');A.2z(z.el.I(0),\'1j\');if(z.29&&z.29.1F==2w){z.29.1x(z.el.I(0))}}}},\'M\');z.e.1G(z.U.M-20,z.U.M)}},\'M\');z.e.1G(z.U.M+20,z.U.M-20)}},\'M\');z.e.1G(z.U.M,z.U.M+20)}};A.fn.1U({dR:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'4l\',\'in\',c)})},c6:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'4l\',\'3U\',c)})},fr:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'4l\',\'3E\',c)})},fq:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'41\',\'in\',c)})},fp:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'41\',\'3U\',c)})},fo:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'41\',\'3E\',c)})},fm:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'M\',\'in\',c)})},fl:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'M\',\'3U\',c)})},fk:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'M\',\'3E\',c)})},fj:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'2D\',\'in\',c)})},fi:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'2D\',\'3U\',c)})},fh:C(a,b,c){G B.1r(\'1j\',C(){W A.fx.1u(B,a,b,\'2D\',\'3E\',c)})}});A.fx.1u=C(e,a,b,c,d,f){if(!A.4n(e)){A.2z(e,\'1j\');G H}F z=B;z.el=A(e);z.1e=28 b==\'4B\'?b:f||P;z.29=28 b==\'C\'?b:P;if(d==\'3E\'){d=z.el.E(\'11\')==\'1k\'?\'in\':\'3U\'}if(!e.4f)e.4f=z.el.E(\'11\');z.el.1S();z.1l=a;z.fx=A.fx.9u(e);z.1K=d;z.6T=c;z.1T=C(){if(z.1K==\'3U\')z.el.E(\'2W\',\'2B\');A.fx.9n(z.fx.2Y.I(0),z.fx.U);if(z.1K==\'in\'){z.el.E(\'11\',z.el.I(0).4f==\'1k\'?\'2v\':z.el.I(0).4f)}L{z.el.E(\'11\',\'1k\');z.el.E(\'2W\',\'cl\')}if(z.29&&z.29.1F==2w){z.29.1x(z.el.I(0))}A.2z(z.el.I(0),\'1j\')};2X(z.6T){19\'4l\':z.ef=W A.fx(z.el.I(0),A.1l(z.1l,z.1e,z.1T),\'O\');z.79=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e),\'S\');if(z.1K==\'in\'){z.ef.1G(-z.fx.U.1o.hb,0);z.79.1G(0,z.fx.U.1o.hb)}L{z.ef.1G(0,-z.fx.U.1o.hb);z.79.1G(z.fx.U.1o.hb,0)}1n;19\'41\':z.ef=W A.fx(z.el.I(0),A.1l(z.1l,z.1e,z.1T),\'O\');if(z.1K==\'in\'){z.ef.1G(z.fx.U.1o.hb,0)}L{z.ef.1G(0,z.fx.U.1o.hb)}1n;19\'M\':z.ef=W A.fx(z.el.I(0),A.1l(z.1l,z.1e,z.1T),\'M\');z.79=W A.fx(z.fx.2Y.I(0),A.1l(z.1l,z.1e),\'V\');if(z.1K==\'in\'){z.ef.1G(-z.fx.U.1o.1D,0);z.79.1G(0,z.fx.U.1o.1D)}L{z.ef.1G(0,-z.fx.U.1o.1D);z.79.1G(z.fx.U.1o.1D,0)}1n;19\'2D\':z.ef=W A.fx(z.el.I(0),A.1l(z.1l,z.1e,z.1T),\'M\');if(z.1K==\'in\'){z.ef.1G(z.fx.U.1o.1D,0)}L{z.ef.1G(0,z.fx.U.1o.1D)}1n}};A.2O=P;A.fn.fg=C(o){G B.1r(\'1j\',C(){W A.fx.cj(B,o)})};A.fx.cj=C(e,o){if(A.2O==P){A(\'23\',1c).1L(\'<1W id="2O">\');A.2O=A(\'#2O\')}A.2O.E(\'11\',\'2v\').E(\'T\',\'1J\');F z=B;z.el=A(e);if(!o||!o.3v){G}if(o.3v.1F==8t&&1c.7o(o.3v)){o.3v=1c.7o(o.3v)}L if(!o.3v.ci){G}if(!o.1H){o.1H=ch}z.1H=o.1H;z.3v=o.3v;z.7e=o.2Z;z.1T=o.1T;if(z.7e){A.2O.2H(z.7e)}z.8s=0;z.8i=0;if(A.e0){z.8s=(R(A.2O.E(\'4y\'))||0)+(R(A.2O.E(\'5i\'))||0)+(R(A.2O.E(\'4F\'))||0)+(R(A.2O.E(\'5g\'))||0);z.8i=(R(A.2O.E(\'4x\'))||0)+(R(A.2O.E(\'5d\'))||0)+(R(A.2O.E(\'5b\'))||0)+(R(A.2O.E(\'4Q\'))||0)}z.2b=A.1U(A.12.3a(z.el.I(0)),A.12.2f(z.el.I(0)));z.3m=A.1U(A.12.3a(z.3v),A.12.2f(z.3v));z.2b.1D-=z.8s;z.2b.hb-=z.8i;z.3m.1D-=z.8s;z.3m.hb-=z.8i;z.29=o.1T;A.2O.E(\'V\',z.2b.1D+\'Q\').E(\'S\',z.2b.hb+\'Q\').E(\'O\',z.2b.y+\'Q\').E(\'M\',z.2b.x+\'Q\').4S({O:z.3m.y,M:z.3m.x,V:z.3m.1D,S:z.3m.hb},z.1H,C(){if(z.7e)A.2O.3S(z.7e);A.2O.E(\'11\',\'1k\');if(z.1T&&z.1T.1F==2w){z.1T.1x(z.el.I(0),[z.3v])}A.2z(z.el.I(0),\'1j\')})};A.1q={24:{2u:10,cf:\'1R/ff.ce\',cd:\'<3O 2E="1R/5o.cc" />\',cb:0.8,ca:\'fb 8G\',c9:\'6m\',3F:7n},fa:H,f8:H,5A:P,7m:H,7l:H,a3:C(a){if(!A.1q.7l||A.1q.7m)G;F b=a.6S||a.6R||-1;2X(b){19 35:if(A.1q.5A)A.1q.2b(P,A(\'a[@4o=\'+A.1q.5A+\']:f7\').I(0));1n;19 36:if(A.1q.5A)A.1q.2b(P,A(\'a[@4o=\'+A.1q.5A+\']:f6\').I(0));1n;19 37:19 8:19 33:19 80:19 f4:F c=A(\'#7j\');if(c.I(0).4q!=P){c.I(0).4q.1x(c.I(0))}1n;19 38:1n;19 39:19 34:19 32:19 fd:19 78:F d=A(\'#7h\');if(d.I(0).4q!=P){d.I(0).4q.1x(d.I(0))}1n;19 40:1n;19 27:A.1q.8q();1n}},6g:C(a){if(a)A.1U(A.1q.24,a);if(1P.3N){A(\'23\',1c).1C(\'5Q\',A.1q.a3)}L{A(1c).1C(\'5Q\',A.1q.a3)}A(\'a\').1y(C(){el=A(B);c5=el.1m(\'4o\')||\'\';c4=el.1m(\'2U\')||\'\';cg=/\\.cc|\\.f2|\\.7q|\\.ce|\\.f1/g;if(c4.5u().aD(cg)!=P&&c5.5u().3o(\'c2\')==0){el.1C(\'4U\',A.1q.2b)}});if(A.2R.46){3q=1c.3x(\'3q\');A(3q).1m({id:\'a1\',2E:\'dc:H;\',da:\'b0\',d7:\'b0\'}).E({11:\'1k\',T:\'1J\',O:\'0\',M:\'0\',4X:\'9x:9C.9E.a6(1E=0)\'});A(\'23\').1L(3q)}7r=1c.3x(\'1W\');A(7r).1m(\'id\',\'a0\').E({T:\'1J\',11:\'1k\',O:\'0\',M:\'0\',1E:0}).1L(1c.8b(\' \')).1C(\'4U\',A.1q.8q);5C=1c.3x(\'1W\');A(5C).1m(\'id\',\'c0\').E({4F:A.1q.24.2u+\'Q\'}).1L(1c.8b(\' \'));9Z=1c.3x(\'1W\');A(9Z).1m(\'id\',\'bY\').E({4F:A.1q.24.2u+\'Q\',4Q:A.1q.24.2u+\'Q\'}).1L(1c.8b(\' \'));9Y=1c.3x(\'a\');A(9Y).1m({id:\'f0\',2U:\'#\'}).E({T:\'1J\',2D:A.1q.24.2u+\'Q\',O:\'0\'}).1L(A.1q.24.cd).1C(\'4U\',A.1q.8q);6Z=1c.3x(\'1W\');A(6Z).1m(\'id\',\'9X\').E({T:\'2i\',9W:\'M\',5X:\'0 8x\',3j:1}).1L(5C).1L(9Z).1L(9Y);21=1c.3x(\'3O\');21.2E=A.1q.24.cf;A(21).1m(\'id\',\'bW\').E({T:\'1J\'});5G=1c.3x(\'a\');A(5G).1m({id:\'7j\',2U:\'#\'}).E({T:\'1J\',11:\'1k\',2N:\'2B\',cC:\'1k\'}).1L(1c.8b(\' \'));5F=1c.3x(\'a\');A(5F).1m({id:\'7h\',2U:\'#\'}).E({T:\'1J\',2N:\'2B\',cC:\'1k\'}).1L(1c.8b(\' \'));2q=1c.3x(\'1W\');A(2q).1m(\'id\',\'bT\').E({11:\'1k\',T:\'2i\',2N:\'2B\',9W:\'M\',5X:\'0 8x\',O:\'0\',M:\'0\',3j:2}).1L([21,5G,5F]);5Z=1c.3x(\'1W\');A(5Z).1m(\'id\',\'8m\').E({11:\'1k\',T:\'1J\',2N:\'2B\',O:\'0\',M:\'0\',9W:\'az\',6P:\'b7\',eY:\'0\'}).1L([2q,6Z]);A(\'23\').1L(7r).1L(5Z)},2b:C(e,a){el=a?A(a):A(B);8J=el.1m(\'4o\');F b,4E,5G,5F;if(8J!=\'c2\'){A.1q.5A=8J;7F=A(\'a[@4o=\'+8J+\']\');b=7F.1N();4E=7F.aY(a?a:B);5G=7F.I(4E-1);5F=7F.I(4E+1)}aw=el.1m(\'2U\');5C=el.1m(\'3T\');3R=A.12.5O();7r=A(\'#a0\');if(!A.1q.7l){A.1q.7l=14;if(A.2R.46){A(\'#a1\').E(\'S\',Z.3g(3R.ih,3R.h)+\'Q\').E(\'V\',Z.3g(3R.iw,3R.w)+\'Q\').1S()}7r.E(\'S\',Z.3g(3R.ih,3R.h)+\'Q\').E(\'V\',Z.3g(3R.iw,3R.w)+\'Q\').1S().bS(bz,A.1q.24.cb,C(){A.1q.aB(aw,5C,3R,b,4E,5G,5F)});A(\'#8m\').E(\'V\',Z.3g(3R.iw,3R.w)+\'Q\')}L{A(\'#7j\').I(0).4q=P;A(\'#7h\').I(0).4q=P;A.1q.aB(aw,5C,3R,b,4E,5G,5F)}G H},aB:C(a,b,c,d,e,f,g){A(\'#aA\').9U();8l=A(\'#7j\');8l.2x();8k=A(\'#7h\');8k.2x();21=A(\'#bW\');2q=A(\'#bT\');5Z=A(\'#8m\');6Z=A(\'#9X\').E(\'2W\',\'2B\');A(\'#c0\').3i(5C);A.1q.7m=14;if(d)A(\'#bY\').3i(A.1q.24.ca+\' \'+(e+1)+\' \'+A.1q.24.c9+\' \'+d);if(f){8l.I(0).4q=C(){B.4W();A.1q.2b(P,f);G H}}if(g){8k.I(0).4q=C(){B.4W();A.1q.2b(P,g);G H}}21.1S();7u=A.12.2f(2q.I(0));4C=Z.3g(7u.1D,21.I(0).V+A.1q.24.2u*2);59=Z.3g(7u.hb,21.I(0).S+A.1q.24.2u*2);21.E({M:(4C-21.I(0).V)/2+\'Q\',O:(59-21.I(0).S)/2+\'Q\'});2q.E({V:4C+\'Q\',S:59+\'Q\'}).1S();bQ=A.12.a5();5Z.E(\'O\',c.t+(bQ.h/15)+\'Q\');if(5Z.E(\'11\')==\'1k\'){5Z.1S().6U(A.1q.24.3F)}5H=W 8M;A(5H).1m(\'id\',\'aA\').1C(\'eP\',C(){4C=5H.V+A.1q.24.2u*2;59=5H.S+A.1q.24.2u*2;21.2x();2q.4S({S:59},7u.hb!=59?A.1q.24.3F:1,C(){2q.4S({V:4C},7u.1D!=4C?A.1q.24.3F:1,C(){2q.aJ(5H);A(5H).E({T:\'1J\',M:A.1q.24.2u+\'Q\',O:A.1q.24.2u+\'Q\'}).6U(A.1q.24.3F,C(){cL=A.12.2f(6Z.I(0));if(f){8l.E({M:A.1q.24.2u+\'Q\',O:A.1q.24.2u+\'Q\',V:4C/2-A.1q.24.2u*3+\'Q\',S:59-A.1q.24.2u*2+\'Q\'}).1S()}if(g){8k.E({M:4C/2+A.1q.24.2u*2+\'Q\',O:A.1q.24.2u+\'Q\',V:4C/2-A.1q.24.2u*3+\'Q\',S:59-A.1q.24.2u*2+\'Q\'}).1S()}6Z.E({V:4C+\'Q\',O:-cL.hb+\'Q\',2W:\'cl\'}).4S({O:-1},A.1q.24.3F,C(){A.1q.7m=H})})})})});5H.2E=a},8q:C(){A(\'#aA\').9U();A(\'#8m\').2x();A(\'#9X\').E(\'2W\',\'2B\');A(\'#a0\').bS(bz,0,C(){A(B).2x();if(A.2R.46){A(\'#a1\').2x()}});A(\'#7j\').I(0).4q=P;A(\'#7h\').I(0).4q=P;A.1q.5A=P;A.1q.7l=H;A.1q.7m=H;G H}};A.N={1v:P,3A:P,1g:P,1A:P,1o:P,T:P,7f:C(e){A.N.1g=(B.9T)?B.9T:B;A.N.1A=A.12.3W(e);A.N.1o={V:R(A(A.N.1g).E(\'V\'))||0,S:R(A(A.N.1g).E(\'S\'))||0};A.N.T={O:R(A(A.N.1g).E(\'O\'))||0,M:R(A(A.N.1g).E(\'M\'))||0};A(1c).1C(\'3t\',A.N.aO).1C(\'5n\',A.N.aN);if(28 A.N.1g.1h.bO===\'C\'){A.N.1g.1h.bO.1x(A.N.1g)}G H},aN:C(e){A(1c).3h(\'3t\',A.N.aO).3h(\'5n\',A.N.aN);if(28 A.N.1g.1h.cO===\'C\'){A.N.1g.1h.cO.1x(A.N.1g)}A.N.1g=P},aO:C(e){if(!A.N.1g){G}1A=A.12.3W(e);6c=A.N.T.O-A.N.1A.y+1A.y;77=A.N.T.M-A.N.1A.x+1A.x;6c=Z.3g(Z.3k(6c,A.N.1g.1h.7d-A.N.1o.S),A.N.1g.1h.6F);77=Z.3g(Z.3k(77,A.N.1g.1h.7c-A.N.1o.V),A.N.1g.1h.6u);if(28 A.N.1g.1h.4h===\'C\'){F a=A.N.1g.1h.4h.1x(A.N.1g,[77,6c]);if(28 a==\'eI\'&&a.1b==2){77=a[0];6c=a[1]}}A.N.1g.Y.O=6c+\'Q\';A.N.1g.Y.M=77+\'Q\';G H},2b:C(e){A(1c).1C(\'3t\',A.N.7g).1C(\'5n\',A.N.7w);A.N.1v=B.1v;A.N.3A=B.3A;A.N.1A=A.12.3W(e);A.N.1o={V:R(A(B.1v).E(\'V\'))||0,S:R(A(B.1v).E(\'S\'))||0};A.N.T={O:R(A(B.1v).E(\'O\'))||0,M:R(A(B.1v).E(\'M\'))||0};if(A.N.1v.1h.4c){A.N.1v.1h.4c.1x(A.N.1v,[B])}G H},7w:C(){A(1c).3h(\'3t\',A.N.7g).3h(\'5n\',A.N.7w);if(A.N.1v.1h.3C){A.N.1v.1h.3C.1x(A.N.1v,[A.N.3A])}A.N.1v=P;A.N.3A=P},5N:C(a,b){G Z.3k(Z.3g(A.N.1o.V+a*b,A.N.1v.1h.8O),A.N.1v.1h.5R)},5M:C(a,b){G Z.3k(Z.3g(A.N.1o.S+a*b,A.N.1v.1h.7x),A.N.1v.1h.7y)},bN:C(a){G Z.3k(Z.3g(a,A.N.1v.1h.7x),A.N.1v.1h.7y)},7g:C(e){if(A.N.1v==P){G}1A=A.12.3W(e);dx=1A.x-A.N.1A.x;dy=1A.y-A.N.1A.y;1B={V:A.N.1o.V,S:A.N.1o.S};2s={O:A.N.T.O,M:A.N.T.M};2X(A.N.3A){19\'e\':1B.V=A.N.5N(dx,1);1n;19\'eH\':1B.V=A.N.5N(dx,1);1B.S=A.N.5M(dy,1);1n;19\'w\':1B.V=A.N.5N(dx,-1);2s.M=A.N.T.M-1B.V+A.N.1o.V;1n;19\'9R\':1B.V=A.N.5N(dx,-1);2s.M=A.N.T.M-1B.V+A.N.1o.V;1B.S=A.N.5M(dy,1);1n;19\'7a\':1B.S=A.N.5M(dy,-1);2s.O=A.N.T.O-1B.S+A.N.1o.S;1B.V=A.N.5N(dx,-1);2s.M=A.N.T.M-1B.V+A.N.1o.V;1n;19\'n\':1B.S=A.N.5M(dy,-1);2s.O=A.N.T.O-1B.S+A.N.1o.S;1n;19\'9Q\':1B.S=A.N.5M(dy,-1);2s.O=A.N.T.O-1B.S+A.N.1o.S;1B.V=A.N.5N(dx,1);1n;19\'s\':1B.S=A.N.5M(dy,1);1n}if(A.N.1v.1h.44){if(A.N.3A==\'n\'||A.N.3A==\'s\')43=1B.S*A.N.1v.1h.44;L 43=1B.V;4z=A.N.bN(43*A.N.1v.1h.44);43=4z/A.N.1v.1h.44;2X(A.N.3A){19\'n\':19\'7a\':19\'9Q\':2s.O+=1B.S-4z;1n}2X(A.N.3A){19\'7a\':19\'w\':19\'9R\':2s.M+=1B.V-43;1n}1B.S=4z;1B.V=43}if(2s.OA.N.1v.1h.7d){1B.S=A.N.1v.1h.7d-2s.O;if(A.N.1v.1h.44){1B.V=1B.S/A.N.1v.1h.44}}if(2s.M+1B.V>A.N.1v.1h.7c){1B.V=A.N.1v.1h.7c-2s.M;if(A.N.1v.1h.44){1B.S=1B.V*A.N.1v.1h.44}}F a=H;if(A.N.1v.1h.eG){a=A.N.1v.1h.eG.1x(A.N.1v,[1B,2s]);if(a){if(a.1o){A.1U(1B,a.1o)}if(a.T){A.1U(2s,a.T)}}}8f=A.N.1v.Y;8f.M=2s.M+\'Q\';8f.O=2s.O+\'Q\';8f.V=1B.V+\'Q\';8f.S=1B.S+\'Q\';G H},2l:C(b){if(!b||!b.3G||b.3G.1F!=6E){G}G B.1y(C(){F a=B;a.1h=b;a.1h.8O=b.8O||10;a.1h.7x=b.7x||10;a.1h.5R=b.5R||5P;a.1h.7y=b.7y||5P;a.1h.6F=b.6F||-8V;a.1h.6u=b.6u||-8V;a.1h.7c=b.7c||5P;a.1h.7d=b.7d||5P;bK=A(a).E(\'T\');if(!(bK==\'2i\'||bK==\'1J\')){a.Y.T=\'2i\'}eE=/n|9Q|e|eH|s|9R|w|7a/g;1V(i in a.1h.3G){if(i.5u().aD(eE)!=P){if(a.1h.3G[i].1F==8t){3c=A(a.1h.3G[i]);if(3c.1N()>0){a.1h.3G[i]=3c.I(0)}}if(a.1h.3G[i].4D){a.1h.3G[i].1v=a;a.1h.3G[i].3A=i;A(a.1h.3G[i]).1C(\'4R\',A.N.2b)}}}if(a.1h.5k){if(28 a.1h.5k===\'4B\'){9N=A(a.1h.5k);if(9N.1N()>0){9N.1y(C(){B.9T=a});9N.1C(\'4R\',A.N.7f)}}L if(a.1h.5k==14){A(B).1C(\'4R\',A.N.7f)}}})},4v:C(){G B.1y(C(){F a=B;1V(i in a.1h.3G){a.1h.3G[i].1v=P;a.1h.3G[i].3A=P;A(a.1h.3G[i]).3h(\'4R\',A.N.2b)}if(a.1h.5k){if(28 a.1h.5k===\'4B\'){3c=A(a.1h.5k);if(3c.1N()>0){3c.3h(\'4R\',A.N.7f)}}L if(a.1h.5k==14){A(B).3h(\'4R\',A.N.7f)}}a.1h=P})}};A.fn.1U({jk:A.N.2l,jj:A.N.4v});A.2t=P;A.6J=H;A.31=P;A.6B=[];A.9L=C(e){F a=e.6S||e.6R||-1;if(a==17||a==16){A.6J=14}};A.9J=C(e){A.6J=H};A.eB=C(e){B.f.1A=A.12.3W(e);B.f.1I=A.1U(A.12.3a(B),A.12.2f(B));B.f.4p=A.12.5O(B);B.f.1A.x-=B.f.1I.x;B.f.1A.y-=B.f.1I.y;A(B).1L(A.2t.I(0));if(B.f.hc)A.2t.2H(B.f.hc).E(\'11\',\'2v\');A.2t.E({11:\'2v\',V:\'2G\',S:\'2G\'});if(B.f.o){A.2t.E(\'1E\',B.f.o)}A.31=B;A.7A=H;A.6B=[];B.f.el.1y(C(){B.1I={x:B.7Y+(B.4u&&!A.2R.6l?R(B.4u.4y)||0:0)+(A.31.2P||0),y:B.7t+(B.4u&&!A.2R.6l?R(B.4u.4x)||0:0)+(A.31.2T||0),1D:B.3P,hb:B.5r};if(B.s==14){if(A.6J==H){B.s=H;A(B).3S(A.31.f.71)}L{A.7A=14;A.6B[A.6B.1b]=A.1m(B,\'id\')}}});A.9H.1x(B,[e]);A(1c).1C(\'3t\',A.9H).1C(\'5n\',A.bI);G H};A.9H=C(e){if(!A.31)G;A.eA.1x(A.31,[e])};A.eA=C(e){if(!A.31)G;F a=A.12.3W(e);F b=A.12.5O(A.31);a.x+=b.l-B.f.4p.l-B.f.1I.x;a.y+=b.t-B.f.4p.t-B.f.1I.y;F c=Z.3k(a.x,B.f.1A.x);F d=Z.3k(Z.3B(a.x-B.f.1A.x),Z.3B(B.f.4p.w-c));F f=Z.3k(a.y,B.f.1A.y);F g=Z.3k(Z.3B(a.y-B.f.1A.y),Z.3B(B.f.4p.h-f));if(B.2T>0&&a.y-20B.2T+B.f.1I.h){F h=Z.3k(B.f.4p.h-B.2T,10);B.2T+=h;if(B.2T!=b.t)g+=h}if(B.2P>0&&a.x-20B.2P+B.f.1I.w){F h=Z.3k(B.f.4p.w-B.2P,10);B.2P+=h;if(B.2P!=b.l)d+=h}A.2t.E({M:c+\'Q\',O:f+\'Q\',V:d+\'Q\',S:g+\'Q\'});A.2t.l=c+B.f.4p.l;A.2t.t=f+B.f.4p.t;A.2t.r=A.2t.l+d;A.2t.b=A.2t.t+g;A.7A=H;B.f.el.1y(C(){9G=A.6B.3o(A.1m(B,\'id\'));if(!(B.1I.x>A.2t.r||(B.1I.x+B.1I.1D)A.2t.b||(B.1I.y+B.1I.hb)0){h+=\'&\'}h+=s+\'[]=\'+A.1m(B,\'id\');o[o.1b]=A.1m(B,\'id\')}})}G{6A:h,o:o}};A.fn.jg=C(o){if(!A.2t){A(\'23\',1c).1L(\'<1W id="2t">\').1C(\'70\',A.9L).1C(\'5Q\',A.9J);A.2t=A(\'#2t\');A.2t.E({T:\'1J\',11:\'1k\'});if(1P.3N){A(\'23\',1c).1C(\'70\',A.9L).1C(\'5Q\',A.9J)}L{A(1c).1C(\'70\',A.9L).1C(\'5Q\',A.9J)}}if(!o){o={}}G B.1y(C(){if(B.ey)G;B.ey=14;B.f={a:o.3r,o:o.1E?2c(o.1E):H,71:o.ex?o.ex:H,hc:o.4G?o.4G:H,8d:o.8d?o.8d:H,8c:o.8c?o.8c:H};B.f.el=A(\'.\'+o.3r);A(B).1C(\'4R\',A.eB).E(\'T\',\'2i\')})};A.2Q={aT:1,ew:C(b){F b=b;G B.1y(C(){B.4g.69.1y(C(a){A.2Q.4s(B,b[a])})})},I:C(){F e=[];B.1y(C(b){if(B.bD){e[b]=[];F c=B;F d=A.12.2f(B);B.4g.69.1y(C(a){F x=B.7Y;F y=B.7t;7B=R(x*1Y/(d.w-B.3P));7C=R(y*1Y/(d.h-B.5r));e[b][a]=[7B||0,7C||0,x||0,y||0]})}});G e},ad:C(a){a.D.ep=a.D.1Z.w-a.D.1w.1D;a.D.eo=a.D.1Z.h-a.D.1w.hb;if(a.92.4g.bB){8Z=a.92.4g.69.I(a.bA+1);if(8Z){a.D.1Z.w=(R(A(8Z).E(\'M\'))||0)+a.D.1w.1D;a.D.1Z.h=(R(A(8Z).E(\'O\'))||0)+a.D.1w.hb}9f=a.92.4g.69.I(a.bA-1);if(9f){F b=R(A(9f).E(\'M\'))||0;F c=R(A(9f).E(\'M\'))||0;a.D.1Z.x+=b;a.D.1Z.y+=c;a.D.1Z.w-=b;a.D.1Z.h-=c}}a.D.ek=a.D.1Z.w-a.D.1w.1D;a.D.ej=a.D.1Z.h-a.D.1w.hb;if(a.D.2C){a.D.gx=((a.D.1Z.w-a.D.1w.1D)/a.D.2C)||1;a.D.gy=((a.D.1Z.h-a.D.1w.hb)/a.D.2C)||1;a.D.d1=a.D.ek/a.D.2C;a.D.d0=a.D.ej/a.D.2C}a.D.1Z.dx=a.D.1Z.x-a.D.22.x;a.D.1Z.dy=a.D.1Z.y-a.D.22.y;A.X.18.E(\'7z\',\'8T\')},3n:C(a,x,y){if(a.D.2C){d9=R(x/a.D.d1);7B=d9*1Y/a.D.2C;d5=R(y/a.D.d0);7C=d5*1Y/a.D.2C}L{7B=R(x*1Y/a.D.ep);7C=R(y*1Y/a.D.eo)}a.D.aa=[7B||0,7C||0,x||0,y||0];if(a.D.3n)a.D.3n.1x(a,a.D.aa)},d3:C(a){6K=a.6S||a.6R||-1;2X(6K){19 35:A.2Q.4s(B.3H,[91,91]);1n;19 36:A.2Q.4s(B.3H,[-91,-91]);1n;19 37:A.2Q.4s(B.3H,[-B.3H.D.gx||-1,0]);1n;19 38:A.2Q.4s(B.3H,[0,-B.3H.D.gy||-1]);1n;19 39:A.2Q.4s(B.3H,[B.3H.D.gx||1,0]);1n;19 40:A.X.4s(B.3H,[0,B.3H.D.gy||1]);1n}},4s:C(a,b){if(!a.D){G}a.D.1w=A.1U(A.12.3a(a),A.12.2f(a));a.D.22={x:R(A.E(a,\'M\'))||0,y:R(A.E(a,\'O\'))||0};a.D.49=A.E(a,\'T\');if(a.D.49!=\'2i\'&&a.D.49!=\'1J\'){a.Y.T=\'2i\'}A.X.ah(a);A.2Q.ad(a);dx=R(b[0])||0;dy=R(b[1])||0;2n=a.D.22.x+dx;2j=a.D.22.y+dy;if(a.D.2C){57=A.X.a9.1x(a,[2n,2j,dx,dy]);if(57.1F==6E){dx=57.dx;dy=57.dy}2n=a.D.22.x+dx;2j=a.D.22.y+dy}57=A.X.ae.1x(a,[2n,2j,dx,dy]);if(57&&57.1F==6E){dx=57.dx;dy=57.dy}2n=a.D.22.x+dx;2j=a.D.22.y+dy;if(a.D.4P&&(a.D.3n||a.D.2I)){A.2Q.3n(a,2n,2j)}2n=!a.D.2g||a.D.2g==\'3Z\'?2n:a.D.22.x||0;2j=!a.D.2g||a.D.2g==\'3K\'?2j:a.D.22.y||0;a.Y.M=2n+\'Q\';a.Y.O=2j+\'Q\'},2l:C(o){G B.1y(C(){if(B.bD==14||!o.3r||!A.12||!A.X||!A.1s){G}4Y=A(o.3r,B);if(4Y.1N()==0){G}F b={2e:\'7X\',4P:14,3n:o.3n&&o.3n.1F==2w?o.3n:P,2I:o.2I&&o.2I.1F==2w?o.2I:P,3c:B,1E:o.1E||H};if(o.2C&&R(o.2C)){b.2C=R(o.2C)||1;b.2C=b.2C>0?b.2C:1}if(4Y.1N()==1)4Y.6r(b);L{A(4Y.I(0)).6r(b);b.3c=P;4Y.6r(b)}4Y.70(A.2Q.d3);4Y.1m(\'aT\',A.2Q.aT++);B.bD=14;B.4g={};B.4g.ec=b.ec;B.4g.2C=b.2C;B.4g.69=4Y;B.4g.bB=o.bB?14:H;by=B;by.4g.69.1y(C(a){B.bA=a;B.92=by});if(o.5f&&o.5f.1F==6h){1V(i=o.5f.1b-1;i>=0;i--){if(o.5f[i].1F==6h&&o.5f[i].1b==2){el=B.4g.69.I(i);if(el.4D){A.2Q.4s(el,o.5f[i])}}}}})}};A.fn.1U({jc:A.2Q.2l,jb:A.2Q.ew,ja:A.2Q.I});A.2p={56:[],ea:C(){B.4W();1d=B.2S;id=A.1m(1d,\'id\');if(A.2p.56[id]!=P){1P.5h(A.2p.56[id])}1u=1d.J.3d+1;if(1d.J.1R.1b<1u){1u=1}1R=A(\'3O\',1d.J.4O);1d.J.3d=1u;if(1R.1N()>0){1R.6d(1d.J.3F,A.2p.7J)}},di:C(){B.4W();1d=B.2S;id=A.1m(1d,\'id\');if(A.2p.56[id]!=P){1P.5h(A.2p.56[id])}1u=1d.J.3d-1;1R=A(\'3O\',1d.J.4O);if(1u<1){1u=1d.J.1R.1b}1d.J.3d=1u;if(1R.1N()>0){1R.6d(1d.J.3F,A.2p.7J)}},2A:C(c){1d=1c.7o(c);if(1d.J.63){1u=1d.J.3d;6k(1u==1d.J.3d){1u=1+R(Z.63()*1d.J.1R.1b)}}L{1u=1d.J.3d+1;if(1d.J.1R.1b<1u){1u=1}}1R=A(\'3O\',1d.J.4O);1d.J.3d=1u;if(1R.1N()>0){1R.6d(1d.J.3F,A.2p.7J)}},go:C(o){F a;if(o&&o.1F==6E){if(o.21){a=1c.7o(o.21.1d);5v=1P.j8.2U.6W("#");o.21.5J=P;if(5v.1b==2){1u=R(5v[1]);1S=5v[1].48(1u,\'\');if(A.1m(a,\'id\')!=1S){1u=1}}L{1u=1}}if(o.84){o.84.4W();a=o.84.2S.2S;id=A.1m(a,\'id\');if(A.2p.56[id]!=P){1P.5h(A.2p.56[id])}5v=o.84.2U.6W("#");1u=R(5v[1]);1S=5v[1].48(1u,\'\');if(A.1m(a,\'id\')!=1S){1u=1}}if(a.J.1R.1b<1u||1u<1){1u=1}a.J.3d=1u;4t=A.12.2f(a);e4=A.12.9y(a);e3=A.12.6b(a);if(a.J.3e){a.J.3e.o.E(\'11\',\'1k\')}if(a.J.3b){a.J.3b.o.E(\'11\',\'1k\')}if(a.J.21){y=R(e4.t)+R(e3.t);if(a.J.1Q){if(a.J.1Q.4J==\'O\'){y+=a.J.1Q.45.hb}L{4t.h-=a.J.1Q.45.hb}}if(a.J.2o){if(a.J.2o&&a.J.2o.5V==\'O\'){y+=a.J.2o.45.hb}L{4t.h-=a.J.2o.45.hb}}if(!a.J.bu){a.J.e1=o.21?o.21.S:(R(a.J.21.E(\'S\'))||0);a.J.bu=o.21?o.21.V:(R(a.J.21.E(\'V\'))||0)}a.J.21.E(\'O\',y+(4t.h-a.J.e1)/2+\'Q\');a.J.21.E(\'M\',(4t.1D-a.J.bu)/2+\'Q\');a.J.21.E(\'11\',\'2v\')}1R=A(\'3O\',a.J.4O);if(1R.1N()>0){1R.6d(a.J.3F,A.2p.7J)}L{9w=A(\'a\',a.J.1Q.o).I(1u-1);A(9w).2H(a.J.1Q.5s);F b=W 8M();b.1d=A.1m(a,\'id\');b.1u=1u-1;b.2E=a.J.1R[a.J.3d-1].2E;if(b.1T){b.5J=P;A.2p.11.1x(b)}L{b.5J=A.2p.11}if(a.J.2o){a.J.2o.o.3i(a.J.1R[1u-1].5W)}}}},7J:C(){1d=B.2S.2S;1d.J.4O.E(\'11\',\'1k\');if(1d.J.1Q.5s){9w=A(\'a\',1d.J.1Q.o).3S(1d.J.1Q.5s).I(1d.J.3d-1);A(9w).2H(1d.J.1Q.5s)}F a=W 8M();a.1d=A.1m(1d,\'id\');a.1u=1d.J.3d-1;a.2E=1d.J.1R[1d.J.3d-1].2E;if(a.1T){a.5J=P;A.2p.11.1x(a)}L{a.5J=A.2p.11}if(1d.J.2o){1d.J.2o.o.3i(1d.J.1R[1d.J.3d-1].5W)}},11:C(){1d=1c.7o(B.1d);if(1d.J.3e){1d.J.3e.o.E(\'11\',\'1k\')}if(1d.J.3b){1d.J.3b.o.E(\'11\',\'1k\')}4t=A.12.2f(1d);y=0;if(1d.J.1Q){if(1d.J.1Q.4J==\'O\'){y+=1d.J.1Q.45.hb}L{4t.h-=1d.J.1Q.45.hb}}if(1d.J.2o){if(1d.J.2o&&1d.J.2o.5V==\'O\'){y+=1d.J.2o.45.hb}L{4t.h-=1d.J.2o.45.hb}}j4=A(\'.bt\',1d);y=y+(4t.h-B.S)/2;x=(4t.1D-B.V)/2;1d.J.4O.E(\'O\',y+\'Q\').E(\'M\',x+\'Q\').3i(\'<3O 2E="\'+B.2E+\'" />\');1d.J.4O.6U(1d.J.3F);3b=1d.J.3d+1;if(3b>1d.J.1R.1b){3b=1}3e=1d.J.3d-1;if(3e<1){3e=1d.J.1R.1b}1d.J.3b.o.E(\'11\',\'2v\').E(\'O\',y+\'Q\').E(\'M\',x+2*B.V/3+\'Q\').E(\'V\',B.V/3+\'Q\').E(\'S\',B.S+\'Q\').1m(\'3T\',1d.J.1R[3b-1].5W);1d.J.3b.o.I(0).2U=\'#\'+3b+A.1m(1d,\'id\');1d.J.3e.o.E(\'11\',\'2v\').E(\'O\',y+\'Q\').E(\'M\',x+\'Q\').E(\'V\',B.V/3+\'Q\').E(\'S\',B.S+\'Q\').1m(\'3T\',1d.J.1R[3e-1].5W);1d.J.3e.o.I(0).2U=\'#\'+3e+A.1m(1d,\'id\')},2l:C(o){if(!o||!o.2q||A.2p.56[o.2q])G;F a=A(\'#\'+o.2q);F c=a.I(0);if(c.Y.T!=\'1J\'&&c.Y.T!=\'2i\'){c.Y.T=\'2i\'}c.Y.2N=\'2B\';if(a.1N()==0)G;c.J={};c.J.1R=o.1R?o.1R:[];c.J.63=o.63&&o.63==14||H;7T=c.dj(\'j3\');1V(i=0;i<7T.1b;i++){6e=c.J.1R.1b;c.J.1R[6e]={2E:7T[i].2E,5W:7T[i].3T||7T[i].j2||\'\'}}if(c.J.1R.1b==0){G}c.J.49=A.1U(A.12.3a(c),A.12.2f(c));c.J.bp=A.12.9y(c);c.J.bo=A.12.6b(c);t=R(c.J.bp.t)+R(c.J.bo.t);b=R(c.J.bp.b)+R(c.J.bo.b);A(\'3O\',c).9U();c.J.3F=o.3F?o.3F:ch;if(o.4J||o.82||o.5s){c.J.1Q={};a.1L(\'<1W 68="dZ">\');c.J.1Q.o=A(\'.dZ\',c);if(o.82){c.J.1Q.82=o.82;c.J.1Q.o.2H(o.82)}if(o.5s){c.J.1Q.5s=o.5s}c.J.1Q.o.E(\'T\',\'1J\').E(\'V\',c.J.49.w+\'Q\');if(o.4J&&o.4J==\'O\'){c.J.1Q.4J=\'O\';c.J.1Q.o.E(\'O\',t+\'Q\')}L{c.J.1Q.4J=\'4e\';c.J.1Q.o.E(\'4e\',b+\'Q\')}c.J.1Q.9v=o.9v?o.9v:\' \';1V(F i=0;i\'+6e+\'\'+(6e!=c.J.1R.1b?c.J.1Q.9v:\'\'))}A(\'a\',c.J.1Q.o).1C(\'4U\',C(){A.2p.go({84:B})});c.J.1Q.45=A.12.2f(c.J.1Q.o.I(0))}if(o.5V||o.81){c.J.2o={};a.1L(\'<1W 68="dW">&6G;\');c.J.2o.o=A(\'.dW\',c);if(o.81){c.J.2o.81=o.81;c.J.2o.o.2H(o.81)}c.J.2o.o.E(\'T\',\'1J\').E(\'V\',c.J.49.w+\'Q\');if(o.5V&&o.5V==\'O\'){c.J.2o.5V=\'O\';c.J.2o.o.E(\'O\',(c.J.1Q&&c.J.1Q.4J==\'O\'?c.J.1Q.45.hb+t:t)+\'Q\')}L{c.J.2o.5V=\'4e\';c.J.2o.o.E(\'4e\',(c.J.1Q&&c.J.1Q.4J==\'4e\'?c.J.1Q.45.hb+b:b)+\'Q\')}c.J.2o.45=A.12.2f(c.J.2o.o.I(0))}if(o.9j){c.J.3b={9j:o.9j};a.1L(\'&6G;\');c.J.3b.o=A(\'.dV\',c);c.J.3b.o.E(\'T\',\'1J\').E(\'11\',\'1k\').E(\'2N\',\'2B\').E(\'4a\',\'dU\').2H(c.J.3b.9j);c.J.3b.o.1C(\'4U\',A.2p.ea)}if(o.9t){c.J.3e={9t:o.9t};a.1L(\'&6G;\');c.J.3e.o=A(\'.dS\',c);c.J.3e.o.E(\'T\',\'1J\').E(\'11\',\'1k\').E(\'2N\',\'2B\').E(\'4a\',\'dU\').2H(c.J.3e.9t);c.J.3e.o.1C(\'4U\',A.2p.di)}a.aJ(\'<1W 68="bt">\');c.J.4O=A(\'.bt\',c);c.J.4O.E(\'T\',\'1J\').E(\'O\',\'2G\').E(\'M\',\'2G\').E(\'11\',\'1k\');if(o.21){a.aJ(\'<1W 68="dz" Y="11: 1k;"><3O 2E="\'+o.21+\'" />\');c.J.21=A(\'.dz\',c);c.J.21.E(\'T\',\'1J\');F d=W 8M();d.1d=o.2q;d.2E=o.21;if(d.1T){d.5J=P;A.2p.go({21:d})}L{d.5J=C(){A.2p.go({21:B})}}}L{A.2p.go({2q:c})}if(o.ba){dQ=R(o.ba)*8V}A.2p.56[o.2q]=o.ba?1P.5Y(\'A.2p.2A(\\\'\'+o.2q+\'\\\')\',dQ):P}};A.1d=A.2p.2l;A.1p={73:[],54:{},18:H,6X:P,2b:C(){if(A.X.1g==P){G}F a,3s,c,cs;A.1p.18.I(0).2Z=A.X.1g.D.5z;a=A.1p.18.I(0).Y;a.11=\'2v\';A.1p.18.1w=A.1U(A.12.3a(A.1p.18.I(0)),A.12.2f(A.1p.18.I(0)));a.V=A.X.1g.D.1w.1D+\'Q\';a.S=A.X.1g.D.1w.hb+\'Q\';3s=A.12.b2(A.X.1g);a.4M=3s.t;a.53=3s.r;a.4L=3s.b;a.4K=3s.l;if(A.X.1g.D.3L==14){c=A(A.X.1g).cA(14).I(0);cs=c.Y;cs.4M=\'2G\';cs.53=\'2G\';cs.4L=\'2G\';cs.4K=\'2G\';cs.11=\'2v\';A.1p.18.58().1L(c)}A(A.X.1g).dO(A.1p.18.I(0));A.X.1g.Y.11=\'1k\'},c7:C(e){if(!e.D.3I&&A.1s.4T.bC){if(e.D.3C)e.D.3C.1x(1g);A(e).E(\'T\',e.D.av||e.D.49);A(e).8j();A(A.1s.4T).dN(e)}A.1p.18.3S(e.D.5z).3i(\'&6G;\');A.1p.6X=P;F a=A.1p.18.I(0).Y;a.11=\'1k\';A.1p.18.dO(e);if(e.D.fx>0){A(e).6U(e.D.fx)}A(\'23\').1L(A.1p.18.I(0));F b=[];F c=H;1V(F i=0;i0){c(b)}},8n:C(e,o){if(!A.X.1g)G;F a=H;F i=0;if(e.1f.el.1N()>0){1V(i=e.1f.el.1N();i>0;i--){if(e.1f.el.I(i-1)!=A.X.1g){if(!e.5t.bb){if((e.1f.el.I(i-1).1I.y+e.1f.el.I(i-1).1I.hb/2)>A.X.1g.D.2j){a=e.1f.el.I(i-1)}L{1n}}L{if((e.1f.el.I(i-1).1I.x+e.1f.el.I(i-1).1I.1D/2)>A.X.1g.D.2n&&(e.1f.el.I(i-1).1I.y+e.1f.el.I(i-1).1I.hb/2)>A.X.1g.D.2j){a=e.1f.el.I(i-1)}}}}}if(a&&A.1p.6X!=a){A.1p.6X=a;A(a).iT(A.1p.18.I(0))}L if(!a&&(A.1p.6X!=P||A.1p.18.I(0).2S!=e)){A.1p.6X=P;A(e).1L(A.1p.18.I(0))}A.1p.18.I(0).Y.11=\'2v\'},bM:C(e){if(A.X.1g==P){G}e.1f.el.1y(C(){B.1I=A.1U(A.12.6w(B),A.12.6x(B))})},8g:C(s){F i;F h=\'\';F o={};if(s){if(A.1p.54[s]){o[s]=[];A(\'#\'+s+\' .\'+A.1p.54[s]).1y(C(){if(h.1b>0){h+=\'&\'}h+=s+\'[]=\'+A.1m(B,\'id\');o[s][o[s].1b]=A.1m(B,\'id\')})}L{1V(a in s){if(A.1p.54[s[a]]){o[s[a]]=[];A(\'#\'+s[a]+\' .\'+A.1p.54[s[a]]).1y(C(){if(h.1b>0){h+=\'&\'}h+=s[a]+\'[]=\'+A.1m(B,\'id\');o[s[a]][o[s[a]].1b]=A.1m(B,\'id\')})}}}}L{1V(i in A.1p.54){o[i]=[];A(\'#\'+i+\' .\'+A.1p.54[i]).1y(C(){if(h.1b>0){h+=\'&\'}h+=i+\'[]=\'+A.1m(B,\'id\');o[i][o[i].1b]=A.1m(B,\'id\')})}}G{6A:h,o:o}},dL:C(e){if(!e.ci){G}G B.1y(C(){if(!B.5t||!A(e).is(\'.\'+B.5t.3r))A(e).2H(B.5t.3r);A(e).6r(B.5t.D)})},4v:C(){G B.1y(C(){A(\'.\'+B.5t.3r).8j();A(B).ei();B.5t=P;B.dK=P})},2l:C(o){if(o.3r&&A.12&&A.X&&A.1s){if(!A.1p.18){A(\'23\',1c).1L(\'<1W id="dJ">&6G;\');A.1p.18=A(\'#dJ\');A.1p.18.I(0).Y.11=\'1k\'}B.ee({3r:o.3r,9F:o.9F?o.9F:H,8X:o.8X?o.8X:H,4G:o.4G?o.4G:H,76:o.76||o.ev,6C:o.6C||o.er,bC:14,2I:o.2I||o.iR,fx:o.fx?o.fx:H,3L:o.3L?14:H,5T:o.5T?o.5T:\'9S\'});G B.1y(C(){F a={5B:o.5B?14:H,dI:5P,1E:o.1E?2c(o.1E):H,5z:o.4G?o.4G:H,fx:o.fx?o.fx:H,3I:14,3L:o.3L?14:H,3c:o.3c?o.3c:P,2e:o.2e?o.2e:P,4c:o.4c&&o.4c.1F==2w?o.4c:H,4h:o.4h&&o.4h.1F==2w?o.4h:H,3C:o.3C&&o.3C.1F==2w?o.3C:H,2g:/3K|3Z/.3M(o.2g)?o.2g:H,5D:o.5D?R(o.5D)||0:H,2M:o.2M?o.2M:H};A(\'.\'+o.3r,B).6r(a);B.dK=14;B.5t={3r:o.3r,5B:o.5B?14:H,dI:5P,1E:o.1E?2c(o.1E):H,5z:o.4G?o.4G:H,fx:o.fx?o.fx:H,3I:14,3L:o.3L?14:H,3c:o.3c?o.3c:P,2e:o.2e?o.2e:P,bb:o.bb?14:H,D:a}})}}};A.fn.1U({iP:A.1p.2l,dN:A.1p.dL,iO:A.1p.4v});A.iN=A.1p.8g;A.2k={62:P,9o:H,9p:P,6a:C(e){A.2k.9o=14;A.2k.1S(e,B,14)},bk:C(e){if(A.2k.62!=B)G;A.2k.9o=H;A.2k.2x(e,B)},1S:C(e,a,b){if(A.2k.62!=P)G;if(!a){a=B}A.2k.62=a;1I=A.1U(A.12.3a(a),A.12.2f(a));7U=A(a);3T=7U.1m(\'3T\');2U=7U.1m(\'2U\');if(3T){A.2k.9p=3T;7U.1m(\'3T\',\'\');A(\'#dE\').3i(3T);if(2U)A(\'#bj\').3i(2U.48(\'iI://\',\'\'));L A(\'#bj\').3i(\'\');18=A(\'#7S\');if(a.4m.2Z){18.I(0).2Z=a.4m.2Z}L{18.I(0).2Z=\'\'}bi=A.12.2f(18.I(0));dD=b&&a.4m.T==\'bn\'?\'4e\':a.4m.T;2X(dD){19\'O\':2j=1I.y-bi.hb;2n=1I.x;1n;19\'M\':2j=1I.y;2n=1I.x-bi.1D;1n;19\'2D\':2j=1I.y;2n=1I.x+1I.1D;1n;19\'bn\':A(\'23\').1C(\'3t\',A.2k.3t);1A=A.12.3W(e);2j=1A.y+15;2n=1A.x+15;1n;8T:2j=1I.y+1I.hb;2n=1I.x;1n}18.E({O:2j+\'Q\',M:2n+\'Q\'});if(a.4m.4w==H){18.1S()}L{18.6U(a.4m.4w)}if(a.4m.2K)a.4m.2K.1x(a);7U.1C(\'86\',A.2k.2x).1C(\'4W\',A.2k.bk)}},3t:C(e){if(A.2k.62==P){A(\'23\').3h(\'3t\',A.2k.3t);G}1A=A.12.3W(e);A(\'#7S\').E({O:1A.y+15+\'Q\',M:1A.x+15+\'Q\'})},2x:C(e,a){if(!a){a=B}if(A.2k.9o!=14&&A.2k.62==a){A.2k.62=P;A(\'#7S\').6d(1);A(a).1m(\'3T\',A.2k.9p).3h(\'86\',A.2k.2x).3h(\'4W\',A.2k.bk);if(a.4m.2V)a.4m.2V.1x(a);A.2k.9p=P}},2l:C(b){if(!A.2k.18){A(\'23\').1L(\'<1W id="7S"><1W id="dE"><1W id="bj">\');A(\'#7S\').E({T:\'1J\',3j:5P,11:\'1k\'});A.2k.18=14}G B.1y(C(){if(A.1m(B,\'3T\')){B.4m={T:/O|4e|M|2D|bn/.3M(b.T)?b.T:\'4e\',2Z:b.2Z?b.2Z:H,4w:b.4w?b.4w:H,2K:b.2K&&b.2K.1F==2w?b.2K:H,2V:b.2V&&b.2V.1F==2w?b.2V:H};F a=A(B);a.1C(\'9r\',A.2k.1S);a.1C(\'6a\',A.2k.6a)}})}};A.fn.iH=A.2k.2l;A.7O={bl:C(e){6K=e.6S||e.6R||-1;if(6K==9){if(1P.3N){1P.3N.b6=14;1P.3N.b5=H}L{e.9b();e.99()}if(B.9q){1c.64.dv().3D="\\t";B.dB=C(){B.6a();B.dB=P}}L if(B.9m){2b=B.88;3m=B.dA;B.2m=B.2m.iG(0,2b)+"\\t"+B.2m.iF(3m);B.9m(2b+1,2b+1);B.6a()}G H}},4v:C(){G B.1y(C(){if(B.6V&&B.6V==14){A(B).3h(\'70\',A.7O.bl);B.6V=H}})},2l:C(){G B.1y(C(){if(B.4D==\'bs\'&&(!B.6V||B.6V==H)){A(B).1C(\'70\',A.7O.bl);B.6V=14}})}};A.fn.1U({iD:A.7O.2l,iC:A.7O.4v});A.12={3a:C(e){F x=0;F y=0;F a=e.Y;F b=H;if(A(e).E(\'11\')==\'1k\'){F c=a.2W;F d=a.T;b=14;a.2W=\'2B\';a.11=\'2v\';a.T=\'1J\'}F f=e;6k(f){x+=f.7Y+(f.4u&&!A.2R.6l?R(f.4u.4y)||0:0);y+=f.7t+(f.4u&&!A.2R.6l?R(f.4u.4x)||0:0);f=f.dY}f=e;6k(f&&f.4D&&f.4D.5u()!=\'23\'){x-=f.2P||0;y-=f.2T||0;f=f.2S}if(b==14){a.11=\'1k\';a.T=d;a.2W=c}G{x:x,y:y}},6x:C(a){F x=0,y=0;6k(a){x+=a.7Y||0;y+=a.7t||0;a=a.dY}G{x:x,y:y}},2f:C(e){F w=A.E(e,\'V\');F h=A.E(e,\'S\');F a=0;F b=0;F c=e.Y;if(A(e).E(\'11\')!=\'1k\'){a=e.3P;b=e.5r}L{F d=c.2W;F f=c.T;c.2W=\'2B\';c.11=\'2v\';c.T=\'1J\';a=e.3P;b=e.5r;c.11=\'1k\';c.T=f;c.2W=d}G{w:w,h:h,1D:a,hb:b}},6w:C(a){G{1D:a.3P||0,hb:a.5r||0}},a5:C(e){F h,w,de;if(e){w=e.83;h=e.7P}L{de=1c.4A;w=1P.bg||9z.bg||(de&&de.83)||1c.23.83;h=1P.bf||9z.bf||(de&&de.7P)||1c.23.7P}G{w:w,h:h}},5O:C(e){F t=0,l=0,w=0,h=0,iw=0,ih=0;if(e&&e.98.5u()!=\'23\'){t=e.2T;l=e.2P;w=e.be;h=e.bd;iw=0;ih=0}L{if(1c.4A){t=1c.4A.2T;l=1c.4A.2P;w=1c.4A.be;h=1c.4A.bd}L if(1c.23){t=1c.23.2T;l=1c.23.2P;w=1c.23.be;h=1c.23.bd}iw=9z.bg||1c.4A.83||1c.23.83||0;ih=9z.bf||1c.4A.7P||1c.23.7P||0}G{t:t,l:l,w:w,h:h,iw:iw,ih:ih}},b2:C(e,a){F c=A(e);F t=c.E(\'4M\')||\'\';F r=c.E(\'53\')||\'\';F b=c.E(\'4L\')||\'\';F l=c.E(\'4K\')||\'\';if(a)G{t:R(t)||0,r:R(r)||0,b:R(b)||0,l:R(l)};L G{t:t,r:r,b:b,l:l}},9y:C(e,a){F c=A(e);F t=c.E(\'5b\')||\'\';F r=c.E(\'5g\')||\'\';F b=c.E(\'4Q\')||\'\';F l=c.E(\'4F\')||\'\';if(a)G{t:R(t)||0,r:R(r)||0,b:R(b)||0,l:R(l)};L G{t:t,r:r,b:b,l:l}},6b:C(e,a){F c=A(e);F t=c.E(\'4x\')||\'\';F r=c.E(\'5i\')||\'\';F b=c.E(\'5d\')||\'\';F l=c.E(\'4y\')||\'\';if(a)G{t:R(t)||0,r:R(r)||0,b:R(b)||0,l:R(l)||0};L G{t:t,r:r,b:b,l:l}},3W:C(a){F x=a.iB||(a.iz+(1c.4A.2P||1c.23.2P))||0;F y=a.iy||(a.ix+(1c.4A.2T||1c.23.2T))||0;G{x:x,y:y}},bH:C(a,b){b(a);a=a.6M;6k(a){A.12.bH(a,b);a=a.iv}},ji:C(c){A.12.bH(c,C(a){1V(F b in a){if(28 a[b]===\'C\'){a[b]=P}}})},ir:C(a,b){F c=A.12.5O();F d=A.12.2f(a);if(!b||b==\'3K\')A(a).E({O:c.t+((Z.3g(c.h,c.ih)-c.t-d.hb)/2)+\'Q\'});if(!b||b==\'3Z\')A(a).E({M:c.l+((Z.3g(c.w,c.iw)-c.l-d.1D)/2)+\'Q\'})},iq:C(a,b){F c=A(\'3O[@2E*="7q"]\',a||1c),7q;c.1y(C(){7q=B.2E;B.2E=b;B.Y.4X="9x:9C.9E.ip(2E=\'"+7q+"\')"})}};[].3o||(6h.jn.3o=C(v,n){n=(n==P)?0:n;F m=B.1b;1V(F i=n;i= 0 ? '&' : '?') + q; - options.data = null; // data is null for 'get' - } - else - options.data = q; // data is the query string for 'post' - - var $form = this, callbacks = []; - if (options.resetForm) callbacks.push(function() { $form.resetForm(); }); - if (options.clearForm) callbacks.push(function() { $form.clearForm(); }); - - // perform a load on the target only if dataType is not provided - if (!options.dataType && options.target) { - var oldSuccess = options.success || function(){}; - callbacks.push(function(data, status) { - jQuery(options.target).attr("innerHTML", data).evalScripts().each(oldSuccess, [data, status]); - }); - } - else if (options.success) - callbacks.push(options.success); - - options.success = function(data, status) { - for (var i=0, max=callbacks.length; i < max; i++) - callbacks[i](data, status); - }; - - jQuery.ajax(options); - return this; -}; - -/** - * ajaxForm() provides a mechanism for fully automating form submission. - * - * The advantages of using this method instead of ajaxSubmit() are: - * - * 1: This method will include coordinates for elements (if the element - * is used to submit the form). - * 2. This method will include the submit element's name/value data (for the element that was - * used to submit the form). - * 3. This method binds the submit() method to the form for you. - * - * Note that for accurate x/y coordinates of image submit elements in all browsers - * you need to also use the "dimensions" plugin (this method will auto-detect its presence). - * - * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely - * passes the options argument along after properly binding events for submit elements and - * the form itself. See ajaxSubmit for a full description of the options argument. - * - * - * @example - * var options = { - * target: '#myTargetDiv' - * }; - * $('#myForm').ajaxSForm(options); - * @desc Bind form's submit event so that 'myTargetDiv' is updated with the server response - * when the form is submitted. - * - * - * @example - * var options = { - * success: function(responseText) { - * alert(responseText); - * } - * }; - * $('#myForm').ajaxSubmit(options); - * @desc Bind form's submit event so that server response is alerted after the form is submitted. - * - * - * @example - * var options = { - * beforeSubmit: function(formArray, jqForm) { - * if (formArray.length == 0) { - * alert('Please enter data.'); - * return false; - * } - * } - * }; - * $('#myForm').ajaxSubmit(options); - * @desc Bind form's submit event so that pre-submit callback is invoked before the form - * is submitted. - * - * - * @name ajaxForm - * @param options object literal containing options which control the form submission process - * @return jQuery - * @cat Plugins/Form - * @type jQuery - * @see ajaxSubmit - * @author jQuery Community - */ -jQuery.fn.ajaxForm = function(options) { - return this.each(function() { - jQuery("input:submit,input:image,button:submit", this).click(function(ev) { - var $form = this.form; - $form.clk = this; - if (this.type == 'image') { - if (ev.offsetX != undefined) { - $form.clk_x = ev.offsetX; - $form.clk_y = ev.offsetY; - } else if (typeof jQuery.fn.offset == 'function') { // try to use dimensions plugin - var offset = jQuery(this).offset(); - $form.clk_x = ev.pageX - offset.left; - $form.clk_y = ev.pageY - offset.top; - } else { - $form.clk_x = ev.pageX - this.offsetLeft; - $form.clk_y = ev.pageY - this.offsetTop; - } - } - // clear form vars - setTimeout(function() { - $form.clk = $form.clk_x = $form.clk_y = null; - }, 10); - }) - }).submit(function(e) { - jQuery(this).ajaxSubmit(options); - return false; - }); -}; - - -/** - * formToArray() gathers form element data into an array of objects that can - * be passed to any of the following ajax functions: $.get, $.post, or load. - * Each object in the array has both a 'name' and 'value' property. An example of - * an array for a simple login form might be: - * - * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] - * - * It is this array that is passed to pre-submit callback functions provided to the - * ajaxSubmit() and ajaxForm() methods. - * - * The semantic argument can be used to force form serialization in semantic order. - * This is normally true anyway, unless the form contains input elements of type='image'. - * If your form must be submitted with name/value pairs in semantic order and your form - * contains an input of type='image" then pass true for this arg, otherwise pass false - * (or nothing) to avoid the overhead for this logic. - * - * @example var data = $("#myForm").formToArray(); - * $.post( "myscript.cgi", data ); - * @desc Collect all the data from a form and submit it to the server. - * - * @name formToArray - * @param semantic true if serialization must maintain strict semantic ordering of elements (slower) - * @type Array - * @cat Plugins/Form - * @see ajaxForm - * @see ajaxSubmit - * @author jQuery Community - */ -jQuery.fn.formToArray = function(semantic) { - var a = []; - if (this.length == 0) return a; - - var form = this[0]; - var els = semantic ? form.getElementsByTagName('*') : form.elements; - if (!els) return a; - for(var i=0, max=els.length; i < max; i++) { - var el = els[i]; - var n = el.name; - if (!n) continue; - - if (semantic && form.clk && el.type == "image") { - // handle image inputs on the fly when semantic == true - if(!el.disabled && form.clk == el) - a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); - continue; - } - var v = jQuery.fieldValue(el, true); - if (v === null) continue; - if (v.constructor == Array) { - for(var j=0, jmax=v.length; j < jmax; j++) - a.push({name: n, value: v[j]}); - } - else - a.push({name: n, value: v}); - } - - if (!semantic && form.clk) { - // input type=='image' are not found in elements array! handle them here - var inputs = form.getElementsByTagName("input"); - for(var i=0, max=inputs.length; i < max; i++) { - var input = inputs[i]; - var n = input.name; - if(n && !input.disabled && input.type == "image" && form.clk == input) - a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); - } - } - return a; -}; - - -/** - * Serializes form data into a 'submittable' string. This method will return a string - * in the format: name1=value1&name2=value2 - * - * The semantic argument can be used to force form serialization in semantic order. - * If your form must be submitted with name/value pairs in semantic order then pass - * true for this arg, otherwise pass false (or nothing) to avoid the overhead for - * this logic (which can be significant for very large forms). - * - * @example var data = $("#myForm").formSerialize(); - * $.ajax('POST', "myscript.cgi", data); - * @desc Collect all the data from a form into a single string - * - * @name formSerialize - * @param semantic true if serialization must maintain strict semantic ordering of elements (slower) - * @type String - * @cat Plugins/Form - * @see formToArray - * @author jQuery Community - */ -jQuery.fn.formSerialize = function(semantic) { - //hand off to jQuery.param for proper encoding - return jQuery.param(this.formToArray(semantic)); -}; - - -/** - * Serializes all field elements in the jQuery object into a query string. - * This method will return a string in the format: name1=value1&name2=value2 - * - * The successful argument controls whether or not serialization is limited to - * 'successful' controls (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). - * The default value of the successful argument is true. - * - * @example var data = $("input").formSerialize(); - * @desc Collect the data from all successful input elements into a query string - * - * @example var data = $(":radio").formSerialize(); - * @desc Collect the data from all successful radio input elements into a query string - * - * @example var data = $("#myForm :checkbox").formSerialize(); - * @desc Collect the data from all successful checkbox input elements in myForm into a query string - * - * @example var data = $("#myForm :checkbox").formSerialize(false); - * @desc Collect the data from all checkbox elements in myForm (even the unchecked ones) into a query string - * - * @example var data = $(":input").formSerialize(); - * @desc Collect the data from all successful input, select, textarea and button elements into a query string - * - * @name fieldSerialize - * @param successful true if only successful controls should be serialized (default is true) - * @type String - * @cat Plugins/Form - */ -jQuery.fn.fieldSerialize = function(successful) { - var a = []; - this.each(function() { - var n = this.name; - if (!n) return; - var v = jQuery.fieldValue(this, successful); - if (v && v.constructor == Array) { - for (var i=0,max=v.length; i < max; i++) - a.push({name: n, value: v[i]}); - } - else if (v !== null && typeof v != 'undefined') - a.push({name: this.name, value: v}); - }); - //hand off to jQuery.param for proper encoding - return jQuery.param(a); -}; - - -/** - * Returns the value of the field element in the jQuery object. If there is more than one field element - * in the jQuery object the value of the first successful one is returned. - * - * The successful argument controls whether or not the field element must be 'successful' - * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). - * The default value of the successful argument is true. If this value is false then - * the value of the first field element in the jQuery object is returned. - * - * Note: If no valid value can be determined the return value will be undifined. - * - * Note: The fieldValue returned for a select-multiple element or for a checkbox input will - * always be an array if it is not undefined. - * - * - * @example var data = $("#myPasswordElement").formValue(); - * @desc Gets the current value of the myPasswordElement element - * - * @example var data = $("#myForm :input").formValue(); - * @desc Get the value of the first successful control in the jQuery object. - * - * @example var data = $("#myForm :checkbox").formValue(); - * @desc Get the array of values for the first set of successful checkbox controls in the jQuery object. - * - * @example var data = $("#mySingleSelect").formValue(); - * @desc Get the value of the select control - * - * @example var data = $("#myMultiSelect").formValue(); - * @desc Get the array of selected values for the select-multiple control - * - * @name fieldValue - * @param Boolean successful true if value returned must be for a successful controls (default is true) - * @type String or Array - * @cat Plugins/Form - */ -jQuery.fn.fieldValue = function(successful) { - var cbVal, cbName; - - // loop until we find a value - for (var i=0, max=this.length; i < max; i++) { - var el = this[i]; - var v = jQuery.fieldValue(el, successful); - if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) - continue; - - // for checkboxes, consider multiple elements, for everything else just return first valid value - if (el.type != 'checkbox') return v; - - cbName = cbName || el.name; - if (cbName != el.name) // return if we hit a checkbox with a different name - return cbVal; - cbVal = cbVal || []; - cbVal.push(v); - } - return cbVal; -}; - -/** - * Returns the value of the field element. - * - * The successful argument controls whether or not the field element must be 'successful' - * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). - * The default value of the successful argument is true. If the given element is not - * successful and the successful arg is not false then the returned value will be null. - * - * Note: The fieldValue returned for a select-multiple element will always be an array. - * - * @example var data = jQuery.fieldValue($("#myPasswordElement")[0]); - * @desc Gets the current value of the myPasswordElement element - * - * @name fieldValue - * @param Element el The DOM element for which the value will be returned - * @param Boolean successful true if value returned must be for a successful controls (default is true) - * @type String or Array - * @cat Plugins/Form - */ -jQuery.fieldValue = function(el, successful) { - var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); - if (typeof successful == 'undefined') successful = true; - - if (successful && ( !n || el.disabled || t == 'reset' || - (t == 'checkbox' || t == 'radio') && !el.checked || - (t == 'submit' || t == 'image') && el.form && el.form.clk != el || - tag == 'select' && el.selectedIndex == -1)) - return null; - - if (tag == 'select') { - var index = el.selectedIndex; - if (index < 0) return null; - var a = [], ops = el.options; - var one = (t == 'select-one'); - var max = (one ? index+1 : ops.length); - for(var i=(one ? index : 0); i < max; i++) { - var op = ops[i]; - if (op.selected) { - // extra pain for IE... - var v = jQuery.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value; - if (one) return v; - a.push(v); - } - } - return a; - } - return el.value; -}; - - -/** - * Clears the form data. Takes the following actions on the form's input fields: - * - input text fields will have their 'value' property set to the empty string - * - select elements will have their 'selectedIndex' property set to -1 - * - checkbox and radio inputs will have their 'checked' property set to false - * - inputs of type submit, button, reset, and hidden will *not* be effected - * - button elements will *not* be effected - * - * @example $('form').clearForm(); - * @desc Clears all forms on the page. - * - * @name clearForm - * @type jQuery - * @cat Plugins/Form - * @see resetForm - */ -jQuery.fn.clearForm = function() { - return this.each(function() { - jQuery('input,select,textarea', this).clearFields(); - }); -}; - -/** - * Clears the selected form elements. Takes the following actions on the matched elements: - * - input text fields will have their 'value' property set to the empty string - * - select elements will have their 'selectedIndex' property set to -1 - * - checkbox and radio inputs will have their 'checked' property set to false - * - inputs of type submit, button, reset, and hidden will *not* be effected - * - button elements will *not* be effected - * - * @example $('.myInputs').clearFields(); - * @desc Clears all inputs with class myInputs - * - * @name clearFields - * @type jQuery - * @cat Plugins/Form - * @see clearForm - */ -jQuery.fn.clearFields = jQuery.fn.clearInputs = function() { - return this.each(function() { - var t = this.type, tag = this.tagName.toLowerCase(); - if (t == 'text' || t == 'password' || tag == 'textarea') - this.value = ''; - else if (t == 'checkbox' || t == 'radio') - this.checked = false; - else if (tag == 'select') - this.selectedIndex = -1; - }); -}; - - -/** - * Resets the form data. Causes all form elements to be reset to their original value. - * - * @example $('form').resetForm(); - * @desc Resets all forms on the page. - * - * @name resetForm - * @type jQuery - * @cat Plugins/Form - * @see clearForm - */ -jQuery.fn.resetForm = function() { - return this.each(function() { - // guard against an input with the name of 'reset' - // note that IE reports the reset function as an 'object' - if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) - this.reset(); - }); -}; +/* + * jQuery Form Plugin + * version: 2.02 (12/16/2007) + * @requires jQuery v1.1 or later + * + * Examples at: http://malsup.com/jquery/form/ + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Revision: $Id$ + */ + (function($) { +/** + * ajaxSubmit() provides a mechanism for submitting an HTML form using AJAX. + * + * ajaxSubmit accepts a single argument which can be either a success callback function + * or an options Object. If a function is provided it will be invoked upon successful + * completion of the submit and will be passed the response from the server. + * If an options Object is provided, the following attributes are supported: + * + * target: Identifies the element(s) in the page to be updated with the server response. + * This value may be specified as a jQuery selection string, a jQuery object, + * or a DOM element. + * default value: null + * + * url: URL to which the form data will be submitted. + * default value: value of form's 'action' attribute + * + * type: The method in which the form data should be submitted, 'GET' or 'POST'. + * default value: value of form's 'method' attribute (or 'GET' if none found) + * + * data: Additional data to add to the request, specified as key/value pairs (see $.ajax). + * + * beforeSubmit: Callback method to be invoked before the form is submitted. + * default value: null + * + * success: Callback method to be invoked after the form has been successfully submitted + * and the response has been returned from the server + * default value: null + * + * dataType: Expected dataType of the response. One of: null, 'xml', 'script', or 'json' + * default value: null + * + * semantic: Boolean flag indicating whether data must be submitted in semantic order (slower). + * default value: false + * + * resetForm: Boolean flag indicating whether the form should be reset if the submit is successful + * + * clearForm: Boolean flag indicating whether the form should be cleared if the submit is successful + * + * + * The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for + * validating the form data. If the 'beforeSubmit' callback returns false then the form will + * not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data + * in array format, the jQuery object, and the options object passed into ajaxSubmit. + * The form data array takes the following form: + * + * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] + * + * If a 'success' callback method is provided it is invoked after the response has been returned + * from the server. It is passed the responseText or responseXML value (depending on dataType). + * See jQuery.ajax for further details. + * + * + * The dataType option provides a means for specifying how the server response should be handled. + * This maps directly to the jQuery.httpData method. The following values are supported: + * + * 'xml': if dataType == 'xml' the server response is treated as XML and the 'success' + * callback method, if specified, will be passed the responseXML value + * 'json': if dataType == 'json' the server response will be evaluted and passed to + * the 'success' callback, if specified + * 'script': if dataType == 'script' the server response is evaluated in the global context + * + * + * Note that it does not make sense to use both the 'target' and 'dataType' options. If both + * are provided the target will be ignored. + * + * The semantic argument can be used to force form serialization in semantic order. + * This is normally true anyway, unless the form contains input elements of type='image'. + * If your form must be submitted with name/value pairs in semantic order and your form + * contains an input of type='image" then pass true for this arg, otherwise pass false + * (or nothing) to avoid the overhead for this logic. + * + * + * When used on its own, ajaxSubmit() is typically bound to a form's submit event like this: + * + * $("#form-id").submit(function() { + * $(this).ajaxSubmit(options); + * return false; // cancel conventional submit + * }); + * + * When using ajaxForm(), however, this is done for you. + * + * @example + * $('#myForm').ajaxSubmit(function(data) { + * alert('Form submit succeeded! Server returned: ' + data); + * }); + * @desc Submit form and alert server response + * + * + * @example + * var options = { + * target: '#myTargetDiv' + * }; + * $('#myForm').ajaxSubmit(options); + * @desc Submit form and update page element with server response + * + * + * @example + * var options = { + * success: function(responseText) { + * alert(responseText); + * } + * }; + * $('#myForm').ajaxSubmit(options); + * @desc Submit form and alert the server response + * + * + * @example + * var options = { + * beforeSubmit: function(formArray, jqForm) { + * if (formArray.length == 0) { + * alert('Please enter data.'); + * return false; + * } + * } + * }; + * $('#myForm').ajaxSubmit(options); + * @desc Pre-submit validation which aborts the submit operation if form data is empty + * + * + * @example + * var options = { + * url: myJsonUrl.php, + * dataType: 'json', + * success: function(data) { + * // 'data' is an object representing the the evaluated json data + * } + * }; + * $('#myForm').ajaxSubmit(options); + * @desc json data returned and evaluated + * + * + * @example + * var options = { + * url: myXmlUrl.php, + * dataType: 'xml', + * success: function(responseXML) { + * // responseXML is XML document object + * var data = $('myElement', responseXML).text(); + * } + * }; + * $('#myForm').ajaxSubmit(options); + * @desc XML data returned from server + * + * + * @example + * var options = { + * resetForm: true + * }; + * $('#myForm').ajaxSubmit(options); + * @desc submit form and reset it if successful + * + * @example + * $('#myForm).submit(function() { + * $(this).ajaxSubmit(); + * return false; + * }); + * @desc Bind form's submit event to use ajaxSubmit + * + * + * @name ajaxSubmit + * @type jQuery + * @param options object literal containing options which control the form submission process + * @cat Plugins/Form + * @return jQuery + */ +$.fn.ajaxSubmit = function(options) { + if (typeof options == 'function') + options = { success: options }; + + options = $.extend({ + url: this.attr('action') || window.location.toString(), + type: this.attr('method') || 'GET' + }, options || {}); + + // hook for manipulating the form data before it is extracted; + // convenient for use with rich editors like tinyMCE or FCKEditor + var veto = {}; + $.event.trigger('form.pre.serialize', [this, options, veto]); + if (veto.veto) return this; + + var a = this.formToArray(options.semantic); + if (options.data) { + for (var n in options.data) + a.push( { name: n, value: options.data[n] } ); + } + + // give pre-submit callback an opportunity to abort the submit + if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) return this; + + // fire vetoable 'validate' event + $.event.trigger('form.submit.validate', [a, this, options, veto]); + if (veto.veto) return this; + + var q = $.param(a);//.replace(/%20/g,'+'); + + if (options.type.toUpperCase() == 'GET') { + options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; + options.data = null; // data is null for 'get' + } + else + options.data = q; // data is the query string for 'post' + + var $form = this, callbacks = []; + if (options.resetForm) callbacks.push(function() { $form.resetForm(); }); + if (options.clearForm) callbacks.push(function() { $form.clearForm(); }); + + // perform a load on the target only if dataType is not provided + if (!options.dataType && options.target) { + var oldSuccess = options.success || function(){}; + callbacks.push(function(data) { + if (this.evalScripts) + $(options.target).attr("innerHTML", data).evalScripts().each(oldSuccess, arguments); + else // jQuery v1.1.4 + $(options.target).html(data).each(oldSuccess, arguments); + }); + } + else if (options.success) + callbacks.push(options.success); + + options.success = function(data, status) { + for (var i=0, max=callbacks.length; i < max; i++) + callbacks[i](data, status, $form); + }; + + // are there files to upload? + var files = $('input:file', this).fieldValue(); + var found = false; + for (var j=0; j < files.length; j++) + if (files[j]) + found = true; + + // options.iframe allows user to force iframe mode + if (options.iframe || found) { + // hack to fix Safari hang (thanks to Tim Molendijk for this) + // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d + if ($.browser.safari && options.closeKeepAlive) + $.get(options.closeKeepAlive, fileUpload); + else + fileUpload(); + } + else + $.ajax(options); + + // fire 'notify' event + $.event.trigger('form.submit.notify', [this, options]); + return this; + + + // private function for handling file uploads (hat tip to YAHOO!) + function fileUpload() { + var form = $form[0]; + var opts = $.extend({}, $.ajaxSettings, options); + + var id = 'jqFormIO' + $.fn.ajaxSubmit.counter++; + var $io = $('
    "); + jQuery("#TB_overlay").click(tb_remove); + } + }else{//all others + if(document.getElementById("TB_overlay") === null){ + jQuery("body").append("
    "); + jQuery("#TB_overlay").click(tb_remove); + } + } + + if(tb_detectMacXFF()){ + jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash + }else{ + jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity + } + + if(caption===null){caption="";} + jQuery("body").append("
    ");//add loader to the page + jQuery('#TB_load').show();//show loader + + var baseURL; + if(url.indexOf("?")!==-1){ //ff there is a query string involved + baseURL = url.substr(0, url.indexOf("?")); + }else{ + baseURL = url; + } + + var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/; + var urlType = baseURL.toLowerCase().match(urlString); + + if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images + + TB_PrevCaption = ""; + TB_PrevURL = ""; + TB_PrevHTML = ""; + TB_NextCaption = ""; + TB_NextURL = ""; + TB_NextHTML = ""; + TB_imageCount = ""; + TB_FoundURL = false; + if(imageGroup){ + TB_TempArray = jQuery("a[@rel="+imageGroup+"]").get(); + for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) { + var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); + if (!(TB_TempArray[TB_Counter].href == url)) { + if (TB_FoundURL) { + TB_NextCaption = TB_TempArray[TB_Counter].title; + TB_NextURL = TB_TempArray[TB_Counter].href; + TB_NextHTML = "  Next >"; + } else { + TB_PrevCaption = TB_TempArray[TB_Counter].title; + TB_PrevURL = TB_TempArray[TB_Counter].href; + TB_PrevHTML = "  < Prev"; + } + } else { + TB_FoundURL = true; + TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length); + } + } + } + + imgPreloader = new Image(); + imgPreloader.onload = function(){ + imgPreloader.onload = null; + + // Resizing large images - orginal by Christian Montoya edited by me. + var pagesize = tb_getPageSize(); + var x = pagesize[0] - 150; + var y = pagesize[1] - 150; + var imageWidth = imgPreloader.width; + var imageHeight = imgPreloader.height; + if (imageWidth > x) { + imageHeight = imageHeight * (x / imageWidth); + imageWidth = x; + if (imageHeight > y) { + imageWidth = imageWidth * (y / imageHeight); + imageHeight = y; + } + } else if (imageHeight > y) { + imageWidth = imageWidth * (y / imageHeight); + imageHeight = y; + if (imageWidth > x) { + imageHeight = imageHeight * (x / imageWidth); + imageWidth = x; + } + } + // End Resizing + + TB_WIDTH = imageWidth + 30; + TB_HEIGHT = imageHeight + 60; + jQuery("#TB_window").append(""+caption+"" + "
    "+caption+"
    " + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
    "); + + jQuery("#TB_closeWindowButton").click(tb_remove); + + if (!(TB_PrevHTML === "")) { + function goPrev(){ + if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);} + jQuery("#TB_window").remove(); + jQuery("body").append("
    "); + tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); + return false; + } + jQuery("#TB_prev").click(goPrev); + } + + if (!(TB_NextHTML === "")) { + function goNext(){ + jQuery("#TB_window").remove(); + jQuery("body").append("
    "); + tb_show(TB_NextCaption, TB_NextURL, imageGroup); + return false; + } + jQuery("#TB_next").click(goNext); + + } + + document.onkeydown = function(e){ + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + if(keycode == 27){ // close + tb_remove(); + } else if(keycode == 190){ // display previous image + if(!(TB_NextHTML == "")){ + document.onkeydown = ""; + goNext(); + } + } else if(keycode == 188){ // display next image + if(!(TB_PrevHTML == "")){ + document.onkeydown = ""; + goPrev(); + } + } + }; + + tb_position(); + jQuery("#TB_load").remove(); + jQuery("#TB_ImageOff").click(tb_remove); + jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show + }; + + imgPreloader.src = url; + }else{//code to show html + + var queryString = url.replace(/^[^\?]+\??/,''); + var params = tb_parseQuery( queryString ); + + TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL + TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL + ajaxContentW = TB_WIDTH - 30; + ajaxContentH = TB_HEIGHT - 45; + + if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window + urlNoQuery = url.split('TB_'); + jQuery("#TB_iframeContent").remove(); + if(params['modal'] != "true"){//iframe no modal + jQuery("#TB_window").append("
    "+caption+"
    "); + }else{//iframe modal + jQuery("#TB_overlay").unbind(); + jQuery("#TB_window").append(""); + } + }else{// not an iframe, ajax + if(jQuery("#TB_window").css("display") != "block"){ + if(params['modal'] != "true"){//ajax no modal + jQuery("#TB_window").append("
    "+caption+"
    "); + }else{//ajax modal + jQuery("#TB_overlay").unbind(); + jQuery("#TB_window").append("
    "); + } + }else{//this means the window is already up, we are just loading new content via ajax + jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px"; + jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px"; + jQuery("#TB_ajaxContent")[0].scrollTop = 0; + jQuery("#TB_ajaxWindowTitle").html(caption); + } + } + + jQuery("#TB_closeWindowButton").click(tb_remove); + + if(url.indexOf('TB_inline') != -1){ + jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children()); + jQuery("#TB_window").unload(function () { + jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished + }); + tb_position(); + jQuery("#TB_load").remove(); + jQuery("#TB_window").css({display:"block"}); + }else if(url.indexOf('TB_iframe') != -1){ + tb_position(); + if($.browser.safari){//safari needs help because it will not fire iframe onload + jQuery("#TB_load").remove(); + jQuery("#TB_window").css({display:"block"}); + } + }else{ + jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method + tb_position(); + jQuery("#TB_load").remove(); + tb_init("#TB_ajaxContent a.thickbox"); + jQuery("#TB_window").css({display:"block"}); + }); + } + + } + + if(!params['modal']){ + document.onkeyup = function(e){ + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + if(keycode == 27){ // close + tb_remove(); + } + }; + } + + } catch(e) { + //nothing here + } +} + +//helper functions below +function tb_showIframe(){ + jQuery("#TB_load").remove(); + jQuery("#TB_window").css({display:"block"}); +} + +function tb_remove() { + jQuery("#TB_imageOff").unbind("click"); + jQuery("#TB_closeWindowButton").unbind("click"); + jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();}); + jQuery("#TB_load").remove(); + if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 + jQuery("body","html").css({height: "auto", width: "auto"}); + jQuery("html").css("overflow",""); + } + document.onkeydown = ""; + document.onkeyup = ""; + return false; +} + +function tb_position() { +jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'}); + if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6 + jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'}); + } +} + +function tb_parseQuery ( query ) { + var Params = {}; + if ( ! query ) {return Params;}// return empty object + var Pairs = query.split(/[;&]/); + for ( var i = 0; i < Pairs.length; i++ ) { + var KeyVal = Pairs[i].split('='); + if ( ! KeyVal || KeyVal.length != 2 ) {continue;} + var key = unescape( KeyVal[0] ); + var val = unescape( KeyVal[1] ); + val = val.replace(/\+/g, ' '); + Params[key] = val; + } + return Params; +} + +function tb_getPageSize(){ + var de = document.documentElement; + var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; + var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; + arrayPageSize = [w,h]; + return arrayPageSize; +} + +function tb_detectMacXFF() { + var userAgent = navigator.userAgent.toLowerCase(); + if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { + return true; + } +} + + diff --git a/wp-includes/js/tinymce/blank.htm b/wp-includes/js/tinymce/blank.htm index c1ff8352..0ef25247 100644 --- a/wp-includes/js/tinymce/blank.htm +++ b/wp-includes/js/tinymce/blank.htm @@ -1,7 +1,7 @@ - blank_page + blank_page diff --git a/wp-includes/js/tinymce/langs/en.js b/wp-includes/js/tinymce/langs/en.js deleted file mode 100644 index c7faa243..00000000 --- a/wp-includes/js/tinymce/langs/en.js +++ /dev/null @@ -1,41 +0,0 @@ -// UK lang variables - -tinyMCE.addToLang('',{ -bold_desc : 'Bold (Ctrl+B)', -italic_desc : 'Italic (Ctrl+I)', -underline_desc : 'Underline (Ctrl+U)', -striketrough_desc : 'Strikethrough', -justifyleft_desc : 'Align left', -justifycenter_desc : 'Align center', -justifyright_desc : 'Align right', -justifyfull_desc : 'Align full', -bullist_desc : 'Unordered list', -numlist_desc : 'Ordered list', -outdent_desc : 'Outdent', -indent_desc : 'Indent', -undo_desc : 'Undo (Ctrl+Z)', -redo_desc : 'Redo (Ctrl+Y)', -link_desc : 'Insert/edit link', -unlink_desc : 'Unlink', -image_desc : 'Insert/edit image', -cleanup_desc : 'Cleanup messy code', -focus_alert : 'A editor instance must be focused before using this command.', -edit_confirm : 'Do you want to use the WYSIWYG mode for this textarea?', -insert_link_title : 'Insert/edit link', -insert : 'Insert', -update : 'Update', -cancel : 'Cancel', -insert_link_url : 'Link URL', -insert_link_target : 'Target', -insert_link_target_same : 'Open link in the same window', -insert_link_target_blank : 'Open link in a new window', -insert_image_title : 'Insert/edit image', -insert_image_src : 'Image URL', -insert_image_alt : 'Image description', -help_desc : 'Help', -bold_img : "bold.gif", -italic_img : "italic.gif", -underline_img : "underline.gif", -clipboard_msg : 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?', -popup_blocked : 'Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.' -}); diff --git a/wp-includes/js/tinymce/langs/wp-langs.php b/wp-includes/js/tinymce/langs/wp-langs.php new file mode 100644 index 00000000..b1875e9a --- /dev/null +++ b/wp-includes/js/tinymce/langs/wp-langs.php @@ -0,0 +1,401 @@ + \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js index 2cdfb09b..01a994ee 100644 --- a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js @@ -1,46 +1 @@ -/** - * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ - * - * @author Moxiecode - * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. - */ - -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('autosave'); - -var TinyMCE_AutoSavePlugin = { - getInfo : function() { - return { - longname : 'Auto save', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; - }, - - // Private plugin internal methods - - _beforeUnloadHandler : function() { - var n, inst, anyDirty = false, msg = tinyMCE.getLang("lang_autosave_unload_msg"); - - if (tinyMCE.getParam("fullscreen_is_enabled")) - return; - - for (n in tinyMCE.instances) { - inst = tinyMCE.instances[n]; - - if (!tinyMCE.isInstance(inst)) - continue; - - if (inst.isDirty()) - return msg; - } - - return; - } -}; - -window.onbeforeunload = TinyMCE_AutoSavePlugin._beforeUnloadHandler; - -tinyMCE.addPlugin("autosave", TinyMCE_AutoSavePlugin); +(function(){tinymce.create('tinymce.plugins.AutoSavePlugin',{init:function(ed,url){var t=this;t.editor=ed;window.onbeforeunload=tinymce.plugins.AutoSavePlugin._beforeUnloadHandler;},getInfo:function(){return{longname:'Auto save',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',version:tinymce.majorVersion+"."+tinymce.minorVersion};},'static':{_beforeUnloadHandler:function(){var msg;tinymce.each(tinyMCE.editors,function(ed){if(ed.getParam("fullscreen_is_enabled"))return;if(ed.isDirty()){msg=ed.getLang("autosave.unload_msg");return false;}});return msg;}}});tinymce.PluginManager.add('autosave',tinymce.plugins.AutoSavePlugin);})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js deleted file mode 100644 index 7c2ddb00..00000000 --- a/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js +++ /dev/null @@ -1,30 +0,0 @@ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('autosave', 'en,sv,cs,he,no,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,fi,cy,es,is,pl'); - -function TinyMCE_autosave_getInfo() { - return { - longname : 'Auto save', - author : 'Moxiecode Systems', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; -}; - -function TinyMCE_autosave_beforeUnloadHandler() { - var msg = tinyMCE.getLang("lang_autosave_unload_msg"); - - var anyDirty = false; - for (var n in tinyMCE.instances) { - var inst = tinyMCE.instances[n]; - if (!tinyMCE.isInstance(inst)) - continue; - - if (inst.isDirty()) - return msg; - } - - return; -} - -window.onbeforeunload = TinyMCE_autosave_beforeUnloadHandler; diff --git a/wp-includes/js/tinymce/plugins/autosave/langs/en.js b/wp-includes/js/tinymce/plugins/autosave/langs/en.js deleted file mode 100644 index a1849339..00000000 --- a/wp-includes/js/tinymce/plugins/autosave/langs/en.js +++ /dev/null @@ -1,5 +0,0 @@ -// EN lang variables - -tinyMCE.addToLang('',{ -autosave_unload_msg : 'The changes you made will be lost if you navigate away from this page.' -}); diff --git a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js index 7864535d..6966d80a 100644 --- a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js @@ -1,90 +1 @@ -/** - * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ - * - * @author Moxiecode - * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. - */ - -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('directionality'); - -var TinyMCE_DirectionalityPlugin = { - getInfo : function() { - return { - longname : 'Directionality', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; - }, - - getControlHTML : function(cn) { - switch (cn) { - case "ltr": - return tinyMCE.getButtonHTML(cn, 'lang_directionality_ltr_desc', '{$pluginurl}/images/ltr.gif', 'mceDirectionLTR'); - - case "rtl": - return tinyMCE.getButtonHTML(cn, 'lang_directionality_rtl_desc', '{$pluginurl}/images/rtl.gif', 'mceDirectionRTL'); - } - - return ""; - }, - - execCommand : function(editor_id, element, command, user_interface, value) { - // Handle commands - switch (command) { - case "mceDirectionLTR": - var inst = tinyMCE.getInstanceById(editor_id); - var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); - - if (elm) - elm.setAttribute("dir", "ltr"); - - tinyMCE.triggerNodeChange(false); - return true; - - case "mceDirectionRTL": - var inst = tinyMCE.getInstanceById(editor_id); - var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); - - if (elm) - elm.setAttribute("dir", "rtl"); - - tinyMCE.triggerNodeChange(false); - return true; - } - - // Pass to next handler in chain - return false; - }, - - handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { - function getAttrib(elm, name) { - return elm.getAttribute(name) ? elm.getAttribute(name) : ""; - } - - if (node == null) - return; - - var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); - if (!elm) { - tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonDisabled'); - return true; - } - - tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonNormal'); - - var dir = getAttrib(elm, "dir"); - if (dir == "ltr" || dir == "") - tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonSelected'); - else - tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonSelected'); - - return true; - } -}; - -tinyMCE.addPlugin("directionality", TinyMCE_DirectionalityPlugin); +(function(){tinymce.create('tinymce.plugins.Directionality',{init:function(ed,url){var t=this;t.editor=ed;ed.addCommand('mceDirectionLTR',function(){var e=ed.dom.getParent(ed.selection.getNode(),ed.dom.isBlock);if(e){if(ed.dom.getAttrib(e,"dir")!="ltr")ed.dom.setAttrib(e,"dir","ltr");else ed.dom.setAttrib(e,"dir","");}ed.nodeChanged();});ed.addCommand('mceDirectionRTL',function(){var e=ed.dom.getParent(ed.selection.getNode(),ed.dom.isBlock);if(e){if(ed.dom.getAttrib(e,"dir")!="rtl")ed.dom.setAttrib(e,"dir","rtl");else ed.dom.setAttrib(e,"dir","");}ed.nodeChanged();});ed.addButton('ltr',{title:'directionality.ltr_desc',cmd:'mceDirectionLTR'});ed.addButton('rtl',{title:'directionality.rtl_desc',cmd:'mceDirectionRTL'});ed.onNodeChange.add(t._nodeChange,t);},getInfo:function(){return{longname:'Directionality',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_nodeChange:function(ed,cm,n){var dom=ed.dom,dir;n=dom.getParent(n,dom.isBlock);if(!n){cm.setDisabled('ltr',1);cm.setDisabled('rtl',1);return;}dir=dom.getAttrib(n,'dir');cm.setActive('ltr',dir=="ltr");cm.setDisabled('ltr',0);cm.setActive('rtl',dir=="rtl");cm.setDisabled('rtl',0);}});tinymce.PluginManager.add('directionality',tinymce.plugins.Directionality);})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/directionality/images/ltr.gif b/wp-includes/js/tinymce/plugins/directionality/images/ltr.gif deleted file mode 100644 index ac8f30c1..00000000 Binary files a/wp-includes/js/tinymce/plugins/directionality/images/ltr.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/directionality/images/rtl.gif b/wp-includes/js/tinymce/plugins/directionality/images/rtl.gif deleted file mode 100644 index 0348f996..00000000 Binary files a/wp-includes/js/tinymce/plugins/directionality/images/rtl.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/directionality/langs/en.js b/wp-includes/js/tinymce/plugins/directionality/langs/en.js deleted file mode 100644 index 94c3c040..00000000 --- a/wp-includes/js/tinymce/plugins/directionality/langs/en.js +++ /dev/null @@ -1,6 +0,0 @@ -// UK lang variables - -tinyMCE.addToLang('',{ -directionality_ltr_desc : 'Direction left to right (Alt-.)', -directionality_rtl_desc : 'Direction right to left (Alt-,)' -}); diff --git a/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js b/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js new file mode 100644 index 00000000..7b848f1e --- /dev/null +++ b/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js @@ -0,0 +1 @@ +(function(){var DOM=tinymce.DOM;tinymce.create('tinymce.plugins.FullScreenPlugin',{init:function(ed,url){var t=this,s={},vp;t.editor=ed;ed.addCommand('mceFullScreen',function(){var win,de=DOM.doc.documentElement;if(ed.getParam('fullscreen_is_enabled')){if(ed.getParam('fullscreen_new_window'))closeFullscreen();else{DOM.win.setTimeout(function(){tinymce.dom.Event.remove(DOM.win,'resize',t.resizeFunc);tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format:'raw'}),{format:'raw'});tinyMCE.remove(ed);DOM.remove('mce_fullscreen_container');de.style.overflow=ed.getParam('fullscreen_html_overflow');DOM.setStyle(DOM.doc.body,'overflow',ed.getParam('fullscreen_overflow'));DOM.win.scrollTo(ed.getParam('fullscreen_scrollx'),ed.getParam('fullscreen_scrolly'));tinyMCE.settings=tinyMCE.oldSettings;},10);}return;}if(ed.getParam('fullscreen_new_window')){win=DOM.win.open(url+"/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{win.resizeTo(screen.availWidth,screen.availHeight);}catch(e){}}else{tinyMCE.oldSettings=tinyMCE.settings;s.fullscreen_overflow=DOM.getStyle(DOM.doc.body,'overflow',1)||'auto';s.fullscreen_html_overflow=DOM.getStyle(de,'overflow',1);vp=DOM.getViewPort();s.fullscreen_scrollx=vp.x;s.fullscreen_scrolly=vp.y;if(tinymce.isOpera&&s.fullscreen_overflow=='visible')s.fullscreen_overflow='auto';if(tinymce.isIE&&s.fullscreen_overflow=='scroll')s.fullscreen_overflow='auto';if(s.fullscreen_overflow=='0px')s.fullscreen_overflow='';DOM.setStyle(DOM.doc.body,'overflow','hidden');de.style.overflow='hidden';vp=DOM.getViewPort();DOM.win.scrollTo(0,0);if(tinymce.isIE)vp.h-=1;n=DOM.add(DOM.doc.body,'div',{id:'mce_fullscreen_container',style:'position:absolute;top:0;left:0;width:'+vp.w+'px;height:'+vp.h+'px;z-index:200000;'});DOM.add(n,'div',{id:'mce_fullscreen'});tinymce.each(ed.settings,function(v,n){s[n]=v;});s.id='mce_fullscreen';s.width=n.clientWidth;s.height=n.clientHeight-15;s.fullscreen_is_enabled=true;s.fullscreen_editor_id=ed.id;s.theme_advanced_resizing=false;s.save_onsavecallback=function(){ed.setContent(tinyMCE.get(s.id).getContent({format:'raw'}),{format:'raw'});ed.execCommand('mceSave');};tinymce.each(ed.getParam('fullscreen_settings'),function(v,k){s[k]=v;});if(s.theme_advanced_toolbar_location==='external')s.theme_advanced_toolbar_location='top';t.fullscreenEditor=new tinymce.Editor('mce_fullscreen',s);t.fullscreenEditor.onInit.add(function(){t.fullscreenEditor.setContent(ed.getContent());t.fullscreenEditor.focus();});t.fullscreenEditor.render();tinyMCE.add(t.fullscreenEditor);t.fullscreenElement=new tinymce.dom.Element('mce_fullscreen_container');t.fullscreenElement.update();t.resizeFunc=tinymce.dom.Event.add(DOM.win,'resize',function(){var vp=tinymce.DOM.getViewPort();t.fullscreenEditor.theme.resizeTo(vp.w,vp.h);});}});ed.addButton('fullscreen',{title:'fullscreen.desc',cmd:'mceFullScreen'});ed.onNodeChange.add(function(ed,cm){cm.setActive('fullscreen',ed.getParam('fullscreen_is_enabled'));});},getInfo:function(){return{longname:'Fullscreen',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',version:tinymce.majorVersion+"."+tinymce.minorVersion};}});tinymce.PluginManager.add('fullscreen',tinymce.plugins.FullScreenPlugin);})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm b/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm new file mode 100644 index 00000000..a18f3967 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css b/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css deleted file mode 100644 index 43be823c..00000000 --- a/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css +++ /dev/null @@ -1,69 +0,0 @@ -/* Window classes */ - -.mceWindow { - position: absolute; - left: 0; - top: 0; - border: 1px solid black; - background-color: #D4D0C8; -} - -.mceWindowHead { - background-color: #334F8D; - width: 100%; - height: 18px; - cursor: move; - overflow: hidden; -} - -.mceWindowBody { - clear: both; - background-color: white; -} - -.mceWindowStatusbar { - background-color: #D4D0C8; - height: 12px; - border-top: 1px solid black; -} - -.mceWindowTitle { - float: left; - font-family: "MS Sans Serif"; - font-size: 9pt; - font-weight: bold; - line-height: 18px; - color: white; - margin-left: 2px; - overflow: hidden; -} - -.mceWindowHeadTools { - margin-right: 2px; -} - -.mceWindowClose, .mceWindowMinimize, .mceWindowMaximize { - display: block; - float: right; - overflow: hidden; - margin-top: 2px; -} - -.mceWindowClose { - margin-left: 2px; -} - -.mceWindowMinimize { -} - -.mceWindowMaximize { -} - -.mceWindowResize { - display: block; - float: right; - overflow: hidden; - cursor: se-resize; - width: 12px; - height: 12px; -} diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js index 69170320..0766b49a 100644 --- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js @@ -1,826 +1 @@ -/** - * $Id: editor_plugin_src.js 268 2007-04-28 15:52:59Z spocke $ - * - * Moxiecode DHTML Windows script. - * - * @author Moxiecode - * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. - */ - -// Patch openWindow, closeWindow TinyMCE functions - -var TinyMCE_InlinePopupsPlugin = { - getInfo : function() { - return { - longname : 'Inline Popups', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; - } -}; - -tinyMCE.addPlugin("inlinepopups", TinyMCE_InlinePopupsPlugin); - -// Patch openWindow, closeWindow TinyMCE functions - -TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow; -TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow; - -TinyMCE_Engine.prototype.openWindow = function(template, args) { - // Does the caller support inline - if (args['inline'] != "yes" || tinyMCE.isOpera || tinyMCE.getParam("plugins").indexOf('inlinepopups') == -1) { - mcWindows.selectedWindow = null; - args['mce_inside_iframe'] = false; - this.orgOpenWindow(template, args); - return; - } - - var url, resizable, scrollbars; - - args['mce_inside_iframe'] = true; - tinyMCE.windowArgs = args; - - if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1) - url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file']; - else - url = template['file']; - - if (!(width = parseInt(template['width']))) - width = 320; - - if (!(height = parseInt(template['height']))) - height = 200; - - if (!(minWidth = parseInt(template['minWidth']))) - minWidth = 100; - - if (!(minHeight = parseInt(template['minHeight']))) - minHeight = 100; - - resizable = (args && args['resizable']) ? args['resizable'] : "no"; - scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no"; - - height += 18; - - // Replace all args as variables in URL - for (var name in args) { - if (typeof(args[name]) == 'function') - continue; - - url = tinyMCE.replaceVar(url, name, escape(args[name])); - } - - var elm = document.getElementById(this.selectedInstance.editorId + '_parent'); - - if (tinyMCE.hasPlugin('fullscreen') && this.selectedInstance.getData('fullscreen').enabled) - pos = { absLeft: 0, absTop: 0 }; - else - pos = tinyMCE.getAbsPosition(elm); - - // Center div in editor area - pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2)); - pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2)); - - // WordPress cache buster - url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; - - mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop + ",minWidth=" + minWidth + ",minHeight=" + minHeight ); -}; - -TinyMCE_Engine.prototype.closeWindow = function(win) { - var gotit = false, n, w; - - for (n in mcWindows.windows) { - w = mcWindows.windows[n]; - - if (typeof(w) == 'function') - continue; - - if (win.name == w.id + '_iframe') { - w.close(); - gotit = true; - } - } - - if (!gotit) - this.orgCloseWindow(win); - - tinyMCE.selectedInstance.getWin().focus(); -}; - -TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) { - for (var n in mcWindows.windows) { - var win = mcWindows.windows[n]; - if (typeof(win) == 'function') - continue; - - if (win_ref.name == win.id + "_iframe") - window.frames[win.id + "_iframe"].document.getElementById(win.id + '_title').innerHTML = title; - } -}; - -// * * * * * TinyMCE_Windows classes below - -// Windows handler -function TinyMCE_Windows() { - this.settings = new Array(); - this.windows = new Array(); - this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); - this.isGecko = navigator.userAgent.indexOf('Gecko') != -1; - this.isSafari = navigator.userAgent.indexOf('Safari') != -1; - this.isMac = navigator.userAgent.indexOf('Mac') != -1; - this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1); - this.action = "none"; - this.selectedWindow = null; - this.lastSelectedWindow = null; - this.zindex = 1001; - this.mouseDownScreenX = 0; - this.mouseDownScreenY = 0; - this.mouseDownLayerX = 0; - this.mouseDownLayerY = 0; - this.mouseDownWidth = 0; - this.mouseDownHeight = 0; - this.idCounter = 0; -}; - -TinyMCE_Windows.prototype.init = function(settings) { - this.settings = settings; - - if (this.isMSIE) - this.addEvent(document, "mousemove", mcWindows.eventDispatcher); - else - this.addEvent(window, "mousemove", mcWindows.eventDispatcher); - - this.addEvent(document, "mouseup", mcWindows.eventDispatcher); - - this.addEvent(window, "resize", mcWindows.eventDispatcher); - this.addEvent(document, "scroll", mcWindows.eventDispatcher); - - this.doc = document; -}; - -TinyMCE_Windows.prototype.getBounds = function() { - if (!this.bounds) { - var vp = tinyMCE.getViewPort(window); - var top, left, bottom, right, docEl = this.doc.documentElement; - - top = vp.top; - left = vp.left; - bottom = vp.height + top - 2; - right = vp.width + left - 22; // TODO this number is platform dependant - // x1, y1, x2, y2 - this.bounds = [left, top, right, bottom]; - } - return this.bounds; -}; - -TinyMCE_Windows.prototype.clampBoxPosition = function(x, y, w, h, minW, minH) { - var bounds = this.getBounds(); - - x = Math.max(bounds[0], Math.min(bounds[2], x + w) - w); - y = Math.max(bounds[1], Math.min(bounds[3], y + h) - h); - - return this.clampBoxSize(x, y, w, h, minW, minH); -}; - -TinyMCE_Windows.prototype.clampBoxSize = function(x, y, w, h, minW, minH) { - var bounds = this.getBounds(); - - return [ - x, y, - Math.max(minW, Math.min(bounds[2], x + w) - x), - Math.max(minH, Math.min(bounds[3], y + h) - y) - ]; -}; - -TinyMCE_Windows.prototype.getParam = function(name, default_value) { - var value = null; - - value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; - - // Fix bool values - if (value == "true" || value == "false") - return (value == "true"); - - return value; -}; - -TinyMCE_Windows.prototype.eventDispatcher = function(e) { - e = typeof(e) == "undefined" ? window.event : e; - - if (mcWindows.selectedWindow == null) - return; - - // Switch focus - if (mcWindows.isGecko && e.type == "mousedown") { - var elm = e.currentTarget; - - for (var n in mcWindows.windows) { - var win = mcWindows.windows[n]; - - if (win.headElement == elm || win.resizeElement == elm) { - win.focus(); - break; - } - } - } - - switch (e.type) { - case "mousemove": - mcWindows.selectedWindow.onMouseMove(e); - break; - - case "mouseup": - mcWindows.selectedWindow.onMouseUp(e); - break; - - case "mousedown": - mcWindows.selectedWindow.onMouseDown(e); - break; - - case "focus": - mcWindows.selectedWindow.onFocus(e); - break; - case "scroll": - case "resize": - if (mcWindows.clampUpdateTimeout) - clearTimeout(mcWindows.clampUpdateTimeout); - mcWindows.clampEventType = e.type; - mcWindows.clampUpdateTimeout = - setTimeout(function () {mcWindows.updateClamping()}, 100); - break; - } -}; - -TinyMCE_Windows.prototype.updateClamping = function () { - var clamp, oversize, etype = mcWindows.clampEventType; - - this.bounds = null; // Recalc window bounds on resize/scroll - this.clampUpdateTimeout = null; - - for (var n in this.windows) { - win = this.windows[n]; - if (typeof(win) == 'function' || ! win.winElement) continue; - - clamp = mcWindows.clampBoxPosition( - win.left, win.top, - win.winElement.scrollWidth, - win.winElement.scrollHeight, - win.features.minWidth, - win.features.minHeight - ); - oversize = ( - clamp[2] != win.winElement.scrollWidth || - clamp[3] != win.winElement.scrollHeight - ) ? true : false; - - if (!oversize || win.features.resizable == "yes" || etype != "scroll") - win.moveTo(clamp[0], clamp[1]); - if (oversize && win.features.resizable == "yes") - win.resizeTo(clamp[2], clamp[3]); - } -}; - -TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) { - if (this.isMSIE) - obj.attachEvent("on" + name, handler); - else - obj.addEventListener(name, handler, false); -}; - -TinyMCE_Windows.prototype.cancelEvent = function(e) { - if (this.isMSIE) { - e.returnValue = false; - e.cancelBubble = true; - } else - e.preventDefault(); -}; - -TinyMCE_Windows.prototype.parseFeatures = function(opts) { - // Cleanup the options - opts = opts.toLowerCase(); - opts = opts.replace(/;/g, ","); - opts = opts.replace(/[^0-9a-z=,]/g, ""); - - var optionChunks = opts.split(','); - var options = new Array(); - - options['left'] = "10"; - options['top'] = "10"; - options['width'] = "300"; - options['height'] = "300"; - options['minwidth'] = "100"; - options['minheight'] = "100"; - options['resizable'] = "yes"; - options['minimizable'] = "yes"; - options['maximizable'] = "yes"; - options['close'] = "yes"; - options['movable'] = "yes"; - options['statusbar'] = "yes"; - options['scrollbars'] = "auto"; - options['modal'] = "no"; - - if (opts == "") - return options; - - for (var i=0; i'; - html += ''; - html += ''; - - html += '
    '; - html += '
    '; - html += '
    '; - if (features['resizable'] == "yes" && features['maximizable'] == "yes") - html += ' '; - // html += ' '; - html += '
    '; - html += '
    '; - html += '
    '; - - if (features['statusbar'] == "yes") { - html += '
    '; - - if (features['resizable'] == "yes") { - if (this.isGecko) - html += '
    '; - else - html += '
    '; - } - - html += '
    '; - } - - html += '
    '; - - html += ''; - html += ''; - - // Create iframe - this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html); -}; - -// Blocks the document events by placing a image over the whole document -TinyMCE_Windows.prototype.setDocumentLock = function(state) { - var elm = document.getElementById('mcWindowEventBlocker'); - - if (state) { - if (elm == null) { - elm = document.createElement("div"); - - elm.id = "mcWindowEventBlocker"; - elm.style.position = "absolute"; - elm.style.left = "0"; - elm.style.top = "0"; - - document.body.appendChild(elm); - } - - elm.style.display = "none"; - - var imgPath = this.getParam("images_path"); - var width = document.body.clientWidth; - var height = document.body.clientHeight; - - elm.style.width = width; - elm.style.height = height; - elm.innerHTML = ''; - - elm.style.zIndex = mcWindows.zindex-1; - elm.style.display = "block"; - } else if (elm != null) { - if (mcWindows.windows.length == 0) - elm.parentNode.removeChild(elm); - else - elm.style.zIndex = mcWindows.zindex-1; - } -}; - -// Gets called when wrapper iframe is initialized -TinyMCE_Windows.prototype.onLoad = function(name) { - var win = mcWindows.windows[name]; - var id = "mcWindow_" + name; - var wrapperIframe = window.frames[id + "_iframe"].frames[0]; - var wrapperDoc = window.frames[id + "_iframe"].document; - var doc = window.frames[id + "_iframe"].document; - var winDiv = document.getElementById("mcWindow_" + name + "_div"); - var realIframe = window.frames[id + "_iframe"].frames[0]; - - // Set window data - win.id = "mcWindow_" + name; - win.winElement = winDiv; - win.bodyElement = doc.getElementById(id + '_body'); - win.iframeElement = doc.getElementById(id + '_iframe'); - win.headElement = doc.getElementById(id + '_head'); - win.titleElement = doc.getElementById(id + '_title'); - win.resizeElement = doc.getElementById(id + '_resize'); - win.containerElement = doc.getElementById(id + '_container'); - win.left = win.features['left']; - win.top = win.features['top']; - win.frame = window.frames[id + '_iframe'].frames[0]; - win.wrapperFrame = window.frames[id + '_iframe']; - win.wrapperIFrameElement = document.getElementById(id + "_iframe"); - - // Add event handlers - mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher); - - if (win.resizeElement != null) - mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher); - - if (mcWindows.isMSIE) { - mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher); - } else { - mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher); - } - - for (var i=0; i'));}mdf=Event.add(id,'mousedown',function(e){var n=e.target,w,vp;w=t.windows[id];t.focus(id);if(n.nodeName=='A'||n.nodeName=='a'){if(n.className=='mceMax'){w.oldPos=w.element.getXY();w.oldSize=w.element.getSize();vp=DOM.getViewPort();vp.w-=2;vp.h-=2;w.element.moveTo(vp.x,vp.y);w.element.resizeTo(vp.w,vp.h);DOM.setStyles(id+'_ifr',{width:vp.w-w.deltaWidth,height:vp.h-w.deltaHeight});DOM.addClass(id+'_wrapper','mceMaximized');}else if(n.className=='mceMed'){w.element.moveTo(w.oldPos.x,w.oldPos.y);w.element.resizeTo(w.oldSize.w,w.oldSize.h);w.iframeElement.resizeTo(w.oldSize.w-w.deltaWidth,w.oldSize.h-w.deltaHeight);DOM.removeClass(id+'_wrapper','mceMaximized');}else if(n.className=='mceMove')return t._startDrag(id,e,n.className);else if(DOM.hasClass(n,'mceResize'))return t._startDrag(id,e,n.className.substring(13));}});clf=Event.add(id,'click',function(e){var n=e.target;t.focus(id);if(n.nodeName=='A'||n.nodeName=='a'){switch(n.className){case'mceClose':t.close(null,id);return Event.cancel(e);case'mceButton mceOk':case'mceButton mceCancel':f.button_func(n.className=='mceButton mceOk');return Event.cancel(e);}}});t.windows=t.windows||{};w=t.windows[id]={id:id,mousedown_func:mdf,click_func:clf,element:new Element(id,{blocker:1,container:ed.getContainer()}),iframeElement:new Element(id+'_ifr'),features:f,deltaWidth:dw,deltaHeight:dh};w.iframeElement.on('focus',function(){t.focus(id);});if(t.count==0&&t.editor.getParam('dialog_type')=='modal'){DOM.add(DOM.doc.body,'div',{id:'mceModalBlocker','class':(t.editor.settings.inlinepopups_skin||'clearlooks2')+'_modalBlocker',style:{left:vp.x,top:vp.y,zIndex:t.zIndex-1}});DOM.show('mceModalBlocker');}else DOM.setStyle('mceModalBlocker','z-index',t.zIndex-1);t.focus(id);t._fixIELayout(id,1);if(DOM.get(id+'_ok'))DOM.get(id+'_ok').focus();t.count++;return w;},focus:function(id){var t=this,w=t.windows[id];w.zIndex=this.zIndex++;w.element.setStyle('zIndex',w.zIndex);w.element.update();id=id+'_wrapper';DOM.removeClass(t.lastId,'mceFocus');DOM.addClass(id,'mceFocus');t.lastId=id;},_addAll:function(te,ne){var i,n,t=this,dom=tinymce.DOM;if(is(ne,'string'))te.appendChild(dom.doc.createTextNode(ne));else if(ne.length){te=te.appendChild(dom.create(ne[0],ne[1]));for(i=2;iix){fw=w;ix=w.zIndex;}});if(fw)t.focus(fw.id);}},setTitle:function(ti,id){var e;if(e=DOM.get(id+'_title'))e.innerHTML=DOM.encode(ti);},alert:function(txt,cb,s){var t=this,w;w=t.open({title:t,type:'alert',button_func:function(s){if(cb)cb.call(s||t,s);t.close(null,w.id);},content:DOM.encode(t.editor.getLang(txt,txt)),inline:1,width:400,height:130});},confirm:function(txt,cb,s){var t=this,w;w=t.open({title:t,type:'confirm',button_func:function(s){if(cb)cb.call(s||t,s);t.close(null,w.id);},content:DOM.encode(t.editor.getLang(txt,txt)),inline:1,width:400,height:130});},_fixIELayout:function(id,s){var w,img;if(!tinymce.isIE6)return;each(['n','s','w','e','nw','ne','sw','se'],function(v){var e=DOM.get(id+'_resize_'+v);DOM.setStyles(e,{width:s?e.clientWidth:'',height:s?e.clientHeight:'',cursor:DOM.getStyle(e,'cursor',1)});DOM.setStyle(id+"_bottom",'bottom','-1px');e=0;});if(w=this.windows[id]){w.element.hide();w.element.show();each(DOM.select('div,a',id),function(e,i){if(e.currentStyle.backgroundImage!='none'){img=new Image();img.src=e.currentStyle.backgroundImage.replace(/url\(\"(.+)\"\)/,'$1');}});DOM.get(id).style.filter='';}}});tinymce.PluginManager.add('inlinepopups',tinymce.plugins.InlinePopups);})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif deleted file mode 100644 index fc256098..00000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/spacer.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif deleted file mode 100644 index 3469e5ae..00000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_close.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_maximize.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_maximize.gif deleted file mode 100644 index fcae73e9..00000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_maximize.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif deleted file mode 100644 index 94f167a4..00000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_minimize.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_resize.gif b/wp-includes/js/tinymce/plugins/inlinepopups/images/window_resize.gif deleted file mode 100644 index 6c402d0b..00000000 Binary files a/wp-includes/js/tinymce/plugins/inlinepopups/images/window_resize.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js b/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js deleted file mode 100644 index b28e51dc..00000000 --- a/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js +++ /dev/null @@ -1,453 +0,0 @@ -/** - * $Id: mcwindows.js 18 2006-06-29 14:11:23Z spocke $ - * - * Moxiecode DHTML Windows script. - * - * @author Moxiecode - * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved. - */ - -// Windows handler -function MCWindows() { - this.settings = new Array(); - this.windows = new Array(); - this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); - this.isGecko = navigator.userAgent.indexOf('Gecko') != -1; - this.isSafari = navigator.userAgent.indexOf('Safari') != -1; - this.isMac = navigator.userAgent.indexOf('Mac') != -1; - this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1); - this.action = "none"; - this.selectedWindow = null; - this.zindex = 100; - this.mouseDownScreenX = 0; - this.mouseDownScreenY = 0; - this.mouseDownLayerX = 0; - this.mouseDownLayerY = 0; - this.mouseDownWidth = 0; - this.mouseDownHeight = 0; -}; - -MCWindows.prototype.init = function(settings) { - this.settings = settings; - - if (this.isMSIE) - this.addEvent(document, "mousemove", mcWindows.eventDispatcher); - else - this.addEvent(window, "mousemove", mcWindows.eventDispatcher); - - this.addEvent(document, "mouseup", mcWindows.eventDispatcher); -}; - -MCWindows.prototype.getParam = function(name, default_value) { - var value = null; - - value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; - - // Fix bool values - if (value == "true" || value == "false") - return (value == "true"); - - return value; -}; - -MCWindows.prototype.eventDispatcher = function(e) { - e = typeof(e) == "undefined" ? window.event : e; - - if (mcWindows.selectedWindow == null) - return; - - // Switch focus - if (mcWindows.isGecko && e.type == "mousedown") { - var elm = e.currentTarget; - - for (var n in mcWindows.windows) { - var win = mcWindows.windows[n]; - if (typeof(win) == 'function') - continue; - - if (win.headElement == elm || win.resizeElement == elm) { - win.focus(); - break; - } - } - } - - switch (e.type) { - case "mousemove": - mcWindows.selectedWindow.onMouseMove(e); - break; - - case "mouseup": - mcWindows.selectedWindow.onMouseUp(e); - break; - - case "mousedown": - mcWindows.selectedWindow.onMouseDown(e); - break; - - case "focus": - mcWindows.selectedWindow.onFocus(e); - break; - } -} - -MCWindows.prototype.addEvent = function(obj, name, handler) { - if (this.isMSIE) - obj.attachEvent("on" + name, handler); - else - obj.addEventListener(name, handler, true); -}; - -MCWindows.prototype.cancelEvent = function(e) { - if (this.isMSIE) { - e.returnValue = false; - e.cancelBubble = true; - } else - e.preventDefault(); -}; - -MCWindows.prototype.parseFeatures = function(opts) { - // Cleanup the options - opts = opts.toLowerCase(); - opts = opts.replace(/;/g, ","); - opts = opts.replace(/[^0-9a-z=,]/g, ""); - - var optionChunks = opts.split(','); - var options = new Array(); - - options['left'] = 10; - options['top'] = 10; - options['width'] = 300; - options['height'] = 300; - options['resizable'] = true; - options['minimizable'] = true; - options['maximizable'] = true; - options['close'] = true; - options['movable'] = true; - - if (opts == "") - return options; - - for (var i=0; i'; - - html += '
    '; - html += '
    '; - html += '
    '; -// html += ' '; -// html += ' '; - html += '
    '; - html += '
    '; - html += '
    '; - html += '
    '; - html += '
    '; - html += '
    '; - html += '
    '; - - html += ''; - html += ''; - - // Create iframe - this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html); -}; - -// Gets called when wrapper iframe is initialized -MCWindows.prototype.onLoad = function(name) { - var win = mcWindows.windows[name]; - var id = "mcWindow_" + name; - var wrapperIframe = window.frames[id + "_iframe"].frames[0]; - var wrapperDoc = window.frames[id + "_iframe"].document; - var doc = window.frames[id + "_iframe"].document; - var winDiv = document.getElementById("mcWindow_" + name + "_div"); - var realIframe = window.frames[id + "_iframe"].frames[0]; - - // Set window data - win.id = "mcWindow_" + name + "_iframe"; - win.winElement = winDiv; - win.bodyElement = doc.getElementById(id + '_body'); - win.iframeElement = doc.getElementById(id + '_iframe'); - win.headElement = doc.getElementById(id + '_head'); - win.titleElement = doc.getElementById(id + '_title'); - win.resizeElement = doc.getElementById(id + '_resize'); - win.containerElement = doc.getElementById(id + '_container'); - win.left = win.features['left']; - win.top = win.features['top']; - win.frame = window.frames[id + '_iframe'].frames[0]; - win.wrapperFrame = window.frames[id + '_iframe']; - win.wrapperIFrameElement = document.getElementById(id + "_iframe"); - - // Add event handlers - mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher); - mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher); - - if (mcWindows.isMSIE) { - mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher); - } else { - mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher); - mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher); - } - - for (var i=0; i --> + + +Template for dialogs + + + + +
    +
    +
    +
    +
    +
    +
    + Blured +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Focused +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Statusbar +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Statusbar, Resizable +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Resizable, Maximizable +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Blurred, Maximizable, Statusbar, Resizable +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Maximized, Maximizable, Minimizable +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Blured +
    + +
    +
    + Content +
    +
    + +
    +
    +
    +
    + Statusbar text. +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    + Alert +
    + +
    +
    + + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + +
    +
    +
    + +
    +
    +
    +
    +
    + + + Ok + +
    +
    + +
    +
    +
    +
    +
    +
    + Confirm +
    + +
    +
    + + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + This is a very long error message. This is a very long error message. + +
    +
    +
    + +
    +
    +
    +
    +
    + + + Ok + Cancel + +
    +
    +
    + + + diff --git a/wp-includes/js/tinymce/plugins/media/css/content.css b/wp-includes/js/tinymce/plugins/media/css/content.css new file mode 100644 index 00000000..7739381d --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/css/content.css @@ -0,0 +1,6 @@ +.mceItemFlash, .mceItemShockWave, .mceItemQuickTime, .mceItemWindowsMedia, .mceItemRealMedia {border:1px dotted #cc0000; background-position:center; background-repeat:no-repeat; background-color:#ffffcc;} +.mceItemShockWave {background-image: url(../img/shockwave.gif);} +.mceItemFlash {background-image:url(../img/flash.gif);} +.mceItemQuickTime {background-image:url(../img/quicktime.gif);} +.mceItemWindowsMedia {background-image:url(../img/windowsmedia.gif);} +.mceItemRealMedia {background-image:url(../img/realmedia.gif);} diff --git a/wp-includes/js/tinymce/plugins/media/css/media.css b/wp-includes/js/tinymce/plugins/media/css/media.css new file mode 100644 index 00000000..62d666a5 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/css/media.css @@ -0,0 +1,68 @@ +#id, #name, #hspace, #vspace, #class_name, #align { + width: 100px; +} + +#hspace, #vspace { + width: 50px; +} + +#flash_quality, #flash_align, #flash_scale, #flash_salign, #flash_wmode { + width: 100px; +} + +#flash_base, #flash_flashvars { + width: 240px; +} + +#width, #height { + width: 40px; +} + +#src, #media_type { + width: 250px; +} + +#class { + width: 120px; +} + +#prev { + margin: 0; + border: 1px solid black; + width: 99%; + height: 230px; + overflow: auto; +} + +.panel_wrapper div.current { + height: 390px; + overflow: auto; +} + +#flash_options, #shockwave_options, #qt_options, #wmp_options, #rmp_options { + display: none; +} + +.mceAddSelectValue { + background-color: #DDDDDD; +} + +#qt_starttime, #qt_endtime, #qt_fov, #qt_href, #qt_moveid, #qt_moviename, #qt_node, #qt_pan, #qt_qtsrc, #qt_qtsrcchokespeed, #qt_target, #qt_tilt, #qt_urlsubstituten, #qt_volume { + width: 70px; +} + +#wmp_balance, #wmp_baseurl, #wmp_captioningid, #wmp_currentmarker, #wmp_currentposition, #wmp_defaultframe, #wmp_playcount, #wmp_rate, #wmp_uimode, #wmp_volume { + width: 70px; +} + +#rmp_console, #rmp_numloop, #rmp_controls, #rmp_scriptcallbacks { + width: 70px; +} + +#shockwave_swvolume, #shockwave_swframe, #shockwave_swurl, #shockwave_swstretchvalign, #shockwave_swstretchhalign, #shockwave_swstretchstyle { + width: 90px; +} + +#qt_qtsrc { + width: 200px; +} diff --git a/wp-includes/js/tinymce/plugins/media/editor_plugin.js b/wp-includes/js/tinymce/plugins/media/editor_plugin.js new file mode 100644 index 00000000..4591be7a --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/editor_plugin.js @@ -0,0 +1 @@ +(function(){var each=tinymce.each;tinymce.create('tinymce.plugins.MediaPlugin',{init:function(ed,url){var t=this;t.editor=ed;t.url=url;function isMediaElm(n){return/^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(n.className);};ed.addCommand('mceMedia',function(){ed.windowManager.open({file:url+'/media.htm',width:430+parseInt(ed.getLang('media.delta_width',0)),height:470+parseInt(ed.getLang('media.delta_height',0)),inline:1},{plugin_url:url});});ed.addButton('media',{title:'media.desc',cmd:'mceMedia'});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('media',n.nodeName=='IMG'&&isMediaElm(n));});ed.onInit.add(function(){var lo={mceItemFlash:'flash',mceItemShockWave:'shockwave',mceItemWindowsMedia:'windowsmedia',mceItemQuickTime:'quicktime',mceItemRealMedia:'realmedia'};if(ed.settings.content_css!==false)ed.dom.loadCSS(url+"/css/content.css");if(ed.theme.onResolveName){ed.theme.onResolveName.add(function(th,o){if(o.name=='img'){each(lo,function(v,k){if(ed.dom.hasClass(o.node,k)){o.name=v;o.title=ed.dom.getAttrib(o.node,'title');return false;}});}});}if(ed&&ed.plugins.contextmenu){ed.plugins.contextmenu.onContextMenu.add(function(th,m,e){if(e.nodeName=='IMG'&&/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(e.className)){m.add({title:'media.edit',icon:'media',cmd:'mceMedia'});}});}});ed.onBeforeSetContent.add(function(ed,o){var h=o.content;h=h.replace(/]*>\s*write(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)\(\{([^\)]*)\}\);\s*<\/script>/gi,function(a,b,c){var o=t._parse(c);return''});h=h.replace(/]*)>/gi,'');h=h.replace(/]*)>/gi,'');h=h.replace(/<\/(object|embed)([^>]*)>/gi,'');h=h.replace(/]*)>/gi,function(a,b){return''});h=h.replace(/\/ class=\"mceItemParam\"><\/span>/gi,'class="mceItemParam">');o.content=h;});ed.onSetContent.add(function(){t._spansToImgs(ed.getBody());});ed.onPreProcess.add(function(ed,o){var dom=ed.dom;if(o.set){t._spansToImgs(o.node);each(dom.select('IMG',o.node),function(n){var p;if(isMediaElm(n)){p=t._parse(n.title);dom.setAttrib(n,'width',dom.getAttrib(n,'width',p.width||100));dom.setAttrib(n,'height',dom.getAttrib(n,'height',p.height||100));}});}if(o.get){each(dom.select('IMG',o.node),function(n){var ci,cb,mt;if(ed.getParam('media_use_script')){if(isMediaElm(n))n.className=n.className.replace(/mceItem/g,'mceTemp');return;}switch(n.className){case'mceItemFlash':ci='d27cdb6e-ae6d-11cf-96b8-444553540000';cb='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';mt='application/x-shockwave-flash';break;case'mceItemShockWave':ci='166b1bca-3f9c-11cf-8075-444553540000';cb='http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0';mt='application/x-director';break;case'mceItemWindowsMedia':ci=ed.getParam('media_wmp6_compatible')?'05589fa1-c356-11ce-bf01-00aa0055595a':'6bf52a52-394a-11d3-b153-00c04f79faa6';cb='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';mt='application/x-mplayer2';break;case'mceItemQuickTime':ci='02bf25d5-8c17-4b23-bc80-d3488abddc6b';cb='http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';mt='video/quicktime';break;case'mceItemRealMedia':ci='cfcdaa03-8be4-11cf-b84b-0020afbbccfa';cb='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';mt='audio/x-pn-realaudio-plugin';break;}if(ci){dom.replace(t._buildObj({classid:ci,codebase:cb,type:mt},n),n);}});}});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/_value=/g,'value=');});if(ed.getParam('media_use_script')){function getAttr(s,n){n=new RegExp(n+'=\"([^\"]+)\"','g').exec(s);return n?ed.dom.decode(n[1]):'';};ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/]+>/g,function(im){var cl=getAttr(im,'class');if(/^(mceTempFlash|mceTempShockWave|mceTempWindowsMedia|mceTempQuickTime|mceTempRealMedia)$/.test(cl)){at=t._parse(getAttr(im,'title'));at.width=getAttr(im,'width');at.height=getAttr(im,'height');im='';}return im;});});}},getInfo:function(){return{longname:'Media',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_buildObj:function(o,n){var ob,ed=this.editor,dom=ed.dom,p=this._parse(n.title);p.width=o.width=dom.getAttrib(n,'width')||100;p.height=o.height=dom.getAttrib(n,'height')||100;ob=dom.create('span',{mce_name:'object',classid:"clsid:"+o.classid,codebase:o.codebase,width:o.width,height:o.height});if(p.src)p.src=ed.convertURL(p.src,'src',n);each(p,function(v,k){if(!/^(width|height|codebase|classid)$/.test(k)){if(o.type=='application/x-mplayer2'&&k=='src')k='url';dom.add(ob,'span',{mce_name:'param',name:k,'_value':v});}});dom.add(ob,'span',tinymce.extend({mce_name:'embed',type:o.type},p));return ob;},_spansToImgs:function(p){var t=this,dom=t.editor.dom,im,ci;each(dom.select('span',p),function(n){if(dom.getAttrib(n,'class')=='mceItemObject'){ci=dom.getAttrib(n,"classid").toLowerCase().replace(/\s+/g,'');switch(ci){case'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000':dom.replace(t._createImg('mceItemFlash',n),n);break;case'clsid:166b1bca-3f9c-11cf-8075-444553540000':dom.replace(t._createImg('mceItemShockWave',n),n);break;case'clsid:6bf52a52-394a-11d3-b153-00c04f79faa6':case'clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95':case'clsid:05589fa1-c356-11ce-bf01-00aa0055595a':dom.replace(t._createImg('mceItemWindowsMedia',n),n);break;case'clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b':dom.replace(t._createImg('mceItemQuickTime',n),n);break;case'clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa':dom.replace(t._createImg('mceItemRealMedia',n),n);break;default:dom.replace(t._createImg('mceItemFlash',n),n);}return;}if(dom.getAttrib(n,'class')=='mceItemEmbed'){switch(dom.getAttrib(n,'type')){case'application/x-shockwave-flash':dom.replace(t._createImg('mceItemFlash',n),n);break;case'application/x-director':dom.replace(t._createImg('mceItemShockWave',n),n);break;case'application/x-mplayer2':dom.replace(t._createImg('mceItemWindowsMedia',n),n);break;case'video/quicktime':dom.replace(t._createImg('mceItemQuickTime',n),n);break;case'audio/x-pn-realaudio-plugin':dom.replace(t._createImg('mceItemRealMedia',n),n);break;default:dom.replace(t._createImg('mceItemFlash',n),n);}}});},_createImg:function(cl,n){var im,dom=this.editor.dom,pa={},ti='';im=dom.create('img',{src:this.url+'/img/trans.gif',width:dom.getAttrib(n,'width')||100,height:dom.getAttrib(n,'height')||100,'class':cl});each(['id','name','width','height','bgcolor','align','flashvars','src','wmode'],function(na){var v=dom.getAttrib(n,na);if(v)pa[na]=v;});each(dom.select('span',n),function(n){if(dom.hasClass(n,'mceItemParam'))pa[dom.getAttrib(n,'name')]=dom.getAttrib(n,'_value');});if(pa.movie){pa.src=pa.movie;delete pa.movie;}delete pa.width;delete pa.height;im.title=this._serialize(pa);return im;},_parse:function(s){return tinymce.util.JSON.parse('{'+s+'}');},_serialize:function(o){return tinymce.util.JSON.serialize(o).replace(/[{}]/g,'');}});tinymce.PluginManager.add('media',tinymce.plugins.MediaPlugin);})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/media/img/flash.gif b/wp-includes/js/tinymce/plugins/media/img/flash.gif new file mode 100644 index 00000000..cb192e6c Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/flash.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/img/flv_player.swf b/wp-includes/js/tinymce/plugins/media/img/flv_player.swf new file mode 100644 index 00000000..042c2ab9 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/flv_player.swf differ diff --git a/wp-includes/js/tinymce/plugins/media/img/quicktime.gif b/wp-includes/js/tinymce/plugins/media/img/quicktime.gif new file mode 100644 index 00000000..3b049914 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/quicktime.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/img/realmedia.gif b/wp-includes/js/tinymce/plugins/media/img/realmedia.gif new file mode 100644 index 00000000..fdfe0b9a Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/realmedia.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/img/shockwave.gif b/wp-includes/js/tinymce/plugins/media/img/shockwave.gif new file mode 100644 index 00000000..5f235dfc Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/shockwave.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/spacer.gif b/wp-includes/js/tinymce/plugins/media/img/trans.gif similarity index 100% rename from wp-includes/js/tinymce/themes/advanced/images/spacer.gif rename to wp-includes/js/tinymce/plugins/media/img/trans.gif diff --git a/wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif b/wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif new file mode 100644 index 00000000..ab50f2d8 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif differ diff --git a/wp-includes/js/tinymce/plugins/media/js/embed.js b/wp-includes/js/tinymce/plugins/media/js/embed.js new file mode 100644 index 00000000..6fe25de0 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/js/embed.js @@ -0,0 +1,73 @@ +/** + * This script contains embed functions for common plugins. This scripts are complety free to use for any purpose. + */ + +function writeFlash(p) { + writeEmbed( + 'D27CDB6E-AE6D-11cf-96B8-444553540000', + 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', + 'application/x-shockwave-flash', + p + ); +} + +function writeShockWave(p) { + writeEmbed( + '166B1BCA-3F9C-11CF-8075-444553540000', + 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0', + 'application/x-director', + p + ); +} + +function writeQuickTime(p) { + writeEmbed( + '02BF25D5-8C17-4B23-BC80-D3488ABDDC6B', + 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0', + 'video/quicktime', + p + ); +} + +function writeRealMedia(p) { + writeEmbed( + 'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA', + 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', + 'audio/x-pn-realaudio-plugin', + p + ); +} + +function writeWindowsMedia(p) { + p.url = p.src; + writeEmbed( + '6BF52A52-394A-11D3-B153-00C04F79FAA6', + 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701', + 'application/x-mplayer2', + p + ); +} + +function writeEmbed(cls, cb, mt, p) { + var h = '', n; + + h += ''; + + h += ''); + +function init() { + var pl = "", f, val; + var type = "flash", fe, i; + + ed = tinyMCEPopup.editor; + + tinyMCEPopup.resizeToInnerSize(); + f = document.forms[0] + + fe = ed.selection.getNode(); + if (/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) { + pl = fe.title; + + switch (ed.dom.getAttrib(fe, 'class')) { + case 'mceItemFlash': + type = 'flash'; + break; + + case 'mceItemFlashVideo': + type = 'flv'; + break; + + case 'mceItemShockWave': + type = 'shockwave'; + break; + + case 'mceItemWindowsMedia': + type = 'wmp'; + break; + + case 'mceItemQuickTime': + type = 'qt'; + break; + + case 'mceItemRealMedia': + type = 'rmp'; + break; + } + + document.forms[0].insert.value = ed.getLang('update', 'Insert', true); + } + + document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media'); + document.getElementById('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','qt_qtsrc','media','media'); + document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); + + var html = getMediaListHTML('medialist','src','media','media'); + if (html == "") + document.getElementById("linklistrow").style.display = 'none'; + else + document.getElementById("linklistcontainer").innerHTML = html; + + // Resize some elements + if (isVisible('filebrowser')) + document.getElementById('src').style.width = '230px'; + + // Setup form + if (pl != "") { + pl = tinyMCEPopup.editor.plugins.media._parse(pl); + + switch (type) { + case "flash": + setBool(pl, 'flash', 'play'); + setBool(pl, 'flash', 'loop'); + setBool(pl, 'flash', 'menu'); + setBool(pl, 'flash', 'swliveconnect'); + setStr(pl, 'flash', 'quality'); + setStr(pl, 'flash', 'scale'); + setStr(pl, 'flash', 'salign'); + setStr(pl, 'flash', 'wmode'); + setStr(pl, 'flash', 'base'); + setStr(pl, 'flash', 'flashvars'); + break; + + case "qt": + setBool(pl, 'qt', 'loop'); + setBool(pl, 'qt', 'autoplay'); + setBool(pl, 'qt', 'cache'); + setBool(pl, 'qt', 'controller'); + setBool(pl, 'qt', 'correction'); + setBool(pl, 'qt', 'enablejavascript'); + setBool(pl, 'qt', 'kioskmode'); + setBool(pl, 'qt', 'autohref'); + setBool(pl, 'qt', 'playeveryframe'); + setBool(pl, 'qt', 'tarsetcache'); + setStr(pl, 'qt', 'scale'); + setStr(pl, 'qt', 'starttime'); + setStr(pl, 'qt', 'endtime'); + setStr(pl, 'qt', 'tarset'); + setStr(pl, 'qt', 'qtsrcchokespeed'); + setStr(pl, 'qt', 'volume'); + setStr(pl, 'qt', 'qtsrc'); + break; + + case "shockwave": + setBool(pl, 'shockwave', 'sound'); + setBool(pl, 'shockwave', 'progress'); + setBool(pl, 'shockwave', 'autostart'); + setBool(pl, 'shockwave', 'swliveconnect'); + setStr(pl, 'shockwave', 'swvolume'); + setStr(pl, 'shockwave', 'swstretchstyle'); + setStr(pl, 'shockwave', 'swstretchhalign'); + setStr(pl, 'shockwave', 'swstretchvalign'); + break; + + case "wmp": + setBool(pl, 'wmp', 'autostart'); + setBool(pl, 'wmp', 'enabled'); + setBool(pl, 'wmp', 'enablecontextmenu'); + setBool(pl, 'wmp', 'fullscreen'); + setBool(pl, 'wmp', 'invokeurls'); + setBool(pl, 'wmp', 'mute'); + setBool(pl, 'wmp', 'stretchtofit'); + setBool(pl, 'wmp', 'windowlessvideo'); + setStr(pl, 'wmp', 'balance'); + setStr(pl, 'wmp', 'baseurl'); + setStr(pl, 'wmp', 'captioningid'); + setStr(pl, 'wmp', 'currentmarker'); + setStr(pl, 'wmp', 'currentposition'); + setStr(pl, 'wmp', 'defaultframe'); + setStr(pl, 'wmp', 'playcount'); + setStr(pl, 'wmp', 'rate'); + setStr(pl, 'wmp', 'uimode'); + setStr(pl, 'wmp', 'volume'); + break; + + case "rmp": + setBool(pl, 'rmp', 'autostart'); + setBool(pl, 'rmp', 'loop'); + setBool(pl, 'rmp', 'autogotourl'); + setBool(pl, 'rmp', 'center'); + setBool(pl, 'rmp', 'imagestatus'); + setBool(pl, 'rmp', 'maintainaspect'); + setBool(pl, 'rmp', 'nojava'); + setBool(pl, 'rmp', 'prefetch'); + setBool(pl, 'rmp', 'shuffle'); + setStr(pl, 'rmp', 'console'); + setStr(pl, 'rmp', 'controls'); + setStr(pl, 'rmp', 'numloop'); + setStr(pl, 'rmp', 'scriptcallbacks'); + break; + } + + setStr(pl, null, 'src'); + setStr(pl, null, 'id'); + setStr(pl, null, 'name'); + setStr(pl, null, 'vspace'); + setStr(pl, null, 'hspace'); + setStr(pl, null, 'bgcolor'); + setStr(pl, null, 'align'); + setStr(pl, null, 'width'); + setStr(pl, null, 'height'); + + if ((val = ed.dom.getAttrib(fe, "width")) != "") + pl.width = f.width.value = val; + + if ((val = ed.dom.getAttrib(fe, "height")) != "") + pl.height = f.height.value = val; + + oldWidth = pl.width ? parseInt(pl.width) : 0; + oldHeight = pl.height ? parseInt(pl.height) : 0; + } else + oldWidth = oldHeight = 0; + + selectByValue(f, 'media_type', type); + changedType(type); + updateColor('bgcolor_pick', 'bgcolor'); + + TinyMCE_EditableSelects.init(); + generatePreview(); +} + +function insertMedia() { + var fe, f = document.forms[0], h; + + tinyMCEPopup.restoreSelection(); + + if (!AutoValidator.validate(f)) { + alert(ed.getLang('invalid_data')); + return false; + } + + f.width.value = f.width.value == "" ? 100 : f.width.value; + f.height.value = f.height.value == "" ? 100 : f.height.value; + + fe = ed.selection.getNode(); + if (fe != null && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) { + switch (f.media_type.options[f.media_type.selectedIndex].value) { + case "flash": + fe.className = "mceItemFlash"; + break; + + case "flv": + fe.className = "mceItemFlashVideo"; + break; + + case "shockwave": + fe.className = "mceItemShockWave"; + break; + + case "qt": + fe.className = "mceItemQuickTime"; + break; + + case "wmp": + fe.className = "mceItemWindowsMedia"; + break; + + case "rmp": + fe.className = "mceItemRealMedia"; + break; + } + + if (fe.width != f.width.value || fe.height != f.height.height) + ed.execCommand('mceRepaint'); + + fe.title = serializeParameters(); + fe.width = f.width.value; + fe.height = f.height.value; + fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : ''); + fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : ''); + fe.align = f.align.options[f.align.selectedIndex].value; + } else { + h = ' 0) { + var html = ""; + + html += ''; + + return html; + } + + return ""; +} + +function getType(v) { + var fo, i, c, el, x, f = document.forms[0]; + + fo = ed.getParam("media_types", "flash=swf;flv=flv;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';'); + + // YouTube + if (v.match(/watch\?v=(.+)(.*)/)) { + f.width.value = '425'; + f.height.value = '350'; + f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1]; + return 'flash'; + } + + // Google video + if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { + f.width.value = '425'; + f.height.value = '326'; + f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en'; + return 'flash'; + } + + for (i=0; i 0 ? s.substring(0, s.length - 1) : s; + + return s; +} + +function setBool(pl, p, n) { + if (typeof(pl[n]) == "undefined") + return; + + document.forms[0].elements[p + "_" + n].checked = pl[n]; +} + +function setStr(pl, p, n) { + var f = document.forms[0], e = f.elements[(p != null ? p + "_" : '') + n]; + + if (typeof(pl[n]) == "undefined") + return; + + if (e.type == "text") + e.value = pl[n]; + else + selectByValue(f, (p != null ? p + "_" : '') + n, pl[n]); +} + +function getBool(p, n, d, tv, fv) { + var v = document.forms[0].elements[p + "_" + n].checked; + + tv = typeof(tv) == 'undefined' ? 'true' : "'" + jsEncode(tv) + "'"; + fv = typeof(fv) == 'undefined' ? 'false' : "'" + jsEncode(fv) + "'"; + + return (v == d) ? '' : n + (v ? ':' + tv + ',' : ':' + fv + ','); +} + +function getStr(p, n, d) { + var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; + var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; + + if (n == 'src') + v = tinyMCEPopup.editor.convertURL(v, 'src', null); + + return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',"); +} + +function getInt(p, n, d) { + var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; + var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; + + return ((n == d || v == '') ? '' : n + ":" + v.replace(/[^0-9]+/g, '') + ","); +} + +function jsEncode(s) { + s = s.replace(new RegExp('\\\\', 'g'), '\\\\'); + s = s.replace(new RegExp('"', 'g'), '\\"'); + s = s.replace(new RegExp("'", 'g'), "\\'"); + + return s; +} + +function generatePreview(c) { + var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh; + + p.innerHTML = ''; + + nw = parseInt(f.width.value); + nh = parseInt(f.height.value); + + if (f.width.value != "" && f.height.value != "") { + if (f.constrain.checked) { + if (c == 'width' && oldWidth != 0) { + wp = nw / oldWidth; + nh = Math.round(wp * nh); + f.height.value = nh; + } else if (c == 'height' && oldHeight != 0) { + hp = nh / oldHeight; + nw = Math.round(hp * nw); + f.width.value = nw; + } + } + } + + if (f.width.value != "") + oldWidth = nw; + + if (f.height.value != "") + oldHeight = nh; + + // After constrain + pl = serializeParameters(); + + switch (f.media_type.options[f.media_type.selectedIndex].value) { + case "flash": + cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; + codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; + type = 'application/x-shockwave-flash'; + break; + + case "shockwave": + cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000'; + codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0'; + type = 'application/x-director'; + break; + + case "qt": + cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'; + codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'; + type = 'video/quicktime'; + break; + + case "wmp": + cls = ed.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'; + codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; + type = 'application/x-mplayer2'; + break; + + case "rmp": + cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'; + codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; + type = 'audio/x-pn-realaudio-plugin'; + break; + } + + if (pl == '') { + p.innerHTML = ''; + return; + } + + pl = tinyMCEPopup.editor.plugins.media._parse(pl); + + if (!pl.src) { + p.innerHTML = ''; + return; + } + + pl.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(pl.src); + pl.width = !pl.width ? 100 : pl.width; + pl.height = !pl.height ? 100 : pl.height; + pl.id = !pl.id ? 'obj' : pl.id; + pl.name = !pl.name ? 'eobj' : pl.name; + pl.align = !pl.align ? '' : pl.align; + + h += ''; + + for (n in pl) { + h += ''; + + // Add extra url parameter if it's an absolute URL + if (n == 'src' && pl[n].indexOf('://') != -1) + h += ''; + } + + h += ' + + + {#media_dlg.title} + + + + + + + + + + +
    + + +
    +
    +
    + {#media_dlg.general} + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + +
     
    +
     
    + + + + + + +
    x   
    +
    +
    + +
    + {#media_dlg.preview} + +
    +
    + +
    +
    + {#media_dlg.advanced} + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + +
     
    +
    +
    + +
    + {#media_dlg.flash_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + + + + + + + +
    +
    + +
    + {#media_dlg.flv_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +
    + +
    + {#media_dlg.qt_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +  
    + + + + + +
     
    +
    +
    + +
    + {#media_dlg.wmp_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +
    + +
    + {#media_dlg.rmp_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +   +
    +
    + +
    + {#media_dlg.shockwave_options} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +
    +
    +
    + +
    +
    + +
    + +
    + +
    +
    +
    + + diff --git a/wp-includes/js/tinymce/plugins/paste/blank.htm b/wp-includes/js/tinymce/plugins/paste/blank.htm index 1ddf8291..59c8c651 100644 --- a/wp-includes/js/tinymce/plugins/paste/blank.htm +++ b/wp-includes/js/tinymce/plugins/paste/blank.htm @@ -1,19 +1,22 @@ - - - blank_page - - - - - - - - - + + +blank_page + + + + + + + + + diff --git a/wp-includes/js/tinymce/plugins/paste/css/blank.css b/wp-includes/js/tinymce/plugins/paste/css/blank.css index eca411a4..f1ab1133 100644 --- a/wp-includes/js/tinymce/plugins/paste/css/blank.css +++ b/wp-includes/js/tinymce/plugins/paste/css/blank.css @@ -1,13 +1,14 @@ -body { - background-color: #FFFFFF; - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; - scrollbar-3dlight-color: #F0F0EE; - scrollbar-arrow-color: #676662; - scrollbar-base-color: #F0F0EE; - scrollbar-darkshadow-color: #DDDDDD; - scrollbar-face-color: #E0E0DD; - scrollbar-highlight-color: #F0F0EE; - scrollbar-shadow-color: #F0F0EE; - scrollbar-track-color: #F5F5F5; -} +html, body {height:98%} +body { +background-color: #FFFFFF; +font-family: Verdana, Arial, Helvetica, sans-serif; +font-size: 10px; +scrollbar-3dlight-color: #F0F0EE; +scrollbar-arrow-color: #676662; +scrollbar-base-color: #F0F0EE; +scrollbar-darkshadow-color: #DDDDDD; +scrollbar-face-color: #E0E0DD; +scrollbar-highlight-color: #F0F0EE; +scrollbar-shadow-color: #F0F0EE; +scrollbar-track-color: #F5F5F5; +} diff --git a/wp-includes/js/tinymce/plugins/paste/css/pasteword.css b/wp-includes/js/tinymce/plugins/paste/css/pasteword.css index b3be6270..77685fd2 100644 --- a/wp-includes/js/tinymce/plugins/paste/css/pasteword.css +++ b/wp-includes/js/tinymce/plugins/paste/css/pasteword.css @@ -1,3 +1,3 @@ -.sourceIframe { - border: 1px solid #808080; -} +.sourceIframe { + border: 1px solid #808080; +} diff --git a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js index 5e884cff..b317ed2c 100644 --- a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js @@ -1,395 +1 @@ -/** - * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ - * - * @author Moxiecode - * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. - */ - -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('paste'); - -var TinyMCE_PastePlugin = { - getInfo : function() { - return { - longname : 'Paste text/word', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; - }, - - initInstance : function(inst) { - if (tinyMCE.isMSIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false)) - tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent); - }, - - handleEvent : function(e) { - // Force paste dialog if non IE browser - if (!tinyMCE.isRealIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false) && e.ctrlKey && e.keyCode == 86 && e.type == "keydown") { - window.setTimeout('tinyMCE.selectedInstance.execCommand("mcePasteText",true)', 1); - return tinyMCE.cancelEvent(e); - } - - return true; - }, - - getControlHTML : function(cn) { - switch (cn) { - case "pastetext": - return tinyMCE.getButtonHTML(cn, 'lang_paste_text_desc', '{$pluginurl}/images/pastetext.gif', 'mcePasteText', true); - - case "pasteword": - return tinyMCE.getButtonHTML(cn, 'lang_paste_word_desc', '{$pluginurl}/images/pasteword.gif', 'mcePasteWord', true); - - case "selectall": - return tinyMCE.getButtonHTML(cn, 'lang_selectall_desc', '{$pluginurl}/images/selectall.gif', 'mceSelectAll', true); - } - - return ''; - }, - - execCommand : function(editor_id, element, command, user_interface, value) { - switch (command) { - case "mcePasteText": - if (user_interface) { - if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) - TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"), true); - else { - var template = new Array(); - template['file'] = '../../plugins/paste/pastetext.htm'; // Relative to theme - template['width'] = 450; - template['height'] = 400; - var plain_text = ""; - tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'}); - } - } else - TinyMCE_PastePlugin._insertText(value['html'], value['linebreaks']); - - return true; - - case "mcePasteWord": - if (user_interface) { - if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) { - TinyMCE_PastePlugin._insertWordContent(TinyMCE_PastePlugin._clipboardHTML()); - } else { - var template = new Array(); - template['file'] = '../../plugins/paste/pasteword.htm'; // Relative to theme - template['width'] = 450; - template['height'] = 400; - var plain_text = ""; - tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'}); - } - } else - TinyMCE_PastePlugin._insertWordContent(value); - - return true; - - case "mceSelectAll": - tinyMCE.execInstanceCommand(editor_id, 'selectall'); - return true; - - } - - // Pass to next handler in chain - return false; - }, - - // Private plugin internal methods - - _handlePasteEvent : function(e) { - switch (e.type) { - case "paste": - var html = TinyMCE_PastePlugin._clipboardHTML(); - var r, inst = tinyMCE.selectedInstance; - - // Removes italic, strong etc, the if was needed due to bug #1437114 - if (inst && (r = inst.getRng()) && r.text.length > 0) - tinyMCE.execCommand('delete'); - - if (html && html.length > 0) - tinyMCE.execCommand('mcePasteWord', false, html); - - tinyMCE.cancelEvent(e); - return false; - } - - return true; - }, - - _insertText : function(content, bLinebreaks) { - if (content && content.length > 0) { - if (bLinebreaks) { - // Special paragraph treatment - if (tinyMCE.getParam("paste_create_paragraphs", true)) { - var rl = tinyMCE.getParam("paste_replace_list", '\u2122,TM,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(','); - for (var i=0; i

    ", "gi"); - content = tinyMCE.regexpReplace(content, "\r\r", "

    ", "gi"); - content = tinyMCE.regexpReplace(content, "\n\n", "

    ", "gi"); - - // Has paragraphs - if ((pos = content.indexOf('

    ')) != -1) { - tinyMCE.execCommand("Delete"); - - var node = tinyMCE.selectedInstance.getFocusElement(); - - // Get list of elements to break - var breakElms = new Array(); - - do { - if (node.nodeType == 1) { - // Don't break tables and break at body - if (node.nodeName == "TD" || node.nodeName == "BODY") - break; - - breakElms[breakElms.length] = node; - } - } while(node = node.parentNode); - - var before = "", after = "

    "; - before += content.substring(0, pos); - - for (var i=0; i"; - after += "<" + breakElms[(breakElms.length-1)-i].nodeName + ">"; - } - - before += "

    "; - content = before + content.substring(pos+7) + after; - } - } - - if (tinyMCE.getParam("paste_create_linebreaks", true)) { - content = tinyMCE.regexpReplace(content, "\r\n", "
    ", "gi"); - content = tinyMCE.regexpReplace(content, "\r", "
    ", "gi"); - content = tinyMCE.regexpReplace(content, "\n", "
    ", "gi"); - } - } - - tinyMCE.execCommand("mceInsertRawHTML", false, content); - } - }, - - _insertWordContent : function(content) { - if (content && content.length > 0) { - // Cleanup Word content - var bull = String.fromCharCode(8226); - var middot = String.fromCharCode(183); - var cb; - - if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "") - content = eval(cb + "('before', content)"); - - var rl = tinyMCE.getParam("paste_replace_list", '\u2122,TM,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(','); - for (var i=0; i(.*?)<\/p>', 'gi'), '

    $1

    '); - } - - content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--"); - content = content.replace(new RegExp(bull + "(.*?)
    ", "gi"), "

    " + middot + "$1

    "); - content = content.replace(new RegExp('', 'gi'), "" + bull); // Covert to bull list - content = content.replace(/<\/o:p>/gi, ""); - content = content.replace(new RegExp('
    ]*>/gi, ""); - - if (tinyMCE.getParam("paste_remove_styles", true)) - content = content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)', 'gi'), "<$1$3"); - - content = content.replace(/<\/?font[^>]*>/gi, ""); - - // Strips class attributes. - switch (tinyMCE.getParam("paste_strip_class_attributes", "all")) { - case "all": - content = content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3"); - break; - - case "mso": - content = content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)', 'gi'), "<$1$3"); - break; - } - - content = content.replace(new RegExp('href="?' + TinyMCE_PastePlugin._reEscape("" + document.location) + '', 'gi'), 'href="' + tinyMCE.settings['document_base_url']); - content = content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3"); - content = content.replace(/<\\?\?xml[^>]*>/gi, ""); - content = content.replace(/<\/?\w+:[^>]*>/gi, ""); - content = content.replace(/-- page break --\s*

     <\/p>/gi, ""); // Remove pagebreaks - content = content.replace(/-- page break --/gi, ""); // Remove pagebreaks - - // content = content.replace(/\/? */gi, "");   - // content = content.replace(/

     <\/p>/gi, ''); - - if (!tinyMCE.settings['force_p_newlines']) { - content = content.replace('', '' ,'gi'); - content = content.replace('

    ', '

    ' ,'gi'); - } - - if (!tinyMCE.isMSIE && !tinyMCE.settings['force_p_newlines']) { - content = content.replace(/<\/?p[^>]*>/gi, ""); - } - - content = content.replace(/<\/?div[^>]*>/gi, ""); - - // Convert all middlot lists to UL lists - if (tinyMCE.getParam("paste_convert_middot_lists", true)) { - var div = document.createElement("div"); - div.innerHTML = content; - - // Convert all middot paragraphs to li elements - var className = tinyMCE.getParam("paste_unindented_list_class", "unIndentedList"); - - while (TinyMCE_PastePlugin._convertMiddots(div, "--list--")) ; // bull - while (TinyMCE_PastePlugin._convertMiddots(div, middot, className)) ; // Middot - while (TinyMCE_PastePlugin._convertMiddots(div, bull)) ; // bull - - content = div.innerHTML; - } - - // Replace all headers with strong and fix some other issues - if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) { - content = content.replace(/ <\/h[1-6]>/gi, '

      

    '); - content = content.replace(//gi, '

    '); - content = content.replace(/<\/h[1-6]>/gi, '

    '); - content = content.replace(/ <\/b>/gi, '  '); - content = content.replace(/^( )*/gi, ''); - } - - content = content.replace(/--list--/gi, ""); // Remove --list-- - - if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "") - content = eval(cb + "('after', content)"); - - // Insert cleaned content - tinyMCE.execCommand("mceInsertContent", false, content); - - if (tinyMCE.getParam('paste_force_cleanup_wordpaste', true)) - window.setTimeout('tinyMCE.execCommand("mceCleanup");', 1); // Do normal cleanup detached from this thread - } - }, - - _reEscape : function(s) { - var l = "?.\\*[](){}+^$:"; - var o = ""; - - for (var i=0; i0)ed.execCommand('delete');if(html&&html.length>0)ed.execCommand('mcePasteWord',false,html);return Event.cancel(e);},_insertText:function(content,bLinebreaks){if(content&&content.length>0){if(bLinebreaks){if(this.editor.getParam("paste_create_paragraphs",true)){var rl=this.editor.getParam("paste_replace_list",'\u2122,TM,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i

    ');content=content.replace(/\r\r/g,'

    ');content=content.replace(/\n\n/g,'

    ');if((pos=content.indexOf('

    '))!=-1){this.editor.execCommand("Delete");var node=this.editor.selection.getNode();var breakElms=[];do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="

    ";before+=content.substring(0,pos);for(var i=0;i";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="

    ";content=before+content.substring(pos+7)+after;}}if(this.editor.getParam("paste_create_linebreaks",true)){content=content.replace(/\r\n/g,'
    ');content=content.replace(/\r/g,'
    ');content=content.replace(/\n/g,'
    ');}}this.editor.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){var t=this,ed=t.editor;if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','before',content);var rl=ed.getParam("paste_replace_list",'\u2122,TM,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i(.*?)<\/p>','gi'),'

    $1

    ');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)
    ","gi"),"

    "+middot+"$1

    ");content=content.replace(new RegExp('','gi'),""+bull);content=content.replace(/<\/o:p>/gi,"");content=content.replace(new RegExp('
    ]*>/gi,"");if(this.editor.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(this.editor.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+this._reEscape(""+document.location)+'','gi'),'href="'+this.editor.documentBaseURI.getURI());content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*

     <\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!this.editor.getParam('force_p_newlines')){content=content.replace('','','gi');content=content.replace('

    ','

    ','gi');}if(!tinymce.isIE&&!this.editor.getParam('force_p_newlines')){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(this.editor.getParam("paste_convert_middot_lists",true)){var div=ed.dom.create("div",null,content);var className=this.editor.getParam("paste_unindented_list_class","unIndentedList");while(this._convertMiddots(div,"--list--"));while(this._convertMiddots(div,middot,className));while(this._convertMiddots(div,bull));content=div.innerHTML;}if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/ <\/h[1-6]>/gi,'

      

    ');content=content.replace(//gi,'

    ');content=content.replace(/<\/h[1-6]>/gi,'

    ');content=content.replace(/ <\/b>/gi,'  ');content=content.replace(/^( )*/gi,'');}content=content.replace(/--list--/gi,"");if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','after',content);this.editor.execCommand("mceInsertContent",false,content);if(this.editor.getParam('paste_force_cleanup_wordpaste',true)){var ed=this.editor;window.setTimeout(function(){ed.execCommand("mceCleanup");},1);}}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i - - {$lang_paste_text_desc} - - - - - - -
    -
    {$lang_paste_text_desc}
    - -
    - -
    - -
    - -
    {$lang_paste_text_title}
    - - - -
    -
    - -
    - -
    - -
    -
    -
    - + + + {#paste.paste_text_desc} + + + + + + +
    +
    {#paste.paste_text_desc}
    + +
    + +
    + +
    + +
    {#paste_dlg.text_title}
    + + + +
    +
    + +
    + +
    + +
    +
    +
    + \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/paste/pasteword.htm b/wp-includes/js/tinymce/plugins/paste/pasteword.htm index 7acc7f78..d3c53e54 100644 --- a/wp-includes/js/tinymce/plugins/paste/pasteword.htm +++ b/wp-includes/js/tinymce/plugins/paste/pasteword.htm @@ -1,29 +1,29 @@ - - - - {$lang_paste_word_desc} - - - - - - -
    -
    {$lang_paste_word_desc}
    - -
    {$lang_paste_word_title}
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - - + + + + {#paste.paste_word_desc} + + + + + + +
    +
    {#paste.paste_word_desc}
    + +
    {#paste_dlg.word_title}
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + + diff --git a/wp-includes/js/tinymce/plugins/safari/blank.htm b/wp-includes/js/tinymce/plugins/safari/blank.htm new file mode 100644 index 00000000..266808ce --- /dev/null +++ b/wp-includes/js/tinymce/plugins/safari/blank.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/safari/editor_plugin.js b/wp-includes/js/tinymce/plugins/safari/editor_plugin.js new file mode 100644 index 00000000..f722c2f1 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/safari/editor_plugin.js @@ -0,0 +1 @@ +(function(){var Event=tinymce.dom.Event,grep=tinymce.grep,each=tinymce.each,inArray=tinymce.inArray,isOldWebKit=tinymce.isOldWebKit;tinymce.create('tinymce.plugins.Safari',{init:function(ed){var t=this,dom;if(!tinymce.isWebKit)return;t.editor=ed;t.webKitFontSizes=['x-small','small','medium','large','x-large','xx-large','-webkit-xxx-large'];t.namedFontSizes=['xx-small','x-small','small','medium','large','x-large','xx-large'];ed.onPaste.add(function(ed,e){function removeStyles(e){e=e.target;if(e.nodeType==1){e.style.cssText='';each(ed.dom.select('*',e),function(e){e.style.cssText='';});}};Event.add(ed.getDoc(),'DOMNodeInserted',removeStyles);window.setTimeout(function(){Event.remove(ed.getDoc(),'DOMNodeInserted',removeStyles);},0);});ed.onKeyUp.add(function(ed,e){var h,b;if(e.keyCode==46||e.keyCode==8){b=ed.getBody();h=b.innerHTML;if(b.childNodes.length==1&&!/<(img|hr)/.test(h)&&tinymce.trim(h.replace(/<[^>]+>/g,'')).length==0)ed.setContent('',{format:'raw'});}});ed.addCommand('FormatBlock',function(u,v){var dom=ed.dom,e=dom.getParent(ed.selection.getNode(),dom.isBlock);if(e)dom.replace(dom.create(v),e,1);else ed.getDoc().execCommand("FormatBlock",false,v);});ed.addCommand('mceInsertContent',function(u,v){ed.getDoc().execCommand("InsertText",false,'mce_marker');ed.getBody().innerHTML=ed.getBody().innerHTML.replace(/mce_marker/g,v+'XX');ed.selection.select(ed.dom.get('_mce_tmp'));ed.getDoc().execCommand("Delete",false,' ');});ed.onKeyPress.add(function(ed,e){if(e.keyCode==13&&(e.shiftKey||ed.settings.force_br_newlines&&ed.selection.getNode().nodeName!='LI')){t._insertBR(ed);Event.cancel(e);}});ed.addQueryValueHandler('FontSize',function(u,v){var e,v;if((e=ed.dom.getParent(ed.selection.getStart(),'span'))&&(v=e.style.fontSize))return tinymce.inArray(t.namedFontSizes,v)+1;if((e=ed.dom.getParent(ed.selection.getEnd(),'span'))&&(v=e.style.fontSize))return tinymce.inArray(t.namedFontSizes,v)+1;return ed.getDoc().queryCommandValue('FontSize');});ed.addQueryValueHandler('FontName',function(u,v){var e,v;if((e=ed.dom.getParent(ed.selection.getStart(),'span'))&&(v=e.style.fontFamily))return v.replace(/, /g,',');if((e=ed.dom.getParent(ed.selection.getEnd(),'span'))&&(v=e.style.fontFamily))return v.replace(/, /g,',');return ed.getDoc().queryCommandValue('FontName');});ed.onClick.add(function(ed,e){e=e.target;if(e.nodeName=='IMG'){t.selElm=e;ed.selection.select(e);}else t.selElm=null;});ed.onInit.add(function(){t._fixWebKitSpans();if(isOldWebKit)t._patchSafari2x(ed);});ed.onSetContent.add(function(){dom=ed.dom;each(['strong','b','em','u','strike','sub','sup','a'],function(v){each(grep(dom.select(v)).reverse(),function(n){var nn=n.nodeName.toLowerCase(),st;if(nn=='a'){if(n.name)dom.replace(dom.create('img',{mce_name:'a',name:n.name,'class':'mceItemAnchor'}),n);return;}switch(nn){case'b':case'strong':if(nn=='b')nn='strong';st='font-weight: bold;';break;case'em':st='font-style: italic;';break;case'u':st='text-decoration: underline;';break;case'sub':st='vertical-align: sub;';break;case'sup':st='vertical-align: super;';break;case'strike':st='text-decoration: line-through;';break;}dom.replace(dom.create('span',{mce_name:nn,style:st,'class':'Apple-style-span'}),n,1);});});});ed.onPreProcess.add(function(ed,o){dom=ed.dom;each(grep(o.node.getElementsByTagName('span')).reverse(),function(n){var v,bg;if(o.get){if(dom.hasClass(n,'Apple-style-span')){bg=n.style.backgroundColor;switch(dom.getAttrib(n,'mce_name')){case'font':if(!ed.settings.convert_fonts_to_spans)dom.setAttrib(n,'style','');break;case'strong':case'em':case'sub':case'sup':dom.setAttrib(n,'style','');break;case'strike':case'u':if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');else dom.setAttrib(n,'mce_name','');break;default:if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');}if(bg)n.style.backgroundColor=bg;}}if(dom.hasClass(n,'mceItemRemoved'))dom.remove(n,1);});});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/
    <\/(h[1-6]|div|p|address|pre)>/g,'');o.content=o.content.replace(/ id=\"undefined\"/g,'');});},getInfo:function(){return{longname:'Safari compatibility',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_fixWebKitSpans:function(){var t=this,ed=t.editor;if(!isOldWebKit){Event.add(ed.getDoc(),'DOMNodeInserted',function(e){e=e.target;if(e&&e.nodeType==1)t._fixAppleSpan(e);});}else{ed.onExecCommand.add(function(){each(ed.dom.select('span'),function(n){t._fixAppleSpan(n);});ed.nodeChanged();});}},_fixAppleSpan:function(e){var ed=this.editor,dom=ed.dom,fz=this.webKitFontSizes,fzn=this.namedFontSizes,s=ed.settings,st,p;if(dom.getAttrib(e,'mce_fixed'))return;if(e.nodeName=='SPAN'&&e.className=='Apple-style-span'){st=e.style;if(!s.convert_fonts_to_spans){if(st.fontSize){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'size',inArray(fz,st.fontSize)+1);}if(st.fontFamily){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'face',st.fontFamily);}if(st.color){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'color',dom.toHex(st.color));}if(st.backgroundColor){dom.setAttrib(e,'mce_name','font');dom.setStyle(e,'background-color',st.backgroundColor);}}else{if(st.fontSize)dom.setStyle(e,'fontSize',fzn[inArray(fz,st.fontSize)]);}if(st.fontWeight=='bold')dom.setAttrib(e,'mce_name','strong');if(st.fontStyle=='italic')dom.setAttrib(e,'mce_name','em');if(st.textDecoration=='underline')dom.setAttrib(e,'mce_name','u');if(st.textDecoration=='line-through')dom.setAttrib(e,'mce_name','strike');if(st.verticalAlign=='super')dom.setAttrib(e,'mce_name','sup');if(st.verticalAlign=='sub')dom.setAttrib(e,'mce_name','sub');dom.setAttrib(e,'mce_fixed','1');}},_patchSafari2x:function(ed){var t=this,setContent,getNode,dom=ed.dom,lr;if(ed.windowManager.onBeforeOpen){ed.windowManager.onBeforeOpen.add(function(){r=ed.selection.getRng();});}ed.selection.select=function(n){this.getSel().setBaseAndExtent(n,0,n,1);};getNode=ed.selection.getNode;ed.selection.getNode=function(){return t.selElm||getNode.call(this);};ed.selection.getRng=function(){var t=this,s=t.getSel(),d=ed.getDoc(),r,rb,ra,di;if(s.anchorNode){r=d.createRange();try{rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(1);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(1);di=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;r.setStart(di?s.anchorNode:s.focusNode,di?s.anchorOffset:s.focusOffset);r.setEnd(di?s.focusNode:s.anchorNode,di?s.focusOffset:s.anchorOffset);lr=r;}catch(ex){}}return r||lr;};setContent=ed.selection.setContent;ed.selection.setContent=function(h,s){var r=this.getRng(),b;try{setContent.call(this,h,s);}catch(ex){b=dom.create('body');b.innerHTML=h;each(b.childNodes,function(n){r.insertNode(n.cloneNode(true));});}};},_insertBR:function(ed){var dom=ed.dom,s=ed.selection,r=s.getRng(),br;r.insertNode(br=dom.create('br'));r.setStartAfter(br);r.setEndAfter(br);s.setRng(r);if(s.getSel().focusNode==br.previousSibling){s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'),br));s.collapse(1);}ed.getWin().scrollTo(0,dom.getPos(s.getRng().startContainer).y);}});tinymce.PluginManager.add('safari',tinymce.plugins.Safari);})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php new file mode 100644 index 00000000..00c9f9f4 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php @@ -0,0 +1,158 @@ +_getMatches($lang, $wordstr); + $words = array(); + + for ($i=0; $i_unhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8")); + + return $words; + } + + /** + * Returns suggestions of for a specific word. + * + * @param {String} $lang Language code like sv or en. + * @param {String} $word Specific word to get suggestions for. + * @return {Array} Array of suggestions for the specified word. + */ + function &getSuggestions($lang, $word) { + $sug = array(); + $osug = array(); + $matches = $this->_getMatches($lang, $word); + + if (count($matches) > 0) + $sug = explode("\t", utf8_encode($this->_unhtmlentities($matches[0][4]))); + + // Remove empty + foreach ($sug as $item) { + if ($item) + $osug[] = $item; + } + + return $osug; + } + + function &_getMatches($lang, $str) { + $server = "www.google.com"; + $port = 443; + $path = "/tbproxy/spell?lang=" . $lang . "&hl=en"; + $host = "www.google.com"; + $url = "https://" . $server; + + // Setup XML request + $xml = '' . $str . ''; + + $header = "POST ".$path." HTTP/1.0 \r\n"; + $header .= "MIME-Version: 1.0 \r\n"; + $header .= "Content-type: application/PTI26 \r\n"; + $header .= "Content-length: ".strlen($xml)." \r\n"; + $header .= "Content-transfer-encoding: text \r\n"; + $header .= "Request-number: 1 \r\n"; + $header .= "Document-type: Request \r\n"; + $header .= "Interface-Version: Test 1.4 \r\n"; + $header .= "Connection: close \r\n\r\n"; + $header .= $xml; + + // Use curl if it exists + if (function_exists('curl_init')) { + // Use curl + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + $xml = curl_exec($ch); + curl_close($ch); + } else { + // Use raw sockets + $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30); + if ($fp) { + // Send request + fwrite($fp, $header); + + // Read response + $xml = ""; + while (!feof($fp)) + $xml .= fgets($fp, 128); + + fclose($fp); + } else + echo "Could not open SSL connection to google."; + } + + // Grab and parse content + $matches = array(); + preg_match_all('/([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); + + return $matches; + } + + function _unhtmlentities($string) { + $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); + $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); + + $trans_tbl = get_html_translation_table(HTML_ENTITIES); + $trans_tbl = array_flip($trans_tbl); + + return strtr($string, $trans_tbl); + } +} + +// Patch in multibyte support +if (!function_exists('mb_substr')) { + function mb_substr($str, $start, $len = '', $encoding="UTF-8"){ + $limit = strlen($str); + + for ($s = 0; $start > 0;--$start) {// found the real start + if ($s >= $limit) + break; + + if ($str[$s] <= "\x7F") + ++$s; + else { + ++$s; // skip length + + while ($str[$s] >= "\x80" && $str[$s] <= "\xBF") + ++$s; + } + } + + if ($len == '') + return substr($str, $s); + else + for ($e = $s; $len > 0; --$len) {//found the real end + if ($e >= $limit) + break; + + if ($str[$e] <= "\x7F") + ++$e; + else { + ++$e;//skip length + + while ($str[$e] >= "\x80" && $str[$e] <= "\xBF" && $e < $limit) + ++$e; + } + } + + return substr($str, $s, $e - $s); + } +} + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php deleted file mode 100755 index cae27f09..00000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php +++ /dev/null @@ -1,339 +0,0 @@ -cookies array ready for the next request - // Note: This currently ignores the cookie path (and time) completely. Time is not important, - // but path could possibly lead to security problems. - var $persist_referers = true; // For each request, sends path of last request as referer - var $debug = false; - var $handle_redirects = true; // Auaomtically redirect if Location or URI header is found - var $max_redirects = 5; - var $headers_only = false; // If true, stops receiving once headers have been read. - // Basic authorization variables - var $username; - var $password; - // Response vars - var $status; - var $headers = array(); - var $content = ''; - var $errormsg; - // Tracker variables - var $redirect_count = 0; - var $cookie_host = ''; - function HttpClient($host, $port=80) { - $this->host = $host; - $this->port = $port; - } - function get($path, $data = false) { - $this->path = $path; - $this->method = 'GET'; - if ($data) { - $this->path .= '?'.$this->buildQueryString($data); - } - return $this->doRequest(); - } - function post($path, $data) { - $this->path = $path; - $this->method = 'POST'; - $this->postdata = $this->buildQueryString($data); - return $this->doRequest(); - } - function buildQueryString($data) { - $querystring = ''; - if (is_array($data)) { - // Change data in to postable data - foreach ($data as $key => $val) { - if (is_array($val)) { - foreach ($val as $val2) { - $querystring .= urlencode($key).'='.urlencode($val2).'&'; - } - } else { - $querystring .= urlencode($key).'='.urlencode($val).'&'; - } - } - $querystring = substr($querystring, 0, -1); // Eliminate unnecessary & - } else { - $querystring = $data; - } - return $querystring; - } - function doRequest() { - // Performs the actual HTTP request, returning true or false depending on outcome - if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) { - // Set error message - switch($errno) { - case -3: - $this->errormsg = 'Socket creation failed (-3)'; - case -4: - $this->errormsg = 'DNS lookup failure (-4)'; - case -5: - $this->errormsg = 'Connection refused or timed out (-5)'; - default: - $this->errormsg = 'Connection failed ('.$errno.')'; - $this->errormsg .= ' '.$errstr; - $this->debug($this->errormsg); - } - return false; - } - socket_set_timeout($fp, $this->timeout); - $request = $this->buildRequest(); - $this->debug('Request', $request); - fwrite($fp, $request); - // Reset all the variables that should not persist between requests - $this->headers = array(); - $this->content = ''; - $this->errormsg = ''; - // Set a couple of flags - $inHeaders = true; - $atStart = true; - // Now start reading back the response - while (!feof($fp)) { - $line = fgets($fp, 4096); - if ($atStart) { - // Deal with first line of returned data - $atStart = false; - if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { - $this->errormsg = "Status code line invalid: ".htmlentities($line); - $this->debug($this->errormsg); - return false; - } - $http_version = $m[1]; // not used - $this->status = $m[2]; - $status_string = $m[3]; // not used - $this->debug(trim($line)); - continue; - } - if ($inHeaders) { - if (trim($line) == '') { - $inHeaders = false; - $this->debug('Received Headers', $this->headers); - if ($this->headers_only) { - break; // Skip the rest of the input - } - continue; - } - if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) { - // Skip to the next header - continue; - } - $key = strtolower(trim($m[1])); - $val = trim($m[2]); - // Deal with the possibility of multiple headers of same name - if (isset($this->headers[$key])) { - if (is_array($this->headers[$key])) { - $this->headers[$key][] = $val; - } else { - $this->headers[$key] = array($this->headers[$key], $val); - } - } else { - $this->headers[$key] = $val; - } - continue; - } - // We're not in the headers, so append the line to the contents - $this->content .= $line; - } - fclose($fp); - // If data is compressed, uncompress it - if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') { - $this->debug('Content is gzip encoded, unzipping it'); - $this->content = substr($this->content, 10); // See http://www.php.net/manual/en/function.gzencode.php - $this->content = gzinflate($this->content); - } - // If $persist_cookies, deal with any cookies - if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) { - $cookies = $this->headers['set-cookie']; - if (!is_array($cookies)) { - $cookies = array($cookies); - } - foreach ($cookies as $cookie) { - if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) { - $this->cookies[$m[1]] = $m[2]; - } - } - // Record domain of cookies for security reasons - $this->cookie_host = $this->host; - } - // If $persist_referers, set the referer ready for the next request - if ($this->persist_referers) { - $this->debug('Persisting referer: '.$this->getRequestURL()); - $this->referer = $this->getRequestURL(); - } - // Finally, if handle_redirects and a redirect is sent, do that - if ($this->handle_redirects) { - if (++$this->redirect_count >= $this->max_redirects) { - $this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')'; - $this->debug($this->errormsg); - $this->redirect_count = 0; - return false; - } - $location = isset($this->headers['location']) ? $this->headers['location'] : ''; - $uri = isset($this->headers['uri']) ? $this->headers['uri'] : ''; - if ($location || $uri) { - $url = parse_url($location.$uri); - // This will FAIL if redirect is to a different site - return $this->get($url['path']); - } - } - return true; - } - function buildRequest() { - $headers = array(); - $headers[] = "{$this->method} {$this->path} HTTP/1.0"; // Using 1.1 leads to all manner of problems, such as "chunked" encoding - $headers[] = "Host: {$this->host}"; - $headers[] = "User-Agent: {$this->user_agent}"; - $headers[] = "Accept: {$this->accept}"; - if ($this->use_gzip) { - $headers[] = "Accept-encoding: {$this->accept_encoding}"; - } - $headers[] = "Accept-language: {$this->accept_language}"; - if ($this->referer) { - $headers[] = "Referer: {$this->referer}"; - } - // Cookies - if ($this->cookies) { - $cookie = 'Cookie: '; - foreach ($this->cookies as $key => $value) { - $cookie .= "$key=$value; "; - } - $headers[] = $cookie; - } - // Basic authentication - if ($this->username && $this->password) { - $headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password); - } - // If this is a POST, set the content type and length - if ($this->postdata) { - $headers[] = 'Content-Type: application/x-www-form-urlencoded'; - $headers[] = 'Content-Length: '.strlen($this->postdata); - } - $request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata; - return $request; - } - function getStatus() { - return $this->status; - } - function getContent() { - return $this->content; - } - function getHeaders() { - return $this->headers; - } - function getHeader($header) { - $header = strtolower($header); - if (isset($this->headers[$header])) { - return $this->headers[$header]; - } else { - return false; - } - } - function getError() { - return $this->errormsg; - } - function getCookies() { - return $this->cookies; - } - function getRequestURL() { - $url = 'http://'.$this->host; - if ($this->port != 80) { - $url .= ':'.$this->port; - } - $url .= $this->path; - return $url; - } - // Setter methods - function setUserAgent($string) { - $this->user_agent = $string; - } - function setAuthorization($username, $password) { - $this->username = $username; - $this->password = $password; - } - function setCookies($array) { - $this->cookies = $array; - } - // Option setting methods - function useGzip($boolean) { - $this->use_gzip = $boolean; - } - function setPersistCookies($boolean) { - $this->persist_cookies = $boolean; - } - function setPersistReferers($boolean) { - $this->persist_referers = $boolean; - } - function setHandleRedirects($boolean) { - $this->handle_redirects = $boolean; - } - function setMaxRedirects($num) { - $this->max_redirects = $num; - } - function setHeadersOnly($boolean) { - $this->headers_only = $boolean; - } - function setDebug($boolean) { - $this->debug = $boolean; - } - // "Quick" static methods - function quickGet($url) { - $bits = parse_url($url); - $host = $bits['host']; - $port = isset($bits['port']) ? $bits['port'] : 80; - $path = isset($bits['path']) ? $bits['path'] : '/'; - if (isset($bits['query'])) { - $path .= '?'.$bits['query']; - } - $client = new HttpClient($host, $port); - if (!$client->get($path)) { - return false; - } else { - return $client->getContent(); - } - } - function quickPost($url, $data) { - $bits = parse_url($url); - $host = $bits['host']; - $port = isset($bits['port']) ? $bits['port'] : 80; - $path = isset($bits['path']) ? $bits['path'] : '/'; - $client = new HttpClient($host, $port); - if (!$client->post($path, $data)) { - return false; - } else { - return $client->getContent(); - } - } - function debug($msg, $object = false) { - if ($this->debug) { - print '
    HttpClient Debug: '.$msg; - if ($object) { - ob_start(); - print_r($object); - $content = htmlentities(ob_get_contents()); - ob_end_clean(); - print '
    '.$content.'
    '; - } - print '
    '; - } - } -} - -?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php new file mode 100644 index 00000000..48af8737 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php @@ -0,0 +1,81 @@ +_getPLink($lang); + + $outWords = array(); + foreach ($words as $word) { + if (!pspell_check($plink, trim($word))) + $outWords[] = utf8_encode($word); + } + + return $outWords; + } + + /** + * Returns suggestions of for a specific word. + * + * @param {String} $lang Language code like sv or en. + * @param {String} $word Specific word to get suggestions for. + * @return {Array} Array of suggestions for the specified word. + */ + function &getSuggestions($lang, $word) { + $words = pspell_suggest($this->_getPLink($lang), $word); + + for ($i=0; $ithrowError("PSpell support not found in PHP installation."); + + // Setup PSpell link + $plink = pspell_new( + $lang, + $this->_config['PSpell.spelling'], + $this->_config['PSpell.jargon'], + $this->_config['PSpell.encoding'], + $this->_config['PSpell.mode'] + ); + + // Setup PSpell link +/* if (!$plink) { + $pspellConfig = pspell_config_create( + $lang, + $this->_config['PSpell.spelling'], + $this->_config['PSpell.jargon'], + $this->_config['PSpell.encoding'] + ); + + $plink = pspell_new_config($pspell_config); + }*/ + + if (!$plink) + $this->throwError("No PSpell link found opened."); + + return $plink; + } +} + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php new file mode 100644 index 00000000..779e8372 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php @@ -0,0 +1,112 @@ +_getCMD($lang); + + if ($fh = fopen($this->_tmpfile, "w")) { + fwrite($fh, "!\n"); + + foreach($words as $key => $value) + fwrite($fh, "^" . $value . "\n"); + + fclose($fh); + } else + $this->throwError("PSpell support was not found."); + + $data = shell_exec($cmd); + @unlink($this->_tmpfile); + + $returnData = array(); + $dataArr = preg_split("/[\r\n]/", $data, -1, PREG_SPLIT_NO_EMPTY); + + foreach ($dataArr as $dstr) { + $matches = array(); + + // Skip this line. + if (strpos($dstr, "@") === 0) + continue; + + preg_match("/\& ([^ ]+) .*/i", $dstr, $matches); + + if (!empty($matches[1])) + $returnData[] = utf8_encode(trim($matches[1])); + } + + return $returnData; + } + + /** + * Returns suggestions of for a specific word. + * + * @param {String} $lang Language code like sv or en. + * @param {String} $word Specific word to get suggestions for. + * @return {Array} Array of suggestions for the specified word. + */ + function &getSuggestions($lang, $word) { + $cmd = $this->_getCMD($lang); + + if (function_exists("mb_convert_encoding")) + $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8")); + else + $word = utf8_encode($word); + + if ($fh = fopen($this->_tmpfile, "w")) { + fwrite($fh, "!\n"); + fwrite($fh, "^$word\n"); + fclose($fh); + } else + $this->throwError("Error opening tmp file."); + + $data = shell_exec($cmd); + @unlink($this->_tmpfile); + + $returnData = array(); + $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); + + foreach($dataArr as $dstr) { + $matches = array(); + + // Skip this line. + if (strpos($dstr, "@") === 0) + continue; + + preg_match("/\&[^:]+:(.*)/i", $dstr, $matches); + + if (!empty($matches[1])) { + $words = array_slice(explode(',', $matches[1]), 0, 10); + + for ($i=0; $i_tmpfile = tempnam($this->_config['PSpellShell.tmp'], "tinyspell"); + + if(preg_match("#win#i", php_uname())) + return $this->_config['PSpellShell.aspell'] . " -a --lang=". $lang . " --encoding=utf-8 -H < " . $this->_tmpfile . " 2>&1"; + + return "cat ". $this->_tmpfile ." | " . $this->_config['PSpellShell.aspell'] . " -a --encoding=utf-8 -H --lang=". $lang; + } +} + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php new file mode 100644 index 00000000..ca7b1432 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php @@ -0,0 +1,61 @@ +_config = $config; + } + + /** + * Simple loopback function everything that gets in will be send back. + * + * @param $args.. Arguments. + * @return {Array} Array of all input arguments. + */ + function &loopback(/* args.. */) { + return func_get_args(); + } + + /** + * Spellchecks an array of words. + * + * @param {String} $lang Language code like sv or en. + * @param {Array} $words Array of words to spellcheck. + * @return {Array} Array of misspelled words. + */ + function &checkWords($lang, $words) { + return $words; + } + + /** + * Returns suggestions of for a specific word. + * + * @param {String} $lang Language code like sv or en. + * @param {String} $word Specific word to get suggestions for. + * @return {Array} Array of suggestions for the specified word. + */ + function &getSuggestions($lang, $word) { + return array(); + } + + /** + * Throws an error message back to the user. This will stop all execution. + * + * @param {String} $str Message to send back to user. + */ + function throwError($str) { + die('{"result":null,"id":null,"error":{"errstr":"' . addslashes($str) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'); + } +} + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php deleted file mode 100755 index e7d8a578..00000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php +++ /dev/null @@ -1,126 +0,0 @@ -lang = $lang; - } - - // Returns array with bad words or false if failed. - function checkWords($word_array) { - $words = array(); - $wordstr = implode(' ', $word_array); - - $matches = $this->_getMatches($wordstr); - - for ($i=0; $iunhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8")); - - return $words; - } - - function unhtmlentities($string) { - $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); - $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); - - $trans_tbl = get_html_translation_table(HTML_ENTITIES); - $trans_tbl = array_flip($trans_tbl); - - return strtr($string, $trans_tbl); - } - - // Returns array with suggestions or false if failed. - function getSuggestion($word) { - $sug = array(); - - $matches = $this->_getMatches($word); - - if (count($matches) > 0) - $sug = explode("\t", utf8_encode($this->unhtmlentities($matches[0][4]))); - - return $sug; - } - - function _xmlChars($string) { - $trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); - - foreach ($trans as $k => $v) - $trans[$k] = "&#".ord($k).";"; - - return strtr($string, $trans); - } - - function _getMatches($word_list) { - $server = "www.google.com"; - $port = 443; - $path = "/tbproxy/spell?lang=" . $this->lang . "&hl=en"; - $host = "www.google.com"; - $url = "https://" . $server; - - // Setup XML request - $xml = '' . $word_list . ''; - - $header = "POST ".$path." HTTP/1.0 \r\n"; - $header .= "MIME-Version: 1.0 \r\n"; - $header .= "Content-type: application/PTI26 \r\n"; - $header .= "Content-length: ".strlen($xml)." \r\n"; - $header .= "Content-transfer-encoding: text \r\n"; - $header .= "Request-number: 1 \r\n"; - $header .= "Document-type: Request \r\n"; - $header .= "Interface-Version: Test 1.4 \r\n"; - $header .= "Connection: close \r\n\r\n"; - $header .= $xml; - //$this->_debugData($xml); - - // Use curl if it exists - if (function_exists('curl_init')) { - // Use curl - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL,$url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - $xml = curl_exec($ch); - curl_close($ch); - } else { - // Use raw sockets - $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30); - if ($fp) { - // Send request - fwrite($fp, $header); - - // Read response - $xml = ""; - while (!feof($fp)) - $xml .= fgets($fp, 128); - - fclose($fp); - } else - echo "Could not open SSL connection to google."; - } - - //$this->_debugData($xml); - - // Grab and parse content - preg_match_all('/([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); - - return $matches; - } - - function _debugData($data) { - $fh = @fopen("debug.log", 'a+'); - @fwrite($fh, $data); - @fclose($fh); - } -} - -// Setup classname, should be the same as the name of the spellchecker class -$spellCheckerConfig['class'] = "TinyGoogleSpell"; - -?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php deleted file mode 100755 index dfea14cb..00000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php +++ /dev/null @@ -1,64 +0,0 @@ -lang = $lang; - $this->mode = $mode; - $this->plink = false; - $this->errorMsg = array(); - - if (!function_exists("pspell_new")) { - $this->errorMsg[] = "PSpell not found."; - return; - } - - $this->plink = pspell_new($this->lang, $this->spelling, $this->jargon, $this->encoding, $this->mode); - } - - // Returns array with bad words or false if failed. - function checkWords($wordArray) { - if (!$this->plink) { - $this->errorMsg[] = "No PSpell link found for checkWords."; - return array(); - } - - $wordError = array(); - foreach($wordArray as $word) { - if(!pspell_check($this->plink, trim($word))) - $wordError[] = $word; - } - - return $wordError; - } - - // Returns array with suggestions or false if failed. - function getSuggestion($word) { - if (!$this->plink) { - $this->errorMsg[] = "No PSpell link found for getSuggestion."; - return array(); - } - - return pspell_suggest($this->plink, $word); - } -} - -// Setup classname, should be the same as the name of the spellchecker class -$spellCheckerConfig['class'] = "TinyPspell"; - -?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php deleted file mode 100755 index 41cb8c35..00000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php +++ /dev/null @@ -1,121 +0,0 @@ -lang = $lang; - $this->mode = $mode; - $this->error = false; - $this->errorMsg = array(); - - $this->tmpfile = tempnam($config['tinypspellshell.tmp'], "tinyspell"); - - if(preg_match("#win#i",php_uname())) - $this->cmd = $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang." --encoding=utf-8 -H < $this->tmpfile 2>&1"; - else - $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --encoding=utf-8 -H --lang=". $this->lang; - } - - // Returns array with bad words or false if failed. - function checkWords($wordArray) { - if ($fh = fopen($this->tmpfile, "w")) { - fwrite($fh, "!\n"); - foreach($wordArray as $key => $value) - fwrite($fh, "^" . $value . "\n"); - fclose($fh); - } else { - $this->errorMsg[] = "PSpell not found."; - return array(); - } - - $data = shell_exec($this->cmd); - @unlink($this->tmpfile); - - $returnData = array(); - $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); - - foreach($dataArr as $dstr) { - $matches = array(); - - // Skip this line. - if (strpos($dstr, "@") === 0) - continue; - - preg_match("/\& (.*) .* .*: .*/i", $dstr, $matches); - - if (!empty($matches[1])) - $returnData[] = $matches[1]; - } - - return $returnData; - } - - // Returns array with suggestions or false if failed. - function getSuggestion($word) { - if (function_exists("mb_convert_encoding")) - $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8")); - else - $word = utf8_encode($word); - - if ($fh = fopen($this->tmpfile, "w")) { - fwrite($fh, "!\n"); - fwrite($fh, "^$word\n"); - fclose($fh); - } else - die("Error opening tmp file."); - - $data = shell_exec($this->cmd); - - @unlink($this->tmpfile); - - $returnData = array(); - $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); - - foreach($dataArr as $dstr) { - $matches = array(); - - // Skip this line. - if (strpos($dstr, "@") === 0) - continue; - - preg_match("/\& .* .* .*: (.*)/i", $dstr, $matches); - - if (!empty($matches[1])) { - // For some reason, the exec version seems to add commas? - $returnData[] = str_replace(",", "", $matches[1]); - } - } - return $returnData; - } - - function _debugData($data) { - $fh = @fopen("debug.log", 'a+'); - @fwrite($fh, $data); - @fclose($fh); - } - -} - -// Setup classname, should be the same as the name of the spellchecker class -$spellCheckerConfig['class'] = "TinyPspellShell"; - -?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php new file mode 100644 index 00000000..1c461167 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php @@ -0,0 +1,595 @@ +_data = $data; + $this->_len = strlen($data); + $this->_pos = -1; + $this->_location = JSON_IN_BETWEEN; + $this->_lastLocations = array(); + $this->_needProp = false; + } + + function getToken() { + return $this->_token; + } + + function getLocation() { + return $this->_location; + } + + function getTokenName() { + switch ($this->_token) { + case JSON_BOOL: + return 'JSON_BOOL'; + + case JSON_INT: + return 'JSON_INT'; + + case JSON_STR: + return 'JSON_STR'; + + case JSON_FLOAT: + return 'JSON_FLOAT'; + + case JSON_NULL: + return 'JSON_NULL'; + + case JSON_START_OBJ: + return 'JSON_START_OBJ'; + + case JSON_END_OBJ: + return 'JSON_END_OBJ'; + + case JSON_START_ARRAY: + return 'JSON_START_ARRAY'; + + case JSON_END_ARRAY: + return 'JSON_END_ARRAY'; + + case JSON_KEY: + return 'JSON_KEY'; + } + + return 'UNKNOWN'; + } + + function getValue() { + return $this->_value; + } + + function readToken() { + $chr = $this->read(); + + if ($chr != null) { + switch ($chr) { + case '[': + $this->_lastLocation[] = $this->_location; + $this->_location = JSON_IN_ARRAY; + $this->_token = JSON_START_ARRAY; + $this->_value = null; + $this->readAway(); + return true; + + case ']': + $this->_location = array_pop($this->_lastLocation); + $this->_token = JSON_END_ARRAY; + $this->_value = null; + $this->readAway(); + + if ($this->_location == JSON_IN_OBJECT) + $this->_needProp = true; + + return true; + + case '{': + $this->_lastLocation[] = $this->_location; + $this->_location = JSON_IN_OBJECT; + $this->_needProp = true; + $this->_token = JSON_START_OBJ; + $this->_value = null; + $this->readAway(); + return true; + + case '}': + $this->_location = array_pop($this->_lastLocation); + $this->_token = JSON_END_OBJ; + $this->_value = null; + $this->readAway(); + + if ($this->_location == JSON_IN_OBJECT) + $this->_needProp = true; + + return true; + + // String + case '"': + case '\'': + return $this->_readString($chr); + + // Null + case 'n': + return $this->_readNull(); + + // Bool + case 't': + case 'f': + return $this->_readBool($chr); + + default: + // Is number + if (is_numeric($chr) || $chr == '-' || $chr == '.') + return $this->_readNumber($chr); + + return true; + } + } + + return false; + } + + function _readBool($chr) { + $this->_token = JSON_BOOL; + $this->_value = $chr == 't'; + + if ($chr == 't') + $this->skip(3); // rue + else + $this->skip(4); // alse + + $this->readAway(); + + if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) + $this->_needProp = true; + + return true; + } + + function _readNull() { + $this->_token = JSON_NULL; + $this->_value = null; + + $this->skip(3); // ull + $this->readAway(); + + if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) + $this->_needProp = true; + + return true; + } + + function _readString($quote) { + $output = ""; + $this->_token = JSON_STR; + $endString = false; + + while (($chr = $this->peek()) != -1) { + switch ($chr) { + case '\\': + // Read away slash + $this->read(); + + // Read escape code + $chr = $this->read(); + switch ($chr) { + case 't': + $output .= "\t"; + break; + + case 'b': + $output .= "\b"; + break; + + case 'f': + $output .= "\f"; + break; + + case 'r': + $output .= "\r"; + break; + + case 'n': + $output .= "\n"; + break; + + case 'u': + $output .= $this->_int2utf8(hexdec($this->read(4))); + break; + + default: + $output .= $chr; + break; + } + + break; + + case '\'': + case '"': + if ($chr == $quote) + $endString = true; + + $chr = $this->read(); + if ($chr != -1 && $chr != $quote) + $output .= $chr; + + break; + + default: + $output .= $this->read(); + } + + // String terminated + if ($endString) + break; + } + + $this->readAway(); + $this->_value = $output; + + // Needed a property + if ($this->_needProp) { + $this->_token = JSON_KEY; + $this->_needProp = false; + return true; + } + + if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) + $this->_needProp = true; + + return true; + } + + function _int2utf8($int) { + $int = intval($int); + + switch ($int) { + case 0: + return chr(0); + + case ($int & 0x7F): + return chr($int); + + case ($int & 0x7FF): + return chr(0xC0 | (($int >> 6) & 0x1F)) . chr(0x80 | ($int & 0x3F)); + + case ($int & 0xFFFF): + return chr(0xE0 | (($int >> 12) & 0x0F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr (0x80 | ($int & 0x3F)); + + case ($int & 0x1FFFFF): + return chr(0xF0 | ($int >> 18)) . chr(0x80 | (($int >> 12) & 0x3F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr(0x80 | ($int & 0x3F)); + } + } + + function _readNumber($start) { + $value = ""; + $isFloat = false; + + $this->_token = JSON_INT; + $value .= $start; + + while (($chr = $this->peek()) != -1) { + if (is_numeric($chr) || $chr == '-' || $chr == '.') { + if ($chr == '.') + $isFloat = true; + + $value .= $this->read(); + } else + break; + } + + $this->readAway(); + + if ($isFloat) { + $this->_token = JSON_FLOAT; + $this->_value = floatval($value); + } else + $this->_value = intval($value); + + if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) + $this->_needProp = true; + + return true; + } + + function readAway() { + while (($chr = $this->peek()) != null) { + if ($chr != ':' && $chr != ',' && $chr != ' ') + return; + + $this->read(); + } + } + + function read($len = 1) { + if ($this->_pos < $this->_len) { + if ($len > 1) { + $str = substr($this->_data, $this->_pos + 1, $len); + $this->_pos += $len; + + return $str; + } else + return $this->_data[++$this->_pos]; + } + + return null; + } + + function skip($len) { + $this->_pos += $len; + } + + function peek() { + if ($this->_pos < $this->_len) + return $this->_data[$this->_pos + 1]; + + return null; + } +} + +/** + * This class handles JSON stuff. + * + * @package MCManager.utils + */ +class Moxiecode_JSON { + function Moxiecode_JSON() { + } + + function decode($input) { + $reader = new Moxiecode_JSONReader($input); + + return $this->readValue($reader); + } + + function readValue(&$reader) { + $this->data = array(); + $this->parents = array(); + $this->cur =& $this->data; + $key = null; + $loc = JSON_IN_ARRAY; + + while ($reader->readToken()) { + switch ($reader->getToken()) { + case JSON_STR: + case JSON_INT: + case JSON_BOOL: + case JSON_FLOAT: + case JSON_NULL: + switch ($reader->getLocation()) { + case JSON_IN_OBJECT: + $this->cur[$key] = $reader->getValue(); + break; + + case JSON_IN_ARRAY: + $this->cur[] = $reader->getValue(); + break; + + default: + return $reader->getValue(); + } + break; + + case JSON_KEY: + $key = $reader->getValue(); + break; + + case JSON_START_OBJ: + case JSON_START_ARRAY: + if ($loc == JSON_IN_OBJECT) + $this->addArray($key); + else + $this->addArray(null); + + $cur =& $obj; + + $loc = $reader->getLocation(); + break; + + case JSON_END_OBJ: + case JSON_END_ARRAY: + $loc = $reader->getLocation(); + + if (count($this->parents) > 0) { + $this->cur =& $this->parents[count($this->parents) - 1]; + array_pop($this->parents); + } + break; + } + } + + return $this->data[0]; + } + + // This method was needed since PHP is crapy and doesn't have pointers/references + function addArray($key) { + $this->parents[] =& $this->cur; + $ar = array(); + + if ($key) + $this->cur[$key] =& $ar; + else + $this->cur[] =& $ar; + + $this->cur =& $ar; + } + + function getDelim($index, &$reader) { + switch ($reader->getLocation()) { + case JSON_IN_ARRAY: + case JSON_IN_OBJECT: + if ($index > 0) + return ","; + break; + } + + return ""; + } + + function encode($input) { + switch (gettype($input)) { + case 'boolean': + return $input ? 'true' : 'false'; + + case 'integer': + return (int) $input; + + case 'float': + case 'double': + return (float) $input; + + case 'NULL': + return 'null'; + + case 'string': + return $this->encodeString($input); + + case 'array': + return $this->_encodeArray($input); + + case 'object': + return $this->_encodeArray(get_object_vars($input)); + } + + return ''; + } + + function encodeString($input) { + // Needs to be escaped + if (preg_match('/[^a-zA-Z0-9]/', $input)) { + $output = ''; + + for ($i=0; $i_utf82utf16($char))); + } if (($byte & 0xF0) == 0xE0) { + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2])); + $i += 2; + $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); + } if (($byte & 0xF8) == 0xF0) { + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]))); + $i += 3; + $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); + } if (($byte & 0xFC) == 0xF8) { + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]))); + $i += 4; + $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); + } if (($byte & 0xFE) == 0xFC) { + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]), ord($input[$i + 5]))); + $i += 5; + $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); + } else if ($byte < 128) + $output .= $input[$i]; + } + } + + return '"' . $output . '"'; + } + + return '"' . $input . '"'; + } + + function _utf82utf16($utf8) { + if (function_exists('mb_convert_encoding')) + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + + switch (strlen($utf8)) { + case 1: + return $utf8; + + case 2: + return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1]))); + + case 3: + return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2]))); + } + + return ''; + } + + function _encodeArray($input) { + $output = ''; + $isIndexed = true; + + $keys = array_keys($input); + for ($i=0; $iencodeString($keys[$i]) . ':' . $this->encode($input[$keys[$i]]); + $isIndexed = false; + } else + $output .= $this->encode($input[$keys[$i]]); + + if ($i != count($keys) - 1) + $output .= ','; + } + + return $isIndexed ? '[' . $output . ']' : '{' . $output . '}'; + } +} + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php new file mode 100644 index 00000000..a1fb4cd0 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php @@ -0,0 +1,268 @@ +_path = ""; + $this->_filename = "{level}.log"; + $this->setMaxSize("100k"); + $this->_maxFiles = 10; + $this->_level = MC_LOGGER_DEBUG; + $this->_format = "[{time}] [{level}] {message}"; + } + + /** + * Sets the current log level, use the MC_LOGGER constants. + * + * @param int $level Log level instance for example MC_LOGGER_DEBUG. + */ + function setLevel($level) { + if (is_string($level)) { + switch (strtolower($level)) { + case "debug": + $level = MC_LOGGER_DEBUG; + break; + + case "info": + $level = MC_LOGGER_INFO; + break; + + case "warn": + case "warning": + $level = MC_LOGGER_WARN; + break; + + case "error": + $level = MC_LOGGER_ERROR; + break; + + case "fatal": + $level = MC_LOGGER_FATAL; + break; + + default: + $level = MC_LOGGER_FATAL; + } + } + + $this->_level = $level; + } + + /** + * Returns the current log level for example MC_LOGGER_DEBUG. + * + * @return int Current log level for example MC_LOGGER_DEBUG. + */ + function getLevel() { + return $this->_level; + } + + function setPath($path) { + $this->_path = $path; + } + + function getPath() { + return $this->_path; + } + + function setFileName($file_name) { + $this->_filename = $file_name; + } + + function getFileName() { + return $this->_filename; + } + + function setFormat($format) { + $this->_format = $format; + } + + function getFormat() { + return $this->_format; + } + + function setMaxSize($size) { + // Fix log max size + $logMaxSizeBytes = intval(preg_replace("/[^0-9]/", "", $size)); + + // Is KB + if (strpos((strtolower($size)), "k") > 0) + $logMaxSizeBytes *= 1024; + + // Is MB + if (strpos((strtolower($size)), "m") > 0) + $logMaxSizeBytes *= (1024 * 1024); + + $this->_maxSizeBytes = $logMaxSizeBytes; + $this->_maxSize = $size; + } + + function getMaxSize() { + return $this->_maxSize; + } + + function setMaxFiles($max_files) { + $this->_maxFiles = $max_files; + } + + function getMaxFiles() { + return $this->_maxFiles; + } + + function debug($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_DEBUG, implode(', ', $args)); + } + + function info($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_INFO, implode(', ', $args)); + } + + function warn($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_WARN, implode(', ', $args)); + } + + function error($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_ERROR, implode(', ', $args)); + } + + function fatal($msg) { + $args = func_get_args(); + $this->_logMsg(MC_LOGGER_FATAL, implode(', ', $args)); + } + + function isDebugEnabled() { + return $this->_level >= MC_LOGGER_DEBUG; + } + + function isInfoEnabled() { + return $this->_level >= MC_LOGGER_INFO; + } + + function isWarnEnabled() { + return $this->_level >= MC_LOGGER_WARN; + } + + function isErrorEnabled() { + return $this->_level >= MC_LOGGER_ERROR; + } + + function isFatalEnabled() { + return $this->_level >= MC_LOGGER_FATAL; + } + + function _logMsg($level, $message) { + $roll = false; + + if ($level < $this->_level) + return; + + $logFile = $this->toOSPath($this->_path . "/" . $this->_filename); + + switch ($level) { + case MC_LOGGER_DEBUG: + $levelName = "DEBUG"; + break; + + case MC_LOGGER_INFO: + $levelName = "INFO"; + break; + + case MC_LOGGER_WARN: + $levelName = "WARN"; + break; + + case MC_LOGGER_ERROR: + $levelName = "ERROR"; + break; + + case MC_LOGGER_FATAL: + $levelName = "FATAL"; + break; + } + + $logFile = str_replace('{level}', strtolower($levelName), $logFile); + + $text = $this->_format; + $text = str_replace('{time}', date("Y-m-d H:i:s"), $text); + $text = str_replace('{level}', strtolower($levelName), $text); + $text = str_replace('{message}', $message, $text); + $message = $text . "\r\n"; + + // Check filesize + if (file_exists($logFile)) { + $size = @filesize($logFile); + + if ($size + strlen($message) > $this->_maxSizeBytes) + $roll = true; + } + + // Roll if the size is right + if ($roll) { + for ($i=$this->_maxFiles-1; $i>=1; $i--) { + $rfile = $this->toOSPath($logFile . "." . $i); + $nfile = $this->toOSPath($logFile . "." . ($i+1)); + + if (@file_exists($rfile)) + @rename($rfile, $nfile); + } + + @rename($logFile, $this->toOSPath($logFile . ".1")); + + // Delete last logfile + $delfile = $this->toOSPath($logFile . "." . ($this->_maxFiles + 1)); + if (@file_exists($delfile)) + @unlink($delfile); + } + + // Append log line + if (($fp = @fopen($logFile, "a")) != null) { + @fputs($fp, $message); + @fflush($fp); + @fclose($fp); + } + } + + /** + * Converts a Unix path to OS specific path. + * + * @param String $path Unix path to convert. + */ + function toOSPath($path) { + return str_replace("/", DIRECTORY_SEPARATOR, $path); + } +} + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/config.php b/wp-includes/js/tinymce/plugins/spellchecker/config.php old mode 100755 new mode 100644 index 097d46b6..a5185700 --- a/wp-includes/js/tinymce/plugins/spellchecker/config.php +++ b/wp-includes/js/tinymce/plugins/spellchecker/config.php @@ -1,24 +1,21 @@ diff --git a/wp-includes/js/tinymce/plugins/spellchecker/css/content.css b/wp-includes/js/tinymce/plugins/spellchecker/css/content.css old mode 100755 new mode 100644 index c56a4538..656ce1ee --- a/wp-includes/js/tinymce/plugins/spellchecker/css/content.css +++ b/wp-includes/js/tinymce/plugins/spellchecker/css/content.css @@ -1,4 +1 @@ -.mceItemHiddenSpellWord { - background: url('../images/wline.gif') repeat-x bottom left; - cursor: default; -} +.mceItemHiddenSpellWord {background:url(../img/wline.gif) repeat-x bottom left; cursor:default;} diff --git a/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css b/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css deleted file mode 100755 index f2c6ac74..00000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css +++ /dev/null @@ -1,35 +0,0 @@ -.mceMsgBox { - border: 1px solid gray; - padding: 8px; -} - -.mceMsgBox span { - vertical-align: top; - color: #555555; -} - -/* Misc */ - -.mceBlockBox { - display: none; - position: absolute; - left: 0; - top: 0; - z-index: 100; - filter:progid:DXImageTransform.Microsoft.Alpha(style=0, opacity=60); - -moz-opacity:0.6; - opacity: 0.6; - background-color: white; -} - -.mceMsgBox { - display: none; - z-index: 101; - position: absolute; - left: 0; - top: 0; - font-family: Arial, Verdana, Tahoma, Helvetica; - font-weight: bold; - font-size: 11px; - background-color: #FFF; -} diff --git a/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js b/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js old mode 100755 new mode 100644 index 865b332a..72c1a7a6 --- a/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js @@ -1,630 +1,338 @@ /** - * $Id: editor_plugin_src.js 289 2007-05-28 09:12:16Z spocke $ + * $Id: editor_plugin_src.js 425 2007-11-21 15:17:39Z spocke $ * * @author Moxiecode - * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. + * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. */ -tinyMCE.importPluginLanguagePack('spellchecker', 'en,fr,sv,nn,nb'); - -// Plucin static class -var TinyMCE_SpellCheckerPlugin = { - _contextMenu : new TinyMCE_Menu(), - _menu : new TinyMCE_Menu(), - _counter : 0, - _ajaxPage : '/tinyspell.php', - - getInfo : function() { - return { - longname : 'Spellchecker PHP', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker', - version : "1.0.5" - }; - }, - - handleEvent : function(e) { - var elm = tinyMCE.isMSIE ? e.srcElement : e.target; - var inst = tinyMCE.selectedInstance, args = ''; - var self = TinyMCE_SpellCheckerPlugin; - var cm = self._contextMenu; - var p, p2, x, y, sx, sy, h, elm; - - // Handle click on word - if ((e.type == "click" || e.type == "contextmenu") && elm) { - do { - if (tinyMCE.getAttrib(elm, 'class') == "mceItemHiddenSpellWord") { - inst.spellCheckerElm = elm; - - // Setup arguments - args += 'id=' + inst.editorId + "|" + (++self._counter); - args += '&cmd=suggest&check=' + encodeURIComponent(elm.innerHTML); - args += '&lang=' + escape(inst.spellCheckerLang); - - elm = inst.spellCheckerElm; - p = tinyMCE.getAbsPosition(inst.iframeElement); - p2 = tinyMCE.getAbsPosition(elm); - h = parseInt(elm.offsetHeight); - sx = inst.getBody().scrollLeft; - sy = inst.getBody().scrollTop; - x = p.absLeft + p2.absLeft - sx; - y = p.absTop + p2.absTop - sy + h; - - cm.clear(); - cm.addTitle(tinyMCE.getLang('lang_spellchecker_wait', '', true)); - cm.show(); - cm.moveTo(x, y); - - inst.selection.selectNode(elm, false, false); - - self._sendAjax(self.baseURL + self._ajaxPage, self._ajaxResponse, 'post', args); - - tinyMCE.cancelEvent(e); - return false; +(function() { + var JSONRequest = tinymce.util.JSONRequest, each = tinymce.each, DOM = tinymce.DOM; + + tinymce.create('tinymce.plugins.SpellcheckerPlugin', { + getInfo : function() { + return { + longname : 'Spellchecker', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker', + version : tinymce.majorVersion + "." + tinymce.minorVersion + }; + }, + + init : function(ed, url) { + var t = this, cm; + + t.url = url; + t.editor = ed; + + // Register commands + ed.addCommand('mceSpellCheck', function() { + if (!t.active) { + ed.setProgressState(1); + t._sendRPC('checkWords', [t.selectedLang, t._getWords()], function(r) { + if (r.length > 0) { + t.active = 1; + t._markWords(r); + ed.setProgressState(0); + ed.nodeChanged(); + } else { + ed.setProgressState(0); + ed.windowManager.alert('spellchecker.no_mpell'); + } + }); + } else + t._done(); + }); + + ed.onInit.add(function() { + if (ed.settings.content_css !== false) + ed.dom.loadCSS(url + '/css/content.css'); + }); + + ed.onClick.add(t._showMenu, t); + ed.onContextMenu.add(t._showMenu, t); + ed.onBeforeGetContent.add(function() { + if (t.active) + t._removeWords(); + }); + + ed.onNodeChange.add(function(ed, cm) { + cm.setActive('spellchecker', t.active); + }); + + ed.onSetContent.add(function() { + t._done(); + }); + + ed.onBeforeGetContent.add(function() { + t._done(); + }); + + ed.onBeforeExecCommand.add(function(ed, cmd) { + if (cmd == 'mceFullScreen') + t._done(); + }); + + // Find selected language + t.languages = {}; + each(ed.getParam('spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv', 'hash'), function(v, k) { + if (k.indexOf('+') === 0) { + k = k.substring(1); + t.selectedLang = v; } - } while ((elm = elm.parentNode)); - } - - return true; - }, - - initInstance : function(inst) { - var self = TinyMCE_SpellCheckerPlugin, m = self._menu, cm = self._contextMenu, e; - - tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/spellchecker/css/content.css"); - - if (!tinyMCE.hasMenu('spellcheckercontextmenu')) { - tinyMCE.importCSS(document, tinyMCE.baseURL + "/plugins/spellchecker/css/spellchecker.css"); - - cm.init({drop_menu : false}); - tinyMCE.addMenu('spellcheckercontextmenu', cm); - } - - if (!tinyMCE.hasMenu('spellcheckermenu')) { - m.init({}); - tinyMCE.addMenu('spellcheckermenu', m); - } - - inst.spellCheckerLang = 'en'; - self._buildSettingsMenu(inst, null); - - e = self._getBlockBoxLayer(inst).create('div', 'mceBlockBox', document.getElementById(inst.editorId + '_parent')); - self._getMsgBoxLayer(inst).create('div', 'mceMsgBox', document.getElementById(inst.editorId + '_parent')); - }, - - _getMsgBoxLayer : function(inst) { - if (!inst.spellCheckerMsgBoxL) - inst.spellCheckerMsgBoxL = new TinyMCE_Layer(inst.editorId + '_spellcheckerMsgBox', false); - - return inst.spellCheckerMsgBoxL; - }, - _getBlockBoxLayer : function(inst) { - if (!inst.spellCheckerBoxL) - inst.spellCheckerBoxL = new TinyMCE_Layer(inst.editorId + '_spellcheckerBlockBox', false); + t.languages[k] = v; + }); + }, - return inst.spellCheckerBoxL; - }, + createControl : function(n, cm) { + var t = this, c, ed = t.editor; - _buildSettingsMenu : function(inst, lang) { - var i, ar = tinyMCE.getParam('spellchecker_languages', '+English=en').split(','), p; - var self = TinyMCE_SpellCheckerPlugin, m = self._menu, c; + if (n == 'spellchecker') { + c = cm.createSplitButton(n, {title : 'spellchecker.desc', cmd : 'mceSpellCheck', scope : t}); - m.clear(); - m.addTitle(tinyMCE.getLang('lang_spellchecker_langs', '', true)); + c.onRenderMenu.add(function(c, m) { + m.add({title : 'spellchecker.langs', 'class' : 'mceMenuItemTitle'}).setDisabled(1); + each(t.languages, function(v, k) { + var o = {icon : 1}, mi; - for (i=0; i'; - h += ''; - h += ''; - h += ''; - } else { - if (tinyMCE.isMSIE && !tinyMCE.isOpera) - h += ''; - else - h += ''; - - h += ''; - h += ''; - h += ''; - h += ''; - } + _walk : function(n, f) { + var d = this.editor.getDoc(), w; - return h; - }, + if (d.createTreeWalker) { + w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false); - _menuButtonEvent : function(e, o) { - var t = this; + while ((n = w.nextNode()) != null) + f.call(this, n); + } else + tinymce.walk(n, f, 'childNodes'); + }, - // Give IE some time since it's buggy!! :( - window.setTimeout(function() { - t._menuButtonEvent2(e, o); - }, 1); - }, + _getSeparators : function() { + var re = '', i, str = this.editor.getParam('spellchecker_word_separator_chars', '\\s!"#$%&()*+,-./:;<=>?@[\]^_{|}§©«®±¶·¸»¼½¾¿×÷¤\u201d\u201c'); - _menuButtonEvent2 : function(e, o) { - if (o.className == 'mceMenuButtonFocus') - return; + // Build word separator regexp + for (i=0; i'; - e.appendChild(mbs); + if (n.nodeType == 3) { + v = n.nodeValue; - mb.show(); - mb.moveRelativeTo(co, 'cc'); + if (r1.test(v) || r2.test(v) || r3.test(v) || r4.test(v)) { + v = dom.encode(v); + v = v.replace(r5, '$1$2'); + v = v.replace(r3, '$1$2'); - if (tinyMCE.isMSIE && !tinyMCE.isOpera) { - nl = co.getElementsByTagName('select'); - for (i=0; i 500) - text = text.substring(500); - - inst.spellcheckerOn = false; - tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton'); - alert("Could not execute AJAX call, server didn't return valid a XML.\nResponse: " + text); - return; - } - - err = el.getAttribute("error"); - - if (err == "true") { - inst.spellcheckerOn = false; - tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton'); - alert(el.getAttribute("msg")); - return; - } - - switch (cmd) { - case "spell": - if (xml.documentElement.firstChild) { - self._markWords(inst.getDoc(), inst.getBody(), decodeURIComponent(el.firstChild.nodeValue).split('+')); - inst.selection.moveToBookmark(inst.spellCheckerBookmark); - - if(tinyMCE.getParam('spellchecker_report_misspellings', false)) - alert(tinyMCE.getLang('lang_spellchecker_mpell_found', '', true, {words : self._countWords(inst)})); - } else - alert(tinyMCE.getLang('lang_spellchecker_no_mpell', '', true)); - - self._checkDone(inst); - - // Odd stuff FF removed useCSS, disable state for it - inst.useCSS = false; - - break; - - case "suggest": - self._buildMenu(el.firstChild ? decodeURIComponent(el.firstChild.nodeValue).split('+') : null, 10); - self._contextMenu.show(); - break; - } - }, - - _getWordSeparators : function() { - var i, re = '', ch = tinyMCE.getParam('spellchecker_word_separator_chars', '\\s!"#$%&()*+,-./:;<=>?@[\]^_{|}§©«®±¶·¸»¼½¾¿×÷¤\u201d\u201c'); - - for (i=0; i 0) - wl[wl.length] = nl[i]; - } - - return wl.join(' '); - }, - - _removeWords : function(doc, word, cleanup) { - var i, c, nl = doc.getElementsByTagName("span"); - var self = TinyMCE_SpellCheckerPlugin; - var inst = tinyMCE.selectedInstance, b = inst ? inst.selection.getBookmark() : null; - - word = typeof(word) == 'undefined' ? null : word; - - for (i=nl.length-1; i>=0; i--) { - c = tinyMCE.getAttrib(nl[i], 'class'); - - if ((c == 'mceItemHiddenSpellWord' || c == 'mceItemHidden') && (word == null || nl[i].innerHTML == word)) - self._removeWord(nl[i]); - } - - if (b && !cleanup) - inst.selection.moveToBookmark(b); - }, - - _checkDone : function(inst) { - var self = TinyMCE_SpellCheckerPlugin; - var w = self._countWords(inst); - - if (w == 0) { - self._removeWords(inst.getDoc()); - inst.spellcheckerOn = false; - tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton'); - } - }, - - _countWords : function(inst) { - var i, w = 0, nl = inst.getDoc().getElementsByTagName("span"), c; - var self = TinyMCE_SpellCheckerPlugin; - - for (i=nl.length-1; i>=0; i--) { - c = tinyMCE.getAttrib(nl[i], 'class'); - - if (c == 'mceItemHiddenSpellWord') - w++; - } - - return w; - }, + if (dom.hasClass(e.target, 'mceItemHiddenSpellWord')) { + m.removeAll(); + m.add({title : 'spellchecker.wait', 'class' : 'mceMenuItemTitle'}).setDisabled(1); + + t._sendRPC('getSuggestions', [t.selectedLang, dom.decode(e.target.innerHTML)], function(r) { + m.removeAll(); + + if (r.length > 0) { + m.add({title : 'spellchecker.sug', 'class' : 'mceMenuItemTitle'}).setDisabled(1); + each(r, function(v) { + m.add({title : v, onclick : function() { + dom.replace(ed.getDoc().createTextNode(v), e.target); + t._checkDone(); + }}); + }); + + m.addSeparator(); + } else + m.add({title : 'spellchecker.no_sug', 'class' : 'mceMenuItemTitle'}).setDisabled(1); + + m.add({ + title : 'spellchecker.ignore_word', + onclick : function() { + dom.remove(e.target, 1); + t._checkDone(); + } + }); + + m.add({ + title : 'spellchecker.ignore_words', + onclick : function() { + t._removeWords(dom.decode(e.target.innerHTML)); + t._checkDone(); + } + }); + + m.update(); + }); + + ed.selection.select(e.target); + p1 = dom.getPos(e.target); + m.showMenu(p1.x, p1.y + e.target.offsetHeight - vp.y); + + return tinymce.dom.Event.cancel(e); + } else + m.hideMenu(); + }, + + _checkDone : function() { + var t = this, ed = t.editor, dom = ed.dom, o; + + each(dom.select('span'), function(n) { + if (n && dom.hasClass(n, 'mceItemHiddenSpellWord')) { + o = true; + return false; + } + }); - _removeWord : function(e) { - if (e != null) - tinyMCE.setOuterHTML(e, e.innerHTML); - }, + if (!o) + t._done(); + }, - _markWords : function(doc, n, wl) { - var i, nv, nn, nl = tinyMCE.getNodeTree(n, new Array(), 3); - var r1, r2, r3, r4, r5, w = ''; - var re = TinyMCE_SpellCheckerPlugin._getWordSeparators(); + _done : function() { + var t = this, la = t.active; - for (i=0; i 0) - w += wl[i] + ((i == wl.length-1) ? '' : '|'); - } + if (t.active) { + t.active = 0; + t._removeWords(); - for (i=0; i$1$2'); - nv = nv.replace(r3, '$1$2'); - - nn = doc.createElement('span'); - nn.className = "mceItemHidden"; - nn.innerHTML = nv; - - // Remove old text node - nl[i].parentNode.replaceChild(nn, nl[i]); + if (la) + t.editor.nodeChanged(); } - } - }, - - _buildMenu : function(sg, max) { - var i, self = TinyMCE_SpellCheckerPlugin, cm = self._contextMenu; - - cm.clear(); + }, - if (sg != null) { - cm.addTitle(tinyMCE.getLang('lang_spellchecker_sug', '', true)); + _sendRPC : function(m, p, cb) { + var t = this, url = t.editor.getParam("spellchecker_rpc_url", this.url+"/rpc.php"); - for (i=0; i $value) + $newarray[formatParam($name, $sanitize)] = formatParam($value, $sanitize); + + return $newarray; + } + + return formatParam($_REQUEST[$name], $sanitize); +} + +function &getLogger() { + global $mcLogger, $man; + + if (isset($man)) + $mcLogger = $man->getLogger(); + + if (!$mcLogger) { + $mcLogger = new Moxiecode_Logger(); + + // Set logger options + $mcLogger->setPath(dirname(__FILE__) . "/../logs"); + $mcLogger->setMaxSize("100kb"); + $mcLogger->setMaxFiles("10"); + $mcLogger->setFormat("{time} - {message}"); + } + + return $mcLogger; +} + +function debug($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->debug(implode(', ', $args)); +} + +function info($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->info(implode(', ', $args)); +} + +function error($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->error(implode(', ', $args)); +} + +function warn($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->warn(implode(', ', $args)); +} + +function fatal($msg) { + $args = func_get_args(); + + $log = getLogger(); + $log->fatal(implode(', ', $args)); +} + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/langs/en.js b/wp-includes/js/tinymce/plugins/spellchecker/langs/en.js deleted file mode 100755 index 74791f9e..00000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/langs/en.js +++ /dev/null @@ -1,15 +0,0 @@ -// UK lang variables - -tinyMCE.addToLang('spellchecker',{ - desc : 'Toggle spellchecker', - menu : 'Spellchecker settings', - ignore_word : 'Ignore word', - ignore_words : 'Ignore all', - langs : 'Languages', - wait : 'Please wait...', - swait : 'Spellchecking, please wait...', - sug : 'Suggestions', - no_sug : 'No suggestions', - no_mpell : 'No misspellings found.', - mpell_found : 'Found {$words} misspellings.' -}); diff --git a/wp-includes/js/tinymce/plugins/spellchecker/rpc.php b/wp-includes/js/tinymce/plugins/spellchecker/rpc.php new file mode 100644 index 00000000..d7b74362 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/rpc.php @@ -0,0 +1,75 @@ +decode($raw); + +// Execute RPC +if (isset($config['general.engine'])) { + $spellchecker = new $config['general.engine']($config); + $result = call_user_func_array(array($spellchecker, $input['method']), $input['params']); +} else + die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'); + +// Request and response id should always be the same +$output = array( + "id" => $input->id, + "result" => $result, + "error" => null +); + +// Return JSON encoded string +echo $json->encode($output); + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php b/wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php deleted file mode 100755 index 4c0cd166..00000000 --- a/wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php +++ /dev/null @@ -1,164 +0,0 @@ -'; - die; - } - - // Basic config - $defaultLanguage = $spellCheckerConfig['default.language']; - $defaultMode = $spellCheckerConfig['default.mode']; - - // Normaly not required to configure - $defaultSpelling = $spellCheckerConfig['default.spelling']; - $defaultJargon = $spellCheckerConfig['default.jargon']; - $defaultEncoding = $spellCheckerConfig['default.encoding']; - $outputType = "xml"; // Do not change - - // Get input parameters. - - $check = urldecode(getRequestParam('check')); - $cmd = sanitize(getRequestParam('cmd')); - $lang = sanitize(getRequestParam('lang'), "strict"); - $mode = sanitize(getRequestParam('mode'), "strict"); - $spelling = sanitize(getRequestParam('spelling'), "strict"); - $jargon = sanitize(getRequestParam('jargon'), "strict"); - $encoding = sanitize(getRequestParam('encoding'), "strict"); - $sg = sanitize(getRequestParam('sg'), "bool"); - $words = array(); - - $validRequest = true; - - if (empty($check)) - $validRequest = false; - - if (empty($lang)) - $lang = $defaultLanguage; - - if (empty($mode)) - $mode = $defaultMode; - - if (empty($spelling)) - $spelling = $defaultSpelling; - - if (empty($jargon)) - $jargon = $defaultJargon; - - if (empty($encoding)) - $encoding = $defaultEncoding; - - function sanitize($str, $type="strict") { - switch ($type) { - case "strict": - $str = preg_replace("/[^a-zA-Z0-9_\-]/i", "", $str); - break; - case "loose": - $str = preg_replace("//i", "<", $str); - break; - case "bool": - if ($str == "true" || $str == true) - $str = true; - else - $str = false; - break; - } - - return $str; - } - - function getRequestParam($name, $default_value = false) { - if (!isset($_REQUEST[$name])) - return $default_value; - - if (!isset($_GLOBALS['magic_quotes_gpc'])) - $_GLOBALS['magic_quotes_gpc'] = ini_get("magic_quotes_gpc"); - - if (isset($_GLOBALS['magic_quotes_gpc'])) { - if (is_array($_REQUEST[$name])) { - $newarray = array(); - - foreach($_REQUEST[$name] as $name => $value) - $newarray[stripslashes($name)] = stripslashes($value); - - return $newarray; - } - return stripslashes($_REQUEST[$name]); - } - - return $_REQUEST[$name]; - } - - $result = array(); - $tinyspell = new $spellCheckerConfig['class']($spellCheckerConfig, $lang, $mode, $spelling, $jargon, $encoding); - - if (count($tinyspell->errorMsg) == 0) { - switch($cmd) { - case "spell": - // Space for non-exec version and \n for the exec version. - $words = preg_split("/ |\n/", $check, -1, PREG_SPLIT_NO_EMPTY); - $result = $tinyspell->checkWords($words); - break; - - case "suggest": - $result = $tinyspell->getSuggestion($check); - break; - - default: - // Just use this for now. - $tinyspell->errorMsg[] = "No command."; - $outputType = $outputType . "error"; - break; - } - } else - $outputType = $outputType . "error"; - - if (!$result) - $result = array(); - - // Output data - switch($outputType) { - case "xml": - header('Content-type: text/xml; charset=utf-8'); - $body = ''; - $body .= "\n"; - - if (count($result) == 0) - $body .= ''; - else - $body .= ''. urlencode(implode(" ", $result)) .''; - - echo $body; - break; - case "xmlerror"; - header('Content-type: text/xml; charset=utf-8'); - $body = ''; - $body .= "\n"; - $body .= 'errorMsg) .'" />'; - echo $body; - break; - case "html": - var_dump($result); - break; - case "htmlerror": - echo "Error"; - break; - } - -?> diff --git a/wp-includes/js/tinymce/plugins/wordpress/css/content.css b/wp-includes/js/tinymce/plugins/wordpress/css/content.css new file mode 100644 index 00000000..a542e6e0 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/css/content.css @@ -0,0 +1,15 @@ + +.mceWPnextpage, .mceWPmore { + border: 0px; + border-top: 1px dotted #cccccc; + display: block; + width: 100%; + height: 12px; + margin-top: 15px; +} +.mceWPmore { + background: #ffffff url(../img/more_bug.gif) no-repeat right top; +} +.mceWPnextpage { + background: #ffffff url(../img/page_bug.gif) no-repeat right top; +} \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js index f834e97a..28144579 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -1,592 +1,238 @@ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('wordpress', 'en'); - -var TinyMCE_wordpressPlugin = { - getInfo : function() { - return { - longname : 'WordPress Plugin', - author : 'WordPress', - authorurl : 'http://wordpress.org', - infourl : 'http://wordpress.org', - version : '1' - }; - }, - - getControlHTML : function(control_name) { - switch (control_name) { - case "wp_more": - return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_more_button', '{$pluginurl}/images/more.gif', 'wpMore'); - case "wp_page": - return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_page_button', '{$pluginurl}/images/page.gif', 'wpPage'); - case "wp_help": - var buttons = tinyMCE.getButtonHTML(control_name, 'lang_help_button_title', '{$pluginurl}/images/help.gif', 'wpHelp'); - var hiddenControls = '
    ' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '
    '; - return buttons+hiddenControls; - case "wp_adv": - return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_adv_button', '{$pluginurl}/images/toolbars.gif', 'wpAdv'); - case "wp_adv_start": - return ''; - } - return ''; - }, - - execCommand : function(editor_id, element, command, user_interface, value) { - var inst = tinyMCE.getInstanceById(editor_id); - var focusElm = inst.getFocusElement(); - var doc = inst.getDoc(); - - function getAttrib(elm, name) { - return elm.getAttribute(name) ? elm.getAttribute(name) : ""; - } - - // Handle commands - switch (command) { - case "wpMore": - var flag = ""; - var template = new Array(); - var altMore = tinyMCE.getLang('lang_wordpress_more_alt'); - - // Is selection a image - if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { - flag = getAttrib(focusElm, 'class'); - - if (flag != 'mce_plugin_wordpress_more') // Not a wordpress - return true; - - action = "update"; +/** + * WordPress plugin. + */ + +(function() { + var DOM = tinymce.DOM; + + // Load plugin specific language pack + tinymce.PluginManager.requireLangPack('wordpress'); + + tinymce.create('tinymce.plugins.WordPress', { + init : function(ed, url) { + var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'); + var moreHTML = ''; + var nextpageHTML = ''; + + if ( tinymce.util.Cookie.get('kitchenSink') == '1' ) + ed.settings.wordpress_adv_hidden = 0; + + // Hides the specified toolbar and resizes the iframe + ed.onPostRender.add(function() { + if ( ed.getParam('wordpress_adv_hidden', 1) ) { + DOM.hide(ed.controlManager.get(tbId).id); + t._resizeIframe(ed, tbId, 28); } - - html = '' - + ''; - tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, html); - tinyMCE.selectedInstance.repaint(); - return true; - - case "wpPage": - var flag = ""; - var template = new Array(); - var altPage = tinyMCE.getLang('lang_wordpress_more_alt'); - - // Is selection a image - if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { - flag = getAttrib(focusElm, 'name'); - - if (flag != 'mce_plugin_wordpress_page') // Not a wordpress - return true; - - action = "update"; - } - - html = '' - + ''; - tinyMCE.execCommand("mceInsertContent",true,html); - tinyMCE.selectedInstance.repaint(); - return true; - - case "wpHelp": - var template = new Array(); - - template['file'] = tinyMCE.baseURL + '/wp-mce-help.php'; - template['width'] = 480; - template['height'] = 380; - - args = { - resizable : 'yes', - scrollbars : 'yes' - }; - - tinyMCE.openWindow(template, args); - return true; - case "wpAdv": - var adv = document.getElementById('wpadvbar'); - if ( adv.style.display == 'none' ) { - adv.style.display = 'block'; - tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonSelected'); + }); + + // Register commands + ed.addCommand('WP_More', function() { + ed.execCommand('mceInsertContent', 0, moreHTML); + }); + + ed.addCommand('WP_Page', function() { + ed.execCommand('mceInsertContent', 0, nextpageHTML); + }); + + ed.addCommand('WP_Help', function() { + ed.windowManager.open({ + url : tinymce.baseURL + '/wp-mce-help.php', + width : 450, + height : 420, + inline : 1 + }); + }); + + ed.addCommand('WP_Adv', function() { + var id = ed.controlManager.get(tbId).id, cm = ed.controlManager, cook = tinymce.util.Cookie, date; + + date = new Date(); + date.setTime(date.getTime()+(10*365*24*60*60*1000)); + + if (DOM.isHidden(id)) { + cm.setActive('wp_adv', 1); + DOM.show(id); + t._resizeIframe(ed, tbId, -28); + ed.settings.wordpress_adv_hidden = 0; + cook.set('kitchenSink', '1', date); } else { - adv.style.display = 'none'; - tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonNormal'); - } - return true; - } - - // Pass to next handler in chain - return false; - }, - - cleanup : function(type, content) { - switch (type) { - - case "insert_to_editor": - var startPos = 0; - var altMore = tinyMCE.getLang('lang_wordpress_more_alt'); - var altPage = tinyMCE.getLang('lang_wordpress_page_alt'); - - // Parse all tags and replace them with images - while ((startPos = content.indexOf('', startPos) + 3; - // Insert image - var moreText = content.substring(startPos + 8, endPos - 3); - var contentAfter = content.substring(endPos); - content = content.substring(0, startPos); - content += ''; - content += contentAfter; - - startPos++; - } - var startPos = 0; - - // Parse all tags and replace them with images - while ((startPos = content.indexOf('', startPos)) != -1) { - // Insert image - var contentAfter = content.substring(startPos + 15); - content = content.substring(0, startPos); - content += ''; - content += contentAfter; - - startPos++; + cm.setActive('wp_adv', 0); + DOM.hide(id); + t._resizeIframe(ed, tbId, 28); + ed.settings.wordpress_adv_hidden = 1; + cook.set('kitchenSink', '0', date); } - - // Look for \n in
    , replace with 
    - var startPos = -1; - while ((startPos = content.indexOf('', startPos+1); - var innerPos = content.indexOf('>', startPos+1); - var chunkBefore = content.substring(0, innerPos); - var chunkAfter = content.substring(endPos); - - var innards = content.substring(innerPos, endPos); - innards = innards.replace(/\n/g, '
    '); - content = chunkBefore + innards + chunkAfter; - } - - break; - - case "get_from_editor": - // Parse all img tags and replace them with - var startPos = -1; - while ((startPos = content.indexOf('', startPos); - var attribs = this._parseAttributes(content.substring(startPos + 4, endPos)); - - if (attribs['class'] == "mce_plugin_wordpress_more" || attribs['name'] == "mce_plugin_wordpress_more") { - endPos += 2; - - var moreText = attribs['moretext'] ? attribs['moretext'] : ''; - var embedHTML = ''; - - // Insert embed/object chunk - chunkBefore = content.substring(0, startPos); - chunkAfter = content.substring(endPos); - content = chunkBefore + embedHTML + chunkAfter; - } - if (attribs['class'] == "mce_plugin_wordpress_page" || attribs['name'] == "mce_plugin_wordpress_page") { - endPos += 2; - - var embedHTML = ''; - - // Insert embed/object chunk - chunkBefore = content.substring(0, startPos); - chunkAfter = content.substring(endPos); - content = chunkBefore + embedHTML + chunkAfter; + }); + + // Register buttons + ed.addButton('wp_more', { + title : 'wordpress.wp_more_desc', + image : url + '/img/more.gif', + cmd : 'WP_More' + }); + + ed.addButton('wp_page', { + title : 'wordpress.wp_page_desc', + image : url + '/img/page.gif', + cmd : 'WP_Page' + }); + + ed.addButton('wp_help', { + title : 'wordpress.wp_help_desc', + image : url + '/img/help.gif', + cmd : 'WP_Help' + }); + + ed.addButton('wp_adv', { + title : 'wordpress.wp_adv_desc', + image : url + '/img/toolbars.gif', + cmd : 'WP_Adv' + }); + + // Add class "alignleft", "alignright" and "aligncenter" when selecting align for images. + ed.onExecCommand.add(function( editor, cmd ) { + var node, bl, dom = editor.dom; + + if ( 'JustifyCenter' == cmd ) { + if ( ( node = editor.selection.getNode() ) && node.nodeName == 'IMG' ) { + if ( ! dom.hasClass( node, "aligncenter" ) && ( bl = editor.forceBlocks.getParentBlock(node) ) && bl.childNodes.length == 1 ) + dom.setStyle(bl, 'text-align', ''); } + editor.execCommand('mceRepaint'); } - - // Remove normal line breaks - content = content.replace(/\n|\r/g, ' '); - - // Look for
    in
    , replace with \n
    -				var startPos = -1;
    -				while ((startPos = content.indexOf('', startPos+1);
    -					var innerPos = content.indexOf('>', startPos+1);
    -					var chunkBefore = content.substring(0, innerPos);
    -					var chunkAfter = content.substring(endPos);
    -					
    -					var innards = content.substring(innerPos, endPos);
    -					innards = innards.replace(new RegExp('', 'g'), '\n');
    -					innards = innards.replace(new RegExp('\\s$', ''), '');
    -					content = chunkBefore + innards + chunkAfter;
    +			});
    +
    +			ed.onBeforeExecCommand.add(function( editor, cmd ) {
    +				var node, dir, xdir, bl, dom = editor.dom;
    +
    +				if ( ( cmd.indexOf('Justify') != -1 ) && ( node = editor.selection.getNode() ) ) {
    +					if ( 'JustifyFull' == cmd || node.nodeName !== 'IMG' ) return;
    +					dir = cmd.substring(7).toLowerCase();
    +
    +					if (  editor.queryCommandState( cmd ) ) {
    +						dom.removeClass( node, "alignleft" );
    +						dom.removeClass( node, "alignright" );
    +						dom.removeClass( node, "aligncenter" );
    +					} else if ( 'JustifyCenter' == cmd ) {
    +						dom.removeClass( node, "alignleft" );
    +						dom.removeClass( node, "alignright" );
    +
    +						if ( dom.hasClass( node, "aligncenter" ) ) {
    +							dom.removeClass( node, "aligncenter" );
    +							if ( ( bl = editor.forceBlocks.getParentBlock(node) ) && bl.childNodes.length == 1 && tinymce.isGecko )
    +								editor.selection.select(bl.firstChild);
    +						} else dom.addClass( node, "aligncenter" );
    +
    +					} else {
    +						xdir = ( dir == 'left' ) ? 'right' : 'left';
    +						dom.removeClass( node, "aligncenter" );
    +						dom.removeClass( node, "align"+xdir );
    +						dom.addClass( node, "align"+dir );
    +					}
     				}
    -
    -				// Remove anonymous, empty paragraphs.
    -				content = content.replace(new RegExp('

    (\\s| )*

    ', 'mg'), ''); - - // Handle table badness. - content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>'); - content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>'); - content = content.replace(new RegExp('.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '<$2>'); - content = content.replace(new RegExp('.*?<(tr|/table)>', 'mg'), '<$1>'); - content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(
    )*)*', 'g'), '<$1>'); - - // Pretty it up for the source editor. - var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p'; - content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>', 'mg'), '\n<$1>'); - content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>'); - content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>'); - content = content.replace(new RegExp('\\s*
    \\s*', 'mg'), '
    \n'); - content = content.replace(new RegExp('^\\s*', ''), ''); - content = content.replace(new RegExp('\\s*$', ''), ''); - - break; - } - - // Pass through to next handler in chain - return content; - }, - - handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { - - tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonNormal'); - - if (node == null) - return; - - do { - if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0) - tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonSelected'); - if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0) - tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonSelected'); - } while ((node = node.parentNode)); - - return true; - }, - - saveCallback : function(el, content, body) { - // We have a TON of cleanup to do. - - // Mark

    if it has any attributes. - content = content.replace(new RegExp('(]+>.*?)

    ', 'mg'), '$1'); - - // Decode the ampersands of time. - // content = content.replace(new RegExp('&', 'g'), '&'); - - // Get it ready for wpautop. - content = content.replace(new RegExp('\\s*

    ', 'mgi'), ''); - content = content.replace(new RegExp('\\s*

    \\s*', 'mgi'), '\n\n'); - content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); - content = content.replace(new RegExp('\\s*
    \\s*', 'gi'), '\n'); - - // Fix some block element newline issues - var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre'; - content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); - content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - content = content.replace(new RegExp('
  • ', 'g'), '\t
  • '); - - // Unmark special paragraph closing tags - content = content.replace(new RegExp('', 'g'), '

    \n'); - content = content.replace(new RegExp('\\s*(]+>.*

    )', 'mg'), '\n$1'); - - // Trim trailing whitespace - content = content.replace(new RegExp('\\s*$', ''), ''); - - // Hope. - return content; - - }, - - _parseAttributes : function(attribute_string) { - var attributeName = ""; - var attributeValue = ""; - var withInName; - var withInValue; - var attributes = new Array(); - var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); - var titleText = tinyMCE.getLang('lang_wordpress_more'); - var titleTextPage = tinyMCE.getLang('lang_wordpress_page'); - - if (attribute_string == null || attribute_string.length < 2) - return null; - - withInName = withInValue = false; - - for (var i=0; i
  • !ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '
    ' "); // Hmm... - return pee; -} + // Register plugin + tinymce.PluginManager.add('wordpress', tinymce.plugins.WordPress); +})(); diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/help.gif b/wp-includes/js/tinymce/plugins/wordpress/img/help.gif similarity index 100% rename from wp-includes/js/tinymce/plugins/wordpress/images/help.gif rename to wp-includes/js/tinymce/plugins/wordpress/img/help.gif diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/more.gif b/wp-includes/js/tinymce/plugins/wordpress/img/more.gif similarity index 100% rename from wp-includes/js/tinymce/plugins/wordpress/images/more.gif rename to wp-includes/js/tinymce/plugins/wordpress/img/more.gif diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/more_bug.gif b/wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif similarity index 100% rename from wp-includes/js/tinymce/plugins/wordpress/images/more_bug.gif rename to wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/page.gif b/wp-includes/js/tinymce/plugins/wordpress/img/page.gif similarity index 100% rename from wp-includes/js/tinymce/plugins/wordpress/images/page.gif rename to wp-includes/js/tinymce/plugins/wordpress/img/page.gif diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif b/wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif similarity index 100% rename from wp-includes/js/tinymce/plugins/wordpress/images/page_bug.gif rename to wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif b/wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif old mode 100755 new mode 100644 similarity index 100% rename from wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif rename to wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif diff --git a/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif b/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif new file mode 100644 index 00000000..38848651 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/js/.preserve-dir b/wp-includes/js/tinymce/plugins/wordpress/js/.preserve-dir new file mode 100644 index 00000000..e69de29b diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js deleted file mode 100644 index 32a5ba57..00000000 --- a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js +++ /dev/null @@ -1,37 +0,0 @@ -// EN lang variables - -if (navigator.userAgent.indexOf('Mac OS') != -1) { -// Mac OS browsers use Ctrl to hit accesskeys - var metaKey = 'Ctrl'; -} -else if (navigator.userAgent.indexOf('Firefox/2') != -1) { -// Firefox 2.x uses Alt+Shift to hit accesskeys - var metaKey = 'Alt+Shift'; -} -else { - var metaKey = 'Alt'; -} - -tinyMCE.addToLang('',{ -wordpress_more_button : 'Split post with More tag (' + metaKey + '+t)', -wordpress_page_button : 'Split post with Page tag', -wordpress_adv_button : 'Show/Hide Advanced Toolbar (' + metaKey + '+v)', -wordpress_more_alt : 'More...', -wordpress_page_alt : '...page...', -help_button_title : 'Help (' + metaKey + '+h)', -bold_desc : 'Bold (Ctrl+B)', -italic_desc : 'Italic (Ctrl+I)', -underline_desc : 'Underline (Ctrl+U)', -link_desc : 'Insert/edit link (' + metaKey + '+a)', -unlink_desc : 'Unlink (' + metaKey + '+s)', -image_desc : 'Insert/edit image (' + metaKey + '+m)', -striketrough_desc : 'Strikethrough (' + metaKey + '+k)', -justifyleft_desc : 'Align left (' + metaKey + '+f)', -justifycenter_desc : 'Align center (' + metaKey + '+c)', -justifyright_desc : 'Align right (' + metaKey + '+r)', -justifyfull_desc : 'Align full (' + metaKey + '+j)', -bullist_desc : 'Unordered list (' + metaKey + '+l)', -numlist_desc : 'Ordered list (' + metaKey + '+o)', -outdent_desc : 'Outdent (' + metaKey + '+w)', -indent_desc : 'Indent list/blockquote (' + metaKey + '+q)' -}); diff --git a/wp-includes/js/tinymce/plugins/wordpress/wordpress.css b/wp-includes/js/tinymce/plugins/wordpress/wordpress.css deleted file mode 100644 index 115b291c..00000000 --- a/wp-includes/js/tinymce/plugins/wordpress/wordpress.css +++ /dev/null @@ -1,81 +0,0 @@ -.mce_plugin_wordpress_more { - border: 0px; - border-top: 1px dotted #cccccc; - display:block; - background-color: #ffffff; - margin-top:15px; - background-image: url(images/more_bug.gif); - background-repeat: no-repeat; - background-position: right top; -} - -.mce_plugin_wordpress_page { - border: 0px; - border-top: 1px dotted #cccccc; - display:block; - background-color: #ffffff; - margin-top:15px; - background-image: url(images/page_bug.gif); - background-repeat: no-repeat; - background-position: right top; -} - -/* This file contains the CSS data for the editable area(iframe) of TinyMCE */ -/* You can extend this CSS by adding your own CSS file with the the content_css option */ - -body { - background: #fff; - font: 1em/1.3em Georgia, "Times New Roman", Times, serif; - padding: .5em; -} - -td { - font-size: 10px; -} - -pre { - font-family: "Courier New", fixed; - font-size: 11px; - line-height: 13px; -} - -.mceVisualAid { - border: 1px dashed #BBBBBB !important; -} - -.mceItemAnchor { - width: 12px; - line-height: 6px; - overflow: hidden; - padding-left: 12px; - background-position: bottom; - background-repeat: no-repeat; -} - -/* Important is needed in Gecko browsers inorder to style links */ -/* -a { - color: green !important; -} -*/ - -/* Style selection range colors in Gecko browsers */ -/* -::-moz-selection { - background-color: red; - color: green; -} -*/ - -/* MSIE specific */ - -* html body { - scrollbar-3dlight-color: #F0F0EE; - scrollbar-arrow-color: #676662; - scrollbar-base-color: #F0F0EE; - scrollbar-darkshadow-color: #DDDDDD; - scrollbar-face-color: #E0E0DD; - scrollbar-highlight-color: #F0F0EE; - scrollbar-shadow-color: #F0F0EE; - scrollbar-track-color: #F5F5F5; -} \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js b/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js deleted file mode 100644 index da29521c..00000000 --- a/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js +++ /dev/null @@ -1,57 +0,0 @@ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('wphelp', ''); - -function TinyMCE_wphelp_getControlHTML(control_name) { - switch (control_name) { - case "wphelp": - var titleHelp = tinyMCE.getLang('lang_help_button_title'); - var buttons = ''; - var hiddenControls = '
    ' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '
    '; - return buttons+hiddenControls; - } - - return ""; -} - -function TinyMCE_wphelp_execCommand(editor_id, element, command, user_interface, value) { - - // Handle commands - switch (command) { - case "mceWordPressHelp": - var template = new Array(); - - template['file'] = tinyMCE.baseURL + '/wp-mce-help.php'; - template['width'] = 480; - template['height'] = 380; - - args = { - resizable : 'yes', - scrollbars : 'yes' - }; - - tinyMCE.openWindow(template, args); - return true; - } - - // Pass to next handler in chain - return false; -} diff --git a/wp-includes/js/tinymce/plugins/wphelp/images/help.gif b/wp-includes/js/tinymce/plugins/wphelp/images/help.gif deleted file mode 100644 index 51a1ee42..00000000 Binary files a/wp-includes/js/tinymce/plugins/wphelp/images/help.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/plugins/wphelp/langs/en.js b/wp-includes/js/tinymce/plugins/wphelp/langs/en.js deleted file mode 100644 index 8c5b35ad..00000000 --- a/wp-includes/js/tinymce/plugins/wphelp/langs/en.js +++ /dev/null @@ -1,5 +0,0 @@ -// EN lang variables - -tinyMCE.addToLang('',{ -help_button_title : 'Help (Alt+h)' -}); diff --git a/wp-includes/js/tinymce/themes/advanced/about.htm b/wp-includes/js/tinymce/themes/advanced/about.htm index bb275f0a..69e37601 100644 --- a/wp-includes/js/tinymce/themes/advanced/about.htm +++ b/wp-includes/js/tinymce/themes/advanced/about.htm @@ -1,35 +1,39 @@ + - {$lang_about_title} - - - - + {#advanced_dlg.about_title} + + + - +
    -

    {$lang_about_title}

    -

    Version: {$tinymce_version} ({$tinymce_releasedate})

    +

    {#advanced_dlg.about_title}

    +

    Version: ()

    TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.

    -

    Copyright © 2003-2007, Moxiecode Systems AB, All rights reserved.

    +

    Copyright © 2003-2008, Moxiecode Systems AB, All rights reserved.

    For more information about this software visit the TinyMCE website.

    -
    +
    + Got Moxie? + Hosted By Sourceforge + Also on freshmeat +
    -

    {$lang_loaded_plugins}

    +

    {#advanced_dlg.about_loaded}

    @@ -45,7 +49,7 @@
    - +
    diff --git a/wp-includes/js/tinymce/themes/advanced/anchor.htm b/wp-includes/js/tinymce/themes/advanced/anchor.htm index 988bcb68..3ae87d01 100644 --- a/wp-includes/js/tinymce/themes/advanced/anchor.htm +++ b/wp-includes/js/tinymce/themes/advanced/anchor.htm @@ -1,33 +1,32 @@ + - {$lang_insert_anchor_title} - - + {#advanced_dlg.anchor_title} + + - -
    - + + - + - - + +
    {$lang_insert_anchor_title}{#advanced_dlg.anchor_title}
    {$lang_insert_anchor_name}:{#advanced_dlg.anchor_name}:
    - +
    - +
    -
    diff --git a/wp-includes/js/tinymce/themes/advanced/charmap.htm b/wp-includes/js/tinymce/themes/advanced/charmap.htm index fbd472b1..4f714576 100644 --- a/wp-includes/js/tinymce/themes/advanced/charmap.htm +++ b/wp-includes/js/tinymce/themes/advanced/charmap.htm @@ -1,27 +1,28 @@ + - {$lang_theme_charmap_title} + {#advanced_dlg.charmap_title} - - + + - + - + - diff --git a/wp-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-includes/js/tinymce/themes/advanced/color_picker.htm index 5e249203..62fc40f4 100644 --- a/wp-includes/js/tinymce/themes/advanced/color_picker.htm +++ b/wp-includes/js/tinymce/themes/advanced/color_picker.htm @@ -1,27 +1,28 @@ + - {$lang_theme_colorpicker_title} - - - - + {#advanced_dlg.colorpicker_title} + + + - + +
    - {$lang_color_picker} + {#advanced_dlg.colorpicker_picker_title}
    - +
    @@ -34,7 +35,7 @@
    - {$lang_web_colors} + {#advanced_dlg.colorpicker_palette_title}
    @@ -45,7 +46,7 @@
    - {$lang_named_colors} + {#advanced_dlg.colorpicker_named_title}
    @@ -53,7 +54,7 @@
    - {$lang_color_name} + {#advanced_dlg.colorpicker_name}
    @@ -61,14 +62,15 @@
    - +
    - +
    + diff --git a/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css b/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css deleted file mode 100644 index 4b0360bf..00000000 --- a/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css +++ /dev/null @@ -1,53 +0,0 @@ -/* Colorpicker dialog specific CSS */ - -#preview { - float: right; - width: 50px; - height: 14px; - line-height: 1px; - border: 1px solid black; - margin-left: 5px; -} - -#colorpicker { - float: left; - cursor: crosshair; -} - -#light { - border: 1px solid gray; - margin-left: 5px; - float: left; - width: 15px; - cursor: crosshair; -} - -#light div { - overflow: hidden; -} - -#previewblock { - float: right; - padding-left: 10px; - height: 20px; -} - -.panel_wrapper div.current { - height: 175px; -} - -#namedcolors { - width: 150px; -} - -#namedcolors a { - display: block; - float: left; - width: 10px; height: 10px; - margin: 1px 1px 0 0; - overflow: hidden; -} - -#colornamecontainer { - margin-top: 5px; -} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css deleted file mode 100644 index 182e7912..00000000 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css +++ /dev/null @@ -1,58 +0,0 @@ -/* This file contains the CSS data for the editable area(iframe) of TinyMCE */ -/* You can extend this CSS by adding your own CSS file with the the content_css option */ - -body, td, pre { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; -} - -body { - background-color: #FFFFFF; -} - -.mceVisualAid { - border: 1px dashed #BBBBBB !important; -} - -div.mceVisualAid { - background-image:url('../images/spacer.gif'); - visibility: visible !important; -} - -.mceItemAnchor { - width: 12px; - line-height: 6px; - overflow: hidden; - padding-left: 12px; - background-image: url('../images/anchor_symbol.gif'); - background-position: bottom; - background-repeat: no-repeat; -} - -/* Important is needed in Gecko browsers inorder to style links */ -/* -a { - color: green !important; -} -*/ - -/* Style selection range colors in Gecko browsers */ -/* -::-moz-selection { - background-color: red; - color: green; -} -*/ - -/* MSIE specific */ - -* html body { - scrollbar-3dlight-color: #F0F0EE; - scrollbar-arrow-color: #676662; - scrollbar-base-color: #F0F0EE; - scrollbar-darkshadow-color: #DDDDDD; - scrollbar-face-color: #E0E0DD; - scrollbar-highlight-color: #F0F0EE; - scrollbar-shadow-color: #F0F0EE; - scrollbar-track-color: #F5F5F5; -} diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css deleted file mode 100644 index e7853e4d..00000000 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css +++ /dev/null @@ -1,358 +0,0 @@ -/* This file contains the CSS data for all popups in TinyMCE */ - -body { - background-color: #F0F0EE; - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - scrollbar-3dlight-color: #F0F0EE; - scrollbar-arrow-color: #676662; - scrollbar-base-color: #F0F0EE; - scrollbar-darkshadow-color: #DDDDDD; - scrollbar-face-color: #E0E0DD; - scrollbar-highlight-color: #F0F0EE; - scrollbar-shadow-color: #F0F0EE; - scrollbar-track-color: #F5F5F5; - margin: 8px; -} - -td { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; -} - -input { - background: #FFFFFF; - border: 1px solid #cccccc; -} - -td, input, select, textarea { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; -} - -input, select, textarea { - border: 1px solid #808080; -} - -.input_noborder { - border: 0; -} - -#insert, .updateButton { - font-weight: bold; - width: 90px; - height: 21px; - border: 0; - background-image: url('../images/insert_button_bg.gif'); - cursor: pointer; -} - -#cancel { - font-weight: bold; - width: 90px; - height: 21px; - border: 0; - background-image: url('../images/cancel_button_bg.gif'); - cursor: pointer; -} - -/* Mozilla only style */ -html>body #insert, html>body #cancel { - padding-bottom: 2px; -} - -.title { - font-size: 12px; - font-weight: bold; - color: #2B6FB6; -} - -table.charmap { - border-style: solid; - border-width: 1px; - border-color: #AAAAAA; -} - -td.charmap, td.charmapOver { - color: #000000; - border-color: #AAAAAA; - border-style: solid; - border-width: 1px; - text-align: center; - font-size: 12px; -} - -td.charmapOver { - background-color: #CCCCCC; - cursor: default; -} - -a.charmap { - color: #000000; - text-decoration: none -} - -.wordWrapCode { - vertical-align: middle; - border: 1px none #000000; - background-color: transparent; -} - -input.radio { - border: 1px none #000000; - background-color: transparent; - vertical-align: middle; -} - -input.checkbox { - border: 1px none #000000; - background-color: transparent; - vertical-align: middle; -} - -.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceButtonDisabled, .mceButtonSelected { - margin-left: 1px; -} - -.mceButtonNormal { - border-top: 1px solid; - border-left: 1px solid; - border-bottom: 1px solid; - border-right: 1px solid; - border-color: #F0F0EE; - cursor: default; -} - -.mceButtonOver { - border: 1px solid #0A246A; - cursor: default; - background-color: #B6BDD2; -} - -.mceButtonDown { - cursor: default; - border: 1px solid #0A246A; - background-color: #8592B5; -} - -.mceButtonDisabled { - filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); - -moz-opacity:0.3; - opacity: 0.3; - border-top: 1px solid; - border-left: 1px solid; - border-bottom: 1px solid; - border-right: 1px solid; - border-color: #F0F0EE; - cursor: default; -} - -.mceActionPanel { - margin-top: 5px; -} - -/* Tabs classes */ - -.tabs { - float: left; - width: 100%; - line-height: normal; - background-image: url("../images/xp/tabs_bg.gif"); -} - -.tabs ul { - margin: 0; - padding: 0 0 0; - list-style: none; -} - -.tabs li { - float: left; - background: url("../images/xp/tab_bg.gif") no-repeat left top; - margin: 0; - margin-left: 0; - margin-right: 2px; - padding: 0 0 0 10px; - line-height: 18px; -} - -.tabs li.current { - background: url("../images/xp/tab_sel_bg.gif") no-repeat left top; - margin-right: 2px; -} - -.tabs span { - float: left; - display: block; - background: url("../images/xp/tab_end.gif") no-repeat right top; - padding: 0px 10px 0 0; -} - -.tabs .current span { - background: url("../images/xp/tab_sel_end.gif") no-repeat right top; -} - -.tabs a { - text-decoration: none; - font-family: Verdana, Arial; - font-size: 10px; -} - -.tabs a:link, .tabs a:visited, .tabs a:hover { - color: black; -} - -.tabs a:hover { -} - -.tabs .current { -} - -.tabs .current a, .tabs .current a:link, .tabs .current a:visited { -} - -.panel_wrapper div.panel { - display: none; -} - -.panel_wrapper div.current { - display: block; - width: 100%; - height: 300px; - overflow: visible; /* Should be auto but that breaks Safari */ -} - -.panel_wrapper { - border: 1px solid #919B9C; - border-top: 0px; - padding: 10px; - padding-top: 5px; - clear: both; - background-color: white; -} - -fieldset { - border: 1px solid #919B9C; - font-family: Verdana, Arial; - font-size: 10px; - padding: 0; - margin: 0; - padding: 4px; -} - -legend { - color: #2B6FB6; - font-weight: bold; -} - -.properties { - width: 100%; -} - -.properties .column1 { -} - -.properties .column2 { - text-align: left; -} - -a:link, a:visited { - color: black; -} - -a:hover { - color: #2B6FB6; -} - -#plugintable thead { - font-weight: bold; - background-color: #DDDDDD; -} - -#plugintable, #about #plugintable td { - border: 1px solid #919B9C; -} - -#plugintable { - width: 99%; - margin-top: 10px; -} - -#pluginscontainer { - height: 290px; - overflow: auto; -} - -/* MSIE Specific styles */ - -* html .panel_wrapper { - width: 100%; -} - -.column { - float: left; -} - -h1, h2, h3, h4 { - color: #2B6FB6; - margin: 0; - padding: 0; - padding-top: 5px; -} - -h3 { - font-size: 14px; -} - -#link .panel_wrapper, #link div.current { - height: 125px; -} - -#image .panel_wrapper, #image div.current { - height: 190px; -} - -label.msg { display: none; } -label.invalid { color: #EE0000; display: inline; } -input.invalid { border: 1px solid #EE0000; } - -/* Disables the advanced tab in the table plugin. */ -/* -#table #advanced_tab { - display: none; -} -*/ - -/* Disables the border input field and label in the table plugin. */ -/* -#table #border, #table #borderlabel { - display: none; -} -*/ - -/* Below this line is WordPress customizations */ -#insert, #cancel, .submitbutton { - font: 11px Verdana, Arial, Helvetica, sans-serif; - height: auto; - width: auto; - background-color: transparent; - background-image: url(../../../../../../wp-admin/images/fade-butt.png); - background-repeat: repeat; - border: 3px double; - border-right-color: rgb(153, 153, 153); - border-bottom-color: rgb(153, 153, 153); - border-left-color: rgb(204, 204, 204); - border-top-color: rgb(204, 204, 204); - color: rgb(51, 51, 51); - padding: 0.1em 0.5em; -} - -#insert:active, #cancel:active, .submitbutton:active { - background: #f4f4f4; - border-left-color: #999; - border-top-color: #999; -} - -#styleSelectRow { - display: none; -} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css deleted file mode 100644 index 851837d9..00000000 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css +++ /dev/null @@ -1,97 +0,0 @@ -/* This file contains the CSS data for the editor UI of TinyMCE instances */ - -.mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {border: 0; margin: 0; padding: 0; background: transparent;} -.mceSeparatorLine {border: 0; padding: 0; margin-left: 4px; margin-right: 2px;} -.mceSelectList {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 7pt !important; font-weight: normal; margin-top: 3px; padding: 0; display: inline; vertical-align: top; background-color: #F0F0EE;} -.mceLabel, .mceLabelDisabled {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt;} -.mceLabel {color: #000000;} -.mceLabelDisabled {cursor: text; color: #999999;} -.mceEditor {background: #F0F0EE; border: 1px solid #cccccc; padding: 0; margin: 0;} -.mceEditorArea { font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; background: #FFFFFF; padding: 0; margin: 0; } -.mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px; font-size: 1px;} -.mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;} -.mceToolbarBottom {border-top: 1px solid #cccccc;} -.mceToolbarContainer {display: block; position: relative; left: 0; top: 0; width: 100%;} -.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;} -.mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; padding: 2px; line-height: 16px; overflow: visible;} -.mceStatusbarTop {border-bottom: 1px solid #cccccc;} -.mceStatusbarBottom {border-top: 1px solid #cccccc;} -.mceStatusbar {border-bottom: 1px solid #cccccc;} -.mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {text-decoration: none; font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; color: #000000;} -.mcePathItem:hover {text-decoration: underline;} -.mceStatusbarPathText {float: left;} -.mceStatusbarResize {float: right; background-image: url('../images/statusbar_resize.gif'); background-repeat: no-repeat; width: 11px; height: 20px; cursor: se-resize;} -.mceResizeBox {width: 10px; height: 10px; display: none; border: 1px dotted gray; margin: 0; padding: 0;} -.mceEditorIframe {border: 0;} - -/* Button CSS rules */ - -a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {width: 20px; height: 20px; cursor: default; margin-top: 1px; margin-left: 1px;} -a.mceButtonDisabled img {border: 0 !important;} -a.mceButtonNormal img, a.mceButtonSelected img {border: 1px solid #F0F0EE !important;} -a.mceButtonSelected img {border: 1px solid #6779AA !important; background-color: #D4D5D8;} -a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {border: 1px solid #0A246A !important; cursor: default; background-color: #B6BDD2;} -a.mceButtonDisabled img {-moz-opacity:0.3; opacity: 0.3; border: 1px solid #F0F0EE !important; cursor: default;} -a.mceTiledButton img {background-image: url('../images/buttons.gif'); background-repeat: no-repeat;} - -/* Menu button CSS rules */ - -span.mceMenuButton img, span.mceMenuButtonSelected img {border: 1px solid #F0F0EE; margin-left: 1px;} -span.mceMenuButtonSelected img {border: 1px solid #6779AA; background-color: #B6BDD2;} -span.mceMenuButtonSelected img.mceMenuButton {border: 1px solid #F0F0EE; background-color: transparent;} -span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {border-left: 0; margin-left: 0;} -span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {border: 1px solid #0A246A; background-color: #B6BDD2;} -span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {border-left: 0;} -span.mceMenuButtonFocus img {border: 1px solid gray; border-right: 0; margin-left: 1px; background-color: #F5F4F2;} -span.mceMenuButtonFocus img.mceMenuButton {border: 1px solid gray; border-left: 1px solid #F5F4F2; margin-left: 0;} -span.mceMenuHover img {border: 1px solid #0A246A; background-color: #B6BDD2;} -span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {border: 1px solid #0A246A; background-color: #B6BDD2; border-left: 0;} - -/* Menu */ - -.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 1000; background-color: white; border: 1px solid gray; font-weight: normal;} -.mceMenu a, .mceMenuTitle, .mceMenuDisabled {display: block; width: 100%; text-decoration: none; background-color: white; font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 11px; line-height: 20px; color: black;} -.mceMenu a:hover {background-color: #B6BDD2; color: black; text-decoration: none !important;} -.mceMenu span {padding-left: 10px; padding-right: 10px; display: block; line-height: 20px;} -.mceMenuSeparator {border-bottom: 1px solid gray; background-color: gray; height: 1px;} -.mceMenuTitle span {padding-left: 5px;} -.mceMenuTitle {background-color: #DDDDDD; font-weight: bold;} -.mceMenuDisabled {color: gray;} -span.mceMenuSelectedItem {background-image: url('../images/menu_check.gif'); background-repeat: no-repeat; background-position: 5px 8px; padding-left: 20px;} -span.mceMenuCheckItem {padding-left: 20px;} -span.mceMenuLine {display: block; position: absolute; left: 0; top: -1px; background-color: #F5F4F2; width: 30px; height: 1px; overflow: hidden; padding-left: 0; padding-right: 0;} -.mceColors table, .mceColors td {margin: 0; padding: 2px;} -a.mceMoreColors {width: auto; padding: 0; margin: 0 3px 3px 3px; text-align: center; border: 1px solid white; text-decoration: none !important;} -.mceColorPreview {position: absolute; overflow:hidden; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px; background-color: red;} -a.mceMoreColors:hover {border: 1px solid #0A246A;} -.mceColors td a {width: 9px; height: 9px; overflow: hidden; border: 1px solid #808080;} - -/* MSIE 6 specific rules */ - -* html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;} -* html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;} -* html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;} -* html a.mceButtonNormal, * html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;} -* html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;} -* html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;} -* html .mceSelectList {margin-top: 2px;} -* html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;} -* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative; top: 1px;} -* html a.mceMoreColors {width: auto;} -* html .mceColors td a {width: 10px; height: 10px;} -* html .mceColorPreview {margin-left: 2px; margin-top: 14px;} - -/* MSIE 7 specific rules */ - -*:first-child+html a.mceButtonNormal img, *:first-child+html a.mceButtonSelected img, *:first-child+html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;} -*:first-child+html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;} -*:first-child+html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;} -*:first-child+html a.mceButtonNormal, *:first-child+html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;} -*:first-child+html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;} -*:first-child+html a.mceButtonNormal:hover, *:first-child+html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;} -*:first-child+html .mceSelectList {margin-top: 2px;} -*:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;} -*:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; top: 1px;} -*:first-child+html a.mceMoreColors {width: 137px;} -*:first-child+html .mceColors td a {width: 10px; height: 10px;} -*:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; margin-top: 14px; width: 14px;} diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js index be0e234e..465a8090 100644 --- a/wp-includes/js/tinymce/themes/advanced/editor_template.js +++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js @@ -1,1521 +1 @@ -/** - * $Id: editor_template_src.js 256 2007-04-24 09:03:20Z spocke $ - * - * @author Moxiecode - * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. - */ - -/* Import theme specific language pack */ -tinyMCE.importThemeLanguagePack('advanced'); - -var TinyMCE_AdvancedTheme = { - // Private theme fields - _defColors : "000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF", - _autoImportCSSClasses : true, - _resizer : {}, - _buttons : [ - // Control id, button img, button title, command, user_interface, value - ['bold', '{$lang_bold_img}', 'lang_bold_desc', 'Bold'], - ['italic', '{$lang_italic_img}', 'lang_italic_desc', 'Italic'], - ['underline', '{$lang_underline_img}', 'lang_underline_desc', 'Underline'], - ['strikethrough', 'strikethrough.gif', 'lang_striketrough_desc', 'Strikethrough'], - ['justifyleft', 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft'], - ['justifycenter', 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter'], - ['justifyright', 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight'], - ['justifyfull', 'justifyfull.gif', 'lang_justifyfull_desc', 'JustifyFull'], - ['bullist', 'bullist.gif', 'lang_bullist_desc', 'InsertUnorderedList'], - ['numlist', 'numlist.gif', 'lang_numlist_desc', 'InsertOrderedList'], - ['outdent', 'outdent.gif', 'lang_outdent_desc', 'Outdent'], - ['indent', 'indent.gif', 'lang_indent_desc', 'Indent'], - ['cut', 'cut.gif', 'lang_cut_desc', 'Cut'], - ['copy', 'copy.gif', 'lang_copy_desc', 'Copy'], - ['paste', 'paste.gif', 'lang_paste_desc', 'Paste'], - ['undo', 'undo.gif', 'lang_undo_desc', 'Undo'], - ['redo', 'redo.gif', 'lang_redo_desc', 'Redo'], - ['link', 'link.gif', 'lang_link_desc', 'mceLink', true], - ['unlink', 'unlink.gif', 'lang_unlink_desc', 'unlink'], - ['image', 'image.gif', 'lang_image_desc', 'mceImage', true], - ['cleanup', 'cleanup.gif', 'lang_cleanup_desc', 'mceCleanup'], - ['help', 'help.gif', 'lang_help_desc', 'mceHelp'], - ['code', 'code.gif', 'lang_theme_code_desc', 'mceCodeEditor'], - ['hr', 'hr.gif', 'lang_theme_hr_desc', 'inserthorizontalrule'], - ['removeformat', 'removeformat.gif', 'lang_theme_removeformat_desc', 'removeformat'], - ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'], - ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'], - ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true], - ['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true], - ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true], - ['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', true], - ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'], - ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'], - ['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'], - ['newdocument', 'newdocument.gif', 'lang_newdocument_desc', 'mceNewDocument'] - ], - - _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells,delete_table', - - /** - * Returns HTML code for the specificed control. - */ - getControlHTML : function(button_name) { - var i, x, but; - - // Lookup button in button list - for (i=0; i 4 ? but[4] : false), (but.length > 5 ? but[5] : null)); - - if (but[0] == button_name) - return tinyMCE.getButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null)); - } - - // Custom controlls other than buttons - switch (button_name) { - case "formatselect": - var html = ''; - - return html; - - case "styleselect": - return ''; - - case "fontselect": - var fontHTML = ''; - return fontHTML; - - case "fontsizeselect": - return ''; - - case "|": - case "separator": - return ''; - - case "spacer": - return ''; - - case "rowseparator": - return '
    '; - } - - return ""; - }, - - /** - * Theme specific execcommand handling. - */ - execCommand : function(editor_id, element, command, user_interface, value) { - switch (command) { - case 'mceHelp': - tinyMCE.openWindow({ - file : 'about.htm', - width : 480, - height : 380 - }, { - tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion, - tinymce_releasedate : tinyMCE.releaseDate, - inline : "yes" - }); - return true; - - case "mceLink": - var inst = tinyMCE.getInstanceById(editor_id); - var doc = inst.getDoc(); - var selectedText = ""; - - if (tinyMCE.isMSIE) { - var rng = doc.selection.createRange(); - selectedText = rng.text; - } else - selectedText = inst.getSel().toString(); - - if (!tinyMCE.linkElement) { - if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) - return true; - } - - var href = "", target = "", title = "", onclick = "", action = "insert", style_class = ""; - - if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") - tinyMCE.linkElement = tinyMCE.selectedElement; - - // Is anchor not a link - if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "") - tinyMCE.linkElement = null; - - if (tinyMCE.linkElement) { - href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href'); - target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target'); - title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title'); - onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); - style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class'); - - // Try old onclick to if copy/pasted content - if (onclick == "") - onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); - - onclick = tinyMCE.cleanupEventStr(onclick); - - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); - - // Use mce_href if defined - mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href'); - if (mceRealHref != "") { - href = mceRealHref; - - if (tinyMCE.getParam('convert_urls')) - href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); - } - - action = "update"; - } - - var template = new Array(); - - template['file'] = 'link.htm'; - template['width'] = 310; - template['height'] = 200; - - // Language specific width and height addons - template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0); - - if (inst.settings['insertlink_callback']) { - var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);"); - if (returnVal && returnVal['href']) - TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']); - } else { - tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"}); - } - - return true; - - case "mceImage": - var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = ""; - var title = "", onmouseover = "", onmouseout = "", action = "insert"; - var img = tinyMCE.imgElement; - var inst = tinyMCE.getInstanceById(editor_id); - - if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { - img = tinyMCE.selectedElement; - tinyMCE.imgElement = img; - } - - if (img) { - // Is it a internal MCE visual aid image, then skip this one. - if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0) - return true; - - src = tinyMCE.getAttrib(img, 'src'); - alt = tinyMCE.getAttrib(img, 'alt'); - - // Try polling out the title - if (alt == "") - alt = tinyMCE.getAttrib(img, 'title'); - - // Fix width/height attributes if the styles is specified - if (tinyMCE.isGecko) { - var w = img.style.width; - if (w != null && w != "") - img.setAttribute("width", w); - - var h = img.style.height; - if (h != null && h != "") - img.setAttribute("height", h); - } - - border = tinyMCE.getAttrib(img, 'border'); - hspace = tinyMCE.getAttrib(img, 'hspace'); - vspace = tinyMCE.getAttrib(img, 'vspace'); - width = tinyMCE.getAttrib(img, 'width'); - height = tinyMCE.getAttrib(img, 'height'); - align = tinyMCE.getAttrib(img, 'align'); - onmouseover = tinyMCE.getAttrib(img, 'onmouseover'); - onmouseout = tinyMCE.getAttrib(img, 'onmouseout'); - title = tinyMCE.getAttrib(img, 'title'); - - // Is realy specified? - if (tinyMCE.isMSIE) { - width = img.attributes['width'].specified ? width : ""; - height = img.attributes['height'].specified ? height : ""; - } - - //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover)); - //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout)); - - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); - - // Use mce_src if defined - mceRealSrc = tinyMCE.getAttrib(img, 'mce_src'); - if (mceRealSrc != "") { - src = mceRealSrc; - - if (tinyMCE.getParam('convert_urls')) - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); - } - - //if (onmouseover != "") - // onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);"); - - //if (onmouseout != "") - // onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);"); - - action = "update"; - } - - var template = new Array(); - - template['file'] = 'image.htm?src={$src}'; - template['width'] = 355; - template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0); - - // Language specific width and height addons - template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0); - - if (inst.settings['insertimage_callback']) { - var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);"); - if (returnVal && returnVal['src']) - TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']); - } else - tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"}); - - return true; - - case "forecolor": - var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm; - - TinyMCE_AdvancedTheme._hideMenus(editor_id); - - if (!fcp.exists()) { - fcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar')); - elm = fcp.getElement(); - elm._editor_id = editor_id; - elm._command = "forecolor"; - elm._switchId = editor_id + "_forecolor"; - tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent); - tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent); - tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent); - } - - img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0]; - p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); - - fcp.moveTo(p.absLeft, p.absTop); - fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor; - fcp.show(); - - return false; - - case "forecolorpicker": - this._pickColor(editor_id, 'forecolor'); - return true; - - case "forecolorMenu": - TinyMCE_AdvancedTheme._hideMenus(editor_id); - - // Create color layer - var ml = new TinyMCE_Layer(editor_id + '_fcMenu'); - - if (!ml.exists()) - ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor')); - - tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus'); - ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl'); - - ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); - - if (tinyMCE.isOpera) - ml.moveBy(0, -2); - - ml.show(); - return true; - - case "HiliteColor": - var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img; - - TinyMCE_AdvancedTheme._hideMenus(editor_id); - - if (!bcp.exists()) { - bcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar')); - elm = bcp.getElement(); - elm._editor_id = editor_id; - elm._command = "HiliteColor"; - elm._switchId = editor_id + "_backcolor"; - tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent); - tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent); - tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent); - } - - img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0]; - p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); - - bcp.moveTo(p.absLeft, p.absTop); - bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor; - bcp.show(); - - return false; - - case "HiliteColorMenu": - TinyMCE_AdvancedTheme._hideMenus(editor_id); - - // Create color layer - var ml = new TinyMCE_Layer(editor_id + '_bcMenu'); - - if (!ml.exists()) - ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor')); - - tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus'); - ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl'); - - ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); - - if (tinyMCE.isOpera) - ml.moveBy(0, -2); - - ml.show(); - return true; - - case "backcolorpicker": - this._pickColor(editor_id, 'HiliteColor'); - return true; - - case "mceColorPicker": - if (user_interface) { - var template = []; - - if (!value['callback'] && !value['color']) - value['color'] = value['document'].getElementById(value['element_id']).value; - - template['file'] = 'color_picker.htm'; - template['width'] = 380; - template['height'] = 250; - template['close_previous'] = "no"; - - template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0); - - if (typeof(value['store_selection']) == "undefined") - value['store_selection'] = true; - - tinyMCE.lastColorPickerValue = value; - tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']}); - } else { - var savedVal = tinyMCE.lastColorPickerValue, elm; - - if (savedVal['callback']) { - savedVal['callback'](value); - return true; - } - - elm = savedVal['document'].getElementById(savedVal['element_id']); - elm.value = value; - - if (elm.onchange != null && elm.onchange != '') - eval('elm.onchange();'); - } - return true; - - case "mceCodeEditor": - var template = new Array(); - - template['file'] = 'source_editor.htm'; - template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720)); - template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580)); - - tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"}); - return true; - - case "mceCharMap": - var template = new Array(); - - template['file'] = 'charmap.htm'; - template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0); - template['height'] = 250; - - template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0); - - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; - - case "mceInsertAnchor": - var template = new Array(); - - template['file'] = 'anchor.htm'; - template['width'] = 320; - template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0); - - template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0); - - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; - - case "mceNewDocument": - if (confirm(tinyMCE.getLang('lang_newdocument'))) - tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' '); - - return true; - } - - return false; - }, - - /** - * Editor instance template function. - */ - getEditorTemplate : function(settings, editorId) { - function removeFromArray(in_array, remove_array) { - var outArray = new Array(), skip; - - for (var i=0; i 

    '; - var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout"); - - // Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY! - var styleSelectHTML = ''; - if (settings['theme_advanced_styles']) { - var stylesAr = settings['theme_advanced_styles'].split(';'); - - for (var i=0; i' + key + ''; - } - - TinyMCE_AdvancedTheme._autoImportCSSClasses = false; - } - - switch(layoutManager) { - case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)... - var toolbarHTML = ""; - var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom"); - var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center"); - var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity - var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation); - var defVals = { - theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect", - theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code", - theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap" - }; - - // Add accessibility control - toolbarHTML += ' 0) { - toolbarHTML += "
    "; - deltaHeight -= 23; - } - } - - // Add accessibility control - toolbarHTML += '
    '; - - // Setup template html - template['html'] = '
    {$lang_theme_charmap_title}{#advanced_dlg.charmap_title}
    - + + - +
    - + - +
      
      
    '; - - if (toolbarLocation == "top") - template['html'] += ''; - - if (statusbarLocation == "top") { - template['html'] += ''; - deltaHeight -= 23; - } - - template['html'] += ''; - - if (toolbarLocation == "bottom") - template['html'] += ''; - - // External toolbar changes - if (toolbarLocation == "external") { - var bod = document.body; - var elm = document.createElement ("div"); - - toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML); - toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId}); - - elm.className = "mceToolbarExternal"; - elm.id = editorId+"_toolbar"; - elm.innerHTML = '
    ' + toolbarHTML + '
    ' + statusbarHTML + '
    ' + toolbarHTML + '
    '+toolbarHTML+'
    '; - bod.appendChild (elm); - // bod.style.marginTop = elm.offsetHeight + "px"; - - deltaHeight = 0; - tinyMCE.getInstanceById(editorId).toolbarElement = elm; - - //template['html'] = '
    '+toolbarHTML+'
    ' + template["html"]; - } else { - tinyMCE.getInstanceById(editorId).toolbarElement = null; - } - - if (statusbarLocation == "bottom") { - template['html'] += '' + statusbarHTML + ''; - deltaHeight -= 23; - } - - template['html'] += ''; - //"SimpleLayout" - break; - - case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom. - template['html'] = ''; - - var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ","); - var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container"); - var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center"); - - //Render Containers: - for (var i = 0; i < containers.length; i++) - { - if (containers[i] == "mceEditor") //Exceptions for mceEditor and ... - template['html'] += ''; - else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath: - { - var pathClass = "mceStatusbar"; - - if (i == containers.length-1) - { - pathClass = "mceStatusbarBottom"; - } - else if (i == 0) - { - pathClass = "mceStatusbar"; - } - else - { - deltaHeight-=2; - } - - template['html'] += ''; - deltaHeight -= 22; - } else { // Render normal Container - var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ','); - var curContainerHTML = ""; - var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign); - var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS); - - curContainer = removeFromArray(curContainer, tinyMCE.getParam("theme_advanced_disable", "", true, ',')); - - for (var j=0; j 0) { - curContainerHTML += "
    "; - deltaHeight -= 23; - } - - template['html'] += '
    '; - } - } - - template['html'] += '
    ' + statusbarHTML + '
    ' + curContainerHTML + '
    '; - //RowLayout - break; - - case "CustomLayout" : //User defined layout callback... - var customLayout = tinyMCE.getParam("theme_advanced_custom_layout",""); - - if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") { - template = eval(customLayout + "(template);"); - } - break; - } - - if (resizing) - template['html'] += ''; - - template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML); - - // Set to default values - if (!template['delta_width']) - template['delta_width'] = 0; - - if (!template['delta_height']) - template['delta_height'] = deltaHeight; - - return template; - }, - - initInstance : function(inst) { - if (tinyMCE.getParam("theme_advanced_resizing", false)) { - if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) { - var w = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_width"); - var h = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height"); - - TinyMCE_AdvancedTheme._resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true)); - } - } - - inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink'); - }, - - removeInstance : function(inst) { - new TinyMCE_Layer(inst.editorId + '_fcMenu').remove(); - new TinyMCE_Layer(inst.editorId + '_bcMenu').remove(); - }, - - hideInstance : function(inst) { - TinyMCE_AdvancedTheme._hideMenus(inst.editorId); - }, - - _handleMenuEvent : function(e) { - var te = tinyMCE.isMSIE ? window.event.srcElement : e.target; - tinyMCE._menuButtonEvent(e.type == "mouseover" ? "over" : "out", document.getElementById(te._switchId)); - - if (e.type == "click") - tinyMCE.execInstanceCommand(te._editor_id, te._command); - }, - - _hideMenus : function(id) { - var fcml = new TinyMCE_Layer(id + '_fcMenu'), bcml = new TinyMCE_Layer(id + '_bcMenu'); - - if (fcml.exists() && fcml.isVisible()) { - tinyMCE.switchClass(id + '_forecolor', 'mceMenuButton'); - fcml.hide(); - } - - if (bcml.exists() && bcml.isVisible()) { - tinyMCE.switchClass(id + '_backcolor', 'mceMenuButton'); - bcml.hide(); - } - }, - - /** - * Node change handler. - */ - handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) { - var alignNode, breakOut, classNode; - - function selectByValue(select_elm, value, first_index) { - first_index = typeof(first_index) == "undefined" ? false : true; - - if (select_elm) { - for (var i=0; i=0; i--) { - var nodeName = path[i].nodeName.toLowerCase(); - var nodeData = ""; - - if (nodeName.indexOf("html:") == 0) - nodeName = nodeName.substring(5); - - if (nodeName == "b") { - nodeName = "strong"; - } - - if (nodeName == "i") { - nodeName = "em"; - } - - if (nodeName == "span") { - var cn = tinyMCE.getAttrib(path[i], "class"); - if (cn != "" && cn.indexOf('mceItem') == -1) - nodeData += "class: " + cn + " "; - - var st = tinyMCE.getAttrib(path[i], "style"); - if (st != "") { - st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st)); - nodeData += "style: " + tinyMCE.xmlEncode(st) + " "; - } - } - - if (nodeName == "font") { - if (tinyMCE.getParam("convert_fonts_to_spans")) - nodeName = "span"; - - var face = tinyMCE.getAttrib(path[i], "face"); - if (face != "") - nodeData += "font: " + tinyMCE.xmlEncode(face) + " "; - - var size = tinyMCE.getAttrib(path[i], "size"); - if (size != "") - nodeData += "size: " + tinyMCE.xmlEncode(size) + " "; - - var color = tinyMCE.getAttrib(path[i], "color"); - if (color != "") - nodeData += "color: " + tinyMCE.xmlEncode(color) + " "; - } - - if (tinyMCE.getAttrib(path[i], 'id') != "") { - nodeData += "id: " + path[i].getAttribute('id') + " "; - } - - var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); - if (className != "" && className.indexOf('mceItem') == -1) - nodeData += "class: " + className + " "; - - if (tinyMCE.getAttrib(path[i], 'src') != "") { - var src = tinyMCE.getAttrib(path[i], "mce_src"); - - if (src == "") - src = tinyMCE.getAttrib(path[i], "src"); - - nodeData += "src: " + tinyMCE.xmlEncode(src) + " "; - } - - if (path[i].nodeName == 'A' && tinyMCE.getAttrib(path[i], 'href') != "") { - var href = tinyMCE.getAttrib(path[i], "mce_href"); - - if (href == "") - href = tinyMCE.getAttrib(path[i], "href"); - - nodeData += "href: " + tinyMCE.xmlEncode(href) + " "; - } - - className = tinyMCE.getAttrib(path[i], "class"); - if ((nodeName == "img" || nodeName == "span") && className.indexOf('mceItem') != -1) { - nodeName = className.replace(/mceItem([a-z]+)/gi, '$1').toLowerCase(); - nodeData = path[i].getAttribute('title'); - } - - if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") { - nodeName = "a"; - nodeName += "#" + tinyMCE.xmlEncode(anchor); - nodeData = ""; - } - - if (tinyMCE.getAttrib(path[i], 'name').indexOf("mce_") != 0) { - var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); - if (className != "" && className.indexOf('mceItem') == -1) { - nodeName += "." + className; - } - } - - var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');'; - html += '' + nodeName + ''; - - if (i > 0) { - html += " » "; - } - } - - pathElm.innerHTML = '' + tinyMCE.getLang('lang_theme_path') + ": " + html + ' '; - } - - // Reset old states - tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_bold', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_italic', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_underline', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_strikethrough', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_sub', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_sup', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_link', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_unlink', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_image', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_hr', 'mceButtonNormal'); - - if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1) - tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonSelected'); - - // Get link - var anchorLink = tinyMCE.getParentElement(node, "a", "href"); - - if (anchorLink || any_selection) { - tinyMCE.switchClass(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal'); - } - - // Handle visual aid - tinyMCE.switchClass(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal'); - - if (undo_levels != -1) { - tinyMCE.switchClass(editor_id + '_undo', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_redo', 'mceButtonDisabled'); - } - - // Within li, blockquote - if (tinyMCE.getParentElement(node, "li,blockquote")) - tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonNormal'); - - // Has redo levels - if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0)) - tinyMCE.switchClass(editor_id + '_redo', 'mceButtonNormal'); - - // Has undo levels - if (undo_index != -1 && (undo_index > 0 && undo_levels > 0)) - tinyMCE.switchClass(editor_id + '_undo', 'mceButtonNormal'); - - // Select class in select box - var selectElm = document.getElementById(editor_id + "_styleSelect"); - - if (selectElm) { - TinyMCE_AdvancedTheme._setupCSSClasses(editor_id); - - classNode = node; - breakOut = false; - var index = 0; - - do { - if (classNode && classNode.className) { - for (var i=0; i"); - else - selectByValue(selectElm, ""); - } - - // Select fontselect - var selectElm = document.getElementById(editor_id + "_fontNameSelect"); - if (selectElm) { - if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) { - var face = inst.queryCommandValue('FontName'); - - face = face == null || face == "" ? "" : face; - - selectByValue(selectElm, face, face != ""); - } else { - var elm = tinyMCE.getParentElement(node, "font", "face"); - - if (elm) { - var family = tinyMCE.getAttrib(elm, "face"); - - if (family == '') - family = '' + elm.style.fontFamily; - - if (!selectByValue(selectElm, family, family != "")) - selectByValue(selectElm, ""); - } else - selectByValue(selectElm, ""); - } - } - - // Select fontsize - var selectElm = document.getElementById(editor_id + "_fontSizeSelect"); - if (selectElm) { - if (!tinyMCE.isSafari && !tinyMCE.isOpera) { - var size = inst.queryCommandValue('FontSize'); - selectByValue(selectElm, size == null || size == "" ? "0" : size); - } else { - var elm = tinyMCE.getParentElement(node, "font", "size"); - if (elm) { - var size = tinyMCE.getAttrib(elm, "size"); - - if (size == '') { - var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px'); - - size = '' + elm.style.fontSize; - - for (var i=0; i 0) - selectElm.setAttribute('cssImported', 'true'); - } - }, - - _setCookie : function(name, value, expires, path, domain, secure) { - var curCookie = name + "=" + escape(value) + - ((expires) ? "; expires=" + expires.toGMTString() : "") + - ((path) ? "; path=" + escape(path) : "") + - ((domain) ? "; domain=" + domain : "") + - ((secure) ? "; secure" : ""); - - document.cookie = curCookie; - }, - - _getCookie : function(name) { - var dc = document.cookie; - var prefix = name + "="; - var begin = dc.indexOf("; " + prefix); - - if (begin == -1) { - begin = dc.indexOf(prefix); - - if (begin != 0) - return null; - } else - begin += 2; - - var end = document.cookie.indexOf(";", begin); - - if (end == -1) - end = dc.length; - - return unescape(dc.substring(begin + prefix.length, end)); - }, - - _resizeTo : function(inst, w, h, set_w) { - var editorContainer = document.getElementById(inst.editorId + '_parent'); - var tableElm = editorContainer.firstChild; - var iframe = inst.iframeElement; - - if (w == null || w == "null") { - set_w = false; - w = 0; - } - - if (h == null || h == "null") - return; - - w = parseInt(w); - h = parseInt(h); - - if (tinyMCE.isGecko) { - w += 2; - h += 2; - } - - var dx = w - tableElm.clientWidth; - var dy = h - tableElm.clientHeight; - - w = w < 1 ? 30 : w; - h = h < 1 ? 30 : h; - - if (set_w) - tableElm.style.width = w + "px"; - - if ( !tinyMCE.isMSIE || tinyMCE.isMSIE7 || tinyMCE.isOpera ) // WordPress: do this later to avoid creeping toolbar bug in MSIE6 - tableElm.style.height = h + "px"; - - iw = iframe.clientWidth + dx; - ih = iframe.clientHeight + dy; - - iw = iw < 1 ? 30 : iw; - ih = ih < 1 ? 30 : ih; -/* WordPress: found that this led to a shrinking editor with every resize. - (Gray background creeps in 1px at a time.) - if (tinyMCE.isGecko) { - iw -= 2; - ih -= 2; - } -*/ - - if (set_w) - iframe.style.width = iw + "px"; - - iframe.style.height = ih + "px"; - - // Is it to small, make it bigger again - if (set_w) { - var tableBodyElm = tableElm.firstChild; - var minIframeWidth = tableBodyElm.scrollWidth; - if (inst.iframeElement.clientWidth < minIframeWidth) { - dx = minIframeWidth - inst.iframeElement.clientWidth; - - inst.iframeElement.style.width = (iw + dx) + "px"; - } - } - - tableElm.style.height = h + "px"; // WordPress: see above - - // Remove pesky table controls - inst.useCSS = false; - }, - - /** - * Handles resizing events. - */ - _resizeEventHandler : function(e) { - var resizer = TinyMCE_AdvancedTheme._resizer; - - // Do nothing - if (!resizer.resizing) - return; - - e = typeof(e) == "undefined" ? window.event : e; - - var dx = e.screenX - resizer.downX; - var dy = e.screenY - resizer.downY; - var resizeBox = resizer.resizeBox; - var editorId = resizer.editorId; - - switch (e.type) { - case "mousemove": - var w, h; - - w = resizer.width + dx; - h = resizer.height + dy; - - w = w < 1 ? 1 : w; - h = h < 1 ? 1 : h; - - if (resizer.horizontal) - resizeBox.style.width = w + "px"; - - resizeBox.style.height = h + "px"; - break; - - case "mouseup": - TinyMCE_AdvancedTheme._setResizing(e, editorId, false); - TinyMCE_AdvancedTheme._resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal); - - // Expire in a month - if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) { - var expires = new Date(); - expires.setTime(expires.getTime() + 3600000 * 24 * 30); - - // Set the cookies - TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires); - TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires); - } - break; - } - }, - - /** - * Starts/stops the editor resizing. - */ - _setResizing : function(e, editor_id, state) { - e = typeof(e) == "undefined" ? window.event : e; - - var resizer = TinyMCE_AdvancedTheme._resizer; - var editorContainer = document.getElementById(editor_id + '_parent'); - var editorArea = document.getElementById(editor_id + '_parent').firstChild; - var resizeBox = document.getElementById(editor_id + '_resize_box'); - var inst = tinyMCE.getInstanceById(editor_id); - - if (state) { - // Place box over editor area - var width = editorArea.clientWidth; - var height = editorArea.clientHeight; - - resizeBox.style.width = width + "px"; - resizeBox.style.height = height + "px"; - - resizer.iframeWidth = inst.iframeElement.clientWidth; - resizer.iframeHeight = inst.iframeElement.clientHeight; - - // Hide editor and show resize box - editorArea.style.display = "none"; - resizeBox.style.display = "block"; - - // Add event handlers, only once - if (!resizer.eventHandlers) { - if (tinyMCE.isMSIE) - tinyMCE.addEvent(document, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler); - else - tinyMCE.addEvent(window, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler); - - tinyMCE.addEvent(document, "mouseup", TinyMCE_AdvancedTheme._resizeEventHandler); - - resizer.eventHandlers = true; - } - - resizer.resizing = true; - resizer.downX = e.screenX; - resizer.downY = e.screenY; - resizer.width = parseInt(resizeBox.style.width); - resizer.height = parseInt(resizeBox.style.height); - resizer.editorId = editor_id; - resizer.resizeBox = resizeBox; - resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true); - } else { - resizer.resizing = false; - resizeBox.style.display = "none"; - editorArea.style.display = tinyMCE.isMSIE && !tinyMCE.isOpera ? "block" : "table"; - tinyMCE.execCommand('mceResetDesignMode'); - } - }, - - _getColorHTML : function(id, n, cm) { - var i, h, cl; - - h = ''; - cl = tinyMCE.getParam(n, TinyMCE_AdvancedTheme._defColors).split(','); - - h += ''; - for (i=0; i'; - - if ((i+1) % 8 == 0) - h += ''; - } - - h += '
    '; - - if (tinyMCE.getParam("theme_advanced_more_colors", true)) - h += '' + tinyMCE.getLang('lang_more_colors') + ''; - - return h; - }, - - _pickColor : function(id, cm) { - var inputColor, inst = tinyMCE.selectedInstance; - - if (cm == 'forecolor' && inst) - inputColor = inst.foreColor; - - if ((cm == 'backcolor' || cm == 'HiliteColor') && inst) - inputColor = inst.backColor; - - tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) { - tinyMCE.execInstanceCommand(id, cm, false, c); - }}); - }, - - _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) { - tinyMCE.execCommand("mceInsertContent", false, tinyMCE.createTagHTML('img', { - src : tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src), // Force absolute - mce_src : src, - alt : alt, - border : border, - hspace : hspace, - vspace : vspace, - width : width, - height : height, - align : align, - title : title, - onmouseover : onmouseover, - onmouseout : onmouseout - })); - }, - - _insertLink : function(href, target, title, onclick, style_class) { - tinyMCE.execCommand('mceBeginUndoLevel'); - - if (tinyMCE.selectedInstance && tinyMCE.selectedElement && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { - var doc = tinyMCE.selectedInstance.getDoc(); - var linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a"); - var newLink = false; - - if (!linkElement) { - linkElement = doc.createElement("a"); - newLink = true; - } - - var mhref = href; - var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);"); - mhref = tinyMCE.getParam('convert_urls') ? href : mhref; - - tinyMCE.setAttrib(linkElement, 'href', thref); - tinyMCE.setAttrib(linkElement, 'mce_href', mhref); - tinyMCE.setAttrib(linkElement, 'target', target); - tinyMCE.setAttrib(linkElement, 'title', title); - tinyMCE.setAttrib(linkElement, 'onclick', onclick); - tinyMCE.setAttrib(linkElement, 'class', style_class); - - if (newLink) { - linkElement.appendChild(tinyMCE.selectedElement.cloneNode(true)); - tinyMCE.selectedElement.parentNode.replaceChild(linkElement, tinyMCE.selectedElement); - } - - return; - } - - if (!tinyMCE.linkElement && tinyMCE.selectedInstance) { - if (tinyMCE.isSafari) { - tinyMCE.execCommand("mceInsertContent", false, '' + tinyMCE.selectedInstance.selection.getSelectedHTML() + ''); - } else - tinyMCE.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL); - - tinyMCE.linkElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); - - var elementArray = tinyMCE.getElementsByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); - - for (var i=0; i'),'focus',function(){tinyMCE.get(ed.id).focus();});if(s.theme_advanced_toolbar_location=='external')o.deltaHeight=0;t.deltaHeight=o.deltaHeight;o.targetNode=null;return{iframeContainer:ic,editorContainer:ed.id+'_parent',sizeContainer:sc,deltaHeight:o.deltaHeight};},getInfo:function(){return{longname:'Advanced theme',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',version:tinymce.majorVersion+"."+tinymce.minorVersion}},resizeBy:function(dw,dh){var e=DOM.get(this.editor.id+'_tbl');this.resizeTo(e.clientWidth+dw,e.clientHeight+dh);},resizeTo:function(w,h){var ed=this.editor,s=ed.settings,e=DOM.get(ed.id+'_tbl'),ifr=DOM.get(ed.id+'_ifr'),dh;w=Math.max(s.theme_advanced_resizing_min_width||100,w);h=Math.max(s.theme_advanced_resizing_min_height||100,h);w=Math.min(s.theme_advanced_resizing_max_width||0xFFFF,w);h=Math.min(s.theme_advanced_resizing_max_height||0xFFFF,h);dh=e.clientHeight-ifr.clientHeight;DOM.setStyle(ifr,'height',h-dh);DOM.setStyles(e,{width:w,height:h});},destroy:function(){var id=this.editor.id;Event.clear(id+'_resize');Event.clear(id+'_path_row');Event.clear(id+'_external_close');},_simpleLayout:function(s,tb,o,p){var t=this,ed=t.editor,lo=s.theme_advanced_toolbar_location,sl=s.theme_advanced_statusbar_location,n,ic,etb,c;if(lo=='top')t._addToolbars(tb,o);if(lo=='external'){n=c=DOM.create('div',{style:'position:relative'});n=DOM.add(n,'div',{id:ed.id+'_external','class':'mceExternalToolbar'});DOM.add(n,'a',{id:ed.id+'_external_close',href:'javascript:;','class':'mceExternalClose'});n=DOM.add(n,'table',{id:ed.id+'_tblext',cellSpacing:0,cellPadding:0});etb=DOM.add(n,'tbody');if(p.firstChild.className=='mceOldBoxModel')p.firstChild.appendChild(c);else p.insertBefore(c,p.firstChild);t._addToolbars(etb,o);ed.onMouseUp.add(function(){var e=DOM.get(ed.id+'_external');DOM.show(e);DOM.hide(lastExtID);var f=Event.add(ed.id+'_external_close','click',function(){DOM.hide(ed.id+'_external');Event.remove(ed.id+'_external_close','click',f);});DOM.show(e);DOM.setStyle(e,'top',0-DOM.getRect(ed.id+'_tblext').h-1);DOM.hide(e);DOM.show(e);e.style.filter='';lastExtID=ed.id+'_external';e=null;});}if(sl=='top')t._addStatusBar(tb,o);if(!s.theme_advanced_toolbar_container){n=DOM.add(tb,'tr');n=ic=DOM.add(n,'td',{'class':'mceIframeContainer'});}if(lo=='bottom')t._addToolbars(tb,o);if(sl=='bottom')t._addStatusBar(tb,o);return ic;},_rowLayout:function(s,tb,o){var t=this,ed=t.editor,dc,da,cf=ed.controlManager,n,ic,to,a;dc=s.theme_advanced_containers_default_class||'';da=s.theme_advanced_containers_default_align||'center';each(explode(s.theme_advanced_containers||''),function(c,i){var v=s['theme_advanced_container_'+c]||'';switch(c.toLowerCase()){case'mceeditor':n=DOM.add(tb,'tr');n=ic=DOM.add(n,'td',{'class':'mceIframeContainer'});break;case'mceelementpath':t._addStatusBar(tb,o);break;default:a=s['theme_advanced_container_'+c+'_align'].toLowerCase();a='mce'+t._ufirst(a);n=DOM.add(DOM.add(tb,'tr'),'td',{'class':'mceToolbar '+(s['theme_advanced_container_'+c+'_class']||dc)+' '+a||da});to=cf.createToolbar("toolbar"+i);t._addControls(v,to);DOM.setHTML(n,to.renderHTML());o.deltaHeight-=s.theme_advanced_row_height;}});return ic;},_addControls:function(v,tb){var t=this,s=t.settings,di,cf=t.editor.controlManager;if(s.theme_advanced_disable&&!t._disabled){di={};each(explode(s.theme_advanced_disable),function(v){di[v]=1;});t._disabled=di;}else di=t._disabled;each(explode(v),function(n){var c;if(di&&di[n])return;if(n=='tablecontrols'){each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"],function(n){n=t.createControl(n,cf);if(n)tb.add(n);});return;}c=t.createControl(n,cf);if(c)tb.add(c);});},_addToolbars:function(c,o){var t=this,i,tb,ed=t.editor,s=t.settings,v,cf=ed.controlManager,di,n,h=[],a;a=s.theme_advanced_toolbar_align.toLowerCase();a='mce'+t._ufirst(a);n=DOM.add(DOM.add(c,'tr'),'td',{'class':'mceToolbar '+a});if(!ed.getParam('accessibility_focus')||ed.getParam('tab_focus'))h.push(DOM.createHTML('a',{href:'#',onfocus:'tinyMCE.get(\''+ed.id+'\').focus();'},''));h.push(DOM.createHTML('a',{href:'#',accesskey:'q',title:ed.getLang("advanced.toolbar_focus")},''));for(i=1;(v=s['theme_advanced_buttons'+i]);i++){tb=cf.createToolbar("toolbar"+i,{'class':'mceToolbarRow'+i});if(s['theme_advanced_buttons'+i+'_add'])v+=','+s['theme_advanced_buttons'+i+'_add'];if(s['theme_advanced_buttons'+i+'_add_before'])v=s['theme_advanced_buttons'+i+'_add_before']+','+v;t._addControls(v,tb);h.push(tb.renderHTML());o.deltaHeight-=s.theme_advanced_row_height;}h.push(DOM.createHTML('a',{href:'#',accesskey:'z',title:ed.getLang("advanced.toolbar_focus"),onfocus:'tinyMCE.getInstanceById(\''+ed.id+'\').focus();'},''));DOM.setHTML(n,h.join(''));},_addStatusBar:function(tb,o){var n,t=this,ed=t.editor,s=t.settings,r,mf,me,td;n=DOM.add(tb,'tr');n=td=DOM.add(n,'td',{'class':'mceStatusbar'});n=DOM.add(n,'div',{id:ed.id+'_path_row'},s.theme_advanced_path?ed.translate('advanced.path')+': ':' ');DOM.add(n,'a',{href:'#',accesskey:'x'});if(s.theme_advanced_resizing&&!tinymce.isOldWebKit){DOM.add(td,'a',{id:ed.id+'_resize',href:'javascript:;',onclick:"return false;",'class':'mceResize'});if(s.theme_advanced_resizing_use_cookie){ed.onPostRender.add(function(){var o=Cookie.getHash("TinyMCE_"+ed.id+"_size"),c=DOM.get(ed.id+'_tbl');if(!o)return;if(s.theme_advanced_resize_horizontal)c.style.width=Math.max(10,o.cw)+'px';c.style.height=Math.max(10,o.ch)+'px';DOM.get(ed.id+'_ifr').style.height=Math.max(10,parseInt(o.ch)+t.deltaHeight)+'px';});}ed.onPostRender.add(function(){Event.add(ed.id+'_resize','mousedown',function(e){var c,p,w,h,n,pa;c=DOM.get(ed.id+'_tbl');w=c.clientWidth;h=c.clientHeight;miw=s.theme_advanced_resizing_min_width||100;mih=s.theme_advanced_resizing_min_height||100;maw=s.theme_advanced_resizing_max_width||0xFFFF;mah=s.theme_advanced_resizing_max_height||0xFFFF;p=DOM.add(DOM.get(ed.id+'_parent'),'div',{'class':'mcePlaceHolder'});DOM.setStyles(p,{width:w,height:h});DOM.hide(c);DOM.show(p);r={x:e.screenX,y:e.screenY,w:w,h:h,dx:null,dy:null};mf=Event.add(DOM.doc,'mousemove',function(e){var w,h;r.dx=e.screenX-r.x;r.dy=e.screenY-r.y;w=Math.max(miw,r.w+r.dx);h=Math.max(mih,r.h+r.dy);w=Math.min(maw,w);h=Math.min(mah,h);if(s.theme_advanced_resize_horizontal)p.style.width=w+'px';p.style.height=h+'px';return Event.cancel(e);});me=Event.add(DOM.doc,'mouseup',function(e){var ifr;Event.remove(DOM.doc,'mousemove',mf);Event.remove(DOM.doc,'mouseup',me);c.style.display='';DOM.remove(p);if(r.dx===null)return;ifr=DOM.get(ed.id+'_ifr');if(s.theme_advanced_resize_horizontal)c.style.width=Math.max(10,r.w+r.dx)+'px';c.style.height=Math.max(10,r.h+r.dy)+'px';ifr.style.height=Math.max(10,ifr.clientHeight+r.dy)+'px';if(s.theme_advanced_resizing_use_cookie){Cookie.setHash("TinyMCE_"+ed.id+"_size",{cw:r.w+r.dx,ch:r.h+r.dy});}});return Event.cancel(e);});});}o.deltaHeight-=21;n=tb=null;},_nodeChanged:function(ed,cm,n,co){var t=this,p,de=0,v,c,s=t.settings;tinymce.each(t.stateControls,function(c){cm.setActive(c,ed.queryCommandState(t.controls[c][1]));});cm.setActive('visualaid',ed.hasVisual);cm.setDisabled('undo',!ed.undoManager.hasUndo()&&!ed.typing);cm.setDisabled('redo',!ed.undoManager.hasRedo());cm.setDisabled('outdent',!ed.queryCommandState('Outdent'));p=DOM.getParent(n,'A');if(c=cm.get('link')){if(!p||!p.name){c.setDisabled(!p&&co);c.setActive(!!p);}}if(c=cm.get('unlink')){c.setDisabled(!p&&co);c.setActive(!!p&&!p.name);}if(c=cm.get('anchor')){c.setActive(!!p&&p.name);if(tinymce.isWebKit){p=DOM.getParent(n,'IMG');c.setActive(!!p&&DOM.getAttrib(p,'mce_name')=='a');}}p=DOM.getParent(n,'IMG');if(c=cm.get('image'))c.setActive(!!p&&n.className.indexOf('mceItem')==-1);if(c=cm.get('styleselect')){if(n.className){t._importClasses();c.select(n.className);}else c.select();}if(c=cm.get('formatselect')){p=DOM.getParent(n,DOM.isBlock);if(p)c.select(p.nodeName.toLowerCase());}if(c=cm.get('fontselect'))c.select(ed.queryCommandValue('FontName'));if(c=cm.get('fontsizeselect'))c.select(ed.queryCommandValue('FontSize'));if(s.theme_advanced_path&&s.theme_advanced_statusbar_location){p=DOM.get(ed.id+'_path')||DOM.add(ed.id+'_path_row','span',{id:ed.id+'_path'});DOM.setHTML(p,'');ed.dom.getParent(n,function(n){var na=n.nodeName.toLowerCase(),u,pi,ti='';if(n.nodeType!=1||(DOM.hasClass(n,'mceItemHidden')||DOM.hasClass(n,'mceItemRemoved')))return;if(v=DOM.getAttrib(n,'mce_name'))na=v;if(tinymce.isIE&&n.scopeName!=='HTML')na=n.scopeName+':'+na;na=na.replace(/mce\:/g,'');switch(na){case'b':na='strong';break;case'i':na='em';break;case'img':if(v=DOM.getAttrib(n,'src'))ti+='src: '+v+' ';break;case'a':if(v=DOM.getAttrib(n,'name')){ti+='name: '+v+' ';na+='#'+v;}if(v=DOM.getAttrib(n,'href'))ti+='href: '+v+' ';break;case'font':if(s.convert_fonts_to_spans)na='span';if(v=DOM.getAttrib(n,'face'))ti+='font: '+v+' ';if(v=DOM.getAttrib(n,'size'))ti+='size: '+v+' ';if(v=DOM.getAttrib(n,'color'))ti+='color: '+v+' ';break;case'span':if(v=DOM.getAttrib(n,'style'))ti+='style: '+v+' ';break;}if(v=DOM.getAttrib(n,'id'))ti+='id: '+v+' ';if(v=n.className){v=v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g,'');if(v&&v.indexOf('mceItem')==-1){ti+='class: '+v+' ';if(DOM.isBlock(n)||na=='img'||na=='span')na+='.'+v;}}na=na.replace(/(html:)/g,'');na={name:na,node:n,title:ti};t.onResolveName.dispatch(t,na);ti=na.title;na=na.name;pi=DOM.create('a',{'href':"javascript:;",onmousedown:"return false;",title:ti,'class':'mcePath_'+(de++)},na);if(p.hasChildNodes()){p.insertBefore(DOM.doc.createTextNode(' \u00bb '),p.firstChild);p.insertBefore(pi,p.firstChild);}else p.appendChild(pi);},ed.getBody());}},_sel:function(v){this.editor.execCommand('mceSelectNodeDepth',false,v);},_mceInsertAnchor:function(ui,v){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/anchor.htm',width:320+parseInt(ed.getLang('advanced.anchor_delta_width',0)),height:90+parseInt(ed.getLang('advanced.anchor_delta_height',0)),inline:true},{theme_url:this.url});},_mceCharMap:function(){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/charmap.htm',width:550+parseInt(ed.getLang('advanced.charmap_delta_width',0)),height:250+parseInt(ed.getLang('advanced.charmap_delta_height',0)),inline:true},{theme_url:this.url});},_mceHelp:function(){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/about.htm',width:480,height:380,inline:true},{theme_url:this.url});},_mceColorPicker:function(u,v){var ed=this.editor;v=v||{};ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/color_picker.htm',width:375+parseInt(ed.getLang('advanced.colorpicker_delta_width',0)),height:250+parseInt(ed.getLang('advanced.colorpicker_delta_height',0)),close_previous:false,inline:true},{input_color:v.color,func:v.func,theme_url:this.url});},_mceCodeEditor:function(ui,val){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/source_editor.htm',width:parseInt(ed.getParam("theme_advanced_source_editor_width",720)),height:parseInt(ed.getParam("theme_advanced_source_editor_height",580)),inline:true,resizable:true,maximizable:true},{theme_url:this.url});},_mceImage:function(ui,val){var ed=this.editor;if(ed.dom.getAttrib(ed.selection.getNode(),'class').indexOf('mceItem')!=-1)return;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/image.htm',width:355+parseInt(ed.getLang('advanced.image_delta_width',0)),height:275+parseInt(ed.getLang('advanced.image_delta_height',0)),inline:true},{theme_url:this.url});},_mceLink:function(ui,val){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/link.htm',width:310+parseInt(ed.getLang('advanced.link_delta_width',0)),height:200+parseInt(ed.getLang('advanced.link_delta_height',0)),inline:true},{theme_url:this.url});},_mceNewDocument:function(){var ed=this.editor;ed.windowManager.confirm('advanced.newdocument',function(s){if(s)ed.execCommand('mceSetContent',false,'');});},_mceForeColor:function(){var t=this;this._mceColorPicker(0,{color:t.fgColor,func:function(co){t.fgColor=co;t.editor.execCommand('ForeColor',false,co);}});},_mceBackColor:function(){var t=this;this._mceColorPicker(0,{color:t.bgColor,func:function(co){t.bgColor=co;t.editor.execCommand('HiliteColor',false,co);}});},_ufirst:function(s){return s.substring(0,1).toUpperCase()+s.substring(1);}});tinymce.ThemeManager.add('advanced',tinymce.themes.AdvancedTheme);}()); \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/image.htm b/wp-includes/js/tinymce/themes/advanced/image.htm index bcebfb13..f0bd23c7 100644 --- a/wp-includes/js/tinymce/themes/advanced/image.htm +++ b/wp-includes/js/tinymce/themes/advanced/image.htm @@ -1,18 +1,18 @@ + - {$lang_insert_image_title} - - - - + {#advanced_dlg.image_title} + + + + - - -
    + + @@ -20,81 +20,69 @@
    - + - - - + + + + - + - - + - + - - + + - - + + - - + + + + + +
    - +
     
    x
    -
    - +
    - +
    diff --git a/wp-includes/js/tinymce/themes/advanced/images/anchor.gif b/wp-includes/js/tinymce/themes/advanced/images/anchor.gif deleted file mode 100644 index 34ab7153..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/anchor.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif b/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif deleted file mode 100644 index d03e206a..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold.gif b/wp-includes/js/tinymce/themes/advanced/images/bold.gif deleted file mode 100644 index d6a9cc2c..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_de_se.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_de_se.gif deleted file mode 100644 index 9b129de2..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_de_se.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif deleted file mode 100644 index ea341e60..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_fr.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_fr.gif deleted file mode 100644 index 28164545..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_fr.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_ru.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_ru.gif deleted file mode 100644 index e000d461..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_ru.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif deleted file mode 100644 index 82085432..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/browse.gif b/wp-includes/js/tinymce/themes/advanced/images/browse.gif deleted file mode 100644 index c786d0b2..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/browse.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bullist.gif b/wp-includes/js/tinymce/themes/advanced/images/bullist.gif deleted file mode 100644 index 6e19467c..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/bullist.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif b/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif deleted file mode 100644 index c3d8fa23..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif deleted file mode 100644 index 5ad99a7c..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/cancel_button_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/cancel_button_bg.gif deleted file mode 100644 index 4b4aeefc..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/cancel_button_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/center.gif b/wp-includes/js/tinymce/themes/advanced/images/center.gif deleted file mode 100644 index 42d609a9..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/center.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/charmap.gif b/wp-includes/js/tinymce/themes/advanced/images/charmap.gif deleted file mode 100644 index 3cdc4ac9..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/charmap.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/cleanup.gif b/wp-includes/js/tinymce/themes/advanced/images/cleanup.gif deleted file mode 100644 index 16491f6c..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/cleanup.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/close.gif b/wp-includes/js/tinymce/themes/advanced/images/close.gif deleted file mode 100644 index 679ca2aa..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/close.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/code.gif b/wp-includes/js/tinymce/themes/advanced/images/code.gif deleted file mode 100644 index c5d5a672..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/code.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/color.gif b/wp-includes/js/tinymce/themes/advanced/images/color.gif deleted file mode 100644 index 1ecd5743..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/color.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/copy.gif b/wp-includes/js/tinymce/themes/advanced/images/copy.gif deleted file mode 100644 index dc146865..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/copy.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/custom_1.gif b/wp-includes/js/tinymce/themes/advanced/images/custom_1.gif deleted file mode 100644 index 4cbccdad..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/custom_1.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/cut.gif b/wp-includes/js/tinymce/themes/advanced/images/cut.gif deleted file mode 100644 index 4e9a70b6..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/cut.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif b/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif deleted file mode 100644 index 8b703616..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/full.gif b/wp-includes/js/tinymce/themes/advanced/images/full.gif deleted file mode 100644 index c8504f62..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/full.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/help.gif b/wp-includes/js/tinymce/themes/advanced/images/help.gif deleted file mode 100644 index 51a1ee42..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/help.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/hr.gif b/wp-includes/js/tinymce/themes/advanced/images/hr.gif deleted file mode 100644 index 1a1ba2a0..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/hr.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/image.gif b/wp-includes/js/tinymce/themes/advanced/images/image.gif deleted file mode 100644 index 4b88eddc..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/image.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/indent.gif b/wp-includes/js/tinymce/themes/advanced/images/indent.gif deleted file mode 100644 index acd315bb..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/indent.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/insert_button_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/insert_button_bg.gif deleted file mode 100644 index 69c131ce..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/insert_button_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic.gif b/wp-includes/js/tinymce/themes/advanced/images/italic.gif deleted file mode 100644 index 8bb330bd..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_de_se.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_de_se.gif deleted file mode 100644 index feb0309e..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic_de_se.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif deleted file mode 100644 index 4572cdb1..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_ru.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_ru.gif deleted file mode 100644 index a2bb69a7..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic_ru.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif deleted file mode 100644 index 4f6eeaa2..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif b/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif deleted file mode 100644 index 42d609a9..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif deleted file mode 100644 index c8504f62..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif deleted file mode 100644 index e8f7e427..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif deleted file mode 100644 index e4cea971..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/left.gif b/wp-includes/js/tinymce/themes/advanced/images/left.gif deleted file mode 100644 index e8f7e427..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/left.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/link.gif b/wp-includes/js/tinymce/themes/advanced/images/link.gif deleted file mode 100644 index 1accf426..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/link.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif b/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif deleted file mode 100644 index 50d6afd5..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/newdocument.gif b/wp-includes/js/tinymce/themes/advanced/images/newdocument.gif deleted file mode 100644 index a9d29384..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/newdocument.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/numlist.gif b/wp-includes/js/tinymce/themes/advanced/images/numlist.gif deleted file mode 100644 index a2683522..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/numlist.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/opacity.png b/wp-includes/js/tinymce/themes/advanced/images/opacity.png deleted file mode 100644 index b4217cb2..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/opacity.png and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/outdent.gif b/wp-includes/js/tinymce/themes/advanced/images/outdent.gif deleted file mode 100644 index 23f6aa40..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/outdent.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/paste.gif b/wp-includes/js/tinymce/themes/advanced/images/paste.gif deleted file mode 100644 index 1b45000a..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/paste.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/redo.gif b/wp-includes/js/tinymce/themes/advanced/images/redo.gif deleted file mode 100644 index 3af90697..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/redo.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/removeformat.gif b/wp-includes/js/tinymce/themes/advanced/images/removeformat.gif deleted file mode 100644 index 0fa3cb79..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/removeformat.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/right.gif b/wp-includes/js/tinymce/themes/advanced/images/right.gif deleted file mode 100644 index e4cea971..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/right.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/statusbar_resize.gif b/wp-includes/js/tinymce/themes/advanced/images/statusbar_resize.gif deleted file mode 100644 index af89d803..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/statusbar_resize.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif b/wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif deleted file mode 100644 index 32646359..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/strikethrough.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/sub.gif b/wp-includes/js/tinymce/themes/advanced/images/sub.gif deleted file mode 100644 index 4d7ce30f..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/sub.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/sup.gif b/wp-includes/js/tinymce/themes/advanced/images/sup.gif deleted file mode 100644 index a7145e01..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/sup.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table.gif b/wp-includes/js/tinymce/themes/advanced/images/table.gif deleted file mode 100644 index 2911830c..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_delete_col.gif b/wp-includes/js/tinymce/themes/advanced/images/table_delete_col.gif deleted file mode 100644 index 91f53af0..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_delete_col.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_delete_row.gif b/wp-includes/js/tinymce/themes/advanced/images/table_delete_row.gif deleted file mode 100644 index 7025733f..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_delete_row.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_after.gif b/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_after.gif deleted file mode 100644 index 85058080..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_after.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_before.gif b/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_before.gif deleted file mode 100644 index b669d4fa..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_insert_col_before.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_after.gif b/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_after.gif deleted file mode 100644 index b9c14466..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_after.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_before.gif b/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_before.gif deleted file mode 100644 index 157d3736..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/table_insert_row_before.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline.gif b/wp-includes/js/tinymce/themes/advanced/images/underline.gif deleted file mode 100644 index 1dfeb5f6..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif deleted file mode 100644 index 551d9148..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif deleted file mode 100644 index 551d9148..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline_fr.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif deleted file mode 100644 index b78e2a49..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline_ru.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif deleted file mode 100644 index b7153904..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/undo.gif b/wp-includes/js/tinymce/themes/advanced/images/undo.gif deleted file mode 100644 index 520796d6..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/undo.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/unlink.gif b/wp-includes/js/tinymce/themes/advanced/images/unlink.gif deleted file mode 100644 index 5c8a33db..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/unlink.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/visualaid.gif b/wp-includes/js/tinymce/themes/advanced/images/visualaid.gif deleted file mode 100644 index 63caf180..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/visualaid.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tab_bg.gif deleted file mode 100644 index 897a01f2..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_end.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tab_end.gif deleted file mode 100644 index aee442be..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_end.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_bg.gif deleted file mode 100644 index 9dc8abe1..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_end.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_end.gif deleted file mode 100644 index 616a889d..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tab_sel_end.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/xp/tabs_bg.gif b/wp-includes/js/tinymce/themes/advanced/images/xp/tabs_bg.gif deleted file mode 100644 index c303f66d..00000000 Binary files a/wp-includes/js/tinymce/themes/advanced/images/xp/tabs_bg.gif and /dev/null differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/colors.jpg b/wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg similarity index 100% rename from wp-includes/js/tinymce/themes/advanced/images/colors.jpg rename to wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg diff --git a/wp-includes/js/tinymce/themes/advanced/img/fm.gif b/wp-includes/js/tinymce/themes/advanced/img/fm.gif new file mode 100644 index 00000000..b5f022b5 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/fm.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png b/wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png new file mode 100644 index 00000000..8a396e03 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/img/icons.gif b/wp-includes/js/tinymce/themes/advanced/img/icons.gif new file mode 100644 index 00000000..68708278 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/icons.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/img/sflogo.png b/wp-includes/js/tinymce/themes/advanced/img/sflogo.png new file mode 100644 index 00000000..142a6f99 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/img/sflogo.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/js/about.js b/wp-includes/js/tinymce/themes/advanced/js/about.js new file mode 100644 index 00000000..277550fb --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/about.js @@ -0,0 +1,72 @@ +tinyMCEPopup.requireLangPack(); + +function init() { + var ed, tcont; + + tinyMCEPopup.resizeToInnerSize(); + ed = tinyMCEPopup.editor; + + // Give FF some time + window.setTimeout('insertHelpIFrame();', 10); + + tcont = document.getElementById('plugintablecontainer'); + document.getElementById('plugins_tab').style.display = 'none'; + + var html = ""; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + + tinymce.each(ed.plugins, function(p, n) { + var info; + + if (!p.getInfo) + return; + + html += ''; + + info = p.getInfo(); + + if (info.infourl != null && info.infourl != '') + html += ''; + else + html += ''; + + if (info.authorurl != null && info.authorurl != '') + html += ''; + else + html += ''; + + html += ''; + html += ''; + + document.getElementById('plugins_tab').style.display = ''; + + }); + + html += ''; + html += '
    ' + ed.getLang('advanced_dlg.about_plugin') + '' + ed.getLang('advanced_dlg.about_author') + '' + ed.getLang('advanced_dlg.about_version') + '
    ' + info.longname + '' + info.longname + '' + info.author + '' + info.author + '' + info.version + '
    '; + + tcont.innerHTML = html; + + tinyMCEPopup.dom.get('version').innerHTML = tinymce.majorVersion + "." + tinymce.minorVersion; + tinyMCEPopup.dom.get('date').innerHTML = tinymce.releaseDate; +} + +function insertHelpIFrame() { + var html; + + if (tinyMCEPopup.getParam('docs_url')) { + html = ''; + document.getElementById('iframecontainer').innerHTML = html; + document.getElementById('help_tab').style.display = 'block'; + } +} + +tinyMCEPopup.onInit.add(init); diff --git a/wp-includes/js/tinymce/themes/advanced/js/anchor.js b/wp-includes/js/tinymce/themes/advanced/js/anchor.js new file mode 100644 index 00000000..76f4f7dd --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/anchor.js @@ -0,0 +1,37 @@ +tinyMCEPopup.requireLangPack(); + +var AnchorDialog = { + init : function(ed) { + var action, elm, f = document.forms[0]; + + this.editor = ed; + elm = ed.dom.getParent(ed.selection.getNode(), 'A,IMG'); + v = ed.dom.getAttrib(elm, 'name'); + + if (v) { + this.action = 'update'; + f.anchorName.value = v; + } + + f.insert.value = ed.getLang(elm ? 'update' : 'insert'); + }, + + update : function() { + var ed = this.editor; + + tinyMCEPopup.restoreSelection(); + + if (this.action != 'update') + ed.selection.collapse(1); + + // Webkit acts weird if empty inline element is inserted so we need to use a image instead + if (tinymce.isWebKit) + ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('img', {mce_name : 'a', name : document.forms[0].anchorName.value, 'class' : 'mceItemAnchor'})); + else + ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : document.forms[0].anchorName.value, 'class' : 'mceItemAnchor'}, '')); + + tinyMCEPopup.close(); + } +}; + +tinyMCEPopup.onInit.add(AnchorDialog.init, AnchorDialog); diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js b/wp-includes/js/tinymce/themes/advanced/js/charmap.js similarity index 92% rename from wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js rename to wp-includes/js/tinymce/themes/advanced/js/charmap.js index c4ec3261..d9fd8d32 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js +++ b/wp-includes/js/tinymce/themes/advanced/js/charmap.js @@ -1,13 +1,6 @@ -function init() { - tinyMCEPopup.resizeToInnerSize(); -} - -var charmap = new Array(); +tinyMCEPopup.requireLangPack(); -// for mor details please see w3c.org -// now here is the complete list ;) - -charmap = [ +var charmap = [ [' ', ' ', true, 'no-break space'], ['&', '&', true, 'ampersand'], ['"', '"', true, 'quotation mark'], @@ -270,32 +263,37 @@ charmap = [ ['­', '­', false,'soft hyphen'] ]; +tinyMCEPopup.onInit.add(function() { + tinyMCEPopup.dom.setHTML('charmapView', renderCharMapHTML()); +}); + function renderCharMapHTML() { - var charsPerRow = 20, tdWidth=20, tdHeight=20; + var charsPerRow = 20, tdWidth=20, tdHeight=20, i; var html = ''; var cols=-1; - for (var i=0; i' + + ''; if ((cols+1) % charsPerRow == 0) html += ''; } } + if (cols % charsPerRow > 0) { var padd = charsPerRow - (cols % charsPerRow); for (var i=0; i '; } + html += '
    ' + + '' + charmap[i][1] + '
    '; - document.write(html); + + return html; } function insertChar(chr) { @@ -305,6 +303,7 @@ function insertChar(chr) { if (tinyMCEPopup.isWindow) window.focus(); + tinyMCEPopup.editor.focus(); tinyMCEPopup.close(); } diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js b/wp-includes/js/tinymce/themes/advanced/js/color_picker.js similarity index 93% rename from wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js rename to wp-includes/js/tinymce/themes/advanced/js/color_picker.js index 6fe6b903..db5ac254 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js +++ b/wp-includes/js/tinymce/themes/advanced/js/color_picker.js @@ -1,6 +1,8 @@ +tinyMCEPopup.requireLangPack(); + var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false; -var colors = new Array( +var colors = [ "#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033", "#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099", "#6600cc","#6600ff","#990000","#990033","#990066","#990099","#9900cc","#9900ff", @@ -28,7 +30,7 @@ var colors = new Array( "#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#99ff00","#99ff33", "#99ff66","#99ff99","#99ffcc","#99ffff","#ccff00","#ccff33","#ccff66","#ccff99", "#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff" -); +]; var named = { '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige', @@ -57,10 +59,9 @@ var named = { }; function init() { - var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color')); + var inputColor = convertRGBToHex(tinyMCEPopup.getWindowArg('input_color')); - if (tinyMCE.isMSIE) - tinyMCEPopup.resizeToInnerSize(); + tinyMCEPopup.resizeToInnerSize(); generatePicker(); @@ -75,9 +76,13 @@ function init() { } function insertAction() { - var color = document.getElementById("color").value; + var color = document.getElementById("color").value, f = tinyMCEPopup.getWindowArg('func'); + + tinyMCEPopup.restoreSelection(); + + if (f) + f(color); - tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color); tinyMCEPopup.close(); } @@ -86,7 +91,7 @@ function showColor(color, name) { document.getElementById("colorname").innerHTML = name; document.getElementById("preview").style.backgroundColor = color; - document.getElementById("color").value = color; + document.getElementById("color").value = color.toLowerCase(); } function convertRGBToHex(col) { @@ -152,9 +157,9 @@ function generateWebColors() { + ''; for (i=0; i' - + '' - + '' + colors[i] +  ''; + h += '' + + '' + + ''; if ((i+1) % 18 == 0) h += ''; } @@ -190,9 +195,9 @@ function computeColor(e) { x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0); y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0); - partWidth = document.getElementById('colorpicker').width / 6; + partWidth = document.getElementById('colors').width / 6; partDetail = detail / 2; - imHeight = document.getElementById('colorpicker').height; + imHeight = document.getElementById('colors').height; r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255; g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255 + (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth); @@ -237,4 +242,4 @@ function changeFinalColor(color) { document.getElementById('color').value = color; } -window.focus(); \ No newline at end of file +tinyMCEPopup.onInit.add(init); diff --git a/wp-includes/js/tinymce/themes/advanced/js/image.js b/wp-includes/js/tinymce/themes/advanced/js/image.js new file mode 100644 index 00000000..4c018eda --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/image.js @@ -0,0 +1,254 @@ +var ImageDialog = { + preInit : function() { + var url; + + tinyMCEPopup.requireLangPack(); + + if (url = tinyMCEPopup.getParam("external_image_list_url")) + document.write(''); + }, + + init : function() { + var f = document.forms[0], ed = tinyMCEPopup.editor; + + // Setup browse button + document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image'); + if (isVisible('srcbrowser')) + document.getElementById('src').style.width = '180px'; + + e = ed.selection.getNode(); + + this.fillFileList('image_list', 'tinyMCEImageList'); + + if (e.nodeName == 'IMG') { + f.src.value = ed.dom.getAttrib(e, 'src'); + f.alt.value = ed.dom.getAttrib(e, 'alt'); + f.border.value = this.getAttrib(e, 'border'); + f.vspace.value = this.getAttrib(e, 'vspace'); + f.hspace.value = this.getAttrib(e, 'hspace'); + f.width.value = ed.dom.getAttrib(e, 'width'); + f.height.value = ed.dom.getAttrib(e, 'height'); + f.insert.value = ed.getLang('update'); + f.class_name.value = ed.dom.getAttrib(e, 'class'); + this.styleVal = ed.dom.getAttrib(e, 'style'); + selectByValue(f, 'image_list', f.src.value); + selectByValue(f, 'align', this.getAttrib(e, 'align')); + this.updateStyle(); + } + }, + + fillFileList : function(id, l) { + var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; + + l = window[l]; + + if (l && l.length > 0) { + lst.options[lst.options.length] = new Option('', ''); + + tinymce.each(l, function(o) { + lst.options[lst.options.length] = new Option(o[0], o[1]); + }); + } else + dom.remove(dom.getParent(id, 'tr')); + }, + + update : function() { + var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, args = {}, el; + + tinyMCEPopup.restoreSelection(); + + if (f.src.value === '') { + if (ed.selection.getNode().nodeName == 'IMG') { + ed.dom.remove(ed.selection.getNode()); + ed.execCommand('mceRepaint'); + } + + tinyMCEPopup.close(); + return; + } + + if (!ed.settings.inline_styles) { + args = tinymce.extend(args, { + vspace : nl.vspace.value, + hspace : nl.hspace.value, + border : nl.border.value, + align : getSelectValue(f, 'align') + }); + } else + args.style = this.styleVal; + + tinymce.extend(args, { + src : f.src.value, + alt : f.alt.value, + width : f.width.value, + height : f.height.value, + 'class' : f.class_name.value + }); + + el = ed.selection.getNode(); + + if (el && el.nodeName == 'IMG') { + ed.dom.setAttribs(el, args); + } else { + ed.execCommand('mceInsertContent', false, '', {skip_undo : 1}); + ed.dom.setAttribs('__mce_tmp', args); + ed.dom.setAttrib('__mce_tmp', 'id', ''); + ed.undoManager.add(); + } + + tinyMCEPopup.close(); + }, + + updateStyle : function() { + var dom = tinyMCEPopup.dom, st, v, cls, oldcls, rep, f = document.forms[0]; + + if (tinyMCEPopup.editor.settings.inline_styles) { + st = tinyMCEPopup.dom.parseStyle(this.styleVal); + + // Handle align + v = getSelectValue(f, 'align'); + cls = f.class_name.value || ''; + cls = cls ? cls.replace(/alignright\s*|alignleft\s*|aligncenter\s*/g, '') : ''; + cls = cls ? cls.replace(/^\s*(.+?)\s*$/, '$1') : ''; + if (v) { + if (v == 'left' || v == 'right') { + st['float'] = v; + delete st['vertical-align']; + oldcls = cls ? ' '+cls : ''; + f.class_name.value = 'align' + v + oldcls; + } else { + st['vertical-align'] = v; + delete st['float']; + f.class_name.value = cls; + } + } else { + delete st['float']; + delete st['vertical-align']; + f.class_name.value = cls; + } + + // Handle border + v = f.border.value; + if (v || v == '0') { + if (v == '0') + st['border'] = '0'; + else + st['border'] = v + 'px solid black'; + } else + delete st['border']; + + // Handle hspace + v = f.hspace.value; + if (v) { + delete st['margin']; + st['margin-left'] = v + 'px'; + st['margin-right'] = v + 'px'; + } else { + delete st['margin-left']; + delete st['margin-right']; + } + + // Handle vspace + v = f.vspace.value; + if (v) { + delete st['margin']; + st['margin-top'] = v + 'px'; + st['margin-bottom'] = v + 'px'; + } else { + delete st['margin-top']; + delete st['margin-bottom']; + } + + // Merge + st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st)); + this.styleVal = dom.serializeStyle(st); + } + }, + + getAttrib : function(e, at) { + var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2; + + if (ed.settings.inline_styles) { + switch (at) { + case 'align': + if (v = dom.getStyle(e, 'float')) + return v; + + if (v = dom.getStyle(e, 'vertical-align')) + return v; + + break; + + case 'hspace': + v = dom.getStyle(e, 'margin-left') + v2 = dom.getStyle(e, 'margin-right'); + if (v && v == v2) + return parseInt(v.replace(/[^0-9]/g, '')); + + break; + + case 'vspace': + v = dom.getStyle(e, 'margin-top') + v2 = dom.getStyle(e, 'margin-bottom'); + if (v && v == v2) + return parseInt(v.replace(/[^0-9]/g, '')); + + break; + + case 'border': + v = 0; + + tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) { + sv = dom.getStyle(e, 'border-' + sv + '-width'); + + // False or not the same as prev + if (!sv || (sv != v && v !== 0)) { + v = 0; + return false; + } + + if (sv) + v = sv; + }); + + if (v) + return parseInt(v.replace(/[^0-9]/g, '')); + + break; + } + } + + if (v = dom.getAttrib(e, at)) + return v; + + return ''; + }, + + resetImageData : function() { + var f = document.forms[0]; + + f.width.value = f.height.value = ""; + }, + + updateImageData : function() { + var f = document.forms[0], t = ImageDialog; + + if (f.width.value == "") + f.width.value = t.preloadImg.width; + + if (f.height.value == "") + f.height.value = t.preloadImg.height; + }, + + getImageData : function() { + var f = document.forms[0]; + + this.preloadImg = new Image(); + this.preloadImg.onload = this.updateImageData; + this.preloadImg.onerror = this.resetImageData; + this.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.src.value); + } +}; + +ImageDialog.preInit(); +tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog); diff --git a/wp-includes/js/tinymce/themes/advanced/js/link.js b/wp-includes/js/tinymce/themes/advanced/js/link.js new file mode 100644 index 00000000..c8cb642a --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/js/link.js @@ -0,0 +1,155 @@ +tinyMCEPopup.requireLangPack(); + +var LinkDialog = { + preInit : function() { + var url; + + if (url = tinyMCEPopup.getParam("external_link_list_url")) + document.write(''); + }, + + init : function() { + var f = document.forms[0], ed = tinyMCEPopup.editor; + + // Setup browse button + document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link'); + if (isVisible('hrefbrowser')) + document.getElementById('href').style.width = '180px'; + + this.fillClassList('class_list'); + this.fillFileList('link_list', 'tinyMCELinkList'); + this.fillTargetList('target_list'); + + if (e = ed.dom.getParent(ed.selection.getNode(), 'A')) { + f.href.value = ed.dom.getAttrib(e, 'href'); + f.linktitle.value = ed.dom.getAttrib(e, 'title'); + f.insert.value = ed.getLang('update'); + selectByValue(f, 'link_list', f.href.value); + selectByValue(f, 'target_list', ed.dom.getAttrib(e, 'target')); + selectByValue(f, 'class_list', ed.dom.getAttrib(e, 'class')); + } + }, + + update : function() { + var f = document.forms[0], ed = tinyMCEPopup.editor, e, b; + + tinyMCEPopup.restoreSelection(); + e = ed.dom.getParent(ed.selection.getNode(), 'A'); + + // Remove element if there is no href + if (!f.href.value) { + if (e) { + tinyMCEPopup.execCommand("mceBeginUndoLevel"); + b = ed.selection.getBookmark(); + ed.dom.remove(e, 1); + ed.selection.moveToBookmark(b); + tinyMCEPopup.execCommand("mceEndUndoLevel"); + tinyMCEPopup.close(); + return; + } + } + + tinyMCEPopup.execCommand("mceBeginUndoLevel"); + + // Create new anchor elements + if (e == null) { + tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1}); + + tinymce.each(ed.dom.select("a"), function(n) { + if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') { + e = n; + + ed.dom.setAttribs(e, { + href : f.href.value, + title : f.linktitle.value, + target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, + 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null + }); + } + }); + } else { + ed.dom.setAttribs(e, { + href : f.href.value, + title : f.linktitle.value, + target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, + 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null + }); + } + + // Don't move caret if selection was image + if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') { + ed.focus(); + ed.selection.select(e); + ed.selection.collapse(0); + tinyMCEPopup.storeSelection(); + } + + tinyMCEPopup.execCommand("mceEndUndoLevel"); + tinyMCEPopup.close(); + }, + + checkPrefix : function(n) { + if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email'))) + n.value = 'mailto:' + n.value; + + if (/^\s*www./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external'))) + n.value = 'http://' + n.value; + }, + + fillFileList : function(id, l) { + var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; + + l = window[l]; + + if (l && l.length > 0) { + lst.options[lst.options.length] = new Option('', ''); + + tinymce.each(l, function(o) { + lst.options[lst.options.length] = new Option(o[0], o[1]); + }); + } else + dom.remove(dom.getParent(id, 'tr')); + }, + + fillClassList : function(id) { + var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; + + if (v = tinyMCEPopup.getParam('theme_advanced_styles')) { + cl = []; + + tinymce.each(v.split(';'), function(v) { + var p = v.split('='); + + cl.push({'title' : p[0], 'class' : p[1]}); + }); + } else + cl = tinyMCEPopup.editor.dom.getClasses(); + + if (cl.length > 0) { + lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); + + tinymce.each(cl, function(o) { + lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); + }); + } else + dom.remove(dom.getParent(id, 'tr')); + }, + + fillTargetList : function(id) { + var dom = tinyMCEPopup.dom, lst = dom.get(id), v; + + lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); + lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self'); + lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank'); + + if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) { + tinymce.each(v.split(','), function(v) { + v = v.split('='); + lst.options[lst.options.length] = new Option(v[0], v[1]); + }); + } + } +}; + +LinkDialog.preInit(); +tinyMCEPopup.onInit.add(LinkDialog.init, LinkDialog); diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js b/wp-includes/js/tinymce/themes/advanced/js/source_editor.js similarity index 53% rename from wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js rename to wp-includes/js/tinymce/themes/advanced/js/source_editor.js index 83648be4..a6235a38 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js +++ b/wp-includes/js/tinymce/themes/advanced/js/source_editor.js @@ -1,33 +1,36 @@ +tinyMCEPopup.requireLangPack(); +tinyMCEPopup.onInit.add(onLoadInit); + function saveContent() { - tinyMCE.setContent(document.getElementById('htmlSource').value); - tinyMCE.closeWindow(window); + tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value); + tinyMCEPopup.close(); } function onLoadInit() { tinyMCEPopup.resizeToInnerSize(); // Remove Gecko spellchecking - if (tinyMCE.isGecko) - document.body.spellcheck = tinyMCE.getParam("gecko_spellcheck"); - - document.getElementById('htmlSource').value = tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')); + if (tinymce.isGecko) + document.body.spellcheck = tinyMCEPopup.editor.getParam("gecko_spellcheck"); - resizeInputs(); + document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent(); - if (tinyMCE.getParam("theme_advanced_source_editor_wrap", true)) { + if (tinyMCEPopup.editor.getParam("theme_advanced_source_editor_wrap", true)) { setWrap('soft'); document.getElementById('wraped').checked = true; } + + resizeInputs(); } function setWrap(val) { - var s = document.getElementById('htmlSource'); + var v, n, s = document.getElementById('htmlSource'); s.wrap = val; - if (tinyMCE.isGecko || tinyMCE.isOpera) { - var v = s.value; - var n = s.cloneNode(false); + if (!tinymce.isIE) { + v = s.value; + n = s.cloneNode(false); n.setAttribute("wrap", val); s.parentNode.replaceChild(n, s); n.value = v; @@ -46,11 +49,11 @@ var wHeight=0, wWidth=0, owHeight=0, owWidth=0; function resizeInputs() { var el = document.getElementById('htmlSource'); - if (!tinyMCE.isMSIE) { - wHeight = self.innerHeight - 60; + if (!tinymce.isIE) { + wHeight = self.innerHeight - 65; wWidth = self.innerWidth - 16; } else { - wHeight = document.body.clientHeight - 60; + wHeight = document.body.clientHeight - 70; wWidth = document.body.clientWidth - 16; } diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/about.js b/wp-includes/js/tinymce/themes/advanced/jscripts/about.js deleted file mode 100644 index f60e6f68..00000000 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/about.js +++ /dev/null @@ -1,75 +0,0 @@ -function init() { - var inst; - - tinyMCEPopup.resizeToInnerSize(); - inst = tinyMCE.selectedInstance; - - // Give FF some time - window.setTimeout('insertHelpIFrame();', 10); - - var tcont = document.getElementById('plugintablecontainer'); - var plugins = tinyMCE.getParam('plugins', '', true, ','); - if (plugins.length == 0) - document.getElementById('plugins_tab').style.display = 'none'; - - var html = ""; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - - for (var i=0; i' + info.longname + ''; - else - html += ''; - - if (info.authorurl != null && info.authorurl != '') - html += ''; - else - html += ''; - - html += ''; - html += ''; - } - - html += ''; - html += '
    ' + tinyMCE.getLang('lang_plugin') + '' + tinyMCE.getLang('lang_author') + '' + tinyMCE.getLang('lang_version') + '
    ' + info.longname + '' + info.author + '' + info.author + '' + info.version + '
    '; - - tcont.innerHTML = html; -} - -function getPluginInfo(name) { - if (tinyMCE.plugins[name].getInfo) - return tinyMCE.plugins[name].getInfo(); - - return { - longname : name, - authorurl : '', - infourl : '', - author : '--', - version : '--' - }; -} - -function insertHelpIFrame() { - var html = ''; - - document.getElementById('iframecontainer').innerHTML = html; - - html = ''; - html += 'Got Moxie? '; - html += 'Hosted By Sourceforge '; - html += 'Also on freshmeat '; - - document.getElementById('buttoncontainer').innerHTML = html; -} diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js b/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js deleted file mode 100644 index f2e5d482..00000000 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js +++ /dev/null @@ -1,74 +0,0 @@ -var action, element; - -function init() { - tinyMCEPopup.resizeToInnerSize(); - - var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); - var anchor = tinyMCE.getParentElement(inst.getFocusElement(), "a", "name"); - var img = inst.getFocusElement(); - action = 'insert'; - - if (anchor != null) { - element = anchor; - action = "update"; - } - - if (tinyMCE.getAttrib(img, "class") == "mceItemAnchor") { - element = img; - action = "update"; - } - - if (action == "update") - document.forms[0].anchorName.value = element.nodeName == "IMG" ? element.getAttribute("title") : element.getAttribute("name"); - - document.forms[0].insert.value = tinyMCE.getLang('lang_' + action, 'Insert', true); -} - -function insertAnchor() { - var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); - var name = document.forms[0].anchorName.value, e; - - tinyMCEPopup.execCommand("mceBeginUndoLevel"); - - if (action == "update") { - if (element.nodeName == "IMG") - element.setAttribute("title", name); - else - element.setAttribute("name", name); - } else { - var rng = inst.getRng(); - - if (rng.collapse) - rng.collapse(false); - - name = name.replace(/&/g, '&'); - name = name.replace(/\"/g, '"'); - name = name.replace(//g, '>'); - - // Fix for bug #1447335 - if (tinyMCE.isGecko) - html = ''; - else - html = ''; - - tinyMCEPopup.execCommand("mceInsertContent", false, html); - - // Fix for bug #1447335 force cursor after the anchor element - if (tinyMCE.isGecko) { - e = inst.getDoc().getElementById('mceNewAnchor'); - - if (e) { - inst.selection.selectNode(e, true, false, false); - e.removeAttribute('id'); - } - } - - tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst); - } - - tinyMCEPopup.execCommand("mceEndUndoLevel"); - - tinyMCE.triggerNodeChange(); - tinyMCEPopup.close(); -} diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/image.js b/wp-includes/js/tinymce/themes/advanced/jscripts/image.js deleted file mode 100644 index 950c043a..00000000 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/image.js +++ /dev/null @@ -1,81 +0,0 @@ -var url = tinyMCE.getParam("external_image_list_url"); -if (url != null) { - // Fix relative - if (url.charAt(0) != '/' && url.indexOf('://') == -1) - url = tinyMCE.documentBasePath + "/" + url; - - document.write(''); -} - -function insertImage() { - var src = document.forms[0].src.value; - var alt = document.forms[0].alt.value; - var border = document.forms[0].border.value; - var vspace = document.forms[0].vspace.value; - var hspace = document.forms[0].hspace.value; - var width = document.forms[0].width.value; - var height = document.forms[0].height.value; - var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value; - - tinyMCEPopup.restoreSelection(); - tinyMCE.themes['advanced']._insertImage(src, alt, border, hspace, vspace, width, height, align); - tinyMCEPopup.close(); -} - -function init() { - tinyMCEPopup.resizeToInnerSize(); - - document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image'); - - var formObj = document.forms[0]; - - for (var i=0; i 0) { - for (var i=0; i'); -} - -function init() { - tinyMCEPopup.resizeToInnerSize(); - - document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','theme_advanced_link'); - - // Handle file browser - if (isVisible('hrefbrowser')) - document.getElementById('href').style.width = '180px'; - - var formObj = document.forms[0]; - - for (var i=0; i 0) { - var formObj = document.forms[0]; - - for (var i=0; i - {$lang_insert_link_title} - - - - - + {#advanced_dlg.link_title} + + + + + - - -
    + + @@ -22,80 +22,41 @@ - + - - - - - - - + + + + + + + + - - - - - - + + + + + +
    - +
     
    -
    -
    - +
    - +
    diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/content.css b/wp-includes/js/tinymce/themes/advanced/skins/default/content.css new file mode 100644 index 00000000..c13d0a3e --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/default/content.css @@ -0,0 +1,27 @@ +body, td, pre {color:#000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; margin:8px;} +body {background:#FFF;} +body.mceForceColors {background:#FFF; color:#000;} +h1 {font-size: 2em} +h2 {font-size: 1.5em} +h3 {font-size: 1.17em} +h4 {font-size: 1em} +h5 {font-size: .83em} +h6 {font-size: .75em} +.mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;} +a.mceItemAnchor {width:12px; line-height:6px; overflow:hidden; padding-left:12px; background:url(img/items.gif) no-repeat bottom left;} +img.mceItemAnchor {width:12px; height:12px; background:url(img/items.gif) no-repeat;} +img {border:0;} +table {cursor:default} +table td, table th {cursor:text} + +/* IE */ +* html body { +scrollbar-3dlight-color:#F0F0EE; +scrollbar-arrow-color:#676662; +scrollbar-base-color:#F0F0EE; +scrollbar-darkshadow-color:#DDD; +scrollbar-face-color:#E0E0DD; +scrollbar-highlight-color:#F0F0EE; +scrollbar-shadow-color:#F0F0EE; +scrollbar-track-color:#F5F5F5; +} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css b/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css new file mode 100644 index 00000000..497dda30 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css @@ -0,0 +1,114 @@ +/* Generic */ +body { +font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; +scrollbar-3dlight-color:#F0F0EE; +scrollbar-arrow-color:#676662; +scrollbar-base-color:#F0F0EE; +scrollbar-darkshadow-color:#DDDDDD; +scrollbar-face-color:#E0E0DD; +scrollbar-highlight-color:#F0F0EE; +scrollbar-shadow-color:#F0F0EE; +scrollbar-track-color:#F5F5F5; +background:#F0F0EE; +padding:0; +margin:8px 8px 0 8px; +} + +html {background:#F0F0EE;} +td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} +textarea {resize:none;outline:none;} +a:link, a:visited {color:black;} +a:hover {color:#2B6FB6;} + +/* Forms */ +fieldset {margin:0; padding:4px; border:1px solid #919B9C; font-family:Verdana, Arial; font-size:10px;} +legend {color:#2B6FB6; font-weight:bold;} +label.msg {display:none;} +label.invalid {color:#EE0000; display:inline;} +input.invalid {border:1px solid #EE0000;} +input {background:#FFF; border:1px solid #CCC;} +input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} +input, select, textarea {border:1px solid #808080;} +input.radio {border:1px none #000000; background:transparent; vertical-align:middle;} +input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;} +.input_noborder {border:0;} + +/* Buttons */ +#insert, #cancel, input.button, .updateButton { +border:0; margin:0; padding:0; +font-weight:bold; +width:94px; height:26px; +background:url(img/buttons.png) 0 -26px; +cursor:pointer; +padding-bottom:2px; +} + +#insert {background:url(img/buttons.png) 0 -52px;} +#cancel {background:url(img/buttons.png) 0 0;} + +/* Browse */ +a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;} +.mceOldBoxModel a.browse span {width:22px; height:20px;} +a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;} +a.browse span.disabled {border:1px solid white; -moz-opacity:0.3; opacity:0.3; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);} +a.browse:hover span.disabled {border:1px solid white; background-color:transparent;} +a.pickcolor span {display:block; width:20px; height:16px; background:url(../../img/icons.gif) -840px 0; margin-left:2px;} +.mceOldBoxModel a.pickcolor span {width:21px; height:17px;} +a.pickcolor:hover span {background-color:#B2BBD0;} +a.pickcolor:hover span.disabled {} + +/* Charmap */ +table.charmap {border:1px solid #AAA; text-align:center} +td.charmap, #charmap a {width:18px; height:18px; color:#000; border:1px solid #AAA; text-align:center; font-size:12px; vertical-align:middle; line-height: 18px;} +#charmap a {display:block; color:#000; text-decoration:none; border:0} +#charmap a:hover {background:#CCC;color:#2B6FB6} +#charmap #codeN {font-size:10px; font-family:Arial,Helvetica,sans-serif; text-align:center} +#charmap #codeV {font-size:40px; height:80px; border:1px solid #AAA; text-align:center} + +/* Source */ +.wordWrapCode {vertical-align:middle; border:1px none #000000; background:transparent;} +.mceActionPanel {margin-top:5px;} + +/* Tabs classes */ +.tabs {width:100%; height:18px; line-height:normal; background:url(img/tabs.gif) repeat-x 0 -72px;} +.tabs ul {margin:0; padding:0; list-style:none;} +.tabs li {float:left; background:url(img/tabs.gif) no-repeat 0 0; margin:0 2px 0 0; padding:0 0 0 10px; line-height:17px; height:18px; display:block;} +.tabs li.current {background:url(img/tabs.gif) no-repeat 0 -18px; margin-right:2px;} +.tabs span {float:left; display:block; background:url(img/tabs.gif) no-repeat right -36px; padding:0px 10px 0 0;} +.tabs .current span {background:url(img/tabs.gif) no-repeat right -54px;} +.tabs a {text-decoration:none; font-family:Verdana, Arial; font-size:10px;} +.tabs a:link, .tabs a:visited, .tabs a:hover {color:black;} + +/* Panels */ +.panel_wrapper div.panel {display:none;} +.panel_wrapper div.current {display:block; width:100%; height:300px; overflow:visible;} +.panel_wrapper {border:1px solid #919B9C; border-top:0px; padding:10px; padding-top:5px; clear:both; background:white;} + +/* Columns */ +.column {float:left;} +.properties {width:100%;} +.properties .column1 {} +.properties .column2 {text-align:left;} + +/* Titles */ +h1, h2, h3, h4 {color:#2B6FB6; margin:0; padding:0; padding-top:5px;} +h3 {font-size:14px;} +.title {font-size:12px; font-weight:bold; color:#2B6FB6;} + +/* Dialog specific */ +#link .panel_wrapper, #link div.current {height:125px;} +#image .panel_wrapper, #image div.current {height:200px;} +#plugintable thead {font-weight:bold; background:#DDD;} +#plugintable, #about #plugintable td {border:1px solid #919B9C;} +#plugintable {width:96%; margin-top:10px;} +#pluginscontainer {height:290px; overflow:auto;} +#colorpicker #preview {float:right; width:50px; height:14px;line-height:1px; border:1px solid black; margin-left:5px;} +#colorpicker #colors {float:left; border:1px solid gray; cursor:crosshair;} +#colorpicker #light {border:1px solid gray; margin-left:5px; float:left;width:15px; height:150px; cursor:crosshair;} +#colorpicker #light div {overflow:hidden;} +#colorpicker #previewblock {float:right; padding-left:10px; height:20px;} +#colorpicker .panel_wrapper div.current {height:175px;} +#colorpicker #namedcolors {width:150px;} +#colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;} +#colorpicker #colornamecontainer {margin-top:5px;} +#colorpicker #picker_panel fieldset {margin:auto;width:325px;} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/img/buttons.png b/wp-includes/js/tinymce/themes/advanced/skins/default/img/buttons.png new file mode 100644 index 00000000..7dd58418 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/default/img/buttons.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/anchor_symbol.gif b/wp-includes/js/tinymce/themes/advanced/skins/default/img/items.gif similarity index 100% rename from wp-includes/js/tinymce/themes/advanced/images/anchor_symbol.gif rename to wp-includes/js/tinymce/themes/advanced/skins/default/img/items.gif diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_arrow.gif b/wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_arrow.gif new file mode 100644 index 00000000..85e31dfb Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_arrow.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_check.gif b/wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_check.gif new file mode 100644 index 00000000..adfdddcc Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_check.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/img/progress.gif b/wp-includes/js/tinymce/themes/advanced/skins/default/img/progress.gif new file mode 100644 index 00000000..5bb90fd6 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/default/img/progress.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/img/tabs.gif b/wp-includes/js/tinymce/themes/advanced/skins/default/img/tabs.gif new file mode 100644 index 00000000..ce4be635 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/default/img/tabs.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css b/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css new file mode 100644 index 00000000..ba8d30a5 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css @@ -0,0 +1,215 @@ +/* Reset */ +.defaultSkin table, .defaultSkin tbody, .defaultSkin a, .defaultSkin img, .defaultSkin tr, .defaultSkin div, .defaultSkin td, .defaultSkin iframe, .defaultSkin span, .defaultSkin *, .defaultSkin .mceText {border:0; margin:0; padding:0; background:transparent; white-space:nowrap; text-decoration:none; font-weight:normal; cursor:default; color:#000; vertical-align:baseline; width:auto; border-collapse:separate; text-align:left} +.defaultSkin a:hover, .defaultSkin a:link, .defaultSkin a:visited, .defaultSkin a:active {text-decoration:none; font-weight:normal; cursor:default; color:#000} +.defaultSkin table td {vertical-align:middle} + +/* Containers */ +.defaultSkin table {background:#F0F0EE} +.defaultSkin iframe {display:block; background:#FFF} +.defaultSkin .mceToolbar {height:26px} +.defaultSkin .mceLeft {text-align:left} +.defaultSkin .mceRight {text-align:right} + +/* External */ +.defaultSkin .mceExternalToolbar {position:absolute; border:1px solid #CCC; border-bottom:0; display:none;} +.defaultSkin .mceExternalToolbar td.mceToolbar {padding-right:13px;} +.defaultSkin .mceExternalClose {position:absolute; top:3px; right:3px; width:7px; height:7px; background:url(../../img/icons.gif) -820px 0} + +/* Layout */ +.defaultSkin table.mceLayout {border:0; border-left:1px solid #CCC; border-right:1px solid #CCC} +.defaultSkin table.mceLayout tr.mceFirst td {border-top:1px solid #CCC} +.defaultSkin table.mceLayout tr.mceLast td {border-bottom:1px solid #CCC} +.defaultSkin table.mceToolbar, .defaultSkin tr.mceFirst .mceToolbar tr td, .defaultSkin tr.mceLast .mceToolbar tr td {border:0; margin:0; padding:0;} +.defaultSkin td.mceToolbar {padding-top:1px; vertical-align:top} +.defaultSkin .mceIframeContainer {border-top:1px solid #CCC; border-bottom:1px solid #CCC} +.defaultSkin .mceStatusbar {font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:9pt; line-height:16px; overflow:visible; color:#000; display:block; height:20px} +.defaultSkin .mceStatusbar div {float:left; margin:2px} +.defaultSkin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize} +.defaultSkin .mceStatusbar a:hover {text-decoration:underline} +.defaultSkin table.mceToolbar {margin-left:3px} +.defaultSkin span.mceIcon, .defaultSkin img.mceIcon {display:block; width:20px; height:20px} +.defaultSkin .mceIcon {background:url(../../img/icons.gif) no-repeat 20px 20px} +.defaultSkin td.mceCenter {text-align:center;} +.defaultSkin td.mceCenter table {margin:0 auto; text-align:left;} +.defaultSkin td.mceRight table {margin:0 0 0 auto;} + +/* Button */ +.defaultSkin .mceButton {display:block; border:1px solid #F0F0EE; width:20px; height:20px; margin-right:1px} +.defaultSkin a.mceButtonEnabled:hover {border:1px solid #0A246A; background-color:#B2BBD0} +.defaultSkin a.mceButtonActive, .defaultSkin a.mceButtonSelected {border:1px solid #0A246A; background-color:#C2CBE0} +.defaultSkin .mceButtonDisabled .mceIcon {opacity:0.3; filter:alpha(opacity=30)} +.defaultSkin .mceButtonLabeled {width:auto} +.defaultSkin .mceButtonLabeled span.mceIcon {float:left} +.defaultSkin span.mceButtonLabel {display:block; font-size:10px; padding:4px 6px 0 22px; font-family:Tahoma,Verdana,Arial,Helvetica} +.defaultSkin .mceButtonDisabled .mceButtonLabel {color:#888} + +/* Separator */ +.defaultSkin .mceSeparator {display:block; background:url(../../img/icons.gif) -180px 0; width:2px; height:20px; margin:2px 2px 0 4px} + +/* ListBox */ +.defaultSkin .mceListBox {direction:ltr} +.defaultSkin .mceListBox, .defaultSkin .mceListBox a {display:block} +.defaultSkin .mceListBox .mceText {padding-left:4px; width:70px; text-align:left; border:1px solid #CCC; border-right:0; background:#FFF; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; height:20px; line-height:20px; overflow:hidden} +.defaultSkin .mceListBox .mceOpen {width:9px; height:20px; background:url(../../img/icons.gif) -741px 0; margin-right:2px; border:1px solid #CCC;} +.defaultSkin table.mceListBoxEnabled:hover .mceText, .defaultSkin .mceListBoxHover .mceText, .defaultSkin .mceListBoxSelected .mceText {border:1px solid #A2ABC0; border-right:0; background:#FFF} +.defaultSkin table.mceListBoxEnabled:hover .mceOpen, .defaultSkin .mceListBoxHover .mceOpen, .defaultSkin .mceListBoxSelected .mceOpen {background-color:#FFF; border:1px solid #A2ABC0} +.defaultSkin .mceListBoxDisabled a.mceText {color:gray; background-color:transparent;} +.defaultSkin .mceListBoxMenu {overflow:auto; overflow-x:hidden} +.defaultSkin .mceOldBoxModel .mceListBox .mceText {height:22px} +.defaultSkin .mceOldBoxModel .mceListBox .mceOpen {width:11px; height:22px;} +.defaultSkin select.mceNativeListBox {font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:7pt; background:#F0F0EE; border:1px solid gray; margin-right:2px;} + +/* SplitButton */ +.defaultSkin .mceSplitButton {width:32px; height:20px; direction:ltr} +.defaultSkin .mceSplitButton a, .defaultSkin .mceSplitButton span {height:20px; display:block} +.defaultSkin .mceSplitButton a.mceAction {width:20px; border:1px solid #F0F0EE; border-right:0;} +.defaultSkin .mceSplitButton span.mceAction {width:20px; background:url(../../img/icons.gif) 20px 20px;} +.defaultSkin .mceSplitButton a.mceOpen {width:9px; border:1px solid #F0F0EE;} +.defaultSkin .mceSplitButton span.mceOpen {width:9px; background:url(../../img/icons.gif) -741px 0;} +.defaultSkin table.mceSplitButtonEnabled:hover a.mceAction, .defaultSkin .mceSplitButtonHover a.mceAction, .defaultSkin .mceSplitButtonSelected a.mceAction {border:1px solid #0A246A; border-right:0; background-color:#B2BBD0} +.defaultSkin table.mceSplitButtonEnabled:hover a.mceOpen, .defaultSkin .mceSplitButtonHover a.mceOpen, .defaultSkin .mceSplitButtonSelected a.mceOpen {border:1px solid #0A246A;} +.defaultSkin table.mceSplitButtonEnabled:hover span.mceOpen, .defaultSkin .mceSplitButtonHover span.mceOpen, .defaultSkin .mceSplitButtonSelected span.mceOpen {background-color:#B2BBD0} +.defaultSkin .mceSplitButtonDisabled .mceAction, .defaultSkin .mceSplitButtonDisabled span.mceOpen {opacity:0.3; filter:alpha(opacity=30)} +.defaultSkin .mceSplitButtonActive a.mceAction {border:1px solid #0A246A; background-color:#C2CBE0} +.defaultSkin .mceSplitButtonActive a.mceOpen {border-left:0;} + +/* ColorSplitButton */ +.defaultSkin div.mceColorSplitMenu table {background:#FFF; border:1px solid gray} +.defaultSkin .mceColorSplitMenu td {padding:2px} +.defaultSkin .mceColorSplitMenu a {display:block; width:9px; height:9px; overflow:hidden; border:1px solid #808080} +.defaultSkin .mceColorSplitMenu td.mceMoreColors {padding:1px 3px 1px 1px} +.defaultSkin .mceColorSplitMenu a.mceMoreColors {width:100%; height:auto; text-align:center; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; line-height:20px; border:1px solid #FFF} +.defaultSkin .mceColorSplitMenu a.mceMoreColors:hover {border:1px solid #0A246A; background-color:#B6BDD2} +.defaultSkin a.mceMoreColors:hover {border:1px solid #0A246A} +.defaultSkin .mceColorPreview {margin-left:2px; width:16px; height:4px; overflow:hidden; background:#9a9b9a} +.defaultSkin .mce_forecolor span.mceAction, .defaultSkin .mce_backcolor span.mceAction {overflow:hidden; height:16px} + +/* Menu */ +.defaultSkin .mceMenu {position:absolute; left:0; top:0; z-index:1000; border:1px solid #D4D0C8} +.defaultSkin .mceNoIcons span.mceIcon {width:0;} +.defaultSkin .mceNoIcons a .mceText {padding-left:10px} +.defaultSkin .mceMenu table {background:#FFF} +.defaultSkin .mceMenu a, .defaultSkin .mceMenu span, .defaultSkin .mceMenu {display:block} +.defaultSkin .mceMenu td {height:20px} +.defaultSkin .mceMenu a {position:relative;padding:3px 0 4px 0} +.defaultSkin .mceMenu .mceText {position:relative; display:block; font-family:Tahoma,Verdana,Arial,Helvetica; color:#000; cursor:default; margin:0; padding:0 25px 0 25px; display:block} +.defaultSkin .mceMenu span.mceText, .defaultSkin .mceMenu .mcePreview {font-size:11px} +.defaultSkin .mceMenu pre.mceText {font-family:Monospace} +.defaultSkin .mceMenu .mceIcon {position:absolute; top:0; left:0; width:22px;} +.defaultSkin .mceMenu .mceMenuItemEnabled a:hover, .defaultSkin .mceMenu .mceMenuItemActive {background-color:#dbecf3} +.defaultSkin td.mceMenuItemSeparator {background:#DDD; height:1px} +.defaultSkin .mceMenuItemTitle a {border:0; background:#EEE; border-bottom:1px solid #DDD} +.defaultSkin .mceMenuItemTitle span.mceText {color:#000; font-weight:bold; padding-left:4px} +.defaultSkin .mceMenuItemDisabled .mceText {color:#888} +.defaultSkin .mceMenuItemSelected .mceIcon {background:url(img/menu_check.gif)} +.defaultSkin .mceNoIcons .mceMenuItemSelected a {background:url(img/menu_arrow.gif) no-repeat -6px center} +.defaultSkin .mceMenu span.mceMenuLine {display:none} +.defaultSkin .mceMenuItemSub a {background:url(img/menu_arrow.gif) no-repeat top right;} + +/* Progress,Resize */ +.defaultSkin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; filter:alpha(opacity=50); background:#FFF} +.defaultSkin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px} +.defaultSkin .mcePlaceHolder {border:1px dotted gray} + +/* Formats */ +.defaultSkin .mce_formatPreview a {font-size:10px} +.defaultSkin .mce_p span.mceText {} +.defaultSkin .mce_address span.mceText {font-style:italic} +.defaultSkin .mce_pre span.mceText {font-family:monospace} +.defaultSkin .mce_h1 span.mceText {font-weight:bolder; font-size: 2em} +.defaultSkin .mce_h2 span.mceText {font-weight:bolder; font-size: 1.5em} +.defaultSkin .mce_h3 span.mceText {font-weight:bolder; font-size: 1.17em} +.defaultSkin .mce_h4 span.mceText {font-weight:bolder; font-size: 1em} +.defaultSkin .mce_h5 span.mceText {font-weight:bolder; font-size: .83em} +.defaultSkin .mce_h6 span.mceText {font-weight:bolder; font-size: .75em} + +/* Theme */ +.defaultSkin span.mce_bold {background-position:0 0} +.defaultSkin span.mce_italic {background-position:-60px 0} +.defaultSkin span.mce_underline {background-position:-140px 0} +.defaultSkin span.mce_strikethrough {background-position:-120px 0} +.defaultSkin span.mce_undo {background-position:-160px 0} +.defaultSkin span.mce_redo {background-position:-100px 0} +.defaultSkin span.mce_cleanup {background-position:-40px 0} +.defaultSkin span.mce_bullist {background-position:-20px 0} +.defaultSkin span.mce_numlist {background-position:-80px 0} +.defaultSkin span.mce_justifyleft {background-position:-460px 0} +.defaultSkin span.mce_justifyright {background-position:-480px 0} +.defaultSkin span.mce_justifycenter {background-position:-420px 0} +.defaultSkin span.mce_justifyfull {background-position:-440px 0} +.defaultSkin span.mce_anchor {background-position:-200px 0} +.defaultSkin span.mce_indent {background-position:-400px 0} +.defaultSkin span.mce_outdent {background-position:-540px 0} +.defaultSkin span.mce_link {background-position:-500px 0} +.defaultSkin span.mce_unlink {background-position:-640px 0} +.defaultSkin span.mce_sub {background-position:-600px 0} +.defaultSkin span.mce_sup {background-position:-620px 0} +.defaultSkin span.mce_removeformat {background-position:-580px 0} +.defaultSkin span.mce_newdocument {background-position:-520px 0} +.defaultSkin span.mce_image {background-position:-380px 0} +.defaultSkin span.mce_help {background-position:-340px 0} +.defaultSkin span.mce_code {background-position:-260px 0} +.defaultSkin span.mce_hr {background-position:-360px 0} +.defaultSkin span.mce_visualaid {background-position:-660px 0} +.defaultSkin span.mce_charmap {background-position:-240px 0} +.defaultSkin span.mce_paste {background-position:-560px 0} +.defaultSkin span.mce_copy {background-position:-700px 0} +.defaultSkin span.mce_cut {background-position:-680px 0} +.defaultSkin span.mce_blockquote {background-position:-220px 0} +.defaultSkin .mce_forecolor span.mceAction {background-position:-720px 0} +.defaultSkin .mce_backcolor span.mceAction {background-position:-760px 0} +.defaultSkin span.mce_forecolorpicker {background-position:-720px 0} +.defaultSkin span.mce_backcolorpicker {background-position:-760px 0} + +/* Plugins */ +.defaultSkin span.mce_advhr {background-position:-0px -20px} +.defaultSkin span.mce_ltr {background-position:-20px -20px} +.defaultSkin span.mce_rtl {background-position:-40px -20px} +.defaultSkin span.mce_emotions {background-position:-60px -20px} +.defaultSkin span.mce_fullpage {background-position:-80px -20px} +.defaultSkin span.mce_fullscreen {background-position:-100px -20px} +.defaultSkin span.mce_iespell {background-position:-120px -20px} +.defaultSkin span.mce_insertdate {background-position:-140px -20px} +.defaultSkin span.mce_inserttime {background-position:-160px -20px} +.defaultSkin span.mce_absolute {background-position:-180px -20px} +.defaultSkin span.mce_backward {background-position:-200px -20px} +.defaultSkin span.mce_forward {background-position:-220px -20px} +.defaultSkin span.mce_insert_layer {background-position:-240px -20px} +.defaultSkin span.mce_insertlayer {background-position:-260px -20px} +.defaultSkin span.mce_movebackward {background-position:-280px -20px} +.defaultSkin span.mce_moveforward {background-position:-300px -20px} +.defaultSkin span.mce_media {background-position:-320px -20px} +.defaultSkin span.mce_nonbreaking {background-position:-340px -20px} +.defaultSkin span.mce_pastetext {background-position:-360px -20px} +.defaultSkin span.mce_pasteword {background-position:-380px -20px} +.defaultSkin span.mce_selectall {background-position:-400px -20px} +.defaultSkin span.mce_preview {background-position:-420px -20px} +.defaultSkin span.mce_print {background-position:-440px -20px} +.defaultSkin span.mce_cancel {background-position:-460px -20px} +.defaultSkin span.mce_save {background-position:-480px -20px} +.defaultSkin span.mce_replace {background-position:-500px -20px} +.defaultSkin span.mce_search {background-position:-520px -20px} +.defaultSkin span.mce_styleprops {background-position:-560px -20px} +.defaultSkin span.mce_table {background-position:-580px -20px} +.defaultSkin span.mce_cell_props {background-position:-600px -20px} +.defaultSkin span.mce_delete_table {background-position:-620px -20px} +.defaultSkin span.mce_delete_col {background-position:-640px -20px} +.defaultSkin span.mce_delete_row {background-position:-660px -20px} +.defaultSkin span.mce_col_after {background-position:-680px -20px} +.defaultSkin span.mce_col_before {background-position:-700px -20px} +.defaultSkin span.mce_row_after {background-position:-720px -20px} +.defaultSkin span.mce_row_before {background-position:-740px -20px} +.defaultSkin span.mce_merge_cells {background-position:-760px -20px} +.defaultSkin span.mce_table_props {background-position:-980px -20px} +.defaultSkin span.mce_row_props {background-position:-780px -20px} +.defaultSkin span.mce_split_cells {background-position:-800px -20px} +.defaultSkin span.mce_template {background-position:-820px -20px} +.defaultSkin span.mce_visualchars {background-position:-840px -20px} +.defaultSkin span.mce_abbr {background-position:-860px -20px} +.defaultSkin span.mce_acronym {background-position:-880px -20px} +.defaultSkin span.mce_attribs {background-position:-900px -20px} +.defaultSkin span.mce_cite {background-position:-920px -20px} +.defaultSkin span.mce_del {background-position:-940px -20px} +.defaultSkin span.mce_ins {background-position:-960px -20px} +.defaultSkin span.mce_pagebreak {background-position:0 -40px} +.defaultSkin .mce_spellchecker span.mceAction {background-position:-540px -20px} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css new file mode 100644 index 00000000..0a73a575 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css @@ -0,0 +1,27 @@ +body, td, pre {color:#000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; margin:8px;} +body {background:#FFF;} +body.mceForceColors {background:#FFF; color:#000;} +h1 {font-size: 2em} +h2 {font-size: 1.5em} +h3 {font-size: 1.17em} +h4 {font-size: 1em} +h5 {font-size: .83em} +h6 {font-size: .75em} +.mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;} +a.mceItemAnchor {width:12px; line-height:6px; overflow:hidden; padding-left:12px; background:url(../default/img/items.gif) no-repeat bottom left;} +img.mceItemAnchor {width:12px; height:12px; background:url(../default/img/items.gif) no-repeat;} +img {border:0;} +table {cursor:default} +table td, table th {cursor:text} + +/* IE */ +* html body { +scrollbar-3dlight-color:#F0F0EE; +scrollbar-arrow-color:#676662; +scrollbar-base-color:#F0F0EE; +scrollbar-darkshadow-color:#DDD; +scrollbar-face-color:#E0E0DD; +scrollbar-highlight-color:#F0F0EE; +scrollbar-shadow-color:#F0F0EE; +scrollbar-track-color:#F5F5F5; +} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css new file mode 100644 index 00000000..e630fa7c --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css @@ -0,0 +1,113 @@ +/* Generic */ +body { +font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; +scrollbar-3dlight-color:#F0F0EE; +scrollbar-arrow-color:#676662; +scrollbar-base-color:#F0F0EE; +scrollbar-darkshadow-color:#DDDDDD; +scrollbar-face-color:#E0E0DD; +scrollbar-highlight-color:#F0F0EE; +scrollbar-shadow-color:#F0F0EE; +scrollbar-track-color:#F5F5F5; +background:#F0F0EE; +padding:0; +margin:8px 8px 0 8px; +} + +html {background:#F0F0EE;} +td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} +textarea {resize:none;outline:none;} +a:link, a:visited {color:black;} +a:hover {color:#2B6FB6;} + +/* Forms */ +fieldset {margin:0; padding:4px; border:1px solid #919B9C; font-family:Verdana, Arial; font-size:10px;} +legend {color:#2B6FB6; font-weight:bold;} +label.msg {display:none;} +label.invalid {color:#EE0000; display:inline;} +input.invalid {border:1px solid #EE0000;} +input {background:#FFF; border:1px solid #CCC;} +input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} +input, select, textarea {border:1px solid #808080;} +input.radio {border:1px none #000000; background:transparent; vertical-align:middle;} +input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;} +.input_noborder {border:0;} + +/* Buttons */ +#insert, #cancel, input.button, .updateButton { +border:0; margin:0; padding:0; +font-weight:bold; +width:94px; height:26px; +background:url(../default/img/buttons.png) 0 -26px; +cursor:pointer; +padding-bottom:2px; +} + +#insert {background:url(../default/img/buttons.png) 0 -52px;} +#cancel {background:url(../default/img/buttons.png) 0 0;} + +/* Browse */ +a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;} +.mceOldBoxModel a.browse span {width:22px; height:20px;} +a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;} +a.browse span.disabled {border:1px solid white; -moz-opacity:0.3; opacity:0.3; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);} +a.browse:hover span.disabled {border:1px solid white; background-color:transparent;} +a.pickcolor span {display:block; width:20px; height:16px; background:url(../../img/icons.gif) -840px 0; margin-left:2px;} +.mceOldBoxModel a.pickcolor span {width:21px; height:17px;} +a.pickcolor:hover span {background-color:#B2BBD0;} +a.pickcolor:hover span.disabled {} + +/* Charmap */ +table.charmap {border:1px solid #AAA; text-align:center} +td.charmap, #charmap a {width:18px; height:18px; color:#000; border:1px solid #AAA; text-align:center; font-size:12px; vertical-align:middle; line-height: 18px;} +#charmap a {display:block; color:#000; text-decoration:none; border:0} +#charmap a:hover {background:#CCC;color:#2B6FB6} +#charmap #codeN {font-size:10px; font-family:Arial,Helvetica,sans-serif; text-align:center} +#charmap #codeV {font-size:40px; height:80px; border:1px solid #AAA; text-align:center} + +/* Source */ +.wordWrapCode {vertical-align:middle; border:1px none #000000; background:transparent;} +.mceActionPanel {margin-top:5px;} + +/* Tabs classes */ +.tabs {width:100%; height:18px; line-height:normal; background:url(../default/img/tabs.gif) repeat-x 0 -72px;} +.tabs ul {margin:0; padding:0; list-style:none;} +.tabs li {float:left; background:url(../default/img/tabs.gif) no-repeat 0 0; margin:0 2px 0 0; padding:0 0 0 10px; line-height:17px; height:18px; display:block;} +.tabs li.current {background:url(../default/img/tabs.gif) no-repeat 0 -18px; margin-right:2px;} +.tabs span {float:left; display:block; background:url(../default/img/tabs.gif) no-repeat right -36px; padding:0px 10px 0 0;} +.tabs .current span {background:url(../default/img/tabs.gif) no-repeat right -54px;} +.tabs a {text-decoration:none; font-family:Verdana, Arial; font-size:10px;} +.tabs a:link, .tabs a:visited, .tabs a:hover {color:black;} + +/* Panels */ +.panel_wrapper div.panel {display:none;} +.panel_wrapper div.current {display:block; width:100%; height:300px; overflow:visible;} +.panel_wrapper {border:1px solid #919B9C; border-top:0px; padding:10px; padding-top:5px; clear:both; background:white;} + +/* Columns */ +.column {float:left;} +.properties {width:100%;} +.properties .column1 {} +.properties .column2 {text-align:left;} + +/* Titles */ +h1, h2, h3, h4 {color:#2B6FB6; margin:0; padding:0; padding-top:5px;} +h3 {font-size:14px;} +.title {font-size:12px; font-weight:bold; color:#2B6FB6;} + +/* Dialog specific */ +#link .panel_wrapper, #link div.current {height:125px;} +#image .panel_wrapper, #image div.current {height:200px;} +#plugintable thead {font-weight:bold; background:#DDD;} +#plugintable, #about #plugintable td {border:1px solid #919B9C;} +#plugintable {width:96%; margin-top:10px;} +#pluginscontainer {height:290px; overflow:auto;} +#colorpicker #preview {float:right; width:50px; height:14px;line-height:1px; border:1px solid black; margin-left:5px;} +#colorpicker #colors {float:left; border:1px solid gray; cursor:crosshair;} +#colorpicker #light {border:1px solid gray; margin-left:5px; float:left;width:15px; height:150px; cursor:crosshair;} +#colorpicker #light div {overflow:hidden;} +#colorpicker #previewblock {float:right; padding-left:10px; height:20px;} +#colorpicker .panel_wrapper div.current {height:175px;} +#colorpicker #namedcolors {width:150px;} +#colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;} +#colorpicker #colornamecontainer {margin-top:5px;} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg.png b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg.png new file mode 100644 index 00000000..12cfb419 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg_black.png b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg_black.png new file mode 100644 index 00000000..8996c749 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg_black.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg_silver.png b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg_silver.png new file mode 100644 index 00000000..bd5d2550 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/img/button_bg_silver.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css new file mode 100644 index 00000000..8363da1d --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css @@ -0,0 +1,215 @@ +/* Reset */ +.o2k7Skin table, .o2k7Skin tbody, .o2k7Skin a, .o2k7Skin img, .o2k7Skin tr, .o2k7Skin div, .o2k7Skin td, .o2k7Skin iframe, .o2k7Skin span, .o2k7Skin *, .o2k7Skin .mceText {border:0; margin:0; padding:0; background:transparent; white-space:nowrap; text-decoration:none; font-weight:normal; cursor:default; color:#000; vertical-align:baseline; width:auto; border-collapse:separate; text-align:left} +.o2k7Skin a:hover, .o2k7Skin a:link, .o2k7Skin a:visited, .o2k7Skin a:active {text-decoration:none; font-weight:normal; cursor:default; color:#000} +.o2k7Skin table td {vertical-align:middle} + +/* Containers */ +.o2k7Skin table {background:#E5EFFD} +.o2k7Skin iframe {display:block; background:#FFF} +.o2k7Skin .mceToolbar {height:26px} + +/* External */ +.o2k7Skin .mceExternalToolbar {position:absolute; border:1px solid #ABC6DD; border-bottom:0; display:none} +.o2k7Skin .mceExternalToolbar td.mceToolbar {padding-right:13px;} +.o2k7Skin .mceExternalClose {position:absolute; top:3px; right:3px; width:7px; height:7px; background:url(../../img/icons.gif) -820px 0} + +/* Layout */ +.o2k7Skin table.mceLayout {border:0; border-left:1px solid #ABC6DD; border-right:1px solid #ABC6DD} +.o2k7Skin table.mceLayout tr.mceFirst td {border-top:1px solid #ABC6DD} +.o2k7Skin table.mceLayout tr.mceLast td {border-bottom:1px solid #ABC6DD} +.o2k7Skin table.mceToolbar, .o2k7Skin tr.mceFirst .mceToolbar tr td, .o2k7Skin tr.mceLast .mceToolbar tr td {border:0; margin:0; padding:0} +.o2k7Skin .mceIframeContainer {border-top:1px solid #ABC6DD; border-bottom:1px solid #ABC6DD} +.o2k7Skin .mceStatusbar {display:block; font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:9pt; line-height:16px; overflow:visible; color:#000; height:20px} +.o2k7Skin .mceStatusbar div {float:left; padding:2px} +.o2k7Skin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize} +.o2k7Skin .mceStatusbar a:hover {text-decoration:underline} +.o2k7Skin table.mceToolbar {margin-left:3px} +.o2k7Skin .mceToolbar .mceToolbarStart span {display:block; background:url(img/button_bg.png) -22px 0; width:1px; height:22px; margin-left:3px;} +.o2k7Skin .mceToolbar td.mceFirst span {margin:0} +.o2k7Skin .mceToolbar .mceToolbarEnd span {display:block; background:url(img/button_bg.png) -22px 0; width:1px; height:22px} +.o2k7Skin .mceToolbar .mceToolbarEndListBox span, .o2k7Skin .mceToolbar .mceToolbarStartListBox span {display:none} +.o2k7Skin span.mceIcon, .o2k7Skin img.mceIcon {display:block; width:20px; height:20px} +.o2k7Skin .mceIcon {background:url(../../img/icons.gif) no-repeat 20px 20px} +.o2k7Skin td.mceCenter {text-align:center;} +.o2k7Skin td.mceCenter table {margin:0 auto; text-align:left;} +.o2k7Skin td.mceRight table {margin:0 0 0 auto;} + +/* Button */ +.o2k7Skin .mceButton {display:block; background:url(img/button_bg.png); width:22px; height:22px} +.o2k7Skin a.mceButton span, .o2k7Skin a.mceButton img {margin-left:1px} +.o2k7Skin .mceOldBoxModel a.mceButton span, .o2k7Skin .mceOldBoxModel a.mceButton img {margin:0 0 0 1px} +.o2k7Skin a.mceButtonEnabled:hover {background-color:#B2BBD0; background-position:0 -22px} +.o2k7Skin a.mceButtonActive, .o2k7Skin a.mceButtonSelected {background-position:0 -44px} +.o2k7Skin .mceButtonDisabled .mceIcon {opacity:0.3; filter:alpha(opacity=30)} +.o2k7Skin .mceButtonLabeled {width:auto} +.o2k7Skin .mceButtonLabeled span.mceIcon {float:left} +.o2k7Skin span.mceButtonLabel {display:block; font-size:10px; padding:4px 6px 0 22px; font-family:Tahoma,Verdana,Arial,Helvetica} +.o2k7Skin .mceButtonDisabled .mceButtonLabel {color:#888} + +/* Separator */ +.o2k7Skin .mceSeparator {display:block; background:url(img/button_bg.png) -22px 0; width:5px; height:22px} + +/* ListBox */ +.o2k7Skin .mceListBox {margin-left:3px} +.o2k7Skin .mceListBox, .o2k7Skin .mceListBox a {display:block} +.o2k7Skin .mceListBox .mceText {padding-left:4px; text-align:left; width:70px; border:1px solid #b3c7e1; border-right:0; background:#eaf2fb; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; height:20px; line-height:20px; overflow:hidden} +.o2k7Skin .mceListBox .mceOpen {width:14px; height:22px; background:url(img/button_bg.png) -66px 0} +.o2k7Skin table.mceListBoxEnabled:hover .mceText, .o2k7Skin .mceListBoxHover .mceText, .o2k7Skin .mceListBoxSelected .mceText {background:#FFF} +.o2k7Skin table.mceListBoxEnabled:hover .mceOpen, .o2k7Skin .mceListBoxHover .mceOpen, .o2k7Skin .mceListBoxSelected .mceOpen {background-position:-66px -22px} +.o2k7Skin .mceListBoxDisabled .mceText {color:gray} +.o2k7Skin .mceListBoxMenu {overflow:auto; overflow-x:hidden} +.o2k7Skin .mceOldBoxModel .mceListBox .mceText {height:22px} +.o2k7Skin select.mceListBox {font-family:Tahoma,Verdana,Arial,Helvetica; font-size:12px; border:1px solid #b3c7e1; background:#FFF;} + +/* SplitButton */ +.o2k7Skin .mceSplitButton, .o2k7Skin .mceSplitButton a, .o2k7Skin .mceSplitButton span {display:block; height:22px} +.o2k7Skin .mceSplitButton {background:url(img/button_bg.png)} +.o2k7Skin .mceSplitButton a.mceAction {width:22px} +.o2k7Skin .mceSplitButton span.mceAction {width:22px; background:url(../../img/icons.gif) 20px 20px} +.o2k7Skin .mceSplitButton a.mceOpen {width:10px} +.o2k7Skin .mceSplitButton span.mceOpen {width:10px; background:url(img/button_bg.png) -44px 0} +.o2k7Skin table.mceSplitButtonEnabled:hover a.mceAction, .o2k7Skin .mceSplitButtonHover a.mceAction, .o2k7Skin .mceSplitButtonSelected {background:url(img/button_bg.png) 0 -22px} +.o2k7Skin table.mceSplitButtonEnabled:hover span.mceOpen, .o2k7Skin .mceSplitButtonHover span.mceOpen, .o2k7Skin .mceSplitButtonSelected span.mceOpen {background-position:-44px -44px} +.o2k7Skin .mceSplitButtonDisabled .mceAction {opacity:0.3; filter:alpha(opacity=30)} +.o2k7Skin .mceSplitButtonActive {background-position:0 -44px} + +/* ColorSplitButton */ +.o2k7Skin div.mceColorSplitMenu table {background:#FFF; border:1px solid gray} +.o2k7Skin .mceColorSplitMenu td {padding:2px} +.o2k7Skin .mceColorSplitMenu a {display:block; width:9px; height:9px; overflow:hidden; border:1px solid #808080} +.o2k7Skin .mceColorSplitMenu td.mceMoreColors {padding:1px 3px 1px 1px} +.o2k7Skin .mceColorSplitMenu a.mceMoreColors {width:100%; height:auto; text-align:center; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; line-height:20px; border:1px solid #FFF} +.o2k7Skin .mceColorSplitMenu a.mceMoreColors:hover {border:1px solid #0A246A; background-color:#B6BDD2} +.o2k7Skin a.mceMoreColors:hover {border:1px solid #0A246A} +.o2k7Skin .mceColorPreview {margin-left:2px; width:16px; height:4px; overflow:hidden; background:#9a9b9a;overflow:hidden} +.o2k7Skin .mce_forecolor span.mceAction, .o2k7Skin .mce_backcolor span.mceAction {height:15px;overflow:hidden} + +/* Menu */ +.o2k7Skin .mceMenu {position:absolute; left:0; top:0; z-index:1000; border:1px solid #ABC6DD} +.o2k7Skin .mceNoIcons span.mceIcon {width:0;} +.o2k7Skin .mceNoIcons a .mceText {padding-left:10px} +.o2k7Skin .mceMenu table {background:#FFF} +.o2k7Skin .mceMenu a, .o2k7Skin .mceMenu span, .o2k7Skin .mceMenu {display:block} +.o2k7Skin .mceMenu td {height:20px} +.o2k7Skin .mceMenu a {position:relative;padding:3px 0 4px 0} +.o2k7Skin .mceMenu .mceText {position:relative; display:block; font-family:Tahoma,Verdana,Arial,Helvetica; color:#000; cursor:default; margin:0; padding:0 25px 0 25px; display:block} +.o2k7Skin .mceMenu span.mceText, .o2k7Skin .mceMenu .mcePreview {font-size:11px} +.o2k7Skin .mceMenu pre.mceText {font-family:Monospace} +.o2k7Skin .mceMenu .mceIcon {position:absolute; top:0; left:0; width:22px;} +.o2k7Skin .mceMenu .mceMenuItemEnabled a:hover, .o2k7Skin .mceMenu .mceMenuItemActive {background-color:#dbecf3} +.o2k7Skin td.mceMenuItemSeparator {background:#DDD; height:1px} +.o2k7Skin .mceMenuItemTitle a {border:0; background:#E5EFFD; border-bottom:1px solid #ABC6DD} +.o2k7Skin .mceMenuItemTitle span.mceText {color:#000; font-weight:bold; padding-left:4px} +.o2k7Skin .mceMenuItemDisabled .mceText {color:#888} +.o2k7Skin .mceMenuItemSelected .mceIcon {background:url(../default/img/menu_check.gif)} +.o2k7Skin .mceNoIcons .mceMenuItemSelected a {background:url(../default/img/menu_arrow.gif) no-repeat -6px center} +.o2k7Skin .mceMenu span.mceMenuLine {display:none} +.o2k7Skin .mceMenuItemSub a {background:url(../default/img/menu_arrow.gif) no-repeat top right;} + +/* Progress,Resize */ +.o2k7Skin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; filter:alpha(opacity=50); background:#FFF} +.o2k7Skin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(../default/img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px} +.o2k7Skin .mcePlaceHolder {border:1px dotted gray} + +/* Formats */ +.o2k7Skin .mce_formatPreview a {font-size:10px} +.o2k7Skin .mce_p span.mceText {} +.o2k7Skin .mce_address span.mceText {font-style:italic} +.o2k7Skin .mce_pre span.mceText {font-family:monospace} +.o2k7Skin .mce_h1 span.mceText {font-weight:bolder; font-size: 2em} +.o2k7Skin .mce_h2 span.mceText {font-weight:bolder; font-size: 1.5em} +.o2k7Skin .mce_h3 span.mceText {font-weight:bolder; font-size: 1.17em} +.o2k7Skin .mce_h4 span.mceText {font-weight:bolder; font-size: 1em} +.o2k7Skin .mce_h5 span.mceText {font-weight:bolder; font-size: .83em} +.o2k7Skin .mce_h6 span.mceText {font-weight:bolder; font-size: .75em} + +/* Theme */ +.o2k7Skin span.mce_bold {background-position:0 0} +.o2k7Skin span.mce_italic {background-position:-60px 0} +.o2k7Skin span.mce_underline {background-position:-140px 0} +.o2k7Skin span.mce_strikethrough {background-position:-120px 0} +.o2k7Skin span.mce_undo {background-position:-160px 0} +.o2k7Skin span.mce_redo {background-position:-100px 0} +.o2k7Skin span.mce_cleanup {background-position:-40px 0} +.o2k7Skin span.mce_bullist {background-position:-20px 0} +.o2k7Skin span.mce_numlist {background-position:-80px 0} +.o2k7Skin span.mce_justifyleft {background-position:-460px 0} +.o2k7Skin span.mce_justifyright {background-position:-480px 0} +.o2k7Skin span.mce_justifycenter {background-position:-420px 0} +.o2k7Skin span.mce_justifyfull {background-position:-440px 0} +.o2k7Skin span.mce_anchor {background-position:-200px 0} +.o2k7Skin span.mce_indent {background-position:-400px 0} +.o2k7Skin span.mce_outdent {background-position:-540px 0} +.o2k7Skin span.mce_link {background-position:-500px 0} +.o2k7Skin span.mce_unlink {background-position:-640px 0} +.o2k7Skin span.mce_sub {background-position:-600px 0} +.o2k7Skin span.mce_sup {background-position:-620px 0} +.o2k7Skin span.mce_removeformat {background-position:-580px 0} +.o2k7Skin span.mce_newdocument {background-position:-520px 0} +.o2k7Skin span.mce_image {background-position:-380px 0} +.o2k7Skin span.mce_help {background-position:-340px 0} +.o2k7Skin span.mce_code {background-position:-260px 0} +.o2k7Skin span.mce_hr {background-position:-360px 0} +.o2k7Skin span.mce_visualaid {background-position:-660px 0} +.o2k7Skin span.mce_charmap {background-position:-240px 0} +.o2k7Skin span.mce_paste {background-position:-560px 0} +.o2k7Skin span.mce_copy {background-position:-700px 0} +.o2k7Skin span.mce_cut {background-position:-680px 0} +.o2k7Skin span.mce_blockquote {background-position:-220px 0} +.o2k7Skin .mce_forecolor span.mceAction {background-position:-720px 0} +.o2k7Skin .mce_backcolor span.mceAction {background-position:-760px 0} +.o2k7Skin span.mce_forecolorpicker {background-position:-720px 0} +.o2k7Skin span.mce_backcolorpicker {background-position:-760px 0} + +/* Plugins */ +.o2k7Skin span.mce_advhr {background-position:-0px -20px} +.o2k7Skin span.mce_ltr {background-position:-20px -20px} +.o2k7Skin span.mce_rtl {background-position:-40px -20px} +.o2k7Skin span.mce_emotions {background-position:-60px -20px} +.o2k7Skin span.mce_fullpage {background-position:-80px -20px} +.o2k7Skin span.mce_fullscreen {background-position:-100px -20px} +.o2k7Skin span.mce_iespell {background-position:-120px -20px} +.o2k7Skin span.mce_insertdate {background-position:-140px -20px} +.o2k7Skin span.mce_inserttime {background-position:-160px -20px} +.o2k7Skin span.mce_absolute {background-position:-180px -20px} +.o2k7Skin span.mce_backward {background-position:-200px -20px} +.o2k7Skin span.mce_forward {background-position:-220px -20px} +.o2k7Skin span.mce_insert_layer {background-position:-240px -20px} +.o2k7Skin span.mce_insertlayer {background-position:-260px -20px} +.o2k7Skin span.mce_movebackward {background-position:-280px -20px} +.o2k7Skin span.mce_moveforward {background-position:-300px -20px} +.o2k7Skin span.mce_media {background-position:-320px -20px} +.o2k7Skin span.mce_nonbreaking {background-position:-340px -20px} +.o2k7Skin span.mce_pastetext {background-position:-360px -20px} +.o2k7Skin span.mce_pasteword {background-position:-380px -20px} +.o2k7Skin span.mce_selectall {background-position:-400px -20px} +.o2k7Skin span.mce_preview {background-position:-420px -20px} +.o2k7Skin span.mce_print {background-position:-440px -20px} +.o2k7Skin span.mce_cancel {background-position:-460px -20px} +.o2k7Skin span.mce_save {background-position:-480px -20px} +.o2k7Skin span.mce_replace {background-position:-500px -20px} +.o2k7Skin span.mce_search {background-position:-520px -20px} +.o2k7Skin span.mce_styleprops {background-position:-560px -20px} +.o2k7Skin span.mce_table {background-position:-580px -20px} +.o2k7Skin span.mce_cell_props {background-position:-600px -20px} +.o2k7Skin span.mce_delete_table {background-position:-620px -20px} +.o2k7Skin span.mce_delete_col {background-position:-640px -20px} +.o2k7Skin span.mce_delete_row {background-position:-660px -20px} +.o2k7Skin span.mce_col_after {background-position:-680px -20px} +.o2k7Skin span.mce_col_before {background-position:-700px -20px} +.o2k7Skin span.mce_row_after {background-position:-720px -20px} +.o2k7Skin span.mce_row_before {background-position:-740px -20px} +.o2k7Skin span.mce_merge_cells {background-position:-760px -20px} +.o2k7Skin span.mce_table_props {background-position:-980px -20px} +.o2k7Skin span.mce_row_props {background-position:-780px -20px} +.o2k7Skin span.mce_split_cells {background-position:-800px -20px} +.o2k7Skin span.mce_template {background-position:-820px -20px} +.o2k7Skin span.mce_visualchars {background-position:-840px -20px} +.o2k7Skin span.mce_abbr {background-position:-860px -20px} +.o2k7Skin span.mce_acronym {background-position:-880px -20px} +.o2k7Skin span.mce_attribs {background-position:-900px -20px} +.o2k7Skin span.mce_cite {background-position:-920px -20px} +.o2k7Skin span.mce_del {background-position:-940px -20px} +.o2k7Skin span.mce_ins {background-position:-960px -20px} +.o2k7Skin span.mce_pagebreak {background-position:0 -40px} +.o2k7Skin .mce_spellchecker span.mceAction {background-position:-540px -20px} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_black.css b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_black.css new file mode 100644 index 00000000..caa7dbbb --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_black.css @@ -0,0 +1,8 @@ +/* Black */ +.o2k7SkinBlack .mceToolbar .mceToolbarStart span, .o2k7SkinBlack .mceToolbar .mceToolbarEnd span, .o2k7SkinBlack .mceButton, .o2k7SkinBlack .mceSplitButton, .o2k7SkinBlack .mceSeparator, .o2k7SkinBlack .mceSplitButton span.mceOpen, .o2k7SkinBlack .mceListBox .mceOpen {background-image:url(img/button_bg_black.png)} +.o2k7SkinBlack table, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack .mceMenuItemTitle span.mceText, .o2k7SkinBlack .mceStatusbar div, .o2k7SkinBlack .mceStatusbar span, .o2k7SkinBlack .mceStatusbar a {background:#535353; color:#FFF} +.o2k7SkinBlack table.mceListBoxEnabled .mceText, o2k7SkinBlack .mceListBox .mceText {background:#FFF; border:1px solid #CBCFD4; border-bottom-color:#989FA9; border-right:0} +.o2k7SkinBlack table.mceListBoxEnabled:hover .mceText, .o2k7Skin .mceListBoxHover .mceText, .o2k7Skin .mceListBoxSelected .mceText {background:#FFF; border:1px solid #FFBD69; border-right:0} +.o2k7SkinBlack .mceExternalToolbar, .o2k7SkinBlack .mceListBox .mceText, .o2k7SkinBlack div.mceMenu, .o2k7SkinBlack table.mceLayout, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack table.mceLayout tr.mceFirst td, .o2k7SkinBlack table.mceLayout, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack table.mceLayout tr.mceLast td, .o2k7SkinBlack .mceIframeContainer {border-color: #535353;} +.o2k7SkinBlack table.mceSplitButtonEnabled:hover a.mceAction, .o2k7Skin .mceSplitButtonHover a.mceAction, .o2k7Skin .mceSplitButtonSelected {background-image:url(img/button_bg_black.png)} +.o2k7SkinBlack .mceMenu .mceMenuItemEnabled a:hover, .o2k7Skin .mceMenu .mceMenuItemActive {background-color:#FFE7A1} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_silver.css b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_silver.css new file mode 100644 index 00000000..bf3c4797 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_silver.css @@ -0,0 +1,5 @@ +/* Silver */ +.o2k7SkinSilver .mceToolbar .mceToolbarStart span, .o2k7SkinSilver .mceButton, .o2k7SkinSilver .mceSplitButton, .o2k7SkinSilver .mceSeparator, .o2k7SkinSilver .mceSplitButton span.mceOpen, .o2k7SkinSilver .mceListBox .mceOpen {background-image:url(img/button_bg_silver.png)} +.o2k7SkinSilver table, .o2k7SkinSilver .mceMenuItemTitle a {background:#eee} +.o2k7SkinSilver .mceListBox .mceText {background:#FFF} +.o2k7SkinSilver .mceExternalToolbar, .o2k7SkinSilver .mceListBox .mceText, .o2k7SkinSilver div.mceMenu, .o2k7SkinSilver table.mceLayout, .o2k7SkinSilver .mceMenuItemTitle a, .o2k7SkinSilver table.mceLayout tr.mceFirst td, .o2k7SkinSilver table.mceLayout, .o2k7SkinSilver .mceMenuItemTitle a, .o2k7SkinSilver table.mceLayout tr.mceLast td, .o2k7SkinSilver .mceIframeContainer {border-color: #bbb} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css new file mode 100644 index 00000000..16d589c4 --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css @@ -0,0 +1,26 @@ +body, td, pre {color:#000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; margin:8px;} +body {background:#FFF;} +body.mceForceColors {background:#FFF; color:#000;} +h1 {font-size: 2em} +h2 {font-size: 1.5em} +h3 {font-size: 1.17em} +h4 {font-size: 1em} +h5 {font-size: .83em} +h6 {font-size: .75em} +.mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;} +a.mceItemAnchor {width:12px; line-height:6px; overflow:hidden; padding-left:12px; background:url(img/items.gif) no-repeat bottom left;} +img.mceItemAnchor {width:12px; height:12px; background:url(img/items.gif) no-repeat;} +img {border:0;} + +/* IE +* html body { +scrollbar-3dlight-color:#F0F0EE; +scrollbar-arrow-color:#676662; +scrollbar-base-color:#F0F0EE; +scrollbar-darkshadow-color:#DDD; +scrollbar-face-color:#E0E0DD; +scrollbar-highlight-color:#F0F0EE; +scrollbar-shadow-color:#F0F0EE; +scrollbar-track-color:#F5F5F5; +} +*/ \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css new file mode 100644 index 00000000..344d7e2d --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css @@ -0,0 +1,119 @@ +/* Generic */ +body { +font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; +/*scrollbar-3dlight-color:#F0F0EE; +scrollbar-arrow-color:#676662; +scrollbar-base-color:#F0F0EE; +scrollbar-darkshadow-color:#DDDDDD; +scrollbar-face-color:#E0E0DD; +scrollbar-highlight-color:#F0F0EE; +scrollbar-shadow-color:#F0F0EE; +scrollbar-track-color:#F5F5F5;*/ +background:#E4F2FD; +padding:0; +margin:8px 8px 0 8px; +} + +html {background:#E4F2FD;} +td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} +textarea {resize:none;outline:none;} +a:link, a:visited {color:black;} +a:hover {color:#2B6FB6;} + +/* Forms */ +fieldset {margin:0; padding:4px; border:1px solid #919B9C; font-family:Verdana, Arial; font-size:10px;} +legend {color:#2B6FB6; font-weight:bold;} +label.msg {display:none;} +label.invalid {color:#EE0000; display:inline;} +input.invalid {border:1px solid #EE0000;} +input {background:#FFF; border:1px solid #CCC;} +input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} +input, select, textarea {border:1px solid #808080;} +input.radio {border:1px none #000000; background:transparent; vertical-align:middle;} +input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;} +.input_noborder {border:0;} + +/* Buttons */ +#insert, #cancel, input.mceButton, .updateButton { +border: 1px solid #bbb; +margin:0; +padding:0 0 1px; +font-weight:bold; +font-size: 11px; +width:94px; +height:24px; +background:url(img/fade-butt.png) 0 0; +cursor:pointer; +} +#insert:hover, #cancel:hover, input.mceButton:hover, .updateButton:hover, +#insert:focus, #cancel:focus, input.mceButton:focus, .updateButton:focus { +border: 1px solid #555; +} + +/* Browse */ +a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;} +.mceOldBoxModel a.browse span {width:22px; height:20px;} +a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;} +a.browse span.disabled {border:1px solid white; -moz-opacity:0.3; opacity:0.3; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);} +a.browse:hover span.disabled {border:1px solid white; background-color:transparent;} +a.pickcolor span {display:block; width:20px; height:16px; background:url(../../img/icons.gif) -840px 0; margin-left:2px;} +.mceOldBoxModel a.pickcolor span {width:21px; height:17px;} +a.pickcolor:hover span {background-color:#B2BBD0;} +a.pickcolor:hover span.disabled {} + +/* Charmap */ +table.charmap {border:1px solid #AAA; text-align:center} +td.charmap, #charmap a {width:18px; height:18px; color:#000; border:1px solid #AAA; text-align:center; font-size:12px; vertical-align:middle; line-height: 18px;} +#charmap a {display:block; color:#000; text-decoration:none; border:0} +#charmap a:hover {background:#CCC;color:#2B6FB6} +#charmap #codeN {font-size:10px; font-family:Arial,Helvetica,sans-serif; text-align:center} +#charmap #codeV {font-size:40px; height:80px; border:1px solid #AAA; text-align:center} +#charmap #charmapView {background-color:#fff;} + +/* Source */ +.wordWrapCode {vertical-align:middle; border:1px none #000000; background:transparent;} +.mceActionPanel {margin-top:5px;} + +/* Tabs classes */ +.tabs {width:100%; height:18px; line-height:normal; background:url(img/tabs.gif) repeat-x 0 -72px;} +.tabs ul {margin:0; padding:0; list-style:none;} +.tabs li {float:left; background:url(img/tabs.gif) no-repeat 0 0; margin:0 2px 0 0; padding:0 0 0 10px; line-height:17px; height:18px; display:block;} +.tabs li.current {background:url(img/tabs.gif) no-repeat 0 -18px; margin-right:2px;} +.tabs span {float:left; display:block; background:url(img/tabs.gif) no-repeat right -36px; padding:0px 10px 0 0;} +.tabs .current span {background:url(img/tabs.gif) no-repeat right -54px;} +.tabs a {text-decoration:none; font-family:Verdana, Arial; font-size:10px;} +.tabs a:link, .tabs a:visited, .tabs a:hover {color:black;} + +/* Panels */ +.panel_wrapper div.panel {display:none;} +.panel_wrapper div.current {display:block; width:100%; height:300px; overflow:visible;} +.panel_wrapper {border:1px solid #919B9C; border-top:0px; padding:10px; padding-top:5px; clear:both; background:white;} + +/* Columns */ +.column {float:left;} +.properties {width:100%;} +.properties .column1 {} +.properties .column2 {text-align:left;} + +/* Titles */ +h1, h2, h3, h4 {color:#2B6FB6; margin:0; padding:0; padding-top:5px;} +h3 {font-size:14px;} +.title {font-size:12px; font-weight:bold; color:#2B6FB6;} + +/* Dialog specific */ +#link .panel_wrapper, #link div.current {height:125px;} +#image .panel_wrapper, #image div.current {height:200px;} +#plugintable thead {font-weight:bold; background:#DDD;} +#plugintable, #about #plugintable td {border:1px solid #919B9C;} +#plugintable {width:96%; margin-top:10px;} +#pluginscontainer {height:290px; overflow:auto;} +#colorpicker #preview {float:right; width:50px; height:14px;line-height:1px; border:1px solid black; margin-left:5px;} +#colorpicker #colors {float:left; border:1px solid gray; cursor:crosshair;} +#colorpicker #light {border:1px solid gray; margin-left:5px; float:left;width:15px; height:150px; cursor:crosshair;} +#colorpicker #light div {overflow:hidden;} +#colorpicker #previewblock {float:right; padding-left:10px; height:20px;} +#colorpicker .panel_wrapper div.current {height:175px;} +#colorpicker #namedcolors {width:150px;} +#colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;} +#colorpicker #colornamecontainer {margin-top:5px;} +#colorpicker #picker_panel fieldset {margin:auto;width:325px;} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png new file mode 100644 index 00000000..df904395 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/button_bg.png b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/button_bg.png new file mode 100644 index 00000000..12cfb419 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/button_bg.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif new file mode 100644 index 00000000..687b241e Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png new file mode 100644 index 00000000..42f08b79 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/separator.gif b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/separator.gif similarity index 100% rename from wp-includes/js/tinymce/themes/advanced/images/separator.gif rename to wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/separator.gif diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/tabs.gif b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/tabs.gif new file mode 100644 index 00000000..ce4be635 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/tabs.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css new file mode 100644 index 00000000..c12d3a5b --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css @@ -0,0 +1,382 @@ +/* Reset */ +.wp_themeSkin table, .wp_themeSkin tbody, .wp_themeSkin a, .wp_themeSkin img, .wp_themeSkin tr, .wp_themeSkin div, .wp_themeSkin td, .wp_themeSkin iframe, .wp_themeSkin span, .wp_themeSkin *, .wp_themeSkin .mceText { +border:0; margin:0; padding:0; white-space:nowrap; text-decoration:none; font-weight:normal; cursor:default; vertical-align:baseline; width:auto; border-collapse:separate; +} +.wp_themeSkin a:hover, .wp_themeSkin a:link, .wp_themeSkin a:visited, .wp_themeSkin a:active {text-decoration:none; font-weight:normal; cursor:default;} +.wp_themeSkin table td {vertical-align:middle} + +/* Containers */ +.wp_themeSkin table {} +.wp_themeSkin iframe {display:block;} +.wp_themeSkin .mceToolbar {padding: 2px;} + +/* External */ +.wp_themeSkin .mceExternalToolbar {position:absolute; border-bottom:0; display:none} +.wp_themeSkin .mceExternalToolbar td.mceToolbar {padding-right:13px;} +.wp_themeSkin .mceExternalClose {position:absolute; top:3px; right:3px; width:7px; height:7px; background:url(../../img/icons.gif) -820px 0} + +/* Layout */ +.wp_themeSkin table.mceToolbar, .wp_themeSkin tr.mceFirst .mceToolbar tr td, .wp_themeSkin tr.mceLast .mceToolbar tr td {border:0; margin:0; padding:0} +.wp_themeSkin table.mceLayout {border:0;} +.wp_themeSkin .mceIframeContainer {} +.wp_themeSkin .mceStatusbar {display:block; font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:9pt; line-height:16px; overflow:visible;height:20px;} +.wp_themeSkin .mceStatusbar div {float:left; padding:2px;} +.wp_themeSkin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize} +.wp_themeSkin .mceStatusbar a:hover {text-decoration:underline} +.wp_themeSkin table.mceToolbar {margin: 0 2px 2px;} +.wp_themeSkin #content_toolbar1 {margin-top: 2px;} +.wp_themeSkin .mceToolbar .mceToolbarEndListBox span {display:none} +.wp_themeSkin span.mceIcon, .wp_themeSkin img.mceIcon {display:block; width:20px; height:20px} +.wp_themeSkin .mceIcon {background:url(../../img/icons.gif) no-repeat 20px 20px} + +/* Button */ +.wp_themeSkin .mceButton { + display:block; + width: 20px; + height: 20px; + cursor: default; + padding: 1px 2px; + margin: 1px; + background-image: url(img/butt2.png); + background-position: 2px 1px; + background-repeat: no-repeat; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + -khtml-border-radius: 3px; + border-radius: 3px; +} +.wp_themeSkin a.mceButton span, .wp_themeSkin a.mceButton img {} +.wp_themeSkin .mceOldBoxModel a.mceButton span, .wp_themeSkin .mceOldBoxModel a.mceButton img {margin:0 0 0 1px} +.wp_themeSkin a.mceButtonEnabled:hover { + background-position:0 -20px; +} +.wp_themeSkin a.mceButtonActive, .wp_themeSkin a.mceButtonSelected { + background-position:0 -20px; +} +.wp_themeSkin .mceButtonDisabled .mceIcon {opacity:0.3; filter:alpha(opacity=30);} +.wp_themeSkin .mceButtonDisabled {} + +/* Separator */ +.wp_themeSkin .mceSeparator { + height: 24px; + width: 1px; + display: block; + background: transparent; + overflow: hidden; + margin: 0 2px; +} + +/* ListBox */ +.wp_themeSkin .mceListBox, .wp_themeSkin .mceListBox a {display:block} +.wp_themeSkin .mceListBox .mceText { + padding: 1px 2px 1px 5px; + text-align:left; + text-decoration: none !important; + width:70px; + background-image: url(img/butt2.png); + background-position: 1px 1px; + background-repeat: repeat-x; + font-family: Tahoma,Verdana,Arial,Helvetica; + font-size: 11px; + height: 20px; + line-height: 20px; + overflow: hidden; +} +.wp_themeSkin .mceListBox { + margin: 1px; + direction: ltr; +} +.wp_themeSkin .mceListBox .mceOpen { + width: 14px; + height: 20px; + border-collapse: separate; + background-image: url(img/butt2.png); + background-position: 1px 1px; + background-repeat: repeat-x; + padding: 1px; + border-left: 0 none !important; +} +.wp_themeSkin .mceListBox .mceOpen span { + display: block; + width:14px; + height:20px; + background-image: url(img/down_arrow.gif); + background-position: 2px 1px; + background-repeat: no-repeat; +} +.wp_themeSkin table.mceListBoxEnabled:hover .mceText, +.wp_themeSkin .mceListBoxHover .mceText, +.wp_themeSkin .mceListBoxSelected .mceText, +.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen, +.wp_themeSkin .mceListBoxHover .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceOpen { + background-image: none; +} +.wp_themeSkin .mceListBoxDisabled .mceText {color:gray} +.wp_themeSkin .mceListBoxMenu {overflow:auto; overflow-x:hidden} +.wp_themeSkin .mceOldBoxModel .mceListBox .mceText {height:22px} +.wp_themeSkin select.mceListBox {font-family:Tahoma,Verdana,Arial,Helvetica; font-size:12px;} + +/* SplitButton */ +.wp_themeSkin .mceSplitButton a, .wp_themeSkin .mceSplitButton span {display:block; height:20px} +.wp_themeSkin .mceSplitButton { + display:block; + margin: 1px; + direction: ltr; +} +.wp_themeSkin table.mceSplitButton td { + padding: 2px; +} +.wp_themeSkin .mceSplitButton a.mceAction { + height:20px; + width:20px; + background-image: url(img/butt2.png); + background-position: 1px 1px; + background-repeat: repeat-x; + padding: 1px 2px; +} +.wp_themeSkin .mceSplitButton span.mceAction { + background: url(../../img/icons.gif) 20px 20px; + width:20px; +} +.wp_themeSkin .mceSplitButton a.mceOpen { + width:10px; + height:20px; + border-collapse:separate; + background-image: url(img/butt2.png); + background-position: 1px 1px; + background-repeat: repeat-x; + padding: 1px; + border-left: 0 none !important; +} +.wp_themeSkin .mceSplitButton span.mceOpen { + width:10px; + background-image: url(img/down_arrow.gif); + background-position: 0px 1px; + background-repeat: no-repeat; + border-collapse:separate; + border-left: 0 none !important; +} +.wp_themeSkin .mceSplitButton a.mceOpen:hover, +.wp_themeSkin .mceSplitButtonSelected a.mceOpen, +.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction, +.wp_themeSkin .mceSplitButton a.mceAction:hover { + background-image: none; +} +.wp_themeSkin table.mceSplitButtonEnabled:hover span.mceOpen, +.wp_themeSkin .mceSplitButtonHover span.mceOpen, +.wp_themeSkin .mceSplitButtonSelected span.mceOpen { +} +.wp_themeSkin .mceSplitButtonDisabled .mceAction { + opacity:0.3; filter:alpha(opacity=30); +} +.wp_themeSkin .mceListBox a.mceText, .wp_themeSkin .mceSplitButton a.mceAction { + -moz-border-radius-bottomleft: 3px; + -webkit-border-bottom-left-radius: 3px; + -khtml-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; + -moz-border-radius-topleft: 3px; + -webkit-border-top-left-radius: 3px; + -khtml-border-top-left-radius: 3px; + border-top-left-radius: 3px; +} +.wp_themeSkin .mceSplitButton a.mceOpen, .wp_themeSkin .mceListBox a.mceOpen { + -moz-border-radius-bottomright: 3px; + -webkit-border-bottom-right-radius: 3px; + -khtml-border-bottom-right-radius: 3px; + border-bottom-right-radius: 3px; + -moz-border-radius-topright: 3px; + -webkit-border-top-right-radius: 3px; + -khtml-border-top-right-radius: 3px; + border-top-right-radius: 3px; +} + +/* ColorSplitButton */ +.wp_themeSkin div.mceColorSplitMenu table {} +.wp_themeSkin .mceColorSplitMenu td {padding:2px} +.wp_themeSkin .mceColorSplitMenu a {display:block; width:9px; height:9px; overflow:hidden;} +.wp_themeSkin .mceColorSplitMenu td.mceMoreColors {padding:1px 3px 1px 1px} +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors {width:100%; height:auto; text-align:center; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; line-height:20px;} +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {} +.wp_themeSkin a.mceMoreColors:hover {} +.wp_themeSkin .mceColorPreview {position:absolute; top:15px; left:2px; width:16px; height:4px; overflow:hidden} + +/* Menu */ +.wp_themeSkin .mceMenu {position:absolute; left:0; top:0; z-index:1000;} +.wp_themeSkin .mceNoIcons span.mceIcon {width:0;} +.wp_themeSkin .mceNoIcons a .mceText {padding-left:10px} +.wp_themeSkin .mceMenu table {} +.wp_themeSkin .mceMenu a, .wp_themeSkin .mceMenu span, .wp_themeSkin .mceMenu {display:block} +.wp_themeSkin .mceMenu td {height:20px;overflow:hidden;} +.wp_themeSkin .mceMenu a { + position:relative; + padding:3px 0 4px 0; + text-decoration: none !important; +} +.wp_themeSkin .mceMenu .mceText { + position:relative; + display:block; + font-family:Tahoma,Verdana,Arial,Helvetica; + cursor:default; + margin:0; + padding:0 25px; +} +.wp_themeSkin .mceMenu span.mceText, .wp_themeSkin .mceMenu .mcePreview {font-size:11px} +.wp_themeSkin .mceMenu pre.mceText {font-family:Monospace} +.wp_themeSkin .mceMenu .mceIcon {position:absolute; top:0; left:0; width:22px;} +.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover, +.wp_themeSkin .mceMenu .mceMenuItemActive {} +.wp_themeSkin td.mceMenuItemSeparator {height:1px} +.wp_themeSkin .mceMenuItemTitle a { + border-top: 0; + border-right: 0; + border-left: 0; + border-bottom-style: solid; + border-bottom-width: 1px; + text-decoration: none !important; +} +.wp_themeSkin .mceMenuItemTitle span.mceText {font-weight:bold; padding-left:4px} +.wp_themeSkin .mceMenuItemDisabled .mceText {} +.wp_themeSkin .mceMenuItemSelected .mceIcon {background:url(../default/img/menu_check.gif)} +.wp_themeSkin .mceNoIcons .mceMenuItemSelected a {background:url(../default/img/menu_arrow.gif) no-repeat -6px center} +.wp_themeSkin .mceMenu span.mceMenuLine {display:none} +.wp_themeSkin .mceMenuItemSub a {background:url(../default/img/menu_arrow.gif) no-repeat top right;} + +/* Progress,Resize */ +.wp_themeSkin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; filter:alpha(opacity=50); background:#FFF} +.wp_themeSkin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(../default/img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px} +.wp_themeSkin .mcePlaceHolder {border:1px dotted gray} + +/* Formats */ +.wp_themeSkin .mce_formatPreview a {font-size:10px} +.wp_themeSkin .mce_p span.mceText {} +.wp_themeSkin .mce_address span.mceText {font-style:italic} +.wp_themeSkin .mce_pre span.mceText {font-family:monospace} +.wp_themeSkin .mce_h1 span.mceText {font-weight:bolder; font-size: 2em} +.wp_themeSkin .mce_h2 span.mceText {font-weight:bolder; font-size: 1.5em} +.wp_themeSkin .mce_h3 span.mceText {font-weight:bolder; font-size: 1.17em} +.wp_themeSkin .mce_h4 span.mceText {font-weight:bolder; font-size: 1em} +.wp_themeSkin .mce_h5 span.mceText {font-weight:bolder; font-size: .83em} +.wp_themeSkin .mce_h6 span.mceText {font-weight:bolder; font-size: .75em} + +/* Theme */ +.wp_themeSkin span.mce_bold {background-position:0 0} +.wp_themeSkin span.mce_italic {background-position:-60px 0} +.wp_themeSkin span.mce_underline {background-position:-140px 0} +.wp_themeSkin span.mce_strikethrough {background-position:-120px 0} +.wp_themeSkin span.mce_undo {background-position:-160px 0} +.wp_themeSkin span.mce_redo {background-position:-100px 0} +.wp_themeSkin span.mce_cleanup {background-position:-40px 0} +.wp_themeSkin span.mce_bullist {background-position:-20px 0} +.wp_themeSkin span.mce_numlist {background-position:-80px 0} +.wp_themeSkin span.mce_justifyleft {background-position:-460px 0} +.wp_themeSkin span.mce_justifyright {background-position:-480px 0} +.wp_themeSkin span.mce_justifycenter {background-position:-420px 0} +.wp_themeSkin span.mce_justifyfull {background-position:-440px 0} +.wp_themeSkin span.mce_anchor {background-position:-200px 0} +.wp_themeSkin span.mce_indent {background-position:-400px 0} +.wp_themeSkin span.mce_outdent {background-position:-540px 0} +.wp_themeSkin span.mce_link {background-position:-500px 0} +.wp_themeSkin span.mce_unlink {background-position:-640px 0} +.wp_themeSkin span.mce_sub {background-position:-600px 0} +.wp_themeSkin span.mce_sup {background-position:-620px 0} +.wp_themeSkin span.mce_removeformat {background-position:-580px 0} +.wp_themeSkin span.mce_newdocument {background-position:-520px 0} +.wp_themeSkin span.mce_image {background-position:-380px 0} +.wp_themeSkin span.mce_help {background-position:-340px 0} +.wp_themeSkin span.mce_code {background-position:-260px 0} +.wp_themeSkin span.mce_hr {background-position:-360px 0} +.wp_themeSkin span.mce_visualaid {background-position:-660px 0} +.wp_themeSkin span.mce_charmap {background-position:-240px 0} +.wp_themeSkin span.mce_paste {background-position:-560px 0} +.wp_themeSkin span.mce_copy {background-position:-700px 0} +.wp_themeSkin span.mce_cut {background-position:-680px 0} +.wp_themeSkin span.mce_blockquote {background-position:-220px 0} +.wp_themeSkin .mce_forecolor span.mceAction {background-position:-720px 0} +.wp_themeSkin .mce_backcolor span.mceAction {background-position:-760px 0} +.wp_themeSkin .mce_forecolorpicker {background-position:-720px 0} +.wp_themeSkin .mce_backcolorpicker {background-position:-760px 0} + +/* Plugins */ +.wp_themeSkin span.mce_advhr {background-position:-0px -20px} +.wp_themeSkin span.mce_ltr {background-position:-20px -20px} +.wp_themeSkin span.mce_rtl {background-position:-40px -20px} +.wp_themeSkin span.mce_emotions {background-position:-60px -20px} +.wp_themeSkin span.mce_fullpage {background-position:-80px -20px} +.wp_themeSkin span.mce_fullscreen {background-position:-100px -20px} +.wp_themeSkin span.mce_iespell {background-position:-120px -20px} +.wp_themeSkin span.mce_insertdate {background-position:-140px -20px} +.wp_themeSkin span.mce_inserttime {background-position:-160px -20px} +.wp_themeSkin span.mce_absolute {background-position:-180px -20px} +.wp_themeSkin span.mce_backward {background-position:-200px -20px} +.wp_themeSkin span.mce_forward {background-position:-220px -20px} +.wp_themeSkin span.mce_insert_layer {background-position:-240px -20px} +.wp_themeSkin span.mce_insertlayer {background-position:-260px -20px} +.wp_themeSkin span.mce_movebackward {background-position:-280px -20px} +.wp_themeSkin span.mce_moveforward {background-position:-300px -20px} +.wp_themeSkin span.mce_media {background-position:-320px -20px} +.wp_themeSkin span.mce_nonbreaking {background-position:-340px -20px} +.wp_themeSkin span.mce_pastetext {background-position:-360px -20px} +.wp_themeSkin span.mce_pasteword {background-position:-380px -20px} +.wp_themeSkin span.mce_selectall {background-position:-400px -20px} +.wp_themeSkin span.mce_preview {background-position:-420px -20px} +.wp_themeSkin span.mce_print {background-position:-440px -20px} +.wp_themeSkin span.mce_cancel {background-position:-460px -20px} +.wp_themeSkin span.mce_save {background-position:-480px -20px} +.wp_themeSkin span.mce_replace {background-position:-500px -20px} +.wp_themeSkin span.mce_search {background-position:-520px -20px} +.wp_themeSkin span.mce_styleprops {background-position:-560px -20px} +.wp_themeSkin span.mce_table {background-position:-580px -20px} +.wp_themeSkin span.mce_cell_props {background-position:-600px -20px} +.wp_themeSkin span.mce_delete_table {background-position:-620px -20px} +.wp_themeSkin span.mce_delete_col {background-position:-640px -20px} +.wp_themeSkin span.mce_delete_row {background-position:-660px -20px} +.wp_themeSkin span.mce_col_after {background-position:-680px -20px} +.wp_themeSkin span.mce_col_before {background-position:-700px -20px} +.wp_themeSkin span.mce_row_after {background-position:-720px -20px} +.wp_themeSkin span.mce_row_before {background-position:-740px -20px} +.wp_themeSkin span.mce_merge_cells {background-position:-760px -20px} +.wp_themeSkin span.mce_table_props {background-position:-980px -20px} +.wp_themeSkin span.mce_row_props {background-position:-780px -20px} +.wp_themeSkin span.mce_split_cells {background-position:-800px -20px} +.wp_themeSkin span.mce_template {background-position:-820px -20px} +.wp_themeSkin span.mce_visualchars {background-position:-840px -20px} +.wp_themeSkin span.mce_abbr {background-position:-860px -20px} +.wp_themeSkin span.mce_acronym {background-position:-880px -20px} +.wp_themeSkin span.mce_attribs {background-position:-900px -20px} +.wp_themeSkin span.mce_cite {background-position:-920px -20px} +.wp_themeSkin span.mce_del {background-position:-940px -20px} +.wp_themeSkin span.mce_ins {background-position:-960px -20px} +.wp_themeSkin span.mce_pagebreak {background-position:0 -40px} +.wp_themeSkin .mce_spellchecker span.mceAction {background-position:-540px -20px} + +/* border */ +.wp_themeSkin .mceExternalToolbar, +.wp_themeSkin .mceButton, +.wp_themeSkin a.mceButtonEnabled:hover, +.wp_themeSkin a.mceButtonActive, +.wp_themeSkin a.mceButtonSelected, +.wp_themeSkin .mceListBox .mceText, +.wp_themeSkin .mceListBox .mceOpen, +.wp_themeSkin table.mceListBoxEnabled:hover .mceText, +.wp_themeSkin .mceListBoxHover .mceText, +.wp_themeSkin .mceListBoxSelected .mceText, +.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen, +.wp_themeSkin .mceListBoxHover .mceOpen, +.wp_themeSkin .mceListBoxSelected .mceOpen, +.wp_themeSkin select.mceListBox, +.wp_themeSkin .mceSplitButton a.mceAction, +.wp_themeSkin .mceSplitButton a.mceOpen, +.wp_themeSkin .mceSplitButton a.mceOpen:hover, +.wp_themeSkin .mceSplitButtonSelected a.mceOpen, +.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction, +.wp_themeSkin .mceSplitButton a.mceAction:hover, +.wp_themeSkin div.mceColorSplitMenu table, +.wp_themeSkin .mceColorSplitMenu a, +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors, +.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover, +.wp_themeSkin a.mceMoreColors:hover, +.wp_themeSkin .mceMenu { + border-style: solid; + border-width: 1px; +} diff --git a/wp-includes/js/tinymce/themes/advanced/source_editor.htm b/wp-includes/js/tinymce/themes/advanced/source_editor.htm index bb3a79b0..dcc636db 100644 --- a/wp-includes/js/tinymce/themes/advanced/source_editor.htm +++ b/wp-includes/js/tinymce/themes/advanced/source_editor.htm @@ -1,32 +1,30 @@ - {$lang_theme_code_title} - - + {#advanced_dlg.code_title} + + - - -
    -
    {$lang_theme_code_title}
    + + +
    {#advanced_dlg.code_title}
    - +

    - +
    -
    - +
    - +
    diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js index 0e83794a..bc86c405 100644 --- a/wp-includes/js/tinymce/tiny_mce.js +++ b/wp-includes/js/tinymce/tiny_mce.js @@ -1,7571 +1 @@ - -/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */ - -function TinyMCE_Engine() { - var ua; - - this.majorVersion = "2"; - this.minorVersion = "1.1.1"; - this.releaseDate = "2007-05-14"; - - this.instances = []; - this.switchClassCache = []; - this.windowArgs = []; - this.loadedFiles = []; - this.pendingFiles = []; - this.loadingIndex = 0; - this.configs = []; - this.currentConfig = 0; - this.eventHandlers = []; - this.log = []; - this.undoLevels = []; - this.undoIndex = 0; - this.typingUndoIndex = -1; - this.settings = []; - - // Browser check - ua = navigator.userAgent; - this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); - this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1); - this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1); - this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1); - this.isGecko = ua.indexOf('Gecko') != -1; // Will also be true on Safari - this.isSafari = ua.indexOf('Safari') != -1; - this.isOpera = window['opera'] && opera.buildNumber ? true : false; - this.isMac = ua.indexOf('Mac') != -1; - this.isNS7 = ua.indexOf('Netscape/7') != -1; - this.isNS71 = ua.indexOf('Netscape/7.1') != -1; - this.dialogCounter = 0; - this.plugins = []; - this.themes = []; - this.menus = []; - this.loadedPlugins = []; - this.buttonMap = []; - this.isLoaded = false; - - // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those - if (this.isOpera) { - this.isMSIE = true; - this.isGecko = false; - this.isSafari = false; - } - - this.isIE = this.isMSIE; - this.isRealIE = this.isMSIE && !this.isOpera; - - // TinyMCE editor id instance counter - this.idCounter = 0; -}; - -TinyMCE_Engine.prototype = { - init : function(settings) { - var theme, nl, baseHREF = "", i, cssPath, entities, h, p, src, elements = [], head; - - // IE 5.0x is no longer supported since 5.5, 6.0 and 7.0 now exists. We can't support old browsers forever, sorry. - if (this.isMSIE5_0) - return; - - this.settings = settings; - - // Check if valid browser has execcommand support - if (typeof(document.execCommand) == 'undefined') - return; - - // Get script base path - if (!tinyMCE.baseURL) { - // Search through head - head = document.getElementsByTagName('head')[0]; - - if (head) { - for (i=0, nl = head.getElementsByTagName('script'); i'); - this._def("font_size_classes", ''); - this._def("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large', true); - this._def("event_elements", 'a,img', true); - this._def("convert_urls", true); - this._def("table_inline_editing", false); - this._def("object_resizing", true); - this._def("custom_shortcuts", true); - this._def("convert_on_click", false); - this._def("content_css", ''); - this._def("fix_list_elements", true); - this._def("fix_table_elements", false); - this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml'); - this._def("hidden_tab_class", ''); - this._def("display_tab_class", ''); - this._def("gecko_spellcheck", false); - this._def("hide_selects_on_submit", true); - this._def("forced_root_block", false); - this._def("remove_trailing_nbsp", false); - - // Force strict loading mode to false on non Gecko browsers - if (this.isMSIE && !this.isOpera) - this.settings.strict_loading_mode = false; - - // Browser check IE - if (this.isMSIE && this.settings.browsers.indexOf('msie') == -1) - return; - - // Browser check Gecko - if (this.isGecko && this.settings.browsers.indexOf('gecko') == -1) - return; - - // Browser check Safari - if (this.isSafari && this.settings.browsers.indexOf('safari') == -1) - return; - - // Browser check Opera - if (this.isOpera && this.settings.browsers.indexOf('opera') == -1) - return; - - // If not super absolute make it so - baseHREF = tinyMCE.settings.document_base_url; - h = document.location.href; - p = h.indexOf('://'); - if (p > 0 && document.location.protocol != "file:") { - p = h.indexOf('/', p + 3); - h = h.substring(0, p); - - if (baseHREF.indexOf('://') == -1) - baseHREF = h + baseHREF; - - tinyMCE.settings.document_base_url = baseHREF; - tinyMCE.settings.document_base_prefix = h; - } - - // Trim away query part - if (baseHREF.indexOf('?') != -1) - baseHREF = baseHREF.substring(0, baseHREF.indexOf('?')); - - this.settings.base_href = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; - - theme = this.settings.theme; - this.inlineStrict = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment'; - this.inlineTransitional = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment'; - this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP'; - this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i"); - this.posKeyCodes = [13,45,36,35,33,34,37,38,39,40]; - this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL - this.uniqueTag = ''; - this.callbacks = ['onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance']; - - // Theme url - this.settings.theme_href = tinyMCE.baseURL + "/themes/" + theme; - - if (!tinyMCE.isIE || tinyMCE.isOpera) - this.settings.force_br_newlines = false; - - if (tinyMCE.getParam("popups_css", false)) { - cssPath = tinyMCE.getParam("popups_css", ""); - - // Is relative - if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings.popups_css = this.documentBasePath + "/" + cssPath; - else - this.settings.popups_css = cssPath; - } else - this.settings.popups_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css"; - - if (tinyMCE.getParam("editor_css", false)) { - cssPath = tinyMCE.getParam("editor_css", ""); - - // Is relative - if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings.editor_css = this.documentBasePath + "/" + cssPath; - else - this.settings.editor_css = cssPath; - } else { - if (this.settings.editor_css !== '') - this.settings.editor_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; - } - - // Only do this once - if (this.configs.length == 0) { - if (typeof(TinyMCECompressed) == "undefined") { - tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad); - - if (tinyMCE.isRealIE) { - if (document.body) - tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad); - else - tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad); - } - - tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad); - tinyMCE._addUnloadEvents(); - } - } - - this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings.theme + '/editor_template' + tinyMCE.srcMode + '.js'); - this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings.language + '.js'); - this.loadCSS(this.settings.editor_css); - - // Add plugins - p = tinyMCE.getParam('plugins', '', true, ','); - if (p.length > 0) { - for (i=0; i&"]', 'g'); - }, - - _addUnloadEvents : function() { - var st = tinyMCE.settings.add_unload_trigger; - - if (tinyMCE.isIE) { - if (st) { - tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler); - tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler); - } - } else { - if (st) - tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);}); - } - }, - - _def : function(key, def_val, t) { - var v = tinyMCE.getParam(key, def_val); - - v = t ? v.replace(/\s+/g, "") : v; - - this.settings[key] = v; - }, - - hasPlugin : function(n) { - return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null; - }, - - addPlugin : function(n, p) { - var op = this.plugins[n]; - - // Use the previous plugin object base URL used when loading external plugins - p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n; - this.plugins[n] = p; - - this.loadNextScript(); - }, - - setPluginBaseURL : function(n, u) { - var op = this.plugins[n]; - - if (op) - op.baseURL = u; - else - this.plugins[n] = {baseURL : u}; - }, - - loadPlugin : function(n, u) { - u = u.indexOf('.js') != -1 ? u.substring(0, u.lastIndexOf('/')) : u; - u = u.charAt(u.length-1) == '/' ? u.substring(0, u.length-1) : u; - this.plugins[n] = {baseURL : u}; - this.loadScript(u + "/editor_plugin" + (tinyMCE.srcMode ? '_src' : '') + ".js"); - }, - - hasTheme : function(n) { - return typeof(this.themes[n]) != "undefined" && this.themes[n] != null; - }, - - addTheme : function(n, t) { - this.themes[n] = t; - - this.loadNextScript(); - }, - - addMenu : function(n, m) { - this.menus[n] = m; - }, - - hasMenu : function(n) { - return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null; - }, - - loadScript : function(url) { - var i; - - for (i=0; i'); - - this.loadedFiles[this.loadedFiles.length] = url; - }, - - loadNextScript : function() { - var d = document, se; - - if (!tinyMCE.settings.strict_loading_mode) - return; - - if (this.loadingIndex < this.pendingFiles.length) { - se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script'); - se.setAttribute('language', 'javascript'); - se.setAttribute('type', 'text/javascript'); - se.setAttribute('src', this.pendingFiles[this.loadingIndex++]); - - d.getElementsByTagName("head")[0].appendChild(se); - } else - this.loadingIndex = -1; // Done with loading - }, - - loadCSS : function(url) { - var ar = url.replace(/\s+/, '').split(','); - var lflen = 0, csslen = 0, skip = false; - var x = 0, i = 0, nl, le; - - for (x = 0,csslen = ar.length; x 0) { - /* Make sure it doesn't exist. */ - for (i=0, lflen=this.loadedFiles.length; i'); - - this.loadedFiles[this.loadedFiles.length] = ar[x]; - } - } - } - }, - - importCSS : function(doc, css) { - var css_ary = css.replace(/\s+/, '').split(','); - var csslen, elm, headArr, x, css_file; - - for (x = 0, csslen = css_ary.length; x 0) { - // Is relative, make absolute - if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/') - css_file = this.documentBasePath + "/" + css_file; - - if (typeof(doc.createStyleSheet) == "undefined") { - elm = doc.createElement("link"); - - elm.rel = "stylesheet"; - elm.href = css_file; - - if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0) - headArr[0].appendChild(elm); - } else - doc.createStyleSheet(css_file); - } - } - }, - - confirmAdd : function(e, settings) { - var elm = tinyMCE.isIE ? event.srcElement : e.target; - var elementId = elm.name ? elm.name : elm.id; - - tinyMCE.settings = settings; - - if (tinyMCE.settings.convert_on_click || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang.lang_edit_confirm))) - tinyMCE.addMCEControl(elm, elementId); - - elm.setAttribute('mce_noask', 'true'); - }, - - updateContent : function(form_element_name) { - var formElement, n, inst, doc; - - // Find MCE instance linked to given form element and copy it's value - formElement = document.getElementById(form_element_name); - for (n in tinyMCE.instances) { - inst = tinyMCE.instances[n]; - - if (!tinyMCE.isInstance(inst)) - continue; - - inst.switchSettings(); - - if (inst.formElement == formElement) { - doc = inst.getDoc(); - - tinyMCE._setHTML(doc, inst.formElement.value); - - if (!tinyMCE.isIE) - doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid); - } - } - }, - - addMCEControl : function(replace_element, form_element_name, target_document) { - var id = "mce_editor_" + tinyMCE.idCounter++; - var inst = new TinyMCE_Control(tinyMCE.settings); - - inst.editorId = id; - this.instances[id] = inst; - - inst._onAdd(replace_element, form_element_name, target_document); - }, - - removeInstance : function(ti) { - var t = [], n, i; - - // Remove from instances - for (n in tinyMCE.instances) { - i = tinyMCE.instances[n]; - - if (tinyMCE.isInstance(i) && ti != i) - t[n] = i; - } - - tinyMCE.instances = t; - - // Remove from global undo/redo - n = []; - t = tinyMCE.undoLevels; - - for (i=0; i 0) { - tinyMCE.nextUndoRedoAction = 'Undo'; - inst = this.undoLevels[--this.undoIndex]; - inst.select(); - - if (!tinyMCE.nextUndoRedoInstanceId) - inst.execCommand('Undo'); - } - } else - inst.execCommand('Undo'); - return true; - - case "Redo": - if (this.getParam('custom_undo_redo_global')) { - if (this.undoIndex <= this.undoLevels.length - 1) { - tinyMCE.nextUndoRedoAction = 'Redo'; - inst = this.undoLevels[this.undoIndex++]; - inst.select(); - - if (!tinyMCE.nextUndoRedoInstanceId) - inst.execCommand('Redo'); - } - } else - inst.execCommand('Redo'); - - return true; - - case 'mceFocus': - inst = tinyMCE.getInstanceById(value); - - if (inst) - inst.getWin().focus(); - return; - - case "mceAddControl": - case "mceAddEditor": - tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); - return; - - case "mceAddFrameControl": - tinyMCE.addMCEControl(tinyMCE._getElementById(value.element, value.document), value.element, value.document); - return; - - case "mceRemoveControl": - case "mceRemoveEditor": - tinyMCE.removeMCEControl(value); - return; - - case "mceToggleEditor": - inst = tinyMCE.getInstanceById(value); - - if (inst) { - pe = document.getElementById(inst.editorId + '_parent'); - te = inst.oldTargetElement; - - if (typeof(inst.enabled) == 'undefined') - inst.enabled = true; - - inst.enabled = !inst.enabled; - - if (!inst.enabled) { - pe.style.display = 'none'; - - if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT') - te.value = inst.getHTML(); - else - te.innerHTML = inst.getHTML(); - - te.style.display = inst.oldTargetDisplay; - tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst); - } else { - pe.style.display = 'block'; - te.style.display = 'none'; - - if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT') - inst.setHTML(te.value); - else - inst.setHTML(te.innerHTML); - - inst.useCSS = false; - tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst); - } - } else - tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); - - return; - - case "mceResetDesignMode": - // Resets the designmode state of the editors in Gecko - if (tinyMCE.isGecko) { - for (n in tinyMCE.instances) { - if (!tinyMCE.isInstance(tinyMCE.instances[n])) - continue; - - try { - tinyMCE.instances[n].getDoc().designMode = "off"; - tinyMCE.instances[n].getDoc().designMode = "on"; - tinyMCE.instances[n].useCSS = false; - } catch (e) { - // Ignore any errors - } - } - } - - return; - } - - if (inst) { - inst.execCommand(command, user_interface, value); - } else if (tinyMCE.settings.focus_alert) - alert(tinyMCELang.lang_focus_alert); - }, - - _createIFrame : function(replace_element, doc, win) { - var iframe, id = replace_element.getAttribute("id"); - var aw, ah; - - if (typeof(doc) == "undefined") - doc = document; - - if (typeof(win) == "undefined") - win = window; - - iframe = doc.createElement("iframe"); - - aw = "" + tinyMCE.settings.area_width; - ah = "" + tinyMCE.settings.area_height; - - if (aw.indexOf('%') == -1) { - aw = parseInt(aw); - aw = (isNaN(aw) || aw < 0) ? 300 : aw; - aw = aw + "px"; - } - - if (ah.indexOf('%') == -1) { - ah = parseInt(ah); - ah = (isNaN(ah) || ah < 0) ? 240 : ah; - ah = ah + "px"; - } - - iframe.setAttribute("id", id); - iframe.setAttribute("name", id); - iframe.setAttribute("class", "mceEditorIframe"); - iframe.setAttribute("border", "0"); - iframe.setAttribute("frameBorder", "0"); - iframe.setAttribute("marginWidth", "0"); - iframe.setAttribute("marginHeight", "0"); - iframe.setAttribute("leftMargin", "0"); - iframe.setAttribute("topMargin", "0"); - iframe.setAttribute("width", aw); - iframe.setAttribute("height", ah); - iframe.setAttribute("allowtransparency", "true"); - iframe.className = 'mceEditorIframe'; - - if (tinyMCE.settings.auto_resize) - iframe.setAttribute("scrolling", "no"); - - // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs - if (tinyMCE.isRealIE) - iframe.setAttribute("src", this.settings.default_document); - - iframe.style.width = aw; - iframe.style.height = ah; - - // Ugly hack for Gecko problem in strict mode - if (tinyMCE.settings.strict_loading_mode) - iframe.style.marginBottom = '-5px'; - - // MSIE 5.0 issue - if (tinyMCE.isRealIE) - replace_element.outerHTML = iframe.outerHTML; - else - replace_element.parentNode.replaceChild(iframe, replace_element); - - if (tinyMCE.isRealIE) - return win.frames[id]; - else - return iframe; - }, - - setupContent : function(editor_id) { - var inst = tinyMCE.instances[editor_id], i, doc = inst.getDoc(), head = doc.getElementsByTagName('head').item(0); - var content = inst.startContent, contentElement, body; - - // HTML values get XML encoded in strict mode - if (tinyMCE.settings.strict_loading_mode) { - content = content.replace(/</g, '<'); - content = content.replace(/>/g, '>'); - content = content.replace(/"/g, '"'); - content = content.replace(/&/g, '&'); - } - - tinyMCE.selectedInstance = inst; - inst.switchSettings(); - - // Not loaded correctly hit it again, Mozilla bug #997860 - if (!tinyMCE.isIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") { - // This part will remove the designMode status - // Failes first time in Firefox 1.5b2 on Mac - try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {} - window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000); - return; - } - - // Wait for it to load - if (!head || !doc.body) { - window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10); - return; - } - - // Import theme specific content CSS the user specific - tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings.theme + "/css/editor_content.css"); - tinyMCE.importCSS(inst.getDoc(), inst.settings.content_css); - tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst); - - // Setup keyboard shortcuts - if (tinyMCE.getParam('custom_undo_redo_keyboard_shortcuts')) { - inst.addShortcut('ctrl', 'z', 'lang_undo_desc', 'Undo'); - inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo'); - } - - // BlockFormat shortcuts keys - for (i=1; i<=6; i++) - inst.addShortcut('ctrl', '' + i, '', 'FormatBlock', false, ''); - - inst.addShortcut('ctrl', '7', '', 'FormatBlock', false, '

    '); - inst.addShortcut('ctrl', '8', '', 'FormatBlock', false, '

    '); - inst.addShortcut('ctrl', '9', '', 'FormatBlock', false, '
    '); - - // Add default shortcuts for gecko - if (tinyMCE.isGecko) { - inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold'); - inst.addShortcut('ctrl', 'i', 'lang_italic_desc', 'Italic'); - inst.addShortcut('ctrl', 'u', 'lang_underline_desc', 'Underline'); - } - - // Setup span styles - if (tinyMCE.getParam("convert_fonts_to_spans")) - inst.getBody().setAttribute('id', 'mceSpanFonts'); - - if (tinyMCE.settings.nowrap) - doc.body.style.whiteSpace = "nowrap"; - - doc.body.dir = this.settings.directionality; - doc.editorId = editor_id; - - // Add on document element in Mozilla - if (!tinyMCE.isIE) - doc.documentElement.editorId = editor_id; - - inst.setBaseHREF(tinyMCE.settings.base_href); - - // Replace new line characters to BRs - if (tinyMCE.settings.convert_newlines_to_brs) { - content = tinyMCE.regexpReplace(content, "\r\n", "
    ", "gi"); - content = tinyMCE.regexpReplace(content, "\r", "
    ", "gi"); - content = tinyMCE.regexpReplace(content, "\n", "
    ", "gi"); - } - - // Open closed anchors - // content = content.replace(new RegExp('', 'gi'), ''); - - // Call custom cleanup code - content = tinyMCE.storeAwayURLs(content); - content = tinyMCE._customCleanup(inst, "insert_to_editor", content); - - if (tinyMCE.isIE) { - // Ugly!!! - window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500); - - if (tinyMCE.settings.force_br_newlines) - doc.styleSheets[0].addRule("p", "margin: 0;"); - - body = inst.getBody(); - body.editorId = editor_id; - } - - content = tinyMCE.cleanupHTMLCode(content); - - // Fix for bug #958637 - if (!tinyMCE.isIE) { - contentElement = inst.getDoc().createElement("body"); - doc = inst.getDoc(); - - contentElement.innerHTML = content; - - if (tinyMCE.settings.cleanup_on_startup) - tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement)); - else - tinyMCE.setInnerHTML(inst.getBody(), content); - - tinyMCE.convertAllRelativeURLs(inst.getBody()); - } else { - if (tinyMCE.settings.cleanup_on_startup) { - tinyMCE._setHTML(inst.getDoc(), content); - - // Produces permission denied error in MSIE 5.5 - try { - tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody())); - } catch(e) { - // Ignore - } - } else - tinyMCE._setHTML(inst.getDoc(), content); - } - - // Fix for bug #957681 - //inst.getDoc().designMode = inst.getDoc().designMode; - - tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings.visual, inst); - tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc()); - - // Re-add design mode on mozilla - if (!tinyMCE.isIE) - tinyMCE.addEventHandlers(inst); - - // Add blur handler - if (tinyMCE.isIE) { - tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch); - tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953 - - // Workaround for drag drop/copy paste base href bug - if (!tinyMCE.isOpera) { - tinyMCE.addEvent(doc.body, "mousemove", TinyMCE_Engine.prototype.onMouseMove); - tinyMCE.addEvent(doc.body, "beforepaste", TinyMCE_Engine.prototype._eventPatch); - tinyMCE.addEvent(doc.body, "drop", TinyMCE_Engine.prototype._eventPatch); - } - } - - // Trigger node change, this call locks buttons for tables and so forth - inst.select(); - tinyMCE.selectedElement = inst.contentWindow.document.body; - - // Call custom DOM cleanup - tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody()); - tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody()); - tinyMCE._setEventsEnabled(inst.getBody(), false); - tinyMCE.cleanupAnchors(inst.getDoc()); - - if (tinyMCE.getParam("convert_fonts_to_spans")) - tinyMCE.convertSpansToFonts(inst.getDoc()); - - inst.startContent = tinyMCE.trim(inst.getBody().innerHTML); - inst.undoRedo.add({ content : inst.startContent }); - - // Cleanup any mess left from storyAwayURLs - if (tinyMCE.isGecko) { - // Remove mce_src from textnodes and comments - tinyMCE.selectNodes(inst.getBody(), function(n) { - if (n.nodeType == 3 || n.nodeType == 8) - n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), ""); - - return false; - }); - } - - // Remove Gecko spellchecking - if (tinyMCE.isGecko) - inst.getBody().spellcheck = tinyMCE.getParam("gecko_spellcheck"); - - // Cleanup any mess left from storyAwayURLs - tinyMCE._removeInternal(inst.getBody()); - - inst.select(); - tinyMCE.triggerNodeChange(false, true); - }, - - storeAwayURLs : function(s) { - // Remove all mce_src, mce_href and replace them with new ones - // s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); - // s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); - - if (!s.match(/(mce_src|mce_href)/gi, s)) { - s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"'); - s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"'); - } - - return s; - }, - - _removeInternal : function(n) { - if (tinyMCE.isGecko) { - // Remove mce_src from textnodes and comments - tinyMCE.selectNodes(n, function(n) { - if (n.nodeType == 3 || n.nodeType == 8) - n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), ""); - - return false; - }); - } - }, - - removeTinyMCEFormElements : function(form_obj) { - var i, elementId; - - // Skip form element removal - if (!tinyMCE.getParam('hide_selects_on_submit')) - return; - - // Check if form is valid - if (typeof(form_obj) == "undefined" || form_obj == null) - return; - - // If not a form, find the form - if (form_obj.nodeName != "FORM") { - if (form_obj.form) - form_obj = form_obj.form; - else - form_obj = tinyMCE.getParentElement(form_obj, "form"); - } - - // Still nothing - if (form_obj == null) - return; - - // Disable all UI form elements that TinyMCE created - for (i=0; i"); - rng.collapse(false); - rng.select(); - - tinyMCE.execCommand("mceAddUndoLevel"); - tinyMCE.triggerNodeChange(false); - return false; - } - } - - // Backspace or delete - if (e.keyCode == 8 || e.keyCode == 46) { - tinyMCE.selectedElement = e.target; - tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a"); - tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img"); - tinyMCE.triggerNodeChange(false); - } - - return false; - - case "keyup": - case "keydown": - tinyMCE.hideMenus(); - tinyMCE.hasMouseMoved = false; - - if (inst && inst.handleShortcut(e)) - return false; - - inst._fixRootBlocks(); - - if (inst.settings.remove_trailing_nbsp) - inst._fixTrailingNbsp(); - - if (e.target.editorId) - tinyMCE.instances[e.target.editorId].select(); - - if (tinyMCE.selectedInstance) - tinyMCE.selectedInstance.switchSettings(); - - inst = tinyMCE.selectedInstance; - - // Handle backspace - if (tinyMCE.isGecko && tinyMCE.settings.force_p_newlines && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { - // Insert P element instead of BR - if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) { - // Cancel event - tinyMCE.execCommand("mceAddUndoLevel"); - e.preventDefault(); - return false; - } - } - - tinyMCE.selectedElement = null; - tinyMCE.selectedNode = null; - elm = tinyMCE.selectedInstance.getFocusElement(); - tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a"); - tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img"); - tinyMCE.selectedElement = elm; - - // Update visualaids on tabs - if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9) - tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings.visual, tinyMCE.selectedInstance); - - // Fix empty elements on return/enter, check where enter occured - if (tinyMCE.isIE && e.type == "keydown" && e.keyCode == 13) - tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement(); - - // Fix empty elements on return/enter - if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) { - elm = tinyMCE.enterKeyElement; - if (elm) { - var re = new RegExp('^HR|IMG|BR$','g'); // Skip these - var dre = new RegExp('^H[1-6]$','g'); // Add double on these - - if (!elm.hasChildNodes() && !re.test(elm.nodeName)) { - if (dre.test(elm.nodeName)) - elm.innerHTML = "  "; - else - elm.innerHTML = " "; - } - } - } - - // Check if it's a position key - keys = tinyMCE.posKeyCodes; - var posKey = false; - for (i=0; i'; - h += '{$'+lang+'}'; - h += ''; - } else { - // Normal button - h += ''; - h += '{$'+lang+'}'; - h += ''; - } - - return h; - }, - - getMenuButtonHTML : function(id, lang, img, mcmd, cmd, ui, val) { - var h = '', m, x; - - mcmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + mcmd + '\');'; - cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\''; - - if (typeof(ui) != "undefined" && ui != null) - cmd += ',' + ui; - - if (typeof(val) != "undefined" && val != null) - cmd += ",'" + val + "'"; - - cmd += ');'; - - // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled - if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) { - x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20); - - if (tinyMCE.isRealIE) - h += ''; - else - h += ''; - - h += ''; - h += ''; - h += ''; - h += ''; - } else { - if (tinyMCE.isRealIE) - h += ''; - else - h += ''; - - h += ''; - h += ''; - h += ''; - h += ''; - } - - return h; - }, - - _menuButtonEvent : function(e, o) { - if (o.className == 'mceMenuButtonFocus') - return; - - if (e == 'over') - o.className = o.className + ' mceMenuHover'; - else - o.className = o.className.replace(/\s.*$/, ''); - }, - - addButtonMap : function(m) { - var i, a = m.replace(/\s+/, '').split(','); - - for (i=0; i 0); - - if (tinyMCE.settings.custom_undo_redo) { - undoIndex = inst.undoRedo.undoIndex; - undoLevels = inst.undoRedo.undoLevels.length; - } - - tinyMCE.dispatchCallback(inst, 'handle_node_change_callback', 'handleNodeChange', editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content); - } - - if (this.selectedInstance && (typeof(focus) == "undefined" || focus)) - this.selectedInstance.contentWindow.focus(); - }, - - _customCleanup : function(inst, type, content) { - var pl, po, i, customCleanup; - - // Call custom cleanup - customCleanup = tinyMCE.settings.cleanup_callback; - if (customCleanup != '') - content = tinyMCE.resolveDots(tinyMCE.settings.cleanup_callback, window)(type, content, inst); - - // Trigger theme cleanup - po = tinyMCE.themes[tinyMCE.settings.theme]; - if (po && po.cleanup) - content = po.cleanup(type, content, inst); - - // Trigger plugin cleanups - pl = inst.plugins; - for (i=0; i 0) - className += " "; - - className += classNames[i]; - } - - return className; - }, - - handleVisualAid : function(el, deep, state, inst, skip_dispatch) { - var i, x, y, tableElement, anchorName, oldW, oldH, bo, cn; - - if (!el) - return; - - if (!skip_dispatch) - tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst); - - tableElement = null; - - switch (el.nodeName) { - case "TABLE": - oldW = el.style.width; - oldH = el.style.height; - bo = tinyMCE.getAttrib(el, "border"); - - bo = bo == '' || bo == "0" ? true : false; - - tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo)); - - el.style.width = oldW; - el.style.height = oldH; - - for (y=0; y 0) - return inst.cssClasses; - - if (!doc) - return; - - styles = doc.styleSheets; - - if (styles && styles.length > 0) { - for (x=0; x' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + ''; - - return tinyMCE.replaceVar(v, "pluginurl", o.baseURL); - } - } - - o = tinyMCE.themes[tinyMCE.settings.theme]; - if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') { - if (rtl) - return '' + v + ''; - - return v; - } - - return ''; - }, - - evalFunc : function(f, idx, a, o) { - o = !o ? window : o; - f = typeof(f) == 'function' ? f : o[f]; - - return f.apply(o, Array.prototype.slice.call(a, idx)); - }, - - dispatchCallback : function(i, p, n) { - return this.callFunc(i, p, n, 0, this.dispatchCallback.arguments); - }, - - executeCallback : function(i, p, n) { - return this.callFunc(i, p, n, 1, this.executeCallback.arguments); - }, - - execCommandCallback : function(i, p, n) { - return this.callFunc(i, p, n, 2, this.execCommandCallback.arguments); - }, - - callFunc : function(ins, p, n, m, a) { - var l, i, on, o, s, v; - - s = m == 2; - - l = tinyMCE.getParam(p, ''); - - if (l !== '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0) - return true; - - if (ins != null) { - for (i=0, l = ins.plugins; i 0) - return true; - } - } - - l = tinyMCE.themes; - for (on in l) { - o = l[on]; - - if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0) - return true; - } - - return false; - }, - - resolveDots : function(s, o) { - var i; - - if (typeof(s) == 'string') { - for (i=0, s=s.split('.'); i': - return '>'; - } - - return c; - }) : s; - }, - - add : function(c, m) { - var n; - - for (n in m) - c.prototype[n] = m[n]; - }, - - extend : function(p, np) { - var o = {}, n; - - o.parent = p; - - for (n in p) - o[n] = p[n]; - - for (n in np) - o[n] = np[n]; - - return o; - }, - - hideMenus : function() { - var e = tinyMCE.lastSelectedMenuBtn; - - if (tinyMCE.lastMenu) { - tinyMCE.lastMenu.hide(); - tinyMCE.lastMenu = null; - } - - if (e) { - tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass); - tinyMCE.lastSelectedMenuBtn = null; - } - } - - }; - -// Global instances -var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors -var tinyMCE = new TinyMCE_Engine(); -var tinyMCELang = {}; - -/* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */ - -function TinyMCE_Control(settings) { - var t, i, tos, fu, p, x, fn, fu, pn, s = settings; - - this.undoRedoLevel = true; - this.isTinyMCE_Control = true; - - // Default settings - this.enabled = true; - this.settings = s; - this.settings.theme = tinyMCE.getParam("theme", "default"); - this.settings.width = tinyMCE.getParam("width", -1); - this.settings.height = tinyMCE.getParam("height", -1); - this.selection = new TinyMCE_Selection(this); - this.undoRedo = new TinyMCE_UndoRedo(this); - this.cleanup = new TinyMCE_Cleanup(); - this.shortcuts = []; - this.hasMouseMoved = false; - this.foreColor = this.backColor = "#999999"; - this.data = {}; - this.cssClasses = []; - - this.cleanup.init({ - valid_elements : s.valid_elements, - extended_valid_elements : s.extended_valid_elements, - valid_child_elements : s.valid_child_elements, - entities : s.entities, - entity_encoding : s.entity_encoding, - debug : s.cleanup_debug, - indent : s.apply_source_formatting, - invalid_elements : s.invalid_elements, - verify_html : s.verify_html, - fix_content_duplication : s.fix_content_duplication, - convert_fonts_to_spans : s.convert_fonts_to_spans - }); - - // Wrap old theme - t = this.settings.theme; - if (!tinyMCE.hasTheme(t)) { - fn = tinyMCE.callbacks; - tos = {}; - - for (i=0; i 0) { - for (i=0; i 1 && tinyMCE.currentConfig != this.settings.index) { - tinyMCE.settings = this.settings; - tinyMCE.currentConfig = this.settings.index; - } - }, - - select : function() { - var oldInst = tinyMCE.selectedInstance; - - if (oldInst != this) { - if (oldInst) - oldInst.execCommand('mceEndTyping'); - - tinyMCE.dispatchCallback(this, 'select_instance_callback', 'selectInstance', this, oldInst); - tinyMCE.selectedInstance = this; - } - }, - - getBody : function() { - return this.contentBody ? this.contentBody : this.getDoc().body; - }, - - getDoc : function() { -// return this.contentDocument ? this.contentDocument : this.contentWindow.document; // Removed due to IE 5.5 ? - return this.contentWindow.document; - }, - - getWin : function() { - return this.contentWindow; - }, - - getContainerWin : function() { - return this.containerWindow ? this.containerWindow : window; - }, - - getViewPort : function() { - return tinyMCE.getViewPort(this.getWin()); - }, - - getParentNode : function(n, f) { - return tinyMCE.getParentNode(n, f, this.getBody()); - }, - - getParentElement : function(n, na, f) { - return tinyMCE.getParentElement(n, na, f, this.getBody()); - }, - - getParentBlockElement : function(n) { - return tinyMCE.getParentBlockElement(n, this.getBody()); - }, - - resizeToContent : function() { - var d = this.getDoc(), b = d.body, de = d.documentElement; - - this.iframeElement.style.height = (tinyMCE.isRealIE) ? b.scrollHeight : de.offsetHeight + 'px'; - }, - - addShortcut : function(m, k, d, cmd, ui, va) { - var n = typeof(k) == "number", ie = tinyMCE.isIE, c, sc, i, scl = this.shortcuts; - - if (!tinyMCE.getParam('custom_shortcuts')) - return false; - - m = m.toLowerCase(); - k = ie && !n ? k.toUpperCase() : k; - c = n ? null : k.charCodeAt(0); - d = d && d.indexOf('lang_') == 0 ? tinyMCE.getLang(d) : d; - - sc = { - alt : m.indexOf('alt') != -1, - ctrl : m.indexOf('ctrl') != -1, - shift : m.indexOf('shift') != -1, - charCode : c, - keyCode : n ? k : (ie ? c : null), - desc : d, - cmd : cmd, - ui : ui, - val : va - }; - - for (i=0; i 1 && /(^\u00a0|\u00a0$)/.test(v)) { - e.firstChild.nodeValue = v.replace(/(^\u00a0|\u00a0$)/, ''); - s.selectNode(e.firstChild, true, false, false); // Select and collapse - } - } - }, - - _setUseCSS : function(b) { - var d = this.getDoc(); - - try {d.execCommand("useCSS", false, !b);} catch (ex) {} - try {d.execCommand("styleWithCSS", false, b);} catch (ex) {} - - if (!tinyMCE.getParam("table_inline_editing")) - try {d.execCommand('enableInlineTableEditing', false, "false");} catch (ex) {} - - if (!tinyMCE.getParam("object_resizing")) - try {d.execCommand('enableObjectResizing', false, "false");} catch (ex) {} - }, - - execCommand : function(command, user_interface, value) { - var i, x, z, align, img, div, doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement(); - - // Is not a undo specific command - if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) - this.undoBookmark = null; - - // Mozilla issue - if (!tinyMCE.isIE && !this.useCSS) { - this._setUseCSS(false); - this.useCSS = true; - } - - //debug("command: " + command + ", user_interface: " + user_interface + ", value: " + value); - this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks - - // Don't dispatch key commands - if (!/mceStartTyping|mceEndTyping/.test(command)) { - if (tinyMCE.execCommandCallback(this, 'execcommand_callback', 'execCommand', this.editorId, this.getBody(), command, user_interface, value)) - return; - } - - // Fix align on images - if (focusElm && focusElm.nodeName == "IMG") { - align = focusElm.getAttribute('align'); - img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm; - - switch (command) { - case "JustifyLeft": - if (align == 'left') - img.removeAttribute('align'); - else - img.setAttribute('align', 'left'); - - // Remove the div - div = focusElm.parentNode; - if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) - div.parentNode.replaceChild(img, div); - - this.selection.selectNode(img); - this.repaint(); - tinyMCE.triggerNodeChange(); - return; - - case "JustifyCenter": - img.removeAttribute('align'); - - // Is centered - div = tinyMCE.getParentElement(focusElm, "div"); - if (div && div.style.textAlign == "center") { - // Remove div - if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) - div.parentNode.replaceChild(img, div); - } else { - // Add div - div = this.getDoc().createElement("div"); - div.style.textAlign = 'center'; - div.appendChild(img); - focusElm.parentNode.replaceChild(div, focusElm); - } - - this.selection.selectNode(img); - this.repaint(); - tinyMCE.triggerNodeChange(); - return; - - case "JustifyRight": - if (align == 'right') - img.removeAttribute('align'); - else - img.setAttribute('align', 'right'); - - // Remove the div - div = focusElm.parentNode; - if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) - div.parentNode.replaceChild(img, div); - - this.selection.selectNode(img); - this.repaint(); - tinyMCE.triggerNodeChange(); - return; - } - } - - if (tinyMCE.settings.force_br_newlines) { - var alignValue = ""; - - if (doc.selection.type != "Control") { - switch (command) { - case "JustifyLeft": - alignValue = "left"; - break; - - case "JustifyCenter": - alignValue = "center"; - break; - - case "JustifyFull": - alignValue = "justify"; - break; - - case "JustifyRight": - alignValue = "right"; - break; - } - - if (alignValue !== '') { - var rng = doc.selection.createRange(); - - if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null) - divElm.setAttribute("align", alignValue); - else if (rng.pasteHTML && rng.htmlText.length > 0) - rng.pasteHTML('
    ' + rng.htmlText + "
    "); - - tinyMCE.triggerNodeChange(); - return; - } - } - } - - switch (command) { - case "mceRepaint": - this.repaint(); - return true; - - case "unlink": - // Unlink if caret is inside link - if (tinyMCE.isGecko && this.getSel().isCollapsed) { - focusElm = tinyMCE.getParentElement(focusElm, 'A'); - - if (focusElm) - this.selection.selectNode(focusElm, false); - } - - this.getDoc().execCommand(command, user_interface, value); - - tinyMCE.isGecko && this.getSel().collapseToEnd(); - - tinyMCE.triggerNodeChange(); - - return true; - - case "InsertUnorderedList": - case "InsertOrderedList": - this.getDoc().execCommand(command, user_interface, value); - tinyMCE.triggerNodeChange(); - break; - - case "Strikethrough": - this.getDoc().execCommand(command, user_interface, value); - tinyMCE.triggerNodeChange(); - break; - - case "mceSelectNode": - this.selection.selectNode(value); - tinyMCE.triggerNodeChange(); - tinyMCE.selectedNode = value; - break; - - case "FormatBlock": - if (value == null || value == '') { - var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address,blockquote,dt,dl,dd,samp"); - - if (elm) - this.execCommand("mceRemoveNode", false, elm); - } else { - if (!this.cleanup.isValid(value)) - return true; - - if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value)) - value = value.replace(/[^a-z]/gi, ''); - - if (tinyMCE.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) { - var b = this.selection.getBookmark(); - this.getDoc().execCommand("FormatBlock", false, '

    '); - tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value); - this.selection.moveToBookmark(b); - } else - this.getDoc().execCommand("FormatBlock", false, value); - } - - tinyMCE.triggerNodeChange(); - - break; - - case "mceRemoveNode": - if (!value) - value = tinyMCE.getParentElement(this.getFocusElement()); - - if (tinyMCE.isIE) { - value.outerHTML = value.innerHTML; - } else { - var rng = value.ownerDocument.createRange(); - rng.setStartBefore(value); - rng.setEndAfter(value); - rng.deleteContents(); - rng.insertNode(rng.createContextualFragment(value.innerHTML)); - } - - tinyMCE.triggerNodeChange(); - - break; - - case "mceSelectNodeDepth": - var parentNode = this.getFocusElement(); - for (i=0; parentNode; i++) { - if (parentNode.nodeName.toLowerCase() == "body") - break; - - if (parentNode.nodeName.toLowerCase() == "#text") { - i--; - parentNode = parentNode.parentNode; - continue; - } - - if (i == value) { - this.selection.selectNode(parentNode, false); - tinyMCE.triggerNodeChange(); - tinyMCE.selectedNode = parentNode; - return; - } - - parentNode = parentNode.parentNode; - } - - break; - - case "mceSetStyleInfo": - case "SetStyleInfo": - var rng = this.getRng(); - var sel = this.getSel(); - var scmd = value.command; - var sname = value.name; - var svalue = value.value == null ? '' : value.value; - //var svalue = value['value'] == null ? '' : value['value']; - var wrapper = value.wrapper ? value.wrapper : "span"; - var parentElm = null; - var invalidRe = new RegExp("^BODY|HTML$", "g"); - var invalidParentsRe = tinyMCE.settings.merge_styles_invalid_parents !== '' ? new RegExp(tinyMCE.settings.merge_styles_invalid_parents, "gi") : null; - - // Whole element selected check - if (tinyMCE.isIE) { - // Control range - if (rng.item) - parentElm = rng.item(0); - else { - var pelm = rng.parentElement(); - var prng = doc.selection.createRange(); - prng.moveToElementText(pelm); - - if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) { - if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName)) - parentElm = pelm; - } - } - } else { - var felm = this.getFocusElement(); - if (sel.isCollapsed || (new RegExp('td|tr|tbody|table|img', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode)) - parentElm = felm; - } - - // Whole element selected - if (parentElm && !invalidRe.test(parentElm.nodeName)) { - if (scmd == "setstyle") - tinyMCE.setStyleAttrib(parentElm, sname, svalue); - - if (scmd == "setattrib") - tinyMCE.setAttrib(parentElm, sname, svalue); - - if (scmd == "removeformat") { - parentElm.style.cssText = ''; - tinyMCE.setAttrib(parentElm, 'class', ''); - } - - // Remove style/attribs from all children - var ch = tinyMCE.getNodeTree(parentElm, [], 1); - for (z=0; z=0; i--) { - var elm = nodes[i]; - var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true"; - - elm.removeAttribute("mce_new"); - - // Is only child a element - if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) { - //tinyMCE.debug("merge1" + isNew); - this._mergeElements(scmd, elm, elm.childNodes[0], isNew); - continue; - } - - // Is I the only child - if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) { - //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName); - if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName)) - this._mergeElements(scmd, elm.parentNode, elm, false); - } - } - - // Remove empty wrappers - var nodes = doc.getElementsByTagName(wrapper); - for (i=nodes.length-1; i>=0; i--) { - var elm = nodes[i], isEmpty = true; - - // Check if it has any attribs - var tmp = doc.createElement("body"); - tmp.appendChild(elm.cloneNode(false)); - - // Is empty span, remove it - tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), ''); - //tinyMCE.debug(tmp.innerHTML); - if (new RegExp('', 'gi').test(tmp.innerHTML)) { - for (x=0; x 0) { - value = tinyMCE.replaceVar(value, "selection", selectedText); - tinyMCE.execCommand('mceInsertContent', false, value); - } - - this._addBogusBR(); - tinyMCE.triggerNodeChange(); - break; - - case "mceSetAttribute": - if (typeof(value) == 'object') { - var targetElms = (typeof(value.targets) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value.targets; - var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms); - - if (targetNode) { - targetNode.setAttribute(value.name, value.value); - tinyMCE.triggerNodeChange(); - } - } - break; - - case "mceSetCSSClass": - this.execCommand("mceSetStyleInfo", false, {command : "setattrib", name : "class", value : value}); - break; - - case "mceInsertRawHTML": - var key = 'tiny_mce_marker'; - - this.execCommand('mceBeginUndoLevel'); - - // Insert marker key - this.execCommand('mceInsertContent', false, key); - - // Store away scroll pos - var scrollX = this.getBody().scrollLeft + this.getDoc().documentElement.scrollLeft; - var scrollY = this.getBody().scrollTop + this.getDoc().documentElement.scrollTop; - - // Find marker and replace with RAW HTML - var html = this.getBody().innerHTML; - if ((pos = html.indexOf(key)) != -1) - tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length)); - - // Restore scoll pos - this.contentWindow.scrollTo(scrollX, scrollY); - - this.execCommand('mceEndUndoLevel'); - - break; - - case "mceInsertContent": - // Force empty string - if (!value) - value = ''; - - var insertHTMLFailed = false; - - // Removed since it produced problems in IE - // this.getWin().focus(); - - if (tinyMCE.isGecko || tinyMCE.isOpera) { - try { - // Is plain text or HTML, &,   etc will be encoded wrong in FF - if (value.indexOf('<') == -1 && !value.match(/(&| |<|>)/g)) { - var r = this.getRng(); - var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value)); - var s = this.getSel(); - var r2 = r.cloneRange(); - - // Insert text at cursor position - s.removeAllRanges(); - r.deleteContents(); - r.insertNode(n); - - // Move the cursor to the end of text - r2.selectNode(n); - r2.collapse(false); - s.removeAllRanges(); - s.addRange(r2); - } else { - value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value); - this.getDoc().execCommand('inserthtml', false, value); - tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); - } - } catch (ex) { - insertHTMLFailed = true; - } - - if (!insertHTMLFailed) { - tinyMCE.triggerNodeChange(); - return; - } - } - - if (!tinyMCE.isIE) { - var isHTML = value.indexOf('<') != -1; - var sel = this.getSel(); - var rng = this.getRng(); - - if (isHTML) { - if (tinyMCE.isSafari) { - var tmpRng = this.getDoc().createRange(); - - tmpRng.setStart(this.getBody(), 0); - tmpRng.setEnd(this.getBody(), 0); - - value = tmpRng.createContextualFragment(value); - } else - value = rng.createContextualFragment(value); - } else { - // Setup text node - value = doc.createTextNode(tinyMCE.entityDecode(value)); - } - - // Insert plain text in Safari - if (tinyMCE.isSafari && !isHTML) { - this.execCommand('InsertText', false, value.nodeValue); - tinyMCE.triggerNodeChange(); - return true; - } else if (tinyMCE.isSafari && isHTML) { - rng.deleteContents(); - rng.insertNode(value); - tinyMCE.triggerNodeChange(); - return true; - } - - rng.deleteContents(); - - // If target node is text do special treatment, (Mozilla 1.3 fix) - if (rng.startContainer.nodeType == 3) { - var node = rng.startContainer.splitText(rng.startOffset); - node.parentNode.insertBefore(value, node); - } else - rng.insertNode(value); - - if (!isHTML) { - // Removes weird selection trails - sel.selectAllChildren(doc.body); - sel.removeAllRanges(); - - // Move cursor to end of content - var rng = doc.createRange(); - - rng.selectNode(value); - rng.collapse(false); - - sel.addRange(rng); - } else - rng.collapse(false); - - tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); - } else { - var rng = doc.selection.createRange(), tmpRng = null; - var c = value.indexOf('"; - } - - if (hc) { - cn = n.childNodes; - - for (i=0, l=cn.length; i'; - - return h; - }, - - _serializeAttribute : function(n, r, an) { - var av = '', t, os = this.settings.on_save; - - if (os && (an.indexOf('mce_') == 0 || an.indexOf('_moz') == 0)) - return ''; - - if (os && this.mceAttribs[an]) - av = this._getAttrib(n, this.mceAttribs[an]); - - if (av.length == 0) - av = this._getAttrib(n, an); - - if (av.length == 0 && r.defaultAttribs && (t = r.defaultAttribs[an])) { - av = t; - - if (av == "mce_empty") - return " " + an + '=""'; - } - - if (r.forceAttribs && (t = r.forceAttribs[an])) - av = t; - - if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an)) - av = this._urlConverter(this, n, av); - - if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av)) - return ""; - - if (av.length != 0 && av == "{$uid}") - av = "uid_" + (this.idCount++); - - if (av.length != 0) { - if (an.indexOf('on') != 0) - av = this.xmlEncode(av, 1); - - return " " + an + "=" + '"' + av + '"'; - } - - return ""; - }, - - formatHTML : function(h) { - var s = this.settings, p = '', i = 0, li = 0, o = '', l; - - // Replace BR in pre elements to \n - h = h.replace(/]*)>(.*?)<\/pre>/gi, function (a, b, c) { - c = c.replace(//gi, '\n'); - return '' + c + ''; - }); - - h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :) - h = '\n' + h; - h = h.replace(new RegExp('\\n\\s+', 'gi'), '\n'); // Remove previous formatting - h = h.replace(this.nlBeforeRe, '\n<$1$2>'); - h = h.replace(this.nlAfterRe, '<$1$2>\n'); - h = h.replace(this.nlBeforeAfterRe, '\n<$1$2$3>\n'); - h += '\n'; - - //tinyMCE.debug(h); - - while ((i = h.indexOf('\n', i + 1)) != -1) { - if ((l = h.substring(li + 1, i)).length != 0) { - if (this.ouRe.test(l) && p.length >= s.indent_levels) - p = p.substring(s.indent_levels); - - o += p + l + '\n'; - - if (this.inRe.test(l)) - p += this.inStr; - } - - li = i; - } - - //tinyMCE.debug(h); - - return o; - }, - - xmlEncode : function(s) { - var cl = this, re = this.xmlEncodeRe; - - if (!this.entitiesDone) - this._setupEntities(); // Will intialize lookup table - - switch (this.settings.entity_encoding) { - case "raw": - return tinyMCE.xmlEncode(s); - - case "named": - return s.replace(re, function (c) { - var b = cl.entities[c.charCodeAt(0)]; - - return b ? '&' + b + ';' : c; - }); - - case "numeric": - return s.replace(re, function (c) { - return '&#' + c.charCodeAt(0) + ';'; - }); - } - - return s; - }, - - split : function(re, s) { - var i, l, o = [], c = s.split(re); - - for (i=0, l=c.length; i' : '>' + h + ''; - - return o; - }, - - createTag : function(d, tn, a, h) { - var o = d.createElement(tn), n; - - if (a) { - for (n in a) { - if (typeof(a[n]) != 'function' && a[n] != null) - tinyMCE.setAttrib(o, n, a[n]); - } - } - - if (h) - o.innerHTML = h; - - return o; - }, - - getElementByAttributeValue : function(n, e, a, v) { - return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0]; - }, - - getElementsByAttributeValue : function(n, e, a, v) { - var i, nl = n.getElementsByTagName(e), o = []; - - for (i=0; i]*)>/gi, ''); - h = h.replace(/]*)>/gi, ''); - h = h.replace(/]*)>/gi, ''); - h = h.replace(/]*)>/gi, ''); - h = h.replace(/<\/strong>/gi, ''); - h = h.replace(/<\/em>/gi, ''); - } - - if (tinyMCE.isRealIE) { - // Since MSIE handles invalid HTML better that valid XHTML we - // need to make some things invalid.


    gets converted to
    . - h = h.replace(/\s\/>/g, '>'); - - // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones - h = h.replace(/]*)>\u00A0?<\/p>/gi, ' 

    '); // Keep empty paragraphs - h = h.replace(/]*)>\s* \s*<\/p>/gi, ' 

    '); // Keep empty paragraphs - h = h.replace(/]*)>\s+<\/p>/gi, ' 

    '); // Keep empty paragraphs - - // Remove first comment - e.innerHTML = tinyMCE.uniqueTag + h; - e.firstChild.removeNode(true); - - // Remove weird auto generated empty paragraphs unless it's supposed to be there - nl = e.getElementsByTagName("p"); - for (i=nl.length-1; i>=0; i--) { - n = nl[i]; - - if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep) - n.parentNode.removeChild(n); - } - } else { - h = this.fixGeckoBaseHREFBug(1, e, h); - e.innerHTML = h; - this.fixGeckoBaseHREFBug(2, e, h); - } - }, - - getOuterHTML : function(e) { - var d; - - if (tinyMCE.isIE) - return e.outerHTML; - - d = e.ownerDocument.createElement("body"); - d.appendChild(e.cloneNode(true)); - - return d.innerHTML; - }, - - setOuterHTML : function(e, h, d) { - var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t; - - if (tinyMCE.isIE && e.nodeType == 1) - e.outerHTML = h; - else { - t = d.createElement("body"); - t.innerHTML = h; - - for (i=0, nl=t.childNodes; i-1; i--) { - if (ar[i].specified && ar[i].nodeValue) - ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue); - } - - ar = e.childNodes; - for (i=0; i= strTok2.length) { - for (i=0; i= strTok2.length || strTok1[i] != strTok2[i]) { - breakPoint = i + 1; - break; - } - } - } - - if (strTok1.length < strTok2.length) { - for (i=0; i= strTok1.length || strTok1[i] != strTok2[i]) { - breakPoint = i + 1; - break; - } - } - } - - if (breakPoint == 1) - return targetURL.path; - - for (i=0; i<(strTok1.length-(breakPoint-1)); i++) - outPath += "../"; - - for (i=breakPoint-1; i=0; i--) { - if (baseURLParts[i].length == 0) - continue; - - newBaseURLParts[newBaseURLParts.length] = baseURLParts[i]; - } - baseURLParts = newBaseURLParts.reverse(); - - // Merge relURLParts chunks - newRelURLParts = []; - numBack = 0; - for (i=relURLParts.length-1; i>=0; i--) { - if (relURLParts[i].length == 0 || relURLParts[i] == ".") - continue; - - if (relURLParts[i] == '..') { - numBack++; - continue; - } - - if (numBack > 0) { - numBack--; - continue; - } - - newRelURLParts[newRelURLParts.length] = relURLParts[i]; - } - - relURLParts = newRelURLParts.reverse(); - - // Remove end from absolute path - len = baseURLParts.length-numBack; - absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/'); - start = ""; - end = ""; - - // Build output URL - relURL.protocol = baseURL.protocol; - relURL.host = baseURL.host; - relURL.port = baseURL.port; - - // Re-add trailing slash if it's removed - if (relURL.path.charAt(relURL.path.length-1) == "/") - absPath += "/"; - - relURL.path = absPath; - - return this.serializeURL(relURL); - }, - - convertURL : function(url, node, on_save) { - var dl = document.location, start, portPart, urlParts, baseUrlParts, tmpUrlParts, curl; - var prot = dl.protocol, host = dl.hostname, port = dl.port; - - // Pass through file protocol - if (prot == "file:") - return url; - - // Something is wrong, remove weirdness - url = tinyMCE.regexpReplace(url, '(http|https):///', '/'); - - // Mailto link or anchor (Pass through) - if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || /^[ \t\r\n\+]*[#\?]/.test(url)) - return url; - - // Fix relative/Mozilla - if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/') - return tinyMCE.settings.base_href + url; - - // Handle relative URLs - if (on_save && tinyMCE.getParam('relative_urls')) { - curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url); - if (curl.charAt(0) == '/') - curl = tinyMCE.settings.document_base_prefix + curl; - - urlParts = tinyMCE.parseURL(curl); - tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings.document_base_url); - - // Force relative - if (urlParts.host == tmpUrlParts.host && (urlParts.port == tmpUrlParts.port)) - return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings.document_base_url, curl); - } - - // Handle absolute URLs - if (!tinyMCE.getParam('relative_urls')) { - urlParts = tinyMCE.parseURL(url); - baseUrlParts = tinyMCE.parseURL(tinyMCE.settings.base_href); - - // Force absolute URLs from relative URLs - url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url); - - // If anchor and path is the same page - if (urlParts.anchor && urlParts.path == baseUrlParts.path) - return "#" + urlParts.anchor; - } - - // Remove current domain - if (tinyMCE.getParam('remove_script_host')) { - start = ""; - portPart = ""; - - if (port !== '') - portPart = ":" + port; - - start = prot + "//" + host + portPart + "/"; - - if (url.indexOf(start) == 0) - url = url.substring(start.length-1); - } - - return url; - }, - - convertAllRelativeURLs : function(body) { - var i, elms, src, href, mhref, msrc; - - // Convert all image URL:s to absolute URL - elms = body.getElementsByTagName("img"); - for (i=0; i bookmark.index) { - try { - rng.addElement(nl[bookmark.index]); - } catch (ex) { - // Might be thrown if the node no longer exists - } - } - } else { - // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs - try { - // Incorrect bookmark - if (bookmark.start < 0) - return true; - - rng = inst.getSel().createRange(); - rng.moveToElementText(inst.getBody()); - rng.collapse(true); - rng.moveStart('character', bookmark.start); - rng.moveEnd('character', bookmark.length); - } catch (ex) { - return true; - } - } - - rng.select(); - - win.scrollTo(bookmark.scrollX, bookmark.scrollY); - return true; - } - - if (tinyMCE.isGecko || tinyMCE.isOpera) { - if (!sel) - return false; - - if (bookmark.rng) { - sel.removeAllRanges(); - sel.addRange(bookmark.rng); - } - - if (bookmark.start != -1 && bookmark.end != -1) { - try { - sd = this._getTextPos(b, bookmark.start, bookmark.end); - rng = doc.createRange(); - rng.setStart(sd.startNode, sd.startOffset); - rng.setEnd(sd.endNode, sd.endOffset); - sel.removeAllRanges(); - sel.addRange(rng); - - if (!tinyMCE.isOpera) - win.focus(); - } catch (ex) { - // Ignore - } - } - - /* - if (typeof(bookmark.index) != 'undefined') { - tinyMCE.selectElements(b, 'IMG', function (n) { - if (bookmark.index-- == 0) { - // Select image in Gecko here - } - - return false; - }); - } - */ - - win.scrollTo(bookmark.scrollX, bookmark.scrollY); - return true; - } - - return false; - }, - - _getPosText : function(r, sn, en) { - var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; - - while ((n = w.nextNode()) != null) { - if (n == sn) - d.start = p; - - if (n == en) { - d.end = p; - return d; - } - - p += n.nodeValue ? n.nodeValue.length : 0; - } - - return null; - }, - - _getTextPos : function(r, sp, ep) { - var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; - - while ((n = w.nextNode()) != null) { - p += n.nodeValue ? n.nodeValue.length : 0; - - if (p >= sp && !d.startNode) { - d.startNode = n; - d.startOffset = sp - (p - n.nodeValue.length); - } - - if (p >= ep) { - d.endNode = n; - d.endOffset = ep - (p - n.nodeValue.length); - - return d; - } - } - - return null; - }, - - selectNode : function(node, collapse, select_text_node, to_start) { - var inst = this.instance, sel, rng, nodes; - - if (!node) - return; - - if (typeof(collapse) == "undefined") - collapse = true; - - if (typeof(select_text_node) == "undefined") - select_text_node = false; - - if (typeof(to_start) == "undefined") - to_start = true; - - if (inst.settings.auto_resize) - inst.resizeToContent(); - - if (tinyMCE.isRealIE) { - rng = inst.getDoc().body.createTextRange(); - - try { - rng.moveToElementText(node); - - if (collapse) - rng.collapse(to_start); - - rng.select(); - } catch (e) { - // Throws illigal agrument in MSIE some times - } - } else { - sel = this.getSel(); - - if (!sel) - return; - - if (tinyMCE.isSafari) { - sel.setBaseAndExtent(node, 0, node, node.innerText.length); - - if (collapse) { - if (to_start) - sel.collapseToStart(); - else - sel.collapseToEnd(); - } - - this.scrollToNode(node); - - return; - } - - rng = inst.getDoc().createRange(); - - if (select_text_node) { - // Find first textnode in tree - nodes = tinyMCE.getNodeTree(node, [], 3); - if (nodes.length > 0) - rng.selectNodeContents(nodes[0]); - else - rng.selectNodeContents(node); - } else - rng.selectNode(node); - - if (collapse) { - // Special treatment of textnode collapse - if (!to_start && node.nodeType == 3) { - rng.setStart(node, node.nodeValue.length); - rng.setEnd(node, node.nodeValue.length); - } else - rng.collapse(to_start); - } - - sel.removeAllRanges(); - sel.addRange(rng); - } - - this.scrollToNode(node); - - // Set selected element - tinyMCE.selectedElement = null; - if (node.nodeType == 1) - tinyMCE.selectedElement = node; - }, - - scrollToNode : function(node) { - var inst = this.instance, w = inst.getWin(), vp = inst.getViewPort(), pos = tinyMCE.getAbsPosition(node), cvp, p, cwin; - - // Only scroll if out of visible area - if (pos.absLeft < vp.left || pos.absLeft > vp.left + vp.width || pos.absTop < vp.top || pos.absTop > vp.top + (vp.height-25)) - w.scrollTo(pos.absLeft, pos.absTop - vp.height + 25); - - // Scroll container window - if (inst.settings.auto_resize) { - cwin = inst.getContainerWin(); - cvp = tinyMCE.getViewPort(cwin); - p = this.getAbsPosition(node); - - if (p.absLeft < cvp.left || p.absLeft > cvp.left + cvp.width || p.absTop < cvp.top || p.absTop > cvp.top + cvp.height) - cwin.scrollTo(p.absLeft, p.absTop - cvp.height + 25); - } - }, - - getAbsPosition : function(n) { - var pos = tinyMCE.getAbsPosition(n), ipos = tinyMCE.getAbsPosition(this.instance.iframeElement); - - return { - absLeft : ipos.absLeft + pos.absLeft, - absTop : ipos.absTop + pos.absTop - }; - }, - - getSel : function() { - var inst = this.instance; - - if (tinyMCE.isRealIE) - return inst.getDoc().selection; - - return inst.contentWindow.getSelection(); - }, - - getRng : function() { - var s = this.getSel(); - - if (s == null) - return null; - - if (tinyMCE.isRealIE) - return s.createRange(); - - if (tinyMCE.isSafari && !s.getRangeAt) - return '' + window.getSelection(); - - if (s.rangeCount > 0) - return s.getRangeAt(0); - - return null; - }, - - isCollapsed : function() { - var r = this.getRng(); - - if (r.item) - return false; - - return r.boundingWidth == 0 || this.getSel().isCollapsed; - }, - - collapse : function(b) { - var r = this.getRng(), s = this.getSel(); - - if (r.select) { - r.collapse(b); - r.select(); - } else { - if (b) - s.collapseToStart(); - else - s.collapseToEnd(); - } - }, - - getFocusElement : function() { - var inst = this.instance, doc, rng, sel, elm; - - if (tinyMCE.isRealIE) { - doc = inst.getDoc(); - rng = doc.selection.createRange(); - - // if (rng.collapse) - // rng.collapse(true); - - elm = rng.item ? rng.item(0) : rng.parentElement(); - } else { - if (!tinyMCE.isSafari && inst.isHidden()) - return inst.getBody(); - - sel = this.getSel(); - rng = this.getRng(); - - if (!sel || !rng) - return null; - - elm = rng.commonAncestorContainer; - //elm = (sel && sel.anchorNode) ? sel.anchorNode : null; - - // Handle selection a image or other control like element such as anchors - if (!rng.collapsed) { - // Is selection small - if (rng.startContainer == rng.endContainer) { - if (rng.startOffset - rng.endOffset < 2) { - if (rng.startContainer.hasChildNodes()) - elm = rng.startContainer.childNodes[rng.startOffset]; - } - } - } - - // Get the element parent of the node - elm = tinyMCE.getParentElement(elm); - - //if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") - // elm = tinyMCE.selectedElement; - } - - return elm; - } - - }; - -/* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */ - -function TinyMCE_UndoRedo(inst) { - this.instance = inst; - this.undoLevels = []; - this.undoIndex = 0; - this.typingUndoIndex = -1; - this.undoRedo = true; -}; - -TinyMCE_UndoRedo.prototype = { - add : function(l) { - var b, customUndoLevels, newHTML, inst = this.instance, i, ul, ur; - - if (l) { - this.undoLevels[this.undoLevels.length] = l; - return true; - } - - if (this.typingUndoIndex != -1) { - this.undoIndex = this.typingUndoIndex; - - if (tinyMCE.typingUndoIndex != -1) - tinyMCE.undoIndex = tinyMCE.typingUndoIndex; - } - - newHTML = tinyMCE.trim(inst.getBody().innerHTML); - if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) { - //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content); - - // Is dirty again - inst.isNotDirty = false; - - tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst); - - // Time to compress - customUndoLevels = tinyMCE.settings.custom_undo_redo_levels; - if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) { - for (i=0; i 0) { - this.undoIndex--; - - tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content); - inst.repaint(); - - if (inst.settings.custom_undo_redo_restore_selection) - inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark); - } - }, - - redo : function() { - var inst = this.instance; - - tinyMCE.execCommand("mceEndTyping"); - - if (this.undoIndex < (this.undoLevels.length-1)) { - this.undoIndex++; - - tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content); - inst.repaint(); - - if (inst.settings.custom_undo_redo_restore_selection) - inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark); - } - - tinyMCE.triggerNodeChange(); - } - - }; - -/* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */ - -var TinyMCE_ForceParagraphs = { - _insertPara : function(inst, e) { - var doc = inst.getDoc(), sel = inst.getSel(), body = inst.getBody(), win = inst.contentWindow, rng = sel.getRangeAt(0); - var rootElm = doc.documentElement, blockName = "P", startNode, endNode, startBlock, endBlock; - var rngBefore, rngAfter, direct, startNode, startOffset, endNode, endOffset, b = tinyMCE.isOpera ? inst.selection.getBookmark() : null; - var paraBefore, paraAfter, startChop, endChop, contents, i; - - function isEmpty(para) { - var nodes; - - function isEmptyHTML(html) { - return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == ''; - } - - // Check for images - if (para.getElementsByTagName("img").length > 0) - return false; - - // Check for tables - if (para.getElementsByTagName("table").length > 0) - return false; - - // Check for HRs - if (para.getElementsByTagName("hr").length > 0) - return false; - - // Check all textnodes - nodes = tinyMCE.getNodeTree(para, [], 3); - for (i=0; i <" + blockName + "> "; - paraAfter = body.childNodes[1]; - } - - inst.selection.moveToBookmark(b); - inst.selection.selectNode(paraAfter, true, true); - - return true; - } - - // Place first part within new paragraph - if (startChop.nodeName == blockName) - rngBefore.setStart(startChop, 0); - else - rngBefore.setStartBefore(startChop); - - rngBefore.setEnd(startNode, startOffset); - paraBefore.appendChild(rngBefore.cloneContents()); - - // Place secound part within new paragraph - rngAfter.setEndAfter(endChop); - rngAfter.setStart(endNode, endOffset); - contents = rngAfter.cloneContents(); - - if (contents.firstChild && contents.firstChild.nodeName == blockName) { - /* var nodes = contents.firstChild.childNodes; - for (i=0; i= r.startOffset && nv.charAt(r.startOffset - 1) == ' ') - s = true;*/ - - // Only remove BRs if we are at the end of line #bug 1464152 - if (nv != null && r.startOffset == nv.length) - sn.nextSibling.parentNode.removeChild(sn.nextSibling); - } - - if (inst.settings.auto_resize) - inst.resizeToContent(); - - return s; - } - - }; - -/* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */ - -function TinyMCE_Layer(id, bm) { - this.id = id; - this.blockerElement = null; - this.events = false; - this.element = null; - this.blockMode = typeof(bm) != 'undefined' ? bm : true; - this.doc = document; -}; - -TinyMCE_Layer.prototype = { - moveRelativeTo : function(re, p) { - var rep = this.getAbsPosition(re), e = this.getElement(), x, y; - var w = parseInt(re.offsetWidth), h = parseInt(re.offsetHeight); - var ew = parseInt(e.offsetWidth), eh = parseInt(e.offsetHeight); - - switch (p) { - case "tl": - x = rep.absLeft; - y = rep.absTop; - break; - - case "tr": - x = rep.absLeft + w; - y = rep.absTop; - break; - - case "bl": - x = rep.absLeft; - y = rep.absTop + h; - break; - - case "br": - x = rep.absLeft + w; - y = rep.absTop + h; - break; - - case "cc": - x = rep.absLeft + (w / 2) - (ew / 2); - y = rep.absTop + (h / 2) - (eh / 2); - break; - } - - this.moveTo(x, y); - }, - - moveBy : function(x, y) { - var e = this.getElement(); - this.moveTo(parseInt(e.style.left) + x, parseInt(e.style.top) + y); - }, - - moveTo : function(x, y) { - var e = this.getElement(); - - e.style.left = x + "px"; - e.style.top = y + "px"; - - this.updateBlocker(); - }, - - resizeBy : function(w, h) { - var e = this.getElement(); - this.resizeTo(parseInt(e.style.width) + w, parseInt(e.style.height) + h); - }, - - resizeTo : function(w, h) { - var e = this.getElement(); - - if (w != null) - e.style.width = w + "px"; - - if (h != null) - e.style.height = h + "px"; - - this.updateBlocker(); - }, - - show : function() { - var el = this.getElement(); - - if (el) { - el.style.display = 'block'; - this.updateBlocker(); - } - }, - - hide : function() { - var el = this.getElement(); - - if (el) { - el.style.display = 'none'; - this.updateBlocker(); - } - }, - - isVisible : function() { - return this.getElement().style.display == 'block'; - }, - - getElement : function() { - if (!this.element) - this.element = this.doc.getElementById(this.id); - - return this.element; - }, - - setBlockMode : function(s) { - this.blockMode = s; - }, - - updateBlocker : function() { - var e, b, x, y, w, h; - - b = this.getBlocker(); - if (b) { - if (this.blockMode) { - e = this.getElement(); - x = this.parseInt(e.style.left); - y = this.parseInt(e.style.top); - w = this.parseInt(e.offsetWidth); - h = this.parseInt(e.offsetHeight); - - b.style.left = x + 'px'; - b.style.top = y + 'px'; - b.style.width = w + 'px'; - b.style.height = h + 'px'; - b.style.display = e.style.display; - } else - b.style.display = 'none'; - } - }, - - getBlocker : function() { - var d, b; - - if (!this.blockerElement && this.blockMode) { - d = this.doc; - b = d.getElementById(this.id + "_blocker"); - - if (!b) { - b = d.createElement("iframe"); - - b.setAttribute('id', this.id + "_blocker"); - b.style.cssText = 'display: none; position: absolute; left: 0; top: 0'; - b.src = 'javascript:false;'; - b.frameBorder = '0'; - b.scrolling = 'no'; - - d.body.appendChild(b); - } - - this.blockerElement = b; - } - - return this.blockerElement; - }, - - getAbsPosition : function(n) { - var p = {absLeft : 0, absTop : 0}; - - while (n) { - p.absLeft += n.offsetLeft; - p.absTop += n.offsetTop; - n = n.offsetParent; - } - - return p; - }, - - create : function(n, c, p, h) { - var d = this.doc, e = d.createElement(n); - - e.setAttribute('id', this.id); - - if (c) - e.className = c; - - if (!p) - p = d.body; - - if (h) - e.innerHTML = h; - - p.appendChild(e); - - return this.element = e; - }, - - exists : function() { - return this.doc.getElementById(this.id) != null; - }, - - parseInt : function(s) { - if (s == null || s == '') - return 0; - - return parseInt(s); - }, - - remove : function() { - var e = this.getElement(), b = this.getBlocker(); - - if (e) - e.parentNode.removeChild(e); - - if (b) - b.parentNode.removeChild(b); - } - - }; - -/* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */ - -function TinyMCE_Menu() { - var id; - - if (typeof(tinyMCE.menuCounter) == "undefined") - tinyMCE.menuCounter = 0; - - id = "mc_menu_" + tinyMCE.menuCounter++; - - TinyMCE_Layer.call(this, id, true); - - this.id = id; - this.items = []; - this.needsUpdate = true; -}; - -TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, { - init : function(s) { - var n; - - // Default params - this.settings = { - separator_class : 'mceMenuSeparator', - title_class : 'mceMenuTitle', - disabled_class : 'mceMenuDisabled', - menu_class : 'mceMenu', - drop_menu : true - }; - - for (n in s) - this.settings[n] = s[n]; - - this.create('div', this.settings.menu_class); - }, - - clear : function() { - this.items = []; - }, - - addTitle : function(t) { - this.add({type : 'title', text : t}); - }, - - addDisabled : function(t) { - this.add({type : 'disabled', text : t}); - }, - - addSeparator : function() { - this.add({type : 'separator'}); - }, - - addItem : function(t, js) { - this.add({text : t, js : js}); - }, - - add : function(mi) { - this.items[this.items.length] = mi; - this.needsUpdate = true; - }, - - update : function() { - var e = this.getElement(), h = '', i, t, m = this.items, s = this.settings; - - if (this.settings.drop_menu) - h += ''; - - h += ''; - - for (i=0; i'; - } - - h += '
    '; - break; - - case 'title': - h += '
    ' + t + ''; - break; - - case 'disabled': - h += '
    ' + t + ''; - break; - - default: - h += '
    ' + t + ''; - } - - h += '
    '; - - e.innerHTML = h; - - this.needsUpdate = false; - this.updateBlocker(); - }, - - show : function() { - var nl, i; - - if (tinyMCE.lastMenu == this) - return; - - if (this.needsUpdate) - this.update(); - - if (tinyMCE.lastMenu && tinyMCE.lastMenu != this) - tinyMCE.lastMenu.hide(); - - TinyMCE_Layer.prototype.show.call(this); - - if (!tinyMCE.isOpera) { - // Accessibility stuff -/* nl = this.getElement().getElementsByTagName("a"); - if (nl.length > 0) - nl[0].focus();*/ - } - - tinyMCE.lastMenu = this; - } - - }); - -/* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */ - -tinyMCE.add(TinyMCE_Engine, { - debug : function() { - var m = "", a, i, l = tinyMCE.log.length; - - for (i=0, a = this.debug.arguments; i=items.length){for(i=0;i=items.length||base[i]!=items[i]){bp=i+1;break;}}}if(base.length=base.length||base[i]!=items[i]){bp=i+1;break;}}}if(bp==1)return path;for(i=0;i=0;i--){if(path[i].length==0||path[i]==".")continue;if(path[i]=='..'){nb++;continue;}if(nb>0){nb--;continue;}o.push(path[i]);}i=base.length-nb;if(i<=0)return'/'+o.reverse().join('/');return'/'+base.slice(0,i).join('/')+'/'+o.reverse().join('/');},getURI:function(nh){var s,t=this;if(!t.source||nh){s='';if(!nh){if(t.protocol)s+=t.protocol+'://';if(t.userInfo)s+=t.userInfo+'@';if(t.host)s+=t.host;if(t.port)s+=':'+t.port;}if(t.path)s+=t.path;if(t.query)s+='?'+t.query;if(t.anchor)s+='#'+t.anchor;t.source=s;}return t.source;}});})();(function(){var each=tinymce.each;tinymce.create('static tinymce.util.Cookie',{getHash:function(n){var v=this.get(n),h;if(v){each(v.split('&'),function(v){v=v.split('=');h=h||{};h[unescape(v[0])]=unescape(v[1]);});}return h;},setHash:function(n,v,e,p,d,s){var o='';each(v,function(v,k){o+=(!o?'':'&')+escape(k)+'='+escape(v);});this.set(n,o,e,p,d,s);},get:function(n){var c=document.cookie,e,p=n+"=",b;if(!c)return;b=c.indexOf("; "+p);if(b==-1){b=c.indexOf(p);if(b!=0)return null;}else b+=2;e=c.indexOf(";",b);if(e==-1)e=c.length;return unescape(c.substring(b+p.length,e));},set:function(n,v,e,p,d,s){document.cookie=n+"="+escape(v)+((e)?"; expires="+e.toGMTString():"")+((p)?"; path="+escape(p):"")+((d)?"; domain="+d:"")+((s)?"; secure":"");},remove:function(n,p){var d=new Date();d.setTime(d.getTime()-1000);this.set(n,'',d,p,d);}});})();tinymce.create('static tinymce.util.JSON',{serialize:function(o){var i,v,s=tinymce.util.JSON.serialize,t;if(o==null)return'null';t=typeof o;if(t=='string'){v='\bb\tt\nn\ff\rr\""\'\'\\\\';return'"'+o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'])/g,function(a,b){i=v.indexOf(b);if(i+1)return'\\'+v.charAt(i+1);a=b.charCodeAt().toString(16);return'\\u'+'0000'.substring(a.length)+a;})+'"';}if(t=='object'){if(o instanceof Array){for(i=0,v='[';i0?',':'')+s(o[i]);return v+']';}v='{';for(i in o)v+=typeof o[i]!='function'?(v.length>1?',"':'"')+i+'":'+s(o[i]):'';return v+'}';}return''+o;},parse:function(s){try{return eval('('+s+')');}catch(ex){}}});tinymce.create('static tinymce.util.XHR',{send:function(o){var x,t,w=window,c=0;o.scope=o.scope||this;o.success_scope=o.success_scope||o.scope;o.error_scope=o.error_scope||o.scope;o.async=o.async===false?false:true;o.data=o.data||'';function get(s){x=0;try{x=new ActiveXObject(s);}catch(ex){}return x;};x=w.XMLHttpRequest?new XMLHttpRequest():get('Microsoft.XMLHTTP')||get('Msxml2.XMLHTTP');if(x){if(x.overrideMimeType)x.overrideMimeType(o.content_type);x.open(o.type||(o.data?'POST':'GET'),o.url,o.async);if(o.content_type)x.setRequestHeader('Content-Type',o.content_type);x.send(o.data);t=w.setInterval(function(){if(x.readyState==4||c++>10000){w.clearInterval(t);if(o.success&&c<10000&&x.status==200)o.success.call(o.success_scope,''+x.responseText,x,o);else if(o.error)o.error.call(o.error_scope,c>10000?'TIMED_OUT':'GENERAL',x,o);x=null;}},10);}}});(function(){var extend=tinymce.extend,JSON=tinymce.util.JSON,XHR=tinymce.util.XHR;tinymce.create('tinymce.util.JSONRequest',{JSONRequest:function(s){this.settings=extend({},s);this.count=0;},send:function(o){var ecb=o.error,scb=o.success;o=extend(this.settings,o);o.success=function(c,x){c=JSON.parse(c);if(typeof(c)=='undefined'){c={error:'JSON Parse error.'};}if(c.error)ecb.call(o.error_scope||o.scope,c.error,x);else scb.call(o.success_scope||o.scope,c.result);};o.error=function(ty,x){ecb.call(o.error_scope||o.scope,ty,x);};o.data=JSON.serialize({id:o.id||'c'+(this.count++),method:o.method,params:o.params});o.content_type='application/json';XHR.send(o);},'static':{sendRPC:function(o){return new tinymce.util.JSONRequest().send(o);}}});}());(function(){var each=tinymce.each,is=tinymce.is;var isWebKit=tinymce.isWebKit,isIE=tinymce.isIE;tinymce.create('tinymce.dom.DOMUtils',{doc:null,root:null,files:null,listeners:{},pixelStyles:/^(top|left|bottom|right|width|height|borderWidth)$/,cache:{},idPattern:/^#[\w]+$/,elmPattern:/^[\w_*]+$/,elmClassPattern:/^([\w_]*)\.([\w_]+)$/,DOMUtils:function(d,s){var t=this;t.doc=d;t.win=window;t.files={};t.cssFlicker=false;t.counter=0;t.boxModel=!tinymce.isIE||d.compatMode=="CSS1Compat";t.stdMode=d.documentMode===8;this.settings=s=tinymce.extend({keep_values:false,hex_colors:1,process_html:1},s);if(tinymce.isIE6){try{d.execCommand('BackgroundImageCache',false,true);}catch(e){t.cssFlicker=true;}}tinymce.addUnload(t.destroy,t);},getRoot:function(){var t=this,s=t.settings;return(s&&t.get(s.root_element))||t.doc.body;},getViewPort:function(w){var d,b;w=!w?this.win:w;d=w.document;b=this.boxModel?d.documentElement:d.body;return{x:w.pageXOffset||b.scrollLeft,y:w.pageYOffset||b.scrollTop,w:w.innerWidth||b.clientWidth,h:w.innerHeight||b.clientHeight};},getRect:function(e){var p,t=this,w,h;e=t.get(e);p=t.getPos(e);w=t.getStyle(e,'width');h=t.getStyle(e,'height');if(w.indexOf('px')===-1)w=0;if(h.indexOf('px')===-1)h=0;return{x:p.x,y:p.y,w:parseInt(w)||e.offsetWidth||e.clientWidth,h:parseInt(h)||e.offsetHeight||e.clientHeight};},getParent:function(n,f,r){var na,se=this.settings;n=this.get(n);if(se.strict_root)r=r||this.getRoot();if(is(f,'string')){na=f.toUpperCase();f=function(n){var s=false;if(n.nodeType==1&&na==='*'){s=true;return false;}each(na.split(','),function(v){if(n.nodeType==1&&((se.strict&&n.nodeName.toUpperCase()==v)||n.nodeName==v)){s=true;return false;}});return s;};}while(n){if(n==r)return null;if(f(n))return n;n=n.parentNode;}return null;},get:function(e){var n;if(e&&this.doc&&typeof(e)=='string'){n=e;e=this.doc.getElementById(e);if(e&&e.id!==n)return this.doc.getElementsByName(n)[1];}return e;},select:function(pa,s){var t=this,cs,c,pl,o=[],x,i,l,n;s=t.get(s)||t.doc;if(s.querySelectorAll){if(s!=t.doc){i=s.id;s.id='_mc_tmp';pa='#_mc_tmp '+pa;}l=tinymce.grep(s.querySelectorAll(pa));s.id=i;return l;}if(t.settings.strict){function get(s,n){return s.getElementsByTagName(n.toLowerCase());};}else{function get(s,n){return s.getElementsByTagName(n);};}if(t.elmPattern.test(pa)){x=get(s,pa);for(i=0,l=x.length;i=0;i--)cs+='}, '+(i?'n':'s')+');';cs+='})';t.cache[pa]=cs=eval(cs);}cs(isIE?collectIE:collect,s);});each(o,function(n){if(isIE)n.removeAttribute('mce_save');else delete n.mce_save;});return o;},add:function(p,n,a,h,c){var t=this;return this.run(p,function(p){var e,k;e=is(n,'string')?t.doc.createElement(n):n;if(a){for(k in a){if(a.hasOwnProperty(k)&&!is(a[k],'object'))t.setAttrib(e,k,''+a[k]);}if(a.style&&!is(a.style,'string')){each(a.style,function(v,n){t.setStyle(e,n,v);});}}if(h){if(h.nodeType)e.appendChild(h);else t.setHTML(e,h);}return!c?p.appendChild(e):e;});},create:function(n,a,h){return this.add(this.doc.createElement(n),n,a,h,1);},createHTML:function(n,a,h){var o='',t=this,k;o+='<'+n;for(k in a){if(a.hasOwnProperty(k))o+=' '+k+'="'+t.encode(a[k])+'"';}if(tinymce.is(h))return o+'>'+h+'';return o+' />';},remove:function(n,k){return this.run(n,function(n){var p,g;p=n.parentNode;if(!p)return null;if(k){each(n.childNodes,function(c){p.insertBefore(c.cloneNode(true),n);});}return p.removeChild(n);});},setStyle:function(n,na,v){var t=this;return t.run(n,function(e){var s,i;s=e.style;na=na.replace(/-(\D)/g,function(a,b){return b.toUpperCase();});if(t.pixelStyles.test(na)&&(tinymce.is(v,'number')||/^[\-0-9\.]+$/.test(v)))v+='px';switch(na){case'opacity':if(isIE){s.filter=v===''?'':"alpha(opacity="+(v*100)+")";if(!n.currentStyle||!n.currentStyle.hasLayout)s.display='inline-block';}s[na]=s['-moz-opacity']=s['-khtml-opacity']=v||'';break;case'float':isIE?s.styleFloat=v:s.cssFloat=v;break;default:s[na]=v||'';}if(t.settings.update_styles)t.setAttrib(e,'mce_style');});},getStyle:function(n,na,c){n=this.get(n);if(!n)return false;if(this.doc.defaultView&&c){na=na.replace(/[A-Z]/g,function(a){return'-'+a;});try{return this.doc.defaultView.getComputedStyle(n,null).getPropertyValue(na);}catch(ex){return null;}}na=na.replace(/-(\D)/g,function(a,b){return b.toUpperCase();});if(na=='float')na=isIE?'styleFloat':'cssFloat';if(n.currentStyle&&c)return n.currentStyle[na];return n.style[na];},setStyles:function(e,o){var t=this,s=t.settings,ol;ol=s.update_styles;s.update_styles=0;each(o,function(v,n){t.setStyle(e,n,v);});s.update_styles=ol;if(s.update_styles)t.setAttrib(e,s.cssText);},setAttrib:function(e,n,v){var t=this;if(t.settings.strict)n=n.toLowerCase();return this.run(e,function(e){var s=t.settings;switch(n){case"style":if(s.keep_values&&/^(| )(top|left|bottom|right|width|height)/i.test(v)){if(v)e.setAttribute('mce_style',v,2);else e.removeAttribute('mce_style',2);}e.style.cssText=v;break;case"class":e.className=v||'';break;case"src":case"href":if(s.keep_values){if(s.url_converter)v=s.url_converter.call(s.url_converter_scope||t,v,n,e);t.setAttrib(e,'mce_'+n,v,2);}break;}if(is(v)&&v!==null&&v.length!==0)e.setAttribute(n,''+v,2);else e.removeAttribute(n,2);});},setAttribs:function(e,o){var t=this;return this.run(e,function(e){each(o,function(v,n){t.setAttrib(e,n,v);});});},getAttrib:function(e,n,dv){var v,t=this;e=t.get(e);if(!e||e.nodeType!==1)return false;if(!is(dv))dv="";if(/^(src|href|style|coords)$/.test(n)){v=e.getAttribute("mce_"+n);if(v)return v;}v=e.getAttribute(n,2);if(!v){switch(n){case'class':v=e.className;break;default:if(isIE&&n==='name'&&e.nodeName==='A'){v=e.name;break;}v=e.attributes[n];v=v&&is(v.nodeValue)?v.nodeValue:v;}}switch(n){case'style':v=v||e.style.cssText;if(v){v=t.serializeStyle(t.parseStyle(v));if(t.settings.keep_values&&/^(| )(top|left|bottom|right|width|height)/i.test(v))e.setAttribute('mce_style',v);}break;}if(isWebKit&&n==="class"&&v)v=v.replace(/(apple|webkit)\-[a-z\-]+/gi,'');if(isIE){switch(n){case'rowspan':case'colspan':if(v===1)v='';break;case'size':if(v==='+0')v='';break;case'hspace':if(v===-1)v='';break;case'tabindex':if(v===32768)v='';break;case'shape':v=v.toLowerCase();break;default:if(n.indexOf('on')===0&&v)v=(''+v).replace(/^function\s+anonymous\(\)\s+\{\s+(.*)\s+\}$/,'$1');}}return(v&&v!='')?''+v:dv;},getPos:function(n){var t=this,x=0,y=0,e,d=t.doc,r;n=t.get(n);if(n&&isIE){n=n.getBoundingClientRect();e=t.boxModel?d.documentElement:d.body;x=t.getStyle(t.select('html')[0],'borderWidth');x=(x=='medium'||t.boxModel&&!t.isIE6)&&2||x;n.top+=t.win.self!=t.win.top?2:0;return{x:n.left+e.scrollLeft-x,y:n.top+e.scrollTop-x};}r=n;while(r){x+=r.offsetLeft||0;y+=r.offsetTop||0;r=r.offsetParent;}r=n;while(r){if(!/^table-row|inline.*/i.test(t.getStyle(r,"display",1))){x-=r.scrollLeft||0;y-=r.scrollTop||0;}r=r.parentNode;if(r==d.body)break;}return{x:x,y:y};},parseStyle:function(st){var t=this,s=t.settings,o={};if(!st)return o;function compress(p,s,ot){var t,r,b,l;t=o[p+'-top'+s];if(!t)return;r=o[p+'-right'+s];if(t!=r)return;b=o[p+'-bottom'+s];if(r!=b)return;l=o[p+'-left'+s];if(b!=l)return;o[ot]=l;delete o[p+'-top'+s];delete o[p+'-right'+s];delete o[p+'-bottom'+s];delete o[p+'-left'+s];};function compress2(ta,a,b,c){var t;t=o[a];if(!t)return;t=o[b];if(!t)return;t=o[c];if(!t)return;o[ta]=o[a]+' '+o[b]+' '+o[c];delete o[a];delete o[b];delete o[c];};each(st.split(';'),function(v){var sv,ur=[];if(v){v=v.replace(/url\([^\)]+\)/g,function(v){ur.push(v);return'url('+ur.length+')';});v=v.split(':');sv=tinymce.trim(v[1]);sv=sv.replace(/url\(([^\)]+)\)/g,function(a,b){return ur[parseInt(b)-1];});sv=sv.replace(/rgb\([^\)]+\)/g,function(v){return t.toHex(v);});if(s.url_converter){sv=sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g,function(x,c){return'url('+t.encode(s.url_converter.call(s.url_converter_scope||t,t.decode(c),'style',null))+')';});}o[tinymce.trim(v[0]).toLowerCase()]=sv;}});compress("border","","border");compress("border","-width","border-width");compress("border","-color","border-color");compress("border","-style","border-style");compress("padding","","padding");compress("margin","","margin");compress2('border','border-width','border-style','border-color');if(isIE){if(o.border=='medium none')o.border='';}return o;},serializeStyle:function(o){var s='';each(o,function(v,k){if(k&&v){switch(k){case'color':case'background-color':v=v.toLowerCase();break;}s+=(s?' ':'')+k+': '+v+';';}});return s;},loadCSS:function(u){var t=this,d=t.doc;if(!u)u='';each(u.split(','),function(u){if(t.files[u])return;t.files[u]=true;t.add(t.select('head')[0],'link',{rel:'stylesheet',href:tinymce._addVer(u)});});},addClass:function(e,c){return this.run(e,function(e){var o;if(!c)return 0;if(this.hasClass(e,c))return e.className;o=this.removeClass(e,c);return e.className=(o!=''?(o+' '):'')+c;});},removeClass:function(e,c){var t=this,re;return t.run(e,function(e){var v;if(t.hasClass(e,c)){if(!re)re=new RegExp("(^|\\s+)"+c+"(\\s+|$)","g");v=e.className.replace(re,' ');return e.className=tinymce.trim(v!=' '?v:'');}return e.className;});},hasClass:function(n,c){n=this.get(n);if(!n||!c)return false;return(' '+n.className+' ').indexOf(' '+c+' ')!==-1;},show:function(e){return this.setStyle(e,'display','block');},hide:function(e){return this.setStyle(e,'display','none');},isHidden:function(e){e=this.get(e);return e.style.display=='none'||this.getStyle(e,'display')=='none';},uniqueId:function(p){return(!p?'mce_':p)+(this.counter++);},setHTML:function(e,h){var t=this;return this.run(e,function(e){var x,i,nl,n,p,x;h=t.processHTML(h);if(isIE){function set(){try{e.innerHTML='
    '+h;e.removeChild(e.firstChild);}catch(ex){while(e.firstChild)e.firstChild.removeNode();x=t.create('div');x.innerHTML='
    '+h;each(x.childNodes,function(n,i){if(i)e.appendChild(n);});}};if(t.settings.fix_ie_paragraphs)h=h.replace(/

    <\/p>|]+)><\/p>|/gi,' 

    ');set();if(t.settings.fix_ie_paragraphs){nl=e.getElementsByTagName("p");for(i=nl.length-1,x=0;i>=0;i--){n=nl[i];if(!n.hasChildNodes()){if(!n.mce_keep){x=1;break;}n.removeAttribute('mce_keep');}}}if(x){h=h.replace(/]+)>|

    /g,'');h=h.replace(/<\/p>/g,'

    ');set();if(t.settings.fix_ie_paragraphs){nl=e.getElementsByTagName("DIV");for(i=nl.length-1;i>=0;i--){n=nl[i];if(n.mce_tmp){p=t.doc.createElement('p');n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi,function(a,b){var v;if(b!=='mce_tmp'){v=n.getAttribute(b);if(!v&&b==='class')v=n.className;p.setAttribute(b,v);}});for(x=0;x|]+)>/gi,'<$1b$2>');h=h.replace(/<(\/?)em>|]+)>/gi,'<$1i$2>');}else if(isIE)h=h.replace(/'/g,''');h=h.replace(/]+)\/>|/gi,'');if(s.keep_values){if(h.indexOf('/g,'';bi=s.body_id||'tinymce';if(bi.indexOf('=')!=-1){bi=t.getParam('body_id','','hash');bi=bi[t.id]||bi;}bc=s.body_class||'';if(bc.indexOf('=')!=-1){bc=t.getParam('body_class','','hash');bc=bc[t.id]||'';}t.iframeHTML+='';if(tinymce.relaxedDomain){if(isIE)u='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinyMCE.get("'+t.id+'");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';else if(tinymce.isOpera)u='javascript:(function(){document.open();document.domain="'+document.domain+'";document.close();ed.setupIframe();})()';}n=DOM.add(o.iframeContainer,'iframe',{id:t.id+"_ifr",src:u||'javascript:""',frameBorder:'0',style:{width:'100%',height:h}});t.contentAreaContainer=o.iframeContainer;DOM.get(o.editorContainer).style.display=t.orgDisplay;DOM.get(t.id).style.display='none';if(tinymce.isOldWebKit){Event.add(n,'load',t.setupIframe,t);n.src=tinymce.baseURL+'/plugins/safari/blank.htm';}else{if(!isIE||!tinymce.relaxedDomain)t.setupIframe();e=n=o=null;}},setupIframe:function(){var t=this,s=t.settings,e=DOM.get(t.id),d=t.getDoc(),h,b;if(!isIE||!tinymce.relaxedDomain){d.open();d.write(t.iframeHTML);d.close();}if(!isIE){try{d.designMode='On';}catch(ex){}}if(isIE){b=t.getBody();DOM.hide(b);b.contentEditable=true;DOM.show(b);}t.dom=new tinymce.DOM.DOMUtils(t.getDoc(),{keep_values:true,url_converter:t.convertURL,url_converter_scope:t,hex_colors:s.force_hex_style_colors,class_filter:s.class_filter,update_styles:1,fix_ie_paragraphs:1});t.serializer=new tinymce.dom.Serializer({entity_encoding:s.entity_encoding,entities:s.entities,valid_elements:s.verify_html===false?'*[*]':s.valid_elements,extended_valid_elements:s.extended_valid_elements,valid_child_elements:s.valid_child_elements,invalid_elements:s.invalid_elements,fix_table_elements:s.fix_table_elements,fix_list_elements:s.fix_list_elements,fix_content_duplication:s.fix_content_duplication,convert_fonts_to_spans:s.convert_fonts_to_spans,font_size_classes:s.font_size_classes,font_size_style_values:s.font_size_style_values,apply_source_formatting:s.apply_source_formatting,remove_linebreaks:s.remove_linebreaks,dom:t.dom});t.selection=new tinymce.dom.Selection(t.dom,t.getWin(),t.serializer);t.forceBlocks=new tinymce.ForceBlocks(t,{forced_root_block:s.forced_root_block});t.editorCommands=new tinymce.EditorCommands(t);t.serializer.onPreProcess.add(function(se,o){return t.onPreProcess.dispatch(t,o,se);});t.serializer.onPostProcess.add(function(se,o){return t.onPostProcess.dispatch(t,o,se);});t.onPreInit.dispatch(t);if(!s.gecko_spellcheck)t.getBody().spellcheck=0;t._addEvents();t.controlManager.onPostRender.dispatch(t,t.controlManager);t.onPostRender.dispatch(t);if(s.directionality)t.getBody().dir=s.directionality;if(s.nowrap)t.getBody().style.whiteSpace="nowrap";if(s.auto_resize)t.onNodeChange.add(t.resizeToContent,t);if(s.custom_elements){function handleCustom(ed,o){each(explode(s.custom_elements),function(v){var n;if(v.indexOf('~')===0){v=v.substring(1);n='span';}else n='div';o.content=o.content.replace(new RegExp('<('+v+')([^>]*)>','g'),'<'+n+' mce_name="$1"$2>');o.content=o.content.replace(new RegExp('','g'),'');});};t.onBeforeSetContent.add(handleCustom);t.onPostProcess.add(function(ed,o){if(o.set)handleCustom(ed,o)});}if(s.handle_node_change_callback){t.onNodeChange.add(function(ed,cm,n){t.execCallback('handle_node_change_callback',t.id,n,-1,-1,true,t.selection.isCollapsed());});}if(s.save_callback){t.onSaveContent.add(function(ed,o){var h=t.execCallback('save_callback',t.id,o.content,t.getBody());if(h)o.content=h;});}if(s.onchange_callback){t.onChange.add(function(ed,l){t.execCallback('onchange_callback',t,l);});}if(s.convert_newlines_to_brs){t.onBeforeSetContent.add(function(ed,o){if(o.initial)o.content=o.content.replace(/\r?\n/g,'
    ');});}if(s.fix_nesting&&isIE){t.onBeforeSetContent.add(function(ed,o){o.content=t._fixNesting(o.content);});}if(s.preformatted){t.onPostProcess.add(function(ed,o){o.content=o.content.replace(/^\s*/,'');o.content=o.content.replace(/<\/pre>\s*$/,'');if(o.set)o.content='
    '+o.content+'
    ';});}if(s.verify_css_classes){t.serializer.attribValueFilter=function(n,v){var s,cl;if(n=='class'){if(!t.classesRE){cl=t.dom.getClasses();if(cl.length>0){s='';each(cl,function(o){s+=(s?'|':'')+o['class'];});t.classesRE=new RegExp('('+s+')','gi');}}return!t.classesRE||/(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v)||t.classesRE.test(v)?v:'';}return v;};}if(s.convert_fonts_to_spans)t._convertFonts();if(s.inline_styles)t._convertInlineElements();if(s.cleanup_callback){t.onBeforeSetContent.add(function(ed,o){o.content=t.execCallback('cleanup_callback','insert_to_editor',o.content,o);});t.onPreProcess.add(function(ed,o){if(o.set)t.execCallback('cleanup_callback','insert_to_editor_dom',o.node,o);if(o.get)t.execCallback('cleanup_callback','get_from_editor_dom',o.node,o);});t.onPostProcess.add(function(ed,o){if(o.set)o.content=t.execCallback('cleanup_callback','insert_to_editor',o.content,o);if(o.get)o.content=t.execCallback('cleanup_callback','get_from_editor',o.content,o);});}if(s.save_callback){t.onGetContent.add(function(ed,o){if(o.save)o.content=t.execCallback('save_callback',t.id,o.content,t.getBody());});}if(s.handle_event_callback){t.onEvent.add(function(ed,e,o){if(t.execCallback('handle_event_callback',e,ed,o)===false)Event.cancel(e);});}t.onSetContent.add(function(){t.addVisual(t.getBody());});if(s.padd_empty_editor){t.onPostProcess.add(function(ed,o){o.content=o.content.replace(/^(

    ( | |\s|\u00a0|)<\/p>[\r\n]*|
    [\r\n]*)$/,'');});}if(isGecko){try{d.designMode='Off';d.designMode='On';}catch(ex){}}setTimeout(function(){if(t.removed)return;t.load({initial:true,format:(s.cleanup_on_startup?'html':'raw')});t.startContent=t.getContent({format:'raw'});t.undoManager.add({initial:true});t.initialized=true;t.onInit.dispatch(t);t.execCallback('setupcontent_callback',t.id,t.getBody(),t.getDoc());t.execCallback('init_instance_callback',t);t.focus(true);t.nodeChanged({initial:1});if(s.content_css){tinymce.each(explode(s.content_css),function(u){t.dom.loadCSS(t.documentBaseURI.toAbsolute(u));});}if(s.auto_focus){setTimeout(function(){var ed=EditorManager.get(s.auto_focus);ed.selection.select(ed.getBody(),1);ed.selection.collapse(1);ed.getWin().focus();},100);}},1);e=null;},focus:function(sf){var oed,t=this;if(!sf){t.getWin().focus();}if(EditorManager.activeEditor!=t){if((oed=EditorManager.activeEditor)!=null)oed.onDeactivate.dispatch(oed,t);t.onActivate.dispatch(t,oed);}EditorManager._setActive(t);},execCallback:function(n){var t=this,f=t.settings[n],s;if(!f)return;if(t.callbackLookup&&(s=t.callbackLookup[n])){f=s.func;s=s.scope;}if(is(f,'string')){s=f.replace(/\.\w+$/,'');s=s?tinymce.resolve(s):0;f=tinymce.resolve(f);t.callbackLookup=t.callbackLookup||{};t.callbackLookup[n]={func:f,scope:s};}return f.apply(s||t,Array.prototype.slice.call(arguments,1));},translate:function(s){var c=this.settings.language,i18n=EditorManager.i18n;if(!s)return'';return i18n[c+'.'+s]||s.replace(/{\#([^}]+)\}/g,function(a,b){return i18n[c+'.'+b]||'{#'+b+'}';});},getLang:function(n,dv){return EditorManager.i18n[this.settings.language+'.'+n]||(is(dv)?dv:'{#'+n+'}');},getParam:function(n,dv,ty){var tr=tinymce.trim,v=is(this.settings[n])?this.settings[n]:dv,o;if(ty==='hash'){o={};if(is(v,'string')){each(v.indexOf('=')>0?v.split(/[;,](?![^=;,]*(?:[;,]|$))/):v.split(','),function(v){v=v.split('=');if(v.length>1)o[tr(v[0])]=tr(v[1]);else o[tr(v[0])]=tr(v);});}else o=v;return o;}return v;},nodeChanged:function(o){var t=this,s=t.selection,n=s.getNode()||t.getBody();if(t.initialized){t.onNodeChange.dispatch(t,o?o.controlManager||t.controlManager:t.controlManager,isIE&&n.ownerDocument!=t.getDoc()?t.getBody():n,s.isCollapsed(),o);}},addButton:function(n,s){var t=this;t.buttons=t.buttons||{};t.buttons[n]=s;},addCommand:function(n,f,s){this.execCommands[n]={func:f,scope:s||this};},addQueryStateHandler:function(n,f,s){this.queryStateCommands[n]={func:f,scope:s||this};},addQueryValueHandler:function(n,f,s){this.queryValueCommands[n]={func:f,scope:s||this};},addShortcut:function(pa,desc,cmd_func,sc){var t=this,c;if(!t.settings.custom_shortcuts)return false;t.shortcuts=t.shortcuts||{};if(is(cmd_func,'string')){c=cmd_func;cmd_func=function(){t.execCommand(c,false,null);};}if(is(cmd_func,'object')){c=cmd_func;cmd_func=function(){t.execCommand(c[0],c[1],c[2]);};}each(explode(pa),function(pa){var o={func:cmd_func,scope:sc||this,desc:desc,alt:false,ctrl:false,shift:false};each(explode(pa,'+'),function(v){switch(v){case'alt':case'ctrl':case'shift':o[v]=true;break;default:o.charCode=v.charCodeAt(0);o.keyCode=v.toUpperCase().charCodeAt(0);}});t.shortcuts[(o.ctrl?'ctrl':'')+','+(o.alt?'alt':'')+','+(o.shift?'shift':'')+','+o.keyCode]=o;});return true;},execCommand:function(cmd,ui,val,a){var t=this,s=0,o,st;if(!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd)&&(!a||!a.skip_focus))t.focus();o={};t.onBeforeExecCommand.dispatch(t,cmd,ui,val,o);if(o.terminate)return false;if(t.execCallback('execcommand_callback',t.id,t.selection.getNode(),cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}if(o=t.execCommands[cmd]){st=o.func.call(o.scope,ui,val);if(st!==true){t.onExecCommand.dispatch(t,cmd,ui,val,a);return st;}}each(t.plugins,function(p){if(p.execCommand&&p.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);s=1;return false;}});if(s)return true;if(t.theme.execCommand&&t.theme.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}if(t.editorCommands.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}t.getDoc().execCommand(cmd,ui,val);t.onExecCommand.dispatch(t,cmd,ui,val,a);},queryCommandState:function(c){var t=this,o,s;if(t._isHidden())return;if(o=t.queryStateCommands[c]){s=o.func.call(o.scope);if(s!==true)return s;}o=t.editorCommands.queryCommandState(c);if(o!==-1)return o;try{return this.getDoc().queryCommandState(c);}catch(ex){}},queryCommandValue:function(c){var t=this,o,s;if(t._isHidden())return;if(o=t.queryValueCommands[c]){s=o.func.call(o.scope);if(s!==true)return s;}o=t.editorCommands.queryCommandValue(c);if(is(o))return o;try{return this.getDoc().queryCommandValue(c);}catch(ex){}},show:function(){var t=this;DOM.show(t.getContainer());DOM.hide(t.id);t.load();},hide:function(){var t=this,d=t.getDoc();if(isIE&&d)d.execCommand('SelectAll');t.save();DOM.hide(t.getContainer());DOM.setStyle(t.id,'display',t.orgDisplay);},isHidden:function(){return!DOM.isHidden(this.id);},setProgressState:function(b,ti,o){this.onSetProgressState.dispatch(this,b,ti,o);return b;},resizeToContent:function(){var t=this;DOM.setStyle(t.id+"_ifr",'height',t.getBody().scrollHeight);},load:function(o){var t=this,e=t.getElement(),h;o=o||{};o.load=true;h=t.setContent(is(e.value)?e.value:e.innerHTML,o);o.element=e;if(!o.no_events)t.onLoadContent.dispatch(t,o);o.element=e=null;return h;},save:function(o){var t=this,e=t.getElement(),h,f;if(!t.initialized)return;o=o||{};o.save=true;o.element=e;h=o.content=t.getContent(o);if(!o.no_events)t.onSaveContent.dispatch(t,o);h=o.content;if(!/TEXTAREA|INPUT/i.test(e.nodeName)){e.innerHTML=h;if(f=DOM.getParent(t.id,'form')){each(f.elements,function(e){if(e.name==t.id){e.value=h;return false;}});}}else e.value=h;o.element=e=null;return h;},setContent:function(h,o){var t=this;o=o||{};o.format=o.format||'html';o.set=true;o.content=h;if(!o.no_events)t.onBeforeSetContent.dispatch(t,o);if(!tinymce.isIE&&(h.length===0||/^\s+$/.test(h))){o.content=t.dom.setHTML(t.getBody(),'
    ',1);o.format='raw';}o.content=t.dom.setHTML(t.getBody(),tinymce.trim(o.content));if(o.format!='raw'&&t.settings.cleanup){o.getInner=true;o.content=t.dom.setHTML(t.getBody(),t.serializer.serialize(t.getBody(),o));}if(!o.no_events)t.onSetContent.dispatch(t,o);return o.content;},getContent:function(o){var t=this,h;o=o||{};o.format=o.format||'html';o.get=true;if(!o.no_events)t.onBeforeGetContent.dispatch(t,o);if(o.format!='raw'&&t.settings.cleanup){o.getInner=true;h=t.serializer.serialize(t.getBody(),o);}else h=t.getBody().innerHTML;h=h.replace(/^\s*|\s*$/g,'');o={content:h};t.onGetContent.dispatch(t,o);return o.content;},isDirty:function(){var t=this;return tinymce.trim(t.startContent)!=tinymce.trim(t.getContent({format:'raw',no_events:1}))&&!t.isNotDirty;},getContainer:function(){var t=this;if(!t.container)t.container=DOM.get(t.editorContainer||t.id+'_parent');return t.container;},getContentAreaContainer:function(){return this.contentAreaContainer;},getElement:function(){return DOM.get(this.settings.content_element||this.id);},getWin:function(){var t=this,e;if(!t.contentWindow){e=DOM.get(t.id+"_ifr");if(e)t.contentWindow=e.contentWindow;}return t.contentWindow;},getDoc:function(){var t=this,w;if(!t.contentDocument){w=t.getWin();if(w)t.contentDocument=w.document;}return t.contentDocument;},getBody:function(){return this.bodyElement||this.getDoc().body;},convertURL:function(u,n,e){var t=this,s=t.settings;if(s.urlconverter_callback)return t.execCallback('urlconverter_callback',u,e,true,n);if(!s.convert_urls||(e&&e.nodeName=='LINK')||u.indexOf('file:')===0)return u;if(s.relative_urls)return t.documentBaseURI.toRelative(u);u=t.documentBaseURI.toAbsolute(u,s.remove_script_host);return u;},addVisual:function(e){var t=this,s=t.settings;e=e||t.getBody();if(!is(t.hasVisual))t.hasVisual=s.visual;each(t.dom.select('table,a',e),function(e){var v;switch(e.nodeName){case'TABLE':v=t.dom.getAttrib(e,'border');if(!v||v=='0'){if(t.hasVisual)t.dom.addClass(e,s.visual_table_class);else t.dom.removeClass(e,s.visual_table_class);}return;case'A':v=t.dom.getAttrib(e,'name');if(v){if(t.hasVisual)t.dom.addClass(e,'mceItemAnchor');else t.dom.removeClass(e,'mceItemAnchor');}return;}});t.onVisualAid.dispatch(t,e,t.hasVisual);},remove:function(){var t=this,e=t.getContainer();t.removed=1;t.hide();t.execCallback('remove_instance_callback',t);t.onRemove.dispatch(t);t.onExecCommand.listeners=[];EditorManager.remove(t);DOM.remove(e);},destroy:function(s){var t=this;if(t.destroyed)return;if(!s){tinymce.removeUnload(t.destroy);tinyMCE.onBeforeUnload.remove(t._beforeUnload);if(t.theme.destroy)t.theme.destroy();t.controlManager.destroy();t.selection.destroy();t.dom.destroy();if(!t.settings.content_editable){Event.clear(t.getWin());Event.clear(t.getDoc());}Event.clear(t.getBody());Event.clear(t.formElement);}if(t.formElement){t.formElement.submit=t.formElement._mceOldSubmit;t.formElement._mceOldSubmit=null;}t.contentAreaContainer=t.formElement=t.container=t.settings.content_element=t.bodyElement=t.contentDocument=t.contentWindow=null;if(t.selection)t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null;t.destroyed=1;},_addEvents:function(){var t=this,i,s=t.settings,lo={mouseup:'onMouseUp',mousedown:'onMouseDown',click:'onClick',keyup:'onKeyUp',keydown:'onKeyDown',keypress:'onKeyPress',submit:'onSubmit',reset:'onReset',contextmenu:'onContextMenu',dblclick:'onDblClick',paste:'onPaste'};function eventHandler(e,o){var ty=e.type;if(t.removed)return;if(t.onEvent.dispatch(t,e,o)!==false){t[lo[e.fakeType||e.type]].dispatch(t,e,o);}};each(lo,function(v,k){switch(k){case'contextmenu':if(tinymce.isOpera){Event.add(t.getDoc(),'mousedown',function(e){if(e.ctrlKey){e.fakeType='contextmenu';eventHandler(e);}});}else Event.add(t.getDoc(),k,eventHandler);break;case'paste':Event.add(t.getBody(),k,function(e){var tx,h,el,r;if(e.clipboardData)tx=e.clipboardData.getData('text/plain');else if(tinymce.isIE)tx=t.getWin().clipboardData.getData('Text');eventHandler(e,{text:tx,html:h});});break;case'submit':case'reset':Event.add(t.getElement().form||DOM.getParent(t.id,'form'),k,eventHandler);break;default:Event.add(s.content_editable?t.getBody():t.getDoc(),k,eventHandler);}});Event.add(s.content_editable?t.getBody():(isGecko?t.getDoc():t.getWin()),'focus',function(e){t.focus(true);});if(tinymce.isGecko){Event.add(t.getDoc(),'DOMNodeInserted',function(e){var v;e=e.target;if(e.nodeType===1&&e.nodeName==='IMG'&&(v=e.getAttribute('mce_src')))e.src=t.documentBaseURI.toAbsolute(v);});}if(isGecko){function setOpts(){var t=this,d=t.getDoc(),s=t.settings;if(isGecko){if(t._isHidden()){try{if(!s.content_editable)d.designMode='On';}catch(ex){}}try{d.execCommand("styleWithCSS",0,false);}catch(ex){if(!t._isHidden())d.execCommand("useCSS",0,true);}if(!s.table_inline_editing)try{d.execCommand('enableInlineTableEditing',false,false);}catch(ex){}if(!s.object_resizing)try{d.execCommand('enableObjectResizing',false,false);}catch(ex){}}};t.onBeforeExecCommand.add(setOpts);t.onMouseDown.add(setOpts);}t.onMouseUp.add(t.nodeChanged);t.onClick.add(t.nodeChanged);t.onKeyUp.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45||e.keyCode==46||e.keyCode==8||e.ctrlKey)t.nodeChanged();});t.onReset.add(function(){t.setContent(t.startContent,{format:'raw'});});if(t.getParam('tab_focus')){function tabCancel(ed,e){if(e.keyCode===9)return Event.cancel(e);};function tabHandler(ed,e){var x,i,f,el,v;function find(d){f=DOM.getParent(ed.id,'form');el=f.elements;if(f){each(el,function(e,i){if(e.id==ed.id){x=i;return false;}});if(d>0){for(i=x+1;i=0;i--){if(el[i].type!='hidden')return el[i];}}}return null;};if(e.keyCode===9){v=explode(ed.getParam('tab_focus'));if(v.length==1){v[1]=v[0];v[0]=':prev';}if(e.shiftKey){if(v[0]==':prev')el=find(-1);else el=DOM.get(v[0]);}else{if(v[1]==':next')el=find(1);else el=DOM.get(v[1]);}if(el){if(ed=EditorManager.get(el.id||el.name))ed.focus();else window.setTimeout(function(){window.focus();el.focus();},10);return Event.cancel(e);}}};t.onKeyUp.add(tabCancel);if(isGecko){t.onKeyPress.add(tabHandler);t.onKeyDown.add(tabCancel);}else t.onKeyDown.add(tabHandler);}if(s.custom_shortcuts){if(s.custom_undo_redo_keyboard_shortcuts){t.addShortcut('ctrl+z',t.getLang('undo_desc'),'Undo');t.addShortcut('ctrl+y',t.getLang('redo_desc'),'Redo');}if(isGecko){t.addShortcut('ctrl+b',t.getLang('bold_desc'),'Bold');t.addShortcut('ctrl+i',t.getLang('italic_desc'),'Italic');t.addShortcut('ctrl+u',t.getLang('underline_desc'),'Underline');}for(i=1;i<=6;i++)t.addShortcut('ctrl+'+i,'',['FormatBlock',false,'']);t.addShortcut('ctrl+7','',['FormatBlock',false,'

    ']);t.addShortcut('ctrl+8','',['FormatBlock',false,'

    ']);t.addShortcut('ctrl+9','',['FormatBlock',false,'
    ']);function find(e){var v=null;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return v;each(t.shortcuts,function(o){if(o.ctrl!=e.ctrlKey&&(!tinymce.isMac||o.ctrl==e.metaKey))return;if(o.alt!=e.altKey)return;if(o.shift!=e.shiftKey)return;if(e.keyCode==o.keyCode||(e.charCode&&e.charCode==o.charCode)){v=o;return false;}});return v;};t.onKeyUp.add(function(ed,e){var o=find(e);if(o)return Event.cancel(e);});t.onKeyPress.add(function(ed,e){var o=find(e);if(o)return Event.cancel(e);});t.onKeyDown.add(function(ed,e){var o=find(e);if(o){o.func.call(o.scope);return Event.cancel(e);}});}if(tinymce.isIE){Event.add(t.getDoc(),'controlselect',function(e){var re=t.resizeInfo,cb;e=e.target;if(e.nodeName!=='IMG')return;if(re)Event.remove(re.node,re.ev,re.cb);if(!t.dom.hasClass(e,'mceItemNoResize')){ev='resizeend';cb=Event.add(e,ev,function(e){var v;e=e.target;if(v=t.dom.getStyle(e,'width')){t.dom.setAttrib(e,'width',v.replace(/[^0-9%]+/g,''));t.dom.setStyle(e,'width','');}if(v=t.dom.getStyle(e,'height')){t.dom.setAttrib(e,'height',v.replace(/[^0-9%]+/g,''));t.dom.setStyle(e,'height','');}});}else{ev='resizestart';cb=Event.add(e,'resizestart',Event.cancel,Event);}re=t.resizeInfo={node:e,ev:ev,cb:cb};});t.onKeyDown.add(function(ed,e){switch(e.keyCode){case 8:if(t.selection.getRng().item){t.selection.getRng().item(0).removeNode();return Event.cancel(e);}}});}if(tinymce.isOpera){t.onClick.add(function(ed,e){Event.prevent(e);});}if(s.custom_undo_redo){function addUndo(){t.undoManager.typing=0;t.undoManager.add();};if(tinymce.isIE){Event.add(t.getWin(),'blur',function(e){var n;if(t.selection){n=t.selection.getNode();if(!t.removed&&n.ownerDocument&&n.ownerDocument!=t.getDoc())addUndo();}});}else{Event.add(t.getDoc(),'blur',function(){if(t.selection&&!t.removed)addUndo();});}t.onMouseDown.add(addUndo);t.onKeyUp.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45||e.ctrlKey){t.undoManager.typing=0;t.undoManager.add();}});t.onKeyDown.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45){if(t.undoManager.typing){t.undoManager.add();t.undoManager.typing=0;}return;}if(!t.undoManager.typing){t.undoManager.add();t.undoManager.typing=1;}});}},_convertInlineElements:function(){var t=this,s=t.settings,dom=t.dom,v,e,na,st,sp;function convert(ed,o){if(!s.inline_styles)return;if(o.get){each(t.dom.select('table,u,strike',o.node),function(n){switch(n.nodeName){case'TABLE':if(v=dom.getAttrib(n,'height')){dom.setStyle(n,'height',v);dom.setAttrib(n,'height','');}break;case'U':case'STRIKE':n.style.textDecoration=n.nodeName=='U'?'underline':'line-through';dom.setAttrib(n,'mce_style','');dom.setAttrib(n,'mce_name','span');break;}});}else if(o.set){each(t.dom.select('table,span',o.node).reverse(),function(n){if(n.nodeName=='TABLE'){if(v=dom.getStyle(n,'height'))dom.setAttrib(n,'height',v.replace(/[^0-9%]+/g,''));}else{if(n.style.textDecoration=='underline')na='u';else if(n.style.textDecoration=='line-through')na='strike';else na='';if(na){n.style.textDecoration='';dom.setAttrib(n,'mce_style','');e=dom.create(na,{style:dom.getAttrib(n,'style')});dom.replace(e,n,1);}}});}};t.onPreProcess.add(convert);if(!s.cleanup_on_startup){t.onSetContent.add(function(ed,o){if(o.initial)convert(t,{node:t.getBody(),set:1});});}},_convertFonts:function(){var t=this,s=t.settings,dom=t.dom,fz,fzn,sl,cl;if(!s.inline_styles)return;fz=[8,10,12,14,18,24,36];fzn=['xx-small','x-small','small','medium','large','x-large','xx-large'];if(sl=s.font_size_style_values)sl=explode(sl);if(cl=s.font_size_classes)cl=explode(cl);function convertToFonts(no){var n,f,nl,x,i,v,st;if(tinymce.isWebKit||!s.inline_styles)return;nl=t.dom.select('span',no);for(x=nl.length-1;x>=0;x--){n=nl[x];f=dom.create('font',{color:dom.toHex(dom.getStyle(n,'color')),face:dom.getStyle(n,'fontFamily'),style:dom.getAttrib(n,'style'),'class':dom.getAttrib(n,'class')});st=f.style;if(st.color||st.fontFamily){st.color=st.fontFamily='';dom.setAttrib(f,'mce_style','');}if(sl){i=inArray(sl,dom.getStyle(n,'fontSize'));if(i!=-1){dom.setAttrib(f,'size',''+(i+1||1));f.style.fontSize='';}}else if(cl){i=inArray(cl,dom.getAttrib(n,'class'));v=dom.getStyle(n,'fontSize');if(i==-1&&v.indexOf('pt')>0)i=inArray(fz,parseInt(v));if(i==-1)i=inArray(fzn,v);if(i!=-1){dom.setAttrib(f,'size',''+(i+1||1));f.style.fontSize='';}}if(f.color||f.face||f.size){f.style.fontFamily='';dom.setAttrib(f,'mce_style','');dom.replace(f,n,1);}f=n=null;}};t.onSetContent.add(function(ed,o){convertToFonts(ed.getBody());});t.onPreProcess.add(function(ed,o){var n,sp,nl,x;if(!s.inline_styles)return;if(o.get){nl=t.dom.select('font',o.node);for(x=nl.length-1;x>=0;x--){n=nl[x];sp=dom.create('span',{style:dom.getAttrib(n,'style'),'class':dom.getAttrib(n,'class')});dom.setStyles(sp,{fontFamily:dom.getAttrib(n,'face'),color:dom.getAttrib(n,'color'),backgroundColor:n.style.backgroundColor});if(n.size){if(sl)dom.setStyle(sp,'fontSize',sl[parseInt(n.size)-1]);else dom.setAttrib(sp,'class',cl[parseInt(n.size)-1]);}dom.setAttrib(sp,'mce_style','');dom.replace(sp,n,1);}}});},_isHidden:function(){var s;if(!isGecko)return 0;s=this.selection.getSel();return(!s||!s.rangeCount||s.rangeCount==0);},_fixNesting:function(s){var d=[],i;s=s.replace(/<(\/)?([^\s>]+)[^>]*?>/g,function(a,b,c){var e;if(b==='/'){if(!d.length)return'';if(c!==d[d.length-1].tag){for(i=d.length-1;i>=0;i--){if(d[i].tag===c){d[i].close=1;break;}}return'';}else{d.pop();if(d.length&&d[d.length-1].close){a=a+'';d.pop();}}}else{if(/^(br|hr|input|meta|img|link|param)$/i.test(c))return a;if(/\/>$/.test(a))return a;d.push({tag:c});}return a;});for(i=d.length-1;i>=0;i--)s+='';return s;}});})();(function(){var each=tinymce.each,isIE=tinymce.isIE,isGecko=tinymce.isGecko,isOpera=tinymce.isOpera,isWebKit=tinymce.isWebKit;tinymce.create('tinymce.EditorCommands',{EditorCommands:function(ed){this.editor=ed;},execCommand:function(cmd,ui,val){var t=this,ed=t.editor,f;switch(cmd){case'Cut':case'Copy':case'Paste':try{ed.getDoc().execCommand(cmd,ui,val);}catch(ex){if(isGecko){ed.windowManager.confirm(ed.getLang('clipboard_msg'),function(s){if(s)window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html','mceExternal');});}else ed.windowManager.alert(ed.getLang('clipboard_no_support'));}return true;case'mceResetDesignMode':case'mceBeginUndoLevel':return true;case'unlink':t.UnLink();return true;case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':t.mceJustify(cmd,cmd.substring(7).toLowerCase());return true;case'mceEndUndoLevel':case'mceAddUndoLevel':ed.undoManager.add();return true;default:f=this[cmd];if(f){f.call(this,ui,val);return true;}}return false;},Indent:function(){var ed=this.editor,d=ed.dom,s=ed.selection,e,iv,iu;iv=ed.settings.indentation;iu=/[a-z%]+$/i.exec(iv);iv=parseInt(iv);if(ed.settings.inline_styles&&(!this.queryStateInsertUnorderedList()&&!this.queryStateInsertOrderedList())){each(this._getSelectedBlocks(),function(e){d.setStyle(e,'paddingLeft',(parseInt(e.style.paddingLeft||0)+iv)+iu);});return;}ed.getDoc().execCommand('Indent',false,null);if(isIE){d.getParent(s.getNode(),function(n){if(n.nodeName=='BLOCKQUOTE'){n.dir=n.style.cssText='';}});}},Outdent:function(){var ed=this.editor,d=ed.dom,s=ed.selection,e,v,iv,iu;iv=ed.settings.indentation;iu=/[a-z%]+$/i.exec(iv);iv=parseInt(iv);if(ed.settings.inline_styles&&(!this.queryStateInsertUnorderedList()&&!this.queryStateInsertOrderedList())){each(this._getSelectedBlocks(),function(e){v=Math.max(0,parseInt(e.style.paddingLeft||0)-iv);d.setStyle(e,'paddingLeft',v?v+iu:'');});return;}ed.getDoc().execCommand('Outdent',false,null);},mceSetAttribute:function(u,v){var ed=this.editor,d=ed.dom,e;if(e=d.getParent(ed.selection.getNode(),d.isBlock))d.setAttrib(e,v.name,v.value);},mceSetContent:function(u,v){this.editor.setContent(v);},mceToggleVisualAid:function(){var ed=this.editor;ed.hasVisual=!ed.hasVisual;ed.addVisual();},mceReplaceContent:function(u,v){var s=this.editor.selection;s.setContent(v.replace(/\{\$selection\}/g,s.getContent({format:'text'})));},mceInsertLink:function(u,v){var ed=this.editor,s=ed.selection,e=ed.dom.getParent(s.getNode(),'A');if(tinymce.is(v,'string'))v={href:v};function set(e){each(v,function(v,k){ed.dom.setAttrib(e,k,v);});};if(!e){ed.execCommand('CreateLink',false,'javascript:mctmp(0);');each(ed.dom.select('a'),function(e){if(e.href=='javascript:mctmp(0);')set(e);});}else{if(v.href)set(e);else ed.dom.remove(e,1);}},UnLink:function(){var ed=this.editor,s=ed.selection;if(s.isCollapsed())s.select(s.getNode());ed.getDoc().execCommand('unlink',false,null);s.collapse(0);},FontName:function(u,v){var t=this,ed=t.editor,s=ed.selection,e;if(!v){if(s.isCollapsed())s.select(s.getNode());t.RemoveFormat();}else ed.getDoc().execCommand('FontName',false,v);},queryCommandValue:function(c){var f=this['queryValue'+c];if(f)return f.call(this,c);return false;},queryCommandState:function(cmd){var f;switch(cmd){case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':return this.queryStateJustify(cmd,cmd.substring(7).toLowerCase());default:if(f=this['queryState'+cmd])return f.call(this,cmd);}return-1;},_queryState:function(c){try{return this.editor.getDoc().queryCommandState(c);}catch(ex){}},_queryVal:function(c){try{return this.editor.getDoc().queryCommandValue(c);}catch(ex){}},queryValueFontSize:function(){var ed=this.editor,v=0,p;if(isOpera||isWebKit){if(p=ed.dom.getParent(ed.selection.getNode(),'FONT'))v=p.size;return v;}return this._queryVal('FontSize');},queryValueFontName:function(){var ed=this.editor,v=0,p;if(p=ed.dom.getParent(ed.selection.getNode(),'FONT'))v=p.face;if(!v)v=this._queryVal('FontName');return v;},mceJustify:function(c,v){var ed=this.editor,se=ed.selection,n=se.getNode(),nn=n.nodeName,bl,nb,dom=ed.dom,rm;if(ed.settings.inline_styles&&this.queryStateJustify(c,v))rm=1;bl=dom.getParent(n,ed.dom.isBlock);if(nn=='IMG'){if(v=='full')return;if(rm){if(v=='center')dom.setStyle(n.parentNode,'textAlign','');dom.setStyle(n,'float','');this.mceRepaint();return;}if(v=='center'){if(/^(TD|TH)$/.test(bl.nodeName))bl=0;if(!bl||bl.childNodes.length>1){nb=dom.create('p');nb.appendChild(n.cloneNode(false));if(bl)dom.insertAfter(nb,bl);else dom.insertAfter(nb,n);dom.remove(n);n=nb.firstChild;bl=nb;}dom.setStyle(bl,'textAlign',v);dom.setStyle(n,'float','');}else{dom.setStyle(n,'float',v);dom.setStyle(n.parentNode,'textAlign','');}this.mceRepaint();return;}if(ed.settings.inline_styles&&ed.settings.forced_root_block){if(rm)v='';each(this._getSelectedBlocks(dom.getParent(se.getStart(),dom.isBlock),dom.getParent(se.getEnd(),dom.isBlock)),function(e){dom.setAttrib(e,'align','');dom.setStyle(e,'textAlign',v=='full'?'justify':v);});return;}else if(!rm)ed.getDoc().execCommand(c,false,null);if(ed.settings.inline_styles){if(rm){dom.getParent(ed.selection.getNode(),function(n){if(n.style&&n.style.textAlign)dom.setStyle(n,'textAlign','');});return;}each(dom.select('*'),function(n){var v=n.align;if(v){if(v=='full')v='justify';dom.setStyle(n,'textAlign',v);dom.setAttrib(n,'align','');}});}},mceSetCSSClass:function(u,v){this.mceSetStyleInfo(0,{command:'setattrib',name:'class',value:v});},getSelectedElement:function(){var t=this,ed=t.editor,dom=ed.dom,se=ed.selection,r=se.getRng(),r1,r2,sc,ec,so,eo,e,sp,ep,re;if(se.isCollapsed()||r.item)return se.getNode();re=ed.settings.merge_styles_invalid_parents;if(tinymce.is(re,'string'))re=new RegExp(re,'i');if(isIE){r1=r.duplicate();r1.collapse(true);sc=r1.parentElement();r2=r.duplicate();r2.collapse(false);ec=r2.parentElement();if(sc!=ec){r1.move('character',1);sc=r1.parentElement();}if(sc==ec){r1=r.duplicate();r1.moveToElementText(sc);if(r1.compareEndPoints('StartToStart',r)==0&&r1.compareEndPoints('EndToEnd',r)==0)return re&&re.test(sc.nodeName)?null:sc;}}else{function getParent(n){return dom.getParent(n,function(n){return n.nodeType==1;});};sc=r.startContainer;ec=r.endContainer;so=r.startOffset;eo=r.endOffset;if(!r.collapsed){if(sc==ec){if(so-eo<2){if(sc.hasChildNodes()){sp=sc.childNodes[so];return re&&re.test(sp.nodeName)?null:sp;}}}}if(sc.nodeType!=3||ec.nodeType!=3)return null;if(so==0){sp=getParent(sc);if(sp&&sp.firstChild!=sc)sp=null;}if(so==sc.nodeValue.length){e=sc.nextSibling;if(e&&e.nodeType==1)sp=sc.nextSibling;}if(eo==0){e=ec.previousSibling;if(e&&e.nodeType==1)ep=e;}if(eo==ec.nodeValue.length){ep=getParent(ec);if(ep&&ep.lastChild!=ec)ep=null;}if(sp==ep)return re&&sp&&re.test(sp.nodeName)?null:sp;}return null;},InsertHorizontalRule:function(){if(isGecko||isIE)this.editor.selection.setContent('
    ');else this.editor.getDoc().execCommand('InsertHorizontalRule',false,'');},RemoveFormat:function(){var t=this,ed=t.editor,s=ed.selection,b;if(isWebKit)s.setContent(s.getContent({format:'raw'}).replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g,''),{format:'raw'});else ed.getDoc().execCommand('RemoveFormat',false,null);t.mceSetStyleInfo(0,{command:'removeformat'});ed.addVisual();},mceSetStyleInfo:function(u,v){var t=this,ed=t.editor,d=ed.getDoc(),dom=ed.dom,e,b,s=ed.selection,nn=v.wrapper||'span',b=s.getBookmark(),re;function set(n,e){if(n.nodeType==1){switch(v.command){case'setattrib':return dom.setAttrib(n,v.name,v.value);case'setstyle':return dom.setStyle(n,v.name,v.value);case'removeformat':return dom.setAttrib(n,'class','');}}};re=ed.settings.merge_styles_invalid_parents;if(tinymce.is(re,'string'))re=new RegExp(re,'i');if(e=t.getSelectedElement())set(e,1);else{d.execCommand('FontName',false,'__');each(isWebKit?dom.select('span'):dom.select('font'),function(n){var sp,e;if(dom.getAttrib(n,'face')=='__'||n.style.fontFamily==='__'){sp=dom.create(nn,{mce_new:'1'});set(sp);each(n.childNodes,function(n){sp.appendChild(n.cloneNode(true));});dom.replace(sp,n);}});}each(dom.select(nn).reverse(),function(n){var p=n.parentNode;if(!dom.getAttrib(n,'mce_new')){p=dom.getParent(n,function(n){return n.nodeType==1&&dom.getAttrib(n,'mce_new');});if(p)dom.remove(n,1);}});each(dom.select(nn).reverse(),function(n){var p=n.parentNode;if(!p||!dom.getAttrib(n,'mce_new'))return;if(p.nodeName==nn.toUpperCase()&&p.childNodes.length==1)return dom.remove(p,1);if(n.nodeType==1&&(!re||!re.test(p.nodeName))&&p.childNodes.length==1){set(p);dom.setAttrib(n,'class','');}});each(dom.select(nn).reverse(),function(n){if(dom.getAttrib(n,'mce_new')||(dom.getAttribs(n).length<=1&&n.className==='')){if(!dom.getAttrib(n,'class')&&!dom.getAttrib(n,'style'))return dom.remove(n,1);dom.setAttrib(n,'mce_new','');}});s.moveToBookmark(b);},queryStateJustify:function(c,v){var ed=this.editor,n=ed.selection.getNode(),dom=ed.dom;if(n&&n.nodeName=='IMG'){if(dom.getStyle(n,'float')==v)return 1;return n.parentNode.style.textAlign==v;}n=dom.getParent(ed.selection.getStart(),function(n){return n.nodeType==1&&n.style.textAlign;});if(v=='full')v='justify';if(ed.settings.inline_styles)return(n&&n.style.textAlign==v);return this._queryState(c);},HiliteColor:function(ui,val){var t=this,ed=t.editor,d=ed.getDoc();function set(s){if(!isGecko)return;try{d.execCommand("styleWithCSS",0,s);}catch(ex){d.execCommand("useCSS",0,!s);}};if(isGecko||isOpera){set(true);d.execCommand('hilitecolor',false,val);set(false);}else d.execCommand('BackColor',false,val);},Undo:function(){var ed=this.editor;if(ed.settings.custom_undo_redo){ed.undoManager.undo();ed.nodeChanged();}else ed.getDoc().execCommand('Undo',false,null);},Redo:function(){var ed=this.editor;if(ed.settings.custom_undo_redo){ed.undoManager.redo();ed.nodeChanged();}else ed.getDoc().execCommand('Redo',false,null);},FormatBlock:function(ui,val){var t=this,ed=t.editor;val=ed.settings.forced_root_block?(val||'

    '):val;if(/^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(ed.selection.getNode().nodeName))t.mceRemoveNode();if(val.indexOf('<')==-1)val='<'+val+'>';if(tinymce.isGecko)val=val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi,'$1');ed.getDoc().execCommand('FormatBlock',false,val);},mceCleanup:function(){var ed=this.editor,s=ed.selection,b=s.getBookmark();ed.setContent(ed.getContent());s.moveToBookmark(b);},mceRemoveNode:function(ui,val){var ed=this.editor,s=ed.selection,b,n=val||s.getNode();if(n==ed.getBody())return;b=s.getBookmark();ed.dom.remove(n,1);s.moveToBookmark(b);ed.nodeChanged();},mceSelectNodeDepth:function(ui,val){var ed=this.editor,s=ed.selection,c=0;ed.dom.getParent(s.getNode(),function(n){if(n.nodeType==1&&c++==val){s.select(n);ed.nodeChanged();return false;}},ed.getBody());},mceSelectNode:function(u,v){this.editor.selection.select(v);},mceInsertContent:function(ui,val){this.editor.selection.setContent(val);},mceInsertRawHTML:function(ui,val){var ed=this.editor;ed.selection.setContent('tiny_mce_marker');ed.setContent(ed.getContent().replace(/tiny_mce_marker/g,val));},mceRepaint:function(){var s,b,e=this.editor;if(tinymce.isGecko){try{s=e.selection;b=s.getBookmark(true);if(s.getSel())s.getSel().selectAllChildren(e.getBody());s.collapse(true);s.moveToBookmark(b);}catch(ex){}}},queryStateUnderline:function(){var ed=this.editor,n=ed.selection.getNode();if(n&&n.nodeName=='A')return false;return this._queryState('Underline');},queryStateOutdent:function(){var ed=this.editor,n;if(ed.settings.inline_styles){if((n=ed.dom.getParent(ed.selection.getStart(),ed.dom.isBlock))&&parseInt(n.style.paddingLeft)>0)return true;if((n=ed.dom.getParent(ed.selection.getEnd(),ed.dom.isBlock))&&parseInt(n.style.paddingLeft)>0)return true;}else return!!ed.dom.getParent(ed.selection.getNode(),'BLOCKQUOTE');return this.queryStateInsertUnorderedList()||this.queryStateInsertOrderedList();},queryStateInsertUnorderedList:function(){return this.editor.dom.getParent(this.editor.selection.getNode(),'UL');},queryStateInsertOrderedList:function(){return this.editor.dom.getParent(this.editor.selection.getNode(),'OL');},queryStatemceBlockQuote:function(){return!!this.editor.dom.getParent(this.editor.selection.getStart(),function(n){return n.nodeName==='BLOCKQUOTE';});},mceBlockQuote:function(){var t=this,ed=t.editor,s=ed.selection,dom=ed.dom,sb,eb,n,bm,bq,r,bq2,i,nl;function getBQ(e){return dom.getParent(e,function(n){return n.nodeName==='BLOCKQUOTE';});};sb=dom.getParent(s.getStart(),dom.isBlock);eb=dom.getParent(s.getEnd(),dom.isBlock);if(bq=getBQ(sb)){if(sb!=eb||sb.childNodes.length>1||(sb.childNodes.length==1&&sb.firstChild.nodeName!='BR'))bm=s.getBookmark();if(getBQ(eb)){bq2=bq.cloneNode(false);while(n=eb.nextSibling)bq2.appendChild(n.parentNode.removeChild(n));}if(bq2)dom.insertAfter(bq2,bq);nl=t._getSelectedBlocks(sb,eb);for(i=nl.length-1;i>=0;i--){dom.insertAfter(nl[i],bq);}if(/^\s*$/.test(bq.innerHTML))dom.remove(bq,1);if(bq2&&/^\s*$/.test(bq2.innerHTML))dom.remove(bq2,1);if(!bm){if(!isIE){r=ed.getDoc().createRange();r.setStart(sb,0);r.setEnd(sb,0);s.setRng(r);}else{s.select(sb);s.collapse(0);if(dom.getParent(s.getStart(),dom.isBlock)!=sb){r=s.getRng();r.move('character',-1);r.select();}}}else t.editor.selection.moveToBookmark(bm);return;}if(isIE&&!sb&&!eb){t.editor.getDoc().execCommand('Indent');n=getBQ(s.getNode());n.style.margin=n.dir='';return;}if(!sb||!eb)return;if(sb!=eb||sb.childNodes.length>1||(sb.childNodes.length==1&&sb.firstChild.nodeName!='BR'))bm=s.getBookmark();each(t._getSelectedBlocks(getBQ(s.getStart()),getBQ(s.getEnd())),function(e){if(e.nodeName=='BLOCKQUOTE'&&!bq){bq=e;return;}if(!bq){bq=dom.create('blockquote');e.parentNode.insertBefore(bq,e);}if(e.nodeName=='BLOCKQUOTE'&&bq){n=e.firstChild;while(n){bq.appendChild(n.cloneNode(true));n=n.nextSibling;}dom.remove(e);return;}bq.appendChild(dom.remove(e));});if(!bm){if(!isIE){r=ed.getDoc().createRange();r.setStart(sb,0);r.setEnd(sb,0);s.setRng(r);}else{s.select(sb);s.collapse(1);}}else s.moveToBookmark(bm);},_getSelectedBlocks:function(st,en){var ed=this.editor,dom=ed.dom,s=ed.selection,sb,eb,n,bl=[];sb=dom.getParent(st||s.getStart(),dom.isBlock);eb=dom.getParent(en||s.getEnd(),dom.isBlock);if(sb)bl.push(sb);if(sb&&eb&&sb!=eb){n=sb;while((n=n.nextSibling)&&n!=eb){if(dom.isBlock(n))bl.push(n);}}if(eb&&sb!=eb)bl.push(eb);return bl;}});})();tinymce.create('tinymce.UndoManager',{index:0,data:null,typing:0,UndoManager:function(ed){var t=this,Dispatcher=tinymce.util.Dispatcher;t.editor=ed;t.data=[];t.onAdd=new Dispatcher(this);t.onUndo=new Dispatcher(this);t.onRedo=new Dispatcher(this);},add:function(l){var t=this,i,ed=t.editor,b,s=ed.settings,la;l=l||{};l.content=l.content||ed.getContent({format:'raw',no_events:1});l.content=l.content.replace(/^\s*|\s*$/g,'');la=t.data[t.index>0?t.index-1:0];if(!l.initial&&la&&l.content==la.content)return null;if(s.custom_undo_redo_levels){if(t.data.length>s.custom_undo_redo_levels){for(i=0;i0){if(t.index==t.data.length&&t.index>1){i=t.index;t.typing=0;if(!t.add())t.index=i;--t.index;}l=t.data[--t.index];ed.setContent(l.content,{format:'raw'});ed.selection.moveToBookmark(l.bookmark);t.onUndo.dispatch(t,l);}return l;},redo:function(){var t=this,ed=t.editor,l=null;if(t.index','gi');t.rePadd=new RegExp(']+)><\\\/p>|]+)\\\/>|]+)>\\s+<\\\/p>|

    <\\\/p>||

    \\s+<\\\/p>'.replace(/p/g,elm),'gi');t.reNbsp2BR1=new RegExp(']+)>[\\s\\u00a0]+<\\\/p>|

    [\\s\\u00a0]+<\\\/p>'.replace(/p/g,elm),'gi');t.reNbsp2BR2=new RegExp(']+)>( | )<\\\/p>|

    ( | )<\\\/p>'.replace(/p/g,elm),'gi');t.reBR2Nbsp=new RegExp(']+)>\\s*
    \\s*<\\\/p>|

    \\s*
    \\s*<\\\/p>'.replace(/p/g,elm),'gi');t.reTrailBr=new RegExp('\\s*
    \\s*<\\\/p>'.replace(/p/g,elm),'gi');function padd(ed,o){if(isOpera)o.content=o.content.replace(t.reOpera,'');o.content=o.content.replace(t.rePadd,'<'+elm+'$1$2$3$4$5$6>\u00a0');if(!isIE&&!isOpera&&o.set){o.content=o.content.replace(t.reNbsp2BR1,'<'+elm+'$1$2>
    ');o.content=o.content.replace(t.reNbsp2BR2,'<'+elm+'$1$2>
    ');}else{o.content=o.content.replace(t.reBR2Nbsp,'<'+elm+'$1$2>\u00a0');o.content=o.content.replace(t.reTrailBr,'');}};ed.onBeforeSetContent.add(padd);ed.onPostProcess.add(padd);if(s.forced_root_block){ed.onInit.add(t.forceRoots,t);ed.onSetContent.add(t.forceRoots,t);ed.onBeforeGetContent.add(t.forceRoots,t);}},setup:function(){var t=this,ed=t.editor,s=ed.settings;if(s.forced_root_block){ed.onKeyUp.add(t.forceRoots,t);ed.onPreProcess.add(t.forceRoots,t);}if(s.force_br_newlines){if(isIE){ed.onKeyPress.add(function(ed,e){var n,s=ed.selection;if(e.keyCode==13&&s.getNode().nodeName!='LI'){s.setContent('
    ',{format:'raw'});n=ed.dom.get('__');n.removeAttribute('id');s.select(n);s.collapse();return Event.cancel(e);}});}return;}if(!isIE&&s.force_p_newlines){ed.onKeyPress.add(function(ed,e){if(e.keyCode==13&&!e.shiftKey){if(!t.insertPara(e))Event.cancel(e);}});if(isGecko){ed.onKeyDown.add(function(ed,e){if((e.keyCode==8||e.keyCode==46)&&!e.shiftKey)t.backspaceDelete(e,e.keyCode==8);});}}function ren(rn,na){var ne=ed.dom.create(na);each(rn.attributes,function(a){if(a.specified&&a.nodeValue)ne.setAttribute(a.nodeName.toLowerCase(),a.nodeValue);});each(rn.childNodes,function(n){ne.appendChild(n.cloneNode(true));});rn.parentNode.replaceChild(ne,rn);return ne;};if(isIE&&s.element!='P'){ed.onKeyPress.add(function(ed,e){t.lastElm=ed.selection.getNode().nodeName;});ed.onKeyUp.add(function(ed,e){var bl,sel=ed.selection,n=sel.getNode(),b=ed.getBody();if(b.childNodes.length===1&&n.nodeName=='P'){n=ren(n,s.element);sel.select(n);sel.collapse();ed.nodeChanged();}else if(e.keyCode==13&&!e.shiftKey&&t.lastElm!='P'){bl=ed.dom.getParent(n,'P');if(bl){ren(bl,s.element);ed.nodeChanged();}}});}},find:function(n,t,s){var ed=this.editor,w=ed.getDoc().createTreeWalker(n,4,null,false),c=-1;while(n=w.nextNode()){c++;if(t==0&&n==s)return c;if(t==1&&c==s)return n;}return-1;},forceRoots:function(ed,e){var t=this,ed=t.editor,b=ed.getBody(),d=ed.getDoc(),se=ed.selection,s=se.getSel(),r=se.getRng(),si=-2,ei,so,eo,tr,c=-0xFFFFFF;var nx,bl,bp,sp,le,nl=b.childNodes,i;if(e&&e.keyCode==13)return true;for(i=nl.length-1;i>=0;i--){nx=nl[i];if(nx.nodeType==3||(!t.dom.isBlock(nx)&&nx.nodeType!=8)){if(!bl){if(nx.nodeType!=3||/[^\s]/g.test(nx.nodeValue)){if(si==-2&&r){if(!isIE){so=r.startOffset;eo=r.endOffset;si=t.find(b,0,r.startContainer);ei=t.find(b,0,r.endContainer);}else{tr=d.body.createTextRange();tr.moveToElementText(b);tr.collapse(1);bp=tr.move('character',c)*-1;tr=r.duplicate();tr.collapse(1);sp=tr.move('character',c)*-1;tr=r.duplicate();tr.collapse(0);le=(tr.move('character',c)*-1)-sp;si=sp-bp;ei=le;}}bl=ed.dom.create(ed.settings.forced_root_block);bl.appendChild(nx.cloneNode(1));nx.parentNode.replaceChild(bl,nx);}}else{if(bl.hasChildNodes())bl.insertBefore(nx,bl.firstChild);else bl.appendChild(nx);}}else bl=null;}if(si!=-2){if(!isIE){bl=d.getElementsByTagName(ed.settings.element)[0];r=d.createRange();if(si!=-1)r.setStart(t.find(b,1,si),so);else r.setStart(bl,0);if(ei!=-1)r.setEnd(t.find(b,1,ei),eo);else r.setEnd(bl,0);if(s){s.removeAllRanges();s.addRange(r);}}else{try{r=s.createRange();r.moveToElementText(b);r.collapse(1);r.moveStart('character',si);r.moveEnd('character',ei);r.select();}catch(ex){}}}},getParentBlock:function(n){var d=this.dom;return d.getParent(n,d.isBlock);},insertPara:function(e){var t=this,ed=t.editor,dom=ed.dom,d=ed.getDoc(),se=ed.settings,s=ed.selection.getSel(),r=s.getRangeAt(0),b=d.body;var rb,ra,dir,sn,so,en,eo,sb,eb,bn,bef,aft,sc,ec,n,vp=dom.getViewPort(ed.getWin()),y,ch;function isEmpty(n){n=n.innerHTML;n=n.replace(/<(img|hr|table)/gi,'-');n=n.replace(/<[^>]+>/g,'');return n.replace(/[ \t\r\n]+/g,'')=='';};rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(true);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(true);dir=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;sn=dir?s.anchorNode:s.focusNode;so=dir?s.anchorOffset:s.focusOffset;en=dir?s.focusNode:s.anchorNode;eo=dir?s.focusOffset:s.anchorOffset;if(sn===en&&/^(TD|TH)$/.test(sn.nodeName)){dom.remove(sn.firstChild);ed.dom.add(sn,se.element,null,'
    ');aft=ed.dom.add(sn,se.element,null,'
    ');r=d.createRange();r.selectNodeContents(aft);r.collapse(1);ed.selection.setRng(r);return false;}if(sn==b&&en==b&&b.firstChild&&ed.dom.isBlock(b.firstChild)){sn=en=sn.firstChild;so=eo=0;rb=d.createRange();rb.setStart(sn,0);ra=d.createRange();ra.setStart(en,0);}sn=sn.nodeName=="HTML"?d.body:sn;sn=sn.nodeName=="BODY"?sn.firstChild:sn;en=en.nodeName=="HTML"?d.body:en;en=en.nodeName=="BODY"?en.firstChild:en;sb=t.getParentBlock(sn);eb=t.getParentBlock(en);bn=sb?sb.nodeName:se.element;if(t.dom.getParent(sb,function(n){return/OL|UL|PRE/.test(n.nodeName);}))return true;if(sb&&(sb.nodeName=='CAPTION'||/absolute|relative|static/gi.test(sb.style.position))){bn=se.element;sb=null;}if(eb&&(eb.nodeName=='CAPTION'||/absolute|relative|static/gi.test(eb.style.position))){bn=se.element;eb=null;}if(/(TD|TABLE|TH|CAPTION)/.test(bn)||(sb&&bn=="DIV"&&/left|right/gi.test(sb.style.cssFloat))){bn=se.element;sb=eb=null;}bef=(sb&&sb.nodeName==bn)?sb.cloneNode(0):ed.dom.create(bn);aft=(eb&&eb.nodeName==bn)?eb.cloneNode(0):ed.dom.create(bn);aft.removeAttribute('id');if(/^(H[1-6])$/.test(bn)&&sn.nodeValue&&so==sn.nodeValue.length)aft=ed.dom.create(se.element);n=sc=sn;do{if(n==b||n.nodeType==9||t.dom.isBlock(n)||/(TD|TABLE|TH|CAPTION)/.test(n.nodeName))break;sc=n;}while((n=n.previousSibling?n.previousSibling:n.parentNode));n=ec=en;do{if(n==b||n.nodeType==9||t.dom.isBlock(n)||/(TD|TABLE|TH|CAPTION)/.test(n.nodeName))break;ec=n;}while((n=n.nextSibling?n.nextSibling:n.parentNode));if(sc.nodeName==bn)rb.setStart(sc,0);else rb.setStartBefore(sc);rb.setEnd(sn,so);bef.appendChild(rb.cloneContents()||d.createTextNode(''));try{ra.setEndAfter(ec);}catch(ex){}ra.setStart(en,eo);aft.appendChild(ra.cloneContents()||d.createTextNode(''));r=d.createRange();if(!sc.previousSibling&&sc.parentNode.nodeName==bn){r.setStartBefore(sc.parentNode);}else{if(rb.startContainer.nodeName==bn&&rb.startOffset==0)r.setStartBefore(rb.startContainer);else r.setStart(rb.startContainer,rb.startOffset);}if(!ec.nextSibling&&ec.parentNode.nodeName==bn)r.setEndAfter(ec.parentNode);else r.setEnd(ra.endContainer,ra.endOffset);r.deleteContents();if(isOpera)ed.getWin().scrollTo(0,vp.y);if(bef.firstChild&&bef.firstChild.nodeName==bn)bef.innerHTML=bef.firstChild.innerHTML;if(aft.firstChild&&aft.firstChild.nodeName==bn)aft.innerHTML=aft.firstChild.innerHTML;if(isEmpty(bef))bef.innerHTML='
    ';if(isEmpty(aft))aft.innerHTML=isOpera?' ':'
    ';if(isOpera){r.insertNode(bef);r.insertNode(aft);}else{r.insertNode(aft);r.insertNode(bef);}aft.normalize();bef.normalize();r=d.createRange();r.selectNodeContents(aft);r.collapse(1);s.removeAllRanges();s.addRange(r);y=ed.dom.getPos(aft).y;ch=aft.clientHeight;if(yvp.y+vp.h){ed.getWin().scrollTo(0,y 'url'. +It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin. +The url should be absolute and should include the js file name to be loaded. Example: +array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' ) +If the plugin uses a button, it should be added with one of the "$mce_buttons" filters. +*/ +$mce_external_plugins = apply_filters('mce_external_plugins', array()); + +$ext_plugins = "\n"; +if ( ! empty($mce_external_plugins) ) { + + /* + The following filter loads external language files for TinyMCE plugins. + It takes an associative array 'plugin_name' => 'path', where path is the + include path to the file. The language file should follow the same format as + /tinymce/langs/wp-langs.php and should define a variable $strings that + holds all translated strings. Example: + $strings = 'tinyMCE.addI18n("' . $mce_locale . '.mypluginname_dlg",{tab_general:"General", ... })'; + */ + $mce_external_languages = apply_filters('mce_external_languages', array()); + + $loaded_langs = array(); + $strings = ''; + + if ( ! empty($mce_external_languages) ) { + foreach ( $mce_external_languages as $name => $path ) { + if ( is_file($path) && is_readable($path) ) { + include_once($path); + $ext_plugins .= $strings; + $loaded_langs[] = $name; + } } } - // Set up init variables - $valid_elements = 'p/-div[*],-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]'; - $valid_elements = apply_filters('mce_valid_elements', $valid_elements); + foreach ( $mce_external_plugins as $name => $url ) { + + if ( $https ) $url = str_replace('http://', 'https://', $url); + + $plugins[] = '-' . $name; - $plugins = array('inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress'); - $plugins = apply_filters('mce_plugins', $plugins); - $plugins = implode($plugins, ','); + if ( in_array($name, $loaded_langs) ) { + $plugurl = dirname($url); + $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; + } + $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n"; + } +} +$plugins = implode($plugins, ','); + +$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'image', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' )); +$mce_buttons = implode($mce_buttons, ','); + +$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' )); +$mce_buttons_2 = implode($mce_buttons_2, ','); + +$mce_buttons_3 = apply_filters('mce_buttons_3', array()); +$mce_buttons_3 = implode($mce_buttons_3, ','); + +$mce_buttons_4 = apply_filters('mce_buttons_4', array()); +$mce_buttons_4 = implode($mce_buttons_4, ','); + +// TinyMCE init settings +$initArray = array ( + 'mode' => 'none', + 'onpageload' => 'wpEditorInit', + 'width' => '100%', + 'theme' => 'advanced', + 'skin' => 'wp_theme', + 'theme_advanced_buttons1' => "$mce_buttons", + 'theme_advanced_buttons2' => "$mce_buttons_2", + 'theme_advanced_buttons3' => "$mce_buttons_3", + 'theme_advanced_buttons4' => "$mce_buttons_4", + 'language' => "$mce_locale", + 'spellchecker_languages' => "$mce_spellchecker_languages", + 'theme_advanced_toolbar_location' => 'top', + 'theme_advanced_toolbar_align' => 'left', + 'theme_advanced_statusbar_location' => 'bottom', + 'theme_advanced_resizing' => true, + 'theme_advanced_resize_horizontal' => false, + 'dialog_type' => 'modal', + 'relative_urls' => false, + 'remove_script_host' => false, + 'convert_urls' => false, + 'apply_source_formatting' => false, + 'remove_linebreaks' => true, + 'paste_convert_middot_lists' => true, + 'paste_remove_spans' => true, + 'paste_remove_styles' => true, + 'gecko_spellcheck' => true, + 'entities' => '38,amp,60,lt,62,gt', + 'accessibility_focus' => false, + 'tab_focus' => ':next', + 'content_css' => "$mce_css", + 'save_callback' => 'switchEditors.saveCallback', + 'plugins' => "$plugins", + // pass-through the settings for compression and caching, so they can be changed with "tiny_mce_before_init" + 'disk_cache' => true, + 'compress' => true, + 'old_cache_max' => '1' // number of cache files to keep +); + +// For people who really REALLY know what they're doing with TinyMCE +// You can modify initArray to add, remove, change elements of the config before tinyMCE.init (changed from action to filter) +$initArray = apply_filters('tiny_mce_before_init', $initArray); - $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'link', 'unlink', 'image', 'wp_more', 'separator', 'spellchecker', 'separator', 'wp_help', 'wp_adv', 'wp_adv_start', 'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo', 'wp_adv_end')); - $mce_buttons = implode($mce_buttons, ','); +// Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init". +// Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0. - $mce_buttons_2 = apply_filters('mce_buttons_2', array()); - $mce_buttons_2 = implode($mce_buttons_2, ','); +// support for deprecated actions +ob_start(); +do_action('mce_options'); +$mce_deprecated = ob_get_contents(); +ob_end_clean(); - $mce_buttons_3 = apply_filters('mce_buttons_3', array()); - $mce_buttons_3 = implode($mce_buttons_3, ','); +$mce_deprecated = (string) $mce_deprecated; +if ( strlen( $mce_deprecated ) < 10 || ! strpos( $mce_deprecated, ':' ) || ! strpos( $mce_deprecated, ',' ) ) + $mce_deprecated = ''; - $mce_browsers = apply_filters('mce_browsers', array('msie', 'gecko', 'opera', 'safari')); - $mce_browsers = implode($mce_browsers, ','); +// Settings for the gzip compression and cache +$disk_cache = ( ! isset($initArray['disk_cache']) || false == $initArray['disk_cache'] ) ? false : true; +$compress = ( ! isset($initArray['compress']) || false == $initArray['compress'] ) ? false : true; +$old_cache_max = ( isset($initArray['old_cache_max']) ) ? (int) $initArray['old_cache_max'] : 0; - $mce_popups_css = get_option('siteurl') . '/wp-includes/js/tinymce/plugins/wordpress/popups.css'; - $mce_css = get_option('siteurl') . '/wp-includes/js/tinymce/plugins/wordpress/wordpress.css'; - $mce_css = apply_filters('mce_css', $mce_css); - if ( $_SERVER['HTTPS'] == 'on' ) { - $mce_css = str_replace('http://', 'https://', $mce_css); - $mce_popups_css = str_replace('http://', 'https://', $mce_popups_css); +$initArray['disk_cache'] = $initArray['compress'] = $initArray['old_cache_max'] = null; +unset( $initArray['disk_cache'], $initArray['compress'], $initArray['old_cache_max'] ); + +// Anybody still using IE5/5.5? It can't handle gzip compressed js well. +if ( $msie = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) { + $ie_ver = (int) substr( $_SERVER['HTTP_USER_AGENT'] , $msie + 5, 3 ); + if ( $ie_ver && $ie_ver < 6 ) $compress = false; +} + +// Cache path, this is where the .gz files will be stored +$cache_path = ABSPATH . 'wp-content/uploads/js_cache'; +if ( $disk_cache && ! is_dir($cache_path) ) + $disk_cache = wp_mkdir_p($cache_path); + +$cache_ext = '.js'; +$plugins = explode( ',', $initArray['plugins'] ); +$theme = ( 'simple' == $initArray['theme'] ) ? 'simple' : 'advanced'; +$language = isset($initArray['language']) ? substr( $initArray['language'], 0, 2 ) : 'en'; +$cacheKey = $mce_options = ''; + +// Check if browser supports gzip +if ( $compress && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { + if ( ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') || isset($_SERVER['---------------']) ) && function_exists('gzencode') && ! ini_get('zlib.output_compression') ) { + $cache_ext = '.gz'; } +} - $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower(get_locale()); -?> +// Setup cache info +if ( $disk_cache ) { -initArray = { - mode : "specific_textareas", - editor_selector : "mceEditor", - width : "100%", - theme : "advanced", - theme_advanced_buttons1 : "", - theme_advanced_buttons2 : "", - theme_advanced_buttons3 : "", - language : "", - theme_advanced_toolbar_location : "top", - theme_advanced_toolbar_align : "left", - theme_advanced_path_location : "bottom", - theme_advanced_resizing : true, - browsers : "", - dialog_type : "modal", - theme_advanced_resize_horizontal : false, - convert_urls : false, - relative_urls : false, - remove_script_host : false, - force_p_newlines : true, - force_br_newlines : false, - convert_newlines_to_brs : false, - remove_linebreaks : false, - fix_list_elements : true, - gecko_spellcheck : true, - entities : "38,amp,60,lt,62,gt", - button_tile_map : true, - content_css : "", - valid_elements : "", - save_callback : 'TinyMCE_wordpressPlugin.saveCallback', - imp_version : "", - - plugins : "" -}; - - + $cacheKey = apply_filters('tiny_mce_version', '20080414'); + + foreach ( $initArray as $v ) + $cacheKey .= $v; -tinyMCE.init(initArray); + if ( ! empty($mce_external_plugins) ) { + foreach ( $mce_external_plugins as $n => $v ) + $cacheKey .= $n; + } + + $cacheKey = md5( $cacheKey ); + $cache_file = $cache_path . '/tinymce_' . $cacheKey . $cache_ext; +} + +$expiresOffset = 864000; // 10 days +header( 'Content-Type: application/x-javascript; charset=UTF-8' ); +header( 'Vary: Accept-Encoding' ); // Handle proxies +header( 'Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . ' GMT' ); + +// Use cached file if exists +if ( $disk_cache && is_file($cache_file) && is_readable($cache_file) ) { + + $mtime = gmdate("D, d M Y H:i:s", filemtime($cache_file)) . " GMT"; + + if ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $mtime ) { + header('HTTP/1.1 304 Not Modified'); + exit; + } + header("Last-Modified: " . $mtime); + header("Cache-Control: must-revalidate", false); + + $content = getFileContents( $cache_file ); + + if ( '.gz' == $cache_ext ) + header( 'Content-Encoding: gzip' ); + + echo $content; + exit; +} + +foreach ( $initArray as $k => $v ) + $mce_options .= $k . ':"' . $v . '",'; + +if ( $mce_deprecated ) $mce_options .= $mce_deprecated; + +$mce_options = rtrim( trim($mce_options), '\n\r,' ); + +$content = 'var tinyMCEPreInit = { settings : { themes : "' . $theme . '", plugins : "' . $initArray['plugins'] . '", languages : "' . $language . '", debug : false }, base : "' . $baseurl . '", suffix : "" };'; + +// Load patch +$content .= getFileContents( 'tiny_mce_ext.js' ); + +// Add core +$content .= getFileContents( 'tiny_mce.js' ); + +// Patch loading functions +$content .= 'tinyMCEPreInit.start();'; + +// Add all languages (WP) +include_once( dirname(__FILE__).'/langs/wp-langs.php' ); +$content .= $strings; + +// Add themes +$content .= getFileContents( 'themes/' . $theme . '/editor_template.js' ); + +// Add plugins +foreach ( $plugins as $plugin ) + $content .= getFileContents( 'plugins/' . $plugin . '/editor_plugin.js' ); + +// Add external plugins and init +$content .= $ext_plugins . 'tinyMCE.init({' . $mce_options . '});'; + +// Generate GZIP'd content +if ( '.gz' == $cache_ext ) { + header('Content-Encoding: gzip'); + $content = gzencode( $content, 9, FORCE_GZIP ); +} + +// Stream to client +echo $content; + +// Write file +if ( '' != $cacheKey && is_dir($cache_path) && is_readable($cache_path) ) { + + $old_cache = array(); + $handle = opendir($cache_path); + while ( false !== ( $file = readdir($handle) ) ) { + if ( $file == '.' || $file == '..' ) continue; + $saved = filectime("$cache_path/$file"); + if ( strpos($file, 'tinymce_') !== false && substr($file, -3) == $cache_ext ) $old_cache["$saved"] = $file; + } + closedir($handle); + + krsort($old_cache); + if ( 1 >= $old_cache_max ) $del_cache = $old_cache; + else $del_cache = array_slice( $old_cache, ($old_cache_max - 1) ); + + foreach ( $del_cache as $key ) + @unlink("$cache_path/$key"); + + putFileContents( $cache_file, $content ); +} + +?> diff --git a/wp-includes/js/tinymce/tiny_mce_ext.js b/wp-includes/js/tinymce/tiny_mce_ext.js new file mode 100644 index 00000000..6eab9106 --- /dev/null +++ b/wp-includes/js/tinymce/tiny_mce_ext.js @@ -0,0 +1,36 @@ +tinyMCEPreInit.start = function() { + var t = this, each = tinymce.each, s = t.settings, sl = tinymce.ScriptLoader, ln = s.languages, th = s.themes; + + function load(u, sp) { + var o; + + if (!sp) + u = t.base + u; + + o = {url : u, state : 2}; + sl.queue.push(o); + sl.lookup[o.url] = o; + }; + + sl.markDone(t.base + '/langs/' + ln + '.js'); + + load('/themes/' + th + '/editor_template' + t.suffix + '.js'); + sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '.js'); + sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '_dlg.js'); + + each(s.plugins.split(','), function(n) { + if (n && n.charAt(0) != '-') { + load('/plugins/' + n + '/editor_plugin' + t.suffix + '.js'); + + sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '.js'); + sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '_dlg.js'); + } + }); +}; +tinyMCEPreInit.load_ext = function(url,lang) { + var sl = tinymce.ScriptLoader; + +// sl.add(url + '/langs/lang.php'); + sl.markDone(url + '/langs/' + lang + '.js'); + sl.markDone(url + '/langs/' + lang + '_dlg.js'); +}; diff --git a/wp-includes/js/tinymce/tiny_mce_gzip.php b/wp-includes/js/tinymce/tiny_mce_gzip.php deleted file mode 100644 index 7c21f480..00000000 --- a/wp-includes/js/tinymce/tiny_mce_gzip.php +++ /dev/null @@ -1,361 +0,0 @@ - -1) { - // Write main script and patch some things - if ( $index == 0 ) { - // Add core - $content .= wp_compact_tinymce_js(getFileContents("tiny_mce" . $suffix . ".js")); - $content .= 'TinyMCE.prototype.orgLoadScript = TinyMCE.prototype.loadScript;'; - $content .= 'TinyMCE.prototype.loadScript = function() {};var realTinyMCE = tinyMCE;'; - } else - $content .= 'tinyMCE = realTinyMCE;'; - - // Patch loading functions - //$content .= "tinyMCE_GZ.start();"; - - // Do init based on index - $content .= "tinyMCE.init(tinyMCECompressed.configs[" . $index . "]);"; - - // Load external plugins - if ( $index == 0 ) - $content .= "tinyMCECompressed.loadPlugins();"; - - // Add core languages - $lang_content = ''; - foreach ($languages as $lang) - $lang_content .= getFileContents("langs/" . $lang . ".js"); - if ( empty($lang_content) ) - $lang_content .= getFileContents("langs/en.js"); - $content .= $lang_content; - - // Add themes - foreach ($themes as $theme) { - $content .= wp_compact_tinymce_js(getFileContents( "themes/" . $theme . "/editor_template" . $suffix . ".js")); - - $lang_content = ''; - foreach ($languages as $lang) - $lang_content .= getFileContents("themes/" . $theme . "/langs/" . $lang . ".js"); - if ( empty($lang_content) ) - $lang_content .= getFileContents("themes/" . $theme . "/langs/en.js"); - $content .= $lang_content; - } - - // Add plugins - foreach ($plugins as $plugin) { - $content .= getFileContents("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"); - - $lang_content = ''; - foreach ($languages as $lang) - $lang_content .= getFileContents("plugins/" . $plugin . "/langs/" . $lang . ".js"); - if ( empty($lang_content) ) - $lang_content .= getFileContents("plugins/" . $plugin . "/langs/en.js"); - $content .= $lang_content; - } - - // Add custom files - foreach ($custom as $file) - $content .= getFileContents($file); - - // Reset tinyMCE compressor engine - $content .= "tinyMCE = tinyMCECompressed;"; - - // Restore loading functions - //$content .= "tinyMCE_GZ.end();"; - - // Generate GZIP'd content - if ($supportsGzip) { - if ($compress) { - header("Content-Encoding: " . $enc); - $cacheData = gzencode($content, 9, FORCE_GZIP); - } else - $cacheData = $content; - - // Write gz file - if ($diskCache && $cacheKey != "") - putFileContents($cacheFile, $cacheData); - - // Stream to client - echo $cacheData; - } else { - // Stream uncompressed content - echo $content; - } - - die; -} - - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - - function getParam($name, $def = false) { - if (!isset($_GET[$name])) - return $def; - - return preg_replace("/[^0-9a-z\-_,]+/i", "", $_GET[$name]); // Remove anything but 0-9,a-z,-_ - } - - function getFileContents($path) { - $path = realpath($path); - - if (!$path || !@is_file($path)) - return ""; - - if (function_exists("file_get_contents")) - return @file_get_contents($path); - - $content = ""; - $fp = @fopen($path, "r"); - if (!$fp) - return ""; - - while (!feof($fp)) - $content .= fgets($fp); - - fclose($fp); - - return $content; - } - - function putFileContents($path, $content) { - if (function_exists("file_put_contents")) - return @file_put_contents($path, $content); - - $fp = @fopen($path, "wb"); - if ($fp) { - fwrite($fp, $content); - fclose($fp); - } - } - - // WP specific - function wp_compact_tinymce_js($text) { - // This function was custom-made for TinyMCE 2.0, not expected to work with any other JS. - - // Strip comments - $text = preg_replace("!(^|\s+)//.*$!m", '', $text); - $text = preg_replace("!/\*.*?\*/!s", '', $text); - - // Strip leading tabs, carriage returns and unnecessary line breaks. - $text = preg_replace("!^\t+!m", '', $text); - $text = str_replace("\r", '', $text); - $text = preg_replace("!(^|{|}|;|:|\))\n!m", '\\1', $text); - - return "$text\n"; - } -?> - -function TinyMCECompressed() { - this.configs = new Array(); - this.loadedFiles = new Array(); - this.externalPlugins = new Array(); - this.loadAdded = false; - this.isLoaded = false; -} - -TinyMCECompressed.prototype.init = function(settings) { - var elements = document.getElementsByTagName('script'); - var scriptURL = ""; - - for (var i=0; i'); - - if (!this.loadAdded) { - tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCECompressed.prototype.onLoad); - tinyMCE.addEvent(window, "load", TinyMCECompressed.prototype.onLoad); - this.loadAdded = true; - } -} - -TinyMCECompressed.prototype.onLoad = function() { - if (tinyMCE.isLoaded) - return true; - - tinyMCE = realTinyMCE; - TinyMCE_Engine.prototype.onLoad(); - tinyMCE._addUnloadEvents(); - - tinyMCE.isLoaded = true; -} - -TinyMCECompressed.prototype.addEvent = function(o, n, h) { - if (o.attachEvent) - o.attachEvent("on" + n, h); - else - o.addEventListener(n, h, false); -} - -TinyMCECompressed.prototype.getOnce = function(str) { - var ar = str.replace(/\s+/g, '').split(','); - - for (var i=0; i'); + if (t.isWindow) + window.resizeBy(dw, dh); + else + t.editor.windowManager.resizeBy(dw, dh, t.id); + }, - if (tinyMCE.getParam("popups_css_add")) { - c = tinyMCE.getParam("popups_css_add"); + executeOnLoad : function(s) { + this.onInit.add(function() { + eval(s); + }); + }, - // Is relative - if (c.indexOf('://') == -1 && c.charAt(0) != '/') - c = tinyMCE.documentBasePath + "/" + c; + storeSelection : function() { + this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple'); + }, - document.write(''); - } + restoreSelection : function() { + var t = tinyMCEPopup; - tinyMCE.addEvent(window, "load", this.onLoad); + if (!t.isWindow && tinymce.isIE) + t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark); }, - onLoad : function() { - var dir, i, elms, body = document.body; + requireLangPack : function() { + var u = this.getWindowArg('plugin_url') || this.getWindowArg('theme_url'); - if (tinyMCE.getWindowArg('mce_replacevariables', true)) - body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs); + if (u && this.editor.settings.language) { + u += '/langs/' + this.editor.settings.language + '_dlg.js'; - dir = tinyMCE.selectedInstance.settings.directionality; - if (dir == "rtl" && document.forms && document.forms.length > 0) { - elms = document.forms[0].elements; - for (i=0; i'); + tinymce.ScriptLoader.markDone(u); } } - - if (body.style.display == 'none') - body.style.display = 'block'; - - // Execute real onload (Opera fix) - if (tinyMCEPopup.onLoadEval !== '') - eval(tinyMCEPopup.onLoadEval); }, - executeOnLoad : function(str) { - if (tinyMCE.isOpera) - this.onLoadEval = str; - else - eval(str); + pickColor : function(e, element_id) { + this.execCommand('mceColorPicker', true, { + color : document.getElementById(element_id).value, + func : function(c) { + document.getElementById(element_id).value = c; + + try { + document.getElementById(element_id).onchange(); + } catch (ex) { + // Try fire event, ignore errors + } + } + }); }, - resizeToInnerSize : function() { - var i, doc, body, oldMargin, wrapper, iframe, nodes, dx, dy; - - // Netscape 7.1 workaround - if (this.isWindow && tinyMCE.isNS71) { - window.resizeBy(0, 10); - return; - } - - if (this.isWindow) { - doc = document; - body = doc.body; + openBrowser : function(element_id, type, option) { + tinyMCEPopup.restoreSelection(); + this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window); + }, - if (body.style.display == 'none') - body.style.display = 'block'; + close : function() { + var t = this; - // Remove margin - oldMargin = body.style.margin; - body.style.margin = '0'; + // To avoid domain relaxing issue in Opera + function close() { + t.editor.windowManager.close(window, t.id); + tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup + }; - // Create wrapper - wrapper = doc.createElement("div"); - wrapper.id = 'mcBodyWrapper'; - wrapper.style.display = 'none'; - wrapper.style.margin = '0'; + if (tinymce.isOpera) + t.getWin().setTimeout(close, 0); + else + close(); + }, - // Wrap body elements - nodes = doc.body.childNodes; - for (i=nodes.length-1; i>=0; i--) { - if (wrapper.hasChildNodes()) - wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild); - else - wrapper.appendChild(nodes[i].cloneNode(true)); + // Internal functions - nodes[i].parentNode.removeChild(nodes[i]); - } + _restoreSelection : function() { + var e = window.event.srcElement; - // Add wrapper - doc.body.appendChild(wrapper); - - // Create iframe - iframe = document.createElement("iframe"); - iframe.id = "mcWinIframe"; - iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings.default_document; - iframe.width = "100%"; - iframe.height = "100%"; - iframe.style.margin = '0'; - - // Add iframe - doc.body.appendChild(iframe); - - // Measure iframe - iframe = document.getElementById('mcWinIframe'); - dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth; - dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight; - - // Resize window - // tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy); - window.resizeBy(dx, dy); - - // Hide iframe and show wrapper - body.style.margin = oldMargin; - iframe.style.display = 'none'; - wrapper.style.display = 'block'; - } + if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button')) + tinyMCEPopup.restoreSelection(); }, - resizeToContent : function() { - var isMSIE = (navigator.appName == "Microsoft Internet Explorer"); - var isOpera = (navigator.userAgent.indexOf("Opera") != -1); - var elm, width, height, x, y, dx, dy; +/* _restoreSelection : function() { + var e = window.event.srcElement; - if (isOpera) - return; + // If user focus a non text input or textarea + if ((e.nodeName != 'INPUT' && e.nodeName != 'TEXTAREA') || e.type != 'text') + tinyMCEPopup.restoreSelection(); + },*/ - if (isMSIE) { - try { window.resizeTo(10, 10); } catch (e) {} + _onDOMLoaded : function() { + var t = this, ti = document.title, bm, h; - elm = document.body; - width = elm.offsetWidth; - height = elm.offsetHeight; - dx = (elm.scrollWidth - width) + 4; - dy = elm.scrollHeight - height; + // Translate page + h = document.body.innerHTML; - try { window.resizeBy(dx, dy); } catch (e) {} - } else { - window.scrollBy(1000, 1000); - if (window.scrollX > 0 || window.scrollY > 0) { - window.resizeBy(window.innerWidth * 2, window.innerHeight * 2); - window.sizeToContent(); - window.scrollTo(0, 0); - x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0); - y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0); - window.moveTo(x, y); - } - } - }, + // Replace a=x with a="x" in IE + if (tinymce.isIE) + h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"') - getWindowArg : function(name, default_value) { - return tinyMCE.getWindowArg(name, default_value); - }, + document.dir = t.editor.getParam('directionality',''); + document.body.innerHTML = t.editor.translate(h); + document.title = ti = t.editor.translate(ti); + document.body.style.display = ''; - restoreSelection : function() { - var inst; + // Restore selection in IE when focus is placed on a non textarea or input element of the type text + if (tinymce.isIE) + document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection); - if (this.storeSelection) { - inst = tinyMCE.selectedInstance; + t.restoreSelection(); + t.resizeToInnerSize(); - inst.getWin().focus(); + // Set inline title + if (!t.isWindow) + t.editor.windowManager.setTitle(ti, t.id); + else + window.focus(); - if (inst.selectionBookmark) - inst.selection.moveToBookmark(inst.selectionBookmark); + if (!tinymce.isIE && !t.isWindow) { + tinymce.dom.Event._add(document, 'focus', function() { + t.editor.windowManager.focus(t.id) + }); } - }, - execCommand : function(command, user_interface, value) { - var inst = tinyMCE.selectedInstance; + // Patch for accessibility + tinymce.each(t.dom.select('select'), function(e) { + e.onkeydown = tinyMCEPopup._accessHandler; + }); - this.restoreSelection(); - inst.execCommand(command, user_interface, value); + // Call onInit + // Init must be called before focus so the selection won't get lost by the focus call + tinymce.each(t.listeners, function(o) { + o.func.call(o.scope, t.editor); + }); - // Store selection - if (this.storeSelection) - inst.selectionBookmark = inst.selection.getBookmark(true); - }, + // Move focus to window + if (t.getWindowArg('mce_auto_focus', true)) { + window.focus(); - close : function() { - tinyMCE.closeWindow(window); - }, + // Focus element with mceFocus class + tinymce.each(document.forms, function(f) { + tinymce.each(f.elements, function(e) { + if (t.dom.hasClass(e, 'mceFocus') && !e.disabled) { + e.focus(); + return false; // Break loop + } + }); + }); + } - pickColor : function(e, element_id) { - tinyMCE.selectedInstance.execCommand('mceColorPicker', true, { - element_id : element_id, - document : document, - window : window, - store_selection : false - }); + document.onkeyup = tinyMCEPopup._closeWinKeyHandler; }, - openBrowser : function(element_id, type, option) { - var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback")); - var url = document.getElementById(element_id).value; + _accessHandler : function(e) { + e = e || window.event; - tinyMCE.setWindowArg("window", window); - tinyMCE.setWindowArg("document", document); + if (e.keyCode == 13 || e.keyCode == 32) { + e = e.target || e.srcElement; - // Call to external callback - if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined") - alert("Callback function: " + cb + " could not be found."); - else - eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);"); - }, + if (e.onchange) + e.onchange(); - importClass : function(c) { - var n; + return tinymce.dom.Event.cancel(e); + } + }, - window[c] = function() {}; + _closeWinKeyHandler : function(e) { + e = e || window.event; - for (n in window.opener[c].prototype) - window[c].prototype[n] = window.opener[c].prototype[n]; + if (e.keyCode == 27) + tinyMCEPopup.close(); + }, - window[c].constructor = window.opener[c].constructor; + _wait : function() { + var t = this, ti; + + if (tinymce.isIE && document.location.protocol != 'https:') { + // Fake DOMContentLoaded on IE + document.write(' +

    -

    +
      -
    • -
    • -
    • -
    • +
    • +
    • +
    • +
    @@ -132,50 +170,81 @@ header('Content-Type: text/html; charset=' . get_bloginfo('charset'));

    Rich editing, also called WYSIWYG for What You See Is What You Get, means your text is formatted as you type. The rich editor creates HTML code behind the scenes while you concentrate on writing. Font styles, links and images all appear approximately as they will on the internet.') ?>

    -

    +

    +

    +

    +
    +
    +
    + +
    diff --git a/wp-includes/js/wp-ajax-response.js b/wp-includes/js/wp-ajax-response.js new file mode 100644 index 00000000..95558536 --- /dev/null +++ b/wp-includes/js/wp-ajax-response.js @@ -0,0 +1,60 @@ +wpAjax = jQuery.extend( { + unserialize: function( s ) { + var r = {}; if ( !s ) { return r; } + var q = s.split('?'); if ( q[1] ) { s = q[1]; } + var pp = s.split('&'); + for ( var i in pp ) { + if ( jQuery.isFunction(pp.hasOwnProperty) && !pp.hasOwnProperty(i) ) { continue; } + var p = pp[i].split('='); + r[p[0]] = p[1]; + } + return r; + }, + parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission + var parsed = {}; + var re = jQuery('#' + r).html(''); + if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) { + parsed.responses = []; + parsed.errors = false; + var err = ''; + jQuery('response', x).each( function() { + var th = jQuery(this); + var child = jQuery(this.firstChild); + var response = { action: th.attr('action'), what: child.get(0).nodeName, id: child.attr('id'), oldId: child.attr('old_id'), position: child.attr('position') }; + response.data = jQuery( 'response_data', child ).text(); + response.supplemental = {}; + if ( !jQuery( 'supplemental', child ).children().each( function() { + response.supplemental[this.nodeName] = jQuery(this).text(); + } ).size() ) { response.supplemental = false } + response.errors = []; + if ( !jQuery('wp_error', child).each( function() { + var code = jQuery(this).attr('code'); + var anError = { code: code, message: this.firstChild.nodeValue, data: false }; + var errorData = jQuery('wp_error_data[code="' + code + '"]', x); + if ( errorData ) { anError.data = errorData.get(); } + var formField = jQuery( 'form-field', errorData ).text(); + if ( formField ) { code = formField; } + if ( e ) { wpAjax.invalidateForm( jQuery('#' + e + ' :input[name="' + code + '"]' ).parents('.form-field:first') ); } + err += '

    ' + anError.message + '

    '; + response.errors.push( anError ); + parsed.errors = true; + } ).size() ) { response.errors = false; } + parsed.responses.push( response ); + } ); + if ( err.length ) { re.html( '
    ' + err + '
    ' ); } + return parsed; + } + if ( isNaN(x) ) { return !re.html('

    ' + x + '

    '); } + x = parseInt(x,10); + if ( -1 == x ) { return !re.html('

    ' + wpAjax.noPerm + '

    '); } + else if ( 0 === x ) { return !re.html('

    ' + wpAjax.broken + '

    '); } + return true; + }, + invalidateForm: function ( selector ) { + return jQuery( selector ).addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } ); + }, + validateForm: function( selector ) { + selector = jQuery( selector ); + return !wpAjax.invalidateForm( selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]') ).size(); + } +}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'An unidentified error has occurred.' } ); diff --git a/wp-includes/js/wp-lists.js b/wp-includes/js/wp-lists.js new file mode 100644 index 00000000..884f02a6 --- /dev/null +++ b/wp-includes/js/wp-lists.js @@ -0,0 +1,370 @@ +(function($) { +var currentFormEl = false; +var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}; + +var wpList = { + settings: { + url: wpListL10n.url, type: 'POST', + response: 'ajax-response', + + what: '', + alt: 'alternate', altOffset: 0, + addColor: null, delColor: null, dimAddColor: null, dimDelColor: null, + + confirm: null, + addBefore: null, addAfter: null, + delBefore: null, delAfter: null, + dimBefore: null, dimAfter: null + }, + + nonce: function(e,s) { + var url = wpAjax.unserialize(e.attr('href')); + return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[name=_wpnonce]').val() || 0; + }, + + parseClass: function(e,t) { + var c = [], cl; + try { + cl = $(e).attr('class') || ''; + cl = cl.match(new RegExp(t+':[A-Za-z0-9:_=-]+')); + if ( cl ) { c = cl[0].split(':'); } + } catch(r) {} + return c; + }, + + pre: function(e,s,a) { + var bg; var r; + s = $.extend( {}, this.wpList.settings, { + element: null, + nonce: 0, + target: e.get(0) + }, s || {} ); + if ( $.isFunction( s.confirm ) ) { + if ( 'add' != a ) { + bg = $('#' + s.element).css('backgroundColor'); + $('#' + s.element).css('backgroundColor', '#FF9966'); + } + r = s.confirm.call(this,e,s,a,bg); + if ( 'add' != a ) { $('#' + s.element).css('backgroundColor', bg ); } + if ( !r ) { return false; } + } + return s; + }, + + ajaxAdd: function( e, s ) { + var list = this; e = $(e); s = s || {}; + var cls = wpList.parseClass(e,'add'); + s = wpList.pre.call( list, e, s, 'add' ); + + s.element = cls[2] || e.attr( 'id' ) || s.element || null; + if ( cls[3] ) { s.addColor = '#' + cls[3]; } + else { s.addColor = s.addColor || '#FFFF33'; } + + if ( !s ) { return false; } + + if ( !e.is("[class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); } + + if ( !s.element ) { return true; } + + s.action = 'add-' + s.what; + + s.nonce = wpList.nonce(e,s); + + var es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]'); + var valid = wpAjax.validateForm( '#' + s.element ); + if ( !valid ) { return false; } + + s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) ); + var formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize(); + if ( formData ) { s.data += '&' + formData; } + + if ( $.isFunction(s.addBefore) ) { + s = s.addBefore( s ); + if ( !s ) { return true; } + } + if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) ) { return true; } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element); + if ( !res || res.errors ) { return false; } + + jQuery.each( res.responses, function() { + wpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue + pos: this.position || 0, + id: this.id || 0, + oldId: this.oldId || null + } ) ); + } ); + + if ( $.isFunction(s.addAfter) ) { + var o = this.complete; + this.complete = function(x,st) { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.addAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + }; + } + list.wpList.recolor(); + wpList.clear.call(list,'#' + s.element); + }; + + $.ajax( s ); + return false; + }, + + ajaxDel: function( e, s ) { + var list = this; e = $(e); s = s || {}; + var cls = wpList.parseClass(e,'delete'); + s = wpList.pre.call( list, e, s, 'delete' ); + + s.element = cls[2] || s.element || null; + if ( cls[3] ) { s.delColor = '#' + cls[3]; } + else { s.delColor = s.delColor || '#FF3333'; } + + if ( !s || !s.element ) { return false; } + + s.action = 'delete-' + s.what; + + s.nonce = wpList.nonce(e,s); + + s.data = $.extend( + { action: s.action, id: s.element.split('-').pop(), _ajax_nonce: s.nonce }, + wpAjax.unserialize( cls[4] || '' ) + ); + + if ( $.isFunction(s.delBefore) ) { + s = s.delBefore( s ); + if ( !s ) { return true; } + } + if ( !s.data._ajax_nonce ) { return true; } + + var element = $('#' + s.element); + + if ( 'none' != s.delColor ) { + var anim = 'slideUp'; + if ( element.css( 'display' ).match(/table/) ) + anim = 'fadeOut'; // Can't slideup table rows and other table elements. Known jQuery bug + element + .animate( { backgroundColor: s.delColor }, 'fast' )[anim]( 'fast' ) + .queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + } else { + list.wpList.recolor(); + } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element); + if ( !res || res.errors ) { + element.stop().stop().css( 'backgroundColor', '#FF3333' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + return false; + } + if ( $.isFunction(s.delAfter) ) { + var o = this.complete; + this.complete = function(x,st) { + element.queue( function() { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.delAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + } ).dequeue(); + }; + } + }; + $.ajax( s ); + return false; + }, + + ajaxDim: function( e, s ) { + var list = this; e = $(e); s = s || {}; + var cls = wpList.parseClass(e,'dim'); + s = wpList.pre.call( list, e, s, 'dim' ); + + s.element = cls[2] || s.element || null; + s.dimClass = cls[3] || s.dimClass || null; + if ( cls[4] ) { s.dimAddColor = '#' + cls[4]; } + else { s.dimAddColor = s.dimAddColor || '#FFFF33'; } + if ( cls[5] ) { s.dimDelColor = '#' + cls[5]; } + else { s.dimDelColor = s.dimDelColor || '#FF3333'; } + + if ( !s || !s.element || !s.dimClass ) { return true; } + + s.action = 'dim-' + s.what; + + s.nonce = wpList.nonce(e,s); + + s.data = $.extend( + { action: s.action, id: s.element.split('-').pop(), dimClass: s.dimClass, _ajax_nonce : s.nonce }, + wpAjax.unserialize( cls[6] || '' ) + ); + + if ( $.isFunction(s.dimBefore) ) { + s = s.dimBefore( s ); + if ( !s ) { return true; } + } + + var element = $('#' + s.element); + var isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass); + var color = wpList.getColor( element ); + element.toggleClass( s.dimClass ) + var dimColor = isClass ? s.dimAddColor : s.dimDelColor; + if ( 'none' != dimColor ) { + element + .animate( { backgroundColor: dimColor }, 'fast' ) + .queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } ) + .animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } ); + } + + if ( !s.data._ajax_nonce ) { return true; } + + s.success = function(r) { + var res = wpAjax.parseAjaxResponse(r, s.response, s.element); + if ( !res || res.errors ) { + element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); + return false; + } + if ( $.isFunction(s.dimAfter) ) { + var o = this.complete; + this.complete = function(x,st) { + element.queue( function() { + var _s = $.extend( { xml: x, status: st, parsed: res }, s ); + s.dimAfter( r, _s ); + if ( $.isFunction(o) ) { o(x,st); } + } ).dequeue(); + }; + } + }; + + $.ajax( s ); + return false; + }, + + // From jquery.color.js: jQuery Color Animation by John Resig + getColor: function( el ) { + if ( el.constructor == Object ) + el = el.get(0); + var elem = el, color, rgbaTrans = new RegExp( "rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)", "i" ); + do { + color = jQuery.curCSS(elem, 'backgroundColor'); + if ( color != '' && color != 'transparent' && !color.match(rgbaTrans) || jQuery.nodeName(elem, "body") ) + break; + } while ( elem = elem.parentNode ); + return color || '#ffffff'; + }, + + add: function( e, s ) { + var list = $(this); + e = $(e); + + var old = false; + var _s = { pos: 0, id: 0, oldId: null }; + if ( 'string' == typeof s ) { s = { what: s }; } + s = $.extend(_s, this.wpList.settings, s); + if ( !e.size() || !s.what ) { return false; } + if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); } + if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); } + + if ( old && old.size() ) { + old.replaceWith(e); + } else if ( isNaN(s.pos) ) { + var ba = 'after'; + if ( '-' == s.pos.substr(0,1) ) { + s.pos = s.pos.substr(1); + ba = 'before'; + } + var ref = list.find( '#' + s.pos ); + if ( 1 === ref.size() ) { ref[ba](e); } + else { list.append(e); } + } else if ( s.pos < 0 ) { + list.prepend(e); + } else { + list.append(e); + } + + if ( s.alt ) { + if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); } + else { e.addClass( s.alt ); } + } + + if ( 'none' != s.addColor ) { + var color = wpList.getColor( e ); + e.css( 'backgroundColor', s.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } ); + } + list.each( function() { this.wpList.process( e ); } ); + return e; + }, + + clear: function(e) { + var list = this; + e = $(e); + if ( list.wpList && e.parents( '#' + list.id ).size() ) { return; } + e.find(':input').each( function() { + if ( $(this).parents('.form-no-clear').size() ) + return; + var t = this.type.toLowerCase(); var tag = this.tagName.toLowerCase(); + if ( 'text' == t || 'password' == t || 'textarea' == tag ) { this.value = ''; } + else if ( 'checkbox' == t || 'radio' == t ) { this.checked = false; } + else if ( 'select' == tag ) { this.selectedIndex = null; } + }); + }, + + process: function(el) { + var list = this; + $("[class^=add:" + list.id + ":]", el || null) + .filter('form').submit( function() { return list.wpList.add(this); } ).end() + .not('form').click( function() { return list.wpList.add(this); } ).each( function() { + var addEl = this; + var c = wpList.parseClass(this,'add')[2] || addEl.id; + if ( !c ) { return; } + var forms = []; var ins = []; // this is all really inefficient + $('#' + c + ' :input').focus( function() { currentFormEl = this; } ).blur( function() { currentFormEl = false; } ).each( function() { + ins.push(this); + var f = $(this).parents('form:first').get(0); + if ( $.inArray(f,forms) < 0 ) { forms.push(f); } + } ); + $(forms).submit( function() { + if ( 0 <= $.inArray(currentFormEl,ins) ) { + $(addEl).trigger( 'click' ); + $(currentFormEl).focus(); + return false; + } + } ); + } ); + $("[class^=delete:" + list.id + ":]", el || null).click( function() { return list.wpList.del(this); } ); + $("[class^=dim:" + list.id + ":]", el || null).click( function() { return list.wpList.dim(this); } ); + }, + + recolor: function() { + var list = this; + if ( !list.wpList.settings.alt ) { return; } + var items = $('.list-item:visible', list); + if ( !items.size() ) { items = $(list).children(':visible'); } + var eo = [':even',':odd']; + if ( list.wpList.settings.altOffset % 2 ) { eo.reverse(); } + items.filter(eo[0]).addClass(list.wpList.settings.alt).end().filter(eo[1]).removeClass(list.wpList.settings.alt); + }, + + init: function() { + var lists = this; + lists.wpList.process = function(a) { + lists.each( function() { + this.wpList.process(a); + } ); + }; + lists.wpList.recolor = function() { + lists.each( function() { + this.wpList.recolor(); + } ); + }; + } +}; + +$.fn.wpList = function( settings ) { + this.each( function() { + var _this = this; + this.wpList = { settings: $.extend( {}, wpList.settings, { what: wpList.parseClass(this,'list')[1] || '' }, settings ) }; + $.each( fs, function(i,f) { _this.wpList[i] = function( e, s ) { return wpList[f].call( _this, e, s ); }; } ); + } ); + wpList.init.call(this); + this.wpList.process(); + return this; +}; + +})(jQuery); diff --git a/wp-includes/kses.php b/wp-includes/kses.php index 8c448958..ae37fc26 100644 --- a/wp-includes/kses.php +++ b/wp-includes/kses.php @@ -1,215 +1,316 @@ + * + * @package External + * @subpackage KSES + * + * @internal + * *** CONTACT INFORMATION *** + * E-mail: metaur at users dot sourceforge dot net + * Web page: http://sourceforge.net/projects/kses + * Paper mail: Ulf Harnhammar + * Ymergatan 17 C + * 753 25 Uppsala + * SWEDEN + * + * [kses strips evil scripts!] + */ + +/** + * You can override this in your my-hacks.php file + * You can also override this in a plugin file. The + * my-hacks.php is deprecated in its usage. + * + * @since 1.2.0 + */ if (!defined('CUSTOM_TAGS')) define('CUSTOM_TAGS', false); -// You can override this in your my-hacks.php file if (!CUSTOM_TAGS) { + /** + * Kses global for default allowable HTML tags + * + * Can be override by using CUSTOM_TAGS constant + * @global array $allowedposttags + * @since 2.0.0 + */ $allowedposttags = array( 'address' => array(), 'a' => array( - 'href' => array(), 'title' => array(), - 'rel' => array(), 'rev' => array(), - 'name' => array() - ), + 'class' => array (), + 'href' => array (), + 'id' => array (), + 'title' => array (), + 'rel' => array (), + 'rev' => array (), + 'name' => array (), + 'target' => array()), 'abbr' => array( - 'title' => array(), 'class' => array() - ), + 'class' => array (), + 'title' => array ()), 'acronym' => array( - 'title' => array() - ), + 'title' => array ()), 'b' => array(), 'big' => array(), 'blockquote' => array( - 'cite' => array(), 'xml:lang' => array(), - 'lang' => array() - ), - 'br' => array(), + 'id' => array (), + 'cite' => array (), + 'class' => array(), + 'lang' => array(), + 'xml:lang' => array()), + 'br' => array ( + 'class' => array ()), 'button' => array( - 'disabled' => array(), 'name' => array(), - 'type' => array(), 'value' => array() - ), + 'disabled' => array (), + 'name' => array (), + 'type' => array (), + 'value' => array ()), 'caption' => array( - 'align' => array() - ), - 'code' => array(), + 'align' => array (), + 'class' => array ()), + 'cite' => array ( + 'class' => array(), + 'dir' => array(), + 'lang' => array(), + 'title' => array ()), + 'code' => array ( + 'style' => array()), 'col' => array( - 'align' => array(), 'char' => array(), - 'charoff' => array(), 'span' => array(), - 'valign' => array(), 'width' => array() - ), + 'align' => array (), + 'char' => array (), + 'charoff' => array (), + 'span' => array (), + 'dir' => array(), + 'style' => array (), + 'valign' => array (), + 'width' => array ()), 'del' => array( - 'datetime' => array() - ), + 'datetime' => array ()), 'dd' => array(), 'div' => array( - 'align' => array(), 'xml:lang' => array(), - 'lang' => array() - ), + 'align' => array (), + 'class' => array (), + 'dir' => array (), + 'lang' => array(), + 'style' => array (), + 'xml:lang' => array()), 'dl' => array(), 'dt' => array(), 'em' => array(), 'fieldset' => array(), 'font' => array( - 'color' => array(), 'face' => array(), - 'size' => array() - ), + 'color' => array (), + 'face' => array (), + 'size' => array ()), 'form' => array( - 'action' => array(), 'accept' => array(), - 'accept-charset' => array(), 'enctype' => array(), - 'method' => array(), 'name' => array(), - 'target' => array() - ), + 'action' => array (), + 'accept' => array (), + 'accept-charset' => array (), + 'enctype' => array (), + 'method' => array (), + 'name' => array (), + 'target' => array ()), 'h1' => array( - 'align' => array() - ), + 'align' => array (), + 'class' => array ()), 'h2' => array( - 'align' => array() - ), + 'align' => array (), + 'class' => array ()), 'h3' => array( - 'align' => array() - ), + 'align' => array (), + 'class' => array ()), 'h4' => array( - 'align' => array() - ), + 'align' => array (), + 'class' => array ()), 'h5' => array( - 'align' => array() - ), + 'align' => array (), + 'class' => array ()), 'h6' => array( - 'align' => array() - ), + 'align' => array (), + 'class' => array ()), 'hr' => array( - 'align' => array(), 'noshade' => array(), - 'size' => array(), 'width' => array() - ), + 'align' => array (), + 'class' => array (), + 'noshade' => array (), + 'size' => array (), + 'width' => array ()), 'i' => array(), 'img' => array( - 'alt' => array(), 'align' => array(), - 'border' => array(), 'height' => array(), - 'hspace' => array(), 'longdesc' => array(), - 'vspace' => array(), 'src' => array(), - 'width' => array() - ), + 'alt' => array (), + 'align' => array (), + 'border' => array (), + 'class' => array (), + 'height' => array (), + 'hspace' => array (), + 'longdesc' => array (), + 'vspace' => array (), + 'src' => array (), + 'style' => array (), + 'width' => array ()), 'ins' => array( - 'datetime' => array(), 'cite' => array() - ), + 'datetime' => array (), + 'cite' => array ()), 'kbd' => array(), 'label' => array( - 'for' => array() - ), + 'for' => array ()), 'legend' => array( - 'align' => array() - ), - 'li' => array(), + 'align' => array ()), + 'li' => array ( + 'align' => array (), + 'class' => array ()), 'p' => array( - 'align' => array(), 'xml:lang' => array(), - 'lang' => array() - ), + 'class' => array (), + 'align' => array (), + 'dir' => array(), + 'lang' => array(), + 'style' => array (), + 'xml:lang' => array()), 'pre' => array( - 'width' => array() - ), + 'style' => array(), + 'width' => array ()), 'q' => array( - 'cite' => array() - ), + 'cite' => array ()), 's' => array(), + 'span' => array ( + 'class' => array (), + 'dir' => array (), + 'align' => array (), + 'style' => array (), + 'title' => array ()), 'strike' => array(), 'strong' => array(), 'sub' => array(), 'sup' => array(), 'table' => array( - 'align' => array(), 'bgcolor' => array(), - 'border' => array(), 'cellpadding' => array(), - 'cellspacing' => array(), 'rules' => array(), - 'summary' => array(), 'width' => array() - ), + 'align' => array (), + 'bgcolor' => array (), + 'border' => array (), + 'cellpadding' => array (), + 'cellspacing' => array (), + 'class' => array (), + 'dir' => array(), + 'id' => array(), + 'rules' => array (), + 'style' => array (), + 'summary' => array (), + 'width' => array ()), 'tbody' => array( - 'align' => array(), 'char' => array(), - 'charoff' => array(), 'valign' => array() - ), + 'align' => array (), + 'char' => array (), + 'charoff' => array (), + 'valign' => array ()), 'td' => array( - 'abbr' => array(), 'align' => array(), - 'axis' => array(), 'bgcolor' => array(), - 'char' => array(), 'charoff' => array(), - 'colspan' => array(), 'headers' => array(), - 'height' => array(), 'nowrap' => array(), - 'rowspan' => array(), 'scope' => array(), - 'valign' => array(), 'width' => array() - ), + 'abbr' => array (), + 'align' => array (), + 'axis' => array (), + 'bgcolor' => array (), + 'char' => array (), + 'charoff' => array (), + 'class' => array (), + 'colspan' => array (), + 'dir' => array(), + 'headers' => array (), + 'height' => array (), + 'nowrap' => array (), + 'rowspan' => array (), + 'scope' => array (), + 'style' => array (), + 'valign' => array (), + 'width' => array ()), 'textarea' => array( - 'cols' => array(), 'rows' => array(), - 'disabled' => array(), 'name' => array(), - 'readonly' => array() - ), + 'cols' => array (), + 'rows' => array (), + 'disabled' => array (), + 'name' => array (), + 'readonly' => array ()), 'tfoot' => array( - 'align' => array(), 'char' => array(), - 'charoff' => array(), 'valign' => array() - ), + 'align' => array (), + 'char' => array (), + 'class' => array (), + 'charoff' => array (), + 'valign' => array ()), 'th' => array( - 'abbr' => array(), 'align' => array(), - 'axis' => array(), 'bgcolor' => array(), - 'char' => array(), 'charoff' => array(), - 'colspan' => array(), 'headers' => array(), - 'height' => array(), 'nowrap' => array(), - 'rowspan' => array(), 'scope' => array(), - 'valign' => array(), 'width' => array() - ), + 'abbr' => array (), + 'align' => array (), + 'axis' => array (), + 'bgcolor' => array (), + 'char' => array (), + 'charoff' => array (), + 'class' => array (), + 'colspan' => array (), + 'headers' => array (), + 'height' => array (), + 'nowrap' => array (), + 'rowspan' => array (), + 'scope' => array (), + 'valign' => array (), + 'width' => array ()), 'thead' => array( - 'align' => array(), 'char' => array(), - 'charoff' => array(), 'valign' => array() - ), + 'align' => array (), + 'char' => array (), + 'charoff' => array (), + 'class' => array (), + 'valign' => array ()), 'title' => array(), 'tr' => array( - 'align' => array(), 'bgcolor' => array(), - 'char' => array(), 'charoff' => array(), - 'valign' => array() - ), + 'align' => array (), + 'bgcolor' => array (), + 'char' => array (), + 'charoff' => array (), + 'class' => array (), + 'style' => array (), + 'valign' => array ()), 'tt' => array(), 'u' => array(), - 'ul' => array(), - 'ol' => array(), - 'var' => array() - ); - + 'ul' => array ( + 'class' => array (), + 'style' => array (), + 'type' => array ()), + 'ol' => array ( + 'class' => array (), + 'start' => array (), + 'style' => array (), + 'type' => array ()), + 'var' => array ()); + /** + * Kses allowed HTML elements + * + * @global array $allowedtags + * @since 1.0.0 + */ $allowedtags = array( 'a' => array( - 'href' => array(), 'title' => array() - ), + 'href' => array (), + 'title' => array ()), 'abbr' => array( - 'title' => array() - ), + 'title' => array ()), 'acronym' => array( - 'title' => array() - ), + 'title' => array ()), 'b' => array(), 'blockquote' => array( - 'cite' => array() - ), + 'cite' => array ()), // 'br' => array(), + 'cite' => array (), 'code' => array(), - // 'del' => array('datetime' => array()), + 'del' => array( + 'datetime' => array ()), // 'dd' => array(), // 'dl' => array(), // 'dt' => array(), - 'em' => array(), - 'i' => array(), + 'em' => array (), 'i' => array (), // 'ins' => array('datetime' => array(), 'cite' => array()), // 'li' => array(), // 'ol' => array(), // 'p' => array(), - // 'q' => array(), + 'q' => array( + 'cite' => array ()), 'strike' => array(), 'strong' => array(), // 'sub' => array(), @@ -219,57 +320,103 @@ if (!CUSTOM_TAGS) { ); } -function wp_kses($string, $allowed_html, $allowed_protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet')) - ############################################################################### - # This function makes sure that only the allowed HTML element names, attribute - # names and attribute values plus only sane HTML entities will occur in - # $string. You have to remove any slashes from PHP's magic quotes before you - # call this function. - ############################################################################### - { +/** + * wp_kses() - Filters content and keeps only allowable HTML elements. + * + * This function makes sure that only the allowed HTML element names, + * attribute names and attribute values plus only sane HTML entities + * will occur in $string. You have to remove any slashes from PHP's + * magic quotes before you call this function. + * + * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', + * 'news', 'irc', 'gopher', 'nntp', 'feed', and finally 'telnet. This + * covers all common link protocols, except for 'javascript' which + * should not be allowed for untrusted users. + * + * @since 1.0.0 + * + * @param string $string Content to filter through kses + * @param array $allowed_html List of allowed HTML elements + * @param array $allowed_protocols Optional. Allowed protocol in links. + * @return string Filtered content with only allowed HTML elements + */ +function wp_kses($string, $allowed_html, $allowed_protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet')) { $string = wp_kses_no_null($string); $string = wp_kses_js_entities($string); $string = wp_kses_normalize_entities($string); $allowed_html_fixed = wp_kses_array_lc($allowed_html); $string = wp_kses_hook($string, $allowed_html_fixed, $allowed_protocols); // WP changed the order of these funcs and added args to wp_kses_hook return wp_kses_split($string, $allowed_html_fixed, $allowed_protocols); -} # function wp_kses +} -function wp_kses_hook($string, $allowed_html, $allowed_protocols) -############################################################################### -# You add any kses hooks here. -############################################################################### -{ +/** + * wp_kses_hook() - You add any kses hooks here. + * + * There is currently only one kses WordPress hook and it is + * called here. All parameters are passed to the hooks and + * expected to recieve a string. + * + * @since 1.0.0 + * + * @param string $string Content to filter through kses + * @param array $allowed_html List of allowed HTML elements + * @param array $allowed_protocols Allowed protocol in links + * @return string Filtered content through 'pre_kses' hook + */ +function wp_kses_hook($string, $allowed_html, $allowed_protocols) { $string = apply_filters('pre_kses', $string, $allowed_html, $allowed_protocols); return $string; -} # function wp_kses_hook +} -function wp_kses_version() -############################################################################### -# This function returns kses' version number. -############################################################################### -{ +/** + * wp_kses_version() - This function returns kses' version number. + * + * @since 1.0.0 + * + * @return string Version Number + */ +function wp_kses_version() { return '0.2.2'; -} # function wp_kses_version - -function wp_kses_split($string, $allowed_html, $allowed_protocols) -############################################################################### -# This function searches for HTML tags, no matter how malformed. It also -# matches stray ">" characters. -############################################################################### -{ +} + +/** + * wp_kses_split() - Searches for HTML tags, no matter how malformed + * + * It also matches stray ">" characters. + * + * @since 1.0.0 + * + * @param string $string Content to filter + * @param array $allowed_html Allowed HTML elements + * @param array $allowed_protocols Allowed protocols to keep + * @return string Content with fixed HTML tags + */ +function wp_kses_split($string, $allowed_html, $allowed_protocols) { return preg_replace('%((|$))|(<[^>]*(>|$)|>))%e', "wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string); -} # function wp_kses_split - -function wp_kses_split2($string, $allowed_html, $allowed_protocols) -############################################################################### -# This function does a lot of work. It rejects some very malformed things -# like <:::>. It returns an empty string, if the element isn't allowed (look -# ma, no strip_tags()!). Otherwise it splits the tag into an element and an -# attribute list. -############################################################################### -{ +} + +/** + * wp_kses_split2() - Callback for wp_kses_split for fixing malformed HTML tags + * + * This function does a lot of work. It rejects some very malformed things + * like <:::>. It returns an empty string, if the element isn't allowed (look + * ma, no strip_tags()!). Otherwise it splits the tag into an element and an + * attribute list. + * + * After the tag is split into an element and an attribute list, it is run + * through another filter which will remove illegal attributes and once + * that is completed, will be returned. + * + * @since 1.0.0 + * @uses wp_kses_attr() + * + * @param string $string Content to filter + * @param array $allowed_html Allowed HTML elements + * @param array $allowed_protocols Allowed protocols to keep + * @return string Fixed HTML element + */ +function wp_kses_split2($string, $allowed_html, $allowed_protocols) { $string = wp_kses_stripslashes($string); if (substr($string, 0, 1) != '<') @@ -303,18 +450,26 @@ function wp_kses_split2($string, $allowed_html, $allowed_protocols) # No attributes are allowed for closing elements return wp_kses_attr("$slash$elem", $attrlist, $allowed_html, $allowed_protocols); -} # function wp_kses_split2 - -function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) -############################################################################### -# This function removes all attributes, if none are allowed for this element. -# If some are allowed it calls wp_kses_hair() to split them further, and then it -# builds up new HTML code from the data that kses_hair() returns. It also -# removes "<" and ">" characters, if there are any left. One more thing it -# does is to check if the tag has a closing XHTML slash, and if it does, -# it puts one in the returned code as well. -############################################################################### -{ +} + +/** + * wp_kses_attr() - Removes all attributes, if none are allowed for this element + * + * If some are allowed it calls wp_kses_hair() to split them further, and then + * it builds up new HTML code from the data that kses_hair() returns. It also + * removes "<" and ">" characters, if there are any left. One more thing it + * does is to check if the tag has a closing XHTML slash, and if it does, it + * puts one in the returned code as well. + * + * @since 1.0.0 + * + * @param string $element HTML element/tag + * @param string $attr HTML attributes from HTML element to closing HTML element tag + * @param array $allowed_html Allowed HTML elements + * @param array $allowed_protocols Allowed protocols to keep + * @return string Sanitized HTML element + */ +function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) { # Is there a closing XHTML slash at the end of the attributes? $xhtml_slash = ''; @@ -366,18 +521,25 @@ function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) $attr2 = preg_replace('/[<>]/', '', $attr2); return "<$element$attr2$xhtml_slash>"; -} # function wp_kses_attr - -function wp_kses_hair($attr, $allowed_protocols) -############################################################################### -# This function does a lot of work. It parses an attribute list into an array -# with attribute data, and tries to do the right thing even if it gets weird -# input. It will add quotes around attribute values that don't have any quotes -# or apostrophes around them, to make it easier to produce HTML code that will -# conform to W3C's HTML specification. It will also remove bad URL protocols -# from attribute values. -############################################################################### -{ +} + +/** + * wp_kses_hair() - Builds an attribute list from string containing attributes. + * + * This function does a lot of work. It parses an attribute list into an array + * with attribute data, and tries to do the right thing even if it gets weird + * input. It will add quotes around attribute values that don't have any quotes + * or apostrophes around them, to make it easier to produce HTML code that will + * conform to W3C's HTML specification. It will also remove bad URL protocols + * from attribute values. + * + * @since 1.0.0 + * + * @param string $attr Attribute list from HTML element to closing HTML element tag + * @param array $allowed_protocols Allowed protocols to keep + * @return array List of attributes after parsing + */ +function wp_kses_hair($attr, $allowed_protocols) { $attrarr = array (); $mode = 0; $attrname = ''; @@ -460,7 +622,7 @@ function wp_kses_hair($attr, $allowed_protocols) } # switch if ($working == 0) # not well formed, remove and try again - { + { $attr = wp_kses_html_error($attr); $mode = 0; } @@ -472,15 +634,23 @@ function wp_kses_hair($attr, $allowed_protocols) $attrarr[] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); return $attrarr; -} # function wp_kses_hair - -function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) -############################################################################### -# This function performs different checks for attribute values. The currently -# implemented checks are "maxlen", "minlen", "maxval", "minval" and "valueless" -# with even more checks to come soon. -############################################################################### -{ +} + +/** + * wp_kses_check_attr_val() - Performs different checks for attribute values. + * + * The currently implemented checks are "maxlen", "minlen", "maxval", "minval" + * and "valueless" with even more checks to come soon. + * + * @since 1.0.0 + * + * @param string $value Attribute value + * @param string $vless Whether the value is valueless or not. Use 'y' or 'n' + * @param string $checkname What $checkvalue is checking for. + * @param mixed $checkvalue What constraint the value should pass + * @return bool Whether check passes (true) or not (false) + */ +function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) { $ok = true; switch (strtolower($checkname)) { @@ -536,16 +706,23 @@ function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) } # switch return $ok; -} # function wp_kses_check_attr_val - -function wp_kses_bad_protocol($string, $allowed_protocols) -############################################################################### -# This function removes all non-allowed protocols from the beginning of -# $string. It ignores whitespace and the case of the letters, and it does -# understand HTML entities. It does its work in a while loop, so it won't be -# fooled by a string like "javascript:javascript:alert(57)". -############################################################################### -{ +} + +/** + * wp_kses_bad_protocol() - Sanitize string from bad protocols + * + * This function removes all non-allowed protocols from the beginning + * of $string. It ignores whitespace and the case of the letters, and + * it does understand HTML entities. It does its work in a while loop, + * so it won't be fooled by a string like "javascript:javascript:alert(57)". + * + * @since 1.0.0 + * + * @param string $string Content to filter bad protocols from + * @param array $allowed_protocols Allowed protocols to keep + * @return string Filtered content + */ +function wp_kses_bad_protocol($string, $allowed_protocols) { $string = wp_kses_no_null($string); $string = preg_replace('/\xad+/', '', $string); # deals with Opera "feature" $string2 = $string.'a'; @@ -556,34 +733,48 @@ function wp_kses_bad_protocol($string, $allowed_protocols) } # while return $string; -} # function wp_kses_bad_protocol +} -function wp_kses_no_null($string) -############################################################################### -# This function removes any NULL characters in $string. -############################################################################### -{ +/** + * wp_kses_no_null() - Removes any NULL characters in $string. + * + * @since 1.0.0 + * + * @param string $string + * @return string + */ +function wp_kses_no_null($string) { $string = preg_replace('/\0+/', '', $string); $string = preg_replace('/(\\\\0)+/', '', $string); return $string; -} # function wp_kses_no_null - -function wp_kses_stripslashes($string) -############################################################################### -# This function changes the character sequence \" to just " -# It leaves all other slashes alone. It's really weird, but the quoting from -# preg_replace(//e) seems to require this. -############################################################################### -{ +} + +/** + * wp_kses_stripslashes() - Strips slashes from in front of quotes + * + * This function changes the character sequence \" to just " + * It leaves all other slashes alone. It's really weird, but the + * quoting from preg_replace(//e) seems to require this. + * + * @since 1.0.0 + * + * @param string $string String to strip slashes + * @return string Fixed strings with quoted slashes + */ +function wp_kses_stripslashes($string) { return preg_replace('%\\\\"%', '"', $string); -} # function wp_kses_stripslashes +} -function wp_kses_array_lc($inarray) -############################################################################### -# This function goes through an array, and changes the keys to all lower case. -############################################################################### -{ +/** + * wp_kses_array_lc() - Goes through an array and changes the keys to all lower case. + * + * @since 1.0.0 + * + * @param array $inarray Unfiltered array + * @return array Fixed array with all lowercase keys + */ +function wp_kses_array_lc($inarray) { $outarray = array (); foreach ($inarray as $inkey => $inval) { @@ -597,42 +788,73 @@ function wp_kses_array_lc($inarray) } # foreach $inarray return $outarray; -} # function wp_kses_array_lc - -function wp_kses_js_entities($string) -############################################################################### -# This function removes the HTML JavaScript entities found in early versions of -# Netscape 4. -############################################################################### -{ +} + +/** + * wp_kses_js_entities() - Removes the HTML JavaScript entities found in early versions of Netscape 4. + * + * @since 1.0.0 + * + * @param string $string + * @return string + */ +function wp_kses_js_entities($string) { return preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string); -} # function wp_kses_js_entities - -function wp_kses_html_error($string) -############################################################################### -# This function deals with parsing errors in wp_kses_hair(). The general plan is -# to remove everything to and including some whitespace, but it deals with -# quotes and apostrophes as well. -############################################################################### -{ +} + +/** + * wp_kses_html_error() - Handles parsing errors in wp_kses_hair() + * + * The general plan is to remove everything to and including some + * whitespace, but it deals with quotes and apostrophes as well. + * + * @since 1.0.0 + * + * @param string $string + * @return string + */ +function wp_kses_html_error($string) { return preg_replace('/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $string); -} # function wp_kses_html_error - -function wp_kses_bad_protocol_once($string, $allowed_protocols) -############################################################################### -# This function searches for URL protocols at the beginning of $string, while -# handling whitespace and HTML entities. -############################################################################### -{ - return preg_replace('/^((&[^;]*;|[\sA-Za-z0-9])*)'.'(:|:|&#[Xx]3[Aa];)\s*/e', 'wp_kses_bad_protocol_once2("\\1", $allowed_protocols)', $string); -} # function wp_kses_bad_protocol_once - -function wp_kses_bad_protocol_once2($string, $allowed_protocols) -############################################################################### -# This function processes URL protocols, checks to see if they're in the white- -# list or not, and returns different data depending on the answer. -############################################################################### -{ +} + +/** + * wp_kses_bad_protocol_once() - Sanitizes content from bad protocols and other characters + * + * This function searches for URL protocols at the beginning of $string, + * while handling whitespace and HTML entities. + * + * @since 1.0.0 + * + * @param string $string Content to check for bad protocols + * @param string $allowed_protocols Allowed protocols + * @return string Sanitized content + */ +function wp_kses_bad_protocol_once($string, $allowed_protocols) { + global $_kses_allowed_protocols; + $_kses_allowed_protocols = $allowed_protocols; + + $string2 = preg_split('/:|:|:/i', $string, 2); + if ( isset($string2[1]) && !preg_match('%/\?%', $string2[0]) ) + $string = wp_kses_bad_protocol_once2($string2[0], $allowed_protocols) . trim($string2[1]); + else + $string = preg_replace_callback('/^((&[^;]*;|[\sA-Za-z0-9])*)'.'(:|:|&#[Xx]3[Aa];)\s*/', create_function('$matches', 'global $_kses_allowed_protocols; return wp_kses_bad_protocol_once2($matches[1], $_kses_allowed_protocols);'), $string); + + return $string; +} + +/** + * wp_kses_bad_protocol_once2() - Callback for wp_kses_bad_protocol_once() regular expression. + * + * This function processes URL protocols, checks to see if they're in the + * white-list or not, and returns different data depending on the answer. + * + * @since 1.0.0 + * + * @param string $string Content to check for bad protocols + * @param array $allowed_protocols Allowed protocols + * @return string Sanitized content + */ +function wp_kses_bad_protocol_once2($string, $allowed_protocols) { $string2 = wp_kses_decode_entities($string); $string2 = preg_replace('/\s/', '', $string2); $string2 = wp_kses_no_null($string2); @@ -651,14 +873,21 @@ function wp_kses_bad_protocol_once2($string, $allowed_protocols) return "$string2:"; else return ''; -} # function wp_kses_bad_protocol_once2 - -function wp_kses_normalize_entities($string) -############################################################################### -# This function normalizes HTML entities. It will convert "AT&T" to the correct -# "AT&T", ":" to ":", "&#XYZZY;" to "&#XYZZY;" and so on. -############################################################################### -{ +} + +/** + * wp_kses_normalize_entities() - Converts and fixes HTML entities + * + * This function normalizes HTML entities. It will convert "AT&T" to the + * correct "AT&T", ":" to ":", "&#XYZZY;" to "&#XYZZY;" + * and so on. + * + * @since 1.0.0 + * + * @param string $string Content to normalize entities + * @return string Content with normalized entities + */ +function wp_kses_normalize_entities($string) { # Disarm all entities by converting & to & $string = str_replace('&', '&', $string); @@ -666,48 +895,101 @@ function wp_kses_normalize_entities($string) # Change back the allowed entities in our entity whitelist $string = preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $string); - $string = preg_replace('/&#0*([0-9]{1,5});/e', 'wp_kses_normalize_entities2("\\1")', $string); + $string = preg_replace_callback('/&#0*([0-9]{1,5});/', create_function('$matches', 'return wp_kses_normalize_entities2($matches[1]);'), $string); $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string); return $string; -} # function wp_kses_normalize_entities - -function wp_kses_normalize_entities2($i) -############################################################################### -# This function helps wp_kses_normalize_entities() to only accept 16 bit values -# and nothing more for &#number; entities. -############################################################################### -{ +} + +/** + * wp_kses_normalize_entities2() - Callback for wp_kses_normalize_entities() regular expression + * + * This function helps wp_kses_normalize_entities() to only accept 16 bit + * values and nothing more for &#number; entities. + * + * @since 1.0.0 + * + * @param int $i Number encoded entity + * @return string Correctly encoded entity + */ +function wp_kses_normalize_entities2($i) { return (($i > 65535) ? "&#$i;" : "&#$i;"); -} # function wp_kses_normalize_entities2 - -function wp_kses_decode_entities($string) -############################################################################### -# This function decodes numeric HTML entities (A and A). It doesn't -# do anything with other entities like ä, but we don't need them in the -# URL protocol whitelisting system anyway. -############################################################################### -{ +} + +/** + * wp_kses_decode_entities() - Convert all entities to their character counterparts. + * + * This function decodes numeric HTML entities (A and A). It + * doesn't do anything with other entities like ä, but we don't need + * them in the URL protocol whitelisting system anyway. + * + * @since 1.0.0 + * + * @param string $string Content to change entities + * @return string Content after decoded entities + */ +function wp_kses_decode_entities($string) { $string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string); $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))', $string); return $string; -} # function wp_kses_decode_entities +} +/** + * wp_filter_kses() - Sanitize content with allowed HTML Kses rules + * + * @since 1.0.0 + * @uses $allowedtags + * + * @param string $data Content to filter + * @return string Filtered content + */ function wp_filter_kses($data) { global $allowedtags; return addslashes( wp_kses(stripslashes( $data ), $allowedtags) ); } +/** + * wp_filter_post_kses() - Sanitize content for allowed HTML tags for post content + * + * Post content refers to the page contents of the 'post' type and not + * $_POST data from forms. + * + * @since 2.0.0 + * @uses $allowedposttags + * + * @param string $data Post content to filter + * @return string Filtered post content with allowed HTML tags and attributes intact. + */ function wp_filter_post_kses($data) { global $allowedposttags; return addslashes ( wp_kses(stripslashes( $data ), $allowedposttags) ); } +/** + * wp_filter_nohtml_kses() - Strips all of the HTML in the content + * + * @since 2.1.0 + * + * @param string $data Content to strip all HTML from + * @return string Filtered content without any HTML + */ function wp_filter_nohtml_kses($data) { return addslashes ( wp_kses(stripslashes( $data ), array()) ); } +/** + * kses_init_filters() - Adds all Kses input form content filters + * + * All hooks have default priority. The wp_filter_kses() fucntion + * is added to the 'pre_comment_content' and 'title_save_pre' + * hooks. The wp_filter_post_kses() function is added to the + * 'content_save_pre', 'excerpt_save_pre', and 'content_filtered_save_pre' + * hooks. + * + * @since 2.0.0 + * @uses add_filter() See description for what functions are added to what hooks. + */ function kses_init_filters() { // Normal filtering. add_filter('pre_comment_content', 'wp_filter_kses'); @@ -719,6 +1001,19 @@ function kses_init_filters() { add_filter('content_filtered_save_pre', 'wp_filter_post_kses'); } +/** + * kses_remove_filters() - Removes all Kses input form content filters + * + * A quick procedural method to removing all of the filters + * that kses uses for content in WordPress Loop. + * + * Does not remove the kses_init() function from 'init' hook + * (priority is default). Also does not remove kses_init() + * function from 'set_current_user' hook (priority is also + * default). + * + * @since 2.0.6 + */ function kses_remove_filters() { // Normal filtering. remove_filter('pre_comment_content', 'wp_filter_kses'); @@ -730,6 +1025,22 @@ function kses_remove_filters() { remove_filter('content_filtered_save_pre', 'wp_filter_post_kses'); } +/** + * kses_init() - Sets up most of the Kses filters for input form content + * + * If you remove the kses_init() function from 'init' hook and + * 'set_current_user' (priority is default), then none of the + * Kses filter hooks will be added. + * + * First removes all of the Kses filters in case the current user + * does not need to have Kses filter the content. If the user does + * not have unfiltered html capability, then Kses filters are added. + * + * @uses kses_remove_filters() Removes the Kses filters + * @uses kses_init_filters() Adds the Kses filters back if the user + * does not have unfiltered HTML capability. + * @since 2.0.0 + */ function kses_init() { kses_remove_filters(); @@ -739,4 +1050,4 @@ function kses_init() { add_action('init', 'kses_init'); add_action('set_current_user', 'kses_init'); -?> +?> \ No newline at end of file diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 4dba6798..0584f9da 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -1,4 +1,32 @@ ngettext_noop('%s post', '%s posts'), + * 'page' => ngettext_noop('%s pages', '%s pages') + * ); + * ... + * $message = $messages[$type]; + * $usable_text = sprintf(__ngettext($message[0], $message[1], $count), $count); + * + * @since 2.5 + * @param $single Single form to be i18ned + * @param $plural Plural form to be i18ned + * @param $number Not used, here for compatibility with __ngettext, optional + * @param $domain Not used, here for compatibility with __ngettext, optional + * @return array array($single, $plural) + */ +function __ngettext_noop($single, $plural, $number=1, $domain = 'default') { + return array($single, $plural); +} + +/** + * load_textdomain() - Loads MO file into the list of domains + * + * If the domain already exists, the inclusion will fail. If the + * MO file is not readable, the inclusion will fail. + * + * On success, the mofile will be placed in the $l10n global by + * $domain and will be an gettext_reader object. + * + * @since 1.5.0 + * @uses $l10n Gets list of domain translated string (gettext_reader) objects + * @uses CacheFileReader Reads the MO file + * @uses gettext_reader Allows for retrieving translated strings + * + * @param string $domain Unique identifier for retrieving translated strings + * @param string $mofile Path to the .mo file + * @return null On failure returns null and also on success returns nothing. + */ function load_textdomain($domain, $mofile) { global $l10n; @@ -74,9 +253,15 @@ function load_textdomain($domain, $mofile) { $l10n[$domain] = new gettext_reader($input); } +/** + * load_default_textdomain() - Loads default translated strings based on locale + * + * Loads the .mo file in LANGDIR constant path from WordPress root. + * The translated (.mo) file is named based off of the locale. + * + * @since 1.5.0 + */ function load_default_textdomain() { - global $l10n; - $locale = get_locale(); if ( empty($locale) ) $locale = 'en_US'; @@ -86,6 +271,24 @@ function load_default_textdomain() { load_textdomain('default', $mofile); } +/** + * load_plugin_textdomain() - Loads the plugin's translated strings + * + * If the path is not given then it will be the root of the plugin + * directory. The .mo file should be named based on the domain with a + * dash followed by a dash, and then the locale exactly. + * + * The plugin may place all of the .mo files in another folder and set + * the $path based on the relative location from ABSPATH constant. The + * plugin may use the constant PLUGINDIR and/or plugin_basename() to + * get path of the plugin and then add the folder which holds the .mo + * files. + * + * @since 1.5.0 + * + * @param string $domain Unique identifier for retrieving translated strings + * @param string $path Optional. Path of the folder where the .mo files reside. + */ function load_plugin_textdomain($domain, $path = false) { $locale = get_locale(); if ( empty($locale) ) @@ -98,6 +301,18 @@ function load_plugin_textdomain($domain, $path = false) { load_textdomain($domain, $mofile); } +/** + * load_theme_textdomain() - Includes theme's translated strings for the theme + * + * If the current locale exists as a .mo file in the theme's root directory, it + * will be included in the translated strings by the $domain. + * + * The .mo files must be named based on the locale exactly. + * + * @since 1.5.0 + * + * @param string $domain Unique identifier for retrieving translated strings + */ function load_theme_textdomain($domain) { $locale = get_locale(); if ( empty($locale) ) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 6a0677b7..74da3e74 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -32,7 +32,7 @@ function permalink_anchor($mode = 'id') { global $post; switch ( strtolower($mode) ) { case 'title': - $title = sanitize_title($post->post_title) . '-' . $id; + $title = sanitize_title($post->post_title) . '-' . $post->ID; echo ''; break; case 'id': @@ -43,7 +43,7 @@ function permalink_anchor($mode = 'id') { } -function get_permalink($id = 0) { +function get_permalink($id = 0, $leavename=false) { $rewritecode = array( '%year%', '%monthnum%', @@ -51,11 +51,11 @@ function get_permalink($id = 0) { '%hour%', '%minute%', '%second%', - '%postname%', + $leavename? '' : '%postname%', '%post_id%', '%category%', '%author%', - '%pagename%' + $leavename? '' : '%pagename%', ); $post = &get_post($id); @@ -63,7 +63,7 @@ function get_permalink($id = 0) { if ( empty($post->ID) ) return FALSE; if ( $post->post_type == 'page' ) - return get_page_link($post->ID); + return get_page_link($post->ID, $leavename); elseif ($post->post_type == 'attachment') return get_attachment_link($post->ID); @@ -73,17 +73,28 @@ function get_permalink($id = 0) { $unixtime = strtotime($post->post_date); $category = ''; - if (strpos($permalink, '%category%') !== false) { + if ( strpos($permalink, '%category%') !== false ) { $cats = get_the_category($post->ID); if ( $cats ) usort($cats, '_usort_terms_by_ID'); // order by ID $category = $cats[0]->slug; if ( $parent=$cats[0]->parent ) $category = get_category_parents($parent, FALSE, '/', TRUE) . $category; + + // show default category in permalinks, without + // having to assign it explicitly + if ( empty($category) ) { + $default_category = get_category( get_option( 'default_category' ) ); + $category = is_wp_error( $default_category ) ? '' : $default_category->slug; + } + } + + $author = ''; + if ( strpos($permalink, '%author%') !== false ) { + $authordata = get_userdata($post->post_author); + $author = $authordata->user_nicename; } - $authordata = get_userdata($post->post_author); - $author = $authordata->user_nicename; $date = explode(" ",date('Y m d H i s', $unixtime)); $rewritereplace = array( @@ -114,7 +125,7 @@ function post_permalink($post_id = 0, $deprecated = '') { } // Respects page_on_front. Use this one. -function get_page_link($id = false) { +function get_page_link($id = false, $leavename = false) { global $post; $id = (int) $id; @@ -124,23 +135,25 @@ function get_page_link($id = false) { if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) $link = get_option('home'); else - $link = _get_page_link( $id ); + $link = _get_page_link( $id , $leavename ); return apply_filters('page_link', $link, $id); } // Ignores page_on_front. Internal use only. -function _get_page_link( $id = false ) { +function _get_page_link( $id = false, $leavename = false ) { global $post, $wp_rewrite; if ( !$id ) $id = (int) $post->ID; + else + $post = &get_post($id); $pagestruct = $wp_rewrite->get_page_permastruct(); - if ( '' != $pagestruct && 'draft' != $post->post_status ) { + if ( '' != $pagestruct && isset($post->post_status) && 'draft' != $post->post_status ) { $link = get_page_uri($id); - $link = str_replace('%pagename%', $link, $pagestruct); + $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct); $link = get_option('home') . "/$link"; $link = user_trailingslashit($link, 'page'); } else { @@ -166,8 +179,12 @@ function get_attachment_link($id = false) { $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front else $parentlink = get_permalink( $object->post_parent ); + if ( is_numeric($object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) + $name = 'attachment/' . $object->post_name; // // is paged so we use the explicit attachment marker + else + $name = $object->post_name; if (strpos($parentlink, '?') === false) - $link = trailingslashit($parentlink) . $object->post_name . '/'; + $link = trailingslashit($parentlink) . $name . '/'; } if (! $link ) { @@ -226,11 +243,8 @@ function get_day_link($year, $month, $day) { } } -function get_feed_link($feed='rss2') { +function get_feed_link($feed = '') { global $wp_rewrite; - $do_perma = 0; - $feed_url = get_option('siteurl'); - $comment_feed_url = $feed_url; $permalink = $wp_rewrite->get_feed_permastruct(); if ( '' != $permalink ) { @@ -239,13 +253,16 @@ function get_feed_link($feed='rss2') { $permalink = $wp_rewrite->get_comment_feed_permastruct(); } - if ( 'rss2' == $feed ) + if ( get_default_feed() == $feed ) $feed = ''; $permalink = str_replace('%feed%', $feed, $permalink); $permalink = preg_replace('#/+#', '/', "/$permalink"); $output = get_option('home') . user_trailingslashit($permalink, 'feed'); } else { + if ( empty($feed) ) + $feed = get_default_feed(); + if ( false !== strpos($feed, 'comments_') ) $feed = str_replace('comments_', 'comments-', $feed); @@ -255,15 +272,18 @@ function get_feed_link($feed='rss2') { return apply_filters('feed_link', $output, $feed); } -function get_post_comments_feed_link($post_id = '', $feed = 'rss2') { +function get_post_comments_feed_link($post_id = '', $feed = '') { global $id; if ( empty($post_id) ) $post_id = (int) $id; + if ( empty($feed) ) + $feed = get_default_feed(); + if ( '' != get_option('permalink_structure') ) { $url = trailingslashit( get_permalink($post_id) ) . 'feed'; - if ( 'rss2' != $feed ) + if ( $feed != get_default_feed() ) $url .= "/$feed"; $url = user_trailingslashit($url, 'single_feed'); } else { @@ -277,41 +297,188 @@ function get_post_comments_feed_link($post_id = '', $feed = 'rss2') { return apply_filters('post_comments_feed_link', $url); } -function get_edit_post_link( $id = 0 ) { - $post = &get_post( $id ); +/** post_comments_feed_link() - Output the comment feed link for a post. + * + * Prints out the comment feed link for a post. Link text is placed in the + * anchor. If no link text is specified, default text is used. If no post ID + * is specified, the current post is used. + * + * @package WordPress + * @subpackage Feed + * @since 2.5 + * + * @param string Descriptive text + * @param int Optional post ID. Default to current post. + * @return string Link to the comment feed for the current post +*/ +function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { + $url = get_post_comments_feed_link($post_id, $feed); + if ( empty($link_text) ) + $link_text = __('Comments Feed'); + + echo "$link_text"; +} - if ( $post->post_type == 'attachment' ) { +function get_author_feed_link( $author_id, $feed = '' ) { + $author_id = (int) $author_id; + $permalink_structure = get_option('permalink_structure'); + + if ( empty($feed) ) + $feed = get_default_feed(); + + if ( '' == $permalink_structure ) { + $link = get_option('home') . '?feed=rss2&author=' . $author_id; + } else { + $link = get_author_posts_url($author_id); + $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); + } + + $link = apply_filters('author_feed_link', $link); + + return $link; +} + +/** get_category_feed_link() - Get the feed link for a given category + * + * Returns a link to the feed for all post in a given category. A specific feed can be requested + * or left blank to get the default feed. + * + * @package WordPress + * @subpackage Feed + * @since 2.5 + * + * @param int $cat_id ID of a category + * @param string $feed Feed type + * @return string Link to the feed for the category specified by $cat_id +*/ +function get_category_feed_link($cat_id, $feed = '') { + $cat_id = (int) $cat_id; + + $category = get_category($cat_id); + + if ( empty($category) || is_wp_error($category) ) + return false; + + if ( empty($feed) ) + $feed = get_default_feed(); + + $permalink_structure = get_option('permalink_structure'); + + if ( '' == $permalink_structure ) { + $link = get_option('home') . "?feed=$feed&cat=" . $cat_id; + } else { + $link = get_category_link($cat_id); + if( $feed == get_default_feed() ) + $feed_link = 'feed'; + else + $feed_link = "feed/$feed"; + + $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); + } + + $link = apply_filters('category_feed_link', $link, $feed); + + return $link; +} + +function get_tag_feed_link($tag_id, $feed = '') { + $tag_id = (int) $tag_id; + + $tag = get_tag($tag_id); + + if ( empty($tag) || is_wp_error($tag) ) + return false; + + $permalink_structure = get_option('permalink_structure'); + + if ( empty($feed) ) + $feed = get_default_feed(); + + if ( '' == $permalink_structure ) { + $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug; + } else { + $link = get_tag_link($tag->term_id); + if ( $feed == get_default_feed() ) + $feed_link = 'feed'; + else + $feed_link = "feed/$feed"; + $link = $link . user_trailingslashit($feed_link, 'feed'); + } + + $link = apply_filters('tag_feed_link', $link, $feed); + + return $link; +} + +function get_search_feed_link($search_query = '', $feed = '') { + if ( empty($search_query) ) + $search = attribute_escape(get_search_query()); + else + $search = attribute_escape(stripslashes($search_query)); + + if ( empty($feed) ) + $feed = get_default_feed(); + + $link = get_option('home') . "?s=$search&feed=$feed"; + + $link = apply_filters('search_feed_link', $link); + + return $link; +} + +function get_search_comments_feed_link($search_query = '', $feed = '') { + if ( empty($search_query) ) + $search = attribute_escape(get_search_query()); + else + $search = attribute_escape(stripslashes($search_query)); + + if ( empty($feed) ) + $feed = get_default_feed(); + + $link = get_option('home') . "?s=$search&feed=comments-$feed"; + + $link = apply_filters('search_feed_link', $link); + + return $link; +} + +function get_edit_post_link( $id = 0 ) { + if ( !$post = &get_post( $id ) ) return; - } elseif ( $post->post_type == 'page' ) { + + switch ( $post->post_type ) : + case 'page' : if ( !current_user_can( 'edit_page', $post->ID ) ) return; - $file = 'page'; - } else { + $var = 'post'; + break; + case 'attachment' : + if ( !current_user_can( 'edit_post', $post->ID ) ) + return; + $file = 'media'; + $var = 'attachment_id'; + break; + default : if ( !current_user_can( 'edit_post', $post->ID ) ) return; - $file = 'post'; - } - - return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&post=' . $post->ID, $post->ID ); + $var = 'post'; + break; + endswitch; + + return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . "/wp-admin/$file.php?action=edit&$var=$post->ID", $post->ID ); } function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) { global $post; - if ( $post->post_type == 'attachment' ) { - return; - } elseif ( $post->post_type == 'page' ) { + if ( $post->post_type == 'page' ) { if ( !current_user_can( 'edit_page', $post->ID ) ) return; - - $file = 'page'; } else { if ( !current_user_can( 'edit_post', $post->ID ) ) return; - - $file = 'post'; } $link = '' . $link . ''; @@ -322,9 +489,7 @@ function get_edit_comment_link( $comment_id = 0 ) { $comment = &get_comment( $comment_id ); $post = &get_post( $comment->comment_post_ID ); - if ( $post->post_type == 'attachment' ) { - return; - } elseif ( $post->post_type == 'page' ) { + if ( $post->post_type == 'page' ) { if ( !current_user_can( 'edit_page', $post->ID ) ) return; } else { @@ -340,7 +505,6 @@ function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) { global $comment, $post; if ( $post->post_type == 'attachment' ) { - return; } elseif ( $post->post_type == 'page' ) { if ( !current_user_can( 'edit_page', $post->ID ) ) return; @@ -356,39 +520,14 @@ function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) { // Navigation links function get_previous_post($in_same_cat = false, $excluded_categories = '') { - global $post, $wpdb; - - if( empty($post) || !is_single() || is_attachment() ) - return null; - - $current_post_date = $post->post_date; - - $join = ''; - if ( $in_same_cat ) { - $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id "; - $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=tt_ids'); - $join .= ' AND (tr.term_taxonomy_id = ' . intval($cat_array[0]); - for ( $i = 1; $i < (count($cat_array)); $i++ ) { - $join .= ' OR tr.term_taxonomy_id = ' . intval($cat_array[$i]); - } - $join .= ')'; - } - - $sql_exclude_cats = ''; - if ( !empty($excluded_categories) ) { - $blah = explode(' and ', $excluded_categories); - $posts_in_ex_cats = get_objects_in_term($blah, 'category'); - $posts_in_ex_cats_sql = 'AND p.ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; - } - - $join = apply_filters( 'get_previous_post_join', $join, $in_same_cat, $excluded_categories ); - $where = apply_filters( 'get_previous_post_where', "WHERE p.post_date < '$current_post_date' AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql", $in_same_cat, $excluded_categories ); - $sort = apply_filters( 'get_previous_post_sort', 'ORDER BY p.post_date DESC LIMIT 1' ); - - return @$wpdb->get_row("SELECT p.ID, p.post_title FROM $wpdb->posts AS p $join $where $sort"); + return get_adjacent_post($in_same_cat, $excluded_categories); } function get_next_post($in_same_cat = false, $excluded_categories = '') { + return get_adjacent_post($in_same_cat, $excluded_categories, false); +} + +function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true) { global $post, $wpdb; if( empty($post) || !is_single() || is_attachment() ) @@ -397,58 +536,53 @@ function get_next_post($in_same_cat = false, $excluded_categories = '') { $current_post_date = $post->post_date; $join = ''; - if ( $in_same_cat ) { - $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id "; - $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=tt_ids'); - $join .= ' AND (tr.term_taxonomy_id = ' . intval($cat_array[0]); - for ( $i = 1; $i < (count($cat_array)); $i++ ) { - $join .= ' OR tr.term_taxonomy_id = ' . intval($cat_array[$i]); + $posts_in_ex_cats_sql = ''; + if ( $in_same_cat || !empty($excluded_categories) ) { + $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; + + if ( $in_same_cat ) { + $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids'); + $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode($cat_array, ',') . ')'; } - $join .= ')'; - } - $sql_exclude_cats = ''; - if ( !empty($excluded_categories) ) { - $blah = explode(' and ', $excluded_categories); - $posts_in_ex_cats = get_objects_in_term($blah, 'category'); - $posts_in_ex_cats_sql = 'AND p.ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; + $posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'"; + if ( !empty($excluded_categories) ) { + $excluded_categories = array_map('intval', explode(' and ', $excluded_categories)); + if ( !empty($cat_array) ) { + $excluded_categories = array_diff($excluded_categories, $cat_array); + $posts_in_ex_cats_sql = ''; + } + + if ( !empty($excluded_categories) ) { + $posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')'; + } + } } - $join = apply_filters( 'get_next_post_join', $join, $in_same_cat, $excluded_categories ); - $where = apply_filters( 'get_next_post_where', "WHERE p.post_date > '$current_post_date' AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql AND p.ID != $post->ID", $in_same_cat, $excluded_categories ); - $sort = apply_filters( 'get_next_post_sort', 'ORDER BY p.post_date ASC LIMIT 1' ); + $adjacent = $previous ? 'previous' : 'next'; + $op = $previous ? '<' : '>'; + $order = $previous ? 'DESC' : 'ASC'; - return @$wpdb->get_row("SELECT p.ID, p.post_title FROM $wpdb->posts AS p $join $where $sort"); -} + $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories ); + $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date), $in_same_cat, $excluded_categories ); + $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); + return $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort"); +} function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { - - if ( is_attachment() ) - $post = & get_post($GLOBALS['post']->post_parent); - else - $post = get_previous_post($in_same_cat, $excluded_categories); - - if ( !$post ) - return; - - $title = $post->post_title; - - if ( empty($post->post_title) ) - $title = __('Previous Post'); - - $title = apply_filters('the_title', $title, $post); - $string = ''; - $link = str_replace('%title', $title, $link); - $link = $pre . $string . $link . ''; - - $format = str_replace('%link', $link, $format); - - echo $format; + adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true); } function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { - $post = get_next_post($in_same_cat, $excluded_categories); + adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false); +} + +function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { + if ( $previous && is_attachment() ) + $post = & get_post($GLOBALS['post']->post_parent); + else + $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); if ( !$post ) return; @@ -456,12 +590,13 @@ function next_post_link($format='%link »', $link='%title', $in_same_cat = $title = $post->post_title; if ( empty($post->post_title) ) - $title = __('Next Post'); + $title = $previous ? __('Previous Post') : __('Next Post'); $title = apply_filters('the_title', $title, $post); - $string = ''; + $string = ''; $link = str_replace('%title', $title, $link); $link = $string . $link . ''; + $format = str_replace('%link', $link, $format); echo $format; @@ -475,7 +610,7 @@ function get_pagenum_link($pagenum = 1) { $request = remove_query_arg( 'paged' ); $home_root = parse_url(get_option('home')); - $home_root = $home_root['path']; + $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : ''; $home_root = preg_quote( trailingslashit( $home_root ), '|' ); $request = preg_replace('|^'. $home_root . '|', '', $request); @@ -493,14 +628,14 @@ function get_pagenum_link($pagenum = 1) { $qs_regex = '|\?.*?$|'; preg_match( $qs_regex, $request, $qs_match ); - if ( $qs_match[0] ) { + if ( !empty( $qs_match[0] ) ) { $query_string = $qs_match[0]; $request = preg_replace( $qs_regex, '', $request ); } else { $query_string = ''; } - $request = preg_replace( '|page/(.+)/?$|', '', $request); + $request = preg_replace( '|page/\d+/?$|', '', $request); $request = preg_replace( '|^index\.php|', '', $request); $request = ltrim($request, '/'); @@ -516,11 +651,13 @@ function get_pagenum_link($pagenum = 1) { $result = $base . $request . $query_string; } + $result = apply_filters('get_pagenum_link', $result); + return $result; } function get_next_posts_page_link($max_page = 0) { - global $paged, $pagenow; + global $paged; if ( !is_single() ) { if ( !$paged ) @@ -536,7 +673,7 @@ function next_posts($max_page = 0) { } function next_posts_link($label='Next Page »', $max_page=0) { - global $paged, $wpdb, $wp_query; + global $paged, $wp_query; if ( !$max_page ) { $max_page = $wp_query->max_num_pages; } @@ -551,7 +688,7 @@ function next_posts_link($label='Next Page »', $max_page=0) { } function get_previous_posts_page_link() { - global $paged, $pagenow; + global $paged; if ( !is_single() ) { $nextpage = intval($paged) - 1; diff --git a/wp-includes/locale.php b/wp-includes/locale.php index 70f3b03b..5f24c543 100644 --- a/wp-includes/locale.php +++ b/wp-includes/locale.php @@ -1,20 +1,110 @@ weekday[0] = __('Sunday'); @@ -107,35 +197,117 @@ class WP_Locale { } + /** + * Retrieve the full translated weekday word. + * + * Week starts on translated Sunday and can be fetched + * by using 0 (zero). So the week starts with 0 (zero) + * and ends on Saturday with is fetched by using 6 (six). + * + * @since 2.1.0 + * @access public + * + * @param int $weekday_number 0 for Sunday through 6 Saturday + * @return string Full translated weekday + */ function get_weekday($weekday_number) { return $this->weekday[$weekday_number]; } + /** + * Retrieve the translated weekday initial. + * + * The weekday initial is retrieved by the translated + * full weekday word. When translating the weekday initial + * pay attention to make sure that the starting letter does + * not conflict. + * + * @since 2.1.0 + * @access public + * + * @param string $weekday_name + * @return string + */ function get_weekday_initial($weekday_name) { return $this->weekday_initial[$weekday_name]; } + /** + * Retrieve the translated weekday abbreviation. + * + * The weekday abbreviation is retrieved by the translated + * full weekday word. + * + * @since 2.1.0 + * @access public + * + * @param string $weekday_name Full translated weekday word + * @return string Translated weekday abbreviation + */ function get_weekday_abbrev($weekday_name) { return $this->weekday_abbrev[$weekday_name]; } + /** + * Retrieve the full translated month by month number. + * + * The $month_number parameter has to be a string + * because it must have the '0' in front of any number + * that is less than 10. Starts from '01' and ends at + * '12'. + * + * You can use an integer instead and it will add the + * '0' before the numbers less than 10 for you. + * + * @since 2.1.0 + * @access public + * + * @param string|int $month_number '01' through '12' + * @return string Translated full month name + */ function get_month($month_number) { return $this->month[zeroise($month_number, 2)]; } - function get_month_initial($month_name) { - return $this->month_initial[$month_name]; - } - + /** + * Retrieve translated version of month abbreviation string. + * + * The $month_name parameter is expected to be the translated or + * translatable version of the month. + * + * @since 2.1.0 + * @access public + * + * @param string $month_name Translated month to get abbreviated version + * @return string Translated abbreviated month + */ function get_month_abbrev($month_name) { return $this->month_abbrev[$month_name]; } + /** + * Retrieve translated version of meridiem string. + * + * The $meridiem parameter is expected to not be translated. + * + * @since 2.1.0 + * @access public + * + * @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version. + * @return string Translated version + */ function get_meridiem($meridiem) { return $this->meridiem[$meridiem]; } - // Global variables are deprecated. For backwards compatibility only. + /** + * Global variables are deprecated. For backwards compatibility only. + * + * @deprecated For backwards compatibility only. + * @access private + * + * @since 2.1.0 + */ function register_globals() { $GLOBALS['weekday'] = $this->weekday; $GLOBALS['weekday_initial'] = $this->weekday_initial; @@ -144,6 +316,15 @@ class WP_Locale { $GLOBALS['month_abbrev'] = $this->month_abbrev; } + /** + * PHP4 style constructor which calls helper methods to set up object variables + * + * @uses WP_Locale::init() + * @uses WP_Locale::register_globals() + * @since 2.1.0 + * + * @return WP_Locale + */ function WP_Locale() { $this->init(); $this->register_globals(); diff --git a/wp-includes/media.php b/wp-includes/media.php new file mode 100644 index 00000000..f43a2f0e --- /dev/null +++ b/wp-includes/media.php @@ -0,0 +1,480 @@ + tag. Empty values will be omitted. +function image_hwstring($width, $height) { + $out = ''; + if ($width) + $out .= 'width="'.intval($width).'" '; + if ($height) + $out .= 'height="'.intval($height).'" '; + return $out; +} + +// Scale an image to fit a particular size (such as 'thumb' or 'medium'), and return an image URL, height and width. +// The URL might be the original image, or it might be a resized version. This function won't create a new resized copy, it will just return an already resized one if it exists. +// returns an array($url, $width, $height) +function image_downsize($id, $size = 'medium') { + + if ( !wp_attachment_is_image($id) ) + return false; + + $img_url = wp_get_attachment_url($id); + $meta = wp_get_attachment_metadata($id); + $width = $height = 0; + + // plugins can use this to provide resize services + if ( $out = apply_filters('image_downsize', false, $id, $size) ) + return $out; + + // try for a new style intermediate size + if ( $intermediate = image_get_intermediate_size($id, $size) ) { + $img_url = str_replace(basename($img_url), $intermediate['file'], $img_url); + $width = $intermediate['width']; + $height = $intermediate['height']; + } + elseif ( $size == 'thumbnail' ) { + // fall back to the old thumbnail + if ( $thumb_file = wp_get_attachment_thumb_file() && $info = getimagesize($thumb_file) ) { + $img_url = str_replace(basename($img_url), basename($thumb_file), $img_url); + $width = $info[0]; + $height = $info[1]; + } + } + if ( !$width && !$height && isset($meta['width'], $meta['height']) ) { + // any other type: use the real image and constrain it + list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'], $size ); + } + + if ( $img_url) + return array( $img_url, $width, $height ); + return false; + +} + +// return an tag for the given image attachment, scaling it down if requested +function get_image_tag($id, $alt, $title, $align, $size='medium') { + + list( $img_src, $width, $height ) = image_downsize($id, $size); + $hwstring = image_hwstring($width, $height); + + $html = ''.attribute_escape($alt).''; + + $url = ''; + $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size ); + + return $html; +} + +// same as wp_shrink_dimensions, except the max parameters are optional. +// if either width or height are empty, no constraint is applied on that dimension. +function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) { + if ( !$max_width and !$max_height ) + return array( $current_width, $current_height ); + + $width_ratio = $height_ratio = 1.0; + + if ( $max_width > 0 && $current_width > $max_width ) + $width_ratio = $max_width / $current_width; + + if ( $max_height > 0 && $current_height > $max_height ) + $height_ratio = $max_height / $current_height; + + // the smaller ratio is the one we need to fit it to the constraining box + $ratio = min( $width_ratio, $height_ratio ); + + return array( intval($current_width * $ratio), intval($current_height * $ratio) ); +} + +// calculate dimensions and coordinates for a resized image that fits within a specified width and height +// if $crop is true, the largest matching central portion of the image will be cropped out and resized to the required size +function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop=false) { + + if ($orig_w <= 0 || $orig_h <= 0) + return false; + // at least one of dest_w or dest_h must be specific + if ($dest_w <= 0 && $dest_h <= 0) + return false; + + if ( $crop ) { + // crop the largest possible portion of the original image that we can size to $dest_w x $dest_h + $aspect_ratio = $orig_w / $orig_h; + $new_w = min($dest_w, $orig_w); + $new_h = min($dest_h, $orig_h); + if (!$new_w) { + $new_w = intval($new_h * $aspect_ratio); + } + if (!$new_h) { + $new_h = intval($new_w / $aspect_ratio); + } + + $size_ratio = max($new_w / $orig_w, $new_h / $orig_h); + + $crop_w = ceil($new_w / $size_ratio); + $crop_h = ceil($new_h / $size_ratio); + + $s_x = floor(($orig_w - $crop_w)/2); + $s_y = floor(($orig_h - $crop_h)/2); + } + else { + // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box + $crop_w = $orig_w; + $crop_h = $orig_h; + + $s_x = 0; + $s_y = 0; + + list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h ); + } + + // if the resulting image would be the same size or larger we don't want to resize it + if ($new_w >= $orig_w && $new_h >= $orig_h) + return false; + + // the return array matches the parameters to imagecopyresampled() + // int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h + return array(0, 0, $s_x, $s_y, $new_w, $new_h, $crop_w, $crop_h); + +} + +// Scale down an image to fit a particular size and save a new copy of the image +function image_resize( $file, $max_w, $max_h, $crop=false, $suffix=null, $dest_path=null, $jpeg_quality=90) { + + $image = wp_load_image( $file ); + if ( !is_resource( $image ) ) + return new WP_Error('error_loading_image', $image); + + list($orig_w, $orig_h, $orig_type) = getimagesize( $file ); + $dims = image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop); + if (!$dims) + return $dims; + list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims; + + $newimage = imagecreatetruecolor( $dst_w, $dst_h); + + // preserve PNG transparency + if ( IMAGETYPE_PNG == $orig_type && function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) { + imagealphablending( $newimage, false); + imagesavealpha( $newimage, true); + } + + imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); + + // we don't need the original in memory anymore + imagedestroy( $image ); + + // $suffix will be appended to the destination filename, just before the extension + if ( !$suffix ) + $suffix = "{$dst_w}x{$dst_h}"; + + $info = pathinfo($file); + $dir = $info['dirname']; + $ext = $info['extension']; + $name = basename($file, ".{$ext}"); + if ( !is_null($dest_path) and $_dest_path = realpath($dest_path) ) + $dir = $_dest_path; + $destfilename = "{$dir}/{$name}-{$suffix}.{$ext}"; + + if ( $orig_type == IMAGETYPE_GIF ) { + if (!imagegif( $newimage, $destfilename ) ) + return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); + } + elseif ( $orig_type == IMAGETYPE_PNG ) { + if (!imagepng( $newimage, $destfilename ) ) + return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); + } + else { + // all other formats are converted to jpg + $destfilename = "{$dir}/{$name}-{$suffix}.jpg"; + if (!imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality ) ) ) + return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); + } + + imagedestroy( $newimage ); + + // Set correct file permissions + $stat = stat( dirname( $destfilename )); + $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits + @ chmod( $destfilename, $perms ); + + return $destfilename; +} + +// resize an image to make a thumbnail or intermediate size, and return metadata describing the new copy +// returns false if no image was created +function image_make_intermediate_size($file, $width, $height, $crop=false) { + if ( $width || $height ) { + $resized_file = image_resize($file, $width, $height, $crop); + if ( !is_wp_error($resized_file) && $resized_file && $info = getimagesize($resized_file) ) { + $resized_file = apply_filters('image_make_intermediate_size', $resized_file); + return array( + 'file' => basename( $resized_file ), + 'width' => $info[0], + 'height' => $info[1], + ); + } + } + return false; +} + +function image_get_intermediate_size($post_id, $size='thumbnail') { + if ( !$imagedata = wp_get_attachment_metadata( $post_id ) ) + return false; + + // get the best one for a specified set of dimensions + if ( is_array($size) && !empty($imagedata['sizes']) ) { + foreach ( $imagedata['sizes'] as $_size => $data ) { + // already cropped to width or height; so use this size + if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) { + $file = $data['file']; + list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); + return compact( 'file', 'width', 'height' ); + } + // add to lookup table: area => size + $areas[$data['width'] * $data['height']] = $_size; + } + if ( !$size || !empty($areas) ) { + // find for the smallest image not smaller than the desired size + ksort($areas); + foreach ( $areas as $_size ) { + $data = $imagedata['sizes'][$_size]; + if ( $data['width'] >= $size[0] || $data['height'] >= $size[1] ) { + $file = $data['file']; + list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); + return compact( 'file', 'width', 'height' ); + } + } + } + } + + if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) ) + return false; + + $data = $imagedata['sizes'][$size]; + // include the full filesystem path of the intermediate file + if ( empty($data['path']) && !empty($data['file']) ) { + $file_url = wp_get_attachment_url($post_id); + $data['path'] = path_join( dirname($imagedata['file']), $data['file'] ); + $data['url'] = path_join( dirname($file_url), $data['file'] ); + } + return $data; +} + +// get an image to represent an attachment - a mime icon for files, thumbnail or intermediate size for images +// returns an array (url, width, height), or false if no image is available +function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) { + + // get a thumbnail or intermediate image if there is one + if ( $image = image_downsize($attachment_id, $size) ) + return $image; + + if ( $icon && $src = wp_mime_type_icon($attachment_id) ) { + $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' ); + $src_file = $icon_dir . '/' . basename($src); + @list($width, $height) = getimagesize($src_file); + } + if ( $src && $width && $height ) + return array( $src, $width, $height ); + return false; +} + +// as per wp_get_attachment_image_src, but returns an tag +function wp_get_attachment_image($attachment_id, $size='thumbnail', $icon = false) { + + $html = ''; + $image = wp_get_attachment_image_src($attachment_id, $size, $icon); + if ( $image ) { + list($src, $width, $height) = $image; + $hwstring = image_hwstring($width, $height); + if ( is_array($size) ) + $size = join('x', $size); + $html = ''; + } + + return $html; +} + +add_shortcode('gallery', 'gallery_shortcode'); + +function gallery_shortcode($attr) { + global $post; + + // Allow plugins/themes to override the default gallery template. + $output = apply_filters('post_gallery', '', $attr); + if ( $output != '' ) + return $output; + + // We're trusting author input, so let's at least make sure it looks like a valid orderby statement + if ( isset( $attr['orderby'] ) ) { + $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); + if ( !$attr['orderby'] ) + unset( $attr['orderby'] ); + } + + extract(shortcode_atts(array( + 'orderby' => 'menu_order ASC, ID ASC', + 'id' => $post->ID, + 'itemtag' => 'dl', + 'icontag' => 'dt', + 'captiontag' => 'dd', + 'columns' => 3, + 'size' => 'thumbnail', + ), $attr)); + + $id = intval($id); + $attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby={$orderby}"); + + if ( empty($attachments) ) + return ''; + + if ( is_feed() ) { + $output = "\n"; + foreach ( $attachments as $id => $attachment ) + $output .= wp_get_attachment_link($id, $size, true) . "\n"; + return $output; + } + + $listtag = tag_escape($listtag); + $itemtag = tag_escape($itemtag); + $captiontag = tag_escape($captiontag); + $columns = intval($columns); + $itemwidth = $columns > 0 ? floor(100/$columns) : 100; + + $output = apply_filters('gallery_style', " + + + \n"; + + return $output; +} + +function previous_image_link() { + adjacent_image_link(true); +} + +function next_image_link() { + adjacent_image_link(false); +} + +function adjacent_image_link($prev = true) { + global $post; + $post = get_post($post); + $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=menu_order ASC, ID ASC")); + + foreach ( $attachments as $k => $attachment ) + if ( $attachment->ID == $post->ID ) + break; + + $k = $prev ? $k - 1 : $k + 1; + + if ( isset($attachments[$k]) ) + echo wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true); +} + +function get_attachment_taxonomies($attachment) { + if ( is_int( $attachment ) ) + $attachment = get_post($attachment); + else if ( is_array($attachment) ) + $attachment = (object) $attachment; + + if ( ! is_object($attachment) ) + return array(); + + $filename = basename($attachment->guid); + + $objects = array('attachment'); + + if ( false !== strpos($filename, '.') ) + $objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1); + if ( !empty($attachment->post_mime_type) ) { + $objects[] = 'attachment:' . $attachment->post_mime_type; + if ( false !== strpos($attachment->post_mime_type, '/') ) + foreach ( explode('/', $attachment->post_mime_type) as $token ) + if ( !empty($token) ) + $objects[] = "attachment:$token"; + } + + $taxonomies = array(); + foreach ( $objects as $object ) + if ( $taxes = get_object_taxonomies($object) ) + $taxonomies = array_merge($taxonomies, $taxes); + + return array_unique($taxonomies); +} + +?> diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 6cff71d2..1a2bdc26 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1,15 +1,47 @@ get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id' LIMIT 1") ) + if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id)) ) return false; - $show = $wpdb->hide_errors(); - $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'"); - $wpdb->show_errors($show); - - if ($metavalues) { - foreach ( $metavalues as $meta ) { - $value = maybe_unserialize($meta->meta_value); - $user->{$meta->meta_key} = $value; - - // We need to set user_level from meta, not row - if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) - $user->user_level = $meta->meta_value; - } // end foreach - } //end if - - // For backwards compat. - if ( isset($user->first_name) ) - $user->user_firstname = $user->first_name; - if ( isset($user->last_name) ) - $user->user_lastname = $user->last_name; - if ( isset($user->description) ) - $user->user_description = $user->description; - - wp_cache_add($user_id, $user, 'users'); - wp_cache_add($user->user_login, $user_id, 'userlogins'); + _fill_user($user); + return $user; } endif; if ( !function_exists('update_user_cache') ) : +/** + * update_user_cache() - Updates a users cache when overridden by a plugin + * + * Core function does nothing. + * + * @since 1.5 + * + * @return bool Only returns true + */ function update_user_cache() { return true; } endif; if ( !function_exists('get_userdatabylogin') ) : +/** + * get_userdatabylogin() - Retrieve user info by login name + * + * @since 0.71 + * + * @param string $user_login User's username + * @return bool|object False on failure, User DB row object + */ function get_userdatabylogin($user_login) { global $wpdb; $user_login = sanitize_user( $user_login ); @@ -116,22 +170,92 @@ function get_userdatabylogin($user_login) { return false; $user_id = wp_cache_get($user_login, 'userlogins'); - $userdata = wp_cache_get($user_id, 'users'); - if ( $userdata ) - return $userdata; + $user = false; + if ( false !== $user_id ) + $user = wp_cache_get($user_id, 'users'); - $user_login = $wpdb->escape($user_login); + if ( false !== $user ) + return $user; - if ( !$user_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_login'") ) + if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_login = %s", $user_login)) ) return false; - $user = get_userdata($user_ID); + _fill_user($user); + + return $user; +} +endif; + +if ( !function_exists('get_user_by_email') ) : +/** + * get_user_by_email() - Retrieve user info by email + * + * @since 2.5 + * + * @param string $email User's email address + * @return bool|object False on failure, User DB row object + */ +function get_user_by_email($email) { + global $wpdb; + + $user_id = wp_cache_get($email, 'useremail'); + + $user = false; + if ( false !== $user_id ) + $user = wp_cache_get($user_id, 'users'); + + if ( false !== $user ) + return $user; + + if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_email = %s", $email)) ) + return false; + + _fill_user($user); + return $user; } endif; if ( !function_exists( 'wp_mail' ) ) : +/** + * wp_mail() - Function to send mail, similar to PHP's mail + * + * A true return value does not automatically mean that the + * user received the email successfully. It just only means + * that the method used was able to process the request + * without any errors. + * + * Using the two 'wp_mail_from' and 'wp_mail_from_name' hooks + * allow from creating a from address like 'Name ' + * when both are set. If just 'wp_mail_from' is set, then just + * the email address will be used with no name. + * + * The default content type is 'text/plain' which does not + * allow using HTML. However, you can set the content type + * of the email by using the 'wp_mail_content_type' filter. + * + * The default charset is based on the charset used on the + * blog. The charset can be set using the 'wp_mail_charset' + * filter. + * + * @since 1.2.1 + * @uses apply_filters() Calls 'wp_mail' hook on an array of all of the parameters. + * @uses apply_filters() Calls 'wp_mail_from' hook to get the from email address. + * @uses apply_filters() Calls 'wp_mail_from_name' hook to get the from address name. + * @uses apply_filters() Calls 'wp_mail_content_type' hook to get the email content type. + * @uses apply_filters() Calls 'wp_mail_charset' hook to get the email charset + * @uses do_action_ref_array() Calls 'phpmailer_init' hook on the reference to + * phpmailer object. + * @uses PHPMailer + * @ + * + * @param string $to Email address to send message + * @param string $subject Email subject + * @param string $message Message contents + * @param string|array $headers Optional. Additional headers. + * @return bool Whether the email contents were sent successfully. + */ function wp_mail( $to, $subject, $message, $headers = '' ) { // Compact the input, apply the filters, and extract them back out extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers' ) ) ); @@ -276,41 +400,192 @@ function wp_mail( $to, $subject, $message, $headers = '' ) { } endif; -if ( !function_exists('wp_login') ) : -function wp_login($username, $password, $already_md5 = false) { - global $wpdb, $error; - +/** + * wp_authenticate() - Checks a user's login information and logs them in if it checks out + * @since 2.5 + * + * @param string $username User's username + * @param string $password User's password + * @return WP_Error|WP_User WP_User object if login successful, otherwise WP_Error object. + */ +if ( !function_exists('wp_authenticate') ) : +function wp_authenticate($username, $password) { $username = sanitize_user($username); if ( '' == $username ) + return new WP_Error('empty_username', __('ERROR: The username field is empty.')); + + if ( '' == $password ) + return new WP_Error('empty_password', __('ERROR: The password field is empty.')); + + $user = get_userdatabylogin($username); + + if ( !$user || ($user->user_login != $username) ) { + do_action( 'wp_login_failed', $username ); + return new WP_Error('invalid_username', __('ERROR: Invalid username.')); + } + + $user = apply_filters('wp_authenticate_user', $user, $password); + if ( is_wp_error($user) ) { + do_action( 'wp_login_failed', $username ); + return $user; + } + + if ( !wp_check_password($password, $user->user_pass, $user->ID) ) { + do_action( 'wp_login_failed', $username ); + return new WP_Error('incorrect_password', __('ERROR: Incorrect password.')); + } + + return new WP_User($user->ID); +} +endif; + +/** + * wp_logout() - Log the current user out + * @since 2.5 + * + */ +if ( !function_exists('wp_logout') ) : +function wp_logout() { + wp_clear_auth_cookie(); + do_action('wp_logout'); +} +endif; + +if ( !function_exists('wp_validate_auth_cookie') ) : +/** + * wp_validate_auth_cookie() - Validates authentication cookie + * + * The checks include making sure that the authentication cookie + * is set and pulling in the contents (if $cookie is not used). + * + * Makes sure the cookie is not expired. Verifies the hash in + * cookie is what is should be and compares the two. + * + * @since 2.5 + * + * @param string $cookie Optional. If used, will validate contents instead of cookie's + * @return bool|int False if invalid cookie, User ID if valid. + */ +function wp_validate_auth_cookie($cookie = '') { + if ( empty($cookie) ) { + if ( empty($_COOKIE[AUTH_COOKIE]) ) + return false; + $cookie = $_COOKIE[AUTH_COOKIE]; + } + + $cookie_elements = explode('|', $cookie); + if ( count($cookie_elements) != 3 ) return false; - if ( '' == $password ) { - $error = __('ERROR: The password field is empty.'); + list($username, $expiration, $hmac) = $cookie_elements; + + $expired = $expiration; + + // Allow a grace period for POST and AJAX requests + if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] ) + $expired += 3600; + + // Quick check to see if an honest cookie has expired + if ( $expired < time() ) return false; - } - $login = get_userdatabylogin($username); - //$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); + $key = wp_hash($username . '|' . $expiration); + $hash = hash_hmac('md5', $username . '|' . $expiration, $key); - if (!$login) { - $error = __('ERROR: Invalid username.'); + if ( $hmac != $hash ) return false; + + $user = get_userdatabylogin($username); + if ( ! $user ) + return false; + + return $user->ID; +} +endif; + +if ( !function_exists('wp_generate_auth_cookie') ) : +/** + * wp_generate_auth_cookie() - Generate authentication cookie contents + * + * @since 2.5 + * @uses apply_filters() Calls 'auth_cookie' hook on $cookie contents, User ID + * and expiration of cookie. + * + * @param int $user_id User ID + * @param int $expiration Cookie expiration in seconds + * @return string Authentication cookie contents + */ +function wp_generate_auth_cookie($user_id, $expiration) { + $user = get_userdata($user_id); + + $key = wp_hash($user->user_login . '|' . $expiration); + $hash = hash_hmac('md5', $user->user_login . '|' . $expiration, $key); + + $cookie = $user->user_login . '|' . $expiration . '|' . $hash; + + return apply_filters('auth_cookie', $cookie, $user_id, $expiration); +} +endif; + +if ( !function_exists('wp_set_auth_cookie') ) : +/** + * wp_set_auth_cookie() - Sets the authentication cookies based User ID + * + * The $remember parameter increases the time that the cookie will + * be kept. The default the cookie is kept without remembering is + * two days. When $remember is set, the cookies will be kept for + * 14 days or two weeks. + * + * @since 2.5 + * + * @param int $user_id User ID + * @param bool $remember Whether to remember the user or not + */ +function wp_set_auth_cookie($user_id, $remember = false) { + if ( $remember ) { + $expiration = $expire = time() + 1209600; } else { - // If the password is already_md5, it has been double hashed. - // Otherwise, it is plain text. - if ( ($already_md5 && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) { - return true; - } else { - $error = __('ERROR: Incorrect password.'); - $pwd = ''; - return false; - } + $expiration = time() + 172800; + $expire = 0; } + + $cookie = wp_generate_auth_cookie($user_id, $expiration); + + do_action('set_auth_cookie', $cookie, $expire); + + setcookie(AUTH_COOKIE, $cookie, $expire, COOKIEPATH, COOKIE_DOMAIN); + if ( COOKIEPATH != SITECOOKIEPATH ) + setcookie(AUTH_COOKIE, $cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN); +} +endif; + +if ( !function_exists('wp_clear_auth_cookie') ) : +/** + * wp_clear_auth_cookie() - Deletes all of the cookies associated with authentication + * + * @since 2.5 + */ +function wp_clear_auth_cookie() { + setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); + setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); + + // Old cookies + setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); + setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); + setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); + setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); } endif; if ( !function_exists('is_user_logged_in') ) : +/** + * is_user_logged_in() - Checks if the current visitor is a logged in user + * + * @since 2.0.0 + * + * @return bool True if user is logged in, false if not logged in. + */ function is_user_logged_in() { $user = wp_get_current_user(); @@ -322,11 +597,16 @@ function is_user_logged_in() { endif; if ( !function_exists('auth_redirect') ) : +/** + * auth_redirect() - Checks if a user is logged in, if not it redirects them to the login page + * + * @since 1.5 + */ function auth_redirect() { // Checks if a user is logged in, if not redirects them to the login page - if ( (!empty($_COOKIE[USER_COOKIE]) && - !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) || - (empty($_COOKIE[USER_COOKIE])) ) { + if ( (!empty($_COOKIE[AUTH_COOKIE]) && + !wp_validate_auth_cookie($_COOKIE[AUTH_COOKIE])) || + (empty($_COOKIE[AUTH_COOKIE])) ) { nocache_headers(); wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); @@ -336,47 +616,71 @@ function auth_redirect() { endif; if ( !function_exists('check_admin_referer') ) : -function check_admin_referer($action = -1) { +/** + * check_admin_referer() - Makes sure that a user was referred from another admin page, to avoid security exploits + * + * @since 1.2.0 + * @uses do_action() Calls 'check_admin_referer' on $action. + * + * @param string $action Action nonce + * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5) + */ +function check_admin_referer($action = -1, $query_arg = '_wpnonce') { $adminurl = strtolower(get_option('siteurl')).'/wp-admin'; $referer = strtolower(wp_get_referer()); - if ( !wp_verify_nonce($_REQUEST['_wpnonce'], $action) && - !(-1 == $action && strpos($referer, $adminurl) !== false)) { + $result = wp_verify_nonce($_REQUEST[$query_arg], $action); + if ( !$result && !(-1 == $action && strpos($referer, $adminurl) !== false) ) { wp_nonce_ays($action); die(); } - do_action('check_admin_referer', $action); + do_action('check_admin_referer', $action, $result); + return $result; }endif; if ( !function_exists('check_ajax_referer') ) : -function check_ajax_referer() { - $current_name = ''; - if ( ( $current = wp_get_current_user() ) && $current->ID ) - $current_name = $current->data->user_login; - if ( !$current_name ) - die('-1'); +/** + * check_ajax_referer() - Verifies the AJAX request to prevent processing requests external of the blog. + * + * @since 2.0.4 + * + * @param string $action Action nonce + * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5) + */ +function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) { + if ( $query_arg ) + $nonce = $_REQUEST[$query_arg]; + else + $nonce = $_REQUEST['_ajax_nonce'] ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce']; - $cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie - foreach ( $cookie as $tasty ) { - if ( false !== strpos($tasty, USER_COOKIE) ) - $user = substr(strstr($tasty, '='), 1); - if ( false !== strpos($tasty, PASS_COOKIE) ) - $pass = substr(strstr($tasty, '='), 1); - } + $result = wp_verify_nonce( $nonce, $action ); - if ( $current_name != $user || !wp_login( $user, $pass, true ) ) + if ( $die && false == $result ) die('-1'); - do_action('check_ajax_referer'); + + do_action('check_ajax_referer', $action, $result); + + return $result; } endif; -// Cookie safe redirect. Works around IIS Set-Cookie bug. -// http://support.microsoft.com/kb/q176113/ if ( !function_exists('wp_redirect') ) : +/** + * wp_redirect() - Redirects to another page, with a workaround for the IIS Set-Cookie bug + * + * @link http://support.microsoft.com/kb/q176113/ + * @since 1.5.1 + * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status. + * + * @param string $location The path to redirect to + * @param int $status Status code to use + * @return bool False if $location is not set + */ function wp_redirect($location, $status = 302) { global $is_IIS; $location = apply_filters('wp_redirect', $location, $status); - + $status = apply_filters('wp_redirect_status', $status, $location); + if ( !$location ) // allows the wp_redirect filter to cancel a redirect return false; @@ -394,7 +698,10 @@ endif; if ( !function_exists('wp_sanitize_redirect') ) : /** - * sanitizes a URL for use in a redirect + * wp_sanitize_redirect() - Sanitizes a URL for use in a redirect + * + * @since 2.3 + * * @return string redirect-sanitized URL **/ function wp_sanitize_redirect($location) { @@ -419,8 +726,20 @@ endif; if ( !function_exists('wp_safe_redirect') ) : /** - * performs a safe (local) redirect, using wp_redirect() - * @return void + * wp_safe_redirect() - Performs a safe (local) redirect, using wp_redirect() + * + * Checks whether the $location is using an allowed host, if it has an absolute + * path. A plugin can therefore set or remove allowed host(s) to or from the list. + * + * If the host is not allowed, then the redirect is to wp-admin on the siteurl + * instead. This prevents malicious redirects which redirect to another host, but + * only used in a few places. + * + * @since 2.3 + * @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing + * WordPress host string and $location host string. + * + * @return void Does not return anything **/ function wp_safe_redirect($location, $status = 302) { @@ -434,7 +753,7 @@ function wp_safe_redirect($location, $status = 302) { $lp = parse_url($location); $wpp = parse_url(get_option('home')); - $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), $lp['host']); + $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : ''); if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) ) $location = get_option('siteurl') . '/wp-admin/'; @@ -443,62 +762,17 @@ function wp_safe_redirect($location, $status = 302) { } endif; -if ( !function_exists('wp_get_cookie_login') ): -function wp_get_cookie_login() { - if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ) - return false; - - return array('login' => $_COOKIE[USER_COOKIE], 'password' => $_COOKIE[PASS_COOKIE]); -} - -endif; - -if ( !function_exists('wp_setcookie') ) : -function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember = false) { - if ( !$already_md5 ) - $password = md5( md5($password) ); // Double hash the password in the cookie. - - if ( empty($home) ) - $cookiepath = COOKIEPATH; - else - $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' ); - - if ( empty($siteurl) ) { - $sitecookiepath = SITECOOKIEPATH; - $cookiehash = COOKIEHASH; - } else { - $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' ); - $cookiehash = md5($siteurl); - } - - if ( $remember ) - $expire = time() + 31536000; - else - $expire = 0; - - setcookie(USER_COOKIE, $username, $expire, $cookiepath, COOKIE_DOMAIN); - setcookie(PASS_COOKIE, $password, $expire, $cookiepath, COOKIE_DOMAIN); - - if ( $cookiepath != $sitecookiepath ) { - setcookie(USER_COOKIE, $username, $expire, $sitecookiepath, COOKIE_DOMAIN); - setcookie(PASS_COOKIE, $password, $expire, $sitecookiepath, COOKIE_DOMAIN); - } -} -endif; - -if ( !function_exists('wp_clearcookie') ) : -function wp_clearcookie() { - setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); - setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); - setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); - setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); -} -endif; - if ( ! function_exists('wp_notify_postauthor') ) : +/** + * wp_notify_postauthor() - Notify an author of a comment/trackback/pingback to one of their posts + * + * @since 1.0.0 + * + * @param int $comment_id Comment ID + * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback' + * @return bool False if user email does not exist. True on completion. + */ function wp_notify_postauthor($comment_id, $comment_type='') { - global $wpdb; - $comment = get_comment($comment_id); $post = get_post($comment->comment_post_ID); $user = get_userdata( $post->post_author ); @@ -567,36 +841,62 @@ function wp_notify_postauthor($comment_id, $comment_type='') { } endif; -/* wp_notify_moderator - notifies the moderator of the blog (usually the admin) - about a new comment that waits for approval - always returns true - */ if ( !function_exists('wp_notify_moderator') ) : +/** + * wp_notify_moderator() - Notifies the moderator of the blog about a new comment that is awaiting approval + * + * @since 1.0 + * @uses $wpdb + * + * @param int $comment_id Comment ID + * @return bool Always returns true + */ function wp_notify_moderator($comment_id) { global $wpdb; if( get_option( "moderation_notify" ) == 0 ) return true; - $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); - $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1"); + $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID=%d LIMIT 1", $comment_id)); + $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID=%d LIMIT 1", $comment->comment_post_ID)); $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); - $notify_message = sprintf( __('A new comment on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n"; - $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; - $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; - $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; - $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; - $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; - $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; + switch ($comment->comment_type) + { + case 'trackback': + $notify_message = sprintf( __('A new trackback on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n"; + $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; + $notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; + $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; + $notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; + break; + case 'pingback': + $notify_message = sprintf( __('A new pingback on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n"; + $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; + $notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; + $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; + $notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; + break; + default: //Comments + $notify_message = sprintf( __('A new comment on the post #%1$s "%2$s" is waiting for your approval'), $post->ID, $post->post_title ) . "\r\n"; + $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; + $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; + $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; + $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; + $notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n"; + $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; + break; + } + $notify_message .= sprintf( __('Approve it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=mac&c=$comment_id" ) . "\r\n"; $notify_message .= sprintf( __('Delete it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n"; $notify_message .= sprintf( __('Spam it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n"; - $notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n"; - $notify_message .= get_option('siteurl') . "/wp-admin/moderation.php\r\n"; + + $strCommentsPending = sprintf( __ngettext('%s comment', '%s comments', $comments_waiting), $comments_waiting ); + $notify_message .= sprintf( __('Currently %s are waiting for approval. Please visit the moderation panel:'), $strCommentsPending ) . "\r\n"; + $notify_message .= get_option('siteurl') . "/wp-admin/edit-comments.php?comment_status=moderated\r\n"; $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_option('blogname'), $post->post_title ); $admin_email = get_option('admin_email'); @@ -611,6 +911,14 @@ function wp_notify_moderator($comment_id) { endif; if ( !function_exists('wp_new_user_notification') ) : +/** + * wp_new_user_notification() - Notify the blog admin of a new user, normally via email + * + * @since 2.0 + * + * @param int $user_id User ID + * @param string $plaintext_pass Optional. The user's plaintext password + */ function wp_new_user_notification($user_id, $plaintext_pass = '') { $user = new WP_User($user_id); @@ -635,50 +943,410 @@ function wp_new_user_notification($user_id, $plaintext_pass = '') { } endif; +if ( !function_exists('wp_nonce_tick') ) : +/** + * wp_nonce_tick() - Get the time-dependent variable for nonce creation + * + * A nonce has a lifespan of two ticks. Nonces in their second tick may be updated, e.g. by autosave. + * + * @since 2.5 + * + * @return int + */ +function wp_nonce_tick() { + $nonce_life = apply_filters('nonce_life', 86400); + + return ceil(time() / ( $nonce_life / 2 )); +} +endif; + if ( !function_exists('wp_verify_nonce') ) : +/** + * wp_verify_nonce() - Verify that correct nonce was used with time limit + * + * The user is given an amount of time to use the token, so therefore, since + * the UID and $action remain the same, the independent variable is the time. + * + * @since 2.0.4 + * + * @param string $nonce Nonce that was used in the form to verify + * @param string|int $action Should give context to what is taking place and be the same when nonce was created. + * @return bool Whether the nonce check passed or failed. + */ function wp_verify_nonce($nonce, $action = -1) { $user = wp_get_current_user(); $uid = (int) $user->id; - $i = ceil(time() / 43200); + $i = wp_nonce_tick(); - //Allow for expanding range, but only do one check if we can - if( substr(wp_hash($i . $action . $uid), -12, 10) == $nonce || substr(wp_hash(($i - 1) . $action . $uid), -12, 10) == $nonce ) - return true; + // Nonce generated 0-12 hours ago + if ( substr(wp_hash($i . $action . $uid), -12, 10) == $nonce ) + return 1; + // Nonce generated 12-24 hours ago + if ( substr(wp_hash(($i - 1) . $action . $uid), -12, 10) == $nonce ) + return 2; + // Invalid nonce return false; } endif; if ( !function_exists('wp_create_nonce') ) : +/** + * wp_create_nonce() - Creates a random, one time use token + * + * @since 2.0.4 + * + * @param string|int $action Scalar value to add context to the nonce. + * @return string The one use form token + */ function wp_create_nonce($action = -1) { $user = wp_get_current_user(); $uid = (int) $user->id; - $i = ceil(time() / 43200); + $i = wp_nonce_tick(); return substr(wp_hash($i . $action . $uid), -12, 10); } endif; if ( !function_exists('wp_salt') ) : +/** + * wp_salt() - Get salt to add to hashes to help prevent attacks + * + * You can set the salt by defining two areas. One is in the database and + * the other is in your wp-config.php file. The database location is defined + * in the option named 'secret', but most likely will not need to be changed. + * + * The second, located in wp-config.php, is a constant named 'SECRET_KEY', but + * is not required. If the constant is not defined then the database constants + * will be used, since they are most likely given to be unique. However, given + * that the salt will be added to the password and can be seen, the constant + * is recommended to be set manually. + * + * + * define('SECRET_KEY', 'mAry1HadA15|\/|b17w55w1t3asSn09w'); + * + * + * Attention: Do not use above example! + * + * Salting passwords helps against tools which has stored hashed values + * of common dictionary strings. The added values makes it harder to crack + * if given salt string is not weak. + * + * Salting only helps if the string is not predictable and should be + * made up of various characters. Think of the salt as a password for + * securing your passwords, but common among all of your passwords. + * Therefore the salt should be as long as possible as as difficult as + * possible, because you will not have to remember it. + * + * @since 2.5 + * + * @return string Salt value from either 'SECRET_KEY' or 'secret' option + */ function wp_salt() { - $salt = get_option('secret'); - if ( empty($salt) ) - $salt = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH; + global $wp_default_secret_key; + $secret_key = ''; + if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) ) + $secret_key = SECRET_KEY; + + if ( defined('SECRET_SALT') ) { + $salt = SECRET_SALT; + } else { + $salt = get_option('secret'); + if ( empty($salt) ) { + $salt = wp_generate_password(); + update_option('secret', $salt); + } + } - return $salt; + return apply_filters('salt', $secret_key . $salt); } endif; if ( !function_exists('wp_hash') ) : +/** + * wp_hash() - Get hash of given string + * + * @since 2.0.4 + * @uses wp_salt() Get WordPress salt + * + * @param string $data Plain text to hash + * @return string Hash of $data + */ function wp_hash($data) { $salt = wp_salt(); - if ( function_exists('hash_hmac') ) { - return hash_hmac('md5', $data, $salt); + return hash_hmac('md5', $data, $salt); +} +endif; + +if ( !function_exists('wp_hash_password') ) : +/** + * wp_hash_password() - Create a hash (encrypt) of a plain text password + * + * For integration with other applications, this function can be + * overwritten to instead use the other package password checking + * algorithm. + * + * @since 2.5 + * @global object $wp_hasher PHPass object + * @uses PasswordHash::HashPassword + * + * @param string $password Plain text user password to hash + * @return string The hash string of the password + */ +function wp_hash_password($password) { + global $wp_hasher; + + if ( empty($wp_hasher) ) { + require_once( ABSPATH . 'wp-includes/class-phpass.php'); + // By default, use the portable hash from phpass + $wp_hasher = new PasswordHash(8, TRUE); + } + + return $wp_hasher->HashPassword($password); +} +endif; + +if ( !function_exists('wp_check_password') ) : +/** + * wp_check_password() - Checks the plaintext password against the encrypted Password + * + * Maintains compatibility between old version and the new cookie + * authentication protocol using PHPass library. The $hash parameter + * is the encrypted password and the function compares the plain text + * password when encypted similarly against the already encrypted + * password to see if they match. + * + * For integration with other applications, this function can be + * overwritten to instead use the other package password checking + * algorithm. + * + * @since 2.5 + * @global object $wp_hasher PHPass object used for checking the password + * against the $hash + $password + * @uses PasswordHash::CheckPassword + * + * @param string $password Plaintext user's password + * @param string $hash Hash of the user's password to check against. + * @return bool False, if the $password does not match the hashed password + */ +function wp_check_password($password, $hash, $user_id = '') { + global $wp_hasher; + + // If the hash is still md5... + if ( strlen($hash) <= 32 ) { + $check = ( $hash == md5($password) ); + if ( $check && $user_id ) { + // Rehash using new hash. + wp_set_password($password, $user_id); + $hash = wp_hash_password($password); + } + + return apply_filters('check_password', $check, $password, $hash, $user_id); + } + + // If the stored hash is longer than an MD5, presume the + // new style phpass portable hash. + if ( empty($wp_hasher) ) { + require_once( ABSPATH . 'wp-includes/class-phpass.php'); + // By default, use the portable hash from phpass + $wp_hasher = new PasswordHash(8, TRUE); + } + + $check = $wp_hasher->CheckPassword($password, $hash); + + return apply_filters('check_password', $check, $password, $hash, $user_id); +} +endif; + +if ( !function_exists('wp_generate_password') ) : +/** + * wp_generate_password() - Generates a random password drawn from the defined set of characters + * + * @since 2.5 + * + * @return string The random password + **/ +function wp_generate_password($length = 12) { + $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()"; + $password = ''; + for ( $i = 0; $i < $length; $i++ ) + $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); + return $password; +} +endif; + +if ( !function_exists('wp_set_password') ) : +/** + * wp_set_password() - Updates the user's password with a new encrypted one + * + * For integration with other applications, this function can be + * overwritten to instead use the other package password checking + * algorithm. + * + * @since 2.5 + * @uses $wpdb WordPress database object for queries + * @uses wp_hash_password() Used to encrypt the user's password before passing to the database + * + * @param string $password The plaintext new user password + * @param int $user_id User ID + */ +function wp_set_password( $password, $user_id ) { + global $wpdb; + + $hash = wp_hash_password($password); + $query = $wpdb->prepare("UPDATE $wpdb->users SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $hash, $user_id); + $wpdb->query($query); + wp_cache_delete($user_id, 'users'); +} +endif; + +if ( !function_exists( 'get_avatar' ) ) : +/** + * get_avatar() - Get avatar for a user + * + * Retrieve the avatar for a user provided a user ID or email address + * + * @since 2.5 + * @param int|string|object $id_or_email A user ID, email address, or comment object + * @param int $size Size of the avatar image + * @param string $default URL to a default image to use if no avatar is available + * @return string tag for the user's avatar +*/ +function get_avatar( $id_or_email, $size = '96', $default = '' ) { + if ( ! get_option('show_avatars') ) + return false; + + if ( !is_numeric($size) ) + $size = '96'; + + $email = ''; + if ( is_numeric($id_or_email) ) { + $id = (int) $id_or_email; + $user = get_userdata($id); + if ( $user ) + $email = $user->user_email; + } elseif ( is_object($id_or_email) ) { + if ( !empty($id_or_email->user_id) ) { + $id = (int) $id_or_email->user_id; + $user = get_userdata($id); + if ( $user) + $email = $user->user_email; + } elseif ( !empty($id_or_email->comment_author_email) ) { + $email = $id_or_email->comment_author_email; + } + } else { + $email = $id_or_email; + } + + if ( empty($default) ) + $default = "http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=$size"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com') + + if ( !empty($email) ) { + $out = 'http://www.gravatar.com/avatar/'; + $out .= md5( strtolower( $email ) ); + $out .= '?s='.$size; + $out .= '&d=' . urlencode( $default ); + + $rating = get_option('avatar_rating'); + if ( !empty( $rating ) ) + $out .= "&r={$rating}"; + + $avatar = ""; } else { - return md5($data . $salt); + $avatar = ""; } + + return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default); +} +endif; + +if ( !function_exists('wp_setcookie') ) : +/** + * wp_setcookie() - Sets a cookie for a user who just logged in + * + * @since 1.5 + * @deprecated Use wp_set_auth_cookie() + * @see wp_set_auth_cookie() + * + * @param string $username The user's username + * @param string $password Optional. The user's password + * @param bool $already_md5 Optional. Whether the password has already been through MD5 + * @param string $home Optional. Will be used instead of COOKIEPATH if set + * @param string $siteurl Optional. Will be used instead of SITECOOKIEPATH if set + * @param bool $remember Optional. Remember that the user is logged in + */ +function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) { + _deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' ); + $user = get_userdatabylogin($username); + wp_set_auth_cookie($user->ID, $remember); +} +endif; + +if ( !function_exists('wp_clearcookie') ) : +/** + * wp_clearcookie() - Clears the authentication cookie, logging the user out + * + * @since 1.5 + * @deprecated Use wp_clear_auth_cookie() + * @see wp_clear_auth_cookie() + */ +function wp_clearcookie() { + _deprecated_function( __FUNCTION__, '2.5', 'wp_clear_auth_cookie()' ); + wp_clear_auth_cookie(); +} +endif; + +if ( !function_exists('wp_get_cookie_login') ): +/** + * wp_get_cookie_login() - Gets the user cookie login + * + * This function is deprecated and should no longer be extended as it won't + * be used anywhere in WordPress. Also, plugins shouldn't use it either. + * + * @since 2.0.4 + * @deprecated No alternative + * + * @return bool Always returns false + */ +function wp_get_cookie_login() { + _deprecated_function( __FUNCTION__, '2.5', '' ); + return false; +} +endif; + +if ( !function_exists('wp_login') ) : +/** + * wp_login() - Checks a users login information and logs them in if it checks out + * + * Use the global $error to get the reason why the login failed. + * If the username is blank, no error will be set, so assume + * blank username on that case. + * + * Plugins extending this function should also provide the global + * $error and set what the error is, so that those checking the + * global for why there was a failure can utilize it later. + * + * @since 1.2.2 + * @deprecated Use wp_signon() + * @global string $error Error when false is returned + * + * @param string $username User's username + * @param string $password User's password + * @param bool $deprecated Not used + * @return bool False on login failure, true on successful check + */ +function wp_login($username, $password, $deprecated = '') { + global $error; + + $user = wp_authenticate($username, $password); + + if ( ! is_wp_error($user) ) + return true; + + $error = $user->get_error_message(); + return false; } endif; diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 2c04c1c2..556570a7 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -1,150 +1,294 @@ + * function example_hook($example) { echo $example; } + * + * add_filter('example_filter', 'example_hook'); + * + * + * In WordPress 1.5.1+, hooked functions can take extra arguments that are set when + * the matching do_action() or apply_filters() call is run. The $accepted_args + * allow for calling functions only when the number of args match. Hooked functions + * can take extra arguments that are set when the matching do_action() or + * apply_filters() call is run. For example, the action comment_id_not_found + * will pass any functions that hook onto it the ID of the requested comment. + * + * Note: the function will return true no matter if the function was hooked + * fails or not. There are no checks for whether the function exists beforehand and no checks + * to whether the $function_to_add is even a string. It is up to you to take care and + * this is done for optimization purposes, so everything is as quick as possible. + * + * @package WordPress + * @subpackage Plugin + * @since 0.71 + * @global array $wp_filter Stores all of the filters added in the form of + * wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] + * @global array $merged_filters Tracks the tags that need to be merged for later. If the hook is added, it doesn't need to run through that process. * * @param string $tag The name of the filter to hook the $function_to_add to. * @param callback $function_to_add The name of the function to be called when the filter is applied. * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. - * @param int $accepted_args optional. The number of arguments the function accept (default 1). In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. - * @return boolean true if the $function_to_add is added succesfully to filter $tag. How many arguments your function takes. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. For example, the action comment_id_not_found will pass any functions that hook onto it the ID of the requested comment. + * @param int $accepted_args optional. The number of arguments the function accept (default 1). + * @return boolean true */ function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { global $wp_filter, $merged_filters; - // So the format is wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); - $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); - //$wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); + $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); unset( $merged_filters[ $tag ] ); return true; } /** - * Call the functions added to a filter hook. + * has_filter() - Check if any filter has been registered for a hook. + * + * @package WordPress + * @subpackage Plugin + * @since 2.5 + * @global array $wp_filter Stores all of the filters + * + * @param string $tag The name of the filter hook. + * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached. + * @return int|boolean Optionally returns the priority on that hook for the specified function. + */ +function has_filter($tag, $function_to_check = false) { + global $wp_filter; + + $has = !empty($wp_filter[$tag]); + if ( false === $function_to_check || false == $has ) + return $has; + + if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) ) + return false; + + foreach ( array_keys($wp_filter[$tag]) as $priority ) { + if ( isset($wp_filter[$tag][$priority][$idx]) ) + return $priority; + } + + return false; +} + +/** + * apply_filters() - Call the functions added to a filter hook. * * The callback functions attached to filter hook $tag are invoked by * calling this function. This function can be used to create a new filter hook * by simply calling this function with the name of the new hook specified using * the $tag parameter. - * @uses merge_filters Merges the filter hooks using this function. + * + * The function allows for additional arguments to be added and passed to hooks. + * + * function example_hook($string, $arg1, $arg2) + * { + * //Do stuff + * return $string; + * } + * $value = apply_filters('example_filter', 'filter me', 'arg1', 'arg2'); + * + * + * @package WordPress + * @subpackage Plugin + * @since 0.71 + * @global array $wp_filter Stores all of the filters + * @global array $merge_filters Merges the filter hooks using this function. + * @global array $wp_current_filter stores the list of current filters with the current one last + * * @param string $tag The name of the filter hook. - * @param string $string The text on which the filters hooked to $tag are applied on. + * @param mixed $value The value on which the filters hooked to $tag are applied on. * @param mixed $var,... Additional variables passed to the functions hooked to $tag. - * @return string The text in $string after all hooked functions are applied to it. + * @return mixed The filtered value after all hooked functions are applied to it. */ -function apply_filters($tag, $string) { - global $wp_filter, $merged_filters; +function apply_filters($tag, $value) { + global $wp_filter, $merged_filters, $wp_current_filter; - if ( !isset( $merged_filters[ $tag ] ) ) - merge_filters($tag); + $args = array(); + $wp_current_filter[] = $tag; + + // Do 'all' actions first + if ( isset($wp_filter['all']) ) { + $args = func_get_args(); + _wp_call_all_hook($args); + } - if ( !isset($wp_filter[$tag]) ) - return $string; + if ( !isset($wp_filter[$tag]) ) { + array_pop($wp_current_filter); + return $value; + } + + // Sort + if ( !isset( $merged_filters[ $tag ] ) ) { + ksort($wp_filter[$tag]); + $merged_filters[ $tag ] = true; + } reset( $wp_filter[ $tag ] ); - $args = func_get_args(); + if ( empty($args) ) + $args = func_get_args(); - do{ + do { foreach( (array) current($wp_filter[$tag]) as $the_ ) if ( !is_null($the_['function']) ){ - $args[1] = $string; - $string = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); + $args[1] = $value; + $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); } } while ( next($wp_filter[$tag]) !== false ); - return $string; -} - -/** - * Merge the filter functions of a specific filter hook with generic filter functions. - * - * It is possible to defined generic filter functions using the filter hook - * all. These functions are called for every filter tag. This function - * merges the functions attached to the all hook with the functions - * of a specific hoook defined by $tag. - * @param string $tag The filter hook of which the functions should be merged. - */ -function merge_filters($tag) { - global $wp_filter, $merged_filters; - - if ( isset($wp_filter['all']) && is_array($wp_filter['all']) ) - $wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]); + array_pop( $wp_current_filter ); - if ( isset($wp_filter[$tag]) ){ - reset($wp_filter[$tag]); - uksort($wp_filter[$tag], "strnatcasecmp"); - } - $merged_filters[ $tag ] = true; + return $value; } /** - * Removes a function from a specified filter hook. + * remove_filter() - Removes a function from a specified filter hook. * * This function removes a function attached to a specified filter hook. This * method can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. + * + * To remove a hook, the $function_to_remove and $priority arguments + * must match when the hook was added. This goes for both filters and actions. No warning + * will be given on removal failure. + * + * @package WordPress + * @subpackage Plugin + * @since 1.2 + * * @param string $tag The filter hook to which the function to be removed is hooked. * @param callback $function_to_remove The name of the function which should be removed. * @param int $priority optional. The priority of the function (default: 10). * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). - * @return boolean Whether the function is removed. + * @return boolean Whether the function existed before it was removed. */ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); - unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); - unset($GLOBALS['merged_filters'][$tag]); + if ( true === $r) { + unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); + if ( empty($GLOBALS['wp_filter'][$tag][$priority]) ) + unset($GLOBALS['wp_filter'][$tag][$priority]); + unset($GLOBALS['merged_filters'][$tag]); + } return $r; } + /** - * Hooks a function on to a specific action. + * current_filter() - Return the name of the current filter or action. + * + * @package WordPress + * @subpackage Plugin + * @since 2.5 + * + * @return string Hook name of the current filter or action. + */ +function current_filter() { + global $wp_current_filter; + return end( $wp_current_filter ); +} + + +/** + * add_action() - Hooks a function on to a specific action. * * Actions are the hooks that the WordPress core launches at specific points * during execution, or when specific events occur. Plugins can specify that * one or more of its PHP functions are executed at these points, using the * Action API. * + * @uses add_filter() Adds an action. Parameter list and functionality are the same. + * + * @package WordPress + * @subpackage Plugin + * @since 1.2 + * * @param string $tag The name of the action to which the $function_to-add is hooked. - * @param callback $function_to_add The name of the function you wish to be called. Note: any of the syntaxes explained in the PHP documentation for the 'callback' type (http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback) are valid. + * @param callback $function_to_add The name of the function you wish to be called. * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. - * @param int $accepted_args optional. The number of arguments the function accept (default 1). In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. - * @return boolean Always true. + * @param int $accepted_args optional. The number of arguments the function accept (default 1). */ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { - add_filter($tag, $function_to_add, $priority, $accepted_args); + return add_filter($tag, $function_to_add, $priority, $accepted_args); } + /** - * Execute functions hooked on a specific action hook. + * do_action() - Execute functions hooked on a specific action hook. * * This function invokes all functions attached to action hook $tag. * It is possible to create new action hooks by simply calling this function, * specifying the name of the new hook using the $tag parameter. - * @uses merge_filters + * + * You can pass extra arguments to the hooks, much like you can with apply_filters(). + * + * @see apply_filters() This function works similar with the exception that nothing is + * returned and only the functions or methods are called. + * + * @package WordPress + * @subpackage Plugin + * @since 1.2 + * @global array $wp_filter Stores all of the filters + * @global array $wp_actions Increments the amount of times action was triggered. + * * @param string $tag The name of the action to be executed. * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action. + * @return null Will return null if $tag does not exist in $wp_filter array */ function do_action($tag, $arg = '') { - global $wp_filter, $wp_actions; + global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; if ( is_array($wp_actions) ) $wp_actions[] = $tag; else $wp_actions = array($tag); + $wp_current_filter[] = $tag; + + // Do 'all' actions first + if ( isset($wp_filter['all']) ) { + $all_args = func_get_args(); + _wp_call_all_hook($all_args); + } + + if ( !isset($wp_filter[$tag]) ) { + array_pop($wp_current_filter); + return; + } + $args = array(); if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this) $args[] =& $arg[0]; @@ -153,22 +297,32 @@ function do_action($tag, $arg = '') { for ( $a = 2; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); - merge_filters($tag); + // Sort + if ( !isset( $merged_filters[ $tag ] ) ) { + ksort($wp_filter[$tag]); + $merged_filters[ $tag ] = true; + } - if ( !isset($wp_filter[$tag]) ) - return; + reset( $wp_filter[ $tag ] ); - do{ - foreach( (array) current($wp_filter[$tag]) as $the_ ) + do { + foreach ( (array) current($wp_filter[$tag]) as $the_ ) if ( !is_null($the_['function']) ) call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); } while ( next($wp_filter[$tag]) !== false ); + array_pop($wp_current_filter); } /** - * Return the number times an action is fired. + * did_action() - Return the number times an action is fired. + * + * @package WordPress + * @subpackage Plugin + * @since 2.1 + * @global array $wp_actions Increments the amount of times action was triggered. + * * @param string $tag The name of the action hook. * @return int The number of times action hook $tag is fired */ @@ -182,41 +336,87 @@ function did_action($tag) { } /** - * Execute functions hooked on a specific action hook, specifying arguments in a array. + * do_action_ref_array() - Execute functions hooked on a specific action hook, specifying arguments in an array. * - * This function is identical to {@link do_action}, but the argumetns passe to + * @see do_action() This function is identical, but the arguments passed to * the functions hooked to $tag are supplied using an array. + * + * @package WordPress + * @subpackage Plugin + * @since 2.1 + * @global array $wp_filter Stores all of the filters + * @global array $wp_actions Increments the amount of times action was triggered. + * * @param string $tag The name of the action to be executed. * @param array $args The arguments supplied to the functions hooked to $tag + * @return null Will return null if $tag does not exist in $wp_filter array */ function do_action_ref_array($tag, $args) { - global $wp_filter, $wp_actions; + global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; if ( !is_array($wp_actions) ) $wp_actions = array($tag); else $wp_actions[] = $tag; - merge_filters($tag); + $wp_current_filter[] = $tag; + + // Do 'all' actions first + if ( isset($wp_filter['all']) ) { + $all_args = func_get_args(); + _wp_call_all_hook($all_args); + } - if ( !isset($wp_filter[$tag]) ) + if ( !isset($wp_filter[$tag]) ) { + array_pop($wp_current_filter); return; + } - do{ + // Sort + if ( !isset( $merged_filters[ $tag ] ) ) { + ksort($wp_filter[$tag]); + $merged_filters[ $tag ] = true; + } + + reset( $wp_filter[ $tag ] ); + + do { foreach( (array) current($wp_filter[$tag]) as $the_ ) if ( !is_null($the_['function']) ) call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); } while ( next($wp_filter[$tag]) !== false ); + array_pop($wp_current_filter); +} + +/** + * has_action() - Check if any action has been registered for a hook. + * + * @package WordPress + * @subpackage Plugin + * @since 2.5 + * @see has_filter() has_action() is an alias of has_filter(). + * + * @param string $tag The name of the action hook. + * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached. + * @return int|boolean Optionally returns the priority on that hook for the specified function. + */ +function has_action($tag, $function_to_check = false) { + return has_filter($tag, $function_to_check); } /** - * Removes a function from a specified action hook. + * remove_action() - Removes a function from a specified action hook. * * This function removes a function attached to a specified action hook. This * method can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. + * + * @package WordPress + * @subpackage Plugin + * @since 1.2 + * * @param string $tag The action hook to which the function to be removed is hooked. * @param callback $function_to_remove The name of the function which should be removed. * @param int $priority optional The priority of the function (default: 10). @@ -232,30 +432,44 @@ function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args // /** - * Gets the basename of a plugin. + * plugin_basename() - Gets the basename of a plugin. * * This method extract the name of a plugin from its filename. + * + * @package WordPress + * @subpackage Plugin + * @since 1.5 + * + * @access private + * * @param string $file The filename of plugin. * @return string The name of a plugin. */ function plugin_basename($file) { $file = str_replace('\\','/',$file); // sanitize for Win32 installs $file = preg_replace('|/+|','/', $file); // remove any duplicate slash - $file = preg_replace('|^.*/wp-content/plugins/|','',$file); // get relative path from plugins dir + $file = preg_replace('|^.*/' . PLUGINDIR . '/|','',$file); // get relative path from plugins dir return $file; } /** - * Hook a function on a plugin activation action hook. + * register_activation_hook() - Hook a function on a plugin activation action hook. * * When a plugin is activated, the action 'activate_PLUGINNAME' hook is * activated. In the name of this hook, PLUGINNAME is replaced with the name of * the plugin, including the optional subdirectory. For example, when the plugin * is located in wp-content/plugin/sampleplugin/sample.php, then the - * name of this hook will become 'activate_sampleplugin/sample.php'. + * name of this hook will become 'activate_sampleplugin/sample.php' * When the plugin consists of only one file and is (as by default) located at * wp-content/plugin/sample.php the name of this hook will be * 'activate_sample.php'. + * + * @package WordPress + * @subpackage Plugin + * @since 2.0 + * + * @access private + * * @param string $file The filename of the plugin including the path. * @param string $function the function hooked to the 'activate_PLUGIN' action. */ @@ -265,7 +479,7 @@ function register_activation_hook($file, $function) { } /** - * Hook a function on a plugin deactivation action hook. + * register_deactivation_hook() - Hook a function on a plugin deactivation action hook. * * When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is * deactivated. In the name of this hook, PLUGINNAME is replaced with the name of @@ -275,6 +489,13 @@ function register_activation_hook($file, $function) { * When the plugin consists of only one file and is (as by default) located at * wp-content/plugin/sample.php the name of this hook will be * 'activate_sample.php'. + * + * @package WordPress + * @subpackage Plugin + * @since 2.0 + * + * @access private + * * @param string $file The filename of the plugin including the path. * @param string $function the function hooked to the 'activate_PLUGIN' action. */ @@ -283,19 +504,82 @@ function register_deactivation_hook($file, $function) { add_action('deactivate_' . $file, $function); } -function _wp_filter_build_unique_id($tag, $function, $priority = 10) -{ +/** + * _wp_call_all_hook() - Calls the 'all' hook, which will process the functions hooked into it. + * + * The 'all' hook passes all of the arguments or parameters that were used for the + * hook, which this function was called for. + * + * This function is used internally for apply_filters(), do_action(), and do_action_ref_array() + * and is not meant to be used from outside those functions. This function does not check for the + * existence of the all hook, so it will fail unless the all hook exists prior to this function call. + * + * @package WordPress + * @subpackage Plugin + * @since 2.5 + * @access private + * + * @uses $wp_filter Used to process all of the functions in the 'all' hook + * + * @param array $args The collected parameters from the hook that was called. + * @param string $hook Optional. The hook name that was used to call the 'all' hook. + */ +function _wp_call_all_hook($args) { + global $wp_filter; + + reset( $wp_filter['all'] ); + do { + foreach( (array) current($wp_filter['all']) as $the_ ) + if ( !is_null($the_['function']) ) + call_user_func_array($the_['function'], $args); + + } while ( next($wp_filter['all']) !== false ); +} + +/** + * _wp_filter_build_unique_id() - Build Unique ID for storage and retrieval + * + * The old way to serialize the callback caused issues and this function is the + * solution. It works by checking for objects and creating an a new property in + * the class to keep track of the object and new objects of the same class that + * need to be added. + * + * It also allows for the removal of actions and filters for objects after they + * change class properties. It is possible to include the property $wp_filter_id + * in your class and set it to "null" or a number to bypass the workaround. However + * this will prevent you from adding new classes and any new classes will overwrite + * the previous hook by the same class. + * + * Functions and static method callbacks are just returned as strings and shouldn't + * have any speed penalty. + * + * @package WordPress + * @subpackage Plugin + * @since 2.2.3 + * + * @link http://trac.wordpress.org/ticket/3875 + * + * @access private + * + * @global array $wp_filter Storage for all of the filters and actions + * @param string $tag Used in counting how many hooks were applied + * @param string|array $function Used for creating unique id + * @param int|bool $priority Used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise. + * @param string $type filter or action + * @return string Unique ID for usage as array key + */ +function _wp_filter_build_unique_id($tag, $function, $priority) { global $wp_filter; // If function then just skip all of the tests and not overwrite the following. - // Static Calling - if( is_string($function) ) + if ( is_string($function) ) return $function; // Object Class Calling - else if(is_object($function[0]) ) - { + else if (is_object($function[0]) ) { $obj_idx = get_class($function[0]).$function[1]; - if( is_null($function[0]->wp_filter_id) ) { + if ( !isset($function[0]->wp_filter_id) ) { + if ( false === $priority ) + return false; $count = count((array)$wp_filter[$tag][$priority]); $function[0]->wp_filter_id = $count; $obj_idx .= $count; @@ -304,7 +588,8 @@ function _wp_filter_build_unique_id($tag, $function, $priority = 10) $obj_idx .= $function[0]->wp_filter_id; return $obj_idx; } - else if( is_string($function[0]) ) + // Static Calling + else if ( is_string($function[0]) ) return $function[0].$function[1]; } diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index a956dc48..915101cb 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -54,11 +54,13 @@ function get_the_title( $id = 0 ) { $post = &get_post($id); $title = $post->post_title; - if ( !empty($post->post_password) ) - $title = sprintf(__('Protected: %s'), $title); - else if ( 'private' == $post->post_status ) - $title = sprintf(__('Private: %s'), $title); + if ( !is_admin() ) { + if ( !empty($post->post_password) ) + $title = sprintf(__('Protected: %s'), $title); + else if ( isset($post->post_status) && 'private' == $post->post_status ) + $title = sprintf(__('Private: %s'), $title); + } return apply_filters( 'the_title', $title ); } @@ -81,13 +83,12 @@ function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { - global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages; - global $preview; - global $pagenow; + global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow; + $output = ''; if ( !empty($post->post_password) ) { // if there's a password - if ( stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie + if ( !isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie $output = get_the_password_form(); return $output; } @@ -137,12 +138,12 @@ function the_excerpt() { } -function get_the_excerpt($deprecated = true) { - global $id, $post; +function get_the_excerpt($deprecated = '') { + global $post; $output = ''; $output = $post->post_excerpt; if ( !empty($post->post_password) ) { // if there's a password - if ( $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie + if ( !isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie $output = __('There is no excerpt because this is a protected post.'); return $output; } @@ -167,7 +168,7 @@ function wp_link_pages($args = '') { $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); - global $post, $id, $page, $numpages, $multipage, $more, $pagenow; + global $post, $page, $numpages, $multipage, $more, $pagenow; if ( $more_file != '' ) $file = $more_file; else @@ -249,8 +250,6 @@ function post_custom( $key = '' ) { // this will probably change at some point... function the_meta() { - global $id; - if ( $keys = get_post_custom_keys() ) { echo "