FINAL suepr merge step : added all modules to this super repos

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-19 16:46:59 +02:00
7585 changed files with 1723356 additions and 18 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,159 @@
Drupal colorbox module:
------------------------
Maintainers:
Fredrik Jonsson (http://drupal.org/user/5546)
Requires - Drupal 7
License - GPL (see LICENSE)
Overview:
--------
Colorbox is a light-weight, customizable lightbox plugin for jQuery 1.4.3+.
This module allows for integration of Colorbox into Drupal.
The jQuery library is a part of Drupal since version 5+.
Images, iframed or inline content etc. can be displayed in a
overlay above the current page.
* jQuery - http://jquery.com/
* Colorbox - http://www.jacklmoore.com/colorbox/
Features:
---------
The Colorbox module:
* Excellent integration with Image field and Image styles
* Choose between a default style and 5 example styles that are included.
* Style the Colorbox with a custom colorbox.css file in your theme.
* Drush command to download and install the Colorbox plugin in
sites/all/libraries
The Colorbox plugin:
* Supports images, image groups, slideshow, ajax, inline, and
iframed content.
* Appearance is controlled through CSS so users can restyle the box.
* Preloads background images and can preload upcoming images in a
photo group.
* Generates W3C valid XHTML and adds no JS global variables and
passes JSLint.
* Tested in Firefox 2 & 3, Safari 3 & 4, Opera 9, Chrome,
Internet Explorer 6, 7, 8.
* Released under the MIT License.
Installation:
------------
1. Download and unpack the Libraries module directory in your modules folder
(this will usually be "sites/all/modules/").
Link: http://drupal.org/project/libraries
2. Download and unpack the Colorbox module directory in your modules folder
(this will usually be "sites/all/modules/").
3. Download and unpack the Colorbox plugin in "sites/all/libraries".
Make sure the path to the plugin file becomes:
"sites/all/libraries/colorbox/jquery.colorbox-min.js"
Link: https://github.com/jackmoore/colorbox/archive/1.x.zip
Drush users can use the command "drush colorbox-plugin".
4. Go to "Administer" -> "Modules" and enable the Colorbox module.
Configuration:
-------------
Go to "Configuration" -> "Media" -> "Colorbox" to find
all the configuration options.
Use the Views Colorbox Trigger field:
------------------------------------
TODO
Add a custom Colorbox style to your theme:
----------------------------------------
The easiest way is to start with either the default style or one of the
example styles included in the Colorbox JS library download. Simply copy the entire
style folder to your theme and rename it to something logical like "mycolorbox".
Inside that folder are both a .css and .js file, rename both of those as well to match
your folder name: i.e. "colorbox_mycolorbox.css" and "colorbox_mycolorbox.js"
Add entries in your theme's .info file for the Colorbox CSS/JS files:
stylesheets[all][] = mycolorbox/colorbox_mycolorbox.css
scripts[] = mycolorbox/colorbox_mycolorbox.js
Go to "Configuration" -> "Media" -> "Colorbox" and select "None" under
"Styles and Options". This will leave the styling of Colorbox up to your theme.
Make any CSS adjustments to your "colorbox_mycolorbox.css" file.
Load images from custom links in a Colorbox:
--------------------------------------------
Add the class "colorbox" to the link and point the src to the image
you want to display in the Colorbox.
Load content in a Colorbox:
---------------------------
Check the "Enable Colorbox load" option in Colorbox settings.
This enables custom links that can open content in a Colorbox.
Add the class "colorbox-load" to the link and build the url like
this "[path]?width=500&height=500&iframe=true"
or "[path]?width=500&height=500" if you don't want an iframe.
Other modules may activate this for easy Colorbox integration.
Load inline content in a Colorbox:
----------------------------------
Check the "Enable Colorbox inline" option in Colorbox settings.
This enables custom links that can open inline content in a Colorbox.
Inline in this context means some part/tag of the current page, e.g. a div.
Replace "id-of-content" with the id of the tag you want to open.
Add the class "colorbox-inline" to the link and build the url like
this "?width=500&height=500&inline=true#id-of-content".
It could e.g. look like this.
<a class="colorbox-inline" href="?width=500&height=500&inline=true#id-of-content">Link to click</a>
<div style="display: none;">
<div id="id-of-content">What ever content you want to display in a Colorbox.</div>
</div>
Other modules may activate this for easy Colorbox integration.
Drush:
------
A Drush command is provides for easy installation of the Colorbox
plugin itself.
% drush colorbox-plugin
The command will download the plugin and unpack it in "sites/all/libraries".
It is possible to add another path as an option to the command, but not
recommended unless you know what you are doing.
Image in Colorbox not displayed in Internet Explorer 8:
-------------------------------------------------------
If your theme has CSS like this (popular in responsive design):
img {
max-width: 100%;
}
Internet Explorer 8 will have problems with showing images in the Colorbox.
The fix is to add this to the theme CSS:
#cboxLoadedContent img {
max-width: none;
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* @file
* Template file for Colorbox content inserted via the Insert module.
*
* Available variables:
* - $item: The complete item being inserted.
* - $image_path: The URL to the image.
* - $link_path: The URL to the image that Colorbox should open.
* - $class: A set of classes assigned to this image (if any).
* - $gallery_id: The ID of the Colorbox gallery.
*
* Note that ALT and Title fields should not be filled in here, instead they
* should use placeholders that will be updated through JavaScript when the
* image is inserted.
*
* Available placeholders:
* - __alt__: The ALT text, intended for use in the <img> tag.
* - __title__: The Title text, intended for use in the <img> tag.
* - __description__: A description of the image, sometimes used as a caption.
*/
?>
<a href="<?php print $link_path; ?>" title="__title__" class="colorbox colorbox-insert-image" rel="<?php print $gallery_id; ?>"><img typeof="foaf:Image" src="<?php print $image_path; ?>" alt="__alt__" title="__title__" class="<?php print $class; ?>" /></a>

View File

@@ -0,0 +1,294 @@
<?php
/**
* @file
* Administrative page callbacks for the colorbox module.
*/
/**
* General configuration form for controlling the colorbox behaviour.
*/
function colorbox_admin_settings() {
drupal_add_js(drupal_get_path('module', 'colorbox') . '/js/colorbox_admin_settings.js', array('preprocess' => FALSE));
$library = libraries_detect('colorbox');
if (module_exists('insert')) {
$form['colorbox_insert_module'] = array(
'#type' => 'fieldset',
'#title' => t('Insert module settings'),
);
$image_styles = image_style_options(FALSE);
$form['colorbox_insert_module']['colorbox_image_style'] = array(
'#type' => 'select',
'#title' => t('Image style'),
'#empty_option' => t('None (original image)'),
'#options' => $image_styles,
'#default_value' => variable_get('colorbox_image_style', ''),
'#description' => t('Select which image style to use for viewing images in the colorbox.'),
);
$form['colorbox_insert_module']['colorbox_insert_gallery'] = array(
'#type' => 'radios',
'#title' => t('Insert image gallery'),
'#default_value' => variable_get('colorbox_insert_gallery', 0),
'#options' => array(0 => t('Per page gallery'), 3 => t('No gallery')),
'#description' => t('Should the gallery be all images on the page (default) or disabled.'),
);
}
$form['colorbox_extra_features'] = array(
'#type' => 'fieldset',
'#title' => t('Extra features'),
);
$form['colorbox_extra_features']['colorbox_load'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Colorbox load'),
'#default_value' => variable_get('colorbox_load', 0),
'#description' => t('This enables custom links that can open forms and paths in a Colorbox. Add the class "colorbox-load" to the link and build the url like this for paths "[path]?width=500&height=500&iframe=true" or "[path]?width=500&height=500" if you don\'t want an iframe. Other modules may activate this for easy Colorbox integration.'),
);
$form['colorbox_extra_features']['colorbox_inline'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Colorbox inline'),
'#default_value' => variable_get('colorbox_inline', 0),
'#description' => t('This enables custom links that can open inline content in a Colorbox. Add the class "colorbox-inline" to the link and build the url like this "?width=500&height=500&inline=true#id-of-content". Other modules may activate this for easy Colorbox integration.'),
);
$form['colorbox_custom_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Styles and options'),
);
$colorbox_styles = array(
'default' => t('Default'),
'plain' => t('Plain (mainly for images)'),
'stockholmsyndrome' => t('Stockholm Syndrome'),
$library['library path'] . '/example1' => t('Example 1'),
$library['library path'] . '/example2' => t('Example 2'),
$library['library path'] . '/example3' => t('Example 3'),
$library['library path'] . '/example4' => t('Example 4'),
$library['library path'] . '/example5' => t('Example 5'),
'none' => t('None'),
);
$form['colorbox_custom_settings']['colorbox_style'] = array(
'#type' => 'select',
'#title' => t('Style'),
'#options' => $colorbox_styles,
'#default_value' => variable_get('colorbox_style', 'default'),
'#description' => t('Select the style to use for the Colorbox. The example styles are the ones that come with the Colorbox plugin. Select "None" if you have added Colorbox styles to your theme.'),
);
$form['colorbox_custom_settings']['colorbox_custom_settings_activate'] = array(
'#type' => 'radios',
'#title' => t('Options'),
'#options' => array(0 => t('Default'), 1 => t('Custom')),
'#default_value' => variable_get('colorbox_custom_settings_activate', 0),
'#description' => t('Use the default or custom options for Colorbox.'),
'#prefix' => '<div class="colorbox-custom-settings-activate">',
'#suffix' => '</div>',
);
$js_hide = variable_get('colorbox_custom_settings_activate', 0) ? '' : ' js-hide';
$form['colorbox_custom_settings']['wrapper_start'] = array(
'#markup' => '<div class="colorbox-custom-settings' . $js_hide . '">',
);
$form['colorbox_custom_settings']['colorbox_transition_type'] = array(
'#type' => 'radios',
'#title' => t('Transition type'),
'#options' => array('elastic' => t('Elastic'), 'fade' => t('Fade'), 'none' => t('None')),
'#default_value' => variable_get('colorbox_transition_type', 'elastic'),
'#description' => t('The transition type.'),
);
$form['colorbox_custom_settings']['colorbox_transition_speed'] = array(
'#type' => 'select',
'#title' => t('Transition speed'),
'#options' => drupal_map_assoc(array(100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600)),
'#default_value' => variable_get('colorbox_transition_speed', 350),
'#description' => t('Sets the speed of the fade and elastic transitions, in milliseconds.'),
);
$form['colorbox_custom_settings']['colorbox_opacity'] = array(
'#type' => 'select',
'#title' => t('Opacity'),
'#options' => drupal_map_assoc(array('0', '0.10', '0.15', '0.20', '0.25', '0.30', '0.35', '0.40', '0.45', '0.50', '0.55', '0.60', '0.65', '0.70', '0.75', '0.80', '0.85', '0.90', '0.95', '1')),
'#default_value' => variable_get('colorbox_opacity', '0.85'),
'#description' => t('The overlay opacity level. Range: 0 to 1.'),
);
$form['colorbox_custom_settings']['colorbox_text_current'] = array(
'#type' => 'textfield',
'#title' => t('Current'),
'#default_value' => variable_get('colorbox_text_current', '{current} of {total}'),
'#size' => 30,
'#description' => t('Text format for the content group / gallery count. {current} and {total} are detected and replaced with actual numbers while Colorbox runs.'),
);
$form['colorbox_custom_settings']['colorbox_text_previous'] = array(
'#type' => 'textfield',
'#title' => t('Previous'),
'#default_value' => variable_get('colorbox_text_previous', '« Prev'),
'#size' => 30,
'#description' => t('Text for the previous button in a shared relation group.'),
);
$form['colorbox_custom_settings']['colorbox_text_next'] = array(
'#type' => 'textfield',
'#title' => t('Next'),
'#default_value' => variable_get('colorbox_text_next', 'Next »'),
'#size' => 30,
'#description' => t('Text for the next button in a shared relation group.'),
);
$form['colorbox_custom_settings']['colorbox_text_close'] = array(
'#type' => 'textfield',
'#title' => t('Close'),
'#default_value' => variable_get('colorbox_text_close', 'Close'),
'#size' => 30,
'#description' => t('Text for the close button. The "Esc" key will also close Colorbox.'),
);
$form['colorbox_custom_settings']['colorbox_overlayclose'] = array(
'#type' => 'checkbox',
'#title' => t('Overlay close'),
'#default_value' => variable_get('colorbox_overlayclose', 1),
'#description' => t('Enable closing Colorbox by clicking on the background overlay.'),
);
$form['colorbox_custom_settings']['colorbox_maxwidth'] = array(
'#type' => 'textfield',
'#title' => t('Max width'),
'#default_value' => variable_get('colorbox_maxwidth', '98%'),
'#size' => 30,
'#description' => t('Set a maximum width for loaded content. Example: "100%", 500, "500px".'),
);
$form['colorbox_custom_settings']['colorbox_maxheight'] = array(
'#type' => 'textfield',
'#title' => t('Max height'),
'#default_value' => variable_get('colorbox_maxheight', '98%'),
'#size' => 30,
'#description' => t('Set a maximum height for loaded content. Example: "100%", 500, "500px".'),
);
$form['colorbox_custom_settings']['colorbox_initialwidth'] = array(
'#type' => 'textfield',
'#title' => t('Initial width'),
'#default_value' => variable_get('colorbox_initialwidth', '300'),
'#size' => 30,
'#description' => t('Set the initial width, prior to any content being loaded. Example: "100%", 500, "500px".'),
);
$form['colorbox_custom_settings']['colorbox_initialheight'] = array(
'#type' => 'textfield',
'#title' => t('Initial height'),
'#default_value' => variable_get('colorbox_initialheight', '250'),
'#size' => 30,
'#description' => t('Set the initial height, prior to any content being loaded. Example: "100%", 500, "500px".'),
);
$form['colorbox_custom_settings']['colorbox_fixed'] = array(
'#type' => 'checkbox',
'#title' => t('Fixed'),
'#default_value' => variable_get('colorbox_fixed', 1),
'#description' => t('If the Colorbox should be displayed in a fixed position within the visitor\'s viewport or relative to the document.'),
);
$form['colorbox_custom_settings']['colorbox_slideshow_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Slideshow settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshow'] = array(
'#type' => 'radios',
'#title' => t('Slideshow'),
'#options' => array(0 => t('Off'), 1 => t('On')),
'#default_value' => variable_get('colorbox_slideshow', 0),
'#description' => t('An automatic slideshow to a content group / gallery.'),
'#prefix' => '<div class="colorbox-slideshow-settings-activate">',
'#suffix' => '</div>',
);
$form['colorbox_custom_settings']['colorbox_scrolling'] = array(
'#type' => 'radios',
'#title' => t('Scrollbars'),
'#options' => array(0 => t('Off'), 1 => t('On')),
'#default_value' => variable_get('colorbox_scrolling', 1),
'#description' => t('If false, Colorbox will hide scrollbars for overflowing content. This could be used on conjunction with the resize method for a smoother transition if you are appending content to an already open instance of Colorbox.'),
);
$js_hide = variable_get('colorbox_slideshow', 0) ? '' : ' js-hide';
$form['colorbox_custom_settings']['colorbox_slideshow_settings']['wrapper_start'] = array(
'#markup' => '<div class="colorbox-slideshow-settings' . $js_hide . '">',
);
$form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshowauto'] = array(
'#type' => 'checkbox',
'#title' => t('Slideshow autostart'),
'#default_value' => variable_get('colorbox_slideshowauto', 1),
'#description' => t('If the slideshow should automatically start to play.'),
);
$form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshowspeed'] = array(
'#type' => 'select',
'#title' => t('Slideshow speed'),
'#options' => drupal_map_assoc(array(1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000)),
'#default_value' => variable_get('colorbox_slideshowspeed', 2500),
'#description' => t('Sets the speed of the slideshow, in milliseconds.'),
);
$form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_text_start'] = array(
'#type' => 'textfield',
'#title' => t('Start slideshow'),
'#default_value' => variable_get('colorbox_text_start', 'start slideshow'),
'#size' => 30,
'#description' => t('Text for the slideshow start button.'),
);
$form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_text_stop'] = array(
'#type' => 'textfield',
'#title' => t('Stop slideshow'),
'#default_value' => variable_get('colorbox_text_stop', 'stop slideshow'),
'#size' => 30,
'#description' => t('Text for the slideshow stop button.'),
);
$form['colorbox_custom_settings']['colorbox_slideshow_settings']['wrapper_stop'] = array(
'#markup' => '</div>',
);
$form['colorbox_custom_settings']['wrapper_stop'] = array(
'#markup' => '</div>',
);
$form['colorbox_advanced_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['colorbox_advanced_settings']['colorbox_caption_trim'] = array(
'#type' => 'radios',
'#title' => t('Caption shortening'),
'#options' => array(0 => t('Default'), 1 => t('Yes')),
'#default_value' => variable_get('colorbox_caption_trim', 0),
'#description' => t('If the caption should be made shorter in the Colorbox to avoid layout problems. The default is to shorten for the example styles, they need it, but not for other styles.'),
);
$form['colorbox_advanced_settings']['colorbox_caption_trim_length'] = array(
'#type' => 'select',
'#title' => t('Caption max length'),
'#options' => drupal_map_assoc(array(40, 45, 50, 55, 60, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120)),
'#default_value' => variable_get('colorbox_caption_trim_length', 75),
'#states' => array(
'visible' => array(
':input[name="colorbox_caption_trim"]' => array('value' => '1'),
),
),
);
$form['colorbox_advanced_settings']['colorbox_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show Colorbox on specific pages'),
'#options' => array(0 => t('All pages except those listed'), 1 => t('Only the listed pages')),
'#default_value' => variable_get('colorbox_visibility', 0),
);
$form['colorbox_advanced_settings']['colorbox_pages'] = array(
'#type' => 'textarea',
'#title' => '<span class="element-invisible">' . t('Pages') . '</span>',
'#default_value' => variable_get('colorbox_pages', "admin*\nimagebrowser*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*\nsystem/ajax\nsystem/ajax/*"),
'#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
$form['colorbox_advanced_settings']['colorbox_compression_type'] = array(
'#type' => 'radios',
'#title' => t('Choose Colorbox compression level'),
'#options' => array(
'minified' => t('Production (Minified)'),
'source' => t('Development (Uncompressed Code)'),
),
'#default_value' => variable_get('colorbox_compression_type', 'minified'),
);
return system_settings_form($form);
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @file
* API documentation for the colorbox module.
*/
/**
* Allows to override Colorbox settings and style.
*
* Implements hook_colorbox_settings_alter().
*
* @param $settings
* An associative array of Colorbox settings. See the
* @link http://colorpowered.com/colorbox/ Colorbox documentation @endlink
* for the full list of supported parameters.
* @param $style
* The name of the active style plugin. If $style is 'none', no Colorbox
* theme will be loaded.
*/
function hook_colorbox_settings_alter(&$settings, &$style) {
// Disable automatic downscaling of images to maxWidth/maxHeight size.
$settings['scalePhotos'] = FALSE;
// Use custom style plugin specifically for node/123.
if ($_GET['q'] == 'node/123') {
$style = 'mystyle';
}
}

View File

@@ -0,0 +1,14 @@
name = Colorbox
description = A light-weight, customizable lightbox plugin for jQuery 1.4.3+.
dependencies[] = libraries (2.x)
core = 7.x
configure = admin/config/media/colorbox
files[] = views/colorbox_handler_field_colorbox.inc
; Information added by drupal.org packaging script on 2013-04-08
version = "7.x-2.4"
core = "7.x"
project = "colorbox"
datestamp = "1365452412"

View File

@@ -0,0 +1,118 @@
<?php
/**
* @file
* Install, update and uninstall functions for the colorbox module.
*/
/**
* Implements hook_requirements().
*/
function colorbox_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$t = get_t();
$library = libraries_detect('colorbox');
if (empty($library['installed'])) {
$requirements['colorbox_plugin'] = array(
'title' => $t('Colorbox plugin'),
'value' => $t('At least @a', array('@a' => COLORBOX_MIN_PLUGIN_VERSION)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('You need to download the !colorbox, extract the archive and place the colorbox directory in the %path directory on your server.', array('!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => 'sites/all/libraries')),
);
}
elseif (version_compare($library['version'], COLORBOX_MIN_PLUGIN_VERSION, '>=')) {
$requirements['colorbox_plugin'] = array(
'title' => $t('Colorbox plugin'),
'severity' => REQUIREMENT_OK,
'value' => $library['version'],
);
}
else {
$requirements['colorbox_plugin'] = array(
'title' => $t('Colorbox plugin'),
'value' => $t('At least @a', array('@a' => COLORBOX_MIN_PLUGIN_VERSION)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('You need to download a later version of the !colorbox and replace the old version located in the %path directory on your server.', array('!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => $library['library path'])),
);
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function colorbox_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'colorbox_%'");
}
/**
* Delete the unused colorbox_login_form variable.
*/
function colorbox_update_7001() {
$ret = array();
variable_del('colorbox_login_form');
return $ret;
}
/**
* Delete the unused colorbox_title_trim and
* colorbox_title_trim_length variables.
*/
function colorbox_update_7002() {
$ret = array();
$colorbox_title_trim = variable_get('colorbox_title_trim', NULL);
$colorbox_title_trim_length = variable_get('colorbox_title_trim_length', NULL);
if (!empty($colorbox_title_trim)) {
variable_set('colorbox_caption_trim', $colorbox_title_trim);
}
if (!empty($colorbox_title_trim_length)) {
variable_set('colorbox_caption_trim_length', $colorbox_title_trim_length);
}
variable_del('colorbox_title_trim');
variable_del('colorbox_title_trim_length');
return $ret;
}
/**
* Delete the unused colorbox_login and colorbox_login_links variables.
*/
function colorbox_update_7200() {
$ret = array();
variable_del('colorbox_login');
variable_del('colorbox_login_links');
return $ret;
}
/**
* Delete the unused colorbox_auto_image_nodes variable.
*/
function colorbox_update_7201() {
$ret = array();
variable_del('colorbox_auto_image_nodes');
return $ret;
}
/**
* Update the colorbox_compression_type variable.
*/
function colorbox_update_7202() {
$ret = array();
if (variable_get('colorbox_compression_type', 'minified') == 'none') {
variable_set('colorbox_compression_type', 'source');
}
else {
variable_set('colorbox_compression_type', 'minified');
}
return $ret;
}

View File

@@ -0,0 +1,9 @@
; $Id$
core = 7.x
api = 2
libraries[colorbox][download][type] = "get"
libraries[colorbox][download][url] = "http://colorpowered.com/colorbox/colorbox.zip"
libraries[colorbox][directory_name] = "colorbox"
libraries[colorbox][destination] = "libraries"

View File

@@ -0,0 +1,493 @@
<?php
/**
* @file
* A light-weight, customizable lightbox plugin for jQuery 1.3
*/
/**
* The default path to the Colorbox directory.
*/
define('COLORBOX_MIN_PLUGIN_VERSION', '1.3.21.1');
/**
* Implements hook_theme().
*/
function colorbox_theme() {
return array(
'colorbox_imagefield' => array(
'variables' => array(
'image' => array(),
'path' => NULL,
'title' => NULL,
'gid' => NULL,
),
'file' => 'colorbox.theme.inc',
),
'colorbox_insert_image' => array(
'variables' => array(
'item' => NULL,
'widget' => NULL,
),
'template' => 'colorbox-insert-image',
'file' => 'colorbox.theme.inc',
),
'colorbox_image_formatter' => array(
'variables' => array(
'item' => NULL,
'entity_type' => NULL,
'entity' => NULL,
'node' => NULL, // Left for legacy support.
'field' => array(),
'display_settings' => array(),
),
'file' => 'colorbox.theme.inc',
),
);
}
/**
* Implements hook_init().
*/
function colorbox_init() {
// Do not load colorbox during the Drupal installation process, e.g. if part
// of installation profiles.
if (!drupal_installation_attempted()) {
_colorbox_doheader();
}
}
/**
* Implements hook_views_api().
*/
function colorbox_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'colorbox') . '/views',
);
}
/**
* Implements hook_libraries_info().
*/
function colorbox_libraries_info() {
$libraries['colorbox'] = array(
'name' => 'Colorbox plugin',
'vendor url' => 'http://www.jacklmoore.com/colorbox',
'download url' => 'http://www.jacklmoore.com/colorbox',
'version arguments' => array(
'file' => 'jquery.colorbox-min.js',
'pattern' => '@(?i:Colorbox) v([0-9\.a-z]+)@',
'lines' => 5,
),
'files' => array(
'js' => array(
'jquery.colorbox-min.js',
),
),
'variants' => array(
'minified' => array(
'files' => array(
'js' => array(
'jquery.colorbox-min.js',
),
),
),
'source' => array(
'files' => array(
'js' => array(
'jquery.colorbox.js',
),
),
),
),
);
return $libraries;
}
/**
* Implements hook_menu().
*/
function colorbox_menu() {
$items = array();
$items['admin/config/media/colorbox'] = array(
'title' => 'Colorbox',
'description' => 'Adjust Colorbox settings.',
'file' => 'colorbox.admin.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('colorbox_admin_settings'),
'access arguments' => array('administer site configuration'),
);
return $items;
}
/**
* Check if Colorbox should be active for the current URL.
*
* @return
* TRUE if Colorbox should be active for the current page.
*/
function _colorbox_active() {
// Make it possible deactivate Colorbox with
// parameter ?colorbox=no in the url.
if (isset($_GET['colorbox']) && $_GET['colorbox'] == 'no') {
return FALSE;
}
// Code from the block_list funtion in block.module.
$path = drupal_get_path_alias($_GET['q']);
$colorbox_pages = variable_get('colorbox_pages', "admin*\nimagebrowser*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*\nsystem/ajax\nsystem/ajax/*");
// Compare with the internal and path alias (if any).
$page_match = drupal_match_path($path, $colorbox_pages);
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $colorbox_pages);
}
$page_match = variable_get('colorbox_visibility', 0) == 0 ? !$page_match : $page_match;
return $page_match;
}
/**
* Loads the various js and css files.
*/
function _colorbox_doheader() {
static $already_added = FALSE;
if ($already_added) {
return; // Don't add the JavaScript and CSS multiple times.
}
if (!_colorbox_active()) {
return; // Don't add the JavaScript and CSS on specified paths.
}
// Insert options and translated strings as javascript settings.
if (variable_get('colorbox_custom_settings_activate', 0)) {
$js_settings = array(
'transition' => variable_get('colorbox_transition_type', 'elastic'),
'speed' => variable_get('colorbox_transition_speed', 350),
'opacity' => variable_get('colorbox_opacity', '0.85'),
'slideshow' => variable_get('colorbox_slideshow', 0) ? TRUE : FALSE,
'slideshowAuto' => variable_get('colorbox_slideshowauto', 1) ? TRUE : FALSE,
'slideshowSpeed' => variable_get('colorbox_slideshowspeed', 2500),
'slideshowStart' => variable_get('colorbox_text_start', 'start slideshow'),
'slideshowStop' => variable_get('colorbox_text_stop', 'stop slideshow'),
'current' => variable_get('colorbox_text_current', '{current} of {total}'),
'previous' => variable_get('colorbox_text_previous', '« Prev'),
'next' => variable_get('colorbox_text_next', 'Next »'),
'close' => variable_get('colorbox_text_close', 'Close'),
'overlayClose' => variable_get('colorbox_overlayclose', 1) ? TRUE : FALSE,
'maxWidth' => variable_get('colorbox_maxwidth', '98%'),
'maxHeight' => variable_get('colorbox_maxheight', '98%'),
'initialWidth' => variable_get('colorbox_initialwidth', '300'),
'initialHeight' => variable_get('colorbox_initialheight', '250'),
'fixed' => variable_get('colorbox_fixed', 1) ? TRUE : FALSE,
'scrolling' => variable_get('colorbox_scrolling', 1) ? TRUE : FALSE,
);
}
else {
$js_settings = array(
'opacity' => '0.85',
'current' => t('{current} of {total}'),
'previous' => t('« Prev'),
'next' => t('Next »'),
'close' => t('Close'),
'maxWidth' => '98%',
'maxHeight' => '98%',
'fixed' => TRUE,
);
}
$path = drupal_get_path('module', 'colorbox');
$style = variable_get('colorbox_style', 'default');
// Give other modules the possibility to override Colorbox settings and style.
$data = &$js_settings;
drupal_alter('colorbox_settings', $data, $style);
drupal_add_js(array('colorbox' => $js_settings), array('type' => 'setting', 'scope' => JS_DEFAULT));
// Add and initialise the Colorbox plugin.
$variant = variable_get('colorbox_compression_type', 'minified');
libraries_load('colorbox', $variant);
drupal_add_js($path . '/js/colorbox.js');
// Add JS and CSS based on selected style.
switch ($style) {
case 'none':
break;
case 'default':
case 'plain':
case 'stockholmsyndrome':
drupal_add_css($path . '/styles/' . $style . '/colorbox_style.css');
drupal_add_js($path . '/styles/' . $style . '/colorbox_style.js');
break;
default:
drupal_add_css($style . '/colorbox.css');
}
if (variable_get('colorbox_load', 0)) {
drupal_add_js($path . '/js/colorbox_load.js');
}
if (variable_get('colorbox_inline', 0)) {
drupal_add_js($path . '/js/colorbox_inline.js');
}
$already_added = TRUE;
}
/**
* Implements hook_field_formatter_info().
*/
function colorbox_field_formatter_info() {
return array(
'colorbox' => array(
'label' => t('Colorbox'),
'field types' => array('image'),
'settings' => array(
'colorbox_node_style' => '',
'colorbox_image_style' => '',
'colorbox_gallery' => 'post',
'colorbox_gallery_custom' => '',
'colorbox_caption' => 'auto',
'colorbox_caption_custom' => '',
'colorbox_multivalue_index' => NULL,
),
),
);
}
/**
* Implements hook_field_formatter_settings_form().
*/
function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$image_styles = image_style_options(FALSE);
$image_styles_hide = $image_styles;
$image_styles_hide['hide'] = t('Hide (do not display image)');
$element['colorbox_node_style'] = array(
'#title' => t('Content image style'),
'#type' => 'select',
'#default_value' => $settings['colorbox_node_style'],
'#empty_option' => t('None (original image)'),
'#options' => $image_styles_hide,
'#description' => t('Image style to use in the content.'),
);
$element['colorbox_image_style'] = array(
'#title' => t('Colorbox image style'),
'#type' => 'select',
'#default_value' => $settings['colorbox_image_style'],
'#empty_option' => t('None (original image)'),
'#options' => $image_styles,
'#description' => t('Image style to use in the Colorbox.'),
);
$gallery = array(
'post' => t('Per post gallery'),
'page' => t('Per page gallery'),
'field_post' => t('Per field in post gallery'),
'field_page' => t('Per field in page gallery'),
'custom' => t('Custom'),
'none' => t('No gallery'),
);
$element['colorbox_gallery'] = array(
'#title' => t('Gallery (image grouping)'),
'#type' => 'select',
'#default_value' => $settings['colorbox_gallery'],
'#options' => $gallery,
'#description' => t('How Colorbox should group the image galleries.'),
);
$element['colorbox_gallery_custom'] = array(
'#title' => t('Custom gallery'),
'#type' => 'machine_name',
'#maxlength' => 32,
'#default_value' => $settings['colorbox_gallery_custom'],
'#description' => t('All images on a page with the same gallery value (rel attribute) will be grouped together. It must only contain lowercase letters, numbers, and underscores.'),
'#required' => FALSE,
'#machine_name' => array(
'exists' => 'colorbox_gallery_exists',
'error' => t('The custom gallery field must only contain lowercase letters, numbers, and underscores.'),
),
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_gallery]"]' => array('value' => 'custom'),
),
),
);
$caption = array(
'auto' => t('Automatic'),
'title' => t('Title text'),
'alt' => t('Alt text'),
'node_title' => t('Content title'),
'custom' => t('Custom (with tokens)'),
'none' => t('None'),
);
$element['colorbox_caption'] = array(
'#title' => t('Caption'),
'#type' => 'select',
'#default_value' => $settings['colorbox_caption'],
'#options' => $caption,
'#description' => t('Automatic will use the first none empty value of the title, the alt text and the content title.'),
);
$element['colorbox_caption_custom'] = array(
'#title' => t('Custom caption'),
'#type' => 'textfield',
'#default_value' => $settings['colorbox_caption_custom'],
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
),
),
);
// Allow users to hide or set a custom recursion limit.
// The module token_tweaks sets a global recursion limit that can not be bypassed.
if (module_exists('token') && $recursion_limit = min(variable_get('token_tree_recursion_limit', 3), variable_get('colorbox_token_recursion_limit', 3))) {
$element['colorbox_token'] = array(
'#type' => 'fieldset',
'#title' => t('Replacement patterns'),
'#theme' => 'token_tree',
'#token_types' => array($instance['entity_type'], 'file'),
'#recursion_limit' => $recursion_limit,
'#dialog' => TRUE,
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
),
),
);
}
else {
$element['colorbox_token'] = array(
'#type' => 'fieldset',
'#title' => t('Replacement patterns'),
'#description' => '<strong class="error">' . t('For token support the <a href="@token_url">token module</a> must be installed.', array('@token_url' => 'http://drupal.org/project/token')) . '</strong>',
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
),
),
);
}
return $element;
}
/**
* Implements hook_field_formatter_settings_summary().
*/
function colorbox_field_formatter_settings_summary($field, $instance, $view_mode) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$summary = array();
$image_styles = image_style_options(FALSE);
// Unset possible 'No defined styles' option.
unset($image_styles['']);
// Styles could be lost because of enabled/disabled modules that defines
// their styles in code.
if (isset($image_styles[$settings['colorbox_node_style']])) {
$summary[] = t('Content image style: @style', array('@style' => $image_styles[$settings['colorbox_node_style']]));
}
elseif ($settings['colorbox_node_style'] == 'hide') {
$summary[] = t('Content image style: Hide');
}
else {
$summary[] = t('Content image style: Original image');
}
if (isset($image_styles[$settings['colorbox_image_style']])) {
$summary[] = t('Colorbox image style: @style', array('@style' => $image_styles[$settings['colorbox_image_style']]));
}
else {
$summary[] = t('Colorbox image style: Original image');
}
$gallery = array(
'post' => t('Per post gallery'),
'page' => t('Per page gallery'),
'field_post' => t('Per field in post gallery'),
'field_page' => t('Per field in page gallery'),
'custom' => t('Custom'),
'none' => t('No gallery'),
);
if (isset($settings['colorbox_gallery'])) {
$summary[] = t('Colorbox gallery type: @type', array('@type' => $gallery[$settings['colorbox_gallery']])) . ($settings['colorbox_gallery'] == 'custom' ? ' (' . $settings['colorbox_gallery_custom'] . ')' : '');
}
$caption = array(
'auto' => t('Automatic'),
'title' => t('Title text'),
'alt' => t('Alt text'),
'node_title' => t('Content title'),
'custom' => t('Custom (with tokens)'),
'none' => t('None'),
);
if (isset($settings['colorbox_caption'])) {
$summary[] = t('Colorbox caption: @type', array('@type' => $caption[$settings['colorbox_caption']]));
}
return implode('<br />', $summary);
}
/**
* Implements hook_field_formatter_view().
*/
function colorbox_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
$index = $display['settings']['colorbox_multivalue_index'];
foreach ($items as $delta => $item) {
if ($index === NULL || $index === $delta) {
$element[$delta] = array(
'#theme' => 'colorbox_image_formatter',
'#item' => $item,
'#entity_type' => $entity_type,
'#entity' => $entity,
'#node' => $entity, // Left for legacy support.
'#field' => $field,
'#display_settings' => $display['settings'],
);
}
}
return $element;
}
/**
* Implements hook_insert_styles().
*/
function colorbox_insert_styles() {
$insert_styles = array();
foreach (image_styles() as $key => $style) {
$insert_styles['colorbox__' . $key] = array('label' => t('Colorbox @style', array('@style' => $style['name'])));
}
return $insert_styles;
}
/**
* Implements hook_insert_content().
*/
function colorbox_insert_content($item, $style, $widget) {
list($item['module_name'], $item['style_name']) = explode('__', $style['name'], 2);
return theme('colorbox_insert_image', array('item' => $item, 'widget' => $widget));
}
/**
* Machine names normally need to be unique but that does not apply to galleries.
*
* @return
* Always FALSE
*/
function colorbox_gallery_exists() {
return FALSE;
}

