FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
7
sites/all/modules/contrib/admin/nodeformcols/CHANGELOG
Normal file
7
sites/all/modules/contrib/admin/nodeformcols/CHANGELOG
Normal file
@@ -0,0 +1,7 @@
|
||||
// $Id$
|
||||
|
||||
Node form columns 7.x-1.x, xxxx-xx-xx
|
||||
------------------------------
|
||||
#801804 by yhahn, voxpelli: Port to drupal 7
|
||||
by voxpelli: No longer positions form fields that the access is denied to
|
||||
#664840 by swentel, voxpelli: Fixed PHP notices
|
339
sites/all/modules/contrib/admin/nodeformcols/LICENSE.txt
Normal file
339
sites/all/modules/contrib/admin/nodeformcols/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.
|
@@ -0,0 +1,16 @@
|
||||
#fields td.region {
|
||||
font-weight: bold;
|
||||
}
|
||||
#fields tr.region-message {
|
||||
font-weight: normal;
|
||||
color: #999;
|
||||
}
|
||||
#fields tr.region-populated {
|
||||
display: none;
|
||||
}
|
||||
.field-region {
|
||||
background-color: #ff6;
|
||||
margin-top: 4px;
|
||||
margin-bottom: 4px;
|
||||
padding: 3px;
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
.node-form .form-region-right {
|
||||
width: 29%;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.node-form-has-region-right .form-region-main {
|
||||
float: left;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.node-form-has-region-right .form-region-footer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.node-form .form-region-right input,
|
||||
.node-form .form-region-right text-area {
|
||||
max-width: 100%;
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
|
||||
/**
|
||||
* Move a field in the fields table from one region to another via select list.
|
||||
*
|
||||
* This behavior is dependent on the tableDrag behavior, since it uses the
|
||||
* objects initialized in that behavior to update the row.
|
||||
*/
|
||||
(function($) {
|
||||
Drupal.behaviors.fieldDrag = {};
|
||||
Drupal.behaviors.fieldDrag.attach = function(context) {
|
||||
var table = $('table#fields');
|
||||
var tableDrag = Drupal.tableDrag.fields; // Get the fields tableDrag object.
|
||||
|
||||
// Add a handler for when a row is swapped, update empty regions.
|
||||
tableDrag.row.prototype.onSwap = function(swappedRow) {
|
||||
checkEmptyRegions(table, this);
|
||||
};
|
||||
|
||||
// Add a handler so when a row is dropped, update fields dropped into new regions.
|
||||
tableDrag.onDrop = function() {
|
||||
dragObject = this;
|
||||
if ($(dragObject.rowObject.element).prev('tr').is('.region-message')) {
|
||||
var regionRow = $(dragObject.rowObject.element).prev('tr').get(0);
|
||||
var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
||||
var regionField = $('select.field-region-select', dragObject.rowObject.element);
|
||||
var weightField = $('input.field-weight', dragObject.rowObject.element);
|
||||
var oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*field-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
|
||||
|
||||
if (!regionField.is('.field-region-'+ regionName)) {
|
||||
regionField.removeClass('field-region-' + oldRegionName).addClass('field-region-' + regionName);
|
||||
weightField.removeClass('field-weight-' + oldRegionName).addClass('field-weight-' + regionName);
|
||||
regionField.val(regionName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Add the behavior to each region select list.
|
||||
$('select.field-region-select:not(.fieldregionselect-processed)', context).each(function() {
|
||||
$(this).change(function(event) {
|
||||
// Make our new row and select field.
|
||||
var row = $(this).parents('tr:first');
|
||||
var select = $(this);
|
||||
tableDrag.rowObject = new tableDrag.row(row);
|
||||
|
||||
// Find the correct region and insert the row as the first in the region.
|
||||
$('tr.region-message', table).each(function() {
|
||||
if ($(this).is('.region-' + select[0].value + '-message')) {
|
||||
// Add the new row and remove the old one.
|
||||
$(this).after(row);
|
||||
// Manually update weights and restripe.
|
||||
tableDrag.updateFields(row.get(0));
|
||||
tableDrag.rowObject.changed = true;
|
||||
if (tableDrag.oldRowElement) {
|
||||
$(tableDrag.oldRowElement).removeClass('drag-previous');
|
||||
}
|
||||
tableDrag.oldRowElement = row.get(0);
|
||||
tableDrag.restripeTable();
|
||||
tableDrag.rowObject.markChanged();
|
||||
tableDrag.oldRowElement = row;
|
||||
$(row).addClass('drag-previous');
|
||||
}
|
||||
});
|
||||
|
||||
// Modify empty regions with added or removed fields.
|
||||
checkEmptyRegions(table, row);
|
||||
// Remove focus from selectbox.
|
||||
select.get(0).blur();
|
||||
});
|
||||
$(this).addClass('fieldregionselect-processed');
|
||||
});
|
||||
|
||||
var checkEmptyRegions = function(table, rowObject) {
|
||||
$('tr.region-message', table).each(function() {
|
||||
// If the dragged row is in this region, but above the message row, swap it down one space.
|
||||
if ($(this).prev('tr').get(0) == rowObject.element) {
|
||||
// Prevent a recursion problem when using the keyboard to move rows up.
|
||||
if ((rowObject.method != 'keyboard' || rowObject.direction == 'down')) {
|
||||
rowObject.swap('after', this);
|
||||
}
|
||||
}
|
||||
// This region has become empty
|
||||
if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').size() == 0) {
|
||||
$(this).removeClass('region-populated').addClass('region-empty');
|
||||
}
|
||||
// This region has become populated.
|
||||
else if ($(this).is('.region-empty')) {
|
||||
$(this).removeClass('region-empty').addClass('region-populated');
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
} (jQuery));
|
@@ -0,0 +1,16 @@
|
||||
diff --git a/nodeformcols.module b/nodeformcols.module
|
||||
index b27f9b5..53ec8f0 100644
|
||||
--- a/nodeformcols.module
|
||||
+++ b/nodeformcols.module
|
||||
@@ -137,8 +137,9 @@ function template_preprocess_node_form(&$aVars) {
|
||||
continue;
|
||||
}
|
||||
|
||||
- if (isset($placements[$key])) {
|
||||
- $p = $placements[$key];
|
||||
+ if (isset($placements[$key]) || isset($field['#placement'])) {
|
||||
+ $p = isset($placements[$key]) ? $placements[$key] : $field['#placement'];
|
||||
+ unset($field['#placement']);
|
||||
|
||||
if (isset($p['weight'])) {
|
||||
$field['#weight'] = $p['weight'];
|
13
sites/all/modules/contrib/admin/nodeformcols/nfcbiblio.info
Normal file
13
sites/all/modules/contrib/admin/nodeformcols/nfcbiblio.info
Normal file
@@ -0,0 +1,13 @@
|
||||
name = Biblio compatability
|
||||
description = Adds support for biblio fields
|
||||
dependencies[] = nodeformcols
|
||||
dependencies[] = biblio
|
||||
core = 7.x
|
||||
package = Node form columns
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-06-13
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "nodeformcols"
|
||||
datestamp = "1339547249"
|
||||
|
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_nodeformcols_variants_alter().
|
||||
*
|
||||
* Implement this hook to supply information about form variants that can be
|
||||
* configured.
|
||||
*
|
||||
* @param array $variants
|
||||
* The current variants of the form
|
||||
* @param string $type
|
||||
* The node type
|
||||
* @return void
|
||||
*/
|
||||
function nfcbiblio_nodeformcols_variants_alter(&$variants, $type) {
|
||||
if ($type == 'biblio') {
|
||||
$res = db_query('SELECT tid, name
|
||||
FROM {biblio_types}
|
||||
WHERE tid >= :tid
|
||||
AND visible = :visible
|
||||
ORDER BY weight ASC', array(':tid' => 0, ':visible' => 1));
|
||||
while ($option = db_fetch_object($res)) {
|
||||
$variants[$option->tid] = $option->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to get a default biblio type
|
||||
*
|
||||
* @return int
|
||||
* The id of a default biblio type
|
||||
*/
|
||||
function _nfcbiblio_top_visible_type() {
|
||||
return db_query_range("SELECT tid
|
||||
FROM {biblio_types}
|
||||
WHERE visible = :visible
|
||||
AND tid> = :tid>
|
||||
ORDER BY weight ASC", array(':visible' => 1, ':tid>' => 0))->fetchField();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_nodeformcols_pre_form_alter().
|
||||
*
|
||||
* Implement this hook to tell nodeformcols what variant the form is before
|
||||
* any alterations to the form is made.
|
||||
*
|
||||
* @param array $form
|
||||
* The form.
|
||||
* @return void
|
||||
*/
|
||||
function nfcbiblio_nodeformcols_pre_form_alter(&$form) {
|
||||
if ($form['#node']->type == 'biblio') {
|
||||
if (!empty($form['biblio_type']['#value'])) {
|
||||
$form['#nodeformcols_variant'] = $form['biblio_type']['#value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_nodeformcols_base_form_alter().
|
||||
*
|
||||
* Implement this hook if you want to alter the node creation form that
|
||||
* nodeformcols uses to construct the configuration interface before
|
||||
* nodeformcols reads field information from it.
|
||||
*
|
||||
* @param array $form
|
||||
* The programatically created node creation form.
|
||||
* @param string $variant
|
||||
* The variant of the form that's being configured.
|
||||
* @return void
|
||||
*/
|
||||
function nfcbiblio_nodeformcols_base_form_alter(&$form, $variant) {
|
||||
if ($form['#node']->type == 'biblio') {
|
||||
if ($variant == 'default') {
|
||||
$variant = _nfcbiblio_top_visible_type();
|
||||
}
|
||||
|
||||
$biblio_form_state = array();
|
||||
$biblio_form_state['post']['biblio_type'] = $variant;
|
||||
foreach (biblio_form($form['#node'], $biblio_form_state) as $name => $def) {
|
||||
$form[$name] = $def;
|
||||
}
|
||||
}
|
||||
}
|
13
sites/all/modules/contrib/admin/nodeformcols/nfccaptcha.info
Normal file
13
sites/all/modules/contrib/admin/nodeformcols/nfccaptcha.info
Normal file
@@ -0,0 +1,13 @@
|
||||
name = CAPTCHA compatability
|
||||
description = Adds support for CAPTCHA in node forms
|
||||
dependencies[] = nodeformcols
|
||||
dependencies[] = captcha
|
||||
core = 7.x
|
||||
package = Node form columns
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-06-13
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "nodeformcols"
|
||||
datestamp = "1339547249"
|
||||
|
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_nodeformcols_base_form_alter().
|
||||
*
|
||||
* Implement this hook if you want to alter the node creation form that
|
||||
* nodeformcols uses to construct the configuration interface before
|
||||
* nodeformcols reads field information from it.
|
||||
*
|
||||
* @param array $form
|
||||
* The programatically created node creation form.
|
||||
* @param string $variant
|
||||
* The variant of the form that's being configured.
|
||||
* @return void
|
||||
*/
|
||||
function nodeformcols_nodeformcols_base_form_alter(&$form, $variant) {
|
||||
$using_captcha = db_query("SELECT COUNT(module)
|
||||
FROM {captcha_points} WHERE form_id = :form_id", array(':form_id' => array(
|
||||
':form_id' => $form['#node']->type . '_node_form',
|
||||
)))->fetchField();
|
||||
if ($using_captcha) {
|
||||
$form['captcha'] = array(
|
||||
'#title' => t('CAPTCHA'),
|
||||
'#weight' => $form['buttons']['#weight'] - 1,
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template that renders a part of the node form
|
||||
*/
|
||||
?>
|
||||
<div class="<?php print $class; ?>">
|
||||
<?php print drupal_render_children($form); ?>
|
||||
</div>
|
@@ -0,0 +1,13 @@
|
||||
diff --git a/sites/all/modules/contrib/nodeformcols/nodeformcols.module b/sites/all/modules/contrib/nodeformcols/nodeformcols.module
|
||||
index f538452..793edcf 100755
|
||||
--- a/sites/all/modules/contrib/nodeformcols/nodeformcols.module
|
||||
+++ b/sites/all/modules/contrib/nodeformcols/nodeformcols.module
|
||||
@@ -175,7 +175,7 @@ function template_preprocess_node_form(&$aVars) {
|
||||
*/
|
||||
function nodeformcols_node_type_delete($info) {
|
||||
$result = db_select('variable')
|
||||
- ->condition('name', 'nodeformscols_field_placements_' . $info->old_type . '%', 'LIKE')
|
||||
+ ->condition('name', 'nodeformscols_field_placements_' . $info->type . '%', 'LIKE')
|
||||
->fields('variable', array('name'))
|
||||
->execute();
|
||||
foreach ($result as $row) {
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Template for the configuration table
|
||||
*/
|
||||
|
||||
$regions = nodeformcols_form_regions();
|
||||
?>
|
||||
<table id="fields" class="sticky-enabled">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php print t('Field'); ?></th>
|
||||
<th><?php print t('Options'); ?></th>
|
||||
<th><?php print t('Region'); ?></th>
|
||||
<th><?php print t('Weight'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $row = 0; ?>
|
||||
<?php foreach ($regions as $region => $title): ?>
|
||||
<tr class="region region-<?php print $region?>">
|
||||
<td colspan="4" class="region"><?php print $title; ?></td>
|
||||
</tr>
|
||||
<tr class="region-message region-<?php print $region?>-message <?php print empty($element[$region]) ? 'region-empty' : 'region-populated'; ?>">
|
||||
<td colspan="4"><em><?php print t('No fields in this region'); ?></em></td>
|
||||
</tr>
|
||||
<?php if (!empty($element[$region])): ?>
|
||||
<?php foreach ($element[$region] as $field => $data): ?>
|
||||
<?php
|
||||
if (substr($field, 0, 1) == '#') {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<tr class="draggable <?php print $row % 2 == 0 ? 'odd' : 'even'; ?>">
|
||||
<td><?php print drupal_render($data[$field . '_name']) ?></td>
|
||||
<td><?php
|
||||
if (isset($data[$field . '_collapsed'])) {
|
||||
print drupal_render($data[$field . '_collapsed']);
|
||||
}
|
||||
if (isset($data[$field . '_hidden'])) {
|
||||
print drupal_render($data[$field . '_hidden']);
|
||||
}
|
||||
?></td>
|
||||
<td><?php print drupal_render($data[$field . '_region']) ?></td>
|
||||
<td><?php print drupal_render($data[$field . '_weight']) ?></td>
|
||||
</tr>
|
||||
<?php $row++; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the admin functions for Node form columns
|
||||
*/
|
||||
|
||||
function _nodeformcols_get_node_type_form($type) {
|
||||
module_load_include('inc', 'node', 'node.pages');
|
||||
|
||||
global $user;
|
||||
$node = new stdClass();
|
||||
$node->uid = $user->uid;
|
||||
$node->name = isset($user->name) ? $user->name : '';
|
||||
$node->type = $type;
|
||||
$node->language = '';
|
||||
$nfid = $type . '_node_form';
|
||||
$fs = array(
|
||||
'build_info' => array('args' => array($node)),
|
||||
'input' => array(),
|
||||
);
|
||||
$fs += form_state_defaults();
|
||||
$nf = drupal_retrieve_form($nfid, $fs);
|
||||
drupal_prepare_form($nfid, $nf, $fs);
|
||||
drupal_process_form($nfid, $nf, $fs);
|
||||
return $nf;
|
||||
}
|
||||
|
||||
function nodeformcols_update_placements($type, $variant, &$placements) {
|
||||
$form = _nodeformcols_get_node_type_form($type);
|
||||
drupal_alter('nodeformcols_base_form', $form, $variant);
|
||||
$default_region = variable_get('nodeformcols_default_region', NODEFORMCOLS_DEFAULT_REGION);
|
||||
|
||||
foreach (element_children($form) as $key) {
|
||||
$field = $form[$key];
|
||||
if (
|
||||
substr($key, 0, 8) == 'section_' ||
|
||||
(isset($field['#type']) && in_array($field['#type'], array('value', 'hidden', 'token'))) ||
|
||||
(isset($field['#type'], $field['#group']) && $field['#type'] === 'fieldset')
|
||||
) {
|
||||
// Remove placements that meet exclusion rules.
|
||||
if (isset($placements[$key])) {
|
||||
unset($placements[$key]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ensure a weight so that we don't have to worry about it later
|
||||
$field['#weight'] = isset($field['#weight']) ? $field['#weight'] : 0;
|
||||
|
||||
if (!isset($placements[$key])) {
|
||||
// If the element is unknown we'll add it to
|
||||
// the field placement list
|
||||
$placements[$key] = array(
|
||||
'region' => $default_region,
|
||||
'weight' => $field['#weight'],
|
||||
);
|
||||
// Make sure that we don't auto-place the field below the buttons.
|
||||
if ($placements['actions']['region'] == $default_region && $placements[$key]['weight'] >= $placements['actions']['weight']) {
|
||||
$placements[$key]['weight'] = $placements['actions']['weight'] - .1;
|
||||
}
|
||||
}
|
||||
elseif (!isset($placements[$key]['weight'])) {
|
||||
$placements[$key]['weight'] = $field['#weight'];
|
||||
}
|
||||
|
||||
$placements[$key]['has_required'] = _nodeformcols_has_required($field);
|
||||
|
||||
// Get the element title
|
||||
$placements[$key]['title'] = _nodeformcols_get_element_title($field);
|
||||
|
||||
if (isset($field['#collapsible']) && $field['#collapsible']) {
|
||||
if (!isset($placements[$key]['collapsed'])) {
|
||||
$placements[$key]['collapsed'] = isset($field['#collapsed']) && $field['#collapsed'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
unset($placements[$key]['collapsed']);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove fields that have disappeared from
|
||||
// the placements list.
|
||||
foreach ($placements as $key => $info) {
|
||||
if (!isset($form[$key])) {
|
||||
unset($placements[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _nodeformcols_get_element_title($element) {
|
||||
if (!empty($element['#title'])) {
|
||||
return $element['#title'];
|
||||
}
|
||||
if (isset($element['#type']) && $element['#type'] == 'submit') {
|
||||
return $element['#value'];
|
||||
}
|
||||
if (isset($element['#type']) && $element['#type'] == 'vertical_tabs') {
|
||||
return t('Vertical tabs');
|
||||
}
|
||||
foreach (element_children($element) as $key) {
|
||||
if ($title = _nodeformcols_get_element_title($element[$key])) {
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nodeformcols_configuration_form($form, $form_state, $node_type, $variant = 'default') {
|
||||
$type = $node_type->type;
|
||||
$variants = array();
|
||||
drupal_alter('nodeformcols_variants', $variants, $type);
|
||||
|
||||
$form = array();
|
||||
if (!empty($variants)) {
|
||||
$variant_links = array(
|
||||
'default' => array(
|
||||
'title' => t('Default'),
|
||||
'href' => 'admin/structure/types/manage/' . $type . '/form',
|
||||
),
|
||||
);
|
||||
foreach ($variants as $id => $title) {
|
||||
$variant_links[] = array(
|
||||
'title' => $title,
|
||||
'href' => 'admin/structure/types/manage/' . $type . '/form/' . $id,
|
||||
);
|
||||
}
|
||||
|
||||
$form['variant'] = array(
|
||||
'#type' => 'item',
|
||||
'#title' => t('Select a form variant'),
|
||||
'#value' => theme('links', array('links' => $variant_links)),
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($variant)) {
|
||||
$variant = 'default';
|
||||
}
|
||||
$form['#variant'] = $variant;
|
||||
|
||||
$placements = nodeformscols_field_placements($type, $variant);
|
||||
nodeformcols_update_placements($type, $variant, $placements);
|
||||
|
||||
$regions = nodeformcols_form_regions();
|
||||
|
||||
$form['type'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $type,
|
||||
);
|
||||
$form['#after_build'][] = '_nodeformcols_configuration_form_after_build';
|
||||
$form['conf'] = array(
|
||||
'#theme' => array('nodeformcols_configuration'),
|
||||
);
|
||||
|
||||
foreach ($placements as $name => $info) {
|
||||
$key = 'field_' . $name;
|
||||
$weight = isset($info['weight']) ? $info['weight'] : 0;
|
||||
$form['conf'][$info['region']][$key] = array(
|
||||
'#weight' => $weight,
|
||||
$key . '_name' => array(
|
||||
'#markup' => !empty($info['title']) ? $info['title'] : $name,
|
||||
),
|
||||
$key . '_region' => array(
|
||||
'#type' => 'select',
|
||||
'#options' => $regions,
|
||||
'#default_value' => $info['region'],
|
||||
'#attributes' => array(
|
||||
'class' => array('field-region-select field-region-' . $info['region']),
|
||||
),
|
||||
),
|
||||
$key . '_weight' => array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $weight,
|
||||
'#size' => 3,
|
||||
'#attributes' => array(
|
||||
'class' => array('field-weight field-weight-' . $info['region']),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!$info['has_required']) {
|
||||
$form['conf'][$info['region']][$key][$key . '_hidden'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Hide'),
|
||||
'#default_value' => isset($info['hidden']) ? $info['hidden'] : FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($info['collapsed'])) {
|
||||
$form['conf'][$info['region']][$key][$key . '_collapsed'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show collapsed'),
|
||||
'#default_value' => isset($info['collapsed']) ? $info['collapsed'] : FALSE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a form element or any of it's children are required
|
||||
*
|
||||
* @param array $element
|
||||
* @return bool
|
||||
*/
|
||||
function _nodeformcols_has_required($element) {
|
||||
if (isset($element['#required']) && $element['#required']) {
|
||||
return TRUE;
|
||||
}
|
||||
$children = element_children($element);
|
||||
foreach ($children as $child) {
|
||||
if (_nodeformcols_has_required($element[$child])) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function _nodeformcols_configuration_form_after_build($form) {
|
||||
drupal_add_js('misc/tableheader.js');
|
||||
drupal_add_js(drupal_get_path('module', 'nodeformcols') . '/js/nodeformcols.js');
|
||||
drupal_add_css(drupal_get_path('module', 'nodeformcols') . '/css/nodeformcols.admin.css');
|
||||
|
||||
$regions = nodeformcols_form_regions();
|
||||
foreach ($regions as $region => $title) {
|
||||
if (isset($form['conf'][$region]) && is_array($form['conf'][$region])) {
|
||||
uasort($form['conf'][$region], "element_sort");
|
||||
}
|
||||
drupal_add_tabledrag('fields', 'match', 'sibling', 'field-region-select', 'field-region-' . $region, NULL, FALSE);
|
||||
drupal_add_tabledrag('fields', 'order', 'sibling', 'field-weight', 'field-weight-' . $region);
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
function nodeformcols_configuration_form_submit($form, $form_state) {
|
||||
$values = $form_state['values'];
|
||||
$type = $values['type'];
|
||||
$placements = nodeformscols_field_placements($type, $form['#variant']);
|
||||
nodeformcols_update_placements($type, $form['#variant'], $placements);
|
||||
|
||||
foreach ($placements as $name => &$opt) {
|
||||
$field = 'field_' . $name;
|
||||
$opt['region'] = $values[$field . '_region'];
|
||||
$opt['weight'] = $values[$field . '_weight'];
|
||||
if (isset($values[$field . '_hidden'])) {
|
||||
$opt['hidden'] = $values[$field . '_hidden'];
|
||||
}
|
||||
if (isset($values[$field . '_collapsed'])) {
|
||||
$opt['collapsed'] = $values[$field . '_collapsed'];
|
||||
}
|
||||
}
|
||||
|
||||
variable_set('nodeformscols_field_placements_' . $type .
|
||||
'_' . $form['#variant'], $placements);
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
name = Node form columns
|
||||
description = Separates the node forms into two columns and a footer.
|
||||
core = 7.x
|
||||
package = Node form columns
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-06-13
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "nodeformcols"
|
||||
datestamp = "1339547249"
|
||||
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install and update hooks
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
function nodeformcols_install() {
|
||||
// We need our hook_theme() to run after node.module's hook_theme().
|
||||
db_update('system')
|
||||
->fields(array('weight' => 1))
|
||||
->condition('name', 'nodeformcols')
|
||||
->condition('type', 'module')
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall().
|
||||
*/
|
||||
function nodeformcols_uninstall() {
|
||||
$res = db_select('variable')
|
||||
->fields('variable', array('name'))
|
||||
->condition('name', 'nodeformscols_field_placements_%', 'LIKE')
|
||||
->execute();
|
||||
foreach ($res as $v) {
|
||||
variable_del($v->name);
|
||||
}
|
||||
}
|
203
sites/all/modules/contrib/admin/nodeformcols/nodeformcols.module
Normal file
203
sites/all/modules/contrib/admin/nodeformcols/nodeformcols.module
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
define('NODEFORMCOLS_DEFAULT_REGION', 'main');
|
||||
|
||||
/**
|
||||
* Implementation of hook_theme().
|
||||
*/
|
||||
function nodeformcols_theme($aExisting) {
|
||||
return array(
|
||||
// This needs to run after node.module's hook_theme(), which we ensure
|
||||
// by setting this module's weight to 1 during install.
|
||||
'node_form' => array(
|
||||
'render element' => 'form',
|
||||
'template' => 'node-form',
|
||||
),
|
||||
'nodeformcols_configuration' => array(
|
||||
'render element' => 'element',
|
||||
'template' => 'nodeformcols-configuration',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
function nodeformcols_menu() {
|
||||
$items = array();
|
||||
|
||||
if (!defined('MAINTENANCE_MODE')) {
|
||||
$items['admin/structure/types/manage/%node_type/form'] = array(
|
||||
'title' => 'Manage form',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('nodeformcols_configuration_form', 4, 6),
|
||||
'access arguments' => array('administer content types'),
|
||||
'file' => 'nodeformcols.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 3,
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_ctools_plugin_directory().
|
||||
*/
|
||||
function nodeformcols_ctools_plugin_directory($module, $plugin) {
|
||||
if ($module == 'ctools') {
|
||||
return 'plugins/' . $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
function nodeformcols_form_regions() {
|
||||
return array(
|
||||
'main' => t('Main column'),
|
||||
'right' => t('Right'),
|
||||
'footer' => t('Footer'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets default placements for standard fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function _nodeformscols_default_field_placements() {
|
||||
return array(
|
||||
'title' => array('region' => 'main'),
|
||||
'additional_settings' => array('region' => 'main'),
|
||||
'actions' => array('region' => NODEFORMCOLS_DEFAULT_REGION, 'weight' => 100),
|
||||
);
|
||||
}
|
||||
|
||||
function nodeformscols_field_placements($content_type, $variant) {
|
||||
$default = _nodeformscols_default_field_placements();
|
||||
if ($variant != 'default') {
|
||||
$default = variable_get('nodeformscols_field_placements_' .
|
||||
$content_type . '_default', $default);
|
||||
}
|
||||
|
||||
$placements = variable_get('nodeformscols_field_placements_' . $content_type .
|
||||
'_' . $variant, $default);
|
||||
|
||||
return $placements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter().
|
||||
*/
|
||||
function nodeformcols_form_alter(&$form, $form_state, $form_id) {
|
||||
if (isset($form['#node_edit_form']) && $form['#node_edit_form']) {
|
||||
drupal_alter('nodeformcols_pre_form', $form);
|
||||
$variant = isset($form['#nodeformcols_variant']) ? $form['#nodeformcols_variant'] : 'default';
|
||||
$placements = nodeformscols_field_placements($form['#node']->type, $variant);
|
||||
foreach ($placements as $key => $p) {
|
||||
if (isset($p['hidden']) && $p['hidden']) {
|
||||
$form[$key]['#access'] = FALSE;
|
||||
}
|
||||
}
|
||||
drupal_alter('nodeformcols_post_form', $form);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function to run ahead of other modules.
|
||||
*/
|
||||
function template_preprocess_node_form(&$aVars) {
|
||||
drupal_add_css(drupal_get_path('module', 'nodeformcols') . '/css/nodeformcols.css');
|
||||
|
||||
$default_region = variable_get('nodeformcols_default_region', NODEFORMCOLS_DEFAULT_REGION);
|
||||
$form = &$aVars['form'];
|
||||
$class = array('node-form', 'clearfix');
|
||||
|
||||
$regions = array();
|
||||
$has_elements = array();
|
||||
$weight = 0;
|
||||
foreach (nodeformcols_form_regions() as $name => $title) {
|
||||
$regions[$name] = array(
|
||||
'#prefix' => '<div class="form-region-' . $name . '">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => $weight,
|
||||
);
|
||||
$weight++;
|
||||
}
|
||||
|
||||
drupal_alter('nodeformcols_pre_placement', $form);
|
||||
$variant = isset($form['#nodeformcols_variant']) ? $form['#nodeformcols_variant'] : 'default';
|
||||
$placements = nodeformscols_field_placements($form['#node']->type, $variant);
|
||||
|
||||
// Track if new fields should be adjusted above the buttons.
|
||||
// TODO: This should be generalized to a way to tell nodeformcols where to place new fields (above below field X).
|
||||
$adjust_to_buttons = isset($placements['buttons']['region']) && ($placements['buttons']['region'] == $default_region);
|
||||
|
||||
foreach (element_children($form) as $key) {
|
||||
$field = $form[$key];
|
||||
if (isset($field['#type']) && in_array($field['#type'], array('value', 'hidden', 'token')) ||
|
||||
(isset($field['#access']) && $field['#access'] == FALSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($placements[$key])) {
|
||||
$p = $placements[$key];
|
||||
if (isset($p['weight'])) {
|
||||
$field['#weight'] = $p['weight'];
|
||||
}
|
||||
if (isset($p['collapsed']) && isset($field['#collapsible']) && $field['#collapsible']) {
|
||||
$field['#collapsed'] = $p['collapsed'];
|
||||
}
|
||||
$regions[$p['region']][$key] = $field;
|
||||
$has_elements[$p['region']] = TRUE;
|
||||
unset($form[$key]);
|
||||
}
|
||||
else { // Set the default placement for unknown fields
|
||||
$regions[$default_region][$key] = $field;
|
||||
if ($adjust_to_buttons && $regions[$default_region][$key]['#weight'] >= $placements['buttons']['weight']) {
|
||||
$regions[$default_region][$key]['#weight'] = $placements['buttons']['weight'] - .1;
|
||||
}
|
||||
$has_elements[$default_region] = TRUE;
|
||||
unset($form[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($has_elements as $name => $has) {
|
||||
if ($has) {
|
||||
$class[] = 'node-form-has-region-' . $name;
|
||||
$form['nodeformcols_region_' . $name] = $regions[$name];
|
||||
}
|
||||
}
|
||||
|
||||
$aVars['class'] = join($class, ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_node_type_delete().
|
||||
*/
|
||||
function nodeformcols_node_type_delete($info) {
|
||||
$result = db_select('variable')
|
||||
->condition('name', 'nodeformscols_field_placements_' . $info->old_type . '%', 'LIKE')
|
||||
->fields('variable', array('name'))
|
||||
->execute();
|
||||
foreach ($result as $row) {
|
||||
variable_del($row->name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_node_type_update().
|
||||
*/
|
||||
function nodeformcols_node_type_update($info) {
|
||||
if (!empty($info->old_type) && $info->old_type != $info->type) {
|
||||
$base = 'nodeformscols_field_placements_' . $info->old_type;
|
||||
$new_base = 'nodeformscols_field_placements_' . $info->type;
|
||||
$result = db_select('variable')
|
||||
->condition('name', $base . '%', 'LIKE')
|
||||
->fields('variable', array('name'))
|
||||
->execute();
|
||||
foreach ($result as $row) {
|
||||
$value = variable_get($row->name, NULL);
|
||||
$new_name = str_replace($base, $new_base, $row->name);
|
||||
variable_set($new_name, $value);
|
||||
variable_del($row->name);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
define('NODEFORMCOLS_DEFAULT_REGION', 'main');
|
||||
|
||||
/**
|
||||
* Implementation of hook_theme().
|
||||
*/
|
||||
function nodeformcols_theme($aExisting) {
|
||||
return array(
|
||||
// This needs to run after node.module's hook_theme(), which we ensure
|
||||
// by setting this module's weight to 1 during install.
|
||||
'node_form' => array(
|
||||
'render element' => 'form',
|
||||
'template' => 'node-form',
|
||||
),
|
||||
'nodeformcols_configuration' => array(
|
||||
'render element' => 'element',
|
||||
'template' => 'nodeformcols-configuration',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
function nodeformcols_menu() {
|
||||
$items = array();
|
||||
|
||||
if (!defined('MAINTENANCE_MODE')) {
|
||||
$items['admin/structure/types/manage/%node_type/form'] = array(
|
||||
'title' => 'Manage form',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('nodeformcols_configuration_form', 4, 6),
|
||||
'access arguments' => array('administer content types'),
|
||||
'file' => 'nodeformcols.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 3,
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_ctools_plugin_directory().
|
||||
*/
|
||||
function nodeformcols_ctools_plugin_directory($module, $plugin) {
|
||||
if ($module == 'ctools') {
|
||||
return 'plugins/' . $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
function nodeformcols_form_regions() {
|
||||
return array(
|
||||
'main' => t('Main column'),
|
||||
'right' => t('Right'),
|
||||
'footer' => t('Footer'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets default placements for standard fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function _nodeformscols_default_field_placements() {
|
||||
return array(
|
||||
'title' => array('region' => 'main'),
|
||||
'additional_settings' => array('region' => 'main'),
|
||||
'actions' => array('region' => NODEFORMCOLS_DEFAULT_REGION, 'weight' => 100),
|
||||
);
|
||||
}
|
||||
|
||||
function nodeformscols_field_placements($content_type, $variant) {
|
||||
$default = _nodeformscols_default_field_placements();
|
||||
if ($variant != 'default') {
|
||||
$default = variable_get('nodeformscols_field_placements_' .
|
||||
$content_type . '_default', $default);
|
||||
}
|
||||
|
||||
$placements = variable_get('nodeformscols_field_placements_' . $content_type .
|
||||
'_' . $variant, $default);
|
||||
|
||||
return $placements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter().
|
||||
*/
|
||||
function nodeformcols_form_alter(&$form, $form_state, $form_id) {
|
||||
if (isset($form['#node_edit_form']) && $form['#node_edit_form']) {
|
||||
drupal_alter('nodeformcols_pre_form', $form);
|
||||
$variant = isset($form['#nodeformcols_variant']) ? $form['#nodeformcols_variant'] : 'default';
|
||||
$placements = nodeformscols_field_placements($form['#node']->type, $variant);
|
||||
foreach ($placements as $key => $p) {
|
||||
if (isset($p['hidden']) && $p['hidden']) {
|
||||
$form[$key]['#access'] = FALSE;
|
||||
}
|
||||
}
|
||||
drupal_alter('nodeformcols_post_form', $form);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function to run ahead of other modules.
|
||||
*/
|
||||
function template_preprocess_node_form(&$aVars) {
|
||||
drupal_add_css(drupal_get_path('module', 'nodeformcols') . '/css/nodeformcols.css');
|
||||
|
||||
$default_region = variable_get('nodeformcols_default_region', NODEFORMCOLS_DEFAULT_REGION);
|
||||
$form = &$aVars['form'];
|
||||
$class = array('node-form', 'clearfix');
|
||||
|
||||
$regions = array();
|
||||
$has_elements = array();
|
||||
$weight = 0;
|
||||
foreach (nodeformcols_form_regions() as $name => $title) {
|
||||
$regions[$name] = array(
|
||||
'#prefix' => '<div class="form-region-' . $name . '">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => $weight,
|
||||
);
|
||||
$weight++;
|
||||
}
|
||||
|
||||
drupal_alter('nodeformcols_pre_placement', $form);
|
||||
$variant = isset($form['#nodeformcols_variant']) ? $form['#nodeformcols_variant'] : 'default';
|
||||
$placements = nodeformscols_field_placements($form['#node']->type, $variant);
|
||||
|
||||
// Track if new fields should be adjusted above the buttons.
|
||||
// TODO: This should be generalized to a way to tell nodeformcols where to place new fields (above below field X).
|
||||
$adjust_to_buttons = isset($placements['buttons']['region']) && ($placements['buttons']['region'] == $default_region);
|
||||
|
||||
foreach (element_children($form) as $key) {
|
||||
$field = $form[$key];
|
||||
if (isset($field['#type']) && in_array($field['#type'], array('value', 'hidden', 'token')) ||
|
||||
(isset($field['#access']) && $field['#access'] == FALSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (isset($placements[$key])) {
|
||||
$p = $placements[$key];
|
||||
|
||||
=======
|
||||
if (isset($placements[$key])) {
|
||||
$p = $placements[$key];
|
||||
|
||||
>>>>>>> parent of 02b3130... extra field via form_alter patch
|
||||
if (isset($p['weight'])) {
|
||||
$field['#weight'] = $p['weight'];
|
||||
}
|
||||
if (isset($p['collapsed']) && isset($field['#collapsible']) && $field['#collapsible']) {
|
||||
$field['#collapsed'] = $p['collapsed'];
|
||||
}
|
||||
$regions[$p['region']][$key] = $field;
|
||||
$has_elements[$p['region']] = TRUE;
|
||||
unset($form[$key]);
|
||||
}
|
||||
else { // Set the default placement for unknown fields
|
||||
$regions[$default_region][$key] = $field;
|
||||
if ($adjust_to_buttons && $regions[$default_region][$key]['#weight'] >= $placements['buttons']['weight']) {
|
||||
$regions[$default_region][$key]['#weight'] = $placements['buttons']['weight'] - .1;
|
||||
}
|
||||
$has_elements[$default_region] = TRUE;
|
||||
unset($form[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($has_elements as $name => $has) {
|
||||
if ($has) {
|
||||
$class[] = 'node-form-has-region-' . $name;
|
||||
$form['nodeformcols_region_' . $name] = $regions[$name];
|
||||
}
|
||||
}
|
||||
|
||||
$aVars['class'] = join($class, ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_node_type_delete().
|
||||
*/
|
||||
function nodeformcols_node_type_delete($info) {
|
||||
$result = db_select('variable')
|
||||
->condition('name', 'nodeformscols_field_placements_' . $info->old_type . '%', 'LIKE')
|
||||
->fields('variable', array('name'))
|
||||
->execute();
|
||||
foreach ($result as $row) {
|
||||
variable_del($row->name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_node_type_update().
|
||||
*/
|
||||
function nodeformcols_node_type_update($info) {
|
||||
if (!empty($info->old_type) && $info->old_type != $info->type) {
|
||||
$base = 'nodeformscols_field_placements_' . $info->old_type;
|
||||
$new_base = 'nodeformscols_field_placements_' . $info->type;
|
||||
$result = db_select('variable')
|
||||
->condition('name', $base . '%', 'LIKE')
|
||||
->fields('variable', array('name'))
|
||||
->execute();
|
||||
foreach ($result as $row) {
|
||||
$value = variable_get($row->name, NULL);
|
||||
$new_name = str_replace($base, $new_base, $row->name);
|
||||
variable_set($new_name, $value);
|
||||
variable_del($row->name);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 460 B |
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Renders the nodeformcols form in a panel pane. The entire panel is inside the
|
||||
* <form> tag. Most of the code is from the CTools form.inc content type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback function to supply a list of content types.
|
||||
*/
|
||||
function nodeformcols_nodeformcols_ctools_content_types() {
|
||||
return array(
|
||||
// only provides a single content type
|
||||
'single' => TRUE,
|
||||
'render last' => TRUE,
|
||||
'title' => t('Nodeformcols form'),
|
||||
'icon' => 'icon_form.png',
|
||||
'description' => t('A complete nodeformcols node form.'),
|
||||
'required context' => new ctools_context_required(t('Form'), 'form'),
|
||||
'category' => t('Form'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output function for the 'nodeformcols' content type. Outputs a node form
|
||||
* as displayed by the nodeformcols module.
|
||||
*/
|
||||
function nodeformcols_nodeformcols_content_type_render($subtype, $conf, $panel_args, &$context) {
|
||||
$block = new stdClass();
|
||||
$block->module = 'nodeformcols';
|
||||
|
||||
$context->form['#theme'] = 'node_form';
|
||||
unset($context->form['#theme_used']);
|
||||
|
||||
if (isset($context->form)) {
|
||||
$block->title = $context->form_title;
|
||||
if (!empty($context->form_id)) {
|
||||
// If this is a form, drupal_render it.
|
||||
$block->content = drupal_render($context->form);
|
||||
}
|
||||
else {
|
||||
// Otherwise just spit back what we were given. This is probably an
|
||||
// error message or something.
|
||||
$block->content = $context->form;
|
||||
}
|
||||
$block->delta = $context->form_id;
|
||||
}
|
||||
else {
|
||||
$block->title = t('Form');
|
||||
$block->content = t('Form goes here.');
|
||||
$block->delta = 'unknown';
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to provide the administrative title of the custom content.
|
||||
*/
|
||||
function nodeformcols_nodeformcols_content_type_admin_title($subtype, $conf, $context) {
|
||||
return t('Nodeformcols node form');
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to provide administrative info.
|
||||
*/
|
||||
function nodeformcols_nodeformcols_content_type_admin_info($subtype, $conf) {
|
||||
$block = new stdClass();
|
||||
$block->title = t('Affected forms');
|
||||
|
||||
$types = node_type_get_types();
|
||||
$forms = array();
|
||||
foreach ($types as $type => $description) {
|
||||
if (variable_get('nodeformscols_field_placements_' . $type . '_default', FALSE)) {
|
||||
$forms[] = $description->name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($forms)) {
|
||||
$block->content = theme('item_list', array('items' => $forms));
|
||||
}
|
||||
else {
|
||||
$block->content = '<p>' . t('No forms are using customized nodeformcols settings.') . '</p>';
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
|
||||
function nodeformcols_nodeformcols_content_type_edit_form(&$form, &$form_state) {
|
||||
// provide a blank form so we have a place to add settings widgets
|
||||
}
|
Reference in New Issue
Block a user