FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
339
sites/all/modules/contrib/admin/token/LICENSE.txt
Normal file
339
sites/all/modules/contrib/admin/token/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.
|
2
sites/all/modules/contrib/admin/token/README.txt
Normal file
2
sites/all/modules/contrib/admin/token/README.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
Provides common and resuable token UI elements and missing core tokens.
|
BIN
sites/all/modules/contrib/admin/token/arrow-down.png
Normal file
BIN
sites/all/modules/contrib/admin/token/arrow-down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 118 B |
BIN
sites/all/modules/contrib/admin/token/arrow-right.png
Normal file
BIN
sites/all/modules/contrib/admin/token/arrow-right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 127 B |
44
sites/all/modules/contrib/admin/token/jquery.treeTable.css
Normal file
44
sites/all/modules/contrib/admin/token/jquery.treeTable.css
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
/* jQuery TreeTable Core 2.0 stylesheet
|
||||
*
|
||||
* This file contains styles that are used to display the tree table. Each tree
|
||||
* table is assigned the +treeTable+ class.
|
||||
* ========================================================================= */
|
||||
|
||||
/* jquery.treeTable.collapsible
|
||||
* ------------------------------------------------------------------------- */
|
||||
.treeTable tr td .expander {
|
||||
background-position: left center;
|
||||
background-repeat: no-repeat;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
zoom: 1; /* IE7 Hack */
|
||||
}
|
||||
|
||||
.treeTable tr.collapsed td .expander {
|
||||
background-image: url(arrow-right.png);
|
||||
}
|
||||
|
||||
.treeTable tr.expanded td .expander {
|
||||
background-image: url(arrow-down.png);
|
||||
}
|
||||
|
||||
/* jquery.treeTable.sortable
|
||||
* ------------------------------------------------------------------------- */
|
||||
.treeTable tr.selected, .treeTable tr.accept {
|
||||
background-color: #3875d7;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.treeTable tr.collapsed.selected td .expander, .treeTable tr.collapsed.accept td .expander {
|
||||
background-image: url(../images/toggle-expand-light.png);
|
||||
}
|
||||
|
||||
.treeTable tr.expanded.selected td .expander, .treeTable tr.expanded.accept td .expander {
|
||||
background-image: url(../images/toggle-collapse-light.png);
|
||||
}
|
||||
|
||||
.treeTable .ui-draggable-dragging {
|
||||
color: #000;
|
||||
z-index: 1;
|
||||
}
|
220
sites/all/modules/contrib/admin/token/jquery.treeTable.js
Normal file
220
sites/all/modules/contrib/admin/token/jquery.treeTable.js
Normal file
@@ -0,0 +1,220 @@
|
||||
|
||||
/*
|
||||
* jQuery treeTable Plugin 2.3.0
|
||||
* http://ludo.cubicphuse.nl/jquery-plugins/treeTable/
|
||||
*
|
||||
* Copyright 2010, Ludo van den Boom
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*/
|
||||
(function($) {
|
||||
// Helps to make options available to all functions
|
||||
// TODO: This gives problems when there are both expandable and non-expandable
|
||||
// trees on a page. The options shouldn't be global to all these instances!
|
||||
var options;
|
||||
var defaultPaddingLeft;
|
||||
|
||||
$.fn.treeTable = function(opts) {
|
||||
options = $.extend({}, $.fn.treeTable.defaults, opts);
|
||||
|
||||
return this.each(function() {
|
||||
$(this).addClass("treeTable").find("tbody tr").each(function() {
|
||||
// Initialize root nodes only if possible
|
||||
if(!options.expandable || $(this)[0].className.search(options.childPrefix) == -1) {
|
||||
// To optimize performance of indentation, I retrieve the padding-left
|
||||
// value of the first root node. This way I only have to call +css+
|
||||
// once.
|
||||
if (isNaN(defaultPaddingLeft)) {
|
||||
defaultPaddingLeft = parseInt($($(this).children("td")[options.treeColumn]).css('padding-left'), 10);
|
||||
}
|
||||
|
||||
initialize($(this));
|
||||
} else if(options.initialState == "collapsed") {
|
||||
this.style.display = "none"; // Performance! $(this).hide() is slow...
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.treeTable.defaults = {
|
||||
childPrefix: "child-of-",
|
||||
clickableNodeNames: false,
|
||||
expandable: true,
|
||||
indent: 19,
|
||||
initialState: "collapsed",
|
||||
treeColumn: 0
|
||||
};
|
||||
|
||||
// Recursively hide all node's children in a tree
|
||||
$.fn.collapse = function() {
|
||||
$(this).addClass("collapsed");
|
||||
|
||||
childrenOf($(this)).each(function() {
|
||||
if(!$(this).hasClass("collapsed")) {
|
||||
$(this).collapse();
|
||||
}
|
||||
|
||||
this.style.display = "none"; // Performance! $(this).hide() is slow...
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Recursively show all node's children in a tree
|
||||
$.fn.expand = function() {
|
||||
$(this).removeClass("collapsed").addClass("expanded");
|
||||
|
||||
childrenOf($(this)).each(function() {
|
||||
initialize($(this));
|
||||
|
||||
if($(this).is(".expanded.parent")) {
|
||||
$(this).expand();
|
||||
}
|
||||
|
||||
// this.style.display = "table-row"; // Unfortunately this is not possible with IE :-(
|
||||
$(this).show();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Reveal a node by expanding all ancestors
|
||||
$.fn.reveal = function() {
|
||||
$(ancestorsOf($(this)).reverse()).each(function() {
|
||||
initialize($(this));
|
||||
$(this).expand().show();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Add an entire branch to +destination+
|
||||
$.fn.appendBranchTo = function(destination) {
|
||||
var node = $(this);
|
||||
var parent = parentOf(node);
|
||||
|
||||
var ancestorNames = $.map(ancestorsOf($(destination)), function(a) { return a.id; });
|
||||
|
||||
// Conditions:
|
||||
// 1: +node+ should not be inserted in a location in a branch if this would
|
||||
// result in +node+ being an ancestor of itself.
|
||||
// 2: +node+ should not have a parent OR the destination should not be the
|
||||
// same as +node+'s current parent (this last condition prevents +node+
|
||||
// from being moved to the same location where it already is).
|
||||
// 3: +node+ should not be inserted as a child of +node+ itself.
|
||||
if($.inArray(node[0].id, ancestorNames) == -1 && (!parent || (destination.id != parent[0].id)) && destination.id != node[0].id) {
|
||||
indent(node, ancestorsOf(node).length * options.indent * -1); // Remove indentation
|
||||
|
||||
if(parent) { node.removeClass(options.childPrefix + parent[0].id); }
|
||||
|
||||
node.addClass(options.childPrefix + destination.id);
|
||||
move(node, destination); // Recursively move nodes to new location
|
||||
indent(node, ancestorsOf(node).length * options.indent);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Add reverse() function from JS Arrays
|
||||
$.fn.reverse = function() {
|
||||
return this.pushStack(this.get().reverse(), arguments);
|
||||
};
|
||||
|
||||
// Toggle an entire branch
|
||||
$.fn.toggleBranch = function() {
|
||||
if($(this).hasClass("collapsed")) {
|
||||
$(this).expand();
|
||||
} else {
|
||||
$(this).removeClass("expanded").collapse();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// === Private functions
|
||||
|
||||
function ancestorsOf(node) {
|
||||
var ancestors = [];
|
||||
while(node = parentOf(node)) {
|
||||
ancestors[ancestors.length] = node[0];
|
||||
}
|
||||
return ancestors;
|
||||
};
|
||||
|
||||
function childrenOf(node) {
|
||||
return $(node).siblings("tr." + options.childPrefix + node[0].id);
|
||||
};
|
||||
|
||||
function getPaddingLeft(node) {
|
||||
var paddingLeft = parseInt(node[0].style.paddingLeft, 10);
|
||||
return (isNaN(paddingLeft)) ? defaultPaddingLeft : paddingLeft;
|
||||
}
|
||||
|
||||
function indent(node, value) {
|
||||
var cell = $(node.children("td")[options.treeColumn]);
|
||||
cell[0].style.paddingLeft = getPaddingLeft(cell) + value + "px";
|
||||
|
||||
childrenOf(node).each(function() {
|
||||
indent($(this), value);
|
||||
});
|
||||
};
|
||||
|
||||
function initialize(node) {
|
||||
if(!node.hasClass("initialized")) {
|
||||
node.addClass("initialized");
|
||||
|
||||
var childNodes = childrenOf(node);
|
||||
|
||||
if(!node.hasClass("parent") && childNodes.length > 0) {
|
||||
node.addClass("parent");
|
||||
}
|
||||
|
||||
if(node.hasClass("parent")) {
|
||||
var cell = $(node.children("td")[options.treeColumn]);
|
||||
var padding = getPaddingLeft(cell) + options.indent;
|
||||
|
||||
childNodes.each(function() {
|
||||
$(this).children("td")[options.treeColumn].style.paddingLeft = padding + "px";
|
||||
});
|
||||
|
||||
if(options.expandable) {
|
||||
cell.prepend('<span style="margin-left: -' + options.indent + 'px; padding-left: ' + options.indent + 'px" class="expander"></span>');
|
||||
$(cell[0].firstChild).click(function() { node.toggleBranch(); });
|
||||
|
||||
if(options.clickableNodeNames) {
|
||||
cell[0].style.cursor = "pointer";
|
||||
$(cell).click(function(e) {
|
||||
// Don't double-toggle if the click is on the existing expander icon
|
||||
if (e.target.className != 'expander') {
|
||||
node.toggleBranch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check for a class set explicitly by the user, otherwise set the default class
|
||||
if(!(node.hasClass("expanded") || node.hasClass("collapsed"))) {
|
||||
node.addClass(options.initialState);
|
||||
}
|
||||
|
||||
if(node.hasClass("expanded")) {
|
||||
node.expand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function move(node, destination) {
|
||||
node.insertAfter(destination);
|
||||
childrenOf(node).reverse().each(function() { move($(this), node[0]); });
|
||||
};
|
||||
|
||||
function parentOf(node) {
|
||||
var classNames = node[0].className.split(' ');
|
||||
|
||||
for(key in classNames) {
|
||||
if(classNames[key].match(options.childPrefix)) {
|
||||
return $(node).siblings("#" + classNames[key].substring(options.childPrefix.length));
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
13
sites/all/modules/contrib/admin/token/tests/token_test.info
Normal file
13
sites/all/modules/contrib/admin/token/tests/token_test.info
Normal file
@@ -0,0 +1,13 @@
|
||||
name = Token Test
|
||||
description = Testing module for token functionality.
|
||||
package = Testing
|
||||
core = 7.x
|
||||
files[] = token_test.module
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-02-24
|
||||
version = "7.x-1.5"
|
||||
core = "7.x"
|
||||
project = "token"
|
||||
datestamp = "1361665026"
|
||||
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Helper module for token tests.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_exit().
|
||||
*/
|
||||
function token_test_exit() {
|
||||
if ($debug = variable_get('token_page_tokens', array())) {
|
||||
$debug += array('tokens' => array(), 'data' => array(), 'options' => array());
|
||||
foreach (array_keys($debug['tokens']) as $token) {
|
||||
$debug['values'][$token] = token_replace($token, $debug['data'], $debug['options']);
|
||||
}
|
||||
variable_set('token_page_tokens', $debug);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_date_format_types().
|
||||
*
|
||||
* @todo Remove when http://drupal.org/node/1173706 is fixed.
|
||||
*/
|
||||
function token_test_date_format_types() {
|
||||
$info['token_test'] = t('Token test date format');
|
||||
|
||||
// Explicitly set the variable here as well.
|
||||
variable_set('date_format_token_test', 'Y');
|
||||
|
||||
return $info;
|
||||
}
|
27
sites/all/modules/contrib/admin/token/token.css
Normal file
27
sites/all/modules/contrib/admin/token/token.css
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
.token-tree {
|
||||
font-size: 0.85em;
|
||||
margin-left: 19px;
|
||||
}
|
||||
|
||||
.ui-dialog-content .token-tree {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.token-tree td, .token-tree th {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.token-group {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.js .token-group {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* Prevent the token columns from being wrapped. */
|
||||
.token-tree td.token-key {
|
||||
white-space: nowrap;
|
||||
}
|
22
sites/all/modules/contrib/admin/token/token.drush.inc
Normal file
22
sites/all/modules/contrib/admin/token/token.drush.inc
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Drush integration for the Token module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_drush_cache_clear().
|
||||
*/
|
||||
function token_drush_cache_clear(&$types) {
|
||||
if (function_exists('module_exists') && module_exists('token')) {
|
||||
$types['token'] = 'drush_token_cache_clear_token_info';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear caches internal to Token module.
|
||||
*/
|
||||
function drush_token_cache_clear_token_info() {
|
||||
token_clear_cache();
|
||||
}
|
11
sites/all/modules/contrib/admin/token/token.info
Normal file
11
sites/all/modules/contrib/admin/token/token.info
Normal file
@@ -0,0 +1,11 @@
|
||||
name = Token
|
||||
description = Provides a user interface for the Token API and some missing core tokens.
|
||||
core = 7.x
|
||||
files[] = token.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-02-24
|
||||
version = "7.x-1.5"
|
||||
core = "7.x"
|
||||
project = "token"
|
||||
datestamp = "1361665026"
|
||||
|
332
sites/all/modules/contrib/admin/token/token.install
Normal file
332
sites/all/modules/contrib/admin/token/token.install
Normal file
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the token module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_requirements().
|
||||
*/
|
||||
function token_requirements($phase = 'runtime') {
|
||||
$requirements = array();
|
||||
$t = get_t();
|
||||
|
||||
if ($phase == 'runtime') {
|
||||
// Check for various token definition problems.
|
||||
$token_problems = token_get_token_problems();
|
||||
// Format and display each token problem.
|
||||
foreach ($token_problems as $problem_key => $problem) {
|
||||
if (!empty($problem['problems'])) {
|
||||
$problems = array_unique($problem['problems']);
|
||||
$problems = array_map('check_plain', $problems);
|
||||
$token_problems[$problem_key] = $problem['label'] . theme('item_list', array('items' => $problems));
|
||||
}
|
||||
else {
|
||||
unset($token_problems[$problem_key]);
|
||||
}
|
||||
}
|
||||
if (!empty($token_problems)) {
|
||||
$requirements['token_problems'] = array(
|
||||
'title' => $t('Tokens'),
|
||||
'value' => $t('Problems detected'),
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
'description' => '<p>' . implode('</p><p>', $token_problems) . '</p>', //theme('item_list', array('items' => $token_problems)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_schema().
|
||||
*/
|
||||
function token_schema() {
|
||||
$schema['cache_token'] = drupal_get_schema_unprocessed('system', 'cache');
|
||||
$schema['cache_token']['description'] = 'Cache table for token information.';
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the cache_token table.
|
||||
*/
|
||||
function token_update_7000() {
|
||||
if (!db_table_exists('cache_token')) {
|
||||
$schema = drupal_get_schema_unprocessed('system', 'cache');
|
||||
$schema['description'] = 'Cache table for token information.';
|
||||
db_create_table('cache_token', $schema);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecate and disable the token_actions module.
|
||||
*/
|
||||
function token_update_7001() {
|
||||
module_disable(array('token_actions'));
|
||||
return 'The Token actions module has been deprecated by the updated system module actions that support tokens.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate old token_actions module actions to system actions.
|
||||
*/
|
||||
//function token_update_700X() {
|
||||
// $actions = db_query("SELECT aid, type, callback, parameters, label FROM {actions} WHERE type = 'system' AND callback IN ('token_actions_message_action', 'token_actions_send_email_action', 'token_actions_goto_action')")->fetchAll();
|
||||
// foreach ($actions as $action) {
|
||||
// $action->parameters = unserialize($action->parameters);
|
||||
// foreach ($action->parameters as $key => $value) {
|
||||
// if (is_string($value)) {
|
||||
// $action->parameters[$key] = token_update_token_text($value);
|
||||
// }
|
||||
// }
|
||||
// $action->callback = str_replace('token_actions_', '', $action->callback);
|
||||
// actions_save($action->callback, $action->type, $action->parameters, $action->label, $action->aid);
|
||||
// }
|
||||
// return 'Token actions module actions migrated to system module actions. You may still want to verify that the actions were upgraded correctly.';
|
||||
//}
|
||||
|
||||
/**
|
||||
* Build a list of Drupal 6 tokens and their Drupal 7 token names.
|
||||
*/
|
||||
function _token_upgrade_token_list() {
|
||||
$tokens = array(
|
||||
// Global tokens
|
||||
'user-name' => 'current-user:name',
|
||||
'user-id' => 'current-user:id',
|
||||
'user-mail' => 'current-user:mail',
|
||||
'site-url' => 'site:url',
|
||||
'site-name' => 'site:name',
|
||||
'site-slogan' => 'site:slogan',
|
||||
'site-mission' => 'site:mission',
|
||||
'site-mail' => 'site:mail',
|
||||
'site-date' => 'date:short',
|
||||
//'site-date-' => '', // Date tokens expanded below
|
||||
'current-page-path' => 'current-page:path',
|
||||
'current-page-url' => 'current-page:url',
|
||||
'page-number' => 'current-page:page-number',
|
||||
|
||||
// Comment tokens
|
||||
'comment-cid' => 'comment:cid',
|
||||
'comment-nid' => 'comment:node:nid',
|
||||
'comment-title' => 'comment:title',
|
||||
'comment-body' => 'comment:body',
|
||||
'comment-author-name' => 'comment:author:name',
|
||||
'comment-author-mail' => 'comment:author:mail',
|
||||
//'comment-body-format' => '',
|
||||
//'comment-' => '', // Date tokens expanded below
|
||||
'comment-node-title' => 'comment:node',
|
||||
|
||||
// Node tokens
|
||||
'nid' => 'node:nid',
|
||||
'type' => 'node:type',
|
||||
'type-name' => 'node:type-name',
|
||||
'language' => 'node:language',
|
||||
'title' => 'node:title',
|
||||
'author-uid' => 'node:author:uid',
|
||||
'author-name' => 'node:author:name',
|
||||
'author-mail' => 'node:author:mail',
|
||||
'node_comment_count' => 'node:comment-count',
|
||||
'unread_comment_count' => 'node:comment-count-new',
|
||||
'log' => 'node:log',
|
||||
//'' => '', // Date tokens expanded below
|
||||
//'mod-' => '', // Date tokens expanded below
|
||||
'menupath' => 'node:menu-link:parent:path][node:menu-link',
|
||||
'menu' => 'node:menu-link:menu-name',
|
||||
'menu-link-title' => 'node:menu-link',
|
||||
'menu-link-mlid' => 'node:menu-link:mlid',
|
||||
'menu-link-plid' => 'node:menu-link:parent:mlid',
|
||||
//'term' => 'node:term',
|
||||
//'term-id' => 'node:term:tid',
|
||||
//'vocab' => 'node:term:vocabulary',
|
||||
//'vocab-id' => 'node:term:vocabulary:vid',
|
||||
|
||||
// Book tokens
|
||||
//'book' => 'node:book',
|
||||
//'book_id' => 'node:book:bid',
|
||||
//'bookpath' => 'node:book:path',
|
||||
|
||||
// Taxonomy tokens
|
||||
'tid' => 'term:tid',
|
||||
'cat' => 'term:name',
|
||||
'cat-description' => 'term:description',
|
||||
'vid' => 'term:vocabulary:vid',
|
||||
'vocab' => 'term:vocabulary',
|
||||
'vocab-description' => 'term:vocabulary:description',
|
||||
|
||||
// User tokens
|
||||
'user' => 'user:name',
|
||||
'uid' => 'user:uid',
|
||||
'mail' => 'user:mail',
|
||||
'reg-date' => 'user:created',
|
||||
'reg-since' => 'user:created:since',
|
||||
//'user-created' => '', // Date tokens expanded below
|
||||
'log-date' => 'user:last-login',
|
||||
'log-since' => 'user:last-login:since',
|
||||
//'user-last-login' => '', // Date tokens expanded below
|
||||
//'date-in-tz' => '',
|
||||
'account-url' => 'user:url',
|
||||
'account-edit' => 'user:edit-url',
|
||||
);
|
||||
|
||||
// Account for date tokens which need to be expanded.
|
||||
$tokens += _token_upgrade_token_date_list('site-', 'site:date');
|
||||
$tokens += _token_upgrade_token_date_list('', 'node:created');
|
||||
$tokens += _token_upgrade_token_date_list('mod-', 'node:changed');
|
||||
//$tokens += _token_upgrade_token_date_list('node-revision-', 'node:changed');
|
||||
$tokens += _token_upgrade_token_date_list('comment-', 'comment:created');
|
||||
$tokens += _token_upgrade_token_date_list('user-register-', 'user:created');
|
||||
$tokens += _token_upgrade_token_date_list('user-last-login-', 'user:last-login');
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a list of Drupal 6 date tokens and their Drupal 7 token names.
|
||||
*/
|
||||
function _token_upgrade_token_date_list($old_token, $new_token) {
|
||||
$tokens = array();
|
||||
$formats = array(
|
||||
'yyyy' => 'Y',
|
||||
'yy' => 'y',
|
||||
'month' => 'F',
|
||||
'mon' => 'M',
|
||||
'mm' => 'm',
|
||||
'm' => 'n',
|
||||
'ww' => 'W',
|
||||
'date' => 'N',
|
||||
'day' => 'l',
|
||||
'ddd' => 'D',
|
||||
'dd' => 'd',
|
||||
'd' => 'j',
|
||||
);
|
||||
foreach ($formats as $token_format => $date_format) {
|
||||
$tokens[$old_token . $token_format] = "$new_token:custom:$date_format";
|
||||
}
|
||||
$tokens[$old_token . 'raw'] = "$new_token:raw";
|
||||
$tokens[$old_token . 'since'] = "$new_token:since";
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a string containing Drupal 6 style tokens to Drupal 7 style tokens.
|
||||
*
|
||||
* @param $text
|
||||
* A string containing tokens.
|
||||
* @param $updates
|
||||
* An optional array of Drupal 7 tokens keyed by their Drupal 6 token name.
|
||||
* The default tokens will be merged into this array. Note neither the old
|
||||
* or new token names should include the surrounding bracket ([ and ])
|
||||
* characters.
|
||||
* @return
|
||||
* A string with the tokens upgraded
|
||||
*
|
||||
* @see _token_upgrade_token_list()
|
||||
*/
|
||||
function token_update_token_text($text, $updates = array(), $leading = '[', $trailing = ']') {
|
||||
$updates += _token_upgrade_token_list();
|
||||
$regex = '/' . preg_quote($leading, '/') . '([^\s]*)' . preg_quote($trailing, '/') . '/';
|
||||
preg_match_all($regex, $text, $matches);
|
||||
|
||||
foreach ($matches[1] as $index => $old_token) {
|
||||
if (isset($updates[$old_token])) {
|
||||
$new_token = $updates[$old_token];
|
||||
$text = str_replace("{$leading}{$old_token}{$trailing}", "[$new_token]", $text);
|
||||
// Also replace any tokens that have a -raw suffix.
|
||||
$text = str_replace("{$leading}{$old_token}-raw{$trailing}", "[$new_token]", $text);
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get token problems.
|
||||
*/
|
||||
function token_get_token_problems() {
|
||||
// @todo Improve the duplicate checking to report which modules are the offenders.
|
||||
//$token_info = array();
|
||||
//foreach (module_implements('token_info') as $module) {
|
||||
// $module_token_info = module_invoke($module, 'token_info');
|
||||
// if (in_array($module, _token_core_supported_modules())) {
|
||||
// $module .= '/token';
|
||||
// }
|
||||
// if (isset($module_token_info['types'])) {
|
||||
// if (is_array($module_token_info['types'])) {
|
||||
// foreach (array_keys($module_token_info['types']) as $type) {
|
||||
// if (is_array($module_token_info['types'][$type])) {
|
||||
// $module_token_info['types'][$type] += array('module' => $module);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (isset($module_token_info['tokens'])) {
|
||||
// if (is_array($module_token_info['tokens'])) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// if (is_array($module_token_info)) {
|
||||
// $token_info = array_merge_recursive($token_info, $module_token_info);
|
||||
// }
|
||||
//}
|
||||
|
||||
$token_info = token_info();
|
||||
$token_problems = array(
|
||||
'not-array' => array(
|
||||
'label' => t('The following tokens or token types are not defined as arrays:'),
|
||||
),
|
||||
'missing-info' => array(
|
||||
'label' => t('The following tokens or token types are missing required name and/or description information:'),
|
||||
),
|
||||
'type-no-tokens' => array(
|
||||
'label' => t('The following token types do not have any tokens defined:'),
|
||||
),
|
||||
'tokens-no-type' => array(
|
||||
'label' => t('The following token types are not defined but have tokens:'),
|
||||
),
|
||||
'duplicate' => array(
|
||||
'label' => t('The following token or token types are defined by multiple modules:')
|
||||
),
|
||||
);
|
||||
|
||||
// Check token types for problems.
|
||||
foreach ($token_info['types'] as $type => $type_info) {
|
||||
$real_type = !empty($type_info['type']) ? $type_info['type'] : $type;
|
||||
if (!is_array($type_info)) {
|
||||
$token_problems['not-array']['problems'][] = "\$info['types']['$type']";
|
||||
continue;
|
||||
}
|
||||
elseif (!isset($type_info['name']) || !isset($type_info['description'])) {
|
||||
$token_problems['missing-info']['problems'][] = "\$info['types']['$type']";
|
||||
}
|
||||
elseif (empty($token_info['tokens'][$real_type])) {
|
||||
$token_problems['type-no-tokens']['problems'][] = "\$info['tokens']['$real_type']";
|
||||
}
|
||||
}
|
||||
|
||||
// Check tokens for problems.
|
||||
foreach ($token_info['tokens'] as $type => $tokens) {
|
||||
if (!is_array($tokens)) {
|
||||
$token_problems['not-array']['problems'][] = "\$info['tokens']['$type']";
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
foreach (array_keys($tokens) as $token) {
|
||||
if (!is_array($tokens[$token])) {
|
||||
$token_problems['not-array']['problems'][] = "\$info['tokens']['$type']['$token']";
|
||||
continue;
|
||||
}
|
||||
elseif (!isset($tokens[$token]['name']) || !isset($tokens[$token]['description'])) {
|
||||
$token_problems['missing-info']['problems'][] = "\$info['tokens']['$type']['$token']";
|
||||
}
|
||||
elseif (is_array($tokens[$token]['name']) || is_array($tokens[$token]['description'])) {
|
||||
$token_problems['duplicate']['problems'][] = "\$info['tokens']['$type']['$token']";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($token_info['types'][$type])) {
|
||||
$token_problems['tokens-no-type']['problems'][] = "\$info['types']['$type']";
|
||||
}
|
||||
}
|
||||
|
||||
return $token_problems;
|
||||
}
|
87
sites/all/modules/contrib/admin/token/token.js
Normal file
87
sites/all/modules/contrib/admin/token/token.js
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
(function ($) {
|
||||
|
||||
Drupal.behaviors.tokenTree = {
|
||||
attach: function (context, settings) {
|
||||
$('table.token-tree', context).once('token-tree', function () {
|
||||
$(this).treeTable();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.tokenDialog = {
|
||||
attach: function (context, settings) {
|
||||
$('a.token-dialog', context).once('token-dialog').click(function() {
|
||||
var url = $(this).attr('href');
|
||||
var dialog = $('<div style="display: none" class="loading">' + Drupal.t('Loading token browser...') + '</div>').appendTo('body');
|
||||
|
||||
// Emulate the AJAX data sent normally so that we get the same theme.
|
||||
var data = {};
|
||||
data['ajax_page_state[theme]'] = Drupal.settings.ajaxPageState.theme;
|
||||
data['ajax_page_state[theme_token]'] = Drupal.settings.ajaxPageState.theme_token;
|
||||
|
||||
dialog.dialog({
|
||||
title: $(this).attr('title') || Drupal.t('Available tokens'),
|
||||
width: 700,
|
||||
close: function(event, ui) {
|
||||
dialog.remove();
|
||||
}
|
||||
});
|
||||
// Load the token tree using AJAX.
|
||||
dialog.load(
|
||||
url,
|
||||
data,
|
||||
function (responseText, textStatus, XMLHttpRequest) {
|
||||
dialog.removeClass('loading');
|
||||
}
|
||||
);
|
||||
// Prevent browser from following the link.
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.behaviors.tokenInsert = {
|
||||
attach: function (context, settings) {
|
||||
// Keep track of which textfield was last selected/focused.
|
||||
$('textarea, input[type="text"]', context).focus(function() {
|
||||
Drupal.settings.tokenFocusedField = this;
|
||||
});
|
||||
|
||||
$('.token-click-insert .token-key', context).once('token-click-insert', function() {
|
||||
var newThis = $('<a href="javascript:void(0);" title="' + Drupal.t('Insert this token into your form') + '">' + $(this).html() + '</a>').click(function(){
|
||||
if (typeof Drupal.settings.tokenFocusedField == 'undefined') {
|
||||
alert(Drupal.t('First click a text field to insert your tokens into.'));
|
||||
}
|
||||
else {
|
||||
var myField = Drupal.settings.tokenFocusedField;
|
||||
var myValue = $(this).text();
|
||||
|
||||
//IE support
|
||||
if (document.selection) {
|
||||
myField.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
}
|
||||
|
||||
//MOZILLA/NETSCAPE support
|
||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
||||
var startPos = myField.selectionStart;
|
||||
var endPos = myField.selectionEnd;
|
||||
myField.value = myField.value.substring(0, startPos)
|
||||
+ myValue
|
||||
+ myField.value.substring(endPos, myField.value.length);
|
||||
} else {
|
||||
myField.value += myValue;
|
||||
}
|
||||
|
||||
$('html,body').animate({scrollTop: $(myField).offset().top}, 500);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$(this).html(newThis);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
1283
sites/all/modules/contrib/admin/token/token.module
Normal file
1283
sites/all/modules/contrib/admin/token/token.module
Normal file
File diff suppressed because it is too large
Load Diff
364
sites/all/modules/contrib/admin/token/token.pages.inc
Normal file
364
sites/all/modules/contrib/admin/token/token.pages.inc
Normal file
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* User page callbacks for the token module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Theme a link to a token tree either as a regular link or a dialog.
|
||||
*/
|
||||
function theme_token_tree_link($variables) {
|
||||
if (empty($variables['text'])) {
|
||||
$variables['text'] = t('Browse available tokens.');
|
||||
}
|
||||
|
||||
if (!empty($variables['dialog'])) {
|
||||
drupal_add_library('token', 'dialog');
|
||||
$variables['options']['attributes']['class'][] = 'token-dialog';
|
||||
}
|
||||
|
||||
$info = token_theme();
|
||||
$variables['options']['query']['options'] = array_intersect_key($variables, $info['token_tree']['variables']);
|
||||
|
||||
// We should never pass the dialog option to theme_token_tree(). It is only
|
||||
// used for this function.
|
||||
unset($variables['options']['query']['options']['dialog']);
|
||||
|
||||
// Add a security token so that the tree page should only work when used
|
||||
// when the dialog link is output with theme('token_tree_link').
|
||||
$variables['options']['query']['token'] = drupal_get_token('token-tree:' . serialize($variables['options']['query']['options']));
|
||||
|
||||
// Because PHP converts query strings with arrays into a different syntax on
|
||||
// the next request, the options have to be encoded with JSON in the query
|
||||
// string so that we can reliably decode it for token comparison.
|
||||
$variables['options']['query']['options'] = drupal_json_encode($variables['options']['query']['options']);
|
||||
|
||||
// Set the token tree to open in a separate window.
|
||||
$variables['options']['attributes'] + array('target' => '_blank');
|
||||
|
||||
return l($variables['text'], 'token/tree', $variables['options']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback to output a token tree as an empty page.
|
||||
*/
|
||||
function token_page_output_tree() {
|
||||
$options = isset($_GET['options']) ? drupal_json_decode($_GET['options']) : array();
|
||||
|
||||
// Check the token against the serialized options to prevent random access to
|
||||
// the token browser page.
|
||||
if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'token-tree:' . serialize($options))) {
|
||||
return MENU_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
// Force the dialog option to be false so we're not creating a dialog within
|
||||
// a dialog.
|
||||
$options['dialog'] = FALSE;
|
||||
|
||||
$output = theme('token_tree', $options);
|
||||
print '<html><head>' . drupal_get_css() . drupal_get_js() . '</head>';
|
||||
print '<body class="token-tree">' . $output . '</body></html>';
|
||||
drupal_exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme a tree table.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_tree_table($variables) {
|
||||
foreach ($variables['rows'] as &$row) {
|
||||
$row += array('class' => array());
|
||||
if (!empty($row['parent'])) {
|
||||
$row['class'][] = 'child-of-' . $row['parent'];
|
||||
unset($row['parent']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($variables['rows'])) {
|
||||
drupal_add_library('token', 'treeTable');
|
||||
}
|
||||
|
||||
return theme('table', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a 'tree' display of nested tokens.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_token_tree($variables) {
|
||||
if (!empty($variables['dialog'])) {
|
||||
return theme_token_tree_link($variables);
|
||||
}
|
||||
|
||||
$token_types = $variables['token_types'];
|
||||
$info = token_get_info();
|
||||
|
||||
if ($token_types == 'all') {
|
||||
$token_types = array_keys($info['types']);
|
||||
}
|
||||
elseif ($variables['global_types']) {
|
||||
$token_types = array_merge($token_types, token_get_global_token_types());
|
||||
}
|
||||
|
||||
$element = array(
|
||||
'#cache' => array(
|
||||
'cid' => 'tree-rendered:' . hash('sha256', serialize(array('token_types' => $token_types, 'global_types' => NULL) + $variables)),
|
||||
'bin' => 'cache_token',
|
||||
),
|
||||
);
|
||||
if ($cached_output = token_render_cache_get($element)) {
|
||||
return $cached_output;
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'flat' => TRUE,
|
||||
'restricted' => $variables['show_restricted'],
|
||||
'depth' => $variables['recursion_limit'],
|
||||
);
|
||||
$multiple_token_types = (count($token_types) > 1);
|
||||
$rows = array();
|
||||
|
||||
foreach ($info['types'] as $type => $type_info) {
|
||||
if (!in_array($type, $token_types)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($multiple_token_types) {
|
||||
$row = _token_token_tree_format_row($type, $type_info, TRUE);
|
||||
unset($row['data']['value']);
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$tree = token_build_tree($type, $options);
|
||||
foreach ($tree as $token => $token_info) {
|
||||
if (!empty($token_info['restricted']) && empty($variables['show_restricted'])) {
|
||||
continue;
|
||||
}
|
||||
if ($multiple_token_types && !isset($token_info['parent'])) {
|
||||
$token_info['parent'] = $type;
|
||||
}
|
||||
$row = _token_token_tree_format_row($token, $token_info);
|
||||
unset($row['data']['value']);
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$element += array(
|
||||
'#theme' => 'tree_table',
|
||||
'#header' => array(
|
||||
t('Name'),
|
||||
t('Token'),
|
||||
t('Description'),
|
||||
),
|
||||
'#rows' => $rows,
|
||||
'#attributes' => array('class' => array('token-tree')),
|
||||
'#empty' => t('No tokens available'),
|
||||
'#attached' => array(
|
||||
'js' => array(drupal_get_path('module', 'token') . '/token.js'),
|
||||
'css' => array(drupal_get_path('module', 'token') . '/token.css'),
|
||||
'library' => array(array('token', 'treeTable')),
|
||||
),
|
||||
);
|
||||
|
||||
if ($variables['click_insert']) {
|
||||
$element['#caption'] = t('Click a token to insert it into the field you\'ve last clicked.');
|
||||
$element['#attributes']['class'][] = 'token-click-insert';
|
||||
}
|
||||
|
||||
$output = drupal_render($element);
|
||||
token_render_cache_set($output, $element);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a row in the token tree.
|
||||
*/
|
||||
function _token_token_tree_format_row($token, array $token_info, $is_group = FALSE) {
|
||||
// Build a statically cached array of default values. This is around four
|
||||
// times as efficient as building the base array from scratch each time this
|
||||
// function is called.
|
||||
static $defaults = array(
|
||||
'id' => '',
|
||||
'class' => array(),
|
||||
'data' => array(
|
||||
'name' => '',
|
||||
'token' => '',
|
||||
'value' => '',
|
||||
'description' => '',
|
||||
),
|
||||
);
|
||||
|
||||
$row = $defaults;
|
||||
$row['id'] = _token_clean_css_identifier($token);
|
||||
$row['data']['name'] = $token_info['name'];
|
||||
$row['data']['description'] = $token_info['description'];
|
||||
|
||||
if ($is_group) {
|
||||
// This is a token type/group.
|
||||
$row['class'][] = 'token-group';
|
||||
}
|
||||
else {
|
||||
// This is a token.
|
||||
$row['data']['token']['data'] = $token;
|
||||
$row['data']['token']['class'][] = 'token-key';
|
||||
if (isset($token_info['value'])) {
|
||||
$row['data']['value'] = $token_info['value'];
|
||||
}
|
||||
if (!empty($token_info['parent'])) {
|
||||
$row['parent'] = _token_clean_css_identifier($token_info['parent']);
|
||||
}
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function for drupal_clean_css_identifier() for use with tokens.
|
||||
*
|
||||
* This trims any brackets from the token and also cleans the colon character
|
||||
* to a hyphen.
|
||||
*
|
||||
* @see drupal_clean_css_identifier()
|
||||
*/
|
||||
function _token_clean_css_identifier($id) {
|
||||
static $replacements = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '', ':' => '--', '?' => '', '<' => '-', '>' => '-');
|
||||
return 'token-' . rtrim(strtr(trim($id, '[]'), $replacements), '-');
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback; prints the available tokens and values for an object.
|
||||
*/
|
||||
function token_devel_token_object($entity_type, $entity, $token_type = NULL) {
|
||||
$header = array(
|
||||
t('Token'),
|
||||
t('Value'),
|
||||
);
|
||||
$rows = array();
|
||||
|
||||
$options = array(
|
||||
'flat' => TRUE,
|
||||
'values' => TRUE,
|
||||
'data' => array($entity_type => $entity),
|
||||
);
|
||||
if (!isset($token_type)) {
|
||||
$token_type = $entity_type;
|
||||
}
|
||||
$tree = token_build_tree($token_type, $options);
|
||||
foreach ($tree as $token => $token_info) {
|
||||
if (!empty($token_info['restricted'])) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($token_info['value']) && !empty($token_info['parent']) && !isset($tree[$token_info['parent']]['value'])) {
|
||||
continue;
|
||||
}
|
||||
$row = _token_token_tree_format_row($token, $token_info);
|
||||
unset($row['data']['description']);
|
||||
unset($row['data']['name']);
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$build['tokens'] = array(
|
||||
'#theme' => 'tree_table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#attributes' => array('class' => array('token-tree')),
|
||||
'#empty' => t('No tokens available.'),
|
||||
'#attached' => array(
|
||||
'js' => array(drupal_get_path('module', 'token') . '/token.js'),
|
||||
'css' => array(drupal_get_path('module', 'token') . '/token.css'),
|
||||
),
|
||||
);
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback to clear the token registry caches.
|
||||
*/
|
||||
function token_flush_cache_callback() {
|
||||
if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], current_path())) {
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
token_clear_cache();
|
||||
drupal_set_message(t('Token registry caches cleared.'));
|
||||
drupal_goto();
|
||||
}
|
||||
|
||||
function token_autocomplete() {
|
||||
$args = func_get_args();
|
||||
$string = implode('/', $args);
|
||||
|
||||
$token_info = token_info();
|
||||
|
||||
preg_match_all('/\[([^\s\]:]*):?([^\s\]]*)?\]?/', $string, $matches);
|
||||
$types = $matches[1];
|
||||
$tokens = $matches[2];
|
||||
|
||||
foreach ($types as $index => $type) {
|
||||
if (!empty($tokens[$index]) || isset($token_info['types'][$type])) {
|
||||
token_autocomplete_token($type, $tokens[$index]);
|
||||
}
|
||||
else {
|
||||
token_autocomplete_type($type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function token_autocomplete_type($string = '') {
|
||||
$token_info = token_info();
|
||||
$types = $token_info['types'];
|
||||
$matches = array();
|
||||
|
||||
foreach ($types as $type => $info) {
|
||||
if (!$string || strpos($type, $string) === 0) {
|
||||
$type_key = "[{$type}:";
|
||||
$matches[$type_key] = levenshtein($type, $string);
|
||||
}
|
||||
}
|
||||
|
||||
if ($string) {
|
||||
asort($matches);
|
||||
}
|
||||
else {
|
||||
ksort($matches);
|
||||
}
|
||||
|
||||
$matches = drupal_map_assoc(array_keys($matches));
|
||||
drupal_json_output($matches);
|
||||
}
|
||||
|
||||
function token_autocomplete_token($token_type) {
|
||||
$args = func_get_args();
|
||||
array_shift($args);
|
||||
$string = trim(implode('/', $args));
|
||||
$string = substr($string, strrpos($string, '['));
|
||||
|
||||
$token_type = $token_type['type'];
|
||||
$matches = array();
|
||||
|
||||
if (!drupal_strlen($string)) {
|
||||
$matches["[{$token_type}:"] = 0;
|
||||
}
|
||||
else {
|
||||
$depth = max(1, substr_count($string, ':'));
|
||||
$tree = token_build_tree($token_type, array('flat' => TRUE, 'depth' => $depth));
|
||||
foreach (array_keys($tree) as $token) {
|
||||
if (strpos($token, $string) === 0) {
|
||||
$matches[$token] = levenshtein($token, $string);
|
||||
if (isset($tree[$token]['children'])) {
|
||||
$token = rtrim($token, ':]') . ':';
|
||||
$matches[$token] = levenshtein($token, $string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asort($matches);
|
||||
$matches = drupal_map_assoc(array_keys($matches));
|
||||
drupal_json_output($matches);
|
||||
}
|
1095
sites/all/modules/contrib/admin/token/token.test
Normal file
1095
sites/all/modules/contrib/admin/token/token.test
Normal file
File diff suppressed because it is too large
Load Diff
1460
sites/all/modules/contrib/admin/token/token.tokens.inc
Normal file
1460
sites/all/modules/contrib/admin/token/token.tokens.inc
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user