View File

@@ -0,0 +1,188 @@
<?php
/**
* @file
* Colorbox theme functions.
*/
/**
* Returns HTML for an Colorbox image field formatter.
*
* @param $variables
* An associative array containing:
* - item: An array of image data.
* - image_style: An optional image style.
* - path: An array containing the link 'path' and link 'options'.
*
* @ingroup themeable
*/
function theme_colorbox_image_formatter($variables) {
$item = $variables['item'];
$entity_type = $variables['entity_type'];
$entity = $variables['entity'];
$field = $variables['field'];
$settings = $variables['display_settings'];
$image = array(
'path' => $item['uri'],
'alt' => $item['alt'],
'title' => $item['title'],
'style_name' => $settings['colorbox_node_style'],
);
if (isset($item['width']) && isset($item['height'])) {
$image['width'] = $item['width'];
$image['height'] = $item['height'];
}
$entity_title = entity_label($entity_type, $entity);
switch ($settings['colorbox_caption']) {
case 'auto':
// If the title is empty use alt or the entity title in that order.
if (!empty($image['title'])) {
$caption = $image['title'];
}
elseif (!empty($image['alt'])) {
$caption = $image['alt'];
}
elseif (!empty($entity_title)) {
$caption = $entity_title;
}
else {
$caption = '';
}
break;
case 'title':
$caption = $image['title'];
break;
case 'alt':
$caption = $image['alt'];
break;
case 'node_title':
$caption = $entity_title;
break;
case 'custom':
$caption = token_replace($settings['colorbox_caption_custom'], array($entity_type => $entity, 'file' => (object) $item), array('clear' => TRUE));
break;
default:
$caption = '';
}
// Shorten the caption for the example styles or when caption shortening is active.
$colorbox_style = variable_get('colorbox_style', 'default');
$trim_length = variable_get('colorbox_caption_trim_length', 75);
if (((strpos($colorbox_style, 'colorbox/example') !== FALSE) || variable_get('colorbox_caption_trim', 0)) && (drupal_strlen($caption) > $trim_length)) {
$caption = drupal_substr($caption, 0, $trim_length - 5) . '...';
}
// Build the gallery id.
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$entity_id = !empty($id) ? $entity_type . '-' . $id : 'entity-id';
switch ($settings['colorbox_gallery']) {
case 'post':
$gallery_id = 'gallery-' . $entity_id;
break;
case 'page':
$gallery_id = 'gallery-all';
break;
case 'field_post':
$gallery_id = 'gallery-' . $entity_id . '-' . $field['field_name'];
break;
case 'field_page':
$gallery_id = 'gallery-' . $field['field_name'];
break;
case 'custom':
$gallery_id = $settings['colorbox_gallery_custom'];
break;
default:
$gallery_id = '';
}
if ($style_name = $settings['colorbox_image_style']) {
$path = image_style_url($style_name, $image['path']);
}
else {
$path = file_create_url($image['path']);
}
return theme('colorbox_imagefield', array('image' => $image, 'path' => $path, 'title' => $caption, 'gid' => $gallery_id));
}
/**
* Returns HTML for an image using a specific Colorbox image style.
*
* @param $variables
* An associative array containing:
* - image: image item as array.
* - path: The path of the image that should be displayed in the Colorbox.
* - title: The title text that will be used as a caption in the Colorbox.
* - gid: Gallery id for Colorbox image grouping.
*
* @ingroup themeable
*/
function theme_colorbox_imagefield($variables) {
$class = array('colorbox');
if ($variables['image']['style_name'] == 'hide') {
$image = '';
$class[] = 'js-hide';
}
elseif (!empty($variables['image']['style_name'])) {
$image = theme('image_style', $variables['image']);
}
else {
$image = theme('image', $variables['image']);
}
$options = array(
'html' => TRUE,
'attributes' => array(
'title' => $variables['title'],
'class' => $class,
'rel' => $variables['gid'],
)
);
return l($image, $variables['path'], $options);
}
/**
* Preprocess variables for the colorbox-insert-image.tpl.php file.
*/
function template_preprocess_colorbox_insert_image(&$variables) {
$class = array();
$file = file_load($variables['item']['fid']);
if (!empty($variables['widget']['settings']['insert_class'])) {
$class = explode(' ', $variables['widget']['settings']['insert_class']);
}
$class[] = 'image-' . $variables['item']['style_name'];
foreach ($class as $key => $value) {
$class[$key] = drupal_html_class($value);
}
$variables['image_path'] = image_style_url($variables['item']['style_name'], $file->uri);
if ($style_name = variable_get('colorbox_image_style', '')) {
$variables['link_path'] = image_style_url($style_name, $file->uri);
}
else {
$variables['link_path'] = file_create_url($file->uri);
}
$variables['class'] = implode(' ', $class);
$variables['gallery_id'] = '';
switch (variable_get('colorbox_insert_gallery', 0)) {
case 0:
case 1:
case 2:
$variables['gallery_id'] = 'gallery-all';
break;
case 3:
$variables['gallery_id'] = '';
break;
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* @file
* Colorbox translatable variables.
*/
/**
* Implements hook_variable_info().
*/
function colorbox_variable_info($options) {
$variable['colorbox_text_start'] = array(
'title' => t('Colorbox Start slideshow'),
'description' => t('Text for the slideshow start button.'),
'type' => 'string',
);
$variable['colorbox_text_stop'] = array(
'title' => t('Colorbox Stop slideshow'),
'description' => t('Text for the slideshow stop button.'),
'type' => 'string',
);
$variable['colorbox_text_current'] = array(
'title' => t('Colorbox current text'),
'description' => t('Text for the content group / gallery count'),
'type' => 'string',
);
$variable['colorbox_text_previous'] = array(
'title' => t('Colorbox Previous'),
'description' => t('Text for the previous button in a shared relation group.'),
'type' => 'string',
);
$variable['colorbox_text_next'] = array(
'title' => t('Colorbox Next'),
'description' => t('Text for the next button in a shared relation group.'),
'type' => 'string',
);
$variable['colorbox_text_close'] = array(
'title' => t('Colorbox Close'),
'description' => t('Text for the close button.'),
'type' => 'string',
);
return $variable;
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* @file
* drush integration for colorbox.
*/
/**
* The Colorbox plugin URI.
*/
define('COLORBOX_DOWNLOAD_URI', 'https://github.com/jackmoore/colorbox/archive/1.x.zip');
define('COLORBOX_DOWNLOAD_PREFIX', 'colorbox-');
/**
* Implementation of hook_drush_command().
*
* In this hook, you specify which commands your
* drush module makes available, what it does and
* description.
*
* Notice how this structure closely resembles how
* you define menu hooks.
*
* See `drush topic docs-commands` for a list of recognized keys.
*
* @return
* An associative array describing your command(s).
*/
function colorbox_drush_command() {
$items = array();
// the key in the $items array is the name of the command.
$items['colorbox-plugin'] = array(
'callback' => 'drush_colorbox_plugin',
'description' => dt('Download and install the Colorbox plugin.'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, // No bootstrap.
'arguments' => array(
'path' => dt('Optional. A path where to install the Colorbox plugin. If omitted Drush will use the default location.'),
),
'aliases' => array('colorboxplugin'),
);
return $items;
}
/**
* Implementation of hook_drush_help().
*
* This function is called whenever a drush user calls
* 'drush help <name-of-your-command>'
*
* @param
* A string with the help section (prepend with 'drush:')
*
* @return
* A string with the help text for your command.
*/
function colorbox_drush_help($section) {
switch ($section) {
case 'drush:colorbox-plugin':
return dt('Download and install the Colorbox plugin from jacklmoore.com/colorbox, default location is sites/all/libraries.');
}
}
/**
* Implements drush_MODULE_post_pm_enable().
*/
// function drush_colorbox_post_pm_enable() {
// $modules = func_get_args();
// if (in_array('colorbox', $modules)) {
// drush_colorbox_plugin();
// }
// }
/**
* Command to download the Colorbox plugin.
*/
function drush_colorbox_plugin() {
$args = func_get_args();
if (!empty($args[0])) {
$path = $args[0];
}
else {
$path = 'sites/all/libraries';
}
// Create the path if it does not exist.
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', array('@path' => $path)), 'notice');
}
// Set the directory to the download location.
$olddir = getcwd();
chdir($path);
// Download the zip archive
if ($filepath = drush_download_file(COLORBOX_DOWNLOAD_URI)) {
$filename = basename($filepath);
$dirname = COLORBOX_DOWNLOAD_PREFIX . basename($filepath, '.zip');
// Remove any existing Colorbox plugin directory
if (is_dir($dirname) || is_dir('colorbox')) {
drush_delete_dir($dirname, TRUE);
drush_delete_dir('colorbox', TRUE);
drush_log(dt('A existing Colorbox plugin was deleted from @path', array('@path' => $path)), 'notice');
}
// Decompress the zip archive
drush_tarball_extract($filename);
// Change the directory name to "colorbox" if needed.
if ($dirname != 'colorbox') {
drush_move_dir($dirname, 'colorbox', TRUE);
$dirname = 'colorbox';
}
}
if (is_dir($dirname)) {
drush_log(dt('Colorbox plugin has been installed in @path', array('@path' => $path)), 'success');
}
else {
drush_log(dt('Drush was unable to install the Colorbox plugin to @path', array('@path' => $path)), 'error');
}
// Set working directory back to the previous working directory.
chdir($olddir);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

View File

@@ -0,0 +1,20 @@
(function ($) {
Drupal.behaviors.initColorbox = {
attach: function (context, settings) {
if (!$.isFunction($.colorbox)) {
return;
}
$('.colorbox', context)
.once('init-colorbox')
.colorbox(settings.colorbox);
}
};
{
$(document).bind('cbox_complete', function () {
Drupal.attachBehaviors('#cboxLoadedContent');
});
}
})(jQuery);

View File

@@ -0,0 +1,32 @@
(function ($) {
Drupal.behaviors.initColorboxAdminSettings = {
attach: function (context, settings) {
$('div.colorbox-custom-settings-activate input.form-radio', context).click(function () {
if (this.value == 1) {
$('div.colorbox-custom-settings', context).show();
}
else {
$('div.colorbox-custom-settings', context).hide();
}
});
$('div.colorbox-slideshow-settings-activate input.form-radio', context).click(function () {
if (this.value == 1) {
$('div.colorbox-slideshow-settings', context).show();
}
else {
$('div.colorbox-slideshow-settings', context).hide();
}
});
$('div.colorbox-title-trim-settings-activate input.form-radio', context).click(function () {
if (this.value == 1) {
$('div.colorbox-title-trim-settings', context).show();
}
else {
$('div.colorbox-title-trim-settings', context).hide();
}
});
}
};
})(jQuery);

View File

@@ -0,0 +1,56 @@
(function ($) {
Drupal.behaviors.initColorboxInline = {
attach: function (context, settings) {
if (!$.isFunction($.colorbox)) {
return;
}
$.urlParam = function(name, url){
if (name == 'fragment') {
var results = new RegExp('(#[^&#]*)').exec(url);
}
else {
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
}
if (!results) { return ''; }
return results[1] || '';
};
$('.colorbox-inline', context).once('init-colorbox-inline').colorbox({
transition:settings.colorbox.transition,
speed:settings.colorbox.speed,
opacity:settings.colorbox.opacity,
slideshow:settings.colorbox.slideshow,
slideshowAuto:settings.colorbox.slideshowAuto,
slideshowSpeed:settings.colorbox.slideshowSpeed,
slideshowStart:settings.colorbox.slideshowStart,
slideshowStop:settings.colorbox.slideshowStop,
current:settings.colorbox.current,
previous:settings.colorbox.previous,
next:settings.colorbox.next,
close:settings.colorbox.close,
overlayClose:settings.colorbox.overlayClose,
maxWidth:settings.colorbox.maxWidth,
maxHeight:settings.colorbox.maxHeight,
innerWidth:function(){
return $.urlParam('width', $(this).attr('href'));
},
innerHeight:function(){
return $.urlParam('height', $(this).attr('href'));
},
title:function(){
return decodeURIComponent($.urlParam('title', $(this).attr('href')));
},
iframe:function(){
return $.urlParam('iframe', $(this).attr('href'));
},
inline:function(){
return $.urlParam('inline', $(this).attr('href'));
},
href:function(){
return $.urlParam('fragment', $(this).attr('href'));
}
});
}
};
})(jQuery);

View File

@@ -0,0 +1,42 @@
(function ($) {
Drupal.behaviors.initColorboxLoad = {
attach: function (context, settings) {
if (!$.isFunction($.colorbox)) {
return;
}
$.urlParams = function (url) {
var p = {},
e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, ' ')); },
q = url.split('?');
while (e = r.exec(q[1])) {
e[1] = d(e[1]);
e[2] = d(e[2]);
switch (e[2].toLowerCase()) {
case 'true':
case 'yes':
e[2] = true;
break;
case 'false':
case 'no':
e[2] = false;
break;
}
if (e[1] == 'width') { e[1] = 'innerWidth'; }
if (e[1] == 'height') { e[1] = 'innerHeight'; }
p[e[1]] = e[2];
}
return p;
};
$('.colorbox-load', context)
.once('init-colorbox-load', function () {
var params = $.urlParams($(this).attr('href'));
$(this).colorbox($.extend({}, settings.colorbox, params));
});
}
};
})(jQuery);

View File

@@ -0,0 +1,216 @@
/**
* Colorbox Core Style:
* The following CSS is consistent between example themes and should not be altered.
*/
#colorbox, #cboxOverlay, #cboxWrapper {
position: absolute;
top: 0;
left: 0;
z-index: 9999;
overflow: hidden;
}
#cboxOverlay {
position: fixed;
width: 100%;
height: 100%;
}
#cboxMiddleLeft, #cboxBottomLeft {
clear: left;
}
#cboxContent {
position: relative;
}
#cboxLoadedContent {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
#cboxTitle {
margin: 0;
}
#cboxLoadingOverlay, #cboxLoadingGraphic {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/**
* These elements are buttons, and may need to have additional
* styles reset to avoid unwanted base styles.
*/
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow {
border: 0;
padding: 0;
margin: 0;
overflow: visible;
width: auto;
background: none;
cursor: pointer;
}
/**
* Avoid outlines on :active (mouseclick),
* but preserve outlines on :focus (tabbed navigating)
*/
#cboxPrevious:active, #cboxNext:active, #cboxClose:active, #cboxSlideshow:active {
outline: 0;
}
.cboxPhoto {
float: left;
margin: auto;
border: 0;
display: block;
max-width: none;
}
.cboxIframe {
width: 100%;
height: 100%;
display: block;
border: 0;
}
/* Reset box sizing to content-box if theme is using border-box. */
#colorbox, #cboxContent, #cboxLoadedContent {
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
/**
* Colorbox module default style:
* The styles are ordered & tabbed in a way that represents
* the nesting of the generated HTML.
*/
#cboxOverlay {
background: #000;
}
#colorbox {
outline: 0;
}
#cboxWrapper {
background: #fff;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
#cboxTopLeft {
width: 15px;
height: 15px;
}
#cboxTopCenter {
height: 15px;
}
#cboxTopRight {
width: 15px;
height: 15px;
}
#cboxBottomLeft {
width: 15px;
height: 10px;
}
#cboxBottomCenter {
height: 10px;
}
#cboxBottomRight {
width: 15px;
height: 10px;
}
#cboxMiddleLeft {
width: 15px;
}
#cboxMiddleRight {
width: 15px;
}
#cboxContent {
background: #fff;
overflow: hidden;
}
#cboxError {
padding: 50px;
border: 1px solid #ccc;
}
#cboxLoadedContent {
margin-bottom: 28px;
}
#cboxTitle {
position: absolute;
background: rgba(255, 255, 255, 0.7);
bottom: 28px;
left: 0;
color: #535353;
width: 100%;
padding: 4px 6px;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#cboxCurrent {
position: absolute;
bottom: 4px;
left: 60px;
color: #949494;
}
.cboxSlideshow_on #cboxSlideshow {
position: absolute;
bottom: 0px;
right: 30px;
background: url(images/controls.png) no-repeat -75px -50px;
width: 25px;
height: 25px;
text-indent: -9999px;
}
.cboxSlideshow_on #cboxSlideshow:hover {
background-position: -101px -50px;
}
.cboxSlideshow_off #cboxSlideshow {
position: absolute;
bottom: 0px;
right: 30px;
background: url(images/controls.png) no-repeat -25px -50px;
width: 25px;
height: 25px;
text-indent: -9999px;
}
.cboxSlideshow_off #cboxSlideshow:hover {
background-position: -49px -50px;
}
#cboxPrevious {
position: absolute;
bottom: 0;
left: 0;
background: url(images/controls.png) no-repeat -75px 0px;
width: 25px;
height: 25px;
text-indent: -9999px;
}
#cboxPrevious:hover {
background-position: -75px -25px;
}
#cboxNext {
position: absolute;
bottom: 0;
left: 27px;
background: url(images/controls.png) no-repeat -50px 0px;
width: 25px;
height: 25px;
text-indent: -9999px;
}
#cboxNext:hover {
background-position: -50px -25px;
}
#cboxLoadingOverlay {
background: #fff;
}
#cboxLoadingGraphic {
background: url(images/loading_animation.gif) no-repeat center center;
}
#cboxClose {
position: absolute;
bottom: 0;
right: 0;
background: url(images/controls.png) no-repeat -25px 0px;
width: 25px;
height: 25px;
text-indent: -9999px;
}
#cboxClose:hover {
background-position: -25px -25px;
}

View File

@@ -0,0 +1,22 @@
(function ($) {
Drupal.behaviors.initColorboxDefaultStyle = {
attach: function (context, settings) {
$(document).bind('cbox_complete', function () {
// Only run if there is a title.
if ($('#cboxTitle:empty', context).length == false) {
$('#cboxLoadedContent img', context).bind('mouseover', function () {
$('#cboxTitle', context).slideDown();
});
$('#cboxOverlay', context).bind('mouseover', function () {
$('#cboxTitle', context).slideUp();
});
}
else {
$('#cboxTitle', context).hide();
}
});
}
};
})(jQuery);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

View File

@@ -0,0 +1,144 @@
/**
* Colorbox Core Style:
* The following CSS is consistent between example themes and should not be altered.
*/
#colorbox, #cboxOverlay, #cboxWrapper {
position: absolute;
top: 0;
left: 0;
z-index: 9999;
overflow: hidden;
}
#cboxOverlay {
position: fixed;
width: 100%;
height: 100%;
}
#cboxMiddleLeft, #cboxBottomLeft {
clear: left;
}
#cboxContent {
position: relative;
}
#cboxLoadedContent {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
#cboxTitle {
margin: 0;
}
#cboxLoadingOverlay, #cboxLoadingGraphic {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/**
* These elements are buttons, and may need to have additional
* styles reset to avoid unwanted base styles.
*/
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow {
border: 0;
padding: 0;
margin: 0;
overflow: visible;
width: auto;
background: none;
cursor: pointer;
}
/**
* Avoid outlines on :active (mouseclick),
* but preserve outlines on :focus (tabbed navigating)
*/
#cboxPrevious:active, #cboxNext:active, #cboxClose:active, #cboxSlideshow:active {
outline: 0;
}
.cboxPhoto {
float: left;
margin: auto;
border: 0;
display: block;
max-width: none;
}
.cboxIframe {
width: 100%;
height: 100%;
display: block;
border: 0;
}
/* Reset box sizing to content-box if theme is using border-box. */
#colorbox, #cboxContent, #cboxLoadedContent {
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
/**
* Colorbox module plain style:
* The styles are ordered & tabbed in a way that represents
* the nesting of the generated HTML.
*/
#cboxOverlay {
background: #000;
}
#colorbox {
outline: 0;
}
#cboxWrapper {}
#cboxContent {
overflow: hidden;
}
#cboxContent, .cboxPhoto {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#cboxError {
padding: 50px;
border: 1px solid #ccc;
}
#cboxTitle {
position: absolute;
background: rgba(255, 255, 255, 0.7);
bottom: 0;
left: 0;
color: #535353;
width: 100%;
padding: 4px 6px;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
#cboxLoadingOverlay {
background: #fff;
}
#cboxLoadingGraphic {
background: url(images/loading_animation.gif) no-repeat center center;
}
#cboxClose.cbox-close-plain {
position: absolute;
font-size: 20px;
line-height: 18px;;
text-align: center;
color: rgba(255, 255, 255, 0.7);
background: rgba(0, 0, 0, 0.5);
top: 4px;
right: 4px;
width: 20px;
height: 20px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
.cbox-close-plain:hover {
color: rgba(255, 255, 255, 0.9);
background: rgba(0, 0, 0, 0.8);
}

