git-svn-id: https://192.168.0.254/svn/Proyectos.FundacionLQDVI_Web/trunk@7 77ab8c26-3d69-2c4d-86f2-786f4ba54905
This commit is contained in:
David Arranz 2011-06-08 08:46:02 +00:00
parent e8eb65a2cb
commit 93fbec950e
26 changed files with 6185 additions and 0 deletions

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.

View File

@ -0,0 +1,28 @@
.subhead {
margin-bottom: .2em;
}
#slb_settings {
display: block;
padding: 2em 0 0;
}
.slb_option_item .block {
display: inline-block;
}
.slb_option_item label.title {
width: 200px;
padding: 10px;
}
.slb_option_item .input {
font-size: 11px;
line-height: 20px;
margin-bottom: 9px;
padding: 8px 10px;
}
.slb_option_item .input select {
min-width: 12em;
}

View File

@ -0,0 +1,138 @@
.slb_dataCaption { font-weight: bold;}
.slb_dataNumber { display: block; clear: left; }
#slb_nav { display: block; clear: left; padding:0 0 10px 0;}
.slb_navPrev { margin:0 8px 0 0; }
.slb_navNext { margin:0 8px 0 0; }
.slb_slbClose {
display:block;
margin:0;
padding:0 0 10px 0;
text-decoration:none;
float:right;
width:66px;
height:28px;
background:url("../images/closelabel_black.gif") no-repeat;
text-indent:-9999px;
overflow:hidden;
}
#slb_lightbox {
position: absolute;
top: 20px;
left: 0;
width: 100%;
z-index: 3100;
text-align: center;
line-height: 0;
color:#fff;
}
#slb_lightbox a, #slb_lightbox a:hover {
border-bottom:none;
color:#fff;
text-decoration:underline;
}
#slb_lightbox a img { border: none; }
#slb_container {
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;
}
#slb_slbLoading {
display:block;
margin:0 auto;
padding:0;
width:32px;
height:32px;
background:url("../images/loading_black.gif") center center no-repeat;
text-indent:-9999px;
}
#nav_hover {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
left: 0;
}
#nav_hover a { outline: none; }
#nav_hover .slb_nav {
width: 47%;
height: 98%;
background: transparent url("../images/blank.gif") no-repeat; /* Trick IE into showing hover */
display: block;
text-indent: -9999px;
}
#nav_hover .slb_navPrev { left: 0; float: left;}
#nav_hover .slb_navNext { right: 0; float: right;}
#nav_hover .slb_navPrev:hover, #nav_hover .slb_navPrev:visited:hover { background: url("../images/prevlabel_black.gif") left 15% no-repeat; }
#nav_hover .slb_navNext:hover, #nav_hover .slb_navNext:visited:hover { background: url("../images/nextlabel_black.gif") right 15% no-repeat; }
#slb_details {
font: 10px Verdana, Helvetica, sans-serif;
background-color: #000;
margin: 0 auto;
line-height: 1.4em;
}
#imageData {
padding:0 10px;
}
#imageDetails { width: 70%; float: left; text-align: left; }
#slb_overlay {
position: absolute;
top: 0;
left: 0;
z-index: 3090;
width: 100%;
height: 500px;
background-color: #151410;
filter:alpha(opacity=60);
-moz-opacity: 0.6;
opacity: 0.6;
}
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
* html>body .clearfix {
display: inline-block;
width: 100%;
}
* html .clearfix {
/* Hides from IE-mac \*/
height: 1%;
/* End hide from IE-mac */
}

View File

