New approach to retheming

This commit is contained in:
nikolark committed 2012-06-20 19:25:26 +02:00
1 parent b0ebcbb93c
commit 68dbcba745
195 files changed
+15902

No files matched your search

@@ -0,0 +1 @@
*.swp
+339
View File
@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+1
View File
@@ -0,0 +1 @@
@@ -0,0 +1,164 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: neuf-events\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-01-20 21:51+0100\n"
"PO-Revision-Date: 2012-01-20 21:58+0100\n"
"Last-Translator: Nikolai Kristiansen <nikolaik@gmail.com>\n"
"Language-Team: Nikolai Kristiansen <nikolai@studentersamfundet.no>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: Norwegian Bokmal\n"
"X-Poedit-KeywordsList: __;_e\n"
"X-Poedit-Basepath: /home/nikolark/dev/edb/neuf-web/wp-content/plugins/neuf-events/\n"
"X-Poedit-SearchPath-0: .\n"
#: neuf-events-taxonomies.php:9
#: neuf-events-taxonomies.php:10
msgid "Event Type"
msgstr "Arrangementstype"
#: neuf-events-taxonomies.php:11
msgid "Search Event Types"
msgstr "Søk i arrangementstyper"
#: neuf-events-taxonomies.php:12
msgid "All Event Types"
msgstr "Alle arrangementstyper"
#: neuf-events-taxonomies.php:13
msgid "Subtype of"
msgstr "Undertype av"
#: neuf-events-taxonomies.php:14
msgid "Subtype of:"
msgstr "Undertype av:"
#: neuf-events-taxonomies.php:15
msgid "Edit Event Type"
msgstr "Endre arrangementstype"
#: neuf-events-taxonomies.php:16
msgid "Update Event Type"
msgstr "Oppdater arrangementstype"
#: neuf-events-taxonomies.php:17
msgid "Add New Event Type"
msgstr "Legg til ny arrangementstype"
#: neuf-events-taxonomies.php:18
msgid "Name"
msgstr "Navn"
#: neuf-events-taxonomies.php:19
msgid "Event Types"
msgstr "Arrangementstyper"
#: neuf-events-admin.php:7
msgid "Title"
msgstr "Tittel"
#: neuf-events-admin.php:8
msgid "Date & Time"
msgstr "Dato og klokkeslett"
#: neuf-events-admin.php:9
msgid "Ending Date & Time"
msgstr "Sluttdato og -klokkeslett"
#: neuf-events-admin.php:10
msgid "Venue"
msgstr "Sted"
#: neuf-events-admin.php:11
msgid "Type"
msgstr "Type"
#: neuf-events-admin.php:12
msgid "Date Published"
msgstr "Publiseringsdato"
#: neuf-events-admin.php:13
msgid "Author"
msgstr "Forfatter"
#: neuf-events-admin.php:28
msgid "None"
msgstr "Ikke satt"
#: neuf-events-admin.php:80
msgid "Event Details"
msgstr "Arrangementsdetaljer"
#: neuf-events-admin.php:113
msgid "Starts"
msgstr "Start"
#: neuf-events-admin.php:114
msgid "Ends"
msgstr "Slutt"
#: neuf-events-admin.php:127
msgid "Venue:"
msgstr "Sted:"
#: neuf-events-admin.php:137
msgid "<option value=\"Annet\">Other</option>"
msgstr "<option value=\"Annet\">Annet</option>"
#: neuf-events-admin.php:150
msgid "Price"
msgstr "Pris:"
#: neuf-events-admin.php:152
msgid "Billettservice address"
msgstr "Billettservice adresse"
#: neuf-events-admin.php:154
msgid "Facebook address"
msgstr "Facebook adresse"
#: neuf-events-post-types.php:11
msgid "Events"
msgstr "Arrangementer"
#: neuf-events-post-types.php:12
msgid "Event"
msgstr "Arrangement"
#: neuf-events-post-types.php:13
#: neuf-events-post-types.php:14
msgid "Add New"
msgstr "Legg til ny"
#: neuf-events-post-types.php:15
msgid "Edit Event"
msgstr "Rediger arrrangement"
#: neuf-events-post-types.php:16
msgid "Add New Event"
msgstr "Legg til nytt arrangement"
#: neuf-events-post-types.php:17
msgid "View Event"
msgstr "Vis arrangement"
#: neuf-events-post-types.php:18
msgid "Search Events"
msgstr "Søk i arrangementer"
#: neuf-events-post-types.php:19
msgid "No events found"
msgstr "Ingen arrangement funnet"
#: neuf-events-post-types.php:20
msgid "No events found in trash"
msgstr "Ingen arrangement funnet i søpla"
@@ -0,0 +1,158 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-01-20 21:46+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: neuf-events-admin.php:7
msgid "Title"
msgstr ""
#: neuf-events-admin.php:8
msgid "Date & Time"
msgstr ""
#: neuf-events-admin.php:9
msgid "Ending Date & Time"
msgstr ""
#: neuf-events-admin.php:10
msgid "Venue"
msgstr ""
#: neuf-events-admin.php:11
msgid "Type"
msgstr ""
#: neuf-events-admin.php:12
msgid "Date Published"
msgstr ""
#: neuf-events-admin.php:13
msgid "Author"
msgstr ""
#: neuf-events-admin.php:28
msgid "Ikke satt"
msgstr ""
#: neuf-events-admin.php:80
msgid "Event Details"
msgstr ""
#: neuf-events-admin.php:113
msgid "Starts"
msgstr ""
#: neuf-events-admin.php:114
msgid "Ends"
msgstr ""
#: neuf-events-admin.php:127
msgid "Venue:"
msgstr ""
#: neuf-events-admin.php:137
msgid "<option value=\"Annet\">Other</option>"
msgstr ""
#: neuf-events-admin.php:150
msgid "Price"
msgstr ""
#: neuf-events-admin.php:152
msgid "Billettservice address"
msgstr ""
#: neuf-events-admin.php:154
msgid "Facebook address"
msgstr ""
#: neuf-events-post-types.php:11
msgid "Events"
msgstr ""
#: neuf-events-post-types.php:12
msgid "Event"
msgstr ""
#: neuf-events-post-types.php:13 neuf-events-post-types.php:14
msgid "Add New"
msgstr ""
#: neuf-events-post-types.php:15
msgid "Edit Event"
msgstr ""
#: neuf-events-post-types.php:16
msgid "Add New Event"
msgstr ""
#: neuf-events-post-types.php:17
msgid "View Event"
msgstr ""
#: neuf-events-post-types.php:18
msgid "Search Events"
msgstr ""
#: neuf-events-post-types.php:19
msgid "No events found"
msgstr ""
#: neuf-events-post-types.php:20
msgid "No events found in trash"
msgstr ""
#: neuf-events-taxonomies.php:9 neuf-events-taxonomies.php:10
msgid "Event Type"
msgstr ""
#: neuf-events-taxonomies.php:11
msgid "Search Event Types"
msgstr ""
#: neuf-events-taxonomies.php:12
msgid "All Event Types"
msgstr ""
#: neuf-events-taxonomies.php:13
msgid "Subtype of"
msgstr ""
#: neuf-events-taxonomies.php:14
msgid "Subtype of:"
msgstr ""
#: neuf-events-taxonomies.php:15
msgid "Edit Event Type"
msgstr ""
#: neuf-events-taxonomies.php:16
msgid "Update Event Type"
msgstr ""
#: neuf-events-taxonomies.php:17
msgid "Add New Event Type"
msgstr ""
#: neuf-events-taxonomies.php:18
msgid "Name"
msgstr ""
#: neuf-events-taxonomies.php:19
msgid "Event Types"
msgstr ""
@@ -0,0 +1,202 @@
<?php
/* Add custom columns. */
function change_columns( $cols ) {
$custom_cols = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title', 'neuf_event' ),
'starttime' => __( 'Date & Time', 'neuf_event' ),
'endtime' => __( 'Ending Date & Time', 'neuf_event'),
'venue' => __( 'Venue', 'neuf_event' ),
'type' => __( 'Type', 'neuf_event' ),
'promoperiod' => __( 'Promo Period', 'neuf_event' ),
'date' => __( 'Date Published', 'neuf_event' ),
'author' => __( 'Author', 'neuf_event' ),
);
return $custom_cols;
}
add_filter( "manage_event_posts_columns", "change_columns" );
// Add values to the custom columns
function custom_columns( $column, $post_id ) {
switch ( $column ) {
case "starttime":
$starttime = intval(get_post_meta( $post_id, '_neuf_events_starttime', true));
echo format_datetime($starttime);
break;
case "endtime":
$endtime = intval(get_post_meta( $post_id, '_neuf_events_endtime', true));
echo $endtime ? format_datetime($endtime) : __("None", 'neuf_event');
break;
case "type":
echo the_terms( $post_id , 'event_type', '', ', ', '' );
break;
case "venue":
echo get_post_meta( $post_id , '_neuf_events_venue', true);
break;
case "promoperiod":
echo get_post_meta( $post_id, '_neuf_events_promo_period', true);
break;
}
}
add_action( "manage_posts_custom_column" , "custom_columns", 10, 2 );
// Make these columns sortable
function sortable_columns( $cols ) {
$custom_cols = array(
'starttime' => 'starttime',
'endtime' => 'endtime',
'type' => 'type',
'venue' => 'venue',
'promoperiod' => 'promoperiod',
);
return array_merge($cols, $custom_cols);
}
add_filter( "manage_edit-event_sortable_columns", "sortable_columns" );
function add_admin_script_and_styles() {
// Date-selection for events
wp_register_style('timecss', plugins_url("/neuf-events/style/jquery-ui-1.8.12.custom.css", dirname(__FILE__)));
wp_register_script('timepicker', plugins_url("/neuf-events/script/jquery-ui-timepicker-addon.js", dirname(__FILE__)));
wp_register_script('timedefs', plugins_url("/neuf-events/script/timepickdef.js", dirname(__FILE__)));
// for upgrading jQuery ui, get core, widget, mouse, slider and datepicker
wp_register_script('custom-jqui', plugins_url("/neuf-events/script/jquery-ui-1.8.11.custom.min.js", dirname(__FILE__)));
// form validation: http://docs.jquery.com/Plugins/Validation#API_Documentation
wp_register_script('formvalidation', plugins_url("/neuf-events/script/jquery.validate.min.js", dirname(__FILE__)));
wp_register_script('validation_rules', plugins_url("/neuf-events/script/validation_rules.js", dirname(__FILE__)));
wp_enqueue_style('timecss');
wp_enqueue_script('jquery');
wp_enqueue_script('custom-jqui');
wp_enqueue_script('timepicker');
wp_enqueue_script('timedefs');
wp_enqueue_script('formvalidation');
wp_enqueue_script('validation_rules');
}
/* Add metaboxes (with styles) */
function add_events_metaboxes() {
add_admin_script_and_styles();
add_meta_box(
'neuf_events_details',
__('Event Details', 'neuf_event'),
'neuf_event_details',
'event',
'side',
'high'
);
}
function neuf_event_details() {
?>
<div class="misc-pub-section">
<?php neuf_date_details(); ?>
</div>
<div class="misc-pub-section ">
<?php neuf_event_venue(); ?>
</div>
<div class="misc-pub-section ">
<?php neuf_event_div(); ?>
</div>
<div class="misc-pub-section misc-pub-section-last">
<?php
/* Only editor or superior can set the promo period */
if ( current_user_can('edit_others_posts') ) {
neuf_event_promoperiod();
}
?>
</div>
<?php
}
/*
* Date & Time
* Note: Jquery datetimepickers is loaded in scripts/timepickdef.js
*/
function neuf_date_details() {
global $post;
$start = get_post_meta($post->ID, '_neuf_events_starttime', true);
$end = get_post_meta($post->ID, '_neuf_events_endtime', true);
wp_nonce_field( 'neuf_events_nonce','neuf_events_nonce' );
?>
<label for="_neuf_events_starttime"><?php _e('Starts', 'neuf_event'); ?>:</label><input type="text" class="datepicker required" name="_neuf_events_starttime" value="<?php echo $start ? date("Y-m-d H:i", $start) : "" ?>" /><br />
<label for="_neuf_events_endtime"><?php _e('Ends', 'neuf_event'); ?>:</label><input name="_neuf_events_endtime" type="text" class="datepicker" value="<?php echo $end ? date("Y-m-d H:i", $end) : "" ?>" /><br />
<?php
}
/* Venue */
function neuf_event_venue(){
global $post;
$venues = array(
'Betong', 'Betonghaven','Biblioteket', 'BokCaféen',
'Klubbscenen', 'Lillesalen', 'Teaterscenen', 'Storsalen',
);
$neuf_event_venue = get_post_meta($post->ID, '_neuf_events_venue', true);
_e('Venue:', 'neuf_event');
echo '<select name="_neuf_events_venue">';
foreach ($venues as $venue) {
echo '<option value="'.$venue.'"';
if($venue == $neuf_event_venue) {
echo ' selected="selected"';
}
echo '>'.$venue.'</option>';
}
_e('<option value="Annet">Other</option>', 'neuf_event');
echo '</select><br />';
}
/* Promo period */
function neuf_event_promoperiod(){
global $post;
$promoperiod = array(
__('Default', 'neuf_event'), __('Week', 'neuf_event'), __('Month', 'neuf_event'), __('Semester', 'neuf_event'),
);
$neuf_event_promoperiod = get_post_meta($post->ID, '_neuf_events_promo_period', true);
_e('Promo Period', 'neuf_event');
echo '<select name="_neuf_events_promo_period">';
foreach ($promoperiod as $period) {
echo '<option value="'.$period.'"';
if($period == $neuf_event_promoperiod) {
echo ' selected="selected"';
}
echo '>'.$period.'</option>';
}
echo '</select><br />';
}
/* Price and additional info. */
function neuf_event_div() {
global $post;
$event_price_regular = get_post_meta($post->ID, '_neuf_events_price_regular') ? get_post_meta($post->ID, '_neuf_events_price_regular', true) : "";
$event_price_member = get_post_meta($post->ID, '_neuf_events_price_member') ? get_post_meta($post->ID, '_neuf_events_price_member', true) : "";
$event_bs = get_post_meta($post->ID, '_neuf_events_bs_url') ? get_post_meta($post->ID, '_neuf_events_bs_url', true) : "";
$event_fb = get_post_meta($post->ID, '_neuf_events_fb_url', true);
?>
<label for="_neuf_events_price_regular"><?php _e("Price Regular", 'neuf_event'); ?></label>
<input name="_neuf_events_price_regular" type="text" value="<?php echo $event_price_regular; ?>"></input><br />
<label for="_neuf_events_price_member"><?php _e("Price Member", 'neuf_event'); ?></label>
<input name="_neuf_events_price_member" type="text" value="<?php echo $event_price_member; ?>"></input><br />
<label for="_neuf_events_bs_url"><?php _e("Billettservice address", 'neuf_event'); ?>:</label>
<input type="text" name="_neuf_events_bs_url" value="<?php echo $event_bs; ?>" /><br />
<label for="_neuf_events_fb_url"><?php _e("Facebook address", 'neuf_event'); ?>:</label>
<input type="text" name="_neuf_events_fb_url" value="<?php echo $event_fb; ?>" />
<?php
}
/* Format a unix timestamp respecting the options set in Settings->General. */
if( !function_exists('format_datetime') ) {
function format_datetime($timestamp) {
return date_i18n(get_option('date_format')." ".get_option('time_format'), intval($timestamp));
}
}
?>
@@ -0,0 +1,48 @@
<?php
/*
* Custom events controller providing handy methods.
*/
class JSON_API_Events_Controller {
/* /?json=events.get_upcoming */
public function get_upcoming() {
global $json_api;
$meta_query = array(
'key' => '_neuf_events_starttime',
'value' => date( 'U' , strtotime( '-8 hours' ) ),
'compare' => '>',
'type' => 'numeric'
);
$query = array(
'post_type' => 'event',
'meta_query' => array( $meta_query ),
'posts_per_page' => 50,
'orderby' => 'meta_value_num',
'meta_key' => '_neuf_events_starttime',
'order' => 'ASC'
);
$custom_fields = array(
'_neuf_events_price_regular',
'_neuf_events_starttime',
'_neuf_events_endtime',
'_neuf_events_venue',
'_neuf_events_bs_url',
'_neuf_events_fb_url',
);
$json_api->query->custom_fields = implode(',', $custom_fields);
$events = $json_api->introspector->get_posts($query);
return $this->events_result($events);
}
protected function events_result($events) {
global $wp_query;
return array(
'count' => count($events),
'count_total' => (int) $wp_query->found_posts,
'pages' => $wp_query->max_num_pages,
'events' => $events
);
}
}
?>
@@ -0,0 +1,132 @@
<?php
/**
* Registers the event post type.
*
* This post type will be used to store events to our system. With events, we mean such events as concerts, movie screenings, parties and so on (as opposed to MouseOverEvents and the like).
*/
/* Create the fields the post type should have */
function neuf_events_post_type() {
$labels = array(
'name' => __( 'Events', 'neuf_event'),
'singular_name' => __( 'Event', 'neuf_event'),
'add_new' => __( 'Add New', 'neuf_event'),
'add_new_item' => __( 'Add New', 'neuf_event'),
'edit_item' => __( 'Edit Event', 'neuf_event'),
'new_item' => __( 'Add New Event', 'neuf_event'),
'view_item' => __( 'View Event', 'neuf_event'),
'search_items' => __( 'Search Events', 'neuf_event'),
'not_found' => __( 'No events found', 'neuf_event'),
'not_found_in_trash' => __( 'No events found in trash', 'neuf_event')
);
register_post_type(
'event',
array(
'labels' => $labels,
'menu_position' => 5,
'public' => true,
'publicly_queryable' => true,
'query_var' => 'event',
'show_ui' => true,
'capability_type' => 'post',
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'excerpt',
'comments',
'revisions',
'administrator',
'custom-fields'
),
'register_meta_box_cb' => 'add_events_metaboxes',
)
);
}
/* When the post is saved, save our custom data */
function neuf_events_save_post( $post_id, $post ) {
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if ( !array_key_exists('neuf_events_nonce', $_POST) || !wp_verify_nonce( $_POST['neuf_events_nonce'], 'neuf_events_nonce' )) {
return $post_id;
}
// If this is an auto save routine, our form has not been submitted,
// and we do nothing.
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
// Check permissions
if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id;
// Date strings are converted to unix time
$tosave['_neuf_events_starttime'] = strtotime( $_POST['_neuf_events_starttime'] );
$tosave['_neuf_events_endtime'] = strtotime( $_POST['_neuf_events_endtime'] );
$tosave['_neuf_events_price_regular'] = $_POST['_neuf_events_price_regular'];
$tosave['_neuf_events_price_member'] = $_POST['_neuf_events_price_member'];
$tosave['_neuf_events_bs_url'] = $_POST['_neuf_events_bs_url'];
$tosave['_neuf_events_fb_url'] = $_POST['_neuf_events_fb_url'];
$tosave['_neuf_events_venue'] = $_POST['_neuf_events_venue'];
$tosave['_neuf_events_promo_period'] = $_POST['_neuf_events_promo_period'];
// Update or add post meta
foreach($tosave as $key=>$value)
if(!update_post_meta($post_id, $key, $value)) {
add_post_meta($post_id, $key, $value, true);
}
return $post_id;
}
/** Sample table view of events */
function neuf_events_program() {
global $post, $wp_locale;
$events = new WP_Query( array(
'post_type' => 'event',
'posts_per_page' => -1,
'meta_key' => '_neuf_events_starttime',
'orderby' => 'meta_value',
'order' => 'ASC'
) );
if ( $events->have_posts() ) :
$date = "";
ob_start();
echo '<table class="event-table">';
while ( $events->have_posts() ) : $events->the_post();
$venue = get_post_meta( $post->ID, '_neuf_events_venue', true);
$price_regular = get_post_meta( $post->ID, '_neuf_events_price_regular', true);
$price_member = get_post_meta( $post->ID, '_neuf_events_price_member', true);
$time = get_post_meta( $post->ID, '_neuf_events_starttime', true);
?>
<tr>
<td class="day">
<?php echo date('l d. F', $time); ?>
</td>
<td class="time">
kl <?php echo date("H.i", $time); ?>
</td>
<td class="title">
<a href="<?php the_permalink();?>"><?php the_title();?></a>
</td>
<td class="place">
<?php echo $venue;?>
</td>
</tr>
<?php
endwhile;
echo '</table><!-- .event-table -->';
endif;
$html = ob_get_contents();
ob_end_clean();
return $html;
}
?>
@@ -0,0 +1,82 @@
<?php
/**
* Adds a custom taxonomy 'event_type'.
*
* We use the taxonomy to differ between different event types, such as concerts, movie screenings and parties. The taxonomy can also be applied to regular posts, so that you can assign terms to a news story. This way, we are able to showcase relevant events alongside our news articles.
*/
function neuf_events_register_taxonomies() {
$labels = array(
'name' => __('Event Type', 'neuf_event'), //Arrangementstype
'singular_name' => __('Event Type', 'neuf_event'),
'search_items' => __('Search Event Types', 'neuf_event'),//'S&oslash;k etter arrangementstype',
'all_items' => __('All Event Types', 'neuf_event'),
'parent_item' => __('Subtype of', 'neuf_event'),//'Undertype av',
'parent_item_colon' => __('Subtype of:', 'neuf_event'),//'Undertype av:',
'edit_item' => __('Edit Event Type', 'neuf_event'),
'update_item' => __('Update Event Type', 'neuf_event'),
'add_new_item' => __('Add New Event Type', 'neuf_event'),
'new_item_name' => __('Name', 'neuf_event'),//'Navn p&aring; ny arrangementstype',
'menu_name' => __('Event Types', 'neuf_event'),
);
register_taxonomy( 'event_type', array(
'post',
'event'
), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array(
'slug' => 'eventtypes',
'hierarchical' => true
)
) );
}
/**
* Extend post_class() to include event type classes.
*
* post_class() is called to output semantic classes to post elements. In this function, we add a class for each event type associated with the post.
*
* In the neuf-old-style theme, consider using neuf_post_class() instead. (Defined in the theme's functions.php.)
*
* This function was originally written to be able to display different icons on different types of events.
*/
function neuf_post_class_event_type( $classes ) {
global $post;
if ( is_object_in_taxonomy( $post->post_type, 'event_type' ) ) {
foreach ( (array) get_the_terms ( $post->ID , 'event_type' ) as $event_type ) {
if ( empty( $event_type->slug ) )
continue;
$classes[] = 'event-type-' . sanitize_html_class( $event_type->slug, $event_type->term_id);
}
}
return $classes;
}
add_filter( 'post_class', 'neuf_post_class_event_type' );
/* Default terms for custom taxonomies */
function neuf_events_set_default_object_terms( $post_id, $post ) {
/* Make sure it's an event */
if ( !isset($_POST['post_type']) || $_POST['post_type'] !== 'event' ) {
return;
}
/* Taxonomy => array of default terms */
$defaults = array(
'event_type' => array( 'annet' ),
);
$taxonomies = get_object_taxonomies( $_POST['post_type'] );
foreach ( (array) $taxonomies as $taxonomy ) {
$terms = wp_get_post_terms( $post_id, $taxonomy );
/* No tax terms assoc with post? */
if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) {
/* ... then add defaults */
wp_set_object_terms( $post_id, $defaults[$taxonomy], $taxonomy );
}
}
}
add_action( 'save_post', 'neuf_events_set_default_object_terms', 100, 2 );
?>
@@ -0,0 +1,48 @@
<?php
/*
Plugin Name: neuf-events
Plugin URI: http://www.studentersamfundet.no
Description: Events custom post type
Version: 0.3
Author: EDB-web
Author URI: http://www.studentersamfundet.no
License: GPL v2 or later
*/
/* TODO (nikolark):
* - Pickup stuff from: http://codex.wordpress.org/Post_Types
*/
require_once( 'neuf-events-post-types.php' );
require_once( 'neuf-events-admin.php' );
require_once( 'neuf-events-taxonomies.php' );
/* Register the translations */
add_action( 'init' , 'neuf_events_i18n' , 0 );
/* Register the event post type */
add_action( 'init' , 'neuf_events_post_type' , 0 );
add_action( 'save_post' , 'neuf_events_save_post', 100, 2);
add_action( 'publish_neuf_events' , 'neuf_events_publish' );
/* Register taxonomies */
add_action( 'init' , 'neuf_events_register_taxonomies', 1 );
/* Register shortcode for sample table view of program. */
add_shortcode( 'neuf-events-program' , 'neuf_events_program' );
function neuf_events_i18n() {
load_plugin_textdomain( 'neuf_event', false, dirname( plugin_basename( __FILE__ ) ) .'/languages' );
}
/* JSON API controller */
function add_events_controller($controllers) {
$controllers[] = 'events';
return $controllers;
}
add_filter('json_api_controllers', 'add_events_controller');
function set_events_controller_path() {
return WP_PLUGIN_DIR."/".dirname( plugin_basename( __FILE__ ))."/neuf-events-json-controller.php";
}
add_filter('json_api_events_controller_path', 'set_events_controller_path');
?>
@@ -0,0 +1,16 @@
/*!
* jQuery JavaScript Library v1.5.1
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Wed Feb 23 13:55:29 2011 -0500
*/
(function(a,b){function cg(a){return d.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cd(a){if(!bZ[a]){var b=d("<"+a+">").appendTo("body"),c=b.css("display");b.remove();if(c==="none"||c==="")c="block";bZ[a]=c}return bZ[a]}function cc(a,b){var c={};d.each(cb.concat.apply([],cb.slice(0,b)),function(){c[this]=a});return c}function bY(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function bX(){try{return new a.XMLHttpRequest}catch(b){}}function bW(){d(a).unload(function(){for(var a in bU)bU[a](0,1)})}function bQ(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var e=a.dataTypes,f={},g,h,i=e.length,j,k=e[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h==="string"&&(f[h.toLowerCase()]=a.converters[h]);l=k,k=e[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=f[m]||f["* "+k];if(!n){p=b;for(o in f){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=f[j[1]+" "+k];if(p){o=f[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&d.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function bP(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function bO(a,b,c,e){if(d.isArray(b)&&b.length)d.each(b,function(b,f){c||bq.test(a)?e(a,f):bO(a+"["+(typeof f==="object"||d.isArray(f)?b:"")+"]",f,c,e)});else if(c||b==null||typeof b!=="object")e(a,b);else if(d.isArray(b)||d.isEmptyObject(b))e(a,"");else for(var f in b)bO(a+"["+f+"]",b[f],c,e)}function bN(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bH,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l==="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bN(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bN(a,c,d,e,"*",g));return l}function bM(a){return function(b,c){typeof b!=="string"&&(c=b,b="*");if(d.isFunction(c)){var e=b.toLowerCase().split(bB),f=0,g=e.length,h,i,j;for(;f<g;f++)h=e[f],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bo(a,b,c){var e=b==="width"?bi:bj,f=b==="width"?a.offsetWidth:a.offsetHeight;if(c==="border")return f;d.each(e,function(){c||(f-=parseFloat(d.css(a,"padding"+this))||0),c==="margin"?f+=parseFloat(d.css(a,"margin"+this))||0:f-=parseFloat(d.css(a,"border"+this+"Width"))||0});return f}function ba(a,b){b.src?d.ajax({url:b.src,async:!1,dataType:"script"}):d.globalEval(b.text||b.textContent||b.innerHTML||""),b.parentNode&&b.parentNode.removeChild(b)}function _(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function $(a,b){if(b.nodeType===1){var c=b.nodeName.toLowerCase();b.clearAttributes(),b.mergeAttributes(a);if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(d.expando)}}function Z(a,b){if(b.nodeType===1&&d.hasData(a)){var c=d.expando,e=d.data(a),f=d.data(b,e);if(e=e[c]){var g=e.events;f=f[c]=d.extend({},e);if(g){delete f.handle,f.events={};for(var h in g)for(var i=0,j=g[h].length;i<j;i++)d.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function Y(a,b){return d.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function O(a,b,c){if(d.isFunction(b))return d.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return d.grep(a,function(a,d){return a===b===c});if(typeof b==="string"){var e=d.grep(a,function(a){return a.nodeType===1});if(J.test(b))return d.filter(b,e,!c);b=d.filter(b,e)}return d.grep(a,function(a,e){return d.inArray(a,b)>=0===c})}function N(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function F(a,b){return(a&&a!=="*"?a+".":"")+b.replace(r,"`").replace(s,"&")}function E(a){var b,c,e,f,g,h,i,j,k,l,m,n,o,q=[],r=[],s=d._data(this,"events");if(a.liveFired!==this&&s&&s.live&&!a.target.disabled&&(!a.button||a.type!=="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var t=s.live.slice(0);for(i=0;i<t.length;i++)g=t[i],g.origType.replace(p,"")===a.type?r.push(g.selector):t.splice(i--,1);f=d(a.target).closest(r,a.currentTarget);for(j=0,k=f.length;j<k;j++){m=f[j];for(i=0;i<t.length;i++){g=t[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,e=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,e=d(a.relatedTarget).closest(g.selector)[0];(!e||e!==h)&&q.push({elem:h,handleObj:g,level:m.level}Line truncated
@@ -0,0 +1,165 @@
/*!
* jQuery UI 1.8.12
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI
*/
(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.12",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,
NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,
"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");
if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f,
"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,
d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}});
c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&
b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery);
;/*!
* jQuery UI Widget 1.8.12
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Widget
*/
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
;/*!
* jQuery UI Mouse 1.8.12
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Mouse
*
* Depends:
* jquery.ui.widget.js
*/
(function(b){b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(c){return a._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===b.data(c.target,a.widgetName+".preventClickEvent")){b.removeData(c.target,a.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(a){a.originalEvent=
a.originalEvent||{};if(!a.originalEvent.mouseHandled){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var c=this,e=a.which==1,f=typeof this.options.cancel=="string"?b(a.target).parents().add(a.target).filter(this.options.cancel).length:false;if(!e||f||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=
this._mouseStart(a)!==false;if(!this._mouseStarted){a.preventDefault();return true}}true===b.data(a.target,this.widgetName+".preventClickEvent")&&b.removeData(a.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(d){return c._mouseMove(d)};this._mouseUpDelegate=function(d){return c._mouseUp(d)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);a.preventDefault();return a.originalEvent.mouseHandled=
true}},_mouseMove:function(a){if(b.browser.msie&&!(document.documentMode>=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);
if(this._mouseStarted){this._mouseStarted=false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
;/*
* jQuery UI Slider 1.8.12
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Slider
*
* Depends:
* jquery.ui.core.js
* jquery.ui.mouse.js
* jquery.ui.widget.js
*/
(function(d){d.widget("ui.slider",d.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var b=this,a=this.options;this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all");a.disabled&&this.element.addClass("ui-slider-disabled ui-disabled");
this.range=d([]);if(a.range){if(a.range===true){this.range=d("<div></div>");if(!a.values)a.values=[this._valueMin(),this._valueMin()];if(a.values.length&&a.values.length!==2)a.values=[a.values[0],a.values[0]]}else this.range=d("<div></div>");this.range.appendTo(this.element).addClass("ui-slider-range");if(a.range==="min"||a.range==="max")this.range.addClass("ui-slider-range-"+a.range);this.range.addClass("ui-widget-header")}d(".ui-slider-handle",this.element).length===0&&d("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");
if(a.values&&a.values.length)for(;d(".ui-slider-handle",this.element).length<a.values.length;)d("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");this.handles=d(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(c){c.preventDefault()}).hover(function(){a.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){if(a.disabled)d(this).blur();
else{d(".ui-slider .ui-state-focus").removeClass("ui-state-focus");d(this).addClass("ui-state-focus")}}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(c){d(this).data("index.ui-slider-handle",c)});this.handles.keydown(function(c){var e=true,f=d(this).data("index.ui-slider-handle"),h,g,i;if(!b.options.disabled){switch(c.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:e=
false;if(!b._keySliding){b._keySliding=true;d(this).addClass("ui-state-active");h=b._start(c,f);if(h===false)return}break}i=b.options.step;h=b.options.values&&b.options.values.length?(g=b.values(f)):(g=b.value());switch(c.keyCode){case d.ui.keyCode.HOME:g=b._valueMin();break;case d.ui.keyCode.END:g=b._valueMax();break;case d.ui.keyCode.PAGE_UP:g=b._trimAlignValue(h+(b._valueMax()-b._valueMin())/5);break;case d.ui.keyCode.PAGE_DOWN:g=b._trimAlignValue(h-(b._valueMax()-b._valueMin())/5);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(h===
b._valueMax())return;g=b._trimAlignValue(h+i);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(h===b._valueMin())return;g=b._trimAlignValue(h-i);break}b._slide(c,f,g);return e}}).keyup(function(c){var e=d(this).data("index.ui-slider-handle");if(b._keySliding){b._keySliding=false;b._stop(c,e);b._change(c,e);d(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");
this._mouseDestroy();return this},_mouseCapture:function(b){var a=this.options,c,e,f,h,g;if(a.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:b.pageX,y:b.pageY});e=this._valueMax()-this._valueMin()+1;h=this;this.handles.each(function(i){var j=Math.abs(c-h.values(i));if(e>j){e=j;f=d(this);g=i}});if(a.range===true&&this.values(1)===a.min){g+=1;f=d(this.handles[g])}if(this._start(b,
g)===false)return false;this._mouseSliding=true;h._handleIndex=g;f.addClass("ui-state-active").focus();a=f.offset();this._clickOffset=!d(b.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:b.pageX-a.left-f.width()/2,top:b.pageY-a.top-f.height()/2-(parseInt(f.css("borderTopWidth"),10)||0)-(parseInt(f.css("borderBottomWidth"),10)||0)+(parseInt(f.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(b,g,c);return this._animateOff=true},_mouseStart:function(){return true},
_mouseDrag:function(b){var a=this._normValueFromMouse({x:b.pageX,y:b.pageY});this._slide(b,this._handleIndex,a);return false},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(b){var a;
if(this.orientation==="horizontal"){a=this.elementSize.width;b=b.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{a=this.elementSize.height;b=b.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}a=b/a;if(a>1)a=1;if(a<0)a=0;if(this.orientation==="vertical")a=1-a;b=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+a*b)},_start:function(b,a){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=
this.values(a);c.values=this.values()}return this._trigger("start",b,c)},_slide:function(b,a,c){var e;if(this.options.values&&this.options.values.length){e=this.values(a?0:1);if(this.options.values.length===2&&this.options.range===true&&(a===0&&c>e||a===1&&c<e))c=e;if(c!==this.values(a)){e=this.values();e[a]=c;b=this._trigger("slide",b,{handle:this.handles[a],value:c,values:e});this.values(a?0:1);b!==false&&this.values(a,c,true)}}else if(c!==this.value()){b=this._trigger("slide",b,{handle:this.handles[a],
value:c});b!==false&&this.value(c)}},_stop:function(b,a){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}this._trigger("stop",b,c)},_change:function(b,a){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}this._trigger("change",b,c)}},value:function(b){if(arguments.length){this.options.value=
this._trimAlignValue(b);this._refreshValue();this._change(null,0)}else return this._value()},values:function(b,a){var c,e,f;if(arguments.length>1){this.options.values[b]=this._trimAlignValue(a);this._refreshValue();this._change(null,b)}else if(arguments.length)if(d.isArray(arguments[0])){c=this.options.values;e=arguments[0];for(f=0;f<c.length;f+=1){c[f]=this._trimAlignValue(e[f]);this._change(null,f)}this._refreshValue()}else return this.options.values&&this.options.values.length?this._values(b):
this.value();else return this._values()},_setOption:function(b,a){var c,e=0;if(d.isArray(this.options.values))e=this.options.values.length;d.Widget.prototype._setOption.apply(this,arguments);switch(b){case "disabled":if(a){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.attr("disabled","disabled");this.element.addClass("ui-disabled")}else{this.handles.removeAttr("disabled");this.element.removeClass("ui-disabled")}break;case "orientation":this._detectOrientation();
this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case "value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case "values":this._animateOff=true;this._refreshValue();for(c=0;c<e;c+=1)this._change(null,c);this._animateOff=false;break}},_value:function(){var b=this.options.value;return b=this._trimAlignValue(b)},_values:function(b){var a,c;if(arguments.length){a=this.options.values[b];
return a=this._trimAlignValue(a)}else{a=this.options.values.slice();for(c=0;c<a.length;c+=1)a[c]=this._trimAlignValue(a[c]);return a}},_trimAlignValue:function(b){if(b<=this._valueMin())return this._valueMin();if(b>=this._valueMax())return this._valueMax();var a=this.options.step>0?this.options.step:1,c=(b-this._valueMin())%a;alignValue=b-c;if(Math.abs(c)*2>=a)alignValue+=c>0?a:-a;return parseFloat(alignValue.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},
_refreshValue:function(){var b=this.options.range,a=this.options,c=this,e=!this._animateOff?a.animate:false,f,h={},g,i,j,l;if(this.options.values&&this.options.values.length)this.handles.each(function(k){f=(c.values(k)-c._valueMin())/(c._valueMax()-c._valueMin())*100;h[c.orientation==="horizontal"?"left":"bottom"]=f+"%";d(this).stop(1,1)[e?"animate":"css"](h,a.animate);if(c.options.range===true)if(c.orientation==="horizontal"){if(k===0)c.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},a.animate);
if(k===1)c.range[e?"animate":"css"]({width:f-g+"%"},{queue:false,duration:a.animate})}else{if(k===0)c.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},a.animate);if(k===1)c.range[e?"animate":"css"]({height:f-g+"%"},{queue:false,duration:a.animate})}g=f});else{i=this.value();j=this._valueMin();l=this._valueMax();f=l!==j?(i-j)/(l-j)*100:0;h[c.orientation==="horizontal"?"left":"bottom"]=f+"%";this.handle.stop(1,1)[e?"animate":"css"](h,a.animate);if(b==="min"&&this.orientation==="horizontal")this.range.stop(1,
1)[e?"animate":"css"]({width:f+"%"},a.animate);if(b==="max"&&this.orientation==="horizontal")this.range[e?"animate":"css"]({width:100-f+"%"},{queue:false,duration:a.animate});if(b==="min"&&this.orientation==="vertical")this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},a.animate);if(b==="max"&&this.orientation==="vertical")this.range[e?"animate":"css"]({height:100-f+"%"},{queue:false,duration:a.animate})}}});d.extend(d.ui.slider,{version:"1.8.12"})})(jQuery);
;/*
* jQuery UI Datepicker 1.8.12
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Datepicker
*
* Depends:
* jquery.ui.core.js
*/
(function(d,A){function K(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._inDialog=this._datepickerShowing=false;this._mainDivId="ui-datepicker-div";this._inlineClass="ui-datepicker-inline";this._appendClass="ui-datepicker-append";this._triggerClass="ui-datepicker-trigger";this._dialogClass="ui-datepicker-dialog";this._disableClass="ui-datepicker-disabled";this._unselectableClass="ui-datepicker-unselectable";this._currentClass="ui-datepicker-current-day";this._dayOverClass=
"ui-datepicker-days-cell-over";this.regional=[];this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su",
"Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:false,showMonthAfterYear:false,yearSuffix:""};this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:false,hideIfNoPrevNext:false,navigationAsDateFormat:false,gotoCurrent:false,changeMonth:false,changeYear:false,yearRange:"c-10:c+10",showOtherMonths:false,selectOtherMonths:false,showWeek:false,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",
minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:true,showButtonPanel:false,autoSize:false};d.extend(this._defaults,this.regional[""]);this.dpDiv=d('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')}function F(a,b){d.extend(a,b);for(var c in b)if(b[c]==
null||b[c]==A)a[c]=b[c];return a}d.extend(d.ui,{datepicker:{version:"1.8.12"}});var y=(new Date).getTime();d.extend(K.prototype,{markerClassName:"hasDatepicker",log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){F(this._defaults,a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();
f=e=="div"||e=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input")this._connectDatepicker(a,i);else f&&this._inlineDatepicker(a,i)},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:d('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')}},
_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&
b.append.remove();if(c){b.append=d('<span class="'+this._appendClass+'">'+c+"</span>");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c=="focus"||c=="both")a.focus(this._showDatepicker);if(c=="button"||c=="both"){c=this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d("<img/>").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d('<button type="button"></button>').addClass(this._triggerClass).html(f==
""?c:d("<img/>").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker():d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;g<f.length;g++)if(f[g].length>h){h=f[g].length;i=g}return i};b.setMonth(e(this._get(a,
c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),
true);this._updateDatepicker(b);this._updateAlternate(b);b.dpDiv.show()}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){this.uuid+=1;this._dialogInput=d('<input type="text" id="'+("dp"+this.uuid)+'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}F(a.settings,e||{});
b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos)this._pos=[document.documentElement.clientWidth/2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)];this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);
this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",
this._doKeyUp)}else if(e=="div"||e=="span")b.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=false;c.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else if(e=="div"||e=="span")b.children("."+this._inlineClass).children().removeClass("ui-state-disabled");this._disabledInputs=d.map(this._disabledInputs,
function(f){return f==a?null:f})}},_disableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=true;c.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",cursor:"default"})}else if(e=="div"||e=="span")b.children("."+this._inlineClass).children().addClass("ui-state-disabled");this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:
f});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(a){if(!a)return false;for(var b=0;b<this._disabledInputs.length;b++)if(this._disabledInputs[b]==a)return true;return false},_getInst:function(a){try{return d.data(a,"datepicker")}catch(b){throw"Missing instance data for this datepicker";}},_optionDatepicker:function(a,b,c){var e=this._getInst(a);if(arguments.length==2&&typeof b=="string")return b=="defaults"?d.extend({},d.datepicker._defaults):e?b=="all"?d.extend({},
e.settings):this._get(e,b):null;var f=b||{};if(typeof b=="string"){f={};f[b]=c}if(e){this._curInst==e&&this._hideDatepicker();var h=this._getDateDatepicker(a,true),i=this._getMinMaxDate(e,"min"),g=this._getMinMaxDate(e,"max");F(e.settings,f);if(i!==null&&f.dateFormat!==A&&f.minDate===A)e.settings.minDate=this._formatDate(e,i);if(g!==null&&f.dateFormat!==A&&f.maxDate===A)e.settings.maxDate=this._formatDate(e,g);this._attachments(d(a),e);this._autoSize(e);this._setDateDatepicker(a,h);this._updateDatepicker(e)}},
_changeDatepicker:function(a,b,c){this._optionDatepicker(a,b,c)},_refreshDatepicker:function(a){(a=this._getInst(a))&&this._updateDatepicker(a)},_setDateDatepicker:function(a,b){if(a=this._getInst(a)){this._setDate(a,b);this._updateDatepicker(a);this._updateAlternate(a)}},_getDateDatepicker:function(a,b){(a=this._getInst(a))&&!a.inline&&this._setDateFromField(a,b);return a?this._getDate(a):null},_doKeyDown:function(a){var b=d.datepicker._getInst(a.target),c=true,e=b.dpDiv.is(".ui-datepicker-rtl");
b._keyEvent=true;if(d.datepicker._datepickerShowing)switch(a.keyCode){case 9:d.datepicker._hideDatepicker();c=false;break;case 13:c=d("td."+d.datepicker._dayOverClass+":not(."+d.datepicker._currentClass+")",b.dpDiv);c[0]?d.datepicker._selectDay(a.target,b.selectedMonth,b.selectedYear,c[0]):d.datepicker._hideDatepicker();return false;case 27:d.datepicker._hideDatepicker();break;case 33:d.datepicker._adjustDate(a.target,a.ctrlKey?-d.datepicker._get(b,"stepBigMonths"):-d.datepicker._get(b,"stepMonths"),
"M");break;case 34:d.datepicker._adjustDate(a.target,a.ctrlKey?+d.datepicker._get(b,"stepBigMonths"):+d.datepicker._get(b,"stepMonths"),"M");break;case 35:if(a.ctrlKey||a.metaKey)d.datepicker._clearDate(a.target);c=a.ctrlKey||a.metaKey;break;case 36:if(a.ctrlKey||a.metaKey)d.datepicker._gotoToday(a.target);c=a.ctrlKey||a.metaKey;break;case 37:if(a.ctrlKey||a.metaKey)d.datepicker._adjustDate(a.target,e?+1:-1,"D");c=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey)d.datepicker._adjustDate(a.target,a.ctrlKey?
-d.datepicker._get(b,"stepBigMonths"):-d.datepicker._get(b,"stepMonths"),"M");break;case 38:if(a.ctrlKey||a.metaKey)d.datepicker._adjustDate(a.target,-7,"D");c=a.ctrlKey||a.metaKey;break;case 39:if(a.ctrlKey||a.metaKey)d.datepicker._adjustDate(a.target,e?-1:+1,"D");c=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey)d.datepicker._adjustDate(a.target,a.ctrlKey?+d.datepicker._get(b,"stepBigMonths"):+d.datepicker._get(b,"stepMonths"),"M");break;case 40:if(a.ctrlKey||a.metaKey)d.datepicker._adjustDate(a.target,
+7,"D");c=a.ctrlKey||a.metaKey;break;default:c=false}else if(a.keyCode==36&&a.ctrlKey)d.datepicker._showDatepicker(this);else c=false;if(c){a.preventDefault();a.stopPropagation()}},_doKeyPress:function(a){var b=d.datepicker._getInst(a.target);if(d.datepicker._get(b,"constrainInput")){b=d.datepicker._possibleChars(d.datepicker._get(b,"dateFormat"));var c=String.fromCharCode(a.charCode==A?a.keyCode:a.charCode);return a.ctrlKey||a.metaKey||c<" "||!b||b.indexOf(c)>-1}},_doKeyUp:function(a){a=d.datepicker._getInst(a.target);
if(a.input.val()!=a.lastVal)try{if(d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),a.input?a.input.val():null,d.datepicker._getFormatConfig(a))){d.datepicker._setDateFromField(a);d.datepicker._updateAlternate(a);d.datepicker._updateDatepicker(a)}}catch(b){d.datepicker.log(b)}return true},_showDatepicker:function(a){a=a.target||a;if(a.nodeName.toLowerCase()!="input")a=d("input",a.parentNode)[0];if(!(d.datepicker._isDisabledDatepicker(a)||d.datepicker._lastInput==a)){var b=d.datepicker._getInst(a);
d.datepicker._curInst&&d.datepicker._curInst!=b&&d.datepicker._curInst.dpDiv.stop(true,true);var c=d.datepicker._get(b,"beforeShow");F(b.settings,c?c.apply(a,[a,b]):{});b.lastVal=null;d.datepicker._lastInput=a;d.datepicker._setDateFromField(b);if(d.datepicker._inDialog)a.value="";if(!d.datepicker._pos){d.datepicker._pos=d.datepicker._findPos(a);d.datepicker._pos[1]+=a.offsetHeight}var e=false;d(a).parents().each(function(){e|=d(this).css("position")=="fixed";return!e});if(e&&d.browser.opera){d.datepicker._pos[0]-=
document.documentElement.scrollLeft;d.datepicker._pos[1]-=document.documentElement.scrollTop}c={left:d.datepicker._pos[0],top:d.datepicker._pos[1]};d.datepicker._pos=null;b.dpDiv.empty();b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});d.datepicker._updateDatepicker(b);c=d.datepicker._checkOffset(b,c,e);b.dpDiv.css({position:d.datepicker._inDialog&&d.blockUI?"static":e?"fixed":"absolute",display:"none",left:c.left+"px",top:c.top+"px"});if(!b.inline){c=d.datepicker._get(b,"showAnim");
var f=d.datepicker._get(b,"duration"),h=function(){d.datepicker._datepickerShowing=true;var i=b.dpDiv.find("iframe.ui-datepicker-cover");if(i.length){var g=d.datepicker._getBorders(b.dpDiv);i.css({left:-g[0],top:-g[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex(d(a).zIndex()+1);d.effects&&d.effects[c]?b.dpDiv.show(c,d.datepicker._get(b,"showOptions"),f,h):b.dpDiv[c||"show"](c?f:null,h);if(!c||!f)h();b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus();d.datepicker._curInst=
b}}},_updateDatepicker:function(a){var b=this,c=d.datepicker._getBorders(a.dpDiv);a.dpDiv.empty().append(this._generateHTML(a));var e=a.dpDiv.find("iframe.ui-datepicker-cover");e.length&&e.css({left:-c[0],top:-c[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()});a.dpDiv.find("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a").bind("mouseout",function(){d(this).removeClass("ui-state-hover");this.className.indexOf("ui-datepicker-prev")!=-1&&d(this).removeClass("ui-datepicker-prev-hover");
this.className.indexOf("ui-datepicker-next")!=-1&&d(this).removeClass("ui-datepicker-next-hover")}).bind("mouseover",function(){if(!b._isDisabledDatepicker(a.inline?a.dpDiv.parent()[0]:a.input[0])){d(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");d(this).addClass("ui-state-hover");this.className.indexOf("ui-datepicker-prev")!=-1&&d(this).addClass("ui-datepicker-prev-hover");this.className.indexOf("ui-datepicker-next")!=-1&&d(this).addClass("ui-datepicker-next-hover")}}).end().find("."+
this._dayOverClass+" a").trigger("mouseover").end();c=this._getNumberOfMonths(a);e=c[1];e>1?a.dpDiv.addClass("ui-datepicker-multi-"+e).css("width",17*e+"em"):a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");a.dpDiv[(c[0]!=1||c[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");a==d.datepicker._curInst&&d.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&
a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var f=a.yearshtml;setTimeout(function(){f===a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml);f=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(c){return{thin:1,medium:2,thick:3}[c]||c};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var e=a.dpDiv.outerWidth(),f=a.dpDiv.outerHeight(),h=a.input?a.input.outerWidth():
0,i=a.input?a.input.outerHeight():0,g=document.documentElement.clientWidth+d(document).scrollLeft(),j=document.documentElement.clientHeight+d(document).scrollTop();b.left-=this._get(a,"isRTL")?e-h:0;b.left-=c&&b.left==a.input.offset().left?d(document).scrollLeft():0;b.top-=c&&b.top==a.input.offset().top+i?d(document).scrollTop():0;b.left-=Math.min(b.left,b.left+e>g&&g>e?Math.abs(b.left+e-g):0);b.top-=Math.min(b.top,b.top+f>j&&j>f?Math.abs(f+i):0);return b},_findPos:function(a){for(var b=this._get(this._getInst(a),
"isRTL");a&&(a.type=="hidden"||a.nodeType!=1||d.expr.filters.hidden(a));)a=a[b?"previousSibling":"nextSibling"];a=d(a).offset();return[a.left,a.top]},_hideDatepicker:function(a){var b=this._curInst;if(!(!b||a&&b!=d.data(a,"datepicker")))if(this._datepickerShowing){a=this._get(b,"showAnim");var c=this._get(b,"duration"),e=function(){d.datepicker._tidyDialog(b);this._curInst=null};d.effects&&d.effects[a]?b.dpDiv.hide(a,d.datepicker._get(b,"showOptions"),c,e):b.dpDiv[a=="slideDown"?"slideUp":a=="fadeIn"?
"fadeOut":"hide"](a?c:null,e);a||e();if(a=this._get(b,"onClose"))a.apply(b.input?b.input[0]:null,[b.input?b.input.val():"",b]);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",left:"0",top:"-100px"});if(d.blockUI){d.unblockUI();d("body").append(this.dpDiv)}}this._inDialog=false}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(d.datepicker._curInst){a=
d(a.target);a[0].id!=d.datepicker._mainDivId&&a.parents("#"+d.datepicker._mainDivId).length==0&&!a.hasClass(d.datepicker.markerClassName)&&!a.hasClass(d.datepicker._triggerClass)&&d.datepicker._datepickerShowing&&!(d.datepicker._inDialog&&d.blockUI)&&d.datepicker._hideDatepicker()}},_adjustDate:function(a,b,c){a=d(a);var e=this._getInst(a[0]);if(!this._isDisabledDatepicker(a[0])){this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):0),c);this._updateDatepicker(e)}},_gotoToday:function(a){a=
d(a);var b=this._getInst(a[0]);if(this._get(b,"gotoCurrent")&&b.currentDay){b.selectedDay=b.currentDay;b.drawMonth=b.selectedMonth=b.currentMonth;b.drawYear=b.selectedYear=b.currentYear}else{var c=new Date;b.selectedDay=c.getDate();b.drawMonth=b.selectedMonth=c.getMonth();b.drawYear=b.selectedYear=c.getFullYear()}this._notifyChange(b);this._adjustDate(a)},_selectMonthYear:function(a,b,c){a=d(a);var e=this._getInst(a[0]);e._selectingMonthYear=false;e["selected"+(c=="M"?"Month":"Year")]=e["draw"+(c==
"M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_clickMonthYear:function(a){var b=this._getInst(d(a)[0]);b.input&&b._selectingMonthYear&&setTimeout(function(){b.input.focus()},0);b._selectingMonthYear=!b._selectingMonthYear},_selectDay:function(a,b,c,e){var f=d(a);if(!(d(e).hasClass(this._unselectableClass)||this._isDisabledDatepicker(f[0]))){f=this._getInst(f[0]);f.selectedDay=f.currentDay=d("a",e).html();f.selectedMonth=f.currentMonth=
b;f.selectedYear=f.currentYear=c;this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))}},_clearDate:function(a){a=d(a);this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,b){a=this._getInst(d(a)[0]);b=b!=null?b:this._formatDate(a);a.input&&a.input.val(b);this._updateAlternate(a);var c=this._get(a,"onSelect");if(c)c.apply(a.input?a.input[0]:null,[b,a]);else a.input&&a.input.trigger("change");if(a.inline)this._updateDatepicker(a);else{this._hideDatepicker();
this._lastInput=a.input[0];typeof a.input[0]!="object"&&a.input.focus();this._lastInput=null}},_updateAlternate:function(a){var b=this._get(a,"altField");if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),f=this.formatDate(c,e,this._getFormatConfig(a));d(b).each(function(){d(this).val(f)})}},noWeekends:function(a){a=a.getDay();return[a>0&&a<6,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b=a.getTime();a.setMonth(0);
a.setDate(1);return Math.floor(Math.round((b-a)/864E5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"?b.toString():b+"";if(b=="")return null;var e=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;e=typeof e!="string"?e:(new Date).getFullYear()%100+parseInt(e,10);for(var f=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,h=(c?c.dayNames:null)||this._defaults.dayNames,i=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?
c.monthNames:null)||this._defaults.monthNames,j=c=-1,l=-1,u=-1,k=false,o=function(p){(p=z+1<a.length&&a.charAt(z+1)==p)&&z++;return p},m=function(p){var v=o(p);p=new RegExp("^\\d{1,"+(p=="@"?14:p=="!"?20:p=="y"&&v?4:p=="o"?3:2)+"}");p=b.substring(s).match(p);if(!p)throw"Missing number at position "+s;s+=p[0].length;return parseInt(p[0],10)},n=function(p,v,H){p=o(p)?H:v;for(v=0;v<p.length;v++)if(b.substr(s,p[v].length).toLowerCase()==p[v].toLowerCase()){s+=p[v].length;return v+1}throw"Unknown name at position "+
s;},r=function(){if(b.charAt(s)!=a.charAt(z))throw"Unexpected literal at position "+s;s++},s=0,z=0;z<a.length;z++)if(k)if(a.charAt(z)=="'"&&!o("'"))k=false;else r();else switch(a.charAt(z)){case "d":l=m("d");break;case "D":n("D",f,h);break;case "o":u=m("o");break;case "m":j=m("m");break;case "M":j=n("M",i,g);break;case "y":c=m("y");break;case "@":var w=new Date(m("@"));c=w.getFullYear();j=w.getMonth()+1;l=w.getDate();break;case "!":w=new Date((m("!")-this._ticksTo1970)/1E4);c=w.getFullYear();j=w.getMonth()+
1;l=w.getDate();break;case "'":if(o("'"))r();else k=true;break;default:r()}if(c==-1)c=(new Date).getFullYear();else if(c<100)c+=(new Date).getFullYear()-(new Date).getFullYear()%100+(c<=e?0:-100);if(u>-1){j=1;l=u;do{e=this._getDaysInMonth(c,j-1);if(l<=e)break;j++;l-=e}while(1)}w=this._daylightSavingAdjust(new Date(c,j-1,l));if(w.getFullYear()!=c||w.getMonth()+1!=j||w.getDate()!=l)throw"Invalid date";return w},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",
RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1E7,formatDate:function(a,b,c){if(!b)return"";var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,h=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort;c=(c?c.monthNames:null)||this._defaults.monthNames;var i=function(o){(o=k+1<a.length&&
a.charAt(k+1)==o)&&k++;return o},g=function(o,m,n){m=""+m;if(i(o))for(;m.length<n;)m="0"+m;return m},j=function(o,m,n,r){return i(o)?r[m]:n[m]},l="",u=false;if(b)for(var k=0;k<a.length;k++)if(u)if(a.charAt(k)=="'"&&!i("'"))u=false;else l+=a.charAt(k);else switch(a.charAt(k)){case "d":l+=g("d",b.getDate(),2);break;case "D":l+=j("D",b.getDay(),e,f);break;case "o":l+=g("o",(b.getTime()-(new Date(b.getFullYear(),0,0)).getTime())/864E5,3);break;case "m":l+=g("m",b.getMonth()+1,2);break;case "M":l+=j("M",
b.getMonth(),h,c);break;case "y":l+=i("y")?b.getFullYear():(b.getYear()%100<10?"0":"")+b.getYear()%100;break;case "@":l+=b.getTime();break;case "!":l+=b.getTime()*1E4+this._ticksTo1970;break;case "'":if(i("'"))l+="'";else u=true;break;default:l+=a.charAt(k)}return l},_possibleChars:function(a){for(var b="",c=false,e=function(h){(h=f+1<a.length&&a.charAt(f+1)==h)&&f++;return h},f=0;f<a.length;f++)if(c)if(a.charAt(f)=="'"&&!e("'"))c=false;else b+=a.charAt(f);else switch(a.charAt(f)){case "d":case "m":case "y":case "@":b+=
"0123456789";break;case "D":case "M":return null;case "'":if(e("'"))b+="'";else c=true;break;default:b+=a.charAt(f)}return b},_get:function(a,b){return a.settings[b]!==A?a.settings[b]:this._defaults[b]},_setDateFromField:function(a,b){if(a.input.val()!=a.lastVal){var c=this._get(a,"dateFormat"),e=a.lastVal=a.input?a.input.val():null,f,h;f=h=this._getDefaultDate(a);var i=this._getFormatConfig(a);try{f=this.parseDate(c,e,i)||h}catch(g){this.log(g);e=b?"":e}a.selectedDay=f.getDate();a.drawMonth=a.selectedMonth=
f.getMonth();a.drawYear=a.selectedYear=f.getFullYear();a.currentDay=e?f.getDate():0;a.currentMonth=e?f.getMonth():0;a.currentYear=e?f.getFullYear():0;this._adjustInstDate(a)}},_getDefaultDate:function(a){return this._restrictMinMax(a,this._determineDate(a,this._get(a,"defaultDate"),new Date))},_determineDate:function(a,b,c){var e=function(h){var i=new Date;i.setDate(i.getDate()+h);return i},f=function(h){try{return d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),h,d.datepicker._getFormatConfig(a))}catch(i){}var g=
(h.toLowerCase().match(/^c/)?d.datepicker._getDate(a):null)||new Date,j=g.getFullYear(),l=g.getMonth();g=g.getDate();for(var u=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,k=u.exec(h);k;){switch(k[2]||"d"){case "d":case "D":g+=parseInt(k[1],10);break;case "w":case "W":g+=parseInt(k[1],10)*7;break;case "m":case "M":l+=parseInt(k[1],10);g=Math.min(g,d.datepicker._getDaysInMonth(j,l));break;case "y":case "Y":j+=parseInt(k[1],10);g=Math.min(g,d.datepicker._getDaysInMonth(j,l));break}k=u.exec(h)}return new Date(j,
l,g)};if(b=(b=b==null||b===""?c:typeof b=="string"?f(b):typeof b=="number"?isNaN(b)?c:e(b):new Date(b.getTime()))&&b.toString()=="Invalid Date"?c:b){b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(0)}return this._daylightSavingAdjust(b)},_daylightSavingAdjust:function(a){if(!a)return null;a.setHours(a.getHours()>12?a.getHours()+2:0);return a},_setDate:function(a,b,c){var e=!b,f=a.selectedMonth,h=a.selectedYear;b=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=
a.currentDay=b.getDate();a.drawMonth=a.selectedMonth=a.currentMonth=b.getMonth();a.drawYear=a.selectedYear=a.currentYear=b.getFullYear();if((f!=a.selectedMonth||h!=a.selectedYear)&&!c)this._notifyChange(a);this._adjustInstDate(a);if(a.input)a.input.val(e?"":this._formatDate(a))},_getDate:function(a){return!a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay))},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),
b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),e=this._get(a,"showButtonPanel"),f=this._get(a,"hideIfNoPrevNext"),h=this._get(a,"navigationAsDateFormat"),i=this._getNumberOfMonths(a),g=this._get(a,"showCurrentAtPos"),j=this._get(a,"stepMonths"),l=i[0]!=1||i[1]!=1,u=this._daylightSavingAdjust(!a.currentDay?new Date(9999,9,9):new Date(a.currentYear,a.currentMonth,a.currentDay)),k=this._getMinMaxDate(a,"min"),o=this._getMinMaxDate(a,"max");g=a.drawMonth-g;var m=a.drawYear;if(g<0){g+=12;m--}if(o){var n=
this._daylightSavingAdjust(new Date(o.getFullYear(),o.getMonth()-i[0]*i[1]+1,o.getDate()));for(n=k&&n<k?k:n;this._daylightSavingAdjust(new Date(m,g,1))>n;){g--;if(g<0){g=11;m--}}}a.drawMonth=g;a.drawYear=m;n=this._get(a,"prevText");n=!h?n:this.formatDate(n,this._daylightSavingAdjust(new Date(m,g-j,1)),this._getFormatConfig(a));n=this._canAdjustMonth(a,-1,m,g)?'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_'+y+".datepicker._adjustDate('#"+a.id+"', -"+j+", 'M');\" title=\""+n+'"><span class="ui-icon ui-icon-circle-triangle-'+
(c?"e":"w")+'">'+n+"</span></a>":f?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+n+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+n+"</span></a>";var r=this._get(a,"nextText");r=!h?r:this.formatDate(r,this._daylightSavingAdjust(new Date(m,g+j,1)),this._getFormatConfig(a));f=this._canAdjustMonth(a,+1,m,g)?'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_'+y+".datepicker._adjustDate('#"+a.id+"', +"+j+", 'M');\" title=\""+r+'"><span class="ui-icon ui-icon-circle-triangle-'+
(c?"w":"e")+'">'+r+"</span></a>":f?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+r+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+r+"</span></a>";j=this._get(a,"currentText");r=this._get(a,"gotoCurrent")&&a.currentDay?u:b;j=!h?j:this.formatDate(j,r,this._getFormatConfig(a));h=!a.inline?'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_'+y+'.datepicker._hideDatepicker();">'+this._get(a,
"closeText")+"</button>":"";e=e?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(c?h:"")+(this._isInRange(a,r)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_'+y+".datepicker._gotoToday('#"+a.id+"');\">"+j+"</button>":"")+(c?"":h)+"</div>":"";h=parseInt(this._get(a,"firstDay"),10);h=isNaN(h)?0:h;j=this._get(a,"showWeek");r=this._get(a,"dayNames");this._get(a,"dayNamesShort");var s=this._get(a,"dayNamesMin"),z=
this._get(a,"monthNames"),w=this._get(a,"monthNamesShort"),p=this._get(a,"beforeShowDay"),v=this._get(a,"showOtherMonths"),H=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var L=this._getDefaultDate(a),I="",D=0;D<i[0];D++){for(var M="",E=0;E<i[1];E++){var N=this._daylightSavingAdjust(new Date(m,g,a.selectedDay)),t=" ui-corner-all",x="";if(l){x+='<div class="ui-datepicker-group';if(i[1]>1)switch(E){case 0:x+=" ui-datepicker-group-first";t=" ui-corner-"+(c?"right":"left");break;case i[1]-
1:x+=" ui-datepicker-group-last";t=" ui-corner-"+(c?"left":"right");break;default:x+=" ui-datepicker-group-middle";t="";break}x+='">'}x+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+t+'">'+(/all|left/.test(t)&&D==0?c?f:n:"")+(/all|right/.test(t)&&D==0?c?n:f:"")+this._generateMonthYearHeader(a,g,m,k,o,D>0||E>0,z,w)+'</div><table class="ui-datepicker-calendar"><thead><tr>';var B=j?'<th class="ui-datepicker-week-col">'+this._get(a,"weekHeader")+"</th>":"";for(t=0;t<7;t++){var q=
(t+h)%7;B+="<th"+((t+h+6)%7>=5?' class="ui-datepicker-week-end"':"")+'><span title="'+r[q]+'">'+s[q]+"</span></th>"}x+=B+"</tr></thead><tbody>";B=this._getDaysInMonth(m,g);if(m==a.selectedYear&&g==a.selectedMonth)a.selectedDay=Math.min(a.selectedDay,B);t=(this._getFirstDayOfMonth(m,g)-h+7)%7;B=l?6:Math.ceil((t+B)/7);q=this._daylightSavingAdjust(new Date(m,g,1-t));for(var O=0;O<B;O++){x+="<tr>";var P=!j?"":'<td class="ui-datepicker-week-col">'+this._get(a,"calculateWeek")(q)+"</td>";for(t=0;t<7;t++){var G=
p?p.apply(a.input?a.input[0]:null,[q]):[true,""],C=q.getMonth()!=g,J=C&&!H||!G[0]||k&&q<k||o&&q>o;P+='<td class="'+((t+h+6)%7>=5?" ui-datepicker-week-end":"")+(C?" ui-datepicker-other-month":"")+(q.getTime()==N.getTime()&&g==a.selectedMonth&&a._keyEvent||L.getTime()==q.getTime()&&L.getTime()==N.getTime()?" "+this._dayOverClass:"")+(J?" "+this._unselectableClass+" ui-state-disabled":"")+(C&&!v?"":" "+G[1]+(q.getTime()==u.getTime()?" "+this._currentClass:"")+(q.getTime()==b.getTime()?" ui-datepicker-today":
""))+'"'+((!C||v)&&G[2]?' title="'+G[2]+'"':"")+(J?"":' onclick="DP_jQuery_'+y+".datepicker._selectDay('#"+a.id+"',"+q.getMonth()+","+q.getFullYear()+', this);return false;"')+">"+(C&&!v?"&#xa0;":J?'<span class="ui-state-default">'+q.getDate()+"</span>":'<a class="ui-state-default'+(q.getTime()==b.getTime()?" ui-state-highlight":"")+(q.getTime()==u.getTime()?" ui-state-active":"")+(C?" ui-priority-secondary":"")+'" href="#">'+q.getDate()+"</a>")+"</td>";q.setDate(q.getDate()+1);q=this._daylightSavingAdjust(q)}x+=
P+"</tr>"}g++;if(g>11){g=0;m++}x+="</tbody></table>"+(l?"</div>"+(i[0]>0&&E==i[1]-1?'<div class="ui-datepicker-row-break"></div>':""):"");M+=x}I+=M}I+=e+(d.browser.msie&&parseInt(d.browser.version,10)<7&&!a.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':"");a._keyEvent=false;return I},_generateMonthYearHeader:function(a,b,c,e,f,h,i,g){var j=this._get(a,"changeMonth"),l=this._get(a,"changeYear"),u=this._get(a,"showMonthAfterYear"),k='<div class="ui-datepicker-title">',
o="";if(h||!j)o+='<span class="ui-datepicker-month">'+i[b]+"</span>";else{i=e&&e.getFullYear()==c;var m=f&&f.getFullYear()==c;o+='<select class="ui-datepicker-month" onchange="DP_jQuery_'+y+".datepicker._selectMonthYear('#"+a.id+"', this, 'M');\" onclick=\"DP_jQuery_"+y+".datepicker._clickMonthYear('#"+a.id+"');\">";for(var n=0;n<12;n++)if((!i||n>=e.getMonth())&&(!m||n<=f.getMonth()))o+='<option value="'+n+'"'+(n==b?' selected="selected"':"")+">"+g[n]+"</option>";o+="</select>"}u||(k+=o+(h||!(j&&
l)?"&#xa0;":""));if(!a.yearshtml){a.yearshtml="";if(h||!l)k+='<span class="ui-datepicker-year">'+c+"</span>";else{g=this._get(a,"yearRange").split(":");var r=(new Date).getFullYear();i=function(s){s=s.match(/c[+-].*/)?c+parseInt(s.substring(1),10):s.match(/[+-].*/)?r+parseInt(s,10):parseInt(s,10);return isNaN(s)?r:s};b=i(g[0]);g=Math.max(b,i(g[1]||""));b=e?Math.max(b,e.getFullYear()):b;g=f?Math.min(g,f.getFullYear()):g;for(a.yearshtml+='<select class="ui-datepicker-year" onchange="DP_jQuery_'+y+".datepicker._selectMonthYear('#"+
a.id+"', this, 'Y');\" onclick=\"DP_jQuery_"+y+".datepicker._clickMonthYear('#"+a.id+"');\">";b<=g;b++)a.yearshtml+='<option value="'+b+'"'+(b==c?' selected="selected"':"")+">"+b+"</option>";a.yearshtml+="</select>";if(d.browser.mozilla)k+='<select class="ui-datepicker-year"><option value="'+c+'" selected="selected">'+c+"</option></select>";else{k+=a.yearshtml;a.yearshtml=null}}}k+=this._get(a,"yearSuffix");if(u)k+=(h||!(j&&l)?"&#xa0;":"")+o;k+="</div>";return k},_adjustInstDate:function(a,b,c){var e=
a.drawYear+(c=="Y"?b:0),f=a.drawMonth+(c=="M"?b:0);b=Math.min(a.selectedDay,this._getDaysInMonth(e,f))+(c=="D"?b:0);e=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(e,f,b)));a.selectedDay=e.getDate();a.drawMonth=a.selectedMonth=e.getMonth();a.drawYear=a.selectedYear=e.getFullYear();if(c=="M"||c=="Y")this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");b=c&&b<c?c:b;return b=a&&b>a?a:b},_notifyChange:function(a){var b=this._get(a,
"onChangeMonthYear");if(b)b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return a==null?[1,1]:typeof a=="number"?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,e){var f=this._getNumberOfMonths(a);
c=this._daylightSavingAdjust(new Date(c,e+(b<0?b:f[0]*f[1]),1));b<0&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!a||b.getTime()<=a.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,
"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,e){if(!b){a.currentDay=a.selectedDay;a.currentMonth=a.selectedMonth;a.currentYear=a.selectedYear}b=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(e,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});d.fn.datepicker=
function(a){if(!this.length)return this;if(!d.datepicker.initialized){d(document).mousedown(d.datepicker._checkExternalClick).find("body").append(d.datepicker.dpDiv);d.datepicker.initialized=true}var b=Array.prototype.slice.call(arguments,1);if(typeof a=="string"&&(a=="isDisabled"||a=="getDate"||a=="widget"))return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b));if(a=="option"&&arguments.length==2&&typeof arguments[1]=="string")return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,
[this[0]].concat(b));return this.each(function(){typeof a=="string"?d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this].concat(b)):d.datepicker._attachDatepicker(this,a)})};d.datepicker=new K;d.datepicker.initialized=false;d.datepicker.uuid=(new Date).getTime();d.datepicker.version="1.8.12";window["DP_jQuery_"+y]=d})(jQuery);
;
@@ -0,0 +1,911 @@
/*
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
* Version 0.9.3
* Last Modified: 02/05/2011
*
* Copyright 2010 Trent Richardson
* Dual licensed under the MIT and GPL licenses.
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
*
* HERES THE CSS:
* .ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
* .ui-timepicker-div dl{ text-align: left; }
* .ui-timepicker-div dl dt{ height: 25px; }
* .ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }
* .ui-timepicker-div td { font-size: 90%; }
*/
(function($) {
$.extend($.ui, { timepicker: { version: "0.9.3" } });
/* Time picker manager.
Use the singleton instance of this class, $.timepicker, to interact with the time picker.
Settings for (groups of) time pickers are maintained in an instance object,
allowing multiple different settings on the same page. */
function Timepicker() {
this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings
currentText: 'Now',
closeText: 'Done',
ampm: false,
timeFormat: 'hh:mm tt',
timeOnlyTitle: 'Choose Time',
timeText: 'Time',
hourText: 'Hour',
minuteText: 'Minute',
secondText: 'Second'
};
this._defaults = { // Global defaults for all the datetime picker instances
showButtonPanel: true,
timeOnly: false,
showHour: true,
showMinute: true,
showSecond: false,
showTime: true,
stepHour: 0.05,
stepMinute: 0.05,
stepSecond: 0.05,
hour: 0,
minute: 0,
second: 0,
hourMin: 0,
minuteMin: 0,
secondMin: 0,
hourMax: 23,
minuteMax: 59,
secondMax: 59,
minDateTime: null,
maxDateTime: null,
hourGrid: 0,
minuteGrid: 0,
secondGrid: 0,
alwaysSetTime: true,
separator: ' ',
altFieldTimeOnly: true,
showTimepicker: true
};
$.extend(this._defaults, this.regional['']);
}
$.extend(Timepicker.prototype, {
$input: null,
$altInput: null,
$timeObj: null,
inst: null,
hour_slider: null,
minute_slider: null,
second_slider: null,
hour: 0,
minute: 0,
second: 0,
hourMinOriginal: null,
minuteMinOriginal: null,
secondMinOriginal: null,
hourMaxOriginal: null,
minuteMaxOriginal: null,
secondMaxOriginal: null,
ampm: '',
formattedDate: '',
formattedTime: '',
formattedDateTime: '',
/* Override the default settings for all instances of the time picker.
@param settings object - the new settings to use as defaults (anonymous object)
@return the manager object */
setDefaults: function(settings) {
extendRemove(this._defaults, settings || {});
return this;
},
//########################################################################
// Create a new Timepicker instance
//########################################################################
_newInst: function($input, o) {
var tp_inst = new Timepicker(),
inlineSettings = {};
tp_inst.hour = tp_inst._defaults.hour;
tp_inst.minute = tp_inst._defaults.minute;
tp_inst.second = tp_inst._defaults.second;
tp_inst.ampm = '';
tp_inst.$input = $input;
for (var attrName in this._defaults) {
var attrValue = $input.attr('time:' + attrName);
if (attrValue) {
try {
inlineSettings[attrName] = eval(attrValue);
} catch (err) {
inlineSettings[attrName] = attrValue;
}
}
}
tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
beforeShow: function(input, dp_inst) {
if ($.isFunction(o.beforeShow))
o.beforeShow(input, dp_inst, tp_inst);
},
onChangeMonthYear: function(year, month, dp_inst) {
// Update the time as well : this prevents the time from disappearing from the $input field.
tp_inst._updateDateTime(dp_inst);
if ($.isFunction(o.onChangeMonthYear))
o.onChangeMonthYear(year, month, dp_inst, tp_inst);
},
onClose: function(dateText, dp_inst) {
if (tp_inst.timeDefined === true && $input.val() != '')
tp_inst._updateDateTime(dp_inst);
if ($.isFunction(o.onClose))
o.onClose(dateText, dp_inst, tp_inst);
},
timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
});
if (o.altField)
tp_inst.$altInput = $(o.altField)
.css({ cursor: 'pointer' })
.focus(function(){ $input.trigger("focus"); });
// datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
if(tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date)
tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
if(tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date)
tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
if(tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date)
tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
return tp_inst;
},
//########################################################################
// add our sliders to the calendar
//########################################################################
_addTimePicker: function(dp_inst) {
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
this.$input.val() + ' ' + this.$altInput.val() :
this.$input.val();
this.timeDefined = this._parseTime(currDT);
this._limitMinMaxDateTime(dp_inst, false);
this._injectTimePicker();
},
//########################################################################
// parse the time string from input value or _setTime
//########################################################################
_parseTime: function(timeString, withDate) {
var regstr = this._defaults.timeFormat.toString()
.replace(/h{1,2}/ig, '(\\d?\\d)')
.replace(/m{1,2}/ig, '(\\d?\\d)')
.replace(/s{1,2}/ig, '(\\d?\\d)')
.replace(/t{1,2}/ig, '(am|pm|a|p)?')
.replace(/\s/g, '\\s?') + '$',
order = this._getFormatPositions(),
treg;
if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
if (withDate || !this._defaults.timeOnly) {
// the time should come after x number of characters and a space.
// x = at least the length of text specified by the date format
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator + regstr;
}
treg = timeString.match(new RegExp(regstr, 'i'));
if (treg) {
if (order.t !== -1)
this.ampm = ((treg[order.t] === undefined || treg[order.t].length === 0) ?
'' :
(treg[order.t].charAt(0).toUpperCase() == 'A') ? 'AM' : 'PM').toUpperCase();
if (order.h !== -1) {
if (this.ampm == 'AM' && treg[order.h] == '12')
this.hour = 0; // 12am = 0 hour
else if (this.ampm == 'PM' && treg[order.h] != '12')
this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
else this.hour = Number(treg[order.h]);
}
if (order.m !== -1) this.minute = Number(treg[order.m]);
if (order.s !== -1) this.second = Number(treg[order.s]);
return true;
}
return false;
},
//########################################################################
// figure out position of time elements.. cause js cant do named captures
//########################################################################
_getFormatPositions: function() {
var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2})/g),
orders = { h: -1, m: -1, s: -1, t: -1 };
if (finds)
for (var i = 0; i < finds.length; i++)
if (orders[finds[i].toString().charAt(0)] == -1)
orders[finds[i].toString().charAt(0)] = i + 1;
return orders;
},
//########################################################################
// generate and inject html for timepicker into ui datepicker
//########################################################################
_injectTimePicker: function() {
var $dp = this.inst.dpDiv,
o = this._defaults,
tp_inst = this,
// Added by Peter Medeiros:
// - Figure out what the hour/minute/second max should be based on the step values.
// - Example: if stepMinute is 15, then minMax is 45.
hourMax = (o.hourMax - (o.hourMax % o.stepHour)).toFixed(0),
minMax = (o.minuteMax - (o.minuteMax % o.stepMinute)).toFixed(0),
secMax = (o.secondMax - (o.secondMax % o.stepSecond)).toFixed(0),
dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
// Prevent displaying twice
//if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
var noDisplay = ' style="display:none;"',
html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
'<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
'<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
((o.showTime) ? '' : noDisplay) + '></dd>' +
'<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
hourGridSize = 0,
minuteGridSize = 0,
secondGridSize = 0,
size;
if (o.showHour && o.hourGrid > 0) {
html += '<dd class="ui_tpicker_hour">' +
'<div id="ui_tpicker_hour_' + dp_id + '"' + ((o.showHour) ? '' : noDisplay) + '></div>' +
'<div style="padding-left: 1px"><table><tr>';
for (var h = o.hourMin; h < hourMax; h += o.hourGrid) {
hourGridSize++;
var tmph = (o.ampm && h > 12) ? h-12 : h;
if (tmph < 10) tmph = '0' + tmph;
if (o.ampm) {
if (h == 0) tmph = 12 +'a';
else if (h < 12) tmph += 'a';
else tmph += 'p';
}
html += '<td>' + tmph + '</td>';
}
html += '</tr></table></div>' +
'</dd>';
} else html += '<dd class="ui_tpicker_hour" id="ui_tpicker_hour_' + dp_id + '"' +
((o.showHour) ? '' : noDisplay) + '></dd>';
html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>';
if (o.showMinute && o.minuteGrid > 0) {
html += '<dd class="ui_tpicker_minute ui_tpicker_minute_' + o.minuteGrid + '">' +
'<div id="ui_tpicker_minute_' + dp_id + '"' +
((o.showMinute) ? '' : noDisplay) + '></div>' +
'<div style="padding-left: 1px"><table><tr>';
for (var m = o.minuteMin; m < minMax; m += o.minuteGrid) {
minuteGridSize++;
html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
}
html += '</tr></table></div>' +
'</dd>';
} else html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_id + '"' +
((o.showMinute) ? '' : noDisplay) + '></dd>';
html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>';
if (o.showSecond && o.secondGrid > 0) {
html += '<dd class="ui_tpicker_second ui_tpicker_second_' + o.secondGrid + '">' +
'<div id="ui_tpicker_second_' + dp_id + '"' +
((o.showSecond) ? '' : noDisplay) + '></div>' +
'<div style="padding-left: 1px"><table><tr>';
for (var s = o.secondMin; s < secMax; s += o.secondGrid) {
secondGridSize++;
html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
}
html += '</tr></table></div>' +
'</dd>';
} else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
((o.showSecond) ? '' : noDisplay) + '></dd>';
html += '</dl></div>';
$tp = $(html);
// if we only want time picker...
if (o.timeOnly === true) {
$tp.prepend(
'<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' +
'<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' +
'</div>');
$dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
}
this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({
orientation: "horizontal",
value: this.hour,
min: o.hourMin,
max: hourMax,
step: o.stepHour,
slide: function(event, ui) {
tp_inst.hour_slider.slider( "option", "value", ui.value);
tp_inst._onTimeChange();
}
});
// Updated by Peter Medeiros:
// - Pass in Event and UI instance into slide function
this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
orientation: "horizontal",
value: this.minute,
min: o.minuteMin,
max: minMax,
step: o.stepMinute,
slide: function(event, ui) {
// update the global minute slider instance value with the current slider value
tp_inst.minute_slider.slider( "option", "value", ui.value);
tp_inst._onTimeChange();
}
});
this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({
orientation: "horizontal",
value: this.second,
min: o.secondMin,
max: secMax,
step: o.stepSecond,
slide: function(event, ui) {
tp_inst.second_slider.slider( "option", "value", ui.value);
tp_inst._onTimeChange();
}
});
// Add grid functionality
if (o.showHour && o.hourGrid > 0) {
size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
$tp.find(".ui_tpicker_hour table").css({
width: size + "%",
marginLeft: (size / (-2 * hourGridSize)) + "%",
borderCollapse: 'collapse'
}).find("td").each( function(index) {
$(this).click(function() {
var h = $(this).html();
if(o.ampm) {
var ap = h.substring(2).toLowerCase(),
aph = parseInt(h.substring(0,2));
if (ap == 'a') {
if (aph == 12) h = 0;
else h = aph;
} else if (aph == 12) h = 12;
else h = aph + 12;
}
tp_inst.hour_slider.slider("option", "value", h);
tp_inst._onTimeChange();
}).css({
cursor: 'pointer',
width: (100 / hourGridSize) + '%',
textAlign: 'center',
overflow: 'hidden'
});
});
}
if (o.showMinute && o.minuteGrid > 0) {
size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
$tp.find(".ui_tpicker_minute table").css({
width: size + "%",
marginLeft: (size / (-2 * minuteGridSize)) + "%",
borderCollapse: 'collapse'
}).find("td").each(function(index) {
$(this).click(function() {
tp_inst.minute_slider.slider("option", "value", $(this).html());
tp_inst._onTimeChange();
}).css({
cursor: 'pointer',
width: (100 / minuteGridSize) + '%',
textAlign: 'center',
overflow: 'hidden'
});
});
}
if (o.showSecond && o.secondGrid > 0) {
$tp.find(".ui_tpicker_second table").css({
width: size + "%",
marginLeft: (size / (-2 * secondGridSize)) + "%",
borderCollapse: 'collapse'
}).find("td").each(function(index) {
$(this).click(function() {
tp_inst.second_slider.slider("option", "value", $(this).html());
tp_inst._onTimeChange();
}).css({
cursor: 'pointer',
width: (100 / secondGridSize) + '%',
textAlign: 'center',
overflow: 'hidden'
});
});
}
var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
if ($buttonPanel.length) $buttonPanel.before($tp);
else $dp.append($tp);
this.$timeObj = $('#ui_tpicker_time_'+ dp_id);
if (this.inst !== null) {
var timeDefined = this.timeDefined;
this._onTimeChange();
this.timeDefined = timeDefined;
}
//Emulate datepicker onSelect behavior. Call on slidestop.
var onSelect = tp_inst._defaults['onSelect'];
if (onSelect) {
var inputEl = tp_inst.$input ? tp_inst.$input[0] : null;
var onSelectHandler = function() {
onSelect.apply(inputEl, [tp_inst.formattedDateTime, tp_inst]); // trigger custom callback*/
}
this.hour_slider.bind('slidestop',onSelectHandler);
this.minute_slider.bind('slidestop',onSelectHandler);
this.second_slider.bind('slidestop',onSelectHandler);
}
}
},
//########################################################################
// This function tries to limit the ability to go outside the
// min/max date range
//########################################################################
_limitMinMaxDateTime: function(dp_inst, adjustSliders){
var o = this._defaults,
dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
tp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay, this.hour, this.minute, this.second, 0);
if(this._defaults.minDateTime !== null && dp_date){
var minDateTime = this._defaults.minDateTime,
minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
if(this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null){
this.hourMinOriginal = o.hourMin;
this.minuteMinOriginal = o.minuteMin;
this.secondMinOriginal = o.secondMin;
}
if(minDateTimeDate.getTime() == dp_date.getTime()){
this._defaults.hourMin = minDateTime.getHours();
this._defaults.minuteMin = minDateTime.getMinutes();
this._defaults.secondMin = minDateTime.getSeconds();
if(this.hour < this._defaults.hourMin) this.hour = this._defaults.hourMin;
if(this.minute < this._defaults.minuteMin) this.minute = this._defaults.minuteMin;
if(this.second < this._defaults.secondMin) this.second = this._defaults.secondMin;
}else{
this._defaults.hourMin = this.hourMinOriginal;
this._defaults.minuteMin = this.minuteMinOriginal;
this._defaults.secondMin = this.secondMinOriginal;
}
}
if(this._defaults.maxDateTime !== null && dp_date){
var maxDateTime = this._defaults.maxDateTime,
maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
if(this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null){
this.hourMaxOriginal = o.hourMax;
this.minuteMaxOriginal = o.minuteMax;
this.secondMaxOriginal = o.secondMax;
}
if(maxDateTimeDate.getTime() == dp_date.getTime()){
this._defaults.hourMax = maxDateTime.getHours();
this._defaults.minuteMax = maxDateTime.getMinutes();
this._defaults.secondMax = maxDateTime.getSeconds();
if(this.hour > this._defaults.hourMax){ this.hour = this._defaults.hourMax; }
if(this.minute > this._defaults.minuteMax) this.minute = this._defaults.minuteMax;
if(this.second > this._defaults.secondMax) this.second = this._defaults.secondMax;
}else{
this._defaults.hourMax = this.hourMaxOriginal;
this._defaults.minuteMax = this.minuteMaxOriginal;
this._defaults.secondMax = this.secondMaxOriginal;
}
}
if(adjustSliders !== undefined && adjustSliders === true){
this.hour_slider.slider("option", { min: this._defaults.hourMin, max: this._defaults.hourMax }).slider('value', this.hour);
this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: this._defaults.minuteMax }).slider('value', this.minute);
this.second_slider.slider("option", { min: this._defaults.secondMin, max: this._defaults.secondMax }).slider('value', this.second);
}
},
//########################################################################
// when a slider moves, set the internal time...
// on time change is also called when the time is updated in the text field
//########################################################################
_onTimeChange: function() {
var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
second = (this.second_slider) ? this.second_slider.slider('value') : false;
if (hour !== false) hour = parseInt(hour,10);
if (minute !== false) minute = parseInt(minute,10);
if (second !== false) second = parseInt(second,10);
var ampm = (hour < 12) ? 'AM' : 'PM';
// If the update was done in the input field, the input field should not be updated.
// If the update was done using the sliders, update the input field.
var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || (this.ampm.length > 0 && this.ampm != ampm));
if (hasChanged) {
if (hour !== false)this.hour = hour;
if (minute !== false) this.minute = minute;
if (second !== false) this.second = second;
}
if (this._defaults.ampm) this.ampm = ampm;
this._formatTime();
if (this.$timeObj) this.$timeObj.text(this.formattedTime);
this.timeDefined = true;
if (hasChanged) this._updateDateTime();
},
//########################################################################
// format the time all pretty...
//########################################################################
_formatTime: function(time, format, ampm) {
if (ampm == undefined) ampm = this._defaults.ampm;
time = time || { hour: this.hour, minute: this.minute, second: this.second, ampm: this.ampm };
var tmptime = format || this._defaults.timeFormat.toString();
if (ampm) {
var hour12 = ((time.ampm == 'AM') ? (time.hour) : (time.hour % 12));
hour12 = (Number(hour12) === 0) ? 12 : hour12;
tmptime = tmptime.toString()
.replace(/hh/g, ((hour12 < 10) ? '0' : '') + hour12)
.replace(/h/g, hour12)
.replace(/mm/g, ((time.minute < 10) ? '0' : '') + time.minute)
.replace(/m/g, time.minute)
.replace(/ss/g, ((time.second < 10) ? '0' : '') + time.second)
.replace(/s/g, time.second)
.replace(/TT/g, time.ampm.toUpperCase())
.replace(/tt/g, time.ampm.toLowerCase())
.replace(/T/g, time.ampm.charAt(0).toUpperCase())
.replace(/t/g, time.ampm.charAt(0).toLowerCase());
} else {
tmptime = tmptime.toString()
.replace(/hh/g, ((time.hour < 10) ? '0' : '') + time.hour)
.replace(/h/g, time.hour)
.replace(/mm/g, ((time.minute < 10) ? '0' : '') + time.minute)
.replace(/m/g, time.minute)
.replace(/ss/g, ((time.second < 10) ? '0' : '') + time.second)
.replace(/s/g, time.second);
tmptime = $.trim(tmptime.replace(/t/gi, ''));
}
if (arguments.length) return tmptime;
else this.formattedTime = tmptime;
},
//########################################################################
// update our input with the new date time..
//########################################################################
_updateDateTime: function(dp_inst) {
dp_inst = this.inst || dp_inst,
dt = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
formatCfg = $.datepicker._getFormatConfig(dp_inst),
timeAvailable = dt !== null && this.timeDefined;
this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
var formattedDateTime = this.formattedDate;
if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
return;
if (this._defaults.timeOnly === true) {
formattedDateTime = this.formattedTime;
} else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
formattedDateTime += this._defaults.separator + this.formattedTime;
}
this.formattedDateTime = formattedDateTime;
if(!this._defaults.showTimepicker) {
this.$input.val(this.formattedDate);
} else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
this.$altInput.val(this.formattedTime);
this.$input.val(this.formattedDate);
} else if(this.$altInput) {
this.$altInput.val(formattedDateTime);
this.$input.val(formattedDateTime);
} else {
this.$input.val(formattedDateTime);
}
this.$input.trigger("change");
}
});
$.fn.extend({
//########################################################################
// shorthand just to use timepicker..
//########################################################################
timepicker: function(o) {
o = o || {};
var tmp_args = arguments;
if (typeof o == 'object') tmp_args[0] = $.extend(o, { timeOnly: true });
return $(this).each(function() {
$.fn.datetimepicker.apply($(this), tmp_args);
});
},
//########################################################################
// extend timepicker to datepicker
//########################################################################
datetimepicker: function(o) {
o = o || {};
var $input = this,
tmp_args = arguments;
if (typeof(o) == 'string'){
if(o == 'getDate')
return $.fn.datepicker.apply($(this[0]), tmp_args);
else
return this.each(function() {
var $t = $(this);
$t.datepicker.apply($t, tmp_args);
});
}
else
return this.each(function() {
var $t = $(this);
$t.datepicker($.timepicker._newInst($t, o)._defaults);
});
}
});
//########################################################################
// the bad hack :/ override datepicker so it doesnt close on select
// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
//########################################################################
$.datepicker._base_selectDate = $.datepicker._selectDate;
$.datepicker._selectDate = function (id, dateStr) {
var inst = this._getInst($(id)[0]),
tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
tp_inst._limitMinMaxDateTime(inst, true);
inst.inline = inst.stay_open = true;
//This way the onSelect handler called from calendarpicker get the full dateTime
this._base_selectDate(id, dateStr + tp_inst._defaults.separator + tp_inst.formattedTime);
inst.inline = inst.stay_open = false;
this._notifyChange(inst);
this._updateDatepicker(inst);
}
else this._base_selectDate(id, dateStr);
};
//#############################################################################################
// second bad hack :/ override datepicker so it triggers an event when changing the input field
// and does not redraw the datepicker on every selectDate event
//#############################################################################################
$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
$.datepicker._updateDatepicker = function(inst) {
if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
this._base_updateDatepicker(inst);
// Reload the time control when changing something in the input text field.
var tp_inst = this._get(inst, 'timepicker');
if(tp_inst) tp_inst._addTimePicker(inst);
}
};
//#######################################################################################
// third bad hack :/ override datepicker so it allows spaces and colan in the input field
//#######################################################################################
$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
$.datepicker._doKeyPress = function(event) {
var inst = $.datepicker._getInst(event.target),
tp_inst = $.datepicker._get(inst, 'timepicker');
if (tp_inst) {
if ($.datepicker._get(inst, 'constrainInput')) {
var ampm = tp_inst._defaults.ampm,
datetimeChars = tp_inst._defaults.timeFormat.toString()
.replace(/[hms]/g, '')
.replace(/TT/g, ampm ? 'APM' : '')
.replace(/T/g, ampm ? 'AP' : '')
.replace(/tt/g, ampm ? 'apm' : '')
.replace(/t/g, ampm ? 'ap' : '') +
" " +
tp_inst._defaults.separator +
$.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
return event.ctrlKey || (chr < ' ' || !datetimeChars || datetimeChars.indexOf(chr) > -1);
}
}
return $.datepicker._base_doKeyPress(event);
};
//#######################################################################################
// Override key up event to sync manual input changes.
//#######################################################################################
$.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
$.datepicker._doKeyUp = function (event) {
var inst = $.datepicker._getInst(event.target),
tp_inst = $.datepicker._get(inst, 'timepicker');
if (tp_inst) {
if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
try {
$.datepicker._updateDatepicker(inst);
}
catch (err) {
$.datepicker.log(err);
}
}
}
return $.datepicker._base_doKeyUp(event);
};
//#######################################################################################
// override "Today" button to also grab the time.
//#######################################################################################
$.datepicker._base_gotoToday = $.datepicker._gotoToday;
$.datepicker._gotoToday = function(id) {
this._base_gotoToday(id);
this._setTime(this._getInst($(id)[0]), new Date());
};
//#######################################################################################
// Disable & enable the Time in the datetimepicker
//#######################################################################################
$.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
tp_inst._defaults.showTimepicker = false;
tp_inst._onTimeChange();
tp_inst._updateDateTime(inst);
}
};
$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
tp_inst._defaults.showTimepicker = true;
tp_inst._onTimeChange();
tp_inst._updateDateTime(inst);
}
};
//#######################################################################################
// Create our own set time function
//#######################################################################################
$.datepicker._setTime = function(inst, date) {
var tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
var defaults = tp_inst._defaults,
// calling _setTime with no date sets time to defaults
hour = date ? date.getHours() : defaults.hour,
minute = date ? date.getMinutes() : defaults.minute,
second = date ? date.getSeconds() : defaults.second;
//check if within min/max times..
if ((hour < defaults.hourMin || hour > defaults.hourMax) || (minute < defaults.minuteMin || minute > defaults.minuteMax) || (second < defaults.secondMin || second > defaults.secondMax)) {
hour = defaults.hourMin;
minute = defaults.minuteMin;
second = defaults.secondMin;
}
if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
else tp_inst.hour = hour;
if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
else tp_inst.minute = minute;
if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
else tp_inst.second = second;
tp_inst._onTimeChange();
tp_inst._updateDateTime(inst);
}
};
//#######################################################################################
// Create new public method to set only time, callable as $().datepicker('setTime', date)
//#######################################################################################
$.datepicker._setTimeDatepicker = function(target, date, withDate) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
this._setDateFromField(inst);
var tp_date;
if (date) {
if (typeof date == "string") {
tp_inst._parseTime(date, withDate);
tp_date = new Date();
tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
}
else tp_date = new Date(date.getTime());
if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
}
this._setTime(inst, tp_date);
}
};
//#######################################################################################
// override setDate() to allow setting time too within Date object
//#######################################################################################
$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
$.datepicker._setDateDatepicker = function(target, date) {
var inst = this._getInst(target),
tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
this._updateDatepicker(inst);
this._base_setDateDatepicker.apply(this, arguments);
this._setTimeDatepicker(target, tp_date, true);
};
//#######################################################################################
// override getDate() to allow getting time too within Date object
//#######################################################################################
$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
$.datepicker._getDateDatepicker = function(target, noDefault) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
this._setDateFromField(inst, noDefault);
var date = this._getDate(inst);
if (date && tp_inst._parseTime($(target).val(), true)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
return date;
}
return this._base_getDateDatepicker(target, noDefault);
};
//#######################################################################################
// jQuery extend now ignores nulls!
//#######################################################################################
function extendRemove(target, props) {
$.extend(target, props);
for (var name in props)
if (props[name] === null || props[name] === undefined)
target[name] = props[name];
return target;
}
$.timepicker = new Timepicker(); // singleton instance
$.timepicker.version = "0.9.3";
})(jQuery);
@@ -0,0 +1,51 @@
/**
* jQuery Validation Plugin 1.8.1
*
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
* Copyright (c) 2006 - 2011 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&this.find("input, button").filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("<input type='hidden'/>").attr("name",
b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form();
else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name];
return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a,
b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",
validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)},
onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).addClass(b).removeClass(d):c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).removeClass(b).addClass(d):c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults,
a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."),
minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."),range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator");e="on"+e.type.replace(/^validate/,
"");f.settings[e]&&f.settings[e].call(f,this[0])}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d=this.settings.rules;
c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate(":text, :password, :file, select, textarea","focusin focusout keyup",a).validateDelegate(":radio, :checkbox, select, option","click",a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",
[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(a){this.lastElement=a=this.clean(a);this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,
a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList,function(d){return!(d.name in a)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},
objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return this.size()==0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==
a.name}).length==1&&a},elements:function(){var a=this,b={};return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,
this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.clean(a);if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=
c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&&window.console&&console.log("exception occured when checking element "+a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=
this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==undefined)return arguments[a]},defaultMessage:function(a,b){return this.findDefined(this.customMessage(a.name,b),this.customMetaMessage(a,b),!this.settings.ignoreTitle&&a.title||undefined,c.validator.messages[b],"<strong>Warning: No message defined for "+
a.name+"</strong>")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d,element:a});this.errorMap[a.name]=d;this.submitted[a.name]=d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];
this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);
this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a,b){var d=this.errorsFor(a);if(d.length){d.removeClass().addClass(this.settings.errorClass);d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||
"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text("");typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow=this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},
idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d,e){return e.form==b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},
depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this,c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<
0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},
email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings,a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b=
{};a=c(a);for(var d in c.validator.methods){var e=a.attr(d);if(e)b[d]=e}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{};var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]:c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===
false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined?e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)?e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&
a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages;return a},normalizeRule:function(a){if(typeof a=="string"){var b={};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},
methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a,b)>0;default:return c.trim(a).length>0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=
e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d,mode:"abort",port:"validate"+b.name,dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=
e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||
a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(a)},
url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},
date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9-]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>=
0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery);
(function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery);
(function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a,
b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery);
@@ -0,0 +1,20 @@
var $j = jQuery.noConflict();
$j(function(){
// Datepicker
$j('.datepicker').datetimepicker({
currentText: 'Nå',
closeText: 'Ok',
hourText: 'Time',
dateFormat: 'yy-mm-dd',
timeFormat: 'hh:mm',
minuteText: 'Minutt',
timeText: 'Tid',
firstDay: 1,
monthNames: ['Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember'],
dayNames: ['søndag','mandag','tirsdag','onsdag','torsdag','fredag','lørdag'],
dayNamesShort: ['søn','man','tir','ons','tor','fre','lør'],
dayNamesMin: ['sø','ma','ti','on','to','fr','lø']
});
});
@@ -0,0 +1,12 @@
var $j = jQuery.noConflict();
$j(function(){
$j("#post").validate({
rules: {
neuf_events_start_time: "required"
},
messages: {
neuf_events_start_time: "Velg startdato og klokkeslett"
}
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

@@ -0,0 +1,581 @@
/*
* jQuery UI CSS Framework 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Theming/API
*/
/* Layout helpers
----------------------------------*/
.ui-helper-hidden { display: none; }
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.ui-helper-clearfix { display: inline-block; }
/* required comment for clearfix to work in Opera \*/
* html .ui-helper-clearfix { height:1%; }
.ui-helper-clearfix { display:block; }
/* end clearfix */
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
/* Interaction Cues
----------------------------------*/
.ui-state-disabled { cursor: default !important; }
/* Icons
----------------------------------*/
/* states and images */
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
/* Misc visuals
----------------------------------*/
/* Overlays */
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
/*
* jQuery UI CSS Framework 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Theming/API
*
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS,%20Tahoma,%20Verdana,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=03_highlight_soft.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=08_diagonals_thick.png&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=01_flat.png&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px
*/
/* Component containers
----------------------------------*/
.ui-widget { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1.1em; }
.ui-widget .ui-widget { font-size: 1em; }
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1em; }
.ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; color: #333333; }
.ui-widget-content a { color: #333333; }
.ui-widget-header { border: 1px solid #e78f08; background: #f6a828 url(images/ui-bg_gloss-wave_35_f6a828_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; }
.ui-widget-header a { color: #ffffff; }
/* Interaction states
----------------------------------*/
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1c94c4; }
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #fbcb09; background: #fdf5ce url(images/ui-bg_glass_100_fdf5ce_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #c77405; }
.ui-state-hover a, .ui-state-hover a:hover { color: #c77405; text-decoration: none; }
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #fbd850; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eb8f00; }
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #eb8f00; text-decoration: none; }
.ui-widget :active { outline: none; }
/* Interaction Cues
----------------------------------*/
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fed22f; background: #ffe45c url(images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; color: #363636; }
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat; color: #ffffff; }
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #ffffff; }
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #ffffff; }
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
/* Icons
----------------------------------*/
/* states and images */
.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
.ui-state-default .ui-icon { background-image: url(images/ui-icons_ef8c08_256x240.png); }
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
.ui-state-active .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_228ef1_256x240.png); }
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_ffd27a_256x240.png); }
/* positioning */
.ui-icon-carat-1-n { background-position: 0 0; }
.ui-icon-carat-1-ne { background-position: -16px 0; }
.ui-icon-carat-1-e { background-position: -32px 0; }
.ui-icon-carat-1-se { background-position: -48px 0; }
.ui-icon-carat-1-s { background-position: -64px 0; }
.ui-icon-carat-1-sw { background-position: -80px 0; }
.ui-icon-carat-1-w { background-position: -96px 0; }
.ui-icon-carat-1-nw { background-position: -112px 0; }
.ui-icon-carat-2-n-s { background-position: -128px 0; }
.ui-icon-carat-2-e-w { background-position: -144px 0; }
.ui-icon-triangle-1-n { background-position: 0 -16px; }
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
.ui-icon-triangle-1-e { background-position: -32px -16px; }
.ui-icon-triangle-1-se { background-position: -48px -16px; }
.ui-icon-triangle-1-s { background-position: -64px -16px; }
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
.ui-icon-triangle-1-w { background-position: -96px -16px; }
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
.ui-icon-arrow-1-n { background-position: 0 -32px; }
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
.ui-icon-arrow-1-e { background-position: -32px -32px; }
.ui-icon-arrow-1-se { background-position: -48px -32px; }
.ui-icon-arrow-1-s { background-position: -64px -32px; }
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
.ui-icon-arrow-1-w { background-position: -96px -32px; }
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
.ui-icon-arrow-4 { background-position: 0 -80px; }
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
.ui-icon-extlink { background-position: -32px -80px; }
.ui-icon-newwin { background-position: -48px -80px; }
.ui-icon-refresh { background-position: -64px -80px; }
.ui-icon-shuffle { background-position: -80px -80px; }
.ui-icon-transfer-e-w { background-position: -96px -80px; }
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
.ui-icon-folder-collapsed { background-position: 0 -96px; }
.ui-icon-folder-open { background-position: -16px -96px; }
.ui-icon-document { background-position: -32px -96px; }
.ui-icon-document-b { background-position: -48px -96px; }
.ui-icon-note { background-position: -64px -96px; }
.ui-icon-mail-closed { background-position: -80px -96px; }
.ui-icon-mail-open { background-position: -96px -96px; }
.ui-icon-suitcase { background-position: -112px -96px; }
.ui-icon-comment { background-position: -128px -96px; }
.ui-icon-person { background-position: -144px -96px; }
.ui-icon-print { background-position: -160px -96px; }
.ui-icon-trash { background-position: -176px -96px; }
.ui-icon-locked { background-position: -192px -96px; }
.ui-icon-unlocked { background-position: -208px -96px; }
.ui-icon-bookmark { background-position: -224px -96px; }
.ui-icon-tag { background-position: -240px -96px; }
.ui-icon-home { background-position: 0 -112px; }
.ui-icon-flag { background-position: -16px -112px; }
.ui-icon-calendar { background-position: -32px -112px; }
.ui-icon-cart { background-position: -48px -112px; }
.ui-icon-pencil { background-position: -64px -112px; }
.ui-icon-clock { background-position: -80px -112px; }
.ui-icon-disk { background-position: -96px -112px; }
.ui-icon-calculator { background-position: -112px -112px; }
.ui-icon-zoomin { background-position: -128px -112px; }
.ui-icon-zoomout { background-position: -144px -112px; }
.ui-icon-search { background-position: -160px -112px; }
.ui-icon-wrench { background-position: -176px -112px; }
.ui-icon-gear { background-position: -192px -112px; }
.ui-icon-heart { background-position: -208px -112px; }
.ui-icon-star { background-position: -224px -112px; }
.ui-icon-link { background-position: -240px -112px; }
.ui-icon-cancel { background-position: 0 -128px; }
.ui-icon-plus { background-position: -16px -128px; }
.ui-icon-plusthick { background-position: -32px -128px; }
.ui-icon-minus { background-position: -48px -128px; }
.ui-icon-minusthick { background-position: -64px -128px; }
.ui-icon-close { background-position: -80px -128px; }
.ui-icon-closethick { background-position: -96px -128px; }
.ui-icon-key { background-position: -112px -128px; }
.ui-icon-lightbulb { background-position: -128px -128px; }
.ui-icon-scissors { background-position: -144px -128px; }
.ui-icon-clipboard { background-position: -160px -128px; }
.ui-icon-copy { background-position: -176px -128px; }
.ui-icon-contact { background-position: -192px -128px; }
.ui-icon-image { background-position: -208px -128px; }
.ui-icon-video { background-position: -224px -128px; }
.ui-icon-script { background-position: -240px -128px; }
.ui-icon-alert { background-position: 0 -144px; }
.ui-icon-info { background-position: -16px -144px; }
.ui-icon-notice { background-position: -32px -144px; }
.ui-icon-help { background-position: -48px -144px; }
.ui-icon-check { background-position: -64px -144px; }
.ui-icon-bullet { background-position: -80px -144px; }
.ui-icon-radio-off { background-position: -96px -144px; }
.ui-icon-radio-on { background-position: -112px -144px; }
.ui-icon-pin-w { background-position: -128px -144px; }
.ui-icon-pin-s { background-position: -144px -144px; }
.ui-icon-play { background-position: 0 -160px; }
.ui-icon-pause { background-position: -16px -160px; }
.ui-icon-seek-next { background-position: -32px -160px; }
.ui-icon-seek-prev { background-position: -48px -160px; }
.ui-icon-seek-end { background-position: -64px -160px; }
.ui-icon-seek-start { background-position: -80px -160px; }
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
.ui-icon-seek-first { background-position: -80px -160px; }
.ui-icon-stop { background-position: -96px -160px; }
.ui-icon-eject { background-position: -112px -160px; }
.ui-icon-volume-off { background-position: -128px -160px; }
.ui-icon-volume-on { background-position: -144px -160px; }
.ui-icon-power { background-position: 0 -176px; }
.ui-icon-signal-diag { background-position: -16px -176px; }
.ui-icon-signal { background-position: -32px -176px; }
.ui-icon-battery-0 { background-position: -48px -176px; }
.ui-icon-battery-1 { background-position: -64px -176px; }
.ui-icon-battery-2 { background-position: -80px -176px; }
.ui-icon-battery-3 { background-position: -96px -176px; }
.ui-icon-circle-plus { background-position: 0 -192px; }
.ui-icon-circle-minus { background-position: -16px -192px; }
.ui-icon-circle-close { background-position: -32px -192px; }
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
.ui-icon-circle-zoomin { background-position: -176px -192px; }
.ui-icon-circle-zoomout { background-position: -192px -192px; }
.ui-icon-circle-check { background-position: -208px -192px; }
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
.ui-icon-circlesmall-close { background-position: -32px -208px; }
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
.ui-icon-squaresmall-close { background-position: -80px -208px; }
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
/* Misc visuals
----------------------------------*/
/* Corner radius */
.ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; border-top-left-radius: 4px; }
.ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; border-top-right-radius: 4px; }
.ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
.ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
.ui-corner-top { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; border-top-left-radius: 4px; -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; border-top-right-radius: 4px; }
.ui-corner-bottom { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
.ui-corner-right { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; border-top-right-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
.ui-corner-left { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; border-top-left-radius: 4px; -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
/* Overlays */
.ui-widget-overlay { background: #666666 url(images/ui-bg_diagonals-thick_20_666666_40x40.png) 50% 50% repeat; opacity: .50;filter:Alpha(Opacity=50); }
.ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .20;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }/*
* jQuery UI Resizable 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Resizable#theming
*/
.ui-resizable { position: relative;}
.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;}
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/*
* jQuery UI Selectable 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Selectable#theming
*/
.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
/*
* jQuery UI Accordion 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Accordion#theming
*/
/* IE/Win - Fix animation bug - #4615 */
.ui-accordion { width: 100%; }
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
.ui-accordion .ui-accordion-li-fix { display: inline; }
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
.ui-accordion .ui-accordion-content-active { display: block; }
/*
* jQuery UI Autocomplete 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Autocomplete#theming
*/
.ui-autocomplete { position: absolute; cursor: default; }
/* workarounds */
* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
/*
* jQuery UI Menu 1.8.11
*
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Menu#theming
*/
.ui-menu {
list-style:none;
padding: 2px;
margin: 0;
display:block;
float: left;
}
.ui-menu .ui-menu {
margin-top: -3px;
}
.ui-menu .ui-menu-item {
margin:0;
padding: 0;
zoom: 1;
float: left;
clear: left;
width: 100%;
}
.ui-menu .ui-menu-item a {
text-decoration:none;
display:block;
padding:.2em .4em;
line-height:1.5;
zoom:1;
}
.ui-menu .ui-menu-item a.ui-state-hover,
.ui-menu .ui-menu-item a.ui-state-active {
font-weight: normal;
margin: -1px;
}
/*
* jQuery UI Button 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Button#theming
*/
.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
.ui-button-icons-only { width: 3.4em; }
button.ui-button-icons-only { width: 3.7em; }
/*button text element */
.ui-button .ui-button-text { display: block; line-height: 1.4; }
.ui-button-text-only .ui-button-text { padding: .4em 1em; }
.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
/* no icon support for input elements, provide padding by default */
input.ui-button { padding: .4em 1em; }
/*button icon element(s) */
.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
/*button sets*/
.ui-buttonset { margin-right: 7px; }
.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; }
/* workarounds */
button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
/*
* jQuery UI Dialog 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Dialog#theming
*/
.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
.ui-draggable .ui-dialog-titlebar { cursor: move; }
/*
* jQuery UI Slider 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Slider#theming
*/
.ui-slider { position: relative; text-align: left; }
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
.ui-slider-horizontal { height: .8em; }
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
.ui-slider-horizontal .ui-slider-range-max { right: 0; }
.ui-slider-vertical { width: .8em; height: 100px; }
.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
.ui-slider-vertical .ui-slider-range-max { top: 0; }/*
* jQuery UI Tabs 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Tabs#theming
*/
.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; }
.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; }
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; }
.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
.ui-tabs .ui-tabs-hide { display: none !important; }
/*
* jQuery UI Datepicker 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Datepicker#theming
*/
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
.ui-datepicker .ui-datepicker-prev { left:2px; }
.ui-datepicker .ui-datepicker-next { right:2px; }
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year { width: 49%;}
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
.ui-datepicker td { border: 0; padding: 1px; }
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
/* with multiple calendars */
.ui-datepicker.ui-datepicker-multi { width:auto; }
.ui-datepicker-multi .ui-datepicker-group { float:left; }
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
.ui-datepicker-row-break { clear:both; width:100%; }
/* RTL support */
.ui-datepicker-rtl { direction: rtl; }
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
.ui-datepicker-cover {
display: none; /*sorry for IE5*/
display/**/: block; /*sorry for IE5*/
position: absolute; /*must have*/
z-index: -1; /*must have*/
filter: mask(); /*must have*/
top: -4px; /*must have*/
left: -4px; /*must have*/
width: 200px; /*must have*/
height: 200px; /*must have*/
}/*
* jQuery UI Progressbar 1.8.11
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Progressbar#theming
*/
.ui-progressbar { height:2em; text-align: left; }
.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
/* JQuery UI TimePicker added here */
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; }
.ui-timepicker-div dl dd { margin: -25px 0 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
@@ -0,0 +1,334 @@
<?php
/*
Controller name: Core
Controller description: Basic introspection methods
*/
class JSON_API_Core_Controller {
public function info() {
global $json_api;
$php = '';
if (!empty($json_api->query->controller)) {
return $json_api->controller_info($json_api->query->controller);
} else {
$dir = json_api_dir();
if (file_exists("$dir/json-api.php")) {
$php = file_get_contents("$dir/json-api.php");
} else {
// Check one directory up, in case json-api.php was moved
$dir = dirname($dir);
if (file_exists("$dir/json-api.php")) {
$php = file_get_contents("$dir/json-api.php");
}
}
if (preg_match('/^\s*Version:\s*(.+)$/m', $php, $matches)) {
$version = $matches[1];
} else {
$version = '(Unknown)';
}
$active_controllers = explode(',', get_option('json_api_controllers', 'core'));
$controllers = array_intersect($json_api->get_controllers(), $active_controllers);
return array(
'json_api_version' => $version,
'controllers' => array_values($controllers)
);
}
}
public function get_recent_posts() {
global $json_api;
$posts = $json_api->introspector->get_posts();
return $this->posts_result($posts);
}
public function get_post() {
global $json_api, $post;
extract($json_api->query->get(array('id', 'slug', 'post_id', 'post_slug')));
if ($id || $post_id) {
if (!$id) {
$id = $post_id;
}
$posts = $json_api->introspector->get_posts(array(
'p' => $id
), true);
} else if ($slug || $post_slug) {
if (!$slug) {
$slug = $post_slug;
}
$posts = $json_api->introspector->get_posts(array(
'name' => $slug
), true);
} else {
$json_api->error("Include 'id' or 'slug' var in your request.");
}
if (count($posts) == 1) {
$post = $posts[0];
$previous = get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
$post = new JSON_API_Post($post);
$response = array(
'post' => $post
);
if ($previous) {
$response['previous_url'] = get_permalink($previous->ID);
}
if ($next) {
$response['next_url'] = get_permalink($next->ID);
}
return $response;
} else {
$json_api->error("Not found.");
}
}
public function get_page() {
global $json_api;
extract($json_api->query->get(array('id', 'slug', 'page_id', 'page_slug', 'children')));
if ($id || $page_id) {
if (!$id) {
$id = $page_id;
}
$posts = $json_api->introspector->get_posts(array(
'page_id' => $id
));
} else if ($slug || $page_slug) {
if (!$slug) {
$slug = $page_slug;
}
$posts = $json_api->introspector->get_posts(array(
'pagename' => $slug
));
} else {
$json_api->error("Include 'id' or 'slug' var in your request.");
}
// Workaround for https://core.trac.wordpress.org/ticket/12647
if (empty($posts)) {
$url = $_SERVER['REQUEST_URI'];
$parsed_url = parse_url($url);
$path = $parsed_url['path'];
if (preg_match('#^http://[^/]+(/.+)$#', get_bloginfo('url'), $matches)) {
$blog_root = $matches[1];
$path = preg_replace("#^$blog_root#", '', $path);
}
if (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
$posts = $json_api->introspector->get_posts(array('pagename' => $path));
}
if (count($posts) == 1) {
if (!empty($children)) {
$json_api->introspector->attach_child_posts($posts[0]);
}
return array(
'page' => $posts[0]
);
} else {
$json_api->error("Not found.");
}
}
public function get_date_posts() {
global $json_api;
if ($json_api->query->date) {
$date = preg_replace('/\D/', '', $json_api->query->date);
if (!preg_match('/^\d{4}(\d{2})?(\d{2})?$/', $date)) {
$json_api->error("Specify a date var in one of 'YYYY' or 'YYYY-MM' or 'YYYY-MM-DD' formats.");
}
$request = array('year' => substr($date, 0, 4));
if (strlen($date) > 4) {
$request['monthnum'] = (int) substr($date, 4, 2);
}
if (strlen($date) > 6) {
$request['day'] = (int) substr($date, 6, 2);
}
$posts = $json_api->introspector->get_posts($request);
} else {
$json_api->error("Include 'date' var in your request.");
}
return $this->posts_result($posts);
}
public function get_category_posts() {
global $json_api;
$category = $json_api->introspector->get_current_category();
if (!$category) {
$json_api->error("Not found.");
}
$posts = $json_api->introspector->get_posts(array(
'cat' => $category->id
));
return $this->posts_object_result($posts, $category);
}
public function get_tag_posts() {
global $json_api;
$tag = $json_api->introspector->get_current_tag();
if (!$tag) {
$json_api->error("Not found.");
}
$posts = $json_api->introspector->get_posts(array(
'tag' => $tag->slug
));
return $this->posts_object_result($posts, $tag);
}
public function get_author_posts() {
global $json_api;
$author = $json_api->introspector->get_current_author();
if (!$author) {
$json_api->error("Not found.");
}
$posts = $json_api->introspector->get_posts(array(
'author' => $author->id
));
return $this->posts_object_result($posts, $author);
}
public function get_search_results() {
global $json_api;
if ($json_api->query->search) {
$posts = $json_api->introspector->get_posts(array(
's' => $json_api->query->search
));
} else {
$json_api->error("Include 'search' var in your request.");
}
return $this->posts_result($posts);
}
public function get_date_index() {
global $json_api;
$permalinks = $json_api->introspector->get_date_archive_permalinks();
$tree = $json_api->introspector->get_date_archive_tree($permalinks);
return array(
'permalinks' => $permalinks,
'tree' => $tree
);
}
public function get_category_index() {
global $json_api;
$categories = $json_api->introspector->get_categories();
return array(
'count' => count($categories),
'categories' => $categories
);
}
public function get_tag_index() {
global $json_api;
$tags = $json_api->introspector->get_tags();
return array(
'count' => count($tags),
'tags' => $tags
);
}
public function get_author_index() {
global $json_api;
$authors = $json_api->introspector->get_authors();
return array(
'count' => count($authors),
'authors' => array_values($authors)
);
}
public function get_page_index() {
global $json_api;
$pages = array();
// Thanks to blinder for the fix!
$numberposts = empty($json_api->query->count) ? -1 : $json_api->query->count;
$wp_posts = get_posts(array(
'post_type' => 'page',
'post_parent' => 0,
'order' => 'ASC',
'orderby' => 'menu_order',
'numberposts' => $numberposts
));
foreach ($wp_posts as $wp_post) {
$pages[] = new JSON_API_Post($wp_post);
}
foreach ($pages as $page) {
$json_api->introspector->attach_child_posts($page);
}
return array(
'pages' => $pages
);
}
public function get_nonce() {
global $json_api;
extract($json_api->query->get(array('controller', 'method')));
if ($controller && $method) {
$controller = strtolower($controller);
if (!in_array($controller, $json_api->get_controllers())) {
$json_api->error("Unknown controller '$controller'.");
}
require_once $json_api->controller_path($controller);
if (!method_exists($json_api->controller_class($controller), $method)) {
$json_api->error("Unknown method '$method'.");
}
$nonce_id = $json_api->get_nonce_id($controller, $method);
return array(
'controller' => $controller,
'method' => $method,
'nonce' => wp_create_nonce($nonce_id)
);
} else {
$json_api->error("Include 'controller' and 'method' vars in your request.");
}
}
protected function get_object_posts($object, $id_var, $slug_var) {
global $json_api;
$object_id = "{$type}_id";
$object_slug = "{$type}_slug";
extract($json_api->query->get(array('id', 'slug', $object_id, $object_slug)));
if ($id || $$object_id) {
if (!$id) {
$id = $$object_id;
}
$posts = $json_api->introspector->get_posts(array(
$id_var => $id
));
} else if ($slug || $$object_slug) {
if (!$slug) {
$slug = $$object_slug;
}
$posts = $json_api->introspector->get_posts(array(
$slug_var => $slug
));
} else {
$json_api->error("No $type specified. Include 'id' or 'slug' var in your request.");
}
return $posts;
}
protected function posts_result($posts) {
global $wp_query;
return array(
'count' => count($posts),
'count_total' => (int) $wp_query->found_posts,
'pages' => $wp_query->max_num_pages,
'posts' => $posts
);
}
protected function posts_object_result($posts, $object) {
global $wp_query;
// Convert something like "JSON_API_Category" into "category"
$object_key = strtolower(substr(get_class($object), 9));
return array(
'count' => count($posts),
'pages' => (int) $wp_query->max_num_pages,
$object_key => $object,
'posts' => $posts
);
}
}
?>
@@ -0,0 +1,34 @@
<?php
/*
Controller name: Posts
Controller description: Data manipulation methods for posts
*/
class JSON_API_Posts_Controller {
public function create_post() {
global $json_api;
if (!current_user_can('edit_posts')) {
$json_api->error("You need to login with a user capable of creating posts.");
}
if (!$json_api->query->nonce) {
$json_api->error("You must include a 'nonce' value to create posts. Use the `get_nonce` Core API method.");
}
$nonce_id = $json_api->get_nonce_id('posts', 'create_post');
if (!wp_verify_nonce($json_api->query->nonce, $nonce_id)) {
$json_api->error("Your 'nonce' value was incorrect. Use the 'get_nonce' API method.");
}
nocache_headers();
$post = new JSON_API_Post();
$id = $post->create($_REQUEST);
if (empty($id)) {
$json_api->error("Could not create post.");
}
return array(
'post' => $post
);
}
}
?>
@@ -0,0 +1,27 @@
<?php
/*
Controller name: Respond
Controller description: Comment/trackback submission methods
*/
class JSON_API_Respond_Controller {
function submit_comment() {
global $json_api;
nocache_headers();
if (empty($_REQUEST['post_id'])) {
$json_api->error("No post specified. Include 'post_id' var in your request.");
} else if (empty($_REQUEST['name']) ||
empty($_REQUEST['email']) ||
empty($_REQUEST['content'])) {
$json_api->error("Please include all required arguments (name, email, content).");
} else if (!is_email($_REQUEST['email'])) {
$json_api->error("Please enter a valid email address.");
}
$pending = new JSON_API_Comment();
return $pending->handle_submission();
}
}
?>
@@ -0,0 +1,83 @@
<?php
/*
Plugin Name: JSON API
Plugin URI: http://wordpress.org/extend/plugins/json-api/
Description: A RESTful API for WordPress
Version: 1.0.7
Author: Dan Phiffer
Author URI: http://phiffer.org/
*/
$dir = json_api_dir();
@include_once "$dir/singletons/api.php";
@include_once "$dir/singletons/query.php";
@include_once "$dir/singletons/introspector.php";
@include_once "$dir/singletons/response.php";
@include_once "$dir/models/post.php";
@include_once "$dir/models/comment.php";
@include_once "$dir/models/category.php";
@include_once "$dir/models/tag.php";
@include_once "$dir/models/author.php";
@include_once "$dir/models/attachment.php";
function json_api_init() {
global $json_api;
if (phpversion() < 5) {
add_action('admin_notices', 'json_api_php_version_warning');
return;
}
if (!class_exists('JSON_API')) {
add_action('admin_notices', 'json_api_class_warning');
return;
}
add_filter('rewrite_rules_array', 'json_api_rewrites');
$json_api = new JSON_API();
}
function json_api_php_version_warning() {
echo "<div id=\"json-api-warning\" class=\"updated fade\"><p>Sorry, JSON API requires PHP version 5.0 or greater.</p></div>";
}
function json_api_class_warning() {
echo "<div id=\"json-api-warning\" class=\"updated fade\"><p>Oops, JSON_API class not found. If you've defined a JSON_API_DIR constant, double check that the path is correct.</p></div>";
}
function json_api_activation() {
// Add the rewrite rule on activation
global $wp_rewrite;
add_filter('rewrite_rules_array', 'json_api_rewrites');
$wp_rewrite->flush_rules();
}
function json_api_deactivation() {
// Remove the rewrite rule on deactivation
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
function json_api_rewrites($wp_rules) {
$base = get_option('json_api_base', 'api');
if (empty($base)) {
return $wp_rules;
}
$json_api_rules = array(
"$base\$" => 'index.php?json=info',
"$base/(.+)\$" => 'index.php?json=$matches[1]'
);
return array_merge($json_api_rules, $wp_rules);
}
function json_api_dir() {
if (defined('JSON_API_DIR') && file_exists(JSON_API_DIR)) {
return JSON_API_DIR;
} else {
return dirname(__FILE__);
}
}
// Add initialization and activation hooks
add_action('init', 'json_api_init');
register_activation_hook("$dir/json-api.php", 'json_api_activation');
register_deactivation_hook("$dir/json-api.php", 'json_api_deactivation');
?>
@@ -0,0 +1,861 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php 288200 2009-09-09 15:41:29Z alan_k $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 3);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 4);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 5);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 16);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* encodes an arbitrary variable into JSON format (and sends JSON Header)
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
header('Content-type: application/json');
return $this->_encode($var);
}
/**
* encodes an arbitrary variable into JSON format without JSON Header - warning - may allow CSS!!!!)
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encodeUnsafe($var)
{
return $this->_encode($var);
}
/**
* PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function _encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
if ($c+1 >= $strlen_var) {
$c += 1;
$ascii .= '?';
break;
}
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
if ($c+2 >= $strlen_var) {
$c += 2;
$ascii .= '?';
break;
}
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
@ord($var{$c + 1}),
@ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
if ($c+3 >= $strlen_var) {
$c += 3;
$ascii .= '?';
break;
}
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
if ($c+4 >= $strlen_var) {
$c += 4;
$ascii .= '?';
break;
}
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
if ($c+5 >= $strlen_var) {
$c += 5;
$ascii .= '?';
break;
}
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
}
// treat it like a regular array
$elements = array_map(array($this, '_encode'), $var);
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
return '[' . join(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->_encode($value);
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
return $this->_encode(strval($name)) . ':' . $encoded_value;
}
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
case 'null':
return null;
default:
$m = array();
if (is_numeric($str)) {
// Lookie-loo, it's a number
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
}
}
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} else {
return $obj;
}
}
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
}
}
}
}
/**
* @todo Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
return false;
}
}
if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
} else {
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
}
}
}
@@ -0,0 +1,56 @@
<?php
class JSON_API_Attachment {
var $id; // Integer
var $url; // String
var $slug; // String
var $title; // String
var $description; // String
var $caption; // String
var $parent; // Integer
var $mime_type; // String
function JSON_API_Attachment($wp_attachment = null) {
if ($wp_attachment) {
$this->import_wp_object($wp_attachment);
if ($this->is_image()) {
$this->query_images();
}
}
}
function import_wp_object($wp_attachment) {
$this->id = (int) $wp_attachment->ID;
$this->url = $wp_attachment->guid;
$this->slug = $wp_attachment->post_name;
$this->title = $wp_attachment->post_title;
$this->description = $wp_attachment->post_content;
$this->caption = $wp_attachment->post_excerpt;
$this->parent = (int) $wp_attachment->post_parent;
$this->mime_type = $wp_attachment->post_mime_type;
}
function is_image() {
return (substr($this->mime_type, 0, 5) == 'image');
}
function query_images() {
$sizes = array('thumbnail', 'medium', 'large', 'full');
if (function_exists('get_intermediate_image_sizes')) {
$sizes = array_merge(array('full'), get_intermediate_image_sizes());
}
$this->images = array();
foreach ($sizes as $size) {
list($url, $width, $height) = wp_get_attachment_image_src($this->id, $size);
$this->images[$size] = (object) array(
'url' => $url,
'width' => $width,
'height' => $height
);
}
}
}
?>
@@ -0,0 +1,62 @@
<?php
class JSON_API_Author {
var $id; // Integer
var $slug; // String
var $name; // String
var $first_name; // String
var $last_name; // String
var $nickname; // String
var $url; // String
var $description; // String
// Note:
// JSON_API_Author objects can include additional values by using the
// author_meta query var.
function JSON_API_Author($id = null) {
if ($id) {
$this->id = (int) $id;
} else {
$this->id = (int) get_the_author_meta('ID');
}
$this->set_value('slug', 'user_nicename');
$this->set_value('name', 'display_name');
$this->set_value('first_name', 'first_name');
$this->set_value('last_name', 'last_name');
$this->set_value('nickname', 'nickname');
$this->set_value('url', 'user_url');
$this->set_value('description', 'description');
$this->set_author_meta();
//$this->raw = get_userdata($this->id);
}
function set_value($key, $wp_key = false) {
if (!$wp_key) {
$wp_key = $key;
}
$this->$key = get_the_author_meta($wp_key, $this->id);
}
function set_author_meta() {
global $json_api;
if (!$json_api->query->author_meta) {
return;
}
$protected_vars = array(
'user_login',
'user_pass',
'user_email',
'user_activation_key'
);
$vars = explode(',', $json_api->query->author_meta);
$vars = array_diff($vars, $protected_vars);
foreach ($vars as $var) {
$this->set_value($var);
}
}
}
?>
@@ -0,0 +1,29 @@
<?php
class JSON_API_Category {
var $id; // Integer
var $slug; // String
var $title; // String
var $description; // String
var $parent; // Integer
var $post_count; // Integer
function JSON_API_Category($wp_category = null) {
if ($wp_category) {
$this->import_wp_object($wp_category);
}
}
function import_wp_object($wp_category) {
$this->id = (int) $wp_category->term_id;
$this->slug = $wp_category->slug;
$this->title = $wp_category->name;
$this->description = $wp_category->description;
$this->parent = (int) $wp_category->parent;
$this->post_count = (int) $wp_category->count;
}
}
?>
@@ -0,0 +1,80 @@
<?php
class JSON_API_Comment {
var $id; // Integer
var $name; // String
var $url; // String
var $date; // String
var $content; // String
var $parent; // Integer
var $author; // Object (only if the user was registered & logged in)
function JSON_API_Comment($wp_comment = null) {
if ($wp_comment) {
$this->import_wp_object($wp_comment);
}
}
function import_wp_object($wp_comment) {
global $json_api;
$date_format = $json_api->query->date_format;
$content = apply_filters('comment_text', $wp_comment->comment_content);
$this->id = (int) $wp_comment->comment_ID;
$this->name = $wp_comment->comment_author;
$this->url = $wp_comment->comment_author_url;
$this->date = date($date_format, strtotime($wp_comment->comment_date));
$this->content = $content;
$this->parent = (int) $wp_comment->comment_parent;
//$this->raw = $wp_comment;
if (!empty($wp_comment->user_id)) {
$this->author = new JSON_API_Author($wp_comment->user_id);
} else {
unset($this->author);
}
}
function handle_submission() {
global $comment, $wpdb;
add_action('comment_id_not_found', array(&$this, 'comment_id_not_found'));
add_action('comment_closed', array(&$this, 'comment_closed'));
add_action('comment_on_draft', array(&$this, 'comment_on_draft'));
add_filter('comment_post_redirect', array(&$this, 'comment_post_redirect'));
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['comment_post_ID'] = $_REQUEST['post_id'];
$_POST['author'] = $_REQUEST['name'];
$_POST['email'] = $_REQUEST['email'];
$_POST['url'] = empty($_REQUEST['url']) ? '' : $_REQUEST['url'];
$_POST['comment'] = $_REQUEST['content'];
$_POST['parent'] = $_REQUEST['parent'];
include ABSPATH . 'wp-comments-post.php';
}
function comment_id_not_found() {
global $json_api;
$json_api->error("Post ID '{$_REQUEST['post_id']}' not found.");
}
function comment_closed() {
global $json_api;
$json_api->error("Post is closed for comments.");
}
function comment_on_draft() {
global $json_api;
$json_api->error("You cannot comment on unpublished posts.");
}
function comment_post_redirect() {
global $comment, $json_api;
$status = ($comment->comment_approved) ? 'ok' : 'pending';
$new_comment = new JSON_API_Comment($comment);
$json_api->response->respond($new_comment, $status);
}
}
?>
@@ -0,0 +1,300 @@
<?php
class JSON_API_Post {
// Note:
// JSON_API_Post objects must be instantiated within The Loop.
var $id; // Integer
var $type; // String
var $slug; // String
var $url; // String
var $status; // String ("draft", "published", or "pending")
var $title; // String
var $title_plain; // String
var $content; // String (modified by read_more query var)
var $excerpt; // String
var $date; // String (modified by date_format query var)
var $modified; // String (modified by date_format query var)
var $categories; // Array of objects
var $tags; // Array of objects
var $author; // Object
var $comments; // Array of objects
var $attachments; // Array of objects
var $comment_count; // Integer
var $comment_status; // String ("open" or "closed")
var $thumbnail; // String
var $custom_fields; // Object (included by using custom_fields query var)
function JSON_API_Post($wp_post = null) {
if (!empty($wp_post)) {
$this->import_wp_object($wp_post);
}
}
function create($values = null) {
unset($values['id']);
if (empty($values) || empty($values['title'])) {
$values = array(
'title' => 'Untitled',
'content' => ''
);
}
return $this->save($values);
}
function update($values) {
$values['id'] = $this->id;
return $this->save($values);
}
function save($values = null) {
global $json_api, $user_ID;
$wp_values = array();
if (!empty($values['id'])) {
$wp_values['ID'] = $values['id'];
}
if (!empty($values['type'])) {
$wp_values['post_type'] = $values['type'];
}
if (!empty($values['status'])) {
$wp_values['post_status'] = $values['status'];
}
if (!empty($values['title'])) {
$wp_values['post_title'] = $values['title'];
}
if (!empty($values['content'])) {
$wp_values['post_content'] = $values['content'];
}
if (!empty($values['author'])) {
$author = $json_api->introspector->get_author_by_login($values['author']);
$wp_values['post_author'] = $author->id;
}
if (isset($values['categories'])) {
$categories = explode(',', $values['categories']);
foreach ($categories as $category_slug) {
$category_slug = trim($category_slug);
$category = $json_api->introspector->get_category_by_slug($category_slug);
if (empty($wp_values['post_category'])) {
$wp_values['post_category'] = array($category->id);
} else {
array_push($wp_values['post_category'], $category->id);
}
}
}
if (isset($values['tags'])) {
$tags = explode(',', $values['tags']);
foreach ($tags as $tag_slug) {
$tag_slug = trim($tag_slug);
if (empty($wp_values['tags_input'])) {
$wp_values['tags_input'] = array($tag_slug);
} else {
array_push($wp_values['tags_input'], $tag_slug);
}
}
}
if (isset($wp_values['ID'])) {
$this->id = wp_update_post($wp_values);
} else {
$this->id = wp_insert_post($wp_values);
}
if (!empty($_FILES['attachment'])) {
include_once ABSPATH . '/wp-admin/includes/file.php';
include_once ABSPATH . '/wp-admin/includes/media.php';
include_once ABSPATH . '/wp-admin/includes/image.php';
$attachment_id = media_handle_upload('attachment', $this->id);
$this->attachments[] = new JSON_API_Attachment($attachment_id);
unset($_FILES['attachment']);
}
$wp_post = get_post($this->id);
$this->import_wp_object($wp_post);
return $this->id;
}
function import_wp_object($wp_post) {
global $json_api, $post;
$date_format = $json_api->query->date_format;
$this->id = (int) $wp_post->ID;
setup_postdata($wp_post);
$this->set_value('type', $wp_post->post_type);
$this->set_value('slug', $wp_post->post_name);
$this->set_value('url', get_permalink($this->id));
$this->set_value('status', $wp_post->post_status);
$this->set_value('title', get_the_title($this->id));
$this->set_value('title_plain', strip_tags(@$this->title));
$this->set_content_value();
$this->set_value('excerpt', get_the_excerpt());
$this->set_value('date', get_the_time($date_format));
$this->set_value('modified', date($date_format, strtotime($wp_post->post_modified)));
$this->set_categories_value();
$this->set_tags_value();
$this->set_author_value($wp_post->post_author);
$this->set_comments_value();
$this->set_attachments_value();
$this->set_value('comment_count', (int) $wp_post->comment_count);
$this->set_value('comment_status', $wp_post->comment_status);
$this->set_thumbnail_value();
$this->set_custom_fields_value();
$this->set_event_value();
}
function set_value($key, $value) {
global $json_api;
if ($json_api->include_value($key)) {
$this->$key = $value;
} else {
unset($this->$key);
}
}
function set_event_value() {
global $post;
$event_array = get_the_terms( $post->ID , 'event_type');
$event_types = array();
foreach ( $event_array as $event_type ) {
while ( $event_type->parent !== "0" ) {
$id = (int)$event_type->parent;
$event_type = get_term( $id, 'event_type' );
}
$event_types[] = $event_type->name;
}
$this->set_value('event', $event_type->name);
}
function set_content_value() {
global $json_api;
if ($json_api->include_value('content')) {
$content = get_the_content($json_api->query->read_more);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
$this->content = $content;
} else {
unset($this->content);
}
}
function set_categories_value() {
global $json_api;
if ($json_api->include_value('categories')) {
$this->categories = array();
if ($wp_categories = get_the_category($this->id)) {
foreach ($wp_categories as $wp_category) {
$category = new JSON_API_Category($wp_category);
if ($category->id == 1 && $category->slug == 'uncategorized') {
// Skip the 'uncategorized' category
continue;
}
$this->categories[] = $category;
}
}
} else {
unset($this->categories);
}
}
function set_tags_value() {
global $json_api;
if ($json_api->include_value('tags')) {
$this->tags = array();
if ($wp_tags = get_the_tags($this->id)) {
foreach ($wp_tags as $wp_tag) {
$this->tags[] = new JSON_API_Tag($wp_tag);
}
}
} else {
unset($this->tags);
}
}
function set_author_value($author_id) {
global $json_api;
if ($json_api->include_value('author')) {
$this->author = new JSON_API_Author($author_id);
} else {
unset($this->author);
}
}
function set_comments_value() {
global $json_api;
if ($json_api->include_value('comments')) {
$this->comments = $json_api->introspector->get_comments($this->id);
} else {
unset($this->comments);
}
}
function set_attachments_value() {
global $json_api;
if ($json_api->include_value('attachments')) {
$this->attachments = $json_api->introspector->get_attachments($this->id);
} else {
unset($this->attachments);
}
}
function set_thumbnail_value() {
global $json_api;
if (!$json_api->include_value('thumbnail') ||
!function_exists('get_post_thumbnail_id')) {
unset($this->thumbnail);
return;
}
$attachment_id = get_post_thumbnail_id($this->id);
if (!$attachment_id) {
unset($this->thumbnail);
return;
}
$thumbnail_size = $this->get_thumbnail_size();
list($thumbnail) = wp_get_attachment_image_src($attachment_id, $thumbnail_size);
$this->thumbnail = $thumbnail;
}
function set_custom_fields_value() {
global $json_api;
if ($json_api->include_value('custom_fields') &&
$json_api->query->custom_fields) {
$keys = explode(',', $json_api->query->custom_fields);
$wp_custom_fields = get_post_custom($this->id);
$this->custom_fields = new stdClass();
foreach ($keys as $key) {
if (isset($wp_custom_fields[$key])) {
$this->custom_fields->$key = $wp_custom_fields[$key];
}
}
} else {
unset($this->custom_fields);
}
}
function get_thumbnail_size() {
global $json_api;
if ($json_api->query->thumbnail_size) {
return $json_api->query->thumbnail_size;
} else if (function_exists('get_intermediate_image_sizes')) {
$sizes = get_intermediate_image_sizes();
if (in_array('post-thumbnail', $sizes)) {
return 'post-thumbnail';
}
}
return 'thumbnail';
}
}
?>
@@ -0,0 +1,26 @@
<?php
class JSON_API_Tag {
var $id; // Integer
var $slug; // String
var $title; // String
var $description; // String
function JSON_API_Tag($wp_tag = null) {
if ($wp_tag) {
$this->import_wp_object($wp_tag);
}
}
function import_wp_object($wp_tag) {
$this->id = (int) $wp_tag->term_id;
$this->slug = $wp_tag->slug;
$this->title = $wp_tag->name;
$this->description = $wp_tag->description;
$this->post_count = (int) $wp_tag->count;
}
}
?>
File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

@@ -0,0 +1,371 @@
<?php
class JSON_API {
function __construct() {
$this->query = new JSON_API_Query();
$this->introspector = new JSON_API_Introspector();
$this->response = new JSON_API_Response();
add_action('template_redirect', array(&$this, 'template_redirect'));
add_action('admin_menu', array(&$this, 'admin_menu'));
add_action('update_option_json_api_base', array(&$this, 'flush_rewrite_rules'));
add_action('pre_update_option_json_api_controllers', array(&$this, 'update_controllers'));
}
function template_redirect() {
// Check to see if there's an appropriate API controller + method
$controller = strtolower($this->query->get_controller());
$available_controllers = $this->get_controllers();
$enabled_controllers = explode(',', get_option('json_api_controllers', 'core'));
$active_controllers = array_intersect($available_controllers, $enabled_controllers);
if ($controller) {
if (!in_array($controller, $active_controllers)) {
$this->error("Unknown controller '$controller'.");
}
$controller_path = $this->controller_path($controller);
if (file_exists($controller_path)) {
require_once $controller_path;
}
$controller_class = $this->controller_class($controller);
if (!class_exists($controller_class)) {
$this->error("Unknown controller '$controller_class'.");
}
$this->controller = new $controller_class();
$method = $this->query->get_method($controller);
if ($method) {
$this->response->setup();
// Run action hooks for method
do_action("json_api-{$controller}-$method");
// Error out if nothing is found
if ($method == '404') {
$this->error('Not found');
}
// Run the method
$result = $this->controller->$method();
// Handle the result
$this->response->respond($result);
// Done!
exit;
}
}
}
function admin_menu() {
add_options_page('JSON API Settings', 'JSON API', 'manage_options', 'json-api', array(&$this, 'admin_options'));
}
function admin_options() {
if (!current_user_can('manage_options')) {
wp_die( __('You do not have sufficient permissions to access this page.') );
}
$available_controllers = $this->get_controllers();
$active_controllers = explode(',', get_option('json_api_controllers', 'core'));
if (count($active_controllers) == 1 && empty($active_controllers[0])) {
$active_controllers = array();
}
if (!empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], "update-options")) {
if ((!empty($_REQUEST['action']) || !empty($_REQUEST['action2'])) &&
(!empty($_REQUEST['controller']) || !empty($_REQUEST['controllers']))) {
if (!empty($_REQUEST['action'])) {
$action = $_REQUEST['action'];
} else {
$action = $_REQUEST['action2'];
}
if (!empty($_REQUEST['controllers'])) {
$controllers = $_REQUEST['controllers'];
} else {
$controllers = array($_REQUEST['controller']);
}
foreach ($controllers as $controller) {
if (in_array($controller, $available_controllers)) {
if ($action == 'activate' && !in_array($controller, $active_controllers)) {
$active_controllers[] = $controller;
} else if ($action == 'deactivate') {
$index = array_search($controller, $active_controllers);
if ($index !== false) {
unset($active_controllers[$index]);
}
}
}
}
$this->save_option('json_api_controllers', implode(',', $active_controllers));
}
if (isset($_REQUEST['json_api_base'])) {
$this->save_option('json_api_base', $_REQUEST['json_api_base']);
}
}
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div>
<h2>JSON API Settings</h2>
<form action="options-general.php?page=json-api" method="post">
<?php wp_nonce_field('update-options'); ?>
<h3>Controllers</h3>
<?php $this->print_controller_actions(); ?>
<table id="all-plugins-table" class="widefat">
<thead>
<tr>
<th class="manage-column check-column" scope="col"><input type="checkbox" /></th>
<th class="manage-column" scope="col">Controller</th>
<th class="manage-column" scope="col">Description</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="manage-column check-column" scope="col"><input type="checkbox" /></th>
<th class="manage-column" scope="col">Controller</th>
<th class="manage-column" scope="col">Description</th>
</tr>
</tfoot>
<tbody class="plugins">
<?php
foreach ($available_controllers as $controller) {
$error = false;
$active = in_array($controller, $active_controllers);
$info = $this->controller_info($controller);
if (is_string($info)) {
$active = false;
$error = true;
$info = array(
'name' => $controller,
'description' => "<p><strong>Error</strong>: $info</p>",
'methods' => array(),
'url' => null
);
}
?>
<tr class="<?php echo ($active ? 'active' : 'inactive'); ?>">
<th class="check-column" scope="row">
<input type="checkbox" name="controllers[]" value="<?php echo $controller; ?>" />
</th>
<td class="plugin-title">
<strong><?php echo $info['name']; ?></strong>
<div class="row-actions-visible">
<?php
if ($active) {
echo '<a href="' . wp_nonce_url('options-general.php?page=json-api&amp;action=deactivate&amp;controller=' . $controller, 'update-options') . '" title="' . __('Deactivate this controller') . '" class="edit">' . __('Deactivate') . '</a>';
} else if (!$error) {
echo '<a href="' . wp_nonce_url('options-general.php?page=json-api&amp;action=activate&amp;controller=' . $controller, 'update-options') . '" title="' . __('Activate this controller') . '" class="edit">' . __('Activate') . '</a>';
}
if ($info['url']) {
echo ' | ';
echo '<a href="' . $info['url'] . '" target="_blank">Docs</a></div>';
}
?>
</td>
<td class="desc">
<p><?php echo $info['description']; ?></p>
<p>
<?php
foreach($info['methods'] as $method) {
$url = $this->get_method_url($controller, $method, array('dev' => 1));
if ($active) {
echo "<code><a href=\"$url\">$method</a></code> ";
} else {
echo "<code>$method</code> ";
}
}
?>
</p>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php $this->print_controller_actions('action2'); ?>
<h3>Address</h3>
<p>Specify a base URL for JSON API. For example, using <code>api</code> as your API base URL would enable the following <code><?php bloginfo('url'); ?>/api/get_recent_posts/</code>. If you assign a blank value the API will only be available by setting a <code>json</code> query variable.</p>
<table class="form-table">
<tr valign="top">
<th scope="row">API base</th>
<td><code><?php bloginfo('url'); ?>/</code><input type="text" name="json_api_base" value="<?php echo get_option('json_api_base', 'api'); ?>" size="15" /></td>
</tr>
</table>
<?php if (!get_option('permalink_structure', '')) { ?>
<br />
<p><strong>Note:</strong> User-friendly permalinks are not currently enabled. <a target="_blank" class="button" href="options-permalink.php">Change Permalinks</a>
<?php } ?>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php
}
function print_controller_actions($name = 'action') {
?>
<div class="tablenav">
<div class="alignleft actions">
<select name="<?php echo $name; ?>">
<option selected="selected" value="-1">Bulk Actions</option>
<option value="activate">Activate</option>
<option value="deactivate">Deactivate</option>
</select>
<input type="submit" class="button-secondary action" id="doaction" name="doaction" value="Apply">
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
<?php
}
function get_method_url($controller, $method, $options = '') {
$url = get_bloginfo('url');
$base = get_option('json_api_base', 'api');
$permalink_structure = get_option('permalink_structure', '');
if (!empty($options) && is_array($options)) {
$args = array();
foreach ($options as $key => $value) {
$args[] = urlencode($key) . '=' . urlencode($value);
}
$args = implode('&', $args);
} else {
$args = $options;
}
if ($controller != 'core') {
$method = "$controller/$method";
}
if (!empty($base) && !empty($permalink_structure)) {
if (!empty($args)) {
$args = "?$args";
}
return "$url/$base/$method/$args";
} else {
return "$url?json=$method&$args";
}
}
function save_option($id, $value) {
$option_exists = (get_option($id, null) !== null);
if ($option_exists) {
update_option($id, $value);
} else {
add_option($id, $value);
}
}
function get_controllers() {
$controllers = array();
$dir = json_api_dir();
$dh = opendir("$dir/controllers");
while ($file = readdir($dh)) {
if (preg_match('/(.+)\.php$/', $file, $matches)) {
$controllers[] = $matches[1];
}
}
$controllers = apply_filters('json_api_controllers', $controllers);
return array_map('strtolower', $controllers);
}
function controller_is_active($controller) {
if (defined('JSON_API_CONTROLLERS')) {
$default = JSON_API_CONTROLLERS;
} else {
$default = 'core';
}
$active_controllers = explode(',', get_option('json_api_controllers', $default));
return (in_array($controller, $active_controllers));
}
function update_controllers($controllers) {
if (is_array($controllers)) {
return implode(',', $controllers);
} else {
return $controllers;
}
}
function controller_info($controller) {
$path = $this->controller_path($controller);
$class = $this->controller_class($controller);
$response = array(
'name' => $controller,
'description' => '(No description available)',
'methods' => array()
);
if (file_exists($path)) {
$source = file_get_contents($path);
if (preg_match('/^\s*Controller name:(.+)$/im', $source, $matches)) {
$response['name'] = trim($matches[1]);
}
if (preg_match('/^\s*Controller description:(.+)$/im', $source, $matches)) {
$response['description'] = trim($matches[1]);
}
if (preg_match('/^\s*Controller URI:(.+)$/im', $source, $matches)) {
$response['docs'] = trim($matches[1]);
}
if (!class_exists($class)) {
require_once($path);
}
$response['methods'] = get_class_methods($class);
return $response;
} else if (is_admin()) {
return "Cannot find controller class '$class' (filtered path: $path).";
} else {
$this->error("Unknown controller '$controller'.");
}
return $response;
}
function controller_class($controller) {
return "json_api_{$controller}_controller";
}
function controller_path($controller) {
$dir = json_api_dir();
$controller_class = $this->controller_class($controller);
return apply_filters("{$controller_class}_path", "$dir/controllers/$controller.php");
}
function get_nonce_id($controller, $method) {
$controller = strtolower($controller);
$method = strtolower($method);
return "json_api-$controller-$method";
}
function flush_rewrite_rules() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
function error($message = 'Unknown error', $status = 'error') {
$this->response->respond(array(
'error' => $message
), $status);
}
function include_value($key) {
return $this->response->is_value_included($key);
}
}
?>
@@ -0,0 +1,299 @@
<?php
class JSON_API_Introspector {
public function get_posts($query = false, $wp_posts = false) {
global $post;
$this->set_posts_query($query);
$output = array();
while (have_posts()) {
the_post();
if ($wp_posts) {
$output[] = $post;
} else {
$output[] = new JSON_API_Post($post);
}
}
return $output;
}
public function get_date_archive_permalinks() {
$archives = wp_get_archives('echo=0');
preg_match_all("/href='([^']+)'/", $archives, $matches);
return $matches[1];
}
public function get_date_archive_tree($permalinks) {
$tree = array();
foreach ($permalinks as $url) {
if (preg_match('#(\d{4})/(\d{2})#', $url, $date)) {
$year = $date[1];
$month = $date[2];
} else if (preg_match('/(\d{4})(\d{2})/', $url, $date)) {
$year = $date[1];
$month = $date[2];
} else {
continue;
}
$count = $this->get_date_archive_count($year, $month);
if (empty($tree[$year])) {
$tree[$year] = array(
$month => $count
);
} else {
$tree[$year][$month] = $count;
}
}
return $tree;
}
public function get_date_archive_count($year, $month) {
if (!isset($this->month_archives)) {
global $wpdb;
$post_counts = $wpdb->get_results("
SELECT DATE_FORMAT(post_date, '%Y%m') AS month,
COUNT(ID) AS post_count
FROM $wpdb->posts
WHERE post_status = 'publish'
AND post_type = 'post'
GROUP BY month
");
$this->month_archives = array();
foreach ($post_counts as $post_count) {
$this->month_archives[$post_count->month] = $post_count->post_count;
}
}
return $this->month_archives["$year$month"];
}
public function get_categories() {
$wp_categories = get_categories();
$categories = array();
foreach ($wp_categories as $wp_category) {
if ($wp_category->term_id == 1 && $wp_category->slug == 'uncategorized') {
continue;
}
$categories[] = $this->get_category_object($wp_category);
}
return $categories;
}
public function get_current_category() {
global $json_api;
extract($json_api->query->get(array('id', 'slug', 'category_id', 'category_slug')));
if ($id || $category_id) {
if (!$id) {
$id = $category_id;
}
return $this->get_category_by_id($id);
} else if ($slug || $category_slug) {
if (!$slug) {
$slug = $category_slug;
}
return $this->get_category_by_slug($slug);
} else {
$json_api->error("Include 'id' or 'slug' var in your request.");
}
return null;
}
public function get_category_by_id($category_id) {
$wp_category = get_term_by('id', $category_id, 'category');
return $this->get_category_object($wp_category);
}
public function get_category_by_slug($category_slug) {
$wp_category = get_term_by('slug', $category_slug, 'category');
return $this->get_category_object($wp_category);
}
public function get_tags() {
$wp_tags = get_tags();
return array_map(array(&$this, 'get_tag_object'), $wp_tags);
}
public function get_current_tag() {
global $json_api;
extract($json_api->query->get(array('id', 'slug', 'tag_id', 'tag_slug')));
if ($id || $tag_id) {
if (!$id) {
$id = $tag_id;
}
return $this->get_tag_by_id($id);
} else if ($slug || $tag_slug) {
if (!$slug) {
$slug = $tag_slug;
}
return $this->get_tag_by_slug($slug);
} else {
$json_api->error("Include 'id' or 'slug' var in your request.");
}
return null;
}
public function get_tag_by_id($tag_id) {
$wp_tag = get_term_by('id', $tag_id, 'post_tag');
return $this->get_tag_object($wp_tag);
}
public function get_tag_by_slug($tag_slug) {
$wp_tag = get_term_by('slug', $tag_slug, 'post_tag');
return $this->get_tag_object($wp_tag);
}
public function get_authors() {
global $wpdb;
$author_ids = $wpdb->get_col($wpdb->prepare("
SELECT u.ID, m.meta_value AS last_name
FROM $wpdb->users AS u,
$wpdb->usermeta AS m
WHERE m.user_id = u.ID
AND m.meta_key = 'last_name'
ORDER BY last_name
"));
$all_authors = array_map(array(&$this, 'get_author_by_id'), $author_ids);
$active_authors = array_filter($all_authors, array(&$this, 'is_active_author'));
return $active_authors;
}
public function get_current_author() {
global $json_api;
extract($json_api->query->get(array('id', 'slug', 'author_id', 'author_slug')));
if ($id || $author_id) {
if (!$id) {
$id = $author_id;
}
return $this->get_author_by_id($id);
} else if ($slug || $author_slug) {
if (!$slug) {
$slug = $author_slug;
}
return $this->get_author_by_login($slug);
} else {
$json_api->error("Include 'id' or 'slug' var in your request.");
}
return null;
}
public function get_author_by_id($id) {
$id = get_the_author_meta('ID', $id);
if (!$id) {
return null;
}
return new JSON_API_Author($id);
}
public function get_author_by_login($login) {
global $wpdb;
$id = $wpdb->get_var($wpdb->prepare("
SELECT ID
FROM $wpdb->users
WHERE user_nicename = %s
", $login));
return $this->get_author_by_id($id);
}
public function get_comments($post_id) {
global $wpdb;
$wp_comments = $wpdb->get_results($wpdb->prepare("
SELECT *
FROM $wpdb->comments
WHERE comment_post_ID = %d
AND comment_approved = 1
AND comment_type = ''
ORDER BY comment_date
", $post_id));
$comments = array();
foreach ($wp_comments as $wp_comment) {
$comments[] = new JSON_API_Comment($wp_comment);
}
return $comments;
}
public function get_attachments($post_id) {
$wp_attachments = get_children(array(
'post_type' => 'attachment',
'post_parent' => $post_id,
'orderby' => 'menu_order',
'order' => 'ASC'
));
$attachments = array();
if (!empty($wp_attachments)) {
foreach ($wp_attachments as $wp_attachment) {
$attachments[] = new JSON_API_Attachment($wp_attachment);
}
}
return $attachments;
}
public function attach_child_posts(&$post) {
$post->children = array();
$wp_children = get_posts(array(
'post_type' => $post->type,
'post_parent' => $post->id,
'order' => 'ASC',
'orderby' => 'menu_order'
));
foreach ($wp_children as $wp_post) {
$post->children[] = new JSON_API_Post($wp_post);
}
foreach ($post->children as $child) {
$this->attach_child_posts($child);
}
}
protected function get_category_object($wp_category) {
if (!$wp_category) {
return null;
}
return new JSON_API_Category($wp_category);
}
protected function get_tag_object($wp_tag) {
if (!$wp_tag) {
return null;
}
return new JSON_API_Tag($wp_tag);
}
protected function is_active_author($author) {
if (!isset($this->active_authors)) {
$this->active_authors = explode(',', wp_list_authors(array(
'html' => false,
'echo' => false,
'exclude_admin' => false
)));
$this->active_authors = array_map('trim', $this->active_authors);
}
return in_array($author->name, $this->active_authors);
}
protected function set_posts_query($query = false) {
global $json_api, $wp_query;
if (!$query) {
$query = array();
}
$query = array_merge($query, $wp_query->query);
if ($json_api->query->page) {
$query['paged'] = $json_api->query->page;
}
if ($json_api->query->count) {
$query['posts_per_page'] = $json_api->query->count;
}
if ($json_api->query->post_type) {
$query['post_type'] = $json_api->query->post_type;
}
if (!empty($query)) {
query_posts($query);
}
}
}
?>
@@ -0,0 +1,194 @@
<?php
class JSON_API_Query {
// Default values
protected $defaults = array(
'date_format' => 'Y-m-d H:i:s',
'read_more' => 'Read more'
);
function __construct() {
// Register JSON API query vars
add_filter('query_vars', array(&$this, 'query_vars'));
}
function get($key) {
if (is_array($key)) {
$result = array();
foreach ($key as $k) {
$result[$k] = $this->get($k);
}
return $result;
}
$query_var = (isset($_REQUEST[$key])) ? $_REQUEST[$key] : null;
$wp_query_var = $this->wp_query_var($key);
if ($wp_query_var) {
return $wp_query_var;
} else if ($query_var) {
return $this->strip_magic_quotes($query_var);
} else if (isset($this->defaults[$key])) {
return $this->defaults[$key];
} else {
return null;
}
}
function __get($key) {
return $this->get($key);
}
function __isset($key) {
return ($this->get($key) !== null);
}
function wp_query_var($key) {
$wp_translation = array(
'json' => 'json',
'post_id' => 'p',
'post_slug' => 'name',
'page_id' => 'page_id',
'page_slug' => 'name',
'category_id' => 'cat',
'category_slug' => 'category_name',
'tag_id' => 'tag_id',
'tag_slug' => 'tag',
'author_id' => 'author',
'author_slug' => 'author_name',
'search' => 's',
'order' => 'order',
'order_by' => 'orderby'
);
if ($key == 'date') {
$date = null;
if (get_query_var('year')) {
$date = get_query_var('year');
}
if (get_query_var('monthnum')) {
$month = get_query_var('monthnum');
if ($month < 10) {
$month = "0$month";
}
$date .= $month;
}
if (get_query_var('day')) {
$day = get_query_var('day');
if ($day < 10) {
$day = "0$day";
}
$date .= $day;
}
return $date;
} else if (isset($wp_translation[$key])) {
return get_query_var($wp_translation[$key]);
} else {
return null;
}
}
function strip_magic_quotes($value) {
if (get_magic_quotes_gpc()) {
return stripslashes($value);
} else {
return $value;
}
}
function query_vars($wp_vars) {
$wp_vars[] = 'json';
return $wp_vars;
}
function get_controller() {
$json = $this->get('json');
if (empty($json)) {
return false;
}
if (preg_match('/^[a-zA-Z_]+$/', $json)) {
return $this->get_legacy_controller($json);
} else if (preg_match('/^([a-zA-Z_]+)(\/|\.)[a-zA-Z_]+$/', $json, $matches)) {
return $matches[1];
} else {
return 'core';
}
}
function get_legacy_controller($json) {
global $json_api;
if ($json == 'submit_comment') {
if ($json_api->controller_is_active('respond')) {
return 'respond';
} else {
$json_api->error("The 'submit_comment' method has been removed from the Core controller. To use this method you must enable the Respond controller from WP Admin > Settings > JSON API.");
}
} else if ($json == 'create_post') {
if ($json_api->controller_is_active('posts')) {
return 'posts';
} else {
$json_api->error("The 'create_post' method has been removed from the Core controller. To use this method you must enable the Posts controller from WP Admin > Settings > JSON API.");
}
} else {
return 'core';
}
}
function get_method($controller) {
global $json_api;
// Returns an appropriate API method name or false. Four possible outcomes:
// 1. API isn't being invoked at all (return false)
// 2. A specific API method was requested (return method name)
// 3. A method is chosen implicitly on a given WordPress page
// 4. API invoked incorrectly (return "error" method)
//
// Note:
// The implicit outcome (3) is invoked by setting the json query var to a
// non-empty value on any WordPress page:
// * http://example.org/2009/11/10/hello-world/?json=1 (get_post)
// * http://example.org/2009/11/?json=1 (get_date_posts)
// * http://example.org/category/foo?json=1 (get_category_posts)
$method = $this->get('json');
if (strpos($method, '/') !== false) {
$method = substr($method, strpos($method, '/') + 1);
} else if (strpos($method, '.') !== false) {
$method = substr($method, strpos($method, '.') + 1);
}
if (empty($method)) {
// Case 1: we're not being invoked (done!)
return false;
} else if (method_exists("JSON_API_{$controller}_Controller", $method)) {
// Case 2: an explicit method was specified
return $method;
} else if ($controller == 'core') {
// Case 3: choose the method implicitly based on which page we're on...
if (is_search()) {
return 'get_search_results';
} else if (is_home()) {
if (empty($_GET['json'])) {
$json_api->error("Uknown method '$method'.");
}
return 'get_recent_posts';
} else if (is_page()) {
return 'get_page';
} else if (is_single()) {
return 'get_post';
} else if (is_category()) {
return 'get_category_posts';
} else if (is_tag()) {
return 'get_tag_posts';
} else if (is_author()) {
return 'get_author_posts';
} else if (is_date()) {
return 'get_date_posts';
} else if (is_404()) {
return '404';
}
}
// Case 4: either the method doesn't exist or we don't support the page implicitly
return 'error';
}
}
@@ -0,0 +1,184 @@
<?php
class JSON_API_Response {
function setup() {
global $json_api;
$this->include_values = array();
$this->exclude_values = array();
if ($json_api->query->include) {
$this->include_values = explode(',', $json_api->query->include);
}
// Props to ikesyo for submitting a fix!
if ($json_api->query->exclude) {
$this->exclude_values = explode(',', $json_api->query->exclude);
$this->include_values = array_diff($this->include_values, $this->exclude_values);
}
// Compatibility with Disqus plugin
remove_action('loop_end', 'dsq_loop_end');
}
function get_json($data, $status = 'ok') {
// Include a status value with the response
if (is_array($data)) {
$data = array_merge(array('status' => $status), $data);
} else if (is_object($data)) {
$data = get_object_vars($data);
$data = array_merge(array('status' => $status), $data);
}
$data = apply_filters('json_api_encode', $data);
if (function_exists('json_encode')) {
// Use the built-in json_encode function if it's available
return json_encode($data);
} else {
// Use PEAR's Services_JSON encoder otherwise
if (!class_exists('Services_JSON')) {
$dir = json_api_dir();
require_once "$dir/library/JSON.php";
}
$json = new Services_JSON();
return $json->encode($data);
}
}
function is_value_included($key) {
// Props to ikesyo for submitting a fix!
if (empty($this->include_values) && empty($this->exclude_values)) {
return true;
} else {
if (empty($this->exclude_values)) {
return in_array($key, $this->include_values);
} else {
return !in_array($key, $this->exclude_values);
}
}
}
function respond($result, $status = 'ok') {
global $json_api;
$json = $this->get_json($result, $status);
$status_redirect = "redirect_$status";
if ($json_api->query->dev || !empty($_REQUEST['dev'])) {
// Output the result in a human-redable format
if (!headers_sent()) {
header('HTTP/1.1 200 OK');
header('Content-Type: text/plain; charset: UTF-8', true);
} else {
echo '<pre>';
}
echo $this->prettify($json);
} else if (!empty($_REQUEST[$status_redirect])) {
wp_redirect($_REQUEST[$status_redirect]);
} else if ($json_api->query->redirect) {
$url = $this->add_status_query_var($json_api->query->redirect, $status);
wp_redirect($url);
} else if ($json_api->query->callback) {
// Run a JSONP-style callback with the result
$this->callback($json_api->query->callback, $json);
} else {
// Output the result
$this->output($json);
}
exit;
}
function output($result) {
$charset = get_option('blog_charset');
if (!headers_sent()) {
header('HTTP/1.1 200 OK', true);
header("Content-Type: application/json; charset=$charset", true);
}
echo $result;
}
function callback($callback, $result) {
$charset = get_option('blog_charset');
if (!headers_sent()) {
header('HTTP/1.1 200 OK', true);
header("Content-Type: application/javascript; charset=$charset", true);
}
echo "$callback($result)";
}
function add_status_query_var($url, $status) {
if (strpos($url, '#')) {
// Remove the anchor hash for now
$pos = strpos($url, '#');
$anchor = substr($url, $pos);
$url = substr($url, 0, $pos);
}
if (strpos($url, '?')) {
$url .= "&status=$status";
} else {
$url .= "?status=$status";
}
if (!empty($anchor)) {
// Add the anchor hash back in
$url .= $anchor;
}
return $url;
}
function prettify($ugly) {
$pretty = "";
$indent = "";
$last = '';
$pos = 0;
$level = 0;
$string = false;
while ($pos < strlen($ugly)) {
$char = substr($ugly, $pos++, 1);
if (!$string) {
if ($char == '{' || $char == '[') {
if ($char == '[' && substr($ugly, $pos, 1) == ']') {
$pretty .= "[]";
$pos++;
} else if ($char == '{' && substr($ugly, $pos, 1) == '}') {
$pretty .= "{}";
$pos++;
} else {
$pretty .= "$char\n";
$indent = str_repeat(' ', ++$level);
$pretty .= "$indent";
}
} else if ($char == '}' || $char == ']') {
$indent = str_repeat(' ', --$level);
if ($last != '}' && $last != ']') {
$pretty .= "\n$indent";
} else if (substr($pretty, -2, 2) == ' ') {
$pretty = substr($pretty, 0, -2);
}
$pretty .= $char;
if (substr($ugly, $pos, 1) == ',') {
$pretty .= ",";
$last = ',';
$pos++;
}
$pretty .= "\n$indent";
} else if ($char == ':') {
$pretty .= ": ";
} else if ($char == ',') {
$pretty .= ",\n$indent";
} else if ($char == '"') {
$pretty .= '"';
$string = true;
} else {
$pretty .= $char;
}
} else {
if ($last != '\\' && $char == '"') {
$string = false;
}
$pretty .= $char;
}
$last = $char;
}
return $pretty;
}
}
?>
@@ -0,0 +1,14 @@
--TEST--
core.get_author_index
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_author_index');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":2,"authors":[{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},{"id":4,"slug":"ian-stewart","name":"Ian Stewart","first_name":"","last_name":"","nickname":"Ian Stewart","url":"","description":""}]}
@@ -0,0 +1,14 @@
--TEST--
core.get_author_posts by slug
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_author_posts&slug=chip-bennett');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":10,"pages":3,"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"posts":[{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_author_posts by author_slug
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_author_posts&author_slug=chip-bennett');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":10,"pages":3,"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"posts":[{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_author_posts by id
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_author_posts&id=3');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":10,"pages":3,"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"posts":[{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_author_posts by author_id
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_author_posts&author_id=3');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":10,"pages":3,"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"posts":[{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_category_index
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_category_index');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":44,"categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":4,"slug":"antiquarianism","title":"antiquarianism","description":"","parent":0,"post_count":1},{"id":5,"slug":"arrangement","title":"arrangement","description":"","parent":0,"post_count":1},{"id":6,"slug":"asmodeus","title":"asmodeus","description":"","parent":0,"post_count":1},{"id":7,"slug":"broder","title":"broder","description":"","parent":0,"post_count":1},{"id":8,"slug":"buying","title":"buying","description":"","parent":0,"post_count":1},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":12,"slug":"championship","title":"championship","description":"","parent":0,"post_count":1},{"id":13,"slug":"chastening","title":"chastening","description":"","parent":0,"post_count":1},{"id":14,"slug":"clerkship","title":"clerkship","description":"","parent":0,"post_count":1},{"id":15,"slug":"disinclination","title":"disinclination","description":"","parent":0,"post_count":1},{"id":16,"slug":"disinfection","title":"disinfection","description":"","parent":0,"post_count":1},{"id":17,"slug":"dispatch","title":"dispatch","description":"","parent":0,"post_count":1},{"id":18,"slug":"echappee","title":"echappee","description":"","parent":0,"post_count":1},{"id":19,"slug":"enphagy","title":"enphagy","description":"","parent":0,"post_count":1},{"id":20,"slug":"equipollent","title":"equipollent","description":"","parent":0,"post_count":1},{"id":21,"slug":"fatuity","title":"fatuity","description":"","parent":0,"post_count":1},{"id":24,"slug":"gaberlunzie","title":"gaberlunzie","description":"","parent":0,"post_count":1},{"id":25,"slug":"illtempered","title":"illtempered","description":"","parent":0,"post_count":1},{"id":26,"slug":"insubordination","title":"insubordination","description":"","parent":0,"post_count":1},{"id":27,"slug":"lender","title":"lender","description":"","parent":0,"post_count":1},{"id":28,"slug":"monosyllable","title":"monosyllable","description":"","parent":0,"post_count":1},{"id":29,"slug":"packthread","title":"packthread","description":"","parent":0,"post_count":1},{"id":30,"slug":"palter","title":"palter","description":"","parent":0,"post_count":1},{"id":31,"slug":"papilionaceous","title":"papilionaceous","description":"","parent":0,"post_count":1},{"id":33,"slug":"personable","title":"personable","description":"","parent":0,"post_count":1},{"id":34,"slug":"propylaeum","title":"propylaeum","description":"","parent":0,"post_count":1},{"id":35,"slug":"pustule","title":"pustule","description":"","parent":0,"post_count":1},{"id":36,"slug":"quartern","title":"quartern","description":"","parent":0,"post_count":1},{"id":37,"slug":"scholarship","title":"scholarship","description":"","parent":0,"post_count":1},{"id":38,"slug":"selfconvicted","title":"selfconvicted","description":"","parent":0,"post_count":1},{"id":39,"slug":"showshoe","title":"showshoe","description":"","parent":0,"post_count":1},{"id":40,"slug":"sloyd","title":"sloyd","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1},{"id":42,"slug":"sublunary","title":"sublunary","description":"","parent":0,"post_count":1},{"id":43,"slug":"tamtam","title":"tamtam","description":"","parent":0,"post_count":1},{"id":44,"slug":"weakhearted","title":"weakhearted","description":"","parent":0,"post_count":1},{"id":45,"slug":"ween","title":"ween","description":"","parent":0,"post_count":1},{"id":46,"slug":"wellhead","title":"wellhead","description":"","parent":0,"post_count":1},{"id":47,"slug":"wellintentioned","title":"wellintentioned","description":"","parent":0,"post_count":1},{"id":48,"slug":"whetstone","title":"whetstone","description":"","parent":0,"post_count":1},{"id":49,"slug":"years","title":"years","description":"","parent":0,"post_count":1}]}
@@ -0,0 +1,14 @@
--TEST--
core.get_category_posts default
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_category_posts&slug=cat-a');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":2,"pages":1,"category":{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},"posts":[{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"}]}
@@ -0,0 +1,14 @@
--TEST--
core.get_search_posts default
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_date_index');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","permalinks":["http:\/\/wordpress.test\/2008\/09\/","http:\/\/wordpress.test\/2008\/06\/","http:\/\/wordpress.test\/2008\/05\/","http:\/\/wordpress.test\/2008\/04\/","http:\/\/wordpress.test\/2008\/03\/"],"tree":{"2008":{"09":"3","06":"10","05":"5","04":"1","03":"3"}}}
@@ -0,0 +1,14 @@
--TEST--
core.get_date_posts by day
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_date_posts&date=2008-09-05');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":1,"count_total":1,"pages":1,"posts":[{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"}]}
@@ -0,0 +1,14 @@
--TEST--
core.get_date_posts by month
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_date_posts&date=2008-09');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":3,"count_total":3,"pages":1,"posts":[{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur euLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_date_posts by year
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_date_posts&date=2008-09');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":3,"count_total":3,"pages":1,"posts":[{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur euLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_page default
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_page&slug=about');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","page":{"id":686,"type":"page","slug":"about","url":"http:\/\/wordpress.test\/about\/","status":"publish","title":"About The Tests","title_plain":"About The Tests","content":"<p>This site is using the standard WordPress Theme Unit Test Data for content. The Theme Unit Test is a series of posts and pages that match up with a checklist on the WordPress codex. You can use the data and checklist together to test your theme.<\/p>\n<h2>WordPress Theme Development Resources<\/h2>\n<ol>\n<li>See <a href=\"http:\/\/codex.wordpress.org\/Theme_Development\">Theme Development<\/a> for <a href=\"http:\/\/codex.wordpress.org\/Theme_Development#Code_Standards\">code standards<\/a>, examples of best practices, and <a href=\"http:\/\/codex.wordpress.org\/Theme_Development#Resources_and_References\">resources for Theme development<\/a>.<\/li>\n<li>See <a href=\"http:\/\/codex.wordpress.org\/Theme_Unit_Test\">Theme Unit Test<\/a> for a robust test suite for your Theme and get the latest version of the test data you see here.<\/li>\n<li>See <a href=\"http:\/\/codex.wordpress.org\/Theme_Review\">Theme Review<\/a> for a guide to submitting your Theme to the <a href=\"http:\/\/wordpress.org\/extend\/themes\/\">Themes Directory<\/a>.<\/li>\n<\/ol>\n","excerpt":"This site is using the standard WordPress Theme Unit Test Data for content. The Theme Unit Test is a series of posts and pages that match up with a checklist on the WordPress codex. You can use the data and &hellip; <a href=\"http:\/\/wordpress.test\/about\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2010-07-25 19:40:01","modified":"2010-07-25 19:40:01","categories":[],"tags":[],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"}}
@@ -0,0 +1,14 @@
--TEST--
core.get_page children argument
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_page&slug=level-1&children=1');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","page":{"id":174,"type":"page","slug":"level-1","url":"http:\/\/wordpress.test\/level-1\/","status":"publish","title":"Level 1","title_plain":"Level 1","content":"<p>Level 1 of the reverse hierarchy test. This is to make sure the importer correctly assigns parents and children even when the children come first in the export file.<\/p>\n","excerpt":"Level 1 of the reverse hierarchy test. This is to make sure the importer correctly assigns parents and children even when the children come first in the export file.","date":"2007-12-11 16:25:40","modified":"2007-12-11 16:25:40","categories":[],"tags":[],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed","children":[{"id":173,"type":"page","slug":"level-2","url":"http:\/\/wordpress.test\/level-1\/level-2\/","status":"publish","title":"Level 2","title_plain":"Level 2","content":"<p>Level 2 of the reverse hierarchy test.<\/p>\n","excerpt":"Level 2 of the reverse hierarchy test.","date":"2007-12-11 16:25:40","modified":"2007-12-11 16:23:33","categories":[],"tags":[],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed","children":[{"id":172,"type":"page","slug":"level-3","url":"http:\/\/wordpress.test\/level-1\/level-2\/level-3\/","status":"publish","title":"Level 3","title_plain":"Level 3","content":"<p>Level 3 of the reverse hierarchy test.<\/p>\n","excerpt":"Level 3 of the reverse hierarchy test.","date":"2007-12-11 16:25:40","modified":"2007-12-11 16:23:16","categories":[],"tags":[],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed","children":[]}]}]}}
@@ -0,0 +1,14 @@
--TEST--
core.get_post default
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_post&slug=readability-test');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","post":{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p><span id=\"more-358\"><\/span><\/p>\n<p>Mrs. Darling first heard of Peter when she was tidying up her children&#8217;s minds. It is the nightly custom of every good mother after her children are asleep to rummage in their minds and put things straight for next morning, repacking into their proper places the many articles that have wandered during the day.<\/p>\n<p>If you could keep awake (but of course you can&#8217;t) you would see your own mother doing this, and you would find it very interesting to watch her. It is quite like tidying up drawers. You would see her on her knees, I expect, lingering humorously over some of your contents, wondering where on earth you had picked this thing up, making discoveries sweet and not so sweet, pressing this to her cheek as if it were as nice as a kitten, and hurriedly stowing that out of sight. When you wake in the morning, the naughtiness and evil passions with which you went to bed have been folded up small and placed at the bottom of your mind and on the top, beautifully aired, are spread out your prettier thoughts, ready for you to put on.<\/p>\n<p>I don&#8217;t know whether you have ever seen a map of a person&#8217;s mind. Doctors sometimes draw maps of other parts of you, and your own map can become intensely interesting, but catch them trying to draw a map of a child&#8217;s mind, which is not only confused, but keeps going round all the time. There are zigzag lines on it, just like your temperature on a card, and these are probably roads in the island, for the Neverland is always more or less an island, with astonishing splashes of colour here and there, and coral reefs and rakish-looking craft in the offing, and savages and lonely lairs, and gnomes who are mostly tailors, and caves through which a river runs, and princes with six elder brothers, and a hut fast going to decay, and one very small old lady with a hooked nose. It would be an easy map if that were all, but there is also first day at school, religion, fathers, the round pond, needle-work, murders, hangings, verbs that take the dative, chocolate pudding day, getting into braces, say ninety-nine, three-pence for pulling out your tooth yourself, and so on, and either these are part of the island or they are another map showing through, and it is all rather confusing, especially as nothing will stand still.<\/p>\n<p>Of course the Neverlands vary a good deal. John&#8217;s, for instance, had a lagoon with flamingoes flying over it at which John was shooting, while Michael, who was very small, had a flamingo with lagoons flying over it. John lived in a boat turned upside down on the sands, Michael in a wigwam, Wendy in a house of leaves deftly sewn together. John had no friends, Michael had friends at night, Wendy had a pet wolf forsaken by its parents, but on the whole the Neverlands have a family resemblance, and if they stood still in a row you could say of them that they have each other&#8217;s nose, and so forth. On these magic shores children at play are for ever beaching their coracles [simple boat]. We too have been there; we can still hear the sound of the surf, though we shall land no more.<\/p>\n<p>Of all delectable islands the Neverland is the snuggest and most compact, not large and sprawly, you know, with tedious distances between one adventure and another, but nicely crammed. When you play at it by day with the chairs and table-cloth, it is not in the least alarming, but in the two minutes before you go to sleep it becomes very real. That is why there are night-lights.<\/p>\n<p>Occasionally in her travels through her children&#8217;s minds Mrs. Darling found things she could not understand, and of these quite the most perplexing was the word Peter. She knew of no Peter, and yet he was here and there in John and Michael&#8217;s minds, while Wendy&#8217;s began to be scrawled all over with him. The name stood out in bolder letters than any of the other words, and as Mrs. Darling gazed she felt that it had an oddly cocky appearance.<\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old shLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_recent_posts default
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_recent_posts');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":10,"count_total":22,"pages":3,"posts":[{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur Line truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_recent_posts count argument
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_recent_posts&count=3');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":3,"count_total":22,"pages":8,"posts":[{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_recent_posts page argument
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_recent_posts&page=2');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":10,"count_total":22,"pages":3,"posts":[{"id":579,"type":"post","slug":"post-format-test-status","url":"http:\/\/wordpress.test\/2008\/06\/04\/post-format-test-status\/","status":"publish","title":"Post Format Test: Status","title_plain":"Post Format Test: Status","content":"<p>WordPress, how do I love thee? Let me count the ways (in 140 characters or less).<\/p>\n","excerpt":"WordPress, how do I love thee? Let me count the ways (in 140 characters or less).","date":"2008-06-04 08:21:24","modified":"2008-06-04 08:21:24","categories":[],"tags":[{"id":80,"slug":"post-formats","title":"Post Formats","description":"","post_count":10}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":582,"type":"post","slug":"post-format-test-video","url":"http:\/\/wordpress.test\/2008\/06\/03\/post-format-test-video\/","status":"publish","title":"Post Format Test: Video","title_plain":"Post Format Test: Video","content":"<p><embed src=\"http:\/\/v.wordpress.com\/hrPKeL5t\" type=\"application\/x-shockwave-flash\" width=\"640\" height=\"360\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"transparent\"><\/embed><\/p>\n<p>Posted as per the <a href=\"http:\/\/codex.wordpress.org\/Embeds\" target=\"_blank\">instructions in the Codex<\/a>.<\/p>\n","excerpt":"Posted as per the instructions in the Codex.","date":"2008-06-03 08:25:58","modified":"2008-06-03 08:25:58","categories":[],"tags":[{"id":80,"slug":"post-formats","title":"Post Formats","description":"","post_count":10}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":587,"type":"post","slug":"post-format-test-audio","url":"http:\/\/wordpress.test\/2008\/06\/02\/post-format-test-audio\/","status":"publish","title":"Post Format Test: Audio","title_plain":"Post Format Test: Audio","content":"<p><a href='http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/hayseedrag-thedizzytrio_vbr3.mp3'>Hayseed Rag \u2013 The Dizzy Trio<\/a><\/p>\n","excerpt":"Hayseed Rag \u2013 The Dizzy Trio","date":"2008-06-02 08:36:44","modified":"2008-06-02 08:36:44","categories":[],"tags":[{"id":80,"slug":"post-formats","title":"Post Formats","description":"","post_count":10}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[{"id":622,"url":"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/hayseedrag-thedizzytrio_vbr3.mp3","slug":"hayseedrag-thedizzytrio_vbr-2","title":"Hayseed Rag \u2013 The Dizzy Trio","description":"Victor # 19421-B The dizzy trio -novelty fox trot \u2013 Harmonica specialty by Borrah Minevitch \u2013 Harmonica,guitar,banjo, with Jew\u2019s harp and piano \u2013 issue date: May 1924. (<a href=\"http:\/\/www.archive.org\/details\/HayseedRag\">public domain<\/a>)","caption":"Hayseed Rag \u2013 The Dizzy Trio","parent":587,"mime_type":"audio\/mpeg"}],"comment_count":0,"comment_status":"closed"},{"id":494,"type":"post","slug":"if-you-say-it-loud-enough-you%e2%80%99ll-always-sound-precocious-supercalifragilisticexpialidocious","url":"http:\/\/wordpress.test\/2008\/05\/06\/if-you-say-it-loud-enough-you%e2%80%99ll-always-sound-precocious-supercalifragilisticexpialidocious\/","status":"publish","title":"If you say it loud enough, you\u2019ll always sound precocious; Supercalifragilisticexpialidocious!","title_plain":"If you say it loud enough, you\u2019ll always sound precocious; Supercalifragilisticexpialidocious!","content":"<p>A post with an exceptionally long title and single word (supercalifragilisticexpialidocious\u2014it&#8217;s the biggest word you ever heard) useful for testing title line heights and potential overflow issues on posts with small title areas. <img src='http:\/\/wordpress.test\/wp-includes\/images\/smilies\/icon_smile.gif' alt=':)' class='wp-smiley' \/> <\/p>\n","excerpt":"A post with an exceptionally long title and single word (supercalifragilisticexpialidocious\u2014it&#8217;s the biggest word you ever heard) useful for testing title line heights and potential overflow issues on posts with small title areas.","date":"2008-05-06 12:23:00","modified":"2008-05-06 12:23:00","categories":[],"tags":[],"author":{"id":4,"slug":"ian-stewart","name":"Ian Stewart","first_name":"","last_name":"","nickname":"Ian Stewart","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":134,"type":"post","slug":"this-post-has-no-body","url":"http:\/\/wordpress.test\/2008\/05\/05\/this-post-has-no-body\/","status":"publish","title":"This post has no body","title_plain":"This post has no body","content":"","excerpt":"","dateLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_search_posts default
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_search_posts&search=wordpress');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":10,"count_total":22,"pages":3,"posts":[{"id":188,"type":"post","slug":"layout-test","url":"http:\/\/wordpress.test\/2008\/09\/04\/layout-test\/","status":"publish","title":"Layout Test","title_plain":"Layout Test","content":"<p>This is a sticky post!!! Make sure it sticks!<\/p>\n<p>This should then split into other pages with layout, images, HTML tags, and other things.<\/p>\n","excerpt":"This is a sticky post!!! Make sure it sticks! This should then split into other pages with layout, images, HTML tags, and other things.","date":"2008-09-04 23:02:20","modified":"2008-09-04 23:02:20","categories":[{"id":3,"slug":"aciform","title":"aciform","description":"","parent":0,"post_count":2},{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2},{"id":10,"slug":"cat-b","title":"Cat B","description":"","parent":0,"post_count":1},{"id":11,"slug":"cat-c","title":"Cat C","description":"","parent":0,"post_count":1},{"id":41,"slug":"sub","title":"sub","description":"","parent":3,"post_count":1}],"tags":[{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":358,"type":"post","slug":"readability-test","url":"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/","status":"publish","title":"Readability Test","title_plain":"Readability Test","content":"<p>All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, &#8220;Oh, why can&#8217;t you remain like this for ever!&#8221; This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end.<\/p>\n<p> <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/#more-358\" class=\"more-link\">Read more<\/a><\/p>\n","excerpt":"All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower &hellip; <a href=\"http:\/\/wordpress.test\/2008\/09\/05\/readability-test\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a>","date":"2008-09-05 00:27:25","modified":"2008-09-05 00:27:25","categories":[{"id":9,"slug":"cat-a","title":"Cat A","description":"","parent":0,"post_count":2}],"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"closed"},{"id":128,"type":"post","slug":"images-test","url":"http:\/\/wordpress.test\/2008\/09\/03\/images-test\/","status":"publish","title":"Images Test","title_plain":"Images Test","content":"<h2>Image Alignment Tests: Un-Captioned Images<\/h2>\n<h3 id=\"center-align-no-caption\">Center-align, no caption<\/h3>\n<p>Center-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"aligncenter size-full wp-image-535\" \/> ALorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur eu tortor id turpis tristique adipiscing. Morbi blandit. Maecenas vel est. Nunc aliquam, orci at accumsan commodo, libero nibh euismod augue, a ullamcorper velit dui et purus. Aenean volutpat, ipsum ac imperdiet fermentum, dui dui suscipit arcu, vitae dictum purus diam ac ligula.<\/p>\n<h3 id=\"left-align-no-caption\">Left-align, no caption<\/h3>\n<p>Left-aligned image with no caption, and text before and after. <img src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2010\/08\/test-image-landscape1.jpg\" alt=\"\" title=\"test-image-landscape\" width=\"300\" height=\"199\" class=\"alignleft size-full wp-image-535\" \/> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed odio nibh, tincidunt adipiscing, pretium nec, tincidunt id, enim. Fusce scelerisque nunc vitae nisl. Quisque quis urna in velit dictum pellentesque. Vivamus a quam. Curabitur Line truncated
@@ -0,0 +1,14 @@
--TEST--
core.get_tag_index
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_tag_index');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":40,"tags":[{"id":53,"slug":"chattels","title":"chattels","description":"","post_count":2},{"id":54,"slug":"cienaga","title":"cienaga","description":"","post_count":1},{"id":55,"slug":"claycold","title":"claycold","description":"","post_count":1},{"id":56,"slug":"crushing","title":"crushing","description":"","post_count":1},{"id":58,"slug":"dinarchy","title":"dinarchy","description":"","post_count":1},{"id":59,"slug":"doolie","title":"doolie","description":"","post_count":1},{"id":60,"slug":"energumen","title":"energumen","description":"","post_count":1},{"id":61,"slug":"ephialtes","title":"ephialtes","description":"","post_count":1},{"id":62,"slug":"eudiometer","title":"eudiometer","description":"","post_count":1},{"id":63,"slug":"figuriste","title":"figuriste","description":"","post_count":1},{"id":66,"slug":"habergeon","title":"habergeon","description":"","post_count":1},{"id":67,"slug":"hapless","title":"hapless","description":"","post_count":1},{"id":68,"slug":"hartshorn","title":"hartshorn","description":"","post_count":1},{"id":69,"slug":"hostility-impregnability","title":"hostility impregnability","description":"","post_count":1},{"id":70,"slug":"impropriation","title":"impropriation","description":"","post_count":1},{"id":72,"slug":"knave","title":"knave","description":"","post_count":1},{"id":73,"slug":"misinformed","title":"misinformed","description":"","post_count":1},{"id":74,"slug":"moil","title":"moil","description":"","post_count":1},{"id":75,"slug":"mornful","title":"mornful","description":"","post_count":1},{"id":76,"slug":"outlaw","title":"outlaw","description":"","post_count":1},{"id":77,"slug":"pamphjlet","title":"pamphjlet","description":"","post_count":1},{"id":78,"slug":"pneumatics","title":"pneumatics","description":"","post_count":1},{"id":79,"slug":"portly-portreeve","title":"portly portreeve","description":"","post_count":1},{"id":80,"slug":"post-formats","title":"Post Formats","description":"","post_count":10},{"id":81,"slug":"precipitancy","title":"precipitancy","description":"","post_count":1},{"id":82,"slug":"privation","title":"privation","description":"","post_count":2},{"id":83,"slug":"programme","title":"programme","description":"","post_count":1},{"id":84,"slug":"psychological","title":"psychological","description":"","post_count":1},{"id":85,"slug":"puncher","title":"puncher","description":"","post_count":1},{"id":86,"slug":"ramose","title":"ramose","description":"","post_count":1},{"id":87,"slug":"renegade","title":"renegade","description":"","post_count":1},{"id":88,"slug":"retrocede","title":"retrocede","description":"","post_count":1},{"id":89,"slug":"stagnation-unhorsed","title":"stagnation unhorsed","description":"","post_count":1},{"id":93,"slug":"tag1","title":"tag1","description":"","post_count":1},{"id":94,"slug":"tag2","title":"tag2","description":"","post_count":1},{"id":95,"slug":"tag3","title":"tag3","description":"","post_count":1},{"id":98,"slug":"thunderheaded","title":"thunderheaded","description":"","post_count":1},{"id":99,"slug":"unculpable","title":"unculpable","description":"","post_count":1},{"id":100,"slug":"withered-brandnew","title":"withered brandnew","description":"","post_count":1},{"id":101,"slug":"xanthopsia","title":"xanthopsia","description":"","post_count":1}]}
@@ -0,0 +1,14 @@
--TEST--
core.get_tag_posts default
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.get_tag_posts&slug=post-formats');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":10,"pages":1,"tag":{"id":80,"slug":"post-formats","title":"Post Formats","description":"","post_count":10},"posts":[{"id":555,"type":"post","slug":"post-format-test-gallery","url":"http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/","status":"publish","title":"Post Format Test: Gallery","title_plain":"Post Format Test: Gallery","content":"\n\t\t<div id='gallery-1' class='gallery galleryid-555 gallery-columns-3 gallery-size-thumbnail'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon'>\n\t\t\t\t<a href='http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/canola2\/' title='canola2'><img width=\"150\" height=\"112\" src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/canola21.jpg\" class=\"attachment-thumbnail\" alt=\"canola\" title=\"canola2\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon'>\n\t\t\t\t<a href='http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/dsc20040724_152504_532\/' title='dsc20040724_152504_532'><img width=\"150\" height=\"112\" src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/dsc20040724_152504_5321.jpg\" class=\"attachment-thumbnail\" alt=\"chunk of resinous blackboy husk\" title=\"dsc20040724_152504_532\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption'>\n\t\t\t\tChunk of resinous blackboy husk, Clarkson, Western Australia. This burns like a spinifex log.\n\t\t\t\t<\/dd><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon'>\n\t\t\t\t<a href='http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/dsc20050315_145007_132\/' title='dsc20050315_145007_132'><img width=\"150\" height=\"112\" src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/dsc20050315_145007_1321.jpg\" class=\"attachment-thumbnail\" alt=\"dsc20050315_145007_132\" title=\"dsc20050315_145007_132\" \/><\/a>\n\t\t\t<\/dt><\/dl><br style=\"clear: both\" \/><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon'>\n\t\t\t\t<a href='http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/dsc20050604_133440_3421\/' title='dsc20050604_133440_3421'><img width=\"150\" height=\"112\" src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/dsc20050604_133440_34211.jpg\" class=\"attachment-thumbnail\" alt=\"dsc20050604_133440_3421\" title=\"dsc20050604_133440_3421\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon'>\n\t\t\t\t<a href='http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/dsc20050727_091048_222\/' title='dsc20050727_091048_222'><img width=\"150\" height=\"112\" src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/dsc20050727_091048_2221.jpg\" class=\"attachment-thumbnail\" alt=\"dsc20050727_091048_222\" title=\"dsc20050727_091048_222\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon'>\n\t\t\t\t<a href='http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/dsc20050813_115856_52\/' title='dsc20050813_115856_52'><img width=\"150\" height=\"112\" src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/dsc20050813_115856_521.jpg\" class=\"attachment-thumbnail\" alt=\"dsc20050813_115856_52\" title=\"dsc20050813_115856_52\" \/><\/a>\n\t\t\t<\/dt><\/dl><br style=\"clear: both\" \/><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon'>\n\t\t\t\t<a href='http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/dsc20050831_165238_332\/' title='dsc20050831_165238_332'><img width=\"150\" height=\"112\" src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/dsc20050831_165238_3321.jpg\" class=\"attachment-thumbnail\" alt=\"dsc20050831_165238_332\" title=\"dsc20050831_165238_332\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon'>\n\t\t\t\t<a href='http:\/\/wordpress.test\/2008\/06\/10\/post-format-test-gallery\/dsc20050901_105100_212\/' title='dsc20050901_105100_212'><img width=\"150\" height=\"112\" src=\"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/dsc20050901_105100_2121.jpg\" class=\"attachment-thumbnail\" alt=\"Seed pods on stem, Woodvale\" title=\"dsc20050901_105100_212\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption'>\n\t\t\t\tSeed pods on stem, Woodvale\n\t\t\t\t<\/dd><\/dl>\n\t\t\t<br style='clear: both;' \/>\n\t\t<\/div>\n\n","excerpt":"","date":"2008-06-10 07:24:14","modified":"2008-06-10 07:24:14","categories":[],"tags":[{"id":80,"slug":"post-formats","title":"Post Formats","description":"","post_count":10}],"author":{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},"comments":[],"attachments":[{"id":611,"url":"http:\/\/wordpress.test\/wp-content\/uploads\/2011\/01\/canola21.jpg","slug":"canola2","title":"canola2","description":"","caption":"","parent":555,"mime_type":"image\/jpeg","images":{"full":{"url":"http:\/\/wordpress.test\/wp-coLine truncated
@@ -0,0 +1,14 @@
--TEST--
core.info default
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.info');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","json_api_version":"1.0.7","controllers":["core","posts","respond"]}
@@ -0,0 +1,14 @@
--TEST--
core.info controller detail
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/?json=core.info&controller=core');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","name":"Core","description":"Basic introspection methods","methods":["info","get_recent_posts","get_post","get_page","get_date_posts","get_category_posts","get_tag_posts","get_author_posts","get_search_results","get_date_index","get_category_index","get_tag_index","get_author_index","get_page_index","get_nonce"]}
@@ -0,0 +1,14 @@
--TEST--
core.get_author_index with user-friendly URLs
--FILE--
<?php
require_once 'HTTP/Client.php';
$http = new HTTP_Client();
$http->get('http://wordpress.test/api/core/get_author_index');
$response = $http->currentResponse();
echo $response['body'];
?>
--EXPECT--
{"status":"ok","count":2,"authors":[{"id":3,"slug":"chip-bennett","name":"Chip Bennett","first_name":"","last_name":"","nickname":"Chip Bennett","url":"","description":""},{"id":4,"slug":"ian-stewart","name":"Ian Stewart","first_name":"","last_name":"","nickname":"Ian Stewart","url":"","description":""}]}
+35
View File
@@ -0,0 +1,35 @@
<?php get_header(); ?>
<div id="content" class="container_12">
<article <?php neuf_post_class(); ?>>
<div class="grid_6">
<h1 class="entry-title">404: Denne siden er på grisefest</h1>
<div class="entry-content">
<p>Lykke til videre.</p>
</div> <!-- .entry-content -->
</div> <!-- .grid_6 -->
<div class="grid_6">
<div class="vedlegg">
<div class="nyhetsbilde">
<img src="<?php bloginfo('stylesheet_directory'); ?>/img/piggies.jpg" alt="" />
</div> <!-- .nyhetsbilde -->
</div> <!-- .vedlegg -->
</div> <!-- .grid_6 -->
</article> <!-- .post -->
<?php //get_sidebar(); ?>
</div> <!-- #content -->
<?php get_footer(); ?>
@@ -0,0 +1,25 @@
# Require any additional compass plugins here.
require 'ninesixty'
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
@@ -0,0 +1,143 @@
--Do not remove this if you are using--
Original Author: Remiz Rahnas
Original Author URL: http://www.htmlremix.com
Published date: 2008/09/24
Changes by Nick Fetchak:
- IE8 standards mode compatibility
- VML elements now positioned behind original box rather than inside of it - should be less prone to breakage
Published date : 2009/11/18
<public:attach event="oncontentready" onevent="oncontentready('v08vnSVo78t4JfjH')" />
<script type="text/javascript">
// findPos() borrowed from http://www.quirksmode.org/js/findpos.html
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
}
return({
'x': curleft,
'y': curtop
});
}
function oncontentready(classID) {
if (this.className.match(classID)) { return(false); }
if (!document.namespaces.v) { document.namespaces.add("v", "urn:schemas-microsoft-com:vml"); }
this.className = this.className.concat(' ', classID);
var arcSize = Math.min(parseInt(this.currentStyle['-moz-border-radius'] ||
this.currentStyle['-webkit-border-radius'] ||
this.currentStyle['border-radius'] ||
this.currentStyle['-khtml-border-radius']) /
Math.min(this.offsetWidth, this.offsetHeight), 1);
var fillColor = this.currentStyle.backgroundColor;
var fillSrc = this.currentStyle.backgroundImage.replace(/^url\("(.+)"\)$/, '$1');
var strokeColor = this.currentStyle.borderColor;
var strokeWeight = parseInt(this.currentStyle.borderWidth);
var stroked = 'true';
if (isNaN(strokeWeight)) {
strokeWeight = 0;
strokeColor = fillColor;
stroked = 'false';
}
this.style.background = 'transparent';
this.style.borderColor = 'transparent';
// Find which element provides position:relative for the target element (default to BODY)
var el = this;
var limit = 100, i = 0;
while ((typeof(el) != 'unknown') && (el.currentStyle.position != 'relative') && (el.tagName != 'BODY')) {
el = el.parentElement;
i++;
if (i >= limit) { return(false); }
}
var el_zindex = parseInt(el.currentStyle.zIndex);
if (isNaN(el_zindex)) { el_zindex = 0; }
//alert('got tag '+ el.tagName +' with pos '+ el.currentStyle.position);
var rect_size = {
'width': this.offsetWidth - strokeWeight,
'height': this.offsetHeight - strokeWeight
};
var el_pos = findPos(el);
var this_pos = findPos(this);
this_pos.y = this_pos.y + (0.5 * strokeWeight) - el_pos.y;
this_pos.x = this_pos.x + (0.5 * strokeWeight) - el_pos.x;
var rect = document.createElement('v:roundrect');
rect.arcsize = arcSize +'px';
rect.strokecolor = strokeColor;
rect.strokeWeight = strokeWeight +'px';
rect.stroked = stroked;
rect.style.display = 'block';
rect.style.position = 'absolute';
rect.style.top = this_pos.y +'px';
rect.style.left = this_pos.x +'px';
rect.style.width = rect_size.width +'px';
rect.style.height = rect_size.height +'px';
rect.style.antialias = true;
rect.style.zIndex = el_zindex - 1;
var fill = document.createElement('v:fill');
fill.color = fillColor;
fill.src = fillSrc;
fill.type = 'tile';
rect.appendChild(fill);
el.appendChild(rect);
var css = el.document.createStyleSheet();
css.addRule("v\\:roundrect", "behavior: url(#default#VML)");
css.addRule("v\\:fill", "behavior: url(#default#VML)");
isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
// IE6 doesn't support transparent borders, use padding to offset original element
if (isIE6 && (strokeWeight > 0)) {
this.style.borderStyle = 'none';
this.style.paddingTop = parseInt(this.currentStyle.paddingTop || 0) + strokeWeight;
this.style.paddingBottom = parseInt(this.currentStyle.paddingBottom || 0) + strokeWeight;
}
if (typeof(window.rounded_elements) == 'undefined') {
window.rounded_elements = new Array();
if (typeof(window.onresize) == 'function') { window.previous_onresize = window.onresize; }
window.onresize = window_resize;
}
this.element.vml = rect;
window.rounded_elements.push(this.element);
}
function window_resize() {
if (typeof(window.rounded_elements) == 'undefined') { return(false); }
for (var i in window.rounded_elements) {
var el = window.rounded_elements[i];
var strokeWeight = parseInt(el.currentStyle.borderWidth);
if (isNaN(strokeWeight)) { strokeWeight = 0; }
var parent_pos = findPos(el.vml.parentNode);
var pos = findPos(el);
pos.y = pos.y + (0.5 * strokeWeight) - parent_pos.y;
pos.x = pos.x + (0.5 * strokeWeight) - parent_pos.x;
el.vml.style.top = pos.y +'px';
el.vml.style.left = pos.x +'px';
}
if (typeof(window.previous_onresize) == 'function') { window.previous_onresize(); }
}
</script>
+388
View File
@@ -0,0 +1,388 @@
/*
Variable Grid System.
Learn more ~ http://www.spry-soft.com/grids/
Based on 960 Grid System - http://960.gs/
Licensed under GPL and MIT.
Looking for a preview of the grid? Check out http://grids.heroku.com/grid?column_width=70&column_amount=12&gutter_width=30
*/
/*
Forces backgrounds to span full width,
even if there is horizontal scrolling.
Increase this if your layout is wider.
Note: IE6 works fine without this fix.
*/
body {
min-width: 1200px;
}
/* Containers
----------------------------------------------------------------------------------------------------*/
.container_12 {
margin-left: auto;
margin-right: auto;
width: 1200px;
}
/* Grid >> Global
----------------------------------------------------------------------------------------------------*/
.column,
.sidebar .event,
.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6,
.grid_7,
.grid_8,
.grid_9,
.grid_10,
.grid_11,
.grid_12 {
display:inline;
float: left;
position: relative;
margin-left: 15px;
margin-right: 15px;
}
.push_1, .pull_1,
.push_2, .pull_2,
.push_3, .pull_3,
.push_4, .pull_4,
.push_5, .pull_5,
.push_6, .pull_6,
.push_7, .pull_7,
.push_8, .pull_8,
.push_9, .pull_9,
.push_10, .pull_10,
.push_11, .pull_11,
.push_12, .pull_12 {
position:relative;
}
/* Grid >> Children (Alpha ~ First, Omega ~ Last)
----------------------------------------------------------------------------------------------------*/
.alpha {
margin-left: 0;
}
.omega {
margin-right: 0;
}
/* Grid >> 12 Columns
----------------------------------------------------------------------------------------------------*/
.container_12 .grid_1 {
width:70px;
}
.container_12 .grid_2 {
width:170px;
}
.sidebar .event,
.container_12 .grid_3 {
width:270px;
}
.container_12 .grid_4 {
width:370px;
}
.container_12 .grid_5 {
width:470px;
}
.column,
.container_12 .grid_6 {
width:570px;
}
.container_12 .grid_7 {
width:670px;
}
.container_12 .grid_8 {
width:770px;
}
.container_12 .grid_9 {
width:870px;
}
.container_12 .grid_10 {
width:970px;
}
.container_12 .grid_11 {
width:1070px;
}
.container_12 .grid_12 {
width:1170px;
}
/* Prefix Extra Space >> 12 Columns
----------------------------------------------------------------------------------------------------*/
.container_12 .prefix_1 {
padding-left:100px;
}
.container_12 .prefix_2 {
padding-left:200px;
}
.container_12 .prefix_3 {
padding-left:300px;
}
.container_12 .prefix_4 {
padding-left:400px;
}
.container_12 .prefix_5 {
padding-left:500px;
}
.container_12 .prefix_6 {
padding-left:600px;
}
.container_12 .prefix_7 {
padding-left:700px;
}
.container_12 .prefix_8 {
padding-left:800px;
}
.container_12 .prefix_9 {
padding-left:900px;
}
.container_12 .prefix_10 {
padding-left:1000px;
}
.container_12 .prefix_11 {
padding-left:1100px;
}
/* Suffix Extra Space >> 12 Columns
----------------------------------------------------------------------------------------------------*/
.container_12 .suffix_1 {
padding-right:100px;
}
.container_12 .suffix_2 {
padding-right:200px;
}
.container_12 .suffix_3 {
padding-right:300px;
}
.container_12 .suffix_4 {
padding-right:400px;
}
.container_12 .suffix_5 {
padding-right:500px;
}
.container_12 .suffix_6 {
padding-right:600px;
}
.container_12 .suffix_7 {
padding-right:700px;
}
.container_12 .suffix_8 {
padding-right:800px;
}
.container_12 .suffix_9 {
padding-right:900px;
}
.container_12 .suffix_10 {
padding-right:1000px;
}
.container_12 .suffix_11 {
padding-right:1100px;
}
/* Push Space >> 12 Columns
----------------------------------------------------------------------------------------------------*/
.container_12 .push_1 {
left:100px;
}
.container_12 .push_2 {
left:200px;
}
.container_12 .push_3 {
left:300px;
}
.container_12 .push_4 {
left:400px;
}
.container_12 .push_5 {
left:500px;
}
.container_12 .push_6 {
left:600px;
}
.container_12 .push_7 {
left:700px;
}
.container_12 .push_8 {
left:800px;
}
.container_12 .push_9 {
left:900px;
}
.container_12 .push_10 {
left:1000px;
}
.container_12 .push_11 {
left:1100px;
}
/* Pull Space >> 12 Columns
----------------------------------------------------------------------------------------------------*/
.container_12 .pull_1 {
left:-100px;
}
.container_12 .pull_2 {
left:-200px;
}
.container_12 .pull_3 {
left:-300px;
}
.container_12 .pull_4 {
left:-400px;
}
.container_12 .pull_5 {
left:-500px;
}
.container_12 .pull_6 {
left:-600px;
}
.container_12 .pull_7 {
left:-700px;
}
.container_12 .pull_8 {
left:-800px;
}
.container_12 .pull_9 {
left:-900px;
}
.container_12 .pull_10 {
left:-1000px;
}
.container_12 .pull_11 {
left:-1100px;
}
/* `Clear Floated Elements
----------------------------------------------------------------------------------------------------*/
/* http://sonspring.com/journal/clearing-floats */
.clear {
clear: both;
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}
/* http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified */
.hentry:before,
.hentry:after,
#program-3days:before,
#program-3days:after,
#program-6days:before,
#program-6days:after,
.clearfix:before,
.clearfix:after {
content: '\0020';
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}
.hentry:after,
#program-3days:after,
#program-6days:after,
.clearfix:after {
clear: both;
}
/*
The following zoom:1 rule is specifically for IE6 + IE7.
Move to separate stylesheet if invalid CSS is a problem.
*/
.clearfix {
zoom: 1;
}
@@ -0,0 +1,13 @@
/* Border radius hack:
TODO: does not work
*/
.single-event .event-type:before,
#featured article .event-type:before,
#featured article.type-post h1:before,
#featured #slidernav a span.circle,
.home #digest_news .post a.permalink:before,
.big_bullet,
.btn {
behavior: url(css/border-radius.htc);
}
+111
View File
@@ -0,0 +1,111 @@
#lightbox{ position: absolute; left: 0; width: 100%; z-index: 100; text-align: center; line-height: 0;}
#lightbox img{ width: auto; height: auto;}
#lightbox a img{ border: none; }
#outerImageContainer{ position: relative; background-color: #000; width: 250px; height: 250px; margin: 0 auto; }
#imageContainer{ padding: 10px; }
#loading{ position: absolute; top: 40%; left: 0%; height: 25%; width: 100%; text-align: center; line-height: 0; }
#hoverNav{ position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 10; }
#imageContainer>#hoverNav{ left: 0;}
#hoverNav a{ outline: none;}
#prevLink, #nextLink{ width: 49%; height: 100%; background-image: url(data:image/gif;base64,AAAA); /* Trick IE into showing hover */ display: block; }
#prevLink { left: 0; float: left;}
#nextLink { right: 0; float: right;}
#prevLink:hover, #prevLink:visited:hover { background: url(../images/prevlabel.gif) left 15% no-repeat; }
#nextLink:hover, #nextLink:visited:hover { background: url(../images/nextlabel.gif) right 15% no-repeat; }
#imageDataContainer{ font: 10px Verdana, Helvetica, sans-serif; background-color: #000; margin: 0 auto; line-height: 1.4em; overflow: auto; width: 100% ; }
#imageData{ padding:0 10px; color: #666; }
#imageData #imageDetails{ width: 70%; float: left; text-align: left; }
#imageData #caption{ font-weight: bold; }
#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; }
#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; outline: none;}
#overlay{ position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 500px; background-color: #000; }
/* Dark Theme starts here */
/*
#stimuli_lightbox {
position: absolute;
left: 0;
width: 100%;
z-index: 100;
text-align: center;
line-height: 0;
}
#stimuli_lightbox a img { border: none; }
#stimuli_outerImageContainer {
position: relative;
background-color: #000;
width: 250px;
height: 250px;
margin: 0 auto;
}
#stimuli_imageContainer {
padding: 10px;
}
#stimuli_loading {
position: absolute;
top: 40%;
left: 0%;
height: 25%;
width: 100%;
text-align: center;
line-height: 0;
background: transparent center url(img/loading.gif) no-repeat;
}
#stimuli_hoverNav {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
}
#stimuli_imageContainer>#stimuli_hoverNav { left: 0;}
#stimuli_hoverNav a { outline: none;}
#stimuli_prevLink, #stimuli_nextLink {
width: 49%;
height: 100%;
background: transparent url(img/blank.gif) no-repeat; /* Trick IE into showing hover * /
display: block;
}
#stimuli_prevLink { left: 0; float: left;}
#stimuli_nextLink { right: 0; float: right;}
#stimuli_prevLink:hover, #stimuli_prevLink:visited:hover { background: url(img/prev.gif) left 55% no-repeat; }
#stimuli_nextLink:hover, #stimuli_nextLink:visited:hover { background: url(img/next.gif) right 55% no-repeat; }
#stimuli_imageDataContainer {
font: 10px Verdana, Helvetica, sans-serif;
background-color: #000;
margin: 0 auto;
line-height: 1.4em;
overflow: auto;
width: 100%
}
#stimuli_imageData { padding:0 10px; color: #666; }
#stimuli_imageData #stimuli_imageDetails { width: 70%; float: left; text-align: left; }
#stimuli_imageData #stimuli_caption { font-weight: bold;}
#stimuli_imageData #stimuli_numberDisplay { display: block; clear: left; padding-bottom: 1.0em;}
#stimuli_imageData #stimuli_bottomNavClose { width: 66px; float: right; padding-bottom: 0.7em; background: url(img/closelabel.gif) right 55% no-repeat; padding-top: 1.0em; margin-bottom: 1.0em;}
#stimuli_overlay {
position: absolute;
top: 0;
left: 0;
z-index: 90;
width: 100%;
height: 500px;
background-color: #000;
}
*/
+137
View File
@@ -0,0 +1,137 @@
/* --------------------------------------------------------------
Rebuild the default browser styles
Based on work by Blueprint CSS
http://code.google.com/p/blueprintcss/
-------------------------------------------------------------- */
body {
background: #fff;
}
body, input, textarea {
color: #111;
font: 12px Arial,sans-serif;
line-height: 1.5;
}
/* Headings
-------------------------------------------------------------- */
h1,h2,h3,h4,h5,h6 {
font-weight: normal;
clear: both;
}
hr {
background-color: #999;
border:0;
height: 1px;
margin-bottom: 1.5em;
}
/* Text elements
-------------------------------------------------------------- */
p {
margin-bottom: 1.5em;
}
ul {
margin: 0 0 1.5em 2.5em;
}
ol {
margin: 0 0 1.5em 2.5em;
}
ul {
list-style:disc;
}
ol {
list-style-type: decimal;
}
ol ol {
list-style:upper-alpha;
}
ol ol ol {
list-style:lower-roman;
}
ol ol ol ol {
list-style:lower-alpha;
}
ul ul, ol ol, ul ol, ol ul {
margin-bottom:0;
}
dl {
margin:0 1.5em;
}
dt {
font-weight: bold;
}
dd {
margin-bottom: 1.5em;
}
strong {
font-weight: bold;
}
cite, em, i {
font-style: italic;
}
blockquote {
margin: 0 3em;
}
blockquote em, blockquote i, blockquote cite {
font-style: normal;
}
pre {
font: 11px Monaco, monospace;
line-height: 1.5;
margin-bottom: 1.5em;
}
code {
font: 11px Monaco, monospace;
}
abbr, acronym {
border-bottom: 1px dotted #666;
cursor: help;
}
ins {
text-decoration: none;
}
sup,
sub {
height: 0;
line-height: 1;
vertical-align: baseline;
position: relative;
}
sup {
bottom: 1ex;
}
sub {
top: .5ex;
}
/*
Adapt the following for use in your Child Themes when using
different font-sizes and line-heights
body, input, textarea {
font: --px Arial,sans-serif;
line-height:--;
}
p, ul, ol, dd, pre {
margin-bottom:--em;
}
pre, code {
font:--px Monaco, monospace;
line-height:--;
}
All other styles can be overridden--or ignored!--in Child Theme stylesheets
*/
+63
View File
@@ -0,0 +1,63 @@
/* --------------------------------------------------------------
Reset default browser CSS.
Based on work by Eric Meyer:
http://meyerweb.com/eric/tools/css/reset/index.html
-------------------------------------------------------------- */
/* v1.0 | 20080212 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
/* remember to define focus styles! */
:focus {
outline: 0;
}
/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
a img { border: none; }
+74
View File
@@ -0,0 +1,74 @@
/* --------------------------------------------------------------
Basic WordPress Blog Styles
-------------------------------------------------------------- */
/* Images
-------------------------------------------------------------- */
.entry-content img {
margin: 0 0 1.5em 0;
}
.alignleft,
img.alignleft {
display: inline;
float: left;
margin-right: 1.5em;
}
.alignright,
img.alignright {
display: inline;
float: right;
margin-left: 1.5em;
}
.aligncenter,
img.aligncenter {
clear: both;
display: block;
margin-left: auto !important;
margin-right: auto !important;
}
.wp-caption {
text-align: center;
margin-bottom: 1.5em;
}
.wp-caption img {
border: 0 none;
margin: 0;
padding: 0;
}
.wp-caption p.wp-caption-text {
margin: 0;
}
.wp-smiley {
max-height: 1em;
margin:0 !important;
}
.gallery dl {
margin: 0;
}
.gallery-caption {
margin:0;
font-size:0.8em;
}
/* Pullquotes
-------------------------------------------------------------- */
blockquote.left {
float: left;
margin-left: 0;
margin-right: 20px;
text-align: right;
width: 33%;
}
blockquote.right {
float: right;
margin-left: 20px;
margin-right: 0;
text-align: left;
width: 33%;
}
+62
View File
@@ -0,0 +1,62 @@
<div id="digest_news" class="grid_8 hfeed">
<h2 id="digest_news_headline">Aktuelt</h2>
<div class="grid_4 alpha">
<?php // The LOOP
$digest_news = new WP_Query( 'posts_per_page=6' );
$digest_news_counter = 1;
if ( $digest_news->have_posts() ) : while ( $digest_news->have_posts() ) : $digest_news->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php neuf_post_class(); ?>>
<a class="permalink" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<div class="when"><?php the_date()?> <?php the_time(); ?></div>
<div class="entry-summary"><?php echo linkify(trim_excerpt(get_the_excerpt(), 28), '/\[\.\.\.\]/', get_permalink()); ?></div>
</article>
<?php
if($digest_news_counter == 3) {
?>
</div>
<div class="grid_4 omega">
<?php
}
$digest_news_counter++;
endwhile;
?>
<?php endif; ?>
</div>
</div> <!-- #articles -->
<div id="digest_events" class="grid_4">
<h2 id="digest_events_headline"><a href="<?php bloginfo('url'); ?>/program/">Program</a></h2>
<table class="table">
<?php
$meta_query = array(
'key' => '_neuf_events_starttime',
'value' => date( 'U' , strtotime( '-8 hours' ) ),
'compare' => '>',
'type' => 'numeric'
);
$args = array(
'post_type' => 'event',
'meta_query' => array( $meta_query ),
'posts_per_page' => 10,
'orderby' => 'meta_value_num',
'meta_key' => '_neuf_events_starttime',
'order' => 'ASC'
);
$digest_events = new WP_Query( $args );
if ( $digest_events->have_posts() ) : while ( $digest_events->have_posts() ) : $digest_events->the_post();
?>
<tr>
<td id="post-<?php the_ID(); ?>" <?php neuf_post_class(); ?>>
<?php $date = get_post_meta(get_the_ID(), '_neuf_events_starttime'); echo neuf_event_format_date($date[0]); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></td>
</tr>
<?php endwhile; endif; ?>
</table>
</div> <!-- #events -->
+28
View File
@@ -0,0 +1,28 @@
<header class="entry-meta">
<?php
$post->neuf_event_venue = get_post_meta(get_the_ID(), '_neuf_events_venue',true);
$ticket = get_post_meta(get_the_id(), '_neuf_events_bs_url',true);
if ( 'Annet' != $post->neuf_event_venue ) {
?>
<?php } ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-meta-info">
<div>
<span class="event-date"><?php echo ucfirst( date_i18n( 'l j. F' , get_post_meta(get_the_ID() , '_neuf_events_starttime' , true ) ) ); ?></span>
</div>
<div>
<span class="meta-prep meta-prep-event-time"><?php _e( 'Kl:' , 'neuf' ); ?></span>
<span class="event-time"><?php echo date_i18n( 'G.i' , get_post_meta( get_the_ID() , '_neuf_events_starttime' , true ) ); ?></span>
<span class="meta-sep meta-sep-event-price"> - </span>
<span class="meta-prep meta-prep-price">CC: </span>
<span class="price"><?php echo ($price = neuf_get_price( $post )) ? $price : "Gratis"; ?></span>
<span class="meta-prep meta-prep-price"><?php echo $ticket ? ' <a href="'.$ticket.'">Kjøp billett</a>' : ""; ?></span>
</div>
<div>
<span class="venue"><?php echo $post->neuf_event_venue; ?></span>
</div>
</div>
</header> <!-- .entry-meta-->
+20
View File
@@ -0,0 +1,20 @@
<div class="entry-meta">
<?php
$post->neuf_event_venue = get_post_meta(get_the_id(), '_neuf_events_venue',true);
$ticket = get_post_meta(get_the_id(), '_neuf_events_bs_url',true);
if ( 'Annet' != $post->neuf_event_venue ) {
?>
<span class="venue"><?php echo $post->neuf_event_venue; ?></span>
<?php } ?>
<div class="time-price">
<span class="event-date"><?php echo ucfirst( date_i18n( 'l j. F' , get_post_meta(get_the_ID() , '_neuf_events_starttime' , true ) ) ); ?></span>
<span class="meta-prep meta-prep-event-time"><br /><?php _e( 'Kl:' , 'neuf' ); ?></span>
<span class="event-time"><?php echo date_i18n( 'G.i' , get_post_meta( get_the_ID() , '_neuf_events_starttime' , true ) ); ?></span>
<span class="meta-sep meta-sep-event-price"> - </span>
<span class="meta-prep meta-prep-price">CC: </span>
<span class="meta-prep meta-prep-ticket"><?php echo $ticket ? ' <a href="'.$ticket.'">Kjøp billett</a>' : ""; ?></span>
<span class="price"><?php echo ($price = neuf_get_price( $post )) ? $price : "Gratis"; ?></span>
</div> <!-- .time-price -->
</div> <!-- .entry-meta-->
+86
View File
@@ -0,0 +1,86 @@
<?php
/**
* Fetch events from today and onwards.
*
* Ref: http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
*/
$meta_query = array(
'relation' => 'AND',
array(
'key' => '_neuf_events_starttime',
'value' => date( 'U' , strtotime( '-8 hours' ) ),
'compare' => '>',
'type' => 'numeric'
),
array(
'key' => '_neuf_events_promo_period',
'value' => array( 'Month' , 'semester' ),
'compare' => 'IN',
)
);
$args = array(
'post_type' => 'event',
'meta_query' => $meta_query,
'posts_per_page' => 4
);
$events = new WP_Query( $args );
$news = new WP_Query( 'type=post' );
?>
<?php if ($events->have_posts()) : ?>
<section id="featured" class="clearfix">
<a href="#" id="prevLink">Forrige</a>
<a href="#" id="nextLink">Neste</a>
<div id="slidernav"></div>
<div id="slider">
<?php
if ($news->have_posts()) : $news->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php neuf_post_class(); ?>>
<a class="permalink blocklink" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
<header class="grid_6">
<h1><?php the_title(); ?></h1>
<?php the_excerpt(); ?>
</header>
<div class="grid_6">
<?php the_post_thumbnail( 'six-column-promo' ); ?>
</div>
</a>
</article> <!-- #post-<?php the_ID(); ?> -->
<?php endif; // $news->have_posts() ?>
<?php $counter = 0;
while ($events->have_posts() && $counter < 4) : $events->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php neuf_post_class(); ?>>
<a class="permalink blocklink" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
<header class="grid_6">
<?php
$event_array = get_the_terms( $post->ID , 'event_type' );
foreach ( $event_array as $event_type )
$post->event_types[] = $event_type->name;
$html = '<div class="type">' . implode( ', ' , $post->event_types ) . '</div>';
echo $html;
?>
<h1><?php the_title(); ?></h1>
<div class="datetime"><?php echo ucfirst( date_i18n( 'l j. F' , get_post_meta(get_the_ID() , '_neuf_events_starttime' , true ) ) ); ?></div>
<div class="price"><?php echo ($price = neuf_get_price( $post )) ? $price : "Gratis"; ?></div>
<div class="venue"><?php echo get_post_meta(get_the_ID(), '_neuf_events_venue',true);?></div>
<?php the_excerpt(); ?>
</header>
<div class="grid_6">
<?php the_post_thumbnail( 'six-column-promo' ); ?>
</div>
</a>
</article> <!-- #post-<?php the_ID(); ?> -->
<?php
$counter++;
endwhile; // $events->have_posts()
?>
</div>
</section>
<?php endif; // $events->have_posts()
@@ -0,0 +1,24 @@
/*
* flowplayer.js 3.2.6. The Flowplayer API
*
* Copyright 2009-2011 Flowplayer Oy
*
* This file is part of Flowplayer.
*
* Flowplayer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Flowplayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Flowplayer. If not, see <http://www.gnu.org/licenses/>.
*
* Date: 2011-02-04 05:45:28 -0500 (Fri, 04 Feb 2011)
* Revision: 614
*/
(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,G,t){var w=this,v=null,D=false,u,s,F=[],y={},x={},E,r,p,C,o,A;i(w,{id:function(){return E},isLoaded:function(){return(v!==null&&v.fp_play!==undefined&&!D)},getParent:function(){return q},hide:function(H){if(H){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=A+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(J){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var H=function(){u=q.innerHTML;if(u&&!flashembed.isSupported(G.version)){q.innerHTML=""}if(J){J.cached=true;j(x,"onLoad",J)}flashembed(q,G,{config:t})};var I=0;m(a,function(){this.unload(function(K){if(++I==a.length){H()}})})}return w},unload:function(J){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(J){J(false)}return w}if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(J){J(false)}return w}D=true;try{if(v){v.fp_close();w._fireEvent("onUnload")}}catch(H){}var I=function(){v=null;q.innerHTML=u;D=false;if(J){J(true)}};setTimeout(I,50)}else{if(J){J(false)}}return w},getClip:function(H){if(H===undefined){H=C}rLine truncated
+70
View File
@@ -0,0 +1,70 @@
<footer id="site-footer">
<div class="container_12">
<div class="grid_12">
<div id="footer-about" class="grid_4 alpha">
<h2>Det Norske Studentersamfund</h2>
<p>
Studentene i Oslo har sitt naturlige tilholdssted p&aring; Det Norske Studentersamfund, i hyggelige lokaler p&aring; Chateau Neuf &oslash;verst p&aring; Majorstuen. Her er det &aring;pent alle dager unntatt s&oslash;ndag, og enten man &oslash;nsker en tur i baren, p&aring; kaf&eacute;, p&aring; debatt, p&aring; konsert, teater eller kino, har man muligheten p&aring; Det Norske Studentersamfund.
</p>
<span class="links"><a href="<?php bloginfo('url'); ?>/kart/">Kart</a> | <a href="<?php bloginfo('url'); ?>/kontakt/">Kontakt</a></span>
</div> <!-- #footer-about -->
<div id="fb-like-box" class="grid_4">
<div class="fb-like-box" data-href="https://www.facebook.com/studentersamfundet" data-width="315" data-height="285" data-show-faces="true" data-stream="false" data-header="false" data-border-color="#e89735"></div>
</div>
<div id="flickr-box" class="grid_4 omega">
<h2><a href='http://www.flickr.com/groups/neuf/pool/'>Bilder fra flickr</a></h2>
<div id="flickr-images">
<ul id="flickr_feed"></ul>
</div>
</div>
</div>
<div class="grid_12">
<div id="sponsors">
<div id="sponsor-uio" class="sponsor">
<a href="http://www.uio.no/" rel="nofollow"><img alt="Universitetet i Oslo eier Chateau Neuf" src="<?php bloginfo('stylesheet_directory'); ?>/img/sponsors/logo_black_uio.png" /></a>
</div>
<div id="sposor-nrf" class="sponsor">
<a href="http://www.norskrockforbund.no/" rel="nofollow"><img alt="Norsk Rockforbund sponser Studentersamfundet" src="<?php bloginfo('stylesheet_directory'); ?>/img/sponsors/logo_black_nrf.png" /></a>
</div>
<div id="sponsor-akademika" class="sponsor">
<a href="http://www.akademika.no/" rel="nofollow"><img alt="Akademika sponser Studentersamfundet" src="<?php bloginfo('stylesheet_directory'); ?>/img/sponsors/logo_black_akademika.png" /></a>
</div>
</div>
</div>
<div id="kolofon" class="grid_12">
<span>Det Norske Studentersamfund | Slemdalsveien 15, 0369 Oslo | Webdesign av <a href="http://edb.neuf.no">EDB-gjengen</a> og Designerne i <a href="http://studentersamfundet.no/association/kommunikasjonsavdelingen/">KAK</a>.</span>
</div> <!-- #kolofon -->
<!-- Google Analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-52914-1']);
_gaq.push(['_setDomainName', 'studentersamfundet.no']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- end Google Analytics -->
</div>
</footer> <!-- #site-footer -->
<?php wp_footer(); ?>
</body>
</html>
+24
View File
@@ -0,0 +1,24 @@
<?php
get_header();
?>
<div id="content">
<div class="container_12">
<?php get_template_part( 'eventslider' ); ?>
<?php //get_template_part( 'program' , '3days' ); ?>
<?php //get_template_part( 'program' , '6days' ); ?>
<?php get_template_part( 'program' , '6days' ); ?>
<?php get_template_part ( 'digest' ); ?>
<?php get_template_part( 'studentmedia' ); ?>
</div> <!-- .container_12 -->
</div> <!-- #content -->
<?php get_footer(); ?>
@@ -0,0 +1,449 @@
<?php
add_theme_support( 'menus' );
add_theme_support( 'post-thumbnails');
add_theme_support( 'automatic-feed-links' );
$content_width = 770;
add_image_size( 'two-column-thumb' , 170 , 69 , true );
add_image_size( 'four-column-thumb' , 370 , 150 , true );
add_image_size( 'four-column-promo' , 370 , 322 , true );
add_image_size( 'six-column-promo' , 570 , 322 , true );
add_image_size( 'six-column-slim' , 570 , 161 , true );
add_image_size( 'association-thumb' , 270 , 250, false );
add_image_size( 'extra-large' , 1600 , 1600 , false);
add_image_size( 'newsletter-wide' , 620, 80, false);
/**
* Register navigation menus.
*/
function neuf_register_nav_menus() {
register_nav_menus(
array( 'main-menu' => __( 'Hovedmeny' ) )
);
}
add_action( 'init' , 'neuf_register_nav_menus' );
/**
* Enqueue various scripts we use.
*/
function neuf_enqueue_scripts() {
wp_deregister_script( 'jquery' );
// register your script location, dependencies and version
wp_register_script( 'jquery' , 'http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js' );
wp_register_script( 'program' , get_template_directory_uri() . '/js/program.js', array( 'jquery' ) );
wp_register_script( 'cycle' , get_template_directory_uri() . '/js/jquery.cycle.all.js', array( 'jquery' ), '0.9.8' );
wp_register_script( 'front-page', get_template_directory_uri() . '/js/front-page.js', array('cycle','moment-lang') );
wp_register_script( 'application', get_template_directory_uri() . '/js/application.js', array('jquery') );
wp_register_script( 'underscore', get_template_directory_uri() . '/js/underscore.js');
wp_register_script( 'knockout', get_template_directory_uri() . '/js/knockout-2.0.0.js');
wp_register_script( 'util', get_template_directory_uri() . '/js/neuf/util/util.js' );
wp_register_script( 'date.js', get_template_directory_uri() . '/js/neuf/util/date-nb-NO.js');
wp_register_script( 'moment', get_template_directory_uri() . '/js/moment.min.js');
wp_register_script( 'moment-lang', get_template_directory_uri() . '/js/lang/nb.js', array('moment'));
wp_register_script( 'eventProgram', get_template_directory_uri() . '/js/neuf/eventProgram.js', array('jquery', 'underscore', 'knockout', 'date.js', 'util') );
wp_register_script( 'footer', get_template_directory_uri() . '/js/footer.js', array('jquery') );
// enqueue the scripts
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'cycle' );
wp_enqueue_script( 'application' );
if ( is_front_page() )
wp_enqueue_script( 'front-page' );
}
add_action( 'wp_enqueue_scripts' , 'neuf_enqueue_scripts' );
/**
* Force large uploaded images.
*
* Denies uploads of images smaller (in pixels) than given width and height values.
*/
function neuf_handle_upload_prefilter( $file ) {
$minimum = array( 'width' => 640, 'height' => 480);
$img = getimagesize( $file['tmp_name'] );
$width = $img[0];
$height = $img[1];
if ( $width < $minimum['width'] )
return array( "error" => "Image dimensions are too small. Minimum width is {$minimum['width']}px. Uploaded image width is $width px" );
elseif ($height < $minimum['height'])
return array( "error" => "Image dimensions are too small. Minimum height is {$minimum['height']}px. Uploaded image height is $height px" );
else
return $file;
}
// Commenting out for testing purposes
add_filter( 'wp_handle_upload_prefilter' , 'neuf_handle_upload_prefilter' );
/**
* Adds more semantic classes to WP's post_class.
*
* Adds these classes:
* i) a class with a page-wide post count. The first post on this page is named .p1, the second p2 and so forth.
* ii) a class 'alt' to every other post.
*/
function neuf_post_class( $classes = '' ) {
global $neuf_pagewide_post_count;
if ( $classes )
$classes = array ( $classes );
$classes[] = 'p' . ++$neuf_pagewide_post_count;
if ( 0 == $neuf_pagewide_post_count % 2 )
$classes[] = 'alt';
$classes = join( ' ' , $classes );
post_class( $classes );
}
/* Gets nicely the regular and member price nicely formated */
function neuf_get_price( $neuf_event ) {
$price_regular = get_post_meta( $neuf_event->ID , '_neuf_events_price_regular' , true );
$price_member = get_post_meta( $neuf_event->ID , '_neuf_events_price_member' , true );
if ( $price_regular ) {
if ( $price_member )
$cc = "$price_regular/$price_member";
else
$cc = $price_regular;
} else
$cc = '';
return $cc;
}
/**
* Adds more semantic classes to WP's body_class.
*
* Adds these classes:
* i) For pages, adds 'page-slug'
*/
function neuf_body_class( $classes = '' ) {
global $post;
if ( $classes )
$classes .= ' ';
if ( is_page() )
$classes .= 'page-' . $post->post_name ;
body_class( $classes );
}
/**
* Determines what to display in our title element.
*
* Most of this borrowed from the Thematic theme framework.
*/
function neuf_doctitle() {
$site_name = get_bloginfo( 'name' );
$separator = '|';
if ( is_single() ) {
$content = single_post_title( '' , false );
} elseif ( is_home() || is_front_page() ) {
$content = get_bloginfo( 'description' );
} elseif ( is_page() ) {
$content = single_post_title( '' , false );
} elseif ( is_search() ) {
$content = __( 'S&oslashkeresultater for', 'neuf-web' );
$content .= ' ' . esc_html(stripslashes(get_search_query()));
} elseif ( is_category() ) {
$content = __( 'Arkiv for kategorien' , 'neuf-web' );
$content .= ' ' . single_cat_title( "" , false );;
} elseif ( is_tag() ) {
$content = __( 'Arkiv for stikkordet' , 'neuf-web' );
$content .= ' ' . neuf-web_tag_query();
} elseif ( is_404() ) {
$content = __( 'Ikke funnet', 'neuf-web' );
} else {
$content = get_bloginfo( 'description' );
}
if ( get_query_var( 'paged' ) ) {
$content .= ' ' .$separator. ' ';
$content .= 'side';
$content .= ' ';
$content .= get_query_var('paged');
}
if($content) {
if ( is_home() || is_front_page() ) {
$elements = array(
'site_name' => $site_name,
'separator' => $separator,
'content' => $content
);
} else {
$elements = array(
'content' => $content,
'separator' => $separator,
'site_name' => $site_name
);
}
} else {
$elements = array(
'site_name' => $site_name
);
}
$doctitle = implode(' ', $elements);
$doctitle = "\t" . "<title>" . $doctitle . "</title>" . "\n\n";
echo $doctitle;
} // end neuf_doctitle
/**
* Should return true if the file displaying the current page is defined as part of the given section.
*
* @todo Do we need this in a WordPress theme? misund 2012-12-18
*/
function is_in_section($section) {
switch ($section) {
case 'program':
if ( in_array(get_requested_file(),array('prog','konsepter','konsept','booking','vis')) )
return true;
break;
case 'foreninger':
if ( in_array(get_requested_file(),array('foreninger')) )
return true;
break;
case 'forum':
if ( substr($_SERVER['REQUEST_URI'],1,5) == 'forum' )
return true;
break;
case 'inside':
if ( substr($_SERVER['REQUEST_URI'],1,6) == 'inside' || in_array(get_requested_file(),array('aktive')) )
return true;
break;
case 'nyheter':
if ( in_array(get_requested_file(),array('nyheter','nyhet')) )
return true;
break;
case 'forside':
if ( !( is_in_section('program') || is_in_section('foreninger') || is_in_section('medlem') || is_in_section('forum') || is_in_section('inside') || is_in_section('nyheter') ) )
return true;
break;
default:
return false;
}
}
/**
* Display social sharing buttons
*/
function display_social_sharing_buttons() { ?>
<div id="social-sharing">
<div class="share-twitter">
<a href="https://twitter.com/share" class="twitter-share-button" data-lang="no">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div> <!-- .share-twitter -->
<div class="share-facebook">
<div class="fb-like" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true" data-action="recommend"></div>
</div> <!-- .share-facebook -->
</div> <!-- #social-sharing -->
<?php }
/**
* Count attachments to a post.
*
* Stolen from misund's blog theme.
*
* @author misund
*/
function neuf_get_attachment_count() {
global $post;
$attachments = get_children( array(
'post_parent' => $post->ID,
'post_type' => 'any',
'numberposts' => -1,
'post_status' => 'any'
) );
return count( $attachments );
}
/**
* Displays a gallery if suitable (Template Tag).
*
* If a post has more than two attachments, we should probably display them in
* single view. This particularly applies to events. Photos of concerts etc.
* can this way easily be added after the event, without much hassle.
*
* @author misund
*/
function neuf_maybe_display_gallery() {
if ( 2 < neuf_get_attachment_count() )
echo do_shortcode( '[gallery link="file" size="four-column-promo"]' );
}
function neuf_event_format_date($timestamp) {
return date_i18n('d/n', intval($timestamp));
}
/**
* Takes 2 date strings in $format.
*
* Returns the difference in days * 2, for use in
* a grid based layout on the program page.
*/
function neuf_event_day_gap_size($current_day,$previous_day) {
$format = '%Y-%m-%d';
$prev = new DateTime($previous_day);
$cur = new DateTime($current_day);
$diff = $prev->diff($cur)->d;
return ($diff - 1) * 2;
}
/**
* Trims $text down to $length words.
* If $text is truncated, then "[..]" is appended.
*/
function trim_excerpt($text, $length) {
$org_length = strlen($text);
$text = explode(" ", $text); // word boundary
$text = array_slice($text, 0, $length);
$text = implode(" ", $text);
$shorter = $org_length != strlen($text) ? " [...]" : "";
return $text . $shorter;
}
/**
* Replaces the matching $pattern with $replacement in the string $subject.
*/
function linkify($subject, $pattern, $link) {
$replacement = '<a href="'.$link.'">[...]</a>';
$output = preg_replace($pattern, $replacement, $subject);
return $output;
}
/**
* Builds and displays suitable page titles.
*
* Original author: Ian Stewart (theme Thematic).
*/
function neuf_page_title() {
global $post;
$content = '';
if (is_attachment()) {
$content .= '<h1 class="page-title"><a href="';
$content .= apply_filters('the_permalink',get_permalink($post->post_parent));
$content .= '" rev="attachment"><span class="meta-nav">Tilbake til </span>';
$content .= get_the_title($post->post_parent);
$content .= '</a></h1>';
} elseif (is_author()) {
$content .= '<h1 class="page-title author">';
$author = get_the_author_meta( 'display_name' );
$content .= __('Innhold skrevet av', 'neuf');
$content .= ' <span>';
$content .= $author;
$content .= '</span></h1>';
} elseif (is_category()) {
$content .= '<h1 class="page-title">';
$content .= __('Innhold i kategorien', 'neuf');
$content .= ' <span>';
$content .= single_cat_title('', FALSE);
$content .= '</span></h1>' . "\n";
$content .= '<div class="archive-meta">';
if ( !(''== category_description()) ) : $content .= apply_filters('archive_meta', category_description()); endif;
$content .= '</div>';
} elseif (is_search()) {
$content .= '<h1 class="page-title">';
$content .= __('S&oslash;keresultater for:', 'neuf');
$content .= ' <span id="search-terms">';
$content .= esc_html(stripslashes($_GET['s']));
$content .= '</span></h1>';
} elseif (is_tag()) {
$content .= '<h1 class="page-title">';
$content .= __('Innhold merket med', 'neuf');
$content .= ' <span>';
$content .= __(neuf_tag_query());
$content .= '</span></h1>';
} elseif (is_tax()) {
global $taxonomy;
$content .= '<h1 class="page-title">';
$tax = get_taxonomy($taxonomy);
$content .= $tax->labels->name . ' ';
$content .= __('Arkiv:', 'neuf');
$content .= ' <span>';
$content .= neuf_get_term_name();
$content .= '</span></h1>';
} elseif (is_day()) {
$content .= '<h1 class="page-title">';
$content .= sprintf(__('Innhold fra dagen <span>%s</span>', 'neuf'), get_the_time(get_option('date_format')));
$content .= '</h1>';
} elseif (is_month()) {
$content .= '<h1 class="page-title">';
$content .= sprintf(__('Innhold fra m&aring;neden <span>%s</span>', 'neuf'), get_the_time('F Y'));
$content .= '</h1>';
} elseif (is_year()) {
$content .= '<h1 class="page-title">';
$content .= sprintf(__('Innhold fra &aring;ret <span>%s</span>', 'neuf'), get_the_time('Y'));
$content .= '</h1>';
} elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {
$content .= '<h1 class="page-title">';
$content .= __('Arkiv', 'neuf');
$content .= '</h1>';
}
$content .= "\n";
echo( $content );
}
/**
* Creates nice multi_tag_title.
*
* Original author: Martin Kopischke.
*/
function neuf_tag_query() {
$nice_tag_query = get_query_var('tag'); // tags in current query
$nice_tag_query = str_replace(' ', '+', $nice_tag_query); // get_query_var returns ' ' for AND, replace by +
$tag_slugs = preg_split('%[,+]%', $nice_tag_query, -1, PREG_SPLIT_NO_EMPTY); // create array of tag slugs
$tag_ops = preg_split('%[^,+]*%', $nice_tag_query, -1, PREG_SPLIT_NO_EMPTY); // create array of operators
$tag_ops_counter = 0;
$nice_tag_query = '';
foreach ($tag_slugs as $tag_slug) {
$tag = get_term_by('slug', $tag_slug ,'post_tag');
// prettify tag operator, if any
if ($tag_ops[$tag_ops_counter] == ',') {
$tag_ops[$tag_ops_counter] = ', ';
} elseif ($tag_ops[$tag_ops_counter] == '+') {
$tag_ops[$tag_ops_counter] = ' + ';
}
// concatenate display name and prettified operators
$nice_tag_query = $nice_tag_query.$tag->name.$tag_ops[$tag_ops_counter];
$tag_ops_counter += 1;
}
return $nice_tag_query;
}
/**
* Gets the name of a term.
*
* Original author: Justin Tadlock (theme Hybrid).
*/
function neuf_get_term_name() {
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
return $term->name;
}
?>
+44
View File
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="no" lang="no">
<head>
<meta charset="utf-8" />
<meta name="robots" content="index,follow" />
<?php neuf_doctitle(); ?>
<link rel="icon" type="image/png" href="favicon.png" />
<?php // @todo Make sure our feeds work properly :) ?>
<link rel="alternate" type="application/rss+xml" href="<?php bloginfo('url'); ?>/feed/" title="Det Norske Studentersamfund (nyheter)" />
<link rel="alternate" type="application/rss+xml" href="http://studentersamfundet.no/syndikering/kommende-program/" title="Det Norske Studentersamfund (kommende program)" />
<link href="<?php bloginfo( 'stylesheet_url' ); ?>" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Arvo:700,400italic' rel='stylesheet' type='text/css'>
<?php wp_head(); ?>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body <?php neuf_body_class(); ?>>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/nb_NO/all.js#xfbml=1&appId=220213643760";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<header id="site-header">
<div class="container_12" style="margin-left:auto;margin-right:auto">
<div id="access"><a href="#content">Gå direkte til innholdet</a></div>
<div class="site-title grid_6">
<span><a href="<?php bloginfo('url') ?>/" title="<?php bloginfo('name') ?>" rel="home"><?php bloginfo('name') ?></a></span>
</div>
<?php get_template_part( 'menu' ); ?>
</div>
</header><!-- #site-header -->
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Loaded 100 of 195 files, more files were not shown because too many files have changed in this diff. Show more