View File

@@ -0,0 +1,33 @@
(function ($) {
Drupal.behaviors.initColorboxPlainStyle = {
attach: function (context, settings) {
$(document).bind('cbox_complete', function () {
// Make all the controls invisible.
$('#cboxCurrent, #cboxSlideshow, #cboxPrevious, #cboxNext', context).addClass('element-invisible');
// Replace "Close" with "×" and show.
$('#cboxClose', context).html('\327').addClass('cbox-close-plain');
// Hide empty title.
if ($('#cboxTitle:empty', context).length == true) {
$('#cboxTitle', context).hide();
}
$('#cboxLoadedContent', context).bind('mouseover', function () {
$('#cboxClose', context).animate({opacity: 1}, {queue: false, duration: "fast"});
if ($('#cboxTitle:empty', context).length == false) {
$('#cboxTitle', context).slideDown();
}
});
$('#cboxOverlay', context).bind('mouseover', function () {
$('#cboxClose', context).animate({opacity: 0}, {queue: false, duration: "fast"});
if ($('#cboxTitle:empty', context).length == false) {
$('#cboxTitle', context).slideUp();
}
});
});
$(document).bind('cbox_closed', function () {
$('#cboxClose', context).removeClass('cbox-close-plain');
});
}
};
})(jQuery);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

View File

@@ -0,0 +1,218 @@
/**
* Colorbox Core Style:
* The following CSS is consistent between example themes and should not be altered.
*/
#colorbox, #cboxOverlay, #cboxWrapper {
position: absolute;
top: 0;
left: 0;
z-index: 9999;
overflow: hidden;
}
#cboxOverlay {
position: fixed;
width: 100%;
height: 100%;
}
#cboxMiddleLeft, #cboxBottomLeft {
clear: left;
}
#cboxContent {
position: relative;
}
#cboxLoadedContent {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
#cboxTitle {
margin: 0;
}
#cboxLoadingOverlay, #cboxLoadingGraphic {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/**
* These elements are buttons, and may need to have additional
* styles reset to avoid unwanted base styles.
*/
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow {
border: 0;
padding: 0;
margin: 0;
overflow: visible;
width: auto;
background: none;
cursor: pointer;
}
/**
* Avoid outlines on :active (mouseclick),
* but preserve outlines on :focus (tabbed navigating)
*/
#cboxPrevious:active, #cboxNext:active, #cboxClose:active, #cboxSlideshow:active {
outline: 0;
}
.cboxPhoto {
float: left;
margin: auto;
border: 0;
display: block;
max-width: none;
}
.cboxIframe {
width: 100%;
height: 100%;
display: block;
border: 0;
}
/* Reset box sizing to content-box if theme is using border-box. */
#colorbox, #cboxContent, #cboxLoadedContent {
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
/**
* Colorbox module Stockholm syndrome style:
* The styles are ordered & tabbed in a way that represents
* the nesting of the generated HTML.
*/
#cboxOverlay {
background: #000;
}
#colorbox {
background: #fff url(images/bg_tab.png) center bottom repeat-x;
-moz-box-shadow: 3px 3px 16px #333;
-webkit-box-shadow: 3px 3px 16px #333;
box-shadow: 3px 3px 16px #333;
-moz-border-radius-bottomleft: 9px;
-moz-border-radius-bottomright: 9px;
-webkit-border-bottom-left-radius: 9px;
-webkit-border-bottom-right-radius: 9px;
border-bottom-left-radius: 9px;
border-bottom-right-radius: 9px;
outline: 0;
}
#colorbox, #colorbox div {
overflow: visible; /* Required by the close button. */
}
#cboxWrapper {
-moz-border-radius-bottomleft: 9px;
-moz-border-radius-bottomright: 9px;
-webkit-border-bottom-left-radius: 9px;
-webkit-border-bottom-right-radius: 9px;
border-bottom-left-radius: 9px;
border-bottom-right-radius: 9px;
}
#cboxTopLeft {
width: 0;
height: 0;
}
#cboxTopCenter {
height: 0;
}
#cboxTopRight {
width: 0;
height: 0;
}
#cboxBottomLeft {
width: 15px;
height: 10px;
}
#cboxBottomCenter {
height: 10px;
}
#cboxBottomRight {
width: 15px;
height: 10px;
}
#cboxMiddleLeft {
width: 0;
}
#cboxMiddleRight {
width: 0;
}
#cboxContent {
background: #fff;
overflow: hidden;
margin-bottom: 28px;
}
#cboxError {
padding: 50px;
border: 1px solid #ccc;
}
#cboxLoadedContent {
}
#cboxTitle {
left: 0;
height: 38px;
color: #313131;
padding: 0 140px 0 15px;
display: table-cell;
vertical-align: middle;
}
#cboxCurrent {
position: absolute;
bottom: -26px;
right: 80px;
color: #313131;
border-left: 1px solid #313131;
padding: 0 0 0 15px;
}
/* Slideshow not implemented. */
.cboxSlideshow_on #cboxSlideshow {
display: none;
}
.cboxSlideshow_on #cboxSlideshow:hover {
}
.cboxSlideshow_off #cboxSlideshow {
display: none;
}
.cboxSlideshow_off #cboxSlideshow:hover {
}
#cboxPrevious {
position: absolute;
bottom: -26px;
right: 45px;
background: url(images/controls.png) no-repeat 0 -48px;
width: 21px;
height: 15px;
text-indent: -9999px;
}
#cboxPrevious:hover {
background-position: 0 -111px;
}
#cboxNext {
position: absolute;
bottom: -26px;
right: 15px;
background: url(images/controls.png) no-repeat 0 -29px;
width: 21px;
height: 15px;
text-indent: -9999px;
}
#cboxNext:hover {
background-position: 0 -92px;
}
#cboxLoadingOverlay {
background: #e6e6e6;
}
#cboxLoadingGraphic {
background: url(images/loading_animation.gif) no-repeat center center;
}
#cboxClose {
position: absolute;
top: -10px;
right: -10px;
background: url(images/controls.png) no-repeat 0px 0px;
width: 25px;
height: 25px;
text-indent: -9999px;
opacity: 0;
}
#cboxClose:hover {
background-position: 0 -63px;
}