@ -0,0 +1,138 @@
.slb_dataCaption { font-weight: bold;}
.slb_dataNumber { display: block; clear: left; }
#slb_nav { display: block; clear: left; padding:0 0 10px 0;}
.slb_navPrev { margin:0 8px 0 0; }
.slb_navNext { margin:0 8px 0 0; }
.slb_slbClose {
display:block;
margin:0;
padding:0 0 10px 0;
text-decoration:none;
float:right;
width:66px;
height:28px;
background:url("../images/closelabel.gif") no-repeat;
text-indent:-9999px;
overflow:hidden;
}
#slb_lightbox {
position: absolute;
top: 20px;
left: 0;
width: 100%;
z-index: 3100;
text-align: center;
line-height: 0;
color:#151410;
}
#slb_lightbox a, #slb_lightbox a:hover {
border-bottom:none;
color:#151410;
text-decoration:underline;
}
#slb_lightbox a img { border: none; }
#slb_container {
position: relative;
background-color: #fff;
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;
}
#slb_slbLoading {
display:block;
margin:0 auto;
padding:0;
width:32px;
height:32px;
background:url("../images/loading.gif") center center no-repeat;
text-indent:-9999px;
}
#nav_hover {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
left: 0;
}
#nav_hover a { outline: none; }
#nav_hover .slb_nav {
width: 47%;
height: 98%;
background: transparent url("../images/blank.gif") no-repeat; /* Trick IE into showing hover */
display: block;
text-indent: -9999px;
}
#nav_hover .slb_navPrev { left: 0; float: left;}
#nav_hover .slb_navNext { right: 0; float: right;}
#nav_hover .slb_navPrev:hover, #nav_hover .slb_navPrev:visited:hover { background: url("../images/prevlabel.gif") left 15% no-repeat; }
#nav_hover .slb_navNext:hover, #nav_hover .slb_navNext:visited:hover { background: url("../images/nextlabel.gif") right 15% no-repeat; }
#slb_details {
font: 10px Verdana, Helvetica, sans-serif;
background-color: #fff;
margin: 0 auto;
line-height: 1.4em;
}
#imageData {
padding:0 10px;
}
#imageDetails { width: 70%; float: left; text-align: left; }
#slb_overlay {
position: absolute;
top: 0;
left: 0;
z-index: 3090;
width: 100%;
height: 500px;
background-color: #151410;
filter:alpha(opacity=60);
-moz-opacity: 0.6;
opacity: 0.6;
}
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
* html>body .clearfix {
display: inline-block;
width: 100%;
}
* html .clearfix {
/* Hides from IE-mac \*/
height: 1%;
/* End hide from IE-mac */
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

View File

@ -0,0 +1,135 @@
<?php
require_once 'class.utilities.php';
/**
* @package Simple Lightbox
* @subpackage Base
* @author Archetyped
*
*/
class SLB_Base {
/**
* Variable name of base object in global scope
* @var string
*/
var $base = 'slb';
/**
* Prefix for Cornerstone-related data (attributes, DB tables, etc.)
* @var string
*/
var $prefix = 'slb';
/**
* Utilities
* @var SLB_Utilities
*/
var $util = null;
/**
* Legacy constructor
*/
function SLB_Base() {
$this->__construct();
}
/**
* Constructor
*/
function __construct() {
$this->util =& new SLB_Utilities($this);
}
/*-** Init **-*/
/**
* Default initialization method
* To be overriden by child classes
*/
function init() {
$func = 'register_hooks';
if ( isset($this) && method_exists($this, $func) ) {
call_user_method($func, $this);
}
}
function register_hooks() {
//Activation
$func_activate = 'activate';
if ( method_exists($this, $func_activate) )
register_activation_hook($this->util->get_plugin_base_file(), $this->m($func_activate));
//Deactivation
$func_deactivate = 'deactivate';
if ( method_exists($this, $func_deactivate) )
register_deactivation_hook($this->util->get_plugin_base_file(), $this->m($func_deactivate));
}
/*-** Reflection **-*/
/**
* Retrieve base object
* @return object|bool Base object (FALSE if object does not exist)
*/
function &get_base() {
return ( isset($GLOBALS[$this->base]) ) ? $GLOBALS[$this->base] : false;
}
/*-** Method/Function calling **-*/
/**
* Returns callback to instance method
* @param string $method Method name
* @return array Callback array
*/
function &m($method) {
return $this->util->m($this, $method);
}
/*-** Prefix **-*/
/**
* Retrieve class prefix (with separator if set)
* @param bool|string $sep Separator to append to class prefix (Default: no separator)
* @return string Class prefix
*/
function get_prefix($sep = null) {
$args = func_get_args();
return call_user_func_array($this->util->m($this->util, 'get_prefix'), $args);
}
/**
* Check if a string is prefixed
* @param string $text Text to check for prefix
* @param string $sep (optional) Separator used
*/
function has_prefix($text, $sep = null) {
$args = func_get_args();
return call_user_func_array($this->util->m($this->util, 'has_prefix'), $args);
}
/**
* Prepend plugin prefix to some text
* @param string $text Text to add to prefix
* @param string $sep (optional) Text used to separate prefix and text
* @param bool $once (optional) Whether to add prefix to text that already contains a prefix or not
* @return string Text with prefix prepended
*/
function add_prefix($text, $sep = null, $once = true) {
$args = func_get_args();
return call_user_func_array($this->util->m($this->util, 'add_prefix'), $args);
}
/**
* Remove prefix from specified string
* @param string $text String to remove prefix from
* @param string $sep (optional) Separator used with prefix
*/
function remove_prefix($text, $sep = null) {
$args = func_get_args();
return call_user_func_array($this->util->m($this->util, 'remove_prefix'), $args);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,394 @@
<?php
require_once 'class.fields.php';
/**
* Option object
* @package Simple Lightbox
* @subpackage Options
* @author SM
*/
class SLB_Option extends SLB_Field {
/**
* Child mapping
* @see SLB_Field_Base::map
* @var array
*/
var $map = array(
'default' => 'data',
'attr' => 'properties'
);
/* Init */
function SLB_Option($id, $title = '', $default = '') {
$args = func_get_args();
call_user_func_array(array(&$this, '__construct'), $args);
}
/**
* @see SLB_Field::__construct()
* @uses parent::__construct() to initialize instance
* @param $id
* @param $title
* @param $default
*/
function __construct($id, $title = '', $default = '') {
//Normalize properties
$args = func_get_args();
$props = SLB_Utilities::func_get_options($args);
$props = wp_parse_args($props, array ('id' => $id, 'title' => $title, 'default' => $default));
//Send to parent constructor
parent::__construct($props);
}
/* Getters/Setters */
/**
* Retrieve default value for option
* @return mixed Default option value
*/
function get_default($context = '') {
return $this->get_data($context, false);
}
/**
* Sets parent based on default value
*/
function set_parent($parent = null) {
$p =& $this->get_parent();
if ( empty($parent) && empty($p) ) {
$parent = 'text';
$d = $this->get_default();
if ( is_bool($d) )
$parent = 'checkbox';
$parent = 'option_' . $parent;
} elseif ( !empty($p) && !is_object($p) ) {
$parent =& $p;
}
parent::set_parent($parent);
}
/* Formatting */
/**
* Format data as string for browser output
* @see SLB_Field_Base::format()
* @param mixed $value Data to format
* @param string $context (optional) Current context
* @return string Formatted value
*/
function format_display($value, $context = '') {
if ( !is_string($value) ) {
if ( is_bool($value) )
$value = ( $value ) ? 'Enabled' : 'Disabled';
elseif ( is_null($value) )
$value = '';
else
$value = strval($value);
}
return htmlentities($value);
}
}
/**
* Options collection
* @package Simple Lightbox
* @subpackage Options
* @author SM
* @uses SLB_Field_Collection
*/
class SLB_Options extends SLB_Field_Collection {
/* Properties */
var $item_type = 'SLB_Option';
/* Init */
function SLB_Options($id, $props = array()) {
$args = func_get_args();
call_user_func_array(array(&$this, '__construct'), $args);
}
function __construct($id, $props = array()) {
parent::__construct($id, $props);
}
function register_hooks() {
parent::register_hooks();
//Register fields
add_action($this->add_prefix('register_fields'), $this->m('register_fields'));
//Set option parents
add_action($this->add_prefix('fields_registered'), $this->m('set_parents'));
}
/**
* Migrate options from old versions to current version
*/
function migrate() {
//Legacy options
$oid = 'enabled_single';
$d = null;
$this->load_data();
if ( ($o = get_option($oid, $d)) && $o !== $d ) {
$this->set_data('enabled_post', $o, false);
$this->set_data('enabled_page', $o, false);
}
//Migrate separate options to unified option
$items =& $this->get_items();
foreach ( $items as $id => $opt ) {
$oid = $this->add_prefix($id);
$o = get_option($oid, $d);
if ( $o !== $d ) {
//Migrate value to data array
$this->set_data($id, $o, false);
//Delete legacy option
delete_option($oid);
}
}
//Remove any remaining legacy items
if ( is_array($this->properties_init) && isset($this->properties_init['legacy']) && is_array($this->properties_init['legacy']) ) {
foreach( $this->properties_init['legacy'] as $opt )
delete_option($this->add_prefix($opt));
}
//Save changes
$this->save();
}
/* Option setup */
/**
* Register option-specific fields
* @param SLB_Fields $fields Reference to global fields object
* @return void
*/
function register_fields(&$fields) {
//Layouts
$layout_label = '<label for="{field_id}" class="title block">{label}</label>';
$label_ref = '{label ref_base="layout"}';
$field_pre = '<div class="input block">';
$field_post = '</div>';
$opt_pre = '<div class="' . $this->add_prefix('option_item') . '">';
$opt_post = '</div>';
$layout_form = '<{form_attr ref_base="layout"} /> (Default: {data context="display" top="0"})';
//Text input
$otxt =& new SLB_Field_Type('option_text', 'text');
$otxt->set_property('class', '{inherit} code');
$otxt->set_property('size', null);
$otxt->set_property('value', '{data context="form"}');
$otxt->set_layout('label', $layout_label);
$otxt->set_layout('form', $opt_pre . $label_ref . $field_pre . $layout_form . $field_post . $opt_post);
$fields->add($otxt);
//Checkbox
$ocb =& new SLB_Field_Type('option_checkbox', 'checkbox');
$ocb->set_layout('label', $layout_label);
$ocb->set_layout('form', $opt_pre . $label_ref . $field_pre . $layout_form . $field_post . $opt_post);
$fields->add($ocb);
//Theme
$othm =& new SLB_Field_Type('option_theme', 'select');
$othm->set_layout('label', $layout_label);
$othm->set_layout('form_start', $field_pre . '{inherit}');
$othm->set_layout('form_end', '{inherit}' . $field_post);
$othm->set_layout('form', $opt_pre . '{inherit}' . $opt_post);
$fields->add($othm);
}
/**
* Set parent field types for options
* Parent only set for Admin pages
* @uses SLB_Option::set_parent() to set parent field for each option item
* @uses is_admin() to determine if current request is admin page
* @param object $fields Collection of default field types
* @return void
*/
function set_parents(&$fields) {
if ( !is_admin() )
return false;
$items =& $this->get_items();
foreach ( array_keys($items) as $opt ) {
$items[$opt]->set_parent();
}
foreach ( $this->items as $opt ) {
$p = $opt->parent;
if ( is_object($p) )
$p = 'o:' . $p->id;
}
}
/* Processing */
function validate($values) {
if ( is_array($values) ) {
//Get option group being validated
/*
$group = '';
$filter = 'sanitize_option_';
$option = str_replace($filter, '', current_filter());
if ( $this->get_id() == $this->remove_prefix($option) ) {
$group = '';
} else {
$group = substr($option, strlen($this->add_prefix($this->get_id())) + 1);
}
*/
//Format data based on option type (bool, string, etc.)
foreach ( $values as $id => $val ) {
//Get default
$d = $this->get_default($id);
if ( is_bool($d) && !empty($val) )
$values[$id] = true;
}
//Merge in additional options that are not in post data
//Missing options (e.g. disabled checkboxes) & defaults
$items =& $this->get_items();
foreach ( $items as $id => $opt ) {
//Add options that were not included in form submission
if ( !array_key_exists($id, $values) ) {
if ( is_bool($opt->get_default()) )
$values[$id] = false;
else
$values[$id] = $opt->get_default();
}
}
}
//Return value
return $values;
}
/* Data */
/**
* Retrieve options from database
* @return array Options data
*/
function fetch_data($sanitize = true) {
$data = get_option($this->get_key(), null);
if ( $sanitize && is_array($data) ) {
//Sanitize loaded data based on default values
foreach ( $data as $id => $val ) {
if ( $this->has($id) ) {
$opt = $this->get($id);
if ( is_bool($opt->get_default()) )
$data[$id] = !!$val;
} else {
unset($data[$id]);
}
}
}
return $data;
}
/**
* Retrieves option data for collection
* @see SLB_Field_Collection::load_data()
*/
function load_data() {
static $fetched = false;
if ( !$fetched ) {
$fetched = true;
//Retrieve data
$this->data = $this->fetch_data();
}
}
/**
* Resets option values to their default values
* @param bool $hard Reset all options if TRUE (default), Reset only unset options if FALSE
*/
function reset($hard = true) {
$this->load_data();
//Reset data
if ( $hard ) {
$this->data = null;
}
//Save
$this->save();
}
/**
* Save options data to database
*/
function save() {
$opts =& $this->get_items();
$data = array();
foreach ( $opts as $id => $opt ) {
$data[$id] = $opt->get_data();
}
$this->data = $data;
update_option($this->get_key(), $data);
}
/* Collection */
/**
* Build key for saving/retrieving data to options table
* @return string Key
*/
function get_key() {
return $this->add_prefix($this->get_id());
}
/**
* Add option to collection
* @uses SLB_Field_Collection::add() to add item
* @param string $id Unique item ID
* @param string $title Item title
* @param mixed $default Default value
* @param string $group (optional) Group ID to add item to
* @return SLB_Option Option instance reference
*/
function &add($id, $title = '', $default = '', $group = null) {
//Build properties array
$properties = $this->make_properties($title, array('title' => $title, 'group' => $group, 'default' => $default));
//Create item
/**
* @var SLB_Option
*/
$item =& parent::add($id, $properties);
return $item;
}
/**
* Retrieve option value
* @uses get_data() to retrieve option data
* @param string $option Option ID to retrieve value for
* @param string $context (optional) Context for formatting data
* @return mixed Option value
*/
function get_value($option, $context = '') {
return $this->get_data($option, $context);
}
/**
* Retrieve option's default value
* @uses get_data() to retrieve option data
* @param string $option Option ID to retrieve value for
* @param string $context (optional) Context for formatting data
* @return mixed Option's default value
*/
function get_default($option, $context = '') {
return $this->get_data($option, $context, false);
}
/* Output */
function build_group($group) {
if ( !$this->group_exists($group) )
return false;
$group =& $this->get_group($group);
//Stop processing if group contains no items
if ( !count($this->get_items($group)) )
return false;
//Group header
echo '<h4 class="subhead">' . $group->title . '</h4>';
//Build items
echo $this->build_items($group);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,867 @@
// -----------------------------------------------------------------------------------
//
// Simple Lightbox
// by Archetyped - http://archetyped.com/tools/simple-lightbox/
// Updated: 2011-01-27
//
// Originally based on Lightbox Slideshow v1.1
// by Justin Barkhuff - http://www.justinbarkhuff.com/lab/lightbox_slideshow/
// 2007/08/15
//
// Largely based on Lightbox v2.02
// by Lokesh Dhakar - http://huddletogether.com/projects/lightbox2/
// 2006/03/31
//
// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//
// The code inserts HTML at the bottom of the page for displaying content in a non-modal dialog
//
// -----------------------------------------------------------------------------------
/**
* Lightbox object
*/
//var SLB = null;
(function($) {
SLB = {
activeImage : null,
badObjects : ['select','object','embed'],
container : null,
enableSlideshow : null,
groupName : null,
imageArray : [],
options : null,
overlayDuration : null,
overlayOpacity : null,
playSlides : null,
refTags : ['a'],
relAttribute : null,
resizeDuration : null,
slideShowTimer : null,
startImage : null,
prefix : 'slb',
checkedUrls : {},
/**
* Initialize lightbox instance
* @param object options Instance options
*/
initialize: function(options) {
this.options = $.extend(true, {
animate : true, // resizing animations
validateLinks : false, //Validate links before adding them to lightbox
captionEnabled: true, //Display caption
captionSrc : true, //Use image source URI if title not set
autoPlay : true, // should slideshow start automatically
borderSize : 10, // if you adjust the padding in the CSS, you will need to update this variable
containerID : document, // lightbox container object
enableSlideshow : true, // enable slideshow feature
googleAnalytics : false, // track individual image views using Google Analytics
imageDataLocation : 'south', // location of image caption information
initImage : '', // ID of image link to automatically launch when upon script initialization
loop : true, // whether to continuously loop slideshow images
overlayDuration : .2, // time to fade in shadow overlay
overlayOpacity : .8, // transparency of shadow overlay
relAttribute : 'lightbox', // specifies the rel attribute value that triggers lightbox
resizeSpeed : 400, // controls the speed of the image resizing (milliseconds)
showGroupName : false, // show group name of images in image details
slideTime : 4, // time to display images during slideshow
altsrc : 'src',
strings : { // allows for localization
closeLink : 'close',
loadingMsg : 'loading',
nextLink : 'next &raquo;',
prevLink : '&laquo; prev',
startSlideshow : 'start slideshow',
stopSlideshow : 'stop slideshow',
numDisplayPrefix : 'Image',
numDisplaySeparator : 'of'
},
placeholders : {
slbContent: '<img id="slb_slbContent" />',
slbLoading: '<span id="slb_slbLoading">loading</span>',
slbClose: '<a class="slb_slbClose" href="#">close</a>',
navPrev: '<a class="slb_navPrev slb_nav" href="#">&laquo; prev</a>',
navNext: '<a class="slb_navNext slb_nav" href="#">&raquo; next</a>',
navSlideControl: '<a class="slb_navSlideControl" href="#">Stop</a>',
dataCaption: '<span class="slb_dataCaption"></span>',
dataNumber: '<span class="slb_dataNumber"></span>'
},
layout : null
}, options);
//Stop if no layout is defined
if (!this.options.layout || this.options.layout.toString().length == 0)
this.end();
//Validate options
if ( this.options.animate ) {
this.overlayDuration = Math.max(this.options.overlayDuration,0);
this.resizeDuration = this.options.resizeSpeed;
} else {
this.overlayDuration = 0;
this.resizeDuration = 0;
}
this.enableSlideshow = this.options.enableSlideshow;
this.overlayOpacity = Math.max(Math.min(this.options.overlayOpacity,1),0);
this.playSlides = this.options.autoPlay;
this.container = $(this.options.containerID);
this.relAttribute = this.options.relAttribute;
this.updateImageList();
var t = this;
var objBody = $(this.container).get(0) != document ? this.container : $('body');
var objOverlay = $('<div/>', {
'id': this.getID('overlay'),
'css': {'display': 'none'}
}).appendTo(objBody)
.click(function() {t.end()});
var objLightbox = $('<div/>', {
'id': this.getID('lightbox'),
'css': {'display': 'none'}
}).appendTo(objBody)
.click(function() {t.end()});
//Build layout from template
var layout = this.getLayout();
//Append to container
$(layout).appendTo(objLightbox);
//Set UI
this.setUI();
//Add events
this.setEvents();
if (this.options.initImage != '') {
this.start($(this.options.initImage));
}
},
/**
* Build layout from template
* @uses options.layout
* @return string Layout markup (HTML)
*/
getLayout: function() {
var l = this.options.layout;
//Expand placeholders
var ph, phs, phr;
for (ph in this.options.placeholders) {
phs = '{' + ph + '}';
//Continue to next placeholder if current one is not in layout
if (l.indexOf(phs) == -1)
continue;
phr = new RegExp(phs, "g");
l = l.replace(phr, this.options.placeholders[ph]);
}
//Return final layout
return l;
},
/**
* Set localized values for UI elements
*/
setUI: function() {
var s = this.options.strings;
this.get('slbClose').html(s.closeLink);
this.get('navNext').html(s.nextLink);
this.get('navPrev').html(s.prevLink);
this.get('navSlideControl').html(((this.playSlides) ? s.stopSlideshow : s.startSlideshow));
},
/**
* Add events to various UI elements
*/
setEvents: function() {
var t = this, delay = 500;
this.get('container,details').click(function(ev) {
ev.stopPropagation();
});
var clickP = function() {
t.get('navPrev').unbind('click').click(false);
setTimeout(function() {t.get('navPrev').click(clickP)}, delay);
t.showPrev();
return false;
};
this.get('navPrev').click(function(){
return clickP();
});
var clickN = function() {
t.get('navNext').unbind('click').click(false);
setTimeout(function() {t.get('navNext').click(clickN)}, delay);
t.showNext();
return false;
};
this.get('navNext').click(function() {
return clickN();
});
this.get('navSlideControl').click(function() {
t.toggleSlideShow();
return false;
});
this.get('slbClose').click(function() {
t.end();
return false;
});
},
/**
* Finds all compatible image links on page
*/
updateImageList: function() {
var el, els, rel, t = this;
sel = [], selBase = '[href][rel*="' + this.relAttribute + '"]';
//Define event handler
var handler = function() {
//Check if element is valid for lightbox
t.start(this);
return false;
};
//Build selector
for (var i = 0; i < this.refTags.length; i++) {
sel.push(this.refTags[i] + selBase);
}
sel = sel.join(',');
//Add event handler to links
$(sel, $(this.container)).live('click', handler);
},
/**
* Build caption for displayed caption
* @param {Object} imageLink
*/
getCaption: function(imageLink) {
imageLink = $(imageLink);
var caption = '';
if (this.options.captionEnabled) {
caption = imageLink.attr('title') || '';
if (caption == '') {
var inner = $(imageLink).find('img').first();
if ($(inner).length)
caption = $(inner).attr('title') || $(inner).attr('alt');
if (!caption) {
if (imageLink.text().length)
caption = imageLink.text();
else
if (this.options.captionSrc)
caption = imageLink.attr('href');
}
if (!caption)
caption = '';
}
}
return caption;
},
/**
* Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
* @param node imageLink Link element containing image URL
*/
start: function(imageLink) {
imageLink = $(imageLink);
this.hideBadObjects();
this.imageArray = [];
this.groupName = this.getGroup(imageLink);
var rel = $(imageLink).attr('rel') || '';
var imageTitle = '';
var t = this;
var groupTemp = {};
this.fileExists(this.getSourceFile(imageLink),
function() { //File exists
// Stretch overlay to fill page and fade in
t.get('overlay')
.height($(document).height())
.fadeTo(t.overlayDuration, t.overlayOpacity);
// Add image to array closure
var addLink = function(el, idx) {
groupTemp[idx] = el;
return groupTemp.length;
};
//Build final image array & launch lightbox
var proceed = function() {
t.startImage = 0;
//Sort links by document order
var order = [], el;
for (var x in groupTemp) {
order.push(x);
}
order.sort(function(a, b) { return (a - b); });
for (x = 0; x < order.length; x++) {
el = groupTemp[order[x]];
//Check if link being evaluated is the same as the clicked link
if ($(el).get(0) == $(imageLink).get(0)) {
t.startImage = x;
}
t.imageArray.push({'link':t.getSourceFile($(el)), 'title':t.getCaption(el)});
}
// Calculate top offset for the lightbox and display
var lightboxTop = $(document).scrollTop() + ($(window).height() / 15);
t.get('lightbox').css('top', lightboxTop + 'px').show();
t.changeImage(t.startImage);
}
// If image is NOT part of a group..
if (null == t.groupName) {
// Add single image to imageArray
addLink(imageLink, 0);
t.startImage = 0;
proceed();
} else {
// If image is part of a group
var els = $(t.container).find($(imageLink).get(0).tagName.toLowerCase());
// Loop through links on page & find other images in group
var grpLinks = [];
var i, el;
for (i = 0; i < els.length; i++) {
el = $(els[i]);
if (t.getSourceFile(el) && (t.getGroup(el) == t.groupName)) {
//Add links in same group to temp array
grpLinks.push(el);
}
}
//Loop through group links, validate, and add to imageArray
var processed = 0;
for (i = 0; i < grpLinks.length; i++) {
el = grpLinks[i];
t.fileExists(t.getSourceFile($(el)),
function(args) { //File exists
var el = args.els[args.idx];
var il = addLink(el, args.idx);
processed++;
if (processed == args.els.length)
proceed();
},
function(args) { //File does not exist
processed++;
if (args.idx == args.els.length)
proceed();
},
{'idx': i, 'els': grpLinks});
}
}
},
function() { //File does not exist
t.end();
});
},
/**
* Retrieve source URI in link
* @param {Object} el
* @return string Source file URI
*/
getSourceFile: function(el) {
var src = $(el).attr('href');
var rel = $(el).attr('rel') || '';
var reSrc = new RegExp('\\b' + this.options.altsrc + '\\[(.+?)\\](?:\\b|$)');
if ( reSrc.test(rel) ) {
src = reSrc.exec(rel)[1];
}
return src;
},
/**
* Extract group name from
* @param obj el Element to extract group name from
* @return string Group name
*/
getGroup: function(el) {
//Get full attribute value
var g = null;
var rel = $(el).attr('rel') || '';
if (rel != '') {
var gTmp = '';
var gSt = '[';
var gEnd = ']';
var search = this.relAttribute;
var searching = true;
var idx;
var prefix = ' ';
while (searching) {
idx = rel.indexOf(search);
//Stop processing if value is not found
if (idx == -1)
return g;
//Prefix with space to find whole word
if (prefix != search.charAt(0) && idx > 0) {
search = prefix + search;
}
else {
searching = false;
}
}
gTmp = $.trim(rel.substring(idx).replace(search, ''));
//Check if group defined
if (gTmp.length && gSt == gTmp.charAt(0) && gTmp.indexOf(gEnd) != -1) {
//Extract group name
g = gTmp.substring(1, gTmp.indexOf(gEnd));
}
}
return g;
},
/**
* Preload requested image prior to displaying it in lightbox
* @param int imageNum Index of image in imageArray property
* @uses imageArray to retrieve index at specified image
* @uses resizeImageContainer() to resize lightbox after image has loaded
*/
changeImage: function(imageNum) {
this.activeImage = imageNum;
this.disableKeyboardNav();
this.pauseSlideShow();
// hide elements during transition
this.get('slbLoading').show();
this.get('slbContent').hide();
this.get('details').hide();
var imgPreloader = new Image();
var t = this;
// once image is preloaded, resize image container
$(imgPreloader).bind('load', function() {
t.get('slbContent').attr('src', imgPreloader.src);
t.resizeImageContainer(imgPreloader.width, imgPreloader.height);
//Restart slideshow if active
if ( t.isSlideShowActive() )
t.startSlideShow();
});
//Load image
imgPreloader.src = this.imageArray[this.activeImage].link;
},
/**
* Resizes lightbox to fit image
* @param int imgWidth Image width in pixels
* @param int imgHeight Image height in pixels
*/
resizeImageContainer: function(imgWidth, imgHeight) {
// get current height and width
var el = this.get('container');
var borderSize = this.options.borderSize * 2;
this.get('container').animate({width: imgWidth + borderSize, height: imgHeight + borderSize}, this.resizeDuration)
this.showImage();
},
/**
* Display image and begin preloading neighbors.
*/
showImage: function() {
this.get('slbLoading').hide();
var t = this;
this.get('slbContent').fadeIn(500, function() { t.updateDetails(); });
this.preloadNeighborImages();
},
/**
* Display caption, image number, and bottom nav
*/
updateDetails: function() {
if (this.options.captionEnabled) {
this.get('dataCaption').text(this.imageArray[this.activeImage].title);
this.get('dataCaption').show();
} else {
this.get('dataCaption').hide();
}
// if image is part of set display 'Image x of y'
if (this.hasImages()) {
var num_display = this.options.strings.numDisplayPrefix + ' ' + (this.activeImage + 1) + ' ' + this.options.strings.numDisplaySeparator + ' ' + this.imageArray.length;
if (this.options.showGroupName && this.groupName != '') {
num_display += ' ' + this.options.strings.numDisplaySeparator + ' ' + this.groupName;
}
this.get('dataNumber')
.text(num_display)
.show();
}
this.get('details').width(this.get('slbContent').width() + (this.options.borderSize * 2));
this.updateNav();
var t = this;
this.get('details').animate({height: 'show', opacity: 'show'}, 650);
},
/**
* Display appropriate previous and next hover navigation.
*/
updateNav: function() {
if (this.hasImages()) {
this.get('navPrev').show();
this.get('navNext').show();
if (this.enableSlideshow) {
this.get('navSlideControl').show();
if (this.playSlides) {
this.startSlideShow();
} else {
this.stopSlideShow();
}
} else {
this.get('navSlideControl').hide();
}
} else {
// Hide navigation controls when only one image exists
this.get('dataNumber').hide();
this.get('navPrev').hide();
this.get('navNext').hide();
this.get('navSlideControl').hide();
}
this.enableKeyboardNav();
},
/**
* Checks if slideshow is currently activated
* @return bool TRUE if slideshow is active, FALSE otherwise
* @uses playSlides to check slideshow activation status
*/
isSlideShowActive: function() {
return this.playSlides;
},
/**
* Start the slideshow
*/
startSlideShow: function() {
this.playSlides = true;
var t = this;
clearInterval(this.slideShowTimer);
this.slideShowTimer = setInterval(function() { t.showNext(); t.pauseSlideShow(); }, this.options.slideTime * 1000);
this.get('navSlideControl').text(this.options.strings.stopSlideshow);
},
/**
* Stop the slideshow
*/
stopSlideShow: function() {
this.playSlides = false;
if (this.slideShowTimer) {
clearInterval(this.slideShowTimer);
}
this.get('navSlideControl').text(this.options.strings.startSlideshow);
},
/**
* Toggles the slideshow status
*/
toggleSlideShow: function() {
if (this.playSlides) {
this.stopSlideShow();
}else{
this.startSlideShow();
}
},
/**
* Pauses the slideshow
* Stops the slideshow but does not change the slideshow's activation status
*/
pauseSlideShow: function() {
if (this.slideShowTimer) {
clearInterval(this.slideShowTimer);
}
},
/**
* Check if there is at least one image to display in the lightbox
* @return bool TRUE if at least one image is found
* @uses imageArray to check for images
*/
hasImage: function() {
return ( this.imageArray.length > 0 );
},
/**
* Check if there are multiple images to display in the lightbox
* @return bool TRUE if there are multiple images
* @uses imageArray to determine the number of images
*/
hasImages: function() {
return ( this.imageArray.length > 1 );
},
/**
* Check if the current image is the first image in the list
* @return bool TRUE if image is first
* @uses activeImage to check index of current image
*/
isFirstImage: function() {
return ( this.activeImage == 0 );
},
/**
* Check if the current image is the last image in the list
* @return bool TRUE if image is last
* @uses activeImage to check index of current image
* @uses imageArray to compare current image to total number of images
*/
isLastImage: function() {
return ( this.activeImage == this.imageArray.length - 1 );
},
/**
* Show the next image in the list
*/
showNext : function() {
if (this.hasImages()) {
if ( !this.options.loop && this.isLastImage() ) {
return this.end();
}
if ( this.isLastImage() ) {
this.showFirst();
} else {
this.changeImage(this.activeImage + 1);
}
}
},
/**
* Show the previous image in the list
*/
showPrev : function() {
if (this.hasImages()) {
if ( !this.options.loop && this.isFirstImage() )
return this.end();
if (this.activeImage == 0) {
this.showLast();
} else {
this.changeImage(this.activeImage - 1);
}
}
},
/**
* Show the first image in the list
*/
showFirst : function() {
if (this.hasImages()) {
this.changeImage(0);
}
},
/**
* Show the last image in the list
*/
showLast : function() {
if (this.hasImages()) {
this.changeImage(this.imageArray.length - 1);
}
},
/**
* Enable image navigation via the keyboard
*/
enableKeyboardNav: function() {
var t = this;
$(document).keydown(function(e) {
t.keyboardAction(e);
});
},
/**
* Disable image navigation via the keyboard
*/
disableKeyboardNav: function() {
$(document).unbind('keydown');
},
/**
* Handler for keyboard events
* @param event e Keyboard event data
*/
keyboardAction: function(e) {
if (e == null) { // ie
keycode = event.keyCode;
} else { // mozilla
keycode = e.which;
}
key = String.fromCharCode(keycode).toLowerCase();
if (keycode == 27 || key == 'x' || key == 'o' || key == 'c') { // close lightbox
this.end();
} else if (key == 'p' || key == '%') { // display previous image
this.showPrev();
} else if (key == 'n' || key =='\'') { // display next image
this.showNext();
} else if (key == 'f') { // display first image
this.showFirst();
} else if (key == 'l') { // display last image
this.showLast();
} else if (key == 's') { // toggle slideshow
if (this.hasImage() && this.options.enableSlideshow) {
this.toggleSlideShow();
}
}
},
/**
* Preloads images before/after current image
*/
preloadNeighborImages: function() {
var nextImageID = this.imageArray.length - 1 == this.activeImage ? 0 : this.activeImage + 1;
nextImage = new Image();
nextImage.src = this.imageArray[nextImageID].link;
var prevImageID = this.activeImage == 0 ? this.imageArray.length - 1 : this.activeImage - 1;
prevImage = new Image();
prevImage.src = this.imageArray[prevImageID].link;
},
/**
* Close the lightbox
*/
end: function() {
this.disableKeyboardNav();
this.pauseSlideShow();
this.get('lightbox').hide();
this.get('overlay').fadeOut(this.overlayDuration);
this.showBadObjects();
},
/**
* Displays objects that may conflict with the lightbox
* @param bool show (optional) Whether or not to show objects (Default: TRUE)
*/
showBadObjects: function (show) {
show = ( typeof(show) == 'undefined' ) ? true : !!show;
var vis = (show) ? 'visible' : 'hidden';
$(this.badObjects.join(',')).css('visibility', vis);
},
/**
* Hides objects that may conflict with the lightbox
* @uses showBadObjects() to hide objects
*/
hideBadObjects: function () {
this.showBadObjects(false);
},
/**
* Add prefix to text
* @param string txt Text to add prefix to
* @return string Prefixed text
*/
addPrefix: function(txt) {
return this.prefix + '_' + txt;
},
/**
* Generate formatted ID for lightbox-specific elements
* @param string id Base ID of element
* @return string Formatted ID
*/
getID: function(id) {
return this.addPrefix(id);
},
/**
* Generate formatted selector for lightbox-specific elements
* Compares specified ID to placeholders first, then named elements
* Multiple selectors can be included and separated by commas (',')
* @param string id Base ID of element
* @uses options.placeholders to compare id to placeholder names
* @return string Formatted selector
*/
getSel: function(id) {
//Process multiple selectors
var delim = ',', prefix = '#', sel;
if (id.toString().indexOf(delim) != -1) {
//Split
var sels = id.toString().split(delim);
//Build selector
for (var x = 0; x < sels.length; x++) {
sels[x] = this.getSel($.trim(sels[x]));
}
//Join
sel = sels.join(delim);
} else {
//Single selector
if (id in this.options.placeholders) {
var ph = $(this.options.placeholders[id]);
if (!ph.attr('id')) {
//Class selector
prefix = '.';
}
}
sel = prefix + this.getID(id);
}
return sel;
},
/**
* Retrieve lightbox-specific element
* @param string id Base ID of element
* @uses getSel() to generate formatted selector for element
* @return object jQuery object of selected element(s)
*/
get: function(id) {
return $(this.getSel(id));
},
/**
* Checks if file exists using AJAX request
* @param string url File URL
* @param callback success Callback to run if file exists
* @param callback failure Callback to run if file does not exist
* @param obj args Arguments for callback
*/
fileExists: function(url, success, failure, args) {
if (!this.options.validateLinks)
return success(args);
var statusFail = 400;
var stateCheck = 4;
var t = this;
var proceed = function(res) {
if (res.status < statusFail) {
if ($.isFunction(success))
success(args);
} else {
if ($.isFunction(failure))
failure(args);
}
};
//Check if URL already processed
if (url in this.checkedUrls) {
proceed(this.checkedUrls[url]);
} else {
var req = new XMLHttpRequest();
req.open('HEAD', url, true);
req.onreadystatechange = function() {
if (stateCheck == this.readyState) {
t.addUrl(url, this);
proceed(this);
}
};
req.send();
}
},
addUrl: function(url, res) {
if (!(url in this.checkedUrls))
this.checkedUrls[url] = res;
}
}
})(jQuery);

View File

@ -0,0 +1,21 @@
(function(d){SLB={activeImage:null,badObjects:["select","object","embed"],container:null,enableSlideshow:null,groupName:null,imageArray:[],options:null,overlayDuration:null,overlayOpacity:null,playSlides:null,refTags:["a"],relAttribute:null,resizeDuration:null,slideShowTimer:null,startImage:null,prefix:"slb",checkedUrls:{},initialize:function(a){this.options=d.extend(true,{animate:true,validateLinks:false,captionEnabled:true,captionSrc:true,autoPlay:true,borderSize:10,containerID:document,enableSlideshow:true,
googleAnalytics:false,imageDataLocation:"south",initImage:"",loop:true,overlayDuration:0.2,overlayOpacity:0.8,relAttribute:"lightbox",resizeSpeed:400,showGroupName:false,slideTime:4,altsrc:"src",strings:{closeLink:"close",loadingMsg:"loading",nextLink:"next &raquo;",prevLink:"&laquo; prev",startSlideshow:"start slideshow",stopSlideshow:"stop slideshow",numDisplayPrefix:"Image",numDisplaySeparator:"of"},placeholders:{slbContent:'<img id="slb_slbContent" />',slbLoading:'<span id="slb_slbLoading">loading</span>',
slbClose:'<a class="slb_slbClose" href="#">close</a>',navPrev:'<a class="slb_navPrev slb_nav" href="#">&laquo; prev</a>',navNext:'<a class="slb_navNext slb_nav" href="#">&raquo; next</a>',navSlideControl:'<a class="slb_navSlideControl" href="#">Stop</a>',dataCaption:'<span class="slb_dataCaption"></span>',dataNumber:'<span class="slb_dataNumber"></span>'},layout:null},a);if(!this.options.layout||this.options.layout.toString().length==0)this.end();if(this.options.animate){this.overlayDuration=Math.max(this.options.overlayDuration,
0);this.resizeDuration=this.options.resizeSpeed}else this.resizeDuration=this.overlayDuration=0;this.enableSlideshow=this.options.enableSlideshow;this.overlayOpacity=Math.max(Math.min(this.options.overlayOpacity,1),0);this.playSlides=this.options.autoPlay;this.container=d(this.options.containerID);this.relAttribute=this.options.relAttribute;this.updateImageList();var b=this;a=d(this.container).get(0)!=document?this.container:d("body");d("<div/>",{id:this.getID("overlay"),css:{display:"none"}}).appendTo(a).click(function(){b.end()});
a=d("<div/>",{id:this.getID("lightbox"),css:{display:"none"}}).appendTo(a).click(function(){b.end()});var c=this.getLayout();d(c).appendTo(a);this.setUI();this.setEvents();this.options.initImage!=""&&this.start(d(this.options.initImage))},getLayout:function(){var a=this.options.layout,b,c;for(b in this.options.placeholders){c="{"+b+"}";if(a.indexOf(c)!=-1){c=new RegExp(c,"g");a=a.replace(c,this.options.placeholders[b])}}return a},setUI:function(){var a=this.options.strings;this.get("slbClose").html(a.closeLink);
this.get("navNext").html(a.nextLink);this.get("navPrev").html(a.prevLink);this.get("navSlideControl").html(this.playSlides?a.stopSlideshow:a.startSlideshow)},setEvents:function(){var a=this;this.get("container,details").click(function(g){g.stopPropagation()});var b=function(){a.get("navPrev").unbind("click").click(false);setTimeout(function(){a.get("navPrev").click(b)},500);a.showPrev();return false};this.get("navPrev").click(function(){return b()});var c=function(){a.get("navNext").unbind("click").click(false);
setTimeout(function(){a.get("navNext").click(c)},500);a.showNext();return false};this.get("navNext").click(function(){return c()});this.get("navSlideControl").click(function(){a.toggleSlideShow();return false});this.get("slbClose").click(function(){a.end();return false})},updateImageList:function(){var a=this;sel=[];selBase='[href][rel*="'+this.relAttribute+'"]';for(var b=0;b<this.refTags.length;b++)sel.push(this.refTags[b]+selBase);sel=sel.join(",");d(sel,d(this.container)).live("click",function(){a.start(this);
return false})},getCaption:function(a){a=d(a);var b="";if(this.options.captionEnabled){b=a.attr("title")||"";if(b==""){var c=d(a).find("img").first();if(d(c).length)b=d(c).attr("title")||d(c).attr("alt");if(!b)if(a.text().length)b=a.text();else if(this.options.captionSrc)b=a.attr("href");b||(b="")}}return b},start:function(a){a=d(a);this.hideBadObjects();this.imageArray=[];this.groupName=this.getGroup(a);d(a).attr("rel");var b=this,c={};this.fileExists(this.getSourceFile(a),function(){b.get("overlay").height(d(document).height()).fadeTo(b.overlayDuration,
b.overlayOpacity);var g=function(){b.startImage=0;var e=[],l;for(var k in c)e.push(k);e.sort(function(n,o){return n-o});for(k=0;k<e.length;k++){l=c[e[k]];if(d(l).get(0)==d(a).get(0))b.startImage=k;b.imageArray.push({link:b.getSourceFile(d(l)),title:b.getCaption(l)})}e=d(document).scrollTop()+d(window).height()/15;b.get("lightbox").css("top",e+"px").show();b.changeImage(b.startImage)};if(null==b.groupName){c[0]=a;b.startImage=0;g()}else{var h=d(b.container).find(d(a).get(0).tagName.toLowerCase()),
j=[],f,i;for(f=0;f<h.length;f++){i=d(h[f]);b.getSourceFile(i)&&b.getGroup(i)==b.groupName&&j.push(i)}var m=0;for(f=0;f<j.length;f++){i=j[f];b.fileExists(b.getSourceFile(d(i)),function(e){c[e.idx]=e.els[e.idx];m++;m==e.els.length&&g()},function(e){m++;e.idx==e.els.length&&g()},{idx:f,els:j})}}},function(){b.end()})},getSourceFile:function(a){var b=d(a).attr("href");a=d(a).attr("rel")||"";var c=new RegExp("\\b"+this.options.altsrc+"\\[(.+?)\\](?:\\b|$)");if(c.test(a))b=c.exec(a)[1];return b},getGroup:function(a){var b=
null;a=d(a).attr("rel")||"";if(a!=""){var c="";c=this.relAttribute;for(var g=true,h;g;){h=a.indexOf(c);if(h==-1)return b;if(" "!=c.charAt(0)&&h>0)c=" "+c;else g=false}c=d.trim(a.substring(h).replace(c,""));if(c.length&&"["==c.charAt(0)&&c.indexOf("]")!=-1)b=c.substring(1,c.indexOf("]"))}return b},changeImage:function(a){this.activeImage=a;this.disableKeyboardNav();this.pauseSlideShow();this.get("slbLoading").show();this.get("slbContent").hide();this.get("details").hide();var b=new Image,c=this;d(b).bind("load",
function(){c.get("slbContent").attr("src",b.src);c.resizeImageContainer(b.width,b.height);c.isSlideShowActive()&&c.startSlideShow()});b.src=this.imageArray[this.activeImage].link},resizeImageContainer:function(a,b){this.get("container");var c=this.options.borderSize*2;this.get("container").animate({width:a+c,height:b+c},this.resizeDuration);this.showImage()},showImage:function(){this.get("slbLoading").hide();var a=this;this.get("slbContent").fadeIn(500,function(){a.updateDetails()});this.preloadNeighborImages()},
updateDetails:function(){if(this.options.captionEnabled){this.get("dataCaption").text(this.imageArray[this.activeImage].title);this.get("dataCaption").show()}else this.get("dataCaption").hide();if(this.hasImages()){var a=this.options.strings.numDisplayPrefix+" "+(this.activeImage+1)+" "+this.options.strings.numDisplaySeparator+" "+this.imageArray.length;if(this.options.showGroupName&&this.groupName!="")a+=" "+this.options.strings.numDisplaySeparator+" "+this.groupName;this.get("dataNumber").text(a).show()}this.get("details").width(this.get("slbContent").width()+
this.options.borderSize*2);this.updateNav();this.get("details").animate({height:"show",opacity:"show"},650)},updateNav:function(){if(this.hasImages()){this.get("navPrev").show();this.get("navNext").show();if(this.enableSlideshow){this.get("navSlideControl").show();this.playSlides?this.startSlideShow():this.stopSlideShow()}else this.get("navSlideControl").hide()}else{this.get("dataNumber").hide();this.get("navPrev").hide();this.get("navNext").hide();this.get("navSlideControl").hide()}this.enableKeyboardNav()},
isSlideShowActive:function(){return this.playSlides},startSlideShow:function(){this.playSlides=true;var a=this;clearInterval(this.slideShowTimer);this.slideShowTimer=setInterval(function(){a.showNext();a.pauseSlideShow()},this.options.slideTime*1E3);this.get("navSlideControl").text(this.options.strings.stopSlideshow)},stopSlideShow:function(){this.playSlides=false;this.slideShowTimer&&clearInterval(this.slideShowTimer);this.get("navSlideControl").text(this.options.strings.startSlideshow)},toggleSlideShow:function(){this.playSlides?
this.stopSlideShow():this.startSlideShow()},pauseSlideShow:function(){this.slideShowTimer&&clearInterval(this.slideShowTimer)},hasImage:function(){return this.imageArray.length>0},hasImages:function(){return this.imageArray.length>1},isFirstImage:function(){return this.activeImage==0},isLastImage:function(){return this.activeImage==this.imageArray.length-1},showNext:function(){if(this.hasImages()){if(!this.options.loop&&this.isLastImage())return this.end();this.isLastImage()?this.showFirst():this.changeImage(this.activeImage+
1)}},showPrev:function(){if(this.hasImages()){if(!this.options.loop&&this.isFirstImage())return this.end();this.activeImage==0?this.showLast():this.changeImage(this.activeImage-1)}},showFirst:function(){this.hasImages()&&this.changeImage(0)},showLast:function(){this.hasImages()&&this.changeImage(this.imageArray.length-1)},enableKeyboardNav:function(){var a=this;d(document).keydown(function(b){a.keyboardAction(b)})},disableKeyboardNav:function(){d(document).unbind("keydown")},keyboardAction:function(a){keycode=
a==null?event.keyCode:a.which;key=String.fromCharCode(keycode).toLowerCase();if(keycode==27||key=="x"||key=="o"||key=="c")this.end();else if(key=="p"||key=="%")this.showPrev();else if(key=="n"||key=="'")this.showNext();else if(key=="f")this.showFirst();else if(key=="l")this.showLast();else key=="s"&&this.hasImage()&&this.options.enableSlideshow&&this.toggleSlideShow()},preloadNeighborImages:function(){var a=this.imageArray.length-1==this.activeImage?0:this.activeImage+1;nextImage=new Image;nextImage.src=
this.imageArray[a].link;a=this.activeImage==0?this.imageArray.length-1:this.activeImage-1;prevImage=new Image;prevImage.src=this.imageArray[a].link},end:function(){this.disableKeyboardNav();this.pauseSlideShow();this.get("lightbox").hide();this.get("overlay").fadeOut(this.overlayDuration);this.showBadObjects()},showBadObjects:function(a){d(this.badObjects.join(",")).css("visibility",(typeof a=="undefined"?true:!!a)?"visible":"hidden")},hideBadObjects:function(){this.showBadObjects(false)},addPrefix:function(a){return this.prefix+
"_"+a},getID:function(a){return this.addPrefix(a)},getSel:function(a){var b="#";if(a.toString().indexOf(",")!=-1){a=a.toString().split(",");for(b=0;b<a.length;b++)a[b]=this.getSel(d.trim(a[b]));a=a.join(",")}else{if(a in this.options.placeholders)d(this.options.placeholders[a]).attr("id")||(b=".");a=b+this.getID(a)}return a},get:function(a){return d(this.getSel(a))},fileExists:function(a,b,c,g){if(!this.options.validateLinks)return b(g);var h=this,j=function(i){if(i.status<400)d.isFunction(b)&&b(g);
else d.isFunction(c)&&c(g)};if(a in this.checkedUrls)j(this.checkedUrls[a]);else{var f=new XMLHttpRequest;f.open("HEAD",a,true);f.onreadystatechange=function(){if(4==this.readyState){h.addUrl(a,this);j(this)}};f.send()}},addUrl:function(a,b){a in this.checkedUrls||(this.checkedUrls[a]=b)}}})(jQuery);

View File

@ -0,0 +1,42 @@
<?php
/*
Plugin Name: Simple Lightbox
Plugin URI: http://archetyped.com/lab/slb-1-5-5-beta/
Description: Customizable Lightbox for Wordpress
Version: 1.5.5b5 (BETA TESTING)
Author: Archetyped
Author URI: http://archetyped.com
*/
/*
Copyright 2010 Solomon Marchessault (contact@archetyped.com)
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.
*/
require_once 'model.php';
$slb =& new SLB_Lightbox();
function slb_enabled() {
global $slb;
return $slb->is_enabled();
}
function slb_register_theme($name, $title, $stylesheet_url, $layout) {
global $slb;
$slb->register_theme($name, $title, $stylesheet_url, $layout);
}
?>

View File

@ -0,0 +1,633 @@
<?php
require_once 'includes/class.base.php';
require_once 'includes/class.fields.php';
require_once 'includes/class.options.php';
/**
* Lightbox functionality class
* @package Simple Lightbox
* @author Archetyped
*/
class SLB_Lightbox extends SLB_Base {
/*-** Properties **-*/
/**
* Themes
* @var array
*/
var $themes = array();
var $theme_default = 'default';
/**
* Page that plugin options are on
* @var string
*/
var $options_admin_page = 'options-media.php';
/**
* Page that processes options
* @var string
*/
var $options_admin_form = 'options.php';
/**
* Options Configuration
* @var array
*/
var $options_config = array (
'groups' => array (
'activation' => 'Activation',
'grouping' => 'Grouping',
'ui' => 'UI',
'labels' => 'Labels'
),
'items' => array (
'enabled' => array('title' => 'Enable Lightbox Functionality', 'default' => true, 'group' => 'activation'),
'enabled_home' => array('title' => 'Enable on Home page', 'default' => true, 'group' => 'activation'),
'enabled_post' => array('title' => 'Enable on Posts', 'default' => true, 'group' => 'activation'),
'enabled_page' => array('title' => 'Enable on Pages', 'default' => true, 'group' => 'activation'),
'enabled_archive' => array('title' => 'Enable on Archive Pages (tags, categories, etc.)', 'default' => true, 'group' => 'activation'),
'activate_links' => array('title' => 'Activate all image links in item content', 'default' => true, 'group' => 'activation'),
'activate_attachments' => array('title' => 'Activate all image attachment links', 'default' => true, 'group' => 'activation'),
'validate_links' => array('title' => 'Validate links', 'default' => false, 'group' => 'activation'),
'group_links' => array('title' => 'Group automatically activated links (for displaying as a slideshow)', 'default' => true, 'group' => 'grouping'),
'group_post' => array('title' => 'Group image links by Post (e.g. on pages with multiple posts)', 'default' => true, 'group' => 'grouping'),
'theme' => array('title' => 'Theme', 'default' => 'default', 'group' => 'ui', 'parent' => 'option_theme'),
'animate' => array('title' => 'Animate lightbox resizing', 'default' => true, 'group' => 'ui'),
'autostart' => array('title' => 'Automatically Start Slideshow', 'default' => true, 'group' => 'ui'),
'duration' => array('title' => 'Slide Duration (Seconds)', 'default' => '6', 'attr' => array('size' => 3, 'maxlength' => 3), 'group' => 'ui'),
'loop' => array('title' => 'Loop through images', 'default' => true, 'group' => 'ui'),
'overlay_opacity' => array('title' => 'Overlay Opacity (0 - 1)', 'default' => '0.8', 'attr' => array('size' => 3, 'maxlength' => 3), 'group' => 'ui'),
'enabled_caption' => array('title' => 'Enable caption', 'default' => true, 'group' => 'ui'),
'caption_src' => array('title' => 'Use image URI as caption when link title not set', 'default' => true, 'group' => 'ui'),
'txt_closeLink' => array('title' => 'Close link (for accessibility only, image used for button)', 'default' => 'close', 'group' => 'labels'),
'txt_loadingMsg' => array('title' => 'Loading indicator', 'default' => 'loading', 'group' => 'labels'),
'txt_nextLink' => array('title' => 'Next Image link', 'default' => 'next &raquo;', 'group' => 'labels'),
'txt_prevLink' => array('title' => 'Previous Image link', 'default' => '&laquo; prev', 'group' => 'labels'),
'txt_startSlideshow' => array('title' => 'Start Slideshow link', 'default' => 'start slideshow', 'group' => 'labels'),
'txt_stopSlideshow' => array('title' => 'Stop Slideshow link', 'default' => 'stop slideshow', 'group' => 'labels'),
'txt_numDisplayPrefix' => array('title' => 'Image number prefix (e.g. <strong>Image</strong> x of y)', 'default' => 'Image', 'group' => 'labels'),
'txt_numDisplaySeparator' => array('title' => 'Image number separator (e.g. Image x <strong>of</strong> y)', 'default' => 'of', 'group' => 'labels')
),
'legacy' => array (
'header_activation',
'header_enabled',
'header_strings',
'header_ui',
'enabled_single'
)
);
/* Instance members */
/**
* Options instance
* @var SLB_Options
*/
var $options = null;
/**
* Fields
* @var SLB_Fields
*/
var $fields = null;
/*-** Init **-*/
function SLB_Lightbox() {
$this->__construct();
}
function __construct() {
parent::__construct();
$this->init();
//Setup options
$opt_theme =& $this->options_config['items']['theme'];
$opt_theme['default'] = $this->theme_default = $this->add_prefix($this->theme_default);
$opt_theme['options'] = $this->m('get_theme_options');
//Init objects
$this->fields =& new SLB_Fields();
$this->options =& new SLB_Options('options', $this->options_config);
}
function register_hooks() {
parent::register_hooks();
/* Admin */
//Init lightbox admin
add_action('admin_init', $this->m('admin_settings'));
//Enqueue header files (CSS/JS)
add_action('admin_enqueue_scripts', $this->m('admin_enqueue_files'));
//Reset Settings
add_action('admin_action_' . $this->add_prefix('reset'), $this->m('admin_reset'));
add_action('admin_notices', $this->m('admin_notices'));
//Plugin listing
add_filter('plugin_action_links_' . $this->util->get_plugin_base_name(), $this->m('admin_plugin_action_links'), 10, 4);
/* Client-side */
//Init lightbox
add_action('wp_enqueue_scripts', $this->m('enqueue_files'));
add_action('wp_head', $this->m('client_init'));
add_filter('the_content', $this->m('activate_post_links'), 99);
/* Themes */
$this->util->add_action('init_themes', $this->m('init_default_themes'));
}
function activate() {
//Set default options (if not yet set)
$this->options->reset(false);
$this->options->migrate();
}
/*-** Helpers **-*/
/**
* Checks whether lightbox is currently enabled/disabled
* @return bool TRUE if lightbox is currently enabled, FALSE otherwise
*/
function is_enabled($check_request = true) {
$ret = ( $this->options->get_value('enabled') ) ? true : false;
if ( $ret && $check_request ) {
$opt = '';
//Determine option to check
if ( is_home() )
$opt = 'home';
elseif ( is_singular() ) {
$opt = ( is_page() ) ? 'page' : 'post';
}
elseif ( is_archive() || is_search() )
$opt = 'archive';
//Check option
if ( !empty($opt) && ( $opt = 'enabled_' . $opt ) && $this->options->has($opt) ) {
$ret = ( $this->options->get_value($opt) ) ? true : false;
}
}
return $ret;
}
/*-** Theme **-*/
/**
* Retrieve themes
* @uses do_action() Calls 'slb_init_themes' hook to allow plugins to register themes
* @uses $themes to return registered themes
* @return array Retrieved themes
*/
function get_themes() {
static $fetched = false;
if ( !$fetched ) {
$this->themes = array();
$this->util->do_action('init_themes');
$fetched = true;
}
return $this->themes;
}
/**
* Retrieve theme
* @param string $name Name of theme to retrieve
* @uses theme_exists() to check for existence of theme
* @return array Theme data
*/
function get_theme($name = '') {
$name = strval($name);
//Default: Get current theme if no theme specified
if ( empty($name) ) {
$name = $this->options->get_value('theme');
}
if ( !$this->theme_exists($name) )
$name = $this->theme_default;
return $this->themes[$name];
}
/**
* Retrieve specific of theme data
* @uses get_theme() to retrieve theme data
* @param string $name Theme name
* @param string $field Theme field to retrieve
* @return mixed Field data
*/
function get_theme_data($name = '', $field) {
$theme = $this->get_theme($name);
return ( isset($theme[$field]) ) ? $theme[$field] : '';
}
/**
* Retrieve theme stylesheet URL
* @param string $name Theme name
* @uses get_theme_data() to retrieve theme data
* @return string Stylesheet URL
*/
function get_theme_style($name = '') {
return $this->get_theme_data($name, 'stylesheet_url');
}
/**
* Retrieve theme layout
* @uses get_theme_data() to retrieve theme data
* @param string $name Theme name
* @param bool $filter (optional) Filter layout based on user preferences
* @return string Theme layout HTML
*/
function get_theme_layout($name = '', $filter = true) {
$l = $this->get_theme_data($name, 'layout');
//Filter
if ( !$this->options->get_value('enabled_caption') )
$l = str_replace($this->get_theme_placeholder('dataCaption'), '', $l);
return $l;
}
/**
* Check whether a theme exists
* @param string $name Theme to look for
* @uses get_themes() to intialize themes if not already performed
* @return bool TRUE if theme exists, FALSE otherwise
*/
function theme_exists($name) {
$this->get_themes();
return ( isset($this->themes[trim(strval($name))]) );
}
/**
* Register lightbox theme
* @param string $name Unique theme name
* @param string $title Display name for theme
* @param string $stylesheet_url URL to stylesheet
* @param string $layout Layout HTML
* @uses $themes to store the registered theme
*/
function register_theme($name, $title, $stylesheet_url, $layout) {
if ( !is_array($this->themes) ) {
$this->themes = array();
}
//Validate parameters
$name = trim(strval($name));
$title = trim(strval($title));
$stylesheet_url = trim(strval($stylesheet_url));
$layout = $this->format_theme_layout($layout);
$defaults = array(
'name' => '',
'title' => '',
'stylesheet_url' => '',
'layout' => ''
);
//Add theme to array
$this->themes[$name] = wp_parse_args(compact(array_keys($defaults), $defaults));
}
/**
* Build theme placeholder
* @param string $name Placeholder name
* @return string Placeholder
*/
function get_theme_placeholder($name) {
return '{' . $name . '}';
}
/**
* Formats layout for usage in JS
* @param string $layout Layout to format
* @return string Formatted layout
*/
function format_theme_layout($layout = '') {
//Remove line breaks
$layout = str_replace(array("\r\n", "\n", "\r", "\t"), '', $layout);
//Escape quotes
$layout = str_replace("'", "\'", $layout);
//Return
return "'" . $layout . "'";
}
/**
* Add default themes
* @uses register_theme() to register the theme(s)
*/
function init_default_themes() {
$name = $this->theme_default;
$title = 'Default';
$stylesheet_url = $this->util->get_file_url('css/lightbox.css');
$layout = file_get_contents($this->util->normalize_path($this->util->get_path_base(), 'templates', 'default', 'layout.html'));
$this->register_theme($name, $title, $stylesheet_url, $layout);
//Testing: Additional themes
$this->register_theme('black', 'Black', $this->util->get_file_url('css/lb_black.css'), $layout);
}
/*-** Frontend **-*/
/**
* Scans post content for image links and activates them
*
* Lightbox will not be activated for feeds
* @param $content
*/
function activate_post_links($content) {
//Check option
if ( ! is_feed() && $this->is_enabled() && $this->options->get_value('activate_links') ) {
$links = array();
//Get all links on page
$rgx = "/\<a[^\>]+href=.*?\>/i";
preg_match_all($rgx, $content, $links);
$links = $links[0];
$domain = str_replace(array('http://', 'https://'), '', get_bloginfo('url'));
//Process links
if ( count($links) > 0 ) {
global $post;
$types = (object) array('img' => 'image', 'att' => 'attachment');
$img_types = array('jpg', 'jpeg', 'gif', 'png');
$rgx = "/\b(\w+.*?)=([\"'])(.*?)\\2(?:\s|$)/i";
//Iterate through links & add lightbox if necessary
foreach ( $links as $link ) {
//Check if rel attribute exists
$link_new = $link;
//Parse link
$link_attr = substr($link_new, 2, strlen($link_new) - 3);
$attr_matches = $attr = array();
preg_match_all($rgx, $link_attr, $attr_matches);
foreach ( $attr_matches[1] as $key => $val ) {
if ( isset($attr_matches[3][$key]) )
$attr[trim($val)] = trim($attr_matches[3][$key]);
}
//Destroy parsing vars
unset($link_attr, $attr_matches);
//Set default attributes
$attr = array_merge(array('rel' => '', 'href' => ''), $attr);
$h =& $attr['href'];
$r =& $attr['rel'];
//Stop processing link if lightbox attribute has already been set
$lb = 'lightbox';
if ( empty($h) || '#' == $h || ( !empty($r) && ( strpos($r, $lb) !== false || strpos($r, $this->add_prefix('off')) !== false ) ) )
continue;
//Determine link type
$type = false;
if ( in_array($this->util->get_file_extension($h), $img_types) )
$type = $types->img;
elseif ( strpos($h, $domain) !== false && is_local_attachment($h) && ( $pid = url_to_postid($h) ) && wp_attachment_is_image($pid) )
$type = $types->att;
if ( !$type ) {
continue;
}
if ( $type == $types->att && !$this->options->get_value('activate_attachments') )
continue;
//Process link
if ( empty($r) )
$r = array();
else
$r = array($r);
//Check if links should be grouped
if ( $this->options->get_value('group_links') ) {
$group = ( $this->options->get_value('group_post') ) ? $this->add_prefix($post->ID) : $this->get_prefix();
$lb .= '[' . $group . ']';
}
$r[] = $lb;
//Type specific processing
switch ($type) {
case $types->att:
//Get attachment URL
$src = wp_get_attachment_url($pid);
if ( !empty($src) )
$r[] = $this->add_prefix('src[' . $src . ']');
break;
}
//Convert rel attribute to string
$r = implode(' ', $r);
$link_new = '<a ' . $this->util->build_attribute_string($attr) . '>';
//Insert modified link
$content = str_replace($link, $link_new, $content);
unset($h, $r);
}
}
}
return $content;
}
/**
* Enqueue files in template head
*/
function enqueue_files() {
if ( ! $this->is_enabled() )
return;
wp_enqueue_script($this->add_prefix('lib'), $this->util->get_file_url('js/lib.js'), array('jquery'), $this->util->get_plugin_version());
wp_enqueue_style($this->add_prefix('style'), $this->get_theme_style(), array(), $this->util->get_plugin_version());
}
/**
* Sets options/settings to initialize lightbox functionality on page load
* @return void
*/
function client_init() {
if ( ! $this->is_enabled() )
return;
$options = array();
$out = array();
$out['script_start'] = '<script type="text/javascript">/* <![CDATA[ */(function($){$(document).ready(function(){';
$out['script_end'] = '})})(jQuery);/* ]]> */</script>';
$js_code = array();
//Get options
$options = array(
'validateLinks' => $this->options->get_value('validate_links'),
'autoPlay' => $this->options->get_value('autostart'),
'slideTime' => $this->options->get_value('duration'),
'loop' => $this->options->get_value('loop'),
'overlayOpacity' => $this->options->get_value('overlay_opacity'),
'animate' => $this->options->get_value('animate'),
'captionEnabled' => $this->options->get_value('enabled_caption'),
'captionSrc' => $this->options->get_value('caption_src'),
'layout' => $this->get_theme_layout(),
'altsrc' => $this->add_prefix('src')
);
$lb_obj = array();
foreach ($options as $option => $val) {
if ( is_bool($val) )
$val = ( $val ) ? 'true' : 'false';
elseif ( is_string($val) && "'" != $val[0] )
$val = "'" . $val . "'";
$lb_obj[] = "'{$option}':{$val}";
}
//Load UI Strings
if ( ($strings = $this->build_strings()) && !empty($strings) )
$lb_obj[] = $strings;
$js_code[] = 'SLB.initialize({' . implode(',', $lb_obj) . '});';
echo $out['script_start'] . implode('', $js_code) . $out['script_end'];
}
/**
* Build JS object of UI strings when initializing lightbox
* @return string JS object of UI strings
*/
function build_strings() {
$ret = '';
$prefix = 'txt_';
$opt_strings = array_filter(array_keys($this->options->get_items()), create_function('$opt', 'return ( strpos($opt, "' . $prefix . '") === 0 );'));
if ( $opt_strings ) {
$strings = array();
foreach ( $opt_strings as $key ) {
$name = substr($key, strlen($prefix));
$strings[] = "'" . $name . "':'" . $this->options->get_value($key) . "'";
}
$ret = "'strings':{" . implode(',', $strings) . "}";
}
return $ret;
}
/*-** Admin **-*/
/**
* Adds custom links below plugin on plugin listing page
* @param $actions
* @param $plugin_file
* @param $plugin_data
* @param $context
*/
function admin_plugin_action_links($actions, $plugin_file, $plugin_data, $context) {
//Add link to settings (only if active)
if ( is_plugin_active($this->util->get_plugin_base_name()) ) {
$settings = __('Settings');
$reset = __('Reset');
$reset_confirm = "'" . __('Are you sure you want to reset your settings?') . "'";
$action = $this->add_prefix('reset');
$reset_link = wp_nonce_url(add_query_arg('action', $action, remove_query_arg(array($this->add_prefix('action'), 'action'), $_SERVER['REQUEST_URI'])), $action);
array_unshift($actions, '<a class="delete" href="options-media.php#' . $this->admin_get_settings_section() . '" title="' . $settings . '">' . $settings . '</a>');
array_splice($actions, 1, 0, '<a id="' . $this->add_prefix('reset') . '" href="' . $reset_link . '" onclick="return confirm(' . $reset_confirm . ');" title="' . $reset . '">' . $reset . '</a>');
}
return $actions;
}
/**
* Reset plugin settings
* Redirects to referring page upon completion
*/
function admin_reset() {
//Validate user
if ( ! current_user_can('activate_plugins') || ! check_admin_referer($this->add_prefix('reset')) )
wp_die(__('You do not have sufficient permissions to manage plugins for this blog.'));
$action = 'reset';
if ( isset($_REQUEST['action']) && $this->add_prefix($action) == $_REQUEST['action'] ) {
//Reset settings
$this->options->reset(true);
$uri = remove_query_arg(array('_wpnonce', 'action'), add_query_arg(array($this->add_prefix('action') => $action), $_SERVER['REQUEST_URI']));
//Redirect user
wp_redirect($uri);
exit;
}
}
/**
* Displays notices for admin operations
*/
function admin_notices() {
if ( is_admin() && isset($_REQUEST[$this->add_prefix('action')]) ) {
$action = $_REQUEST[$this->add_prefix('action')];
$msg = null;
if ( $action ) {
switch ( $action ) {
case 'reset':
$msg = "Simple Lightbox's settings have been <strong>reset</strong>";
break;
}
if ( ! is_null($msg) ) {
?>
<div id="message" class="updated fade"><p><?php _e($msg); ?></p></div>
<?php
}
}
}
}
/**
* Adds settings section for Lightbox functionality
* Section is added to Settings > Media Admin menu
* @todo Move appropriate code to options class
*/
function admin_settings() {
$page = $this->options_admin_page;
$form = $this->options_admin_form;
$curr = basename($_SERVER['SCRIPT_NAME']);
if ( $curr != $page && $curr != $form ) {
return;
}
$page = 'media';
$section = $this->get_prefix();
//Section
add_settings_section($section, '<span id="' . $this->admin_get_settings_section() . '">' . __('Lightbox Settings') . '</span>', $this->m('admin_section'), $page);
//Register settings container
register_setting($page, $this->add_prefix('options'), $this->options->m('validate'));
}
/**
* Enqueues header files for admin pages
* @todo Separate and move options CSS to options class
*/
function admin_enqueue_files() {
//Enqueue custom CSS for options page
if ( is_admin() && basename($_SERVER['SCRIPT_NAME']) == $this->options_admin_page ) {
wp_enqueue_style($this->add_prefix('admin'), $this->util->get_file_url('css/admin.css'), array(), $this->util->get_plugin_version());
}
}
/**
* Get ID of settings section on admin page
* @return string ID of settings section
* @todo Eval for moving to options class
*/
function admin_get_settings_section() {
return $this->add_prefix('settings');
}
/**
* Placeholder function for lightbox admin settings
* Required because setting init function requires a callback
* @todo Evaluate for moving to options class
*/
function admin_section() {
$this->options->build();
}
/* Custom fields */
function get_theme_options() {
//Get themes
$themes = $this->get_themes();
//Pop out default theme
$theme_default = $themes[$this->theme_default];
unset($themes[$this->theme_default]);
//Sort themes by title
uasort($themes, create_function('$a,$b', 'return strcmp($a[\'title\'], $b[\'title\']);'));
//Insert default theme at top of array
$themes = array($this->theme_default => $theme_default) + $themes;
//Build options
foreach ( $themes as $name => $props ) {
$themes[$name] = $props['title'];
}
return $themes;
}
}
?>

View File

@ -0,0 +1,150 @@
=== Plugin Name ===
Contributors: Archetyped
Donate link: http://archetyped.com/tools/simple-lightbox/#donate
Tags: lightbox, gallery, photography, images, theme, template, style
Requires at least: 3.1.2
Tested up to: 3.2
Stable tag: trunk
A simple, themeable, and customizable Lightbox for Wordpress
== Description ==
Simple Lightbox is a very simple and customizable lightbox that is easy to add to your Wordpress website. It also [supports themes](http://archetyped.com/lab/slb-registering-themes/), so it can be fully integrated with your site's theme.
### BETA NOTES
The current release is a beta version. Please test and [provide feedback on the beta release page](http://archetyped.com/lab/slb-1-5-5-beta/).
Main changes
#### Beta 5
* Update: Additional WordPress 3.2 support (Gallery)
* Fix: Improved options migration from old versions (Hutchison Migration)
#### Beta 4
* Add: Support for WordPress 3.2
* Add: Support for links added after page load (e.g. via AJAX, etc.)
* Add: Admin option to enable/disable attachment links
* Optimize: Improved compatibility for older versions of PHP
#### Beta 3
* Add: Support for image attachment links
* Optimize: Improved compatibility for older versions of PHP
* Optimize: Internal optimizations
#### Beta 2
* Fix: Debug code removed (Fatal Seb)
* Update: Improved URL handling
* Update: Cache-management for enqueued files
#### Beta 1
* Update: Options management overhaul
* Fix: XHTML Validation (Hajo Validation)
#### Customization
Options for customizing the lightbox behavior are located in the **Settings > Media** admin menu in the **Lightbox Settings** section (or just click the **Settings** link below the plugin's name when viewing the list of installed plugins)
* **New: Link Validation** (Optional)
* **New: Keyboard Navigation**
* **New: Show/Hide Lightbox Caption**
* Theme Support
* Customizable UI Text
* Enable/Disable Lightbox Functionality (Default: Enabled)
* Enable Lightbox depending on Page Type (Home, Pages, Archive, etc.)
* Automatically activate lightbox for links to images on page (no need to add `rel="lightbox"` attribute to link)
* Group automatically-activated links (play as a slideshow)
* Group image links by Post (separate slideshow for each Post on page)
* Enable/Disable Lightbox resizing animation
* Automatically Start Slideshow (Default: Enabled)
* Slide Duration (Seconds) (Default: 6)
* Loop through images (Default: Enabled)
* Overlay Opacity (0 - 1) (Default: 0.8)
#### Usage
* The necessary Javascript and CSS files will be automatically added to the page as long as `wp_head()` is called in the theme
* That's it!
== Installation ==
1. Verify that your theme uses the `wp_head()` template tag (this is where the necessary files will be added to your theme output)
1. Let plugin automatically add lightbox functionality for links to images or manually add `rel="lightbox"` to any image links that you want to be displayed in a lightbox
== Upgrade Notice ==
No upgrade notices
== Frequently Asked Questions ==
Post your questions and comments on [Simple Lightbox's beta release page](http://archetyped.com/lab/slb-1-5-5-beta/)
== Screenshots ==
1. Lightbox Customization Options
2. Customized UI Text
== Changelog ==
= 1.5.4 =
* Add: Optional Link validation
* Add: Keyboard Navigation
* Add: Option to enable/disable image caption
* Add: `rel` attribute supported again
* Add: Use `slb_off` in link's `rel` attribute to disable automatic activation for link
* Fix: HTTPS compatibility (J&uuml;rgen Protocol)
* Fix: Enabling SLB on Pages issue
* Fix: Zmanu is_single
* Fix: Image order is sometimes incorrect
* Optimize: Filter double clicks
* Optimize: Separate options to enable/disable SLB on Posts and Pages
* Optimize: Better grouping support
= 1.5.3 =
* Fix: Caption may not display under certain circumstances (Caption Erin)
* Fix: Images not grouped when "separate by post" option is activated (Logical Ross)
* Update: Lightbox will not be activated for links that already have `rel` attribute set
= 1.5.2 =
* Fix: Slideshow loops out of control (Mirage of Wallentin)
* Fix: Lightbox fails when group by posts disabled (Lange Find)
* Add: Option to use the image's URI as caption when link title not set (Under UI options)
= 1.5.1 =
* Add: WP Gallery support
* Fix: Navigation hidden when only one image
* Fix: Use user-defined UI text
= 1.5 =
* Add: Theme support
* Optimize: Javascript cleanup and file size reductions
* Optimize: CSS cleanup
= 1.4 =
* Update: Integrated with jQuery
* Optimize: Javascript filesize 9x smaller
* Add: Close lightbox by clicking to left/right outside of image (an oft-requested feature)
= 1.3.2 =
* Add: Option to enable/disable lightbox resizing animation (thanks Maria!)
= 1.3.1 =
* Update: Utilities code (internal)
= 1.3 =
* Add: Customizable UI label text (close, next, and prev button images can be replaced in `images` directory)
* Add: Group image links by Post (separate slideshow for each post)
* Add: Reset settings link on plugin listings page
* Optimize: Organized settings page
= 1.2.1 =
* Fixed: Image title given higher precedence than Image alt (more compatible w/WP workflow)
= 1.2 =
* Added: Option to group automatically activated links
* Optimized: Lightbox caption retrieval
= 1.1 =
* Added: Enable/disable lightbox functionality by page type (Home, Pages/Posts, Archive, etc.)
* Added: Automatically activate lightbox functionality for image links
* Added: Link to settings menu on plugin listing page
* Optimized: Options menu field building
* Optimized: Loading of default values for plugin options
* Optimized: General code optimizations
= 1.0 =
* Initial release

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -0,0 +1,28 @@
<div id="slb_container">
<div id="imageContainer">
{slbContent}
<div id="nav_hover">
{navPrev}
{navNext}
</div>
<div id="loading">
{slbLoading}
</div>
</div>
</div>
<div id="slb_details" class="clearfix">
<div id="imageData">
<div id="imageDetails">
{dataCaption}
{dataNumber}
<span id="slb_nav">
{navPrev}
{navNext}
{navSlideControl}
</span>
</div>
<div id="close">
{slbClose}
</div>
</div>
</div>