mirror of
https://github.com/tag1consulting/d7_to_d10_migration.git
synced 2025-06-16 01:15:12 +00:00
Initial commit
This commit is contained in:
commit
1664d5cfe6
2772 changed files with 600692 additions and 0 deletions
drupal7/web/sites/all/modules
README.txt
contrib
addressfield
LICENSE.txtaddresses.txtaddressfield-rtl.cssaddressfield.address_formats.incaddressfield.administrative_areas.incaddressfield.api.phpaddressfield.cssaddressfield.devel_generate.incaddressfield.feeds.incaddressfield.infoaddressfield.installaddressfield.migrate.incaddressfield.moduleaddressfield.tokens.inc
example
plugins/format
address-hide-administrative-area.incaddress-hide-country.incaddress-hide-locality.incaddress-hide-postal-code.incaddress-hide-street.incaddress-optional.incaddress.incname-full.incname-oneline.incorganisation.inc
views
ctools
API.txtLICENSE.txtREADME.txtUPGRADE.txt
bulk_export
css
button.csscollapsible-div.csscontext.cssctools.cssdropbutton.cssdropdown.cssexport-ui-list.cssmodal-rtl.cssmodal.cssruleset.cssstylizer.csswizard.css
ctools.api.phpctools.infoctools.installctools.modulectools_access_ruleset
ctools_ajax_sample
ctools_custom_content
ctools_custom_content.infoctools_custom_content.installctools_custom_content.module
plugins/export_ui
ctools_plugin_example
README.txtctools_plugin_example.infoctools_plugin_example.modulectools_plugin_example.pages_default.inc
help
Access-Plugins--Determining-access-and-visibility.htmlArgument-Plugins--Starting-at-the-beginning.htmlChaos-Tools--CTools--Plugin-Examples.htmlContent-Type-Plugins--Displaying-content-using-a-context.htmlContext-plugins--Creating-a--context--from-an-argument.htmlModule-setup-and-hooks.htmlRelationships--Letting-one-context-take-us-to-another.htmlctools_plugin_example.help.ini
plugins
drush
37
drupal7/web/sites/all/modules/README.txt
Normal file
37
drupal7/web/sites/all/modules/README.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
Modules extend your site functionality beyond Drupal core.
|
||||
|
||||
WHAT TO PLACE IN THIS DIRECTORY?
|
||||
--------------------------------
|
||||
|
||||
Placing downloaded and custom modules in this directory separates downloaded and
|
||||
custom modules from Drupal core's modules. This allows Drupal core to be updated
|
||||
without overwriting these files.
|
||||
|
||||
DOWNLOAD ADDITIONAL MODULES
|
||||
---------------------------
|
||||
|
||||
Contributed modules from the Drupal community may be downloaded at
|
||||
https://www.drupal.org/project/project_module.
|
||||
|
||||
ORGANIZING MODULES IN THIS DIRECTORY
|
||||
------------------------------------
|
||||
|
||||
You may create subdirectories in this directory, to organize your added modules,
|
||||
without breaking the site. Some common subdirectories include "contrib" for
|
||||
contributed modules, and "custom" for custom modules. Note that if you move a
|
||||
module to a subdirectory after it has been enabled, you may need to clear the
|
||||
Drupal cache so it can be found. (Alternatively, you can disable the module
|
||||
before moving it and then re-enable it after the move.)
|
||||
|
||||
MULTISITE CONFIGURATION
|
||||
-----------------------
|
||||
|
||||
In multisite configurations, modules found in this directory are available to
|
||||
all sites. Alternatively, the sites/your_site_name/modules directory pattern
|
||||
may be used to restrict modules to a specific site instance.
|
||||
|
||||
MORE INFORMATION
|
||||
----------------
|
||||
|
||||
Refer to the "Developing for Drupal" section of the README.txt in the Drupal
|
||||
root directory for further information on extending Drupal with custom modules.
|
339
drupal7/web/sites/all/modules/contrib/addressfield/LICENSE.txt
Normal file
339
drupal7/web/sites/all/modules/contrib/addressfield/LICENSE.txt
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
298
drupal7/web/sites/all/modules/contrib/addressfield/addresses.txt
Normal file
298
drupal7/web/sites/all/modules/contrib/addressfield/addresses.txt
Normal file
|
@ -0,0 +1,298 @@
|
|||
AT NULL Feldkirch NULL 6800 Pater Grimm Weg 20 NULL
|
||||
AU NULL Melbourne NULL NULL
|
||||
AU NULL Sydney NULL NULL
|
||||
AU 4 NULL NORMANBY NULL 4059 30 Normanby Terrace NULL
|
||||
BD NULL Dhaka NULL 1205 23, Subal Das Road, Chowdhury Bazar, Lalbagh NULL
|
||||
BD NULL Dhaka NULL 1207 R-1,H-19,Kallaynpur,Mirpur,Dhaka NULL
|
||||
BD NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar NULL
|
||||
BD NULL Dhaka NULL 1209 House# 66B, Flat# B2 Zigatola NULL
|
||||
BD NULL Dhaka NULL 1219 390 West Rampura Dhaka NULL
|
||||
BD NULL Dhaka NULL 1230 Uttara NULL
|
||||
BD 81 NULL Dhaka NULL 1000 Institute of Water and Flood Management NULL
|
||||
BD 81 NULL Dhaka NULL 1203 84/a maniknagar NULL
|
||||
BD 81 NULL Dhaka NULL 1205 Dhaka Bangladesh NULL
|
||||
BD 81 NULL Dhaka NULL 1207 BetterStories Limited 17 West Panthopath NULL
|
||||
BD 81 NULL Dhaka NULL 1216 Mirpur, Dhaka NULL
|
||||
BD 81 NULL Dhaka NULL 1230 830, Prembagan, Dhakshin Khan NULL
|
||||
BD 82 NULL khulna NULL 9203 NULL
|
||||
BD NULL NULL Dhaka NULL 1000 Institute of Water and Flood Management NULL
|
||||
BD NULL NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar NULL
|
||||
BE NULL Brussels NULL NULL
|
||||
BE NULL Watermael-Boitsfort NULL 1170 Avenue des Staphylins NULL
|
||||
BH NULL Manama NULL 973 Manama Bahrain Manama Bahrain NULL
|
||||
BR NULL Porto Alegre NULL NULL
|
||||
BR NULL Recife NULL NULL
|
||||
BR RJ NULL Rio de Janeiro NULL NULL
|
||||
BW NULL Francistown NULL NULL NULL
|
||||
BW NULL NULL Francistown NULL NULL NULL
|
||||
CA NULL Montreal NULL NULL
|
||||
CA NULL Toronto NULL NULL
|
||||
CA BC NULL Vancouver NULL NULL
|
||||
CA ON NULL Kitchener NULL NULL
|
||||
CA ON NULL wterloo NULL n2l3g1 200 University Avenue West NULL
|
||||
CH NULL Geneva NULL 1202 15, chemin Louis-Dunant NULL
|
||||
CH 25 NULL Zurich NULL 8098 UBS Optimus Foundation Augustinerhof 1 NULL
|
||||
DE NULL Berlin NULL NULL
|
||||
DE 5 NULL Frankfurt am Main NULL 60386 Johanna-Tesch-Platz 7 NULL
|
||||
DK NULL Aarhus NULL NULL
|
||||
ES NULL Bilbao NULL NULL
|
||||
ET 44 NULL ADDIS ABABA NULL 11945 ADDIS ABABA,P.O.BOX 11945 NULL
|
||||
FI NULL Espoo NULL 2130 Mahlarinne 3B NULL
|
||||
FI NULL Helsinki NULL 580 Hermannin rantatie 2 A Hermannin rantatie 2 A NULL
|
||||
FI NULL Tampere NULL 33101 Tampere University of Technology NULL
|
||||
FI 13 NULL Espoo NULL 2150 Aalto Venture Garage Betonimiehenkuja 3 NULL
|
||||
GB NULL Exeter NULL NULL
|
||||
GB NULL London NULL NULL
|
||||
GB NULL London NULL N4 2DP 2 Myddleton Ave NULL
|
||||
GB NULL London NULL N7 0AH 104 St George’s Avenue NULL
|
||||
GB NULL London NULL SE16 3UL 25 Blue Anchor Lane NULL
|
||||
GB NULL London NULL SW18 5SP Flat 1 150 Merton road NULL
|
||||
GB NULL London NULL W1T 4BQ 13 Fitzroy Street NULL
|
||||
GB NULL Oxford NULL NULL
|
||||
GB NULL Southampton NULL NULL
|
||||
GB C3 NULL NULL cb244qg 32 market street swavesey NULL
|
||||
GB E7 NULL London NULL SE3 7TP NULL
|
||||
GB F3 NULL Wood Green NULL N22 5RU 6 Cedar House NULL
|
||||
GB H1 NULL London NULL SE11 5JD 47-49 Durham Street NULL
|
||||
GB H6 NULL London NULL SE8 4DD 8 Harton St Deptford NULL
|
||||
GB K2 NULL Oxford NULL OX2 6QY 3 The Villas, Rutherway NULL
|
||||
GH 5 NULL NSAWAM NULL NULL P.O.BOX 455 NULL
|
||||
GH NULL NULL Accra NULL NULL NULL
|
||||
ID NULL Bandung NULL 40134 Jalan Sadang Hegar 1 No. 12 RT04 RW13 Sadang Serang NULL
|
||||
ID NULL Bekasi NULL 17411 Jl.Binadharma 1 No.62. Jatiwaringin NULL
|
||||
ID NULL Jakarta NULL NULL
|
||||
ID NULL Jakarta NULL 12440 Jl. H. Niin 7 Lebak Bulus, Cilandak NULL
|
||||
ID NULL Jakarta NULL 13330 Otista NULL
|
||||
ID NULL Jakarta selatan NULL 12000 jl. rawa jati timur 6 no. 10 NULL
|
||||
ID NULL Jakarta Timur NULL Jl.Mulia No.15B Kel.Bidara Cina, Kec.Jatinegara, Jakarta Timur NULL
|
||||
ID NULL Pematang Siantar NULL 51511 Jl. Durian I 30 NULL
|
||||
ID 4 NULL Bogor NULL 16165 NULL
|
||||
ID 4 NULL jakarta NULL otista NULL
|
||||
ID 4 NULL Jakarta NULL 12520 Jl. Pertanian Raya III No.42 Jakarta Selatan Pasar Minggu NULL
|
||||
ID 4 NULL Jakarta NULL 13330 Jakarta NULL
|
||||
ID 4 NULL Jakarta NULL 13330 Jl Sensus IIC Bidaracina Jaktim NULL
|
||||
ID 4 NULL Jakarta NULL 13330 Jl. Bonasut 2 no.22 NULL
|
||||
ID 4 NULL Jakarta NULL 13330 Otista 64c NULL
|
||||
ID 4 NULL jakarta NULL 13330 Otista jaktim NULL
|
||||
ID 4 NULL Jakarta Timur NULL 13330 Kebon Sayur I no. 1 RT 10/15 NULL
|
||||
ID 4 NULL Jakarta Timur NULL 13460 Jl. Pondok Kopi Blok G4/5 RT. 005/08 Jakarta Timur NULL
|
||||
ID 4 NULL Jakarta Timur NULL 13810 Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur NULL
|
||||
ID 7 NULL Brebes NULL 54321 Jl Kersem Blok D14 Perum Taman Indo Kaligangsa Wetan Brebes NULL
|
||||
ID 7 NULL Semarang NULL 50143 Puspowarno Tengah 2/2 NULL
|
||||
ID 8 NULL Lumajang NULL 67373 Desa Tumpeng Kecamatan Candipuro Lumajang NULL
|
||||
ID 30 NULL Bandung NULL 55241 Jl Pelesiran No 55A/56 NULL
|
||||
ID 30 NULL Bekasi NULL 17510 bekasi West Java Indonesia NULL
|
||||
ID 30 NULL Depok NULL 16245 Jalan juragan sinda 2 no 10 NULL
|
||||
ID 30 NULL Depok NULL 16424 Jalan Margonda RayaJalan Kober Gang Mawar NULL
|
||||
ID 30 NULL Depok NULL 16424 Jl. Haji Yahya Nuih no.24, Pondok Cina NULL
|
||||
ID 30 NULL Depok NULL 16425 Kukusan Kelurahan NULL
|
||||
ID 30 NULL Depok NULL 16518 Jl. Salak No.1/C.88 Durenseribu Bojongsari NULL
|
||||
ID 30 NULL Depok NULL 16952 Jl. Merak No.34 -36 Rt.004/014 Jl. Merak No. 34 -36 Rt. 004/014 NULL
|
||||
ID 36 NULL biak numfor NULL 98111 jl. s. mamberamo no 6782 biak numfor NULL
|
||||
IL NULL Tel Aviv NULL NULL
|
||||
IN NULL Bangalore NULL NULL
|
||||
IN NULL India NULL NULL
|
||||
IN NULL new delhi NULL 110003 55 lodi estate NULL
|
||||
IN 7 NULL NEW DELHI NULL 110018 15/11 A 1ST FLOOR TILAK NAGAR NULL
|
||||
IN 7 NULL New Delhu NULL 110075 B 54 Hilansh Apartments Plot No 1, Sector 10, Dwarka NULL
|
||||
IN 10 NULL Gurgaon NULL D- 201 Ivy Apartments Sushant Lok 1 Gurgaon Haryana NULL
|
||||
IN 13 NULL Trivandrum NULL 695010 TC 9/1615, SRMH Road, Sasthamangalam, Trivandrum NULL
|
||||
IN 16 NULL Mumbai NULL 400020 Bharat Mahal, Flat#55 Marine Drive NULL
|
||||
IN 16 NULL Mumbai NULL 400028 303,Shree Parvati Co-Op Housing Society, D.L.Vaidya Road,Dadar NULL
|
||||
IN 16 NULL Pune NULL NULL
|
||||
IN 16 NULL Pune NULL Infosys Campus Hinjewadi Phase 2 NULL
|
||||
IN 16 NULL Pune NULL 400705 #22 Iris Garden Gokhale Road NULL
|
||||
IN 16 NULL PUNE NULL 411043 NULL
|
||||
IN 16 NULL Pune NULL 411051 NULL
|
||||
IN 16 NULL Pune NULL 411057 Infosys Ltd. Rajiv gandhi infostech park Hinjewadi phase 2 NULL
|
||||
IN 16 NULL Pune NULL 412108 Pune Maharatshtra NULL
|
||||
IN 16 NULL Pune NULL 433011 502 utkarsh vihar golande state pune NULL
|
||||
IN 19 NULL Bangalore NULL 560080 Indian Institute for Human Settlements IIHS Bangalore City Campus, Sadashivanagar, NULL
|
||||
IN 19 NULL Bangalore NULL 560100 electronic city NULL
|
||||
IN 19 NULL Bhalki NULL 585411 bhalki,bidar ,karnataka karnataka NULL
|
||||
IN 24 NULL Jaipur NULL 302011 Institute of Health Management Research 1, Prabhu Dayal Marg NULL
|
||||
IR 26 NULL Tehran NULL 1118844454 Baharestan sq. mostafa khomeini str., javahery Ave., no. 11, NULL
|
||||
IT NULL Trento NULL NULL
|
||||
JM 8 NULL Kingston NULL Kgn 7 MOna Campus UWI NULL
|
||||
KE NULL Nairobi NULL NULL
|
||||
KE 5 NULL Nairobi NULL 30300 212,kapsabet NULL
|
||||
KH NULL NULL Phnom Penh NULL NULL
|
||||
LR NULL Monrovia NULL 0 NULL
|
||||
NG 11 NULL Abuja NULL 930001 17 Bechar street Wuse zone 2 NULL
|
||||
PE 15 NULL Lima NULL 18 Lima Lima NULL
|
||||
PE 15 NULL Lima NULL Lima 18 123 Miraflores NULL
|
||||
PE NULL NULL Lima NULL 3 Calle Granada 104 NULL
|
||||
PE NULL NULL Lima NULL 18 Lima Lima NULL
|
||||
PH NULL Manila NULL Globe Telepark 111 Valero Street NULL
|
||||
PH NULL Quezon Coty NULL 1109 86 Harvard Street, Cubao, Quezon City, Philippines 84 Harvard Street, Cubao, Quezon City,hilippines NULL
|
||||
PH 20 NULL Silang NULL 4118 370 Bayungan Kaong Silang Cavite NULL
|
||||
PH 57 NULL Kidapawan NULL 9400 Kidapawan City Kidapawan City NULL
|
||||
PH 66 NULL zamboanga NULL 7000 29-tripplet rd san jose 29-tripplet rd san jose NULL
|
||||
PH D9 NULL Pasig City NULL World Bank Office Manila, 20/F Taipan Place F. Ortigas Jr. Road, Ortigas Center NULL
|
||||
PK NULL Lahore NULL 54000 17-R Model Town Lahore NULL
|
||||
PK NULL Lahore NULL 54000 53- chamber lane road Lahore NULL
|
||||
PK NULL Lahore NULL 54000 85 E block Model Town NULL
|
||||
PK NULL Lahore NULL 54000 House no 227, street no 5, Imamia Colony Shahadra Lahore NULL
|
||||
PK NULL LAHORE NULL 54000 room no.6 khalid bim waleed hall, near New Anarkali, LAHORE room no.6 khalid bim waleed hall, near New Anarkali, LAHORE NULL
|
||||
PK NULL Lahore NULL pk097 LUMS, Lahore, NULL
|
||||
PK NULL Sheikhupura NULL 3935 D.H.Q.Hospital Sheikhupura House number 08. Room no 109 Khalid bin waleed haal, punjab University lahore old campus. NULL
|
||||
PK 2 NULL Quetta NULL 87000 Postal Address 87000, Kuchlak, Quetta, Balochistan. H#24 Peer Abul Khair road Quetta, Balochistan. NULL
|
||||
PK 2 NULL Quetta NULL 87300 block no-1 falt no. 7 New Crime Branch Abbas Ali Road Cantt NULL
|
||||
PK 2 NULL Quetta NULL 87300 Flat no. 3 Shafeen Centre Jinnah Town ,Near I.T university , Quetta NULL
|
||||
PK 2 NULL Quetta NULL 87300 H-no. C-220 Zarghoonabad Phase-2 , Nawa Killi ,Quetta NULL
|
||||
PK 4 NULL burewala NULL 60101 Fatima Fayyaz Hazrat Sakina hall girls hostel number 9 Punjab university Lahore Pakistan Sardar Wajid Azim Azeem abad Burewala dist Vehari Pakistan NULL
|
||||
PK 4 NULL Faisalabad NULL 38000 P 101/1, Green Town, Millat Road, Faisalabad NULL
|
||||
PK 4 NULL Islamabad NULL 44000 P.O Tarlai kalan chappar Islamabad NULL
|
||||
PK 4 NULL lahore NULL NULL
|
||||
PK 4 NULL Lahore NULL 54000 NULL
|
||||
PK 4 NULL lahore NULL 54000 Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. NULL
|
||||
PK 4 NULL Lahore NULL 54000 1149-1-D2 Green Town Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 124, street# 2, karim block Allama Iqbal Town lahore. 124, street# 2, karim block Allama Iqbal Town lahore. NULL
|
||||
PK 4 NULL Lahore NULL 54000 150 A Qila Lachman Singh Ravi Road lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 166/1L DHA Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 172 A2 Township Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 183,S/Block, Model Town, Lhr NULL
|
||||
PK 4 NULL lahore NULL 54000 19- A block ,Eden Lane Villas Raiwind Road ,Lahore NULL
|
||||
PK 4 NULL lahore NULL 54000 3-c kaliyar road opposite kids lyceum, rustam park near mor samnabad NULL
|
||||
PK 4 NULL Lahore NULL 54000 31 Saeed Block, Canal Bank Scheme NULL
|
||||
PK 4 NULL Lahore NULL 54000 31c DHA Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 387 E1 wapda town, Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 45-D dha eme sector multan road,lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 5 Zafar Ali Road NULL
|
||||
PK 4 NULL Lahore NULL 54000 54-R PGECHS NULL
|
||||
PK 4 NULL lahore NULL 54000 566 E-1 johar town lahore 566 E-1 johar town lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 82/1 Z Block, Phase 3 DHA NULL
|
||||
PK 4 NULL Lahore NULL 54000 A-1 VRI Zarrar shaheed road lahore cantt A-1 VRI Zarrar shaheed road lahore cantt NULL
|
||||
PK 4 NULL lahore NULL 54000 e5/39D street 6 zaman colony cavalry ground ext NULL
|
||||
PK 4 NULL Lahore NULL 54000 Ho # 61, Block G3, Johar Town Lahore NULL
|
||||
PK 4 NULL LAhore NULL 54000 House #19-A street #5 Usman nagr Ghaziabad Lahore NULL
|
||||
PK 4 NULL lahore NULL 54000 House no 692 street no 67 sadar bazar NULL
|
||||
PK 4 NULL Lahore NULL 54000 Khosa Law Chamber 1 Turner Road NULL
|
||||
PK 4 NULL Lahore NULL 54000 Lahore,Pakistan Lahore,Pakistan NULL
|
||||
PK 4 NULL Lahore NULL 54000 room no 69, khalid bin waleed hall, anarkali NULL
|
||||
PK 4 NULL Lahore NULL 54000 Suite # 8, Al-Hafeez Suites, Gulberg II NULL
|
||||
PK 4 NULL Lahore NULL 54085 199 Shadman 2 NULL
|
||||
PK 4 NULL Lahore NULL 54300 Mughalpura Lahore Pakistan NULL
|
||||
PK 4 NULL Lahore NULL 54660 SD 69 falcon complex gulberg III lahore NULL
|
||||
PK 4 NULL lahore NULL 54800 764-G4 johar town ,lahore NULL
|
||||
PK 4 NULL Rawalpindi NULL 44000 House 522, F-Block Sattellite Town, Rawalpindi NULL
|
||||
PK 4 NULL Rawalpindi NULL 46000 1950/c, Indusroad 2, Tariqabad, Rawalpindi Cantt NULL
|
||||
PK 4 NULL Rawalpindi NULL 46000 House 54-E Lane 9 Sector 4, AECHS Chaklala Rawalpindi NULL
|
||||
PK 4 NULL Rawalpindi NULL 46000 House B-1343, Sattellite town Rawalpindi NULL
|
||||
PK 4 NULL Rawalpindi NULL 46000 House CB-299F, Street 1, Lane 4 Peshawar Road Rawalpindi NULL
|
||||
PK 4 NULL Rawalpindi NULL 46300 House No 1518 Umer Block phase 8 BehriaTown NULL
|
||||
PK 4 NULL sialkot NULL 51310 The National Model School, Ismaiealabad, Pacca Garah Sialkot NULL
|
||||
PK 8 NULL Islamabad NULL CIomsats Institute of Information Technology Islamabad NULL
|
||||
PK 8 NULL Islamabad NULL 38700 COMSATS tarlai boys hostel Islamabad. COMSATS tarlai boys hostel Islamabad (Room 30) NULL
|
||||
PK 8 NULL Islamabad NULL 44000 NULL
|
||||
PK 8 NULL Islamabad NULL 44000 House # 256, Street # 9, Shahzad Town, Islamabad. NULL
|
||||
PK 8 NULL Islamabad NULL 44000 Islamabad , Comsats University Islamabd ,Pakistan NULL
|
||||
PK 8 NULL Islamabad NULL 44000 World Bank Building Sector G 5 NULL
|
||||
PK 8 NULL lahore NULL 54000 3c zafar ali road gulburg 5 3c zafar ali road gulburg 5 NULL
|
||||
PK 8 NULL lahore NULL 54000 49-a bilal park, chaburgy 49-a bilal park, chaburgy NULL
|
||||
PK NULL NULL Lahore NULL 54000 NULL
|
||||
PK NULL NULL Lahore NULL 54000 85 E block Model Town NULL
|
||||
SN 1 NULL NULL ouakam cité comico en face 217 NULL
|
||||
SN 1 NULL Dakar NULL NULL
|
||||
SN 1 NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11 NULL
|
||||
SN 1 NULL Dakar NULL liberte 6/ dakar NULL
|
||||
SN 1 NULL Dakar NULL ngor NULL
|
||||
SN 1 NULL Dakar NULL 4027 ZAC Mbao Cité Fadia NULL
|
||||
SN NULL NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11 NULL
|
||||
TZ NULL Dar es Salaam NULL NULL NULL
|
||||
TZ NULL Dar es salaam NULL NULL 76021 Dar es salaam 1507 Morogoro NULL
|
||||
TZ NULL Dar es salaam NULL NULL dar es salaam nassoro.ahmedy@yahoo.com NULL
|
||||
TZ NULL DAR ES SALAAM NULL NULL dar es salaam UDSM NULL
|
||||
TZ NULL Dar es salaam NULL NULL NA NULL
|
||||
TZ NULL DAR ES SALAAM NULL NULL P O BOX 23409 NULL
|
||||
TZ NULL dar es salaam NULL NULL p. o. box 104994 NULL
|
||||
TZ NULL Dar es Salaam NULL NULL P.o. BOX 71415 Dar es Salaam NULL
|
||||
TZ NULL Dar es Salaam NULL NULL P.O.BOx 66675 DSM NULL
|
||||
TZ NULL Dar es salaam NULL NULL Tz Tz NULL
|
||||
TZ NULL dsm NULL NULL NULL
|
||||
TZ 2 NULL Bagamoyo NULL NULL PO.Box 393 NULL
|
||||
TZ 2 NULL Dar es salaam NULL NULL 22548 NULL
|
||||
TZ 3 NULL Dar-es-salaam NULL NULL Dodoma Municipal Kimara, Dar-es-salaa, NULL
|
||||
TZ 23 NULL Dar es Salaam NULL NULL NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL 35074 NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL 67389 NULL
|
||||
TZ 23 NULL Dar es Salaam NULL NULL COSTECH, Dar es Salaam, Tanzania NULL
|
||||
TZ 23 NULL Dar es salaam NULL NULL na NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL p o box 60164 NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL P. O. Box 77588 NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL P.O BOX 78144 NULL
|
||||
TZ 23 NULL Dar es Salaam NULL NULL P.O.BOX 78373 NULL
|
||||
TZ 23 NULL Dar es salaam NULL NULL UDSM Dar es Salaam NULL
|
||||
TZ 23 NULL Dar es salaam NULL NULL udsm udsm NULL
|
||||
TZ 23 NULL Temeke NULL NULL P.O. Box 50127 NULL
|
||||
TZ NULL NULL Dar es Salaam NULL NULL NULL
|
||||
TZ NULL NULL Dar es Salaam NULL NULL Kigoma NULL
|
||||
TZ NULL NULL Dar es Salaam NULL NULL Mwanza NULL
|
||||
UG NULL Kampala NULL NULL NULL
|
||||
UG NULL Kampala NULL NULL Kampala Uganda East Africa NULL
|
||||
US NULL London NULL SE1 8RT Capital Tower 91 Waterloo Road NULL
|
||||
US CA NULL Los Angeles NULL NULL
|
||||
US CA NULL Pleasanton NULL 94588 3412 Pickens Lane NULL
|
||||
US CA NULL Sacramento NULL NULL
|
||||
US CA NULL San Francisco NULL NULL
|
||||
US CA NULL seattle NULL 98113 1234 1st st NULL
|
||||
US CO NULL Denver NULL 80235 6666 West Quincy Ave NULL
|
||||
US CT NULL Greenwich NULL 6830 140 Milbank NULL
|
||||
US CT NULL Hartford NULL 6106 Center for Urban and Global Studies at Trinity College, 70 Vernon Street NULL
|
||||
US DC NULL Washington NULL NULL
|
||||
US DC NULL Washington NULL 20007 World Bank Headquarters 1818 H Street NW NULL
|
||||
US DC NULL Washington NULL 20010 NULL
|
||||
US DC NULL Washington NULL 20036 NULL
|
||||
US DC NULL Washington NULL 20405 1889 F St NW NULL
|
||||
US DC NULL Washington NULL 20433 NULL
|
||||
US DC NULL Washington NULL 20433 1818 H Street NW NULL
|
||||
US DC NULL Washington NULL 20433 1818H St NULL
|
||||
US DC NULL Washington NULL 20433 1818 H Street NW NULL
|
||||
US DC NULL Washington DC NULL 20005 1424, K Street, NW Suite 600 NULL
|
||||
US DC NULL Washington DC NULL 20010 1818 H Street, NW NULL
|
||||
US DC NULL Washington, DC NULL 20003 1818 H Street NW NULL
|
||||
US DE NULL Virgin Islands|Charlotte Amalie,Cruz Bay,Christiansted NULL Morocco|Tafraout,Rabat,Tangier,Tetouan,Casablanca,Marrakesh,Fez,Oujda,Meknes,Agadir United Arab Emirates|Garhoud,Dubai,Bur Dubai,Ras al Khaymah,Abu Dhabi,Ajman,Al Fujayrah,Sharjah NULL
|
||||
US FL NULL Falmouth NULL Falmouth Falmouth NULL
|
||||
US FL NULL Lilongwe NULL Lilongwe Lilongwe NULL
|
||||
US GA NULL Atlanta NULL NULL
|
||||
US GU NULL Herndon NULL 15642 Ht USA NULL
|
||||
US GU NULL Miami NULL Miami Miami NULL
|
||||
US MD NULL Gaithersburg NULL 20877 554 N Frederick Avenue Suite 216 NULL
|
||||
US MD NULL Potomac NULL 20854 14 Sandalfoot Court NULL
|
||||
US MD NULL Silver Spring NULL 20901 9202 Whitney St. NULL
|
||||
US MI NULL Traverse City NULL 49685 PO Box 792 NULL
|
||||
US ND NULL Pirassununga NULL Pirassununga Pirassununga NULL
|
||||
US NJ NULL Princeton NULL NULL
|
||||
US NY NULL Brooklyn NULL 11206-1980 25 Montrose Ave. Apt 304 NULL
|
||||
US NY NULL Brooklyn NULL 11225 975 washington ave 2d NULL
|
||||
US NY NULL Brooklyn NULL 11217 150 4TH AVE APT 9E NULL
|
||||
US NY NULL New York NULL NULL
|
||||
US NY NULL New York NULL 10013 148 Lafayette St. PH NULL
|
||||
US NY NULL New York NULL 10017 UNICEF 3 UN Plaza NULL
|
||||
US NY NULL New York NULL 10019 25 Columbus Circle Suite 52E NULL
|
||||
US NY NULL New York NULL 10024 65 West 85th Street 3A NULL
|
||||
US NY NULL New York NULL 10027 606 W. 116th Street #22 NULL
|
||||
US NY NULL New York NULL 10037 NULL
|
||||
US NY NULL Rochester NULL NULL
|
||||
US NY NULL Scarsdale NULL 10583-1423 54 Walworth Avenue NULL
|
||||
US OR NULL Portland NULL NULL
|
||||
US PA NULL Philadelphia NULL NULL
|
||||
US PA NULL Philadelphia NULL NULL
|
||||
US PR NULL Colonel Hill NULL Colonel Hill Colonel Hill NULL
|
||||
US SD NULL Banjul NULL Banjul Banjul NULL
|
||||
US SD NULL London NULL London London NULL
|
||||
US TX NULL Aledo NULL 76008 1588 Hunterglenn Dr NULL
|
||||
US TX NULL Keller NULL 76248 810 Placid View Ct. NULL
|
||||
US WA NULL Seattle NULL NULL
|
||||
ZA NULL Cape Town NULL NULL
|
||||
ZA NULL Cape Town NULL 7945 Alexander Road Muizenberg NULL
|
||||
ZA NULL Pretoria NULL NULL
|
||||
ZA 11 NULL Cape Town NULL NULL
|
||||
ZA 11 NULL Cape Town NULL 7435 PostNet Suite #57, Private Bag X18 Milnerton NULL
|
||||
ZA 11 NULL Cape town NULL 7508 24 Solyet Court, Lansdowne Road Claremont NULL
|
||||
ZA 11 NULL Cape Town NULL 7701 NULL
|
||||
ZA 11 NULL Cape Town NULL 7785 10 Nyamakazi Road Luzuko Park Phillipi East NULL
|
||||
ZA 11 NULL Cape Town NULL 7915 66 Albert Rd NULL
|
||||
ZA 11 NULL Cape Town NULL 8001 210 Long Street NULL
|
||||
ZM NULL Lusaka NULL NULL
|
||||
ZM 9 NULL LUSAKA NULL 10101 P.O. BOX FW 174 NULL
|
|
@ -0,0 +1,10 @@
|
|||
div.addressfield-container-inline > div.form-item {
|
||||
float: right;
|
||||
margin-right: 0;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
div.addressfield-container-inline.country-GB > div.form-item {
|
||||
margin-left: auto;
|
||||
margin-right: 0;
|
||||
}
|
|
@ -0,0 +1,454 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Contains the predefined address formats.
|
||||
*
|
||||
* Derived from Google's dataset: https://chromium-i18n.appspot.com/ssl-address.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the address format for the given country code.
|
||||
*
|
||||
* @param $country_code
|
||||
* The country code for which the address format should be returned.
|
||||
*
|
||||
* @return
|
||||
* The address format array with the following keys:
|
||||
* - used_fields: An array of fields used by this format. Possible values:
|
||||
* 'dependent_locality', 'locality', 'administrative_area', 'postal_code'.
|
||||
* - required_fields: An array of required fields. See "used_fields".
|
||||
* - dependent_locality_label: The label for the dependent locality field.
|
||||
* - locality_label: The label for the locality field.
|
||||
* - administrative_area_label: The label for the administrative area field.
|
||||
* - postal_code_label: The label for the postal code field.
|
||||
* - render_administrative_area_value: True if the value should be rendered
|
||||
* instead of the ISO code. US example: California instead of CA.
|
||||
* Only relevant for countries with predefined administrative areas.
|
||||
*/
|
||||
function addressfield_get_address_format($country_code) {
|
||||
$default_values = array(
|
||||
'used_fields' => array('locality'),
|
||||
'required_fields' => array('locality'),
|
||||
'dependent_locality_label' => t('Suburb'),
|
||||
'locality_label' => t('City'),
|
||||
'administrative_area_label' => t('Province'),
|
||||
'postal_code_label' => t('Postal code'),
|
||||
'render_administrative_area_value' => FALSE,
|
||||
);
|
||||
|
||||
$address_formats = array();
|
||||
// These formats differ from the default only by the presence of the
|
||||
// postal code in 'used_fields'.
|
||||
$countries_with_optional_postal_code = array(
|
||||
'AC', 'AD', 'AF', 'AI', 'AL', 'AZ', 'BA', 'BB', 'BD', 'BG', 'BH', 'BM',
|
||||
'BN', 'BT', 'CU', 'CR', 'CY', 'DO', 'DZ', 'EC', 'EH', 'ET', 'FO', 'GE',
|
||||
'GN', 'GT', 'GW', 'HR', 'HM', 'HT', 'IL', 'IS', 'JO', 'KE', 'KG', 'KH',
|
||||
'KP', 'KW', 'LA', 'LB', 'LK', 'LR', 'LS', 'MA', 'MC', 'MD', 'ME', 'MG',
|
||||
'MK', 'MM', 'MT', 'MU', 'MV', 'NE', 'NP', 'OM', 'PK', 'PY', 'RO', 'RS',
|
||||
'SA', 'SD', 'SI', 'SN', 'SZ', 'TA', 'TJ', 'TM', 'TN', 'TZ', 'VA', 'VC',
|
||||
'VG', 'XK', 'ZM',
|
||||
);
|
||||
foreach ($countries_with_optional_postal_code as $code) {
|
||||
$address_formats[$code] = array(
|
||||
'used_fields' => array('locality', 'postal_code'),
|
||||
);
|
||||
}
|
||||
|
||||
// These formats differ from the default only by the presence of the
|
||||
// postal code in 'used_fields' and 'required_fields'.
|
||||
$countries_with_required_postal_code = array(
|
||||
'AT', 'AX', 'BE', 'BL', 'CH', 'CZ', 'DE', 'DK', 'FI', 'FK', 'FR', 'GF', 'GG',
|
||||
'GL', 'GP', 'GR', 'GS', 'HU', 'IM', 'IO', 'JE', 'LI', 'LU', 'MF', 'MQ', 'NC',
|
||||
'NL', 'NO', 'PL', 'PM', 'PN', 'PT', 'RE', 'SE', 'SH', 'SJ', 'SK', 'TC', 'WF',
|
||||
'YT',
|
||||
);
|
||||
foreach ($countries_with_required_postal_code as $code) {
|
||||
$address_formats[$code] = array(
|
||||
'used_fields' => array('locality', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
);
|
||||
}
|
||||
|
||||
$address_formats['AE'] = array(
|
||||
'used_fields' => array('administrative_area'),
|
||||
'administrative_area_label' => t('Emirate'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
'required_fields' => array('administrative_area'),
|
||||
);
|
||||
$address_formats['AM'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['AR'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['AS'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['AU'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'locality_label' => t('City/Suburb'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('Postcode'),
|
||||
);
|
||||
$address_formats['BR'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'dependent_locality_label' => t('Neighborhood'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['BS'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
'administrative_area_label' => t('Island'),
|
||||
);
|
||||
$address_formats['BY'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['CA'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['CC'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['CL'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['CN'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
'dependent_locality_label' => t('District'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['CO'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['CV'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('Island'),
|
||||
);
|
||||
$address_formats['CX'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['EG'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('Governorate'),
|
||||
);
|
||||
$address_formats['EE'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'administrative_area_label' => t('County'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['ES'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['FM'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['GB'] = array(
|
||||
'used_fields' => array('locality', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'locality_label' => t('Town/City'),
|
||||
'administrative_area_label' => t('County'),
|
||||
'postal_code_label' => t('Postcode'),
|
||||
);
|
||||
$address_formats['GI'] = array(
|
||||
'used_fields' => array('postal_code'),
|
||||
);
|
||||
$address_formats['GU'] = array(
|
||||
'used_fields' => array('locality', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['HK'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
'required_fields' => array('administrative_area'),
|
||||
'locality_label' => t('District'),
|
||||
'administrative_area_label' => t('Area', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['HN'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
);
|
||||
$address_formats['ID'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('administrative_area'),
|
||||
'locality_label' => t('City/Regency'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['IE'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'locality_label' => t('Town/City'),
|
||||
'administrative_area_label' => t('County'),
|
||||
'postal_code_label' => t('Eircode'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['IN'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('PIN code'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['IQ'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
);
|
||||
$address_formats['IR'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'dependent_locality_label' => t('Neighborhood'),
|
||||
);
|
||||
$address_formats['IT'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['JM'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
'administrative_area_label' => t('Parish', array(), array('context' => 'Territory of a country')),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['JP'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('Prefecture'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['KI'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
'administrative_area_label' => t('Island'),
|
||||
);
|
||||
$address_formats['KN'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
'administrative_area_label' => t('Island'),
|
||||
);
|
||||
$address_formats['KR'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'dependent_locality_label' => t('District'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['KY'] = array(
|
||||
'used_fields' => array('administrative_area', 'postal_code'),
|
||||
'required_fields' => array('administrative_area'),
|
||||
'administrative_area_label' => t('Island'),
|
||||
);
|
||||
$address_formats['KZ'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('Region', array(), array('context' => 'Territory of a country')),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['LT'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'administrative_area_label' => t('County'),
|
||||
);
|
||||
$address_formats['LV'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'administrative_area_label' => t('Municipality'),
|
||||
);
|
||||
$address_formats['MH'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['MN'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['MP'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['MX'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'dependent_locality_label' => t('Neighborhood'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['MY'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'dependent_locality_label' => t('Village / Township'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['MZ'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['NF'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['NG'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['NI'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['NR'] = array(
|
||||
'used_fields' => array('administrative_area'),
|
||||
'required_fields' => array('administrative_area'),
|
||||
'administrative_area_label' => t('District'),
|
||||
);
|
||||
$address_formats['NZ'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'locality_label' => t('Town/City'),
|
||||
'postal_code_label' => t('Postcode'),
|
||||
);
|
||||
$address_formats['PA'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
);
|
||||
$address_formats['PE'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'locality_label' => t('District'),
|
||||
'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['PF'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('Island'),
|
||||
);
|
||||
$address_formats['PG'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
);
|
||||
$address_formats['PH'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['PR'] = array(
|
||||
'used_fields' => array('locality', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['PW'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['RU'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['SC'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
'administrative_area_label' => t('Island'),
|
||||
);
|
||||
$address_formats['SG'] = array(
|
||||
'used_fields' => array('postal_code'),
|
||||
'required_fields' => array('postal_code'),
|
||||
);
|
||||
$address_formats['SM'] = array(
|
||||
'used_fields' => array('locality', 'postal_code'),
|
||||
'required_fields' => array('postal_code'),
|
||||
);
|
||||
$address_formats['SO'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
);
|
||||
$address_formats['SR'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
);
|
||||
$address_formats['SV'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
);
|
||||
$address_formats['TH'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['TR'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
'locality_label' => t('District'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['TV'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
'administrative_area_label' => t('Island'),
|
||||
);
|
||||
$address_formats['TW'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['UA'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('Region', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['UM'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['US'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['UY'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['UZ'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['VE'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['VI'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'postal_code_label' => t('ZIP code'),
|
||||
);
|
||||
$address_formats['VN'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['ZA'] = array(
|
||||
'used_fields' => array('dependent_locality', 'locality', 'postal_code'),
|
||||
'required_fields' => array('locality', 'postal_code'),
|
||||
);
|
||||
|
||||
// Allow other modules to alter the formats.
|
||||
drupal_alter('addressfield_address_formats', $address_formats);
|
||||
|
||||
if (isset($address_formats[$country_code])) {
|
||||
$format = $address_formats[$country_code] + $default_values;
|
||||
}
|
||||
else {
|
||||
// There is no predefined address format for the requested country,
|
||||
// but the defaults should work fine.
|
||||
$format = $default_values;
|
||||
}
|
||||
|
||||
return $format;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* API documentation for Addressfield.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format generation callback.
|
||||
*
|
||||
* @param $format
|
||||
* The address format being generated.
|
||||
* @param $address
|
||||
* The address this format is generated for.
|
||||
* @param $context
|
||||
* An associative array of context information pertaining to how the address
|
||||
* format should be generated. If no mode is given, it will initialize to the
|
||||
* default value. The remaining context keys should only be present when the
|
||||
* address format is being generated for a field:
|
||||
* - mode: either 'form' or 'render'; defaults to 'render'.
|
||||
* - field: the field info array.
|
||||
* - instance: the field instance array.
|
||||
* - langcode: the langcode of the language the field is being rendered in.
|
||||
* - delta: the delta value of the given address.
|
||||
*
|
||||
* @ingroup addressfield_format
|
||||
*/
|
||||
function CALLBACK_addressfield_format_callback(&$format, $address, $context = array()) {
|
||||
// No example.
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows modules to alter the default values for an address field.
|
||||
*
|
||||
* @param $default_values
|
||||
* The array of default values. The country is populated from the
|
||||
* 'default_country' widget setting.
|
||||
* @param $context
|
||||
* An array with the following keys:
|
||||
* - field: The field array.
|
||||
* - instance: The instance array.
|
||||
* - address: The current address values. Allows for per-country defaults.
|
||||
*/
|
||||
function hook_addressfield_default_values_alter(&$default_values, $context) {
|
||||
// If no other default country was provided, set it to France.
|
||||
// Note: you might want to check $context['instance']['required'] and
|
||||
// skip setting the default country if the field is optional.
|
||||
if (empty($default_values['country'])) {
|
||||
$default_values['country'] = 'FR';
|
||||
}
|
||||
|
||||
// Determine the country for which other defaults should be provided.
|
||||
$selected_country = $default_values['country'];
|
||||
if (isset($context['address']['country'])) {
|
||||
$selected_country = $context['address']['country'];
|
||||
}
|
||||
|
||||
// Add defaults for the US.
|
||||
if ($selected_country == 'US') {
|
||||
$default_values['locality'] = 'New York';
|
||||
$default_values['administrative_area'] = 'NY';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows modules to alter the predefined address formats.
|
||||
*
|
||||
* @param $address_formats
|
||||
* The array of all predefined address formats.
|
||||
*
|
||||
* @see addressfield_get_address_format()
|
||||
*/
|
||||
function hook_addressfield_address_formats_alter(&$address_formats) {
|
||||
// Remove the postal_code from the list of required fields for China.
|
||||
$address_formats['CN']['required_fields'] = array('locality', 'administrative_area');
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows modules to alter the predefined administrative areas.
|
||||
*
|
||||
* @param $administrative_areas
|
||||
* The array of all predefined administrative areas.
|
||||
*
|
||||
* @see addressfield_get_administrative_areas()
|
||||
*/
|
||||
function hook_addressfield_administrative_areas_alter(&$administrative_areas) {
|
||||
// Alter the label of the Spanish administrative area with the iso code PM.
|
||||
$administrative_areas['ES']['PM'] = t('Balears / Baleares');
|
||||
|
||||
// Add administrative areas for imaginary country XT, keyed by their
|
||||
// imaginary ISO codes.
|
||||
$administrative_areas['XT'] = array(
|
||||
'A' => t('Aland'),
|
||||
'B' => t('Bland'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows modules to add arbitrary AJAX commands to the array returned from the
|
||||
* standard address field widget refresh.
|
||||
*
|
||||
* @param &$commands
|
||||
* The array of AJAX commands used to refresh the address field widget.
|
||||
* @param $form
|
||||
* The rebuilt form array.
|
||||
* @param $form_state
|
||||
* The form state array from the form.
|
||||
*
|
||||
* @see addressfield_standard_widget_refresh()
|
||||
*/
|
||||
function hook_addressfield_standard_widget_refresh_alter(&$commands, $form, $form_state) {
|
||||
// Display an alert message.
|
||||
$commands[] = ajax_command_alert(t('The address field widget has been updated.'));
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
div.addressfield-container-inline > div.form-item {
|
||||
float: left; /* LTR */
|
||||
margin-right: 1em; /* LTR */
|
||||
}
|
||||
|
||||
div.addressfield-container-inline.country-GB > div.form-item {
|
||||
float: none;
|
||||
margin-right: auto; /* LTR */
|
||||
}
|
||||
|
||||
/* Clear-fix markup for the inline container */
|
||||
div.addressfield-container-inline:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
/* IE6 */
|
||||
* html div.addressfield-container-inline {
|
||||
height: 1%;
|
||||
}
|
||||
/* IE7 */
|
||||
*:first-child + html div.addressfield-container-inline {
|
||||
min-height: 1%;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Devel Generate for addressfield module
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implements hook_devel_generate();
|
||||
*/
|
||||
function addressfield_devel_generate($object, $field, $instance, $bundle) {
|
||||
if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_CUSTOM) {
|
||||
return devel_generate_multiple('_addressfield_devel_generate', $object, $field, $instance, $bundle);
|
||||
}
|
||||
else {
|
||||
return _addressfield_devel_generate($object, $field, $instance, $bundle);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to generate a greeky US-based address
|
||||
*/
|
||||
function _addressfield_devel_generate($object, $field, $instance, $bundle) {
|
||||
// Set default value
|
||||
$object_field = addressfield_default_values($field, $instance);
|
||||
$addresses = _addressfield_sample_addresses();
|
||||
$object_field = array_merge($object_field, $addresses[array_rand($addresses)]);
|
||||
unset($object_field['data']);
|
||||
return $object_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of sample addresses.
|
||||
*
|
||||
* @return
|
||||
* An array of addressfield arrays
|
||||
*/
|
||||
function _addressfield_sample_addresses() {
|
||||
$fields = &drupal_static(__FUNCTION__);
|
||||
if (!isset($fields)) {
|
||||
$filepath = DRUPAL_ROOT . '/' . drupal_get_path('module', 'addressfield');
|
||||
$fields = array();
|
||||
if ($handle = @fopen("$filepath/addresses.txt", 'r')) {
|
||||
if (is_resource($handle)) {
|
||||
while (($buffer = fgets($handle)) !== FALSE) {
|
||||
list($country, $administrative_area, $sub_administrative_area, $locality, $dependent_locality, $postal_code, $thoroughfare, $premise, $sub_premise) = explode("\t", $buffer);
|
||||
$fields[] = array(
|
||||
'country' => ($country == 'NULL') ? NULL : trim($country),
|
||||
'administrative_area' => ($administrative_area == 'NULL') ? NULL : trim($administrative_area),
|
||||
'sub_administrative_area' => ($sub_administrative_area == 'NULL') ? NULL : trim($sub_administrative_area),
|
||||
'locality' => ($locality == 'NULL') ? NULL : trim($locality),
|
||||
'dependent_locality' => ($dependent_locality == 'NULL') ? NULL : trim($dependent_locality),
|
||||
'postal_code' => ($postal_code == 'NULL') ? NULL : trim($postal_code),
|
||||
'thoroughfare' => ($thoroughfare == 'NULL') ? NULL : trim($thoroughfare),
|
||||
'premise' => ($premise == 'NULL') ? NULL : trim($premise),
|
||||
'sub_premise' => ($sub_premise == 'NULL') ? NULL : trim($sub_premise),
|
||||
);
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Integration with the Feeds module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_processor_targets_alter().
|
||||
*/
|
||||
function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bundle) {
|
||||
foreach (field_info_instances($entity_type, $bundle) as $name => $instance) {
|
||||
$info = field_info_field($name);
|
||||
if ($info['type'] == 'addressfield') {
|
||||
foreach ($info['columns'] as $sub_field => $schema_info) {
|
||||
$name_label = $instance['label'] . ': ' . drupal_ucfirst(str_replace('_', ' ', $sub_field));
|
||||
$targets[$name . ':' . $sub_field] = array(
|
||||
'name' => $name_label,
|
||||
'callback' => 'addressfield_set_target',
|
||||
'real_target' => $info['field_name'],
|
||||
'description' => $schema_info['description'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for hook_feeds_processor_targets_alter().
|
||||
*
|
||||
* @param $source
|
||||
* Field mapper source settings.
|
||||
* @param $entity
|
||||
* An entity object, for instance a node object.
|
||||
* @param $target
|
||||
* A string identifying the target on the node.
|
||||
* @param $values
|
||||
* The value to populate the target with.
|
||||
* @param array $mapping
|
||||
* Associative array of the mapping settings from the per mapping
|
||||
* configuration form.
|
||||
*/
|
||||
function addressfield_set_target($source, $entity, $target, $values, $mapping) {
|
||||
$language = $mapping['language'];
|
||||
list($field_name, $sub_field) = explode(':', $target, 2);
|
||||
|
||||
// Field info and instance are required for setting default values.
|
||||
$entity_type = $source->importer->processor->entityType();
|
||||
list(, , $bundle_name) = entity_extract_ids($entity_type, $entity);
|
||||
$info = field_info_field($field_name);
|
||||
$instance = field_info_instance($entity_type, $field_name, $bundle_name);
|
||||
|
||||
// Convert the values into an array if it isn't one already to correspond to
|
||||
// Drupal's handling of field value arrays.
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
|
||||
// If the field is already set on the given entity, update the existing value
|
||||
// array. Otherwise start with a fresh field value array.
|
||||
$field = isset($entity->{$field_name}) ? $entity->{$field_name} : array();
|
||||
|
||||
// Loop over the field values array...
|
||||
foreach ($values as $delta => $value) {
|
||||
// Set defaults for new values.
|
||||
if (!isset($field[$language][$delta])) {
|
||||
$field[$language][$delta] = addressfield_default_values($info, $instance);
|
||||
}
|
||||
$field[$language][$delta][$sub_field] = $value;
|
||||
}
|
||||
|
||||
$entity->{$field_name} = $field;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
name = Address Field
|
||||
description = Manage a flexible address field, implementing the xNAL standard.
|
||||
core = 7.x
|
||||
package = Fields
|
||||
|
||||
dependencies[] = ctools
|
||||
|
||||
files[] = addressfield.migrate.inc
|
||||
files[] = views/addressfield_views_handler_field_administrative_area.inc
|
||||
files[] = views/addressfield_views_handler_field_country.inc
|
||||
files[] = views/addressfield_views_handler_filter_country.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2018-10-26
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "addressfield"
|
||||
datestamp = "1540579391"
|
|
@ -0,0 +1,216 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_field_schema()
|
||||
*/
|
||||
function addressfield_field_schema() {
|
||||
$columns = array(
|
||||
'country' => array(
|
||||
'description' => 'Two letter ISO country code of this address.',
|
||||
'type' => 'varchar',
|
||||
'length' => 2,
|
||||
'not null' => FALSE,
|
||||
'default' => '',
|
||||
),
|
||||
'administrative_area' => array(
|
||||
'description' => 'The administrative area of this address. (i.e. State/Province)',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'sub_administrative_area' => array(
|
||||
'description' => 'The sub administrative area of this address.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'locality' => array(
|
||||
'description' => 'The locality of this address. (i.e. City)',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'dependent_locality' => array(
|
||||
'description' => 'The dependent locality of this address.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'postal_code' => array(
|
||||
'description' => 'The postal code of this address.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'thoroughfare' => array(
|
||||
'description' => 'The thoroughfare of this address. (i.e. Street address)',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'premise' => array(
|
||||
'description' => 'The premise of this address. (i.e. Apartment / Suite number)',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'sub_premise' => array(
|
||||
'description' => 'The sub_premise of this address.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'organisation_name' => array(
|
||||
'description' => 'Contents of a primary OrganisationName element in the xNL XML.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'default' => '',
|
||||
),
|
||||
'name_line' => array(
|
||||
'description' => 'Contents of a primary NameLine element in the xNL XML.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'default' => '',
|
||||
),
|
||||
'first_name' => array(
|
||||
'description' => 'Contents of the FirstName element of a primary PersonName element in the xNL XML.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'default' => '',
|
||||
),
|
||||
'last_name' => array(
|
||||
'description' => 'Contents of the LastName element of a primary PersonName element in the xNL XML.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'default' => '',
|
||||
),
|
||||
'data' => array(
|
||||
'description' => 'Additional data for this address.',
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'not null' => FALSE,
|
||||
'serialize' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
return array(
|
||||
'columns' => $columns,
|
||||
// TODO Add indexes.
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the field configuration to the new plugin structure.
|
||||
*/
|
||||
function addressfield_update_7000() {
|
||||
// Enable ctools.
|
||||
if (!module_enable(array('ctools'))) {
|
||||
throw new Exception('This version of addressfield requires ctools, but it could not be enabled.');
|
||||
}
|
||||
|
||||
// Get the list of fields of type 'addressfield'.
|
||||
$address_fields = array();
|
||||
foreach (field_info_fields() as $field_name => $field_info) {
|
||||
if ($field_info['type'] == 'addressfield') {
|
||||
$address_fields[$field_name] = $field_name;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (field_info_instances() as $entity_type => $bundles) {
|
||||
foreach ($bundles as $bundle_name => $instances) {
|
||||
foreach (array_intersect_key($instances, $address_fields) as $field_name => $instance) {
|
||||
$widget_settings = &$instance['widget']['settings'];
|
||||
|
||||
if ($instance['widget']['type'] == 'addressfield_standard') {
|
||||
// Default to use the country-based address widget.
|
||||
$format_handlers = array('address');
|
||||
|
||||
// Map the old 'name_format' setting to the name and organization widgets.
|
||||
if (in_array($widget_settings['name_format'], array('name_line_organisation', 'first_last_organisation'))) {
|
||||
$format_handlers[] = 'organisation';
|
||||
}
|
||||
if (in_array($widget_settings['name_format'], array('name_line', 'name_line_organisation'))) {
|
||||
$format_handlers[] = 'name-oneline';
|
||||
}
|
||||
else {
|
||||
$format_handlers[] = 'name-full';
|
||||
}
|
||||
unset($widget_settings['name_format']);
|
||||
$widget_settings['format_handlers'] = $format_handlers;
|
||||
}
|
||||
|
||||
// Update displays.
|
||||
foreach ($instance['display'] as $view_mode => &$view_mode_info) {
|
||||
$display_settings = &$view_mode_info['settings'];
|
||||
|
||||
if ($view_mode_info['type'] == 'addressfield_default') {
|
||||
if (isset($widget_settings['format_handlers'])) {
|
||||
$display_settings['use_widget_handlers'] = 1;
|
||||
}
|
||||
else {
|
||||
// If the widget is non-standard, just use a sane default.
|
||||
$display_settings['use_widget_handlers'] = 0;
|
||||
$display_settings['format_handlers'] = array('address', 'name-oneline');
|
||||
}
|
||||
}
|
||||
else if ($view_mode_info['type'] == 'addressfield_name') {
|
||||
// Migrate the 'addressfield_name' formatter to the new framework.
|
||||
$view_mode_info['type'] = 'addressfield_default';
|
||||
// Start from the widget configuration.
|
||||
$display_settings['use_widget_handlers'] = 0;
|
||||
$display_settings['format_handlers'] = isset($widget_settings['format_handlers']) ? $widget_settings['format_handlers'] : array('address', 'name-oneline');
|
||||
|
||||
if (empty($display_settings['organisation'])) {
|
||||
$display_settings['format_handlers'] = array_diff( $display_settings['format_handlers'], array('organisation'));
|
||||
}
|
||||
unset($display_settings['organisation']);
|
||||
}
|
||||
}
|
||||
|
||||
field_update_instance($instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the new "Default country" setting.
|
||||
*/
|
||||
function addressfield_update_7001() {
|
||||
$address_fields = array();
|
||||
foreach (field_info_fields() as $field_name => $field_info) {
|
||||
if ($field_info['type'] == 'addressfield') {
|
||||
$address_fields[$field_name] = $field_name;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (field_info_instances() as $entity_type => $bundles) {
|
||||
foreach ($bundles as $bundle_name => $instances) {
|
||||
foreach (array_intersect_key($instances, $address_fields) as $field_name => $instance) {
|
||||
// Optional fields get the None default. Required fields get the
|
||||
// previously selected default country.
|
||||
$default_country = '';
|
||||
if (!empty($instance['required']) && !empty($instance['default_value'])) {
|
||||
$default_country = $instance['default_value'][0]['country'];
|
||||
}
|
||||
|
||||
$instance['widget']['settings']['default_country'] = $default_country;
|
||||
unset($instance['default_value']);
|
||||
|
||||
field_update_instance($instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Base integration with the Migrate API class.
|
||||
*/
|
||||
|
||||
// Avoid issues when migrate module is disabled.
|
||||
if (!class_exists('MigrateFieldHandler')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_migrate_api().
|
||||
*/
|
||||
function addressfield_migrate_api() {
|
||||
$api = array(
|
||||
'api' => 2,
|
||||
'field handlers' => array('MigrateAddressFieldHandler'),
|
||||
);
|
||||
return $api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary value passed to this field must be the two letter ISO country code of
|
||||
* the address.
|
||||
*
|
||||
* Arguments are used to specify all the other values:
|
||||
* 'administrative_area' - The administrative area of this address. (i.e. State/Province)
|
||||
* 'sub_administrative_area' - The sub administrative area of this address.
|
||||
* 'locality' - The locality of this address. (i.e. City)
|
||||
* 'dependent_locality' - The dependent locality of this address.
|
||||
* 'postal_code' - The postal code of this address.
|
||||
* 'thoroughfare' - The thoroughfare of this address. (i.e. Street address)
|
||||
* 'premise' - The premise of this address. (i.e. Apartment / Suite number)
|
||||
* 'sub_premise' - The sub_premise of this address.
|
||||
* 'organisation_name' - Contents of a primary OrganisationName element in the xNL XML.
|
||||
* 'name_line' - Contents of a primary NameLine element in the xNL XML.
|
||||
* 'first_name' - Contents of the FirstName element of a primary PersonName element in the xNL XML.
|
||||
* 'last_name' - Contents of the LastName element of a primary PersonName element in the xNL XML.
|
||||
* 'data' - Additional data for this address.
|
||||
*
|
||||
* Add the source field mappings to the argument array then add null mappings to
|
||||
* avoid having fields flagged as as unmapped:
|
||||
* @code
|
||||
* // The country should be passed in as the primary value.
|
||||
* $this->addFieldMapping('field_address', 'profile_country');
|
||||
* $this->addFieldMapping('field_address:thoroughfare', 'profile_address');
|
||||
* $this->addFieldMapping('field_address:locality', 'profile_city');
|
||||
* $this->addFieldMapping('field_address:administrative_area', 'profile_state');
|
||||
* @endcode
|
||||
*/
|
||||
class MigrateAddressFieldHandler extends MigrateFieldHandler {
|
||||
public function __construct() {
|
||||
$this->registerTypes(array('addressfield'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide subfields for the addressfield columns.
|
||||
*/
|
||||
public function fields() {
|
||||
// Declare our arguments to also be available as subfields.
|
||||
$fields = array(
|
||||
'administrative_area' => t('<a href="@doc">The administrative area of ' .
|
||||
'this address (i.e. State/Province)</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#administrative_area')),
|
||||
'sub_administrative_area' => t('<a href="@doc">The sub administrative ' .
|
||||
'area of this address</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#sub_administrative_area')),
|
||||
'locality' => t('<a href="@doc">The locality of this address (i.e. ' .
|
||||
'City)</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#locality')),
|
||||
'dependent_locality' => t('<a href="@doc">The dependent locality of ' .
|
||||
'this address</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#dependent_locality')),
|
||||
'postal_code' => t('<a href="@doc">The postal code of this address</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#postal_code')),
|
||||
'thoroughfare' => t('<a href="@doc">The thoroughfare of this address ' .
|
||||
'(i.e. Street address)</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#thoroughfare')),
|
||||
'premise' => t('<a href="@doc">The premise of this address (i.e. Apartment / Suite number)</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#premise')),
|
||||
'sub_premise' => t('<a href="@doc">The sub_premise of this address</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#sub_premise')),
|
||||
'organisation_name' => t('<a href="@doc">Contents of a primary ' .
|
||||
'OrganisationName element in the xNL XML</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#organisation_name')),
|
||||
'name_line' => t('<a href="@doc">Contents of a primary NameLine element ' .
|
||||
'in the xNL XML</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#name_line')),
|
||||
'first_name' => t('<a href="@doc">Contents of the FirstName element of ' .
|
||||
'a primary PersonName element in the xNL XML</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#first_name')),
|
||||
'last_name' => t('<a href="@doc">Contents of the LastName element of a ' .
|
||||
'primary PersonName element in the xNL XML</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#last_name')),
|
||||
'data' => t('<a href="@doc">Additional data for this address</a>',
|
||||
array('@doc' => 'http://drupal.org/node/1996546#data')),
|
||||
);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements MigrateFieldHandler::prepare().
|
||||
*
|
||||
* @param $entity
|
||||
* @param array $field_info
|
||||
* @param array $instance
|
||||
* @param array $values
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function prepare($entity, array $field_info, array $instance,
|
||||
array $values) {
|
||||
$arguments = array();
|
||||
if (isset($values['arguments'])) {
|
||||
$arguments = array_filter($values['arguments']);
|
||||
unset($values['arguments']);
|
||||
}
|
||||
$language = $this->getFieldLanguage($entity, $field_info, $arguments);
|
||||
|
||||
// Setup the standard Field API array for saving.
|
||||
$delta = 0;
|
||||
foreach ($values as $value) {
|
||||
$return[$language][$delta] = array('country' => $value)
|
||||
+ $this->prepareArguments($arguments, $field_info, $delta);
|
||||
$delta++;
|
||||
}
|
||||
|
||||
return isset($return) ? $return : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an array with additional data for the current $delta.
|
||||
*
|
||||
* @param array $arguments
|
||||
* @param array $field_info
|
||||
* @param $delta
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareArguments(array $arguments, array $field_info, $delta) {
|
||||
$result = array();
|
||||
$data = array();
|
||||
|
||||
foreach ($arguments as $column_key => $column_value) {
|
||||
$value = NULL;
|
||||
|
||||
if (is_array($arguments[$column_key])) {
|
||||
if (!empty($arguments[$column_key][$delta])) {
|
||||
$value = $arguments[$column_key][$delta];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$value = $arguments[$column_key];
|
||||
}
|
||||
|
||||
if ($value) {
|
||||
if (isset($field_info['columns'][$column_key])) {
|
||||
// Store the data in a separate column.
|
||||
$result[$column_key] = $value;
|
||||
}
|
||||
else {
|
||||
// Add the data to the 'data' column.
|
||||
$data[$column_key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store all the other data as a serialized array in the data field.
|
||||
if (!empty($data)) {
|
||||
$result['data'] = serialize($data);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,939 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines a field for attaching country-specific addresses to entities.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_directory().
|
||||
*/
|
||||
function addressfield_ctools_plugin_directory($module, $plugin) {
|
||||
if ($module == 'addressfield') {
|
||||
return 'plugins/' . $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_type().
|
||||
*/
|
||||
function addressfield_ctools_plugin_type() {
|
||||
$plugins['format'] = array(
|
||||
'load themes' => TRUE,
|
||||
);
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function addressfield_views_api() {
|
||||
return array(
|
||||
'api' => 3,
|
||||
'path' => drupal_get_path('module', 'addressfield') . '/views',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_module_implements_alter().
|
||||
*
|
||||
* Moves the hook_token_info_alter() implementation to the bottom so it is
|
||||
* invoked after all modules implementing the same hook.
|
||||
*/
|
||||
function addressfield_module_implements_alter(&$implementations, $hook) {
|
||||
if ($hook == 'token_info_alter') {
|
||||
// Make sure that the $implementations list is populated before altering it,
|
||||
// to work around a crash experienced by some people (#2181001).
|
||||
if (isset($implementations['addressfield'])) {
|
||||
$group = $implementations['addressfield'];
|
||||
unset($implementations['addressfield']);
|
||||
$implementations['addressfield'] = $group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of address fields optionally filtered by entity type.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* Optional machine-name of an entity type to filter the returned array by.
|
||||
*
|
||||
* @return array
|
||||
* An array of address field mapping data.
|
||||
*/
|
||||
function addressfield_get_address_fields($entity_type = '') {
|
||||
$fields = &drupal_static(__FUNCTION__ . '_' . $entity_type);
|
||||
|
||||
if (isset($fields)) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
// Get mapping data for all address fields.
|
||||
$fields = array_filter(field_info_field_map(), 'addressfield_field_map_filter');
|
||||
|
||||
// Filter the list of fields by entity type if specified.
|
||||
if (!empty($fields) && !empty($entity_type)) {
|
||||
foreach ($fields as $field_name => $field) {
|
||||
if (!isset($field['bundles'][$entity_type])) {
|
||||
unset($fields[$field_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if a field map array value represents an addressfield.
|
||||
*
|
||||
* Provided for use as a callback by array_filter().
|
||||
*/
|
||||
function addressfield_field_map_filter($field) {
|
||||
return !empty($field['type']) && $field['type'] == 'addressfield';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of format plugins.
|
||||
*/
|
||||
function addressfield_format_plugins() {
|
||||
ctools_include('plugins');
|
||||
$plugins = ctools_get_plugins('addressfield', 'format');
|
||||
uasort($plugins, 'ctools_plugin_sort');
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of format plugins in a format suitable for #options.
|
||||
*/
|
||||
function addressfield_format_plugins_options() {
|
||||
$options = array();
|
||||
foreach (addressfield_format_plugins() as $widget => $info) {
|
||||
$options[$widget] = check_plain($info['title']);
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @defgroup addressfield_format Address format API
|
||||
* @{
|
||||
* API for generating address forms and display formats.
|
||||
*
|
||||
* Addresses forms and display formats are collaboratively generated by one or
|
||||
* more format handler plugins. An address with a name and a company, for example,
|
||||
* will be generated by three handlers:
|
||||
* - 'address' that will generate the country, locality, street blocks
|
||||
* - 'organisation' that will add the organisation block to the address
|
||||
* - 'name-full' that will add a first name and last name block to the address
|
||||
*
|
||||
* A format handler is a CTools plugin of type 'addressfield' / 'format'. Each
|
||||
* handler is passed the format in turn, and can add to or modify the format.
|
||||
*
|
||||
* The format itself is a renderable array stub. This stub will be transformed
|
||||
* into either a Form API array suitable for use as part of a form or into a
|
||||
* renderable array suitable for use with drupal_render(). The following
|
||||
* modifications are done:
|
||||
* - when rendering as a form, every element which name (its key in the array)
|
||||
* is a valid addressfield column (see addressfield_field_schema()), will
|
||||
* be transformed into a form element, either using a type explicitly
|
||||
* defined in '#widget_type' or using 'select' if '#options' is set or
|
||||
* 'textfield' if it is not. In addition, the '#default_value' of every
|
||||
* field will be populated from the address being edited.
|
||||
* - when rendering as a formatter, every element which name (its key in the array)
|
||||
* is a valid addressfield column (see addressfield_field_schema()), will
|
||||
* be transformed into a renderable element, either using a type explicitly
|
||||
* defined in '#render_type' or else using 'addressfield_container'. When
|
||||
* the type is 'addressfield_container' the element will be rendered as
|
||||
* an HTML element set by '#tag' (default: span).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate a format for a given address.
|
||||
*
|
||||
* @param $address
|
||||
* The address format being generated.
|
||||
* @param $handlers
|
||||
* The format handlers to use to generate the format.
|
||||
* @param $context
|
||||
* An associative array of context information pertaining to how the address
|
||||
* format should be generated. If no mode is given, it will initialize to the
|
||||
* default value. The remaining context keys should only be present when the
|
||||
* address format is being generated for a field:
|
||||
* - mode: either 'form' or 'render'; defaults to 'render'.
|
||||
* - field: the field info array.
|
||||
* - instance: the field instance array.
|
||||
* - langcode: the langcode of the language the field is being rendered in.
|
||||
* - delta: the delta value of the given address.
|
||||
*
|
||||
* @return
|
||||
* A renderable array suitable for use as part of a form (if 'mode' is 'form')
|
||||
* or for formatted address output when passed to drupal_render().
|
||||
*/
|
||||
function addressfield_generate($address, array $handlers, array $context = array()) {
|
||||
// If no mode is given in the context array, default it to 'render'.
|
||||
if (empty($context['mode'])) {
|
||||
$context['mode'] = 'render';
|
||||
}
|
||||
|
||||
ctools_include('plugins');
|
||||
$format = array();
|
||||
// Add the handlers, ordered by weight.
|
||||
$plugins = addressfield_format_plugins();
|
||||
$format['#handlers'] = array_intersect(array_keys($plugins), $handlers);
|
||||
|
||||
foreach ($format['#handlers'] as $handler) {
|
||||
if ($callback = ctools_plugin_load_function('addressfield', 'format', $handler, 'format callback')) {
|
||||
$callback($format, $address, $context);
|
||||
}
|
||||
}
|
||||
|
||||
// Store the address in the format, for processing.
|
||||
$format['#address'] = $address;
|
||||
|
||||
// Post-process the format stub, depending on the rendering mode.
|
||||
if ($context['mode'] == 'form') {
|
||||
$format['#addressfield'] = TRUE;
|
||||
$format['#process'][] = 'addressfield_process_format_form';
|
||||
}
|
||||
elseif ($context['mode'] == 'render') {
|
||||
$format['#pre_render'][] = 'addressfield_render_address';
|
||||
}
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a full-fledged form from a format snippet, as returned by addressfield_formats().
|
||||
*/
|
||||
function addressfield_process_format_form($format, &$form_state, $complete_form) {
|
||||
// Make sure to load all the plugins that participated in this format.
|
||||
ctools_include('plugins');
|
||||
foreach ($format['#handlers'] as $handler) {
|
||||
ctools_plugin_load_function('addressfield', 'format', $handler, 'format callback');
|
||||
}
|
||||
|
||||
_addressfield_process_format_form($format, $format['#address']);
|
||||
return $format;
|
||||
}
|
||||
|
||||
function _addressfield_process_format_form(&$format, $address) {
|
||||
foreach (element_children($format) as $key) {
|
||||
$child = &$format[$key];
|
||||
|
||||
// Automatically convert any element in the format array to an appropriate
|
||||
// form element that matches one of the address component names.
|
||||
if (in_array($key, array('name_line', 'first_name', 'last_name', 'organisation_name', 'country', 'administrative_area', 'sub_administrative_area', 'locality', 'dependent_locality', 'postal_code', 'thoroughfare', 'premise', 'sub_premise'))) {
|
||||
// Set the form element type for the address component to whatever the
|
||||
// address format specified in its #widget_type property.
|
||||
if (isset($child['#widget_type'])) {
|
||||
$child['#type'] = $child['#widget_type'];
|
||||
}
|
||||
else {
|
||||
// If the element didn't specify a #widget_type and has options, turn it
|
||||
// into a select list and unset its #size value, which is typically used
|
||||
// to provide the width of a textfield.
|
||||
if (isset($child['#options'])) {
|
||||
$child['#type'] = 'select';
|
||||
unset($child['#size']);
|
||||
}
|
||||
else {
|
||||
// Otherwise go ahead and make it a textfield.
|
||||
$child['#type'] = 'textfield';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($address[$key])) {
|
||||
$child['#default_value'] = $address[$key];
|
||||
}
|
||||
}
|
||||
|
||||
// Recurse through the element's children if it has any.
|
||||
_addressfield_process_format_form($child, $address);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an address in a given format.
|
||||
*/
|
||||
function addressfield_render_address($format) {
|
||||
_addressfield_render_address($format, $format['#address']);
|
||||
return $format;
|
||||
}
|
||||
|
||||
function _addressfield_render_address(&$format, $address) {
|
||||
foreach (element_children($format) as $key) {
|
||||
$child = &$format[$key];
|
||||
|
||||
// Automatically expand elements that match one of the fields of the address
|
||||
// structure.
|
||||
if (in_array($key, array('name_line', 'first_name', 'last_name', 'organisation_name', 'country', 'administrative_area', 'sub_administrative_area', 'locality', 'dependent_locality', 'postal_code', 'thoroughfare', 'premise', 'sub_premise'), TRUE)) {
|
||||
if (isset($child['#render_type'])) {
|
||||
$child['#type'] = $child['#render_type'];
|
||||
}
|
||||
else {
|
||||
$child['#type'] = 'addressfield_container';
|
||||
if (!isset($child['#tag'])) {
|
||||
$child['#tag'] = 'span';
|
||||
}
|
||||
}
|
||||
|
||||
// If the element instructs us to render the option value instead of the
|
||||
// raw address element value and its #options array has a matching key,
|
||||
// swap it out for the option value now.
|
||||
if (!empty($child['#render_option_value']) && isset($address[$key]) && isset($child['#options'][$address[$key]])) {
|
||||
$child['#children'] = check_plain($child['#options'][$address[$key]]);
|
||||
}
|
||||
elseif (isset($address[$key])) {
|
||||
$child['#children'] = check_plain($address[$key]);
|
||||
}
|
||||
else {
|
||||
$child['#children'] = '';
|
||||
}
|
||||
|
||||
// Skip empty elements.
|
||||
if ((string) $child['#children'] === '') {
|
||||
$child['#access'] = FALSE;
|
||||
}
|
||||
|
||||
// Add #field_prefix and #field_suffix to the prefixes and suffixes.
|
||||
if (isset($child['#field_prefix'])) {
|
||||
$child['#prefix'] = (isset($child['#prefix']) ? $child['#prefix'] : '') . $child['#field_prefix'];
|
||||
}
|
||||
if (isset($child['#field_suffix'])) {
|
||||
$child['#suffix'] = (isset($child['#suffix']) ? $child['#suffix'] : '') . $child['#field_suffix'];
|
||||
}
|
||||
}
|
||||
|
||||
// Recurse through the child.
|
||||
_addressfield_render_address($child, $address);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "ingroup addressfield_format"
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_theme().
|
||||
*/
|
||||
function addressfield_theme() {
|
||||
$hooks['addressfield_container'] = array(
|
||||
'render element' => 'element',
|
||||
);
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a container for a set of address fields.
|
||||
*/
|
||||
function theme_addressfield_container($variables) {
|
||||
$element = $variables['element'];
|
||||
$element['#children'] = trim($element['#children']);
|
||||
// Remove the autocomplete attribute because the W3C validator complains.
|
||||
// It's only used on forms anyway.
|
||||
unset($element['#attributes']['autocomplete']);
|
||||
|
||||
if (strlen($element['#children']) > 0) {
|
||||
$output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>';
|
||||
$output .= $element['#children'];
|
||||
$output .= '</' . $element['#tag'] . '>';
|
||||
// Add a linebreak to the HTML after a div. This is invisible on the
|
||||
// rendered page but improves the appearance of address field output when
|
||||
// HTML tags are stripped, such as by Views Data Export.
|
||||
if ($element['#tag'] == 'div') {
|
||||
$output .= PHP_EOL;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_element_info().
|
||||
*/
|
||||
function addressfield_element_info() {
|
||||
$types['addressfield_container'] = array(
|
||||
'#theme_wrappers' => array('addressfield_container'),
|
||||
'#process' => array('addressfield_widget_process'),
|
||||
'#attributes' => array(),
|
||||
'#tag' => 'div',
|
||||
);
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form API process function: set the #parents of the children of this element so they appear at the same level as the parent.
|
||||
*/
|
||||
function addressfield_widget_process($element) {
|
||||
foreach (element_children($element) as $key) {
|
||||
$element[$key]['#parents'] = $element['#parents'];
|
||||
$element[$key]['#parents'][count($element[$key]['#parents']) - 1] = $key;
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_info()
|
||||
*/
|
||||
function addressfield_field_info() {
|
||||
$fields = array();
|
||||
|
||||
$fields['addressfield'] = array(
|
||||
'label' => t('Postal address'),
|
||||
'description' => t('A field type used for storing postal addresses according the xNAL standard.'),
|
||||
'settings' => array(),
|
||||
'instance_settings' => array(),
|
||||
'default_widget' => 'addressfield_standard',
|
||||
'default_formatter' => 'addressfield_default',
|
||||
'property_type' => 'addressfield',
|
||||
'property_callbacks' => array('addressfield_property_info_callback'),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of default values for the addressfield form elements.
|
||||
*
|
||||
* @param $field
|
||||
* The field array.
|
||||
* @param $instance
|
||||
* The instance array.
|
||||
* @param $address
|
||||
* The current address values, if known. Allows for per-country defaults.
|
||||
*
|
||||
* @return
|
||||
* An array of default values.
|
||||
*/
|
||||
function addressfield_default_values($field, $instance, array $address = array()) {
|
||||
$available_countries = _addressfield_country_options_list($field, $instance);
|
||||
$default_country = $instance['widget']['settings']['default_country'];
|
||||
// Resolve the special site_default option.
|
||||
if ($default_country == 'site_default') {
|
||||
$default_country = variable_get('site_default_country', '');
|
||||
}
|
||||
// Fallback to the first country in the list if the default country is not
|
||||
// available, or is empty even though the field is required.
|
||||
$not_available = $default_country && !isset($available_countries[$default_country]);
|
||||
$empty_but_required = empty($default_country) && !empty($instance['required']);
|
||||
if ($not_available || $empty_but_required) {
|
||||
$default_country = key($available_countries);
|
||||
}
|
||||
|
||||
$default_values = array(
|
||||
'country' => $default_country,
|
||||
'name_line' => '',
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'organisation_name' => '',
|
||||
'administrative_area' => '',
|
||||
'sub_administrative_area' => '',
|
||||
'locality' => '',
|
||||
'dependent_locality' => '',
|
||||
'postal_code' => '',
|
||||
'thoroughfare' => '',
|
||||
'premise' => '',
|
||||
'sub_premise' => '',
|
||||
'data' => '',
|
||||
);
|
||||
|
||||
// Allow other modules to alter the default values.
|
||||
$context = array(
|
||||
'field' => $field,
|
||||
'instance' => $instance,
|
||||
'address' => $address,
|
||||
);
|
||||
drupal_alter('addressfield_default_values', $default_values, $context);
|
||||
|
||||
return $default_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_is_empty().
|
||||
*/
|
||||
function addressfield_field_is_empty($item, $field) {
|
||||
// Every address field must have at least a country value or it is considered
|
||||
// empty, even if it has name information.
|
||||
return empty($item['country']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_presave().
|
||||
*/
|
||||
function addressfield_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
|
||||
foreach ($items as $delta => &$item) {
|
||||
// If the first name and last name are set but the name line isn't...
|
||||
if (isset($item['first_name']) && isset($item['last_name']) && !isset($item['name_line'])) {
|
||||
// Combine the first and last name to be the name line.
|
||||
$items[$delta]['name_line'] = $items[$delta]['first_name'] . ' ' . $items[$delta]['last_name'];
|
||||
}
|
||||
elseif (isset($item['name_line'])) {
|
||||
// Otherwise if the name line is set, separate it out into a best guess at
|
||||
// the first and last name.
|
||||
$names = explode(' ', $item['name_line']);
|
||||
|
||||
$item['first_name'] = array_shift($names);
|
||||
$item['last_name'] = implode(' ', $names);
|
||||
}
|
||||
|
||||
// Trim whitespace from all of the address components and convert any double
|
||||
// spaces to single spaces.
|
||||
foreach ($item as $key => &$value) {
|
||||
if (!in_array($key, array('data')) && is_string($value)) {
|
||||
$value = trim(preg_replace('/[[:blank:]]{2,}/u', ' ', $value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_info()
|
||||
*/
|
||||
function addressfield_field_widget_info() {
|
||||
$widgets = array();
|
||||
|
||||
$widgets['addressfield_standard'] = array(
|
||||
'label' => t('Dynamic address form'),
|
||||
'field types' => array('addressfield'),
|
||||
'settings' => array(
|
||||
'available_countries' => array(),
|
||||
// Can't use variable_get('site_default_country') here because it would
|
||||
// set the value in stone. Instead, the site_default option allows the
|
||||
// default country to always reflect the current site setting.
|
||||
'default_country' => 'site_default',
|
||||
'format_handlers' => array('address'),
|
||||
),
|
||||
);
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_settings_form()
|
||||
*/
|
||||
function addressfield_field_widget_settings_form($field, $instance) {
|
||||
$widget = $instance['widget'];
|
||||
$defaults = field_info_widget_settings($widget['type']);
|
||||
$settings = array_merge($defaults, $widget['settings']);
|
||||
$form = array();
|
||||
|
||||
if ($widget['type'] == 'addressfield_standard') {
|
||||
$form['available_countries'] = array(
|
||||
'#type' => 'select',
|
||||
'#multiple' => TRUE,
|
||||
'#title' => t('Available countries'),
|
||||
'#description' => t('If no countries are selected, all countries will be available.'),
|
||||
'#options' => _addressfield_country_options_list(),
|
||||
'#default_value' => $settings['available_countries'],
|
||||
);
|
||||
$form['default_country'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default country'),
|
||||
'#options' => array('site_default' => t('- Site default -')) + _addressfield_country_options_list(),
|
||||
'#default_value' => $settings['default_country'],
|
||||
'#empty_value' => '',
|
||||
);
|
||||
$form['format_handlers'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Format handlers'),
|
||||
'#options' => addressfield_format_plugins_options(),
|
||||
'#default_value' => $settings['format_handlers'],
|
||||
);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_BASE_FORM_ID_alter().
|
||||
*
|
||||
* Removes the default values form from the field settings page.
|
||||
* Allows the module to implement its own, more predictable default value
|
||||
* handling, getting around #1253820 and other bugs.
|
||||
*/
|
||||
function addressfield_form_field_ui_field_edit_form_alter(&$form, $form_state) {
|
||||
if ($form['#field']['type'] == 'addressfield') {
|
||||
$form['instance']['default_value_widget']['#access'] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_form()
|
||||
*/
|
||||
function addressfield_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||
$settings = $instance['widget']['settings'];
|
||||
|
||||
$address = array();
|
||||
// If the form has been rebuilt via AJAX, use the form state values.
|
||||
// $form_state['values'] is empty because of #limit_validation_errors, so
|
||||
// $form_state['input'] needs to be used instead.
|
||||
$parents = array_merge($element['#field_parents'], array($element['#field_name'], $langcode, $delta));
|
||||
if (!empty($form_state['input'])) {
|
||||
$input_address = drupal_array_get_nested_value($form_state['input'], $parents);
|
||||
}
|
||||
if (!empty($input_address)) {
|
||||
$address = $input_address;
|
||||
}
|
||||
elseif (!empty($items[$delta]['country'])) {
|
||||
// Else use the saved value for the field.
|
||||
$address = $items[$delta];
|
||||
}
|
||||
|
||||
// Determine the list of available countries, and if the currently selected
|
||||
// country is not in it, unset it so it can be reset to the default country.
|
||||
$countries = _addressfield_country_options_list($field, $instance);
|
||||
if (!empty($address['country']) && !isset($countries[$address['country']])) {
|
||||
unset($address['country']);
|
||||
}
|
||||
|
||||
// Merge in default values.
|
||||
$address += addressfield_default_values($field, $instance, $address);
|
||||
|
||||
// Add the form elements for the standard widget, which includes a country
|
||||
// select list at the top that reloads the available address elements when the
|
||||
// country is changed.
|
||||
if ($instance['widget']['type'] == 'addressfield_standard') {
|
||||
// Wrap everything in a fieldset. This is not the best looking element,
|
||||
// but it's the only wrapper available in Drupal we can properly use
|
||||
// in that context, and it is overridable if necessary.
|
||||
$element['#type'] = 'fieldset';
|
||||
|
||||
if (!empty($instance['description'])) {
|
||||
// Checkout panes convert the fieldset into a container, causing
|
||||
// #description to not be rendered. Hence, a real element is added and
|
||||
// the old #description is removed.
|
||||
$element['#description'] = '';
|
||||
$element['element_description'] = array(
|
||||
'#markup' => $instance['description'],
|
||||
'#prefix' => '<div class="fieldset-description">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => -999,
|
||||
);
|
||||
}
|
||||
|
||||
// Generate the address form.
|
||||
$context = array(
|
||||
'mode' => 'form',
|
||||
'field' => $field,
|
||||
'instance' => $instance,
|
||||
'langcode' => $langcode,
|
||||
'delta' => $delta,
|
||||
);
|
||||
$element += addressfield_generate($address, $settings['format_handlers'], $context);
|
||||
|
||||
// Remove any already saved default value.
|
||||
// See addressfield_form_field_ui_field_edit_form_alter() for the reasoning.
|
||||
if ($form_state['build_info']['form_id'] == 'field_ui_field_edit_form') {
|
||||
$element['#address'] = array('country' => '');
|
||||
}
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element validate callback: rebuilds the form on country change.
|
||||
*/
|
||||
function addressfield_standard_country_validate($element, &$form_state) {
|
||||
if ($element['#default_value'] != $element['#value']) {
|
||||
$parents = $element['#parents'];
|
||||
array_pop($parents);
|
||||
$address = drupal_array_get_nested_value($form_state['values'], $parents);
|
||||
|
||||
// Clear the country-specific field values.
|
||||
$country_specific_data = array(
|
||||
'dependent_locality' => '',
|
||||
'locality' => '',
|
||||
'administrative_area' => '',
|
||||
'postal_code' => '',
|
||||
);
|
||||
$address = array_diff_key($address, $country_specific_data);
|
||||
|
||||
drupal_array_set_nested_value($form_state['values'], $parents, $address);
|
||||
drupal_array_set_nested_value($form_state['input'], $parents, $address);
|
||||
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax callback in response to a change of country in an address field.
|
||||
*
|
||||
* The only thing we have to do is to find the proper element to render.
|
||||
*/
|
||||
function addressfield_standard_widget_refresh($form, $form_state) {
|
||||
// The target element is one element below the triggering country selector.
|
||||
$array_parents = $form_state['triggering_element']['#array_parents'];
|
||||
array_pop($array_parents);
|
||||
|
||||
// Iterate over the form parents to find the element.
|
||||
$element = $form;
|
||||
foreach ($array_parents as $name) {
|
||||
$element = &$element[$name];
|
||||
if (!empty($element['#addressfield'])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the address block, but remove the '_weight' element inserted
|
||||
// by the field API.
|
||||
unset($element['_weight']);
|
||||
|
||||
// Replace the address field widget with the updated widget and focus on the
|
||||
// new country select list.
|
||||
$commands[] = ajax_command_replace(NULL, render($element));
|
||||
$commands[] = ajax_command_invoke('#' . $element['country']['#id'], 'focus');
|
||||
// Add the status messages inside the new addressfield's wrapper element,
|
||||
// just like core does.
|
||||
$commands[] = ajax_command_prepend(NULL, theme('status_messages'));
|
||||
|
||||
// Allow other modules to add arbitrary AJAX commands on the refresh.
|
||||
drupal_alter('addressfield_standard_widget_refresh', $commands, $form, $form_state);
|
||||
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_info().
|
||||
*/
|
||||
function addressfield_field_formatter_info() {
|
||||
return array(
|
||||
'addressfield_default' => array(
|
||||
'label' => t('Default'),
|
||||
'field types' => array('addressfield'),
|
||||
'settings' => array(
|
||||
'use_widget_handlers' => 1,
|
||||
'format_handlers' => array('address'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_settings_form().
|
||||
*/
|
||||
function addressfield_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
|
||||
$element['use_widget_handlers'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use the same configuration as the widget.'),
|
||||
'#default_value' => !empty($settings['use_widget_handlers']),
|
||||
);
|
||||
|
||||
$element['format_handlers'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Format handlers'),
|
||||
'#options' => addressfield_format_plugins_options(),
|
||||
'#default_value' => $settings['format_handlers'],
|
||||
'#process' => array('form_process_checkboxes', '_addressfield_field_formatter_settings_form_process_add_state'),
|
||||
'#element_validate' => array('_addressfield_field_formatter_settings_form_validate')
|
||||
);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function: set the proper #states to the use widget handlers checkbox.
|
||||
*/
|
||||
function _addressfield_field_formatter_settings_form_process_add_state($element, $form_state) {
|
||||
// Build a #parents based on the current checkbox.
|
||||
$target_parents = array_slice($element['#parents'], 0, -1);
|
||||
$target_parents[] = 'use_widget_handlers';
|
||||
$target_parents = array_shift($target_parents) . ($target_parents ? '[' . implode('][', $target_parents) . ']' : '');
|
||||
|
||||
$element['#states']['visible'] = array(
|
||||
':input[name="' . $target_parents . '"]' => array('checked' => FALSE),
|
||||
);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function: filter the results of the checkboxes form element.
|
||||
*/
|
||||
function _addressfield_field_formatter_settings_form_validate($element, &$element_state) {
|
||||
form_set_value($element, array_filter($element['#value']), $element_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_settings_summary().
|
||||
*/
|
||||
function addressfield_field_formatter_settings_summary($field, $instance, $view_mode) {
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
|
||||
if ($settings['use_widget_handlers']) {
|
||||
return t('Use widget configuration');
|
||||
}
|
||||
else {
|
||||
$summary = array();
|
||||
$plugins = addressfield_format_plugins();
|
||||
foreach ($settings['format_handlers'] as $handler) {
|
||||
$summary[] = $plugins[$handler]['title'];
|
||||
}
|
||||
return $summary ? implode(', ', $summary) : t('No handler');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_view().
|
||||
*/
|
||||
function addressfield_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
|
||||
$settings = $display['settings'];
|
||||
$element = array();
|
||||
|
||||
switch ($display['type']) {
|
||||
case 'addressfield_default':
|
||||
if (!empty($settings['use_widget_handlers'])) {
|
||||
$handlers = $instance['widget']['settings']['format_handlers'];
|
||||
}
|
||||
else {
|
||||
$handlers = $settings['format_handlers'];
|
||||
}
|
||||
foreach ($items as $delta => $address) {
|
||||
// Generate the address format.
|
||||
$context = array(
|
||||
'mode' => 'render',
|
||||
'field' => $field,
|
||||
'instance' => $instance,
|
||||
'langcode' => $langcode,
|
||||
'delta' => $delta,
|
||||
);
|
||||
$element[$delta] = addressfield_generate($address, $handlers, $context);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to alter the property info of address fields.
|
||||
*
|
||||
* @see addressfield_field_info().
|
||||
*/
|
||||
function addressfield_property_info_callback(&$info, $entity_type, $field, $instance, $field_type) {
|
||||
$name = $field['field_name'];
|
||||
$property = &$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$name];
|
||||
|
||||
$property['type'] = ($field['cardinality'] != 1) ? 'list<addressfield>' : 'addressfield';
|
||||
$property['getter callback'] = 'entity_metadata_field_verbatim_get';
|
||||
$property['setter callback'] = 'entity_metadata_field_verbatim_set';
|
||||
$property['auto creation'] = 'addressfield_auto_creation';
|
||||
$property['property info'] = addressfield_data_property_info();
|
||||
|
||||
unset($property['query callback']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto creation callback for an addressfield value array.
|
||||
*
|
||||
* @see addressfield_property_info_callback()
|
||||
*/
|
||||
function addressfield_auto_creation($property_name, $context) {
|
||||
return addressfield_default_values($context['field'], $context['instance']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines info for the properties of the address field data structure.
|
||||
*/
|
||||
function addressfield_data_property_info($name = NULL) {
|
||||
// Build an array of basic property information for the address field.
|
||||
$properties = array(
|
||||
'country' => array(
|
||||
'label' => t('Country'),
|
||||
'options list' => '_addressfield_country_options_list',
|
||||
),
|
||||
'name_line' => array(
|
||||
'label' => t('Full name'),
|
||||
),
|
||||
'first_name' => array(
|
||||
'label' => t('First name'),
|
||||
),
|
||||
'last_name' => array(
|
||||
'label' => t('Last name'),
|
||||
),
|
||||
'organisation_name' => array(
|
||||
'label' => t('Company'),
|
||||
),
|
||||
'administrative_area' => array(
|
||||
'label' => t('Administrative area (i.e. State / Province)'),
|
||||
),
|
||||
'sub_administrative_area' => array(
|
||||
'label' => t('Sub administrative area'),
|
||||
),
|
||||
'locality' => array(
|
||||
'label' => t('Locality (i.e. City)'),
|
||||
),
|
||||
'dependent_locality' => array(
|
||||
'label' => t('Dependent locality'),
|
||||
),
|
||||
'postal_code' => array(
|
||||
'label' => t('Postal code'),
|
||||
),
|
||||
'thoroughfare' => array(
|
||||
'label' => t('Thoroughfare (i.e. Street address)'),
|
||||
),
|
||||
'premise' => array(
|
||||
'label' => t('Premise (i.e. Apartment / Suite number)'),
|
||||
),
|
||||
'sub_premise' => array(
|
||||
'label' => t('Sub Premise (i.e. Suite, Apartment, Floor, Unknown.'),
|
||||
),
|
||||
);
|
||||
|
||||
// Add the default values for each of the address field properties.
|
||||
foreach ($properties as $key => &$value) {
|
||||
$value += array(
|
||||
'description' => !empty($name) ? t('!label of field %name', array('!label' => $value['label'], '%name' => $name)) : '',
|
||||
'type' => 'text',
|
||||
'getter callback' => 'entity_property_verbatim_get',
|
||||
'setter callback' => 'entity_property_verbatim_set',
|
||||
);
|
||||
}
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the country list in a format suitable for use as an options list.
|
||||
*/
|
||||
function _addressfield_country_options_list($field = NULL, $instance = NULL) {
|
||||
if (module_exists('countries')) {
|
||||
$countries = countries_get_countries('name', array('enabled' => COUNTRIES_ENABLED));
|
||||
}
|
||||
else {
|
||||
require_once DRUPAL_ROOT . '/includes/locale.inc';
|
||||
$countries = country_get_list();
|
||||
}
|
||||
|
||||
if (isset($field)) {
|
||||
// If the instance is not specified, loop against all the instances of the field.
|
||||
if (!isset($instance)) {
|
||||
$instances = array();
|
||||
foreach ($field['bundles'] as $entity_type => $bundles) {
|
||||
foreach ($bundles as $bundle_name) {
|
||||
$instances[] = field_info_instance($entity_type, $field['field_name'], $bundle_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$instances = array($instance);
|
||||
}
|
||||
|
||||
foreach ($instances as $instance) {
|
||||
if (!empty($instance['widget']['settings']['available_countries'])) {
|
||||
$countries = array_intersect_key($countries, $instance['widget']['settings']['available_countries']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $countries;
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Token module integration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_token_info().
|
||||
*/
|
||||
function addressfield_token_info() {
|
||||
$type = array(
|
||||
'name' => t('Address field'),
|
||||
'description' => t('Tokens related to address field values and their components.'),
|
||||
'needs-data' => 'address-field',
|
||||
'field' => TRUE,
|
||||
);
|
||||
|
||||
// Define tokens for the various components of addresses supported through the
|
||||
// user interface along with two helper tokens for country and administrative
|
||||
// area to distinguish between names and abbreviations.
|
||||
$info['country'] = array(
|
||||
'name' => t('Country name'),
|
||||
'description' => t('The full name of the country.'),
|
||||
);
|
||||
$info['country-code'] = array(
|
||||
'name' => t('Country code'),
|
||||
'description' => t('The two letter ISO country code.'),
|
||||
);
|
||||
$info['administrative-area'] = array(
|
||||
'name' => t('Administrative area (i.e. State/Province)'),
|
||||
'description' => t('The administrative area value, expanded to the full name if applicable.'),
|
||||
);
|
||||
$info['administrative-area-raw'] = array(
|
||||
'name' => t('Administrative area (raw value)'),
|
||||
'description' => t('The raw administrative area value.'),
|
||||
);
|
||||
$info['locality'] = array(
|
||||
'name' => t('Locality (i.e. City)'),
|
||||
'description' => t('The locality value.'),
|
||||
);
|
||||
$info['postal-code'] = array(
|
||||
'name' => t('Postal code'),
|
||||
'description' => t('The postal code value.'),
|
||||
);
|
||||
$info['thoroughfare'] = array(
|
||||
'name' => t('Thoroughfare (i.e. Street address)'),
|
||||
'description' => t('The thoroughfare value.'),
|
||||
);
|
||||
$info['premise'] = array(
|
||||
'name' => t('Premise (i.e. Street address)'),
|
||||
'description' => t('The premise value.'),
|
||||
);
|
||||
$info['sub_premise'] = array(
|
||||
'name' => t('Sub Premise (i.e. Suite, Apartment, Floor, Unknown.)'),
|
||||
'description' => t('The sub premise value.'),
|
||||
);
|
||||
$info['organisation'] = array(
|
||||
'name' => t('Organisation'),
|
||||
'description' => t('The organisation name value.'),
|
||||
);
|
||||
$info['name-line'] = array(
|
||||
'name' => t('Full name'),
|
||||
'description' => t('The name line value of the address.'),
|
||||
);
|
||||
$info['first-name'] = array(
|
||||
'name' => t('First name'),
|
||||
'description' => t('The first name value.'),
|
||||
);
|
||||
$info['last-name'] = array(
|
||||
'name' => t('Last name'),
|
||||
'description' => t('The last name value.'),
|
||||
);
|
||||
|
||||
// Add a helper token to format addresses as expected by MailChimp.
|
||||
$info['format-mailchimp'] = array(
|
||||
'name' => t('Address formatted for MailChimp'),
|
||||
'description' => t('The full address formatted for import into MailChimp.'),
|
||||
);
|
||||
|
||||
return array(
|
||||
'types' => array('address-field' => $type),
|
||||
'tokens' => array('address-field' => $info),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_token_info_alter().
|
||||
*/
|
||||
function addressfield_token_info_alter(&$data) {
|
||||
// Loop over every address field on the site.
|
||||
foreach (addressfield_get_address_fields() as $field_name => $field) {
|
||||
foreach (array($field_name, strtr($field_name, '_', '-')) as $name) {
|
||||
foreach ($data['tokens'] as $group => $token) {
|
||||
if (isset($data['tokens'][$group][$name]) && is_array($data['tokens'][$group][$name])) {
|
||||
// Set the token type for the field to use the addressfield child tokens.
|
||||
$data['tokens'][$group][$name]['type'] = 'address-field';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_tokens().
|
||||
*/
|
||||
function addressfield_tokens($type, $tokens, array $data = array(), array $options = array()) {
|
||||
if (isset($options['language'])) {
|
||||
$language_code = $options['language']->language;
|
||||
}
|
||||
else {
|
||||
$language_code = LANGUAGE_NONE;
|
||||
}
|
||||
|
||||
$sanitize = !empty($options['sanitize']);
|
||||
|
||||
$replacements = array();
|
||||
|
||||
// If we're generating tokens for an address field, extract the address data
|
||||
// from the field value array and generate the necessary replacements.
|
||||
if ($type == 'address-field' && !empty($data['address-field'][$language_code]) && is_array($data['address-field'][$language_code])) {
|
||||
$address = reset($data['address-field'][$language_code]);
|
||||
|
||||
foreach ($tokens as $name => $original) {
|
||||
switch ($name) {
|
||||
case 'country':
|
||||
$countries = _addressfield_country_options_list();
|
||||
$replacements[$original] = $sanitize ? check_plain($countries[$address['country']]) : $countries[$address['country']];
|
||||
break;
|
||||
|
||||
case 'country-code':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['country']) : $address['country'];
|
||||
break;
|
||||
|
||||
case 'administrative-area':
|
||||
// If we received format handlers in the data array, generate the form
|
||||
// for the address field to see if the administrative area should be
|
||||
// expanded from an abbreviation to a related name.
|
||||
$administrative_area = $address['administrative_area'];
|
||||
|
||||
if (!empty($data['format_handlers'])) {
|
||||
$form = addressfield_generate($address, $data['format_handlers'], array('mode' => 'form'));
|
||||
|
||||
if (!empty($form['locality_block']['administrative_area']['#options'][$administrative_area])) {
|
||||
$administrative_area = $form['locality_block']['administrative_area']['#options'][$administrative_area];
|
||||
}
|
||||
}
|
||||
|
||||
$replacements[$original] = $sanitize ? check_plain($administrative_area) : $administrative_area;
|
||||
break;
|
||||
|
||||
case 'administrative-area-raw':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['administrative_area']) : $address['administrative_area'];
|
||||
break;
|
||||
|
||||
case 'locality':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['locality']) : $address['locality'];
|
||||
break;
|
||||
|
||||
case 'postal-code':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['postal_code']) : $address['postal_code'];
|
||||
break;
|
||||
|
||||
case 'thoroughfare':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['thoroughfare']) : $address['thoroughfare'];
|
||||
break;
|
||||
|
||||
case 'premise':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['premise']) : $address['premise'];
|
||||
break;
|
||||
|
||||
case 'sub_premise':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['sub_premise']) : $address['sub_premise'];
|
||||
break;
|
||||
|
||||
case 'organisation':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['organisation_name']) : $address['organisation_name'];
|
||||
break;
|
||||
|
||||
case 'name-line':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['name_line']) : $address['name_line'];
|
||||
break;
|
||||
|
||||
case 'first-name':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['first_name']) : $address['first_name'];
|
||||
break;
|
||||
|
||||
case 'last-name':
|
||||
$replacements[$original] = $sanitize ? check_plain($address['last_name']) : $address['last_name'];
|
||||
break;
|
||||
|
||||
// See: http://kb.mailchimp.com/article/how-do-i-format-my-list-fields-to-import-them
|
||||
case 'format-mailchimp':
|
||||
$components = array();
|
||||
|
||||
foreach (array('thoroughfare', 'premise', 'locality', 'administrative_area', 'postal_code', 'country') as $component) {
|
||||
if (!empty($address[$component])) {
|
||||
$components[] = $address[$component];
|
||||
}
|
||||
}
|
||||
|
||||
$format_mailchimp = implode(' ', $components);
|
||||
$replacements[$original] = $sanitize ? check_plain($format_mailchimp) : $format_mailchimp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The Token module extends direct token generation by using a generic entity
|
||||
// token generation process. Since we intend to overwrite the default Token
|
||||
// module implementation of address field tokens, we use this generic token
|
||||
// generation process to find and replace address field tokens on relevant
|
||||
// entities. This ensures our tokens aren't overwritten by the Token module
|
||||
// and helps us avoid having to do the entity detection ourselves.
|
||||
if ($type == 'entity') {
|
||||
// Loop over the address fields defined on the site.
|
||||
foreach (addressfield_get_address_fields($data['entity_type']) as $field_name => $field) {
|
||||
// If the current field is on the matching entity type...
|
||||
if (!empty($field['bundles'][$data['entity_type']])) {
|
||||
// Extract the format handlers selected in a representative instance
|
||||
// settings form for use in formatting tokens.
|
||||
$instance = field_info_instance($data['entity_type'], $field_name, reset($field['bundles'][$data['entity_type']]));
|
||||
$format_handlers = $instance['widget']['settings']['format_handlers'];
|
||||
}
|
||||
|
||||
foreach (array($field_name, strtr($field_name, '_', '-')) as $prefix) {
|
||||
// If there are any address field tokens in the token list...
|
||||
$addressfield_tokens = token_find_with_prefix($tokens, $prefix);
|
||||
|
||||
if (!$addressfield_tokens) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property_exists($data['entity'], $field_name)) {
|
||||
// Generate the necessary address field tokens for the entity.
|
||||
$replacements += token_generate('address-field', $addressfield_tokens, array('address-field' => $data['entity']->$field_name, 'format_handlers' => $format_handlers), $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $replacements;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
name = Address Field Example
|
||||
description = Example module for how to implement an addressfield format handler.
|
||||
core = 7.x
|
||||
package = Fields
|
||||
hidden = TRUE
|
||||
|
||||
dependencies[] = ctools
|
||||
dependencies[] = addressfield
|
||||
|
||||
; Information added by Drupal.org packaging script on 2018-10-26
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "addressfield"
|
||||
datestamp = "1540579391"
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_directory().
|
||||
*/
|
||||
function addressfield_example_ctools_plugin_directory($module, $plugin) {
|
||||
if ($module == 'addressfield') {
|
||||
return 'plugins/' . $plugin;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hide the administrative area field.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Hide the administrative area'),
|
||||
'format callback' => 'addressfield_format_address_hide_administrative_area',
|
||||
'type' => 'address',
|
||||
'weight' => -84,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_address_hide_administrative_area(&$format, $address, $context = array()) {
|
||||
if (isset($format['locality_block']['administrative_area'])) {
|
||||
$format['locality_block']['administrative_area']['#access'] = FALSE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hide the country when only one country is available.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Hide the country when only one is available'),
|
||||
'format callback' => 'addressfield_format_address_hide_country',
|
||||
'type' => 'address',
|
||||
'weight' => -80,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_address_hide_country(&$format, $address, $context = array()) {
|
||||
// Hide the country element only if the whole field is required, otherwise
|
||||
// there will always be an additional None option.
|
||||
if ($context['mode'] == 'form' && (empty($context['instance']) || $context['instance']['required'])) {
|
||||
if (!empty($format['country']['#options']) && count($format['country']['#options']) == 1) {
|
||||
$format['country']['#access'] = FALSE;
|
||||
}
|
||||
}
|
||||
elseif ($context['mode'] == 'render') {
|
||||
// However, in render mode, the element does not have an #options list, so
|
||||
// we look instead in the field instance settings if given. If we find a
|
||||
// single country option and it matches the country of the current address,
|
||||
// go ahead and hide it.
|
||||
if (!empty($context['instance']['widget']['settings']['available_countries']) &&
|
||||
count($context['instance']['widget']['settings']['available_countries']) == 1) {
|
||||
if (isset($context['instance']['widget']['settings']['available_countries'][$address['country']])) {
|
||||
$format['country']['#access'] = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hide the locality field.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Hide the locality'),
|
||||
'format callback' => 'addressfield_format_address_hide_locality',
|
||||
'type' => 'address',
|
||||
'weight' => -84,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_address_hide_locality(&$format, $address, $context = array()) {
|
||||
if (isset($format['locality_block']['locality'])) {
|
||||
$format['locality_block']['locality']['#access'] = FALSE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hide the postal code field.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Hide the postal code'),
|
||||
'format callback' => 'addressfield_format_address_hide_postal_code',
|
||||
'type' => 'address',
|
||||
'weight' => -85,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_address_hide_postal_code(&$format, $address, $context = array()) {
|
||||
if (isset($format['locality_block']['postal_code'])) {
|
||||
$format['locality_block']['postal_code']['#access'] = FALSE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hide the street address fields.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Hide the street address'),
|
||||
'format callback' => 'addressfield_format_address_hide_street',
|
||||
'type' => 'address',
|
||||
'weight' => -85,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_address_hide_street(&$format, $address, $context = array()) {
|
||||
if (isset($format['street_block'])) {
|
||||
$format['street_block']['#access'] = FALSE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Make all fields optional.
|
||||
* Allows users to save incomplete addresses, bypassing validation.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Make all fields optional (No validation - unsuitable for postal purposes)'),
|
||||
'format callback' => 'addressfield_format_address_optional',
|
||||
'type' => 'address',
|
||||
'weight' => 100,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_address_optional(&$format, $address, $context = array()) {
|
||||
if (isset($format['name_block'])) {
|
||||
if (isset($format['name_block']['name_line'])) {
|
||||
$format['name_block']['name_line']['#required'] = FALSE;
|
||||
}
|
||||
elseif (isset($format['name_block']['first_name'])) {
|
||||
$format['name_block']['first_name']['#required'] = FALSE;
|
||||
$format['name_block']['last_name']['#required'] = FALSE;
|
||||
}
|
||||
}
|
||||
$format['street_block']['thoroughfare']['#required'] = FALSE;
|
||||
$format['locality_block']['postal_code']['#required'] = FALSE;
|
||||
$format['locality_block']['dependent_locality']['#required'] = FALSE;
|
||||
$format['locality_block']['locality']['#required'] = FALSE;
|
||||
$format['locality_block']['administrative_area']['#required'] = FALSE;
|
||||
}
|
|
@ -0,0 +1,297 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* The default format for adresses.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Address form (country-specific)'),
|
||||
'format callback' => 'addressfield_format_address_generate',
|
||||
'type' => 'address',
|
||||
'weight' => -100,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_address_generate(&$format, $address, $context = array()) {
|
||||
// Load the predefined address format for the selected country.
|
||||
module_load_include('inc', 'addressfield', 'addressfield.address_formats');
|
||||
$address_format = addressfield_get_address_format($address['country']);
|
||||
|
||||
// Used to move certain fields to their own row.
|
||||
$clearfix = '<div class="clearfix"></div>';
|
||||
|
||||
// The street block.
|
||||
$format['street_block'] = array(
|
||||
'#type' => 'addressfield_container',
|
||||
'#attributes' => array(
|
||||
'class' => array('street-block'),
|
||||
),
|
||||
'#weight' => 0,
|
||||
);
|
||||
$format['street_block']['thoroughfare'] = array(
|
||||
'#title' => t('Address 1'),
|
||||
'#tag' => 'div',
|
||||
'#attributes' => array(
|
||||
'class' => array('thoroughfare'),
|
||||
'autocomplete' => 'address-line1',
|
||||
),
|
||||
'#size' => 30,
|
||||
'#maxlength' => 255,
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$format['street_block']['premise'] = array(
|
||||
'#title' => t('Address 2'),
|
||||
'#tag' => 'div',
|
||||
'#attributes' => array(
|
||||
'class' => array('premise'),
|
||||
'autocomplete' => 'address-line2',
|
||||
),
|
||||
'#size' => 30,
|
||||
'#maxlength' => 255,
|
||||
);
|
||||
$format['locality_block'] = array(
|
||||
'#type' => 'addressfield_container',
|
||||
'#attributes' => array(
|
||||
'class' => array('addressfield-container-inline', 'locality-block', 'country-' . $address['country']),
|
||||
),
|
||||
'#weight' => 50,
|
||||
'#maxlength' => 255,
|
||||
);
|
||||
$format['locality_block']['#attached']['css'][] = drupal_get_path('module', 'addressfield') . '/addressfield.css';
|
||||
$format['locality_block']['postal_code'] = array(
|
||||
'#title' => $address_format['postal_code_label'],
|
||||
'#required' => in_array('postal_code', $address_format['required_fields']),
|
||||
'#access' => in_array('postal_code', $address_format['used_fields']),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 255,
|
||||
'#attributes' => array(
|
||||
'class' => array('postal-code'),
|
||||
'autocomplete' => 'postal-code',
|
||||
),
|
||||
);
|
||||
$format['locality_block']['dependent_locality'] = array(
|
||||
'#title' => $address_format['dependent_locality_label'],
|
||||
'#required' => in_array('dependent_locality', $address_format['required_fields']),
|
||||
'#access' => in_array('dependent_locality', $address_format['used_fields']),
|
||||
'#size' => 25,
|
||||
'#maxlength' => 255,
|
||||
'#tag' => 'div',
|
||||
'#attributes' => array(
|
||||
'class' => array('dependent-locality'),
|
||||
'autocomplete' => 'address-level3',
|
||||
),
|
||||
// Most formats place this field in its own row.
|
||||
'#suffix' => $clearfix,
|
||||
);
|
||||
$format['locality_block']['locality'] = array(
|
||||
'#title' => $address_format['locality_label'],
|
||||
'#required' => in_array('locality', $address_format['required_fields']),
|
||||
'#access' => in_array('locality', $address_format['used_fields']),
|
||||
'#size' => 30,
|
||||
'#maxlength' => 255,
|
||||
'#prefix' => ' ',
|
||||
'#attributes' => array(
|
||||
'class' => array('locality'),
|
||||
'autocomplete' => 'address-level2',
|
||||
),
|
||||
);
|
||||
$format['locality_block']['administrative_area'] = array(
|
||||
'#title' => $address_format['administrative_area_label'],
|
||||
'#required' => in_array('administrative_area', $address_format['required_fields']),
|
||||
'#access' => in_array('administrative_area', $address_format['used_fields']),
|
||||
'#empty_value' => '',
|
||||
'#size' => 10,
|
||||
'#maxlength' => 255,
|
||||
'#prefix' => ' ',
|
||||
'#render_option_value' => $address_format['render_administrative_area_value'],
|
||||
'#attributes' => array(
|
||||
'class' => array('state'),
|
||||
'autocomplete' => 'address-level1',
|
||||
),
|
||||
);
|
||||
$format['country'] = array(
|
||||
'#title' => t('Country'),
|
||||
'#options' => _addressfield_country_options_list(),
|
||||
'#render_option_value' => TRUE,
|
||||
'#required' => TRUE,
|
||||
'#attributes' => array(
|
||||
'class' => array('country'),
|
||||
'autocomplete' => 'country',
|
||||
),
|
||||
'#weight' => 100,
|
||||
);
|
||||
|
||||
if (empty($format['locality_block']['postal_code']['#access'])) {
|
||||
// Remove the prefix from the first widget of the block.
|
||||
$element_children = element_children($format['locality_block']);
|
||||
$first_child = reset($element_children);
|
||||
unset($format['locality_block'][$first_child]['#prefix']);
|
||||
}
|
||||
|
||||
if (!empty($format['locality_block']['administrative_area']['#access'])) {
|
||||
// Set the predefined administrative areas, if found.
|
||||
module_load_include('inc', 'addressfield', 'addressfield.administrative_areas');
|
||||
$administrative_areas = addressfield_get_administrative_areas($address['country']);
|
||||
$format['locality_block']['administrative_area']['#options'] = $administrative_areas;
|
||||
}
|
||||
|
||||
// Country-specific customizations.
|
||||
if (in_array($address['country'], array('AU', 'EE', 'LT', 'LV', 'NZ', 'RU'))) {
|
||||
// These countries don't use the "Address 2" line.
|
||||
// Leave it as a precaution, but hide the label to avoid confusing users.
|
||||
$format['street_block']['thoroughfare']['#title'] = t('Address');
|
||||
$format['street_block']['premise']['#title_display'] = 'invisible';
|
||||
}
|
||||
elseif ($address['country'] == 'US') {
|
||||
if ($context['mode'] == 'render') {
|
||||
$format['locality_block']['locality']['#suffix'] = ',';
|
||||
}
|
||||
}
|
||||
elseif ($address['country'] == 'BR') {
|
||||
$format['locality_block']['dependent_locality']['#suffix'] = $clearfix;
|
||||
$format['locality_block']['dependent_locality']['#tag'] = 'div';
|
||||
$format['locality_block']['administrative_area']['#suffix'] = $clearfix;
|
||||
$format['locality_block']['postal_code']['#tag'] = 'div';
|
||||
// Change some titles to make translation easier.
|
||||
$format['street_block']['#attributes'] = array(
|
||||
'class' => array('addressfield-container-inline'),
|
||||
);
|
||||
$format['street_block']['thoroughfare']['#title'] = t('Thoroughfare');
|
||||
$format['street_block']['thoroughfare']['#tag'] = NULL;
|
||||
$format['street_block']['premise'] = array(
|
||||
'#title' => t('Complement'),
|
||||
'#tag' => NULL,
|
||||
'#attributes' => array('class' => array('premise')),
|
||||
'#size' => 20,
|
||||
'#maxlength' => 255,
|
||||
'#prefix' => ', ',
|
||||
);
|
||||
$format['locality_block']['locality']['#suffix'] = ' - ';
|
||||
// Hide suffixes and prefixes while in form.
|
||||
if ($context['mode'] == 'form') {
|
||||
$format['street_block']['premise']['#prefix'] = NULL;
|
||||
$format['street_block']['premise']['#suffix'] = NULL;
|
||||
$format['locality_block']['locality']['#suffix'] = NULL;
|
||||
}
|
||||
}
|
||||
elseif ($address['country'] == 'CN') {
|
||||
$format['locality_block']['locality']['#suffix'] = $clearfix;
|
||||
}
|
||||
elseif ($address['country'] == 'CA') {
|
||||
if ($context['mode'] == 'render') {
|
||||
$format['locality_block']['locality']['#suffix'] = ',';
|
||||
}
|
||||
}
|
||||
elseif ($address['country'] == 'GB') {
|
||||
$format['locality_block']['administrative_area']['#size'] = '30';
|
||||
}
|
||||
elseif ($address['country'] == 'ID') {
|
||||
$format['locality_block']['administrative_area']['#weight'] = 1;
|
||||
}
|
||||
elseif ($address['country'] == 'JP') {
|
||||
$format['locality_block']['#weight'] = 10;
|
||||
$format['locality_block']['postal_code']['#weight'] = 10;
|
||||
$format['locality_block']['postal_code']['#tag'] = 'div';
|
||||
$format['locality_block']['postal_code']['#size'] = 30;
|
||||
$format['locality_block']['administrative_area']['#weight'] = 20;
|
||||
$format['locality_block']['administrative_area']['#size'] = 30;
|
||||
$format['locality_block']['locality']['#weight'] = 30;
|
||||
$format['street_block']['#weight'] = 20;
|
||||
}
|
||||
elseif ($address['country'] == 'PE') {
|
||||
$format['locality_block']['administrative_area']['#weight'] = 1;
|
||||
$format['locality_block']['locality']['#weight'] = 2;
|
||||
}
|
||||
elseif ($address['country'] == 'PH' || $address['country'] == 'TH') {
|
||||
$format['locality_block']['dependent_locality']['#suffix'] = '';
|
||||
$format['locality_block']['locality']['#suffix'] = $clearfix;
|
||||
}
|
||||
|
||||
// These countries show every field in its own row.
|
||||
$countries_field_per_row = array(
|
||||
'AM', 'EG', 'FK', 'GB', 'GG', 'GS', 'HK', 'HU', 'IE', 'IM', 'IO', 'JE', 'JM',
|
||||
'JP', 'KE', 'KR', 'KZ', 'LK', 'PA', 'PN', 'RU', 'SC', 'SH', 'SZ', 'TC', 'UA',
|
||||
'VG', 'ZA',
|
||||
);
|
||||
if (in_array($address['country'], $countries_field_per_row)) {
|
||||
$format['locality_block']['#attributes']['class'][0] = 'addressfield-container';
|
||||
$format['locality_block']['postal_code']['#prefix'] = '';
|
||||
$format['locality_block']['postal_code']['#tag'] = 'div';
|
||||
$format['locality_block']['locality']['#prefix'] = '';
|
||||
$format['locality_block']['locality']['#tag'] = 'div';
|
||||
$format['locality_block']['administrative_area']['#prefix'] = '';
|
||||
$format['locality_block']['administrative_area']['#tag'] = 'div';
|
||||
}
|
||||
|
||||
// These countries tend to put the postal code after the locality.
|
||||
$countries_postal_code_after_locality = array(
|
||||
'AS', 'AU', 'BD', 'BF', 'BH', 'BM', 'BN', 'BR', 'BT', 'CA', 'CC', 'CN', 'CX',
|
||||
'EG', 'FK', 'FM', 'GB', 'GG', 'GS', 'GU', 'HN', 'HU', 'ID', 'IL', 'IM', 'IN',
|
||||
'IO', 'IQ', 'IR', 'JE', 'JO', 'JP', 'KE', 'KH', 'KR', 'LB', 'LK', 'LS', 'LV',
|
||||
'MH', 'MM', 'MN', 'MP', 'MT', 'MV', 'MX', 'MY', 'NF', 'NG', 'NP', 'NZ', 'PG',
|
||||
'PH', 'PK', 'PN', 'PR', 'PW', 'RU', 'SA', 'SH', 'SO', 'SZ', 'TC', 'TH', 'TW',
|
||||
'UA', 'UM', 'US', 'VE', 'VI', 'VG', 'VN', 'ZA',
|
||||
);
|
||||
if (in_array($address['country'], $countries_postal_code_after_locality)) {
|
||||
// Take the widget out of the array.
|
||||
$postal_code_widget = $format['locality_block']['postal_code'];
|
||||
|
||||
// If the postal code not in its own row, add a separating space.
|
||||
if (empty($postal_code_widget['#tag'])) {
|
||||
$postal_code_widget['#prefix'] = ' ';
|
||||
}
|
||||
|
||||
unset($format['locality_block']['postal_code']);
|
||||
|
||||
// Add it back.
|
||||
$format['locality_block']['postal_code'] = $postal_code_widget;
|
||||
|
||||
// Remove the prefix from the first widget of the block.
|
||||
$element_children = element_children($format['locality_block']);
|
||||
$first_child = reset($element_children);
|
||||
unset($format['locality_block'][$first_child]['#prefix']);
|
||||
}
|
||||
|
||||
if ($context['mode'] == 'form') {
|
||||
// Provide a wrapper ID for AJAX replacement based on country selection.
|
||||
if (!isset($format['#wrapper_id'])) {
|
||||
$format['#wrapper_id'] = drupal_html_id('addressfield-wrapper');
|
||||
$format['#prefix'] = '<div id="' . $format['#wrapper_id'] . '">';
|
||||
$format['#suffix'] = '</div>';
|
||||
}
|
||||
// AJAX enable it.
|
||||
$format['country']['#ajax'] = array(
|
||||
'callback' => 'addressfield_standard_widget_refresh',
|
||||
'wrapper' => $format['#wrapper_id'],
|
||||
);
|
||||
$format['country']['#element_validate'] = array('addressfield_standard_country_validate');
|
||||
// Don't validate any element when the country is changed.
|
||||
$format['country']['#limit_validation_errors'] = array();
|
||||
|
||||
// Move the country selector to the top of the form.
|
||||
$format['country']['#weight'] = -500;
|
||||
// Limit it to the countries supported by the widget.
|
||||
if (isset($context['field'])) {
|
||||
$format['country']['#options'] = _addressfield_country_options_list($context['field'], $context['instance']);
|
||||
}
|
||||
|
||||
// The whole field is considered empty if the country column is empty.
|
||||
// Therefore, if the field is optional, allow the country to be optional.
|
||||
// The same logic applies if the field allows multiple values, in which case
|
||||
// only the first delta needs to have a value.
|
||||
if (empty($context['instance']['required']) || (isset($context['delta']) && $context['delta'] > 0)) {
|
||||
$format['country']['#required'] = FALSE;
|
||||
$format['country']['#empty_value'] = '';
|
||||
// Hide all other fields until the country is selected.
|
||||
if (empty($address['country'])) {
|
||||
$format['street_block']['#access'] = FALSE;
|
||||
$format['locality_block']['#access'] = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Generates a first name + last name format.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Name (First name, Last name)'),
|
||||
'format callback' => 'addressfield_format_name_full_generate',
|
||||
'type' => 'name',
|
||||
'weight' => 0,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_name_full_generate(&$format, $address) {
|
||||
$format['name_block'] = array(
|
||||
'#type' => 'addressfield_container',
|
||||
'#attributes' => array(
|
||||
'class' => array('addressfield-container-inline', 'name-block'),
|
||||
),
|
||||
'#weight' => -100,
|
||||
// The addressfield is considered empty without a country, hide all fields
|
||||
// until one is selected.
|
||||
'#access' => !empty($address['country']),
|
||||
);
|
||||
// Maxlength is set to 127 so that the name_line still can be created without
|
||||
// exceeding the char limit from the database.
|
||||
$format['name_block']['first_name'] = array(
|
||||
'#title' => t('First name'),
|
||||
'#size' => 30,
|
||||
'#maxlength' => 127,
|
||||
'#required' => TRUE,
|
||||
'#attributes' => array(
|
||||
'class' => array('first-name'),
|
||||
'autocomplete' => 'given-name',
|
||||
),
|
||||
);
|
||||
$format['name_block']['last_name'] = array(
|
||||
'#title' => t('Last name'),
|
||||
'#size' => 30,
|
||||
'#maxlength' => 127,
|
||||
'#required' => TRUE,
|
||||
'#prefix' => ' ',
|
||||
'#attributes' => array(
|
||||
'class' => array('last-name'),
|
||||
'autocomplete' => 'family-name',
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Generates a first name + last name format.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Name (single line)'),
|
||||
'format callback' => 'addressfield_format_name_oneline_generate',
|
||||
'type' => 'name',
|
||||
'weight' => 0,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_name_oneline_generate(&$format, $address) {
|
||||
$format['name_block'] = array(
|
||||
'#type' => 'addressfield_container',
|
||||
'#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
|
||||
'#weight' => -100,
|
||||
// The addressfield is considered empty without a country, hide all fields
|
||||
// until one is selected.
|
||||
'#access' => !empty($address['country']),
|
||||
);
|
||||
$format['name_block']['name_line'] = array(
|
||||
'#title' => t('Full name'),
|
||||
'#tag' => 'div',
|
||||
'#attributes' => array(
|
||||
'class' => array('name-block'),
|
||||
'autocomplete' => 'name',
|
||||
),
|
||||
'#size' => 30,
|
||||
'#maxlength' => 255,
|
||||
'#required' => TRUE,
|
||||
);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Generates a first name + last name format.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Organisation (single line)'),
|
||||
'format callback' => 'addressfield_format_organisation_generate',
|
||||
'type' => 'organisation',
|
||||
'weight' => -10,
|
||||
);
|
||||
|
||||
/**
|
||||
* Format callback.
|
||||
*
|
||||
* @see CALLBACK_addressfield_format_callback()
|
||||
*/
|
||||
function addressfield_format_organisation_generate(&$format, $address) {
|
||||
$format['organisation_block'] = array(
|
||||
'#type' => 'addressfield_container',
|
||||
'#attributes' => array('class' => array('addressfield-container-inline', 'organisation-block')),
|
||||
'#weight' => -50,
|
||||
// The addressfield is considered empty without a country, hide all fields
|
||||
// until one is selected.
|
||||
'#access' => !empty($address['country']),
|
||||
);
|
||||
$format['organisation_block']['organisation_name'] = array(
|
||||
'#title' => t('Company'),
|
||||
'#size' => 30,
|
||||
'#maxlength' => 255,
|
||||
'#attributes' => array(
|
||||
'class' => array('organisation-name'),
|
||||
'autocomplete' => 'organization',
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_field_views_data().
|
||||
*/
|
||||
function addressfield_field_views_data($field) {
|
||||
$data = field_views_field_default_views_data($field);
|
||||
|
||||
// Add a filter handler for countries.
|
||||
$key = key($field['storage']['details']);
|
||||
foreach ($field['storage']['details'][$key] as $type => $tables) {
|
||||
foreach ($tables as $table_name => $columns) {
|
||||
if (!isset($columns['country'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$column_real_name = $columns['country'];
|
||||
if (!isset($data[$table_name][$column_real_name]['filter'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data[$table_name][$column_real_name]['filter']['handler'] = 'addressfield_views_handler_filter_country';
|
||||
}
|
||||
}
|
||||
|
||||
// Only expose these components as Views field handlers.
|
||||
$implemented = array(
|
||||
'country' => 'addressfield_views_handler_field_country',
|
||||
'administrative_area' => 'addressfield_views_handler_field_administrative_area',
|
||||
'sub_administrative_area' => 'views_handler_field',
|
||||
'dependent_locality' => 'views_handler_field',
|
||||
'locality' => 'views_handler_field',
|
||||
'postal_code' => 'views_handler_field',
|
||||
'thoroughfare' => 'views_handler_field',
|
||||
'premise' => 'views_handler_field',
|
||||
'sub_premise' => 'views_handler_field',
|
||||
'organisation_name' => 'views_handler_field',
|
||||
'name_line' => 'views_handler_field',
|
||||
'first_name' => 'views_handler_field',
|
||||
'last_name' => 'views_handler_field',
|
||||
'data' => 'views_handler_field_serialized',
|
||||
);
|
||||
|
||||
// Get the translated field information.
|
||||
$properties = addressfield_data_property_info();
|
||||
|
||||
// Iterate over addressfield defined tables.
|
||||
foreach ($data as &$table) {
|
||||
// Make sure the parent Views field (addressfield) is defined.
|
||||
if (isset($table[$field['field_name']]['field'])) {
|
||||
// Use the parent field definition as a template for component columns.
|
||||
$field_def = $table[$field['field_name']]['field'];
|
||||
|
||||
// Remove 'additional fields' from the field definition. We don't
|
||||
// necessarily want all our sibling columns.
|
||||
unset($field_def['additional fields']);
|
||||
|
||||
// Define the valid columns.
|
||||
$valid_columns = array();
|
||||
foreach ($implemented as $implement => $handler) {
|
||||
$column_name = $field['field_name'] . '_' . $implement;
|
||||
$valid_columns[$column_name] = $handler;
|
||||
}
|
||||
|
||||
// Iterate over the addressfield components.
|
||||
foreach ($table as $column_name => &$column) {
|
||||
if (empty($column['field']) && isset($valid_columns[$column_name])) {
|
||||
// Assign the default component definition.
|
||||
$column['field'] = $field_def;
|
||||
$column['field']['real field'] = $column_name;
|
||||
$column['field']['handler'] = $valid_columns[$column_name];
|
||||
|
||||
// Assign human-friendly field labels for addressfield components.
|
||||
$field_labels = field_views_field_label($field['field_name']);
|
||||
$field_label = array_shift($field_labels);
|
||||
$property = str_replace($field_def['field_name'] . '_', '', $column_name);
|
||||
|
||||
if (!empty($properties[$property])) {
|
||||
$property_label = $properties[$property]['label'];
|
||||
|
||||
$title = t('@field-label - @property-label', array(
|
||||
'@field-label' => $field_label,
|
||||
'@property-label' => $property_label,
|
||||
));
|
||||
|
||||
$column['title'] = $title;
|
||||
$column['title short'] = $title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Defines a field handler that can display the administrative area name
|
||||
* instead of the code.
|
||||
*/
|
||||
class addressfield_views_handler_field_administrative_area extends views_handler_field {
|
||||
|
||||
function query() {
|
||||
parent::query();
|
||||
|
||||
$this->country_alias = $this->query->add_field($this->table_alias, $this->definition['field_name'] . '_country');
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['display_name'] = array('default' => TRUE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['display_name'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the name of administrative area instead of the code.'),
|
||||
'#default_value' => $this->options['display_name'],
|
||||
);
|
||||
}
|
||||
|
||||
function get_value($values, $field = NULL) {
|
||||
$value = parent::get_value($values, $field);
|
||||
|
||||
// If we have a value for the field, look for the administrative area name in the
|
||||
// Address Field options list array if specified.
|
||||
if (!empty($value) && !empty($this->options['display_name'])) {
|
||||
module_load_include('inc', 'addressfield', 'addressfield.administrative_areas');
|
||||
$country = $values->{$this->country_alias};
|
||||
$areas = addressfield_get_administrative_areas($country);
|
||||
|
||||
if (!empty($areas[$value])) {
|
||||
$value = $areas[$value];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Defines a field handler that can display the country name instead of the two
|
||||
* character country code for an address field country value.
|
||||
*/
|
||||
class addressfield_views_handler_field_country extends views_handler_field {
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['display_name'] = array('default' => TRUE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['display_name'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the localized country name instead of the two character country code'),
|
||||
'#default_value' => $this->options['display_name'],
|
||||
);
|
||||
}
|
||||
|
||||
function get_value($values, $field = NULL) {
|
||||
$value = parent::get_value($values, $field);
|
||||
|
||||
// If we have a value for the field, look for the country name in the
|
||||
// Address Field options list array if specified.
|
||||
if (!empty($value) && !empty($this->options['display_name'])) {
|
||||
$countries = _addressfield_country_options_list();
|
||||
|
||||
if (!empty($countries[$value])) {
|
||||
$value = $countries[$value];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
class addressfield_views_handler_filter_country extends views_handler_filter_in_operator {
|
||||
function get_value_options() {
|
||||
$this->value_title = t('Country');
|
||||
$field = field_info_field($this->definition['field_name']);
|
||||
$this->value_options = _addressfield_country_options_list($field);
|
||||
}
|
||||
}
|
54
drupal7/web/sites/all/modules/contrib/ctools/API.txt
Normal file
54
drupal7/web/sites/all/modules/contrib/ctools/API.txt
Normal file
|
@ -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.
|
339
drupal7/web/sites/all/modules/contrib/ctools/LICENSE.txt
Normal file
339
drupal7/web/sites/all/modules/contrib/ctools/LICENSE.txt
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
78
drupal7/web/sites/all/modules/contrib/ctools/README.txt
Normal file
78
drupal7/web/sites/all/modules/contrib/ctools/README.txt
Normal file
|
@ -0,0 +1,78 @@
|
|||
CONTENTS OF THIS FILE
|
||||
---------------------
|
||||
|
||||
* Introduction
|
||||
* Requirements
|
||||
* Recommended Modules
|
||||
* Installation
|
||||
* Configuration
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
------------
|
||||
|
||||
The Chaos tool suite (ctools) module is primarily a set of APIs and tools to
|
||||
improve the developer experience. It also contains a module called the Page
|
||||
Manager whose job is to manage pages. In particular it manages panel pages, but
|
||||
as it grows it will be able to manage far more than just Panels.
|
||||
|
||||
The Chaos Tool Suite (ctools) is a series of tools that makes code readily
|
||||
available for developers and creates libraries for other modules to use. Modules
|
||||
that use ctools include Views and Panels.
|
||||
|
||||
End users will use ctools as underlying user interface libraries when operating
|
||||
Views and Panels modules and will not need to explore further (ctools is geared
|
||||
more toward developer usage). Developers will use the module differently and
|
||||
work more with the tools provided.
|
||||
|
||||
For the moment, it includes the following tools:
|
||||
|
||||
* Plugins -- tools to make it easy for modules to let other modules implement
|
||||
plugins from .inc files.
|
||||
* Exportables -- tools to make it easier for modules to have objects that live
|
||||
in database or live in code, such as 'default views'.
|
||||
* AJAX responder -- tools to make it easier for the server to handle AJAX
|
||||
requests and tell the client what to do with them.
|
||||
* Form tools -- tools to make it easier for forms to deal with AJAX.
|
||||
* Object caching -- tool to make it easier to edit an object across multiple
|
||||
page requests and cache the editing work.
|
||||
* Contexts -- the notion of wrapping objects in a unified wrapper and providing
|
||||
an API to create and accept these contexts as input.
|
||||
* Modal dialog -- tool to make it simple to put a form in a modal dialog.
|
||||
* Dependent -- a simple form widget to make form items appear and disappear
|
||||
based upon the selections in another item.
|
||||
* Content -- pluggable content types used as panes in Panels and other modules
|
||||
like Dashboard.
|
||||
* Form wizard -- an API to make multi-step forms much easier.
|
||||
* CSS tools -- tools to cache and sanitize CSS easily to make user-input CSS
|
||||
safe.
|
||||
|
||||
* For a full description of the module visit:
|
||||
https://www.drupal.org/project/ctools
|
||||
|
||||
* To submit bug reports and feature suggestions, or to track changes visit:
|
||||
https://www.drupal.org/project/issues/ctools
|
||||
|
||||
|
||||
REQUIREMENTS
|
||||
------------
|
||||
|
||||
This module requires no modules outside of Drupal core.
|
||||
|
||||
|
||||
RECOMMENDED MODULES
|
||||
-------------------
|
||||
|
||||
The Advanced help module provides extended documentation. Once enabled,
|
||||
navigate to Administration > Advanced Help and select the Chaos tools link to
|
||||
view documentation.
|
||||
|
||||
* Advanced help - https://www.drupal.org/project/advanced_help
|
||||
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
* Install the Chaos tool suite module as you would normally install a
|
||||
contributed Drupal module. Visit https://www.drupal.org/node/895232 for
|
||||
further information.
|
63
drupal7/web/sites/all/modules/contrib/ctools/UPGRADE.txt
Normal file
63
drupal7/web/sites/all/modules/contrib/ctools/UPGRADE.txt
Normal file
|
@ -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.
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
name = Bulk Export
|
||||
description = Performs bulk exporting of data objects known about by Chaos tools.
|
||||
core = 7.x
|
||||
dependencies[] = ctools:ctools
|
||||
package = Chaos tool suite
|
||||
|
||||
; Information added by Drupal.org packaging script on 2023-01-31
|
||||
version = "7.x-1.21"
|
||||
core = "7.x"
|
||||
project = "ctools"
|
||||
datestamp = "1675152418"
|
|
@ -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);
|
|
@ -0,0 +1,278 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Perform bulk exports.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function bulk_export_permission() {
|
||||
return array(
|
||||
'use bulk exporter' => 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 = "<?php\n\n";
|
||||
$code .= "/**\n";
|
||||
$code .= " * @file\n";
|
||||
$code .= " * Bulk export of $api objects generated by Bulk export module.\n";
|
||||
$code .= " */\n\n";
|
||||
$code .= $info['code'];
|
||||
if ($cli) {
|
||||
$file_data[$file] = $code;
|
||||
}
|
||||
else {
|
||||
$export_form = drupal_get_form('ctools_export_form', $code, t('Place this in @file', array('@file' => $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 = "<?php\n\n";
|
||||
$module .= "/**\n";
|
||||
$module .= " * @file\n";
|
||||
$module .= " * Bulk export of objects generated by Bulk export module.\n";
|
||||
$module .= " */\n";
|
||||
$module .= $module_code;
|
||||
if ($cli) {
|
||||
$file_data[$module_name . '.module'] = $module;
|
||||
}
|
||||
else {
|
||||
$export_form = drupal_get_form('ctools_export_form', $module, t('Place this in @file', array('@file' => $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' => '<div class="export-container">',
|
||||
'#suffix' => '</div>',
|
||||
'#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;
|
||||
}
|
30
drupal7/web/sites/all/modules/contrib/ctools/css/button.css
Normal file
30
drupal7/web/sites/all/modules/contrib/ctools/css/button.css
Normal file
|
@ -0,0 +1,30 @@
|
|||
.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: none none;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.ctools-button-processed li {
|
||||
line-height: 1.3333;
|
||||
}
|
||||
|
||||
.ctools-button li a {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
.ctools-collapsible-container .ctools-toggle {
|
||||
float: left;
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
cursor: pointer;
|
||||
background: url(../images/collapsible-expanded.png) no-repeat 7px 7px;
|
||||
}
|
||||
|
||||
.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);
|
||||
}
|
10
drupal7/web/sites/all/modules/contrib/ctools/css/context.css
Normal file
10
drupal7/web/sites/all/modules/contrib/ctools/css/context.css
Normal file
|
@ -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%;
|
||||
}
|
25
drupal7/web/sites/all/modules/contrib/ctools/css/ctools.css
Normal file
25
drupal7/web/sites/all/modules/contrib/ctools/css/ctools.css
Normal file
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
.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;
|
||||
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;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
div.ctools-modal-content {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.ctools-modal-content .modal-header {
|
||||
background-color: #2385c2;
|
||||
padding: 0 1em 0 .25em;
|
||||
}
|
||||
|
||||
div.ctools-modal-content a.close {
|
||||
color: white;
|
||||
float: left;
|
||||
}
|
||||
|
||||
/** modal forms CSS **/
|
||||
div.ctools-modal-content .form-item label {
|
||||
float: right;
|
||||
}
|
||||
|
||||
div.ctools-modal-content .form-item .description {
|
||||
clear: right;
|
||||
}
|
||||
|
||||
div.ctools-modal-content .form-item .description .tips {
|
||||
margin-left: 0;
|
||||
margin-right: 2em;
|
||||
}
|
||||
|
||||
div.ctools-modal-content fieldset,
|
||||
div.ctools-modal-content .form-radios,
|
||||
div.ctools-modal-content .form-checkboxes {
|
||||
clear: right;
|
||||
}
|
||||
|
||||
div.ctools-modal-content .resizable-textarea {
|
||||
margin-left: 5em;
|
||||
margin-right: 15em;
|
||||
}
|
||||
|
||||
div.ctools-modal-content .container-inline .form-item {
|
||||
margin-right: 0;
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
div.ctools-modal-content label.hidden-options {
|
||||
background-position: left;
|
||||
padding-right: 0;
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
div.ctools-modal-content label.expanded-options {
|
||||
background-position: left;
|
||||
padding-right: 0;
|
||||
padding-left: 16px;
|
||||
}
|
||||
|
||||
div.ctools-modal-content .dependent-options {
|
||||
padding-left: 0;
|
||||
padding-right: 30px;
|
||||
}
|
130
drupal7/web/sites/all/modules/contrib/ctools/css/modal.css
Normal file
130
drupal7/web/sites/all/modules/contrib/ctools/css/modal.css
Normal file
|
@ -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;
|
||||
}
|
11
drupal7/web/sites/all/modules/contrib/ctools/css/ruleset.css
Normal file
11
drupal7/web/sites/all/modules/contrib/ctools/css/ruleset.css
Normal file
|
@ -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%;
|
||||
}
|
129
drupal7/web/sites/all/modules/contrib/ctools/css/stylizer.css
Normal file
129
drupal7/web/sites/all/modules/contrib/ctools/css/stylizer.css
Normal file
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
.wizard-trail {
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
.wizard-trail-current {
|
||||
font-weight: bold;
|
||||
}
|
340
drupal7/web/sites/all/modules/contrib/ctools/ctools.api.php
Normal file
340
drupal7/web/sites/all/modules/contrib/ctools/ctools.api.php
Normal file
|
@ -0,0 +1,340 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hooks provided by the Chaos Tool Suite.
|
||||
*
|
||||
* This file is divided into static hooks (hooks with string literal names) and
|
||||
* dynamic hooks (hooks with pattern-derived string names).
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Inform CTools about plugin types.
|
||||
*
|
||||
* @return array
|
||||
* An array of plugin types, keyed by the type name.
|
||||
* See the advanced help topic 'plugins-creating' for details of the array
|
||||
* properties.
|
||||
*/
|
||||
function hook_ctools_plugin_type() {
|
||||
$plugins['my_type'] = array(
|
||||
'load themes' => TRUE,
|
||||
);
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells CTools where to find module-defined 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
|
||||
// <moduleroot>/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 (== 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 array $plugin
|
||||
* An associative array defining a plugin.
|
||||
* @param array $info
|
||||
* An associative array of plugin type info.
|
||||
*/
|
||||
function hook_ctools_plugin_pre_alter(array &$plugin, array &$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 array $plugin
|
||||
* An associative array defining a plugin.
|
||||
* @param array $info
|
||||
* An associative array of plugin type info.
|
||||
*/
|
||||
function hook_ctools_plugin_post_alter(array &$plugin, array &$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(array &$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 use case would be to create your own function in your module and
|
||||
* allow to use it in the math expression api.
|
||||
*
|
||||
* @param array $functions
|
||||
* An array which has the functions as value.
|
||||
* @param array $context
|
||||
* An array containing an item 'final' whose value is a reference to the
|
||||
* definitions for multiple-arg functions. Use this to add in functions that
|
||||
* require more than one arg.
|
||||
*/
|
||||
function hook_ctools_math_expression_functions_alter(array &$functions, array $context) {
|
||||
// Allow to convert from degrees to radians.
|
||||
$functions[] = 'deg2rad';
|
||||
|
||||
$multiarg = $context['final'];
|
||||
$multiarg['pow'] = array(
|
||||
'function' => 'pow',
|
||||
'arguments' => 2,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 array $constants
|
||||
* An array of name:value pairs, one for each named constant. Values added
|
||||
* to this array become read-only variables with the value assigned here.
|
||||
*/
|
||||
function hook_ctools_math_expression_constants_alter(array &$constants) {
|
||||
// Add the speed of light as constant 'c':
|
||||
$constants['c'] = 299792458;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter everything.
|
||||
*
|
||||
* @param array $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 bool $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 array $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(array &$info, &$page, array &$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) {
|
||||
// Force a particular subtype of a particular plugin to render last.
|
||||
if ($plugin['module'] === 'some_plugin_module'
|
||||
&& $plugin['name'] === 'some_plugin_name'
|
||||
&& $subtype['subtype_id'] === 'my_subtype_id'
|
||||
) {
|
||||
$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(array &$plugin, array &$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 conversion of context items by ctools context plugin convert()s.
|
||||
*
|
||||
* @param ctools_context $context
|
||||
* The current context plugin object. If this implemented a 'convert'
|
||||
* function, the value passed in has been processed by that function.
|
||||
* @param string $converter
|
||||
* A string associated with the plugin type, identifying the operation.
|
||||
* @param string $value
|
||||
* The value being converted; this is the only return from the function.
|
||||
* @param array $converter_options
|
||||
* Array of key-value pairs to pass to a converter function from higher
|
||||
* levels.
|
||||
*
|
||||
* @see ctools_context_convert_context()
|
||||
*/
|
||||
function hook_ctools_context_converter_alter(ctools_context $context, $converter, &$value, array $converter_options) {
|
||||
if ($converter === 'mystring') {
|
||||
$value = 'fixed';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(array &$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(array &$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(array &$settings) {
|
||||
// Convert all strings to lower case.
|
||||
$settings['lower case'] = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let other modules modify the context handler before it is rendered.
|
||||
*
|
||||
* @param object $handler
|
||||
* A handler for a current task and subtask.
|
||||
* @param array $contexts
|
||||
* An associative array of contexts.
|
||||
* @param array $args
|
||||
* An array for current args.
|
||||
*
|
||||
* @see ctools_context_handler_pre_render()
|
||||
*/
|
||||
function ctools_context_handler_pre_render($handler, array $contexts, array $args) {
|
||||
$handler->conf['css_id'] = 'my-id';
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup hooks".
|
||||
*/
|
26
drupal7/web/sites/all/modules/contrib/ctools/ctools.info
Normal file
26
drupal7/web/sites/all/modules/contrib/ctools/ctools.info
Normal file
|
@ -0,0 +1,26 @@
|
|||
name = Chaos tools
|
||||
description = A library of helpful tools by Merlin of Chaos.
|
||||
core = 7.x
|
||||
package = Chaos tool suite
|
||||
files[] = includes/context.inc
|
||||
files[] = includes/css-cache.inc
|
||||
files[] = includes/math-expr.inc
|
||||
files[] = includes/stylizer.inc
|
||||
|
||||
; Tests.
|
||||
files[] = tests/context.test
|
||||
files[] = tests/css.test
|
||||
files[] = tests/css_cache.test
|
||||
files[] = tests/ctools.plugins.test
|
||||
files[] = tests/ctools.test
|
||||
files[] = tests/math_expression.test
|
||||
files[] = tests/math_expression_stack.test
|
||||
files[] = tests/object_cache.test
|
||||
files[] = tests/object_cache_unit.test
|
||||
files[] = tests/page_tokens.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2023-01-31
|
||||
version = "7.x-1.21"
|
||||
core = "7.x"
|
||||
project = "ctools"
|
||||
datestamp = "1675152418"
|
299
drupal7/web/sites/all/modules/contrib/ctools/ctools.install
Normal file
299
drupal7/web/sites/all/modules/contrib/ctools/ctools.install
Normal file
|
@ -0,0 +1,299 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains install and update functions for ctools.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Use requirements to ensure that the CTools CSS cache directory can be
|
||||
* created and that the PHP version requirement is met.
|
||||
*/
|
||||
function ctools_requirements($phase) {
|
||||
$requirements = array();
|
||||
if ($phase == 'runtime') {
|
||||
$t = get_t();
|
||||
$requirements['ctools_css_cache'] = array(
|
||||
'title' => $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_4();
|
||||
}
|
||||
|
||||
/**
|
||||
* Version 4 of the CTools schema.
|
||||
*/
|
||||
function ctools_schema_4() {
|
||||
$schema = ctools_schema_3();
|
||||
|
||||
// Removed due to alternative database configuration issues.
|
||||
// @see https://www.drupal.org/project/ctools/issues/2941920
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* The 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* The 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.',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the length of the ctools_object_cache.name column to 255.
|
||||
*/
|
||||
function ctools_update_7002() {
|
||||
// Removed due to alternative database configuration issues.
|
||||
// @see https://www.drupal.org/project/ctools/issues/2941920
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert the length of the ctools_object_cache.name column back to 128.
|
||||
*/
|
||||
function ctools_update_7003() {
|
||||
db_delete('ctools_object_cache')->execute();
|
||||
db_change_field('ctools_object_cache', 'name', 'name', array(
|
||||
'type' => 'varchar',
|
||||
'length' => '128',
|
||||
'not null' => TRUE,
|
||||
'description' => 'The name of the object this cache is attached to.',
|
||||
));
|
||||
}
|
1206
drupal7/web/sites/all/modules/contrib/ctools/ctools.module
Normal file
1206
drupal7/web/sites/all/modules/contrib/ctools/ctools.module
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,11 @@
|
|||
name = Custom rulesets
|
||||
description = Create custom, exportable, reusable access rulesets for applications like Panels.
|
||||
core = 7.x
|
||||
package = Chaos tool suite
|
||||
dependencies[] = ctools:ctools
|
||||
|
||||
; Information added by Drupal.org packaging script on 2023-01-31
|
||||
version = "7.x-1.21"
|
||||
core = "7.x"
|
||||
project = "ctools"
|
||||
datestamp = "1675152418"
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/**
|
||||
* Schema for customizable access rulesets.
|
||||
*/
|
||||
function ctools_access_ruleset_schema() {
|
||||
return ctools_access_ruleset_schema_1();
|
||||
}
|
||||
|
||||
function ctools_access_ruleset_schema_1() {
|
||||
$schema = array();
|
||||
|
||||
$schema['ctools_access_ruleset'] = array(
|
||||
'description' => '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;
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* The ctools_access_ruleset module.
|
||||
*
|
||||
* This module allows styles to be created and managed on behalf of modules
|
||||
* that implement styles.
|
||||
*
|
||||
* The ctools_access_ruleset tool allows recolorable styles to be created via a miniature
|
||||
* scripting language. Panels utilizes this to allow administrators to add
|
||||
* styles directly to any panel display.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_permission()
|
||||
*/
|
||||
function ctools_access_ruleset_permission() {
|
||||
return array(
|
||||
'administer ctools access ruleset' => 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 = '<p>' . t('There are no custom rulesets.') . '</p>';
|
||||
}
|
||||
|
||||
$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',
|
||||
);
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Plugin to provide access control based on user rulesetission strings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => '',
|
||||
'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' => '<div class="description">' . check_plain($form_state['plugin']['ruleset']->admin_description) . '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for access.
|
||||
*/
|
||||
function ctools_ruleset_ctools_access_check($conf, $context, $plugin) {
|
||||
// Load up any contexts we might be using.
|
||||
$contexts = ctools_context_match_required_contexts($plugin['ruleset']->requiredcontexts, $context);
|
||||
$contexts = ctools_context_load_contexts($plugin['ruleset'], FALSE, $contexts);
|
||||
|
||||
return ctools_access($plugin['ruleset']->access, $contexts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a summary description based upon the checked roles.
|
||||
*/
|
||||
function ctools_ruleset_ctools_access_summary($conf, $context, $plugin) {
|
||||
if (!empty($plugin['ruleset']->admin_description)) {
|
||||
return check_plain($plugin['ruleset']->admin_description);
|
||||
}
|
||||
else {
|
||||
return check_plain($plugin['ruleset']->admin_title);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'schema' => 'ctools_access_ruleset',
|
||||
'access' => 'administer ctools access ruleset',
|
||||
|
||||
'menu' => array(
|
||||
'menu item' => 'ctools-rulesets',
|
||||
'menu title' => 'Custom access rulesets',
|
||||
'menu description' => 'Add, edit or delete custom access rulesets for use with Panels and other systems that utilize CTools content plugins.',
|
||||
),
|
||||
|
||||
'title singular' => t('ruleset'),
|
||||
'title singular proper' => t('Ruleset'),
|
||||
'title plural' => t('rulesets'),
|
||||
'title plural proper' => t('Rulesets'),
|
||||
|
||||
'handler' => 'ctools_access_ruleset_ui',
|
||||
|
||||
'use wizard' => TRUE,
|
||||
'form info' => array(
|
||||
'order' => array(
|
||||
'basic' => t('Basic information'),
|
||||
'context' => t('Contexts'),
|
||||
'rules' => t('Rules'),
|
||||
),
|
||||
),
|
||||
);
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
class ctools_access_ruleset_ui extends ctools_export_ui {
|
||||
|
||||
public function edit_form_context(&$form, &$form_state) {
|
||||
ctools_include('context-admin');
|
||||
ctools_context_admin_includes();
|
||||
ctools_add_css('ruleset');
|
||||
|
||||
$form['right'] = array(
|
||||
'#prefix' => '<div class="ctools-right-container">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$form['left'] = array(
|
||||
'#prefix' => '<div class="ctools-left-container clearfix">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
// Set this up and we can use CTools' Export UI's built in wizard caching,
|
||||
// which already has callbacks for the context cache under this name.
|
||||
$module = 'export_ui::' . $this->plugin['name'];
|
||||
$name = $this->edit_cache_get_key($form_state['item'], $form_state['form type']);
|
||||
|
||||
ctools_context_add_context_form($module, $form, $form_state, $form['right']['contexts_table'], $form_state['item'], $name);
|
||||
ctools_context_add_required_context_form($module, $form, $form_state, $form['left']['required_contexts_table'], $form_state['item'], $name);
|
||||
ctools_context_add_relationship_form($module, $form, $form_state, $form['right']['relationships_table'], $form_state['item'], $name);
|
||||
}
|
||||
|
||||
public function edit_form_rules(&$form, &$form_state) {
|
||||
// The 'access' UI passes everything via $form_state, unlike the 'context' UI.
|
||||
// The main difference is that one is about 3 years newer than the other.
|
||||
ctools_include('context');
|
||||
ctools_include('context-access-admin');
|
||||
|
||||
$form_state['access'] = $form_state['item']->access;
|
||||
$form_state['contexts'] = ctools_context_load_contexts($form_state['item']);
|
||||
|
||||
$form_state['module'] = 'ctools_export_ui';
|
||||
$form_state['callback argument'] = $form_state['object']->plugin['name'] . ':' . $form_state['object']->edit_cache_get_key($form_state['item'], $form_state['form type']);
|
||||
$form_state['no buttons'] = TRUE;
|
||||
|
||||
$form = ctools_access_admin_form($form, $form_state);
|
||||
}
|
||||
|
||||
public function edit_form_rules_submit(&$form, &$form_state) {
|
||||
$form_state['item']->access['logic'] = $form_state['values']['logic'];
|
||||
}
|
||||
|
||||
public function edit_form_submit(&$form, &$form_state) {
|
||||
parent::edit_form_submit($form, $form_state);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
div.ctools-sample-modal-content {
|
||||
background: none;
|
||||
border: 0;
|
||||
color: #000;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
div.ctools-sample-modal-content .modal-scroll {
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
div.ctools-sample-modal-content #popups-overlay {
|
||||
background-color: transparent;
|
||||
}
|
||||
div.ctools-sample-modal-content #popups-loading {
|
||||
width: 248px;
|
||||
position: absolute;
|
||||
display: none;
|
||||
opacity: 1;
|
||||
-moz-border-radius: 8px;
|
||||
-webkit-border-radius: 8px;
|
||||
z-index: 99;
|
||||
}
|
||||
div.ctools-sample-modal-content #popups-loading span.popups-loading-message {
|
||||
background: #fff url(../images/loading-large.gif) no-repeat 8px center;
|
||||
display: block;
|
||||
color: #444;
|
||||
font-family: Arial, serif;
|
||||
font-size: 22px;
|
||||
font-weight: bold;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
padding: 0 40px;
|
||||
}
|
||||
div.ctools-sample-modal-content #popups-loading table,
|
||||
div.ctools-sample-modal-content .popups-box table {
|
||||
margin: 0;
|
||||
}
|
||||
div.ctools-sample-modal-content #popups-loading tbody,
|
||||
div.ctools-sample-modal-content .popups-box tbody {
|
||||
border: none;
|
||||
}
|
||||
div.ctools-sample-modal-content .popups-box tr {
|
||||
background-color: transparent;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-border {
|
||||
background: url(../images/popups-border.png);
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-tl,
|
||||
div.ctools-sample-modal-content td.popups-tr,
|
||||
div.ctools-sample-modal-content td.popups-bl,
|
||||
div.ctools-sample-modal-content td.popups-br {
|
||||
background-repeat: no-repeat;
|
||||
height: 10px;
|
||||
padding: 0;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-tl {
|
||||
background-position: 0 0;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-t,
|
||||
div.ctools-sample-modal-content td.popups-b {
|
||||
background-position: 0 -40px;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-tr {
|
||||
background-position: 0 -10px;
|
||||
width: 10px;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-cl,
|
||||
div.ctools-sample-modal-content td.popups-cr {
|
||||
background-position: -10px 0;
|
||||
background-repeat: repeat-y;
|
||||
width: 10px;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-cl,
|
||||
div.ctools-sample-modal-content td.popups-cr,
|
||||
div.ctools-sample-modal-content td.popups-c {
|
||||
padding: 0;
|
||||
border: none;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-c {
|
||||
background: #fff;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-bl {
|
||||
background-position: 0 -20px;
|
||||
}
|
||||
div.ctools-sample-modal-content td.popups-br {
|
||||
background-position: 0 -30px;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
div.ctools-sample-modal-content .popups-box,
|
||||
div.ctools-sample-modal-content #popups-loading {
|
||||
border: 0 solid #454545;
|
||||
opacity: 1;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
}
|
||||
div.ctools-sample-modal-content .popups-container {
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
background-color: #fff;
|
||||
}
|
||||
div.ctools-sample-modal-content div.popups-title {
|
||||
-moz-border-radius-topleft: 0;
|
||||
-webkit-border-radius-topleft: 0;
|
||||
margin-bottom: 0;
|
||||
background-color: #ff7200;
|
||||
border: 1px solid #ce5c00;
|
||||
padding: 4px 10px 5px;
|
||||
color: white;
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
}
|
||||
div.ctools-sample-modal-content .popups-body {
|
||||
background-color: #fff;
|
||||
padding: 8px;
|
||||
}
|
||||
div.ctools-sample-modal-content .popups-box .popups-buttons,
|
||||
div.ctools-sample-modal-content .popups-box .popups-footer {
|
||||
background-color: #fff;
|
||||
}
|
||||
div.ctools-sample-modal-content .popups-title a.close {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
div.ctools-sample-modal-content .popups-close {
|
||||
font-size: 120%;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
div.ctools-sample-modal-content .modal-loading-wrapper {
|
||||
width: 220px;
|
||||
height: 19px;
|
||||
margin: 0 auto;
|
||||
margin-top: 2%;
|
||||
}
|
||||
|
||||
div.ctools-sample-modal-content tbody {
|
||||
border: none;
|
||||
}
|
||||
|
||||
div.ctools-sample-modal-content .modal-content .modal-throbber-wrapper img {
|
||||
margin-top: 100px;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
name = Chaos Tools (CTools) AJAX Example
|
||||
description = Shows how to use the power of Chaos AJAX.
|
||||
package = Chaos tool suite
|
||||
dependencies[] = ctools:ctools
|
||||
core = 7.x
|
||||
|
||||
; Information added by Drupal.org packaging script on 2023-01-31
|
||||
version = "7.x-1.21"
|
||||
core = "7.x"
|
||||
project = "ctools"
|
||||
datestamp = "1675152418"
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_install()
|
||||
*/
|
||||
function ctools_ajax_sample_install() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall()
|
||||
*/
|
||||
function ctools_ajax_sample_uninstall() {
|
||||
|
||||
}
|
|
@ -0,0 +1,756 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Sample AJAX functionality so people can see some of the CTools AJAX
|
||||
* features in use.
|
||||
*/
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Drupal hooks.
|
||||
/**
|
||||
* Implementation of hook_menu()
|
||||
*/
|
||||
|
||||
function ctools_ajax_sample_menu() {
|
||||
$items['ctools_ajax_sample'] = array(
|
||||
'title' => 'Chaos Tools AJAX Demo',
|
||||
'page callback' => 'ctools_ajax_sample_page',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
$items['ctools_ajax_sample/simple_form'] = array(
|
||||
'title' => 'Simple Form',
|
||||
'page callback' => 'ctools_ajax_simple_form',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['ctools_ajax_sample/%ctools_js/hello'] = array(
|
||||
'title' => 'Hello World',
|
||||
'page callback' => 'ctools_ajax_sample_hello',
|
||||
'page arguments' => array(1),
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['ctools_ajax_sample/%ctools_js/tablenix/%'] = array(
|
||||
'title' => 'Hello World',
|
||||
'page callback' => 'ctools_ajax_sample_tablenix',
|
||||
'page arguments' => array(1, 3),
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['ctools_ajax_sample/%ctools_js/login'] = array(
|
||||
'title' => 'Login',
|
||||
'page callback' => 'ctools_ajax_sample_login',
|
||||
'page arguments' => array(1),
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['ctools_ajax_sample/%ctools_js/animal'] = array(
|
||||
'title' => 'Animal',
|
||||
'page callback' => 'ctools_ajax_sample_animal',
|
||||
'page arguments' => array(1),
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['ctools_ajax_sample/%ctools_js/login/%'] = array(
|
||||
'title' => 'Post-Login Action',
|
||||
'page callback' => 'ctools_ajax_sample_login_success',
|
||||
'page arguments' => array(1, 3),
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['ctools_ajax_sample/jumped'] = array(
|
||||
'title' => 'Successful Jumping',
|
||||
'page callback' => 'ctools_ajax_sample_jump_menu_page',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function ctools_ajax_simple_form() {
|
||||
ctools_include('content');
|
||||
ctools_include('context');
|
||||
$node = node_load(1);
|
||||
$context = ctools_context_create('node', $node);
|
||||
$context = array('context_node_1' => $context);
|
||||
return ctools_content_render('node_comment_form', 'node_comment_form', ctools_ajax_simple_form_pane(), array(), array(), $context);
|
||||
}
|
||||
|
||||
function ctools_ajax_simple_form_pane() {
|
||||
$configuration = array(
|
||||
'anon_links' => 0,
|
||||
'context' => 'context_node_1',
|
||||
'override_title' => 0,
|
||||
'override_title_text' => '',
|
||||
);
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_theme()
|
||||
*
|
||||
* Render some basic output for this module.
|
||||
*/
|
||||
function ctools_ajax_sample_theme() {
|
||||
return array(
|
||||
// Sample theme functions.
|
||||
'ctools_ajax_sample_container' => array(
|
||||
'arguments' => array('content' => NULL),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Page callbacks.
|
||||
/**
|
||||
* Page callback to display links and render a container for AJAX stuff.
|
||||
*/
|
||||
|
||||
function ctools_ajax_sample_page() {
|
||||
global $user;
|
||||
|
||||
// Include the CTools tools that we need.
|
||||
ctools_include('ajax');
|
||||
ctools_include('modal');
|
||||
|
||||
// Add CTools' javascript to the page.
|
||||
ctools_modal_add_js();
|
||||
|
||||
// Create our own javascript that will be used to theme a modal.
|
||||
$sample_style = array(
|
||||
'ctools-sample-style' => array(
|
||||
'modalSize' => array(
|
||||
'type' => 'fixed',
|
||||
'width' => 500,
|
||||
'height' => 300,
|
||||
'addWidth' => 20,
|
||||
'addHeight' => 15,
|
||||
),
|
||||
'modalOptions' => array(
|
||||
'opacity' => .5,
|
||||
'background-color' => '#000',
|
||||
),
|
||||
'animation' => 'fadeIn',
|
||||
'modalTheme' => 'CToolsSampleModal',
|
||||
'throbber' => theme('image', array('path' => ctools_image_path('ajax-loader.gif', 'ctools_ajax_sample'), 'alt' => t('Loading...'), 'title' => t('Loading'))),
|
||||
),
|
||||
);
|
||||
|
||||
drupal_add_js($sample_style, 'setting');
|
||||
|
||||
// Since we have our js, css and images in well-known named directories,
|
||||
// CTools makes it easy for us to just use them without worrying about
|
||||
// using drupal_get_path() and all that ugliness.
|
||||
ctools_add_js('ctools-ajax-sample', 'ctools_ajax_sample');
|
||||
ctools_add_css('ctools-ajax-sample', 'ctools_ajax_sample');
|
||||
|
||||
// Create a list of clickable links.
|
||||
$links = array();
|
||||
|
||||
// Only show login links to the anonymous user.
|
||||
if ($user->uid == 0) {
|
||||
$links[] = ctools_modal_text_button(t('Modal Login (default style)'), 'ctools_ajax_sample/nojs/login', t('Login via modal'));
|
||||
|
||||
// The extra class points to the info in ctools-sample-style which we added
|
||||
// to the settings, prefixed with 'ctools-modal'.
|
||||
$links[] = ctools_modal_text_button(t('Modal Login (custom style)'), 'ctools_ajax_sample/nojs/login', t('Login via modal'), 'ctools-modal-ctools-sample-style');
|
||||
}
|
||||
|
||||
// Four ways to do our animal picking wizard.
|
||||
$button_form = ctools_ajax_sample_ajax_button_form();
|
||||
$links[] = l(t('Wizard (no modal)'), 'ctools_ajax_sample/nojs/animal');
|
||||
$links[] = ctools_modal_text_button(t('Wizard (default modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'));
|
||||
$links[] = ctools_modal_text_button(t('Wizard (custom modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'), 'ctools-modal-ctools-sample-style');
|
||||
$links[] = drupal_render($button_form);
|
||||
|
||||
$links[] = ctools_ajax_text_button(t('Hello world!'), "ctools_ajax_sample/nojs/hello", t('Replace text with "hello world"'));
|
||||
|
||||
$output = theme('item_list', array('items' => $links, 'title' => t('Actions')));
|
||||
|
||||
// This container will have data AJAXed into it.
|
||||
$output .= theme('ctools_ajax_sample_container', array('content' => '<h1>' . t('Sample Content') . '</h1>'));
|
||||
|
||||
// Create a table that we can have data removed from via AJAX.
|
||||
$header = array(t('Row'), t('Content'), t('Actions'));
|
||||
$rows = array();
|
||||
for ($i = 1; $i < 11; $i++) {
|
||||
$rows[] = array(
|
||||
'class' => array('ajax-sample-row-' . $i),
|
||||
'data' => array(
|
||||
$i,
|
||||
md5($i),
|
||||
ctools_ajax_text_button("remove", "ctools_ajax_sample/nojs/tablenix/$i", t('Delete this row')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('ajax-sample-table'))));
|
||||
|
||||
// Show examples of ctools javascript widgets.
|
||||
$output .= '<h2>' . t('CTools Javascript Widgets') . '</h2>';
|
||||
|
||||
// Create a drop down menu.
|
||||
$links = array();
|
||||
$links[] = array('title' => t('Link 1'), 'href' => $_GET['q']);
|
||||
$links[] = array('title' => t('Link 2'), 'href' => $_GET['q']);
|
||||
$links[] = array('title' => t('Link 3'), 'href' => $_GET['q']);
|
||||
|
||||
$output .= '<h3>' . t('Drop Down Menu') . '</h3>';
|
||||
$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 .= '<h3>' . t('Collapsible Div') . '</h3>';
|
||||
$output .= theme('ctools_collapsible', array('handle' => $handle, 'content' => $content, 'collapsed' => FALSE));
|
||||
|
||||
// Create a jump menu.
|
||||
ctools_include('jump-menu');
|
||||
$form = drupal_get_form('ctools_ajax_sample_jump_menu_form');
|
||||
$output .= '<h3>' . t('Jump Menu') . '</h3>';
|
||||
$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 = '<h1>' . t('Hello World') . '</h1>';
|
||||
if ($js) {
|
||||
ctools_include('ajax');
|
||||
$commands = array();
|
||||
$commands[] = ajax_command_html('#ctools-sample', $output);
|
||||
// This function exits.
|
||||
print ajax_render($commands);
|
||||
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'), '<div class="modal-message">Login successful. You can now choose whether to ' . $inplace . ', or go to ' . $account . '.</div>');
|
||||
}
|
||||
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();
|
||||
}
|
||||
elseif (!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;
|
||||
}
|
||||
elseif (!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 = '<div id="ctools-sample">';
|
||||
$output .= $vars['content'];
|
||||
$output .= '</div>';
|
||||
|
||||
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;
|
||||
}
|
Binary file not shown.
After ![]() (image error) Size: 11 KiB |
Binary file not shown.
After ![]() (image error) Size: 2.5 KiB |
Binary file not shown.
After ![]() (image error) Size: 1.8 KiB |
Binary file not shown.
After ![]() (image error) Size: 380 B |
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* Provide the HTML to create the modal dialog.
|
||||
*/
|
||||
Drupal.theme.prototype.CToolsSampleModal = function () {
|
||||
var html = '';
|
||||
|
||||
html += '<div id="ctools-modal" class="popups-box">';
|
||||
html += ' <div class="ctools-modal-content ctools-sample-modal-content">';
|
||||
html += ' <table cellpadding="0" cellspacing="0" id="ctools-face-table">';
|
||||
html += ' <tr>';
|
||||
html += ' <td class="popups-tl popups-border"></td>';
|
||||
html += ' <td class="popups-t popups-border"></td>';
|
||||
html += ' <td class="popups-tr popups-border"></td>';
|
||||
html += ' </tr>';
|
||||
html += ' <tr>';
|
||||
html += ' <td class="popups-cl popups-border"></td>';
|
||||
html += ' <td class="popups-c" valign="top">';
|
||||
html += ' <div class="popups-container">';
|
||||
html += ' <div class="modal-header popups-title">';
|
||||
html += ' <span id="modal-title" class="modal-title"></span>';
|
||||
html += ' <span class="popups-close"><a class="close" href="#">' + Drupal.CTools.Modal.currentSettings.closeText + '</a></span>';
|
||||
html += ' <div class="clear-block"></div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="modal-scroll"><div id="modal-content" class="modal-content popups-body"></div></div>';
|
||||
html += ' <div class="popups-buttons"></div>'; //Maybe someday add the option for some specific buttons.
|
||||
html += ' <div class="popups-footer"></div>'; //Maybe someday add some footer.
|
||||
html += ' </div>';
|
||||
html += ' </td>';
|
||||
html += ' <td class="popups-cr popups-border"></td>';
|
||||
html += ' </tr>';
|
||||
html += ' <tr>';
|
||||
html += ' <td class="popups-bl popups-border"></td>';
|
||||
html += ' <td class="popups-b popups-border"></td>';
|
||||
html += ' <td class="popups-br popups-border"></td>';
|
||||
html += ' </tr>';
|
||||
html += ' </table>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
|
||||
return html;
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
name = Custom content panes
|
||||
description = Create custom, exportable, reusable content panes for applications like Panels.
|
||||
core = 7.x
|
||||
package = Chaos tool suite
|
||||
dependencies[] = ctools:ctools
|
||||
|
||||
; Information added by Drupal.org packaging script on 2023-01-31
|
||||
version = "7.x-1.21"
|
||||
core = "7.x"
|
||||
project = "ctools"
|
||||
datestamp = "1675152418"
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/**
|
||||
* Schema for CTools custom content.
|
||||
*/
|
||||
function ctools_custom_content_schema() {
|
||||
return ctools_custom_content_schema_1();
|
||||
}
|
||||
|
||||
function ctools_custom_content_schema_1() {
|
||||
$schema = array();
|
||||
|
||||
$schema['ctools_custom_content'] = array(
|
||||
'description' => '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;
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* The ctools_custom_content module.
|
||||
*
|
||||
* This module allows styles to be created and managed on behalf of modules
|
||||
* that implement styles.
|
||||
*
|
||||
* The ctools_custom_content tool allows recolorable styles to be created via a miniature
|
||||
* scripting language. Panels utilizes this to allow administrators to add
|
||||
* styles directly to any panel display.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_permission()
|
||||
*/
|
||||
function ctools_custom_content_permission() {
|
||||
return array(
|
||||
'administer custom content' => 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 = '<p>' . t('There are no custom content panes.') . '</p>';
|
||||
}
|
||||
|
||||
$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',
|
||||
);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'schema' => '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',
|
||||
);
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
|
||||
class ctools_custom_content_ui extends ctools_export_ui {
|
||||
|
||||
public function edit_form(&$form, &$form_state) {
|
||||
// Correct for an error that came in because filter format changed.
|
||||
if (is_array($form_state['item']->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['title_heading'] = array(
|
||||
'#title' => t('Title heading'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => isset($form_state['item']->settings['title_heading']) ? $form_state['item']->settings['title_heading'] : 'h2',
|
||||
'#options' => array(
|
||||
'h1' => t('h1'),
|
||||
'h2' => t('h2'),
|
||||
'h3' => t('h3'),
|
||||
'h4' => t('h4'),
|
||||
'h5' => t('h5'),
|
||||
'h6' => t('h6'),
|
||||
'div' => t('div'),
|
||||
'span' => t('span'),
|
||||
),
|
||||
);
|
||||
|
||||
$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']),
|
||||
);
|
||||
}
|
||||
|
||||
public 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['title_heading'] = $form_state['values']['title_heading'];
|
||||
$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'];
|
||||
}
|
||||
|
||||
public 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,
|
||||
);
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
|
||||
public function list_sort_options() {
|
||||
return array(
|
||||
'disabled' => t('Enabled, title'),
|
||||
'title' => t('Title'),
|
||||
'name' => t('Name'),
|
||||
'category' => t('Category'),
|
||||
'storage' => t('Storage'),
|
||||
);
|
||||
}
|
||||
|
||||
public 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'),
|
||||
);
|
||||
}
|
||||
|
||||
public 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')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
|
@ -0,0 +1,14 @@
|
|||
name = Chaos Tools (CTools) Plugin Example
|
||||
description = Shows how an external module can provide ctools plugins (for Panels, etc.).
|
||||
core = 7.x
|
||||
package = Chaos tool suite
|
||||
dependencies[] = advanced_help:advanced_help
|
||||
dependencies[] = ctools:ctools
|
||||
dependencies[] = ctools:page_manager
|
||||
dependencies[] = panels:panels
|
||||
|
||||
; Information added by Drupal.org packaging script on 2023-01-31
|
||||
version = "7.x-1.21"
|
||||
core = "7.x"
|
||||
project = "ctools"
|
||||
datestamp = "1675152418"
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Working sample module to demonstrate CTools 3 plugins.
|
||||
*
|
||||
* This sample module is only intended to demonstrate how external modules can
|
||||
* provide ctools plugins. There is no useful functionality, and it's only
|
||||
* intended for developers or for educational use.
|
||||
*
|
||||
* As far as possible, everything is kept very simple, not exercising all of
|
||||
* the capabilities of CTools or Panels.
|
||||
*
|
||||
* Although the ctools documentation suggests that strict naming conventions
|
||||
* be followed, this code attempts to follow only the conventions which are
|
||||
* required (the hooks), in order to demonstrate the difference. You can
|
||||
* certainly use the conventions, but it's important to know the difference
|
||||
* between a convention and a requirement.
|
||||
*
|
||||
* The advanced_help module is required, because both CTools and this module
|
||||
* provide help that way.
|
||||
*
|
||||
* There is a demonstration panel provided at /ctools_plugin_example/123
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu.
|
||||
*/
|
||||
function ctools_plugin_example_menu() {
|
||||
$items = array();
|
||||
|
||||
$items["admin/settings/ctools_plugin_example"] = array(
|
||||
'title' => '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
|
||||
* <modulename>.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 = '<p>' . 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.") . '</p>';
|
||||
|
||||
$content .= '<p>' . t(
|
||||
'There is a demo panel demonstrating much of the functionality provided at
|
||||
<a href="@demo_url">CTools demo panel</a>, 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'),
|
||||
)) . '</p>';
|
||||
|
||||
return $content;
|
||||
}
|
|
@ -0,0 +1,449 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This module provides default panels to demonstrate the behavior of the plugins.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default panels pages for CTools Plugin Example.
|
||||
*
|
||||
* To pick up this file, your module needs to implement
|
||||
* hook_ctools_plugin_api() - See ctools_plugin_example_ctools_plugin_api() in
|
||||
* ctools_plugin_example.module.
|
||||
*
|
||||
*
|
||||
* Note the naming of the file: <modulename>.pages_default.inc
|
||||
* With this naming, no additional code needs to be provided. CTools will just find the file.
|
||||
* The name of the hook is <modulename>_default_page_manager_pages()
|
||||
*
|
||||
* This example provides two pages, but the returned array could
|
||||
* have several pages.
|
||||
*
|
||||
* @return
|
||||
* Array of pages, normally exported from Panels.
|
||||
*/
|
||||
function ctools_plugin_example_default_page_manager_pages() {
|
||||
|
||||
// Begin exported panel.
|
||||
$page = new stdClass();
|
||||
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
|
||||
$page->api_version = 1;
|
||||
$page->name = 'ctools_plugin_example';
|
||||
$page->task = 'page';
|
||||
$page->admin_title = 'CTools plugin example';
|
||||
$page->admin_description = 'This panel provides no functionality to a working Drupal system. It\'s intended to display the various sample plugins provided by the CTools Plugin Example module. ';
|
||||
$page->path = 'ctools_plugin_example/%sc';
|
||||
$page->access = array(
|
||||
'logic' => 'and',
|
||||
);
|
||||
$page->menu = array(
|
||||
'type' => 'normal',
|
||||
'title' => 'CTools plugin example',
|
||||
'name' => 'navigation',
|
||||
'weight' => '0',
|
||||
'parent' => array(
|
||||
'type' => 'none',
|
||||
'title' => '',
|
||||
'name' => 'navigation',
|
||||
'weight' => '0',
|
||||
),
|
||||
);
|
||||
$page->arguments = array(
|
||||
'sc' => array(
|
||||
'id' => 2,
|
||||
'identifier' => 'simplecontext-arg',
|
||||
'name' => 'simplecontext_arg',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
$page->conf = array();
|
||||
$page->default_handlers = array();
|
||||
$handler = new stdClass();
|
||||
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
|
||||
$handler->api_version = 1;
|
||||
$handler->name = 'page_ctools_panel_context';
|
||||
$handler->task = 'page';
|
||||
$handler->subtask = 'ctools_plugin_example';
|
||||
$handler->handler = 'panel_context';
|
||||
$handler->weight = 0;
|
||||
$handler->conf = array(
|
||||
'title' => 'Panel',
|
||||
'no_blocks' => FALSE,
|
||||
'css_id' => '',
|
||||
'css' => '',
|
||||
'contexts' => array(
|
||||
'0' => array(
|
||||
'name' => 'simplecontext',
|
||||
'id' => 1,
|
||||
'identifier' => 'Configured simplecontext (not from argument)',
|
||||
'keyword' => 'configured_simplecontext',
|
||||
'context_settings' => array(
|
||||
'sample_simplecontext_setting' => 'default simplecontext setting',
|
||||
),
|
||||
),
|
||||
),
|
||||
'relationships' => array(
|
||||
'0' => array(
|
||||
'context' => 'argument_simplecontext_arg_2',
|
||||
'name' => 'relcontext_from_simplecontext',
|
||||
'id' => 1,
|
||||
'identifier' => 'Relcontext from simplecontext (from relationship)',
|
||||
'keyword' => 'relcontext',
|
||||
),
|
||||
),
|
||||
'access' => array(
|
||||
'logic' => 'and',
|
||||
),
|
||||
'pipeline' => 'standard',
|
||||
);
|
||||
$display = new panels_display();
|
||||
$display->layout = 'threecol_33_34_33_stacked';
|
||||
$display->layout_settings = array();
|
||||
$display->panel_settings = array(
|
||||
'style' => 'rounded_corners',
|
||||
'style_settings' => array(
|
||||
'default' => array(
|
||||
'corner_location' => 'pane',
|
||||
),
|
||||
),
|
||||
);
|
||||
$display->cache = array();
|
||||
$display->title = 'CTools plugin example panel';
|
||||
$display->hide_title = FALSE;
|
||||
$display->title_pane = 1;
|
||||
$display->content = array();
|
||||
$display->panels = array();
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-1';
|
||||
$pane->panel = 'left';
|
||||
$pane->type = 'no_context_content_type';
|
||||
$pane->subtype = 'no_context_content_type';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'item1' => 'contents of config item 1',
|
||||
'item2' => 'contents of config item 2',
|
||||
'override_title' => 0,
|
||||
'override_title_text' => '',
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 0;
|
||||
$display->content['new-1'] = $pane;
|
||||
$display->panels['left'][0] = 'new-1';
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-2';
|
||||
$pane->panel = 'left';
|
||||
$pane->type = 'custom';
|
||||
$pane->subtype = 'custom';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array(
|
||||
'plugins' => array(
|
||||
'0' => array(
|
||||
'name' => 'arg_length',
|
||||
'settings' => array(
|
||||
'greater_than' => '1',
|
||||
'arg_length' => '4',
|
||||
),
|
||||
'context' => 'argument_simplecontext_arg_2',
|
||||
),
|
||||
),
|
||||
);
|
||||
$pane->configuration = array(
|
||||
'title' => 'Long Arg Visibility Block',
|
||||
'body' => 'This block will be here when the argument is longer than configured arg length. It uses the \'arg_length\' access plugin to test against the length of the argument used for Simplecontext.',
|
||||
'format' => 'filtered_html',
|
||||
'substitute' => 1,
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 1;
|
||||
$display->content['new-2'] = $pane;
|
||||
$display->panels['left'][1] = 'new-2';
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-3';
|
||||
$pane->panel = 'left';
|
||||
$pane->type = 'custom';
|
||||
$pane->subtype = 'custom';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array(
|
||||
'plugins' => array(
|
||||
'0' => array(
|
||||
'name' => 'arg_length',
|
||||
'settings' => array(
|
||||
'greater_than' => '0',
|
||||
'arg_length' => '4',
|
||||
),
|
||||
'context' => 'argument_simplecontext_arg_2',
|
||||
),
|
||||
),
|
||||
);
|
||||
$pane->configuration = array(
|
||||
'title' => 'Short Arg Visibility',
|
||||
'body' => 'This block appears when the simplecontext argument is <i>less than</i> the configured length.',
|
||||
'format' => 'filtered_html',
|
||||
'substitute' => 1,
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 2;
|
||||
$display->content['new-3'] = $pane;
|
||||
$display->panels['left'][2] = 'new-3';
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-4';
|
||||
$pane->panel = 'middle';
|
||||
$pane->type = 'simplecontext_content_type';
|
||||
$pane->subtype = 'simplecontext_content_type';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'buttons' => NULL,
|
||||
'#validate' => NULL,
|
||||
'#submit' => NULL,
|
||||
'#action' => NULL,
|
||||
'context' => 'argument_simplecontext_arg_2',
|
||||
'aligner_start' => NULL,
|
||||
'override_title' => 1,
|
||||
'override_title_text' => 'Simplecontext (with an arg)',
|
||||
'aligner_stop' => NULL,
|
||||
'override_title_markup' => NULL,
|
||||
'config_item_1' => 'Config item 1 contents',
|
||||
'#build_id' => NULL,
|
||||
'#type' => NULL,
|
||||
'#programmed' => NULL,
|
||||
'form_build_id' => 'form-19c4ae6cb54fad8f096da46e95694e5a',
|
||||
'#token' => NULL,
|
||||
'form_token' => '17141d3531eaa7b609da78afa6f3b560',
|
||||
'form_id' => 'simplecontext_content_type_edit_form',
|
||||
'#id' => NULL,
|
||||
'#description' => NULL,
|
||||
'#attributes' => NULL,
|
||||
'#required' => NULL,
|
||||
'#tree' => NULL,
|
||||
'#parents' => NULL,
|
||||
'#method' => NULL,
|
||||
'#post' => NULL,
|
||||
'#processed' => NULL,
|
||||
'#defaults_loaded' => NULL,
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 0;
|
||||
$display->content['new-4'] = $pane;
|
||||
$display->panels['middle'][0] = 'new-4';
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-5';
|
||||
$pane->panel = 'middle';
|
||||
$pane->type = 'simplecontext_content_type';
|
||||
$pane->subtype = 'simplecontext_content_type';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'buttons' => NULL,
|
||||
'#validate' => NULL,
|
||||
'#submit' => NULL,
|
||||
'#action' => NULL,
|
||||
'context' => 'context_simplecontext_1',
|
||||
'aligner_start' => NULL,
|
||||
'override_title' => 1,
|
||||
'override_title_text' => 'Configured simplecontext content type (not from arg)',
|
||||
'aligner_stop' => NULL,
|
||||
'override_title_markup' => NULL,
|
||||
'config_item_1' => '(configuration for simplecontext)',
|
||||
'#build_id' => NULL,
|
||||
'#type' => NULL,
|
||||
'#programmed' => NULL,
|
||||
'form_build_id' => 'form-d016200490abd015dc5b8a7e366d76ea',
|
||||
'#token' => NULL,
|
||||
'form_token' => '17141d3531eaa7b609da78afa6f3b560',
|
||||
'form_id' => 'simplecontext_content_type_edit_form',
|
||||
'#id' => NULL,
|
||||
'#description' => NULL,
|
||||
'#attributes' => NULL,
|
||||
'#required' => NULL,
|
||||
'#tree' => NULL,
|
||||
'#parents' => NULL,
|
||||
'#method' => NULL,
|
||||
'#post' => NULL,
|
||||
'#processed' => NULL,
|
||||
'#defaults_loaded' => NULL,
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 1;
|
||||
$display->content['new-5'] = $pane;
|
||||
$display->panels['middle'][1] = 'new-5';
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-6';
|
||||
$pane->panel = 'middle';
|
||||
$pane->type = 'custom';
|
||||
$pane->subtype = 'custom';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'admin_title' => 'Simplecontext keyword usage',
|
||||
'title' => 'Simplecontext keyword usage',
|
||||
'body' => 'Demonstrating context keyword usage:
|
||||
item1 is %sc:item1
|
||||
item2 is %sc:item2
|
||||
description is %sc:description',
|
||||
'format' => 'filtered_html',
|
||||
'substitute' => 1,
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 2;
|
||||
$display->content['new-6'] = $pane;
|
||||
$display->panels['middle'][2] = 'new-6';
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-7';
|
||||
$pane->panel = 'right';
|
||||
$pane->type = 'relcontext_content_type';
|
||||
$pane->subtype = 'relcontext_content_type';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'buttons' => NULL,
|
||||
'#validate' => NULL,
|
||||
'#submit' => NULL,
|
||||
'#action' => NULL,
|
||||
'context' => 'relationship_relcontext_from_simplecontext_1',
|
||||
'aligner_start' => NULL,
|
||||
'override_title' => 0,
|
||||
'override_title_text' => '',
|
||||
'aligner_stop' => NULL,
|
||||
'override_title_markup' => NULL,
|
||||
'config_item_1' => 'some stuff in this one',
|
||||
'#build_id' => NULL,
|
||||
'#type' => NULL,
|
||||
'#programmed' => NULL,
|
||||
'form_build_id' => 'form-8485f84511bd06e51b4a48e998448054',
|
||||
'#token' => NULL,
|
||||
'form_token' => '1c3356396374d51d7d2531a10fd25310',
|
||||
'form_id' => 'relcontext_edit_form',
|
||||
'#id' => NULL,
|
||||
'#description' => NULL,
|
||||
'#attributes' => NULL,
|
||||
'#required' => NULL,
|
||||
'#tree' => NULL,
|
||||
'#parents' => NULL,
|
||||
'#method' => NULL,
|
||||
'#post' => NULL,
|
||||
'#processed' => NULL,
|
||||
'#defaults_loaded' => NULL,
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 0;
|
||||
$display->content['new-7'] = $pane;
|
||||
$display->panels['right'][0] = 'new-7';
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-8';
|
||||
$pane->panel = 'top';
|
||||
$pane->type = 'custom';
|
||||
$pane->subtype = 'custom';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'title' => 'Demonstrating ctools plugins',
|
||||
'body' => 'The CTools Plugin Example module (and this panel page) are just here to demonstrate how to build CTools plugins.
|
||||
|
||||
',
|
||||
'format' => 'full_html',
|
||||
'substitute' => 1,
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 0;
|
||||
$display->content['new-8'] = $pane;
|
||||
$display->panels['top'][0] = 'new-8';
|
||||
$handler->conf['display'] = $display;
|
||||
$page->default_handlers[$handler->name] = $handler;
|
||||
|
||||
// End of exported panel.
|
||||
$pages['ctools_plugin_example_demo_page'] = $page;
|
||||
|
||||
// Begin exported panel.
|
||||
$page = new stdClass();
|
||||
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
|
||||
$page->api_version = 1;
|
||||
$page->name = 'ctools_plugin_example_base';
|
||||
$page->task = 'page';
|
||||
$page->admin_title = 'CTools Plugin Example base page';
|
||||
$page->admin_description = 'This panel is for when people hit /ctools_plugin_example without an argument. We can use it to tell people to move on.';
|
||||
$page->path = 'ctools_plugin_example';
|
||||
$page->access = array();
|
||||
$page->menu = array();
|
||||
$page->arguments = array();
|
||||
$page->conf = array();
|
||||
$page->default_handlers = array();
|
||||
$handler = new stdClass();
|
||||
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
|
||||
$handler->api_version = 1;
|
||||
$handler->name = 'page_ctools_plugin_example_base_panel_context';
|
||||
$handler->task = 'page';
|
||||
$handler->subtask = 'ctools_plugin_example_base';
|
||||
$handler->handler = 'panel_context';
|
||||
$handler->weight = 0;
|
||||
$handler->conf = array(
|
||||
'title' => 'Panel',
|
||||
'no_blocks' => FALSE,
|
||||
'css_id' => '',
|
||||
'css' => '',
|
||||
'contexts' => array(),
|
||||
'relationships' => array(),
|
||||
'pipeline' => 'standard',
|
||||
);
|
||||
$display = new panels_display();
|
||||
$display->layout = 'onecol';
|
||||
$display->layout_settings = array();
|
||||
$display->panel_settings = array();
|
||||
$display->cache = array();
|
||||
$display->title = '';
|
||||
$display->hide_title = FALSE;
|
||||
$display->content = array();
|
||||
$display->panels = array();
|
||||
$pane = new stdClass();
|
||||
$pane->pid = 'new-1';
|
||||
$pane->panel = 'middle';
|
||||
$pane->type = 'custom';
|
||||
$pane->subtype = 'custom';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'title' => 'Use this page with an argument',
|
||||
'body' => 'This demo page works if you use an argument, like <a href="ctools_plugin_example/xxxxx">ctools_plugin_example/xxxxx</a>.',
|
||||
'format' => 'filtered_html',
|
||||
'substitute' => NULL,
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array();
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 0;
|
||||
$display->content['new-1'] = $pane;
|
||||
$display->panels['middle'][0] = 'new-1';
|
||||
$handler->conf['display'] = $display;
|
||||
$page->default_handlers[$handler->name] = $handler;
|
||||
// End exported panel.
|
||||
$pages['base_page'] = $page;
|
||||
|
||||
return $pages;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<div id="node-16" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,20 @@
|
|||
<div id="node-12" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>Contexts are fundamental to CTools, and they almost always start with an argument to a panels page, so we'll start there too.</p>
|
||||
<p>We first need to process an argument.</p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>You can browse plugins/arguments/simplecontext_arg.inc and see the little that it does.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,19 @@
|
|||
<div id="node-10" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>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.</p>
|
||||
<p>There are two parts to this demo: </p>
|
||||
<p>First, there is a sample panel provided that uses all the various plugins. It's at <a href="/ctools_plugin_example/12345">ctools_example/12345</a>. You can edit the panel and configure all the panes on it.</p>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,17 @@
|
|||
<div id="node-14" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,21 @@
|
|||
<div id="node-13" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>Now that we have a plugin for a simplecontext argument, we can create a plugin for a simplecontext context. </p>
|
||||
<p>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. </p>
|
||||
<p>plugins/contexts/simplecontext.inc implements our context.</p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,20 @@
|
|||
<div id="node-11" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>Your module must provide a few things so that your plugins can be found.</p>
|
||||
<p>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.</p>
|
||||
<p><div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">ctools_plugin_example_ctools_plugin_directory</span><span style="color: #007700">(</span><span style="color: #0000BB">$module</span><span style="color: #007700">, </span><span style="color: #0000BB">$plugin</span><span style="color: #007700">) {<br /> if (</span><span style="color: #0000BB">$module </span><span style="color: #007700">== </span><span style="color: #DD0000">'ctools' </span><span style="color: #007700">&& !empty(</span><span style="color: #0000BB">$plugin</span><span style="color: #007700">)) {<br /> return </span><span style="color: #DD0000">"plugins/$plugin"</span><span style="color: #007700">;<br /> }<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div></p>
|
||||
<p>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.</p>
|
||||
<p><div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">ctools_plugin_example_ctools_plugin_api</span><span style="color: #007700">(</span><span style="color: #0000BB">$module</span><span style="color: #007700">, </span><span style="color: #0000BB">$api</span><span style="color: #007700">) {<br /> if (</span><span style="color: #0000BB">$module </span><span style="color: #007700">== </span><span style="color: #DD0000">'panels_mini' </span><span style="color: #007700">&& </span><span style="color: #0000BB">$api </span><span style="color: #007700">== </span><span style="color: #DD0000">'panels_default'</span><span style="color: #007700">) {<br /> return array(</span><span style="color: #DD0000">'version' </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /> }<br /> if (</span><span style="color: #0000BB">$module </span><span style="color: #007700">== </span><span style="color: #DD0000">'page_manager' </span><span style="color: #007700">&& </span><span style="color: #0000BB">$api </span><span style="color: #007700">== </span><span style="color: #DD0000">'pages_default'</span><span style="color: #007700">) {<br /> return array(</span><span style="color: #DD0000">'version' </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /> }<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div></p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,18 @@
|
|||
<div id="node-15" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>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.</p>
|
||||
<p>A relationship plugin allows this kind of data to be accessed. </p>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -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
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Plugin to provide access control/visibility based on length of
|
||||
* simplecontext argument (in URL).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => 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'],
|
||||
));
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Plugin to provide access control based upon role membership.
|
||||
* This is directly from the ctools module, but serves as a good
|
||||
* example of an access plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => 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));
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Sample plugin to provide an argument handler for a simplecontext.
|
||||
*
|
||||
* Given any argument to the page, simplecontext will get it
|
||||
* and turn it into a piece of data (a "context") just by adding some text to it.
|
||||
* Normally, the argument would be a key into some database (like the node
|
||||
* database, for example, and the result of using the argument would be to load
|
||||
* a specific "context" or data item that we can use elsewhere.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => t("Simplecontext arg"),
|
||||
// Keyword to use for %substitution.
|
||||
'keyword' => 'simplecontext',
|
||||
'description' => t('Creates a "simplecontext" from the arg.'),
|
||||
'context' => 'simplecontext_arg_context',
|
||||
// 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);
|
||||
}
|
Binary file not shown.
After ![]() (image error) Size: 566 B |
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* "No context" sample content type. It operates with no context at all. It would
|
||||
* be basically the same as a 'custom content' block, but it's not even that
|
||||
* sophisticated.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => 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("
|
||||
<div>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}
|
||||
</div>
|
||||
");
|
||||
if (!empty($conf)) {
|
||||
$block->content .= '<div>The only information that can be displayed in this block comes from the code and its settings form: </div>';
|
||||
$block->content .= '<div style="border: 1px solid red;">' . var_export($conf, TRUE) . '</div>';
|
||||
}
|
||||
|
||||
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' => '<div class="clear-block no-float">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
$form['item2'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Item2'),
|
||||
'#size' => 50,
|
||||
'#description' => t('The setting for item 2'),
|
||||
'#default_value' => !empty($conf['item2']) ? $conf['item2'] : '',
|
||||
'#prefix' => '<div class="clear-block no-float">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
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];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Content type that displays the relcontext context type.
|
||||
*
|
||||
* This example is for use with the relcontext relationship to show
|
||||
* how we can get a relationship-context into a data type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
// Used in add content dialogs.
|
||||
'title' => 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. <br />
|
||||
In our case, the configuration form (\$conf) has just one field, 'config_item_1;
|
||||
and it's configured with:
|
||||
");
|
||||
if (!empty($conf)) {
|
||||
$block->content .= '<div style="border: 1px solid red;">' . var_export($conf['config_item_1'], TRUE) . '</div>';
|
||||
}
|
||||
if (!empty($context)) {
|
||||
$block->content .= '<br />The args ($args) were <div style="border: 1px solid yellow;" >' .
|
||||
var_export($args, TRUE) . '</div>';
|
||||
}
|
||||
$block->content .= '<br />And the relcontext context ($context->data->description)
|
||||
(which was created from a
|
||||
simplecontext context) was <div style="border: 1px solid green;" >' .
|
||||
print_r($context->data->description, TRUE) . '</div>';
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* 'Edit' callback for the content type.
|
||||
* This example just returns a form.
|
||||
*/
|
||||
function relcontext_edit_form($form, &$form_state) {
|
||||
$conf = $form_state['conf'];
|
||||
|
||||
$form['config_item_1'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Config Item 1 (relcontext)'),
|
||||
'#size' => 50,
|
||||
'#description' => t('Setting for relcontext.'),
|
||||
'#default_value' => !empty($conf['config_item_1']) ? $conf['config_item_1'] : '',
|
||||
'#prefix' => '<div class="clear-block no-float">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Sample ctools content type that takes advantage of context.
|
||||
*
|
||||
* This example uses the context it gets (simplecontext) to demo how a
|
||||
* ctools content type can access and use context. Note that the simplecontext
|
||||
* can be either configured manually into a panel or it can be retrieved via
|
||||
* an argument.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => 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. <br />
|
||||
In our case, the configuration form (\$conf) has just one field, 'config_item_1;
|
||||
and it's configured with:
|
||||
");
|
||||
if (!empty($conf)) {
|
||||
$block->content .= '<div style="border: 1px solid red;">' . print_r(filter_xss_admin($conf['config_item_1']), TRUE) . '</div>';
|
||||
}
|
||||
if (!empty($context)) {
|
||||
$block->content .= '<br />The args ($args) were <div style="border: 1px solid yellow;" >' .
|
||||
var_export($args, TRUE) . '</div>';
|
||||
}
|
||||
$block->content .= '<br />And the simplecontext context ($context->data->description) was <div style="border: 1px solid green;" >' .
|
||||
print_r($context->data->description, TRUE) . '</div>';
|
||||
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' => '<div class="clear-block no-float">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Sample ctools context type plugin that
|
||||
* is used in this demo to create a relcontext from an existing simplecontext.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => 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' => '<div class="clear-block no-float">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
return $form;
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Sample ctools context type plugin that shows how to create a context from an arg.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => t("Simplecontext"),
|
||||
'description' => t('A single "simplecontext" context, or data element.'),
|
||||
// Func to create context.
|
||||
'context' => 'ctools_plugin_example_context_create_simplecontext',
|
||||
'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' => '<div class="clear-block no-float">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Holds the panels pages export.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_default_panel_pages()
|
||||
*/
|
||||
function ctools_plugin_example_default_panel_pages() {
|
||||
$page = new stdClass();
|
||||
$page->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 = <<<END
|
||||
<em>This page is intended to run with an arg and you don\'t have one.</em>
|
||||
<br />
|
||||
Without an arg, the page doesn\'t have any context.
|
||||
<br />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;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Sample relationship plugin.
|
||||
*
|
||||
* We take a simplecontext, look in it for what we need to make a relcontext, and make it.
|
||||
* In the real world, this might be getting a taxonomy id from a node, for example.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => 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, $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();
|
||||
}
|
1036
drupal7/web/sites/all/modules/contrib/ctools/drush/ctools.drush.inc
Normal file
1036
drupal7/web/sites/all/modules/contrib/ctools/drush/ctools.drush.inc
Normal file
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue