diff --git a/sites/all/modules/contrib/backup_migrate/LICENSE.txt b/sites/all/modules/contrib/backup_migrate/LICENSE.txt
new file mode 100644
index 0000000..d159169
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/LICENSE.txt
@@ -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.
+
+
+ Copyright (C)
+
+ 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.
+
+ , 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.
diff --git a/sites/all/modules/contrib/backup_migrate/README.txt b/sites/all/modules/contrib/backup_migrate/README.txt
new file mode 100644
index 0000000..9fc089b
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/README.txt
@@ -0,0 +1,89 @@
+
+-------------------------------------------------------------------------------
+Backup and Migrate 3 for Drupal 7.x
+ by Ronan Dowling, Gorton Studios - ronan (at) gortonstudios (dot) com
+-------------------------------------------------------------------------------
+
+DESCRIPTION:
+This module makes the task of backing up your Drupal database, code and uploaded
+files and of migrating data from one Drupal install to another easier.
+
+Database backup files are a list of SQL statements which can be executed with a
+tool such as phpMyAdmin or the command-line mysql client. File and code
+backup files are tarballs which can be restored by extracting them to the
+desired directory.
+
+-------------------------------------------------------------------------------
+
+INSTALLATION:
+* Put the module in your Drupal modules directory and enable it in
+ admin/modules.
+* Go to admin/people/permissions and grant permission to any roles that need to be
+ able to backup or restore the database.
+* Configure and use the module at admin/config/system/backup_migrate
+
+OPTIONAL:
+* Enable token.module to allow token replacement in backup file names.
+* To Backup to Amazon S3:
+ - Download the S3 library from http://undesigned.org.za/2007/10/22/amazon-s3-php-class
+ and place the file 'S3.php' in the includes directory in this module.
+ The stable version (0.4.0 – 20th Jul 2009) works best with Backup and Migrate.
+
+LIGHTTPD USERS:
+Add the following code to your lighttp.conf to secure your backup directories:
+ $HTTP["url"] =~ "^/sites/default/files/backup_migrate/" {
+ url.access-deny = ( "" )
+ }
+You may need to adjust the path to reflect the actual path to the files.
+
+IIS 7 USERS:
+Add the following code to your web.config code to secure your backup directories:
+
+
+
+
+You may need to adjust the path to reflect the actual path to the files.
+
+-------------------------------------------------------------------------------
+
+VERY IMPORTANT SECURITY NOTE:
+Backup files may contain sensitive data and by default, are saved to your web
+server in a directory normally accessible by the public. This could lead to a
+very serious security vulnerability. Backup and Migrate attempts to protect
+backup files using a .htaccess file, but this is not guaranteed to work on all
+environments (and is guaranteed to fail on web servers that are not apache). You
+should test to see if your backup files are publicly accessible, and if in doubt
+do not save backups to the server, or use the destinations feature to save to a
+folder outside of your webroot.
+
+OTHER WARNINGS:
+A failed restore can destroy your database and therefore your entire Drupal
+installation. ALWAYS TEST BACKUP FILES ON A TEST ENVIRONMENT FIRST. If in doubt
+do not use this module.
+
+This module has only been tested with MySQL and does not work with any other dbms.
+If you have experiences with Postgres or any other dbms and are willing to help
+test and modify the module to work with it, please contact the developer at
+ronan (at) gortonstudios (dot) com.
+
+Make sure your php timeout is set high enough to complete a backup or restore
+operation. Larger databases require more time. Also, while the module attempts
+to keep memory needs to a minimum, a backup or restore will require
+significantly more memory then most Drupal operations.
+
+If your backup file contains the 'sessions' table all other users will be logged
+out after you run a restore. To avoid this, exclude the sessions table when
+creating your backups. Be aware though that you will need to recreate the
+sessions table if you use this backup on an empty database.
+
+Do not change the file extension of backup files or the restore function will be
+unable to determine the compression type the file and will not function
+correctly.
+
+IF A RESTORE FAILS:
+Don't panic, the restore file should work with phpMyAdmin's import function, or
+with the mysql command line tool. If it does not, then it is likely corrupt; you
+may panic now. MAKE SURE THAT THIS MODULE IS NOT YOUR ONLY FORM OF BACKUP.
+
+-------------------------------------------------------------------------------
+
diff --git a/sites/all/modules/contrib/backup_migrate/backup_migrate.css b/sites/all/modules/contrib/backup_migrate/backup_migrate.css
new file mode 100644
index 0000000..59554e7
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/backup_migrate.css
@@ -0,0 +1,67 @@
+.schedule-list-disabled
+{
+ filter:alpha(opacity=50);
+ -moz-opacity: .50;
+ opacity: .50;
+}
+
+.backup-migrate-cache-time {
+ font-size: 0.85em;
+}
+
+.backup-migrate-tables-checkboxes .form-item {
+ width: 15em;
+ float: left;
+ overflow: hidden;
+ white-space: nowrap;
+ height: 1.75em;
+ margin: .25em .25em 0 0;
+}
+.backup-migrate-tables-checkboxes .form-item label input {
+ margin-right: .5em;
+}
+
+div.backup-migrate-tables-checkboxes {
+ height: 20em;
+ overflow: auto;
+}
+div.backup-migrate-tags,
+div.backup-migrate-description,
+div.backup-migrate-date
+{
+ font-size: smaller;
+}
+span.backup-migrate-label {
+ font-weight: bold;
+}
+table.backup-migrate-listing td {
+ vertical-align: top;
+}
+
+div.row-error {
+ color: #FF0000;
+ font-weight: bold;
+}
+
+.backup-migrate-listing {
+ margin-bottom: 2em;
+}
+.backup-migrate-actions {
+ text-align: right;
+}
+
+html.js #backup-migrate-ui-manual-quick-backup-form fieldset.collapsed,
+.backup-migrate-inline {
+ margin-bottom: 1em;
+}
+
+.backup-migrate-form-dependent {
+ padding-left: 2em;
+ padding-bottom: 1em;
+}
+.backup-migrate-form-dependent .form-item {
+ margin-top: 0;
+}
+.backup-migrate-footer-message {
+ margin-bottom: 1em;
+}
diff --git a/sites/all/modules/contrib/backup_migrate/backup_migrate.info b/sites/all/modules/contrib/backup_migrate/backup_migrate.info
new file mode 100644
index 0000000..eb9258a
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/backup_migrate.info
@@ -0,0 +1,16 @@
+name = Backup and Migrate
+description = "Backup the Drupal database and files or migrate them to another environment."
+core = 7.x
+
+files[] = includes/destinations.inc
+files[] = includes/profiles.inc
+files[] = includes/schedules.inc
+
+configure = admin/config/system/backup_migrate
+
+; Information added by Drupal.org packaging script on 2015-05-11
+version = "7.x-3.1"
+core = "7.x"
+project = "backup_migrate"
+datestamp = "1431350582"
+
diff --git a/sites/all/modules/contrib/backup_migrate/backup_migrate.install b/sites/all/modules/contrib/backup_migrate/backup_migrate.install
new file mode 100644
index 0000000..97820cb
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/backup_migrate.install
@@ -0,0 +1,644 @@
+ array(
+ 'key' => 'machine_name',
+ 'key name' => 'Profile ID',
+ 'admin_title' => 'name',
+ 'primary key' => 'profile_id',
+ 'identifier' => 'item', // Exports will be defined as $preset
+ 'default hook' => 'exportables_backup_migrate_profiles', // Function hook name.
+ 'api' => array(
+ 'owner' => 'backup_migrate',
+ 'api' => 'backup_migrate_exportables', // Base name for api include files.
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
+ 'fields' => array(
+ 'profile_id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ 'no export' => TRUE, // Do not export database-only keys.
+ ),
+ 'machine_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The primary identifier for a profile.',
+ ),
+ 'name' => array(
+ 'description' => 'The name of the profile.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE
+ ),
+ 'filename' => array(
+ 'description' => 'The name of the profile.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE
+ ),
+ 'append_timestamp' => array(
+ 'description' => 'Append a timestamp to the filename.',
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0
+ ),
+ 'timestamp_format' => array(
+ 'description' => 'The format of the timestamp.',
+ 'type' => 'varchar',
+ 'length' => 14,
+ 'not null' => TRUE
+ ),
+ 'filters' => array(
+ 'description' => 'The filter settings for the profile.',
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ),
+ ),
+ 'primary key' => array('profile_id'),
+ );
+ $schema['backup_migrate_destinations'] = array(
+ 'export' => array(
+ 'key' => 'machine_name',
+ 'key name' => 'Destination ID',
+ 'admin_title' => 'name',
+ 'primary key' => 'destination_id',
+ 'identifier' => 'item', // Exports will be defined as $preset
+ 'default hook' => 'exportables_backup_migrate_destinations', // Function hook name.
+ 'api' => array(
+ 'owner' => 'backup_migrate',
+ 'api' => 'backup_migrate_exportables', // Base name for api include files.
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
+ 'fields' => array(
+ 'destination_id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ 'no export' => TRUE, // Do not export database-only keys.
+ ),
+ 'machine_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The primary identifier for a destination.',
+ ),
+ 'name' => array(
+ 'description' => 'The name of the destination.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE
+ ),
+ 'subtype' => array(
+ 'description' => 'The type of the destination.',
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE
+ ),
+ 'location' => array(
+ 'description' => 'The the location string of the destination.',
+ 'type' => 'text',
+ 'not null' => TRUE
+ ),
+ 'settings' => array(
+ 'description' => 'Other settings for the destination.',
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ),
+ ),
+ 'primary key' => array('destination_id'),
+ );
+ $schema['backup_migrate_sources'] = array(
+ 'export' => array(
+ 'key' => 'machine_name',
+ 'key name' => 'Source ID',
+ 'admin_title' => 'name',
+ 'primary key' => 'source_id',
+ 'identifier' => 'item', // Exports will be defined as $preset
+ 'default hook' => 'exportables_backup_migrate_sources', // Function hook name.
+ 'api' => array(
+ 'owner' => 'backup_migrate',
+ 'api' => 'backup_migrate_exportables', // Base name for api include files.
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
+ 'fields' => array(
+ 'source_id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ 'no export' => TRUE, // Do not export database-only keys.
+ ),
+ 'machine_name' => array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The primary identifier for a source.',
+ ),
+ 'name' => array(
+ 'description' => 'The name of the source.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE
+ ),
+ 'subtype' => array(
+ 'description' => 'The type of the source.',
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE
+ ),
+ 'location' => array(
+ 'description' => 'The the location string of the source.',
+ 'type' => 'text',
+ 'not null' => TRUE
+ ),
+ 'settings' => array(
+ 'description' => 'Other settings for the source.',
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ),
+ ),
+ 'primary key' => array('source_id'),
+ );
+
+ $schema['backup_migrate_schedules'] = array(
+ 'export' => array(
+ 'key' => 'machine_name',
+ 'key name' => 'Source ID',
+ 'admin_title' => 'name',
+ 'primary key' => 'schedule_id',
+ 'identifier' => 'item', // Exports will be defined as $preset
+ 'default hook' => 'exportables_backup_migrate_schedules', // Function hook name.
+ 'api' => array(
+ 'owner' => 'backup_migrate',
+ 'api' => 'backup_migrate_exportables', // Base name for api include files.
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
+ 'fields' => array(
+ 'schedule_id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ 'no export' => TRUE, // Do not export database-only keys.
+ ),
+ 'machine_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The primary identifier for a profile.',
+ ),
+ 'name' => array(
+ 'description' => 'The name of the profile.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE
+ ),
+ 'source_id' => array(
+ 'description' => 'The {backup_migrate_destination}.destination_id of the source to backup from.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'default' => 'db',
+ 'not null' => TRUE
+ ),
+ 'destination_id' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The {backup_migrate_destination}.destination_id of the destination to back up to.',
+ ),
+ 'copy_destination_id' => array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'A second {backup_migrate_destination}.destination_id of the destination to copy the backup to.',
+ ),
+ 'profile_id' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The primary identifier for a profile.',
+ ),
+ 'keep' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'The number of backups to keep.',
+ ),
+ 'period' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'The number of seconds between backups.',
+ ),
+ 'enabled' => array(
+ 'description' => 'Whether the schedule is enabled.',
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0
+ ),
+ 'cron' => array(
+ 'description' => 'Whether the schedule should be run during cron.',
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => 'builtin',
+ ),
+ 'cron_schedule' => array(
+ 'description' => 'The cron schedule to run on.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0 4 * * *',
+ ),
+ ),
+ 'primary key' => array('schedule_id'),
+ );
+
+ return $schema;
+}
+
+/**
+ * Implementation of hook_install().
+ */
+function backup_migrate_install() {
+}
+
+/**
+ * Remove variables on uninstall.
+ */
+function backup_migrate_uninstall() {
+ db_query("DELETE FROM {variable} WHERE name LIKE 'backup_migrate_%'");
+ db_query("DELETE FROM {variable} WHERE name LIKE 'nodesquirrel_%'");
+ cache_clear_all('variables', 'cache');
+}
+
+/**
+ * Update from 1.x to 2.x.
+ */
+function backup_migrate_update_2000() {
+ _backup_migrate_setup_database_defaults();
+ return array();
+}
+
+/**
+ * Adding filter field for dev release of 2009-01-28
+ */
+function backup_migrate_update_2001() {
+ $ret = array();
+ $schema = drupal_get_schema_unprocessed('backup_migrate', 'backup_migrate_profiles');
+
+ // Add the filters field to the db.
+ if (!db_field_exists('backup_migrate_profiles', 'filters')) {
+ db_add_field('backup_migrate_profiles', 'filters', array('description' => t('The filter settings for the profile.'),'type' => 'text', 'not null' => TRUE));
+ }
+ // Add the source field
+ if (!db_field_exists('backup_migrate_profiles', 'source_id')) {
+ db_add_field('backup_migrate_profiles', 'source_id', array('description' => t('The {backup_migrate_destination}.destination_id of the source to backup from.'), 'type' => 'varchar', 'length' => 255, 'default' => 'db', 'not null' => TRUE));
+ }
+ // Remove the compression field.
+ if (db_field_exists('backup_migrate_profiles', 'compression')) {
+ db_drop_field('backup_migrate_profiles', 'compression');
+ }
+ return $ret;
+}
+
+/**
+ * Clearing the cache because there was a menu structure change in the dev of 2009-05-31
+ */
+function backup_migrate_update_2002() {
+ // Cache should clear automatically. Nothing to do here.
+ return array();
+}
+
+/**
+ * Allowing non-int profile ids in schedules 2009-05-31
+ */
+function backup_migrate_update_2003() {
+ $ret = array();
+ $spec = array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The primary identifier for a profile.',
+ );
+
+ db_change_field('backup_migrate_schedules', 'profile_id', 'profile_id', $spec);
+ return $ret;
+}
+
+/**
+ * Allowing non-int profile ids 2009-07-01
+ */
+function backup_migrate_update_2004() {
+ $ret = array();
+ $spec = array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ );
+
+ $spec['description'] = 'The primary identifier for a destination.';
+ db_change_field('backup_migrate_destinations', 'destination_id', 'destination_id', $spec);
+
+ $spec['description'] = 'The primary identifier for a profile.';
+ db_change_field('backup_migrate_profiles', 'profile_id', 'profile_id', $spec);
+
+ $spec['description'] = 'The primary identifier for a schedule.';
+ db_change_field('backup_migrate_schedules', 'schedule_id', 'schedule_id', $spec);
+
+ // Drop the user/pass fields as they weren't being used.
+ if (db_field_exists('backup_migrate_destinations', 'username')) {
+ db_drop_field('backup_migrate_destinations', 'username');
+ }
+ if (db_field_exists('backup_migrate_destinations', 'password')) {
+ db_drop_field('backup_migrate_destinations', 'password');
+ }
+
+ return $ret;
+}
+
+/**
+ * Change the default database id to something friendlier 2009-08-08
+ */
+function backup_migrate_update_2005() {
+ require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/crud.inc';
+ require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/profiles.inc';
+
+ $ret = array();
+ // Change the destination ids of the defined database sources mostly to make using them with drush friendlier.
+
+ // Change the db_url:default id to simply 'db'
+ $ret[] = db_query("UPDATE {backup_migrate_profiles} SET source_id = 'db' WHERE source_id = 'db_url:default'");
+ $ret[] = db_query("UPDATE {backup_migrate_schedules} SET destination_id = 'db' WHERE destination_id = 'db_url:default'");
+
+ // Change the defined db keys from db_url:key to db:key.
+ $ret[] = db_query("UPDATE {backup_migrate_profiles} SET source_id = REPLACE(source_id, 'db_url:', 'db:')");
+ $ret[] = db_query("UPDATE {backup_migrate_schedules} SET destination_id = REPLACE(destination_id, 'db_url:', 'db:')");
+
+ // Add the source field to the schedule
+ if (!db_field_exists('backup_migrate_schedules', 'source_id')) {
+ db_add_field('backup_migrate_schedules', 'source_id', array('description' => t('The db source to backup from.'), 'type' => 'varchar', 'length' => 255, 'default' => 'db', 'not null' => TRUE));
+ }
+
+ // Copy source data from profiles to schedules.
+ $result = db_query('SELECT p.source_id, s.schedule_id FROM {backup_migrate_schedules} s LEFT JOIN {backup_migrate_profiles} p ON s.profile_id = p.profile_id', array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $schedule) {
+ if (!$schedule['source_id']) {
+ $schedule['source_id'] = 'db';
+ }
+ $ret[] = db_query("UPDATE {backup_migrate_schedules} SET source_id = '". $schedule['source_id'] ."' WHERE schedule_id = '". $schedule['profile_id'] ."'");
+ }
+
+ if (db_field_exists('backup_migrate_profiles', 'source_id')) {
+ db_drop_field('backup_migrate_profiles', 'source_id');
+ }
+
+ // Copy the no-data and exclude tables settings into the 'filter' field.
+ $result = db_query('SELECT * FROM {backup_migrate_profiles}', array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $item) {
+ if (isset($item['nodata_tables']) && isset($item['exclude_tables'])) {
+ $profile = backup_migrate_get_profile($item['profile_id']);
+ $profile->filters['nodata_tables'] = unserialize($item['nodata_tables']);
+ $profile->filters['exclude_tables'] = unserialize($item['exclude_tables']);
+ $profile->save();
+ }
+ }
+ if (db_field_exists('backup_migrate_profiles', 'nodata_tables')) {
+ db_drop_field('backup_migrate_profiles', 'nodata_tables');
+ }
+ if (db_field_exists('backup_migrate_profiles', 'exclude_tables')) {
+ db_drop_field('backup_migrate_profiles', 'exclude_tables');
+ }
+
+ return $ret;
+}
+
+/**
+ * Move the backup and migrate directory to the private directory.
+ */
+function backup_migrate_update_7200() {
+ $from = 'public://backup_migrate';
+ $to = 'private://backup_migrate';
+ if (drupal_realpath($from) && !drupal_realpath($to)) {
+ if (!rename($from, $to)) {
+ drupal_set_message(t('Unable to move the backups directory to your private folder, please check file permissions and move the directory %from to %to', array('%from' => drupal_realpath($from), '%to' => drupal_realpath($to))), 'warning');
+ }
+ }
+}
+
+
+/**
+ * Change the filename field to support 255 characters.
+ */
+function backup_migrate_update_7202() {
+ $ret = array();
+ db_change_field('backup_migrate_profiles', 'filename', 'filename', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
+ return $ret;
+}
+
+
+/**
+ * Update the schedule last run times to use variables instead of saving with the schedule.
+ */
+function backup_migrate_update_7203() {
+ $result = db_query('SELECT * FROM {backup_migrate_schedules}', array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $item) {
+ if (isset($item['last_run'])) {
+ variable_set('backup_migrate_schedule_last_run_' . $item['schedule_id'], $item['last_run']);
+ }
+ }
+ if (db_field_exists('backup_migrate_schedules', 'last_run')) {
+ db_drop_field('backup_migrate_schedules', 'last_run');
+ }
+}
+
+/**
+ * Uninstall backup migrate files if it's installed
+ */
+function backup_migrate_update_7300() {
+ if (module_exists('backup_migrate_files')) {
+ module_disable(array('backup_migrate_files'));
+ $ret[] = array(
+ 'success' => true,
+ 'query' => 'Disabled the Backup and Migrate Files module',
+ );
+ }
+ if (module_exists('nodesquirrel')) {
+ module_disable(array('nodesquirrel'));
+ $ret[] = array(
+ 'success' => true,
+ 'query' => 'Disabled the NodeSquirrel module',
+ );
+ }
+
+ // Add sources to the schema.
+ $schema['backup_migrate_sources'] = array(
+ 'fields' => array(
+ 'source_id' => array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => t('The primary identifier for a source.'),
+ ),
+ 'name' => array(
+ 'description' => t('The name of the source.'),
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE
+ ),
+ 'type' => array(
+ 'description' => t('The type of the source.'),
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE
+ ),
+ 'location' => array(
+ 'description' => t('The the location string of the source.'),
+ 'type' => 'text',
+ 'not null' => TRUE
+ ),
+ 'settings' => array(
+ 'description' => t('Other settings for the source.'),
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ),
+ ),
+ 'primary key' => array('source_id'),
+ );
+
+ if (!db_table_exists('backup_migrate_sources')) {
+ db_create_table('backup_migrate_sources', $schema['backup_migrate_sources']);
+ }
+
+ // Move custom destinations to sources.
+ $result = db_query("SELECT * FROM {backup_migrate_destinations} WHERE type in ('filesource', 'db')", array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $item) {
+ $item['source_id'] = $item['destination_id'];
+ drupal_write_record('backup_migrate_source', $item);
+ }
+
+ // Change 'destination' settings to 'source' settings
+ $result = db_query('SELECT * FROM {backup_migrate_profiles}', array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $item) {
+ $item['filters'] = unserialize($item['filters']);
+ $item['filters']['sources'] = $item['filters']['destinations'];
+ unset($item['filters']['destinations']);
+ drupal_write_record('backup_migrate_profiles', $item, array('profile_id'));
+ }
+}
+
+/**
+ * Switch the cron switch to text.
+ */
+function backup_migrate_update_7301() {
+ db_change_field('backup_migrate_schedules', 'cron', 'cron', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => 'builtin'));
+ db_add_field('backup_migrate_schedules', 'cron_schedule', array('description' => 'The cron schedule to run on.', 'type' => 'varchar', 'length' => 255, 'default' => '0 4 * * *', 'not null' => TRUE));
+}
+
+/**
+ * Add a second destination to schedules.
+ */
+function backup_migrate_update_7302() {
+ db_add_field('backup_migrate_schedules', 'copy_destination_id',
+ array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'A second {backup_migrate_destination}.destination_id of the destination to copy the backup to.',
+ )
+ );
+}
+
+/**
+ * Add a serial id field to all tables to allow them to be ctools exportable.
+ */
+function backup_migrate_update_7303() {
+ foreach (array('backup_migrate_sources' => 'source_id', 'backup_migrate_destinations' => 'destination_id', 'backup_migrate_schedules' => 'schedule_id', 'backup_migrate_profiles' => 'profile_id') as $table => $id) {
+ // Take the primary key status from the machine name so it can be renamed
+ // A serial field must be defined as a key, so make a temporary index.
+ // See: https://www.drupal.org/node/190027
+ db_add_index($table, 'temp', array($id));
+ db_drop_primary_key($table);
+ // Drop our temporary index.
+ db_drop_index($table, 'temp');
+
+ // Switch the name of the id to 'machine_name' to be more ctools standard
+ db_change_field($table, $id, 'machine_name', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE));
+
+ // Add a serial ID
+ db_add_field($table, $id,
+ array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ 'no export' => TRUE, // Do not export database-only keys.
+ ),
+ array('primary key' => array($id))
+ );
+ }
+ foreach (array('backup_migrate_sources', 'backup_migrate_destinations') as $table) {
+ db_change_field($table, 'type', 'subtype', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE));
+ }
+}
+
+/**
+ * Update all schedules to use the built in cron if none is specified.
+ */
+function backup_migrate_update_7304() {
+ db_query("UPDATE {backup_migrate_schedules} SET cron = 'builtin' WHERE cron = '0'");
+}
diff --git a/sites/all/modules/contrib/backup_migrate/backup_migrate.js b/sites/all/modules/contrib/backup_migrate/backup_migrate.js
new file mode 100644
index 0000000..6105b92
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/backup_migrate.js
@@ -0,0 +1,114 @@
+(function($) {
+ Drupal.behaviors.backupMigrate = {
+ attach: function(context) {
+ if (Drupal.settings.backup_migrate !== undefined) {
+ if (Drupal.settings.backup_migrate.dependents !== undefined) {
+ for (key in Drupal.settings.backup_migrate.dependents) {
+ info = Drupal.settings.backup_migrate.dependents[key];
+ dependent = $('#edit-' + info['dependent']);
+ for (key in info['dependencies']) {
+ $('[name="' + key + '"]').each(function() {
+ var dependentval = info['dependencies'][key];
+ var dependency = $(this);
+ (function(dependent, dependency) {
+ var checkval = function(inval) {
+ if (dependency.attr('type') == 'radio') {
+ var val = $('[name="' + dependency.attr('name') + '"]:checked').val();
+ return val == inval;
+ }
+ else if (dependency.attr('type') == 'checkbox') {
+ return dependency.is(':checked') && inval == dependency.val();
+ }
+ else {
+ return dependency.val() == inval;
+ }
+ return false;
+ };
+ if (!checkval(dependentval)) {
+ // Hide doesn't work inside collapsed fieldsets.
+ dependent.css('display', 'none');
+ }
+ dependency.bind('load change click keypress focus', function() {
+ if (checkval(dependentval)) {
+ dependent.slideDown();
+ }
+ else {
+ dependent.slideUp();
+ }
+ }).load();
+ })(dependent, dependency);
+ });
+ }
+ }
+ for (key in Drupal.settings.backup_migrate.destination_selectors) {
+ var info = Drupal.settings.backup_migrate.destination_selectors[key];
+ (function(info) {
+ var selector = $('#' + info['destination_selector']);
+ var copy = $('#' + info['copy'])
+ var copy_selector = $('#' + info['copy_destination_selector']);
+ var copy_selector_options = {};
+
+ // Store a copy of the secondary selector options.
+ copy_selector.find('optgroup').each(function() {
+ var label = $(this).attr('label');
+ copy_selector_options[label] = [];
+ $(this).find('option').each(function() {
+ copy_selector_options[label].push(this);
+ });
+ $(this).remove();
+ })
+
+ // Assign an action to the main selector to modify the secondary selector
+ selector.each(function() {
+ $(this).bind('load change click keypress focus', function() {
+ var group = $(this).find('option[value=' + $(this).val() + ']').parents('optgroup').attr('label');
+ if (group) {
+ copy.parent().find('.backup-migrate-destination-copy-label').text(info['labels'][group]);
+ copy_selector.empty();
+ for (var key in copy_selector_options) {
+ if (key != group) {
+ copy_selector.append(copy_selector_options[key]);
+ }
+ }
+ }
+ }).load();
+ });
+ })(info);
+ }
+ // Add the convert to checkboxes functionality to all multiselects.
+ $('#backup-migrate-ui-manual-backup-form select[multiple], #backup-migrate-crud-edit-form select[multiple]').each(function() {
+ var self = this;
+ $(self).after(
+ $('').append(
+ $(''+ Drupal.settings.backup_migrate.checkboxLinkText +'').click(function() {
+ var $select = $(self);
+ var $checkboxes = $('').addClass('backup-migrate-tables-checkboxes');
+ $('option', $select).each(function(i) {
+ $checkboxes.append(
+ $('').append(
+ $('').prepend(
+ $('')
+ .bind('click change load', function() {
+ if (this.checked) {
+ $(this).parent().addClass('checked');
+ }
+ else {
+ $(this).parent().removeClass('checked');
+ }
+ }).load()
+ )
+ )
+ );
+ });
+ $select.parent().find('.backup-migrate-checkbox-link').remove();
+ $select.before($checkboxes);
+ $select.hide();
+ })
+ )
+ );
+ });
+ }
+ }
+ }
+ }
+})(jQuery);
diff --git a/sites/all/modules/contrib/backup_migrate/backup_migrate.module b/sites/all/modules/contrib/backup_migrate/backup_migrate.module
new file mode 100644
index 0000000..60ab30b
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/backup_migrate.module
@@ -0,0 +1,1871 @@
+
+ t('Backup and Migrate makes the task of backing up your Drupal database and migrating data from one Drupal install to another easier. It provides a function to backup the entire database to file or download, and to restore from a previous backup. You can also schedule the backup operation. Compression of backup files is also supported. The database backup files created with this module can be imported into this or any other Drupal installation with the !restorelink, or you can use a database tool such as phpMyAdmin or the mysql command line command.',
+ array(
+ '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'),
+ '!phpmyadminurl' => 'http://www.phpmyadmin.net'
+ )
+ )
+ ),
+ BACKUP_MIGRATE_MENU_PATH => array(
+ 'title' => t('Quick Backup Tab'),
+ 'body' => t('Use this form to run simple manual backups of your database and files.'),
+ 'access arguments' => array('perform backup'),
+ ),
+ BACKUP_MIGRATE_MENU_PATH . '/export/advanced' => array(
+ 'title' => t('Advanced Backup Tab'),
+ 'body' => t('Use this form to run manual backups of your database and files with more advanced options. If you have any !profilelink saved you can load those settings. You can save any of the changes you make to these settings as a new settings profile.',
+ array("!profilelink" => user_access('administer backup and migrate') ? l(t('settings profiles'), BACKUP_MIGRATE_MENU_PATH . '/profile') : t('settings profiles'), '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'), '!phpmyadminurl' => 'http://www.phpmyadmin.net')),
+ 'access arguments' => array('perform backup'),
+ ),
+ BACKUP_MIGRATE_MENU_PATH . '/restore' => array(
+ 'title' => t('Restore Tab'),
+ 'body' => t('Upload a backup and migrate backup file. The restore function will not work with database dumps from other sources such as phpMyAdmin.'),
+ 'access arguments' => array('restore from backup'),
+ ),
+ BACKUP_MIGRATE_MENU_PATH . '/settings/destination' => array(
+ 'title' => t('Destinations'),
+ 'body' => t('Destinations are the places you can save your backup files to or them load from.'),
+ 'more' => t('Files can be saved to a directory on your web server, downloaded to your desktop or emailed to a specified email account. From the Destinations tab you can create, delete and edit destinations or list the files which have already been backed up to the available destinations.'),
+ 'access arguments' => array('administer backup and migrate'),
+ ),
+ BACKUP_MIGRATE_MENU_PATH . '/settings/source' => array(
+ 'title' => t('Sources'),
+ 'body' => t('Sources are the things that can be backed up such as database or file directories.'),
+ 'access arguments' => array('administer backup and migrate'),
+ ),
+ BACKUP_MIGRATE_MENU_PATH . '/settings/profile' => array(
+ 'title' => t('Profiles'),
+ 'body' => t('Profiles are saved backup settings. Profiles store your table exclusion settings as well as your backup file name, compression and timestamp settings. You can use profiles in !schedulelink and for !manuallink.',
+ array('!schedulelink' => user_access('administer backup and migrate') ? l(t('schedules'), BACKUP_MIGRATE_MENU_PATH . '/schedule') : t('settings profiles'), '!manuallink' => user_access('perform backups') ? l(t('manual backups'), BACKUP_MIGRATE_MENU_PATH) : t('manual backups'))),
+ 'more' => t('You can create new profiles using the add profiles tab or by checking the "Save these settings" button on the advanced backup page.'),
+ 'access arguments' => array('administer backup and migrate'),
+ ),
+ BACKUP_MIGRATE_MENU_PATH . '/schedule' => array(
+ 'title' => t('Scheduling'),
+ 'body' => t('Automatically backup up your database and files on a regular schedule using cron.',
+ array('!cronurl' => 'http://drupal.org/cron')),
+ 'more' => t('Each schedule will run a maximum of once per cron run, so they will not run more frequently than your cron is configured to run. If you specify a number of backups to keep for a schedule, old backups will be deleted as new ones created. If specifiy a number of files to keep other backup files in that schedule\'s destination will get deleted.'),
+ 'access arguments' => array('administer backup and migrate'),
+ ),
+ BACKUP_MIGRATE_MENU_PATH . '/settings/import' => array(
+ 'title' => t('Importing Settings'),
+ 'body' => t('Import a settings profile, backup schedule, source or destination by pasting the export code into the textarea.',
+ array('!cronurl' => 'http://drupal.org/cron')),
+ ),
+ );
+ if (module_exists('help')) {
+ $help[BACKUP_MIGRATE_MENU_PATH]['body'] .= ' ' . t('Visit the !helppage for more help using this module.', array('!helppage' => l(t('help page'), 'admin/help/backup_migrate')));
+ }
+
+ if (isset($help[$section])) {
+ return $help[$section]['body'];
+ }
+
+ if ($section == 'admin/help#backup_migrate') {
+ $out = "";
+ foreach ($help as $key => $section) {
+ if (isset($section['access arguments'])) {
+ foreach ($section['access arguments'] as $access) {
+ if (!user_access($access)) {
+ continue 2;
+ }
+ }
+ }
+ if (@$section['title']) {
+ if (!is_numeric($key)) {
+ $section['title'] = l($section['title'], $key);
+ }
+ $out .= "
',
+ "#tree" => TRUE,
+ '#parents' => array('period'),
+ );
+ $form['cron_settings']['period_settings']['period']['number'] = array(
+ "#type" => "textfield",
+ "#size" => 6,
+ "#default_value" => $default_period_num,
+ '#parents' => array('period', 'number'),
+ );
+ $form['cron_settings']['period_settings']['period']['type'] = array(
+ "#type" => "select",
+ "#options" => $period_options,
+ "#default_value" => $default_period['type'],
+ '#parents' => array('period', 'type'),
+ );
+
+
+ $form['cron_settings']['cron_elysia'] = array(
+ "#type" => "radio",
+ "#title" => t('Run using Elysia cron'),
+ '#return_value' => BACKUP_MIGRATE_CRON_ELYSIA,
+ "#description" => t('You can specify exactly when this schedule should run using !elysia.', array('!elysia' => l(t('the Elysia Cron module'), 'http://drupal.org/project/elysia_cron'))),
+ "#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
+ '#parents' => array('cron'),
+ );
+ if (!module_exists('elysia_cron')) {
+ $form['cron_settings']['cron_elysia']['#disabled'] = TRUE;
+ $form['cron_settings']['cron_elysia']['#description'] .= ' ' . t('Install !elysia to enable this option.', array('!elysia' => l(t('Elysia Cron'), 'http://drupal.org/project/elysia_cron')));
+ }
+ $form['cron_settings']['cron_schedule_settings'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'cron' => BACKUP_MIGRATE_CRON_ELYSIA,
+ ),
+ );
+ $form['cron_settings']['cron_schedule_settings']['cron_schedule'] = array(
+ "#type" => "textfield",
+ "#title" => t('Cron Schedule'),
+ '#length' => 10,
+ "#description" => t('Specify the frequecy of the schedule using standard cron notation. For more information see the !elysiareadme.', array('!elysiareadme' => l(t('the Elysia Cron README'), 'http://drupalcode.org/project/elysia_cron.git/blob/refs/heads/7.x-1.x:/README.txt'))),
+ "#default_value" => $this->get('cron_schedule'),
+ '#parents' => array('cron_schedule'),
+ );
+
+ $form['cron_settings']['cron_none'] = array(
+ "#type" => "radio",
+ "#title" => t('Do not run automatically'),
+ '#return_value' => 'none',
+ "#description" => t('Do not run this schedule automatically. You can still run it using !drush.', array('!drush' => l(t('Drush'), 'http://drupal.org/project/drush'))),
+ "#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
+ '#parents' => array('cron'),
+ );
+
+
+
+ $keep = $this->get('keep');
+ $form['delete'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => $keep != 0,
+ '#title' => t('Automatically delete old backups'),
+ );
+ $form['delete_settings'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'delete' => TRUE,
+ ),
+ );
+
+ $keep_hourly = variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY);
+ $keep_daily = variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY);
+ $keep_weekly = variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY);
+ $form['delete_settings']['smartdelete'] = array(
+ "#type" => "radio",
+ "#title" => t('Smart Delete'),
+ '#return_value' => BACKUP_MIGRATE_SMART_DELETE,
+ "#description" => t('Keep !keep. Recommended', array('!keep' => $this->generate_keep_description(BACKUP_MIGRATE_SMART_DELETE, FALSE))),
+ "#default_value" => $keep ? $keep : BACKUP_MIGRATE_SMART_DELETE,
+ '#parents' => array('deletetype'),
+ );
+ $form['delete_settings']['standarddelete'] = array(
+ "#type" => "radio",
+ "#title" => t('Simple Delete'),
+ '#return_value' => BACKUP_MIGRATE_STANDARD_DELETE,
+ "#description" => t("Keep a specified number of files deleting the oldest ones first."),
+ "#default_value" => $keep > 0 ? BACKUP_MIGRATE_STANDARD_DELETE : 0,
+ '#parents' => array('deletetype'),
+ );
+ $form['delete_settings']['keep-settings'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'deletetype' => BACKUP_MIGRATE_STANDARD_DELETE,
+ ),
+ );
+ $form['delete_settings']['keep-settings']['keep'] = array(
+ "#type" => "textfield",
+ "#size" => 6,
+ "#title" => t("Number of Backup files to keep"),
+ "#description" => t("The number of backup files to keep before deleting old ones."),
+ "#default_value" => $keep > 0 ? $keep : BACKUP_MIGRATE_KEEP_DEFAULT,
+ );
+
+ $form['destination'] = _backup_migrate_get_destination_pulldown('scheduled backup', $this->get('destination_id'), $this->get('copy_destination_id'));
+
+ return $form;
+ }
+
+ /**
+ * Submit the edit form.
+ */
+ function edit_form_validate($form, &$form_state) {
+ if (!is_numeric($form_state['values']['period']['number']) || $form_state['values']['period']['number'] <= 0) {
+ form_set_error('period][number', t('Backup period must be a number greater than 0.'));
+ }
+
+ if (!$form_state['values']['delete']) {
+ $form_state['values']['keep'] = 0;
+ }
+ else if ($form_state['values']['deletetype'] == BACKUP_MIGRATE_SMART_DELETE) {
+ $form_state['values']['keep'] = BACKUP_MIGRATE_SMART_DELETE;
+ }
+ else if (!is_numeric($form_state['values']['keep']) || $form_state['values']['keep'] <= 0) {
+ form_set_error('keep', t('Number to keep must be a number greater than 0.'));
+ }
+ parent::edit_form_validate($form, $form_state);
+ }
+
+ /**
+ * Submit the edit form.
+ */
+ function edit_form_submit($form, &$form_state) {
+ $periods = $this->frequency_periods();
+ $period = $periods[$form_state['values']['period']['type']];
+ $form_state['values']['period'] = $form_state['values']['period']['number'] * $period['seconds'];
+ parent::edit_form_submit($form, $form_state);
+ }
+
+ /**
+ * Get the period of the frequency (ie: seconds, minutes etc.)
+ */
+ function get_frequency_period() {
+ foreach (array_reverse($this->frequency_periods()) as $period) {
+ if ($period['seconds'] && ($this->period % $period['seconds']) === 0) {
+ return $period;
+ }
+ }
+ }
+
+ /**
+ * Get a list of available backup periods. Only returns time periods which have a
+ * (reasonably) consistent number of seconds (ie: no months).
+ */
+ function frequency_periods() {
+ return array(
+ 'seconds' => array('type' => 'seconds', 'seconds' => 1, 'title' => t('Seconds'), 'singular' => t('Once a second'), 'plural' => t('Every @count seconds')),
+ 'minutes' => array('type' => 'minutes', 'seconds' => 60, 'title' => t('Minutes'), 'singular' => t('Once a minute'), 'plural' => t('Every @count minutes')),
+ 'hours' => array('type' => 'hours', 'seconds' => 3600, 'title' => t('Hours'), 'singular' => t('Once an hour'), 'plural' => t('Every @count hours')),
+ 'days' => array('type' => 'days', 'seconds' => 86400, 'title' => t('Days'), 'singular' => t('Once a day'), 'plural' => t('Every @count days')),
+ 'weeks' => array('type' => 'weeks', 'seconds' => 604800, 'title' => t('Weeks'), 'singular' => t('Once a week'), 'plural' => t('Every @count weeks')),
+ );
+ }
+
+ /**
+ * Get the message to send to the user when confirming the deletion of the item.
+ */
+ function delete_confirm_message() {
+ return t('Are you sure you want to delete the schedule %name? Backups made with this schedule will not be deleted.', array('%name' => $this->get('name')));
+ }
+
+ /**
+ * Perform the cron action. Run the backup if enough time has elapsed.
+ */
+ function cron() {
+ $now = time();
+
+ // Add a small negative buffer (1% of the entire period) to the time to account for slight difference in cron run length.
+ $wait_time = $this->period - ($this->period * variable_get('backup_migrate_schedule_buffer', 0.01));
+
+ $cron = $this->get('cron');
+ if ($cron == BACKUP_MIGRATE_CRON_BUILTIN && $this->is_enabled() && ($now - $this->get('last_run')) >= $wait_time) {
+ $this->run();
+ }
+ }
+
+ /**
+ * Run the actual schedule.
+ */
+ function run() {
+ if ($settings = $this->get_profile()) {
+ $settings->source_id = $this->get('source_id');
+ $settings->destination_id = $this->get('destination_ids');
+
+ $this->update_last_run(time());
+ backup_migrate_perform_backup($settings);
+ $this->remove_expired_backups();
+ }
+ else {
+ backup_migrate_backup_fail("Schedule '%schedule' could not be run because requires a profile which is missing.", array('%schedule' => $schedule->get_name()), $settings);
+ }
+ }
+
+ /**
+ * Set the last run time of a schedule to the given timestamp, or now if none specified.
+ */
+ function update_last_run($timestamp = NULL) {
+ if ($timestamp === NULL) {
+ $timestamp = time();
+ }
+ variable_set('backup_migrate_schedule_last_run_' . $this->get('id'), $timestamp);
+ }
+
+ /**
+ * Set the last run time of a schedule to the given timestamp, or now if none specified.
+ */
+ function get_last_run() {
+ return variable_get('backup_migrate_schedule_last_run_' . $this->get('id'), 0);
+ }
+
+ /**
+ * Remove older backups keeping only the number specified by the aministrator.
+ */
+ function remove_expired_backups() {
+ backup_migrate_include('destinations');
+
+ $num_to_keep = $this->keep;
+ // If num to keep is not 0 (0 is infinity).
+ foreach ((array)$this->get_destinations() as $destination) {
+ if ($destination && $destination->op('delete') && $destination_files = $destination->list_files()) {
+ if ($num_to_keep == BACKUP_MIGRATE_SMART_DELETE) {
+ $this->smart_delete_backups(
+ $destination,
+ $destination_files,
+ variable_get('backup_migrate_smart_keep_subhourly', BACKUP_MIGRATE_SMART_KEEP_SUBHOURLY),
+ variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY),
+ variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY),
+ variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY)
+ );
+ }
+ else if ($num_to_keep != BACKUP_MIGRATE_KEEP_ALL) {
+ $this->delete_backups($destination, $destination_files, $num_to_keep);
+ }
+ }
+ }
+ }
+
+ /**
+ * Remove older backups keeping only the number specified by the aministrator.
+ */
+ function delete_backups($destination, $files, $num_to_keep) {
+ backup_migrate_include('destinations');
+
+ $num_to_keep = $this->keep;
+
+ // Sort the files by modified time.
+ $i = 0;
+ foreach ($files as $id => $file) {
+ if ($file->is_recognized_type()) {
+ $time = $file->info('filetime');
+ $sorted[$id] = $time;
+ }
+ }
+ asort($sorted);
+
+ // If we are beyond our limit, remove as many as we need.
+ $num_files = count($files);
+
+ if ($num_files > $num_to_keep) {
+ $num_to_delete = $num_files - $num_to_keep;
+ // Delete from the start of the list (earliest).
+ foreach ($sorted as $id => $time) {
+ if (!$num_to_delete--) {
+ break;
+ }
+ $destination->delete_file($id);
+ }
+ }
+ }
+
+ /**
+ * Delete files keeping the specified number of hourly, daily, weekly and monthly backups.
+ */
+ function smart_delete_backups($destination, $files, $keep_subhourly = 3600, $keep_hourly = 24, $keep_daily = 14, $keep_weekly = PHP_INT_MAX, $keep_monthly = PHP_INT_MAX) {
+ $now = time();
+ $periods = array(
+ 'subhourly' => array(
+ 'delta' => 1,
+ 'keep' => $keep_subhourly,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ 'hourly' => array(
+ 'delta' => 60*60,
+ 'keep' => $keep_hourly,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ 'daily' => array(
+ 'delta' => 60*60*24,
+ 'keep' => $keep_daily,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ 'weekly' => array(
+ 'delta' => 60*60*24*7,
+ 'keep' => $keep_weekly,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ /*
+ 'monthly' => array(
+ 'delta' => 60*60*24*7*4,
+ 'keep' => $keep_monthly,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ */
+ );
+
+ $keep_files = $filetimes = $times = $groups = $sorted = $saved = array();
+ foreach ($files as $id => $file) {
+ if ($file->is_recognized_type()) {
+ $time = $file->info('filetime');
+ $sorted[$id] = $time;
+ }
+ }
+ arsort($sorted);
+
+ $now = time();
+ foreach ($periods as $i => $period) {
+ foreach ($sorted as $id => $time) {
+ if ($time < ($now - ($period['delta'] * $period['keep']))) {
+ break;
+ }
+ if ($period['last_time'] == 0 || $time <= ($period['last_time'] - $period['delta'])) {
+ $period['last_time'] = $time;
+ $keep_files[$id] = $id;
+ }
+ }
+ // Keep oldest backup or it will get deleted if it doesn't fall on an exact multiple of the period
+ if ($id) {
+ $keep_files[$id] = $id;
+ }
+ }
+
+ // Do the delete.
+ foreach ($files as $id => $file) {
+ if (!isset($keep_files[$id])) {
+ $destination->delete_file($file->file_id());
+ }
+ }
+ }
+}
+
diff --git a/sites/all/modules/contrib/backup_migrate/includes/sources.archivesource.inc b/sites/all/modules/contrib/backup_migrate/includes/sources.archivesource.inc
new file mode 100644
index 0000000..c8712eb
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/includes/sources.archivesource.inc
@@ -0,0 +1,287 @@
+ 'archive', 'location' => '.', 'name' => t('Entire Site (code, files & DB)'), 'show_in_list' => FALSE));
+ return $out;
+ }
+
+ /**
+ * Return a list of backup filetypes.
+ */
+ function file_types() {
+ return array(
+ "sitearchive" => array(
+ "extension" => "sitearchive.tar",
+ "filemime" => "application/x-tar",
+ "backup" => TRUE,
+ "restore" => FALSE,
+ ),
+ );
+ }
+
+ /**
+ * Get the form for the settings for this destination.
+ */
+ function backup_settings_default() {
+ $out = parent::backup_settings_default();
+ $excludes = explode("\n", $out['exclude_filepaths']);
+ foreach ($excludes as $i => $exclude) {
+ $excludes[$i] = 'public://' . $exclude;
+ }
+ $excludes[] = 'private://backup_migrate';
+ $excludes[] = conf_path() . '/settings.php';
+ $excludes[] = file_directory_temp();
+
+ return array(
+ 'exclude_filepaths' => implode("\n", $excludes),
+ );
+ }
+
+ /**
+ * Backup from this source.
+ */
+ function _backup_to_file_php($file, $settings) {
+ if ($this->check_libs()) {
+ $base_dir = $this->get_realpath();
+
+ $excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
+ $exclude = $this->get_excluded_paths($settings);
+ $files = $this->get_files_to_backup($this->get_realpath(), $settings, $exclude);
+ if ($files) {
+ $manifest = $this->generate_manifest();
+ $db = $this->get_db();
+
+ $file->push_type('sitearchive');
+ $gz = new Archive_Tar($file->filepath(), false);
+
+ $gz->addModify(array($manifest), $file->name .'/', dirname($manifest));
+ $gz->addModify($files, $file->name .'/docroot', $base_dir);
+ $gz->addModify($db, $file->name . '/', dirname($db));
+
+ unlink($manifest);
+ rmdir(dirname($manifest));
+ unlink($db);
+ rmdir(dirname($db));
+
+ return $file;
+ }
+ backup_migrate_backup_fail('No files available.', array(), $settings);
+ return FALSE;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Backup from this source.
+ */
+ function _backup_to_file_cli($file, $settings) {
+ if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec') && function_exists('escapeshellarg')) {
+ $excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
+ foreach ($this->get_excluded_paths($excluded_paths) as $path) {
+ $exclude[] = '--exclude=' . escapeshellarg($path);
+ }
+ $exclude = implode(' ', $exclude);
+
+ // Create a symlink in a temp directory so we can rename the file in the archive.
+ $temp = backup_migrate_temp_directory();
+
+ $manifest = $this->generate_manifest();
+ $db = $this->get_db();
+ rename($db, $temp . '/database.sql');
+ rename($manifest, $temp . '/MANIFEST.ini');
+
+ $file->push_type('sitearchive');
+ $link = $temp . '/docroot';
+ $input = realpath($this->get_location());
+ backup_migrate_exec("ln -s %input %link; tar --dereference -C %temp -rf %output $exclude .", array('%output' => $file->filepath(), '%input' => $input, '%temp' => $temp, '%link' => $link));
+
+ return $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Generate a manifest file.
+ */
+ function generate_manifest() {
+ $info = array(
+ 'Global' => array(
+ 'datestamp' => time(),
+ 'formatversion' => '2011-07-02',
+ 'generator' => 'Backup and Migrate (http://drupal.org/project/backup_migrate)',
+ 'generatorversion' => BACKUP_MIGRATE_VERSION,
+ ),
+ 'Site 0' => array(
+ 'version' => VERSION,
+ 'name' => variable_get('site_name', ''),
+ 'docroot' => 'docroot',
+ 'sitedir' => 'docroot/' . conf_path(),
+ 'database-file-default' => 'database.sql',
+ 'database-file-driver' => 'mysql',
+ ),
+ );
+ if ($private = variable_get('file_private_path', FALSE)) {
+ $info['Site 0']['files-private'] = 'docroot/' . $private;
+ }
+ $info['Site 0']['files-public'] = 'docroot/' . variable_get('file_public_path', FALSE);
+ $ini = $this->_array_to_ini($info);
+
+ $tmpdir = backup_migrate_temp_directory();
+ $filepath = $tmpdir . '/MANIFEST.ini';
+ file_put_contents($filepath, $ini);
+ return $filepath;
+ }
+
+ /**
+ * Get a database dump to add to the archive.
+ */
+ function get_db() {
+ backup_migrate_include('destinations', 'files', 'filters', 'profiles');
+
+ $file = new backup_file();
+ // Clone the default settings so we can make changes without them leaking out of this function.
+ $settings = clone _backup_migrate_profile_saved_default_profile();
+ $settings->source_id = 'db';
+ $settings->filters['compression'] = 'none';
+
+ // Execute the backup on the db with the default settings.
+ $file = backup_migrate_filters_backup($file, $settings);
+
+ // Generate a tmp file with the correct final title (because ArchiveTar doesn't seem to allow renaming).
+ $tmpdir = backup_migrate_temp_directory();
+ $filepath = $tmpdir . '/database.sql';
+ rename($file->filepath(), $filepath);
+
+ return $filepath;
+ }
+
+ /**
+ * Restore to this source.
+ */
+ function _restore_from_file_php($file, &$settings) {
+ $success = false;
+ if ($this->check_libs()) {
+ $from = $file->pop_type();
+ $temp = backup_migrate_temp_directory();
+
+ $tar = new Archive_Tar($from->filepath());
+ $tar->extractModify($temp, $file->name);
+
+ // Parse the manifest
+ $manifest = $this->read_manifest($temp);
+
+ // Currently only the first site in the archive is supported.
+ $site = $manifest['Site 0'];
+
+ $docroot = $temp . '/' . $site['docroot'];
+ $sqlfile = $temp . '/' . $site['database-file-default'];
+ $filepath = NULL;
+ if (isset($site['files-private'])) {
+ $filepath = $temp . '/' . $site['files-private'];
+ }
+ else if (isset($site['files-public'])) {
+ $filepath = $temp . '/' . $site['files-public'];
+ }
+
+ // Move the files from the temp directory.
+ if ($filepath && file_exists($filepath)) {
+ _backup_migrate_move_files($filepath, file_directory_path());
+ }
+ else {
+ _backup_migrate_message('Files were not restored because the archive did not seem to contain a files directory or was in a format that Backup and Migrate couldn\'t read', array(), 'warning');
+ }
+
+ // Restore the sql db.
+ if ($sqlfile && file_exists($sqlfile)) {
+ $db_settings = clone($settings);
+ $db_settings->source_id = 'db';
+ $file = new backup_file(array('filepath' => $sqlfile));
+ $success = backup_migrate_filters_restore($file, $db_settings);
+ }
+ else {
+ _backup_migrate_message('The database was not restored because the archive did not seem to contain a database backup or was in a format that Backup and Migrate couldn\'t read', array(), 'warning');
+ }
+
+ if ($docroot) {
+ _backup_migrate_message('Backup and Migrate cannot restore the php code of the site for security reasons. You will have to copy the code to the server by hand if you wish to restore the full site.', array(), 'warning');
+ }
+
+ return $success && $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Restore to this source.
+ */
+ function _restore_from_file_cli($file, &$settings) {
+ // @TODO: implement the cli version of the restore.
+ return FALSE;
+ }
+
+ /**
+ * Generate a manifest file.
+ */
+ function read_manifest($directory) {
+ // Assume some defaults if values ore the manifest is missing.
+ $defaults = array(
+ 'docroot' => 'docroot',
+ 'database-file-default' => 'database.sql',
+ 'database-file-driver' => 'mysql',
+ );
+
+ $out = $this->_ini_to_array($directory . '/MANIFEST.ini');
+
+ // Set the defaults.
+ $out['Site 0'] = isset($out['Site 0']) ? $out['Site 0'] : array();
+ $out['Site 0'] += $defaults;
+
+ return $out;
+ }
+
+ /**
+ * Convert an associated array to an ini format string. Only allows 2 levels of depth to allow parse_ini_file to parse.
+ */
+ function _array_to_ini($sections) {
+ $content = "";
+ foreach ($sections as $section => $data) {
+ $content .= '['. $section .']' . "\n";
+ foreach ($data as $key => $val) {
+ $content .= $key . " = \"". $val ."\"\n";
+ }
+ $content .= "\n";
+ }
+ return $content;
+ }
+
+ /**
+ * Convert an associated array to an ini format string. Only allows 2 levels of depth to allow parse_ini_file to parse.
+ */
+ function _ini_to_array($path) {
+ return parse_ini_file($path, TRUE);
+ }
+}
+
diff --git a/sites/all/modules/contrib/backup_migrate/includes/sources.db.inc b/sites/all/modules/contrib/backup_migrate/includes/sources.db.inc
new file mode 100644
index 0000000..8bd75c3
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/includes/sources.db.inc
@@ -0,0 +1,318 @@
+set_source($this->get_id());
+
+ // Restore the file to the source database.
+ $file = backup_migrate_perform_restore($this->get_id(), $file, $settings);
+
+ return $file;
+ }
+
+ /**
+ * Destination configuration callback.
+ */
+ function edit_form() {
+ $form = parent::edit_form();
+ $form['scheme']['#default_value'] = $this->default_scheme();
+ $form['scheme']['#access'] = FALSE;
+ $form['path']['#title'] = t('Database name');
+ $form['path']['#description'] = t('The name of the database. The database must exist, it will not be created for you.');
+ $form['user']['#description'] = t('Enter the name of a user who has write access to the database.');
+ return $form;
+ }
+
+ /**
+ * Validate the configuration form. Make sure the db info is valid.
+ */
+ function edit_form_validate($form, &$form_state) {
+ if (!preg_match('/[a-zA-Z0-9_\$]+/', $form_state['values']['path'])) {
+ form_set_error('path', t('The database name is not valid.'));
+ }
+ parent::edit_form_validate($form, $form_state);
+ }
+
+ /**
+ * Get the form for the settings for this destination.
+ *
+ * Return the default tables whose data can be ignored. These tables mostly contain
+ * info which can be easily reproducted (such as cache or search index)
+ * but also tables which can become quite bloated but are not necessarily extremely
+ * important to back up or migrate during development (such ass access log and watchdog)
+ */
+ function backup_settings_default() {
+ $core = array(
+ 'cache',
+ 'cache_admin_menu',
+ 'cache_browscap',
+ 'cache_content',
+ 'cache_filter',
+ 'cache_calendar_ical',
+ 'cache_location',
+ 'cache_menu',
+ 'cache_page',
+ 'cache_reptag',
+ 'cache_views',
+ 'cache_views_data',
+ 'cache_block',
+ 'cache_update',
+ 'cache_form',
+ 'cache_bootstrap',
+ 'cache_field',
+ 'cache_image',
+ 'cache_path',
+ 'sessions',
+ 'search_dataset',
+ 'search_index',
+ 'search_keywords_log',
+ 'search_total',
+ 'watchdog',
+ 'accesslog',
+ 'devel_queries',
+ 'devel_times',
+ );
+ $nodata_tables = array_merge($core, module_invoke_all('devel_caches'));
+ return array(
+ 'nodata_tables' => $nodata_tables,
+ 'exclude_tables' => array(),
+ 'utils_lock_tables' => FALSE,
+ );
+ }
+
+ /**
+ * Get the form for the backup settings for this destination.
+ */
+ function backup_settings_form($settings) {
+ $objects = $this->get_object_names();
+ $form['#description'] = t("You may omit specific tables, or specific table data from the backup file. Only omit data that you know you will not need such as cache data, or tables from other applications. Excluding tables can break your Drupal install, so do not change these settings unless you know what you're doing.");
+ $form['exclude_tables'] = array(
+ "#type" => "select",
+ "#multiple" => TRUE,
+ "#title" => t("Exclude the following tables altogether"),
+ "#options" => $objects,
+ "#default_value" => $settings['exclude_tables'],
+ "#description" => t("The selected tables will not be added to the backup file."),
+ );
+ $form['nodata_tables'] = array(
+ "#type" => "select",
+ "#multiple" => TRUE,
+ "#title" => t("Exclude the data from the following tables"),
+ "#options" => $objects,
+ "#default_value" => $settings['nodata_tables'],
+ "#description" => t("The selected tables will have their structure backed up but not their contents. This is useful for excluding cache data to reduce file size."),
+ );
+ $form['utils_lock_tables'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Lock tables during backup'),
+ '#default_value' => !empty($settings['utils_lock_tables']) ? $settings['utils_lock_tables'] : NULL,
+ '#description' => t('This can help reduce data corruption, but will make your site unresponsive.'),
+ );
+ return $form;
+ }
+
+ /**
+ * Backup from this source.
+ */
+ function backup_to_file($file, $settings) {
+ $file->push_type($this->get_file_type_id());
+
+ //$this->lock_tables($settings);
+
+ // Switch to a different db if specified.
+ $success = $this->_backup_db_to_file($file, $settings);
+
+ //$this->unlock_tables($settings);
+
+ return $success ? $file : FALSE;
+ }
+
+ /**
+ * Restore to this source.
+ */
+ function restore_from_file($file, &$settings) {
+ $num = 0;
+ $type = $this->get_file_type_id();
+ // Open the file using the file wrapper. Check that the dump is of the right type (allow .sql for legacy reasons).
+ if ($file->type_id() !== $this->get_file_type_id() && $file->type_id() !== 'sql') {
+ _backup_migrate_message("Unable to restore from file %file because a %type file can't be restored to this database.", array("%file" => $file->filepath(), '%type' => $file->type_id()), 'error');
+ }
+ else {
+ backup_migrate_filters_invoke_all('pre_restore', $file, $settings);
+
+ // Restore the database.
+ $num = $this->_restore_db_from_file($file, $settings);
+ $settings->performed_action = $num ? t('%num SQL commands executed.', array('%num' => $num)) : '';
+
+ backup_migrate_filters_invoke_all('post_restore', $file, $settings, $num);
+ }
+ return $num;
+ }
+
+ /**
+ * Get the db connection for the specified db.
+ */
+ function _get_db_connection() {
+ if (!$this->connection) {
+ $target = $key = '';
+ $parts = explode(':', $this->get_id());
+ // One of the predefined databases (set in settings.php)
+ if ($parts[0] == 'db') {
+ $key = empty($parts[1]) ? 'default' : $parts[1];
+ $target = empty($parts[2]) ? 'default' : $parts[2];
+ }
+ // Another db url.
+ else {
+ // If the url is specified build it into a connection info array.
+ if (!empty($this->dest_url)) {
+ $info = array(
+ 'driver' => empty($this->dest_url['scheme']) ? NULL : $this->dest_url['scheme'],
+ 'host' => empty($this->dest_url['host']) ? NULL : $this->dest_url['host'],
+ 'port' => empty($this->dest_url['port']) ? NULL : $this->dest_url['port'],
+ 'username' => empty($this->dest_url['user']) ? NULL : $this->dest_url['user'],
+ 'password' => empty($this->dest_url['pass']) ? NULL : $this->dest_url['pass'],
+ 'database' => empty($this->dest_url['path']) ? NULL : $this->dest_url['path'],
+ );
+ $key = uniqid('backup_migrate_tmp_');
+ $target = 'default';
+ Database::addConnectionInfo($key, $target, $info);
+ }
+ // No database selected. Assume the default.
+ else {
+ $key = $target = 'default';
+ }
+ }
+ if ($target && $key) {
+ $this->connection = Database::getConnection($target, $key);
+ }
+ }
+ return $this->connection;
+ }
+
+ /**
+ * Backup the databases to a file.
+ */
+ function _backup_db_to_file($file, $settings) {
+ // Must be overridden.
+ }
+
+ /**
+ * Backup the databases to a file.
+ */
+ function _restore_db_from_file($file, $settings) {
+ // Must be overridden.
+ }
+
+ /**
+ * Get a list of objects in the database.
+ */
+ function get_object_names() {
+ // Must be overridden.
+ $out = $this->_get_table_names();
+ if (method_exists($this, '_get_view_names')) {
+ $out += $this->_get_view_names();
+ }
+ return $out;
+ }
+
+ /**
+ * Get a list of tables in the database.
+ */
+ function get_table_names() {
+ // Must be overridden.
+ $out = $this->_get_table_names();
+ return $out;
+ }
+
+ /**
+ * Get a list of tables in the database.
+ */
+ function _get_table_names() {
+ // Must be overridden.
+ return array();
+ }
+
+ /**
+ * Lock the database in anticipation of a backup.
+ */
+ function lock_tables($settings) {
+ if ($settings->filters['utils_lock_tables']) {
+ $tables = array();
+ foreach ($this->get_table_names() as $table) {
+ // There's no need to lock excluded or structure only tables because it doesn't matter if they change.
+ if (empty($settings->filters['exclude_tables']) || !in_array($table, (array)$settings->filters['exclude_tables'])) {
+ $tables[] = $table;
+ }
+ }
+ $this->_lock_tables($tables);
+ }
+ }
+
+ /**
+ * Lock the list of given tables in the database.
+ */
+ function _lock_tables($tables) {
+ // Must be overridden.
+ }
+
+ /**
+ * Unlock any tables that have been locked.
+ */
+ function unlock_tables($settings) {
+ if ($settings->filters['utils_lock_tables']) {
+ $this->_unlock_tables();
+ }
+ }
+
+ /**
+ * Unlock the list of given tables in the database.
+ */
+ function _unlock_tables($tables) {
+ // Must be overridden.
+ }
+
+ /**
+ * Get the file type for to backup this destination to.
+ */
+ function get_file_type_id() {
+ return 'sql';
+ }
+
+ /**
+ * Get the version info for the given DB.
+ */
+ function _db_info() {
+ return array(
+ 'type' => FALSE,
+ 'version' => t('Unknown'),
+ );
+ }
+
+}
diff --git a/sites/all/modules/contrib/backup_migrate/includes/sources.db.mysql.inc b/sites/all/modules/contrib/backup_migrate/includes/sources.db.mysql.inc
new file mode 100644
index 0000000..49ded37
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/includes/sources.db.mysql.inc
@@ -0,0 +1,497 @@
+ array(
+ "extension" => "sql",
+ "filemime" => "text/x-sql",
+ "backup" => TRUE,
+ "restore" => TRUE,
+ ),
+ "mysql" => array(
+ "extension" => "mysql",
+ "filemime" => "text/x-sql",
+ "backup" => TRUE,
+ "restore" => TRUE,
+ ),
+ );
+ }
+
+ /**
+ * Return the scheme for this db type.
+ */
+ function default_scheme() {
+ return 'mysql';
+ }
+
+
+ /**
+ * Declare any mysql databases defined in the settings.php file as a possible source.
+ */
+ function sources() {
+ $out = array();
+ global $databases;
+ foreach ((array)$databases as $db_key => $target) {
+ foreach ((array)$target as $tgt_key => $info) {
+ // Only mysql/mysqli supported by this source.
+ $key = $db_key . ':' . $tgt_key;
+ if ($info['driver'] === 'mysql') {
+ $url = $info['driver'] . '://' . $info['username'] . ':' . $info['password'] . '@' . $info['host'] . (isset($info['port']) ? ':' . $info['port'] : '') . '/' . $info['database'];
+ if ($source = backup_migrate_create_destination('mysql', array('url' => $url))) {
+ // Treat the default database differently because it is probably the only one available.
+ if ($key == 'default:default') {
+ $source->set_id('db');
+ $source->set_name(t('Default Database'));
+ // Dissalow backing up to the default database because that's confusing and potentially dangerous.
+ $source->remove_op('scheduled backup');
+ $source->remove_op('manual backup');
+ }
+ else {
+ $source->set_id('db:'. $key);
+ $source->set_name($key .": ". $source->get_display_location());
+ }
+ $out[$source->get_id()] = $source;
+ }
+ }
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Get the file type for to backup this source to.
+ */
+ function get_file_type_id() {
+ return 'mysql';
+ }
+
+ /**
+ * Backup the databases to a file.
+ *
+ * Returns a list of sql commands, one command per line.
+ * That makes it easier to import without loading the whole file into memory.
+ * The files are a little harder to read, but human-readability is not a priority
+ */
+ function _backup_db_to_file($file, $settings) {
+ if (!empty($settings->filters['use_cli']) && $this->_backup_db_to_file_mysqldump($file, $settings)) {
+ return TRUE;
+ }
+
+ $lines = 0;
+ $exclude = !empty($settings->filters['exclude_tables']) ? $settings->filters['exclude_tables'] : array();
+ $nodata = !empty($settings->filters['nodata_tables']) ? $settings->filters['nodata_tables'] : array();
+ if ($file->open(TRUE)) {
+ $file->write($this->_get_sql_file_header());
+ $alltables = $this->_get_tables();
+ $allviews = $this->_get_views();
+
+ foreach ($alltables as $table) {
+ if (_backup_migrate_check_timeout()) {
+ return FALSE;
+ }
+ if ($table['name'] && !isset($exclude[$table['name']])) {
+ $file->write($this->_get_table_structure_sql($table));
+ $lines++;
+ if (!in_array($table['name'], $nodata)) {
+ $lines += $this->_dump_table_data_sql_to_file($file, $table);
+ }
+ }
+ }
+ foreach ($allviews as $view) {
+ if (_backup_migrate_check_timeout()) {
+ return FALSE;
+ }
+ if ($view['name'] && !isset($exclude[$view['name']])) {
+ $file->write($this->_get_view_create_sql($view));
+ }
+ }
+ $file->write($this->_get_sql_file_footer());
+ $file->close();
+ return $lines;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+
+ /**
+ * Backup the databases to a file using the mysqldump command.
+ */
+ function _backup_db_to_file_mysqldump($file, $settings) {
+ $success = FALSE;
+ $nodata_tables = array();
+ $alltables = $this->_get_tables();
+
+
+ $command = 'mysqldump --result-file=%file --opt -Q --host=%host --port=%port --user=%user --password=%pass %db';
+ $args = array(
+ '%file' => $file->filepath(),
+ '%host' => $this->dest_url['host'],
+ '%port' => isset($this->dest_url['port']) ? $this->dest_url['port'] : '3306',
+ '%user' => $this->dest_url['user'],
+ '%pass' => $this->dest_url['pass'],
+ '%db' => $this->dest_url['path'],
+ );
+
+ // Ignore the excluded and no-data tables.
+ if (!empty($settings->filters['exclude_tables'])) {
+ $db = $this->dest_url['path'];
+ foreach ((array)$settings->filters['exclude_tables'] as $table) {
+ if (isset($alltables[$table])) {
+ $command .= ' --ignore-table='. $db .'.'. $table;
+ }
+ }
+ foreach ((array)$settings->filters['nodata_tables'] as $table) {
+ if (isset($alltables[$table])) {
+ $nodata_tables[] = $table;
+ $command .= ' --ignore-table='. $db .'.'. $table;
+ }
+ }
+ }
+ $success = backup_migrate_exec($command, $args);
+
+ // Get the nodata tables.
+ if ($success && !empty($nodata_tables)) {
+ $tables = implode(' ', array_unique($nodata_tables));
+ $command = "mysqldump --no-data --opt -Q --host=%host --port=%port --user=%user --password=%pass %db $tables >> %file";
+ $success = backup_migrate_exec($command, $args);
+ }
+ return $success;
+ }
+
+ /**
+ * Backup the databases to a file.
+ */
+ function _restore_db_from_file($file, $settings) {
+ $num = 0;
+
+ if ($file->open() && $conn = $this->_get_db_connection()) {
+ // Read one line at a time and run the query.
+ while ($line = $this->_read_sql_command_from_file($file)) {
+ if (_backup_migrate_check_timeout()) {
+ return FALSE;
+ }
+ if ($line) {
+ // Prepeare and exexute the statement instead of the api function to avoid substitution of '{' etc.
+ $stmt = $conn->prepare($line);
+ $stmt->execute();
+ $num++;
+ }
+ }
+ // Close the file with fclose/gzclose.
+ $file->close();
+ }
+ else {
+ drupal_set_message(t("Unable to open file %file to restore database", array("%file" => $file->filepath())), 'error');
+ $num = FALSE;
+ }
+ return $num;
+ }
+
+
+ /**
+ * Read a multiline sql command from a file.
+ *
+ * Supports the formatting created by mysqldump, but won't handle multiline comments.
+ */
+ function _read_sql_command_from_file($file) {
+ $out = '';
+ while ($line = $file->read()) {
+ $first2 = substr($line, 0, 2);
+ $first3 = substr($line, 0, 2);
+
+ // Ignore single line comments. This function doesn't support multiline comments or inline comments.
+ if ($first2 != '--' && ($first2 != '/*' || $first3 == '/*!')) {
+ $out .= ' ' . trim($line);
+ // If a line ends in ; or */ it is a sql command.
+ if (substr($out, strlen($out) - 1, 1) == ';') {
+ return trim($out);
+ }
+ }
+ }
+ return trim($out);
+ }
+
+ /**
+ * Get a list of tables in the database.
+ */
+ function _get_table_names() {
+ $out = array();
+ foreach ($this->_get_tables() as $table) {
+ $out[$table['name']] = $table['name'];
+ }
+ return $out;
+ }
+
+ /**
+ * Get a list of views in the database.
+ */
+ function _get_view_names() {
+ $out = array();
+ foreach ($this->_get_views() as $view) {
+ $out[$view['name']] = $view['name'];
+ }
+ return $out;
+ }
+
+ /**
+ * Lock the list of given tables in the database.
+ */
+ function _lock_tables($tables) {
+ if ($tables) {
+ $tables_escaped = array();
+ foreach ($tables as $table) {
+ $tables_escaped[] = '`'. db_escape_table($table) .'` WRITE';
+ }
+ $this->query('LOCK TABLES '. implode(', ', $tables_escaped));
+ }
+ }
+
+ /**
+ * Unlock all tables in the database.
+ */
+ function _unlock_tables($settings) {
+ $this->query('UNLOCK TABLES');
+ }
+
+ /**
+ * Get a list of tables in the db.
+ */
+ function _get_tables() {
+ $out = array();
+ // get auto_increment values and names of all tables
+ $tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($tables as $table) {
+ // Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
+ // See: http://drupal.org/node/1171866
+ $table = array_change_key_case($table);
+ if (!empty($table['engine'])) {
+ $out[$table['name']] = $table;
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Get a list of views in the db.
+ */
+ function _get_views() {
+ $out = array();
+ // get auto_increment values and names of all tables
+ $tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($tables as $table) {
+ // Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
+ // See: http://drupal.org/node/1171866
+ $table = array_change_key_case($table);
+ if (empty($table['engine'])) {
+ $out[$table['name']] = $table;
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Get the sql for the structure of the given view.
+ */
+ function _get_view_create_sql($view) {
+ $out = "";
+ // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user
+ $sql_mode = $this->query("SELECT @@SESSION.sql_mode")->fetchField();
+ $this->query("SET sql_mode = 'ANSI'");
+ $result = $this->query("SHOW CREATE VIEW `" . $view['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ $this->query("SET SQL_mode = :mode", array(':mode' => $sql_mode));
+ foreach ($result as $create) {
+ // Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
+ // See: http://drupal.org/node/1171866
+ $create = array_change_key_case($create);
+ $out .= "DROP VIEW IF EXISTS `". $view['name'] ."`;\n";
+ $out .= "SET sql_mode = 'ANSI';\n";
+ $out .= strtr($create['create view'], "\n", " ") . ";\n";
+ $out .= "SET sql_mode = '$sql_mode';\n";
+ }
+ return $out;
+ }
+
+
+
+ /**
+ * Get the sql for the structure of the given table.
+ */
+ function _get_table_structure_sql($table) {
+ $out = "";
+ $result = $this->query("SHOW CREATE TABLE `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $create) {
+ // Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
+ // See: http://drupal.org/node/1171866
+ $create = array_change_key_case($create);
+ $out .= "DROP TABLE IF EXISTS `". $table['name'] ."`;\n";
+ // Remove newlines and convert " to ` because PDO seems to convert those for some reason.
+ $out .= strtr($create['create table'], array("\n" => ' ', '"' => '`'));
+ if ($table['auto_increment']) {
+ $out .= " AUTO_INCREMENT=". $table['auto_increment'];
+ }
+ $out .= ";\n";
+ }
+ return $out;
+ }
+
+ /**
+ * Get the sql to insert the data for a given table
+ */
+ function _dump_table_data_sql_to_file($file, $table) {
+ $rows_per_line = variable_get('backup_migrate_data_rows_per_line', 30);
+ $bytes_per_line = variable_get('backup_migrate_data_bytes_per_line', 2000);
+
+ $lines = 0;
+ $data = $this->query("SELECT * FROM `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ $rows = $bytes = 0;
+
+ // Escape backslashes, PHP code, special chars
+ $search = array('\\', "'", "\x00", "\x0a", "\x0d", "\x1a");
+ $replace = array('\\\\', "''", '\0', '\n', '\r', '\Z');
+
+ $line = array();
+ foreach ($data as $row) {
+ // DB Escape the values.
+ $items = array();
+ foreach ($row as $key => $value) {
+ $items[] = is_null($value) ? "null" : "'". str_replace($search, $replace, $value) ."'";
+ }
+
+ // If there is a row to be added.
+ if ($items) {
+ // Start a new line if we need to.
+ if ($rows == 0) {
+ $file->write("INSERT INTO `". $table['name'] ."` VALUES ");
+ $bytes = $rows = 0;
+ }
+ // Otherwise add a comma to end the previous entry.
+ else {
+ $file->write(",");
+ }
+
+ // Write the data itself.
+ $sql = implode(',', $items);
+ $file->write('('. $sql .')');
+ $bytes += strlen($sql);
+ $rows++;
+
+ // Finish the last line if we've added enough items
+ if ($rows >= $rows_per_line || $bytes >= $bytes_per_line) {
+ $file->write(";\n");
+ $lines++;
+ $bytes = $rows = 0;
+ }
+ }
+ }
+ // Finish any unfinished insert statements.
+ if ($rows > 0) {
+ $file->write(";\n");
+ $lines++;
+ }
+
+ return $lines;
+ }
+
+ /**
+ * Get the db connection for the specified db.
+ */
+ function _get_db_connection() {
+ if (!$this->connection) {
+ $this->connection = parent::_get_db_connection();
+ // Set the sql mode because the default is ANSI,TRADITIONAL which is not aware of collation or storage engine.
+ $this->connection->exec("SET sql_mode=''");
+ }
+ return $this->connection;
+ }
+
+ /**
+ * Run a db query on this destination's db.
+ */
+ function query($query, $args = array(), $options = array()) {
+ if ($conn = $this->_get_db_connection()) {
+ return $conn->query($query, $args, $options);
+ }
+ }
+
+ /**
+ * The header for the top of the sql dump file. These commands set the connection
+ * character encoding to help prevent encoding conversion issues.
+ */
+ function _get_sql_file_header() {
+ $info = $this->_db_info();
+
+ return "-- Backup and Migrate (Drupal) MySQL Dump
+-- Backup and Migrate Version: ". BACKUP_MIGRATE_VERSION ."
+-- http://drupal.org/project/backup_migrate
+-- Drupal Version: " . VERSION . "
+-- http://drupal.org/
+--
+-- Host: " . url('', array('absolute' => TRUE)) . "
+-- Site Name: " . url('', array('absolute' => TRUE)) . "
+-- Generation Time: " . format_date(time(), 'custom', 'r') . "
+-- MySQL Version: " . $info['version'] . "
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
+
+SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";
+SET NAMES utf8;
+
+";
+ }
+
+ /**
+ * The footer of the sql dump file.
+ */
+ function _get_sql_file_footer() {
+ return "
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+";
+ }
+
+ /**
+ * Get the version info for the given DB.
+ */
+ function _db_info() {
+ $db = $this->_get_db_connection();
+ return array(
+ 'type' => 'mysql',
+ 'version' => $db ? $db->version() : t('Unknown'),
+ );
+ }
+
+}
+
diff --git a/sites/all/modules/contrib/backup_migrate/includes/sources.filesource.inc b/sites/all/modules/contrib/backup_migrate/includes/sources.filesource.inc
new file mode 100644
index 0000000..b031e76
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/includes/sources.filesource.inc
@@ -0,0 +1,314 @@
+ 'files', 'location' => 'public://', 'name' => t('Public Files Directory'), 'show_in_list' => FALSE));
+ if (variable_get('file_private_path', FALSE)) {
+ $out['files_private'] = backup_migrate_create_destination('filesource', array('machine_name' => 'files', 'location' => 'private://', 'name' => t('Private Files Directory'), 'show_in_list' => FALSE));
+ }
+ return $out;
+ }
+
+ /**
+ * Get the form for the settings for the files destination.
+ */
+ function edit_form() {
+ $form = parent::edit_form();
+ $form['location'] = array(
+ "#type" => "textfield",
+ "#title" => t("Directory path"),
+ "#default_value" => $this->get_location(),
+ "#required" => TRUE,
+ "#description" => t('Enter the path to the directory to save the backups to. Use a relative path to pick a path relative to your Drupal root directory. The web server must be able to write to this path.'),
+ );
+ return $form;
+ }
+
+ /**
+ * Return a list of backup filetypes.
+ */
+ function file_types() {
+ return array(
+ "tar" => array(
+ "extension" => "tar",
+ "filemime" => "application/x-tar",
+ "backup" => TRUE,
+ "restore" => TRUE,
+ ),
+ );
+ }
+
+ /**
+ * Get the form for the settings for this destination.
+ *
+ * Return the default directories whose data can be ignored. These directories contain
+ * info which can be easily reproducted. Also exclude the backup and migrate folder
+ * to prevent exponential bloat.
+ */
+ function backup_settings_default() {
+ return array(
+ 'exclude_filepaths' => "backup_migrate\nstyles\ncss\njs\nctools\nless",
+ );
+ }
+
+ /**
+ * Get the form for the backup settings for this destination.
+ */
+ function backup_settings_form($settings) {
+ $form['exclude_filepaths'] = array(
+ "#type" => "textarea",
+ "#multiple" => TRUE,
+ "#title" => t("Exclude the following files or directories"),
+ "#default_value" => $settings['exclude_filepaths'],
+ "#description" => t("A list of files or directories to be excluded from backups. Add one path per line relative to the directory being backed up."),
+ );
+ return $form;
+ }
+
+ /**
+ * Backup from this source.
+ */
+ function backup_to_file($file, $settings) {
+ if ($out = $this->_backup_to_file_cli($file, $settings)) {
+ return $out;
+ }
+ else {
+ return $this->_backup_to_file_php($file, $settings);
+ }
+ }
+
+ /**
+ * Backup from this source.
+ */
+ function _backup_to_file_php($file, $settings) {
+ if ($this->check_libs()) {
+ $excluded = $this->get_excluded_paths($settings);
+ $files = $this->get_files_to_backup($this->get_realpath(), $settings, $excluded);
+ if ($files) {
+ $file->push_type('tar');
+ $gz = new Archive_Tar($file->filepath(), false);
+ $gz->addModify($files, '', $this->get_realpath());
+ return $file;
+ }
+ backup_migrate_backup_fail('No files available.', array(), $settings);
+ return FALSE;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Backup from this source.
+ */
+ function _backup_to_file_cli($file, $settings) {
+ if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec') && function_exists('escapeshellarg')) {
+ $excluded = $this->get_excluded_paths($settings);
+ $exclude = array();
+ foreach ($excluded as $path) {
+ $exclude[] = '--exclude=' . escapeshellarg($path);
+ }
+ $exclude = implode(' ', $exclude);
+
+ // Create a symlink in a temp directory so we can rename the file in the archive.
+ $temp = backup_migrate_temp_directory();
+
+ $file->push_type('tar');
+ backup_migrate_exec("tar --dereference -C %input -rf %output $exclude .", array('%output' => $file->filepath(), '%input' => $this->get_realpath(), '%temp' => $temp));
+ return $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Restore to this source.
+ */
+ function restore_from_file($file, &$settings) {
+ if ($out = $this->_restore_from_file_cli($file, $settings)) {
+ return $out;
+ }
+ else {
+ return $this->_restore_from_file_php($file, $settings);
+ }
+ }
+
+ /**
+ * Restore to this source.
+ */
+ function _restore_from_file_php($file, &$settings) {
+ if ($this->check_libs()) {
+ $from = $file->pop_type();
+ $temp = backup_migrate_temp_directory();
+
+ $tar = new Archive_Tar($from->filepath());
+ $tar->extractModify($temp, $file->name);
+
+ // Older B&M Files format included a base 'files' directory.
+ if (file_exists($temp .'/files')) {
+ $temp = $temp . '/files';
+ }
+ if (file_exists($temp .'/'. $file->name .'/files')) {
+ $temp = $temp . '/files';
+ }
+
+ // Move the files from the temp directory.
+ _backup_migrate_move_files($temp, $this->get_realpath());
+
+ return $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Restore to this source.
+ */
+ function _restore_from_file_cli($file, &$settings) {
+ if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec')) {
+ $temp = backup_migrate_temp_directory();
+ backup_migrate_exec("tar -C %temp -xf %input", array('%input' => $file->filepath(), '%temp' => $temp));
+
+ // Older B&M Files format included a base 'files' directory.
+ if (file_exists($temp .'/files')) {
+ $temp = $temp . '/files';
+ }
+ if (file_exists($temp .'/'. $file->name .'/files')) {
+ $temp = $temp . '/files';
+ }
+
+ // Move the files from the temp directory.
+ backup_migrate_exec("mv -rf %temp/* %output", array('%output' => $this->get_realpath(), '%temp' => $temp));
+ return $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Get a list of files to backup from the given set if dirs. Exclude any that match the array $exclude.
+ */
+ function get_files_to_backup($dir, $settings, $exclude = array()) {
+ $out = $errors = array();
+
+ if (!file_exists($dir)) {
+ backup_migrate_backup_fail('Directory %dir does not exist.', array('%dir' => $dir), $settings);
+ return FALSE;
+ }
+ if ($handle = @opendir($dir)) {
+ while (($file = readdir($handle)) !== FALSE) {
+ if ($file != '.' && $file != '..' && !in_array($file, $exclude)) {
+ $real = realpath($dir . '/' . $file);
+ // If the path is not excluded.
+ if (!in_array($real, $exclude)) {
+ if (is_dir($real)) {
+ $subdir = $this->get_files_to_backup($real, $settings, $exclude);
+ // If there was an error reading the subdirectory then abort the backup.
+ if ($subdir === FALSE) {
+ closedir($handle);
+ return FALSE;
+ }
+ // If the directory is empty, add an empty directory.
+ if (count($subdir) == 0) {
+ $out[] = $real;
+ }
+ $out = array_merge($out, $subdir);
+ }
+ else {
+ if (is_readable($real)) {
+ $out[] = $real;
+ }
+ else {
+ $errors[] = $dir . '/' . $file;
+ }
+ }
+ }
+ }
+ }
+ closedir($handle);
+ }
+ else {
+ backup_migrate_backup_fail('Could not open directory %dir', array('%dir' => $dir), $settings);
+ return FALSE;
+ }
+
+ // Alert the user to any errors there might have been.
+ if ($errors) {
+ if (count($errors < 5)) {
+ $filesmsg = t('The following files: !files', array('!files' => theme('item_list', array('items' => $errors))));
+ }
+ else {
+ $filesmsg = t('!count files', array('!count' => count($errors)));
+ }
+
+ if (empty($settings->filters['ignore_errors'])) {
+ backup_migrate_backup_fail('The backup could not be completed because !files could not be read. If you want to skip unreadable files use the \'Ignore Errors\' setting under \'Advanced Options\' in \'Advanced Backup\' or in your schedule settings profile.', array('!files' => $filesmsg), 'error');
+ $out = FALSE;
+ }
+ else {
+ backup_migrate_backup_fail('!files could not be read and were skipped', array('!files' => $filesmsg), 'error');
+ }
+ }
+
+ return $out;
+ }
+
+ /**
+ * Break the excpluded paths string into a usable list of paths.
+ */
+ function get_excluded_paths($settings) {
+ $base_dir = $this->get_realpath() . '/';
+ $paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
+ $out = explode("\n", $paths);
+ foreach ($out as $key => $val) {
+ $path = trim($val, "/ \t\r\n");
+ // If the path specified is a stream url or absolute path add the normalized version.
+ if ($real = drupal_realpath($path)) {
+ $out[$key] = $real;
+ }
+ // If the path is a relative path add it.
+ else if ($real = drupal_realpath($base_dir . $path)) {
+ $out[$key] = $real;
+ }
+ // Otherwise add it as is even though it probably won't match any files.
+ else {
+ $out[$key] = $path;
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Check that the required libraries are installed.
+ */
+ function check_libs() {
+ $result = true;
+ // Drupal 7 has Archive_Tar built in so there should be no need to include anything here.
+ return $result;
+ }
+
+ /**
+ * Get the file location.
+ */
+ function get_realpath() {
+ return drupal_realpath($this->get_location());
+ }
+}
+
diff --git a/sites/all/modules/contrib/backup_migrate/includes/sources.inc b/sites/all/modules/contrib/backup_migrate/includes/sources.inc
new file mode 100644
index 0000000..6c650fa
--- /dev/null
+++ b/sites/all/modules/contrib/backup_migrate/includes/sources.inc
@@ -0,0 +1,268 @@
+ array(
+ 'type_name' => t('Database'),
+ 'description' => t('Import the backup directly into another database. Database sources can also be used as a source to backup from.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/sources.db.inc',
+ 'class' => 'backup_migrate_source_db',
+ 'can_create' => FALSE,
+ ),
+ 'mysql' => array(
+ 'type_name' => t('MySQL Database'),
+ 'description' => t('Import the backup directly into another MySQL database. Database sources can also be used as a source to backup from.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/sources.db.mysql.inc',
+ 'class' => 'backup_migrate_source_db_mysql',
+ 'can_create' => TRUE,
+ ),
+ 'filesource' => array(
+ 'description' => t('A files directory which can be backed up from.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/sources.filesource.inc',
+ 'class' => 'backup_migrate_destination_filesource',
+ 'type_name' => t('File Directory'),
+ 'can_create' => TRUE,
+ ),
+ 'archive' => array(
+ 'description' => t('Create an archive of your entire site.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/sources.archivesource.inc',
+ 'class' => 'backup_migrate_files_destination_archivesource',
+ 'type_name' => t('Site Archive'),
+ 'can_create' => FALSE,
+ ),
+ );
+
+ return $out;
+}
+
+/**
+ * Implementation of hook_backup_migrate_sources().
+ *
+ * Get the built in backup sources and those in the db.
+ */
+function backup_migrate_backup_migrate_sources() {
+ $out = array();
+
+ // Expose the configured databases as sources.
+ backup_migrate_include('filters');
+ $out += backup_migrate_filters_invoke_all('sources');
+
+ return $out;
+}
+
+/**
+ * Get the source options as a form element.
+ */
+function _backup_migrate_get_source_form($source_id = 'db') {
+ backup_migrate_include('destinations');
+
+ $form = array();
+ $sources = _backup_migrate_get_source_pulldown($source_id);
+ if (count($sources['#options']) > 1) {
+ $form['source'] = array(
+ "#type" => "fieldset",
+ "#title" => t("Backup Source"),
+ "#collapsible" => TRUE,
+ "#collapsed" => FALSE,
+ "#tree" => FALSE,
+ );
+ $sources['#description'] = t("Choose the database to backup. Any database destinations you have created and any databases specified in your settings.php can be backed up.");
+
+ $form['source']['source_id'] = $sources;
+ }
+ else {
+ $form = array();
+ $form['source']['source_id'] = array(
+ "#type" => "value",
+ "#value" => $source_id,
+ );
+ }
+ return $form;
+}
+
+/**
+ * Get pulldown to select existing source options.
+ */
+function _backup_migrate_get_source_pulldown($source_id = NULL) {
+ $sources = _backup_migrate_get_source_form_item_options();
+ $form = array(
+ "#type" => "select",
+ "#title" => t("Backup Source"),
+ "#options" => _backup_migrate_get_source_form_item_options(),
+ "#default_value" => $source_id,
+ );
+ return $form;
+}
+
+/**
+ * Get the location options as an options array for a form item.
+ */
+function _backup_migrate_get_source_form_item_options() {
+ $out = array();
+ foreach (backup_migrate_get_sources() as $key => $location) {
+ $out[$key] = $location->get_name();
+ }
+ return $out;
+}
+
+/**
+ * A base class for creating sources.
+ */
+class backup_migrate_source extends backup_migrate_location {
+ var $db_table = "backup_migrate_sources";
+ var $type_name = 'source';
+ var $singular = 'source';
+ var $plural = 'sources';
+ var $title_plural = 'Sources';
+ var $title_singular = 'Source';
+
+ /**
+ * This function is not supposed to be called. It is just here to help the po extractor out.
+ */
+ function strings() {
+ // Help the pot extractor find these strings.
+ t('source');
+ t('sources');
+ t('Sources');
+ t('Source');
+ }
+
+ /**
+ * Get the available location types.
+ */
+ function location_types() {
+ return backup_migrate_get_source_subtypes();
+ }
+
+}
+
+/**
+ * A base class for creating sources.
+ */
+class backup_migrate_source_remote extends backup_migrate_source {
+ /**
+ * The location is a URI so parse it and store the parts.
+ */
+ function get_location() {
+ return $this->url(FALSE);
+ }
+
+ /**
+ * The location to display is the url without the password.
+ */
+ function get_display_location() {
+ return $this->url(TRUE);
+ }
+
+ /**
+ * Return the location with the password.
+ */
+ function set_location($location) {
+ $this->location = $location;
+ $this->set_url($location);
+ }
+
+ /**
+ * source configuration callback.
+ */
+ function edit_form() {
+ $form = parent::edit_form();
+ $form['scheme'] = array(
+ "#type" => "textfield",
+ "#title" => t("Scheme"),
+ "#default_value" => @$this->dest_url['scheme'] ? $this->dest_url['scheme'] : '',
+ "#required" => TRUE,
+ "#weight" => 0,
+ );
+ $form['host'] = array(
+ "#type" => "textfield",
+ "#title" => t("Host"),
+ "#default_value" => @$this->dest_url['host'] ? $this->dest_url['host'] : 'localhost',
+ "#required" => TRUE,
+ "#weight" => 10,
+ );
+ $form['path'] = array(
+ "#type" => "textfield",
+ "#title" => t("Path"),
+ "#default_value" => @$this->dest_url['path'],
+ "#required" => TRUE,
+ "#weight" => 20,
+ );
+ $form['user'] = array(
+ "#type" => "textfield",
+ "#title" => t("Username"),
+ "#default_value" => @$this->dest_url['user'],
+ "#required" => TRUE,
+ "#weight" => 30,
+ );
+ $form['pass'] = array(
+ "#type" => "password",
+ "#title" => t("Password"),
+ "#default_value" => @$this->dest_url['pass'],
+ '#description' => '',
+ "#weight" => 40,
+ );
+ if (@$this->dest_url['pass']) {
+ $form['old_password'] = array(
+ "#type" => "value",
+ "#value" => @$this->dest_url['pass'],
+ );
+ $form['pass']["#description"] .= t(' You do not need to enter a password unless you wish to change the currently saved password.');
+ }
+ return $form;
+ }
+
+ /**
+ * Submit the configuration form. Glue the url together and add the old password back if a new one was not specified.
+ */
+ function edit_form_submit($form, &$form_state) {
+ $form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password'];
+ $form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE);
+ parent::edit_form_submit($form, $form_state);
+ }
+}
+
diff --git a/sites/all/modules/contrib/ctools/API.txt b/sites/all/modules/contrib/ctools/API.txt
new file mode 100644
index 0000000..b698b79
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/API.txt
@@ -0,0 +1,54 @@
+Current API Version: 2.0.8
+
+Please note that the API version is an internal number and does not match release numbers. It is entirely possible that releases will not increase the API version number, and increasing this number too often would burden contrib module maintainers who need to keep up with API changes.
+
+This file contains a log of changes to the API.
+API Version 2.0.9
+Changed import permissions to use the new 'use ctools import' permission.
+
+API Version 2.0.8
+ Introduce ctools_class_add().
+ Introduce ctools_class_remove().
+
+API Version 2.0.7
+ All ctools object cache database functions can now accept session_id as an optional
+ argument to facilitate using non-session id keys.
+
+API Version 2.0.6
+ Introduce a hook to alter the implementors of a certain api via hook_[ctools_api_hook]_alter.
+
+API Version 2.0.5
+ Introduce ctools_fields_get_fields_by_type().
+ Add language.inc
+ Introduce hook_ctools_content_subtype_alter($subtype, $plugin);
+
+API Version 2.0.4
+ Introduce ctools_form_include_file()
+
+API Version 2.0.3
+ Introduce ctools_field_invoke_field() and ctools_field_invoke_field_default().
+
+API Version 2.0.2
+ Introduce ctools_export_crud_load_multiple() and 'load multiple callback' to
+ export schema.
+
+API Version 2.0.1
+ Introduce ctools_export_crud_enable(), ctools_export_crud_disable() and
+ ctools_export_crud_set_status() and requisite changes.
+ Introduce 'object factory' to export schema, allowing modules to control
+ how the exportable objects are instantiated.
+ Introduce 'hook_ctools_math_expression_functions_alter'.
+
+API Version 2.0
+ Remove the deprecated callback-based behavior of the 'defaults' property on
+ plugin types; array addition is now the only option. If you need more
+ complex logic, do it with the 'process' callback.
+ Introduce a global plugin type registration hook and remove the per-plugin
+ type magic callbacks.
+ Introduce $owner . '_' . $api . '_hook_name' allowing modules to use their own
+ API hook in place of 'hook_ctools_plugin_api'.
+ Introduce ctools_plugin_api_get_hook() to get the hook name above.
+ Introduce 'cache defaults' and 'default cache bin' keys to export.inc
+
+Versions prior to 2.0 have been removed from this document. See the D6 version
+for that information.
diff --git a/sites/all/modules/contrib/ctools/CHANGELOG.txt b/sites/all/modules/contrib/ctools/CHANGELOG.txt
new file mode 100644
index 0000000..c5bd5e6
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/CHANGELOG.txt
@@ -0,0 +1,82 @@
+Current API VERSION: 2.0. See API.txt for more information.
+
+ctools 7.x-1.x-dev
+==================
+#1008120: "New custom content" shows empty form if custom content panes module is not enabled.
+#999302 by troky: Fix jump menu. Apparently this wasn't actually committed the last time it was committed.
+#1065976 by tekante and David_Rothstein: Reset plugin static cache during module enable to prevent stale data from harming export ui.
+#1016510 by EclipseGC: Make the taxonomy system page functional.
+
+ctools 7.x-1.x-alpha2 (05-Jan-2011)
+===================================
+
+#911396 by alex_b: Prevent notices in export UI.
+#919768 by mikey_p: Allow url options to be sent to ctools_ajax_command_url().
+#358953 by cedarm: Allow term context to return lowercase, spaces to dashes versions of terms.
+#931434 by EclipseGc: Argument plugin for node revision ID.
+#910656: CTools AJAX sample wizard demo "domesticated" checkbox value not stored.
+#922442 by EugenMayer, neclimdul and voxpelli: Make sure ctools_include can handle '' or NULL directory.
+#919956 by traviss359: Correct example in wizard advanced help.
+#942968: Fix taxonomy term access rule with tag term vocabs.
+#840344: node add argument had crufty code causing notices.
+#944462 by longhairedgit: Invalid character in regex causes rare notice.
+#938778 by dereine: Fix profile content type for D7 updates.
+Add detach event to modal close so that wysiwyg can detach the editor.
+Variant titles showing up as blank if more than one variant on a page.
+#940016: token support was not yet updated for D7.
+#940446: Skip validation on back and cancel buttons in all wizards.
+#954492: Redirect not always working in wizard.inc
+#955348: Lack of redirect on "Update" button in Page Manager causing data loss sometimes.
+#941778: Update and save button should not appear in the "Add variant" path.
+#955070 by EclipseGc: Update ctools internal page tokens to work properly on content all content.
+#956890 by EclipseGc: Update views_content to not use views dependency since that is gone.
+#954728 by EclipseGc: Update node template page function name to not collide with new hook_node_view().
+#946534 by EclipseGc: Add support for field content on all entitities.
+#952586 by EclipseGc: Fix node_author content type.
+#959206: If a context is not set when rendering content, attempt to guess the context (fixes Views panes where "From context" was added but pane was never edited.)
+#961654 by benshell: drupal_alter() only supports 4 arguments.
+#911362 by alex_b: Facilitate plugin cache resets for tests.
+#945360 by naxoc: node_tag_new() not updated to D7.
+#953804 by EclipseGc: Fix node comment rendering.
+#953542 by EclipseGc: Fix node rendering.
+#953776 by EclipseGc: Fix node link rendering.
+#954772 by EclipseGc: Fix node build mode selection in node content type.
+#954762 by EclipseGc: Fix comment forbidden theme call.
+#954894 by EclipseGc: Fix breadcrumb content type.
+#955180 by EclipseGc: Fix page primary navigation type.
+#957190 by EclipseGc: Fix page secondary navigation type.
+#957194 by EclipseGc: Remove mission content type, since D7 no longer has a site mission.
+#957348 by EclipseGc: Fix search form URL path.
+#952586 by andypost: Use format_username for displaying unlinked usernames.
+#963800 by benshell: Fix query to fetch custom block title.
+#983496 by Amitaibu: Fix term argument to use proper load function.
+#989484 by Amitaibu: Fix notice in views plugin.
+#982496: Fix token context.
+#995026: Fix export UI during enable/disable which would throw notices and not properly set/unset menu items.
+#998870 by Amitaibu: Fix notice when content has no icon by using function already designed for that.
+#983576 by Amitaibu: Node view fallback task showed white screen.
+#1004644 by pillarsdotnet: Update a missed theme() call to D7.
+#1006162 by aspilicious: .info file cleanup.
+#998312 by dereine: Support the expanded/hidden options that Views did for dependent.js
+#955030: Remove no longer supported footer message content type.
+Fix broken query in term context config.
+#992022 by pcambra: Fix node autocomplete.
+#946302 by BerdArt and arywyr: Fix PHP 5.3 reference error.
+#980528 by das-peter: Notice fix with entity settings.
+#999302 by troky: ctools_jump_menu() needed updating to new form parameters.
+#964174: stylizer plugin theme delegation was in the wrong place, causing errors.
+#991658 by burlap: Fully load the "user" context for the logged in user because not all fields are in $user.
+#1014866 by das-peter: Smarter title panes, notice fix on access plugin descriptions.
+#1015662 by troky: plugin .info files were not using correct filepaths.
+#941780 by EclipseGc: Restore the "No blocks" functionality.
+#951048 by EclipseGc: Tighter entity integration so that new entities are automatic contexts and relationships.
+#941800 by me and aspilicious: Use Drupal 7 #machine_name automation on page manager pages and all export_ui defaults.
+Disabled exportables and pages not properly greyed out.
+#969208 by me and benshell: Get user_view and user profile working.
+#941796: Recategorize blocks
+
+ctools 7.x-1.x-alpha1
+=====================
+
+Changelog reset for 7.x
+Basic conversion done during sprint.
diff --git a/sites/all/modules/contrib/ctools/LICENSE.txt b/sites/all/modules/contrib/ctools/LICENSE.txt
new file mode 100644
index 0000000..d159169
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/LICENSE.txt
@@ -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.
+
+
+ Copyright (C)
+
+ 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.
+
+ , 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.
diff --git a/sites/all/modules/contrib/ctools/UPGRADE.txt b/sites/all/modules/contrib/ctools/UPGRADE.txt
new file mode 100644
index 0000000..844ecce
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/UPGRADE.txt
@@ -0,0 +1,63 @@
+Upgrading from ctools-6.x-1.x to ctools-7.x-2.x:
+
+ - Remove ctools_ajax_associate_url_to_element as it shouldn't be necessary
+ with the new AJAX api's in Drupal core.
+
+ - All calls to the ctools_ajax_command_prepend() should be replace with
+ the core function ajax_command_prepend();
+ This is also the case for append, insert, after, before, replace, html,
+ and remove commands.
+ Each of these commands have been incorporated into the
+ Drupal.ajax.prototype.commands.insert
+ function with a corresponding parameter specifying which method to use.
+
+ - All calls to ctools_ajax_render() should be replaced with calls to core
+ ajax_render(). Note that ctools_ajax_render() printed the json object and
+ exited, ajax_render() gives you this responsibility.
+
+ ctools_ajax_render()
+
+ becomes
+
+ print ajax_render();
+ exit;
+
+ - All calls to ctools_static*() should be replaced with corresponding calls
+ to drupal_static*().
+
+ - All calls to ctools_css_add_css should be replaced with calls to
+ drupal_add_css(). Note that the arguments to drupal_add_css() have changed.
+
+ - All wizard form builder functions must now return a form array().
+
+ - ctools_build_form is very close to being removed. In anticipation of this,
+ all $form_state['wrapper callback']s must now be
+ $form_state['wrapper_callback']. In addition to this $form_state['args']
+ must now be $form_state['build_info']['args'].
+
+ NOTE: Previously checking to see if the return from ctools_build_form()
+ is empty would be enough to see if the form was submitted. This is no
+ longer true. Please check for $form_state['executed']. If using a wizard
+ check for $form_state['complete'].
+
+ - Plugin types now must be explicitly registered via a registration hook,
+ hook_ctools_plugin_type(); info once provided in magically-named functions
+ (e.g., ctools_ctools_plugin_content_types() was the old function to
+ provide plugin type info for ctools' content_type plugins) now must be
+ provided in that global hook. See http://drupal.org/node/910538 for more
+ details.
+
+ - Plugins that use 'theme arguments' now use 'theme variables' instead.
+
+ - Context, argument and relationship plugins now use 'add form' and/or
+ 'edit form' rather than 'settings form'. These plugins now support
+ form wizards just like content plugins. These forms now all take
+ $form, &$form_state as arguments, and the configuration for the plugin
+ can be found in $form_state['conf'].
+
+ For all these forms, the submit handler MUST put appropriate data in
+ $form_state['conf']. Data will no longer be stored automatically.
+
+ For all of these forms, the separate settings #trees in the form are now
+ gone, so form ids may be adjusted. Also, these are now all real forms
+ using CTools form wizard instead of fake subforms as previously.
\ No newline at end of file
diff --git a/sites/all/modules/contrib/ctools/bulk_export/bulk_export.css b/sites/all/modules/contrib/ctools/bulk_export/bulk_export.css
new file mode 100644
index 0000000..45a172d
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/bulk_export/bulk_export.css
@@ -0,0 +1,18 @@
+.export-container {
+ width: 48%;
+ float: left;
+ padding: 5px 1% 0;
+}
+.export-container table {
+ width: 100%;
+}
+.export-container table input,
+.export-container table th,
+.export-container table td {
+ padding: 0 0 .2em .5em;
+ margin: 0;
+ vertical-align: middle;
+}
+.export-container .select-all {
+ width: 1.5em;
+}
diff --git a/sites/all/modules/contrib/ctools/bulk_export/bulk_export.info b/sites/all/modules/contrib/ctools/bulk_export/bulk_export.info
new file mode 100644
index 0000000..dd9f3e9
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/bulk_export/bulk_export.info
@@ -0,0 +1,14 @@
+name = Bulk Export
+description = Performs bulk exporting of data objects known about by Chaos tools.
+core = 7.x
+dependencies[] = ctools
+package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
+
+
+; Information added by Drupal.org packaging script on 2015-08-19
+version = "7.x-1.9"
+core = "7.x"
+project = "ctools"
+datestamp = "1440020680"
+
diff --git a/sites/all/modules/contrib/ctools/bulk_export/bulk_export.js b/sites/all/modules/contrib/ctools/bulk_export/bulk_export.js
new file mode 100644
index 0000000..a4fb3f2
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/bulk_export/bulk_export.js
@@ -0,0 +1,29 @@
+
+/**
+ * @file
+ * CTools Bulk Export javascript functions.
+ */
+
+(function ($) {
+
+Drupal.behaviors.CToolsBulkExport = {
+ attach: function (context) {
+
+ $('#bulk-export-export-form .vertical-tabs-pane', context).drupalSetSummary(function (context) {
+
+ // Check if any individual checkbox is checked.
+ if ($('.bulk-selection input:checked', context).length > 0) {
+ return Drupal.t('Exportables selected');
+ }
+
+ return '';
+ });
+
+ // Special bind click on the select-all checkbox.
+ $('.select-all').bind('click', function(context) {
+ $(this, '.vertical-tabs-pane').drupalSetSummary(context);
+ });
+ }
+};
+
+})(jQuery);
diff --git a/sites/all/modules/contrib/ctools/bulk_export/bulk_export.module b/sites/all/modules/contrib/ctools/bulk_export/bulk_export.module
new file mode 100644
index 0000000..afb15b9
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/bulk_export/bulk_export.module
@@ -0,0 +1,279 @@
+ array(
+ 'title' => t('Access Bulk Exporter'),
+ 'description' => t('Export various system objects into code.'),
+ ),
+ );
+}
+
+/**
+ * Implements hook_menu().
+ */
+function bulk_export_menu() {
+ $items['admin/structure/bulk-export'] = array(
+ 'title' => 'Bulk Exporter',
+ 'description' => 'Bulk-export multiple CTools-handled data objects to code.',
+ 'access arguments' => array('use bulk exporter'),
+ 'page callback' => 'bulk_export_export',
+ );
+ $items['admin/structure/bulk-export/results'] = array(
+ 'access arguments' => array('use bulk exporter'),
+ 'page callback' => 'bulk_export_export',
+ 'type' => MENU_CALLBACK,
+ );
+ return $items;
+}
+
+/**
+ * FAPI gateway to the bulk exporter.
+ *
+ * @param $cli
+ * Whether this function is called from command line.
+ * @param $options
+ * A collection of options, only passed in by drush_ctools_export().
+ */
+function bulk_export_export($cli = FALSE, $options = array()) {
+ ctools_include('export');
+ $form = array();
+ $schemas = ctools_export_get_schemas(TRUE);
+ $exportables = $export_tables = array();
+
+ foreach ($schemas as $table => $schema) {
+ if (!empty($schema['export']['list callback']) && function_exists($schema['export']['list callback'])) {
+ $exportables[$table] = $schema['export']['list callback']();
+ }
+ else {
+ $exportables[$table] = ctools_export_default_list($table, $schema);
+ }
+ natcasesort($exportables[$table]);
+ $export_tables[$table] = $schema['module'];
+ }
+ if ($exportables) {
+ $form_state = array(
+ 're_render' => FALSE,
+ 'no_redirect' => TRUE,
+ 'exportables' => $exportables,
+ 'export_tables' => $export_tables,
+ 'name' => '',
+ 'code' => '',
+ 'module' => '',
+ );
+
+ // If called from drush_ctools_export, get the module name and
+ // select all exportables and call the submit function directly.
+ if ($cli) {
+ $module_name = $options['name'];
+ $form_state['values']['name'] = $module_name;
+ if (isset($options['selections'])) {
+ $exportables = $options['selections'];
+ }
+ $form_state['values']['tables'] = array();
+ foreach ($exportables as $table => $names) {
+ if (!empty($names)) {
+ $form_state['values']['tables'][] = $table;
+ $form_state['values'][$table] = array();
+ foreach ($names as $name => $title) {
+ $form_state['values'][$table][$name] = $name;
+ }
+ }
+ }
+ $output = bulk_export_export_form_submit($form, $form_state);
+ }
+ else {
+ $output = drupal_build_form('bulk_export_export_form', $form_state);
+ $module_name = $form_state['module'];
+ }
+
+ if (!empty($form_state['submitted']) || $cli) {
+ drupal_set_title(t('Bulk export results'));
+ $output = '';
+ $module_code = '';
+ $api_code = array();
+ $dependencies = $file_data = array();
+ foreach ($form_state['code'] as $module => $api_info) {
+ if ($module == 'general') {
+ $module_code .= $api_info;
+ }
+ else {
+ foreach ($api_info as $api => $info) {
+ $api_hook = ctools_plugin_api_get_hook($module, $api);
+ if (empty($api_code[$api_hook])) {
+ $api_code[$api_hook] = '';
+ }
+ $api_code[$api_hook] .= " if (\$module == '$module' && \$api == '$api') {\n";
+ $api_code[$api_hook] .= " return array('version' => $info[version]);\n";
+ $api_code[$api_hook] .= " }\n";
+ $dependencies[$module] = TRUE;
+
+ $file = $module_name . '.' . $api . '.inc';
+ $code = " $file)));
+ $output .= drupal_render($export_form);
+ }
+ }
+ }
+ }
+
+ // Add hook_ctools_plugin_api at the top of the module code, if there is any.
+ if ($api_code) {
+ foreach ($api_code as $api_hook => $text) {
+ $api = "\n/**\n";
+ $api .= " * Implements hook_$api_hook().\n";
+ $api .= " */\n";
+ $api .= "function {$module_name}_$api_hook(\$module, \$api) {\n";
+ $api .= $text;
+ $api .= "}\n";
+ $module_code = $api . $module_code;
+ }
+ }
+
+ if ($module_code) {
+ $module = " $form_state['module'] . '.module')));
+ $output = drupal_render($export_form) . $output;
+ }
+ }
+
+ $info = strtr("name = @module export module\n", array('@module' => $form_state['module']));
+ $info .= strtr("description = Export objects from CTools\n", array('@module' => $form_state['values']['name']));
+ foreach ($dependencies as $module => $junk) {
+ $info .= "dependencies[] = $module\n";
+ }
+ $info .= "package = Chaos tool suite\n";
+ $info .= "core = 7.x\n";
+ if ($cli) {
+ $file_data[$module_name . '.info'] = $info;
+ }
+ else {
+ $export_form = drupal_get_form('ctools_export_form', $info, t('Place this in @file', array('@file' => $form_state['module'] . '.info')));
+ $output = drupal_render($export_form) . $output;
+ }
+ }
+
+ if ($cli) {
+ return $file_data;
+ }
+ else {
+ return $output;
+ }
+ }
+ else {
+ return t('There are no objects to be exported at this time.');
+ }
+}
+
+/**
+ * FAPI definition for the bulk exporter form.
+ *
+ */
+function bulk_export_export_form($form, &$form_state) {
+
+ $files = system_rebuild_module_data();
+
+ $form['additional_settings'] = array(
+ '#type' => 'vertical_tabs',
+ );
+
+ $options = $tables = array();
+ foreach ($form_state['exportables'] as $table => $list) {
+ if (empty($list)) {
+ continue;
+ }
+
+ foreach ($list as $id => $title) {
+ $options[$table][$id] = array($title);
+ $options[$table][$id]['#attributes'] = array('class' => array('bulk-selection'));
+ }
+
+ $module = $form_state['export_tables'][$table];
+ $header = array($table);
+ $module_name = $files[$module]->info['name'];
+ $tables[] = $table;
+
+ if (!isset($form[$module_name])) {
+ $form[$files[$module]->info['name']] = array(
+ '#type' => 'fieldset',
+ '#group' => 'additional_settings',
+ '#title' => $module_name,
+ );
+ }
+
+ $form[$module_name]['tables'][$table] = array(
+ '#prefix' => '
',
+ '#suffix' => '
',
+ '#type' => 'tableselect',
+ '#header' => $header,
+ '#options' => $options[$table],
+ );
+ }
+
+ $form['tables'] = array(
+ '#type' => 'value',
+ '#value' => $tables,
+ );
+
+ $form['name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Module name'),
+ '#description' => t('Enter the module name to export code to.'),
+ );
+
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Export'),
+ );
+
+ $form['#action'] = url('admin/structure/bulk-export/results');
+ $form['#attached']['css'][] = drupal_get_path('module', 'bulk_export') . '/bulk_export.css';
+ $form['#attached']['js'][] = drupal_get_path('module', 'bulk_export') . '/bulk_export.js';
+ return $form;
+}
+
+/**
+ * Process the bulk export submit form and make the results available.
+ */
+function bulk_export_export_form_submit($form, &$form_state) {
+ $code = array();
+ $name = empty($form_state['values']['name']) ? 'foo' : $form_state['values']['name'];
+ $tables = $form_state['values']['tables'];
+
+ foreach ($tables as $table) {
+ $names = array_keys(array_filter($form_state['values'][$table]));
+ if ($names) {
+ natcasesort($names);
+ ctools_export_to_hook_code($code, $table, $names, $name);
+ }
+ }
+
+ $form_state['code'] = $code;
+ $form_state['module'] = $name;
+}
diff --git a/sites/all/modules/contrib/ctools/css/button.css b/sites/all/modules/contrib/ctools/css/button.css
new file mode 100644
index 0000000..15e484b
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/button.css
@@ -0,0 +1,31 @@
+
+.ctools-button-processed {
+ border-style: solid;
+ border-width: 1px;
+ display: inline-block;
+ line-height: 1;
+}
+
+.ctools-button-processed:hover {
+ cursor: pointer;
+}
+
+.ctools-button-processed .ctools-content {
+ padding-bottom: 2px;
+ padding-top: 2px;
+}
+
+.ctools-no-js .ctools-content ul,
+.ctools-button-processed .ctools-content ul {
+ list-style-image: none;
+ list-style-type: none;
+}
+
+.ctools-button-processed li {
+ line-height: 1.3333;
+}
+
+.ctools-button li a {
+ padding-left: 12px;
+ padding-right: 12px;
+}
diff --git a/sites/all/modules/contrib/ctools/css/collapsible-div.css b/sites/all/modules/contrib/ctools/css/collapsible-div.css
new file mode 100644
index 0000000..ff64813
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/collapsible-div.css
@@ -0,0 +1,26 @@
+
+.ctools-collapsible-container .ctools-toggle {
+ float: left;
+ width: 21px;
+ height: 21px;
+ cursor: pointer;
+ background-position: 7px 7px;
+ background-repeat: no-repeat;
+ background-image: url(../images/collapsible-expanded.png);
+}
+
+.ctools-collapsible-container .ctools-collapsible-handle {
+ display: none;
+}
+
+html.js .ctools-collapsible-container .ctools-collapsible-handle {
+ display: block;
+}
+
+.ctools-collapsible-container .ctools-collapsible-handle {
+ cursor: pointer;
+}
+
+.ctools-collapsible-container .ctools-toggle-collapsed {
+ background-image: url(../images/collapsible-collapsed.png);
+}
diff --git a/sites/all/modules/contrib/ctools/css/context.css b/sites/all/modules/contrib/ctools/css/context.css
new file mode 100644
index 0000000..5093104
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/context.css
@@ -0,0 +1,10 @@
+.ctools-context-holder .ctools-context-title {
+ float: left;
+ width: 49%;
+ font-style: italic;
+}
+
+.ctools-context-holder .ctools-context-content {
+ float: right;
+ width: 49%;
+}
diff --git a/sites/all/modules/contrib/ctools/css/ctools.css b/sites/all/modules/contrib/ctools/css/ctools.css
new file mode 100644
index 0000000..7372988
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/ctools.css
@@ -0,0 +1,25 @@
+.ctools-locked {
+ color: red;
+ border: 1px solid red;
+ padding: 1em;
+}
+
+.ctools-owns-lock {
+ background: #FFFFDD none repeat scroll 0 0;
+ border: 1px solid #F0C020;
+ padding: 1em;
+}
+
+a.ctools-ajaxing,
+input.ctools-ajaxing,
+button.ctools-ajaxing,
+select.ctools-ajaxing {
+ padding-right: 18px !important;
+ background: url(../images/status-active.gif) right center no-repeat;
+}
+
+div.ctools-ajaxing {
+ float: left;
+ width: 18px;
+ background: url(../images/status-active.gif) center center no-repeat;
+}
diff --git a/sites/all/modules/contrib/ctools/css/dropbutton.css b/sites/all/modules/contrib/ctools/css/dropbutton.css
new file mode 100644
index 0000000..5e3ea24
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/dropbutton.css
@@ -0,0 +1,66 @@
+
+.ctools-dropbutton-processed {
+ padding-right: 18px;
+ position: relative;
+ background-color: inherit;
+}
+
+.ctools-dropbutton-processed.open {
+ z-index: 200;
+}
+
+.ctools-dropbutton-processed .ctools-content li,
+.ctools-dropbutton-processed .ctools-content a {
+ display: block;
+}
+
+.ctools-dropbutton-processed .ctools-link {
+ bottom: 0;
+ display: block;
+ height: auto;
+ position: absolute;
+ right: 0;
+ text-indent: -9999px; /* LTR */
+ top: 0;
+ width: 17px;
+}
+
+.ctools-dropbutton-processed .ctools-link a {
+ overflow: hidden;
+}
+
+.ctools-dropbutton-processed .ctools-content ul {
+ margin: 0;
+ overflow: hidden;
+}
+
+.ctools-dropbutton-processed.open li + li {
+ padding-top: 4px;
+}
+
+/**
+ * This creates the dropbutton arrow and inherits the link color
+ */
+.ctools-twisty {
+ border-bottom-color: transparent;
+ border-left-color: transparent;
+ border-right-color: transparent;
+ border-style: solid;
+ border-width: 4px 4px 0;
+ line-height: 0;
+ right: 6px;
+ position: absolute;
+ top: 0.75em;
+}
+
+.ctools-dropbutton-processed.open .ctools-twisty {
+ border-bottom: 4px solid;
+ border-left-color: transparent;
+ border-right-color: transparent;
+ border-top-color: transparent;
+ top: 0.5em;
+}
+
+.ctools-no-js .ctools-twisty {
+ display: none;
+}
diff --git a/sites/all/modules/contrib/ctools/css/dropdown.css b/sites/all/modules/contrib/ctools/css/dropdown.css
new file mode 100644
index 0000000..bb50f3f
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/dropdown.css
@@ -0,0 +1,73 @@
+html.js div.ctools-dropdown div.ctools-dropdown-container {
+ z-index: 1001;
+ display: none;
+ text-align: left;
+ position: absolute;
+}
+
+html.js div.ctools-dropdown div.ctools-dropdown-container ul li a {
+ display: block;
+}
+
+html.js div.ctools-dropdown div.ctools-dropdown-container ul {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+}
+
+html.js div.ctools-dropdown div.ctools-dropdown-container ul li {
+ display: block;
+ /* prevent excess right margin in IE */
+ margin-right: 0;
+ margin-left: 0;
+ padding-right: 0;
+ padding-left: 0;
+ background-image: none; /* prevent list backgrounds from mucking things up */
+}
+
+.ctools-dropdown-no-js .ctools-dropdown-link,
+.ctools-dropdown-no-js span.text {
+ display: none;
+}
+
+/* Everything from here down is purely visual style and can be overridden. */
+
+html.js div.ctools-dropdown a.ctools-dropdown-text-link {
+ background: url(../images/collapsible-expanded.png) 3px 5px no-repeat;
+ padding-left: 12px;
+}
+
+html.js div.ctools-dropdown div.ctools-dropdown-container {
+ width: 175px;
+ background: #fff;
+ border: 1px solid black;
+ margin: 4px 1px 0 0;
+ padding: 0;
+ color: #494949;
+}
+
+html.js div.ctools-dropdown div.ctools-dropdown-container ul li li a {
+ padding-left: 25px;
+ width: 150px;
+ color: #027AC6;
+}
+
+html.js div.ctools-dropdown div.ctools-dropdown-container ul li a {
+ text-decoration: none;
+ padding-left: 5px;
+ width: 170px;
+ color: #027AC6;
+}
+
+html.js div.ctools-dropdown div.ctools-dropdown-container ul li span {
+ display: block;
+}
+
+html.js div.ctools-dropdown div.ctools-dropdown-container ul li span.text {
+ font-style: italic;
+ padding-left: 5px;
+}
+
+html.js .ctools-dropdown-hover {
+ background-color: #ECECEC;
+}
diff --git a/sites/all/modules/contrib/ctools/css/export-ui-list.css b/sites/all/modules/contrib/ctools/css/export-ui-list.css
new file mode 100644
index 0000000..170d128
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/export-ui-list.css
@@ -0,0 +1,45 @@
+body form#ctools-export-ui-list-form {
+ margin: 0 0 20px 0;
+}
+
+#ctools-export-ui-list-form .form-item {
+ padding-right: 1em; /* LTR */
+ float: left; /* LTR */
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+#ctools-export-ui-list-items {
+ width: 100%;
+}
+
+#edit-order-wrapper {
+ clear: left; /* LTR */
+}
+
+#ctools-export-ui-list-form .form-submit {
+ margin-top: 1.65em;
+ float: left; /* LTR */
+}
+
+tr.ctools-export-ui-disabled td {
+ color: #999;
+}
+
+th.ctools-export-ui-operations,
+td.ctools-export-ui-operations {
+ text-align: right; /* LTR */
+ vertical-align: top;
+}
+
+/* Force the background color to inherit so that the dropbuttons do not need
+ a specific background color. */
+td.ctools-export-ui-operations {
+ background-color: inherit;
+}
+
+td.ctools-export-ui-operations .ctools-dropbutton {
+ text-align: left; /* LTR */
+ position: absolute;
+ right: 10px;
+}
diff --git a/sites/all/modules/contrib/ctools/css/modal.css b/sites/all/modules/contrib/ctools/css/modal.css
new file mode 100644
index 0000000..def374b
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/modal.css
@@ -0,0 +1,130 @@
+div.ctools-modal-content {
+ background: #fff;
+ color: #000;
+ padding: 0;
+ margin: 2px;
+ border: 1px solid #000;
+ width: 600px;
+ text-align: left;
+}
+
+div.ctools-modal-content .modal-title {
+ font-size: 120%;
+ font-weight: bold;
+ color: white;
+ overflow: hidden;
+ white-space: nowrap;
+}
+
+div.ctools-modal-content .modal-header {
+ background-color: #2385c2;
+ padding: 0 .25em 0 1em;
+}
+
+div.ctools-modal-content .modal-header a {
+ color: white;
+}
+
+div.ctools-modal-content .modal-content {
+ padding: 1em 1em 0 1em;
+ overflow: auto;
+ position: relative; /* Keeps IE7 from flowing outside the modal. */
+}
+
+div.ctools-modal-content .modal-form {
+}
+
+div.ctools-modal-content a.close {
+ color: white;
+ float: right;
+}
+
+div.ctools-modal-content a.close:hover {
+ text-decoration: none;
+}
+
+div.ctools-modal-content a.close img {
+ position: relative;
+ top: 1px;
+}
+
+div.ctools-modal-content .modal-content .modal-throbber-wrapper {
+ text-align: center;
+}
+
+div.ctools-modal-content .modal-content .modal-throbber-wrapper img {
+ margin-top: 160px;
+}
+
+/** modal forms CSS **/
+div.ctools-modal-content .form-item label {
+ width: 15em;
+ float: left;
+}
+
+div.ctools-modal-content .form-item label.option {
+ width: auto;
+ float: none;
+}
+
+div.ctools-modal-content .form-item .description {
+ clear: left;
+}
+
+div.ctools-modal-content .form-item .description .tips {
+ margin-left: 2em;
+}
+
+div.ctools-modal-content .no-float .form-item * {
+ float: none;
+}
+
+div.ctools-modal-content .modal-form .no-float label {
+ width: auto;
+}
+
+div.ctools-modal-content fieldset,
+div.ctools-modal-content .form-radios,
+div.ctools-modal-content .form-checkboxes {
+ clear: left;
+}
+
+div.ctools-modal-content .vertical-tabs-panes > fieldset {
+ clear: none;
+}
+
+div.ctools-modal-content .resizable-textarea {
+ width: auto;
+ margin-left: 15em;
+ margin-right: 5em;
+}
+
+div.ctools-modal-content .container-inline .form-item {
+ margin-right: 2em;
+}
+
+#views-exposed-pane-wrapper .form-item {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+div.ctools-modal-content label.hidden-options {
+ background: transparent url(../images/arrow-active.png) no-repeat right;
+ height: 12px;
+ padding-right: 12px;
+}
+
+div.ctools-modal-content label.expanded-options {
+ background: transparent url(../images/expanded-options.png) no-repeat right;
+ height: 12px;
+ padding-right: 16px;
+}
+
+div.ctools-modal-content .option-text-aligner label.expanded-options,
+div.ctools-modal-content .option-text-aligner label.hidden-options {
+ background: none;
+}
+
+div.ctools-modal-content .dependent-options {
+ padding-left: 30px;
+}
diff --git a/sites/all/modules/contrib/ctools/css/ruleset.css b/sites/all/modules/contrib/ctools/css/ruleset.css
new file mode 100644
index 0000000..891455f
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/ruleset.css
@@ -0,0 +1,11 @@
+.ctools-right-container {
+ float: right;
+ padding: 0 0 0 .5em;
+ margin: 0;
+ width: 48.5%;
+}
+
+.ctools-left-container {
+ padding-right: .5em;
+ width: 48.5%;
+}
diff --git a/sites/all/modules/contrib/ctools/css/stylizer.css b/sites/all/modules/contrib/ctools/css/stylizer.css
new file mode 100644
index 0000000..a16ec78
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/stylizer.css
@@ -0,0 +1,129 @@
+
+/* Farbtastic placement */
+.color-form {
+ max-width: 50em;
+ position: relative;
+ min-height: 195px;
+}
+#placeholder {
+/*
+ position: absolute;
+ top: 0;
+ right: 0;
+*/
+ margin: 0 auto;
+ width: 195px;
+}
+
+/* Palette */
+.color-form .form-item {
+ height: 2em;
+ line-height: 2em;
+ padding-left: 1em; /* LTR */
+ margin: 0.5em 0;
+}
+
+.color-form .form-item input {
+ margin-top: .2em;
+}
+
+.color-form label {
+ float: left; /* LTR */
+ clear: left; /* LTR */
+ width: 14em;
+}
+.color-form .form-text, .color-form .form-select {
+ float: left; /* LTR */
+}
+.color-form .form-text {
+ text-align: center;
+ margin-right: 5px; /* LTR */
+ cursor: pointer;
+}
+
+#palette .hook {
+ float: left; /* LTR */
+ margin-top: 3px;
+ width: 16px;
+ height: 16px;
+}
+#palette .up {
+ background-position: 100% -27px; /* LTR */
+}
+#palette .both {
+ background-position: 100% -54px; /* LTR */
+}
+
+
+#palette .form-item {
+ width: 24em;
+}
+#palette .item-selected {
+ background: #eee;
+}
+
+/* Preview */
+#preview {
+ width: 45%;
+ float: right;
+ margin: 0;
+}
+
+#ctools_stylizer_color_scheme_form {
+ float: left;
+ width: 45%;
+ margin: 0;
+}
+
+/* general style for the layout-icon */
+.ctools-style-icon .caption {
+ width: 100px;
+ margin-bottom: 1em;
+ line-height: 1em;
+ text-align: center;
+ cursor: default;
+}
+
+.ctools-style-icons .form-item {
+ width: 100px;
+ float: left;
+ margin: 0 3px !important;
+}
+
+.ctools-style-icons .form-item .ctools-style-icon {
+ float: none;
+ height: 150px;
+ width: 100px;
+}
+
+.ctools-style-icons .form-item label.option {
+ width: 100px;
+ display: block;
+ text-align: center;
+}
+
+.ctools-style-icons .form-item label.option input {
+ margin: 0 auto;
+}
+
+.ctools-style-icons .ctools-style-category {
+ height: 190px;
+}
+
+.ctools-style-icons .ctools-style-category label {
+ font-weight: bold;
+ width: 100%;
+ float: left;
+}
+
+/**
+ * Stylizer font editor widget
+ */
+.ctools-stylizer-spacing-form .form-item {
+ float: left;
+ margin: .25em;
+}
+
+#edit-font-font {
+ width: 9em;
+}
diff --git a/sites/all/modules/contrib/ctools/css/wizard.css b/sites/all/modules/contrib/ctools/css/wizard.css
new file mode 100644
index 0000000..d42a2db
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/css/wizard.css
@@ -0,0 +1,8 @@
+
+.wizard-trail {
+ font-size: 120%;
+}
+
+.wizard-trail-current {
+ font-weight: bold;
+}
diff --git a/sites/all/modules/contrib/ctools/ctools.api.php b/sites/all/modules/contrib/ctools/ctools.api.php
new file mode 100644
index 0000000..a7ab783
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools.api.php
@@ -0,0 +1,268 @@
+ TRUE,
+ );
+
+ return $plugins;
+}
+
+/**
+ * This hook is used to inform the CTools plugin system about the location of a
+ * directory that should be searched for files containing plugins of a
+ * particular type. CTools invokes this same hook for all plugins, using the
+ * two passed parameters to indicate the specific type of plugin for which it
+ * is searching.
+ *
+ * The $plugin_type parameter is self-explanatory - it is the string name of the
+ * plugin type (e.g., Panels' 'layouts' or 'styles'). The $owner parameter is
+ * necessary because CTools internally namespaces plugins by the module that
+ * owns them. This is an extension of Drupal best practices on avoiding global
+ * namespace pollution by prepending your module name to all its functions.
+ * Consequently, it is possible for two different modules to create a plugin
+ * type with exactly the same name and have them operate in harmony. In fact,
+ * this system renders it impossible for modules to encroach on other modules'
+ * plugin namespaces.
+ *
+ * Given this namespacing, it is important that implementations of this hook
+ * check BOTH the $owner and $plugin_type parameters before returning a path.
+ * If your module does not implement plugins for the requested module/plugin
+ * combination, it is safe to return nothing at all (or NULL). As a convenience,
+ * it is also safe to return a path that does not exist for plugins your module
+ * does not implement - see form 2 for a use case.
+ *
+ * Note that modules implementing a plugin also must implement this hook to
+ * instruct CTools as to the location of the plugins. See form 3 for a use case.
+ *
+ * The conventional structure to return is "plugins/$plugin_type" - that is, a
+ * 'plugins' subdirectory in your main module directory, with individual
+ * directories contained therein named for the plugin type they contain.
+ *
+ * @param string $owner
+ * The system name of the module owning the plugin type for which a base
+ * directory location is being requested.
+ * @param string $plugin_type
+ * The name of the plugin type for which a base directory is being requested.
+ * @return string
+ * The path where CTools' plugin system should search for plugin files,
+ * relative to your module's root. Omit leading and trailing slashes.
+ */
+function hook_ctools_plugin_directory($owner, $plugin_type) {
+ // Form 1 - for a module implementing only the 'content_types' plugin owned
+ // by CTools, this would cause the plugin system to search the
+ // /plugins/content_types directory for .inc plugin files.
+ if ($owner == 'ctools' && $plugin_type == 'content_types') {
+ return 'plugins/content_types';
+ }
+
+ // Form 2 - if your module implements only Panels plugins, and has 'layouts'
+ // and 'styles' plugins but no 'cache' or 'display_renderers', it is OK to be
+ // lazy and return a directory for a plugin you don't actually implement (so
+ // long as that directory doesn't exist). This lets you avoid ugly in_array()
+ // logic in your conditional, and also makes it easy to add plugins of those
+ // types later without having to change this hook implementation.
+ if ($owner == 'panels') {
+ return "plugins/$plugin_type";
+ }
+
+ // Form 3 - CTools makes no assumptions about where your plugins are located,
+ // so you still have to implement this hook even for plugins created by your
+ // own module.
+ if ($owner == 'mymodule') {
+ // Yes, this is exactly like Form 2 - just a different reasoning for it.
+ return "plugins/$plugin_type";
+ }
+ // Finally, if nothing matches, it's safe to return nothing at all (or NULL).
+}
+
+/**
+ * Alter a plugin before it has been processed.
+ *
+ * This hook is useful for altering flags or other information that will be
+ * used or possibly overriden by the process hook if defined.
+ *
+ * @param $plugin
+ * An associative array defining a plugin.
+ * @param $info
+ * An associative array of plugin type info.
+ */
+function hook_ctools_plugin_pre_alter(&$plugin, &$info) {
+ // Override a function defined by the plugin.
+ if ($info['type'] == 'my_type') {
+ $plugin['my_flag'] = 'new_value';
+ }
+}
+
+/**
+ * Alter a plugin after it has been processed.
+ *
+ * This hook is useful for overriding the final values for a plugin after it
+ * has been processed.
+ *
+ * @param $plugin
+ * An associative array defining a plugin.
+ * @param $info
+ * An associative array of plugin type info.
+ */
+function hook_ctools_plugin_post_alter(&$plugin, &$info) {
+ // Override a function defined by the plugin.
+ if ($info['type'] == 'my_type') {
+ $plugin['my_function'] = 'new_function';
+ }
+}
+
+/**
+ * Alter the list of modules/themes which implement a certain api.
+ *
+ * The hook named here is just an example, as the real existing hooks are named
+ * for example 'hook_views_api_alter'.
+ *
+ * @param array $list
+ * An array of informations about the implementors of a certain api.
+ * The key of this array are the module names/theme names.
+ */
+function hook_ctools_api_hook_alter(&$list) {
+ // Alter the path of the node implementation.
+ $list['node']['path'] = drupal_get_path('module', 'node');
+}
+
+/**
+ * Alter the available functions to be used in ctools math expression api.
+ *
+ * One usecase would be to create your own function in your module and
+ * allow to use it in the math expression api.
+ *
+ * @param $functions
+ * An array which has the functions as value.
+ */
+function hook_ctools_math_expression_functions_alter(&$functions) {
+ // Allow to convert from degrees to radiant.
+ $functions[] = 'deg2rad';
+}
+
+/**
+ * Alter everything.
+ *
+ * @param $info
+ * An associative array containing the following keys:
+ * - content: The rendered content.
+ * - title: The content's title.
+ * - no_blocks: A boolean to decide if blocks should be displayed.
+ * @param $page
+ * If TRUE then this renderer owns the page and can use theme('page')
+ * for no blocks; if false, output is returned regardless of any no
+ * blocks settings.
+ * @param $context
+ * An associative array containing the following keys:
+ * - args: The raw arguments behind the contexts.
+ * - contexts: The context objects in use.
+ * - task: The task object in use.
+ * - subtask: The subtask object in use.
+ * - handler: The handler object in use.
+ */
+function hook_ctools_render_alter(&$info, &$page, &$context) {
+ if ($context['handler']->name == 'my_handler') {
+ ctools_add_css('my_module.theme', 'my_module');
+ }
+}
+
+/**
+ * Alter a content plugin subtype.
+ *
+ * While content types can be altered via hook_ctools_plugin_pre_alter() or
+ * hook_ctools_plugin_post_alter(), the subtypes that content types rely on
+ * are special and require their own hook.
+ *
+ * This hook can be used to add things like 'render last' or change icons
+ * or categories or to rename content on specific sites.
+ */
+function hook_ctools_content_subtype_alter($subtype, $plugin) {
+ $subtype['render last'] = TRUE;
+}
+
+/**
+ * Alter the definition of an entity context plugin.
+ *
+ * @param array $plugin
+ * An associative array defining a plugin.
+ * @param array $entity
+ * The entity info array of a specific entity type.
+ * @param string $plugin_id
+ * The plugin ID, in the format NAME:KEY.
+ */
+function hook_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
+ ctools_include('context');
+ switch ($plugin_id) {
+ case 'entity_id:taxonomy_term':
+ $plugin['no ui'] = TRUE;
+ case 'entity:user':
+ $plugin = ctools_get_context('user');
+ unset($plugin['no ui']);
+ unset($plugin['no required context ui']);
+ break;
+ }
+}
+
+/**
+ * Alter the definition of entity context plugins.
+ *
+ * @param array $plugins
+ * An associative array of plugin definitions, keyed by plugin ID.
+ *
+ * @see hook_ctools_entity_context_alter()
+ */
+function hook_ctools_entity_contexts_alter(&$plugins) {
+ $plugins['entity_id:taxonomy_term']['no ui'] = TRUE;
+}
+
+/**
+ * Change cleanstring settings.
+ *
+ * @param array $settings
+ * An associative array of cleanstring settings.
+ *
+ * @see ctools_cleanstring()
+ */
+function hook_ctools_cleanstring_alter(&$settings) {
+ // Convert all strings to lower case.
+ $settings['lower case'] = TRUE;
+}
+
+/**
+ * Change cleanstring settings for a specific clean ID.
+ *
+ * @param array $settings
+ * An associative array of cleanstring settings.
+ *
+ * @see ctools_cleanstring()
+ */
+function hook_ctools_cleanstring_CLEAN_ID_alter(&$settings) {
+ // Convert all strings to lower case.
+ $settings['lower case'] = TRUE;
+}
+
+/**
+ * @} End of "addtogroup hooks".
+ */
diff --git a/sites/all/modules/contrib/ctools/ctools.info b/sites/all/modules/contrib/ctools/ctools.info
new file mode 100644
index 0000000..02c86f5
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools.info
@@ -0,0 +1,17 @@
+name = Chaos tools
+description = A library of helpful tools by Merlin of Chaos.
+core = 7.x
+package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
+files[] = includes/context.inc
+files[] = includes/css-cache.inc
+files[] = includes/math-expr.inc
+files[] = includes/stylizer.inc
+files[] = tests/css_cache.test
+
+; Information added by Drupal.org packaging script on 2015-08-19
+version = "7.x-1.9"
+core = "7.x"
+project = "ctools"
+datestamp = "1440020680"
+
diff --git a/sites/all/modules/contrib/ctools/ctools.install b/sites/all/modules/contrib/ctools/ctools.install
new file mode 100644
index 0000000..e96c743
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools.install
@@ -0,0 +1,265 @@
+ t('CTools CSS Cache'),
+ 'severity' => REQUIREMENT_OK,
+ 'value' => t('Exists'),
+ );
+
+ $path = 'public://ctools/css';
+ if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
+ $requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
+ $requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
+ $requirements['ctools_css_cache']['value'] = t('Unable to create');
+ }
+
+ if (!function_exists('error_get_last')) {
+ $requirements['ctools_php_52']['title'] = t('CTools PHP requirements');
+ $requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.');
+ $requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING;
+ $requirements['ctools_php_52']['value'] = t('PHP !version', array('!version' => phpversion()));
+ }
+ }
+
+ return $requirements;
+}
+
+/**
+ * Implements hook_schema().
+ */
+function ctools_schema() {
+ return ctools_schema_3();
+}
+
+/**
+ * Version 3 of the CTools schema.
+ */
+function ctools_schema_3() {
+ $schema = ctools_schema_2();
+
+ // update the 'obj' field to be 128 bytes long:
+ $schema['ctools_object_cache']['fields']['obj']['length'] = 128;
+
+ return $schema;
+}
+
+/**
+ * Version 2 of the CTools schema.
+ */
+function ctools_schema_2() {
+ $schema = ctools_schema_1();
+
+ // update the 'name' field to be 128 bytes long:
+ $schema['ctools_object_cache']['fields']['name']['length'] = 128;
+
+ // Update the 'data' field to be type 'blob'.
+ $schema['ctools_object_cache']['fields']['data'] = array(
+ 'type' => 'blob',
+ 'size' => 'big',
+ 'description' => 'Serialized data being stored.',
+ 'serialize' => TRUE,
+ );
+
+ // DO NOT MODIFY THIS TABLE -- this definition is used to create the table.
+ // Changes to this table must be made in schema_3 or higher.
+ $schema['ctools_css_cache'] = array(
+ 'description' => 'A special cache used to store CSS that must be non-volatile.',
+ 'fields' => array(
+ 'cid' => array(
+ 'type' => 'varchar',
+ 'length' => '128',
+ 'description' => 'The CSS ID this cache object belongs to.',
+ 'not null' => TRUE,
+ ),
+ 'filename' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'description' => 'The filename this CSS is stored in.',
+ ),
+ 'css' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'CSS being stored.',
+ 'serialize' => TRUE,
+ ),
+ 'filter' => array(
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'description' => 'Whether or not this CSS needs to be filtered.',
+ ),
+ ),
+ 'primary key' => array('cid'),
+ );
+
+ return $schema;
+}
+
+/**
+ * CTools' initial schema; separated for the purposes of updates.
+ *
+ * DO NOT MAKE CHANGES HERE. This schema version is locked.
+ */
+function ctools_schema_1() {
+ $schema['ctools_object_cache'] = array(
+ 'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'),
+ 'fields' => array(
+ 'sid' => array(
+ 'type' => 'varchar',
+ 'length' => '64',
+ 'not null' => TRUE,
+ 'description' => 'The session ID this cache object belongs to.',
+ ),
+ 'name' => array(
+ 'type' => 'varchar',
+ 'length' => '32',
+ 'not null' => TRUE,
+ 'description' => 'The name of the object this cache is attached to.',
+ ),
+ 'obj' => array(
+ 'type' => 'varchar',
+ 'length' => '32',
+ 'not null' => TRUE,
+ 'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
+ ),
+ 'updated' => array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'The time this cache was created or updated.',
+ ),
+ 'data' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Serialized data being stored.',
+ 'serialize' => TRUE,
+ ),
+ ),
+ 'primary key' => array('sid', 'obj', 'name'),
+ 'indexes' => array('updated' => array('updated')),
+ );
+ return $schema;
+}
+
+/**
+ * Implements hook_install().
+ */
+function ctools_install() {
+ // Activate our custom cache handler for the CSS cache.
+ variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function ctools_uninstall() {
+ variable_del('cache_class_cache_ctools_css');
+}
+
+/**
+ * Enlarge the ctools_object_cache.name column to prevent truncation and weird
+ * errors.
+ */
+function ctools_update_6001() {
+ // Perform updates like this to reduce code duplication.
+ $schema = ctools_schema_2();
+
+ db_change_field('ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']);
+}
+
+/**
+ * Add the new css cache table.
+ */
+function ctools_update_6002() {
+ // Schema 2 is locked and should not be changed.
+ $schema = ctools_schema_2();
+
+ db_create_table('ctools_css_cache', $schema['ctools_css_cache']);
+}
+
+/**
+ * Take over for the panels_views module if it was on.
+ */
+function ctools_update_6003() {
+ $result = db_query('SELECT status FROM {system} WHERE name = :name', array(':name' => 'panels_views'))->fetchField();
+ if ($result) {
+ db_delete('system')->condition('name', 'panels_views')->execute();
+ module_enable(array('views_content'), TRUE);
+ }
+}
+
+/**
+ * Add primary key to the ctools_object_cache table.
+ */
+function ctools_update_6004() {
+ db_add_primary_key('ctools_object_cache', array('sid', 'obj', 'name'));
+ db_drop_index('ctools_object_cache', 'sid_obj_name');
+}
+
+/**
+ * Removed update.
+ */
+function ctools_update_6005() {
+ return array();
+}
+
+/**
+ * ctools_custom_content table was originally here, but is now moved to
+ * its own module.
+ */
+function ctools_update_6007() {
+ $ret = array();
+ if (db_table_exists('ctools_custom_content')) {
+ // Enable the module to make everything as seamless as possible.
+ module_enable(array('ctools_custom_content'), TRUE);
+ }
+
+ return $ret;
+}
+
+/**
+ * ctools_object_cache needs to be defined as a blob.
+ */
+function ctools_update_6008() {
+ db_delete('ctools_object_cache')
+ ->execute();
+
+ db_change_field('ctools_object_cache', 'data', 'data', array(
+ 'type' => 'blob',
+ 'size' => 'big',
+ 'description' => 'Serialized data being stored.',
+ 'serialize' => TRUE,
+ )
+ );
+}
+
+/**
+ * Enable the custom CSS cache handler.
+ */
+function ctools_update_7000() {
+ variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
+}
+
+/**
+ * Increase the length of the ctools_object_cache.obj column.
+ */
+function ctools_update_7001() {
+ db_change_field('ctools_object_cache', 'obj', 'obj', array(
+ 'type' => 'varchar',
+ 'length' => '128',
+ 'not null' => TRUE,
+ 'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
+ ));
+}
diff --git a/sites/all/modules/contrib/ctools/ctools.module b/sites/all/modules/contrib/ctools/ctools.module
new file mode 100644
index 0000000..008214e
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools.module
@@ -0,0 +1,1088 @@
+ 7.x-1.x.
+ *
+ * To define a specific version of CTools as a dependency for another module,
+ * simply include a dependency line in that module's info file, e.g.:
+ * ; Requires CTools v7.x-1.4 or newer.
+ * dependencies[] = ctools (>=1.4)
+ */
+define('CTOOLS_MODULE_VERSION', '7.x-1.9');
+
+/**
+ * Test the CTools API version.
+ *
+ * This function can always be used to safely test if CTools has the minimum
+ * API version that your module can use. It can also try to protect you from
+ * running if the CTools API version is too new, but if you do that you need
+ * to be very quick about watching CTools API releases and release new versions
+ * of your software as soon as the new release is made, or people might end up
+ * updating CTools and having your module shut down without any recourse.
+ *
+ * It is recommended that every hook of your module that might use CTools or
+ * might lead to a use of CTools be guarded like this:
+ *
+ * @code
+ * if (!module_invoke('ctools', 'api_version', '1.0')) {
+ * return;
+ * }
+ * @endcode
+ *
+ * Note that some hooks such as _menu() or _theme() must return an array().
+ *
+ * You can use it in your hook_requirements to report this error condition
+ * like this:
+ *
+ * @code
+ * define('MODULENAME_MINIMUM_CTOOLS_API_VERSION', '1.0');
+ * define('MODULENAME_MAXIMUM_CTOOLS_API_VERSION', '1.1');
+ *
+ * function MODULENAME_requirements($phase) {
+ * $requirements = array();
+ * if (!module_invoke('ctools', 'api_version', MODULENAME_MINIMUM_CTOOLS_API_VERSION, MODULENAME_MAXIMUM_CTOOLS_API_VERSION)) {
+ * $requirements['MODULENAME_ctools'] = array(
+ * 'title' => $t('MODULENAME required Chaos Tool Suite (CTools) API Version'),
+ * 'value' => t('Between @a and @b', array('@a' => MODULENAME_MINIMUM_CTOOLS_API_VERSION, '@b' => MODULENAME_MAXIMUM_CTOOLS_API_VERSION)),
+ * 'severity' => REQUIREMENT_ERROR,
+ * );
+ * }
+ * return $requirements;
+ * }
+ * @endcode
+ *
+ * Please note that the version is a string, not an floating point number.
+ * This will matter once CTools reaches version 1.10.
+ *
+ * A CTools API changes history will be kept in API.txt. Not every new
+ * version of CTools will necessarily update the API version.
+ * @param $minimum
+ * The minimum version of CTools necessary for your software to run with it.
+ * @param $maximum
+ * The maximum version of CTools allowed for your software to run with it.
+ */
+function ctools_api_version($minimum, $maximum = NULL) {
+ if (version_compare(CTOOLS_API_VERSION, $minimum, '<')) {
+ return FALSE;
+ }
+
+ if (isset($maximum) && version_compare(CTOOLS_API_VERSION, $maximum, '>')) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+// General utility functions
+
+/**
+ * Include .inc files as necessary.
+ *
+ * This fuction is helpful for including .inc files for your module. The
+ * general case is including ctools funcitonality like this:
+ *
+ * @code
+ * ctools_include('plugins');
+ * @endcode
+ *
+ * Similar funcitonality can be used for other modules by providing the $module
+ * and $dir arguments like this:
+ *
+ * @code
+ * // include mymodule/includes/import.inc
+ * ctools_include('import', 'mymodule');
+ * // include mymodule/plugins/foobar.inc
+ * ctools_include('foobar', 'mymodule', 'plugins');
+ * @endcode
+ *
+ * @param $file
+ * The base file name to be included.
+ * @param $module
+ * Optional module containing the include.
+ * @param $dir
+ * Optional subdirectory containing the include file.
+ */
+function ctools_include($file, $module = 'ctools', $dir = 'includes') {
+ static $used = array();
+
+ $dir = '/' . ($dir ? $dir . '/' : '');
+
+ if (!isset($used[$module][$dir][$file])) {
+ require_once DRUPAL_ROOT . '/' . drupal_get_path('module', $module) . "$dir$file.inc";
+ $used[$module][$dir][$file] = TRUE;
+ }
+}
+
+/**
+ * Include .inc files in a form context.
+ *
+ * This is a variant of ctools_include that will save information in the
+ * the form_state so that cached forms will properly include things.
+ */
+function ctools_form_include(&$form_state, $file, $module = 'ctools', $dir = 'includes') {
+ if (!isset($form_state['build_info']['args'])) {
+ $form_state['build_info']['args'] = array();
+ }
+
+ $dir = '/' . ($dir ? $dir . '/' : '');
+ form_load_include($form_state, 'inc', $module, $dir . $file);
+}
+
+/**
+ * Add an arbitrary path to the $form_state so it can work with form cache.
+ *
+ * module_load_include uses an unfortunately annoying syntax to work, making it
+ * difficult to translate the more simple $path + $file syntax.
+ */
+function ctools_form_include_file(&$form_state, $filename) {
+ if (!isset($form_state['build_info']['args'])) {
+ $form_state['build_info']['args'] = array();
+ }
+
+ // Now add this to the build info files so that AJAX requests will know to load it.
+ $form_state['build_info']['files']["$filename"] = $filename;
+ require_once DRUPAL_ROOT . '/' . $filename;
+}
+
+/**
+ * Provide the proper path to an image as necessary.
+ *
+ * This helper function is used by ctools but can also be used in other
+ * modules in the same way as explained in the comments of ctools_include.
+ *
+ * @param $image
+ * The base file name (with extension) of the image to be included.
+ * @param $module
+ * Optional module containing the include.
+ * @param $dir
+ * Optional subdirectory containing the include file.
+ */
+function ctools_image_path($image, $module = 'ctools', $dir = 'images') {
+ return drupal_get_path('module', $module) . "/$dir/" . $image;
+}
+
+/**
+ * Include css files as necessary.
+ *
+ * This helper function is used by ctools but can also be used in other
+ * modules in the same way as explained in the comments of ctools_include.
+ *
+ * @param $file
+ * The base file name to be included.
+ * @param $module
+ * Optional module containing the include.
+ * @param $dir
+ * Optional subdirectory containing the include file.
+ */
+function ctools_add_css($file, $module = 'ctools', $dir = 'css') {
+ drupal_add_css(drupal_get_path('module', $module) . "/$dir/$file.css");
+}
+
+/**
+ * Format a css file name for use with $form['#attached']['css'].
+ *
+ * This helper function is used by ctools but can also be used in other
+ * modules in the same way as explained in the comments of ctools_include.
+ *
+ * @code
+ * $form['#attached']['css'] = array(ctools_attach_css('collapsible-div'));
+ * $form['#attached']['css'][ctools_attach_css('collapsible-div')] = array('preprocess' => FALSE);
+ * @endcode
+ *
+ * @param $file
+ * The base file name to be included.
+ * @param $module
+ * Optional module containing the include.
+ * @param $dir
+ * Optional subdirectory containing the include file.
+ */
+function ctools_attach_css($file, $module = 'ctools', $dir = 'css') {
+ return drupal_get_path('module', $module) . "/$dir/$file.css";
+}
+
+/**
+ * Include js files as necessary.
+ *
+ * This helper function is used by ctools but can also be used in other
+ * modules in the same way as explained in the comments of ctools_include.
+ *
+ * @param $file
+ * The base file name to be included.
+ * @param $module
+ * Optional module containing the include.
+ * @param $dir
+ * Optional subdirectory containing the include file.
+ */
+function ctools_add_js($file, $module = 'ctools', $dir = 'js') {
+ drupal_add_js(drupal_get_path('module', $module) . "/$dir/$file.js");
+}
+
+/**
+ * Format a javascript file name for use with $form['#attached']['js'].
+ *
+ * This helper function is used by ctools but can also be used in other
+ * modules in the same way as explained in the comments of ctools_include.
+ *
+ * @code
+ * $form['#attached']['js'] = array(ctools_attach_js('auto-submit'));
+ * @endcode
+ *
+ * @param $file
+ * The base file name to be included.
+ * @param $module
+ * Optional module containing the include.
+ * @param $dir
+ * Optional subdirectory containing the include file.
+ */
+function ctools_attach_js($file, $module = 'ctools', $dir = 'js') {
+ return drupal_get_path('module', $module) . "/$dir/$file.js";
+}
+
+/**
+ * Get a list of roles in the system.
+ *
+ * @return
+ * An array of role names keyed by role ID.
+ *
+ * @deprecated
+ * user_roles() should be used instead.
+ */
+function ctools_get_roles() {
+ return user_roles();
+}
+
+/*
+ * Break x,y,z and x+y+z into an array. Numeric only.
+ *
+ * @param $str
+ * The string to parse.
+ *
+ * @return $object
+ * An object containing
+ * - operator: Either 'and' or 'or'
+ * - value: An array of numeric values.
+ */
+function ctools_break_phrase($str) {
+ $object = new stdClass();
+
+ if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str)) {
+ // The '+' character in a query string may be parsed as ' '.
+ $object->operator = 'or';
+ $object->value = preg_split('/[+ ]/', $str);
+ }
+ else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) {
+ $object->operator = 'and';
+ $object->value = explode(',', $str);
+ }
+
+ // Keep an 'error' value if invalid strings were given.
+ if (!empty($str) && (empty($object->value) || !is_array($object->value))) {
+ $object->value = array(-1);
+ $object->invalid_input = TRUE;
+ return $object;
+ }
+
+ if (empty($object->value)) {
+ $object->value = array();
+ }
+
+ // Doubly ensure that all values are numeric only.
+ foreach ($object->value as $id => $value) {
+ $object->value[$id] = intval($value);
+ }
+
+ return $object;
+}
+
+/**
+ * Set a token/value pair to be replaced later in the request, specifically in
+ * ctools_page_token_processing().
+ *
+ * @param $token
+ * The token to be replaced later, during page rendering. This should
+ * ideally be a string inside of an HTML comment, so that if there is
+ * no replacement, the token will not render on the page.
+ * @param $type
+ * The type of the token. Can be either 'variable', which will pull data
+ * directly from the page variables
+ * @param $argument
+ * If $type == 'variable' then argument should be the key to fetch from
+ * the $variables. If $type == 'callback' then it should either be the
+ * callback, or an array that will be sent to call_user_func_array().
+ *
+ * @return
+ * A array of token/variable names to be replaced.
+ */
+function ctools_set_page_token($token = NULL, $type = NULL, $argument = NULL) {
+ static $tokens = array();
+
+ if (isset($token)) {
+ $tokens[$token] = array($type, $argument);
+ }
+ return $tokens;
+}
+
+/**
+ * Easily set a token from the page variables.
+ *
+ * This function can be used like this:
+ * $token = ctools_set_variable_token('tabs');
+ *
+ * $token will then be a simple replacement for the 'tabs' about of the
+ * variables available in the page template.
+ */
+function ctools_set_variable_token($token) {
+ $string = '';
+ ctools_set_page_token($string, 'variable', $token);
+ return $string;
+}
+
+/**
+ * Easily set a token from the page variables.
+ *
+ * This function can be used like this:
+ * $token = ctools_set_variable_token('id', 'mymodule_myfunction');
+ */
+function ctools_set_callback_token($token, $callback) {
+ // If the callback uses arguments they are considered in the token.
+ if (is_array($callback)) {
+ $token .= '-' . md5(serialize($callback));
+ }
+ $string = '';
+ ctools_set_page_token($string, 'callback', $callback);
+ return $string;
+}
+
+/**
+ * Tell CTools that sidebar blocks should not be rendered.
+ *
+ * It is often desirable to not display sidebars when rendering a page,
+ * particularly when using Panels. This informs CTools to alter out any
+ * sidebar regions during block render.
+ */
+function ctools_set_no_blocks($blocks = FALSE) {
+ $status = &drupal_static(__FUNCTION__, TRUE);
+ $status = $blocks;
+}
+
+/**
+ * Wrapper function to create UUIDs via ctools, falls back on UUID module
+ * if it is enabled. This code is a copy of uuid.inc from the uuid module.
+ * @see http://php.net/uniqid#65879
+ */
+
+function ctools_uuid_generate() {
+ if (!module_exists('uuid')) {
+ ctools_include('uuid');
+
+ $callback = drupal_static(__FUNCTION__);
+
+ if (empty($callback)) {
+ if (function_exists('uuid_create') && !function_exists('uuid_make')) {
+ $callback = '_ctools_uuid_generate_pecl';
+ }
+ elseif (function_exists('com_create_guid')) {
+ $callback = '_ctools_uuid_generate_com';
+ }
+ else {
+ $callback = '_ctools_uuid_generate_php';
+ }
+ }
+ return $callback();
+ }
+ else {
+ return uuid_generate();
+ }
+}
+
+/**
+ * Check that a string appears to be in the format of a UUID.
+ * @see http://drupal.org/project/uuid
+ *
+ * @param $uuid
+ * The string to test.
+ *
+ * @return
+ * TRUE if the string is well formed.
+ */
+function ctools_uuid_is_valid($uuid = '') {
+ if (empty($uuid)) {
+ return FALSE;
+ }
+ if (function_exists('uuid_is_valid') || module_exists('uuid')) {
+ return uuid_is_valid($uuid);
+ }
+ else {
+ ctools_include('uuid');
+ return uuid_is_valid($uuid);
+ }
+}
+
+/**
+ * Add an array of classes to the body.
+ *
+ * @param mixed $classes
+ * A string or an array of class strings to add.
+ * @param string $hook
+ * The theme hook to add the class to. The default is 'html' which will
+ * affect the body tag.
+ */
+function ctools_class_add($classes, $hook = 'html') {
+ if (!is_array($classes)) {
+ $classes = array($classes);
+ }
+
+ $static = &drupal_static('ctools_process_classes', array());
+ if (!isset($static[$hook]['add'])) {
+ $static[$hook]['add'] = array();
+ }
+ foreach ($classes as $class) {
+ $static[$hook]['add'][] = $class;
+ }
+}
+
+/**
+ * Remove an array of classes from the body.
+ *
+ * @param mixed $classes
+ * A string or an array of class strings to remove.
+ * @param string $hook
+ * The theme hook to remove the class from. The default is 'html' which will
+ * affect the body tag.
+ */
+function ctools_class_remove($classes, $hook = 'html') {
+ if (!is_array($classes)) {
+ $classes = array($classes);
+ }
+
+ $static = &drupal_static('ctools_process_classes', array());
+ if (!isset($static[$hook]['remove'])) {
+ $static[$hook]['remove'] = array();
+ }
+ foreach ($classes as $class) {
+ $static[$hook]['remove'][] = $class;
+ }
+}
+
+// -----------------------------------------------------------------------
+// Drupal core hooks
+
+/**
+ * Implement hook_init to keep our global CSS at the ready.
+ */
+function ctools_init() {
+ ctools_add_css('ctools');
+ // If we are sure that CTools' AJAX is in use, change the error handling.
+ if (!empty($_REQUEST['ctools_ajax'])) {
+ ini_set('display_errors', 0);
+ register_shutdown_function('ctools_shutdown_handler');
+ }
+
+ // Clear plugin cache on the module page submit.
+ if ($_GET['q'] == 'admin/modules/list/confirm' && !empty($_POST)) {
+ cache_clear_all('ctools_plugin_files:', 'cache', TRUE);
+ }
+}
+
+/**
+ * Shutdown handler used during ajax operations to help catch fatal errors.
+ */
+function ctools_shutdown_handler() {
+ if (function_exists('error_get_last') AND ($error = error_get_last())) {
+ switch ($error['type']) {
+ case E_ERROR:
+ case E_CORE_ERROR:
+ case E_COMPILE_ERROR:
+ case E_USER_ERROR:
+ // Do this manually because including files here is dangerous.
+ $commands = array(
+ array(
+ 'command' => 'alert',
+ 'title' => t('Error'),
+ 'text' => t('Unable to complete operation. Fatal error in @file on line @line: @message', array(
+ '@file' => $error['file'],
+ '@line' => $error['line'],
+ '@message' => $error['message'],
+ )),
+ ),
+ );
+
+ // Change the status code so that the client will read the AJAX returned.
+ header('HTTP/1.1 200 OK');
+ drupal_json($commands);
+ }
+ }
+}
+
+/**
+ * Implements hook_theme().
+ */
+function ctools_theme() {
+ ctools_include('utility');
+ $items = array();
+ ctools_passthrough('ctools', 'theme', $items);
+ return $items;
+}
+
+/**
+ * Implements hook_menu().
+ */
+function ctools_menu() {
+ ctools_include('utility');
+ $items = array();
+ ctools_passthrough('ctools', 'menu', $items);
+ return $items;
+}
+
+/**
+ * Implements hook_permission().
+ */
+function ctools_permission() {
+ return array(
+ 'use ctools import' => array(
+ 'title' => t('Use CTools importer'),
+ 'description' => t('The import functionality allows users to execute arbitrary PHP code, so extreme caution must be taken.'),
+ 'restrict access' => TRUE,
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_cron. Clean up old caches.
+ */
+function ctools_cron() {
+ ctools_include('utility');
+ $items = array();
+ ctools_passthrough('ctools', 'cron', $items);
+}
+
+/**
+ * Implements hook_flush_caches().
+ */
+function ctools_flush_caches() {
+ // Only return the CSS cache bin if it has been activated, to avoid
+ // drupal_flush_all_caches() from trying to truncate a non-existing table.
+ return variable_get('cache_class_cache_ctools_css', FALSE) ? array('cache_ctools_css') : array();
+}
+
+/**
+ * Implements hook_element_info_alter().
+ *
+ */
+function ctools_element_info_alter(&$type) {
+ ctools_include('dependent');
+ ctools_dependent_element_info_alter($type);
+}
+
+/**
+ * Implementation of hook_file_download()
+ *
+ * When using the private file system, we have to let Drupal know it's ok to
+ * download CSS and image files from our temporary directory.
+ */
+function ctools_file_download($filepath) {
+ if (strpos($filepath, 'ctools') === 0) {
+ $mime = file_get_mimetype($filepath);
+ // For safety's sake, we allow only text and images.
+ if (strpos($mime, 'text') === 0 || strpos($mime, 'image') === 0) {
+ return array('Content-type:' . $mime);
+ }
+ }
+}
+
+/**
+ * Implements hook_registry_files_alter().
+ *
+ * Alter the registry of files to automagically include all classes in
+ * class-based plugins.
+ */
+function ctools_registry_files_alter(&$files, $indexed_modules) {
+ ctools_include('registry');
+ return _ctools_registry_files_alter($files, $indexed_modules);
+}
+
+// -----------------------------------------------------------------------
+// FAPI hooks that must be in the .module file.
+
+/**
+ * Alter the comment form to get a little more control over it.
+ */
+function ctools_form_comment_form_alter(&$form, &$form_state) {
+ if (!empty($form_state['ctools comment alter'])) {
+ // Force the form to post back to wherever we are.
+ $form['#action'] = url($_GET['q'], array('fragment' => 'comment-form'));
+ if (empty($form['#submit'])) {
+ $form['#submit'] = array('comment_form_submit');
+ }
+ $form['#submit'][] = 'ctools_node_comment_form_submit';
+ }
+}
+
+function ctools_node_comment_form_submit(&$form, &$form_state) {
+ $form_state['redirect'][0] = $_GET['q'];
+}
+
+// -----------------------------------------------------------------------
+// CTools hook implementations.
+
+/**
+ * Implementation of hook_ctools_plugin_directory() to let the system know
+ * where all our own plugins are.
+ */
+function ctools_ctools_plugin_directory($owner, $plugin_type) {
+ if ($owner == 'ctools') {
+ return 'plugins/' . $plugin_type;
+ }
+}
+
+/**
+ * Implements hook_ctools_plugin_type().
+ */
+function ctools_ctools_plugin_type() {
+ ctools_include('utility');
+ $items = array();
+ // Add all the plugins that have their own declaration space elsewhere.
+ ctools_passthrough('ctools', 'plugin-type', $items);
+
+ return $items;
+}
+
+// -----------------------------------------------------------------------
+// Drupal theme preprocess hooks that must be in the .module file.
+
+/**
+ * A theme preprocess function to automatically allow panels-based node
+ * templates based upon input when the panel was configured.
+ */
+function ctools_preprocess_node(&$vars) {
+ // The 'ctools_template_identifier' attribute of the node is added when the pane is
+ // rendered.
+ if (!empty($vars['node']->ctools_template_identifier)) {
+ $vars['ctools_template_identifier'] = check_plain($vars['node']->ctools_template_identifier);
+ $vars['theme_hook_suggestions'][] = 'node__panel__' . check_plain($vars['node']->ctools_template_identifier);
+ }
+}
+
+
+/**
+ * Implements hook_page_alter().
+ *
+ * Last ditch attempt to remove sidebar regions if the "no blocks"
+ * functionality has been activated.
+ *
+ * @see ctools_block_list_alter().
+ */
+function ctools_page_alter(&$page) {
+ $check = drupal_static('ctools_set_no_blocks', TRUE);
+ if (!$check) {
+ foreach ($page as $region_id => $region) {
+ // @todo -- possibly we can set configuration for this so that users can
+ // specify which blocks will not get rendered.
+ if (strpos($region_id, 'sidebar') !== FALSE) {
+ unset($page[$region_id]);
+ }
+ }
+ }
+ $page['#post_render'][] = 'ctools_page_token_processing';
+}
+
+/**
+ * A theme post_render callback to allow content type plugins to use page
+ * template variables which are not yet available when the content type is
+ * rendered.
+ */
+function ctools_page_token_processing($children, $elements) {
+ $tokens = ctools_set_page_token();
+ if (!empty($tokens)) {
+ foreach ($tokens as $token => $key) {
+ list($type, $argument) = $key;
+ switch ($type) {
+ case 'variable':
+ $tokens[$token] = isset($elements[$argument]) ? $elements[$argument] : '';
+ break;
+ case 'callback':
+ if (is_string($argument) && function_exists($argument)) {
+ $tokens[$token] = $argument($elements);
+ }
+ if (is_array($argument) && function_exists($argument[0])) {
+ $function = array_shift($argument);
+ $argument = array_merge(array(&$elements), $argument);
+ $tokens[$token] = call_user_func_array($function, $argument);
+ }
+ break;
+ }
+ }
+ $children = strtr($children, $tokens);
+ }
+ return $children;
+}
+
+/**
+ * Implements hook_process().
+ *
+ * Add and remove CSS classes from the variables array. We use process so that
+ * we alter anything added in the preprocess hooks.
+ */
+function ctools_process(&$variables, $hook) {
+ if (!isset($variables['classes'])) {
+ return;
+ }
+
+ $classes = drupal_static('ctools_process_classes', array());
+
+ // Process the classses to add.
+ if (!empty($classes[$hook]['add'])) {
+ $add_classes = array_map('drupal_clean_css_identifier', $classes[$hook]['add']);
+ $variables['classes_array'] = array_unique(array_merge($variables['classes_array'], $add_classes));
+ }
+
+ // Process the classes to remove.
+ if (!empty($classes[$hook]['remove'])) {
+ $remove_classes = array_map('drupal_clean_css_identifier', $classes[$hook]['remove']);
+ $variables['classes_array'] = array_diff($variables['classes_array'], $remove_classes);
+ }
+
+ // Since this runs after template_process(), we need to re-implode the
+ // classes array.
+ $variables['classes'] = implode(' ', $variables['classes_array']);
+}
+
+// -----------------------------------------------------------------------
+// Menu callbacks that must be in the .module file.
+
+/**
+ * Determine if the current user has access via a plugin.
+ *
+ * This function is meant to be embedded in the Drupal menu system, and
+ * therefore is in the .module file since sub files can't be loaded, and
+ * takes arguments a little bit more haphazardly than ctools_access().
+ *
+ * @param $access
+ * An access control array which contains the following information:
+ * - 'logic': and or or. Whether all tests must pass or one must pass.
+ * - 'plugins': An array of access plugins. Each contains:
+ * - - 'name': The name of the plugin
+ * - - 'settings': The settings from the plugin UI.
+ * - - 'context': Which context to use.
+ * @param ...
+ * zero or more context arguments generated from argument plugins. These
+ * contexts must have an 'id' attached to them so that they can be
+ * properly associated. The argument plugin system should set this, but
+ * if the context is coming from elsewhere it will need to be set manually.
+ *
+ * @return
+ * TRUE if access is granted, false if otherwise.
+ */
+function ctools_access_menu($access) {
+ // Short circuit everything if there are no access tests.
+ if (empty($access['plugins'])) {
+ return TRUE;
+ }
+
+ $contexts = array();
+ foreach (func_get_args() as $arg) {
+ if (is_object($arg) && get_class($arg) == 'ctools_context') {
+ $contexts[$arg->id] = $arg;
+ }
+ }
+
+ ctools_include('context');
+ return ctools_access($access, $contexts);
+}
+
+/**
+ * Determine if the current user has access via checks to multiple different
+ * permissions.
+ *
+ * This function is a thin wrapper around user_access that allows multiple
+ * permissions to be easily designated for use on, for example, a menu callback.
+ *
+ * @param ...
+ * An indexed array of zero or more permission strings to be checked by
+ * user_access().
+ *
+ * @return
+ * Iff all checks pass will this function return TRUE. If an invalid argument
+ * is passed (e.g., not a string), this function errs on the safe said and
+ * returns FALSE.
+ */
+function ctools_access_multiperm() {
+ foreach (func_get_args() as $arg) {
+ if (!is_string($arg) || !user_access($arg)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/**
+ * Check to see if the incoming menu item is js capable or not.
+ *
+ * This can be used as %ctools_js as part of a path in hook menu. CTools
+ * ajax functions will automatically change the phrase 'nojs' to 'ajax'
+ * when it attaches ajax to a link. This can be used to autodetect if
+ * that happened.
+ */
+function ctools_js_load($js) {
+ if ($js == 'ajax') {
+ return TRUE;
+ }
+ return 0;
+}
+
+/**
+ * Provides the default value for %ctools_js.
+ *
+ * This allows drupal_valid_path() to work with %ctools_js.
+ */
+function ctools_js_to_arg($arg) {
+ return empty($arg) || $arg == '%' ? 'nojs' : $arg;
+}
+
+/**
+ * Menu _load hook.
+ *
+ * This function will be called to load an object as a replacement for
+ * %ctools_export_ui in menu paths.
+ */
+function ctools_export_ui_load($item_name, $plugin_name) {
+ $return = &drupal_static(__FUNCTION__, FALSE);
+
+ if (!$return) {
+ ctools_include('export-ui');
+ $plugin = ctools_get_export_ui($plugin_name);
+ $handler = ctools_export_ui_get_handler($plugin);
+
+ if ($handler) {
+ return $handler->load_item($item_name);
+ }
+ }
+
+ return $return;
+}
+
+// -----------------------------------------------------------------------
+// Caching callbacks on behalf of export-ui.
+
+/**
+ * Menu access callback for various tasks of export-ui.
+ */
+function ctools_export_ui_task_access($plugin_name, $op, $item = NULL) {
+ ctools_include('export-ui');
+ $plugin = ctools_get_export_ui($plugin_name);
+ $handler = ctools_export_ui_get_handler($plugin);
+
+ if ($handler) {
+ return $handler->access($op, $item);
+ }
+
+ // Deny access if the handler cannot be found.
+ return FALSE;
+}
+
+/**
+ * Callback for access control ajax form on behalf of export ui.
+ *
+ * Returns the cached access config and contexts used.
+ * Note that this is assuming that access will be in $item->access -- if it
+ * is not, an export UI plugin will have to make its own callbacks.
+ */
+function ctools_export_ui_ctools_access_get($argument) {
+ ctools_include('export-ui');
+ list($plugin_name, $key) = explode(':', $argument, 2);
+
+ $plugin = ctools_get_export_ui($plugin_name);
+ $handler = ctools_export_ui_get_handler($plugin);
+
+ if ($handler) {
+ ctools_include('context');
+ $item = $handler->edit_cache_get($key);
+ if (!$item) {
+ $item = ctools_export_crud_load($handler->plugin['schema'], $key);
+ }
+
+ $contexts = ctools_context_load_contexts($item);
+ return array($item->access, $contexts);
+ }
+}
+
+/**
+ * Callback for access control ajax form on behalf of export ui
+ *
+ * Returns the cached access config and contexts used.
+ * Note that this is assuming that access will be in $item->access -- if it
+ * is not, an export UI plugin will have to make its own callbacks.
+ */
+function ctools_export_ui_ctools_access_set($argument, $access) {
+ ctools_include('export-ui');
+ list($plugin_name, $key) = explode(':', $argument, 2);
+
+ $plugin = ctools_get_export_ui($plugin_name);
+ $handler = ctools_export_ui_get_handler($plugin);
+
+ if ($handler) {
+ ctools_include('context');
+ $item = $handler->edit_cache_get($key);
+ if (!$item) {
+ $item = ctools_export_crud_load($handler->plugin['schema'], $key);
+ }
+ $item->access = $access;
+ return $handler->edit_cache_set_key($item, $key);
+ }
+}
+
+/**
+ * Implements hook_menu_local_tasks_alter().
+ */
+function ctools_menu_local_tasks_alter(&$data, $router_item, $root_path) {
+ ctools_include('menu');
+ _ctools_menu_add_dynamic_items($data, $router_item, $root_path);
+}
+
+/**
+ * Implement hook_block_list_alter() to potentially remove blocks.
+ *
+ * This exists in order to replicate Drupal 6's "no blocks" functionality.
+ */
+function ctools_block_list_alter(&$blocks) {
+ $check = drupal_static('ctools_set_no_blocks', TRUE);
+ if (!$check) {
+ foreach ($blocks as $block_id => $block) {
+ // @todo -- possibly we can set configuration for this so that users can
+ // specify which blocks will not get rendered.
+ if (strpos($block->region, 'sidebar') !== FALSE) {
+ unset($blocks[$block_id]);
+ }
+ }
+ }
+}
+
+/**
+ * Implements hook_modules_enabled().
+ *
+ * Clear caches for detecting new plugins.
+ */
+function ctools_modules_enabled($modules) {
+ ctools_include('plugins');
+ ctools_get_plugins_reset();
+ cache_clear_all('ctools_plugin_files:', 'cache', TRUE);
+}
+
+/**
+ * Implements hook_modules_disabled().
+ *
+ * Clear caches for removing disabled plugins.
+ */
+function ctools_modules_disabled($modules) {
+ ctools_include('plugins');
+ ctools_get_plugins_reset();
+ cache_clear_all('ctools_plugin_files:', 'cache', TRUE);
+}
+
+/**
+ * Menu theme callback.
+ *
+ * This simply ensures that Panels ajax calls are rendered in the same
+ * theme as the original page to prevent .css file confusion.
+ *
+ * To use this, set this as the theme callback on AJAX related menu
+ * items. Since the ajax page state won't be sent during ajax requests,
+ * it should be safe to use even if ajax isn't invoked.
+ */
+function ctools_ajax_theme_callback() {
+ if (!empty($_POST['ajax_page_state']['theme'])) {
+ return $_POST['ajax_page_state']['theme'];
+ }
+}
+
+/**
+ * Implements hook_ctools_entity_context_alter().
+ */
+function ctools_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
+ ctools_include('context');
+ switch ($plugin_id) {
+ case 'entity_id:taxonomy_term':
+ $plugin['no ui'] = TRUE;
+ break;
+ case 'entity:user':
+ $plugin = ctools_get_context('user');
+ unset($plugin['no ui']);
+ unset($plugin['no required context ui']);
+ break;
+ }
+
+ // Apply restrictions on taxonomy term reverse relationships whose
+ // restrictions are in the settings on the field.
+ if (!empty($plugin['parent']) &&
+ $plugin['parent'] == 'entity_from_field' &&
+ !empty($plugin['reverse']) &&
+ $plugin['to entity'] == 'taxonomy_term') {
+ $field = field_info_field($plugin['field name']);
+ if (isset($field['settings']['allowed_values'][0]['vocabulary'])) {
+ $plugin['required context']->restrictions = array('vocabulary' => array($field['settings']['allowed_values'][0]['vocabulary']));
+ }
+ }
+}
+
+/**
+ * Implements hook_field_create_field().
+ */
+function ctools_field_create_field($field) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_create_instance().
+ */
+function ctools_field_create_instance($instance) {
+ ctools_flush_field_caches();
+}
+/**
+ * Implements hook_field_delete_field().
+ */
+function ctools_field_delete_field($field) {
+ ctools_flush_field_caches();
+}
+/**
+ * Implements hook_field_delete_instance().
+ */
+function ctools_field_delete_instance($instance) {
+ ctools_flush_field_caches();
+}
+/**
+ * Implements hook_field_update_field().
+ */
+function ctools_field_update_field($field, $prior_field, $has_data) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_update_instance().
+ */
+function ctools_field_update_instance($instance, $prior_instance) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Clear field related caches.
+ */
+function ctools_flush_field_caches() {
+ // Clear caches of 'Entity field' content type plugin.
+ cache_clear_all('ctools_entity_field_content_type_content_types', 'cache');
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.info b/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.info
new file mode 100644
index 0000000..66ca12c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.info
@@ -0,0 +1,13 @@
+name = Custom rulesets
+description = Create custom, exportable, reusable access rulesets for applications like Panels.
+core = 7.x
+package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
+dependencies[] = ctools
+
+; Information added by Drupal.org packaging script on 2015-08-19
+version = "7.x-1.9"
+core = "7.x"
+project = "ctools"
+datestamp = "1440020680"
+
diff --git a/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.install b/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.install
new file mode 100644
index 0000000..3f00877
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.install
@@ -0,0 +1,82 @@
+ 'Contains exportable customized access rulesets.',
+ 'export' => array(
+ 'identifier' => 'ruleset',
+ 'bulk export' => TRUE,
+ 'primary key' => 'rsid',
+ 'api' => array(
+ 'owner' => 'ctools_access_ruleset',
+ 'api' => 'ctools_rulesets',
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
+ 'fields' => array(
+ 'rsid' => array(
+ 'type' => 'serial',
+ 'description' => 'A database primary key to ensure uniqueness',
+ 'not null' => TRUE,
+ 'no export' => TRUE,
+ ),
+ 'name' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'description' => 'Unique ID for this ruleset. Used to identify it programmatically.',
+ ),
+ 'admin_title' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'description' => 'Administrative title for this ruleset.',
+ ),
+ 'admin_description' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Administrative description for this ruleset.',
+ 'object default' => '',
+ ),
+ 'requiredcontexts' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Any required contexts for this ruleset.',
+ 'serialize' => TRUE,
+ 'object default' => array(),
+ ),
+ 'contexts' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Any embedded contexts for this ruleset.',
+ 'serialize' => TRUE,
+ 'object default' => array(),
+ ),
+ 'relationships' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Any relationships for this ruleset.',
+ 'serialize' => TRUE,
+ 'object default' => array(),
+ ),
+ 'access' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'The actual group of access plugins for this ruleset.',
+ 'serialize' => TRUE,
+ 'object default' => array(),
+ ),
+ ),
+ 'primary key' => array('rsid'),
+ );
+
+ return $schema;
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.module b/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.module
new file mode 100644
index 0000000..fb39f37
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.module
@@ -0,0 +1,85 @@
+ array(
+ 'title' => t('Administer access rulesets'),
+ 'description' => t('Add, delete and edit custom access rulesets.'),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_ctools_plugin_directory() to let the system know
+ * we implement task and task_handler plugins.
+ */
+function ctools_access_ruleset_ctools_plugin_directory($module, $plugin) {
+ // Most of this module is implemented as an export ui plugin, and the
+ // rest is in ctools/includes/ctools_access_ruleset.inc
+ if ($module == 'ctools' && ($plugin == 'export_ui' || $plugin == 'access')) {
+ return 'plugins/' . $plugin;
+ }
+}
+
+/**
+ * Implementation of hook_panels_dashboard_blocks().
+ *
+ * Adds page information to the Panels dashboard.
+ */
+function ctools_access_ruleset_panels_dashboard_blocks(&$vars) {
+ $vars['links']['ctools_access_ruleset'] = array(
+ 'title' => l(t('Custom ruleset'), 'admin/structure/ctools-rulesets/add'),
+ 'description' => t('Custom rulesets are combinations of access plugins you can use for access control, selection criteria and pane visibility.'),
+ );
+
+ // Load all mini panels and their displays.
+ ctools_include('export');
+ $items = ctools_export_crud_load_all('ctools_access_ruleset');
+ $count = 0;
+ $rows = array();
+
+ foreach ($items as $item) {
+ $rows[] = array(
+ check_plain($item->admin_title),
+ array(
+ 'data' => l(t('Edit'), "admin/structure/ctools-rulesets/list/$item->name/edit"),
+ 'class' => 'links',
+ ),
+ );
+
+ // Only show 10.
+ if (++$count >= 10) {
+ break;
+ }
+ }
+
+ if ($rows) {
+ $content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage')));
+ }
+ else {
+ $content = '
' . t('There are no custom rulesets.') . '
';
+ }
+
+ $vars['blocks']['ctools_access_ruleset'] = array(
+ 'title' => t('Manage custom rulesets'),
+ 'link' => l(t('Go to list'), 'admin/structure/ctools-rulesets'),
+ 'content' => $content,
+ 'class' => 'dashboard-ruleset',
+ 'section' => 'right',
+ );
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_access_ruleset/plugins/access/ruleset.inc b/sites/all/modules/contrib/ctools/ctools_access_ruleset/plugins/access/ruleset.inc
new file mode 100644
index 0000000..f8abea6
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_access_ruleset/plugins/access/ruleset.inc
@@ -0,0 +1,109 @@
+ '',
+ 'description' => '',
+ 'callback' => 'ctools_ruleset_ctools_access_check',
+ 'settings form' => 'ctools_ruleset_ctools_access_settings',
+ 'summary' => 'ctools_ruleset_ctools_access_summary',
+
+ // This access plugin actually just contains child plugins that are
+ // exportable, UI configured rulesets.
+ 'get child' => 'ctools_ruleset_ctools_access_get_child',
+ 'get children' => 'ctools_ruleset_ctools_access_get_children',
+);
+
+/**
+ * Merge the main access plugin with a loaded ruleset to form a child plugin.
+ */
+function ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item) {
+ $plugin['name'] = $parent . ':' . $item->name;
+ $plugin['title'] = check_plain($item->admin_title);
+ $plugin['description'] = check_plain($item->admin_description);
+
+ // TODO: Generalize this in CTools.
+ if (!empty($item->requiredcontexts)) {
+ $plugin['required context'] = array();
+ foreach ($item->requiredcontexts as $context) {
+ $info = ctools_get_context($context['name']);
+ // TODO: allow an optional setting
+ $plugin['required context'][] = new ctools_context_required($context['identifier'], $info['context name']);
+ }
+ }
+
+ // Store the loaded ruleset in the plugin.
+ $plugin['ruleset'] = $item;
+ return $plugin;
+}
+
+/**
+ * Get a single child access plugin.
+ */
+function ctools_ruleset_ctools_access_get_child($plugin, $parent, $child) {
+ ctools_include('export');
+ $item = ctools_export_crud_load('ctools_access_ruleset', $child);
+ if ($item) {
+ return ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item);
+ }
+}
+
+/**
+ * Get all child access plugins.
+ */
+function ctools_ruleset_ctools_access_get_children($plugin, $parent) {
+ $plugins = array();
+ ctools_include('export');
+ $items = ctools_export_crud_load_all('ctools_access_ruleset');
+ foreach ($items as $name => $item) {
+ $child = ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item);
+ $plugins[$child['name']] = $child;
+ }
+
+ return $plugins;
+}
+
+/**
+ * Settings form for the 'by ruleset' access plugin
+ */
+function ctools_ruleset_ctools_access_settings(&$form, &$form_state, $conf) {
+ if (!empty($form_state['plugin']['ruleset']->admin_description)) {
+ $form['markup'] = array(
+ '#markup' => '
';
+ $output .= theme('ctools_dropdown', array('title' => t('Click to Drop Down'), 'links' => $links));
+
+ // Create a collapsible div
+ $handle = t('Click to Collapse');
+ $content = 'Nulla ligula ante, aliquam at adipiscing egestas, varius vel arcu. Etiam laoreet elementum mi vel consequat. Etiam scelerisque lorem vel neque consequat quis bibendum libero congue. Nulla facilisi. Mauris a elit a leo feugiat porta. Phasellus placerat cursus est vitae elementum.';
+ $output .= '
';
+ $output .= drupal_render($form);
+
+ return array('markup' => array('#markup' => $output));
+}
+
+/**
+ * Returns a "take it all over" hello world style request.
+ */
+function ctools_ajax_sample_hello($js = NULL) {
+ $output = '
' . t('Hello World') . '
';
+ if ($js) {
+ ctools_include('ajax');
+ $commands = array();
+ $commands[] = ajax_command_html('#ctools-sample', $output);
+ print ajax_render($commands); // this function exits.
+ exit;
+ }
+ else {
+ return $output;
+ }
+}
+
+/**
+ * Nix a row from a table and restripe.
+ */
+function ctools_ajax_sample_tablenix($js, $row) {
+ if (!$js) {
+ // We don't support degrading this from js because we're not
+ // using the server to remember the state of the table.
+ return MENU_ACCESS_DENIED;
+ }
+ ctools_include('ajax');
+
+ $commands = array();
+ $commands[] = ajax_command_remove("tr.ajax-sample-row-$row");
+ $commands[] = ajax_command_restripe("table.ajax-sample-table");
+ print ajax_render($commands);
+ exit;
+}
+
+/**
+ * A modal login callback.
+ */
+function ctools_ajax_sample_login($js = NULL) {
+ // Fall back if $js is not set.
+ if (!$js) {
+ return drupal_get_form('user_login');
+ }
+
+ ctools_include('modal');
+ ctools_include('ajax');
+ $form_state = array(
+ 'title' => t('Login'),
+ 'ajax' => TRUE,
+ );
+ $output = ctools_modal_form_wrapper('user_login', $form_state);
+ if (!empty($form_state['executed'])) {
+ // We'll just overwrite the form output if it was successful.
+ $output = array();
+ $inplace = ctools_ajax_text_button(t('remain here'), 'ctools_ajax_sample/nojs/login/inplace', t('Go to your account'));
+ $account = ctools_ajax_text_button(t('your account'), 'ctools_ajax_sample/nojs/login/user', t('Go to your account'));
+ $output[] = ctools_modal_command_display(t('Login Success'), '
Login successful. You can now choose whether to '. $inplace .', or go to '. $account.'.
');
+ }
+ print ajax_render($output);
+ exit;
+}
+
+/**
+ * Post-login processor: should we go to the user account or stay in place?
+ */
+function ctools_ajax_sample_login_success($js, $action) {
+ if (!$js) {
+ // we should never be here out of ajax context
+ return MENU_NOT_FOUND;
+ }
+
+ ctools_include('ajax');
+ ctools_add_js('ajax-responder');
+ $commands = array();
+ if ($action == 'inplace') {
+ // stay here
+ $commands[] = ctools_ajax_command_reload();
+ }
+ else {
+ // bounce bounce
+ $commands[] = ctools_ajax_command_redirect('user');
+ }
+ print ajax_render($commands);
+ exit;
+}
+
+/**
+ * A modal login callback.
+ */
+function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
+ if ($js) {
+ ctools_include('modal');
+ ctools_include('ajax');
+ }
+
+ $form_info = array(
+ 'id' => 'animals',
+ 'path' => "ctools_ajax_sample/" . ($js ? 'ajax' : 'nojs') . "/animal/%step",
+ 'show trail' => TRUE,
+ 'show back' => TRUE,
+ 'show cancel' => TRUE,
+ 'show return' => FALSE,
+ 'next callback' => 'ctools_ajax_sample_wizard_next',
+ 'finish callback' => 'ctools_ajax_sample_wizard_finish',
+ 'cancel callback' => 'ctools_ajax_sample_wizard_cancel',
+ // this controls order, as well as form labels
+ 'order' => array(
+ 'start' => t('Choose animal'),
+ ),
+ // here we map a step to a form id.
+ 'forms' => array(
+ // e.g. this for the step at wombat/create
+ 'start' => array(
+ 'form id' => 'ctools_ajax_sample_start'
+ ),
+ ),
+ );
+
+ // We're not using any real storage here, so we're going to set our
+ // object_id to 1. When using wizard forms, id management turns
+ // out to be one of the hardest parts. Editing an object with an id
+ // is easy, but new objects don't usually have ids until somewhere
+ // in creation.
+ //
+ // We skip all this here by just using an id of 1.
+
+ $object_id = 1;
+
+ if (empty($step)) {
+ // We reset the form when $step is NULL because that means they have
+ // for whatever reason started over.
+ ctools_ajax_sample_cache_clear($object_id);
+ $step = 'start';
+ }
+
+ // This automatically gets defaults if there wasn't anything saved.
+ $object = ctools_ajax_sample_cache_get($object_id);
+
+ $animals = ctools_ajax_sample_animals();
+
+ // Make sure we can't somehow accidentally go to an invalid animal.
+ if (empty($animals[$object->type])) {
+ $object->type = 'unknown';
+ }
+
+ // Now that we have our object, dynamically add the animal's form.
+ if ($object->type == 'unknown') {
+ // If they haven't selected a type, add a form that doesn't exist yet.
+ $form_info['order']['unknown'] = t('Configure animal');
+ $form_info['forms']['unknown'] = array('form id' => 'nothing');
+ }
+ else {
+ // Add the selected animal to the order so that it shows up properly in the trail.
+ $form_info['order'][$object->type] = $animals[$object->type]['config title'];
+ }
+
+ // Make sure all animals forms are represented so that the next stuff can
+ // work correctly:
+ foreach ($animals as $id => $animal) {
+ $form_info['forms'][$id] = array('form id' => $animals[$id]['form']);
+ }
+
+ $form_state = array(
+ 'ajax' => $js,
+ // Put our object and ID into the form state cache so we can easily find
+ // it.
+ 'object_id' => $object_id,
+ 'object' => &$object,
+ );
+
+ // Send this all off to our form. This is like drupal_get_form only wizardy.
+ ctools_include('wizard');
+ $form = ctools_wizard_multistep_form($form_info, $step, $form_state);
+ $output = drupal_render($form);
+
+ if ($output === FALSE || !empty($form_state['complete'])) {
+ // This creates a string based upon the animal and its setting using
+ // function indirection.
+ $animal = $animals[$object->type]['output']($object);
+ }
+
+ // If $output is FALSE, there was no actual form.
+ if ($js) {
+ // If javascript is active, we have to use a render array.
+ $commands = array();
+ if ($output === FALSE || !empty($form_state['complete'])) {
+ // Dismiss the modal.
+ $commands[] = ajax_command_html('#ctools-sample', $animal);
+ $commands[] = ctools_modal_command_dismiss();
+ }
+ else if (!empty($form_state['cancel'])) {
+ // If cancelling, return to the activity.
+ $commands[] = ctools_modal_command_dismiss();
+ }
+ else {
+ $commands = ctools_modal_form_render($form_state, $output);
+ }
+ print ajax_render($commands);
+ exit;
+ }
+ else {
+ if ($output === FALSE || !empty($form_state['complete'])) {
+ return $animal;
+ }
+ else if (!empty($form_state['cancel'])) {
+ drupal_goto('ctools_ajax_sample');
+ }
+ else {
+ return $output;
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Themes
+
+/**
+ * Theme function for main rendered output.
+ */
+function theme_ctools_ajax_sample_container($vars) {
+ $output = '
';
+ $output .= $vars['content'];
+ $output .= '
';
+
+ return $output;
+}
+
+// ---------------------------------------------------------------------------
+// Stuff needed for our little wizard.
+
+/**
+ * Get a list of our animals and associated forms.
+ *
+ * What we're doing is making it easy to add more animals in just one place,
+ * which is often how it will work in the real world. If using CTools, what
+ * you would probably really have, here, is a set of plugins for each animal.
+ */
+function ctools_ajax_sample_animals() {
+ return array(
+ 'sheep' => array(
+ 'title' => t('Sheep'),
+ 'config title' => t('Configure sheep'),
+ 'form' => 'ctools_ajax_sample_configure_sheep',
+ 'output' => 'ctools_ajax_sample_show_sheep',
+ ),
+ 'lizard' => array(
+ 'title' => t('Lizard'),
+ 'config title' => t('Configure lizard'),
+ 'form' => 'ctools_ajax_sample_configure_lizard',
+ 'output' => 'ctools_ajax_sample_show_lizard',
+ ),
+ 'raptor' => array(
+ 'title' => t('Raptor'),
+ 'config title' => t('Configure raptor'),
+ 'form' => 'ctools_ajax_sample_configure_raptor',
+ 'output' => 'ctools_ajax_sample_show_raptor',
+ ),
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Wizard caching helpers.
+
+/**
+ * Store our little cache so that we can retain data from form to form.
+ */
+function ctools_ajax_sample_cache_set($id, $object) {
+ ctools_include('object-cache');
+ ctools_object_cache_set('ctools_ajax_sample', $id, $object);
+}
+
+/**
+ * Get the current object from the cache, or default.
+ */
+function ctools_ajax_sample_cache_get($id) {
+ ctools_include('object-cache');
+ $object = ctools_object_cache_get('ctools_ajax_sample', $id);
+ if (!$object) {
+ // Create a default object.
+ $object = new stdClass;
+ $object->type = 'unknown';
+ $object->name = '';
+ }
+
+ return $object;
+}
+
+/**
+ * Clear the wizard cache.
+ */
+function ctools_ajax_sample_cache_clear($id) {
+ ctools_include('object-cache');
+ ctools_object_cache_clear('ctools_ajax_sample', $id);
+}
+
+// ---------------------------------------------------------------------------
+// Wizard in-between helpers; what to do between or after forms.
+
+/**
+ * Handle the 'next' click on the add/edit pane form wizard.
+ *
+ * All we need to do is store the updated pane in the cache.
+ */
+function ctools_ajax_sample_wizard_next(&$form_state) {
+ ctools_ajax_sample_cache_set($form_state['object_id'], $form_state['object']);
+}
+
+/**
+ * Handle the 'finish' click on the add/edit pane form wizard.
+ *
+ * All we need to do is set a flag so the return can handle adding
+ * the pane.
+ */
+function ctools_ajax_sample_wizard_finish(&$form_state) {
+ $form_state['complete'] = TRUE;
+}
+
+/**
+ * Handle the 'cancel' click on the add/edit pane form wizard.
+ */
+function ctools_ajax_sample_wizard_cancel(&$form_state) {
+ $form_state['cancel'] = TRUE;
+}
+
+// ---------------------------------------------------------------------------
+// Wizard forms for our simple info collection wizard.
+
+/**
+ * Wizard start form. Choose an animal.
+ */
+function ctools_ajax_sample_start($form, &$form_state) {
+ $form_state['title'] = t('Choose animal');
+
+ $animals = ctools_ajax_sample_animals();
+ foreach ($animals as $id => $animal) {
+ $options[$id] = $animal['title'];
+ }
+
+ $form['type'] = array(
+ '#title' => t('Choose your animal'),
+ '#type' => 'radios',
+ '#options' => $options,
+ '#default_value' => $form_state['object']->type,
+ '#required' => TRUE,
+ );
+
+ return $form;
+}
+
+/**
+ * They have selected a sheep. Set it.
+ */
+function ctools_ajax_sample_start_submit(&$form, &$form_state) {
+ $form_state['object']->type = $form_state['values']['type'];
+ // Override where to go next based on the animal selected.
+ $form_state['clicked_button']['#next'] = $form_state['values']['type'];
+}
+
+/**
+ * Wizard form to configure your sheep.
+ */
+function ctools_ajax_sample_configure_sheep($form, &$form_state) {
+ $form_state['title'] = t('Configure sheep');
+
+ $form['name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name your sheep'),
+ '#default_value' => $form_state['object']->name,
+ '#required' => TRUE,
+ );
+
+ $form['sheep'] = array(
+ '#title' => t('What kind of sheep'),
+ '#type' => 'radios',
+ '#options' => array(
+ t('Wensleydale') => t('Wensleydale'),
+ t('Merino') => t('Merino'),
+ t('Corriedale') => t('Coriedale'),
+ ),
+ '#default_value' => !empty($form_state['object']->sheep) ? $form_state['object']->sheep : '',
+ '#required' => TRUE,
+ );
+ return $form;
+}
+
+/**
+ * Submit the sheep and store the values from the form.
+ */
+function ctools_ajax_sample_configure_sheep_submit(&$form, &$form_state) {
+ $form_state['object']->name = $form_state['values']['name'];
+ $form_state['object']->sheep = $form_state['values']['sheep'];
+}
+
+/**
+ * Provide some output for our sheep.
+ */
+function ctools_ajax_sample_show_sheep($object) {
+ return t('You have a @type sheep named "@name".', array(
+ '@type' => $object->sheep,
+ '@name' => $object->name,
+ ));
+}
+
+/**
+ * Wizard form to configure your lizard.
+ */
+function ctools_ajax_sample_configure_lizard($form, &$form_state) {
+ $form_state['title'] = t('Configure lizard');
+
+ $form['name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name your lizard'),
+ '#default_value' => $form_state['object']->name,
+ '#required' => TRUE,
+ );
+
+ $form['lizard'] = array(
+ '#title' => t('Venomous'),
+ '#type' => 'checkbox',
+ '#default_value' => !empty($form_state['object']->lizard),
+ );
+ return $form;
+}
+
+/**
+ * Submit the lizard and store the values from the form.
+ */
+function ctools_ajax_sample_configure_lizard_submit(&$form, &$form_state) {
+ $form_state['object']->name = $form_state['values']['name'];
+ $form_state['object']->lizard = $form_state['values']['lizard'];
+}
+
+/**
+ * Provide some output for our raptor.
+ */
+function ctools_ajax_sample_show_lizard($object) {
+ return t('You have a @type lizard named "@name".', array(
+ '@type' => empty($object->lizard) ? t('non-venomous') : t('venomous'),
+ '@name' => $object->name,
+ ));
+}
+
+/**
+ * Wizard form to configure your raptor.
+ */
+function ctools_ajax_sample_configure_raptor($form, &$form_state) {
+ $form_state['title'] = t('Configure raptor');
+
+ $form['name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name your raptor'),
+ '#default_value' => $form_state['object']->name,
+ '#required' => TRUE,
+ );
+
+ $form['raptor'] = array(
+ '#title' => t('What kind of raptor'),
+ '#type' => 'radios',
+ '#options' => array(
+ t('Eagle') => t('Eagle'),
+ t('Hawk') => t('Hawk'),
+ t('Owl') => t('Owl'),
+ t('Buzzard') => t('Buzzard'),
+ ),
+ '#default_value' => !empty($form_state['object']->raptor) ? $form_state['object']->raptor : '',
+ '#required' => TRUE,
+ );
+
+ $form['domesticated'] = array(
+ '#title' => t('Domesticated'),
+ '#type' => 'checkbox',
+ '#default_value' => !empty($form_state['object']->domesticated),
+ );
+ return $form;
+}
+
+/**
+ * Submit the raptor and store the values from the form.
+ */
+function ctools_ajax_sample_configure_raptor_submit(&$form, &$form_state) {
+ $form_state['object']->name = $form_state['values']['name'];
+ $form_state['object']->raptor = $form_state['values']['raptor'];
+ $form_state['object']->domesticated = $form_state['values']['domesticated'];
+}
+
+/**
+ * Provide some output for our raptor.
+ */
+function ctools_ajax_sample_show_raptor($object) {
+ return t('You have a @type @raptor named "@name".', array(
+ '@type' => empty($object->domesticated) ? t('wild') : t('domesticated'),
+ '@raptor' => $object->raptor,
+ '@name' => $object->name,
+ ));
+}
+
+/**
+ * Helper function to provide a sample jump menu form
+ */
+function ctools_ajax_sample_jump_menu_form() {
+ $url = url('ctools_ajax_sample/jumped');
+ $form_state = array();
+ $form = ctools_jump_menu(array(), $form_state, array($url => t('Jump!')), array());
+ return $form;
+}
+
+/**
+ * Provide a message to the user that the jump menu worked
+ */
+function ctools_ajax_sample_jump_menu_page() {
+ $return_link = l(t('Return to the examples page.'), 'ctools_ajax_sample');
+ $output = t('You successfully jumped! !return_link', array('!return_link' => $return_link));
+ return $output;
+}
+
+/**
+ * Provide a form for an example ajax modal button
+ */
+function ctools_ajax_sample_ajax_button_form() {
+ $form = array();
+
+ $form['url'] = array(
+ '#type' => 'hidden',
+ // The name of the class is the #id of $form['ajax_button'] with "-url"
+ // suffix.
+ '#attributes' => array('class' => array('ctools-ajax-sample-button-url')),
+ '#value' => url('ctools_ajax_sample/nojs/animal'),
+ );
+
+ $form['ajax_button'] = array(
+ '#type' => 'button',
+ '#value' => 'Wizard (button modal)',
+ '#attributes' => array('class' => array('ctools-use-modal')),
+ '#id' => 'ctools-ajax-sample-button',
+ );
+
+ return $form;
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/ajax-loader.gif b/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/ajax-loader.gif
new file mode 100644
index 0000000..d84f653
Binary files /dev/null and b/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/ajax-loader.gif differ
diff --git a/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/loading-large.gif b/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/loading-large.gif
new file mode 100644
index 0000000..1c72ebb
Binary files /dev/null and b/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/loading-large.gif differ
diff --git a/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/loading.gif b/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/loading.gif
new file mode 100644
index 0000000..dc21df1
Binary files /dev/null and b/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/loading.gif differ
diff --git a/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/popups-border.png b/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/popups-border.png
new file mode 100644
index 0000000..ba939f8
Binary files /dev/null and b/sites/all/modules/contrib/ctools/ctools_ajax_sample/images/popups-border.png differ
diff --git a/sites/all/modules/contrib/ctools/ctools_ajax_sample/js/ctools-ajax-sample.js b/sites/all/modules/contrib/ctools/ctools_ajax_sample/js/ctools-ajax-sample.js
new file mode 100644
index 0000000..0cbfc87
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_ajax_sample/js/ctools-ajax-sample.js
@@ -0,0 +1,42 @@
+/**
+* Provide the HTML to create the modal dialog.
+*/
+Drupal.theme.prototype.CToolsSampleModal = function () {
+ var html = '';
+
+ html += '
';
+ html += ' '; //Maybe someday add the option for some specific buttons.
+ html += ' '; //Maybe someday add some footer.
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+
+ return html;
+
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.info b/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.info
new file mode 100644
index 0000000..185d8b6
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.info
@@ -0,0 +1,13 @@
+name = Custom content panes
+description = Create custom, exportable, reusable content panes for applications like Panels.
+core = 7.x
+package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
+dependencies[] = ctools
+
+; Information added by Drupal.org packaging script on 2015-08-19
+version = "7.x-1.9"
+core = "7.x"
+project = "ctools"
+datestamp = "1440020680"
+
diff --git a/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.install b/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.install
new file mode 100644
index 0000000..b4512f2
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.install
@@ -0,0 +1,67 @@
+ 'Contains exportable customized content for this site.',
+ 'export' => array(
+ 'identifier' => 'content',
+ 'bulk export' => TRUE,
+ 'primary key' => 'cid',
+ 'api' => array(
+ 'owner' => 'ctools_custom_content',
+ 'api' => 'ctools_content',
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ 'create callback' => 'ctools_content_type_new',
+ ),
+ 'fields' => array(
+ 'cid' => array(
+ 'type' => 'serial',
+ 'description' => 'A database primary key to ensure uniqueness',
+ 'not null' => TRUE,
+ 'no export' => TRUE,
+ ),
+ 'name' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'description' => 'Unique ID for this content. Used to identify it programmatically.',
+ ),
+ 'admin_title' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'description' => 'Administrative title for this content.',
+ ),
+ 'admin_description' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Administrative description for this content.',
+ 'object default' => '',
+ ),
+ 'category' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'description' => 'Administrative category for this content.',
+ ),
+ 'settings' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Serialized settings for the actual content to be used',
+ 'serialize' => TRUE,
+ 'object default' => array(),
+ ),
+ ),
+ 'primary key' => array('cid'),
+ );
+
+ return $schema;
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.module b/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.module
new file mode 100644
index 0000000..3e316a9
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.module
@@ -0,0 +1,118 @@
+ array(
+ 'title' => t('Administer custom content'),
+ 'description' => t('Add, edit and delete CTools custom stored custom content'),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_ctools_plugin_directory() to let the system know
+ * we implement task and task_handler plugins.
+ */
+function ctools_custom_content_ctools_plugin_directory($module, $plugin) {
+ // Most of this module is implemented as an export ui plugin, and the
+ // rest is in ctools/includes/ctools_custom_content.inc
+ if ($module == 'ctools' && $plugin == 'export_ui') {
+ return 'plugins/' . $plugin;
+ }
+}
+
+/**
+ * Implements hook_get_pane_links_alter().
+ */
+function ctools_custom_content_get_pane_links_alter(&$links, $pane, $content_type) {
+ if ($pane->type == 'custom') {
+ if(!isset($pane->configuration['name'])) {
+ $name_of_pane = $pane->subtype;
+ }
+ else {
+ $name_of_pane = $pane->configuration['name'];
+ }
+
+ $links['top']['edit_custom_content'] = array(
+ 'title' => t('Edit custom content pane'),
+ 'href' => url('admin/structure/ctools-content/list/' . $name_of_pane . '/edit', array('absolute' => TRUE)),
+ 'attributes' => array('target' => array('_blank')),
+ );
+ }
+}
+
+/**
+ * Create callback for creating a new CTools custom content type.
+ *
+ * This ensures we get proper defaults from the plugin for its settings.
+ */
+function ctools_content_type_new($set_defaults) {
+ $item = ctools_export_new_object('ctools_custom_content', $set_defaults);
+ ctools_include('content');
+ $plugin = ctools_get_content_type('custom');
+ $item->settings = ctools_content_get_defaults($plugin, array());
+ return $item;
+}
+
+/**
+ * Implementation of hook_panels_dashboard_blocks().
+ *
+ * Adds page information to the Panels dashboard.
+ */
+function ctools_custom_content_panels_dashboard_blocks(&$vars) {
+ $vars['links']['ctools_custom_content'] = array(
+ 'title' => l(t('Custom content'), 'admin/structure/ctools-content/add'),
+ 'description' => t('Custom content panes are basic HTML you enter that can be reused in all of your panels.'),
+ );
+
+ // Load all mini panels and their displays.
+ ctools_include('export');
+ $items = ctools_export_crud_load_all('ctools_custom_content');
+ $count = 0;
+ $rows = array();
+
+ foreach ($items as $item) {
+ $rows[] = array(
+ check_plain($item->admin_title),
+ array(
+ 'data' => l(t('Edit'), "admin/structure/ctools-content/list/$item->name/edit"),
+ 'class' => 'links',
+ ),
+ );
+
+ // Only show 10.
+ if (++$count >= 10) {
+ break;
+ }
+ }
+
+ if ($rows) {
+ $content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage')));
+ }
+ else {
+ $content = '
' . t('There are no custom content panes.') . '
';
+ }
+
+ $vars['blocks']['ctools_custom_content'] = array(
+ 'title' => t('Manage custom content'),
+ 'link' => l(t('Go to list'), 'admin/structure/ctools-content'),
+ 'content' => $content,
+ 'class' => 'dashboard-content',
+ 'section' => 'right',
+ );
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc b/sites/all/modules/contrib/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc
new file mode 100644
index 0000000..467dc58
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc
@@ -0,0 +1,20 @@
+ 'ctools_custom_content',
+ 'access' => 'administer custom content',
+
+ 'menu' => array(
+ 'menu item' => 'ctools-content',
+ 'menu title' => 'Custom content panes',
+ 'menu description' => 'Add, edit or delete custom content panes.',
+ ),
+
+ 'title singular' => t('content pane'),
+ 'title singular proper' => t('Content pane'),
+ 'title plural' => t('content panes'),
+ 'title plural proper' => t('Content panes'),
+
+ 'handler' => 'ctools_custom_content_ui',
+);
+
diff --git a/sites/all/modules/contrib/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php b/sites/all/modules/contrib/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
new file mode 100644
index 0000000..56fe4b2
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
@@ -0,0 +1,129 @@
+settings['body'])) {
+ $form_state['item']->settings['format'] = $form_state['item']->settings['body']['format'];
+ $form_state['item']->settings['body'] = $form_state['item']->settings['body']['value'];
+ }
+ parent::edit_form($form, $form_state);
+
+ $form['category'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Category'),
+ '#description' => t('What category this content should appear in. If left blank the category will be "Miscellaneous".'),
+ '#default_value' => $form_state['item']->category,
+ );
+
+ $form['title'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $form_state['item']->settings['title'],
+ '#title' => t('Title'),
+ );
+
+ $form['body'] = array(
+ '#type' => 'text_format',
+ '#title' => t('Body'),
+ '#default_value' => $form_state['item']->settings['body'],
+ '#format' => $form_state['item']->settings['format'],
+ );
+
+ $form['substitute'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Use context keywords'),
+ '#description' => t('If checked, context keywords will be substituted in this content.'),
+ '#default_value' => !empty($form_state['item']->settings['substitute']),
+ );
+ }
+
+ function edit_form_submit(&$form, &$form_state) {
+ parent::edit_form_submit($form, $form_state);
+
+ // Since items in our settings are not in the schema, we have to do these manually:
+ $form_state['item']->settings['title'] = $form_state['values']['title'];
+ $form_state['item']->settings['body'] = $form_state['values']['body']['value'];
+ $form_state['item']->settings['format'] = $form_state['values']['body']['format'];
+ $form_state['item']->settings['substitute'] = $form_state['values']['substitute'];
+ }
+
+ function list_form(&$form, &$form_state) {
+ parent::list_form($form, $form_state);
+
+ $options = array('all' => t('- All -'));
+ foreach ($this->items as $item) {
+ $options[$item->category] = $item->category;
+ }
+
+ $form['top row']['category'] = array(
+ '#type' => 'select',
+ '#title' => t('Category'),
+ '#options' => $options,
+ '#default_value' => 'all',
+ '#weight' => -10,
+ );
+ }
+
+ function list_filter($form_state, $item) {
+ if ($form_state['values']['category'] != 'all' && $form_state['values']['category'] != $item->category) {
+ return TRUE;
+ }
+
+ return parent::list_filter($form_state, $item);
+ }
+
+ function list_sort_options() {
+ return array(
+ 'disabled' => t('Enabled, title'),
+ 'title' => t('Title'),
+ 'name' => t('Name'),
+ 'category' => t('Category'),
+ 'storage' => t('Storage'),
+ );
+ }
+
+ function list_build_row($item, &$form_state, $operations) {
+ // Set up sorting
+ switch ($form_state['values']['order']) {
+ case 'disabled':
+ $this->sorts[$item->name] = empty($item->disabled) . $item->admin_title;
+ break;
+ case 'title':
+ $this->sorts[$item->name] = $item->admin_title;
+ break;
+ case 'name':
+ $this->sorts[$item->name] = $item->name;
+ break;
+ case 'category':
+ $this->sorts[$item->name] = $item->category;
+ break;
+ case 'storage':
+ $this->sorts[$item->name] = $item->type . $item->admin_title;
+ break;
+ }
+
+ $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
+
+ $this->rows[$item->name] = array(
+ 'data' => array(
+ array('data' => check_plain($item->name), 'class' => array('ctools-export-ui-name')),
+ array('data' => check_plain($item->admin_title), 'class' => array('ctools-export-ui-title')),
+ array('data' => check_plain($item->category), 'class' => array('ctools-export-ui-category')),
+ array('data' => $ops, 'class' => array('ctools-export-ui-operations')),
+ ),
+ 'title' => check_plain($item->admin_description),
+ 'class' => array(!empty($item->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'),
+ );
+ }
+
+ function list_table_header() {
+ return array(
+ array('data' => t('Name'), 'class' => array('ctools-export-ui-name')),
+ array('data' => t('Title'), 'class' => array('ctools-export-ui-title')),
+ array('data' => t('Category'), 'class' => array('ctools-export-ui-category')),
+ array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')),
+ );
+ }
+
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/README.txt b/sites/all/modules/contrib/ctools/ctools_plugin_example/README.txt
new file mode 100644
index 0000000..42edcdc
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/README.txt
@@ -0,0 +1,14 @@
+
+The CTools Plugin Example is an example for developers of how to CTools
+access, argument, content type, context, and relationship plugins.
+
+There are a number of ways to profit from this:
+
+1. The code itself intends to be as simple and self-explanatory as possible.
+ Nothing fancy is attempted: It's just trying to use the plugin API to show
+ how it can be used.
+
+2. There is a sample panel. You can access it at /ctools_plugin_example/xxxx
+ to see how it works.
+
+3. There is Advanced Help at admin/advanced_help/ctools_plugin_example.
\ No newline at end of file
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.info b/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.info
new file mode 100644
index 0000000..d378641
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.info
@@ -0,0 +1,16 @@
+name = Chaos Tools (CTools) Plugin Example
+description = Shows how an external module can provide ctools plugins (for Panels, etc.).
+package = Chaos tool suite
+version = CTOOLS_MODULE_VERSION
+dependencies[] = ctools
+dependencies[] = panels
+dependencies[] = page_manager
+dependencies[] = advanced_help
+core = 7.x
+
+; Information added by Drupal.org packaging script on 2015-08-19
+version = "7.x-1.9"
+core = "7.x"
+project = "ctools"
+datestamp = "1440020680"
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.module b/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.module
new file mode 100644
index 0000000..01d5338
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.module
@@ -0,0 +1,94 @@
+ 'CTools plugin example',
+ 'description' => t("Demonstration code, advanced help, and a demo panel to show how to build ctools plugins."),
+ 'page callback' => 'ctools_plugin_example_explanation_page',
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
+ return $items;
+}
+
+/**
+ * Implements hook_ctools_plugin_directory().
+ *
+ * It simply tells panels where to find the .inc files that define various
+ * args, contexts, content_types. In this case the subdirectories of
+ * ctools_plugin_example/panels are used.
+ */
+function ctools_plugin_example_ctools_plugin_directory($module, $plugin) {
+ if ($module == 'ctools' && !empty($plugin)) {
+ return "plugins/$plugin";
+ }
+}
+
+/**
+ * Implement hook_ctools_plugin_api().
+ *
+ * If you do this, CTools will pick up default panels pages in
+ * .pages_default.inc
+ */
+function ctools_plugin_example_ctools_plugin_api($module, $api) {
+ // @todo -- this example should explain how to put it in a different file.
+ if ($module == 'panels_mini' && $api == 'panels_default') {
+ return array('version' => 1);
+ }
+ if ($module == 'page_manager' && $api == 'pages_default') {
+ return array('version' => 1);
+ }
+}
+
+/**
+ * Just provide an explanation page for the admin section
+ * @return unknown_type
+ */
+function ctools_plugin_example_explanation_page() {
+ $content = '
' . t("The CTools Plugin Example is simply a developer's demo of how to create plugins for CTools. It provides no useful functionality for an ordinary user.") . '
';
+
+ $content .= '
' . t(
+ 'There is a demo panel demonstrating much of the functionality provided at
+ CTools demo panel, and you can find documentation on the examples at
+ !ctools_plugin_example_help.
+ CTools itself provides documentation at !ctools_help. Mostly, though, the code itself is intended to be the teacher.
+ You can find it in %path.',
+ array(
+ '@demo_url' => url('ctools_plugin_example/xxxxx'),
+ '!ctools_plugin_example_help' => theme('advanced_help_topic', array('module' => 'ctools_plugin_example', 'topic' => 'Chaos-Tools--CTools--Plugin-Examples', 'type' => 'title')),
+ '!ctools_help' => theme('advanced_help_topic', array('module' => 'ctools', 'topic' => 'plugins', 'type' => 'title')),
+ '%path' => drupal_get_path('module', 'ctools_plugin_example'),
+ )) . '
We can use access plugins to determine access to a page or visibility of the panes in a page. Basically, we just determine access based on configuration settings and the various contexts that are available to us.
+
The arbitrary example in plugins/access/arg_length.inc determines access based on the length of the simplecontext argument. You can configure whether access should be granted if the simplecontext argument is greater or less than some number.
+
+
+
+
+
+
+
+
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Argument-Plugins--Starting-at-the-beginning.html b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Argument-Plugins--Starting-at-the-beginning.html
new file mode 100644
index 0000000..4dd569d
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Argument-Plugins--Starting-at-the-beginning.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
Contexts are fundamental to CTools, and they almost always start with an argument to a panels page, so we'll start there too.
+
We first need to process an argument.
+
We're going to work with a "Simplecontext" context type and argument, and then with a content type that displays it. So we'll start by with the Simplecontext argument plugin in plugins/arguments/simplecontext_arg.inc.
+
Note that the name of the file (simplecontext_arg.inc) is built from the machine name of our plugin (simplecontext_arg). And note also that the primary function that we use to provide our argument (ctools_plugin_example_simplecontext_arg_ctools_arguments()) is also built from the machine name. This magic is most of the naming magic that you have to know.
+
You can browse plugins/arguments/simplecontext_arg.inc and see the little that it does.
+
+
+
+
+
+
+
+
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Chaos-Tools--CTools--Plugin-Examples.html b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Chaos-Tools--CTools--Plugin-Examples.html
new file mode 100644
index 0000000..7576c80
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Chaos-Tools--CTools--Plugin-Examples.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
This demonstration module is intended for developers to look at and play with. CTools plugins are not terribly difficult to do, but it can be hard to sort through the various arguments and required functions. The idea here is that you should have a starting point for most anything you want to do. Just work through the example, and then start experimenting with changing it.
+
There are two parts to this demo:
+
First, there is a sample panel provided that uses all the various plugins. It's at ctools_example/12345. You can edit the panel and configure all the panes on it.
+
Second, the code is there for you to experiment with and change as you see fit. Sometimes starting with simple code and working with it can take you places that it's hard to go when you're looking at more complex examples.
+
+
+
+
+
+
+
+
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Content-Type-Plugins--Displaying-content-using-a-context.html b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Content-Type-Plugins--Displaying-content-using-a-context.html
new file mode 100644
index 0000000..918a13c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Content-Type-Plugins--Displaying-content-using-a-context.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
Now we get to the heart of the matter: Building a content type plugin. A content type plugin uses the contexts available to it to display something. plugins/content_types/simplecontext_content_type.inc does this work for us.
+
Note that our content type also has an edit form which can be used to configure its behavior. This settings form is accessed through the panels interface, and it's up to you what the settings mean to the code and the generation of content in the display rendering.
+
+
+
+
+
+
+
+
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Context-plugins--Creating-a--context--from-an-argument.html b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Context-plugins--Creating-a--context--from-an-argument.html
new file mode 100644
index 0000000..e8efbb3
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Context-plugins--Creating-a--context--from-an-argument.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
Now that we have a plugin for a simplecontext argument, we can create a plugin for a simplecontext context.
+
Normally, a context would take an argument which is a key like a node ID (nid) and retrieve a more complex object from a database or whatever. In our example, we'll artificially transform the argument into an arbitrary "context" data object.
Note that there are actually two ways to create a context. The normal one, which we've been referring to, is to create a context from an argument. However, it is also possible to configure a context in a panel using the panels interface. This is quite inflexible, but might be useful for configuring single page. However, it means that we have a settings form for exactly that purpose. Our context would have to know how to create itself from a settings form as well as from an argument. Simplecontext can do that.
+
A context plugin can also provide keywords that expose parts of its context using keywords like masterkeyword:dataitem. The node plugin for ctools has node:nid and node:title, for example. The simplecontext plugin here provides the simplest of keywords.
+
+
+
+
+
+
+
+
+
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Module-setup-and-hooks.html b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Module-setup-and-hooks.html
new file mode 100644
index 0000000..f816917
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Module-setup-and-hooks.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
Your module must provide a few things so that your plugins can be found.
+
First, you need to implement hook_ctools_plugin_directory(). Here we're telling CTools that our plugins will be found in the module's directory in the plugins/<plugintype> directory. Context plugins will be in ctools_plugin_example/plugins/contexts, Content-type plugins will be in ctools_plugin_example/plugins/content_types.
+
<?php function ctools_plugin_example_ctools_plugin_directory($module, $plugin) { if ($module == 'ctools' && !empty($plugin)) { return "plugins/$plugin"; } } ?>
+
Second, if you module wants to provide default panels pages, you can implement hook_ctools_plugin_api(). CTools will then pick up your panels pages in the file named <modulename>.pages_default.inc.
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Relationships--Letting-one-context-take-us-to-another.html b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Relationships--Letting-one-context-take-us-to-another.html
new file mode 100644
index 0000000..7691245
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/Relationships--Letting-one-context-take-us-to-another.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
Often a single data type can lead us to other data types. For example, a node has a user (the author) and the user has data associated with it.
+
A relationship plugin allows this kind of data to be accessed.
+
An example relationship plugin is provided in plugins/relationships/relcontext_from_simplecontext.inc. It looks at a simplecontext (which we got from an argument) and builds an (artificial) "relcontext" from that.
+
+
+
+
+
+
+
+
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/help/ctools_plugin_example.help.ini b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/ctools_plugin_example.help.ini
new file mode 100644
index 0000000..6fb3d4c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/help/ctools_plugin_example.help.ini
@@ -0,0 +1,42 @@
+[Chaos-Tools--CTools--Plugin-Examples]
+title = CTools Plugin Examples
+file = Chaos-Tools--CTools--Plugin-Examples
+weight = 0
+parent =
+
+[Module-setup-and-hooks]
+title = Module setup and hooks
+file = Module-setup-and-hooks
+weight = -15
+parent = Chaos-Tools--CTools--Plugin-Examples
+
+[Argument-Plugins--Starting-at-the-beginning]
+title = Argument Plugins: Starting at the beginning
+file = Argument-Plugins--Starting-at-the-beginning
+weight = -14
+parent = Chaos-Tools--CTools--Plugin-Examples
+
+[Context-plugins--Creating-a--context--from-an-argument]
+title = Context plugins: Creating a context from an argument
+file = Context-plugins--Creating-a--context--from-an-argument
+weight = -13
+parent = Chaos-Tools--CTools--Plugin-Examples
+
+[Content-Type-Plugins--Displaying-content-using-a-context]
+title = Content Type Plugins: Displaying content using a context
+file = Content-Type-Plugins--Displaying-content-using-a-context
+weight = -12
+parent = Chaos-Tools--CTools--Plugin-Examples
+
+[Access-Plugins--Determining-access-and-visibility]
+title = Access Plugins: Determining access and visibility
+file = Access-Plugins--Determining-access-and-visibility
+weight = -11
+parent = Chaos-Tools--CTools--Plugin-Examples
+
+[Relationships--Letting-one-context-take-us-to-another]
+title = Relationships: Letting one context take us to another
+file = Relationships--Letting-one-context-take-us-to-another
+weight = -10
+parent = Chaos-Tools--CTools--Plugin-Examples
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/access/arg_length.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/access/arg_length.inc
new file mode 100644
index 0000000..2a09eea
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/access/arg_length.inc
@@ -0,0 +1,65 @@
+ t("Arg length"),
+ 'description' => t('Control access by length of simplecontext argument.'),
+ 'callback' => 'ctools_plugin_example_arg_length_ctools_access_check',
+ 'settings form' => 'ctools_plugin_example_arg_length_ctools_access_settings',
+ 'summary' => 'ctools_plugin_example_arg_length_ctools_access_summary',
+ 'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'),
+);
+
+/**
+ * Settings form for the 'by role' access plugin.
+ */
+function ctools_plugin_example_arg_length_ctools_access_settings(&$form, &$form_state, $conf) {
+ $form['settings']['greater_than'] = array(
+ '#type' => 'radios',
+ '#title' => t('Grant access if simplecontext argument length is'),
+ '#options' => array(1 => t('Greater than'), 0 => t('Less than or equal to')),
+ '#default_value' => $conf['greater_than'],
+ );
+ $form['settings']['arg_length'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Length of simplecontext argument'),
+ '#size' => 3,
+ '#default_value' => $conf['arg_length'],
+ '#description' => t('Access/visibility will be granted based on arg length.'),
+ );
+}
+
+/**
+ * Check for access.
+ */
+function ctools_plugin_example_arg_length_ctools_access_check($conf, $context) {
+ // As far as I know there should always be a context at this point, but this
+ // is safe.
+ if (empty($context) || empty($context->data)) {
+ return FALSE;
+ }
+ $compare = ($context->arg_length > $conf['arg_length']);
+ if (($compare && $conf['greater_than']) || (!$compare && !$conf['greater_than'])) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * Provide a summary description based upon the checked roles.
+ */
+function ctools_plugin_example_arg_length_ctools_access_summary($conf, $context) {
+ return t('Simpletext argument must be !comp @length characters',
+ array('!comp' => $conf['greater_than'] ? 'greater than' : 'less than or equal to',
+ '@length' => $conf['arg_length']));
+}
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/access/example_role.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/access/example_role.inc
new file mode 100644
index 0000000..bbe364c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/access/example_role.inc
@@ -0,0 +1,76 @@
+ t("CTools example: role"),
+ 'description' => t('Control access by role.'),
+ 'callback' => 'ctools_plugin_example_example_role_ctools_access_check',
+ 'default' => array('rids' => array()),
+ 'settings form' => 'ctools_plugin_example_example_role_ctools_access_settings',
+ 'summary' => 'ctools_plugin_example_example_role_ctools_access_summary',
+ 'required context' => new ctools_context_required(t('User'), 'user'),
+);
+
+/**
+ * Settings form for the 'by role' access plugin.
+ */
+function ctools_plugin_example_example_role_ctools_access_settings(&$form, &$form_state, $conf) {
+ $form['settings']['rids'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Role'),
+ '#default_value' => $conf['rids'],
+ '#options' => ctools_get_roles(),
+ '#description' => t('Only the checked roles will be granted access.'),
+ );
+}
+
+/**
+ * Compress the roles allowed to the minimum.
+ */
+function ctools_plugin_example_example_role_ctools_access_settings_submit(&$form, &$form_state) {
+ $form_state['values']['settings']['rids'] = array_keys(array_filter($form_state['values']['settings']['rids']));
+}
+
+/**
+ * Check for access.
+ */
+function ctools_plugin_example_example_role_ctools_access_check($conf, $context) {
+ // As far as I know there should always be a context at this point, but this
+ // is safe.
+ if (empty($context) || empty($context->data) || !isset($context->data->roles)) {
+ return FALSE;
+ }
+
+ $roles = array_keys($context->data->roles);
+ $roles[] = $context->data->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
+ return (bool) array_intersect($conf['rids'], $roles);
+}
+
+/**
+ * Provide a summary description based upon the checked roles.
+ */
+function ctools_plugin_example_example_role_ctools_access_summary($conf, $context) {
+ if (!isset($conf['rids'])) {
+ $conf['rids'] = array();
+ }
+ $roles = ctools_get_roles();
+ $names = array();
+ foreach (array_filter($conf['rids']) as $rid) {
+ $names[] = check_plain($roles[$rid]);
+ }
+ if (empty($names)) {
+ return t('@identifier can have any role', array('@identifier' => $context->identifier));
+ }
+ return format_plural(count($names), '@identifier must have role "@roles"', '@identifier can be one of "@roles"', array('@roles' => implode(', ', $names), '@identifier' => $context->identifier));
+}
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc
new file mode 100644
index 0000000..51c7c60
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc
@@ -0,0 +1,52 @@
+ t("Simplecontext arg"),
+ // keyword to use for %substitution
+ 'keyword' => 'simplecontext',
+ 'description' => t('Creates a "simplecontext" from the arg.'),
+ 'context' => 'simplecontext_arg_context',
+ // 'settings form' => 'simplecontext_arg_settings_form',
+
+ // placeholder_form is used in panels preview, for example, so we can
+ // preview without getting the arg from a URL
+ 'placeholder form' => array(
+ '#type' => 'textfield',
+ '#description' => t('Enter the simplecontext arg'),
+ ),
+);
+
+/**
+ * Get the simplecontext context using the arg. In this case we're just going
+ * to manufacture the context from the data in the arg, but normally it would
+ * be an API call, db lookup, etc.
+ */
+function simplecontext_arg_context($arg = NULL, $conf = NULL, $empty = FALSE) {
+ // If $empty == TRUE it wants a generic, unfilled context.
+ if ($empty) {
+ return ctools_context_create_empty('simplecontext');
+ }
+ // Do whatever error checking is required, returning FALSE if it fails the test
+ // Normally you'd check
+ // for a missing object, one you couldn't create, etc.
+ if (empty($arg)) {
+ return FALSE;
+ }
+ return ctools_context_create('simplecontext', $arg);
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/icon_example.png b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/icon_example.png
new file mode 100644
index 0000000..58c6bee
Binary files /dev/null and b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/icon_example.png differ
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc
new file mode 100644
index 0000000..3c02ab8
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc
@@ -0,0 +1,116 @@
+ t('CTools example no context content type'),
+ 'description' => t('No context content type - requires and uses no context.'),
+
+ // 'single' => TRUE means has no subtypes.
+ 'single' => TRUE,
+ // Constructor.
+ 'content_types' => array('no_context_content_type'),
+ // Name of a function which will render the block.
+ 'render callback' => 'no_context_content_type_render',
+ // The default context.
+ 'defaults' => array(),
+
+ // This explicitly declares the config form. Without this line, the func would be
+ // ctools_plugin_example_no_context_content_type_edit_form.
+ 'edit form' => 'no_context_content_type_edit_form',
+
+ // Icon goes in the directory with the content type.
+ 'icon' => 'icon_example.png',
+ 'category' => array(t('CTools Examples'), -9),
+
+ // this example does not provide 'admin info', which would populate the
+ // panels builder page preview.
+);
+
+/**
+ * Run-time rendering of the body of the block.
+ *
+ * @param $subtype
+ * @param $conf
+ * Configuration as done at admin time.
+ * @param $args
+ * @param $context
+ * Context - in this case we don't have any.
+ *
+ * @return
+ * An object with at least title and content members.
+ */
+function no_context_content_type_render($subtype, $conf, $args, $context) {
+ $block = new stdClass();
+
+ $ctools_help = theme('advanced_help_topic', array('module' => 'ctools', 'topic' => 'plugins', 'type' => 'title'));
+ $ctools_plugin_example_help = theme('advanced_help_topic', array('module' => 'ctools_plugin_example', 'topic' => 'Chaos-Tools--CTools--Plugin-Examples', 'type' => 'title'));
+
+ // The title actually used in rendering
+ $block->title = check_plain("No-context content type");
+ $block->content = t("
+
Welcome to the CTools Plugin Example demonstration content type.
+
+ This block is a content type which requires no context at all. It's like a custom block,
+ but not even that sophisticated.
+
+ For more information on the example plugins, please see the advanced help for
+
+ {$ctools_help} and {$ctools_plugin_example_help}
+
+ ");
+ if (!empty($conf)) {
+ $block->content .= '
The only information that can be displayed in this block comes from the code and its settings form:
';
+ $block->content .= '
' . var_export($conf, TRUE) . '
';
+ }
+
+ return $block;
+
+}
+
+/**
+ * 'Edit form' callback for the content type.
+ * This example just returns a form; validation and submission are standard drupal
+ * Note that if we had not provided an entry for this in hook_content_types,
+ * this could have had the default name
+ * ctools_plugin_example_no_context_content_type_edit_form.
+ *
+ */
+function no_context_content_type_edit_form($form, &$form_state) {
+ $conf = $form_state['conf'];
+ $form['item1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Item1'),
+ '#size' => 50,
+ '#description' => t('The setting for item 1.'),
+ '#default_value' => !empty($conf['item1']) ? $conf['item1'] : '',
+ '#prefix' => '
',
+ );
+ return $form;
+}
+
+function no_context_content_type_edit_form_submit($form, &$form_state) {
+ foreach (array('item1', 'item2') as $key) {
+ $form_state['conf'][$key] = $form_state['values'][$key];
+ }
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc
new file mode 100644
index 0000000..bf54dce
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc
@@ -0,0 +1,103 @@
+ t('CTools example relcontext content type'),
+ 'admin info' => 'ctools_plugin_example_relcontext_content_type_admin_info',
+ 'content_types' => 'relcontext_content_type',
+ 'single' => TRUE,
+ 'render callback' => 'relcontext_content_type_render',
+ // Icon goes in the directory with the content type. Here, in plugins/content_types.
+ 'icon' => 'icon_example.png',
+ 'description' => t('Relcontext content type - works with relcontext context.'),
+ 'required context' => new ctools_context_required(t('Relcontext'), 'relcontext'),
+ 'category' => array(t('CTools Examples'), -9),
+ 'edit form' => 'relcontext_edit_form',
+
+ // this example does not provide 'admin info', which would populate the
+ // panels builder page preview.
+
+);
+
+/**
+ * Run-time rendering of the body of the block.
+ *
+ * @param $subtype
+ * @param $conf
+ * Configuration as done at admin time
+ * @param $args
+ * @param $context
+ * Context - in this case we don't have any
+ *
+ * @return
+ * An object with at least title and content members
+ */
+function relcontext_content_type_render($subtype, $conf, $args, $context) {
+ $data = $context->data;
+ $block = new stdClass();
+
+ // Don't forget to check this data if it's untrusted.
+ // The title actually used in rendering.
+ $block->title = "Relcontext content type";
+ $block->content = t("
+ This is a block of data created by the Relcontent content type.
+ Data in the block may be assembled from static text (like this) or from the
+ content type settings form (\$conf) for the content type, or from the context
+ that is passed in.
+ In our case, the configuration form (\$conf) has just one field, 'config_item_1;
+ and it's configured with:
+ ");
+ if (!empty($conf)) {
+ $block->content .= '
' . var_export($conf['config_item_1'], TRUE) . '
';
+ }
+ if (!empty($context)) {
+ $block->content .= ' The args ($args) were
' .
+ var_export($args, TRUE) . '
';
+ }
+ $block->content .= ' And the relcontext context ($context->data->description)
+ (which was created from a
+ simplecontext context) was
',
+ );
+ return $form;
+}
+
+function relcontext_edit_form_submit($form, &$form_state) {
+ foreach (element_children($form) as $key) {
+ if (!empty($form_state['values'][$key])) {
+ $form_state['conf'][$key] = $form_state['values'][$key];
+ }
+ }
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc
new file mode 100644
index 0000000..a308683
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc
@@ -0,0 +1,129 @@
+ t('Simplecontext content type'),
+ 'content_types' => 'simplecontext_content_type',
+ // 'single' means not to be subtyped.
+ 'single' => TRUE,
+ // Name of a function which will render the block.
+ 'render callback' => 'simplecontext_content_type_render',
+
+ // Icon goes in the directory with the content type.
+ 'icon' => 'icon_example.png',
+ 'description' => t('Simplecontext content type - works with a simplecontext context.'),
+ 'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'),
+ 'edit form' => 'simplecontext_content_type_edit_form',
+ 'admin title' => 'ctools_plugin_example_simplecontext_content_type_admin_title',
+
+ // presents a block which is used in the preview of the data.
+ // Pn Panels this is the preview pane shown on the panels building page.
+ 'admin info' => 'ctools_plugin_example_simplecontext_content_type_admin_info',
+ 'category' => array(t('CTools Examples'), -9),
+);
+
+function ctools_plugin_example_simplecontext_content_type_admin_title($subtype, $conf, $context = NULL) {
+ $output = t('Simplecontext');
+ if ($conf['override_title'] && !empty($conf['override_title_text'])) {
+ $output = filter_xss_admin($conf['override_title_text']);
+ }
+ return $output;
+}
+
+/**
+ * Callback to provide administrative info (the preview in panels when building
+ * a panel).
+ *
+ * In this case we'll render the content with a dummy argument and
+ * a dummy context.
+ */
+function ctools_plugin_example_simplecontext_content_type_admin_info($subtype, $conf, $context = NULL) {
+ $context = new stdClass();
+ $context->data = new stdClass();
+ $context->data->description = t("no real context");
+ $block = simplecontext_content_type_render($subtype, $conf, array("Example"), $context);
+ return $block;
+}
+
+/**
+ * Run-time rendering of the body of the block (content type)
+ *
+ * @param $subtype
+ * @param $conf
+ * Configuration as done at admin time
+ * @param $args
+ * @param $context
+ * Context - in this case we don't have any
+ *
+ * @return
+ * An object with at least title and content members
+ */
+function simplecontext_content_type_render($subtype, $conf, $args, $context) {
+ $data = $context->data;
+ $block = new stdClass();
+
+ // Don't forget to check this data if it's untrusted.
+ // The title actually used in rendering.
+ $block->title = "Simplecontext content type";
+ $block->content = t("
+ This is a block of data created by the Simplecontext content type.
+ Data in the block may be assembled from static text (like this) or from the
+ content type settings form (\$conf) for the content type, or from the context
+ that is passed in.
+ In our case, the configuration form (\$conf) has just one field, 'config_item_1;
+ and it's configured with:
+ ");
+ if (!empty($conf)) {
+ $block->content .= '
';
+ return $block;
+}
+
+/**
+ * 'Edit' callback for the content type.
+ * This example just returns a form.
+ *
+ */
+function simplecontext_content_type_edit_form($form, &$form_state) {
+ $conf = $form_state['conf'];
+ $form['config_item_1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Config Item 1 for simplecontext content type'),
+ '#size' => 50,
+ '#description' => t('The stuff for item 1.'),
+ '#default_value' => !empty($conf['config_item_1']) ? $conf['config_item_1'] : '',
+ '#prefix' => '
',
+ '#suffix' => '
',
+ );
+
+ return $form;
+}
+
+function simplecontext_content_type_edit_form_submit($form, &$form_state) {
+ foreach (element_children($form) as $key) {
+ if (!empty($form_state['values'][$key])) {
+ $form_state['conf'][$key] = $form_state['values'][$key];
+ }
+ }
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc
new file mode 100644
index 0000000..0c7ef11
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc
@@ -0,0 +1,83 @@
+ t("Relcontext"),
+ 'description' => t('A relcontext object.'),
+ // Function to create the relcontext.
+ 'context' => 'ctools_plugin_example_context_create_relcontext',
+ // Function that does the settings.
+ 'settings form' => 'relcontext_settings_form',
+ 'keyword' => 'relcontext',
+ 'context name' => 'relcontext',
+);
+
+/**
+ * Create a context, either from manual configuration (form) or from an argument on the URL.
+ *
+ * @param $empty
+ * If true, just return an empty context.
+ * @param $data
+ * If from settings form, an array as from a form. If from argument, a string.
+ * @param $conf
+ * TRUE if the $data is coming from admin configuration, FALSE if it's from a URL arg.
+ *
+ * @return
+ * a Context object.
+ */
+function ctools_plugin_example_context_create_relcontext($empty, $data = NULL, $conf = FALSE) {
+ $context = new ctools_context('relcontext');
+ $context->plugin = 'relcontext';
+ if ($empty) {
+ return $context;
+ }
+ if ($conf) {
+ if (!empty($data)) {
+ $context->data = new stdClass();
+ // For this simple item we'll just create our data by stripping non-alpha and
+ // adding 'sample_relcontext_setting' to it.
+ $context->data->description = 'relcontext_from__' . preg_replace('/[^a-z]/i', '', $data['sample_relcontext_setting']);
+ $context->data->description .= '_from_configuration_sample_simplecontext_setting';
+ $context->title = t("Relcontext context from simplecontext");
+ return $context;
+ }
+ }
+ else {
+ // $data is coming from an arg - it's just a string.
+ // This is used for keyword.
+ $context->title = "relcontext_" . $data->data->description;
+ $context->argument = $data->argument;
+ // Make up a bogus context.
+ $context->data = new stdClass();
+ // For this simple item we'll just create our data by stripping non-alpha and
+ // prepend 'relcontext_' and adding '_created_from_from_simplecontext' to it.
+ $context->data->description = 'relcontext_' . preg_replace('/[^a-z]/i', '', $data->data->description);
+ $context->data->description .= '_created_from_simplecontext';
+ return $context;
+ }
+}
+
+function relcontext_settings_form($conf, $external = FALSE) {
+ $form = array();
+
+ $form['sample_relcontext_setting'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Relcontext setting'),
+ '#size' => 50,
+ '#description' => t('Just an example setting.'),
+ '#default_value' => !empty($conf['sample_relcontext_setting']) ? $conf['sample_relcontext_setting'] : '',
+ '#prefix' => '
',
+ '#suffix' => '
',
+ );
+ return $form;
+}
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc
new file mode 100644
index 0000000..e19a842
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc
@@ -0,0 +1,134 @@
+ t("Simplecontext"),
+ 'description' => t('A single "simplecontext" context, or data element.'),
+ 'context' => 'ctools_plugin_example_context_create_simplecontext', // func to create context
+ 'context name' => 'simplecontext',
+ 'settings form' => 'simplecontext_settings_form',
+ 'keyword' => 'simplecontext',
+
+ // Provides a list of items which are exposed as keywords.
+ 'convert list' => 'simplecontext_convert_list',
+ // Convert keywords into data.
+ 'convert' => 'simplecontext_convert',
+
+ 'placeholder form' => array(
+ '#type' => 'textfield',
+ '#description' => t('Enter some data to represent this "simplecontext".'),
+ ),
+);
+
+/**
+ * Create a context, either from manual configuration or from an argument on the URL.
+ *
+ * @param $empty
+ * If true, just return an empty context.
+ * @param $data
+ * If from settings form, an array as from a form. If from argument, a string.
+ * @param $conf
+ * TRUE if the $data is coming from admin configuration, FALSE if it's from a URL arg.
+ *
+ * @return
+ * a Context object/
+ */
+function ctools_plugin_example_context_create_simplecontext($empty, $data = NULL, $conf = FALSE) {
+ $context = new ctools_context('simplecontext');
+ $context->plugin = 'simplecontext';
+
+ if ($empty) {
+ return $context;
+ }
+
+ if ($conf) {
+ if (!empty($data)) {
+ $context->data = new stdClass();
+ // For this simple item we'll just create our data by stripping non-alpha and
+ // adding '_from_configuration_item_1' to it.
+ $context->data->item1 = t("Item1");
+ $context->data->item2 = t("Item2");
+ $context->data->description = preg_replace('/[^a-z]/i', '', $data['sample_simplecontext_setting']);
+ $context->data->description .= '_from_configuration_sample_simplecontext_setting';
+ $context->title = t("Simplecontext context from config");
+ return $context;
+ }
+ }
+ else {
+ // $data is coming from an arg - it's just a string.
+ // This is used for keyword.
+ $context->title = $data;
+ $context->argument = $data;
+ // Make up a bogus context
+ $context->data = new stdClass();
+ $context->data->item1 = t("Item1");
+ $context->data->item2 = t("Item2");
+
+ // For this simple item we'll just create our data by stripping non-alpha and
+ // adding '_from_simplecontext_argument' to it.
+ $context->data->description = preg_replace('/[^a-z]/i', '', $data);
+ $context->data->description .= '_from_simplecontext_argument';
+ $context->arg_length = strlen($context->argument);
+ return $context;
+ }
+}
+
+function simplecontext_settings_form($conf, $external = FALSE) {
+ if (empty($conf)) {
+ $conf = array(
+ 'sample_simplecontext_setting' => 'default simplecontext setting',
+ );
+ }
+ $form = array();
+ $form['sample_simplecontext_setting'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Setting for simplecontext'),
+ '#size' => 50,
+ '#description' => t('An example setting that could be used to configure a context'),
+ '#default_value' => $conf['sample_simplecontext_setting'],
+ '#prefix' => '
',
+ '#suffix' => '
',
+ );
+ return $form;
+}
+
+
+
+/**
+ * Provide a list of sub-keywords.
+ *
+ * This is used to provide keywords from the context for use in a content type,
+ * pane, etc.
+ */
+function simplecontext_convert_list() {
+ return array(
+ 'item1' => t('Item1'),
+ 'item2' => t('Item2'),
+ 'description' => t('Description'),
+ );
+}
+
+/**
+ * Convert a context into a string to be used as a keyword by content types, etc.
+ */
+function simplecontext_convert($context, $type) {
+ switch ($type) {
+ case 'item1':
+ return $context->data->item1;
+ case 'item2':
+ return $context->data->item2;
+ case 'description':
+ return $context->data->description;
+ }
+}
+
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/panels.pages.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/panels.pages.inc
new file mode 100644
index 0000000..d3022af
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/panels.pages.inc
@@ -0,0 +1,214 @@
+pid = 'new';
+ $page->did = 'new';
+ $page->name = 'ctools_plugin_example_demo_panel';
+ $page->title = 'Panels Plugin Example Demo Panel';
+ $page->access = array();
+ $page->path = 'demo_panel';
+ $page->load_flags = 1;
+ $page->css_id = '';
+ $page->arguments = array(
+ 0 =>
+ array(
+ 'name' => 'simplecontext_arg',
+ 'id' => 1,
+ 'default' => '404',
+ 'title' => '',
+ 'identifier' => 'Simplecontext arg',
+ 'keyword' => 'simplecontext',
+ ),
+ );
+ $page->relationships = array(
+ 0 =>
+ array(
+ 'context' => 'argument_simplecontext_arg_1',
+ 'name' => 'relcontext_from_simplecontext',
+ 'id' => 1,
+ 'identifier' => 'Relcontext from Simplecontext',
+ 'keyword' => 'relcontext',
+ ),
+ );
+ $page->no_blocks = '0';
+ $page->switcher_options = array();
+ $page->menu = '0';
+ $page->contexts = array();
+ $display = new ctools_display();
+ $display->did = 'new';
+ $display->layout = 'threecol_33_34_33_stacked';
+ $display->layout_settings = array();
+ $display->panel_settings = array();
+ $display->content = array();
+ $display->panels = array();
+ $pane = new stdClass();
+ $pane->pid = 'new-1';
+ $pane->panel = 'left';
+ $pane->type = 'custom';
+ $pane->shown = '1';
+ $pane->subtype = 'custom';
+ $pane->access = array();
+ $pane->configuration = array(
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => '"No Context Item"',
+ 'body' => 'The "no context item" content type is here to demonstrate that you can create a content_type that does not require a context. This is probably the same as just creating a custom php block on the fly, and might serve the same purpose.',
+ 'format' => '1',
+ );
+ $pane->cache = array();
+ $display->content['new-1'] = $pane;
+ $display->panels['left'][0] = 'new-1';
+ $pane = new stdClass();
+ $pane->pid = 'new-2';
+ $pane->panel = 'left';
+ $pane->type = 'no_context_item';
+ $pane->shown = '1';
+ $pane->subtype = 'description';
+ $pane->access = array();
+ $pane->configuration = array(
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'item1' => 'one',
+ 'item2' => 'two',
+ 'item3' => 'three',
+ );
+ $pane->cache = array();
+ $display->content['new-2'] = $pane;
+ $display->panels['left'][1] = 'new-2';
+ $pane = new stdClass();
+ $pane->pid = 'new-3';
+ $pane->panel = 'middle';
+ $pane->type = 'custom';
+ $pane->shown = '1';
+ $pane->subtype = 'custom';
+ $pane->access = array();
+ $pane->configuration = array(
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => 'Simplecontext',
+ 'body' => 'The "Simplecontext" content and content type demonstrate a very basic context and how to display it.
+
+ Simplecontext includes configuration, so it can get info from the config. It can also get its information to run from a simplecontext context, generated either from an arg to the panels page or via explicitly adding a context to the page.',
+ 'format' => '1',
+ );
+ $pane->cache = array();
+ $display->content['new-3'] = $pane;
+ $display->panels['middle'][0] = 'new-3';
+ $pane = new stdClass();
+ $pane->pid = 'new-4';
+ $pane->panel = 'middle';
+ $pane->type = 'simplecontext_item';
+ $pane->shown = '1';
+ $pane->subtype = 'description';
+ $pane->access = array(
+ 0 => '2',
+ 1 => '4',
+ );
+ $pane->configuration = array(
+ 'context' => 'argument_simplecontext_arg_1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'config_item_1' => 'simplecontext called from arg',
+ );
+ $pane->cache = array();
+ $display->content['new-4'] = $pane;
+ $display->panels['middle'][1] = 'new-4';
+ $pane = new stdClass();
+ $pane->pid = 'new-5';
+ $pane->panel = 'right';
+ $pane->type = 'custom';
+ $pane->shown = '1';
+ $pane->subtype = 'custom';
+ $pane->access = array();
+ $pane->configuration = array(
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => 'Relcontext',
+ 'body' => 'The relcontext content_type gets its data from a relcontext, which is an example of a relationship. This panel should be run with an argument like "/xxx", which allows the simplecontext to get its context, and then the relcontext is configured in this panel to get (create) its data from the simplecontext.',
+ 'format' => '1',
+ );
+ $pane->cache = array();
+ $display->content['new-5'] = $pane;
+ $display->panels['right'][0] = 'new-5';
+ $pane = new stdClass();
+ $pane->pid = 'new-6';
+ $pane->panel = 'right';
+ $pane->type = 'relcontext_item';
+ $pane->shown = '1';
+ $pane->subtype = 'description';
+ $pane->access = array();
+ $pane->configuration = array(
+ 'context' => 'relationship_relcontext_from_simplecontext_1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'config_item_1' => 'default1',
+ );
+ $pane->cache = array();
+ $display->content['new-6'] = $pane;
+ $display->panels['right'][1] = 'new-6';
+ $pane = new stdClass();
+ $pane->pid = 'new-7';
+ $pane->panel = 'top';
+ $pane->type = 'custom_php';
+ $pane->shown = '1';
+ $pane->subtype = 'custom_php';
+ $pane->access = array();
+ $pane->configuration = array(
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => '',
+ 'body' => '$arg = arg(1);
+ $arg0 = arg(0);
+ if (!$arg) {
+ $block->content = <<This page is intended to run with an arg and you don\'t have one.
+
+ Without an arg, the page doesn\'t have any context.
+ Please try something like "/$arg0/xxx"
+END;
+
+ $block->title = "This is intended to run with an argument";
+ } else {
+ $block->content = "The arg for this page is \'$arg\'";
+ }',
+ );
+ $pane->cache = array();
+ $display->content['new-7'] = $pane;
+ $display->panels['top'][0] = 'new-7';
+ $page->display = $display;
+ $page->displays = array();
+ $pages['ctools_plugin_example'] = $page;
+
+
+ return $pages;
+}
diff --git a/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc
new file mode 100644
index 0000000..6224621
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc
@@ -0,0 +1,50 @@
+ t("Relcontext from simplecontext"),
+ 'keyword' => 'relcontext',
+ 'description' => t('Adds a relcontext from existing simplecontext.'),
+ 'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'),
+ 'context' => 'ctools_relcontext_from_simplecontext_context',
+ 'settings form' => 'ctools_relcontext_from_simplecontext_settings_form',
+);
+
+/**
+ * Return a new context based on an existing context.
+ */
+function ctools_relcontext_from_simplecontext_context($context = NULL, $conf) {
+ // If unset it wants a generic, unfilled context, which is just NULL.
+ if (empty($context->data)) {
+ return ctools_context_create_empty('relcontext', NULL);
+ }
+
+ // You should do error-checking here.
+
+ // Create the new context from some element of the parent context.
+ // In this case, we'll pass in the whole context so it can be used to
+ // create the relcontext.
+ return ctools_context_create('relcontext', $context);
+}
+
+/**
+ * Settings form for the relationship.
+ */
+function ctools_relcontext_from_simplecontext_settings_form($conf) {
+ // We won't configure it in this case.
+ return array();
+}
+
diff --git a/sites/all/modules/contrib/ctools/drush/ctools.drush.inc b/sites/all/modules/contrib/ctools/drush/ctools.drush.inc
new file mode 100644
index 0000000..1862dbe
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/drush/ctools.drush.inc
@@ -0,0 +1,1017 @@
+ array('ctex'),
+ 'callback' => 'ctools_drush_export',
+ 'description' => 'Export multiple CTools exportable objects directly to code.',
+ 'arguments' => array(
+ 'module' => 'Name of your module.',
+ ),
+ 'options' => array(
+ 'subdir' => 'The name of the sub directory to create the module in. Defaults to ctools_export which will be placed into sites/all/modules.',
+ 'remove' => 'Remove existing files before writing, except the .module file.',
+ 'filter' => 'Filter the list of exportables by status. Available options are enabled, disabled, overridden, database, code and all. Defaults to enabled.',
+ 'tables' => 'Comma separated list of exportable table names to filter by.',
+ ),
+ 'examples' => array(
+ 'drush ctex export_module' => 'Export CTools exportables to a module called "export_module".',
+ 'drush ctex export_module --subdir=exports' => 'Same as above, but into the sites/all/modules/exports directory.',
+ 'drush ctex export_module --subdir=exports --remove' => 'Same as above, but automatically removing all files, except for the .module file.',
+ 'drush ctex --filter="views_view"' => 'Filter export selection to the views_view table only.',
+ ),
+ );
+
+ $items['ctools-export-info'] = array(
+ 'aliases' => array('ctei'),
+ 'callback' => 'ctools_drush_export_info',
+ 'description' => 'Show available CTools exportable objects.',
+ 'arguments' => array(),
+ 'options' => array(
+ 'format' => 'Display exportables info in a different format such as print_r, json, export. The default is to show in a tabular format.',
+ 'tables-only' => 'Only show list of exportable types/table names and not available objects.',
+ 'filter' => 'Filter the list of exportables by status. Available options are enabled, disabled, overridden, database, and code.',
+ 'module' => $module_text,
+ ),
+ 'examples' => array(
+ 'drush ctools-export-info' => 'View export info on all exportables.',
+ 'drush ctools-export-info views_view variable' => 'View export info for views_view and variable exportable types only.',
+ 'drush ctei --filter=enabled' => 'Show all enabled exportables.',
+ 'drush ctei views_view --filter=disabled' => 'Show all enabled exportables.',
+ 'drush ctei views_view --module=node' => 'Show all exportables provided by/on behalf of the node module.',
+ ),
+ );
+
+ $items['ctools-export-view'] = array(
+ 'aliases' => array('ctev'),
+ 'callback' => 'ctools_drush_export_op_command',
+ 'description' => 'View CTools exportable object code output.',
+ 'arguments' => array(
+ 'table name' => 'Base table of the exportable you want to view.',
+ 'machine names' => 'Space separated list of exportables you want to view.',
+ ),
+ 'options' => array(
+ 'indent' => 'The string to use for indentation when dispalying the exportable export code. Defaults to \'\'.',
+ 'no-colour' => 'Remove any colour formatting from export string output. Ideal if you are sending the output of this command to a file.',
+ 'module' => $module_text,
+ 'all' => $all_text,
+ ),
+ 'examples' => array(
+ 'drush ctools-export-view views_view' => 'View all views exportable objects.',
+ 'drush ctools-export-view views_view archive' => 'View default views archive view.',
+ ),
+ );
+
+ $items['ctools-export-revert'] = array(
+ 'aliases' => array('cter'),
+ 'callback' => 'ctools_drush_export_op_command',
+ 'description' => 'Revert CTools exportables from changes overridden in the database.',
+ 'arguments' => array(
+ 'table name' => 'Base table of the exportable you want to revert.',
+ 'machine names' => 'Space separated list of exportables you want to revert.',
+ ),
+ 'options' => array(
+ 'module' => $module_text,
+ 'all' => $all_text,
+ ),
+ 'examples' => array(
+ 'drush ctools-export-revert views_view' => 'Revert all overridden views exportable objects.',
+ 'drush ctools-export-revert views_view archive' => 'Revert overridden default views archive view.',
+ 'drush ctools-export-revert --all' => 'Revert all exportables on the system.',
+ ),
+ );
+
+ $items['ctools-export-enable'] = array(
+ 'aliases' => array('ctee'),
+ 'callback' => 'ctools_drush_export_op_command',
+ 'description' => 'Enable CTools exportables.',
+ 'arguments' => array(
+ 'table name' => 'Base table of the exportable you want to enable.',
+ 'machine names' => 'Space separated list of exportables you want to enable.',
+ ),
+ 'options' => array(
+ 'module' => $module_text,
+ 'all' => $all_text,
+ ),
+ 'examples' => array(
+ 'drush ctools-export-enable views_view' => 'Enable all overridden views exportable objects.',
+ 'drush ctools-export-enable views_view archive' => 'Enable overridden default views archive view.',
+ ),
+ );
+
+ $items['ctools-export-disable'] = array(
+ 'aliases' => array('cted'),
+ 'callback' => 'ctools_drush_export_op_command',
+ 'description' => 'Disable CTools exportables.',
+ 'arguments' => array(
+ 'table name' => 'Base table of the exportable you want to disable.',
+ 'machine names' => 'Space separated list of exportables you want to disable.',
+ ),
+ 'options' => array(
+ 'module' => $module_text,
+ 'all' => $all_text,
+ ),
+ 'examples' => array(
+ 'drush ctools-export-disable views_view' => 'Disable all overridden views exportable objects.',
+ 'drush ctools-export-disable views_view archive' => 'Disable overridden default views archive view.',
+ ),
+ );
+
+ return $items;
+}
+
+/**
+ * Implementation of hook_drush_help().
+ */
+function ctools_drush_help($section) {
+ switch ($section) {
+ case 'meta:ctools:title':
+ return dt('CTools commands');
+ case 'meta:entity:summary':
+ return dt('CTools drush commands.');
+ }
+}
+
+/**
+ * Drush callback: export
+ */
+function ctools_drush_export($module = 'foo') {
+ $error = FALSE;
+ if (preg_match('@[^a-z_]+@', $module)) {
+ $error = dt('The name of the module must contain only lowercase letters and underscores') . '.';
+ drush_log($error, 'error');
+ return;
+ }
+
+ // Filter by tables.
+ $tables = _ctools_drush_explode_options('tables');
+
+ // Check status.
+ $filter = drush_get_option('filter', FALSE);
+ if (empty($filter)) {
+ drush_set_option('filter', 'enabled');
+ }
+
+ // Selection.
+ $options = array('all' => dt('Export everything'), 'select' => dt('Make selection'));
+ $selection = drush_choice($options, dt('Select to proceed'));
+
+ if (!$selection) {
+ return;
+ }
+
+ // Present the selection screens.
+ if ($selection == 'select') {
+ $selections = _ctools_drush_selection_screen($tables);
+ }
+ else {
+ $info = _ctools_drush_export_info($tables, TRUE);
+ $selections = $info['exportables'];
+ }
+
+ // Subdirectory.
+ $dest_exists = FALSE;
+ $subdir = drush_get_option('subdir', 'ctools_export');
+ $dest = 'sites/all/modules/' . $subdir . '/' . $module;
+
+ // Overwriting files can be set with 'remove' argument.
+ $remove = drush_get_option('remove', FALSE);
+
+ // Check if folder exists.
+ if (file_exists($dest)) {
+ $dest_exists = TRUE;
+ if ($remove) {
+ if (drush_confirm(dt('All files except for the .info and .module files in !module will be removed. You can choose later if you want to overwrite these files as well. Are you sure you want to proceed ?', array('!module' => $module)))) {
+ $remove = TRUE;
+ drush_log(dt('Files will be removed'), 'success');
+ }
+ else {
+ drush_log(dt('Export aborted.'), 'success');
+ return;
+ }
+ }
+ }
+
+ // Remove files (except for the .module file) if the destination folder exists.
+ if ($remove && $dest_exists) {
+ _ctools_drush_file_delete($dest);
+ }
+
+ // Create new dir if needed.
+ if (!$dest_exists) {
+ if (!file_exists('sites/all/modules/' . $subdir)) {
+ drush_mkdir('sites/all/modules/' . $subdir);
+ }
+ }
+
+ // Create destination directory.
+ drush_mkdir($dest);
+
+ // Load bulk export module.
+ module_load_include('module', 'bulk_export');
+
+ // Create options and call Bulk export function.
+ // We create an array, because maybe in the future we can pass in more
+ // options to the export function (pre-selected modules and/or exportables).
+ $options = array(
+ 'name' => $module,
+ 'selections' => $selections,
+ );
+ $files = bulk_export_export(TRUE, $options);
+
+ $alter = array(
+ 'module' => $module,
+ 'files' => $files,
+ );
+ // Let other drush commands alter the files.
+ drush_command_invoke_all_ref('drush_ctex_files_alter', $alter);
+ $files = $alter['files'];
+
+ // Start writing.
+ if (is_array($files)) {
+ foreach ($files as $base_file => $data) {
+ $filename = $dest . '/' . $base_file;
+ // Extra check for .module file.
+ if ($base_file == ($module . '.module' || $module . '.info') && file_exists($filename)) {
+ if (!drush_confirm(dt('Do you want to overwrite !module_file', array('!module_file' => $base_file)))) {
+ drush_log(dt('Writing of !filename skipped. This is the code that was supposed to be written:', array('!filename' => $filename)), 'success');
+ drush_print('---------');
+ drush_print(shellColours::getColouredOutput("\n$data", 'light_green'));
+ drush_print('---------');
+ continue;
+ }
+ }
+ if (file_put_contents($filename, $data)) {
+ drush_log(dt('Succesfully written !filename', array('!filename' => $filename)), 'success');
+ }
+ else {
+ drush_log(dt('Error writing !filename', array('!filename' => $filename)), 'error');
+ }
+ }
+ }
+ else {
+ drush_log(dt('No files were found to be written.'), 'error');
+ }
+}
+
+/**
+ * Helper function to select the exportables. By default, all exportables
+ * will be selected, so it will be easier to deselect them.
+ *
+ * @param $tables
+ */
+function _ctools_drush_selection_screen(array $tables = array()) {
+ $selections = $build = array();
+ $files = system_rebuild_module_data();
+
+ $selection_number = 0;
+
+ $info = _ctools_drush_export_info($tables, TRUE);
+ $exportables = $info['exportables'];
+ $schemas = $info['schemas'];
+
+ $export_tables = array();
+
+ foreach (array_keys($exportables) as $table) {
+ natcasesort($exportables[$table]);
+ $export_tables[$table] = $files[$schemas[$table]['module']]->info['name'] . ' (' . $table . ')';
+ }
+
+ foreach ($export_tables as $table => $table_title) {
+ if (!empty($exportables[$table])) {
+ $table_count = count($exportables[$table]);
+ $selection_number += $table_count;
+ foreach ($exportables[$table] as $key => $title) {
+ $build[$table]['title'] = $table_title;
+ $build[$table]['items'][$key] = $title;
+ $build[$table]['count'] = $table_count;
+ $selections[$table][$key] = $key;
+ }
+ }
+ }
+
+ drush_print(dt('Number of exportables selected: !number', array('!number' => $selection_number)));
+ drush_print(dt('By default all exportables are selected. Select a table to deselect exportables. Select "cancel" to start writing the files.'));
+
+ // Let's go into a loop.
+ $return = FALSE;
+ while (!$return) {
+
+ // Present the tables choice.
+ $table_rows = array();
+ foreach ($build as $table => $info) {
+ $table_rows[$table] = $info['title'] . ' (' . $info['count'] . ')';
+ }
+ $table_choice = drush_choice($table_rows, dt('Select a table. Select cancel to start writing files.'));
+
+ // Bail out.
+ if (!$table_choice) {
+ drush_log(dt('Selection mode done, starting to write the files.'), 'notice');
+ $return = TRUE;
+ return $selections;
+ }
+
+ // Present the exportables choice, using the drush_choice_multiple.
+ $max = count($build[$table_choice]['items']);
+ $exportable_rows = array();
+ foreach ($build[$table_choice]['items'] as $key => $title) {
+ $exportable_rows[$key] = $title;
+ }
+ drush_print(dt('Exportables from !table', array('!table' => $build[$table_choice]['title'])));
+ $multi_select = drush_choice_multiple($exportable_rows, $selections[$table_choice], dt('Select exportables.'), '!value', '!value (selected)', 0, $max);
+
+ // Update selections.
+ if (is_array($multi_select)) {
+ $build[$table_choice]['count'] = count($multi_select);
+ $selections[$table_choice] = array();
+ foreach ($multi_select as $key) {
+ $selections[$table_choice][$key] = $key;
+ }
+ }
+ }
+}
+
+/**
+ * Delete files in a directory, keeping the .module and .info files.
+ *
+ * @param $path
+ * Path to directory in which to remove files.
+ */
+function _ctools_drush_file_delete($path) {
+ if (is_dir($path)) {
+ $files = new DirectoryIterator($path);
+ foreach ($files as $fileInfo) {
+ if (!$fileInfo->isDot() && !in_array($fileInfo->getExtension(), array('module', 'info'))) {
+ unlink($fileInfo->getPathname());
+ }
+ }
+ }
+}
+
+/**
+ * Drush callback: Export info.
+ *
+ * @params $table_names
+ * Each argument will be taken as a CTools exportable table name.
+ */
+function ctools_drush_export_info() {
+ // Collect array of table names from args.
+ $table_names = func_get_args();
+
+ // Get format option to allow for alternative output.
+ $format = drush_get_option('format', FALSE);
+ $tables_only = drush_get_option('tables-only', FALSE);
+ $filter = drush_get_option('filter', FALSE);
+ $export_module = drush_get_option('module', FALSE);
+
+ $load = (bool) $filter || $export_module;
+
+ // Get info on these tables, or all tables if none specified.
+ $info = _ctools_drush_export_info($table_names, $load);
+ $schemas = $info['schemas'];
+ $exportables = $info['exportables'];
+
+ if (empty($exportables)) {
+ drush_log(dt('There are no exportables available.'), 'warning');
+ return;
+ }
+
+ // Filter by export module.
+ if (is_string($export_module)) {
+ $exportables = _ctools_drush_export_module_filter($exportables, $export_module);
+ }
+
+ if (empty($exportables)) {
+ drush_log(dt('There are no exportables matching this criteria.'), 'notice');
+ return;
+ }
+
+ $exportable_counts = _ctools_drush_count_exportables($exportables);
+
+ // Only use array keys if --tables-only option is set.
+ if ($tables_only) {
+ $exportables = array_keys($exportables);
+ }
+
+ // Use format from --format option if it's present, and send to drush_format.
+ if ($format) {
+ // Create array with all exportable info and counts in one.
+ $output = array(
+ 'exportables' => $exportables,
+ 'count' => $exportable_counts,
+ );
+ drush_print(drush_format($output, NULL, $format));
+ }
+ // Build a tabular output as default.
+ else {
+ $header = $tables_only ? array() : array(dt('Module'), dt('Base table'), dt('Exportables'));
+ $rows = array();
+ foreach ($exportables as $table => $info) {
+ if (is_array($info)) {
+ $row = array(
+ $schemas[$table]['module'],
+ $table,
+ // Machine name is better for this?
+ shellColours::getColouredOutput(implode("\n", array_keys($info)), 'light_green') . "\n",
+ );
+ $rows[] = $row;
+ }
+ else {
+ $rows[] = array($info);
+ }
+ }
+ if (!empty($rows)) {
+ drush_print("\n");
+ array_unshift($rows, $header);
+ drush_print_table($rows, TRUE, array(20, 20));
+ drush_print(dt('Total exportables found: !total', array('!total' => $exportable_counts['total'])));
+ foreach ($exportable_counts['exportables'] as $table_name => $count) {
+ drush_print(dt('!table_name (!count)', array('!table_name' => $table_name, '!count' => $count)), 2);
+ }
+ drush_print("\n");
+ }
+ }
+}
+/**
+ * Drush callback: Acts as the hub for all op commands to keep
+ * all arg handling etc in one place.
+ */
+function ctools_drush_export_op_command() {
+ // Get all info for the current drush command.
+ $command = drush_get_command();
+ $op = '';
+
+ switch ($command['command']) {
+ case 'ctools-export-view':
+ $op = 'view';
+ break;
+ case 'ctools-export-revert':
+ // Revert is same as deleting. As any objects in the db are deleted.
+ $op = 'delete';
+ break;
+ case 'ctools-export-enable':
+ $op = 'enable';
+ break;
+ case 'ctools-export-disable':
+ $op = 'disable';
+ break;
+ }
+
+ if (!$op) {
+ return;
+ }
+
+ if (drush_get_option('all', FALSE)) {
+ $info = _ctools_drush_export_info('', TRUE);
+ $exportable_info = $info['exportables'];
+
+ $all = drush_confirm(dt('Are you sure you would like to !op all exportables on the system?',
+ array('!op' => _ctools_drush_export_op_alias($op))));
+
+ if ($all && $exportable_info) {
+ foreach ($exportable_info as $table => $exportables) {
+ if (!empty($exportables)) {
+ ctools_drush_export_op($op, $table, $exportables);
+ }
+ }
+ }
+ }
+ else {
+ $args = func_get_args();
+ // Table name should always be first arg...
+ $table_name = array_shift($args);
+ // Any additional args are assumed to be exportable names.
+ $object_names = $args;
+
+ // Return any exportables based on table name, object names, options.
+ $exportables = _ctools_drush_export_op_command_logic($op, $table_name, $object_names);
+
+ if ($exportables) {
+ ctools_drush_export_op($op, $table_name, $exportables);
+ }
+ }
+}
+
+/**
+ * Iterate through exportable object names, load them, and pass each
+ * object to the correct op function.
+ *
+ * @param $op
+ * @param $table_name
+ * @param $exportables
+ *
+ */
+function ctools_drush_export_op($op = '', $table_name = '', $exportables = NULL) {
+ $objects = ctools_export_crud_load_multiple($table_name, array_keys($exportables));
+
+ $function = '_ctools_drush_export_' . $op;
+ if (function_exists($function)) {
+ foreach ($objects as $object) {
+ $function($table_name, $object);
+ }
+ }
+ else {
+ drush_log(dt('CTools CRUD function !function doesn\'t exist.',
+ array('!function' => $function)), 'error');
+ }
+}
+
+/**
+ * Helper function to abstract logic for selecting exportable types/objects
+ * from individual commands as they will all share this same error
+ * handling/arguments for returning list of exportables.
+ *
+ * @param $table_name
+ * @param $object_names
+ *
+ * @return
+ * Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not.
+ */
+function _ctools_drush_export_op_command_logic($op = '', $table_name = NULL, array $object_names = array()) {
+ if (!$table_name) {
+ drush_log(dt('Exportable table name empty. Use the --all command if you want to perform this operation on all tables.'), 'error');
+ return FALSE;
+ }
+
+ // Get export info based on table name.
+ $info = _ctools_drush_export_info(array($table_name), TRUE);
+
+ if (!isset($info['exportables'][$table_name])) {
+ drush_log(dt('Exportable table name not found.'), 'error');
+ return FALSE;
+ }
+
+ $exportables = &$info['exportables'];
+
+ if (empty($object_names)) {
+ $all = drush_confirm(dt('No object names entered. Would you like to try and !op all exportables of type !type',
+ array('!op' => _ctools_drush_export_op_alias($op), '!type' => $table_name)));
+ if (!$all) {
+ drush_log(dt('Command cancelled'), 'success');
+ return FALSE;
+ }
+ }
+ else {
+ // Iterate through object names and check they exist in exportables array.
+ // Log error and unset them if they don't.
+ foreach ($object_names as $object_name) {
+ if (!isset($exportables[$table_name][$object_name])) {
+ drush_log(dt('Invalid exportable: !exportable', array('!exportable' => $object_name)), 'error');
+ unset($object_names[$table_name][$object_name]);
+ }
+ }
+ // Iterate through exportables to get just a list of selected ones.
+ foreach (array_keys($exportables[$table_name]) as $exportable) {
+ if (!in_array($exportable, $object_names)) {
+ unset($exportables[$table_name][$exportable]);
+ }
+ }
+ }
+
+ $export_module = drush_get_option('module', FALSE);
+
+ if (is_string($export_module)) {
+ $exportables = _ctools_drush_export_module_filter($exportables, $export_module);
+ }
+
+ return $exportables[$table_name];
+}
+
+/**
+ * Return array of CTools exportable info based on available tables returned from
+ * ctools_export_get_schemas().
+ *
+ * @param $table_names
+ * Array of table names to return.
+ * @param $load
+ * (bool) should ctools exportable objects be loaded for each type.
+ * The default behaviour will load just a list of exportable names.
+ *
+ * @return
+ * Nested arrays of available exportables, keyed by table name.
+ */
+function _ctools_drush_export_info(array $table_names = array(), $load = FALSE) {
+ ctools_include('export');
+ // Get available schemas that declare exports.
+ $schemas = ctools_export_get_schemas(TRUE);
+ $exportables = array();
+
+ if (!empty($schemas)) {
+ // Remove types we don't want, if any.
+ if (!empty($table_names)) {
+ foreach (array_keys($schemas) as $table_name) {
+ if (!in_array($table_name, $table_names)) {
+ unset($schemas[$table_name]);
+ }
+ }
+ }
+ // Load array of available exportables for each schema.
+ foreach ($schemas as $table_name => $schema) {
+ // Load all objects.
+ if ($load) {
+ $exportables[$table_name] = ctools_export_crud_load_all($table_name);
+ }
+ // Get a list of exportable names.
+ else {
+ if (!empty($schema['export']['list callback']) && function_exists($schema['export']['list callback'])) {
+ $exportables[$table_name] = $schema['export']['list callback']();
+ }
+ else {
+ $exportables[$table_name] = ctools_export_default_list($table_name, $schema);
+ }
+ }
+ }
+ }
+
+ if ($load) {
+ $filter = drush_get_option('filter', FALSE);
+ $exportables = _ctools_drush_filter_exportables($exportables, $filter);
+ }
+
+ return array('exportables' => $exportables, 'schemas' => $schemas);
+}
+
+/*
+ * View a single object.
+ *
+ * @param $table_name
+ * @param $object
+ */
+function _ctools_drush_export_view($table_name, $object) {
+ $indent = drush_get_option('indent', '');
+ $no_colour = drush_get_option('no-colour', FALSE);
+ $export = ctools_export_crud_export($table_name, $object, $indent);
+ if ($no_colour) {
+ drush_print("\n$export");
+ }
+ else {
+ drush_print(shellColours::getColouredOutput("\n$export", 'light_green'));
+ }
+}
+
+/*
+ * Revert a single object.
+ *
+ * @param $table_name
+ * @param $object
+ */
+function _ctools_drush_export_delete($table_name, $object) {
+ $name = _ctools_drush_get_export_name($table_name, $object);
+
+ if (_ctools_drush_object_is_overridden($object)) {
+ // Remove from db.
+ ctools_export_crud_delete($table_name, $object);
+ drush_log("Reverted object: $name", 'success');
+ }
+ else {
+ drush_log("Nothing to revert for: $name", 'notice');
+ }
+}
+
+/*
+ * Enable a single object.
+ *
+ * @param $table_name
+ * @param $object
+ */
+function _ctools_drush_export_enable($table_name, $object) {
+ $name = _ctools_drush_get_export_name($table_name, $object);
+
+ if (_ctools_drush_object_is_disabled($object)) {
+
+ // Enable object.
+ ctools_export_crud_enable($table_name, $object);
+ drush_log("Enabled object: $name", 'success');
+ }
+ else {
+ drush_log("$name is already Enabled", 'notice');
+ }
+}
+
+/*
+ * Disable a single object.
+ *
+ * @param $table_name
+ * @param $object
+ */
+function _ctools_drush_export_disable($table_name, $object) {
+ $name = _ctools_drush_get_export_name($table_name, $object);
+
+ if (!_ctools_drush_object_is_disabled($object)) {
+ // Disable object.
+ ctools_export_crud_disable($table_name, $object);
+ drush_log("Disabled object: $name", 'success');
+ }
+ else {
+ drush_log("$name is already disabled", 'notice');
+ }
+}
+
+/**
+ * Filter a nested array of exportables by export module.
+ *
+ * @param $exportables array
+ * Passed by reference. A nested array of exportables, keyed by table name.
+ * @param $export_module string
+ * The name of the export module providing the exportable.
+ */
+function _ctools_drush_export_module_filter($exportables, $export_module) {
+ $module_list = module_list();
+
+ if (!isset($module_list[$export_module])) {
+ drush_log(dt('Invalid export module: !export_module', array('!export_module' => $export_module)), 'error');
+ }
+
+ foreach ($exportables as $table => $objects) {
+ foreach ($objects as $key => $object) {
+ if (empty($object->export_module) || ($object->export_module !== $export_module)) {
+ unset($exportables[$table][$key]);
+ }
+ }
+ }
+
+ return array_filter($exportables);
+}
+
+/**
+ * Gets the key for an exportable type.
+ *
+ * @param $table_name
+ * The exportable table name.
+ * @param $object
+ * The exportable object.
+ *
+ * @return string
+ * The key defined in the export schema data.
+ */
+function _ctools_drush_get_export_name($table_name, $object) {
+ $info = _ctools_drush_export_info(array($table_name));
+ $key = $info['schemas'][$table_name]['export']['key'];
+ return $object->{$key};
+}
+
+/**
+ * Determine if an object is disabled.
+ *
+ * @param $object
+ * Loaded CTools exportable object.
+ *
+ * @return TRUE or FALSE
+ */
+function _ctools_drush_object_is_disabled($object) {
+ return (isset($object->disabled) && ($object->disabled == TRUE)) ? TRUE : FALSE;
+}
+
+/**
+ * Determine if an object is enabled.
+ *
+ * @see _ctools_drush_object_is_disabled.
+ */
+function _ctools_drush_object_is_enabled($object) {
+ return (empty($object->disabled)) ? TRUE : FALSE;
+}
+
+/**
+ * Determine if an object is overridden.
+ */
+function _ctools_drush_object_is_overridden($object) {
+ $status = EXPORT_IN_CODE + EXPORT_IN_DATABASE;
+ return ($object->export_type == $status) ? TRUE : FALSE;
+}
+
+/**
+ * Determine if an object is not overridden.
+ */
+function _ctools_drush_object_is_not_overridden($object) {
+ $status = EXPORT_IN_CODE + EXPORT_IN_DATABASE;
+ return ($object->export_type == $status) ? FALSE : TRUE;
+}
+
+/**
+ * Determine if an object is only in the db.
+ */
+function _ctools_drush_object_is_db_only($object) {
+ return ($object->export_type == EXPORT_IN_DATABASE) ? TRUE : FALSE;
+}
+
+/**
+ * Determine if an object is not in the db.
+ */
+function _ctools_drush_object_is_not_db_only($object) {
+ return ($object->export_type == EXPORT_IN_DATABASE) ? FALSE : TRUE;
+}
+
+/**
+ * Determine if an object is a code only default.
+ */
+function _ctools_drush_object_is_code_only($object) {
+ return ($object->export_type == EXPORT_IN_CODE) ? TRUE : FALSE;
+}
+
+/**
+ * Determine if an object is not a code only default.
+ */
+function _ctools_drush_object_is_not_code_only($object) {
+ return ($object->export_type == EXPORT_IN_CODE) ? FALSE : TRUE;
+}
+
+/**
+ * Return an array of count information based on exportables array.
+ *
+ * @param $exportables
+ * Array of exportables to count.
+ *
+ * @return
+ * Array of count data containing the following:
+ * 'total' - A total count of all exportables.
+ * 'exportables' - An array of exportable counts per table.
+ */
+function _ctools_drush_count_exportables($exportables) {
+ $count = array('exportables' => array());
+
+ foreach ($exportables as $table => $objects) {
+ // Add the object count for each table.
+ $count['exportables'][$table] = count($objects);
+ }
+
+ // Once all tables have been counted, total these up.
+ $count['total'] = array_sum($count['exportables']);
+
+ return $count;
+}
+
+/**
+ * Filters a collection of exportables based on filters.
+ *
+ * @param $exportables
+ * @param $filter
+ */
+function _ctools_drush_filter_exportables($exportables, $filter) {
+ $eval = FALSE;
+
+ if (is_string($filter)) {
+ switch ($filter) {
+ // Show enabled exportables only.
+ case 'enabled':
+ $eval = '_ctools_drush_object_is_disabled';
+ break;
+ // Show disabled exportables only.
+ case 'disabled':
+ $eval = '_ctools_drush_object_is_enabled';
+ break;
+ // Show overridden exportables only.
+ case 'overridden':
+ $eval = '_ctools_drush_object_is_not_overridden';
+ break;
+ // Show database only exportables.
+ case 'database':
+ $eval = '_ctools_drush_object_is_not_db_only';
+ break;
+ // Show code only exportables.
+ case 'code':
+ $eval = '_ctools_drush_object_is_not_code_only';
+ break;
+ // Do nothing.
+ case 'all':
+ break;
+ default:
+ drush_log(dt('Invalid filter option. Available options are: enabled, disabled, overridden, database, and code.'), 'error');
+ return;
+ }
+
+ if ($eval) {
+ foreach ($exportables as $table => $objects) {
+ foreach ($objects as $key => $object) {
+ if ($eval($object)) {
+ unset($exportables[$table][$key]);
+ }
+ }
+ }
+ }
+ }
+
+ return array_filter($exportables);
+}
+
+/**
+ * Return an alias for an op, that will be used to show as output.
+ * For now, this is mainly necessary for delete => revert alias.
+ *
+ * @param $op
+ * The op name. Such as 'enable', 'disable', or 'delete'.
+ *
+ * @return
+ * The matched alias value or the original $op passed in if not found.
+ */
+function _ctools_drush_export_op_alias($op) {
+ $aliases = array(
+ 'delete' => 'revert',
+ );
+
+ if (isset($aliases[$op])) {
+ return $aliases[$op];
+ }
+
+ return $op;
+}
+
+/**
+ * Convert the drush options from a csv list into an array.
+ *
+ * @param $drush_option
+ * The drush option name to invoke.
+ *
+ * @return
+ * Exploded array of options.
+ */
+function _ctools_drush_explode_options($drush_option) {
+ $options = drush_get_option($drush_option, array());
+ if (!empty($options)) {
+ $options = explode(',', $options);
+ return array_map('trim', $options);
+ }
+
+ return $options;
+}
+
+/**
+ * Class to deal with wrapping output strings with
+ * colour formatting for the shell.
+ */
+class shellColours {
+
+ private static $foreground_colours = array(
+ 'black' => '0;30',
+ 'dark_gray' => '1;30',
+ 'blue' => '0;34',
+ 'light_blue' => '1;34',
+ 'green' => '0;32',
+ 'light_green' => '1;32',
+ 'cyan' => '0;36',
+ 'light_cyan' => '1;36',
+ 'red' => '0;31',
+ 'light_red' => '1;31',
+ 'purple' => '0;35',
+ 'light_purple' => '1;35',
+ 'brown' => '0;33',
+ 'yellow' => '1;33',
+ 'light_gray' => '0;37',
+ 'white' => '1;37',
+ );
+
+ private static $background_colours = array(
+ 'black' => '40',
+ 'red' => '41',
+ 'green' => '42',
+ 'yellow' => '43',
+ 'blue' => '44',
+ 'magenta' => '45',
+ 'cyan' => '46',
+ 'light_gray' => '47',
+ );
+
+ private function __construct() {}
+
+ // Returns coloured string
+ public static function getColouredOutput($string, $foreground_colour = NULL, $background_colour = NULL) {
+ $coloured_string = "";
+
+ // Check if given foreground colour found
+ if ($foreground_colour) {
+ $coloured_string .= "\033[" . self::$foreground_colours[$foreground_colour] . "m";
+ }
+ // Check if given background colour found
+ if ($background_colour) {
+ $coloured_string .= "\033[" . self::$background_colours[$background_colour] . "m";
+ }
+
+ // Add string and end colouring
+ $coloured_string .= $string . "\033[0m";
+
+ return $coloured_string;
+ }
+
+ // Returns all foreground colour names
+ public static function getForegroundColours() {
+ return array_keys(self::$foreground_colours);
+ }
+
+ // Returns all background colour names
+ public static function getBackgroundColours() {
+ return array_keys(self::$background_colours);
+ }
+
+} // shellColours
diff --git a/sites/all/modules/contrib/ctools/help/about.html b/sites/all/modules/contrib/ctools/help/about.html
new file mode 100644
index 0000000..30b64c2
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/about.html
@@ -0,0 +1,29 @@
+
The Chaos Tool Suite is a series of tools for developers to make code that I've found to be very useful to Views and Panels more readily available. Certain methods of doing things, particularly with AJAX, exportable objects and a plugin system, are proving to be ideas that are useful outside of just Views and Panels. This module does not offer much directly to the end user, but instead, creates a library for other modules to use. If you are an end user and some module asked you to install the CTools suite, then this is far as you really need to go. If you're a developer and are interested in these tools, read on!
The plugins tool allows a module to allow other modules (and themes!) to provide plugins which provide some kind of functionality or some kind of task. For example, in Panels there are several types of plugins: Content types (which are like blocks), layouts (which are page layouts) and styles (which can be used to style a panel). Each plugin is represented by a .inc file, and the functionality they offer can differ wildly.
Context is the idea that the objects that are used in page generation have more value than simply creating a single piece of output. Instead, contexts can be used to create multiple pieces of content that can all be put onto the page. Additionally, contexts can be used to derive other contexts via relationships, such as determining the node author and displaying data about the new context.
AJAX (also known as AHAH) is a method of allowing the browser and the server to communicate without requiring a page refresh. It can be used to create complicated interactive forms, but it is somewhat difficult to integrate into Drupal's Form API. These tools make it easier to accomplish this goal. In addition, CTools provides a few other javascript helpers, such as a modal dialog, a collapsible div, a simple dropdown and dependent checkboxes.
Drupal comes with a fantastic array of tools to ensure HTML is safe to output but does not contain any similar tools for CSS. CTools provides a small tool to sanitize CSS, so user-input CSS code can still be safely used. It also provides a method for caching CSS for better performance.
Views and Panels both use objects that can either be in code or in the database, and the objects can be exported into a piece of PHP code, so they can be moved from site to site or out of the database entirely. This library abstracts that functionality, so other modules can use this same concept for their data.
Drupal 6's FAPI really improved over Drupal 5, and made a lot of things possible. Still, it missed a few items that were needed to make form wizards and truly dynamic AJAX forms possible. CTools includes a replacement for drupal_get_form() that has a few more options and allows the caller to examine the $form_state once the form has completed.
Finally! An easy way to have form wizards, which is any 'form' that is actually a string of forms that build up to a final conclusion. The form wizard supports a single entry point, the ability to choose whether or not the user can go forward/back/up on the form and easy callbacks to handle the difficult job of dealing with data in between forms.
For normal forms, all of the data needed for an object is stored in the form so that the browser handles a lot of the work. For multi-step and ajax forms, however, this is impractical, and letting the browser store data can be insecure. The object cache provides a non-volatile location to store temporary data while the form is being worked on. This is much safer than the standard Drupal caching mechanism, which is volatile, meaning it can be cleared at any time and any system using it must be capable of recreating the data that was there. This system also allows for object locking, since any object which has an item in the cache from another person can be assumed to be 'locked for editing'.
+
diff --git a/sites/all/modules/contrib/ctools/help/ajax.html b/sites/all/modules/contrib/ctools/help/ajax.html
new file mode 100644
index 0000000..e69de29
diff --git a/sites/all/modules/contrib/ctools/help/collapsible-div.html b/sites/all/modules/contrib/ctools/help/collapsible-div.html
new file mode 100644
index 0000000..b9b6d9c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/collapsible-div.html
@@ -0,0 +1 @@
+
To be written.
diff --git a/sites/all/modules/contrib/ctools/help/context-access.html b/sites/all/modules/contrib/ctools/help/context-access.html
new file mode 100644
index 0000000..95a8d7f
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/context-access.html
@@ -0,0 +1,12 @@
+
Access plugins allow context based access control to pages.
+
'title' => Title of the plugin
+ 'description' => Description of the plugin
+ 'callback' => callback to see if there is access is available. params: $conf, $contexts, $account
+ 'required context' => zero or more required contexts for this access plugin
+ 'default' => an array of defaults or a callback giving defaults
+ 'settings form' => settings form. params: &$form, &$form_state, $conf
+ settings form validate
+ settings form submit
+
+
+
Warning: your settings array will be stored in the meny system to reduce loads, so be trim.
\ No newline at end of file
diff --git a/sites/all/modules/contrib/ctools/help/context-arguments.html b/sites/all/modules/contrib/ctools/help/context-arguments.html
new file mode 100644
index 0000000..5c479ae
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/context-arguments.html
@@ -0,0 +1,14 @@
+
Arguments create a context from external input, which is assumed to be a string as though it came from a URL element.
+
+
'title' => title
+ 'description' => Description
+ 'keyword' => Default keyword for the context
+ 'context' => Callback to create the context. Params: $arg = NULL, $conf = NULL, $empty = FALSE
+ 'default' => either an array of default settings or a string which is a callback or null to not use.
+ 'settings form' => params: $form, $form_state, $conf -- gets the whole form. Should put anything it wants to keep automatically in $form['settings']
+ 'settings form validate' => params: $form, $form_state
+ 'settings form submit' => params: $form, $form_state
+ 'criteria form' => params: $form, &$form_state, $conf, $argument, $id -- gets the whole argument. It should only put form widgets in $form[$id]. $conf may not be properly initialized so always guard against this due to arguments being changed and handlers not being updated to match.
+ + submit + validate
+ 'criteria select' => returns true if the selected criteria matches the context. params: $context, $conf
+
diff --git a/sites/all/modules/contrib/ctools/help/context-content.html b/sites/all/modules/contrib/ctools/help/context-content.html
new file mode 100644
index 0000000..c1c6a35
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/context-content.html
@@ -0,0 +1,157 @@
+
The CTools pluggable content system provides various pieces of content as discrete bits of data that can be added to other applications, such as Panels or Dashboard via the UI. Whatever the content is added to stores the configuration for that individual piece of content, and provides this to the content.
+
+
Each content type plugin will be contained in a .inc file, with subsidiary files, if necessary, in or near the same directory. Each content type consists of some information and one or more subtypes, which all use the same renderer. Subtypes are considered to be instances of the type. For example, the 'views' content type would have each view in the system as a subtype. Many content types will have exactly one subtype.
+
+
Because the content and forms can be provided via ajax, the plugin also provides a list of CSS and JavaScript information that should be available on whatever page the content or forms may be AJAXed onto.
+
+
For the purposes of selecting content from the UI, each content subtype will have the following information:
+
+
+
A title
+
A short description
+
A category [Do we want to add hierarchy categories? Do we want category to be more than just a string?]
+
An icon [do we want multiple icons? This becomes a hefty requirement]
+
+
+
Each piece of content provides one or more configuration forms, if necessary, and the system that includes the content will handle the data storage. These forms can be provided in sequence as wizards or as extra forms that can be accessed through advanced administration.
+
+
The plugin for a content type should contain:
+
+
+
title
+
For use on the content permissions screen.
+
content types
+
Either an array of content type definitions, or a callback that will return content type definitions. This callback will get the plugin definition as an argument.
+
+
content type
+
[Optional] Provide a single content type definition. This is only necessary if content types might be intensive.
+
+
render callback
+
The callback to render the content. Parameters:
+
+
$subtype
+
The name of the subtype being rendered. NOT the loaded subtype data.
+
+
$conf
+
The stored configuration for the content.
+
+
$args
+
Any arguments passed.
+
+
$context
+
An array of contexts requested by the required contexts and assigned by the configuration step.
+
+
$incoming_content
+
Any 'incoming content' if this is a wrapper.
+
+
+
+
admin title
+
A callback to provide the administrative title. If it is not a function, then it will be counted as a string to use as the admin title.
+
+
admin info
+
A callback to provide administrative information about the content, to be displayed when manipulating the content. It should contain a summary of configuration.
+
+
edit form
+
Either a single form ID or an array of forms *keyed* by form ID with the value to be used as the title of the form. %title me be used as a placeholder for the administrative title if necessary.
+ Example:
+
array(
+ 'ctools_example_content_form_second' => t('Configure first form'),
+ 'ctools_example_content_form_first' => t('Configure second form'),
+),
+
+The first form will always have required configuration added to it. These forms are normal FAPI forms, but you do not need to provide buttons, these will be added by the form wizard.
+
+
+
add form
+
[Optional] If different from the edit forms, provide them here in the same manner. Also may be set to FALSE to not have an add form.
+
+
css
+
A file or array of CSS files that are necessary for the content.
+
+
js
+
A file or array of javascript files that are necessary for the content to be displayed.
+
+
admin css
+
A file or array of CSS files that are necessary for the forms.
+
+
admin js
+
A file or array of JavaScript files that are necessary for the forms.
+
+
extra forms
+
An array of form information to handle extra administrative forms.
+
+
no title override
+
Set to TRUE if the title cannot be overridden.
+
+
single
+
Set to TRUE if this content provides exactly one subtype.
+
+
render last
+
Set to true if for some reason this content needs to render after other content. This is primarily used for forms to ensure that render order is correct.
+
+
+
TODO: many of the above callbacks can be assumed based upon patterns: modulename + '_' + name + '_' + function. i.e, render, admin_title, admin_info, etc.
+
+
TODO: Some kind of simple access control to easily filter out content.
+
+
The subtype definition should contain:
+
+
+
title
+
The title of the subtype.
+
+
icon
+
The icon to display for the subtype.
+
+
path
+
The path for the icon if it is not in the same directory as the plugin.
+
+
description
+
The short description of the subtype, to be used when selecting it in the UI.
+
+
category
+
Either a text string for the category, or an array of the text string followed by the category weight.
+
+
required context [Optional]
+
+
Either a ctools_context_required or ctools_context_optional or array of contexts for this content. If omitted, no contexts are used.
+
+
create content access [Optional]
+
+
An optional callback to determine if a user can access this subtype. The callback will receive two arguments, the type and subtype.
+
+
+
Rendered content
+
+
Rendered content is a little more than just HTML.
+
+
+
title
+
The safe to render title of the content.
+
+
content
+
The safe to render HTML content.
+
+
links
+
An array of links associated with the content suitable for theme('links').
+
+
more
+
An optional 'more' link (destination only)
+
+
admin_links
+
Administrative links associated with the content, suitable for theme('links').
+
+
feeds
+
An array of feed icons or links associated with the content. Each member of the array is rendered HTML.
+
+
type
+
The content type.
+
+
subtype
+
The content subtype. These two may be used together as module-delta for block style rendering.
+
+
+
Todo: example
+
+
Todo after implementations are updated to new version.
diff --git a/sites/all/modules/contrib/ctools/help/context-context.html b/sites/all/modules/contrib/ctools/help/context-context.html
new file mode 100644
index 0000000..2314bd5
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/context-context.html
@@ -0,0 +1,13 @@
+
Context plugin data:
+
+
+ 'title' => Visible title
+ 'description' => Description of context
+ 'context' => Callback to create a context. Params: $empty, $data = NULL, $conf = FALSE
+ 'settings form' => Callback to show a context setting form. Params: ($conf, $external = FALSE)
+ 'settings form validate' => params: ($form, &$form_values, &$form_state)
+ 'settings form submit' => params: 'ctools_context_node_settings_form_submit',
+ 'keyword' => The default keyword to use.
+ 'context name' => The unique identifier for this context for use by required context checks.
+ 'no ui' => if TRUE this context cannot be selected.
+
\ No newline at end of file
diff --git a/sites/all/modules/contrib/ctools/help/context-relationships.html b/sites/all/modules/contrib/ctools/help/context-relationships.html
new file mode 100644
index 0000000..cc9969e
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/context-relationships.html
@@ -0,0 +1,13 @@
+
Relationship plugin data:
+
+
+ 'title' => The title to display.
+ 'description' => Description to display.
+ 'keyword' => Default keyword for the context created by this relationship.
+ 'required context' => One or more ctools_context_required/optional objects
+ describing the context input.
+ new panels_required_context(t('Node'), 'node'),
+ 'context' => The callback to create the context. Params: ($context = NULL, $conf)
+ 'settings form' => Settings form. Params: $conf
+ 'settings form validate' => Validate.
+
diff --git a/sites/all/modules/contrib/ctools/help/context.html b/sites/all/modules/contrib/ctools/help/context.html
new file mode 100644
index 0000000..e69de29
diff --git a/sites/all/modules/contrib/ctools/help/css.html b/sites/all/modules/contrib/ctools/help/css.html
new file mode 100644
index 0000000..b9b6d9c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/css.html
@@ -0,0 +1 @@
+
diff --git a/sites/all/modules/contrib/ctools/help/dropbutton.html b/sites/all/modules/contrib/ctools/help/dropbutton.html
new file mode 100644
index 0000000..b9b6d9c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/dropbutton.html
@@ -0,0 +1 @@
+
To be written.
diff --git a/sites/all/modules/contrib/ctools/help/dropdown.html b/sites/all/modules/contrib/ctools/help/dropdown.html
new file mode 100644
index 0000000..b9b6d9c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/dropdown.html
@@ -0,0 +1 @@
+
To be written.
diff --git a/sites/all/modules/contrib/ctools/help/export-ui.html b/sites/all/modules/contrib/ctools/help/export-ui.html
new file mode 100644
index 0000000..e6b1086
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/export-ui.html
@@ -0,0 +1,85 @@
+
Most user interfaces for exportables are very similar, so CTools includes a tool to provide the framework for the most common UI. This tool is a plugin of the 'export_ui' type. In order to create a UI for your exportable object with this tool, you first need to ensure that your module supports the plugin:
Then, you need to create a plugin .inc file describing your UI. Most of the UI runs with sane but simple defaults, so for the very simplest UI you don't need to do very much. This is a very simple example plugin for the 'example' export type:
+
+
+$plugin = array(
+ // The name of the table as found in the schema in hook_install. This
+ // must be an exportable type with the 'export' section defined.
+ 'schema' => 'example',
+
+ // The access permission to use. If not provided it will default to
+ // 'administer site configuration'
+ 'access' => 'administer example',
+
+ // You can actually define large chunks of the menu system here. Nothing
+ // is required here. If you leave out the values, the prefix will default
+ // to admin/structure and the item will default to the plugin name.
+ 'menu' => array(
+ 'menu prefix' => 'admin/structure',
+ 'menu item' => 'example',
+ // Title of the top level menu. Note this should not be translated,
+ // as the menu system will translate it.
+ 'menu title' => 'Example',
+ // Description of the top level menu, which is usually needed for
+ // menu items in an administration list. Will be translated
+ // by the menu system.
+ 'menu description' => 'Administer site example objects.',
+ ),
+
+ // These are required to provide proper strings for referring to the
+ // actual type of exportable. "proper" means it will appear at the
+ // beginning of a sentence.
+ 'title singular' => t('example'),
+ 'title singular proper' => t('Example'),
+ 'title plural' => t('examples'),
+ 'title plural proper' => t('Examples'),
+
+ // This will provide you with a form for editing the properties on your
+ // exportable, with validate and submit handler.
+ //
+ // The item being edited will be in $form_state['item'].
+ //
+ // The submit handler is only responsible for moving data from
+ // $form_state['values'] to $form_state['item'].
+ //
+ // All callbacks will accept &$form and &$form_state as arguments.
+ 'form' => array(
+ 'settings' => 'example_ctools_export_ui_form',
+ 'validate' => 'example_ctools_export_ui_form_validate',
+ 'submit' => 'example_ctools_export_ui_form_submit',
+ ),
+
+);
+
+
+
For a more complete list of what you can set in your plugin, please see ctools_export_ui_defaults() in includes/export-ui.inc to see what the defaults are.
+
+
More advanced UIs
+
+
The bulk of this UI is built on an class called ctools_export_ui, which is itself stored in ctools/plugins/export_ui as the default plugin. Many UIs will have more complex needs than the defaults provide. Using OO and overriding methods can allow an implementation to use the basics and still provide more where it is needed. To utilize this, first add a 'handler' directive to your plugin .inc file:
You can override any method found in the class (see the source file for details). In particular, there are several list methods that are good candidates for overriding if you need to provide richer data for listing, sorting or filtering. If you need multi-step add/edit forms, you can override edit_page(), add_page(), clone_page(), and import_page() to put your wizard in place of the basic editing system. For an example of how to use multi-step wizards, see the import_page() method.
diff --git a/sites/all/modules/contrib/ctools/help/export.html b/sites/all/modules/contrib/ctools/help/export.html
new file mode 100644
index 0000000..ce24cad
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/export.html
@@ -0,0 +1,294 @@
+
Exportable objects are objects that can live either in the database or in code, or in both. If they live in both, then the object in code is considered to be "overridden", meaning that the version in code is ignored in favor of the version in the database.
+
+
The main benefit to this is that you can move objects that are intended to be structure or feature-related into code, thus removing them entirely from the database. This is a very important part of the deployment path, since in an ideal world, the database is primarily user generated content, whereas site structure and site features should be in code. However, many many features in Drupal rely on objects being in the database and provide UIs to create them.
+
+
Using this system, you can give your objects dual life. They can be created in the UI, exported into code and put in revision control. Views and Panels both use this system heavily. Plus, any object that properly implements this system can be utilized by the Features module to be used as part of a bundle of objects that can be turned into feature modules.
+
+
Typically, exportable objects have two identifiers. One identifier is a simple serial used for database identification. It is a primary key in the database and can be used locally. It also has a name which is an easy way to uniquely identify it. This makes it much less likely that importing and exporting these objects across systems will have collisions. They still can, of course, but with good name selection, these problems can be worked around.
+
+
Making your objects exportable
+
+
To make your objects exportable, you do have to do a medium amount of work.
+
+
+
Create a chunk of code in your object's schema definition in the .install file to introduce the object to CTools' export system.
+
Create a load function for your object that utilizes ctools_export_load_object().
+
Create a save function for your object that utilizes drupal_write_record() or any method you desire.
+
Create an import and export mechanism from the UI.
+
+
+
The export section of the schema file
+
+
Exportable objects are created by adding definition to the schema in an 'export' section. For example:
+
+
+function mymodule_schema() {
+ $schema['mymodule_myobj'] = array(
+ 'description' => t('Table storing myobj definitions.'),
+ 'export' => array(
+ 'key' => 'name',
+ 'key name' => 'Name',
+ 'primary key' => 'oid',
+ 'identifier' => 'myobj', // Exports will be as $myobj
+ 'default hook' => 'default_mymodule_myobj', // Function hook name.
+ 'api' => array(
+ 'owner' => 'mymodule',
+ 'api' => 'default_mymodule_myobjs', // Base name for api include files.
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ // If the key is stored in a table that is joined in, specify it:
+ 'key in table' => 'my_join_table',
+
+ ),
+
+ // If your object's data is split up across multiple tables, you can
+ // specify additional tables to join. This is very useful when working
+ // with modules like exportables.module that has a special table for
+ // translating keys to local database IDs.
+ //
+ // The joined table must have its own schema definition.
+ //
+ // If using joins, you should implement a 'delete callback' (see below)
+ // to ensure that deletes happen properly. export.inc does not do this
+ // automatically!
+ 'join' => array(
+ 'exportables' => array(
+ // The following parameters will be used in this way:
+ // SELECT ... FROM {mymodule_myobj} t__0 INNER JOIN {my_join_table} t__1 ON t__0.id = t__1.id AND extras
+ 'table' => 'my_join_table',
+ 'left_key' => 'format',
+ 'right_key' => 'id',
+ // Optionally you can define a callback to add custom conditions or
+ // alter the query as necessary. The callback function takes 3 args:
+ //
+ // myjoincallback(&$query, $schema, $join_schema);
+ //
+ // where $query is the database query object, $schema is the schema for
+ // the export base table and $join_schema is the schema for the current
+ // join table.
+ 'callback' => 'myjoincallback',
+
+ // You must specify which fields will be loaded. These fields must
+ // exist in the schema definition of the joined table.
+ 'load' => array(
+ 'machine',
+ ),
+
+ // And finally you can define other tables to perform INNER JOINS
+ //'other_joins' => array(
+ // 'table' => ...
+ //),
+ ),
+ )
+ 'fields' => array(
+ 'name' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'description' => 'Unique ID for this object. Used to identify it programmatically.',
+ ),
+ 'oid' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ 'no export' => TRUE, // Do not export database-only keys.
+ ),
+ // ......
+ 'primary key' => array('oid'),
+ 'unique keys' => array(
+ 'name' => array('name'),
+ ),
+ );
+ return $schema;
+}
+
+
+
+
key
+
This is the primary key of the exportable object and should be a string as names are more portable across systems. It is possible to use numbers here, but be aware that export collisions are very likely. Defaults to 'name'.
+
+
key name
+
Human readable title of the export key. Defaults to 'Name'. Because the schema is cached, do not translate this. It must instead be translated when used.
+
+
primary key
+
A single field within the table that is to be used as the main identifier to discern whether or not the object has been written. As the schema definition's primary key value will be used by default, it is not usually necessary to define this.
+
+
object
+
The class the object should be created as, if 'object factory' is not set. If this is not set either, defaults as stdClass.
+
+
object factory
+
Function used to create the object. The function receives the schema and the loaded data as a parameters: your_factory_function($schema, $data). If this is set, 'object' has no effect since you can use your function to create whatever class you wish.
+
+
admin_title
+
A convenience field that may contain the field which represents the human readable administrative title for use in export UI. If a field "admin_title" exists, it will automatically be used.
+
+
admin_description
+
A convenience field that may contain the field which represents the human readable administrative title for use in export UI. If a field "admin_title" exists, it will automatically be used.
+
+
can disable
+
Control whether or not the exportable objects can be disabled. All this does is cause the 'disabled' field on the object to always be set appropriately, and a variable is kept to record the state. Changes made to this state must be handled by the owner of the object. Defaults to TRUE.
+
+
status
+
Exportable objects can be enabled or disabled, and this status is stored in a variable. This defines what variable that is. Defaults to: 'default_' . $table.
+
+
default hook
+
What hook to invoke to find exportable objects that are currently defined. These will all be gathered into a giant array. Defaults to 'default_' . $table.
+
+
cache defaults
+
If true, default objects will be cached so that the processing of the hook does not need to be called often. Defaults to FALSE. Recommended if you will potentially have a lot of objects in code. Not recommended if code will be the exception.
+
+
default cache bin
+
If default object caching is enabled, what cache bin to use. This defaults to the basic "cache". It is highly recommended that you use a different cache bin if possible.
+
+
identifier
+
When exporting the object, the identifier is the variable that the exported object will be placed in. Defaults to $table.
+
+
bulk export
+
Declares whether or not the exportable will be available for bulk exporting.
+
+
export type string
+
The export type string (Local, Overridden, Database) is normally stored as $item->type. Since type is a very common keyword, it's possible to specify what key to actually use.
+
+
list callback
+
Bulk export callback to provide a list of exportable objects to be chosen for bulk exporting. Defaults to $module . '_' . $table . '_list' if the function exists. If it is not, a default listing function will be provided that will make a best effort to list the titles. See ctools_export_default_list().
+
+
to hook code callback
+
Function used to generate an export for the bulk export process. This is only necessary if the export is more complicated than simply listing the fields. Defaults to $module . '_' . $table . '_to_hook_code'.
+
+
boolean
+
Explicitly indicate if a table field contains a boolean or not. The Schema API does not model the
+difference between a tinyint and a boolean type. Boolean values are stored in tinyint fields. This may cause mismatch errors when exporting a non-boolean value from a tinyint field. Add this to a tinyint field if it contains boolean data and can be exported. Defaults to TRUE.
+
+
create callback
+
CRUD callback to use to create a new exportable item in memory. If not provided, the default function will be used. The single argument is a boolean used to determine if defaults should be set on the object. This object will not be written to the database by this callback.
+
+
load callback
+
CRUD callback to use to load a single item. If not provided, the default load function will be used. The callback will accept a single argument which should be an identifier of the export key.
+
+
load multiple callback
+
CRUD callback to use to load multiple items. If not provided, the default multiple load function will be used. The callback will accept an array which should be the identifiers of the export key.
+
+
load all callback
+
CRUD callback to use to load all items, usually for administrative purposes. If not provided, the default load function will be used. The callback will accept a single argument to determine if the load cache should be reset or not.
+
+
save callback
+
CRUD callback to use to save a single item. If not provided, the default save function will be used. The callback will accept a single argument which should be the complete exportable object to save.
+
+
delete callback
+
CRUD callback to use to delete a single item. If not provided, the default delete function will be used. The callback will accept a single argument which can be *either* the object or just the export key to delete. The callback MUST be able to accept either.
+
+
export callback
+
CRUD callback to use for exporting. If not provided, the default export function will be used. The callback will accept two arguments, the first is the item to export, the second is the indent to place on the export, if any.
+
+
import callback
+
CRUD callback to use for importing. If not provided, the default export function will be used. This function will accept the code as a single argument and, if the code evaluates, return an object represented by that code. In the case of failure, this will return a string with human readable errors.
+
+
status callback
+
CRUD callback to use for updating the status of an object. If the status is TRUE the object will be disabled. If the status is FALSE the object will be enabled.
+
+
api
+
The 'api' key can optionally contain some information for the plugin API definition. This means that the imports can be tied to an API name which is used to have automatic inclusion of files, and can be used to prevent dangerous objects from older versions from being loaded, causing a loss of functionality rather than site crashes or security loopholes.
+
+
If not present, no additional files will be loaded and the default hook will always be a simple hook that must be either part of the .module file or loaded during normal operations.
+
+
api supports these subkeys:
+
+
+
owner
+
The module that owns the API. Typically this is the name of the module that owns the schema. This will be one of the two keys used by hook_ctools_plugin_api() to determine version compatibility. Note that the name of this hook can be tailored via the use of hook_ctools_plugin_api_hook_name(). See ctools_plugin_api_get_hook() for details.
+
api
+
This is the name of the API, and will be the second parameter to the above mentioned hook. It will also be used as part of the name of the file that the hook containing default objects will be in, which comes in the form of MODULENAME.API.inc.
+
minimum_version
+
The minimum version supported. Any module reporting an API less than this will not have its default objects used. This should be updated only when API changes can cause older objects to crash or otherwise break badly.
+
current_version
+
The current version of the API. Any module reporting a required API higher than this will not have its default objects used.
+
+
+
+
+
In addition, each field can contain the following:
+
+
no export
+
Set to TRUE to prevent that field from being exported.
+
+
export callback
+
A function to override the export behavior. It will receive ($myobject, $field, $value, $indent) as arguments. By default, fields are exported through ctools_var_export().
+
+
+
Reserved keys on exportable objects
+
+
Exportable objects have several reserved keys that are used by the CTools export API. Each key can be found at $myobj->{$key} on an object loaded through ctools_export_load_object(). Implementing modules should not use these keys as they will be overwritten by the CTools export API.
+
+
api_version
+
The API version that this object implements.
+
+
disabled
+
A boolean for whether the object is disabled.
+
+
export_module
+
For objects that live in code, the module which provides the default object.
+
+
export_type
+
A bitmask representation of an object current storage. You can use this bitmask in combination with the EXPORT_IN_CODE and EXPORT_IN_DATABASE constants to test for an object's storage in your code.
+
+
+
in_code_only
+
A boolean for whether the object lives only in code.
+
+
table
+
The schema API table that this object belongs to.
+
+
type
+
A string representing the storage type of this object. Can be one of the following:
+
+
Normal is an object that lives only in the database.
+
Overridden is an object that lives in the database and is overriding the exported configuration of a corresponding object in code.
+
Default is an object that lives only in code.
+
+Note: This key can be changed by setting 'export type string' to something else, to try and prevent "type" from conflicting.
+
+
+
+
The load callback
+
Calling ctools_export_crud_load($table, $name) will invoke your load callback, calling ctools_export_crud_load_multiple($table, $names) will invoke your load multiple callback, and calling ctools_export_crud_load_all($table, $reset) will invoke your load all callback. The default handlers should be sufficient for most uses.
+
+
Typically, there will be three load functions. A 'single' load, to load just one object, a 'multiple' load to load multiple objects, and an 'all' load, to load all of the objects for use in administrating the objects or utilizing the objects when you need all of them. Using ctools_export_load_object() you can easily do both, as well as quite a bit in between. This example duplicates the default functionality for loading one myobj.
+Calling ctools_export_crud_save($table, $object) will invoke your save callback. The default handlers should be sufficient for most uses. For the default save mechanism to work, you must define a 'primary key' in the 'export' section of your schema. The following example duplicates the default functionality for the myobj.
+
+
+/**
+* Save a single myobj.
+*/
+function mymodule_myobj_save(&$myobj) {
+ $update = (isset($myobj->oid) && is_numeric($myobj->oid)) ? array('oid') : array();
+ return drupal_write_record('myobj', $myobj, $update);
+}
+
+
+
Default hooks for your exports
+
All exportables come with a 'default' hook, which can be used to put your exportable into code. The easiest way to actually use this hook is to set up your exportable for bulk exporting, enable the bulk export module and export an object.
diff --git a/sites/all/modules/contrib/ctools/help/form.html b/sites/all/modules/contrib/ctools/help/form.html
new file mode 100644
index 0000000..b9b6d9c
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/form.html
@@ -0,0 +1 @@
+
To be written.
diff --git a/sites/all/modules/contrib/ctools/help/modal.html b/sites/all/modules/contrib/ctools/help/modal.html
new file mode 100644
index 0000000..ea823a0
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/modal.html
@@ -0,0 +1,215 @@
+
CTools provides a simple modal that can be used as a popup to place forms. It differs from the normal modal frameworks in that it does not do its work via an iframe. This is both an advantage and a disadvantage. The iframe simply renders normal pages in a sub-browser and they can do their thing. That makes it much easier to put arbitrary pages and forms in a modal. However, the iframe is not very good at actually communicating changes to the main page, so you cannot open the modal, have it do some work, and then modify the page.
+
+
Invoking the modal
+
+
The basic form of the modal can be set up just by including the javascript and adding the proper class to a link or form that will open the modal. To include the proper javascript, simply include the library and call the add_js function:
You can have links and buttons bound to use the modal by adding the class ctools-use-modal. For convenience, there is a helper function to try and do this, though it's not great at doing all links so using this is optional:
+
+/**
+ * Render an image as a button link. This will automatically apply an AJAX class
+ * to the link and add the appropriate javascript to make this happen.
+ *
+ * @param $image
+ * The path to an image to use that will be sent to theme('image') for rendering.
+ * @param $dest
+ * The destination of the link.
+ * @param $alt
+ * The alt text of the link.
+ * @param $class
+ * Any class to apply to the link. @todo this should be a options array.
+ */
+function ctools_modal_image_button($image, $dest, $alt, $class = '') {
+ return ctools_ajax_text_button(theme('image', array('path' => $image), $dest, $alt, $class, 'ctools-use-modal');
+}
+
+/**
+ * Render text as a link. This will automatically apply an AJAX class
+ * to the link and add the appropriate javascript to make this happen.
+ *
+ * Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will
+ * not use user input so this is a very minor concern.
+ *
+ * @param $text
+ * The text to display as the link.
+ * @param $dest
+ * The destination of the link.
+ * @param $alt
+ * The alt text of the link.
+ * @param $class
+ * Any class to apply to the link. @todo this should be a options array.
+ */
+function ctools_modal_text_button($text, $dest, $alt, $class = '') {
+ return ctools_ajax_text_button($text, $dest, $alt, $class, 'ctools-use-modal');
+}
+
+
+
Like with all CTools' AJAX functionality, the href of the link will be the destination, with any appearance of /nojs/ converted to /ajax/.
+
+
For submit buttons, however, the URL may be found a different, slightly more complex way. If you do not wish to simply submit the form to the modal, you can create a URL using hidden form fields. The ID of the item is taken and -url is appended to it to derive a class name. Then, all form elements that contain that class name are founded and their values put together to form a URL.
+
+
For example, let's say you have an 'add' button, and it has a select form item that tells your system what widget it is adding. If the id of the add button is edit-add, you would place a hidden input with the base of your URL in the form and give it a class of 'edit-add-url'. You would then add 'edit-add-url' as a class to the select widget allowing you to convert this value to the form without posting. If no URL is found, the action of the form will be used and the entire form posted to it.
+
+
Customizing the modal
+
+
If you do not wish to use the default modal, the modal can be customized by creating an array of data to define a customized modal. To do this, you add an array of info to the javascript settings to define the customizations for the modal and add an additional class to your modal link or button to tell it which modal to use.
+
+
First, you need to create a settings array. You can do this most easily with a bit of PHP:
The key to the array above (in this case, my-modal-style) is the identifier to your modal theme. You can have multiple modal themes on a page, so be sure to use an ID that will not collide with some other module's use. Using your module or theme as a prefix is a good idea.
+
+
Then, when adding the ctools-use-modal class to your link or button, also add the following class: ctools-modal-ID (in the example case, that would be ctools-modal-my-modal-style).
+
+
modalSize can be 'fixed' or 'scale'. If fixed it will be a raw pixel value; if 'scale' it will be a percentage of the screen.
+
+
You can set:
+
+
modalSize: an array of data to control the sizing of the modal. It can contain:
+
+
type: Either fixed or scale. If fixed, the modal will always be a fixed size. If scale the modal will scale to a percentage of the browser window. Default: scale.
+
width: If fixed the width in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
+
height: If fixed the height in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
+
addWidth: Any additional width to add to the modal in pixels. Only useful if the type is scale. Default: 0
+
addHeight: Any additional height to add to the modal in pixels. Only useful if the type is scale. Default: 0
+
contentRight: The number of pixels to remove from the content inside the modal to make room for scroll bar and decorations. Default: 25
+
contentBottom: The number of pixels to remove from the content inside the modal to make room for scroll bar and decorations. Default: 45
+
+
+
modalTheme: The Drupal javascript themable function which controls how the modal will be rendered. This function must be in the Drupal.theme.prototype namespace. If you set this value, you must include a corresponding function in a javascript file and use drupal_add_js() to add that file. Default: CToolsModalDialog
+
+ Drupal.theme.prototype.CToolsModalDialog = function () {
+ var html = ''
+ html += ' <div id="ctools-modal">'
+ html += ' <div class="ctools-modal-content">' // panels-modal-content
+ html += ' <div class="modal-header">';
+ html += ' <a class="close" href="#">';
+ html += Drupal.CTools.Modal.currentSettings.closeText + Drupal.CTools.Modal.currentSettings.closeImage;
+ html += ' </a>';
+ html += ' <span id="modal-title" class="modal-title"> </span>';
+ html += ' </div>';
+ html += ' <div id="modal-content" class="modal-content">';
+ html += ' </div>';
+ html += ' </div>';
+ html += ' </div>';
+
+ return html;
+ }
+
+
throbberTheme: The Drupal javascript themable function which controls how the modal throbber will be rendered. This function must be in the Drupal.theme.prototype namespace. If you set this value, you must include a corresponding function in a javascript file and use drupal_add_js() to add that file. Default: CToolsModalThrobber
+
+ Drupal.theme.prototype.CToolsModalThrobber = function () {
+ var html = '';
+ html += ' <div id="modal-throbber">';
+ html += ' <div class="modal-throbber-wrapper">';
+ html += Drupal.CTools.Modal.currentSettings.throbber;
+ html += ' </div>';
+ html += ' </div>';
+
+ return html;
+ };
+
+
+
modalOptions: The options object that's sent to Drupal.CTools.Modal.modalContent. Can contain any CSS settings that will be applied to the modal backdrop, in particular settings such as opacity and background. Default: array('opacity' => .55, 'background' => '#fff');
+
animation: Controls how the modal is animated when it is first drawn. Either show, fadeIn or slideDown. Default: show
+
animationSpeed: The speed of the animation, expressed either as a word jQuery understands (slow, medium or fast) or a number of milliseconds for the animation to run. Defaults: fast
+
closeText: The text to display for the close button. Be sure to wrap this in t() for translatability. Default: t('Close window')
+
closeImage: The image to use for the close button of the modal. Default: theme('image', array('path' => ctools_image_path('icon-close-window.png'), 'alt' => t('Close window'), 'title' => t('Close window')))
+
loadingText: The text to display for the modal title during loading, along with the throbber. Be sure to wrap this in t() for translatability. Default: t('Close window')
+
throbber: The HTML to display for the throbber image. You can use this instead of CToolsModalThrobber theme if you just want to change the image but not the throbber HTML. Default: theme('image', array('path' => ctools_image_path('throbber.gif'), 'alt' => t('Loading...'), 'title' => t('Loading')))
+
+
+
Rendering within the modal
+
To render your data inside the modal, you need to provide a page callback in your module that responds more or less like a normal page.
+
+
In order to handle degradability, it's nice to allow your page to work both inside and outside of the modal so that users whose javascript is turned off can still use your page. There are two ways to accomplish this. First, you can embed 'nojs' as a portion of the URL and then watch to see if that turns into 'ajax' when the link is clicked. Second, if you do not wish to modify the URLs, you can check $_POST['js'] or $_POST['ctools_js'] to see if that flag was set. The URL method is the most flexible because it is easy to send the two links along completely different paths if necessary, and it is also much easier to manually test your module's output by manually visiting the nojs URL. It's actually quite difficult to do this if you have to set $_POST['js'] to test.
+
+
In your hook_menu, you can use the a CTools' AJAX convenience loader to help:
The first argument to the page callback will be the result of ctools_js_load() which will return TRUE if 'ajax' was the string, and FALSE if anything else (i.e, nojs) is the string. Which means you can then declare your function like this:
+
+
+function ctools_ajax_sample_login($js) {
+ if ($js) {
+ // react with the modal
+ }
+ else {
+ // react without the modal
+ }
+}
+
+
+
If your modal does not include a form, rendering the output you wish to give the user is just a matter of calling the modal renderer with your data:
If you need to do more than just render your modal, you can use a CTools $commands array. See the function ctools_modal_render() for more information on what you need to do here.
+
+
If you are displaying a form -- and the vast majority of modals display forms -- then you need to do just slightly more. Fortunately there is the ctools_modal_form_wrapper() function:
+
+
+ ctools_include('modal');
+ ctools_include('ajax');
+ $form_state = array(
+ 'title' => t('Title of my form'),
+ 'ajax' => $js,
+ );
+ $output = ctools_modal_form_wrapper('my_form', $form_state);
+ // There are some possible states after calling the form wrapper:
+ // 1) We are not using $js and the form has been executed.
+ // 2) We are using $js and the form was successfully submitted and
+ // we need to dismiss the modal.
+ // Most other states are handled automatically unless you set flags in
+ // $form_state to avoid handling them, so we only deal with those two
+ // states.
+ if ($form_state['executed'] && $js) {
+ $commands = array();
+ $commands[] = ctools_modal_command_dismiss(t('Login Success'));
+ // In typical usage you will do something else here, such as update a
+ // div with HTML or redirect the page based upon the results of the modal
+ // form.
+ print ajax_render($commands);
+ exit;
+ }
+
+ // Otherwise, just return the output.
+ return $output;
+
+
+
You can also use CTools' form wizard inside the modal. You do not need to do much special beyond setting $form_state['modal'] = TRUE in the wizard form; it already knows how to handle the rest.
diff --git a/sites/all/modules/contrib/ctools/help/object-cache.html b/sites/all/modules/contrib/ctools/help/object-cache.html
new file mode 100644
index 0000000..801a836
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/object-cache.html
@@ -0,0 +1,132 @@
+
The CTools Object Cache is a specialized cache for storing data that is non-volatile. This differs from the standard Drupal cache mechanism, which is volatile, meaning that the data can be cleared at any time and it is expected that any cached data can easily be reconstructed. In contrast, data stored in this cache is not expected to be reconstructable. It is primarily used for storing user input which is retrieved in stages, allowing for more complex user interface interactions.
+
+
The object cache consists of 3 normal functions for cache maintenance, and 2 additional functions to facilitate locking.
+
+
To use any of these functions, you must first use ctools_include:
+
+
+ctools_include('object-cache');
+
+
+
+/**
+ * Get an object from the non-volatile ctools cache.
+ *
+ * This function caches in memory as well, so that multiple calls to this
+ * will not result in multiple database reads.
+ *
+ * @param $obj
+ * A 128 character or less string to define what kind of object is being
+ * stored; primarily this is used to prevent collisions.
+ * @param $name
+ * The name of the object being stored.
+ * @param $skip_cache
+ * Skip the memory cache, meaning this must be read from the db again.
+ *
+ * @return
+ * The data that was cached.
+ */
+function ctools_object_cache_get($obj, $name, $skip_cache = FALSE) {
+
+
+
+/**
+ * Store an object in the non-volatile ctools cache.
+ *
+ * @param $obj
+ * A 128 character or less string to define what kind of object is being
+ * stored; primarily this is used to prevent collisions.
+ * @param $name
+ * The name of the object being stored.
+ * @param $cache
+ * The object to be cached. This will be serialized prior to writing.
+ */
+function ctools_object_cache_set($obj, $name, $cache) {
+
+
+
+/**
+ * Remove an object from the non-volatile ctools cache
+ *
+ * @param $obj
+ * A 128 character or less string to define what kind of object is being
+ * stored; primarily this is used to prevent collisions.
+ * @param $name
+ * The name of the object being removed.
+ */
+function ctools_object_cache_clear($obj, $name) {
+
+
+
To facilitate locking, which is the ability to prohibit updates by other users while one user has an object cached, this system provides two functions:
+
+
+/**
+ * Determine if another user has a given object cached.
+ *
+ * This is very useful for 'locking' objects so that only one user can
+ * modify them.
+ *
+ * @param $obj
+ * A 128 character or less string to define what kind of object is being
+ * stored; primarily this is used to prevent collisions.
+ * @param $name
+ * The name of the object being removed.
+ *
+ * @return
+ * An object containing the UID and updated date if found; NULL if not.
+ */
+function ctools_object_cache_test($obj, $name) {
+
+
+
The object returned by ctools_object_cache_test can be directly used to determine whether a user should be allowed to cache their own version of an object.
+
+
To allow the concept of breaking a lock, that is, clearing another users changes:
+
+
+/**
+ * Remove an object from the non-volatile ctools cache for all session IDs.
+ *
+ * This is useful for clearing a lock.
+ *
+ * @param $obj
+ * A 128 character or less string to define what kind of object is being
+ * stored; primarily this is used to prevent collisions.
+ * @param $name
+ * The name of the object being removed.
+ */
+function ctools_object_cache_clear_all($obj, $name) {
+
+
+
Typical best practice is to use wrapper functions such as these:
+
+
+/**
+ * Get the cached changes to a given task handler.
+ */
+function delegator_page_get_page_cache($name) {
+ ctools_include('object-cache');
+ $cache = ctools_object_cache_get('delegator_page', $name);
+ if (!$cache) {
+ $cache = delegator_page_load($name);
+ $cache->locked = ctools_object_cache_test('delegator_page', $name);
+ }
+
+ return $cache;
+}
+
+/**
+ * Store changes to a task handler in the object cache.
+ */
+function delegator_page_set_page_cache($name, $page) {
+ ctools_include('object-cache');
+ $cache = ctools_object_cache_set('delegator_page', $name, $page);
+}
+
+/**
+ * Remove an item from the object cache.
+ */
+function delegator_page_clear_page_cache($name) {
+ ctools_include('object-cache');
+ ctools_object_cache_clear('delegator_page', $name);
+}
+
diff --git a/sites/all/modules/contrib/ctools/help/plugins-api.html b/sites/all/modules/contrib/ctools/help/plugins-api.html
new file mode 100644
index 0000000..548f17b
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/plugins-api.html
@@ -0,0 +1,55 @@
+
APIs are a form of plugins that are tightly associated with a module. Instead of a module providing any number of plugins, each module provides only one file for an API and this file can contain hooks that the module should invoke.
+
+
Modules support this API by implementing hook_ctools_plugin_api($module, $api). If they support the API, they return a packet of data:
+
+
+function mymodule_ctools_plugin_api($module, $api) {
+ if ($module == 'some module' && $api = 'some api') {
+ return array(
+ 'version' => The minimum API version this system supports. If this API version is incompatible then the .inc file will not be loaded.
+ 'path' => Where to find the file. Optional; if not specified it will be the module's directory.
+ 'file' => an alternative version of the filename. If not specified it will be $module.$api.inc
+ );
+ }
+}
+
+
+
This implementation must be in the .module file.
+
+
Modules utilizing this can invole ctools_plugin_api_include() in order to ensure all modules that support the API will have their files loaded as necessary. It's usually easiest to create a small helper function like this:
Using a define will ensure your use of version numbers is consistent and easy to update when you make API changes. You can then use the usual module_invoke type commands:
If you need to pass references, this construct is standard:
+
+
+foreach (mymodule_include_api() as $module => $info) {
+ $function = $module . '_hookname';
+ // Just because they implement the API and include a file does not guarantee they implemented
+ // a hook function!
+ if (!function_exists($function)) {
+ continue;
+ }
+
+ // Typically array_merge() is used below if data is returned.
+ $result = $function($data1, $data2, $data3);
+}
+
+
+
TODO: There needs to be a way to check API version without including anything, as a module may simply
+provide normal plugins and versioning could still matter.
diff --git a/sites/all/modules/contrib/ctools/help/plugins-creating.html b/sites/all/modules/contrib/ctools/help/plugins-creating.html
new file mode 100644
index 0000000..2323705
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/plugins-creating.html
@@ -0,0 +1,203 @@
+There are two primary pieces to using plugins. The first is getting the data, and the second is using the data.
+
+
Defining a plugin
+To define that you offer a plugin that modules can implement, you first must implement hook_ctools_plugin_type() to tell the plugin system about your plugin.
+
+
+
+The following information can be specified for each plugin type:
+
+
cache
+
Defaults to:FALSE
+
If set to TRUE, the results of ctools_get_plugins will be cached in the 'cache' table (by default), thus preventing .inc files from being loaded. ctools_get_plugins looking for a specific plugin will always load the appropriate .inc file.
+
cache table
+
Defaults to:'cache'
+
If 'cache' is TRUE, then this value specifies the cache table where the cached plugin information will be stored.
+
classes
+
Defaults to:array()
+
An array of class identifiers(i.e. plugin array keys) which a plugin of this type uses to provide classes to the CTools autoloader. For example, if classes is set to array('class'), then CTools will search each $plugin['class'] for a class to autoload. Depending of the plugin structure, a class identifier may be either:
+
+
- a file name:
+
the file which holds the class with the name structure as: [filename].[class].php
+
in this case the class name can be different than the class identifier
+
- the class name:
+
if the class is in the same file as the $plugin
+
the plugin .inc file can have a different name than the class identifier
+
+
defaults
+
Defaults to:array()
+
An array of defaults that should be added to each plugin; this can be used to ensure that every plugin has the basic data necessary. These defaults will not ovewrite data supplied by the plugin. This could also be a function name, in which case the callback will be used to provide defaults. NOTE, however, that the callback-based approach is deprecated as it is redundant with the 'process' callback, and as such will be removed in later versions. Consequently, you should only use the array form for maximum cross-version compatibility.
+
load themes
+
Defaults to:FALSE
+
If set to TRUE, then plugins of this type can be supplied by themes as well as modules. If this is the case, all themes that are currently enabled will provide a plugin: NOTE: Due to a slight UI bug in Drupal, it is possible for the default theme to be active but not enabled. If this is the case, that theme will NOT provide plugins, so if you are using this feature, be sure to document that issue. Also, themes set via $custom_theme do not necessarily need to be enabled, but the system has no way of knowing what those themes are, so the enabled flag is the only true method of identifying which themes can provide layouts.
+
hook
+
Defaults to: (dynamic value)
+
The name of the hook used to collect data for this plugin. Normally this is $module . '_' . $type -- but this can be changed here. If you change this, you MUST be sure to document this for your plugin implementors as it will change the format of the specially named hook.
+
process
+
Defaults to:''
+
An optional function callback to use for processing a plugin. This can be used to provide automated settings that must be calculated per-plugin instance (i.e., it is not enough to simply append an array via 'defaults'). The parameters on this callback are: callback(&$plugin, $info) where $plugin is a reference to the plugin as processed and $info is the fully processed result of hook_ctools_plugin_api_info().
+
extension
+
Defaults to:'inc'
+
Can be used to change the extension on files containing plugins of this type. By default the extension will be "inc", though it will default to "info" if "info files" is set to true. Do not include the dot in the extension if changing it, that will be added automatically.
+
info file
+
Defaults to:FALSE
+
If set to TRUE, then the plugin will look for a .info file instead of a .inc. Internally, this will look exactly the same, though obviously a .info file cannot contain functions. This can be good for styles that may not need to contain code.
+
use hooks
+
Defaults to:TRUE*
+
Use to enable support for plugin definition hooks instead of plugin definition files. NOTE: using a central plugin definition hook is less optimal for the plugins system, and as such this will default to FALSE in later versions.
+
child plugins
+
Defaults to:FALSE
+
If set to TRUE, the plugin type can automatically have 'child plugins' meaning each plugin can actually provide multiple plugins. This is mostly used for plugins that store some of their information in the database, such as views, blocks or exportable custom versions of plugins.
+
To implement, each plugin can have a 'get child' and 'get children' callback. Both of these should be implemented for performance reasons, since it is best to avoid getting all children if necessary, but if 'get child' is not implemented, it will fall back to 'get children' if it has to.
+
Child plugins should be named parent:child, with the : being the separator, so that it knows which parent plugin to ask for the child. The 'get children' method should at least return the parent plugin as part of the list, unless it wants the parent plugin itself to not be a choosable option, which is not unheard of.
+
'get children' arguments are ($plugin, $parent) and 'get child' arguments are ($plugin, $parent, $child).
+
+
+In addition, there is a 'module' and 'type' settings; these are for internal use of the plugin system and you should not change these.
+
Getting the data
+To create a plugin, a module only has to execute ctools_get_plugins with the right data:
+
+
+
+In the above example, $module should be your module's name and $type is the type of the plugin. It is typically best practice to provide some kind of wrapper function to make this easier. For example, Panels provides the following functions to implement the 'content_types' plugin:
+
+
+/**
+ * Fetch metadata on a specific content_type plugin.
+ *
+ * @param $content type
+ * Name of a panel content type.
+ *
+ * @return
+ * An array with information about the requested panel content type.
+ */
+function panels_get_content_type($content_type) {
+ ctools_include('context');
+ ctools_include('plugins');
+ return ctools_get_plugins('panels', 'content_types', $content_type);
+}
+
+/**
+ * Fetch metadata for all content_type plugins.
+ *
+ * @return
+ * An array of arrays with information about all available panel content types.
+ */
+function panels_get_content_types() {
+ ctools_include('context');
+ ctools_include('plugins');
+ return ctools_get_plugins('panels', 'content_types');
+}
+
+
+
Using the data
+
+Each plugin returns a packet of data, which is added to with a few defaults. Each plugin is guaranteed to always have the following data:
+
+
name
+
The name of the plugin. This is also the key in the array, of the full list of plugins, and is placed here since that is not always available.
+
module
+
The module that supplied the plugin.
+
file
+
The actual file containing the plugin.
+
path
+
The path to the file containing the plugin. This is useful for using secondary files, such as templates, css files, images, etc, that may come with a plugin.
+
+
+
Any of the above items can be overridden by the plugin itself, though the most likely one to be modified is the 'path'.
+
+
The most likely data (beyond simple printable data) for a plugin to provide is a callback. The plugin system provides a pair of functions to make it easy and consistent for these callbacks to be used. The first is ctools_plugin_get_function, which requires the full $plugin object.
+
+
+/**
+ * Get a function from a plugin, if it exists. If the plugin is not already
+ * loaded, try ctools_plugin_load_function() instead.
+ *
+ * @param $plugin
+ * The loaded plugin type.
+ * @param $callback_name
+ * The identifier of the function. For example, 'settings form'.
+ *
+ * @return
+ * The actual name of the function to call, or NULL if the function
+ * does not exist.
+ */
+function ctools_plugin_get_function($plugin, $callback_name)
+
+
+
The second does not require the full $plugin object, and will load it:
+
+
+/**
+ * Load a plugin and get a function name from it, returning success only
+ * if the function exists.
+ *
+ * @param $module
+ * The module that owns the plugin type.
+ * @param $type
+ * The type of plugin.
+ * @param $id
+ * The id of the specific plugin to load.
+ * @param $callback_name
+ * The identifier of the function. For example, 'settings form'.
+ *
+ * @return
+ * The actual name of the function to call, or NULL if the function
+ * does not exist.
+ */
+function ctools_plugin_load_function($module, $type, $id, $callback_name) {
+
+
+
Both of these functions will ensure any needed files are included. In fact, it allows each callback to specify alternative include files. The plugin implementation could include code like this:
Since the data provided by your plugin tends to be specific to your plugin type, you really need to document what the data returned in the hook in the .inc file will be or nobody will figure it out. Use advanced help and document it there. If every system that utilizes plugins does this, then plugin implementors will quickly learn to expect the documentation to be in the advanced help.
diff --git a/sites/all/modules/contrib/ctools/help/plugins-implementing.html b/sites/all/modules/contrib/ctools/help/plugins-implementing.html
new file mode 100644
index 0000000..c95e72d
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/plugins-implementing.html
@@ -0,0 +1,62 @@
+
There are two parts to implementing a plugin: telling the system where it is, and implementing one or more .inc files that contain the plugin data.
+
+
Telling the system where your plugins live
+
How a module implements plugins
+
To implement any plugins at all, you must implement a single function for all plugins: hook_ctools_plugin_directory. Every time a module loads plugins, this hook will be called to see which modules implement those plugins and in what directory those plugins will live.
The directory returned should be relative to your module. Another common usage is to simply return that you implement all plugins owned by a given module (or modules):
Typically, it is recommended that all plugins be placed into the 'plugins' directory for clarity and maintainability. Inside the directory, any number of subdirectories can be used. For plugins that require extra files, such as templates, css, javascript or image files, this is highly recommended:
Themes can implement plugins if the plugin owner specified that it's possible in its hook_ctools_plugin_type() call. If so, it is generally exactly the same as modules, except for one important difference: themes don't get hook_ctools_plugin_directory(). Instead, themes add a line to their .info file:
+
+
+plugins[module][type] = directory
+
+
+
How to structure the .inc file
+
+
The top of the .inc file should contain an array that defines the plugin. This array is simply defined in the global namespace of the file and does not need a function. Note that previous versions of this plugin system required a specially named function. While this function will still work, its use is now discouraged, as it is annoying to name properly.
+
+
This array should look something like this:
+
+
+$plugin = array(
+ 'key' => 'value',
+);
+
+
+
Several values will be filled in for you automatically, but you can override them if necessary. They include 'name', 'path', 'file' and 'module'. Additionally, the plugin owner can provide other defaults as well.
+
+
There are no required keys by the plugin system itself. The only requirements in the $plugin array will be defined by the plugin type.
+
+
After this array, if your plugin needs functions, they can be declared. Different plugin types have different needs here, so exactly what else will be needed will change from type to type.
diff --git a/sites/all/modules/contrib/ctools/help/plugins.html b/sites/all/modules/contrib/ctools/help/plugins.html
new file mode 100644
index 0000000..1e64da0
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/plugins.html
@@ -0,0 +1,5 @@
+
The plugins tool allows a module to allow other modules (and themes!) to provide plugins which provide some kind of functionality or some kind of task. For example, in Panels there are several types of plugins: Content types (which are like blocks), layouts (which are page layouts) and styles (which can be used to style a panel). Each plugin is represented by a .inc file, and the functionality they offer can differ wildly.
+
+
A module which uses plugins can implement a hook describing the plugin (which is not necessary, as defaults will be filled in) and then calls a ctools function which loads either all the known plugins (used for listing/choosing) or a specific plugin (used when it's known which plugin is needed). From the perspective of the plugin system, a plugin is a packet of data, usually some printable info and a list of callbacks. It is up to the module implementing plugins to determine what that info means and what the callbacks do.
+
+
A module which implements plugins must first implement the hook_ctools_plugin_directory function, which simply tells the system which plugins are supported and what directory to look in. Each plugin will then be in a separate .inc file in the directory supplied. The .inc file will contain a specially named hook which returns the data necessary to implement the plugin.
diff --git a/sites/all/modules/contrib/ctools/help/wizard.html b/sites/all/modules/contrib/ctools/help/wizard.html
new file mode 100644
index 0000000..33fc456
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/help/wizard.html
@@ -0,0 +1,311 @@
+
Form wizards, or multi-step forms, are a process by which the user goes through or can use an arbitrary number of different forms to create a single object or perform a single task. Traditionally the multi-step form is difficult in Drupal because there is no easy place to put data in between forms. No longer! The form wizard tool allows a single entry point to easily set up a wizard of multiple forms, provide callbacks to handle data storage and updates between forms and when forms are completed. This tool pairs well with the object cache tool for storage.
+
+
The form info array
+
The wizard starts with an array of data that describes all of the forms available to the wizard and sets options for how the wizard will present and control the flow. Here is an example of the $form_info array as used in the delegator module:
The above array starts with an id which is used to identify the wizard in various places and a path which is needed to redirect to the next step between forms. It then creates some settings which control which pieces are displayed. In this case, it displays a form trail and a 'back' button, but not the 'return' button. Then there are the wizard callbacks which allow the wizard to act appropriately when forms are submitted. Finally it contains a list of forms and their order so that it knows which forms to use and what order to use them by default. Note that the keys in the order and list of forms match; that key is called the step and is used to identify each individual step of the wizard.
+
+
Here is a full list of every item that can be in the form info array:
+
+
+
id
+
An id for wizard. This is used like a hook to automatically name callbacks, as well as a form step's form building function. It is also used in trail theming.
+
+
path
+
The path to use when redirecting between forms. %step will be replaced with the key for the form.
+
+
return path
+
When a form is complete, this is the path to go to. This is required if the 'return' button is shown and not using AJAX. It is also used for the 'Finish' button. If it is not present and needed, the cancel path will also be checked.
+
+
cancel path
+
When a form is canceled, this is the path to go to. This is required if the 'cancel' is shown and not using AJAX.
+
+
show trail
+
If set to TRUE, the form trail will be shown like a breadcrumb at the top of each form. Defaults to FALSE.
+
+
show back
+
If set to TRUE, show a back button on each form. Defaults to FALSE.
+
+
show return
+
If set to TRUE, show a return button. Defaults to FALSE.
+
+
show cancel
+
If set to TRUE, show a cancel button. Defaults to FALSE.
+
+
back text
+
Set the text of the 'back' button. Defaults to t('Back').
+
+
next text
+
Set the text of the 'next' button. Defaults to t('Continue').
+
+
return text
+
Set the text of the 'return' button. Defaults to t('Update and return').
+
+
finish text
+
Set the text of the 'finish' button. Defaults to t('Finish').
+
+
cancel text
+
Set the text of the 'cancel' button. Defaults to t('Cancel').
+
+
ajax
+
Turn on AJAX capabilities, using CTools' ajax.inc. Defaults to FALSE.
+
+
modal
+
Put the wizard in the modal tool. The modal must already be open and called from an ajax button for this to work, which is easily accomplished using functions provided by the modal tool.
+
+
ajax render
+
A callback to display the rendered form via ajax. This is not required if using the modal tool, but is required otherwise since ajax by itself does not know how to render the results. Params: &$form_state, $output.
+
+
finish callback
+
The function to call when a form is complete and the finish button has been clicked. This function should finalize all data. Params: &$form_state.
+Defaults to $form_info['id']._finish if function exists.
+
+
+
cancel callback
+
The function to call when a form is canceled by the user. This function should clean up any data that is cached. Params: &$form_state.
+Defaults to $form_info['id']._cancel if function exists.
+
+
return callback
+
The function to call when a form is complete and the return button has been clicked. This is often the same as the finish callback. Params: &$form_state.
+Defaults to $form_info['id']._return if function exists.
+
+
next callback
+
The function to call when the next button has been clicked. This function should take the submitted data and cache it for later use by the finish callback. Params: &$form_state.
+Defaults to $form_info['id']._next if function exists.
+
+
order
+
An optional array of forms, keyed by the step, which represents the default order the forms will be displayed in. If not set, the forms array will control the order. Note that submit callbacks can override the order so that branching logic can be used.
+
+
forms
+
An array of form info arrays, keyed by step, describing every form available to the wizard. If order array isn't set, the wizard will use this to set the default order. Each array contains:
+
+
form id
+
+ The id of the form, as used in the Drupal form system. This is also the name of the function that represents the form builder.
+ Defaults to $form_info['id']._.$step._form.
+
+
+
include
+
The name of a file to include which contains the code for this form. This makes it easy to include the form wizard in another file or set of files. This must be the full path of the file, so be sure to use drupal_get_path() when setting this. This can also be an array of files if multiple files need to be included.
+
+
title
+
The title of the form, to be optionally set via drupal_get_title. This is required when using the modal if $form_state['title'] is not set.
+
+
+
+
+
Invoking the form wizard
+
Your module should create a page callback via hook_menu, and this callback should contain an argument for the step. The path that leads to this page callback should be the same as the 'path' set in the $form_info array.
+
+
The page callback should set up the $form_info, and figure out what the default step should be if no step is provided (note that the wizard does not do this for you; you MUST specify a step). Then invoke the form wizard:
If using AJAX or the modal, This part is actually done! If not, you have one more small step:
+
+
+ return $output;
+
+
+
Forms and their callbacks
+
Each form within the wizard is a complete, independent form using Drupal's Form API system. It has a form builder callback as well as submit and validate callbacks and can be form altered. The primary difference between these forms and a normal Drupal form is that the submit handler should not save any data. Instead, it should make any changes to a cached object (usually placed on the $form_state) and only the _finish or _return handler should actually save any real data.
+
+
How you handle this is completely up to you. The recommended best practice is to use the CTools Object cache, and a good way to do this is to write a couple of wrapper functions around the cache that look like these example functions:
+
+
+/**
+ * Get the cached changes to a given task handler.
+ */
+function delegator_page_get_page_cache($name) {
+ ctools_include('object-cache');
+ $cache = ctools_object_cache_get('delegator_page', $name);
+ if (!$cache) {
+ $cache = delegator_page_load($name);
+ $cache->locked = ctools_object_cache_test('delegator_page', $name);
+ }
+
+ return $cache;
+}
+
+/**
+ * Store changes to a task handler in the object cache.
+ */
+function delegator_page_set_page_cache($name, $page) {
+ ctools_include('object-cache');
+ $cache = ctools_object_cache_set('delegator_page', $name, $page);
+}
+
+/**
+ * Remove an item from the object cache.
+ */
+function delegator_page_clear_page_cache($name) {
+ ctools_include('object-cache');
+ ctools_object_cache_clear('delegator_page', $name);
+}
+
+
+
Using these wrappers, when performing a get_cache operation, it defaults to loading the real object. It then checks to see if another user has this object cached using the ctools_object_cache_test() function, which automatically sets a lock (which can be used to prevent writes later on).
+
+
With this set up, the _next, _finish and _cancel callbacks are quite simple:
+
+
+/**
+ * Callback generated when the add page process is finished.
+ */
+function delegator_page_add_subtask_finish(&$form_state) {
+ $page = &$form_state['page'];
+
+ // Create a real object from the cache
+ delegator_page_save($page);
+
+ // Clear the cache
+ delegator_page_clear_page_cache($form_state['cache name']);
+}
+
+/**
+ * Callback generated when the 'next' button is clicked.
+ *
+ * All we do here is store the cache.
+ */
+function delegator_page_add_subtask_next(&$form_state) {
+ // Update the cache with changes.
+ delegator_page_set_page_cache($form_state['cache name'], $form_state['page']);
+}
+
+/**
+ * Callback generated when the 'cancel' button is clicked.
+ *
+ * All we do here is clear the cache.
+ */
+function delegator_page_add_subtask_cancel(&$form_state) {
+ // Update the cache with changes.
+ delegator_page_clear_page_cache($form_state['cache name']);
+}
+
+
+
All that's needed to tie this together is to understand how the changes made it into the cache in the first place. This happened in the various form _submit handlers, which made changes to $form_state['page'] based upon the values set in the form:
+
+
+/**
+ * Store the values from the basic settings form.
+ */
+function delegator_page_form_basic_submit($form, &$form_state) {
+ if (!isset($form_state['page']->pid) && empty($form_state['page']->import)) {
+ $form_state['page']->name = $form_state['values']['name'];
+ }
+
+ $form_state['page']->admin_title = $form_state['values']['admin_title'];
+ $form_state['page']->path = $form_state['values']['path'];
+
+ return $form;
+}
+
+
+
No database operations were made during this _submit, and that's a very important distinction about this system.
+
+
Proper handling of back button
+
When using 'show back' => TRUE the cached data should be assigned to the #default_value form property. Otherwise when the user goes back to the previous step the forms default values instead of his (cached) input is used.
The data is stored in the my data object on submitting. If the user goes back to this step the cached my data is used as the default form value. The function my_module_get_cache() is like the cache functions explained above.
+
+
Required fields, cancel and back buttons
+
If you have required fields in your forms, the back and cancel buttons will not work as expected since validation of the form will fail. You can add the following code to the top of your form validation to avoid this problem:
+
+/**
+ * Validation handler for step2 form
+ */
+function wizardid_step2_form_validate(&$form, &$form_state) {
+ // if the clicked button is anything but the normal flow
+ if ($form_state['clicked_button']['#next'] != $form_state['next']) {
+ drupal_get_messages('error');
+ form_set_error(NULL, '', TRUE);
+ return;
+ }
+ // you form validation goes here
+ // ...
+}
+
+
+
Wizard for anonymous users
+
If you are creating a wizard which is be used by anonymous users, you might run into some issues with drupal's caching for anonymous users. You can circumvent this by using hook_init and telling drupal to not cache your wizard pages:
+
+/**
+ * Implementation of hook init
+ */
+function mymodule_init() {
+ // if the path leads to the wizard
+ if (drupal_match_path($_GET['q'], 'path/to/your/wizard/*')) {
+ // set cache to false
+ $GLOBALS['conf']['cache'] = FALSE;
+ }
+}
+
diff --git a/sites/all/modules/contrib/ctools/images/arrow-active.png b/sites/all/modules/contrib/ctools/images/arrow-active.png
new file mode 100644
index 0000000..3bbd3c2
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/arrow-active.png differ
diff --git a/sites/all/modules/contrib/ctools/images/collapsible-collapsed.png b/sites/all/modules/contrib/ctools/images/collapsible-collapsed.png
new file mode 100644
index 0000000..95a214a
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/collapsible-collapsed.png differ
diff --git a/sites/all/modules/contrib/ctools/images/collapsible-expanded.png b/sites/all/modules/contrib/ctools/images/collapsible-expanded.png
new file mode 100644
index 0000000..46f39ec
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/collapsible-expanded.png differ
diff --git a/sites/all/modules/contrib/ctools/images/expanded-options.png b/sites/all/modules/contrib/ctools/images/expanded-options.png
new file mode 100644
index 0000000..b7b755c
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/expanded-options.png differ
diff --git a/sites/all/modules/contrib/ctools/images/icon-close-window.png b/sites/all/modules/contrib/ctools/images/icon-close-window.png
new file mode 100644
index 0000000..5f0cf69
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/icon-close-window.png differ
diff --git a/sites/all/modules/contrib/ctools/images/icon-configure.png b/sites/all/modules/contrib/ctools/images/icon-configure.png
new file mode 100644
index 0000000..e23d67c
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/icon-configure.png differ
diff --git a/sites/all/modules/contrib/ctools/images/icon-delete.png b/sites/all/modules/contrib/ctools/images/icon-delete.png
new file mode 100644
index 0000000..5f0cf69
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/icon-delete.png differ
diff --git a/sites/all/modules/contrib/ctools/images/no-icon.png b/sites/all/modules/contrib/ctools/images/no-icon.png
new file mode 100644
index 0000000..fa78ec1
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/no-icon.png differ
diff --git a/sites/all/modules/contrib/ctools/images/status-active.gif b/sites/all/modules/contrib/ctools/images/status-active.gif
new file mode 100644
index 0000000..207e95c
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/status-active.gif differ
diff --git a/sites/all/modules/contrib/ctools/images/throbber.gif b/sites/all/modules/contrib/ctools/images/throbber.gif
new file mode 100644
index 0000000..8a084b8
Binary files /dev/null and b/sites/all/modules/contrib/ctools/images/throbber.gif differ
diff --git a/sites/all/modules/contrib/ctools/includes/action-links.theme.inc b/sites/all/modules/contrib/ctools/includes/action-links.theme.inc
new file mode 100644
index 0000000..3a2398a
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/action-links.theme.inc
@@ -0,0 +1,33 @@
+ 'links',
+ 'file' => 'includes/action-links.theme.inc',
+ );
+}
+
+/**
+ * Render a menu local actions wrapper.
+ *
+ * @param $links
+ * Local actions links.
+ * @param $attributes
+ * An array of attributes to append to the wrapper.
+ */
+function theme_ctools_menu_local_actions_wrapper($variables) {
+ $links = drupal_render($variables['links']);
+
+ if (empty($links)) {
+ return;
+ }
+
+ return '
' . $links . '
';
+}
\ No newline at end of file
diff --git a/sites/all/modules/contrib/ctools/includes/ajax.inc b/sites/all/modules/contrib/ctools/includes/ajax.inc
new file mode 100644
index 0000000..96f5068
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/ajax.inc
@@ -0,0 +1,157 @@
+ $image)), $dest, $alt, $class);
+}
+
+/**
+ * Render text as a link. This will automatically apply an AJAX class
+ * to the link and add the appropriate javascript to make this happen.
+ *
+ * Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will
+ * not use user input so this is a very minor concern.
+ *
+ * @param $text
+ * The text that will be displayed as the link.
+ * @param $dest
+ * The destination of the link.
+ * @param $alt
+ * The alt text of the link.
+ * @param $class
+ * Any class to apply to the link. @todo this should be a options array.
+ * @param $type
+ * A type to use, in case a different behavior should be attached. Defaults
+ * to ctools-use-ajax.
+ */
+function ctools_ajax_text_button($text, $dest, $alt, $class = '', $type = 'use-ajax') {
+ drupal_add_library('system', 'drupal.ajax');
+ return l($text, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
+}
+
+/**
+ * Render an icon and related text as a link. This will automatically apply an AJAX class
+ * to the link and add the appropriate javascript to make this happen.
+ *
+ * Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will
+ * not use user input so this is a very minor concern.
+ *
+ * @param $text
+ * The text that will be displayed as the link.
+ * @param $image
+ * The icon image to include in the link.
+ * @param $dest
+ * The destination of the link.
+ * @param $alt
+ * The title text of the link.
+ * @param $class
+ * Any class to apply to the link. @todo this should be a options array.
+ * @param $type
+ * A type to use, in case a different behavior should be attached. Defaults
+ * to ctools-use-ajax.
+ */
+function ctools_ajax_icon_text_button($text, $image, $dest, $alt, $class = '', $type = 'use-ajax') {
+ drupal_add_library('system', 'drupal.ajax');
+ $rendered_image = theme('image', array('path' => $image));
+ $link_content = $rendered_image . "" . $text . "";
+ return l($link_content, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
+}
+
+/**
+ * Set a single property to a value, on all matched elements.
+ *
+ * @param $selector
+ * The CSS selector. This can be any selector jquery uses in $().
+ * @param $name
+ * The name or key: of the data attached to this selector.
+ * @param $value
+ * The value of the data.
+ */
+function ctools_ajax_command_attr($selector, $name, $value) {
+ ctools_add_js('ajax-responder');
+ return array(
+ 'command' => 'attr',
+ 'selector' => $selector,
+ 'name' => $name,
+ 'value' => $value,
+ );
+ }
+
+/**
+ * Force a client-side redirect.
+ *
+ * @param $url
+ * The url to be redirected to. This can be an absolute URL or a
+ * Drupal path.
+ * @param $delay
+ * A delay before applying the redirection, in milliseconds.
+ * @param $options
+ * An array of options to pass to the url() function.
+ */
+function ctools_ajax_command_redirect($url, $delay = 0, $options = array()) {
+ ctools_add_js('ajax-responder');
+ return array(
+ 'command' => 'redirect',
+ 'url' => url($url, $options),
+ 'delay' => $delay,
+ );
+}
+
+/**
+ * Force a reload of the current page.
+ */
+function ctools_ajax_command_reload() {
+ ctools_add_js('ajax-responder');
+ return array(
+ 'command' => 'reload',
+ );
+}
+
+/**
+ * Submit a form.
+ *
+ * This is useful for submitting a parent form after a child form has finished
+ * processing in a modal overlay.
+ *
+ * @param $selector
+ * The CSS selector to identify the form for submission. This can be any
+ * selector jquery uses in $().
+ */
+function ctools_ajax_command_submit($selector) {
+ ctools_add_js('ajax-responder');
+ return array(
+ 'command' => 'submit',
+ 'selector' => $selector,
+ );
+}
+
+/**
+ * Send an error response back via AJAX and immediately exit.
+ */
+function ctools_ajax_render_error($error = '') {
+ $commands = array();
+ $commands[] = ajax_command_alert($error);
+ print ajax_render($commands);
+ exit;
+}
+
diff --git a/sites/all/modules/contrib/ctools/includes/cache.inc b/sites/all/modules/contrib/ctools/includes/cache.inc
new file mode 100644
index 0000000..3918683
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/cache.inc
@@ -0,0 +1,169 @@
+ TRUE,
+ 'ignore words' => array(),
+ 'separator' => '-',
+ 'replacements' => array(),
+ 'transliterate' => FALSE,
+ 'reduce ascii' => TRUE,
+ 'max length' => FALSE,
+ 'lower case' => FALSE,
+ );
+
+ // Allow modules to make other changes to the settings.
+ if (isset($settings['clean id'])) {
+ drupal_alter('ctools_cleanstring_' . $settings['clean id'], $settings);
+ }
+
+ drupal_alter('ctools_cleanstring', $settings);
+
+ $output = $string;
+
+ // Do any replacements the user selected up front.
+ if (!empty($settings['replacements'])) {
+ $output = strtr($output, $settings['replacements']);
+ }
+
+ // Remove slashes if instructed to do so.
+ if ($settings['clean slash']) {
+ $output = str_replace('/', '', $output);
+ }
+
+ if (!empty($settings['transliterate']) && module_exists('transliteration')) {
+ $output = transliteration_get($output);
+ }
+
+ // Reduce to the subset of ASCII96 letters and numbers
+ if ($settings['reduce ascii']) {
+ $pattern = '/[^a-zA-Z0-9\/]+/';
+ $output = preg_replace($pattern, $settings['separator'], $output);
+ }
+
+ // Get rid of words that are on the ignore list
+ if (!empty($settings['ignore words'])) {
+ $ignore_re = '\b' . preg_replace('/,/', '\b|\b', $settings['ignore words']) . '\b';
+
+ if (function_exists('mb_eregi_replace')) {
+ $output = mb_eregi_replace($ignore_re, '', $output);
+ }
+ else {
+ $output = preg_replace("/$ignore_re/i", '', $output);
+ }
+ }
+
+ // Always replace whitespace with the separator.
+ $output = preg_replace('/\s+/', $settings['separator'], $output);
+
+ // In preparation for pattern matching,
+ // escape the separator if and only if it is not alphanumeric.
+ if (isset($settings['separator'])) {
+ if (preg_match('/^[^' . CTOOLS_PREG_CLASS_ALNUM . ']+$/uD', $settings['separator'])) {
+ $seppattern = $settings['separator'];
+ }
+ else {
+ $seppattern = '\\' . $settings['separator'];
+ }
+ // Trim any leading or trailing separators (note the need to
+ $output = preg_replace("/^$seppattern+|$seppattern+$/", '', $output);
+
+ // Replace multiple separators with a single one
+ $output = preg_replace("/$seppattern+/", $settings['separator'], $output);
+ }
+
+ // Enforce the maximum component length
+ if (!empty($settings['max length'])) {
+ $output = ctools_cleanstring_truncate($output, $settings['max length'], $settings['separator']);
+ }
+
+ if (!empty($settings['lower case'])) {
+ $output = drupal_strtolower($output);
+ }
+ return $output;
+}
+
+/**
+ * A friendly version of truncate_utf8.
+ *
+ * @param $string
+ * The string to be truncated.
+ * @param $length
+ * An integer for the maximum desired length.
+ * @param $separator
+ * A string which contains the word boundary such as - or _.
+ *
+ * @return
+ * The string truncated below the maxlength.
+ */
+function ctools_cleanstring_truncate($string, $length, $separator) {
+ if (drupal_strlen($string) > $length) {
+ $string = drupal_substr($string, 0, $length + 1); // leave one more character
+ if ($last_break = strrpos($string, $separator)) { // space exists AND is not on position 0
+ $string = substr($string, 0, $last_break);
+ }
+ else {
+ $string = drupal_substr($string, 0, $length);
+ }
+ }
+ return $string;
+}
diff --git a/sites/all/modules/contrib/ctools/includes/collapsible.theme.inc b/sites/all/modules/contrib/ctools/includes/collapsible.theme.inc
new file mode 100644
index 0000000..f7bbbb3
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/collapsible.theme.inc
@@ -0,0 +1,79 @@
+ array('handle' => NULL, 'content' => NULL, 'collapsed' => FALSE),
+ 'file' => 'includes/collapsible.theme.inc',
+ );
+ $items['ctools_collapsible_remembered'] = array(
+ 'variables' => array('id' => NULL, 'handle' => NULL, 'content' => NULL, 'collapsed' => FALSE),
+ 'file' => 'includes/collapsible.theme.inc',
+ );
+}
+
+/**
+ * Render a collapsible div.
+ *
+ * @param $handle
+ * Text to put in the handle/title area of the div.
+ * @param $content
+ * Text to put in the content area of the div, this is what will get
+ * collapsed
+ * @param $collapsed = FALSE
+ * If true, this div will start out collapsed.
+ */
+function theme_ctools_collapsible($vars) {
+ ctools_add_js('collapsible-div');
+ ctools_add_css('collapsible-div');
+
+ $class = $vars['collapsed'] ? ' ctools-collapsed' : '';
+ $output = '
';
+ $output .= '
' . $vars['handle'] . '
';
+ $output .= '
' . $vars['content'] . '
';
+ $output .= '
';
+
+ return $output;
+}
+
+/**
+ * Render a collapsible div whose state will be remembered.
+ *
+ * @param $id
+ * The CSS id of the container. This is required.
+ * @param $handle
+ * Text to put in the handle/title area of the div.
+ * @param $content
+ * Text to put in the content area of the div, this is what will get
+ * collapsed
+ * @param $collapsed = FALSE
+ * If true, this div will start out collapsed.
+ */
+function theme_ctools_collapsible_remembered($vars) {
+ $id = $vars['id'];
+ $handle = $vars['handle'];
+ $content = $vars['content'];
+ $collapsed = $vars['collapsed'];
+ ctools_add_js('collapsible-div');
+ ctools_add_css('collapsible-div');
+
+ $class = $collapsed ? ' ctools-collapsed' : '';
+ $output = '
';
+ $output .= '
' . $handle . '
';
+ $output .= '
' . $content . '
';
+ $output .= '
';
+
+ return $output;
+}
+
diff --git a/sites/all/modules/contrib/ctools/includes/content.inc b/sites/all/modules/contrib/ctools/includes/content.inc
new file mode 100644
index 0000000..ae1c607
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/content.inc
@@ -0,0 +1,853 @@
+ $plugin['title'],
+ 'description' => $plugin['description'],
+ 'icon' => ctools_content_admin_icon($plugin),
+ 'category' => $plugin['category'],
+ );
+
+ if (isset($plugin['required context'])) {
+ $type['required context'] = $plugin['required context'];
+ }
+ if (isset($plugin['top level'])) {
+ $type['top level'] = $plugin['top level'];
+ }
+ $plugin['content types'] = array($plugin['name'] => $type);
+ if (!isset($plugin['single'])) {
+ $plugin['single'] = TRUE;
+ }
+ }
+ }
+}
+
+/**
+ * Fetch metadata on a specific content_type plugin.
+ *
+ * @param $content type
+ * Name of a panel content type.
+ *
+ * @return
+ * An array with information about the requested panel content type.
+ */
+function ctools_get_content_type($content_type) {
+ ctools_include('context');
+ ctools_include('plugins');
+ return ctools_get_plugins('ctools', 'content_types', $content_type);
+}
+
+/**
+ * Fetch metadata for all content_type plugins.
+ *
+ * @return
+ * An array of arrays with information about all available panel content types.
+ */
+function ctools_get_content_types() {
+ ctools_include('context');
+ ctools_include('plugins');
+ return ctools_get_plugins('ctools', 'content_types');
+}
+
+/**
+ * Get all of the individual subtypes provided by a given content type. This
+ * would be all of the blocks for the block type, or all of the views for
+ * the view type.
+ *
+ * @param $type
+ * The content type to load.
+ *
+ * @return
+ * An array of all subtypes available.
+ */
+function ctools_content_get_subtypes($type) {
+ static $cache = array();
+
+ $subtypes = array();
+
+ if (is_array($type)) {
+ $plugin = $type;
+ }
+ else {
+ $plugin = ctools_get_content_type($type);
+ }
+
+ if (empty($plugin) || empty($plugin['name'])) {
+ return;
+ }
+
+ if (isset($cache[$plugin['name']])) {
+ return $cache[$plugin['name']];
+ }
+
+ if (isset($plugin['content types'])) {
+ $function = $plugin['content types'];
+ if (is_array($function)) {
+ $subtypes = $function;
+ }
+ else if (function_exists($function)) {
+ // Cast to array to prevent errors from non-array returns.
+ $subtypes = (array) $function($plugin);
+ }
+ }
+
+ // Walk through the subtypes and ensure minimal settings are
+ // retained.
+ foreach ($subtypes as $id => $subtype) {
+ // Use exact name since this is a modify by reference.
+ ctools_content_prepare_subtype($subtypes[$id], $plugin);
+ }
+
+ $cache[$plugin['name']] = $subtypes;
+
+ return $subtypes;
+}
+
+/**
+ * Given a content type and a subtype id, return the information about that
+ * content subtype.
+ *
+ * @param $type
+ * The content type being fetched.
+ * @param $subtype_id
+ * The id of the subtype being fetched.
+ *
+ * @return
+ * An array of information describing the content subtype.
+ */
+function ctools_content_get_subtype($type, $subtype_id) {
+ $subtype = array();
+ if (is_array($type)) {
+ $plugin = $type;
+ }
+ else {
+ $plugin = ctools_get_content_type($type);
+ }
+
+ $function = ctools_plugin_get_function($plugin, 'content type');
+ if ($function) {
+ $subtype = $function($subtype_id, $plugin);
+ }
+ else {
+ $subtypes = ctools_content_get_subtypes($type);
+ if (isset($subtypes[$subtype_id])) {
+ $subtype = $subtypes[$subtype_id];
+ }
+ // If there's only 1 and we somehow have the wrong subtype ID, do not
+ // care. Return the proper subtype anyway.
+ if (empty($subtype) && !empty($plugin['single'])) {
+ $subtype = current($subtypes);
+ }
+ }
+
+ if ($subtype) {
+ ctools_content_prepare_subtype($subtype, $plugin);
+ }
+ return $subtype;
+}
+
+/**
+ * Ensure minimal required settings on a content subtype exist.
+ */
+function ctools_content_prepare_subtype(&$subtype, $plugin) {
+ foreach (array('path', 'js', 'css') as $key) {
+ if (!isset($subtype[$key]) && isset($plugin[$key])) {
+ $subtype[$key] = $plugin[$key];
+ }
+ }
+
+ drupal_alter('ctools_content_subtype', $subtype, $plugin);
+}
+
+/**
+ * Get the content from a given content type.
+ *
+ * @param $type
+ * The content type. May be the name or an already loaded content type plugin.
+ * @param $subtype
+ * The name of the subtype being rendered.
+ * @param $conf
+ * The configuration for the content type.
+ * @param $keywords
+ * An array of replacement keywords that come from outside contexts.
+ * @param $args
+ * The arguments provided to the owner of the content type. Some content may
+ * wish to configure itself based on the arguments the panel or dashboard
+ * received.
+ * @param $context
+ * An array of context objects available for use.
+ * @param $incoming_content
+ * Any incoming content, if this display is a wrapper.
+ *
+ * @return
+ * The content as rendered by the plugin. This content should be an array
+ * with the following possible keys:
+ * - title: The safe to render title of the content.
+ * - title_heading: The title heading.
+ * - content: The safe to render HTML content.
+ * - links: An array of links associated with the content suitable for
+ * theme('links').
+ * - more: An optional 'more' link (destination only)
+ * - admin_links: Administrative links associated with the content, suitable
+ * for theme('links').
+ * - feeds: An array of feed icons or links associated with the content.
+ * Each member of the array is rendered HTML.
+ * - type: The content type.
+ * - subtype: The content subtype. These two may be used together as
+ * module-delta for block style rendering.
+ */
+function ctools_content_render($type, $subtype, $conf, $keywords = array(), $args = array(), $context = array(), $incoming_content = '') {
+ if (is_array($type)) {
+ $plugin = $type;
+ }
+ else {
+ $plugin = ctools_get_content_type($type);
+ }
+
+ $subtype_info = ctools_content_get_subtype($plugin, $subtype);
+
+ $function = ctools_plugin_get_function($subtype_info, 'render callback');
+ if (!$function) {
+ $function = ctools_plugin_get_function($plugin, 'render callback');
+ }
+
+ if ($function) {
+ $pane_context = ctools_content_select_context($plugin, $subtype, $conf, $context);
+ if ($pane_context === FALSE) {
+ return;
+ }
+
+ $content = $function($subtype, $conf, $args, $pane_context, $incoming_content);
+
+ if (empty($content)) {
+ return;
+ }
+
+ // Set up some defaults and other massaging on the content before we hand
+ // it back to the caller.
+ if (!isset($content->type)) {
+ $content->type = $plugin['name'];
+ }
+
+ if (!isset($content->subtype)) {
+ $content->subtype = $subtype;
+ }
+
+ // Override the title if configured to
+ if (!empty($conf['override_title'])) {
+ // Give previous title as an available substitution here.
+ $keywords['%title'] = empty($content->title) ? '' : $content->title;
+ $content->original_title = $keywords['%title'];
+ $content->title = $conf['override_title_text'];
+ $content->title_heading = isset($conf['override_title_heading']) ? $conf['override_title_heading'] : 'h2';
+ }
+
+ if (!empty($content->title)) {
+ // Perform substitutions
+ if (!empty($keywords) || !empty($context)) {
+ $content->title = ctools_context_keyword_substitute($content->title, $keywords, $context);
+ }
+
+ // Sterilize the title
+ $content->title = filter_xss_admin($content->title);
+
+ // If a link is specified, populate.
+ if (!empty($content->title_link)) {
+ if (!is_array($content->title_link)) {
+ $url = array('href' => $content->title_link);
+ }
+ else {
+ $url = $content->title_link;
+ }
+ // set defaults so we don't bring up notices
+ $url += array('href' => '', 'attributes' => array(), 'query' => array(), 'fragment' => '', 'absolute' => NULL, 'html' => TRUE);
+ $content->title = l($content->title, $url['href'], $url);
+ }
+ }
+
+ return $content;
+ }
+}
+
+/**
+ * Determine if a content type can be edited or not.
+ *
+ * Some content types simply have their content and no options. This function
+ * lets a UI determine if it should display an edit link or not.
+ */
+function ctools_content_editable($type, $subtype, $conf) {
+ if (empty($type['edit form']) && empty($subtype['edit form'])) {
+ return FALSE;
+ }
+
+ $function = FALSE;
+
+ if (!empty($subtype['check editable'])) {
+ $function = ctools_plugin_get_function($subtype, 'check editable');
+ }
+ elseif (!empty($type['check editable'])) {
+ $function = ctools_plugin_get_function($type, 'check editable');
+ }
+
+ if ($function) {
+ return $function($type, $subtype, $conf);
+ }
+
+ return TRUE;
+}
+
+/**
+ * Get the administrative title from a given content type.
+ *
+ * @param $type
+ * The content type. May be the name or an already loaded content type object.
+ * @param $subtype
+ * The subtype being rendered.
+ * @param $conf
+ * The configuration for the content type.
+ * @param $context
+ * An array of context objects available for use. These may be placeholders.
+ */
+function ctools_content_admin_title($type, $subtype, $conf, $context = NULL) {
+ if (is_array($type)) {
+ $plugin = $type;
+ }
+ else if (is_string($type)) {
+ $plugin = ctools_get_content_type($type);
+ }
+ else {
+ return;
+ }
+
+ if ($function = ctools_plugin_get_function($plugin, 'admin title')) {
+ $pane_context = ctools_content_select_context($plugin, $subtype, $conf, $context);
+ if ($pane_context === FALSE) {
+ if ($plugin['name'] == $subtype) {
+ return t('@type will not display due to missing context', array('@type' => $plugin['name']));
+ }
+ return t('@type:@subtype will not display due to missing context', array('@type' => $plugin['name'], '@subtype' => $subtype));
+ }
+
+ return $function($subtype, $conf, $pane_context);
+ }
+ else if (isset($plugin['admin title'])) {
+ return $plugin['admin title'];
+ }
+ else if (isset($plugin['title'])) {
+ return $plugin['title'];
+ }
+}
+
+/**
+ * Get the proper icon path to use, falling back to default icons if no icon exists.
+ *
+ * $subtype
+ * The loaded subtype info.
+ */
+function ctools_content_admin_icon($subtype) {
+ $icon = '';
+
+ if (isset($subtype['icon'])) {
+ $icon = $subtype['icon'];
+ if (!file_exists($icon)) {
+ $icon = $subtype['path'] . '/' . $icon;
+ }
+ }
+
+ if (empty($icon) || !file_exists($icon)) {
+ $icon = ctools_image_path('no-icon.png');
+ }
+
+ return $icon;
+}
+
+/**
+ * Set up the default $conf for a new instance of a content type.
+ */
+function ctools_content_get_defaults($plugin, $subtype) {
+ if (isset($plugin['defaults'])) {
+ $defaults = $plugin['defaults'];
+ }
+ else if (isset($subtype['defaults'])) {
+ $defaults = $subtype['defaults'];
+ }
+ if (isset($defaults)) {
+ if (is_string($defaults) && function_exists($defaults)) {
+ if ($return = $defaults($pane)) {
+ return $return;
+ }
+ }
+ else if (is_array($defaults)) {
+ return $defaults;
+ }
+ }
+
+ return array();
+}
+
+/**
+ * Get the administrative title from a given content type.
+ *
+ * @param $type
+ * The content type. May be the name or an already loaded content type object.
+ * @param $subtype
+ * The subtype being rendered.
+ * @param $conf
+ * The configuration for the content type.
+ * @param $context
+ * An array of context objects available for use. These may be placeholders.
+ */
+function ctools_content_admin_info($type, $subtype, $conf, $context = NULL) {
+ if (is_array($type)) {
+ $plugin = $type;
+ }
+ else {
+ $plugin = ctools_get_content_type($type);
+ }
+
+ if ($function = ctools_plugin_get_function($plugin, 'admin info')) {
+ $output = $function($subtype, $conf, $context);
+ }
+
+ if (empty($output) || !is_object($output)) {
+ $output = new stdClass();
+ // replace the _ with " " for a better output
+ $subtype = check_plain(str_replace("_", " ", $subtype));
+ $output->title = $subtype;
+ $output->content = t('No info available.');
+ }
+ return $output;
+}
+
+/**
+ * Add the default FAPI elements to the content type configuration form
+ */
+function ctools_content_configure_form_defaults($form, &$form_state) {
+ $plugin = $form_state['plugin'];
+ $subtype = $form_state['subtype'];
+ $contexts = isset($form_state['contexts']) ? $form_state['contexts'] : NULL;
+ $conf = $form_state['conf'];
+
+ $add_submit = FALSE;
+ if (!empty($subtype['required context']) && is_array($contexts)) {
+ $form['context'] = ctools_context_selector($contexts, $subtype['required context'], isset($conf['context']) ? $conf['context'] : array());
+ $add_submit = TRUE;
+ }
+
+ ctools_include('dependent');
+
+ // Unless we're not allowed to override the title on this content type, add this
+ // gadget to all panes.
+ if (empty($plugin['no title override']) && empty($subtype['no title override'])) {
+ $form['aligner_start'] = array(
+ '#markup' => '
',
+ '#markup' => t('You may use %keywords from contexts, as well as %title to contain the original title.'),
+ );
+ }
+ $add_submit = TRUE;
+ }
+
+ if ($add_submit) {
+ // '#submit' is already set up due to the wizard.
+ $form['#submit'][] = 'ctools_content_configure_form_defaults_submit';
+ }
+ return $form;
+}
+
+/**
+ * Submit handler to store context/title override info.
+ */
+function ctools_content_configure_form_defaults_submit(&$form, &$form_state) {
+ if (isset($form_state['values']['context'])) {
+ $form_state['conf']['context'] = $form_state['values']['context'];
+ }
+ if (isset($form_state['values']['override_title'])) {
+ $form_state['conf']['override_title'] = $form_state['values']['override_title'];
+ $form_state['conf']['override_title_text'] = $form_state['values']['override_title_text'];
+ $form_state['conf']['override_title_heading'] = $form_state['values']['override_title_heading'];
+ }
+}
+
+/**
+ * Get the config form.
+ *
+ * The $form_info and $form_state need to be preconfigured with data you'll need
+ * such as whether or not you're using ajax, or the modal. $form_info will need
+ * your next/submit callbacks so that you can cache your data appropriately.
+ *
+ * @return
+ * If this function returns false, no form exists.
+ */
+function ctools_content_form($op, $form_info, &$form_state, $plugin, $subtype_name, $subtype, &$conf, $step = NULL) {
+ $form_state += array(
+ 'plugin' => $plugin,
+ 'subtype' => $subtype,
+ 'subtype_name' => $subtype_name,
+ 'conf' => &$conf,
+ 'op' => $op,
+ );
+
+ $form_info += array(
+ 'id' => 'ctools_content_form',
+ 'show back' => TRUE,
+ );
+
+ // Turn the forms defined in the plugin into the format the wizard needs.
+ if ($op == 'add') {
+ if (!empty($subtype['add form'])) {
+ _ctools_content_create_form_info($form_info, $subtype['add form'], $subtype, $subtype, $op);
+ }
+ else if (!empty($plugin['add form'])) {
+ _ctools_content_create_form_info($form_info, $plugin['add form'], $plugin, $subtype, $op);
+ }
+ }
+
+ if (empty($form_info['order'])) {
+ // Use the edit form for the add form if add form was completely left off.
+ if (!empty($subtype['edit form'])) {
+ _ctools_content_create_form_info($form_info, $subtype['edit form'], $subtype, $subtype, $op);
+ }
+ else if (!empty($plugin['edit form'])) {
+ _ctools_content_create_form_info($form_info, $plugin['edit form'], $plugin, $subtype, $op);
+ }
+ }
+
+ if (empty($form_info['order'])) {
+ return FALSE;
+ }
+
+ ctools_include('wizard');
+ return ctools_wizard_multistep_form($form_info, $step, $form_state);
+
+}
+
+function _ctools_content_create_form_info(&$form_info, $info, $plugin, $subtype, $op) {
+ if (is_string($info)) {
+ if (empty($subtype['title'])) {
+ $title = t('Configure');
+ }
+ else if ($op == 'add') {
+ $title = t('Configure new !subtype_title', array('!subtype_title' => $subtype['title']));
+ }
+ else {
+ $title = t('Configure !subtype_title', array('!subtype_title' => $subtype['title']));
+ }
+ $form_info['order'] = array('form' => $title);
+ $form_info['forms'] = array(
+ 'form' => array(
+ 'title' => $title,
+ 'form id' => $info,
+ 'wrapper' => 'ctools_content_configure_form_defaults',
+ ),
+ );
+ }
+ else if (is_array($info)) {
+ $form_info['order'] = array();
+ $form_info['forms'] = array();
+ $count = 0;
+ $base = 'step';
+ $wrapper = NULL;
+ foreach ($info as $form_id => $title) {
+ // @todo -- docs say %title can be used to sub for the admin title.
+ $step = $base . ++$count;
+ if (empty($wrapper)) {
+ $wrapper = $step;
+ }
+
+ if (is_array($title)) {
+ if (!empty($title['default'])) {
+ $wrapper = $step;
+ }
+ $title = $title['title'];
+ }
+
+ $form_info['order'][$step] = $title;
+ $form_info['forms'][$step] = array(
+ 'title' => $title,
+ 'form id' => $form_id,
+ );
+ }
+ if ($wrapper) {
+ $form_info['forms'][$wrapper]['wrapper'] = 'ctools_content_configure_form_defaults';
+ }
+ }
+}
+
+/**
+ * Get an array of all available content types that can be fed into the
+ * display editor for the add content list.
+ *
+ * @param $context
+ * If a context is provided, content that requires that context can apepar.
+ * @param $has_content
+ * Whether or not the display will have incoming content
+ * @param $allowed_types
+ * An array of allowed content types (pane types) keyed by content_type . '-' . sub_type
+ * @param $default_types
+ * A default allowed/denied status for content that isn't known about
+ */
+function ctools_content_get_available_types($contexts = NULL, $has_content = FALSE, $allowed_types = NULL, $default_types = NULL) {
+ $plugins = ctools_get_content_types();
+ $available = array();
+
+ foreach ($plugins as $id => $plugin) {
+ foreach (ctools_content_get_subtypes($plugin) as $subtype_id => $subtype) {
+ // exclude items that require content if we're saying we don't
+ // provide it.
+ if (!empty($subtype['requires content']) && !$has_content) {
+ continue;
+ }
+
+ // Check to see if the content type can be used in this context.
+ if (!empty($subtype['required context'])) {
+ if (!ctools_context_match_requirements($contexts, $subtype['required context'])) {
+ continue;
+ }
+ }
+
+ // Check to see if the passed-in allowed types allows this content.
+ if ($allowed_types) {
+ $key = $id . '-' . $subtype_id;
+ if (!isset($allowed_types[$key])) {
+ $allowed_types[$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other'];
+ }
+ if (!$allowed_types[$key]) {
+ continue;
+ }
+ }
+
+ // Check if the content type provides an access callback.
+ if (isset($subtype['create content access']) && function_exists($subtype['create content access']) && !$subtype['create content access']($plugin, $subtype)) {
+ continue;
+ }
+
+ // If we made it through all the tests, then we can use this content.
+ $available[$id][$subtype_id] = $subtype;
+ }
+ }
+ return $available;
+}
+
+/**
+ * Get an array of all content types that can be fed into the
+ * display editor for the add content list, regardless of
+ * availability.
+ *
+ */
+function ctools_content_get_all_types() {
+ $plugins = ctools_get_content_types();
+ $available = array();
+
+ foreach ($plugins as $id => $plugin) {
+ foreach (ctools_content_get_subtypes($plugin) as $subtype_id => $subtype) {
+ // If we made it through all the tests, then we can use this content.
+ $available[$id][$subtype_id] = $subtype;
+ }
+ }
+ return $available;
+}
+
+/**
+ * Select the context to be used for a piece of content, based upon config.
+ *
+ * @param $plugin
+ * The content plugin
+ * @param $subtype
+ * The subtype of the content.
+ * @param $conf
+ * The configuration array that should contain the context.
+ * @param $contexts
+ * A keyed array of available contexts.
+ *
+ * @return
+ * The matching contexts or NULL if none or necessary, or FALSE if
+ * requirements can't be met.
+ */
+function ctools_content_select_context($plugin, $subtype, $conf, $contexts) {
+ // Identify which of our possible contexts apply.
+ if (empty($subtype)) {
+ return;
+ }
+
+ $subtype_info = ctools_content_get_subtype($plugin, $subtype);
+ if (empty($subtype_info)) {
+ return;
+ }
+
+ if (!empty($subtype_info['all contexts']) || !empty($plugin['all contexts'])) {
+ return $contexts;
+ }
+
+ // If the content requires a context, fetch it; if no context is returned,
+ // do not display the pane.
+ if (empty($subtype_info['required context'])) {
+ return;
+ }
+
+ // Deal with dynamic required contexts not getting updated in the panes.
+ // For example, Views let you dynamically change context info. While
+ // we cannot be perfect, one thing we can do is if no context at all
+ // was asked for, and then was later added but none is selected, make
+ // a best guess as to what context should be used. THis is right more
+ // than it's wrong.
+ if (is_array($subtype_info['required context'])) {
+ if (empty($conf['context']) || count($subtype_info['required context']) != count($conf['context'])) {
+ foreach ($subtype_info['required context'] as $index => $required) {
+ if (!isset($conf['context'][$index])) {
+ $filtered = ctools_context_filter($contexts, $required);
+ if ($filtered) {
+ $keys = array_keys($filtered);
+ $conf['context'][$index] = array_shift($keys);
+ }
+ }
+ }
+ }
+ }
+ else {
+ if (empty($conf['context'])) {
+ $filtered = ctools_context_filter($contexts, $subtype_info['required context']);
+ if ($filtered) {
+ $keys = array_keys($filtered);
+ $conf['context'] = array_shift($keys);
+ }
+ }
+ }
+
+ if (empty($conf['context'])) {
+ return;
+ }
+
+ $context = ctools_context_select($contexts, $subtype_info['required context'], $conf['context']);
+
+ return $context;
+}
+
+/**
+ * Fetch a piece of content from the addressable content system.
+ *
+ * @param $address
+ * A string or an array representing the address of the content.
+ * @param $type
+ * The type of content to return. The type is dependent on what
+ * the content actually is. The default, 'content' means a simple
+ * string representing the content. However, richer systems may
+ * offer more options. For example, Panels might allow the
+ * fetching of 'display' and 'pane' objects. Page Manager
+ * might allow for the fetching of 'task_handler' objects
+ * (AKA variants).
+ */
+function ctools_get_addressable_content($address, $type = 'content') {
+ if (!is_array($address)) {
+ $address = explode('::', $address);
+ }
+
+ if (!$address) {
+ return;
+ }
+
+ // This removes the module from the address so the
+ // implementor is not responsible for that part.
+ $module = array_shift($address);
+ return module_invoke($module, 'addressable_content', $address, $type);
+}
diff --git a/sites/all/modules/contrib/ctools/includes/content.menu.inc b/sites/all/modules/contrib/ctools/includes/content.menu.inc
new file mode 100644
index 0000000..f7f9340
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/content.menu.inc
@@ -0,0 +1,179 @@
+ array('access content'),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'includes/content.menu.inc',
+ );
+ $items['ctools/autocomplete/%'] = array(
+ 'page callback' => 'ctools_content_autocomplete_entity',
+ 'page arguments' => array(2),
+ ) + $base;
+}
+
+/**
+ * Helper function for autocompletion of entity titles.
+ */
+function ctools_content_autocomplete_entity($entity_type, $string = '') {
+ if ($string != '') {
+ $entity_info = entity_get_info($entity_type);
+
+ if (!module_exists('entity')) {
+ module_load_include('inc', 'ctools', 'includes/entity-access');
+ _ctools_entity_access($entity_info, $entity_type);
+ }
+
+ // We must query all ids, because if every one of the 10 don't have access
+ // the user may never be able to autocomplete a node title.
+ $preg_matches = array();
+ $matches = array();
+ $match = preg_match('/\[id: (\d+)\]/', $string, $preg_matches);
+ if (!$match) {
+ $match = preg_match('/^id: (\d+)/', $string, $preg_matches);
+ }
+ // If an ID match was found, use that ID rather than the whole string.
+ if ($match) {
+ $entity_id = $preg_matches[1];
+ $results = _ctools_getReferencableEntities($entity_type, $entity_info, $entity_id, '=', 1);
+ }
+ else {
+ // We cannot find results if the entity doesn't have a label to search.
+ if (!isset($entity_info['entity keys']['label'])) {
+ drupal_json_output(array("[id: NULL]" => '' . t('Entity Type !entity_type does not support autocomplete search.', array('!entity_type' => $entity_type)) . ''));
+ return;
+ }
+ $results = _ctools_getReferencableEntities($entity_type, $entity_info, $string, 'LIKE', 10);
+ }
+ foreach ($results as $entity_id => $result) {
+ $matches[$result['label'] . " [id: $entity_id]"] = '' . check_plain($result['label']) . '';
+ $matches[$result['label'] . " [id: $entity_id]"] .= isset($result['bundle']) ? ' (' . check_plain($result['bundle']) . ')' : '';
+ }
+
+ drupal_json_output($matches);
+ }
+}
+
+/*
+ * Use well known/tested entity reference code to build our search query
+ * From EntityReference_SelectionHandler_Generic class
+ */
+function _ctools_buildQuery($entity_type, $entity_info, $match = NULL, $match_operator = 'CONTAINS') {
+ $base_table = $entity_info['base table'];
+ $label_key = $entity_info['entity keys']['label'];
+ $query = db_select($base_table)
+ ->fields($base_table, array($entity_info['entity keys']['id']));
+
+ if (isset($match)) {
+ if (isset($label_key)) {
+ $query->condition($base_table . '.' . $label_key, '%' . $match . '%', $match_operator);
+ }
+ // This should never happen, but double check just in case.
+ else {
+ return array();
+ }
+ }
+ // Add a generic entity access tag to the query.
+ $query->addTag('ctools');
+
+ // We have to perform two checks. First check is a query alter (with tags)
+ // in an attempt to only return results that have access. However, this is
+ // not full-proof since entities many not implement hook_access query tag.
+ // This is why we have a second check after entity load, before we display
+ // the label of an entity.
+ if ($entity_type == 'comment') {
+ // Adding the 'comment_access' tag is sadly insufficient for comments: core
+ // requires us to also know about the concept of 'published' and
+ // 'unpublished'.
+ if (!user_access('administer comments')) {
+ $query->condition('comment.status', COMMENT_PUBLISHED);
+ }
+
+ // Join to a node if the user does not have node access bypass permissions
+ // to obey node published permissions
+ if (!user_access('bypass node access')) {
+ $node_alias = $query->innerJoin('node', 'n', '%alias.nid = comment.nid');
+ $query->condition($node_alias . '.status', NODE_PUBLISHED);
+ }
+ $query->addTag('node_access');
+ }
+ else {
+ $query->addTag($entity_type . '_access');
+ }
+
+ // Add the sort option.
+ if (isset($label_key)) {
+ $query->orderBy($base_table . '.' . $label_key, 'ASC');
+ }
+
+ return $query;
+}
+
+/**
+ * Private function to get referencable entities. Based on code from the
+ * Entity Reference module.
+ */
+function _ctools_getReferencableEntities($entity_type, $entity_info, $match = NULL, $match_operator = 'LIKE', $limit = 0) {
+ global $user;
+ $account = $user;
+ $options = array();
+ // We're an entity ID, return the id
+ if (is_numeric($match) && $match_operator == '=') {
+ if ($entity = array_shift(entity_load($entity_type, array($match)))) {
+ if (isset($entity_info['access callback']) && function_exists($entity_info['access callback'])) {
+ if ($entity_info['access callback']('view', $entity, $account, $entity_type)) {
+ $label = entity_label($entity_type, $entity);
+ return array(
+ $match => array(
+ 'label' => !empty($label) ? $label : $entity->{$entity_info['entity keys']['id']},
+ 'bundle' => !empty($entity_info['entity keys']['bundle']) ? check_plain($entity->{$entity_info['entity keys']['bundle']}) : NULL,
+ ),
+ );
+ }
+ }
+ }
+ // If you don't have access, or an access callback or a valid entity, just
+ // Return back the Entity ID.
+ return array(
+ $match => array(
+ 'label' => $match,
+ 'bundle' => NULL,
+ ),
+ );
+ }
+
+ // We have matches, build a query to fetch the result.
+ if ($query = _ctools_buildQuery($entity_type, $entity_info, $match, $match_operator)) {
+ if ($limit > 0) {
+ $query->range(0, $limit);
+ }
+
+ $results = $query->execute();
+
+ if (!empty($results)) {
+ foreach ($results as $record) {
+ $entities = entity_load($entity_type, array($record->{$entity_info['entity keys']['id']}));
+ $entity = array_shift($entities);
+ if (isset($entity_info['access callback']) && function_exists($entity_info['access callback'])) {
+ if ($entity_info['access callback']('view', $entity, $account, $entity_type)) {
+ $label = entity_label($entity_type, $entity);
+ $options[$record->{$entity_info['entity keys']['id']}] = array(
+ 'label' => !empty($label) ? $label : $entity->{$entity_info['entity keys']['id']},
+ 'bundle' => !empty($entity_info['entity keys']['bundle']) ? check_plain($entity->{$entity_info['entity keys']['bundle']}) : NULL,
+ );
+ }
+ }
+ }
+ }
+ return $options;
+ }
+ return array();
+}
diff --git a/sites/all/modules/contrib/ctools/includes/content.plugin-type.inc b/sites/all/modules/contrib/ctools/includes/content.plugin-type.inc
new file mode 100644
index 0000000..a0debc3
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/content.plugin-type.inc
@@ -0,0 +1,17 @@
+ FALSE,
+ 'process' => array(
+ 'function' => 'ctools_content_process',
+ 'file' => 'content.inc',
+ 'path' => drupal_get_path('module', 'ctools') . '/includes',
+ ),
+ );
+}
\ No newline at end of file
diff --git a/sites/all/modules/contrib/ctools/includes/content.theme.inc b/sites/all/modules/contrib/ctools/includes/content.theme.inc
new file mode 100644
index 0000000..ae4456a
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/content.theme.inc
@@ -0,0 +1,21 @@
+ array(
+ * 0 => array(
+ * 'name' => 'name of access plugin',
+ * 'settings' => array(), // These will be set by the form
+ * ),
+ * // ... as many as needed
+ * ),
+ * 'logic' => 'AND', // or 'OR',
+ * ),
+ * @endcode
+ *
+ * To add this widget to your UI, you need to do a little bit of setup.
+ *
+ * The form will utilize two callbacks, one to get the cached version
+ * of the access settings, and one to store the cached version of the
+ * access settings. These will be used from AJAX forms, so they will
+ * be completely out of the context of this page load and will not have
+ * knowledge of anything sent to this form (the 'module' and 'argument'
+ * will be preserved through the URL only).
+ *
+ * The 'module' is used to determine the location of the callback. It
+ * does not strictly need to be a module, so that if your module defines
+ * multiple systems that use this callback, it can use anything within the
+ * module's namespace it likes.
+ *
+ * When retrieving the cache, the cache may not have already been set up;
+ * In order to efficiently use cache space, we want to cache the stored
+ * settings *only* when they have changed. Therefore, the get access cache
+ * callback should first look for cache, and if it finds nothing, return
+ * the original settings.
+ *
+ * The callbacks:
+ * - $module . _ctools_access_get($argument) -- get the 'access' settings
+ * from cache. Must return array($access, $contexts); This callback can
+ * perform access checking to make sure this URL is not being gamed.
+ * - $module . _ctools_access_set($argument, $access) -- set the 'access'
+ * settings in cache.
+ * - $module . _ctools_access_clear($argument) -- clear the cache.
+ *
+ * The ctools_object_cache is recommended for this purpose, but you can use
+ * any caching mechanism you like. An example:
+ *
+ * @code{
+ * ctools_include('object-cache');
+ * ctools_object_cache_set("$module:argument", $access);
+ * }
+ *
+ * To utilize this form:
+ * @code
+ * ctools_include('context-access-admin');
+ * $form_state = array(
+ * 'access' => $access,
+ * 'module' => 'module name',
+ * 'callback argument' => 'some string',
+ * 'contexts' => $contexts, // an array of contexts. Optional if no contexts.
+ * // 'logged-in-user' will be added if not present as the access system
+ * // requires this context.
+ * ),
+ * $output = drupal_build_form('ctools_access_admin_form', $form_state);
+ * if (!empty($form_state['executed'])) {
+ * // save $form_state['access'] however you like.
+ * }
+ * @endcode
+ *
+ * Additionally, you may add 'no buttons' => TRUE if you wish to embed this
+ * form into your own, and instead call
+ *
+ * @code{
+ * $form = ctools_access_admin_form($form, $form_state);
+ * }
+ *
+ * You'll be responsible for adding a submit button.
+ *
+ * You may use ctools_access($access, $contexts) which will return
+ * TRUE if access is passed or FALSE if access is not passed.
+ */
+
+/**
+ * Administrative form for access control.
+ */
+function ctools_access_admin_form($form, &$form_state) {
+ ctools_include('context');
+ $argument = isset($form_state['callback argument']) ? $form_state['callback argument'] : '';
+ $fragment = $form_state['module'];
+ if ($argument) {
+ $fragment .= '-' . $argument;
+ }
+
+ $contexts = isset($form_state['contexts']) ? $form_state['contexts'] : array();
+
+ $form['access_table'] = array(
+ '#markup' => ctools_access_admin_render_table($form_state['access'], $fragment, $contexts),
+ );
+
+ $form['add-button'] = array(
+ '#theme' => 'ctools_access_admin_add',
+ );
+ // This sets up the URL for the add access modal.
+ $form['add-button']['add-url'] = array(
+ '#attributes' => array('class' => array("ctools-access-add-url")),
+ '#type' => 'hidden',
+ '#value' => url("ctools/context/ajax/access/add/$fragment", array('absolute' => TRUE)),
+ );
+
+ $plugins = ctools_get_relevant_access_plugins($contexts);
+ $options = array();
+ foreach ($plugins as $id => $plugin) {
+ $options[$id] = $plugin['title'];
+ }
+
+ asort($options);
+
+ $form['add-button']['type'] = array(
+ // This ensures that the form item is added to the URL.
+ '#attributes' => array('class' => array("ctools-access-add-url")),
+ '#type' => 'select',
+ '#options' => $options,
+ '#required' => FALSE,
+ );
+
+ $form['add-button']['add'] = array(
+ '#type' => 'submit',
+ '#attributes' => array('class' => array('ctools-use-modal')),
+ '#id' => "ctools-access-add",
+ '#value' => t('Add'),
+ );
+
+ $form['logic'] = array(
+ '#type' => 'radios',
+ '#options' => array(
+ 'and' => t('All criteria must pass.'),
+ 'or' => t('Only one criteria must pass.'),
+ ),
+ '#default_value' => isset($form_state['access']['logic']) ? $form_state['access']['logic'] : 'and',
+ );
+
+ if (empty($form_state['no buttons'])) {
+ $form['buttons']['save'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save'),
+ '#submit' => array('ctools_access_admin_form_submit'),
+ );
+ }
+
+ return $form;
+}
+
+/**
+ * Render the table. This is used both to render it initially and to rerender
+ * it upon ajax response.
+ */
+function ctools_access_admin_render_table($access, $fragment, $contexts) {
+ ctools_include('ajax');
+ ctools_include('modal');
+ $rows = array();
+
+ if (empty($access['plugins'])) {
+ $access['plugins'] = array();
+ }
+
+ foreach ($access['plugins'] as $id => $test) {
+ $row = array();
+ $plugin = ctools_get_access_plugin($test['name']);
+ $title = isset($plugin['title']) ? $plugin['title'] : t('Broken/missing access plugin %plugin', array('%plugin' => $test['name']));
+
+ $row[] = array('data' => $title, 'class' => array('ctools-access-title'));
+
+ $description = ctools_access_summary($plugin, $contexts, $test);
+ $row[] = array('data' => $description, 'class' => array('ctools-access-description'));
+
+ $operations = ctools_modal_image_button(ctools_image_path('icon-configure.png'), "ctools/context/ajax/access/configure/$fragment/$id", t('Configure settings for this item.'));
+ $operations .= ctools_ajax_image_button(ctools_image_path('icon-delete.png'), "ctools/context/ajax/access/delete/$fragment/$id", t('Remove this item.'));
+
+ $row[] = array('data' => $operations, 'class' => array('ctools-access-operations'), 'align' => 'right');
+
+ $rows[] = $row;
+ }
+
+ $header = array(
+ array('data' => t('Title'), 'class' => array('ctools-access-title')),
+ array('data' => t('Description'), 'class' => array('ctools-access-description')),
+ array('data' => '', 'class' => array('ctools-access-operations'), 'align' => 'right'),
+ );
+
+ if (empty($rows)) {
+ $rows[] = array(array('data' => t('No criteria selected, this test will pass.'), 'colspan' => count($header)));
+ }
+
+ ctools_modal_add_js();
+ return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'ctools-access-table')));
+}
+
+/**
+ * Theme the 'add' portion of the access form into a table.
+ */
+function theme_ctools_access_admin_add($vars) {
+ $rows = array(array(drupal_render_children($vars['form'])));
+ $output = '
',
+ '#markup' => $type_info['description'],
+ );
+
+ ctools_context_add_item_table_buttons($type, $module, $form, $available_contexts);
+}
+
+function ctools_context_add_item_table_buttons($type, $module, &$form, $available_contexts) {
+ drupal_add_library('system', 'drupal.ajax');
+ $form['buttons'] = array(
+ '#tree' => TRUE,
+ );
+
+ if (!empty($available_contexts)) {
+ $type_info = ctools_context_info($type);
+
+ $module = $form['#ctools_context_module'];
+ $cache_key = $form['#cache_key'];
+
+ // The URL for this ajax button
+ $form['buttons'][$type]['add-url'] = array(
+ '#attributes' => array('class' => array("ctools-$type-add-url")),
+ '#type' => 'hidden',
+ '#value' => url("ctools/context/ajax/add/$module/$type/$cache_key", array('absolute' => TRUE)),
+ );
+
+ asort($available_contexts);
+ // This also will be in the URL.
+ $form['buttons'][$type]['item'] = array(
+ '#attributes' => array('class' => array("ctools-$type-add-url")),
+ '#type' => 'select',
+ '#options' => $available_contexts,
+ '#required' => FALSE,
+ );
+
+ $form['buttons'][$type]['add'] = array(
+ '#type' => 'submit',
+ '#attributes' => array('class' => array('ctools-use-modal')),
+ '#id' => "ctools-$type-add",
+ '#value' => $type_info['add button'],
+ );
+ }
+}
+
+/**
+ * Add a row to the form. Used both in the main form and by
+ * the ajax to add an item.
+ */
+function ctools_context_add_item_to_form($module, $type, $cache_key, &$form, $position, $item) {
+ // This is the single function way to load any plugin by variable type.
+ $info = ctools_context_get_plugin($type, $item['name']);
+ $form['title'] = array(
+ '#markup' => check_plain($item['identifier']),
+ );
+
+ // Relationships not sortable.
+ $type_info = ctools_context_info($type);
+
+ if (!empty($type_info['sortable'])) {
+ $form['position'] = array(
+ '#type' => 'weight',
+ '#default_value' => $position,
+ '#attributes' => array('class' => array('drag-position')),
+ );
+ }
+
+ $form['remove'] = array(
+ '#markup' => ctools_ajax_image_button(ctools_image_path('icon-delete.png'), "ctools/context/ajax/delete/$module/$type/$cache_key/$position", t('Remove this item.')),
+ );
+
+ $form['settings'] = array(
+ '#markup' => ctools_modal_image_button(ctools_image_path('icon-configure.png'), "ctools/context/ajax/configure/$module/$type/$cache_key/$position", t('Configure settings for this item.')),
+ );
+}
+
+
+// ---------------------------------------------------------------------------
+// AJAX forms and stuff.
+
+/**
+ * Ajax entry point to add an context
+ */
+function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_key = NULL, $name = NULL, $step = NULL) {
+ ctools_include('ajax');
+ ctools_include('modal');
+ ctools_include('context');
+ ctools_include('cache');
+ ctools_include('plugins-admin');
+
+ if (!$name) {
+ return ctools_ajax_render_error();
+ }
+
+ // Load stored object from cache.
+ if (!($object = ctools_cache_get($mechanism, $cache_key))) {
+ ctools_ajax_render_error(t('Invalid object name.'));
+ }
+
+ // Get info about what we're adding, i.e, relationship, context, argument, etc.
+ $plugin_definition = ctools_context_get_plugin($type, $name);
+ if (empty($plugin_definition)) {
+ ctools_ajax_render_error(t('Invalid context type'));
+ }
+
+ // Set up the $conf array for this plugin
+ if (empty($step) || empty($object->temporary)) {
+ // Create the basis for our new context.
+ $conf = ctools_context_get_defaults($plugin_definition, $object, $type);
+ $object->temporary = &$conf;
+ }
+ else {
+ $conf = &$object->temporary;
+ }
+
+ // Load the contexts that may be used.
+ $base_contexts = isset($object->base_contexts) ? $object->base_contexts : array();
+ $contexts = ctools_context_load_contexts($object, TRUE, $base_contexts);
+
+ $type_info = ctools_context_info($type);
+ $form_state = array(
+ 'ajax' => TRUE,
+ 'modal' => TRUE,
+ 'modal return' => TRUE,
+ 'object' => &$object,
+ 'conf' => &$conf,
+ 'plugin' => $plugin_definition,
+ 'type' => $type,
+ 'contexts' => $contexts,
+ 'title' => t('Add @type "@context"', array('@type' => $type_info['singular title'], '@context' => $plugin_definition['title'])),
+ 'type info' => $type_info,
+ 'op' => 'add',
+ 'step' => $step,
+ );
+
+ $form_info = array(
+ 'path' => "ctools/context/ajax/add/$mechanism/$type/$cache_key/$name/%step",
+ 'show cancel' => TRUE,
+ 'default form' => 'ctools_edit_context_form_defaults',
+ 'auto cache' => TRUE,
+ 'cache mechanism' => $mechanism,
+ 'cache key' => $cache_key,
+ // This is stating what the cache will be referred to in $form_state
+ 'cache location' => 'object',
+ );
+
+ if ($type == 'requiredcontext') {
+ $form_info += array(
+ 'add form name' => 'required context add form',
+ 'edit form name' => 'required context edit form',
+ );
+ }
+
+ $output = ctools_plugin_configure_form($form_info, $form_state);
+
+ if (!empty($form_state['cancel'])) {
+ $output = array(ctools_modal_command_dismiss());
+ }
+ else if (!empty($form_state['complete'])) {
+ // Successful submit -- move temporary data to location.
+
+ // Create a reference to the place our context lives. Since this is fairly
+ // generic, this is the easiest way to get right to the place of the
+ // object without knowing precisely what data we're poking at.
+ $ref = &$object->{$type_info['key']};
+
+ // Figure out the position for our new context.
+ $position = empty($ref) ? 0 : max(array_keys($ref)) + 1;
+
+ $conf['id'] = ctools_context_next_id($ref, $name);
+ $ref[$position] = $conf;
+
+ if (isset($object->temporary)) {
+ unset($object->temporary);
+ }
+
+ ctools_cache_operation($mechanism, $cache_key, 'finalize', $object);
+
+ // Very irritating way to update the form for our contexts.
+ $arg_form_state = form_state_defaults() + array(
+ 'values' => array(),
+ 'process_input' => FALSE,
+ 'complete form' => array(),
+ );
+
+ $rel_form_state = $arg_form_state;
+
+ $arg_form = array(
+ '#post' => array(),
+ '#programmed' => FALSE,
+ '#tree' => FALSE,
+ '#parents' => array(),
+ '#array_parents' => array(),
+ );
+
+ // Build a chunk of the form to merge into the displayed form
+ $arg_form[$type] = array(
+ '#tree' => TRUE,
+ );
+ $arg_form[$type][$position] = array(
+ '#tree' => TRUE,
+ );
+
+ ctools_context_add_item_to_form($mechanism, $type, $cache_key, $arg_form[$type][$position], $position, $ref[$position]);
+ $arg_form = form_builder('ctools_context_form', $arg_form, $arg_form_state);
+
+ // Build the relationships table so we can ajax it in.
+ // This is an additional thing that goes in here.
+ $rel_form = array(
+ '#theme' => 'ctools_context_item_form',
+ '#cache_key' => $cache_key,
+ '#ctools_context_type' => 'relationship',
+ '#ctools_context_module' => $mechanism,
+ '#only_buttons' => TRUE,
+ '#post' => array(),
+ '#programmed' => FALSE,
+ '#tree' => FALSE,
+ '#parents' => array(),
+ '#array_parents' => array(),
+ );
+
+ $rel_form['relationship'] = array(
+ '#tree' => TRUE,
+ );
+
+ // Allow an object to set some 'base' contexts that come from elsewhere.
+ $rel_contexts = isset($object->base_contexts) ? $object->base_contexts : array();
+ $all_contexts = ctools_context_load_contexts($object, TRUE, $rel_contexts);
+ $available_relationships = ctools_context_get_relevant_relationships($all_contexts);
+
+ $output = array();
+ if (!empty($available_relationships)) {
+ ctools_context_add_item_table_buttons('relationship', $mechanism, $rel_form, $available_relationships);
+ $rel_form = form_builder('dummy_form_id', $rel_form, $rel_form_state);
+ $output[] = ajax_command_replace('div#ctools-relationships-table div.buttons', drupal_render($rel_form));
+ }
+
+ $theme_vars = array();
+ $theme_vars['type'] = $type;
+ $theme_vars['form'] = $arg_form[$type][$position];
+ $theme_vars['position'] = $position;
+ $theme_vars['count'] = $position;
+ $text = theme('ctools_context_item_row', $theme_vars);
+ $output[] = ajax_command_append('#' . $type . '-table tbody', $text);
+ $output[] = ajax_command_changed('#' . $type . '-row-' . $position, '.title');
+ $output[] = ctools_modal_command_dismiss();
+ }
+ else {
+ $output = ctools_modal_form_render($form_state, $output);
+ }
+ print ajax_render($output);
+ exit;
+}
+
+/**
+ * Ajax entry point to edit an item
+ */
+function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_key = NULL, $position = NULL, $step = NULL) {
+ ctools_include('ajax');
+ ctools_include('modal');
+ ctools_include('context');
+ ctools_include('cache');
+ ctools_include('plugins-admin');
+
+ if (!isset($position)) {
+ return ctools_ajax_render_error();
+ }
+
+ // Load stored object from cache.
+ if (!($object = ctools_cache_get($mechanism, $cache_key))) {
+ ctools_ajax_render_error(t('Invalid object name.'));
+ }
+
+ $type_info = ctools_context_info($type);
+
+ // Create a reference to the place our context lives. Since this is fairly
+ // generic, this is the easiest way to get right to the place of the
+ // object without knowing precisely what data we're poking at.
+ $ref = &$object->{$type_info['key']};
+
+ if (empty($step) || empty($object->temporary)) {
+ // Create the basis for our new context.
+ $conf = $object->{$type_info['key']}[$position];
+ $object->temporary = &$conf;
+ }
+ else {
+ $conf = &$object->temporary;
+ }
+
+ $name = $ref[$position]['name'];
+ if (empty($name)) {
+ ctools_ajax_render_error();
+ }
+
+ // load the plugin definition
+ $plugin_definition = ctools_context_get_plugin($type, $name);
+ if (empty($plugin_definition)) {
+ ctools_ajax_render_error(t('Invalid context type'));
+ }
+
+ // Load the contexts
+ $base_contexts = isset($object->base_contexts) ? $object->base_contexts : array();
+ $contexts = ctools_context_load_contexts($object, TRUE, $base_contexts);
+
+ $form_state = array(
+ 'ajax' => TRUE,
+ 'modal' => TRUE,
+ 'modal return' => TRUE,
+ 'object' => &$object,
+ 'conf' => &$conf,
+ 'position' => $position,
+ 'plugin' => $plugin_definition,
+ 'type' => $type,
+ 'contexts' => $contexts,
+ 'title' => t('Edit @type "@context"', array('@type' => $type_info['singular title'], '@context' => $plugin_definition['title'])),
+ 'type info' => $type_info,
+ 'op' => 'add',
+ 'step' => $step,
+ );
+
+ $form_info = array(
+ 'path' => "ctools/context/ajax/configure/$mechanism/$type/$cache_key/$position/%step",
+ 'show cancel' => TRUE,
+ 'default form' => 'ctools_edit_context_form_defaults',
+ 'auto cache' => TRUE,
+ 'cache mechanism' => $mechanism,
+ 'cache key' => $cache_key,
+ // This is stating what the cache will be referred to in $form_state
+ 'cache location' => 'object',
+ );
+
+ if ($type == 'requiredcontext') {
+ $form_info += array(
+ 'add form name' => 'required context add form',
+ 'edit form name' => 'required context edit form',
+ );
+ }
+
+ $output = ctools_plugin_configure_form($form_info, $form_state);
+
+ if (!empty($form_state['cancel'])) {
+ $output = array(ctools_modal_command_dismiss());
+ }
+ else if (!empty($form_state['complete'])) {
+ // successful submit
+ $ref[$position] = $conf;
+ if (isset($object->temporary)) {
+ unset($object->temporary);
+ }
+
+ ctools_cache_operation($mechanism, $cache_key, 'finalize', $object);
+
+ $output = array();
+ $output[] = ctools_modal_command_dismiss();
+
+ $arg_form_state = form_state_defaults() + array(
+ 'values' => array(),
+ 'process_input' => FALSE,
+ 'complete form' => array(),
+ );
+
+ $arg_form = array(
+ '#post' => array(),
+ '#parents' => array(),
+ '#array_parents' => array(),
+ '#programmed' => FALSE,
+ '#tree' => FALSE,
+ );
+
+ // Build a chunk of the form to merge into the displayed form
+ $arg_form[$type] = array(
+ '#tree' => TRUE,
+ );
+ $arg_form[$type][$position] = array(
+ '#tree' => TRUE,
+ );
+
+ ctools_context_add_item_to_form($mechanism, $type, $cache_key, $arg_form[$type][$position], $position, $ref[$position]);
+ $arg_form = form_builder('ctools_context_form', $arg_form, $arg_form_state);
+
+ $theme_vars = array();
+ $theme_vars['type'] = $type;
+ $theme_vars['form'] = $arg_form[$type][$position];
+ $theme_vars['position'] = $position;
+ $theme_vars['count'] = $position;
+ $output[] = ajax_command_replace('#' . $type . '-row-' . $position, theme('ctools_context_item_row', $theme_vars));
+ $output[] = ajax_command_changed('#' . $type . '-row-' . $position, '.title');
+ }
+ else {
+ $output = ctools_modal_form_render($form_state, $output);
+ }
+ print ajax_render($output);
+ exit;
+}
+
+/**
+ * Get the defaults for a new instance of a context plugin.
+ *
+ * @param $plugin_definition
+ * The metadata definition of the plugin from ctools_get_plugins().
+ * @param $object
+ * The object the context plugin will be added to.
+ * @param $type
+ * The type of context plugin. i.e, context, requiredcontext, relationship
+ */
+function ctools_context_get_defaults($plugin_definition, $object, $type) {
+ // Fetch the potential id of the plugin so we can append
+ // title and keyword information for new ones.
+ $type_info = ctools_context_info($type);
+ $id = ctools_context_next_id($object->{$type_info['key']}, $plugin_definition['name']);
+
+ $conf = array(
+ 'identifier' => $plugin_definition['title'] . ($id > 1 ? ' ' . $id : ''),
+ 'keyword' => ctools_get_keyword($object, $plugin_definition['keyword']),
+ 'name' => $plugin_definition['name'],
+ );
+
+ if (isset($plugin_definition['defaults'])) {
+ $defaults = $plugin_definition['defaults'];
+ }
+ else if (isset($subtype['defaults'])) {
+ $defaults = $subtype['defaults'];
+ }
+
+ if (isset($defaults)) {
+ if (is_string($defaults) && function_exists($defaults)) {
+ if ($settings = $defaults($plugin_definition)) {
+ $conf += $settings;
+ }
+ }
+ else if (is_array($defaults)) {
+ $conf += $defaults;
+ }
+ }
+
+ return $conf;
+}
+
+/**
+ * Form wrapper for the edit context form.
+ *
+ * @todo: We should uncombine these.
+ */
+function ctools_edit_context_form_defaults($form, &$form_state) {
+ // Basic values required to orient ourselves
+ $object = $form_state['object'];
+ $plugin_definition = $form_state['plugin'];
+ $type_info = $form_state['type info'];
+ $contexts = $form_state['contexts'];
+ $conf = $form_state['conf'];
+
+ if ($type_info['key'] == 'arguments' && !isset($conf['default'])) {
+ $conf['default'] = 'ignore';
+ $conf['title'] = '';
+ }
+
+ $form['description'] = array(
+ '#prefix' => '
',
+ '#suffix' => '
',
+ '#markup' => check_plain($plugin_definition['description']),
+ );
+
+ if ($type_info['key'] == 'relationships') {
+ $form['context'] = ctools_context_selector($contexts, $plugin_definition['required context'], isset($conf['context']) ? $conf['context'] : '');
+ }
+ if ($type_info['key'] == 'arguments') {
+ $form['default'] = array(
+ '#type' => 'select',
+ '#title' => t('Default'),
+ '#options' => array(
+ 'ignore' => t('Ignore it; content that requires this context will not be available.'),
+ '404' => t('Display page not found or display nothing at all.'),
+ ),
+ '#default_value' => $conf['default'],
+ '#description' => t('If the argument is missing or is not valid, select how this should behave.'),
+ );
+
+ $form['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title'),
+ '#default_value' => $conf['title'],
+ '#description' => t('Enter a title to use when this argument is present. You may use %KEYWORD substitution, where the keyword is specified below.'),
+ );
+ }
+
+ $form['identifier'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Identifier'),
+ '#description' => t('Enter a name to identify this !type on administrative screens.', array('!type' => t('context'))),
+ '#default_value' => $conf['identifier'],
+ );
+
+ $form['keyword'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Keyword'),
+ '#description' => t('Enter a keyword to use for substitution in titles.'),
+ '#default_value' => $conf['keyword'],
+ );
+
+ if ($type_info['key'] == 'requiredcontexts') {
+ $form['optional'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Context is optional'),
+ '#default_value' => !empty($form_state['conf']['optional']),
+ '#description' => t('This context need not be present for the component to function.'),
+ );
+ }
+
+ $form['#submit'][] = 'ctools_edit_context_form_defaults_submit';
+
+ return $form;
+}
+
+/**
+ * Submit handler to store context identifier and keyword info.
+ */
+function ctools_edit_context_form_defaults_submit(&$form, &$form_state) {
+ if ($form_state['type info']['key'] == 'relationships') {
+ $form_state['conf']['context'] = $form_state['values']['context'];
+ }
+ if ($form_state['type info']['key'] == 'arguments') {
+ $form_state['conf']['default'] = $form_state['values']['default'];
+ $form_state['conf']['title'] = $form_state['values']['title'];
+ }
+ if ($form_state['type info']['key'] == 'requiredcontexts') {
+ $form_state['conf']['optional'] = $form_state['values']['optional'];
+ }
+
+ $form_state['conf']['identifier'] = $form_state['values']['identifier'];
+ $form_state['conf']['keyword'] = $form_state['values']['keyword'];
+}
+
+/**
+ * Ajax entry point to edit an item
+ */
+function ctools_context_ajax_item_delete($mechanism = NULL, $type = NULL, $cache_key = NULL, $position = NULL) {
+ ctools_include('ajax');
+ ctools_include('context');
+ ctools_include('cache');
+
+ if (!isset($position)) {
+ return ctools_ajax_render_error();
+ }
+
+ // Load stored object from cache.
+ if (!($object = ctools_cache_get($mechanism, $cache_key))) {
+ ctools_ajax_render_error(t('Invalid object name.'));
+ }
+
+ $type_info = ctools_context_info($type);
+
+ // Create a reference to the place our context lives. Since this is fairly
+ // generic, this is the easiest way to get right to the place of the
+ // object without knowing precisely what data we're poking at.
+ $ref = &$object->{$type_info['key']};
+
+ if (!array_key_exists($position, $ref)) {
+ ctools_ajax_render_error(t('Unable to delete missing item!'));
+ }
+
+ unset($ref[$position]);
+ ctools_cache_operation($mechanism, $cache_key, 'finalize', $object);
+
+ $output = array();
+ $output[] = ajax_command_replace('#' . $type . '-row-' . $position, '');
+ $output[] = ajax_command_restripe("#$type-table");
+ print ajax_render($output);
+ exit;
+}
+
+// --- End of contexts
+
+function ctools_save_context($type, &$ref, $form_values) {
+ $type_info = ctools_context_info($type);
+
+ // Organize arguments
+ $new = array();
+ $order = array();
+
+ foreach ($ref as $id => $context) {
+ $position = $form_values[$type][$id]['position'];
+ $order[$position] = $id;
+ }
+
+ ksort($order);
+ foreach ($order as $id) {
+ $new[] = $ref[$id];
+ }
+ $ref = $new;
+}
+
+function ctools_get_keyword($page, $word) {
+ // Create a complete set of keywords
+ $keywords = array();
+ foreach (array('arguments', 'relationships', 'contexts', 'requiredcontexts') as $type) {
+ if (!empty($page->$type) && is_array($page->$type)) {
+ foreach ($page->$type as $info) {
+ $keywords[$info['keyword']] = TRUE;
+ }
+ }
+ }
+
+ $keyword = $word;
+ $count = 1;
+ while (!empty($keywords[$keyword])) {
+ $keyword = $word . '_' . ++$count;
+ }
+ return $keyword;
+}
+
diff --git a/sites/all/modules/contrib/ctools/includes/context-task-handler.inc b/sites/all/modules/contrib/ctools/includes/context-task-handler.inc
new file mode 100644
index 0000000..21ceea5
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/context-task-handler.inc
@@ -0,0 +1,540 @@
+ $handler) {
+ $plugin = page_manager_get_task_handler($handler->handler);
+ // First, see if the handler has a tester.
+ $function = ctools_plugin_get_function($plugin, 'test');
+ if ($function) {
+ $test = $function($handler, $contexts, $args);
+ if ($test) {
+ return $id;
+ }
+ }
+ else {
+ // If not, if it's a 'context' type handler, use the default tester.
+ if ($plugin['handler type'] == 'context') {
+ $test = ctools_context_handler_default_test($handler, $contexts, $args);
+ if ($test) {
+ return $id;
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ * Default test function to see if a task handler should be rendered.
+ *
+ * This tests against the standard selection criteria that most task
+ * handlers should be implementing.
+ */
+function ctools_context_handler_default_test($handler, $base_contexts, $args) {
+ ctools_include('context');
+ // Add my contexts
+ $contexts = ctools_context_handler_get_handler_contexts($base_contexts, $handler);
+
+ // Test.
+ return ctools_context_handler_select($handler, $contexts);
+}
+
+/**
+ * Render a task handler.
+ */
+function ctools_context_handler_render_handler($task, $subtask, $handler, $contexts, $args, $page = TRUE) {
+ $function = page_manager_get_renderer($handler);
+ if (!$function) {
+ return NULL;
+ }
+
+ if ($page) {
+ if ($subtask) {
+ $task_name = page_manager_make_task_name($task['name'], $subtask['name']);
+ }
+ else {
+ $task_name = $task['name'];
+ }
+
+ page_manager_get_current_page(array(
+ 'name' => $task_name,
+ 'task' => $task,
+ 'subtask' => $subtask,
+ 'contexts' => $contexts,
+ 'arguments' => $args,
+ 'handler' => $handler,
+ ));
+ }
+
+ $info = $function($handler, $contexts, $args);
+ if (!$info) {
+ return NULL;
+ }
+
+ $context = array(
+ 'args' => $args,
+ 'contexts' => $contexts,
+ 'task' => $task,
+ 'subtask' => $subtask,
+ 'handler' => $handler
+ );
+ drupal_alter('ctools_render', $info, $page, $context);
+
+ // If we don't own the page, let the caller deal with rendering.
+ if (!$page) {
+ return $info;
+ }
+
+ if (!empty($info['response code']) && $info['response code'] != 200) {
+ switch ($info['response code']) {
+ case 403:
+ return MENU_ACCESS_DENIED;
+ case 404:
+ return MENU_NOT_FOUND;
+ case 410:
+ drupal_add_http_header('Status', '410 Gone');
+ drupal_exit();
+ break;
+ case 301:
+ case 302:
+ case 303:
+ case 304:
+ case 305:
+ case 307:
+ $info += array(
+ 'query' => array(),
+ 'fragment' => '',
+ );
+ $options = array(
+ 'query' => $info['query'],
+ 'fragment' => $info['fragment'],
+ );
+ drupal_goto($info['destination'], $options, $info['response code']);
+ // @todo -- should other response codes be supported here?
+ }
+ }
+
+ $plugin = page_manager_get_task_handler($handler->handler);
+
+ if (module_exists('contextual') && user_access('access contextual links') && isset($handler->task)) {
+ // Provide a contextual link to edit this, if we can:
+ $callback = isset($plugin['contextual link']) ? $plugin['contextual link'] : 'ctools_task_handler_default_contextual_link';
+ if ($callback && function_exists($callback)) {
+ $links = $callback($handler, $plugin, $contexts, $args);
+ }
+
+ if (!empty($links) && is_array($links)) {
+ $build = array(
+ '#theme_wrappers' => array('container'),
+ '#attributes' => array('class' => array('contextual-links-region')),
+ );
+
+ if (!is_array($info['content'])) {
+ $build['content']['#markup'] = $info['content'];
+ }
+ else {
+ $build['content'] = $info['content'];
+ }
+
+ $build['contextual_links'] = array(
+ '#prefix' => '
',
+ '#suffix' => '
',
+ '#theme' => 'links__contextual',
+ '#links' => $links,
+ '#attributes' => array('class' => array('contextual-links')),
+ '#attached' => array(
+ 'library' => array(array('contextual', 'contextual-links')),
+ ),
+ );
+ $info['content'] = $build;
+ }
+ }
+
+ foreach (ctools_context_handler_get_task_arguments($task, $subtask) as $id => $argument) {
+ $plugin = ctools_get_argument($argument['name']);
+ $cid = ctools_context_id($argument, 'argument');
+ if (!empty($contexts[$cid]) && ($function = ctools_plugin_get_function($plugin, 'breadcrumb'))) {
+ $function($argument['settings'], $contexts[$cid]);
+ }
+ }
+
+ if (isset($info['title'])) {
+ drupal_set_title($info['title'], PASS_THROUGH);
+ }
+
+ // Only directly output if $page was set to true.
+ if (!empty($info['no_blocks'])) {
+ ctools_set_no_blocks(FALSE);
+ }
+ return $info['content'];
+}
+
+/**
+ * Default function to provide contextual link for a task as defined by the handler.
+ *
+ * This provides a simple link to th main content operation and is suitable
+ * for most normal handlers. Setting 'contextual link' to a function overrides
+ * this and setting it to FALSE will prevent a contextual link from appearing.
+ */
+function ctools_task_handler_default_contextual_link($handler, $plugin, $contexts, $args) {
+ if (!user_access('administer page manager')) {
+ return;
+ }
+
+ $task = page_manager_get_task($handler->task);
+
+ $title = !empty($task['tab title']) ? $task['tab title'] : t('Edit @type', array('@type' => $plugin['title']));
+ $trail = array();
+ if (!empty($plugin['tab operation'])) {
+ if (is_array($plugin['tab operation'])) {
+ $trail = $plugin['tab operation'];
+ }
+ else if (function_exists($plugin['tab operation'])) {
+ $trail = $plugin['tab operation']($handler, $contexts, $args);
+ }
+ }
+ $path = page_manager_edit_url(page_manager_make_task_name($handler->task, $handler->subtask), $trail);
+
+ $links = array(array(
+ 'href' => $path,
+ 'title' => $title,
+ 'query' => drupal_get_destination(),
+ ));
+
+ return $links;
+}
+
+/**
+ * Called to execute actions that should happen before a handler is rendered.
+ */
+function ctools_context_handler_pre_render($handler, $contexts, $args) { }
+
+/**
+ * Compare arguments to contexts for selection purposes.
+ *
+ * @param $handler
+ * The handler in question.
+ * @param $contexts
+ * The context objects provided by the task.
+ *
+ * @return
+ * TRUE if these contexts match the selection rules. NULL or FALSE
+ * otherwise.
+ */
+function ctools_context_handler_select($handler, $contexts) {
+ if (empty($handler->conf['access'])) {
+ return TRUE;
+ }
+
+ ctools_include('context');
+ return ctools_access($handler->conf['access'], $contexts);
+}
+
+/**
+ * Get the array of summary strings for the arguments.
+ *
+ * These summary strings are used to communicate to the user what
+ * arguments the task handlers are selecting.
+ *
+ * @param $task
+ * The loaded task plugin.
+ * @param $subtask
+ * The subtask id.
+ * @param $handler
+ * The handler to be checked.
+ */
+function ctools_context_handler_summary($task, $subtask, $handler) {
+ if (empty($handler->conf['access']['plugins'])) {
+ return array();
+ }
+
+ ctools_include('context');
+ $strings = array();
+ $contexts = ctools_context_handler_get_all_contexts($task, $subtask, $handler);
+
+ foreach ($handler->conf['access']['plugins'] as $test) {
+ $plugin = ctools_get_access_plugin($test['name']);
+ if ($string = ctools_access_summary($plugin, $contexts, $test)) {
+ $strings[] = $string;
+ }
+ }
+
+ return $strings;
+}
+
+// --------------------------------------------------------------------------
+// Tasks and Task handlers can both have their own sources of contexts.
+// Sometimes we need all of these contexts at once (when editing
+// the task handler, for example) but sometimes we need them separately
+// (when a task has contexts loaded and is trying out the task handlers,
+// for example). Therefore there are two paths we can take to getting contexts.
+
+/**
+ * Load the contexts for a task, using arguments.
+ *
+ * This creates the base array of contexts, loaded from arguments, suitable
+ * for use in rendering.
+ */
+function ctools_context_handler_get_task_contexts($task, $subtask, $args) {
+ $contexts = ctools_context_handler_get_base_contexts($task, $subtask);
+ $arguments = ctools_context_handler_get_task_arguments($task, $subtask);
+ ctools_context_get_context_from_arguments($arguments, $contexts, $args);
+
+ return $contexts;
+}
+
+/**
+ * Load the contexts for a task handler.
+ *
+ * This expands a base set of contexts passed in from a task with the
+ * contexts defined on the task handler. The contexts from the task
+ * must already have been loaded.
+ */
+function ctools_context_handler_get_handler_contexts($contexts, $handler) {
+ $object = ctools_context_handler_get_handler_object($handler);
+ return ctools_context_load_contexts($object, FALSE, $contexts);
+}
+
+/**
+ * Load the contexts for a task and task handler together.
+ *
+ * This pulls the arguments from a task and everything else from a task
+ * handler and loads them as a group. Since there is no data, this loads
+ * the contexts as placeholders.
+ */
+function ctools_context_handler_get_all_contexts($task, $subtask, $handler) {
+ $contexts = array();
+
+ $object = ctools_context_handler_get_task_object($task, $subtask, $handler);
+ $contexts = ctools_context_load_contexts($object, TRUE, $contexts);
+ ctools_context_handler_set_access_restrictions($task, $subtask, $handler, $contexts);
+ return $contexts;
+}
+
+/**
+ * Create an object suitable for use with the context system that kind of
+ * expects things in a certain, kind of clunky format.
+ */
+function ctools_context_handler_get_handler_object($handler) {
+ $object = new stdClass;
+ $object->name = $handler->name;
+ $object->contexts = isset($handler->conf['contexts']) ? $handler->conf['contexts'] : array();
+ $object->relationships = isset($handler->conf['relationships']) ? $handler->conf['relationships'] : array();
+
+ return $object;
+}
+
+/**
+ * Create an object suitable for use with the context system that kind of
+ * expects things in a certain, kind of clunky format. This one adds in
+ * arguments from the task.
+ */
+function ctools_context_handler_get_task_object($task, $subtask, $handler) {
+ $object = new stdClass;
+ $object->name = !empty($handler->name) ? $handler->name : 'temp';
+ $object->base_contexts = ctools_context_handler_get_base_contexts($task, $subtask, TRUE);
+ $object->arguments = ctools_context_handler_get_task_arguments($task, $subtask);
+ $object->contexts = isset($handler->conf['contexts']) ? $handler->conf['contexts'] : array();
+ $object->relationships = isset($handler->conf['relationships']) ? $handler->conf['relationships'] : array();
+
+ return $object;
+}
+
+/**
+ * Get base contexts from a task, if it has any.
+ *
+ * Tasks can get their contexts either from base contexts or arguments; base
+ * contexts extract their information from the environment.
+ */
+function ctools_context_handler_get_base_contexts($task, $subtask, $placeholders = FALSE) {
+ if ($function = ctools_plugin_get_function($task, 'get base contexts')) {
+ return $function($task, $subtask, $placeholders);
+ }
+
+ return array();
+}
+
+/**
+ * Get the arguments from a task that are used to load contexts.
+ */
+function ctools_context_handler_get_task_arguments($task, $subtask) {
+ if ($function = ctools_plugin_get_function($task, 'get arguments')) {
+ return $function($task, $subtask);
+ }
+
+ return array();
+}
+
+/**
+ * Set any access restrictions on the contexts for a handler.
+ *
+ * Both the task and the handler could add restrictions to the contexts
+ * based upon the access control. These restrictions might be useful
+ * to limit what kind of content appears in the add content dialog;
+ * for example, if we have an access item that limits a node context
+ * to only 'story' and 'page' types, there is no need for content that
+ * only applies to the 'poll' type to appear.
+ */
+function ctools_context_handler_set_access_restrictions($task, $subtask, $handler, &$contexts) {
+ // First, for the task:
+ if ($function = ctools_plugin_get_function($task, 'access restrictions')) {
+ $function($task, $subtask, $contexts);
+ }
+
+ // Then for the handler:
+ if (isset($handler->conf['access'])) {
+ ctools_access_add_restrictions($handler->conf['access'], $contexts);
+ }
+}
+
+/**
+ * Form to choose context based selection rules for a task handler.
+ *
+ * The configuration will be assumed to go simply in $handler->conf and
+ * will be keyed by the argument ID.
+ */
+function ctools_context_handler_edit_criteria($form, &$form_state) {
+ if (!isset($form_state['handler']->conf['access'])) {
+ $form_state['handler']->conf['access'] = array();
+ }
+
+ ctools_include('context');
+ ctools_include('modal');
+ ctools_include('ajax');
+ ctools_modal_add_plugin_js(ctools_get_access_plugins());
+ ctools_include('context-access-admin');
+ $form_state['module'] = (isset($form_state['module'])) ? $form_state['module'] : 'page_manager_task_handler';
+ // Encode a bunch of info into the argument so we can get our cache later
+ $form_state['callback argument'] = $form_state['task_name'] . '*' . $form_state['handler']->name;
+ $form_state['access'] = $form_state['handler']->conf['access'];
+ $form_state['no buttons'] = TRUE;
+ $form_state['contexts'] = ctools_context_handler_get_all_contexts($form_state['task'], $form_state['subtask'], $form_state['handler']);
+
+ $form['markup'] = array(
+ '#markup' => '
' .
+ t('If there is more than one variant on a page, when the page is visited each variant is given an opportunity to be displayed. Starting from the first variant and working to the last, each one tests to see if its selection rules will pass. The first variant that meets its criteria (as specified below) will be used.') .
+ '
',
+ '#markup' => theme('ctools_context_list', $theme_vars),
+ );
+
+ $form_state['context_object'] = &$cache;
+ return $form;
+}
+
+/**
+ * Process submission of the context edit form.
+ */
+function ctools_context_handler_edit_context_submit(&$form, &$form_state) {
+ $handler = &$form_state['handler'];
+
+ $cache_name = $handler->name ? $handler->name : 'temp';
+
+ $handler->conf['contexts'] = $form_state['context_object']->contexts;
+ $handler->conf['relationships'] = $form_state['context_object']->relationships;
+ if (isset($form_state['page']->context_cache[$cache_name])) {
+ unset($form_state['page']->context_cache[$cache_name]);
+ }
+}
+
diff --git a/sites/all/modules/contrib/ctools/includes/context.inc b/sites/all/modules/contrib/ctools/includes/context.inc
new file mode 100644
index 0000000..1f9c1e4
--- /dev/null
+++ b/sites/all/modules/contrib/ctools/includes/context.inc
@@ -0,0 +1,1602 @@
+type = $type;
+ $this->data = $data;
+ $this->title = t('Unknown context');
+ }
+
+ function is_type($type) {
+ if ($type == 'any' || $this->type == 'any') {
+ return TRUE;
+ }
+
+ $a = is_array($type) ? $type : array($type);
+ $b = is_array($this->type) ? $this->type : array($this->type);
+ return (bool) array_intersect($a, $b);
+ }
+
+ function get_argument() {
+ return $this->argument;
+ }
+
+ function get_original_argument() {
+ if (!is_null($this->original_argument)) {
+ return $this->original_argument;
+ }
+ return $this->argument;
+ }
+
+ function get_keyword() {
+ return $this->keyword;
+ }
+
+ function get_identifier() {
+ return $this->identifier;
+ }
+
+ function get_title() {
+ return $this->title;
+ }
+
+ function get_page_title() {
+ return $this->page_title;
+ }
+}
+
+/**
+ * Used to create a method of comparing if a list of contexts
+ * match a required context type.
+ */
+class ctools_context_required {
+ var $keywords = '';
+
+ /**
+ * If set, the title will be used in the selector to identify
+ * the context. This is very useful when multiple contexts
+ * are required to inform the user will be used for what.
+ */
+ var $title = NULL;
+
+ /**
+ * Test to see if this context is required.
+ */
+ var $required = TRUE;
+
+ /**
+ * If TRUE, skip the check in ctools_context_required::select()
+ * for contexts whose names may have changed.
+ */
+ var $skip_name_check = FALSE;
+
+ /**
+ *
+ * @param $title
+ * The first parameter should be the 'title' of the context for use
+ * in UYI selectors when multiple contexts qualify.
+ * @param ...
+ * One or more keywords to use for matching which contexts are allowed.
+ */
+ function ctools_context_required($title) {
+ $args = func_get_args();
+ $this->title = array_shift($args);
+
+ // If we have a boolean value at the end for $skip_name_check, store it
+ if (is_bool(end($args))) {
+ $this->skip_name_check = array_pop($args);
+ }
+
+ // If we were given restrictions at the end, store them.
+ if (count($args) > 1 && is_array(end($args))) {
+ $this->restrictions = array_pop($args);
+ }
+
+ if (count($args) == 1) {
+ $args = array_shift($args);
+ }
+ $this->keywords = $args;
+ }
+
+ function filter($contexts) {
+ $result = array();
+
+ // See which of these contexts are valid
+ foreach ((array) $contexts as $cid => $context) {
+ if ($context->is_type($this->keywords)) {
+ // Compare to see if our contexts were met.
+ if (!empty($this->restrictions) && !empty($context->restrictions)) {
+ foreach ($this->restrictions as $key => $values) {
+ // If we have a restriction, the context must either not have that
+ // restriction listed, which means we simply don't know what it is,
+ // or there must be an intersection of the restricted values on
+ // both sides.
+ if (!is_array($values)) {
+ $values = array($values);
+ }
+ if (!empty($context->restrictions[$key]) && !array_intersect($values, $context->restrictions[$key])) {
+ continue 2;
+ }
+ }
+ }
+ $result[$cid] = $context;
+ }
+ }
+
+ return $result;
+ }
+
+ function select($contexts, $context) {
+ if (!is_array($contexts)) {
+ if (is_object($contexts) && $contexts instanceof ctools_context) {
+ $contexts = array($contexts->id => $contexts);
+ }
+ else {
+ $contexts = array($contexts);
+ }
+ }
+
+ // If we had requested a $context but that $context doesn't exist
+ // in our context list, there is a good chance that what happened
+ // is our context IDs changed. See if there's another context
+ // that satisfies our requirements.
+ if (!$this->skip_name_check && !empty($context) && !isset($contexts[$context])) {
+ $choices = $this->filter($contexts);
+
+ // If we got a hit, take the first one that matches.
+ if ($choices) {
+ $keys = array_keys($choices);
+ $context = reset($keys);
+ }
+ }
+
+ if (empty($context) || empty($contexts[$context])) {
+ return FALSE;
+ }
+ return $contexts[$context];
+ }
+}
+
+/**
+ * Used to compare to see if a list of contexts match an optional context. This
+ * can produce empty contexts to use as placeholders.
+ */
+class ctools_context_optional extends ctools_context_required {
+ var $required = FALSE;
+ function ctools_context_optional() {
+ $args = func_get_args();
+ call_user_func_array(array($this, 'ctools_context_required'), $args);
+ }
+
+ /**
+ * Add the 'empty' context which is possible for optional
+ */
+ function add_empty(&$contexts) {
+ $context = new ctools_context('any');
+ $context->title = t('No context');
+ $context->identifier = t('No context');
+ $contexts['empty'] = $context;
+ }
+
+ function filter($contexts) {
+ $this->add_empty($contexts);
+ return parent::filter($contexts);
+ }
+
+ function select($contexts, $context) {
+ $this->add_empty($contexts);
+ if (empty($context)) {
+ return $contexts['empty'];
+ }
+
+ $result = parent::select($contexts, $context);
+
+ // Don't flip out if it can't find the context; this is optional, put
+ // in an empty.
+ if ($result == FALSE) {
+ $result = $contexts['empty'];
+ }
+ return $result;
+ }
+}
+
+/**
+ * Return a keyed array of context that match the given 'required context'
+ * filters.
+ *
+ * Functions or systems that require contexts of a particular type provide a
+ * ctools_context_required or ctools_context_optional object. This function
+ * examines that object and an array of contexts to determine which contexts
+ * match the filter.
+ *
+ * Since multiple contexts can be required, this function will accept either
+ * an array of all required contexts, or just a single required context object.
+ *
+ * @param $contexts
+ * A keyed array of all available contexts.
+ * @param $required
+ * A ctools_context_required or ctools_context_optional object, or an array
+ * of such objects.
+ *
+ * @return
+ * A keyed array of contexts that match the filter.
+ */
+function ctools_context_filter($contexts, $required) {
+ if (is_array($required)) {
+ $result = array();
+ foreach ($required as $r) {
+ $result = array_merge($result, _ctools_context_filter($contexts, $r));
+ }
+ return $result;
+ }
+
+ return _ctools_context_filter($contexts, $required);
+}
+
+function _ctools_context_filter($contexts, $required) {
+ $result = array();
+
+ if (is_object($required)) {
+ $result = $required->filter($contexts);
+ }
+
+ return $result;
+}
+
+/**
+ * Create a select box to choose possible contexts.
+ *
+ * This only creates a selector if there is actually a choice; if there
+ * is only one possible context, that one is silently assigned.
+ *
+ * If an array of required contexts is provided, one selector will be
+ * provided for each context.
+ *
+ * @param $contexts
+ * A keyed array of all available contexts.
+ * @param $required
+ * The required context object or array of objects.
+ *
+ * @return
+ * A form element, or NULL if there are no contexts that satisfy the
+ * requirements.
+ */
+function ctools_context_selector($contexts, $required, $default) {
+ if (is_array($required)) {
+ $result = array('#tree' => TRUE);
+ $count = 1;
+ foreach ($required as $id => $r) {
+ $result[] = _ctools_context_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++);
+ }
+ return $result;
+ }
+
+ return _ctools_context_selector($contexts, $required, $default);
+}
+
+function _ctools_context_selector($contexts, $required, $default, $num = 0) {
+ $filtered = ctools_context_filter($contexts, $required);
+ $count = count($filtered);
+
+ $form = array();
+
+ if ($count >= 1) {
+ // If there's more than one to choose from, create a select widget.
+ foreach ($filtered as $cid => $context) {
+ $options[$cid] = $context->get_identifier();
+ }
+ if (!empty($required->title)) {
+ $title = $required->title;
+ }
+ else {
+ $title = $num ? t('Context %count', array('%count' => $num)) : t('Context');
+ }
+
+ $form = array(
+ '#type' => 'select',
+ '#options' => $options,
+ '#title' => $title,
+ '#default_value' => $default,
+ );
+ }
+
+ return $form;
+}
+
+/**
+ * Are there enough contexts for a plugin?
+ *
+ * Some plugins can have a 'required contexts' item which can either
+ * be a context requirement object or an array of them. When contexts
+ * are required, items that do not have enough contexts should not
+ * appear. This tests an item to see if it has enough contexts
+ * to actually appear.
+ *
+ * @param $contexts
+ * A keyed array of all available contexts.
+ * @param $required
+ * The required context object or array of objects.
+ *
+ * @return
+ * TRUE if there are enough contexts, FALSE if there are not.
+ */
+function ctools_context_match_requirements($contexts, $required) {
+ if (!is_array($required)) {
+ $required = array($required);
+ }
+
+ // Get the keys to avoid bugs in PHP 5.0.8 with keys and loops.
+ // And use it to remove optional contexts.
+ $keys = array_keys($required);
+ foreach ($keys as $key) {
+ if (empty($required[$key]->required)) {
+ unset($required[$key]);
+ }
+ }
+
+ $count = count($required);
+ return (count(ctools_context_filter($contexts, $required)) >= $count);
+}
+
+/**
+ * Create a select box to choose possible contexts.
+ *
+ * This only creates a selector if there is actually a choice; if there
+ * is only one possible context, that one is silently assigned.
+ *
+ * If an array of required contexts is provided, one selector will be
+ * provided for each context.
+ *
+ * @param $contexts
+ * A keyed array of all available contexts.
+ * @param $required
+ * The required context object or array of objects.
+ *
+ * @return
+ * A form element, or NULL if there are no contexts that satisfy the
+ * requirements.
+ */
+function ctools_context_converter_selector($contexts, $required, $default) {
+ if (is_array($required)) {
+ $result = array('#tree' => TRUE);
+ $count = 1;
+ foreach ($required as $id => $r) {
+ $result[] = _ctools_context_converter_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++);
+ }
+ return $result;
+ }
+
+ return _ctools_context_converter_selector($contexts, $required, $default);
+}
+
+function _ctools_context_converter_selector($contexts, $required, $default, $num = 0) {
+ $filtered = ctools_context_filter($contexts, $required);
+ $count = count($filtered);
+
+ $form = array();
+
+ if ($count > 1) {
+ // If there's more than one to choose from, create a select widget.
+ $options = array();
+ foreach ($filtered as $cid => $context) {
+ if ($context->type == 'any') {
+ $options[''] = t('No context');
+ continue;
+ }
+ $key = $context->get_identifier();
+ if ($converters = ctools_context_get_converters($cid . '.', $context)) {
+ $options[$key] = $converters;
+ }
+ }
+ if (empty($options)) {
+ return array(
+ '#type' => 'value',
+ '#value' => 'any',
+ );
+ }
+ if (!empty($required->title)) {
+ $title = $required->title;
+ }
+ else {
+ $title = $num ? t('Context %count', array('%count' => $num)) : t('Context');
+ }
+
+ return array(
+ '#type' => 'select',
+ '#options' => $options,
+ '#title' => $title,
+ '#description' => t('Please choose which context and how you would like it converted.'),
+ '#default_value' => $default,
+ );
+ }
+}
+
+/**
+ * Get a list of converters available for a given context.
+ */
+function ctools_context_get_converters($cid, $context) {
+ if (empty($context->plugin)) {
+ return array();
+ }
+
+ return _ctools_context_get_converters($cid, $context->plugin);
+}
+
+/**
+ * Get a list of converters available for a given context.
+ */
+function _ctools_context_get_converters($id, $plugin_name) {
+ $plugin = ctools_get_context($plugin_name);
+ if (empty($plugin['convert list'])) {
+ return array();
+ }
+
+ $converters = array();
+ if (is_array($plugin['convert list'])) {
+ $converters = $plugin['convert list'];
+ }
+ else if ($function = ctools_plugin_get_function($plugin, 'convert list')) {
+ $converters = (array) $function($plugin);
+ }
+
+ foreach (module_implements('ctools_context_convert_list_alter') as $module) {
+ $function = $module . '_ctools_context_convert_list_alter';
+ $function($plugin, $converters);
+ }
+
+ // Now, change them all to include the plugin:
+ $return = array();
+ foreach ($converters as $key => $title) {
+ $return[$id . $key] = $title;
+ }
+
+ natcasesort($return);
+ return $return;
+}
+
+/**
+ * Get a list of all contexts + converters available.
+ */
+function ctools_context_get_all_converters() {
+ $contexts = ctools_get_contexts();
+ $converters = array();
+ foreach ($contexts as $name => $context) {
+ if (empty($context['no required context ui'])) {
+ $context_converters = _ctools_context_get_converters($name . '.', $name);
+ if ($context_converters) {
+ $converters[$context['title']] = $context_converters;
+ }
+ }
+ }
+
+ return $converters;
+}
+
+/**
+ * Let the context convert an argument based upon the converter that was given.
+ *
+ * @param $context
+ * The context object
+ * @param $converter
+ * The converter to use, which should be a string provided by the converter list.
+ * @param $converter_options
+ * A n array of options to pass on to the generation function. For contexts
+ * that use token module, of particular use is 'sanitize' => FALSE which can
+ * get raw tokens. This should ONLY be used in values that will later be
+ * treated as unsafe user input since these values are by themselves unsafe.
+ * It is particularly useful to get raw values from Field API.
+ */
+function ctools_context_convert_context($context, $converter, $converter_options = array()) {
+ // Contexts without plugins might be optional placeholders.
+ if (empty($context->plugin)) {
+ return;
+ }
+
+ $value = $context->argument;
+ $plugin = ctools_get_context($context->plugin);
+ if ($function = ctools_plugin_get_function($plugin, 'convert')) {
+ $value = $function($context, $converter, $converter_options);
+ }
+
+ foreach (module_implements('ctools_context_converter_alter') as $module) {
+ $function = $module . '_ctools_context_converter_alter';
+ $function($context, $converter, $value, $converter_options);
+ }
+
+ return $value;
+}
+
+/**
+ * Choose a context or contexts based upon the selection made via
+ * ctools_context_filter.
+ *
+ * @param $contexts
+ * A keyed array of all available contexts
+ * @param $required
+ * The required context object provided by the plugin
+ * @param $context
+ * The selection made using ctools_context_selector
+ */
+function ctools_context_select($contexts, $required, $context) {
+ if (is_array($required)) {
+ $result = array();
+ foreach ($required as $id => $r) {
+ if (empty($required[$id])) {
+ continue;
+ }
+
+ if (($result[] = _ctools_context_select($contexts, $r, $context[$id])) === FALSE) {
+ return FALSE;
+ }
+ }
+ return $result;
+ }
+
+ return _ctools_context_select($contexts, $required, $context);
+}
+
+function _ctools_context_select($contexts, $required, $context) {
+ if (!is_object($required)) {
+ return FALSE;
+ }
+
+ return $required->select($contexts, $context);
+}
+
+/**
+ * Create a new context object.
+ *
+ * @param $type
+ * The type of context to create; this loads a plugin.
+ * @param $data
+ * The data to put into the context.
+ * @param $empty
+ * Whether or not this context is specifically empty.
+ * @param $conf
+ * A configuration structure if this context was created via UI.
+ *
+ * @return
+ * A $context or NULL if one could not be created.
+ */
+function ctools_context_create($type, $data = NULL, $conf = FALSE) {
+ ctools_include('plugins');
+ $plugin = ctools_get_context($type);
+
+ if ($function = ctools_plugin_get_function($plugin, 'context')) {
+ return $function(FALSE, $data, $conf, $plugin);
+ }
+}
+
+/**
+ * Create an empty context object.
+ *
+ * Empty context objects are primarily used as placeholders in the UI where
+ * the actual contents of a context object may not be known. It may have
+ * additional text embedded to give the user clues as to how the context
+ * is used.
+ *
+ * @param $type
+ * The type of context to create; this loads a plugin.
+ *
+ * @return
+ * A $context or NULL if one could not be created.
+ */
+function ctools_context_create_empty($type) {
+ $plugin = ctools_get_context($type);
+ if ($function = ctools_plugin_get_function($plugin, 'context')) {
+ $context = $function(TRUE, NULL, FALSE, $plugin);
+ if (is_object($context)) {
+ $context->empty = TRUE;
+ }
+
+ return $context;
+ }
+}
+
+/**
+ * Perform keyword and context substitutions.
+ */
+function ctools_context_keyword_substitute($string, $keywords, $contexts, $converter_options = array()) {
+ // Ensure a default keyword exists:
+ $keywords['%%'] = '%';
+
+ // Match contexts to the base keywords:
+ $context_keywords = array();
+ foreach ($contexts as $context) {
+ if (isset($context->keyword)) {
+ $context_keywords[$context->keyword] = $context;
+ }
+ }
+
+ // Look for context matches we we only have to convert known matches.
+ $matches = array();
+ if (preg_match_all('/%(%|[a-zA-Z0-9_-]+(?:\:[a-zA-Z0-9_-]+)*)/us', $string, $matches)) {
+ foreach ($matches[1] as $keyword) {
+ // Ignore anything it finds with %%.
+ if ($keyword[0] == '%') {
+ continue;
+ }
+
+ // If the keyword is already set by something passed in, don't try to
+ // overwrite it.
+ if (!empty($keywords['%' . $keyword])) {
+ continue;
+ }
+
+ // Figure out our keyword and converter, if specified.
+ if (strpos($keyword, ':')) {
+ list($context, $converter) = explode(':', $keyword, 2);
+ }
+ else {
+ $context = $keyword;
+ if (isset($context_keywords[$keyword])) {
+ $plugin = ctools_get_context($context_keywords[$context]->plugin);
+
+ // Fall back to a default converter, if specified.
+ if ($plugin && !empty($plugin['convert default'])) {
+ $converter = $plugin['convert default'];
+ }
+ }
+ }
+
+ if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) {
+ $keywords['%' . $keyword] = '';
+ }
+ else if (!empty($converter)) {
+ $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options);
+ }
+ else {
+ $keywords['%' . $keyword] = $context_keywords[$keyword]->title;
+ }
+ }
+ }
+ return strtr($string, $keywords);
+}
+
+/**
+ * Determine a unique context ID for a context
+ *
+ * Often contexts of many different types will be placed into a list. This
+ * ensures that even though contexts of multiple types may share IDs, they
+ * are unique in the final list.
+ */
+function ctools_context_id($context, $type = 'context') {
+ if (!$context['id']) {
+ $context['id'] = 1;
+ }
+
+ return $type . '_' . $context['name'] . '_' . $context['id'];
+}
+
+/**
+ * Get the next id available given a list of already existing objects.
+ *
+ * This finds the next id available for the named object.
+ *
+ * @param $objects
+ * A list of context descriptor objects, i.e, arguments, relationships, contexts, etc.
+ * @param $name
+ * The name being used.
+ */
+function ctools_context_next_id($objects, $name) {
+ $id = 0;
+ // Figure out which instance of this argument we're creating
+ if (!$objects) {
+ return $id + 1;
+ }
+
+ foreach ($objects as $object) {
+ if (isset($object['name']) && $object['name'] == $name) {
+ if ($object['id'] > $id) {
+ $id = $object['id'];
+ }
+ }
+ }
+
+ return $id + 1;
+}
+
+
+// ---------------------------------------------------------------------------
+// Functions related to contexts from arguments.
+
+/**
+ * Fetch metadata on a specific argument plugin.
+ *
+ * @param $argument
+ * Name of an argument plugin.
+ *
+ * @return
+ * An array with information about the requested argument plugin.
+ */
+function ctools_get_argument($argument) {
+ ctools_include('plugins');
+ return ctools_get_plugins('ctools', 'arguments', $argument);
+}
+
+/**
+ * Fetch metadata for all argument plugins.
+ *
+ * @return
+ * An array of arrays with information about all available argument plugins.
+ */
+function ctools_get_arguments() {
+ ctools_include('plugins');
+ return ctools_get_plugins('ctools', 'arguments');
+}
+
+/**
+ * Get a context from an argument.
+ *
+ * @param $argument
+ * The configuration of an argument. It must contain the following data:
+ * - name: The name of the argument plugin being used.
+ * - argument_settings: The configuration based upon the plugin forms.
+ * - identifier: The human readable identifier for this argument, usually
+ * defined by the UI.
+ * - keyword: The keyword used for this argument for substitutions.
+ *
+ * @param $arg
+ * The actual argument received. This is expected to be a string from a URL but
+ * this does not have to be the only source of arguments.
+ * @param $empty
+ * If true, the $arg will not be used to load the context. Instead, an empty
+ * placeholder context will be loaded.
+ *
+ * @return
+ * A context object if one can be loaded.
+ */
+function ctools_context_get_context_from_argument($argument, $arg, $empty = FALSE) {
+ ctools_include('plugins');
+ if (empty($argument['name'])) {
+ return;
+ }
+
+ if ($function = ctools_plugin_load_function('ctools', 'arguments', $argument['name'], 'context')) {
+ // Backward compatibility: Merge old style settings into new style:
+ if (!empty($argument['settings'])) {
+ $argument += $argument['settings'];
+ unset($argument['settings']);
+ }
+
+ $context = $function($arg, $argument, $empty);
+
+ if (is_object($context)) {
+ $context->identifier = $argument['identifier'];
+ $context->page_title = isset($argument['title']) ? $argument['title'] : '';
+ $context->keyword = $argument['keyword'];
+ $context->id = ctools_context_id($argument, 'argument');
+ $context->original_argument = $arg;
+
+ if (!empty($context->empty)) {
+ $context->placeholder = array(
+ 'type' => 'argument',
+ 'conf' => $argument,
+ );
+ }
+ }
+ return $context;
+ }
+}
+
+/**
+ * Retrieve a list of empty contexts for all arguments.
+ */
+function ctools_context_get_placeholders_from_argument($arguments) {
+ $contexts = array();
+ foreach ($arguments as $argument) {
+ $context = ctools_context_get_context_from_argument($argument, NULL, TRUE);
+ if ($context) {
+ $contexts[ctools_context_id($argument, 'argument')] = $context;
+ }
+ }
+ return $contexts;
+}
+
+/**
+ * Load the contexts for a given list of arguments.
+ *
+ * @param $arguments
+ * The array of argument definitions.
+ * @param &$contexts
+ * The array of existing contexts. New contexts will be added to this array.
+ * @param $args
+ * The arguments to load.
+ *
+ * @return
+ * FALSE if an argument wants to 404.
+ */
+function ctools_context_get_context_from_arguments($arguments, &$contexts, $args) {
+ foreach ($arguments as $argument) {
+ // pull the argument off the list.
+ $arg = array_shift($args);
+ $id = ctools_context_id($argument, 'argument');
+
+ // For % arguments embedded in the URL, our context is already loaded.
+ // There is no need to go and load it again.
+ if (empty($contexts[$id])) {
+ if ($context = ctools_context_get_context_from_argument($argument, $arg)) {
+ $contexts[$id] = $context;
+ }
+ }
+ else {
+ $context = $contexts[$id];
+ }
+
+ if ((empty($context) || empty($context->data)) && !empty($argument['default']) && $argument['default'] == '404') {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+// ---------------------------------------------------------------------------
+// Functions related to contexts from relationships.
+
+/**
+ * Fetch metadata on a specific relationship plugin.
+ *
+ * @param $content type
+ * Name of a panel content type.
+ *
+ * @return
+ * An array with information about the requested relationship.
+ */
+function ctools_get_relationship($relationship) {
+ ctools_include('plugins');
+ return ctools_get_plugins('ctools', 'relationships', $relationship);
+}
+
+/**
+ * Fetch metadata for all relationship plugins.
+ *
+ * @return
+ * An array of arrays with information about all available relationships.
+ */
+function ctools_get_relationships() {
+ ctools_include('plugins');
+ return ctools_get_plugins('ctools', 'relationships');
+}
+
+/**
+ *
+ * @param $relationship
+ * The configuration of a relationship. It must contain the following data:
+ * - name: The name of the relationship plugin being used.
+ * - relationship_settings: The configuration based upon the plugin forms.
+ * - identifier: The human readable identifier for this relationship, usually
+ * defined by the UI.
+ * - keyword: The keyword used for this relationship for substitutions.
+ *
+ * @param $source_context
+ * The context this relationship is based upon.
+ *
+ * @param $placeholders
+ * If TRUE, placeholders are acceptable.
+ *
+ * @return
+ * A context object if one can be loaded.
+ */
+function ctools_context_get_context_from_relationship($relationship, $source_context, $placeholders = FALSE) {
+ ctools_include('plugins');
+ if ($function = ctools_plugin_load_function('ctools', 'relationships', $relationship['name'], 'context')) {
+ // Backward compatibility: Merge old style settings into new style:
+ if (!empty($relationship['relationship_settings'])) {
+ $relationship += $relationship['relationship_settings'];
+ unset($relationship['relationship_settings']);
+ }
+
+ $context = $function($source_context, $relationship, $placeholders);
+ if ($context) {
+ $context->identifier = $relationship['identifier'];
+ $context->page_title = isset($relationship['title']) ? $relationship['title'] : '';
+ $context->keyword = $relationship['keyword'];
+ if (!empty($context->empty)) {
+ $context->placeholder = array(
+ 'type' => 'relationship',
+ 'conf' => $relationship,
+ );
+ }
+ return $context;
+ }
+ }
+}
+
+/**
+ * Fetch all relevant relationships.
+ *
+ * Relevant relationships are any relationship that can be created based upon
+ * the list of existing contexts. For example, the 'node author' relationship
+ * is relevant if there is a 'node' context, but makes no sense if there is
+ * not one.
+ *
+ * @param $contexts
+ * An array of contexts used to figure out which relationships are relevant.
+ *
+ * @return
+ * An array of relationship keys that are relevant for the given set of
+ * contexts.
+ */
+function ctools_context_get_relevant_relationships($contexts) {
+ $relevant = array();
+ $relationships = ctools_get_relationships();
+
+ // Go through each relationship
+ foreach ($relationships as $rid => $relationship) {
+ // For each relationship, see if there is a context that satisfies it.
+ if (empty($relationship['no ui']) && ctools_context_filter($contexts, $relationship['required context'])) {
+ $relevant[$rid] = $relationship['title'];
+ }
+ }
+
+ return $relevant;
+}
+
+/**
+ * Fetch all active relationships
+ *
+ * @param $relationships
+ * An keyed array of relationship data including:
+ * - name: name of relationship
+ * - context: context id relationship belongs to. This will be used to
+ * identify which context in the $contexts array to use to create the
+ * relationship context.
+ *
+ * @param $contexts
+ * A keyed array of contexts used to figure out which relationships
+ * are relevant. New contexts will be added to this.
+ *
+ * @param $placeholders
+ * If TRUE, placeholders are acceptable.
+ */
+function ctools_context_get_context_from_relationships($relationships, &$contexts, $placeholders = FALSE) {
+ $return = array();
+
+ foreach ($relationships as $rdata) {
+ if (!isset($rdata['context'])) {
+ continue;
+ }
+
+ if (is_array($rdata['context'])) {
+ $rcontexts = array();
+ foreach ($rdata['context'] as $cid) {
+ if (empty($contexts[$cid])) {
+ continue 2;
+ }
+ $rcontexts[] = $contexts[$cid];
+ }
+ }
+ else {
+ if (empty($contexts[$rdata['context']])) {
+ continue;
+ }
+ $rcontexts = $contexts[$rdata['context']];
+ }
+
+ $cid = ctools_context_id($rdata, 'relationship');
+ if ($context = ctools_context_get_context_from_relationship($rdata, $rcontexts)) {
+ $contexts[$cid] = $context;
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Functions related to loading contexts from simple context definitions.
+
+/**
+ * Fetch metadata on a specific context plugin.
+ *
+ * @param $context
+ * Name of a context.
+ *
+ * @return
+ * An array with information about the requested panel context.
+ */
+function ctools_get_context($context) {
+ static $gate = array();
+ ctools_include('plugins');
+ $plugin = ctools_get_plugins('ctools', 'contexts', $context);
+ if (empty($gate['context']) && !empty($plugin['superceded by'])) {
+ // This gate prevents infinite loops.
+ $gate[$context] = TRUE;
+ $new_plugin = ctools_get_plugins('ctools', 'contexts', $plugin['superceded by']);
+ $gate[$context] = FALSE;
+
+ // If a new plugin was returned, return it. Otherwise fall through and
+ // return the original we fetched.
+ if ($new_plugin) {
+ return $new_plugin;
+ }
+ }
+
+ return $plugin;
+}
+
+/**
+ * Fetch metadata for all context plugins.
+ *
+ * @return
+ * An array of arrays with information about all available panel contexts.
+ */
+function ctools_get_contexts() {
+ ctools_include('plugins');
+ return ctools_get_plugins('ctools', 'contexts');
+}
+
+/**
+ *
+ * @param $context
+ * The configuration of a context. It must contain the following data:
+ * - name: The name of the context plugin being used.
+ * - context_settings: The configuration based upon the plugin forms.
+ * - identifier: The human readable identifier for this context, usually
+ * defined by the UI.
+ * - keyword: The keyword used for this context for substitutions.
+ * @param $type
+ * This is either 'context' which indicates the context will be loaded
+ * from data in the settings, or 'required_context' which means the
+ * context must be acquired from an external source. This is the method
+ * used to pass pure contexts from one system to another.
+ *
+ * @return
+ * A context object if one can be loaded.
+ */
+function ctools_context_get_context_from_context($context, $type = 'context', $argument = NULL) {
+ ctools_include('plugins');
+ $plugin = ctools_get_context($context['name']);
+ if ($function = ctools_plugin_get_function($plugin, 'context')) {
+ // Backward compatibility: Merge old style settings into new style:
+ if (!empty($context['context_settings'])) {
+ $context += $context['context_settings'];
+ unset($context['context_settings']);
+ }
+
+ if (isset($argument) && isset($plugin['placeholder name'])) {
+ $context[$plugin['placeholder name']] = $argument;
+ }
+
+ $return = $function($type == 'requiredcontext', $context, TRUE, $plugin);
+ if ($return) {
+ $return->identifier = $context['identifier'];
+ $return->page_title = isset($context['title']) ? $context['title'] : '';
+ $return->keyword = $context['keyword'];
+
+ if (!empty($context->empty)) {
+ $context->placeholder = array(
+ 'type' => 'context',
+ 'conf' => $context,
+ );
+ }
+
+ return $return;
+ }
+ }
+}
+
+/**
+ * Retrieve a list of base contexts based upon a simple 'contexts' definition.
+ *
+ * For required contexts this will always retrieve placeholders.
+ *
+ * @param $contexts
+ * The list of contexts defined in the UI.
+ * @param $type
+ * Either 'context' or 'requiredcontext', which indicates whether the contexts
+ * are loaded from internal data or copied from an external source.
+ * @param $placeholders
+ * If true, placeholders are acceptable.
+ */
+function ctools_context_get_context_from_contexts($contexts, $type = 'context', $placeholders = FALSE) {
+ $return = array();
+ foreach ($contexts as $context) {
+ $ctext = ctools_context_get_context_from_context($context, $type);
+ if ($ctext) {
+ if ($placeholders) {
+ $ctext->placeholder = TRUE;
+ }
+ $return[ctools_context_id($context, $type)] = $ctext;
+ }
+ }
+ return $return;
+}
+
+/**
+ * Match up external contexts to our required contexts.
+ *
+ * This function is used to create a list of contexts with proper
+ * IDs based upon a list of required contexts.
+ *
+ * These contexts passed in should match the numeric positions of the
+ * required contexts. The caller must ensure this has already happened
+ * correctly as this function will not detect errors here.
+ *
+ * @param $required
+ * A list of required contexts as defined by the UI.
+ * @param $contexts
+ * A list of matching contexts as passed in from the calling system.
+ */
+function ctools_context_match_required_contexts($required, $contexts) {
+ $return = array();
+ if (!is_array($required)) {
+ return $return;
+ }
+
+ foreach ($required as $r) {
+ $context = clone(array_shift($contexts));
+ $context->identifier = $r['identifier'];
+ $context->page_title = isset($r['title']) ? $r['title'] : '';
+ $context->keyword = $r['keyword'];
+ $return[ctools_context_id($r, 'requiredcontext')] = $context;
+ }
+
+ return $return;
+}
+
+/**
+ * Load a full array of contexts for an object.
+ *
+ * Not all of the types need to be supported by this object.
+ *
+ * This function is not used to load contexts from external data, but may
+ * be used to load internal contexts and relationships. Otherwise it can also
+ * be used to generate a full set of placeholders for UI purposes.
+ *
+ * @param $object
+ * An object that contains some or all of the following variables:
+ *
+ * - requiredcontexts: A list of UI configured contexts that are required
+ * from an external source. Since these require external data, they will
+ * only be added if $placeholders is set to TRUE, and empty contexts will
+ * be created.
+ * - arguments: A list of UI configured arguments that will create contexts.
+ * Since these require external data, they will only be added if $placeholders
+ * is set to TRUE.
+ * - contexts: A list of UI configured contexts that have no external source,
+ * and are essentially hardcoded. For example, these might configure a
+ * particular node or a particular taxonomy term.
+ * - relationships: A list of UI configured contexts to be derived from other
+ * contexts that already exist from other sources. For example, these might
+ * be used to get a user object from a node via the node author relationship.
+ * @param $placeholders
+ * If TRUE, this will generate placeholder objects for types this function
+ * cannot load.
+ * @param $contexts
+ * An array of pre-existing contexts that will be part of the return value.
+ */
+function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts = array()) {
+ if (!empty($object->base_contexts)) {
+ $contexts += $object->base_contexts;
+ }
+
+ if ($placeholders) {
+ // This will load empty contexts as placeholders for arguments that come
+ // from external sources. If this isn't set, it's assumed these context
+ // will already have been matched up and loaded.
+ if (!empty($object->requiredcontexts) && is_array($object->requiredcontexts)) {
+ $contexts += ctools_context_get_context_from_contexts($object->requiredcontexts, 'requiredcontext', $placeholders);
+ }
+
+ if (!empty($object->arguments) && is_array($object->arguments)) {
+ $contexts += ctools_context_get_placeholders_from_argument($object->arguments);
+ }
+ }
+
+ if (!empty($object->contexts) && is_array($object->contexts)) {
+ $contexts += ctools_context_get_context_from_contexts($object->contexts, 'context', $placeholders);
+ }
+
+ // add contexts from relationships
+ if (!empty($object->relationships) && is_array($object->relationships)) {
+ ctools_context_get_context_from_relationships($object->relationships, $contexts, $placeholders);
+ }
+
+ return $contexts;
+}
+
+/**
+ * Return the first context with a form id from a list of contexts.
+ *
+ * This function is used to figure out which contexts represents 'the form'
+ * from a list of contexts. Only one contexts can actually be 'the form' for
+ * a given page, since the @code{