first import
This commit is contained in:
274
sites/all/modules/devel_themer/LICENSE.txt
Normal file
274
sites/all/modules/devel_themer/LICENSE.txt
Normal file
@@ -0,0 +1,274 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
|
||||
Cambridge, MA 02139, 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 Library 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
|
174
sites/all/modules/devel_themer/devel_themer.css
Normal file
174
sites/all/modules/devel_themer/devel_themer.css
Normal file
@@ -0,0 +1,174 @@
|
||||
.field-tip {
|
||||
position: absolute;
|
||||
padding: 3px 5px;
|
||||
}
|
||||
.field-label {
|
||||
background: #000;
|
||||
z-index: 10001;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#themer-fixeder {
|
||||
position:fixed;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
#themer-relativer {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#themer-popup {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
font-family: "lucida grande", helvetica, arial, sans-serif;
|
||||
text-align: left;
|
||||
color: #FFFFFF;
|
||||
background-color: #333;
|
||||
width: 400px;
|
||||
font-size: 10px;
|
||||
opacity:.9;
|
||||
filter: alpha(opacity=90);
|
||||
border: 1px solid #000;
|
||||
display: none;
|
||||
z-index: 10001;
|
||||
}
|
||||
|
||||
#themer-popup h2, #themer-popup h3, #themer-popup h4 {
|
||||
font-family: "lucida grande", helvetica, arial, sans-serif;
|
||||
}
|
||||
|
||||
#themer-popup a, #themer-popup a:visited, #themer-popup span.parent {
|
||||
color: #FFF;
|
||||
text-decoration: none;
|
||||
font-weight: normal;
|
||||
margin-bottom: -4px;
|
||||
border-bottom:1px dotted #666666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#themer-popup .topper {
|
||||
text-align: center;
|
||||
padding: 0 5px;
|
||||
height: 20px;
|
||||
background-color:#666;
|
||||
background-image: url(themer-bar.png);
|
||||
background-repeat: repeat-x;
|
||||
cursor: move;
|
||||
}
|
||||
#themer-popup .close {
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
#themer-popup .starter {
|
||||
font-size:2em;
|
||||
}
|
||||
|
||||
#themer-popup #parents {
|
||||
padding-top: 5px;
|
||||
background-color: #222;
|
||||
color: #999;
|
||||
}
|
||||
#themer-popup .row {
|
||||
padding: 0 5px 5px;
|
||||
border-top: 1px solid #777;
|
||||
}
|
||||
#themer-popup dl {
|
||||
margin: 0;
|
||||
}
|
||||
#themer-popup dt {
|
||||
|
||||
}
|
||||
#themer-popup dd {
|
||||
margin: 0 0 0 15px;
|
||||
display:block;
|
||||
}
|
||||
#themer-popup dd.candidates .delimiter, #themer-popup dd.preprocessors .delimiter {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#themer-popup .devel-obj-output,
|
||||
#themer-popup .krumo-root {
|
||||
max-height: 250px;
|
||||
overflow: auto;
|
||||
}
|
||||
#themer-popup .devel-obj-output dt {
|
||||
cursor: pointer;
|
||||
}
|
||||
#themer-popup .devel-obj-output dd {
|
||||
display: none;
|
||||
}
|
||||
#themer-popup .devel-obj-output .field {
|
||||
color: #CCC;
|
||||
}
|
||||
|
||||
#themer-popup .info .key {
|
||||
font-size: 18px;
|
||||
}
|
||||
#themer-popup .info dt,
|
||||
#themer-popup .info .dt {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#themer-popup h4 {
|
||||
margin: 0;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
font-weight:normal;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#themer-popup .item-list ul li {
|
||||
background: none;
|
||||
list-style: none;
|
||||
padding: 0 0 0 .5em;
|
||||
margin: 0;
|
||||
text-indent: -.5em;
|
||||
}
|
||||
#themer-popup .item-list ul li:before {
|
||||
content: "- ";
|
||||
}
|
||||
|
||||
#themer-popup img.throbber {
|
||||
position:absolute;
|
||||
left:3px;
|
||||
top:2px;
|
||||
}
|
||||
|
||||
#themer-toggle {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
padding: 3px 5px;
|
||||
background: #fff;
|
||||
color: #008;
|
||||
cursor: pointer;
|
||||
z-index: 10002;
|
||||
font-size: 13px;
|
||||
background-color: #333;
|
||||
opacity: .8;
|
||||
color: #FFF;
|
||||
border-top: 1px solid #000;
|
||||
border-right: 1px solid #000;
|
||||
}
|
||||
|
||||
#themer-popup div.krumo-element {
|
||||
background: #222222;
|
||||
}
|
||||
|
||||
#themer-popup div.krumo-expand {
|
||||
background: #999999;
|
||||
}
|
||||
|
||||
#themer-popup div.krumo-hover {
|
||||
background: #000;
|
||||
}
|
||||
|
||||
#themer-popup div.krumo-preview {
|
||||
background: #494949;
|
||||
}
|
||||
|
||||
#themer-popup li.krumo-footnote {
|
||||
display: none;
|
||||
}
|
12
sites/all/modules/devel_themer/devel_themer.info
Normal file
12
sites/all/modules/devel_themer/devel_themer.info
Normal file
@@ -0,0 +1,12 @@
|
||||
name = Theme developer
|
||||
description = Essential theme API information for theme developers
|
||||
package = Development
|
||||
dependencies[] = devel
|
||||
core = 7.x
|
||||
files[] = devel_themer.module
|
||||
; Information added by drupal.org packaging script on 2011-09-04
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "devel_themer"
|
||||
datestamp = "1315138343"
|
||||
|
39
sites/all/modules/devel_themer/devel_themer.install
Normal file
39
sites/all/modules/devel_themer/devel_themer.install
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install and uninstall hooks for theme developer
|
||||
*
|
||||
*/
|
||||
function devel_themer_requirements($phase) {
|
||||
// Ensure translations don't break at install time
|
||||
$t = get_t();
|
||||
|
||||
if ($phase == 'install' || $phase == 'runtime') {
|
||||
// we need the Optimizer check function
|
||||
drupal_load('module', 'devel');
|
||||
|
||||
if (!devel_is_compatible_optimizer()) {
|
||||
$requirements['optimizer'] = array(
|
||||
'title' => $t('Zend Optimizer'),
|
||||
'description' => $t('You must disable or upgrade the php Zend Optimizer extension in order to enable this feature. The minimum required version is 3.2.8. Earlier versions of Zend Optimizer are <a href="!url">horribly buggy and segfault your Apache.', array('!url' => url('http://drupal.org/node/126098'))),
|
||||
'severity' => REQUIREMENT_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
return isset($requirements) ? $requirements : array();
|
||||
}
|
||||
|
||||
function devel_themer_update_6000() {
|
||||
$ret = array();
|
||||
drupal_install_schema('devel_themer');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// We are now using a file based cache to avoid max_packet_size warning.
|
||||
function devel_themer_update_6001() {
|
||||
$ret = array();
|
||||
db_drop_table($ret, 'cache_devel_themer');
|
||||
return $ret;
|
||||
}
|
||||
|
282
sites/all/modules/devel_themer/devel_themer.js
Normal file
282
sites/all/modules/devel_themer/devel_themer.js
Normal file
@@ -0,0 +1,282 @@
|
||||
|
||||
(function ($) {
|
||||
|
||||
$(document).ready(function () {
|
||||
lastObj = false;
|
||||
thmrSpanified = false;
|
||||
strs = Drupal.settings.thmrStrings;
|
||||
$('body').addClass("thmr_call").attr("id", "thmr_" + Drupal.settings.page_id);
|
||||
$('[thmr]')
|
||||
.hover(
|
||||
function () {
|
||||
if (themerEnabled && this.parentNode.nodeName != 'BODY' && $(this).attr('thmr_curr') != 1) {
|
||||
$(this).css('outline', 'red solid 1px');
|
||||
}
|
||||
},
|
||||
function () {
|
||||
if (themerEnabled && $(this).attr('thmr_curr') != 1) {
|
||||
$(this).css('outline', 'none');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
var themerEnabled = 0;
|
||||
var themerToggle = function () {
|
||||
themerEnabled = 1 - themerEnabled;
|
||||
$('#themer-toggle :checkbox').attr('checked', themerEnabled ? 'checked' : '');
|
||||
$('#themer-popup').css('display', themerEnabled ? 'block' : 'none');
|
||||
if (themerEnabled) {
|
||||
document.onclick = themerEvent;
|
||||
if (lastObj != false) {
|
||||
$(lastObj).css('outline', '3px solid #999');
|
||||
}
|
||||
if (!thmrSpanified) {
|
||||
spanify();
|
||||
}
|
||||
}
|
||||
else {
|
||||
document.onclick = null;
|
||||
if (lastObj != false) {
|
||||
$(lastObj).css('outline', 'none');
|
||||
}
|
||||
}
|
||||
};
|
||||
$(Drupal.settings.thmr_popup)
|
||||
.appendTo($('body'));
|
||||
|
||||
$('<div id="themer-toggle"><input type="checkbox" />'+ strs.themer_info +'</div>')
|
||||
.appendTo($('body'))
|
||||
.click(themerToggle);
|
||||
$('#themer-popup').resizable();
|
||||
$('#themer-popup')
|
||||
.draggable({
|
||||
opacity: .6,
|
||||
handle: $('#themer-popup .topper')
|
||||
})
|
||||
.prepend(strs.toggle_throbber)
|
||||
;
|
||||
|
||||
// close box
|
||||
$('#themer-popup .topper .close').click(function() {
|
||||
themerToggle();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Known issue: IE does NOT support outline css property.
|
||||
* Solution: use another browser
|
||||
*/
|
||||
function themerHilight(obj) {
|
||||
// hilight the current object (and un-highlight the last)
|
||||
if (lastObj != false) {
|
||||
$(lastObj).css('outline', 'none').attr('thmr_curr', 0);
|
||||
}
|
||||
$(obj).css('outline', '#999 solid 3px').attr('thmr_curr', 1);
|
||||
lastObj = obj;
|
||||
}
|
||||
|
||||
function themerDoIt(obj) {
|
||||
if (thmrInPop(obj)) {
|
||||
return true;
|
||||
}
|
||||
// start throbber
|
||||
//$('#themer-popup img.throbber').show();
|
||||
var objs = thmrFindParents(obj);
|
||||
if (objs.length) {
|
||||
themerHilight(objs[0]);
|
||||
thmrRebuildPopup(objs);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function spanify() {
|
||||
$('span[thmr]')
|
||||
.each(function () {
|
||||
// make spans around block elements into block elements themselves
|
||||
var kids = $(this).children();
|
||||
for(i=0;i<kids.length;i++) {
|
||||
//console.log(kids[i].style.display);
|
||||
if ($(kids[i]).css('display') != 'inline' && $(kids[i]).is('DIV, P, ADDRESS, BLOCKQUOTE, CENTER, DIR, DL, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HR, ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL, PRE, TABLE, UL, DD, DT, FRAMESET, LI, TBODY, TD, TFOOT, TH, THEAD, TR')) {
|
||||
$(this).css('display', 'block');
|
||||
}
|
||||
}
|
||||
});
|
||||
thmrSpanified = true;
|
||||
// turn off the throbber
|
||||
//$('#themer-toggle img.throbber').hide();
|
||||
}
|
||||
|
||||
function thmrInPop(obj) {
|
||||
//is the element in either the popup box or the toggle div?
|
||||
if (obj.id == "themer-popup" || obj.id == "themer-toggle") return true;
|
||||
if (obj.parentNode) {
|
||||
while (obj = obj.parentNode) {
|
||||
if (obj.id=="themer-popup" || obj.id == "themer-toggle") return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function themerEvent(e) {
|
||||
if (!e) {
|
||||
var e = window.event;
|
||||
};
|
||||
if (e.target) var tg = e.target;
|
||||
else if (e.srcElement) var tg = e.srcElement;
|
||||
return themerDoIt(tg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all parents with @thmr"
|
||||
*/
|
||||
function thmrFindParents(obj) {
|
||||
var parents = new Array();
|
||||
if ($(obj).attr('thmr') != undefined) {
|
||||
parents[parents.length] = obj;
|
||||
}
|
||||
if (obj && obj.parentNode) {
|
||||
while ((obj = obj.parentNode) && (obj.nodeType != 9)) {
|
||||
if ($(obj).attr('thmr') != undefined) {
|
||||
parents[parents.length] = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if object is a block element
|
||||
*/
|
||||
function thmrIsBlock(obj) {
|
||||
if (obj.style.display == 'block') {
|
||||
return true;
|
||||
}
|
||||
else if (obj.style.display == 'inline' || obj.style.display == 'none') {
|
||||
return false;
|
||||
}
|
||||
if (obj.tagName != undefined) {
|
||||
var i = blocks.length;
|
||||
if (i > 0) {
|
||||
do {
|
||||
if (blocks[i] === obj.tagName) {
|
||||
return true;
|
||||
}
|
||||
} while (i--);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function thmrRefreshCollapse() {
|
||||
$('#themer-popup .devel-obj-output dt').each(function() {
|
||||
$(this).toggle(function() {
|
||||
$(this).parent().children('dd').show();
|
||||
}, function() {
|
||||
$(this).parent().children('dd').hide();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild the popup
|
||||
*
|
||||
* @param objs
|
||||
* The array of the current object and its parents. Current object is first element of the array
|
||||
*/
|
||||
function thmrRebuildPopup(objs) {
|
||||
// rebuild the popup box
|
||||
var id = objs[0].getAttribute('thmr');
|
||||
// vars is the settings array element for this theme item
|
||||
var vars = Drupal.settings[id];
|
||||
// strs is the translatable strings
|
||||
var strs = Drupal.settings.thmrStrings;
|
||||
var type = vars.type;
|
||||
var key = vars.used;
|
||||
|
||||
// clear out the initial "click on any element" starter text
|
||||
$('#themer-popup div.starter').empty();
|
||||
|
||||
if (type == 'func') {
|
||||
// populate the function name
|
||||
$('#themer-popup dd.key').empty().prepend('<a href="'+ strs.api_site +'api/search/'+ strs.drupal_version +'/'+ key +'" title="'+ strs.drupal_api_docs +'">'+ key +'()</a>');
|
||||
$('#themer-popup dt.key-type').empty().prepend(strs.function_called);
|
||||
}
|
||||
else {
|
||||
// populate the template name
|
||||
$('#themer-popup dd.key').empty().prepend(key);
|
||||
$('#themer-popup dt.key-type').empty().prepend(strs.template_called);
|
||||
}
|
||||
|
||||
// parents
|
||||
var parents = '';
|
||||
parents = strs.parents +' <span class="parents">';
|
||||
for(i=1;i<objs.length;i++) {
|
||||
var thmrid = $(objs[i]).attr('thmr')
|
||||
var pvars = Drupal.settings[thmrid];
|
||||
parents += i!=1 ? '< ' : '';
|
||||
// populate the parents
|
||||
// each parent is wrapped with a span containing a 'trig' attribute with the id of the element it represents
|
||||
parents += '<span class="parent" trig="'+ thmrid +'">'+ pvars.name +'</span> ';
|
||||
}
|
||||
parents += '</span>';
|
||||
// stick the parents spans in the #parents div
|
||||
$('#themer-popup #parents').empty().prepend(parents);
|
||||
$('#themer-popup span.parent')
|
||||
.click(function() {
|
||||
var thmr_id = $(this).attr('trig');
|
||||
var thmr_obj = $('[thmr = "' + thmr_id + '"]')[0];
|
||||
themerDoIt(thmr_obj);
|
||||
})
|
||||
.hover(
|
||||
function() {
|
||||
// make them highlight their element on mouseover
|
||||
$('#'+ $(this).attr('trig')).trigger('mouseover');
|
||||
},
|
||||
function() {
|
||||
// and unhilight on mouseout
|
||||
$('#'+ $(this).attr('trig')).trigger('mouseout');
|
||||
}
|
||||
);
|
||||
|
||||
if (vars == undefined) {
|
||||
// if there's no item in the settings array for this element
|
||||
$('#themer-popup dd.candidates').empty();
|
||||
$('#themer-popup dd.preprocessors').empty();
|
||||
$('#themer-popup div.attributes').empty();
|
||||
$('#themer-popup div.used').empty();
|
||||
$('#themer-popup div.duration').empty();
|
||||
}
|
||||
else {
|
||||
$('#themer-popup div.duration').empty().prepend('<span class="dt">' + strs.duration + '</span>' + vars.duration + ' ms');
|
||||
$('#themer-popup dd.candidates').empty().prepend(vars.candidates.join('<span class="delimiter"> < </span>'));
|
||||
$('#themer-popup dd.preprocessors').empty().prepend(vars.preprocessors.join('<span class="delimiter"> + </span>'));
|
||||
$('#themer-popup dt.preprocessors-type').empty().prepend(strs.preprocessors);
|
||||
$('#themer-popup dd.processors').empty().prepend(vars.processors.join('<span class="delimiter"> + </span>'));
|
||||
$('#themer-popup dt.processors-type').empty().prepend(strs.processors);
|
||||
|
||||
var uri = Drupal.settings.devel_themer_uri + '/' + id;
|
||||
if (type == 'func') {
|
||||
// populate the candidates
|
||||
$('#themer-popup dt.candidates-type').empty().prepend(strs.candidate_functions);
|
||||
}
|
||||
else {
|
||||
$('#themer-popup dt.candidates-type').empty().prepend(strs.candidate_files);
|
||||
}
|
||||
|
||||
// Use drupal ajax to do what we need
|
||||
vars_div_array = $('div.themer-variables');
|
||||
vars_div = vars_div_array[0];
|
||||
|
||||
// Programatically using the drupal ajax things is tricky, so cheat.
|
||||
dummy_link = $('<a href="'+uri+'" class="use-ajax">Loading Vars</a>');
|
||||
$(vars_div).append(dummy_link);
|
||||
Drupal.attachBehaviors(vars_div);
|
||||
dummy_link.click();
|
||||
|
||||
thmrRefreshCollapse();
|
||||
}
|
||||
// stop throbber
|
||||
//$('#themer-popup img.throbber').hide();
|
||||
}
|
||||
|
||||
})(jQuery);
|
676
sites/all/modules/devel_themer/devel_themer.module
Normal file
676
sites/all/modules/devel_themer/devel_themer.module
Normal file
@@ -0,0 +1,676 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function devel_themer_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/development/devel_themer'] = array(
|
||||
'title' => 'Devel Themer',
|
||||
'description' => 'Display or hide the textual template log',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('devel_themer_admin_settings'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
$items['devel_themer/variables'] = array(
|
||||
'title' => 'Theme Development AJAX variables',
|
||||
'page callback' => 'devel_themer_ajax_variables',
|
||||
'delivery callback' => 'ajax_deliver',
|
||||
'access arguments' => array('access devel information'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* A menu callback used by popup to retrieve variables from cache for a recent page.
|
||||
*
|
||||
* @param $request_id
|
||||
* A unique key that is sent to the browser in Drupal.Settings.devel_themer_request_id
|
||||
* @param $call
|
||||
* The theme call for which you wish to retrieve variables.
|
||||
* @return string
|
||||
* A chunk of HTML with the devel_print_object() rendering of the variables.
|
||||
*/
|
||||
function devel_themer_ajax_variables($request_id, $call) {
|
||||
$file = "temporary://devel_themer_$request_id";
|
||||
if ($data = unserialize(file_get_contents($file))) {
|
||||
$variables = $data[$call]['variables'];
|
||||
if (has_krumo()) {
|
||||
$content = krumo_ob($variables);
|
||||
}
|
||||
elseif ($data[$call]['type'] == 'func') {
|
||||
$content = $variables;
|
||||
}
|
||||
else {
|
||||
$content = $variables;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$content = 'Ajax variables file not found. -' . check_plain($file);
|
||||
}
|
||||
|
||||
$commands[] = ajax_command_replace('div.themer-variables', '<div class="themer-variables">' . $content . '</div>');
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
}
|
||||
|
||||
function devel_themer_admin_settings() {
|
||||
$form['devel_themer_log'] = array('#type' => 'checkbox',
|
||||
'#title' => t('Display theme log'),
|
||||
'#default_value' => variable_get('devel_themer_log', FALSE),
|
||||
'#description' => t('Display the list of theme templates and theme functions which could have been be used for a given page. The one that was actually used is bolded. This is the same data as the represented in the popup, but all calls are listed in chronological order and can alternately be sorted by time.'),
|
||||
);
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
|
||||
function devel_themer_init() {
|
||||
if (user_access('access devel information')) {
|
||||
// Add requisite libraries.
|
||||
drupal_add_library('system', 'jquery.form');
|
||||
drupal_add_library('system', 'drupal.ajax');
|
||||
drupal_add_library('system', 'ui.draggable');
|
||||
drupal_add_library('system', 'ui.resizable');
|
||||
|
||||
// Add this module's JS and CSS.
|
||||
$path = drupal_get_path('module', 'devel_themer');
|
||||
drupal_add_js($path . '/devel_themer.js');
|
||||
drupal_add_css($path . '/devel_themer.css');
|
||||
drupal_add_css($path . '/devel_themer_ie_fix.css', array('browsers' => array('IE' => TRUE, '!IE' => FALSE), 'media' => 'screen', 'weight' => 20, 'preprocess' => FALSE));
|
||||
|
||||
// Add krumo JS and CSS. We can't rely on krumo automatically doing this,
|
||||
// because we add our HTML dynamically after initial page load.
|
||||
if (has_krumo()) {
|
||||
$path_to_devel = drupal_get_path('module', 'devel');
|
||||
// Krumo files don't work correctly when aggregated.
|
||||
drupal_add_js($path_to_devel . '/krumo/krumo.js', array('preprocess' => FALSE));
|
||||
drupal_add_css($path_to_devel . '/krumo/skins/default/skin.css', array('preprocess' => FALSE));
|
||||
}
|
||||
|
||||
devel_themer_popup();
|
||||
|
||||
if (!devel_silent() && variable_get('devel_themer_log', FALSE)) {
|
||||
register_shutdown_function('devel_themer_shutdown');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function devel_themer_shutdown() {
|
||||
print devel_themer_log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all theme templates and functions that could have been used on this page.
|
||||
**/
|
||||
|
||||
function devel_themer_log() {
|
||||
if (isset($GLOBALS['devel_theme_calls'])) {
|
||||
foreach ($GLOBALS['devel_theme_calls'] as $counter => $call) {
|
||||
// Sometimes $call is a string. Not sure why.
|
||||
if (is_array($call)) {
|
||||
$id = "devel_theme_log_link_$counter";
|
||||
$marker = "<div id=\"$id\" class=\"devel_theme_log_link\"></div>\n";
|
||||
|
||||
$used = $call['used'];
|
||||
if ($call['type'] == 'func') {
|
||||
$name = $call['name'] . '()';
|
||||
foreach ($call['candidates'] as $item) {
|
||||
if ($item == $used) {
|
||||
$items[] = "<strong>$used</strong>";
|
||||
}
|
||||
else {
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$name = $call['name'];
|
||||
foreach ($call['candidates'] as $item) {
|
||||
if ($item == basename($used)) {
|
||||
$items[] = "<strong>$used</strong>";
|
||||
}
|
||||
else {
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
$rows[] = array($call['duration'], $marker . $name, implode(', ', $items));
|
||||
unset($items);
|
||||
}
|
||||
}
|
||||
$header = array('Duration (ms)', 'Template/Function', "Candidate template files or function names");
|
||||
$output = theme('table', $header, $rows);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_registry_alter().
|
||||
*
|
||||
* Route all theme hooks to devel_themer_catch_function().
|
||||
*/
|
||||
function devel_themer_theme_registry_alter(&$theme_registry) {
|
||||
foreach ($theme_registry as $hook => $data) {
|
||||
if (isset($theme_registry[$hook]['function'])) {
|
||||
// If the hook is a function, store it so it can be run after it has been intercepted.
|
||||
// This does not apply to template calls.
|
||||
$theme_registry[$hook]['devel_function_intercept'] = $theme_registry[$hook]['function'];
|
||||
}
|
||||
// Add our catch function to intercept functions as well as templates.
|
||||
$theme_registry[$hook]['function'] = 'devel_themer_catch_function';
|
||||
|
||||
// Remove the process and preprocess functions so they are
|
||||
// only called by devel_themer_theme_twin().
|
||||
$theme_registry[$hook]['devel_function_preprocess_intercept'] = isset($theme_registry[$hook]['preprocess functions']) ? $theme_registry[$hook]['preprocess functions'] : array();
|
||||
$theme_registry[$hook]['devel_function_process_intercept'] = isset($theme_registry[$hook]['process functions']) ? $theme_registry[$hook]['process functions'] : array();
|
||||
$theme_registry[$hook]['preprocess functions'] = array();
|
||||
$theme_registry[$hook]['process functions'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_module_implements_alter().
|
||||
*
|
||||
* Ensure devel_themer_theme_registry_alter() runs as late as possible.
|
||||
*/
|
||||
function devel_themer_module_implements_alter(&$implementations, $hook) {
|
||||
if ($hook == 'theme_registry_alter') {
|
||||
// Unsetting and resetting moves the item to the end of the array.
|
||||
$group = $implementations['devel_themer'];
|
||||
unset($implementations['devel_themer']);
|
||||
$implementations['devel_themer'] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercepts all theme calls (including templates), adds to template log, and dispatches to original theme function.
|
||||
*/
|
||||
function devel_themer_catch_function() {
|
||||
$trace = debug_backtrace(FALSE);
|
||||
$hook = $trace[1]['args'][0];
|
||||
if (sizeof($trace[1]['args']) > 1) {
|
||||
$variables = $trace[1]['args'][1];
|
||||
}
|
||||
else {
|
||||
$variables = array();
|
||||
}
|
||||
|
||||
$counter = devel_counter();
|
||||
$variables['thmr_key'] = "thmr_" . $counter;
|
||||
$timer_name = "thmr_$counter";
|
||||
timer_start($timer_name);
|
||||
|
||||
// The twin of theme(). All rendering done through here.
|
||||
list($return, $meta) = devel_themer_theme_twin($hook, $variables);
|
||||
$time = timer_stop($timer_name);
|
||||
|
||||
if (!empty($return) && !is_array($return) && !is_object($return) && user_access('access devel information')) {
|
||||
$key = "thmr_$counter";
|
||||
|
||||
// Check for themer attribute in content returned. Apply word boundaries so
|
||||
// that 'thmr_10' doesn't match 'thmr_1'.
|
||||
if (!preg_match("/\\b$key\\b/", $return)) {
|
||||
// Exclude wrapping a SPAN around content returned by theme functions
|
||||
// whose result is not intended for HTML usage.
|
||||
$exclude = array('options_none');
|
||||
|
||||
// theme_html_tag() is a low-level theme function intended primarily for
|
||||
// markup added to the document HEAD.
|
||||
$exclude[] = 'html_tag';
|
||||
|
||||
if (!in_array($hook, $exclude)) {
|
||||
$return = '<span thmr="' . $key . '">' . $return . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($meta['type'] == 'func') {
|
||||
$name = $meta['name'];
|
||||
$used = $meta['used'];
|
||||
if (empty($meta['wildcards'])) {
|
||||
$meta['wildcards'] = array($hook);
|
||||
}
|
||||
$candidates = $meta['wildcards'];
|
||||
if (empty($meta['variables'])) {
|
||||
$variables = array();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$name = $meta['name'];
|
||||
if (empty($suggestions)) {
|
||||
array_unshift($meta['suggestions'], $meta['used']);
|
||||
}
|
||||
$candidates = array_reverse($meta['suggestions']);
|
||||
$used = $meta['used'];
|
||||
}
|
||||
|
||||
|
||||
// Set preprocessors.
|
||||
if (isset($meta['processor_functions']['preprocess functions'])) {
|
||||
$preprocessors = $meta['processor_functions']['preprocess functions'];
|
||||
}
|
||||
else {
|
||||
$preprocessors = array();
|
||||
}
|
||||
|
||||
// Set processors.
|
||||
if (isset($meta['processor_functions']['process functions'])) {
|
||||
$processors = $meta['processor_functions']['process functions'];
|
||||
}
|
||||
else {
|
||||
$processors = array();
|
||||
}
|
||||
|
||||
// This variable gets sent to the browser in Drupal.settings.
|
||||
$GLOBALS['devel_theme_calls'][$key] = array(
|
||||
'id' => $key,
|
||||
'name' => $name,
|
||||
'used' => $used,
|
||||
'type' => $meta['type'],
|
||||
'duration' => $time['time'],
|
||||
'candidates' => $candidates,
|
||||
'preprocessors' => $preprocessors,
|
||||
'processors' => $processors,
|
||||
);
|
||||
|
||||
// Remove some things from variables to reduce size of item in crumo
|
||||
unset($meta['variables']['page']);
|
||||
|
||||
// This variable gets serialized and cached on the server.
|
||||
$GLOBALS['devel_themer_server'][$key] = array(
|
||||
'variables' => $meta['variables'],
|
||||
'type' => $meta['type'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$output = $return;
|
||||
}
|
||||
return isset($output) ? $output : $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Near clone of theme().
|
||||
*/
|
||||
function devel_themer_theme_twin($hook, $variables) {
|
||||
static $hooks = NULL;
|
||||
$thmr_key = $variables['thmr_key'];
|
||||
unset($variables['thmr_key']);
|
||||
$meta = array();
|
||||
$meta['name'] = $hook;
|
||||
|
||||
// If called before all modules are loaded, we do not necessarily have a full
|
||||
// theme registry to work with, and therefore cannot process the theme
|
||||
// request properly. See also _theme_load_registry().
|
||||
if (!module_load_all(NULL) && !defined('MAINTENANCE_MODE')) {
|
||||
throw new Exception(t('theme() may not be called until all modules are loaded.'));
|
||||
}
|
||||
|
||||
if (!isset($hooks)) {
|
||||
drupal_theme_initialize();
|
||||
$hooks = theme_get_registry();
|
||||
}
|
||||
|
||||
// If an array of hook candidates were passed, use the first one that has an
|
||||
// implementation.
|
||||
if (is_array($hook)) {
|
||||
foreach ($hook as $candidate) {
|
||||
if (isset($hooks[$candidate])) {
|
||||
break;
|
||||
}
|
||||
$meta['wildcards'][] = $candidate;
|
||||
}
|
||||
$hook = $candidate;
|
||||
}
|
||||
|
||||
// If there's no implementation, check for more generic fallbacks. If there's
|
||||
// still no implementation, log an error and return an empty string.
|
||||
if (!isset($hooks[$hook])) {
|
||||
// Iteratively strip everything after the last '__' delimiter, until an
|
||||
// implementation is found.
|
||||
while ($pos = strrpos($hook, '__')) {
|
||||
$hook = substr($hook, 0, $pos);
|
||||
if (isset($hooks[$hook])) {
|
||||
break;
|
||||
}
|
||||
$meta['wildcards'] = $hook;
|
||||
}
|
||||
if (!isset($hooks[$hook])) {
|
||||
// Only log a message when not trying theme suggestions ($hook being an
|
||||
// array).
|
||||
if (!isset($candidate)) {
|
||||
watchdog('theme', 'Theme key "@key" not found.', array('@key' => $hook), WATCHDOG_WARNING);
|
||||
}
|
||||
return array('', $meta);
|
||||
}
|
||||
}
|
||||
|
||||
$meta['hook'] = $hook;
|
||||
$info = $hooks[$hook];
|
||||
$meta['path'] = isset($info['theme path']) ? $info['theme path'] : NULL;
|
||||
|
||||
|
||||
global $theme_path;
|
||||
$temp = $theme_path;
|
||||
// point path_to_theme() to the currently used theme path:
|
||||
$theme_path = isset($info['theme path']) ? $info['theme path'] : NULL;
|
||||
|
||||
// Include a file if the theme function or variable processor is held elsewhere.
|
||||
if (!empty($info['includes'])) {
|
||||
foreach ($info['includes'] as $include_file) {
|
||||
include_once DRUPAL_ROOT . '/' . $include_file;
|
||||
}
|
||||
}
|
||||
|
||||
// If a renderable array is passed as $variables, then set $variables to
|
||||
// the arguments expected by the theme function.
|
||||
if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {
|
||||
$element = $variables;
|
||||
$variables = array();
|
||||
if (isset($info['variables'])) {
|
||||
foreach (array_keys($info['variables']) as $name) {
|
||||
if (isset($element["#$name"])) {
|
||||
$variables[$name] = $element["#$name"];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$variables[$info['render element']] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge in argument defaults.
|
||||
if (!empty($info['variables'])) {
|
||||
$variables += $info['variables'];
|
||||
}
|
||||
elseif (!empty($info['render element'])) {
|
||||
$variables += array($info['render element'] => array());
|
||||
}
|
||||
|
||||
// Add the themer attribute here
|
||||
$variables['attributes_array']['thmr'] = $thmr_key;
|
||||
|
||||
// Invoke the variable processors, if any. The processors may specify
|
||||
// alternate suggestions for which hook's template/function to use. If the
|
||||
// hook is a suggestion of a base hook, invoke the variable processors of
|
||||
// the base hook, but retain the suggestion as a high priority suggestion to
|
||||
// be used unless overridden by a variable processor function.
|
||||
if (isset($info['base hook'])) {
|
||||
$base_hook = $info['base hook'];
|
||||
$base_hook_info = $hooks[$base_hook];
|
||||
// Return the preprocessor functions to their original state
|
||||
$base_hook_info['preprocess functions'] = $base_hook_info['devel_function_preprocess_intercept'];
|
||||
$base_hook_info['process functions'] = $base_hook_info['devel_function_process_intercept'];
|
||||
if (isset($base_hook_info['preprocess functions']) || isset($base_hook_info['process functions'])) {
|
||||
$variables['theme_hook_suggestion'] = $hook;
|
||||
$hook = $base_hook;
|
||||
$info = $base_hook_info;
|
||||
}
|
||||
}
|
||||
$info['preprocess functions'] = $info['devel_function_preprocess_intercept'];
|
||||
$info['process functions'] = $info['devel_function_process_intercept'];
|
||||
if (isset($info['preprocess functions']) || isset($info['process functions'])) {
|
||||
$variables['theme_hook_suggestions'] = array();
|
||||
foreach (array('preprocess functions', 'process functions') as $phase) {
|
||||
if (!empty($info[$phase])) {
|
||||
foreach ($info[$phase] as $processor_function) {
|
||||
$meta['processor_functions'][$phase][] = $processor_function;
|
||||
if (function_exists($processor_function)) {
|
||||
// We don't want a poorly behaved process function changing $hook.
|
||||
$hook_clone = $hook;
|
||||
$processor_function($variables, $hook_clone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the preprocess/process functions specified hook suggestions, and the
|
||||
// suggestion exists in the theme registry, use it instead of the hook that
|
||||
// theme() was called with. This allows the preprocess/process step to
|
||||
// route to a more specific theme hook. For example, a function may call
|
||||
// theme('node', ...), but a preprocess function can add 'node__article' as
|
||||
// a suggestion, enabling a theme to have an alternate template file for
|
||||
// article nodes. Suggestions are checked in the following order:
|
||||
// - The 'theme_hook_suggestion' variable is checked first. It overrides
|
||||
// all others.
|
||||
// - The 'theme_hook_suggestions' variable is checked in FILO order, so the
|
||||
// last suggestion added to the array takes precedence over suggestions
|
||||
// added earlier.
|
||||
$suggestions = array();
|
||||
if (!empty($variables['theme_hook_suggestions'])) {
|
||||
$suggestions = $variables['theme_hook_suggestions'];
|
||||
}
|
||||
if (!empty($variables['theme_hook_suggestion'])) {
|
||||
$suggestions[] = $variables['theme_hook_suggestion'];
|
||||
}
|
||||
foreach (array_reverse($suggestions) as $suggestion) {
|
||||
if (isset($hooks[$suggestion])) {
|
||||
$info = $hooks[$suggestion];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tidy up the theme things here.
|
||||
if (isset($info)) {
|
||||
unset($info['function']);
|
||||
if (isset($info['devel_function_intercept'])) {
|
||||
$info['function'] = $info['devel_function_intercept'];
|
||||
}
|
||||
$meta['hook'] = $hook;
|
||||
$meta['path'] = isset($info['theme path']) ? $info['theme path'] : NULL;
|
||||
}
|
||||
|
||||
// Generate the output using either a function or a template.
|
||||
$output = '';
|
||||
if (isset($info['function'])) {
|
||||
if (function_exists($info['function'])) {
|
||||
$output = $info['function']($variables);
|
||||
$meta['type'] = 'func';
|
||||
$meta['used'] = $info['function'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Default render function and extension.
|
||||
$render_function = 'theme_render_template';
|
||||
$extension = '.tpl.php';
|
||||
|
||||
// The theme engine may use a different extension and a different renderer.
|
||||
global $theme_engine;
|
||||
if (isset($theme_engine)) {
|
||||
if ($info['type'] != 'module') {
|
||||
if (function_exists($theme_engine . '_render_template')) {
|
||||
$render_function = $theme_engine . '_render_template';
|
||||
}
|
||||
$extension_function = $theme_engine . '_extension';
|
||||
if (function_exists($extension_function)) {
|
||||
$extension = $extension_function();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In some cases, a template implementation may not have had
|
||||
// template_preprocess() run (for example, if the default implementation is
|
||||
// a function, but a template overrides that default implementation). In
|
||||
// these cases, a template should still be able to expect to have access to
|
||||
// the variables provided by template_preprocess(), so we add them here if
|
||||
// they don't already exist. We don't want to run template_preprocess()
|
||||
// twice (it would be inefficient and mess up zebra striping), so we use the
|
||||
// 'directory' variable to determine if it has already run, which while not
|
||||
// completely intuitive, is reasonably safe, and allows us to save on the
|
||||
// overhead of adding some new variable to track that.
|
||||
if (!isset($variables['directory'])) {
|
||||
$default_template_variables = array();
|
||||
template_preprocess($default_template_variables, $hook);
|
||||
$variables += $default_template_variables;
|
||||
}
|
||||
|
||||
// Render the output using the template file.
|
||||
$template_file = $info['template'] . $extension;
|
||||
if (isset($info['path'])) {
|
||||
$template_file = $info['path'] . '/' . $template_file;
|
||||
}
|
||||
$meta['type'] = 'tpl';
|
||||
$meta['used'] = $template_file;
|
||||
|
||||
$meta['suggestions'] = $suggestions;
|
||||
$meta['template_file'] = $template_file;
|
||||
$meta['preprocessors'] = isset($info['preprocess functions']) ? $info['preprocess functions'] : array();
|
||||
|
||||
$output = $render_function($template_file, $variables);
|
||||
}
|
||||
$meta['variables'] = $variables;
|
||||
|
||||
// restore path_to_theme()
|
||||
$theme_path = $temp;
|
||||
return array($output, $meta);
|
||||
}
|
||||
|
||||
// We save the huge js array here instead of hook_footer so we can catch theme('page')
|
||||
function devel_themer_exit() {
|
||||
// TODO: limit to html pages only $router_item = menu_get_item();
|
||||
//delivery_callback
|
||||
if (!empty($GLOBALS['devel_theme_calls']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
// A random string that is sent to the browser. It enables the popup to retrieve params/variables from this request.
|
||||
$request_id = uniqid(rand());
|
||||
// Write the variables information to the a file. It will be retrieved on demand via AJAX.
|
||||
// We used to write this to DB but was getting 'Warning: Got a packet bigger than 'max_allowed_packet' bytes'
|
||||
// Writing to temp dir means we don't worry about folder existence/perms and cleanup is free.
|
||||
try {
|
||||
file_save_data(serialize($GLOBALS['devel_themer_server']), "temporary://devel_themer_$request_id", FILE_EXISTS_REPLACE);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
file_save_data(serialize(array("unables to save variables, probably due to pdo")), "temporary://devel_themer_$request_id", FILE_EXISTS_REPLACE);
|
||||
}
|
||||
|
||||
$GLOBALS['devel_theme_calls']['request_id'] = $request_id;
|
||||
$GLOBALS['devel_theme_calls']['devel_themer_uri'] = url("devel_themer/variables/$request_id");
|
||||
print '<script type="text/javascript">jQuery.extend(Drupal.settings, ' . drupal_json_encode($GLOBALS['devel_theme_calls']) . ");</script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// just hand out next counter, or return current value
|
||||
function devel_counter($increment = TRUE) {
|
||||
static $counter = 0;
|
||||
if ($increment) {
|
||||
$counter++;
|
||||
}
|
||||
return $counter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the popup template
|
||||
* placed here for easy editing
|
||||
*/
|
||||
function devel_themer_popup() {
|
||||
$majorver = substr(VERSION, 0, strpos(VERSION, '.'));
|
||||
|
||||
// add translatable strings
|
||||
drupal_add_js(array('thmrStrings' =>
|
||||
array(
|
||||
'themer_info' => t('Themer info'),
|
||||
'toggle_throbber' => ' <img src="' . base_path() . drupal_get_path('module', 'devel_themer') . '/loader-little.gif' . '" alt="' . t('loading') . '" class="throbber" width="16" height="16" style="display:none" />',
|
||||
'parents' => t('Parents:') . ' ',
|
||||
'function_called' => t('Function called:') . ' ',
|
||||
'template_called' => t('Template called:') . ' ',
|
||||
'candidate_files' => t('Candidate template files:') . ' ',
|
||||
'preprocessors' => t('Preprocess functions:') . ' ',
|
||||
'processors' => t('Process functions:') . ' ',
|
||||
'candidate_functions' => t('Candidate function names:') . ' ',
|
||||
'drupal_api_docs' => t('link to Drupal API documentation'),
|
||||
'source_link_title' => t('link to source code'),
|
||||
'function_arguments' => t('Function Arguments'),
|
||||
'template_variables' => t('Template Variables'),
|
||||
'file_used' => t('File used:') . ' ',
|
||||
'duration' => t('Duration:') . ' ',
|
||||
'api_site' => variable_get('devel_api_site', 'http://api.drupal.org/'),
|
||||
'drupal_version' => $majorver,
|
||||
'source_link' => url('devel/source', array('query' => array('file' => ''))),
|
||||
))
|
||||
, 'setting');
|
||||
|
||||
$title = t('Drupal Themer Information');
|
||||
$intro = t('Click on any element to see information about the Drupal theme function or template that created it.');
|
||||
|
||||
$popup = <<<EOT
|
||||
<div id="themer-fixeder">
|
||||
<div id="themer-relativer">
|
||||
<div id="themer-popup">
|
||||
<div class="topper">
|
||||
<span class="close">X</span> $title
|
||||
</div>
|
||||
<div id="parents" class="row">
|
||||
|
||||
</div>
|
||||
<div class="info row">
|
||||
<div class="starter">$intro</div>
|
||||
<dl>
|
||||
<dt class="key-type">
|
||||
|
||||
</dt>
|
||||
<dd class="key">
|
||||
|
||||
</dd>
|
||||
<div class="used">
|
||||
</div>
|
||||
<dt class="candidates-type">
|
||||
|
||||
</dt>
|
||||
<dd class="candidates">
|
||||
|
||||
</dd>
|
||||
|
||||
<dt class="preprocessors-type">
|
||||
|
||||
</dt>
|
||||
<dd class="preprocessors">
|
||||
|
||||
</dd>
|
||||
<dt class="processors-type">
|
||||
|
||||
</dt>
|
||||
<dd class="processors">
|
||||
|
||||
</dd>
|
||||
<div class="duration"></div>
|
||||
</dl>
|
||||
</div><!-- /info -->
|
||||
<div class="attributes row">
|
||||
<div class="themer-variables"></div>
|
||||
</div><!-- /attributes -->
|
||||
</div><!-- /themer-popup -->
|
||||
</div>
|
||||
</div>
|
||||
EOT;
|
||||
|
||||
drupal_add_js(array('thmr_popup' => $popup), 'setting');
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up the files we dropped in the temp dir in devel_themer_exit().
|
||||
*
|
||||
* Limitation: one more devel_themer_exit() will run after this function is
|
||||
* called and drop one more file, since hook_exit() is called after the normal
|
||||
* page cycle.
|
||||
*
|
||||
* @return
|
||||
* void.
|
||||
*/
|
||||
function devel_themer_cleanup() {
|
||||
$scan = file_scan_directory('temporary://', '/^devel_themer_/', array('recurse' => FALSE));
|
||||
foreach (array_keys($scan) as $file) {
|
||||
$fid = db_query('SELECT fid FROM {file_managed} WHERE uri = :uri', array(':uri' => "temporary://$file"))->fetchField();
|
||||
if (!empty($fid)) {
|
||||
file_delete($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_cron() for periodic cleanup.
|
||||
*
|
||||
* @return
|
||||
* void.
|
||||
*/
|
||||
function devel_themer_cron() {
|
||||
devel_themer_cleanup();
|
||||
}
|
9
sites/all/modules/devel_themer/devel_themer_ie_fix.css
Normal file
9
sites/all/modules/devel_themer/devel_themer_ie_fix.css
Normal file
@@ -0,0 +1,9 @@
|
||||
#themer-fixeder {
|
||||
position: absolute !important;
|
||||
}
|
||||
|
||||
#themer-toggle {
|
||||
position: absolute !important;
|
||||
top: 0 !important;
|
||||
bottom: auto !important;
|
||||
}
|
BIN
sites/all/modules/devel_themer/loader-little.gif
Normal file
BIN
sites/all/modules/devel_themer/loader-little.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 673 B |
BIN
sites/all/modules/devel_themer/themer-bar.png
Normal file
BIN
sites/all/modules/devel_themer/themer-bar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 283 B |
Reference in New Issue
Block a user