View File

@@ -0,0 +1,20 @@
(function ($) {
Drupal.behaviors.initColorboxStockholmsyndromeStyle = {
attach: function (context, settings) {
$(document).bind('cbox_open', function () {
// Hide close button initially.
$('#cboxClose', context).css('opacity', 0);
});
$(document).bind('cbox_load', function () {
// Hide close button. (It doesn't handle the load animation well.)
$('#cboxClose', context).css('opacity', 0);
});
$(document).bind('cbox_complete', function () {
// Show close button with a delay.
$('#cboxClose', context).fadeTo('fast', 0, function () {$(this).css('opacity', 1)});
});
}
};
})(jQuery);

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,28 @@
<?php
/**
* @file
* colorbox.views.inc
*/
/**
* Implementation of hook_views_data()
*/
function colorbox_views_data() {
$data['colorbox']['table']['group'] = t('Colorbox');
$data['colorbox']['table']['join'] = array(
'#global' => array(),
);
$data['colorbox']['colorbox'] = array(
'title' => t('Colorbox trigger'),
'help' => t('Provide custom text or link.'),
'field' => array(
'handler' => 'colorbox_handler_field_colorbox',
),
);
return $data;
}

View File

@@ -0,0 +1,198 @@
<?php
/**
* @file
* Views handlers for Colorbox module.
*/
/**
* A handler to provide a field that is completely custom by the administrator.
*
* @ingroup views_field_handlers
*/
class colorbox_handler_field_colorbox extends views_handler_field {
function query() {
// Do nothing, as this handler does not need to do anything to the query itself.
}
function option_definition() {
$options = parent::option_definition();
$options['trigger_field'] = array('default' => '');
$options['popup'] = array('default' => '');
$options['caption'] = array('default' => '');
$options['gid'] = array('default' => TRUE);
$options['custom_gid'] = array('default' => '');
$options['width'] = array('default' => '600px');
$options['height'] = array('default' => '400px');
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Get a list of the available fields and arguments for trigger field and token replacement.
$options = array();
$fields = array('trigger_field' => t('- None -'));
foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
$options[t('Fields')]["[$field]"] = $handler->ui_name();
// We only use fields up to (and including) this one.
if ($field == $this->options['id']) {
break;
}
$fields[$field] = $handler->definition['title'];
}
$count = 0; // This lets us prepare the key as we want it printed.
foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
$options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name()));
$options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name()));
}
$this->document_self_tokens($options[t('Fields')]);
// Default text.
$patterns = t('<p>You must add some additional fields to this display before using this field. These fields may be marked as <em>Exclude from display</em> if you prefer. Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.</p>');
// We have some options, so make a list.
if (!empty($options)) {
$patterns = t('<p>The following tokens are available for this field. Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.
If you would like to have the characters %5B and %5D please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.</p>');
foreach (array_keys($options) as $type) {
if (!empty($options[$type])) {
$items = array();
foreach ($options[$type] as $key => $value) {
$items[] = $key . ' == ' . $value;
}
$patterns .= theme('item_list',
array(
'items' => $items,
'type' => $type
));
}
}
}
$form['trigger_field'] = array(
'#type' => 'select',
'#title' => t('Trigger field'),
'#description' => t('Select the field that should be turned into the trigger for the Colorbox. Only fields that appear before this one in the field list may be used.'),
'#options' => $fields,
'#default_value' => $this->options['trigger_field'],
'#weight' => -12,
);
$form['popup'] = array(
'#type' => 'textarea',
'#title' => t('Popup'),
'#description' => t('The Colorbox popup content. You may include HTML. You may enter data from this view as per the "Replacement patterns" below.'),
'#default_value' => $this->options['popup'],
'#weight' => -11,
);
$form['caption'] = array(
'#type' => 'textfield',
'#title' => t('Caption'),
'#description' => t('The Colorbox Caption. You may include HTML. You may enter data from this view as per the "Replacement patterns" below.'),
'#default_value' => $this->options['caption'],
'#weight' => -10,
);
$form['gid'] = array(
'#type' => 'checkbox',
'#title' => t('Automatic generated Colorbox gallery'),
'#description' => t('Enable Colorbox gallery using a generated gallery id for this view.'),
'#default_value' => $this->options['gid'],
'#weight' => -9,
);
$form['custom_gid'] = array(
'#type' => 'textfield',
'#title' => t('Custom Colorbox gallery'),
'#description' => t('Enable Colorbox gallery with a given string as gallery. Overrides the automatically generated gallery id above.'),
'#default_value' => $this->options['custom_gid'],
'#weight' => -8,
);
$form['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#description' => t('Specify the width of the Colorbox popup window. Because the content is dynamic, we cannot detect this value automatically. Example: "100%", 500, "500px".'),
'#default_value' => $this->options['width'],
'#weight' => -6,
);
$form['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#description' => t('Specify the height of the Colorbox popup window. Because the content is dynamic, we cannot detect this value automatically. Example: "100%", 500, "500px".'),
'#default_value' => $this->options['height'],
'#weight' => -7,
);
$form['patterns'] = array(
'#type' => 'fieldset',
'#title' => t('Replacement patterns'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#value' => $patterns,
);
}
/**
* Render the trigger field and its linked popup information.
*/
function render($values) {
// Load the necessary js file for Colorbox activation.
if (_colorbox_active() && !variable_get('colorbox_inline', 0)) {
drupal_add_js(drupal_get_path('module', 'colorbox') . '/js/colorbox_inline.js');
}
// We need to have multiple unique IDs, one for each record.
static $i = 0;
$i = mt_rand();
// Return nothing if no trigger filed is selected.
if (empty($this->options['trigger_field'])) {
return;
}
// Get the token information and generate the value for the popup and the
// caption.
$tokens = $this->get_render_tokens($this->options['alter']);
$popup = filter_xss_admin($this->options['popup']);
$caption = filter_xss_admin($this->options['caption']);
$popup = strtr($popup, $tokens);
$caption = strtr($caption, $tokens);
$width = $this->options['width'] ? $this->options['width'] : '';
$height = $this->options['height'] ? $this->options['height'] : '';
$gallery_id = !empty($this->options['custom_gid']) ? $this->options['custom_gid'] : ($this->options['gid'] ? 'gallery-' . $this->view->name : '');
$link_text = $tokens["[{$this->options['trigger_field']}]"];
$link_options = array(
'html' => TRUE,
'fragment' => 'colorbox-inline-' . $i,
'query' => array(
'width' => $width,
'height' => $height,
'title' => $caption,
'inline' => 'true'
),
'attributes' => array(
'class' => array('colorbox-inline'),
'rel' => $gallery_id
)
);
// Remove any parameters that aren't set.
$link_options['query'] = array_filter($link_options['query']);
// If the nid is present make the link degrade to the node page if
// JavaScript is off.
$link_target = isset($values->nid) ? 'node/' . $values->nid : '';
$link_tag = l($link_text, $link_target, $link_options);
// The outside div is there to hide all of the divs because if the specific Colorbox
// div is hidden it won't show up as a Colorbox.
return $link_tag . '<div style="display: none;"><div id="colorbox-inline-' . $i . '">' . $popup . '</div></div>';
}
}

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,35 @@
The External Links module is a very simple approach to adding icons to links
to external websites or e-mail addresses. It is a purely JavaScript
implementation, so the icons are only shown to users that have JavaScript
enabled.
External Links was written by Nathan Haug.
Built by Robots: http://www.lullabot.com
Install
-------
Simply install External Links like you would any other module.
1) Copy the extlink folder to the modules folder in your installation.
2) Enable the module using Administer -> Modules (/admin/build/modules).
3) No additional configuration is necessary though you may fine-tune settings at
Administer -> Site configuration -> External Links (/admin/settings/extlink).
A note about the CSS
--------------------
This module adds a CSS file that is only a few lines in length. You may choose
to move this CSS to your theme to prevent the file from needing to be loaded
separately. To do this:
1) Open the .info file for your theme, add this line of code to prevent
the extlink.css file from loading:
stylesheets[all][] = extlink.css
2) Open the extlink.css file within the extlink directory and copy all the code
from the file into your theme's style.css file.
3) Copy the extlink.png and mailto.png files to your theme's directory.
Note that you DO NOT need to make a extlink.css file. Specifying the file in the
info file is enough to tell Drupal not to load the original file.

