uppdated modules
This commit is contained in:
@@ -1,274 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow.
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
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".
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.)
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
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:
|
||||
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,
|
||||
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,
|
||||
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.)
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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
|
||||
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.
|
||||
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.
|
||||
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
|
||||
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.
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
// $Id: README.txt,v 1.3 2010/10/29 10:31:08 anrikun Exp $
|
||||
|
||||
MENU ADMIN PER MENU
|
||||
http://drupal.org/project/menu_admin_per_menu
|
||||
https://www.drupal.org/project/menu_admin_per_menu
|
||||
|
||||
DESCRIPTION
|
||||
By default, Drupal 7 allows only users with "Administer menus and menu items" to add, modify or delete menu items.
|
||||
By default, Drupal allows only users with the "Administer menus and menu items" permission to add, modify or delete menu items.
|
||||
In case you want for instance to let certain users manage Main menu or Navigation menu but not Management menu, this module provides this functionality.
|
||||
|
||||
INSTALLATION
|
||||
Please read instructions at: http://drupal.org/project/menu_admin_per_menu
|
||||
Please read instructions at: https://www.drupal.org/project/menu_admin_per_menu
|
||||
|
||||
CONTACT
|
||||
Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hooks that can be implemented by other modules to extend Menu Admin per Menu.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alter the menus for which a user has per menu admin permissions.
|
||||
*
|
||||
* @param $perm_menus
|
||||
* The $perm_menus array returned by _menu_admin_per_menu_get_perm_menus()
|
||||
* for a user account.
|
||||
* @param $account
|
||||
* The user account object.
|
||||
*
|
||||
* @see _menu_admin_per_menu_get_perm_menus()
|
||||
*/
|
||||
function hook_menu_admin_per_menu_perm_menus_alter(&$perm_menus, $account) {
|
||||
// Change $perm_menus.
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
; $Id: menu_admin_per_menu.info,v 1.4 2011/01/22 22:23:55 anrikun Exp $
|
||||
name = Menu Admin per Menu
|
||||
description = Allows to give roles per menu admin permissions without giving them full administrer menu permission.
|
||||
description = Allows to give roles per menu admin permissions without giving them full administer menu permission.
|
||||
package = Administration
|
||||
core = 7.x
|
||||
dependencies[] = menu
|
||||
files[] = menu_admin_per_menu.module
|
||||
|
||||
; Information added by drupal.org packaging script on January 1, 1970 - 00:00
|
||||
version = "7.x-1.0"
|
||||
; Information added by Drupal.org packaging script on 2015-08-13
|
||||
version = "7.x-1.1"
|
||||
core = "7.x"
|
||||
project = "menu_admin_per_menu"
|
||||
datestamp = "1295735798"
|
||||
datestamp = "1439473440"
|
||||
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
<?php
|
||||
// $Id: menu_admin_per_menu.module,v 1.6 2010/10/29 10:31:08 anrikun Exp $
|
||||
|
||||
/**
|
||||
* @file menu_admin_per_menu.module
|
||||
* Main file for the menu_admin_per_menu module.
|
||||
*
|
||||
* By default, Drupal allows only users with administrer menu permission to add, modify or delete menu items.
|
||||
* In case you want for instance to let certain users manage primary links or secondary links but not navigation menu,
|
||||
* this module provides this functionality.
|
||||
* Developped by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
|
||||
* @file
|
||||
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
|
||||
* http://www.absyx.fr
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_permission().
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function menu_admin_per_menu_permission() {
|
||||
$perms = array();
|
||||
|
||||
$menus = menu_get_menus();
|
||||
foreach ($menus as $name => $title) {
|
||||
$perms['administer '. $name .' menu items'] = array('title' => t('Administer %menu menu items', array('%menu' => $title)));
|
||||
$perms['administer ' . $name . ' menu items'] = array('title' => t('Administer %menu menu items', array('%menu' => $title)));
|
||||
}
|
||||
|
||||
return $perms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu_alter()
|
||||
* Implements hook_menu_alter().
|
||||
*/
|
||||
function menu_admin_per_menu_menu_alter(&$items) {
|
||||
$items['admin/structure/menu']['page callback'] = '_menu_admin_per_menu_menu_overview_page';
|
||||
@@ -43,16 +39,20 @@ function menu_admin_per_menu_menu_alter(&$items) {
|
||||
$items['admin/structure/menu/item/%menu_link/delete']['access arguments'] = array(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides menu_overview_page().
|
||||
*/
|
||||
function _menu_admin_per_menu_menu_overview_page() {
|
||||
if (user_access('administer menu')) {
|
||||
return menu_overview_page();
|
||||
}
|
||||
|
||||
$perm_menus = _menu_admin_per_menu_get_perm_menus();
|
||||
$result = db_query("SELECT * FROM {menu_custom} ORDER BY title", array(), array('fetch' => PDO::FETCH_ASSOC));
|
||||
$header = array(t('Title'), array('data' => t('Operations'), 'colspan' => '2'));
|
||||
$rows = array();
|
||||
foreach ($result as $menu) {
|
||||
if (user_access('administer '. $menu['menu_name'] .' menu items')) {
|
||||
if (isset($perm_menus[$menu['menu_name']])) {
|
||||
$row = array(theme('menu_admin_overview', array('title' => $menu['title'], 'name' => $menu['menu_name'], 'description' => $menu['description'])));
|
||||
$row[] = array('data' => l(t('list links'), 'admin/structure/menu/manage/' . $menu['menu_name']));
|
||||
$row[] = array('data' => l(t('add link'), 'admin/structure/menu/manage/' . $menu['menu_name'] . '/add'));
|
||||
@@ -63,39 +63,42 @@ function _menu_admin_per_menu_menu_overview_page() {
|
||||
return theme('table', array('header' => $header, 'rows' => $rows));
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for the overview page of all the menus.
|
||||
*/
|
||||
function _menu_admin_per_menu_access() {
|
||||
if (user_access('administer menu')) {
|
||||
return TRUE;
|
||||
}
|
||||
$perms = array_keys(menu_admin_per_menu_permission());
|
||||
foreach ($perms as $perm) {
|
||||
if (user_access($perm)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function _menu_admin_per_menu_menu_access($menu = NULL) {
|
||||
if (user_access('administer menu')
|
||||
|| user_access('administer '. $menu['menu_name'] .' menu items')) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function _menu_admin_per_menu_menu_link_access($menu_link = NULL) {
|
||||
if (user_access('administer menu')
|
||||
|| user_access('administer '. $menu_link['menu_name'] .' menu items')) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
return user_access('administer menu') || _menu_admin_per_menu_get_perm_menus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter()
|
||||
* Access callback for the overview and add menu link pages of a menu.
|
||||
*/
|
||||
function _menu_admin_per_menu_menu_access($menu) {
|
||||
if (user_access('administer menu')) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$perm_menus = _menu_admin_per_menu_get_perm_menus();
|
||||
return isset($perm_menus[$menu['menu_name']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for the menu link administration pages.
|
||||
*/
|
||||
function _menu_admin_per_menu_menu_link_access($menu_link) {
|
||||
if (user_access('administer menu')) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$perm_menus = _menu_admin_per_menu_get_perm_menus();
|
||||
return isset($perm_menus[$menu_link['menu_name']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
function menu_admin_per_menu_form_alter(&$form, $form_state, $form_id) {
|
||||
// Alter the menu element of the node form.
|
||||
if (isset($form['menu']['link']['parent']) && !user_access('administer menu')) {
|
||||
$form['menu']['#access'] = FALSE;
|
||||
if (_menu_admin_per_menu_filter_parent_options($form['menu']['link'])) {
|
||||
@@ -108,39 +111,61 @@ function menu_admin_per_menu_form_alter(&$form, $form_state, $form_id) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters parent options based on allowed menus.
|
||||
*/
|
||||
function _menu_admin_per_menu_filter_parent_options(&$element) {
|
||||
$perm_menus = _menu_admin_per_menu_get_perm_menus();
|
||||
if ((count($perm_menus) > 0) && is_array($element['parent']['#options'])) {
|
||||
|
||||
if ($perm_menus && is_array($element['parent']['#options'])) {
|
||||
$has_mlid = !empty($element['mlid']['#value']);
|
||||
$default_value = $element['parent']['#default_value'];
|
||||
$option_keys = array_keys($element['parent']['#options']);
|
||||
|
||||
foreach ($option_keys as $option_key) {
|
||||
list($menu, $item) = explode(':', $option_key);
|
||||
if (!in_array($menu, $perm_menus)) {
|
||||
if (!isset($perm_menus[$menu])) {
|
||||
unset($element['parent']['#options'][$option_key]);
|
||||
if ($has_mlid && ($option_key == $default_value)) {
|
||||
if ($has_mlid && $option_key == $default_value) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count($element['parent']['#options']) > 0;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function _menu_admin_per_menu_get_perm_menus() {
|
||||
$perm_menus = array();
|
||||
$menus = menu_get_menus();
|
||||
foreach ($menus as $name => $title) {
|
||||
if (user_access('administer '. $name .' menu items')) {
|
||||
$perm_menus[] = $name;
|
||||
}
|
||||
/**
|
||||
* Returns the menus for which a user has per menu admin permissions.
|
||||
*/
|
||||
function _menu_admin_per_menu_get_perm_menus($account = NULL) {
|
||||
$perm_menus = &drupal_static(__FUNCTION__, array());
|
||||
|
||||
if (!isset($account)) {
|
||||
$account = $GLOBALS['user'];
|
||||
}
|
||||
return $perm_menus;
|
||||
|
||||
if (!isset($perm_menus[$account->uid])) {
|
||||
$perm_menus[$account->uid] = array();
|
||||
|
||||
$menus = menu_get_menus();
|
||||
foreach ($menus as $name => $title) {
|
||||
if (user_access('administer ' . $name . ' menu items', $account)) {
|
||||
$perm_menus[$account->uid][$name] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
drupal_alter('menu_admin_per_menu_perm_menus', $perm_menus[$account->uid], $account);
|
||||
}
|
||||
|
||||
return $perm_menus[$account->uid];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_FORM_ID_alter()
|
||||
* Implements hook_form_FORM_ID_alter() for menu_edit_item().
|
||||
*/
|
||||
function menu_admin_per_menu_form_menu_edit_item_alter(&$form, &$form_state, $form_id) {
|
||||
if (isset($form['parent']) && !user_access('administer menu') && _menu_admin_per_menu_filter_parent_options($form)) {
|
||||
|
||||
+20
-1
@@ -1,12 +1,29 @@
|
||||
<?php
|
||||
|
||||
|
||||
class me_node_creation_CrumbsMonoPlugin implements crumbs_MonoPlugin {
|
||||
|
||||
/**
|
||||
* @param crumbs_InjectedAPI_describeMonoPlugin $api
|
||||
* Injected API object, with methods that allows the plugin to further
|
||||
* describe itself.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function describe($api) {
|
||||
$api->setTitle('Set breadcrumbs for placeholder pages.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find candidates for the parent path.
|
||||
*
|
||||
* @param string $path
|
||||
* The path that we want to find a parent for.
|
||||
* @param array $item
|
||||
* Item as returned from crumbs_get_router_item()
|
||||
*
|
||||
* @return string
|
||||
* Parent path candidate.
|
||||
*/
|
||||
function findParent($path, $item) {
|
||||
switch ($item['route']) {
|
||||
case 'node/add/%/mlid/%':
|
||||
@@ -16,5 +33,7 @@ class me_node_creation_CrumbsMonoPlugin implements crumbs_MonoPlugin {
|
||||
// Let the menu.hierarchy.* plugin do its thing
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-5
@@ -1,10 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Page callback for node/add/%node_type/mlid/%menu_editor_mlid
|
||||
*
|
||||
* @param object $type
|
||||
* @param array $menu_item
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
function me_node_creation_create_node($type, $menu_item) {
|
||||
function me_node_creation_create_node($type, array $menu_item) {
|
||||
global $user;
|
||||
|
||||
drupal_set_title(t('Create @name', array('@name' => $type->name)), PASS_THROUGH);
|
||||
@@ -24,8 +28,11 @@ function me_node_creation_create_node($type, $menu_item) {
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
function _me_node_creation_form_alter(&$form, $node) {
|
||||
/**
|
||||
* @param array $form
|
||||
* @param object $node
|
||||
*/
|
||||
function _me_node_creation_form_alter(array &$form, $node) {
|
||||
$menu_item = $node->me_node_creation_menu_item;
|
||||
|
||||
unset($form['menu']);
|
||||
@@ -39,7 +46,7 @@ function _me_node_creation_form_alter(&$form, $node) {
|
||||
}
|
||||
|
||||
$txt = t('The created node will be associated with the chosen menu item (!mlid),<br/>with link title "@title"', array(
|
||||
'!mlid' => $mlid_text,
|
||||
'!mlid' => $mlid_text,
|
||||
'@title' => $menu_item['link_title'],
|
||||
));
|
||||
$txt = "<p>$txt</p>";
|
||||
|
||||
@@ -6,9 +6,9 @@ dependencies[] = menu_editor
|
||||
; xautoload for the crumbs plugin
|
||||
dependencies[] = xautoload
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-10-01
|
||||
version = "7.x-1.0-beta3+0-dev"
|
||||
; Information added by Drupal.org packaging script on 2016-11-06
|
||||
version = "7.x-1.0-beta4"
|
||||
core = "7.x"
|
||||
project = "menu_editor"
|
||||
datestamp = "1380586819"
|
||||
datestamp = "1478399941"
|
||||
|
||||
|
||||
+39
-19
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_permission()
|
||||
*/
|
||||
@@ -12,25 +11,31 @@ function me_node_creation_permission() {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu()
|
||||
*/
|
||||
function me_node_creation_menu() {
|
||||
$items = array();
|
||||
/* @see node_type_load() */
|
||||
/* @see menu_editor_menu_link_load() */
|
||||
$items['node/add/%node_type/mlid/%menu_editor_menu_link'] = array(
|
||||
'load arguments' => array(2, 4),
|
||||
'title' => 'Create a node',
|
||||
/* @see me_node_creation_create_node() */
|
||||
'page callback' => 'me_node_creation_create_node',
|
||||
'page arguments' => array(2, 4),
|
||||
'file' => 'me_node_creation.create.inc',
|
||||
/* @see me_node_creation_create_node_access() */
|
||||
'access callback' => 'me_node_creation_create_node_access',
|
||||
'access arguments' => array(2),
|
||||
);
|
||||
/* @see menu_editor_menu_link_load() */
|
||||
$items['mlid/%menu_editor_menu_link/under-construction'] = array(
|
||||
'title' => 'Under Construction',
|
||||
/* @see menu_editor_placeholder_title() */
|
||||
'title callback' => 'menu_editor_placeholder_title',
|
||||
'title arguments' => array(1),
|
||||
/* @see menu_editor_placeholder_page() */
|
||||
'page callback' => 'menu_editor_placeholder_page',
|
||||
'page arguments' => array(1),
|
||||
'file' => 'me_node_creation.placeholder.inc',
|
||||
@@ -40,11 +45,14 @@ function me_node_creation_menu() {
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter()
|
||||
*
|
||||
* @param array $form
|
||||
* @param array $form_state
|
||||
* @param string $form_id
|
||||
*/
|
||||
function me_node_creation_form_alter(&$form, &$form_state, $form_id) {
|
||||
function me_node_creation_form_alter(array &$form, array &$form_state, $form_id) {
|
||||
if (empty($form['#node_edit_form']) || empty($form['#node'])) {
|
||||
return;
|
||||
}
|
||||
@@ -53,12 +61,14 @@ function me_node_creation_form_alter(&$form, &$form_state, $form_id) {
|
||||
return;
|
||||
}
|
||||
module_load_include('create.inc', 'me_node_creation');
|
||||
return _me_node_creation_form_alter($form, $node);
|
||||
form_load_include($form_state, 'inc', 'node', 'node.pages');
|
||||
_me_node_creation_form_alter($form, $node);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_node_insert()
|
||||
*
|
||||
* @param object $node
|
||||
*/
|
||||
function me_node_creation_node_insert($node) {
|
||||
$menu_item = @$node->me_node_creation_menu_item;
|
||||
@@ -77,9 +87,10 @@ function me_node_creation_node_insert($node) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_crumbs_plugins()
|
||||
*
|
||||
* @param crumbs_InjectedAPI_hookCrumbsPlugins $api
|
||||
*/
|
||||
function me_node_creation_crumbs_plugins($api) {
|
||||
$api->monoPlugin();
|
||||
@@ -89,12 +100,15 @@ function me_node_creation_crumbs_plugins($api) {
|
||||
// Wildcard loaders
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Wildcard loader for %menu_editor_menu_link
|
||||
* This is similar to menu_link_load(), but we do some loop prevention.
|
||||
*
|
||||
* TODO: Test if the by-reference does not explode in some edge cases.
|
||||
*
|
||||
* @param int $mlid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function menu_editor_menu_link_load($mlid) {
|
||||
static $_cache = array();
|
||||
@@ -124,10 +138,9 @@ function menu_editor_menu_link_load($mlid) {
|
||||
// Title callbacks
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Title callback for mlid/%menu_link/under-construction
|
||||
*
|
||||
*
|
||||
* @param array $item
|
||||
* The menu link, as returned by menu_link_load()
|
||||
* @return string
|
||||
@@ -138,30 +151,38 @@ function menu_editor_placeholder_title($item) {
|
||||
return $item['link_title'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Title for menu links or tabs.
|
||||
* The page title can be different!
|
||||
*
|
||||
* @param $type_arg
|
||||
* @param $item
|
||||
*
|
||||
* @param string $type_arg
|
||||
* @param array|mixed $item
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @todo This is currently not in use anywhere, and not useful as-is.
|
||||
*/
|
||||
function me_node_creation_title($type_arg, $item) {
|
||||
// @todo This is a stupid way to get a node type label.
|
||||
foreach (node_type_get_types() as $type_name => $type_object) {
|
||||
if ($type_name == $type_arg) {
|
||||
if ($type_name === $type_arg) {
|
||||
// @todo This should use t() with @placeholder.
|
||||
return "New $type_object->name";
|
||||
}
|
||||
}
|
||||
return $type->name;
|
||||
return t('Create node of unknown type');
|
||||
}
|
||||
|
||||
|
||||
// Access callbacks
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Access callback for node/add/%node_type/mlid/%menu_editor_mlid
|
||||
*
|
||||
* @param object|mixed $type
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function me_node_creation_create_node_access($type) {
|
||||
if (!is_object($type)) {
|
||||
@@ -175,9 +196,8 @@ function me_node_creation_create_node_access($type) {
|
||||
// Utility
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
* Array of placeholders
|
||||
*/
|
||||
function me_node_creation_menu_editor_placeholders() {
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Page callback for mlid/%menu_link/under-construction
|
||||
*
|
||||
*
|
||||
* @param array $item
|
||||
* The menu link, as returned by menu_link_load()
|
||||
*
|
||||
* @return string
|
||||
* Rendered HTML
|
||||
* TODO: We could instead return a renderable array.
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@ core = 7.x
|
||||
dependencies[] = menu_editor
|
||||
package = Menu
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-10-01
|
||||
version = "7.x-1.0-beta3+0-dev"
|
||||
; Information added by Drupal.org packaging script on 2016-11-06
|
||||
version = "7.x-1.0-beta4"
|
||||
core = "7.x"
|
||||
project = "menu_editor"
|
||||
datestamp = "1380586819"
|
||||
datestamp = "1478399941"
|
||||
|
||||
|
||||
+117
-49
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* @file
|
||||
* Find node paths on menu item creation via autocomplete.
|
||||
*
|
||||
*
|
||||
* This is a shameless clone of
|
||||
* http://drupal.org/project/mpac
|
||||
* by stBorchert
|
||||
@@ -12,7 +12,8 @@
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*
|
||||
* @return An array of menu items.
|
||||
* @return array
|
||||
* An array of menu items.
|
||||
*/
|
||||
function me_path_autocomplete_menu() {
|
||||
$items = array();
|
||||
@@ -20,6 +21,7 @@ function me_path_autocomplete_menu() {
|
||||
$items['mepac/autocomplete'] = array(
|
||||
'title' => 'Menu path autocomplete',
|
||||
'description' => 'Autocomplete callback for menu path autocomplete',
|
||||
/* @see me_path_autocomplete() */
|
||||
'page callback' => 'me_path_autocomplete',
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array('access content'),
|
||||
@@ -30,76 +32,142 @@ function me_path_autocomplete_menu() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find nodes and URL aliases based on title.
|
||||
* @param $string
|
||||
* Page callback for 'mepac/autocomplete'.
|
||||
*
|
||||
* Finds nodes and URL aliases based on title.
|
||||
* Sets a http header, and prints json output.
|
||||
*
|
||||
* @param string $string
|
||||
* Title of element to find.
|
||||
* @return
|
||||
* List of elements with path as key.
|
||||
*
|
||||
* @see mpac_autocomplete()
|
||||
*/
|
||||
function me_path_autocomplete($string = NULL) {
|
||||
$args = func_get_args();
|
||||
$string = implode('/', $args);
|
||||
$string = strtolower($string);
|
||||
$title = filter_xss_admin($string);
|
||||
$matches = array();
|
||||
// $matches[$string] = $string;
|
||||
|
||||
$matches = _me_path_autocomplete_get_matches($string);
|
||||
|
||||
drupal_json_output($matches);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
function _me_path_autocomplete_get_matches($string) {
|
||||
$string = strtolower($string);
|
||||
|
||||
// @todo Do we need to filter this?
|
||||
// See https://www.drupal.org/node/2785261 in mpac issue queue.
|
||||
# $title = filter_xss_admin($string);
|
||||
|
||||
$matches = _me_path_autocomplete_get_matches_for_placeholders($string);
|
||||
|
||||
if ($string === '') {
|
||||
return $matches;
|
||||
}
|
||||
|
||||
$like_placeholder = (strlen($string) > 3) ? "%" . db_like($string) . "%" : db_like($string) . "%";
|
||||
|
||||
$matches += _me_path_autocomplete_get_matches_for_nodes($like_placeholder);
|
||||
$matches += _me_path_autocomplete_get_matches_for_aliases($like_placeholder);
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @see _mpac_get_matches_for_nodes()
|
||||
*/
|
||||
function _me_path_autocomplete_get_matches_for_placeholders($string) {
|
||||
|
||||
$matches = array();
|
||||
/* @see hook_menu_editor_placeholders() */
|
||||
foreach (module_invoke_all('menu_editor_placeholders') as $placeholder_code => $placeholder_path) {
|
||||
if (!strlen($string) || count(explode($string, $placeholder_code)) > 1) {
|
||||
if ($string === '' || false !== strpos($placeholder_code, $string)) {
|
||||
$matches[$placeholder_code] = htmlentities($placeholder_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get a list of all nodes where the title matches the given string.
|
||||
if (strlen($string) > 1) {
|
||||
$like_placeholder = (strlen($string) > 3) ? "%" . db_like($string) . "%" : db_like($string) . "%";
|
||||
$nodes = db_select('node', 'n')
|
||||
->fields('n')
|
||||
->condition('title', $like_placeholder, 'LIKE')
|
||||
->range(0, 8)
|
||||
->execute();
|
||||
return $matches;
|
||||
}
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
// Add node path and title to list.
|
||||
if (node_access('view', $node) && $node->status) {
|
||||
$node_title = check_plain($node->title);
|
||||
$nid = $node->nid;
|
||||
$lang = $node->language != LANGUAGE_NONE ? ($node->language . ': ') : '';
|
||||
$matches['node/'. $node->nid] = $lang . "$node_title [nid:$nid]";
|
||||
}
|
||||
}
|
||||
if (module_exists('path')) {
|
||||
// Get a list of all URL aliases where the destination matches the given
|
||||
// string.
|
||||
$aliases = db_select('url_alias')
|
||||
->fields('url_alias')
|
||||
->condition('alias', $like_placeholder, 'LIKE')
|
||||
->range(0, 8)
|
||||
->execute();
|
||||
/**
|
||||
* @param string $like_placeholder
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @see _mpac_get_matches_for_nodes()
|
||||
*/
|
||||
function _me_path_autocomplete_get_matches_for_nodes($like_placeholder) {
|
||||
|
||||
foreach ($aliases as $alias) {
|
||||
// Add alias source and destination to list (and add a special marker to
|
||||
// the item).
|
||||
$lang = $alias->language != LANGUAGE_NONE ? ($alias->language . ': ') : '';
|
||||
$src = check_plain($alias->source);
|
||||
$dst = check_plain($alias->alias);
|
||||
$matches[$alias->source] = $lang . "$dst | $src";
|
||||
}
|
||||
$q = db_select('node', 'n');
|
||||
$q->fields('n');
|
||||
$q->condition('title', $like_placeholder, 'LIKE');
|
||||
$q->range(0, 8);
|
||||
|
||||
$matches = array();
|
||||
foreach ($q->execute() as $node) {
|
||||
// Add node path and title to list.
|
||||
if (node_access('view', $node) && $node->status) {
|
||||
$node_title = check_plain($node->title);
|
||||
$nid = $node->nid;
|
||||
$lang = $node->language !== LANGUAGE_NONE ? ($node->language . ': ') : '';
|
||||
$matches['node/'. $node->nid] = $lang . "$node_title [nid:$nid]";
|
||||
}
|
||||
}
|
||||
|
||||
drupal_json_output($matches);
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $like_placeholder
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @see _mpac_get_matches_for_aliases()
|
||||
*/
|
||||
function _me_path_autocomplete_get_matches_for_aliases($like_placeholder) {
|
||||
|
||||
if (!module_exists('path')) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Get a list of all URL aliases where the destination matches the given
|
||||
// string.
|
||||
$q = db_select('url_alias');
|
||||
$q->fields('url_alias');
|
||||
$q->condition('alias', $like_placeholder, 'LIKE');
|
||||
$q->range(0, 8);
|
||||
|
||||
$matches = array();
|
||||
foreach ($q->execute() as $alias) {
|
||||
// Add alias source and destination to list (and add a special marker to
|
||||
// the item).
|
||||
$lang = $alias->language !== LANGUAGE_NONE ? ($alias->language . ': ') : '';
|
||||
$src = check_plain($alias->source);
|
||||
$dst = check_plain($alias->alias);
|
||||
$matches[$alias->source] = $lang . "$dst | $src";
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* Change path field to autocomplete field.
|
||||
*
|
||||
* @param array $form
|
||||
* @param array $form_state
|
||||
*/
|
||||
function me_path_autocomplete_form_menu_editor_overview_form_alter(&$form, &$form_state) {
|
||||
function me_path_autocomplete_form_menu_editor_overview_form_alter(array &$form, array &$form_state) {
|
||||
foreach (element_children($form) as $element_key) {
|
||||
$form[$element_key]['link_path']['#autocomplete_path'] = 'mepac/autocomplete';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Form for editing an entire menu tree at once.
|
||||
*
|
||||
* Shows for one menu the menu items accessible to the current user and
|
||||
* relevant operations.
|
||||
*
|
||||
* @param array $form
|
||||
* @param array $form_state
|
||||
* @param array $menu
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @see menu_overview_form()
|
||||
* @see menu_edit_item()
|
||||
* @see menu_editor_overview_form_validate()
|
||||
* @see menu_editor_overview_form_submit()
|
||||
*/
|
||||
function menu_editor_overview_form($form, &$form_state, $menu) {
|
||||
global $menu_admin;
|
||||
function menu_editor_overview_form(array $form, array &$form_state, array $menu) {
|
||||
$form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/menu.css');
|
||||
$sql = "
|
||||
SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.delivery_callback, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
|
||||
@@ -24,9 +33,9 @@ function menu_editor_overview_form($form, &$form_state, $menu) {
|
||||
$node_links = array();
|
||||
menu_tree_collect_node_links($tree, $node_links);
|
||||
// We indicate that a menu administrator is running the menu access check.
|
||||
$menu_admin = TRUE;
|
||||
$GLOBALS['menu_admin'] = TRUE;
|
||||
menu_tree_check_access($tree, $node_links);
|
||||
$menu_admin = FALSE;
|
||||
$GLOBALS['menu_admin'] = FALSE;
|
||||
|
||||
$form = array('#tree' => TRUE);
|
||||
$form['#multilingual_menu'] = FALSE;
|
||||
@@ -34,12 +43,12 @@ function menu_editor_overview_form($form, &$form_state, $menu) {
|
||||
|
||||
$max_root_weight = _menu_editor_overview_tree_form($form, $form_state, $tree);
|
||||
|
||||
// default values for all new menu items..
|
||||
// default form values for all new menu items..
|
||||
$default_values = array(
|
||||
'link_title' => '',
|
||||
'link_path' => '<front>',
|
||||
'description' => '',
|
||||
'hidden' => true,
|
||||
'enabled' => true,
|
||||
'expanded' => false,
|
||||
'weight' => 0,
|
||||
// 'mlid' => NULL, // this is different for every single one
|
||||
@@ -53,19 +62,22 @@ function menu_editor_overview_form($form, &$form_state, $menu) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
for ($i=0; $i<8; ++$i) {
|
||||
for ($i = 0; $i < 8; ++$i) {
|
||||
// new menu item
|
||||
$default_values['mlid'] = 'new' . $i;
|
||||
$item_key = 'mlid-new'.$i;
|
||||
$form[$item_key] = _menu_editor_overview_tree_form_item('new'.$i, $default_values, $form['#multilingual_menu']);
|
||||
$item_key = 'mlid-new' . $i;
|
||||
$form[$item_key] = _menu_editor_overview_tree_form_item('new' . $i, $default_values, $form['#multilingual_menu']);
|
||||
$form[$item_key]['weight']['#default_value'] = $max_root_weight + $i + 1;
|
||||
$form[$item_key]['#item'] = array();
|
||||
$form[$item_key]['#item'] = array(
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'menu_name' => $menu['menu_name'],
|
||||
);
|
||||
$form[$item_key]['#attributes'] = array('class' => 'menu-new');
|
||||
$form[$item_key]['drag']['#markup'] = t('New menu item');
|
||||
}
|
||||
|
||||
$form['#menu'] = $menu;
|
||||
$form['#menu'] = $menu;
|
||||
if (element_children($form)) {
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
@@ -79,18 +91,25 @@ function menu_editor_overview_form($form, &$form_state, $menu) {
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recursive helper function for menu_overview_form().
|
||||
*
|
||||
* @param array $form
|
||||
* @param array $form_state
|
||||
* @param array $tree
|
||||
*
|
||||
* @return int
|
||||
* The max root weight (whatever this means)
|
||||
*/
|
||||
function _menu_editor_overview_tree_form(&$form, &$form_state, $tree) {
|
||||
function _menu_editor_overview_tree_form(array &$form, array &$form_state, array $tree) {
|
||||
$max_root_weight = 0;
|
||||
foreach ($tree as $data) {
|
||||
$title = '';
|
||||
$item = $data['link'];
|
||||
// Don't show callbacks; these have $item['hidden'] < 0.
|
||||
if ($item && $item['hidden'] >= 0) {
|
||||
$item_key = 'mlid-'. $item['mlid'];
|
||||
$item_key = 'mlid-' . $item['mlid'];
|
||||
// @todo This is bogus. The value might be in $form_state['input'][$item_key], but never in $form_state[$item_key].
|
||||
$weight = isset($form_state[$item_key]['weight']) ? $form_state[$item_key]['weight'] : $item['weight'];
|
||||
$plid = isset($form_state[$item_key]['plid']) ? $form_state[$item_key]['plid'] : $item['plid'];
|
||||
|
||||
@@ -101,24 +120,30 @@ function _menu_editor_overview_tree_form(&$form, &$form_state, $tree) {
|
||||
$path = $item['link_path'];
|
||||
if (!empty($item['options']['query'])) {
|
||||
if (is_array($item['options']['query'])) {
|
||||
$path .= '?'. drupal_http_build_query($item['options']['query']);
|
||||
$path .= '?' . drupal_http_build_query($item['options']['query']);
|
||||
}
|
||||
else {
|
||||
// Query could be a string, due to a malfunction in previous versions of this module.
|
||||
$path .= '?'. $item['options']['query'];
|
||||
$path .= '?' . $item['options']['query'];
|
||||
}
|
||||
}
|
||||
if (isset($item['options']['fragment'])) {
|
||||
$path .= '#'. $item['options']['fragment'];
|
||||
$path .= '#' . $item['options']['fragment'];
|
||||
}
|
||||
|
||||
/* @see menu_firstchild_form_alter() */
|
||||
if (isset($item['href']) && '<firstchild>' === $item['href']) {
|
||||
$item['hidden'] = !empty($item['options']['unaltered_hidden']);
|
||||
}
|
||||
|
||||
$default_values = array(
|
||||
'link_title' => $item['link_title'],
|
||||
'link_path' => $path,
|
||||
'description' => isset($item['options']['attributes']['title']) ? $item['options']['attributes']['title'] : '',
|
||||
'hidden' => !$item['hidden'],
|
||||
'enabled' => !$item['hidden'],
|
||||
'expanded' => $item['expanded'],
|
||||
'weight' => $weight,
|
||||
'plid' => $plid,
|
||||
'weight' => $weight,
|
||||
'plid' => $plid,
|
||||
'depth' => 1,
|
||||
);
|
||||
|
||||
@@ -180,7 +205,7 @@ function _menu_editor_overview_tree_form(&$form, &$form_state, $tree) {
|
||||
}
|
||||
|
||||
// Only items created by the menu module can be deleted.
|
||||
if ($item['module'] == 'menu' || $item['updated'] == 1) {
|
||||
if ($item['module'] === 'menu' || (string)$item['updated'] === '1') {
|
||||
$form[$item_key]['delete'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('delete'),
|
||||
@@ -191,17 +216,23 @@ function _menu_editor_overview_tree_form(&$form, &$form_state, $tree) {
|
||||
|
||||
// process child elements
|
||||
if ($data['below']) {
|
||||
_menu_editor_overview_tree_form($form, $form_data, $data['below']);
|
||||
_menu_editor_overview_tree_form($form, $form_state, $data['below']);
|
||||
}
|
||||
}
|
||||
return $max_root_weight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int|string $item_mlid
|
||||
* @param array $default_values
|
||||
* @param bool $multilingual_menu
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function _menu_editor_overview_tree_form_item($item_mlid, $default_values, $multilingual_menu = FALSE) {
|
||||
|
||||
foreach (menu_editor_get_placeholders() as $code => $path) {
|
||||
if (str_replace('@mlid', $item_mlid, $path) == $default_values['link_path']) {
|
||||
if (str_replace('@mlid', $item_mlid, $path) === $default_values['link_path']) {
|
||||
$default_values['link_path'] = $code;
|
||||
}
|
||||
}
|
||||
@@ -210,10 +241,12 @@ function _menu_editor_overview_tree_form_item($item_mlid, $default_values, $mult
|
||||
$element['link_title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => 25,
|
||||
'#maxlength' => 128,
|
||||
);
|
||||
$element['link_path'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => 25,
|
||||
'#maxlength' => 255,
|
||||
);
|
||||
$element['description'] = array(
|
||||
'#type' => 'textarea',
|
||||
@@ -221,7 +254,7 @@ function _menu_editor_overview_tree_form_item($item_mlid, $default_values, $mult
|
||||
'#rows' => 1,
|
||||
'#resizable' => FALSE,
|
||||
);
|
||||
$element['hidden'] = array(
|
||||
$element['enabled'] = array(
|
||||
'#type' => 'checkbox',
|
||||
);
|
||||
$element['expanded'] = array(
|
||||
@@ -255,22 +288,31 @@ function _menu_editor_overview_tree_form_item($item_mlid, $default_values, $mult
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Weight textfield validation function
|
||||
* Stolen from http://drupal.org/project/tiny_menu_editor
|
||||
* Big thanks to Dmitriy.trt
|
||||
*
|
||||
* @param array $element
|
||||
* @param array $form_state
|
||||
*/
|
||||
function _menu_editor_valid_weight($element, &$form_state) {
|
||||
function _menu_editor_valid_weight(array $element, array &$form_state) {
|
||||
if ((isset($element['#value']) && $element['#value'] !== '') || !empty($element['#required'])) {
|
||||
if (!preg_match('/^\-?\d+$/', $element['#value'])) {
|
||||
form_error($element, t('Weight has to be an integer value.'));
|
||||
form_error($element, t('Weight has to be an integer value.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function menu_editor_overview_form_validate($form, &$form_state) {
|
||||
/**
|
||||
* Form validation callback for menu_editor_overview_form.
|
||||
*
|
||||
* @param array $form
|
||||
* @param array $form_state
|
||||
*
|
||||
* @see menu_editor_overview_form()
|
||||
*/
|
||||
function menu_editor_overview_form_validate(array $form, array &$form_state) {
|
||||
$form_values = &$form_state['values'];
|
||||
|
||||
// Check existing items.
|
||||
@@ -295,11 +337,14 @@ function menu_editor_overview_form_validate($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate form values for a menu link being added or edited.
|
||||
*
|
||||
* @param array $element
|
||||
* @param string $link_path
|
||||
* @param string $error_key_prefix
|
||||
*/
|
||||
function menu_editor_validate_item(&$element, $link_path, $error_key_prefix) {
|
||||
function menu_editor_validate_item(array &$element, $link_path, $error_key_prefix) {
|
||||
$placeholders = menu_editor_get_placeholders();
|
||||
if (isset($placeholders[$link_path])) {
|
||||
// it would be hard to check access,
|
||||
@@ -308,7 +353,7 @@ function menu_editor_validate_item(&$element, $link_path, $error_key_prefix) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($element['link_path']['#default_value'] == $link_path) {
|
||||
if ($element['link_path']['#default_value'] === $link_path) {
|
||||
// link_path is the only field that we check,
|
||||
// and we don't complain about existing link paths.
|
||||
return;
|
||||
@@ -334,27 +379,32 @@ function menu_editor_validate_item(&$element, $link_path, $error_key_prefix) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* validate a menu item that was dynamically added through javascript
|
||||
*
|
||||
* @param unknown_type $item
|
||||
* Validates a menu item that was dynamically added through javascript.
|
||||
*
|
||||
* @param array|mixed $item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function menu_editor_overview_form_validate_new_item($item) {
|
||||
// TODO: add some sanity checks
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Submit handler for the menu overview form.
|
||||
*
|
||||
* This function takes great care in saving parent items first, then items
|
||||
* underneath them. Saving items in the incorrect order can break the menu tree.
|
||||
*
|
||||
* @see menu_overview_form()
|
||||
* @param array $form
|
||||
* @param array $form_state
|
||||
*
|
||||
* @see menu_editor_overview_form()
|
||||
* @see menu_overview_form_submit()
|
||||
* @see menu_edit_item_submit()
|
||||
*/
|
||||
function menu_editor_overview_form_submit($form, &$form_state) {
|
||||
function menu_editor_overview_form_submit(array $form, array &$form_state) {
|
||||
|
||||
// When dealing with saving menu items, the order in which these items are
|
||||
// saved is critical. If a changed child item is saved before its parent,
|
||||
@@ -373,7 +423,9 @@ function menu_editor_overview_form_submit($form, &$form_state) {
|
||||
foreach ($form_values as $item_key => $v) {
|
||||
if (isset($form[$item_key]['#item'])) {
|
||||
$element = $form[$item_key];
|
||||
if (!is_numeric($v['mlid'])) {
|
||||
$original_item = $item = $element['#item'];
|
||||
|
||||
if (!isset($item['mlid'])) {
|
||||
// add new item
|
||||
unset($v['mlid']);
|
||||
if (!is_string($v['link_title']) || empty($v['link_title'])) {
|
||||
@@ -382,42 +434,51 @@ function menu_editor_overview_form_submit($form, &$form_state) {
|
||||
if (!is_string($v['link_path']) || empty($v['link_path'])) {
|
||||
continue;
|
||||
}
|
||||
$element['#item']['menu_name'] = $menu_name;
|
||||
$item['menu_name'] = $menu_name;
|
||||
// Set all fields in this menu item.
|
||||
foreach ($fields as $field) {
|
||||
// Check if field is set since some fields could not be NULL when
|
||||
// Check if field is set since some fields could not be NULL when
|
||||
// doing menu_link_save().
|
||||
if (isset($v[$field])) {
|
||||
$element['#item'][$field] = $v[$field];
|
||||
$item[$field] = $v[$field];
|
||||
}
|
||||
}
|
||||
$updated_items[$item_key] = $element['#item'];
|
||||
} else if (!empty($v['delete'])) {
|
||||
$updated_items[$item_key] = $item;
|
||||
}
|
||||
elseif (!empty($v['delete'])) {
|
||||
// delete existing item
|
||||
if (is_numeric($v['mlid'])) {
|
||||
menu_link_delete($v['mlid']);
|
||||
if (is_numeric($item['mlid'])) {
|
||||
menu_link_delete($item['mlid']);
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// update existing item
|
||||
// Update any fields that have changed in this menu item.
|
||||
foreach ($fields as $field) {
|
||||
// Using != instead of !== to support '5' == 5.
|
||||
/** @noinspection TypeUnsafeComparisonInspection */
|
||||
if ($v[$field] != $element[$field]['#default_value']) {
|
||||
$element['#item'][$field] = $v[$field];
|
||||
$updated_items[$item_key] = $element['#item'];
|
||||
$item[$field] = $v[$field];
|
||||
$updated_items[$item_key] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hidden is a special case, the value needs to be inverted.
|
||||
// Besides, while we operate with boolean, the database wants numeric 0/1.
|
||||
if ($v['hidden'] xor $element['hidden']['#default_value']) {
|
||||
$element['#item']['hidden'] = empty($v['hidden']) ? 1 : 0;
|
||||
if ($v['enabled'] xor $element['enabled']['#default_value']) {
|
||||
// Checkbox for 'enabled' was changed.
|
||||
$element['#item']['hidden'] = empty($v['enabled']) ? 1 : 0;
|
||||
$updated_items[$item_key] = $element['#item'];
|
||||
}
|
||||
else {
|
||||
// Checkbox for 'enabled' was not changed.
|
||||
}
|
||||
// langcode is a special case as well
|
||||
if (!empty($form['#multilingual_menu'])) {
|
||||
$langcode = isset($element['language']['#default_value']) ? $element['language']['#default_value'] : $element['language']['#value'];
|
||||
if ($v['language'] != $langcode) {
|
||||
if ($v['language'] !== $langcode) {
|
||||
$element['#item']['language'] = $v['language'];
|
||||
$updated_items[$item_key] = $element['#item'];
|
||||
}
|
||||
@@ -477,7 +538,7 @@ function menu_editor_overview_form_submit($form, &$form_state) {
|
||||
unset($item['options']['fragment']);
|
||||
}
|
||||
|
||||
if ($link_path != $parsed_link['path']) {
|
||||
if ($link_path !== $parsed_link['path']) {
|
||||
$link_path = $parsed_link['path'];
|
||||
}
|
||||
}
|
||||
@@ -497,6 +558,12 @@ function menu_editor_overview_form_submit($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
// @see menu_firstchild_menu_link_alter() expects $link['module'] to be set.
|
||||
$item += array(
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
);
|
||||
|
||||
$mlid = menu_link_save($item);
|
||||
|
||||
if (is_numeric($mlid)) {
|
||||
@@ -519,18 +586,18 @@ function menu_editor_overview_form_submit($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Theme the menu overview form into a table.
|
||||
*
|
||||
* @param array $variables
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_menu_editor_overview_form($variables) {
|
||||
function theme_menu_editor_overview_form(array $variables) {
|
||||
$form = $variables['form'];
|
||||
drupal_add_css(drupal_get_path('module', 'menu_editor') .'/menu_editor.css');
|
||||
drupal_add_css(drupal_get_path('module', 'menu_editor') . '/menu_editor.css');
|
||||
drupal_add_js(drupal_get_path('module', 'menu_editor') . '/menu_editor.js');
|
||||
global $language;
|
||||
$i18n_menu = $form['#multilingual_menu'] || $form['#translatable_nodes'];
|
||||
@@ -548,13 +615,13 @@ function theme_menu_editor_overview_form($variables) {
|
||||
if ($i18n_menu) {
|
||||
$header[] = t('Language');
|
||||
}
|
||||
$header[] = array('data' => t('Delete'), 'class' => 'delete-checkbox');
|
||||
$header[] = array('data' => t('Delete'), 'class' => 'delete-checkbox');
|
||||
|
||||
$rows = array();
|
||||
$items = array();
|
||||
|
||||
foreach (element_children($form) as $item_key) {
|
||||
if (isset($form[$item_key]['hidden'])) {
|
||||
if (isset($form[$item_key]['enabled'])) {
|
||||
$element = &$form[$item_key];
|
||||
|
||||
// Add special classes to be used for tabledrag.js.
|
||||
@@ -566,7 +633,7 @@ function theme_menu_editor_overview_form($variables) {
|
||||
$element['plid']['#type'] = 'hidden';
|
||||
|
||||
// Adjust tab index to allow vertical tabbing
|
||||
foreach (array('link_title', 'link_path', 'description', 'hidden', 'expanded') as $i => $key) {
|
||||
foreach (array('link_title', 'link_path', 'description', 'enabled', 'expanded') as $i => $key) {
|
||||
$element[$key]['#attributes']['tabindex'] = $i+2;
|
||||
}
|
||||
$element['link_path']['#attributes']['tabindex'] = 2;
|
||||
@@ -581,7 +648,7 @@ function theme_menu_editor_overview_form($variables) {
|
||||
$cells['link_title'] = array('data' => drupal_render($element['link_title']), 'class' => 'title-edit');
|
||||
$cells['link_path'] = array('data' => drupal_render($element['link_path']), 'class' => 'path-edit');
|
||||
$cells['description'] = array('data' => drupal_render($element['description']), 'class' => 'description');
|
||||
$cells['hidden'] = array('data' => drupal_render($element['hidden']), 'class' => 'checkbox');
|
||||
$cells['enabled'] = array('data' => drupal_render($element['enabled']), 'class' => 'checkbox');
|
||||
$cells['expanded'] = array('data' => drupal_render($element['expanded']), 'class' => 'checkbox');
|
||||
$cells['mlid'] = drupal_render($element['weight']) . drupal_render($element['plid']) . drupal_render($element['mlid']);
|
||||
if ($i18n_menu) {
|
||||
@@ -598,8 +665,8 @@ function theme_menu_editor_overview_form($variables) {
|
||||
$row['class'] = array('draggable');
|
||||
if ($i18n_menu) {
|
||||
$langcode = isset($element['language']['#default_value']) ? $element['language']['#default_value'] : $element['language']['#value'];
|
||||
$row['class'][] = ($langcode != LANGUAGE_NONE) ? 'langcode-'.$langcode : 'all-languages';
|
||||
$row['class'][]= ($langcode == $language->language) ? 'active-language' : '';
|
||||
$row['class'][] = ($langcode !== LANGUAGE_NONE) ? 'langcode-'.$langcode : 'all-languages';
|
||||
$row['class'][]= ($langcode === $language->language) ? 'active-language' : '';
|
||||
}
|
||||
$rows[$item_key] = $row;
|
||||
}
|
||||
@@ -611,4 +678,3 @@ function theme_menu_editor_overview_form($variables) {
|
||||
$output .= drupal_render_children($form);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
function hook_menu_editor_placeholders() {
|
||||
return array(
|
||||
'<new>' => 'mlid/@mlid/under-construction',
|
||||
);
|
||||
}
|
||||
@@ -53,4 +53,3 @@ form#menu-editor-overview-form .focus-description-column tr.focus td.description
|
||||
form#menu-editor-overview-form .focus-description-column tr.focus td.description textarea {
|
||||
height:60px !important;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@ package = Menu
|
||||
core = 7.x
|
||||
dependencies[] = menu
|
||||
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-10-01
|
||||
version = "7.x-1.0-beta3+0-dev"
|
||||
; Information added by Drupal.org packaging script on 2016-11-06
|
||||
version = "7.x-1.0-beta4"
|
||||
core = "7.x"
|
||||
project = "menu_editor"
|
||||
datestamp = "1380586819"
|
||||
datestamp = "1478399941"
|
||||
|
||||
|
||||
@@ -2,31 +2,31 @@
|
||||
Drupal.behaviors.menuEditor = {
|
||||
attach: function (context, settings) {
|
||||
$('#menu-editor-overview-form #menu-overview', context).each(function(){
|
||||
|
||||
|
||||
// table elements
|
||||
var table = $(this);
|
||||
var tbody = $('tbody', this);
|
||||
|
||||
|
||||
// delete all checkbox
|
||||
(function(){
|
||||
var th_delete = $('thead th.delete-checkbox', table);
|
||||
var master_delete_checkbox = $('<input type="checkbox" class="master-delete-checkbox" />');
|
||||
th_delete.html('<span> '+th_delete.html()+'</span>');
|
||||
th_delete.prepend(master_delete_checkbox);
|
||||
|
||||
|
||||
var onchange = function(){
|
||||
var checked_now = master_delete_checkbox.attr('checked');
|
||||
$('tbody td.delete-checkbox :checkbox', table).attr('checked', checked_now);
|
||||
};
|
||||
|
||||
|
||||
master_delete_checkbox.change(onchange);
|
||||
|
||||
|
||||
// IE does not trigger the change event..
|
||||
if ($.browser.msie) {
|
||||
master_delete_checkbox.click(onchange);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
// freeze width of first column (currently disabled)
|
||||
if (false) {
|
||||
var w = $('td.drag', this).width();
|
||||
@@ -34,7 +34,7 @@
|
||||
$(this).css('width', w+'px');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// get reference css for textareas
|
||||
var ref_input = $('td.path-edit input', this);
|
||||
var h = ref_input.height();
|
||||
@@ -44,12 +44,12 @@
|
||||
'padding-bottom': ref_input.css('padding-bottom')
|
||||
};
|
||||
var div_ref_height = ref_input.parent().height();
|
||||
|
||||
|
||||
// adjust height of existing description textareas
|
||||
$('td.description textarea', this).css(ref_css);
|
||||
// this is necessary because of the vertical-align:middle
|
||||
$('td.description div.form-item', this).css('height', div_ref_height+'px');
|
||||
|
||||
|
||||
// description column resizing
|
||||
$('td.description textarea', this).focus(function(){
|
||||
table.addClass('focus-description-column');
|
||||
|
||||
@@ -33,6 +33,11 @@ function menu_editor_permission() {
|
||||
return $perm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $menu
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function menu_editor_form_access($menu) {
|
||||
return
|
||||
user_access('administer menu') ||
|
||||
@@ -55,7 +60,9 @@ function menu_editor_form_access($menu) {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Implemenation of hook_theme().
|
||||
* Implements hook_theme().
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
function menu_editor_theme() {
|
||||
return array(
|
||||
@@ -68,21 +75,33 @@ function menu_editor_theme() {
|
||||
|
||||
/**
|
||||
* Title callback for the menu overview page and links.
|
||||
*
|
||||
* @param array $menu
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function menu_editor_overview_title($menu) {
|
||||
function menu_editor_overview_title(array $menu) {
|
||||
return $menu['title'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
function menu_editor_get_placeholders() {
|
||||
static $placeholders;
|
||||
if (!isset($placeholders)) {
|
||||
/* @see hook_menu_editor_placeholders() */
|
||||
$placeholders = module_invoke_all('menu_editor_placeholders');
|
||||
}
|
||||
return $placeholders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $placeholder
|
||||
* @param string|int $mlid
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function menu_editor_get_path_for_placeholder($placeholder, $mlid) {
|
||||
$placeholders = menu_editor_get_placeholders();
|
||||
if (isset($placeholders[$placeholder])) {
|
||||
|
||||
Reference in New Issue
Block a user