View File

@@ -0,0 +1,16 @@
span.ext {
background: url(extlink.png) right center no-repeat;
padding-right: 12px;
}
span.mailto {
background: url(mailto.png) right center no-repeat;
padding-right: 12px;
}
/* Hide the extra spans when printing. */
@media print {
span.ext, span.mailto {
display: none;
padding: 0;
}
}

View File

@@ -0,0 +1,14 @@
name = External Links
description = Determine behavior and appearance for external links. Options include: Make external links open in a new window, add icons next to external links and email addresses, display pop-up warnings when users click external links.
package = User interface
core = 7.x
configure = admin/config/user-interface/extlink
stylesheets[all][] = extlink.css
files[] = extlink.test
; Information added by drupal.org packaging script on 2013-07-29
version = "7.x-1.13"
core = "7.x"
project = "extlink"
datestamp = "1375069568"

View File

@@ -0,0 +1,17 @@
<?php
/**
* Implementation of hook_install().
*/
function extlink_install() {
// Weight needs to be 1 for compatibility with SpamSpan.
db_query("UPDATE {system} SET weight = 1 WHERE name = 'extlink'");
}
/**
* Implementation of hook_uninstall().
*/
function extlink_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'extlink_%'");
cache()->deleteTags(array('variables' => TRUE));
}

View File

@@ -0,0 +1,126 @@
(function ($) {
function extlinkAttach(context) {
// Strip the host name down, removing ports, subdomains, or www.
var pattern = /^(([^\/:]+?\.)*)([^\.:]{4,})((\.[a-z]{1,4})*)(:[0-9]{1,5})?$/;
var host = window.location.host.replace(pattern, '$3$4');
var subdomain = window.location.host.replace(pattern, '$1');
// Determine what subdomains are considered internal.
if (Drupal.settings.extlink.extSubdomains) {
var subdomains = "([^/]*\\.)?";
}
else if (subdomain == 'www.' || subdomain == '') {
var subdomains = "(www\\.)?";
}
else {
var subdomains = subdomain.replace(".", "\\.");
}
// Build regular expressions that define an internal link.
var internal_link = new RegExp("^https?://" + subdomains + host, "i");
// Extra internal link matching.
var extInclude = false;
if (Drupal.settings.extlink.extInclude) {
extInclude = new RegExp(Drupal.settings.extlink.extInclude.replace(/\\/, '\\'));
}
// Extra external link matching.
var extExclude = false;
if (Drupal.settings.extlink.extExclude) {
extExclude = new RegExp(Drupal.settings.extlink.extExclude.replace(/\\/, '\\'));
}
// Extra external link CSS selector exclusion.
var extCssExclude = false;
if (Drupal.settings.extlink.extCssExclude) {
extCssExclude = Drupal.settings.extlink.extCssExclude;
}
// Extra external link CSS selector explicit.
var extCssExplicit = false;
if (Drupal.settings.extlink.extCssExplicit) {
extCssExplicit = Drupal.settings.extlink.extCssExplicit;
}
// Find all links which are NOT internal and begin with http (as opposed
// to ftp://, javascript:, etc. other kinds of links.
// When operating on the 'this' variable, the host has been appended to
// all links by the browser, even local ones.
// In jQuery 1.1 and higher, we'd use a filter method here, but it is not
// available in jQuery 1.0 (Drupal 5 default).
var external_links = new Array();
var mailto_links = new Array();
$("a:not(." + Drupal.settings.extlink.extClass + ", ." + Drupal.settings.extlink.mailtoClass + "), area:not(." + Drupal.settings.extlink.extClass + ", ." + Drupal.settings.extlink.mailtoClass + ")", context).each(function(el) {
try {
var url = this.href.toLowerCase();
if (url.indexOf('http') == 0
&& (!url.match(internal_link) || (extInclude && url.match(extInclude)))
&& !(extExclude && url.match(extExclude))
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
external_links.push(this);
}
// Do not include area tags with begin with mailto: (this prohibits
// icons from being added to image-maps).
else if (this.tagName != 'AREA'
&& url.indexOf('mailto:') == 0
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
mailto_links.push(this);
}
}
// IE7 throws errors often when dealing with irregular links, such as:
// <a href="node/10"></a> Empty tags.
// <a href="http://user:pass@example.com">example</a> User:pass syntax.
catch(error) {
return false;
}
});
if (Drupal.settings.extlink.extClass) {
// Apply the "ext" class to all links not containing images.
if (parseFloat($().jquery) < 1.2) {
$(external_links).not('[img]').addClass(Drupal.settings.extlink.extClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.extClass + '></span>'); });
}
else {
$(external_links).not($(external_links).find('img').parents('a')).addClass(Drupal.settings.extlink.extClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.extClass + '></span>'); });
}
}
if (Drupal.settings.extlink.mailtoClass) {
// Apply the "mailto" class to all mailto links not containing images.
if (parseFloat($().jquery) < 1.2) {
$(mailto_links).not('[img]').addClass(Drupal.settings.extlink.mailtoClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.mailtoClass + '></span>'); });
}
else {
$(mailto_links).not($(mailto_links).find('img').parents('a')).addClass(Drupal.settings.extlink.mailtoClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.mailtoClass + '></span>'); });
}
}
if (Drupal.settings.extlink.extTarget) {
// Apply the target attribute to all links.
$(external_links).attr('target', Drupal.settings.extlink.extTarget);
}
if (Drupal.settings.extlink.extAlert) {
// Add pop-up click-through dialog.
$(external_links).click(function(e) {
return confirm(Drupal.settings.extlink.extAlertText);
});
}
// Work around for Internet Explorer box model problems.
if (($.support && !($.support.boxModel === undefined) && !$.support.boxModel) || ($.browser.msie && parseInt($.browser.version) <= 7)) {
$('span.ext, span.mailto').css('display', 'inline-block');
}
}
Drupal.behaviors.extlink = {
attach: function(context){
extlinkAttach(context);
}
}
})(jQuery);

View File

@@ -0,0 +1,184 @@
<?php
function extlink_menu() {
$items = array();
$items['admin/config/user-interface/extlink'] = array(
'title' => 'External links',
'description' => 'Alter the display of external links on the site.',
'page callback' => 'drupal_get_form',
'page arguments' => array('extlink_admin_settings'),
'access callback' => 'user_access',
'access arguments' => array('administer site configuration'),
);
return $items;
}
/**
* Implementation of hook_init().
*/
function extlink_page_build() {
$path = drupal_get_path('module', 'extlink');
drupal_add_js($path .'/extlink.js', array('every_page' => TRUE));
drupal_add_js(array('extlink' => array(
'extTarget' => variable_get('extlink_target', 0),
'extClass' => variable_get('extlink_class', 'ext'),
'extSubdomains' => variable_get('extlink_subdomains', 1),
'extExclude' => variable_get('extlink_exclude', ''),
'extInclude' => variable_get('extlink_include', ''),
'extCssExclude' => variable_get('extlink_css_exclude', ''),
'extCssExplicit' => variable_get('extlink_css_explicit', ''),
'extAlert' => variable_get('extlink_alert', 0),
'extAlertText' => variable_get('extlink_alert_text', 'This link will take you to an external web site. We are not responsible for their content.'),
'mailtoClass' => variable_get('extlink_mailto_class', 'mailto'))), 'setting'
);
}
function extlink_admin_settings() {
$form = array();
$form['extlink_class'] = array(
'#type' => 'checkbox',
'#title' => t('Place an icon next to external links.'),
'#return_value' => 'ext',
'#default_value' => variable_get('extlink_class', 'ext'),
'#description' => t('Places an !icon icon next to external links.', array('!icon' => theme('image', array('path' => drupal_get_path('module', 'extlink') . '/extlink.png', 'alt' => t('External Links icon'))))),
);
$form['extlink_mailto_class'] = array(
'#type' => 'checkbox',
'#title' => t('Place an icon next to mailto links'),
'#return_value' => 'mailto',
'#default_value' => variable_get('extlink_mailto_class', 'mailto'),
'#description' => t('Places an !icon icon next to mailto links.', array('!icon' => theme('image',array('path' => drupal_get_path('module', 'extlink') . '/mailto.png', 'alt' => t('Email links icon'))))),
);
$form['extlink_subdomains'] = array(
'#type' => 'checkbox',
'#title' => t('Exclude links with the same primary domain.'),
'#default_value' => variable_get('extlink_subdomains', 1),
'#description' => t("For example, a link from 'www.example.com' to the subdomain of 'my.example.com' would be excluded."),
);
$form['extlink_target'] = array(
'#type' => 'checkbox',
'#title' => t('Open external links in a new window'),
'#return_value' => '_blank',
'#default_value' => variable_get('extlink_target', 0),
);
$form['extlink_alert'] = array(
'#type' => 'checkbox',
'#title' => t('Display a pop-up warning when any external link is clicked.'),
'#return_value' => '_blank',
'#default_value' => variable_get('extlink_alert', 0),
);
$form['extlink_alert_text'] = array(
'#type' => 'textarea',
'#title' => t('Text to display in the pop-up warning box.'),
'#rows' => 3,
'#default_value' => variable_get('extlink_alert_text', 'This link will take you to an external web site.'),
'#wysiwyg' => FALSE,
'#states' => array(
// Only show this field when user opts to display a pop-up warning.
'visible' => array(
':input[name="extlink_alert"]' => array('checked' => TRUE),
),
),
);
$patterns = array(
'<em>(example\.com)</em> ' . t('Matches example.com.'),
'<em>(example\.com)|(example\.net)</em> ' . t('Multiple patterns can be strung together by using a pipe. Matches example.com OR example.net.'),
'<em>(links/goto/[0-9]+/[0-9]+)</em> ' . t('Matches links that go through the <a href="http://drupal.org/project/links">Links module</a> redirect.'),
);
$wildcards = array(
'<em>.</em> ' . t('Matches any character.'),
'<em>?</em> ' . t('The previous character or set is optional.'),
'<em>\d</em> ' . t('Matches any digit (0-9).'),
'<em>[a-z]</em> ' . t('Brackets may be used to match a custom set of characters. This matches any alphabetic letter.'),
);
$form['patterns'] = array(
'#tree' => FALSE,
'#type' => 'fieldset',
'#title' => t('Pattern matching'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' =>
'<p>' . t('External links uses patterns (regular expressions) to match the "href" property of links.') . '</p>' .
t('Here are some common patterns.') .
theme('item_list', array('items' => $patterns)) .
t('Common special characters:') .
theme('item_list', array('items' => $wildcards)) .
'<p>' . t('All special characters (<em>^ $ . ? ( ) | * +</em>) must also be escaped with backslashes. Patterns are not case-sensitive. Any <a href="http://www.javascriptkit.com/javatutors/redev2.shtml">pattern supported by JavaScript</a> may be used.') . '</p>',
);
$form['patterns']['extlink_exclude'] = array(
'#type' => 'textfield',
'#title' => t('Exclude links matching the pattern'),
'#maxlength' => NULL,
'#default_value' => variable_get('extlink_exclude', ''),
'#description' => t('Enter a regular expression for links that you wish to exclude from being considered external.'),
);
$form['patterns']['extlink_include'] = array(
'#type' => 'textfield',
'#title' => t('Include links matching the pattern'),
'#maxlength' => NULL,
'#default_value' => variable_get('extlink_include', ''),
'#description' => t('Enter a regular expression for internal links that you wish to be considered external.'),
);
$form['css_matching'] = array(
'#tree' => FALSE,
'#type' => 'fieldset',
'#title' => t('CSS Matching'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' =>
'<p>' . t('Use CSS selectors to exclude entirely or only look inside explicitly specified classes and IDs for external links. These will be passed straight to jQuery for matching.') . '</p>',
);
$form['css_matching']['extlink_css_exclude'] = array(
'#type' => 'textarea',
'#title' => t('Exclude links inside these CSS selectors'),
'#maxlength' => NULL,
'#default_value' => variable_get('extlink_css_exclude', ''),
'#description' => t('Enter a comma-separated list of CSS selectors (ie "#block-block-2 .content, ul.menu")'),
);
$form['css_matching']['extlink_css_explicit'] = array(
'#type' => 'textarea',
'#title' => t('Only look for links inside these CSS selectors'),
'#maxlength' => NULL,
'#default_value' => variable_get('extlink_css_explicit', ''),
'#description' => t('Enter a comma-separated list of CSS selectors (ie "#block-block-2 .content, ul.menu")'),
);
return system_settings_form($form);
}
function extlink_admin_settings_validate($form, &$form_state) {
// Check if the exclude pattern is a valid regular expression
if ($exclude = $form_state['values']['extlink_exclude']) {
// Testing the regex via replace
$regexeval = @preg_replace('/' . $exclude . '/', '', 'Lorem ipsum');
// If the regex returns NULL, then throw an error and reset the variable
if ($regexeval === NULL) {
form_set_error('extlink_exclude', t('Invalid regular expression.'));
variable_set('extlink_exclude', '');
}
}
// Check if the include pattern is a valid regular expression
if ($include = $form_state['values']['extlink_include']) {
// Testing the regex via replace
$regexeval = @preg_replace('/' . $include . '/', '', 'Lorem ipsum');
// If the regex returns NULL, then throw an error and reset the variable
if ($regexeval === NULL) {
form_set_error('extlink_include', t('Invalid regular expression.'));
variable_set('extlink_include', '');
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

View File

@@ -0,0 +1,25 @@
<?php
/**
* Administration tests for my module.
*/
class ExtlinkAdministrationTestCase extends DrupalWebTestCase {
/**
* Implements getInfo().
*/
public static function getInfo() {
return array (
'name' => t('Administration'),
'description' => t('Administration tests for my module.'),
'group' => t('External Links'),
);
}
public function
setUp() {
// Enable any module that you will need in your tests.
parent::setUp();
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B