initial commit of starter install drupal 7
This commit is contained in:
@@ -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,54 @@
|
||||
Content menu module rewires Drupal's default menu management interface for tighter intergation of content authoring and menu management.
|
||||
|
||||
The goal is to make building a site's structure and content in one fluid process seamless, easy and natural. Editors can create content along with a menu item without ever really leaving the menu management process. Editors can find, associate and edit content right from the menu management interface.
|
||||
|
||||
Content Menu module makes building a structure-oriented website "page by page" with Drupal effortless and intuitive.
|
||||
|
||||
To get an impression of how easy content centric menu management is with the content menu module, watch our screencast: http://youtu.be/sYoYtoQ1s8c
|
||||
|
||||
|
||||
HOW IT WORKS
|
||||
|
||||
|
||||
Basically, Content Menu evolves Drupal's simplistic and isolated menu management interface into an editor's intuitive central for site authoring.
|
||||
|
||||
The most important new possibilties are to directly asses and edit a menu item's linked content and to directly create and position a new menu item with selectable target (content) type.
|
||||
|
||||
You can create a new menu item as …
|
||||
|
||||
URL – With the traditional menu item form
|
||||
Dummy – As a dummy menu item (with simple dummy link target)
|
||||
New NODETYPE – directly create a new content for the new item
|
||||
Existing content – selecting an existing content via a nice filterable view (if views is enabled)
|
||||
Menu position rule (if the Menu Position module is enabled)
|
||||
IMPROVED WORKFLOWS
|
||||
|
||||
The workflows are kept concise and seamless, e.g for adding new menu items along with brand new content or with comfortably choosing existing content to link to.
|
||||
|
||||
|
||||
|
||||
HOW TO INSTALL
|
||||
|
||||
|
||||
To install Content Menu module, …
|
||||
|
||||
* Download and enable the module from http://drupal.org/project/content_menu
|
||||
* Download additional modules
|
||||
CTools and Views modules are strongly recommended (though technically not required)
|
||||
Menu Position module is supported (and great for rule based appearance of content in menus)
|
||||
* Configure your permissions and content types:
|
||||
Make sure at least one content type is configured in Drupal's standard node type configuration form to be enabled to receive menu entries of the menu(s) where the content should be placed, to make at least one node type show up in the "target type" dropdown.
|
||||
Make sure the user you try the module with has sufficient permission (to access admin area, to administer menus, to administer content, to create and delete nodes of the respective type, …). The new "administer system menus" is necessary for users that should see _all_ menus on the menu overview admin page (Users without this permission are not shown the content_menu_special_menus (variable details see below)).
|
||||
* Go to Admin > Structure > Menus and start adding menu items into e.g the "Main Menu".
|
||||
* Or watch out Screencast (see above) to get ideas of what to do (and how).
|
||||
* See the content_menu.api.php file for further development information on new permission(s), system variables you can override, or hooks you might want to use as a developer to extend content_menu.module
|
||||
|
||||
|
||||
RESSOURCES
|
||||
|
||||
* Screencast: http://youtu.be/sYoYtoQ1s8c
|
||||
* Blog Post with background-info and discussion: http://wunderkraut.com/en/blog/content-menu-module-%E2%80%93-menu-author...
|
||||
* content_menu.api.php file for further development information.
|
||||
|
||||
|
||||
Content Menu is sponsored by http://www.wunderkraut.com
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* PERMISSIONS introduced by this module:
|
||||
*
|
||||
* administer system menus
|
||||
* Allows a user to show/list _all_ menus on the menu overview admin page.
|
||||
* Users without this permission are not shown the content_menu_special_menus
|
||||
* (variable details see below).
|
||||
*
|
||||
*
|
||||
*
|
||||
* SYSTEM VARIABLES of this module that can be changed:
|
||||
* (There's currently no config interface to set them, but you can do that
|
||||
* manually or programmatically)
|
||||
*
|
||||
* content_menu_add_existing_content_url
|
||||
* URL of the "select existing content" page to use when creating a new menu
|
||||
* item that is linking to "existing content".
|
||||
*
|
||||
* content_menu_add_existing_content_view
|
||||
* VIEWNAME[:DISPLAYNAME] of the view (if any) that should be used
|
||||
* when creating a new menu item that is linking to "existing content".
|
||||
* An "nid" field of this field based view[/display] is changed to be used as
|
||||
* "select" link to select existing content for the new menu item to link to.
|
||||
*
|
||||
* content_menu_special_menus
|
||||
* Array of menu machine names that are considered special/system menus, and
|
||||
* are hence not altered by content_menu, and not shown to users without the
|
||||
* new 'administer system menus' permission.
|
||||
* Default: array('management', 'user-menu', 'navigation', 'devel'));
|
||||
*
|
||||
* content_menu_alter_all_menus
|
||||
* Boolean flag to state whether all menus should be altered to have to
|
||||
* improved interface, including those listed in the variable
|
||||
* content_menu_special_menus.
|
||||
* Default: FALSE (to let system menus be untouched, 'just in case').
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Extend the target types for a new menu item.
|
||||
*
|
||||
* @param $target_types Array
|
||||
* Array of menu item target types that you can extend.
|
||||
* The key is a machine name of a target type (alphanumerical char, _)
|
||||
* The value is an array containing the following entries:
|
||||
* - label => translated label to display in the interface
|
||||
* - handler => full name of a handler function to use, with the signature
|
||||
* ...(&$form, &$form_state, &$item [, $arg_1, ..., $arg_n])
|
||||
* - arguments => array of arg_name=>arg_value (optional),
|
||||
* each argument is passed to handler callback function.
|
||||
* - clean_menu_save_message => flag whether the existing message
|
||||
* "Your configuration has been saved"
|
||||
* should be removed (TRUE) or not (FALSE).
|
||||
*
|
||||
* @param $context Array
|
||||
* Array with context information. Currently the following key is used:
|
||||
* 'menu_name' => machine name of the menu the target types are assembled.
|
||||
*
|
||||
*/
|
||||
function hook_menu_item_target_types_alter(&$target_types, &$context) {
|
||||
$target_types['url'] = array(
|
||||
'label' => t('URL'),
|
||||
'handler' => 'content_menu_menu_form_handler_url',
|
||||
'clean_menu_save_message' => TRUE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alter a menu item's form element in the menu item administration.
|
||||
*
|
||||
* @param $el Array The form element of the menu item to alter.
|
||||
*/
|
||||
function _content_menu_menu_item_element_alter(&$el) {
|
||||
module_load_include('inc', 'content_menu', 'content_menu.menu_admin');
|
||||
_content_menu_menu_item_element_alter($el);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
name = "Content Menu"
|
||||
dependencies[] = "menu"
|
||||
description = "Content centric menu management interface for editors."
|
||||
package = User interface
|
||||
core = "7.x"
|
||||
php = "5.2.4"
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-08-01
|
||||
version = "7.x-1.0+7-dev"
|
||||
core = "7.x"
|
||||
project = "content_menu"
|
||||
datestamp = "1406871528"
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation hooks for Content Menu module
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function content_menu_install() {
|
||||
// Set weight to come after core menu.module.
|
||||
// Make sure this module's hooks' weight is set to be executed after the core.
|
||||
// Menu.module's hooks, so the node add/edit form is already altered by the.
|
||||
// Menu.module befor content_menu does its form alterations.
|
||||
$weight = db_select('system', 's')
|
||||
->fields('s', array('weight'))
|
||||
->condition('name', 'menu', '=')
|
||||
->execute()
|
||||
->fetchField();
|
||||
db_update('system')
|
||||
->fields(array('weight' => $weight + 1))
|
||||
->condition('name', 'content_menu', '=')
|
||||
->execute();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
(function($){
|
||||
Drupal.behaviors.content_menu ={
|
||||
attach:function(context, settings){
|
||||
// Show menu item title input field when clicking on the trigger.
|
||||
$('.menu-overview-title-edit-trigger', context).click(function(e) {
|
||||
$(this).siblings('.form-type-textfield').show().children('input').focus();
|
||||
$(this).siblings('.menu-overview-title-link').hide();
|
||||
$(this).hide();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
});
|
||||
}
|
||||
};})(jQuery);
|
||||
@@ -0,0 +1,770 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Menu Management Workflow improvements.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback for altered admin/structure/menu router item.
|
||||
*
|
||||
* Only show custom menus to regular sitebuilders/editors (no system menus).
|
||||
*/
|
||||
function _content_menu_menu_overview_page_extended() {
|
||||
$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' => '1'));
|
||||
$rows = array();
|
||||
foreach ($result as $menu) {
|
||||
if (content_menu_is_menu_considered($menu['menu_name']) || user_access('administer system menus')) {
|
||||
$url = 'admin/structure/menu/manage/' . $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('Edit'), $url));
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return theme('table', array('header' => $header, 'rows' => $rows));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Actual implementation for content_menu_form_menu_overview_form_alter().
|
||||
*
|
||||
* Overhaul the menu_overview_form to improve menu authoring experience.
|
||||
*/
|
||||
function _content_menu_form_menu_overview_form_alter(&$form, &$form_state, $form_id) {
|
||||
$form['#theme'][0] = 'menu_overview_form_extended';
|
||||
|
||||
// Check whether any filtering element should be acitvated.
|
||||
$filtering_active = TRUE;
|
||||
// Filtering depends on ctools module.
|
||||
// @todo Remove ctools dependency as ajax is actually not used.
|
||||
$filtering_active = $filtering_active && module_exists('ctools');
|
||||
|
||||
if ($filtering_active) {
|
||||
// Add form elements for filters.
|
||||
// @todo Add configuration interface for filters.
|
||||
require_once 'filters/content_menu_domain_filter.php';
|
||||
require_once 'filters/content_menu_language_filter.php';
|
||||
$filters = array(new content_menu_domain_filter(), new content_menu_language_filter($form['#menu']['menu_name']));
|
||||
// Add filter widgets to form.
|
||||
foreach ($filters as $f) {
|
||||
$f->addFilterWidget($form, $form_state, $form_id);
|
||||
}
|
||||
}
|
||||
|
||||
// ToDo: Clean up and untangle operations-changing and target_content setting.
|
||||
$hidden = array();
|
||||
// Adjust operations for each item.
|
||||
foreach (element_children($form) as $mlid) {
|
||||
$el = &$form[$mlid];
|
||||
if ($filtering_active) {
|
||||
foreach ($filters as $f) {
|
||||
if ($f->hideElement($el)) {
|
||||
unset($form[$mlid]);
|
||||
$hidden[$el['#item']['mlid']] = $el['#item']['mlid'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($el['#item']['plid']) &&
|
||||
isset($hidden[$el['#item']['plid']])) {
|
||||
// Check if a parent has been disabled before.
|
||||
// If so, the childern will be hidden too.
|
||||
unset($form[$mlid]);
|
||||
$hidden[$el['#item']['mlid']] = $el['#item']['mlid'];
|
||||
continue;
|
||||
}
|
||||
|
||||
$el['#inline_edit_title'] = TRUE;
|
||||
if (isset($form[$mlid]['operations'])) {
|
||||
// Invoke hook to let modules provide target operations for new item.
|
||||
drupal_alter('menu_item_element', $el);
|
||||
|
||||
// Make sure that operations are ordered by their weight, then unset it.
|
||||
uasort($el['operations'], 'drupal_sort_weight');
|
||||
foreach ($el['operations'] as $el_op_key => $el_op) {
|
||||
unset($el['operations'][$el_op_key]['weight']);
|
||||
}
|
||||
|
||||
// Wrap link-type operations into CTools dropbutton, if available.
|
||||
if (module_exists('ctools') && isset($el['operations'])) {
|
||||
// Split up operation in dropbutton-ops and other ops.
|
||||
$other_operations = array();
|
||||
$dropbutton_operations = array();
|
||||
foreach ($form[$mlid]['operations'] as $op_key => $op_item) {
|
||||
if (is_array($op_item) && isset($op_item['#type'])) {
|
||||
if ($op_item['#type'] == 'link') {
|
||||
$dropbutton_operations[$op_key] = array(
|
||||
'title' => $op_item['#title'],
|
||||
'href' => $op_item['#href'],
|
||||
);
|
||||
if (isset($op_item['#options'])) {
|
||||
$dropbutton_operations[$op_key] += $op_item['#options'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$other_operations[$op_key] = $op_item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compose operation from dropbutton and other ops.
|
||||
$el['operations'] = array();
|
||||
$el['operations']['dropbutton_operations'] = array(
|
||||
'#theme' => 'links__ctools_dropbutton',
|
||||
'#links' => $dropbutton_operations,
|
||||
);
|
||||
$el['operations'] += $other_operations;
|
||||
}
|
||||
|
||||
// Count operations of this item.
|
||||
$el['#operations_count'] = count($form[$mlid]['operations']);
|
||||
}
|
||||
|
||||
// Add inline-editing for menu item title.
|
||||
if ($el['#inline_edit_title'] && isset($el['title'])) {
|
||||
// ToDo: Check title inplace-edit for multilanguage compatibility issues.
|
||||
$title = $el['#item']['title'];
|
||||
$el['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $title,
|
||||
'#size' => 30,
|
||||
'#maxlength' => 255,
|
||||
'#prefix' => '<span class="menu-overview-title-link">' . $el['title']['#markup'] . '</span>',
|
||||
'#suffix' => '<a href="javascript:void();" title="Click to edit title" class="menu-overview-title-edit-trigger">' . t('edit title') . '</a>',
|
||||
);
|
||||
$form['#attached']['js'] = array(drupal_get_path('module', 'content_menu') . '/content_menu.js');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add "add item" item/row/elements.
|
||||
content_menu_form_menu_overview_form_alter_additem($form);
|
||||
|
||||
// Add css as via drupal_add_css and put it after ctools button css files.
|
||||
drupal_add_css(drupal_get_path('module', 'content_menu') . "/css/content_menu.css", array('weight' => 2));
|
||||
|
||||
// Change submit handler function to our own implementation.
|
||||
$form['#submit'] = array('content_menu_menu_overview_form_submit_extended');
|
||||
// Prevent 'destination' from hijacking our submit.
|
||||
unset($_GET['destination']);
|
||||
|
||||
if (!isset($form['actions'])) {
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
);
|
||||
}
|
||||
$form['actions']['submit']['#value'] = t('Save');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu item element alterations provided by default by this module.
|
||||
*
|
||||
* This helper function is called by this module's hook_menu_item_element_alter
|
||||
* implementation content_menu_menu_item_element_alter().
|
||||
*
|
||||
* @param $el Array The form element of the menu item to alter.
|
||||
*/
|
||||
function _content_menu_menu_item_element_alter(&$el) {
|
||||
$el_item = &$el['#item'];
|
||||
$el_ops = &$el['operations'];
|
||||
$target_content = '';
|
||||
|
||||
$link_path = ($el_item['link_path'] == '<front>') ? variable_get('site_frontpage', 'node') : $el_item['link_path'];
|
||||
$link_path = (array) explode('/', $link_path);
|
||||
$link_path = array_pad($link_path, 2, '');
|
||||
|
||||
// Change "edit" operation.
|
||||
if (isset($el_ops['edit']) && ($el_ops['edit']['#type'] == 'link')) {
|
||||
|
||||
$el_ops['edit']['weight'] = 1;
|
||||
|
||||
// Add "select content" operation.
|
||||
$selectcontenturl = content_menu_variable_get_add_existing_content_url();
|
||||
if ($selectcontenturl) {
|
||||
$el_ops['selectcontent'] = array(
|
||||
'#type' => 'link',
|
||||
'weight' => 2,
|
||||
'#title' => t('select content'),
|
||||
'#href' => $selectcontenturl,
|
||||
'#options' => array(
|
||||
'query' => content_menu_assemble_query_string($el_item),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Add "new <node-type>" operation to Dummies.
|
||||
if ($link_path[0] == 'menu-dummy') {
|
||||
$node_type_count = 0;
|
||||
foreach (node_type_get_types() as $node_type) {
|
||||
$type = $node_type->type;
|
||||
if (user_access('create ' . $type . ' content')) {
|
||||
$node_menu_options = variable_get('menu_options_' . $type, array('main-menu' => 'main-menu'));
|
||||
if (in_array($el_item['menu_name'], $node_menu_options)) {
|
||||
$el_ops['new_' . $type] = array(
|
||||
'#type' => 'link',
|
||||
'weight' => 10 + $node_type_count,
|
||||
'#title' => t('New @type', array('@type' => t($node_type->name))),
|
||||
'#href' => 'node/add/' . str_replace("_", "-", $type),
|
||||
'#options' => array(
|
||||
'query' => content_menu_assemble_query_string($el_item),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add "configure" operation by cloning "edit" operation.
|
||||
$el_ops['configure'] = $el_ops['edit'];
|
||||
$el_ops['configure']['#title'] = t('configure item');
|
||||
$el_ops['configure']['weight'] = 3;
|
||||
|
||||
// Change "edit" operation to ...
|
||||
// ... do nothing for menu item dummies.
|
||||
if ($link_path[0] == 'menu-dummy') {
|
||||
$target_content = t('Placeholder');
|
||||
}
|
||||
// ... lead to node edit form for node-url-items.
|
||||
elseif (($link_path[0] == 'node') && (is_numeric($link_path[1]))) {
|
||||
$node = node_load($link_path[1]);
|
||||
if (is_object($node)) {
|
||||
if (node_access('update', $node)) {
|
||||
$el_ops['edit']['#href'] = 'node/' . $link_path[1] . '/edit';
|
||||
}
|
||||
$node_type = node_type_get_type($node);
|
||||
$target_content = t($node_type->name);
|
||||
// Mark unpublished nodes.
|
||||
if (!$node->status) {
|
||||
$target_content = '<span class="menu-item-content-target-unpublished">' . $target_content . '</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// ... lead to panel page edit form for panel paged.
|
||||
elseif (($el_item['page_callback'] == 'page_manager_page_execute')) {
|
||||
if (user_access('use page manager')) {
|
||||
$page_arguments = unserialize($el_item['page_arguments']);
|
||||
$el_ops['edit']['#href'] = 'admin/structure/pages/edit/page-' . implode('/', $page_arguments);
|
||||
}
|
||||
$target_content = t('Panel');
|
||||
}
|
||||
// ... lead to view edit form for views.
|
||||
elseif ($el_item['page_callback'] == 'views_page') {
|
||||
if (user_access('administer views')) {
|
||||
$page_arguments = unserialize($el_item['page_arguments']);
|
||||
$el_ops['edit']['#href'] = 'admin/structure/views/view/' . $page_arguments[0] . '/edit/' . $page_arguments[1];
|
||||
}
|
||||
$el_ops['selectcontent']['#href'] = CONTENT_MENU_ADD_EXISTING_VIEW_URL;
|
||||
$el_ops['selectcontent']['#title'] = t('select view');
|
||||
$target_content = t('View');
|
||||
}
|
||||
// ... menu position rule.
|
||||
elseif ($link_path[0] == 'menu-position') {
|
||||
if (!user_access('administer menu positions')) {
|
||||
$el_ops['configure'] = $el_ops['edit'] = array();
|
||||
}
|
||||
$target_content = t('Menu rule');
|
||||
$el['#inline_edit_title'] = FALSE;
|
||||
}
|
||||
else {
|
||||
// If no other content or target is identifier, assume generic URL.
|
||||
if (url_is_external($el_item['link_path'])) {
|
||||
// External.
|
||||
$target_content = t('URL');
|
||||
}
|
||||
else {
|
||||
// Internal.
|
||||
$target_content = t('Path');
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the "edit" operation altogether if its url didn't change.
|
||||
if (isset($el_ops['edit']['#href'])) {
|
||||
if ($el_ops['edit']['#href'] == $el_ops['configure']['#href']) {
|
||||
$el_ops['edit'] = array();
|
||||
$el_ops['selectcontent']['weight'] = 4;
|
||||
}
|
||||
else {
|
||||
$el_ops['edit']['#title'] = t('edit content');
|
||||
$el_ops['edit']['#options']['query']['destination'] = current_path();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$el_ops['edit'] = array();
|
||||
}
|
||||
|
||||
// Add "delete" operation for menu_position items.
|
||||
if (!isset($el_ops['delete']) && ($link_path[0] == 'menu-position') && (is_numeric($link_path[1]) && user_access('administer menu positions'))) {
|
||||
$el_ops['delete'] = array(
|
||||
'#type' => 'link',
|
||||
'#title' => t('delete'),
|
||||
'#href' => 'admin/structure/menu-position/delete/' . intval($link_path[1]),
|
||||
'#options' => array('query' => array('destination' => current_path())),
|
||||
);
|
||||
}
|
||||
|
||||
// Push "delete" operation to end of ops list.
|
||||
if (isset($el_ops['delete'])) {
|
||||
$el_ops['delete']['#title'] = t('delete item');
|
||||
$el_ops['delete']['weight'] = 100;
|
||||
}
|
||||
|
||||
$el['target_content'] = array('#type' => 'markup', '#markup' => $target_content);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add item/row/elements to menu overview form for "add item" functionality.
|
||||
*/
|
||||
function content_menu_form_menu_overview_form_alter_additem(&$form) {
|
||||
// Assemble and add the "Add link" item.
|
||||
$form['additem'] = array(
|
||||
'#attributes' => array(
|
||||
'class' => array('menu-additem'),
|
||||
),
|
||||
'hidden' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable the new menu link'),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => TRUE,
|
||||
),
|
||||
'weight' => array(
|
||||
'#type' => 'weight',
|
||||
// '#delta' has to be in sync with:
|
||||
// a) CONTENT_MENU_ADD_ITEM_WEIGHT.
|
||||
// b) Delta set in menu_form_node_form_alter().
|
||||
'#delta' => 50,
|
||||
// Real weight is set in content_menu_menu_overview_form_submit_extended.
|
||||
'#default_value' => CONTENT_MENU_ADD_ITEM_WEIGHT,
|
||||
'#title_display' => 'invisible',
|
||||
'#title' => 'Weight',
|
||||
),
|
||||
'mlid' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => '0',
|
||||
),
|
||||
'plid' => array(
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => '0',
|
||||
),
|
||||
'operations' => array(),
|
||||
'#operations_count' => 0,
|
||||
'title' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('New menu item'),
|
||||
'#default_value' => '',
|
||||
'#size' => 30,
|
||||
'#maxlength' => 255,
|
||||
'#required' => FALSE,
|
||||
),
|
||||
);
|
||||
|
||||
$target_types = content_menu_get_target_types($form['#menu']['menu_name']);
|
||||
|
||||
// Retrieve possible add-"type"-operations for "Add link" item.
|
||||
foreach ($target_types as $op_key => $op_info) {
|
||||
$target_types[$op_key] = $op_info['label'];
|
||||
}
|
||||
|
||||
// Build "type" select for "Add link" item.
|
||||
$form['additem']['target_content'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => ' ',
|
||||
'#options' => $target_types,
|
||||
'#default_value' => variable_get('content_menu_default_add_operation', 'url'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns HTML for the menu overview form into a table.
|
||||
*
|
||||
* Code taken mainly from original theme_menu_overview_form().
|
||||
*
|
||||
* @param $variables
|
||||
* An associative array containing:
|
||||
* - form: A render element representing the form.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_menu_overview_form_extended($variables) {
|
||||
$form = $variables['form'];
|
||||
|
||||
drupal_add_tabledrag('menu-overview', 'match', 'parent', 'menu-plid', 'menu-plid', 'menu-mlid', TRUE, MENU_MAX_DEPTH - 1);
|
||||
drupal_add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight');
|
||||
|
||||
// Count max number of operations per item.
|
||||
$operations_count_max = 1;
|
||||
foreach (element_children($form) as $mlid) {
|
||||
if (isset($form[$mlid]['#operations_count'])) {
|
||||
$operations_count_max = max($operations_count_max, $form[$mlid]['#operations_count']);
|
||||
}
|
||||
}
|
||||
|
||||
$header = array(
|
||||
t('Menu link'),
|
||||
array('data' => t('Enabled'), 'class' => array('checkbox')),
|
||||
t('Weight'),
|
||||
t('Target'),
|
||||
array('data' => t('Operations'), 'colspan' => $operations_count_max),
|
||||
);
|
||||
|
||||
// Build item tables.
|
||||
$rows = array();
|
||||
foreach (element_children($form) as $mlid) {
|
||||
if (isset($form[$mlid]['hidden'])) {
|
||||
$element = &$form[$mlid];
|
||||
// Build a list of operations.
|
||||
$operations = array();
|
||||
foreach (element_children($element['operations']) as $op) {
|
||||
$operations[] = array('data' => drupal_render($element['operations'][$op]), 'class' => array('menu-operations'));
|
||||
}
|
||||
while (count($operations) < $operations_count_max) {
|
||||
$operations[] = '';
|
||||
}
|
||||
|
||||
// Add special classes to be used for tabledrag.js.
|
||||
$element['plid']['#attributes']['class'] = array('menu-plid');
|
||||
$element['mlid']['#attributes']['class'] = array('menu-mlid');
|
||||
$element['weight']['#attributes']['class'] = array('menu-weight');
|
||||
|
||||
// Change the parent field to a hidden.
|
||||
// This allows any value but hides the field.
|
||||
$element['plid']['#type'] = 'hidden';
|
||||
$depth = isset($element['#item']) ? $element['#item']['depth'] : 1;
|
||||
|
||||
$row = array();
|
||||
$row[] = theme('indentation', array('size' => $depth - 1)) . drupal_render($element['title']);
|
||||
$row[] = array('data' => drupal_render($element['hidden']), 'class' => array('checkbox', 'menu-enabled'));
|
||||
$row[] = drupal_render($element['weight']) . drupal_render($element['plid']) . drupal_render($element['mlid']);
|
||||
$row[] = array('data' => drupal_render($element['target_content']), 'class' => array('menu-target-content'));
|
||||
$row = array_merge($row, $operations);
|
||||
|
||||
$row = array_merge(array('data' => $row), $element['#attributes']);
|
||||
$row['class'][] = 'draggable';
|
||||
// Highlight row if menu item has been created within the last minute.
|
||||
if (isset($element['#item']['mlid']) && isset($_SESSION['content_menu_inserted_links'][$element['#item']['mlid']])) {
|
||||
if ((time() - $_SESSION['content_menu_inserted_links'][$element['#item']['mlid']]['created']) <= 60) {
|
||||
$row['class'][] = 'ok';
|
||||
}
|
||||
unset($_SESSION['content_menu_inserted_links'][$element['#item']['mlid']]);
|
||||
}
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
$output = '';
|
||||
if (empty($rows)) {
|
||||
$rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '7'));
|
||||
}
|
||||
// Render selection filter widgets on top.
|
||||
if (isset($form['#content_menu_filter_widget'])) {
|
||||
foreach ($form['#content_menu_filter_widget'] as $widgetname) {
|
||||
$output .= drupal_render($form[$widgetname]);
|
||||
}
|
||||
}
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'menu-overview')));
|
||||
$output .= drupal_render_children($form);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Submit handler for menu_overview_form extended with item adding handling.
|
||||
*/
|
||||
function content_menu_menu_overview_form_submit_extended($form, &$form_state) {
|
||||
// Edit item handling.
|
||||
$max_weight = 0;
|
||||
// Step though items.
|
||||
foreach (element_children($form) as $mlid) {
|
||||
$el = &$form[$mlid];
|
||||
// Keep track of maximum weight.
|
||||
if (isset($el['#item']['weight']) && ($el['#item']['weight'] > $max_weight)) {
|
||||
$max_weight = $el['#item']['weight'];
|
||||
}
|
||||
// If title changed, ...
|
||||
if (isset($el['#item']) && isset($el['title']['#value'])) {
|
||||
if ($el['title']['#value'] != $el['title']['#default_value']) {
|
||||
// Inject item title.
|
||||
$title = $form_state['input'][$mlid]['title'];
|
||||
$el['#item']['title'] = $el['#item']['link_title'] = $title;
|
||||
// Change default value of weight field to trigger
|
||||
// menu_overview_form_submit() marking the item as updated.
|
||||
$el['weight']['#default_value'] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do standard menu.module's item processing.
|
||||
menu_overview_form_submit($form, $form_state);
|
||||
|
||||
// Add item handling.
|
||||
$item = $form_state['input']['additem'];
|
||||
|
||||
// If title has been entered for new menu item, prepare add operation.
|
||||
if (trim($item['title'] != '')) {
|
||||
// Complete data for new menu item.
|
||||
$item['link_title'] = $item['title'];
|
||||
$item['name'] = $form['#menu']['menu_name'];
|
||||
$item['hidden'] = $item['hidden'] ? 0 : 1;
|
||||
$item['customized'] = 1;
|
||||
if ($item['weight'] == CONTENT_MENU_ADD_ITEM_WEIGHT) {
|
||||
$item['weight'] = $max_weight + 1;
|
||||
}
|
||||
|
||||
// Determine operation details.
|
||||
$operations = content_menu_get_target_types($item['name']);
|
||||
$op = $operations[$item['target_content']];
|
||||
|
||||
// Prepare arguments for handler callback function.
|
||||
$args = array('form' => $form, 'form_state' => $form_state, 'item' => $item);
|
||||
if (isset($op['arguments']) && is_array($op['arguments'])) {
|
||||
$args += $op['arguments'];
|
||||
}
|
||||
|
||||
// Call handler callback function.
|
||||
if (function_exists($op['handler'])) {
|
||||
// Get rid of the 'Your configuration has been saved.' message.
|
||||
if ($op['clean_menu_save_message']) {
|
||||
foreach ($_SESSION['messages']['status'] as $msg_key => $msg_text) {
|
||||
if ($_SESSION['messages']['status'][$msg_key] == t('Your configuration has been saved.')) {
|
||||
unset($_SESSION['messages']['status'][$msg_key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = call_user_func_array($op['handler'], $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu add item operation handler for a new dummy menu item.
|
||||
*/
|
||||
function content_menu_menu_form_handler_dummy($form, $form_state, $item) {
|
||||
drupal_set_message(t('A new menu item has been created.'));
|
||||
$item['link_path'] = 'menu-dummy';
|
||||
content_menu_link_save($item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu add item operation handler for a new node menu item.
|
||||
*/
|
||||
function content_menu_menu_form_handler_node($form, $form_state, $item, $type) {
|
||||
$types = node_type_get_types();
|
||||
drupal_set_message(t("You're about to create a new menu item with new %type content.", array('%type' => $types[$type]->name)));
|
||||
drupal_set_message(t('Complete the process by filling out and saving the form below.'));
|
||||
$type = str_replace("_", "-", $type);
|
||||
drupal_goto('node/add/' . $type, array('query' => content_menu_assemble_query_string($item)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu add item operation handler for a new generic menu item.
|
||||
*/
|
||||
function content_menu_menu_form_handler_url($form, $form_state, $item) {
|
||||
drupal_set_message(t("You're about to create a new generic menu item linking to a URL path."));
|
||||
drupal_set_message(t('Complete the process by filling out and saving the form below.'));
|
||||
drupal_goto('admin/structure/menu/manage/' . $item['name'] . '/add', array('query' => content_menu_assemble_query_string($item)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu add item operation handler for a new generic menu item.
|
||||
*/
|
||||
function content_menu_menu_form_handler_menu_position_rule($form, $form_state, $item) {
|
||||
drupal_set_message(t("You're about to create a new generic menu position rule."));
|
||||
drupal_set_message(t('Complete the process by filling out and saving the form below.'));
|
||||
drupal_goto('admin/structure/menu-position/add', array('query' => content_menu_assemble_query_string($item)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu add item operation handler for a new menu item to existing content.
|
||||
*/
|
||||
function content_menu_menu_form_handler_menu_position_existing($form, $form_state, $item) {
|
||||
$url = content_menu_variable_get_add_existing_content_url();
|
||||
// If using default view, ensure to only goto view page if views is enabled.
|
||||
if (empty($url)) {
|
||||
content_menu_menu_form_handler_url($form, $form_state, $item);
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t("You're about to create a new menu item for an existing content."));
|
||||
drupal_set_message(t('Complete the process by finding and selecting an existing content to add to the menu.'));
|
||||
drupal_goto($url, array('query' => content_menu_assemble_query_string($item)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu add item operation handler for a new menu item to an existing view.
|
||||
*/
|
||||
function content_menu_menu_form_handler_existing_view($form, $form_state, $item) {
|
||||
drupal_set_message(t("You're about to create a new menu item for an existing view."));
|
||||
drupal_set_message(t('Complete the process by finding and selecting the view to add to the menu.'));
|
||||
drupal_goto(CONTENT_MENU_ADD_EXISTING_VIEW_URL, array('query' => content_menu_assemble_query_string($item)));
|
||||
}
|
||||
|
||||
/**
|
||||
* List all views with a page display.
|
||||
*/
|
||||
function content_menu_add_exiting_view($form, $form_state) {
|
||||
if (!module_exists('views')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$form = array();
|
||||
|
||||
$item = content_menu_get_menu_item_from_querystring();
|
||||
$form['#menu_item'] = $item;
|
||||
|
||||
$all_views = views_get_all_views();
|
||||
foreach ($all_views as $view) {
|
||||
foreach ($view->display as $display) {
|
||||
if ($display->display_plugin == 'page') {
|
||||
if ((!property_exists($view, 'disabled') || (property_exists($view, 'disabled') && !$view->disabled))) {
|
||||
$view_path = $display->display_options['path'];
|
||||
$view_title = check_plain($view->name . ' - ' . $display->display_title . ' (' . $display->display_options['path'] . ')');
|
||||
if (drupal_valid_path($view_path)) {
|
||||
$options[$view_path] = $view_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
asort($options);
|
||||
$form['existing_view'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Link to this view'),
|
||||
'#default_value' => isset($item['link_path']) ? $item['link_path'] : NULL,
|
||||
'#required' => TRUE,
|
||||
'#options' => $options,
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
'#submit' => array('content_menu_add_exiting_view_submit'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$no_views_notice = t('There are no available views.');
|
||||
if (module_exists('views_ui') && user_access('administer views')) {
|
||||
$no_views_notice .= ' ' . t('You can create views in the <a href="@url">Views UI</a>', array('@url' => url('admin/structure/views')));
|
||||
}
|
||||
$form['view_info'] = array(
|
||||
'#title' => t('Use these views'),
|
||||
'#type' => 'item',
|
||||
'#markup' => $no_views_notice,
|
||||
);
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit handler for the form above.
|
||||
*/
|
||||
function content_menu_add_exiting_view_submit($form, $form_state) {
|
||||
$menu_item = $form['#menu_item'];
|
||||
$menu_item['link_path'] = $form_state['values']['existing_view'];
|
||||
content_menu_link_save($menu_item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assembles a query string with menu item data.
|
||||
*/
|
||||
function content_menu_assemble_query_string($item) {
|
||||
if (empty($item['name']) && isset($item['menu_name'])) {
|
||||
$item['name'] = $item['menu_name'];
|
||||
}
|
||||
$query = array(
|
||||
'menu_mlid' => isset($item['mlid']) ? $item['mlid'] : NULL,
|
||||
'menu_title' => $item['title'],
|
||||
'menu_plid' => $item['plid'],
|
||||
'menu_name' => $item['name'],
|
||||
'menu_hidden' => $item['hidden'],
|
||||
'menu_weight' => $item['weight'],
|
||||
'menu_link_path' => isset($item['link_path']) ? $item['link_path'] : NULL ,
|
||||
'destination' => isset($item['destination']) ? $item['destination'] : ('admin/structure/menu/manage/' . $item['name']),
|
||||
'msg_buffer' => isset($item['msg_buffer']) ? $item['msg_buffer'] : NULL,
|
||||
);
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve all supported menu add item operations.
|
||||
*/
|
||||
function content_menu_get_target_types($menu_name) {
|
||||
// Invoke hook to let modules provide target operations for new item.
|
||||
$target_types = array();
|
||||
$context = array('menu_name' => $menu_name);
|
||||
drupal_alter('menu_item_target_types', $target_types, $context);
|
||||
return $target_types;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Actual implementation for content_menu_menu_item_target_types_alter().
|
||||
*
|
||||
* Extend the target types for a new menu item provided by default.
|
||||
* See content_menu.api.php for further documentation.
|
||||
*/
|
||||
function _content_menu_menu_item_target_types_alter(&$target_types, &$context) {
|
||||
$target_types['url'] = array(
|
||||
'label' => t('URL'),
|
||||
'handler' => 'content_menu_menu_form_handler_url',
|
||||
'clean_menu_save_message' => TRUE,
|
||||
);
|
||||
|
||||
$target_types['dummy'] = array(
|
||||
'label' => t('Placeholder'),
|
||||
'handler' => 'content_menu_menu_form_handler_dummy',
|
||||
'clean_menu_save_message' => FALSE,
|
||||
);
|
||||
|
||||
foreach (node_type_get_types() as $node_type) {
|
||||
if (user_access('create ' . $node_type->type . ' content') || user_access('administer nodes')) {
|
||||
$node_menu_options = variable_get('menu_options_' . $node_type->type, array('main-menu' => 'main-menu'));
|
||||
if (in_array($context['menu_name'], $node_menu_options)) {
|
||||
|
||||
$target_types['node_' . $node_type->type] = array(
|
||||
'label' => t('New @type', array('@type' => t($node_type->name))),
|
||||
'handler' => 'content_menu_menu_form_handler_node',
|
||||
'arguments' => array('type' => $node_type->type),
|
||||
'clean_menu_save_message' => TRUE,
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$target_types['existing'] = array(
|
||||
'label' => t('Existing content'),
|
||||
'handler' => 'content_menu_menu_form_handler_menu_position_existing',
|
||||
'clean_menu_save_message' => TRUE,
|
||||
);
|
||||
|
||||
if (module_exists('views')) {
|
||||
$target_types['existing_view'] = array(
|
||||
'label' => t('Existing view'),
|
||||
'handler' => 'content_menu_menu_form_handler_existing_view',
|
||||
'clean_menu_save_message' => TRUE,
|
||||
);
|
||||
}
|
||||
|
||||
if (module_exists('menu_position') && user_access('administer menu positions')) {
|
||||
$target_types['menu_position_rule'] = array(
|
||||
'label' => t('Menu position rule'),
|
||||
'handler' => 'content_menu_menu_form_handler_menu_position_rule',
|
||||
'clean_menu_save_message' => TRUE,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,547 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Main code for the content_menu.module.
|
||||
*
|
||||
* ToDo: Use view query alter hook to mandatorily filter existing-node-selection
|
||||
* by only those node types that can have a menu item in the resp. menu.
|
||||
*
|
||||
* ToDo: Mark menu items in item listing that are linked to unpublished content.
|
||||
* NOTE: menu links to unpublished nodes are suppressed by Drupal.
|
||||
* => Option 1: Alter Drupal's behavior to show unpublished links, too,
|
||||
* and then mark them as unpublished (new permission).
|
||||
* => Options 2: Leave everything as is.
|
||||
*
|
||||
* ToDo: Use menu.module's variable 'menu_override_parent_selector' to provide
|
||||
* custom more scalable menu parent selector.
|
||||
*
|
||||
* ToDo: Pre-placement of new menu items is sometimes slightly misplaced.
|
||||
*/
|
||||
|
||||
define('CONTENT_MENU_ADD_EXISTING_CONTENT_URL', 'admin/structure/menu/manage/add_existing_content');
|
||||
define('CONTENT_MENU_ADD_EXISTING_VIEW_URL', 'admin/structure/menu/manage/add_existing_view');
|
||||
define('CONTENT_MENU_ALTER_ALL_MENUS', FALSE);
|
||||
define('CONTENT_MENU_ADD_ITEM_WEIGHT', 50);
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function content_menu_permission() {
|
||||
return array(
|
||||
// Introduce new permission for editing default system menus.
|
||||
'administer system menus' => array(
|
||||
'title' => t('Administer system menus'),
|
||||
'description' => t('Administer system menus'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function content_menu_menu() {
|
||||
// Add menu router item for use as target with dummy menu items.
|
||||
$items['menu-dummy'] = array(
|
||||
'title' => 'Placeholder for menu item dummies.',
|
||||
'page callback' => 'content_menu_menu_callback_menu_dummy',
|
||||
'access arguments' => array('access content'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items[CONTENT_MENU_ADD_EXISTING_VIEW_URL] = array(
|
||||
'title' => 'Add existing view.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('content_menu_add_exiting_view'),
|
||||
'access arguments' => array('access content'),
|
||||
'file' => 'content_menu.menu_admin.inc',
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu router callback for placeholder menu items.
|
||||
*/
|
||||
function content_menu_menu_callback_menu_dummy() {
|
||||
return t('This is an empty placeholder page for a menu item.<br /><br />You can replace it with a valid target page URL in the <a href="@url">menu administration</a>.', array('@url' => url('admin/structure/menu')));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu_alter().
|
||||
*
|
||||
* Rename some menu management tabs.
|
||||
*/
|
||||
function content_menu_menu_alter(&$items) {
|
||||
$items['admin/structure/menu/manage/%menu']['title'] = $items['admin/structure/menu/manage/%menu/list']['title'] = t('Edit');
|
||||
$items['admin/structure/menu/manage/%menu/edit']['title'] = t('Configure');
|
||||
$items['admin/structure/menu']['page callback'] = 'content_menu_menu_overview_page_extended';
|
||||
unset($items['admin/structure/menu']['file']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_init().
|
||||
*
|
||||
* Necessary to invoke for ajax callback to work correctly.
|
||||
* @todo Refactor as ajax is actually not used.
|
||||
*/
|
||||
function content_menu_init() {
|
||||
if (arg(0) == 'admin' || ((arg(0) == 'system') && (arg(1) == 'ajax'))) {
|
||||
module_load_include('inc', 'content_menu', 'content_menu.menu_admin');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for altered admin/structure/menu router item.
|
||||
*/
|
||||
function content_menu_menu_overview_page_extended() {
|
||||
module_load_include('inc', 'content_menu', 'content_menu.menu_admin');
|
||||
return _content_menu_menu_overview_page_extended();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function content_menu_theme() {
|
||||
return array(
|
||||
// Theming function for extended menu overview form rendering.
|
||||
'menu_overview_form_extended' => array(
|
||||
'file' => 'content_menu.menu_admin.inc',
|
||||
'render element' => 'form',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function content_menu_views_api() {
|
||||
return array('api' => 3.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_page_alter().
|
||||
*
|
||||
* Set consistent menu admin breadcrumbs on pages other than menu admin forms.
|
||||
*/
|
||||
function content_menu_page_alter(&$page) {
|
||||
$menu_paths = array(
|
||||
'admin/structure/menu/',
|
||||
'admin/structure/menu-position/',
|
||||
content_menu_variable_get_add_existing_content_url(),
|
||||
);
|
||||
$path = current_path();
|
||||
foreach ($menu_paths as $menu_path) {
|
||||
if (strpos($path, $menu_path) === 0) {
|
||||
content_menu_set_menu_admin_breadcrumb();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (current_path() == content_menu_variable_get_add_existing_content_url()) {
|
||||
$item = content_menu_get_menu_item_from_querystring();
|
||||
if (isset($item['mlid']) && ($item['mlid'] != 0)) {
|
||||
drupal_set_message(t("You're about to select a new content target for menu item %title.", array('%title' => $item['title'])));
|
||||
drupal_set_message(t('Now you can select an existing content item for menu item %title.', array('%title' => $item['title'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set consistent menu admin breadcrumb.
|
||||
*/
|
||||
function content_menu_set_menu_admin_breadcrumb($menu_name = NULL) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('Home'), '<front>');
|
||||
$breadcrumb[] = l(t('Administration'), 'admin');
|
||||
$breadcrumb[] = l(t('Structure'), 'admin/structure');
|
||||
$breadcrumb[] = l(t('Menus'), 'admin/structure/menu');
|
||||
|
||||
if ($menu_name == NULL) {
|
||||
$menu_item = content_menu_get_menu_item_from_querystring();
|
||||
if (isset($menu_item['name'])) {
|
||||
$menu_name = $menu_item['name'];
|
||||
}
|
||||
}
|
||||
if ($menu_name) {
|
||||
$menus = menu_get_menus();
|
||||
$menu_title = t($menus[$menu_name]);
|
||||
$breadcrumb[] = l(t($menu_title), 'admin/structure/menu/manage/' . $menu_name);
|
||||
drupal_set_title(t($menu_title));
|
||||
}
|
||||
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu_link_insert().
|
||||
*/
|
||||
function content_menu_menu_link_insert($link) {
|
||||
content_menu_mark_link_updated($link);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu_link_update().
|
||||
*/
|
||||
function content_menu_menu_link_update($link) {
|
||||
content_menu_mark_link_updated($link);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mark newly created menu items, to highlight them subsequently.
|
||||
*
|
||||
* @param $link Array defining the link.
|
||||
*/
|
||||
function content_menu_mark_link_updated($link) {
|
||||
// Save menu links created on or right before menu admin pages to session var.
|
||||
if ((isset($_GET['destination']) && (strpos($_GET['destination'], 'admin/structure/menu/manage/') === 0))
|
||||
||
|
||||
(strpos(current_path(), 'admin/structure/menu/manage/') === 0)
|
||||
) {
|
||||
$link['created'] = time();
|
||||
$_SESSION['content_menu_inserted_links'][$link['mlid']] = $link;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* Improve menu_edit_item form for better authoring experience.
|
||||
*/
|
||||
function content_menu_form_menu_edit_item_alter(&$form, &$form_state, $form_id) {
|
||||
// Pre-populate menu item form elements with data from querystring.
|
||||
if (isset($_GET['menu_title'])) {
|
||||
$menu_item = content_menu_get_menu_item_from_querystring();
|
||||
// If even link_path is given, create item right away and go back.
|
||||
if (!empty($menu_item['link_path'])) {
|
||||
content_menu_link_save($menu_item);
|
||||
drupal_goto(check_plain($_GET['destination']));
|
||||
}
|
||||
$form['link_title']['#default_value'] = $menu_item['title'];
|
||||
$form['link_path']['#default_value'] = $menu_item['link_path'];
|
||||
$form['parent']['#default_value'] = $menu_item['name'] . ':' . $menu_item['plid'];
|
||||
$form['weight']['#default_value'] = $menu_item['weight'];
|
||||
$form['enabled']['#default_value'] = !($menu_item['hidden']);
|
||||
}
|
||||
|
||||
// Extend breadcrumb.
|
||||
if ($form['mlid']['#value']) {
|
||||
$menu = explode(':', $form['parent']['#default_value']);
|
||||
content_menu_set_menu_admin_breadcrumb($menu[0]);
|
||||
}
|
||||
|
||||
// Simplify the form, by putting all "advanced" fields in fieldset.
|
||||
$form['advanced'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#weight' => 100,
|
||||
'#title' => t('Advanced menu item settings'),
|
||||
);
|
||||
$advanced_elements = array('description', 'expanded', 'parent', 'weight');
|
||||
foreach ($advanced_elements as $el_key) {
|
||||
$form['advanced'][$el_key] = $form[$el_key];
|
||||
unset($form[$el_key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* Improve menu_item_delete_form form for better authoring experience.
|
||||
*/
|
||||
function content_menu_form_menu_item_delete_form_alter(&$form, &$form_state, $form_id) {
|
||||
if (!empty($form['#item']['mlid'])) {
|
||||
// Extend breadcrumb.
|
||||
$menu_name = $form['#item']['menu_name'];
|
||||
content_menu_set_menu_admin_breadcrumb($menu_name);
|
||||
|
||||
// Add question text to form (instead of having it as the page title).
|
||||
$form['question'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<div class="question">' . t('Are you sure you want to delete the custom menu link %item?', array('%item' => t($form['#item']['link_title']))) . '</div><p></p>',
|
||||
'#weight' => -100,
|
||||
);
|
||||
|
||||
// If menu item to delete links to a node, offer the choice to
|
||||
// delete the associated node as well, if user is permitted.
|
||||
if ($form['#item']['router_path'] == 'node/%') {
|
||||
$nid = explode('/', $form['#item']['link_path']);
|
||||
if (isset($nid[1]) && is_numeric($nid[1])) {
|
||||
$node = node_load($nid[1]);
|
||||
if (is_object($node) && node_access('delete', $node)) {
|
||||
$form['delete_node'] = array(
|
||||
'#type' => 'checkbox',
|
||||
// '#markup' => '<div class="question">' . t('Are you sure you want to delete the custom menu link %item?', array('%item' => t($form['#item']['link_title']))) . '</div><p></p>',
|
||||
'#title' => t('Delete associated %type <a href="@url">%title</a> as well.',
|
||||
array(
|
||||
'%type' => node_type_get_name($node),
|
||||
'@url' => url('node/' . $node->nid),
|
||||
'%title' => $node->title,
|
||||
)),
|
||||
'#default_value' => FALSE,
|
||||
'#weight' => -50,
|
||||
);
|
||||
$form['delete_node_nid'] = array('#type' => 'value', '#value' => $node->nid);
|
||||
$form['#submit'] = array('content_menu_item_delete_form_submit');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extended submit handler for menu_item_delete_form.
|
||||
*/
|
||||
function content_menu_item_delete_form_submit($form, &$form_state) {
|
||||
// Call default submit handler to handle deletion of menu item itself.
|
||||
menu_item_delete_form_submit($form, $form_state);
|
||||
|
||||
// Delete an associated node as well, if intended and user is permitted.
|
||||
if ($form_state['input']['delete_node'] == 1) {
|
||||
$nid = explode('/', $form['#item']['link_path']);
|
||||
if (isset($nid[1]) && is_numeric($nid[1])) {
|
||||
$node = node_load($nid[1]);
|
||||
if (is_object($node) && node_access('delete', $node) && ($node->nid == $form_state['values']['delete_node_nid'])) {
|
||||
node_delete($node->nid);
|
||||
watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
|
||||
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* Pre-populate input elements in menu_position_add_rule_form.
|
||||
*/
|
||||
function content_menu_form_menu_position_add_rule_form_alter(&$form, &$form_state, $form_id) {
|
||||
// Pre-populate menu item form elements with data from querystring.
|
||||
if (isset($_GET['menu_title'])) {
|
||||
$menu_item = content_menu_get_menu_item_from_querystring();
|
||||
$form['admin_title']['#default_value'] = $menu_item['title'];
|
||||
$form['plid']['#default_value'] = $menu_item['name'] . ':' . $menu_item['plid'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* Overhaul the menu_overview_form to improve menu authoring experience.
|
||||
*/
|
||||
function content_menu_form_menu_overview_form_alter(&$form, &$form_state, $form_id) {
|
||||
if (variable_get('content_menu_alter_all_menus', CONTENT_MENU_ALTER_ALL_MENUS) || content_menu_is_menu_considered($form['#menu']['menu_name'])) {
|
||||
module_load_include('inc', 'content_menu', 'content_menu.menu_admin');
|
||||
_content_menu_form_menu_overview_form_alter($form, $form_state, $form_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu_local_tasks_alter().
|
||||
*
|
||||
* Remove the "Add link" link on menu listing page, since
|
||||
* we add a "New item" row and form element, which cares for adding new items.
|
||||
*/
|
||||
function content_menu_menu_local_tasks_alter(&$data, $router_item, $root_path) {
|
||||
if (strpos(current_path(), 'admin/structure/menu/manage/') === 0) {
|
||||
if (variable_get('content_menu_alter_all_menus', CONTENT_MENU_ALTER_ALL_MENUS) || content_menu_is_menu_considered(arg(4))) {
|
||||
foreach ($data['actions']['output'] as $key => $action) {
|
||||
if ($action['#link']['path'] == 'admin/structure/menu/manage/%/add') {
|
||||
unset($data['actions']['output'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements template_preprocess_views_view_field().
|
||||
*
|
||||
* For views to select exiting content, rewrite the nid field ("select" link)
|
||||
* to link to the correct target url and pass through the querystring params.
|
||||
*/
|
||||
function content_menu_preprocess_views_view_field(&$vars) {
|
||||
$view = &$vars['view'];
|
||||
$field = &$vars['field'];
|
||||
$selection_view = explode(':', variable_get('content_menu_add_existing_content_view', 'menu_existing_content_selection'));
|
||||
if (($field->field == 'nid') && ($view->name == $selection_view[0]) && ((!isset($selection_view[1]) || ($view->current_display == $selection_view[1])))) {
|
||||
module_load_include('inc', 'content_menu', 'content_menu.menu_admin');
|
||||
$item = content_menu_get_menu_item_from_querystring();
|
||||
if (!empty($item)) {
|
||||
$item['link_path'] = 'node/' . $field->original_value;
|
||||
$url = 'admin/structure/menu/manage/' . $item['name'] . '/add';
|
||||
$vars['output'] = l(t('select'), $url, array('query' => content_menu_assemble_query_string($item)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu_item_target_types_alter().
|
||||
*
|
||||
* Extend the target types for a new menu item provided by default.
|
||||
* See content_menu.api.php for further documentation.
|
||||
*/
|
||||
function content_menu_menu_item_target_types_alter(&$target_types, &$context) {
|
||||
module_load_include('inc', 'content_menu', 'content_menu.menu_admin');
|
||||
_content_menu_menu_item_target_types_alter($target_types, $context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alter a menu item's form element in the menu item administration.
|
||||
*
|
||||
* @param $el Array The form element of the menu item to alter.
|
||||
*/
|
||||
function content_menu_menu_item_element_alter(&$el) {
|
||||
module_load_include('inc', 'content_menu', 'content_menu.menu_admin');
|
||||
_content_menu_menu_item_element_alter($el);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_node_insert().
|
||||
*
|
||||
* After creating a new node, if it's being created to replace a menu-dummy,
|
||||
* perform the replacement.
|
||||
*/
|
||||
function content_menu_node_insert($node) {
|
||||
// Ensure that this node is replacing a menu dummy.
|
||||
if (isset($_GET['menu_link_path']) && $_GET['menu_link_path'] == 'menu-dummy') {
|
||||
// Update the dummy that is being replaced by this node.
|
||||
$menu_item = content_menu_get_menu_item_from_querystring();
|
||||
$menu_item['link_path'] = "node/" . $node->nid;
|
||||
content_menu_link_save($menu_item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*
|
||||
* Improve menu item management for node edit forms.
|
||||
*/
|
||||
function content_menu_form_alter(&$form, &$form_state, $form_id) {
|
||||
if (isset($form['#node_edit_form'])) {
|
||||
// Add link to menu overview / admin form to menu fieldset.
|
||||
if (user_access('administer menu')) {
|
||||
if ($form['#node_edit_form'] && isset($form['menu'])) {
|
||||
$menu = explode(':', $form['menu']['link']['parent']['#default_value']);
|
||||
$form['menu']['link']['menu_admin_link'] = array('#type' => 'markup', '#markup' => l(t('Manage menu structure') . ' …', 'admin/structure/menu/manage/' . $menu[0], array('attributes' => array('target' => '_blank'))));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($form['menu'])) {
|
||||
if (isset($_GET['menu_link_path']) && $_GET['menu_link_path'] == 'menu-dummy') {
|
||||
// If this node is being created to replace a menu dummy, substitute
|
||||
// the usual menu form for a description of what will happen.
|
||||
$form['menu']['enabled']['#access'] = FALSE;
|
||||
$form['menu']['link']['#access'] = FALSE;
|
||||
$trail = content_menu_get_menu_trail($_GET['menu_mlid']);
|
||||
$form['menu']['menu_dummy_replace'] = array(
|
||||
'#markup' => t('A link to this node will replace the menu dummy at <br /> %trail', array('%trail' => implode(' » ', $trail))),
|
||||
);
|
||||
$form['title']['#default_value'] = $form['title_field']['und']['0']['value']['#default_value'] = $_GET['menu_title'];
|
||||
}
|
||||
else {
|
||||
// Hide description field from menu item fieldset.
|
||||
$form['menu']['link']['description']['#access'] = FALSE;
|
||||
|
||||
// Pre-Populate menu item fields, if given via querystring.
|
||||
if (isset($_GET['menu_title'])) {
|
||||
$menu_item = content_menu_get_menu_item_from_querystring();
|
||||
|
||||
// Set node form's menu item input field
|
||||
// according to query string input.
|
||||
$form['menu']['enabled']['#default_value'] = 1;
|
||||
$form['menu']['link']['hidden']['#value'] = $menu_item['hidden'];
|
||||
$form['menu']['link']['link_title']['#default_value'] = $menu_item['title'];
|
||||
$form['menu']['link']['parent']['#default_value'] = $menu_item['name'] . ':' . $menu_item['plid'];
|
||||
$form['menu']['link']['weight']['#default_value'] = $menu_item['weight'];
|
||||
|
||||
$form['title']['#default_value'] = $form['title_field']['und']['0']['value']['#default_value'] = $menu_item['title'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the menu trail array that points to the given mlid.
|
||||
*/
|
||||
function content_menu_get_menu_trail($leaf_mlid) {
|
||||
$menu_link = menu_link_load($leaf_mlid);
|
||||
$menu = menu_load($menu_link['menu_name']);
|
||||
$trail = array();
|
||||
|
||||
while ($menu_link) {
|
||||
array_unshift($trail, $menu_link['link_title']);
|
||||
$menu_link = menu_link_load($menu_link['plid']);
|
||||
}
|
||||
array_unshift($trail, $menu['title']);
|
||||
|
||||
return $trail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build menu item data from querystring.
|
||||
*/
|
||||
function content_menu_get_menu_item_from_querystring() {
|
||||
// Sanitize querystring input.
|
||||
$menu_item = array();
|
||||
foreach ($_GET as $get_key => $get_value) {
|
||||
if (substr($get_key, 0, 5) == 'menu_') {
|
||||
$menu_item[check_plain(substr($get_key, 5))] = strip_tags($get_value);
|
||||
}
|
||||
}
|
||||
return $menu_item;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a given menu (name) applies for being considered by this module.
|
||||
*/
|
||||
function content_menu_is_menu_considered($menu_name) {
|
||||
$exclude_menus = variable_get('content_menu_special_menus',
|
||||
array('management', 'user-menu', 'navigation', 'devel'));
|
||||
return !in_array($menu_name, $exclude_menus);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper for menu_link_save() to create new menu link item from array.
|
||||
*/
|
||||
function content_menu_link_save($menu_item) {
|
||||
$menu_item['menu_name'] = $menu_item['name'];
|
||||
$menu_item['link_title'] = $menu_item['title'];
|
||||
$menu_item['customized'] = 1;
|
||||
|
||||
return menu_link_save($menu_item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get config variable 'content_menu_add_existing_content_url'.
|
||||
*/
|
||||
function content_menu_variable_get_add_existing_content_url() {
|
||||
$url = variable_get('content_menu_add_existing_content_url', CONTENT_MENU_ADD_EXISTING_CONTENT_URL);
|
||||
// If using default view, ensure to only goto view page if views is enabled.
|
||||
if (($url == CONTENT_MENU_ADD_EXISTING_CONTENT_URL) && !module_exists('views')) {
|
||||
$url = NULL;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views-related stuff for Content Menu module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_default_views().
|
||||
*/
|
||||
function content_menu_views_default_views() {
|
||||
$view = new view();
|
||||
$view->name = 'menu_existing_content_selection';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = 'Menu existing content selection';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['title'] = 'Select existing content';
|
||||
$handler->display->display_options['use_ajax'] = TRUE;
|
||||
$handler->display->display_options['access']['type'] = 'perm';
|
||||
$handler->display->display_options['access']['perm'] = 'administer menu';
|
||||
$handler->display->display_options['cache']['type'] = 'none';
|
||||
$handler->display->display_options['query']['type'] = 'views_query';
|
||||
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
|
||||
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
||||
$handler->display->display_options['pager']['type'] = 'full';
|
||||
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
|
||||
$handler->display->display_options['style_plugin'] = 'table';
|
||||
$handler->display->display_options['style_options']['columns'] = array(
|
||||
'title' => 'title',
|
||||
'name' => 'name',
|
||||
'created' => 'created',
|
||||
'type' => 'type',
|
||||
'nid' => 'nid',
|
||||
);
|
||||
$handler->display->display_options['style_options']['default'] = 'title';
|
||||
$handler->display->display_options['style_options']['info'] = array(
|
||||
'title' => array(
|
||||
'sortable' => 1,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'name' => array(
|
||||
'sortable' => 1,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'created' => array(
|
||||
'sortable' => 1,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'type' => array(
|
||||
'sortable' => 1,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'nid' => array(
|
||||
'sortable' => 0,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
);
|
||||
$handler->display->display_options['style_options']['override'] = 1;
|
||||
$handler->display->display_options['style_options']['sticky'] = 0;
|
||||
$handler->display->display_options['style_options']['empty_table'] = 0;
|
||||
/* No results behavior: Global: Text area */
|
||||
$handler->display->display_options['empty']['area']['id'] = 'area';
|
||||
$handler->display->display_options['empty']['area']['table'] = 'views';
|
||||
$handler->display->display_options['empty']['area']['field'] = 'area';
|
||||
$handler->display->display_options['empty']['area']['empty'] = FALSE;
|
||||
$handler->display->display_options['empty']['area']['content'] = 'There is no content available that matches your selection criteria';
|
||||
$handler->display->display_options['empty']['area']['format'] = 'plain_text';
|
||||
$handler->display->display_options['empty']['area']['tokenize'] = 0;
|
||||
/* Relationship: Content: Author */
|
||||
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
|
||||
$handler->display->display_options['relationships']['uid']['table'] = 'node';
|
||||
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
|
||||
$handler->display->display_options['relationships']['uid']['required'] = 0;
|
||||
/* Field: Content: Nid */
|
||||
$handler->display->display_options['fields']['nid']['id'] = 'nid';
|
||||
$handler->display->display_options['fields']['nid']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['nid']['field'] = 'nid';
|
||||
$handler->display->display_options['fields']['nid']['label'] = '';
|
||||
$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 1;
|
||||
$handler->display->display_options['fields']['nid']['alter']['text'] = '<span class="node-selector" data-nid="[nid]">select</span>';
|
||||
$handler->display->display_options['fields']['nid']['alter']['make_link'] = 1;
|
||||
$handler->display->display_options['fields']['nid']['alter']['path'] = 'node/[nid]';
|
||||
$handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['alt'] = 'Select this content';
|
||||
$handler->display->display_options['fields']['nid']['alter']['link_class'] = 'node-pane-selector';
|
||||
$handler->display->display_options['fields']['nid']['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields']['nid']['alter']['more_link'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['nid']['element_default_classes'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['hide_alter_empty'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['link_to_node'] = 0;
|
||||
/* Field: Content: Link -> */
|
||||
$handler->display->display_options['fields']['title_1']['id'] = 'title_1';
|
||||
$handler->display->display_options['fields']['title_1']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['title_1']['field'] = 'title';
|
||||
$handler->display->display_options['fields']['title_1']['ui_name'] = 'Content: Link ->';
|
||||
$handler->display->display_options['fields']['title_1']['label'] = '';
|
||||
$handler->display->display_options['fields']['title_1']['exclude'] = TRUE;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['alter_text'] = 1;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['text'] = 'view →';
|
||||
$handler->display->display_options['fields']['title_1']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['more_link'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['title_1']['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields']['title_1']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['title_1']['hide_alter_empty'] = 1;
|
||||
$handler->display->display_options['fields']['title_1']['link_to_node'] = 1;
|
||||
/* Field: Content: Title */
|
||||
$handler->display->display_options['fields']['title']['id'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['title']['field'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 1;
|
||||
$handler->display->display_options['fields']['title']['alter']['text'] = '[title] [title_1]';
|
||||
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['more_link'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['title']['element_label_colon'] = 1;
|
||||
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;
|
||||
$handler->display->display_options['fields']['title']['link_to_node'] = 0;
|
||||
/* Field: Content: Type */
|
||||
$handler->display->display_options['fields']['type']['id'] = 'type';
|
||||
$handler->display->display_options['fields']['type']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['type']['field'] = 'type';
|
||||
$handler->display->display_options['fields']['type']['label'] = 'Content Type';
|
||||
$handler->display->display_options['fields']['type']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields']['type']['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields']['type']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['type']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['type']['element_label_colon'] = 1;
|
||||
$handler->display->display_options['fields']['type']['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields']['type']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['type']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['type']['hide_alter_empty'] = 1;
|
||||
$handler->display->display_options['fields']['type']['link_to_node'] = 0;
|
||||
$handler->display->display_options['fields']['type']['machine_name'] = 0;
|
||||
/* Field: User: Name */
|
||||
$handler->display->display_options['fields']['name']['id'] = 'name';
|
||||
$handler->display->display_options['fields']['name']['table'] = 'users';
|
||||
$handler->display->display_options['fields']['name']['field'] = 'name';
|
||||
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
|
||||
$handler->display->display_options['fields']['name']['label'] = 'Author';
|
||||
$handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['name']['element_label_colon'] = 1;
|
||||
$handler->display->display_options['fields']['name']['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields']['name']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['name']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['name']['hide_alter_empty'] = 1;
|
||||
$handler->display->display_options['fields']['name']['link_to_user'] = 0;
|
||||
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
|
||||
$handler->display->display_options['fields']['name']['format_username'] = 1;
|
||||
/* Field: Content: Post date */
|
||||
$handler->display->display_options['fields']['created']['id'] = 'created';
|
||||
$handler->display->display_options['fields']['created']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['created']['field'] = 'created';
|
||||
$handler->display->display_options['fields']['created']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields']['created']['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields']['created']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['created']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['created']['element_label_colon'] = 1;
|
||||
$handler->display->display_options['fields']['created']['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields']['created']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['created']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['created']['hide_alter_empty'] = 1;
|
||||
$handler->display->display_options['fields']['created']['date_format'] = 'short';
|
||||
/* Sort criterion: Content: Post date */
|
||||
$handler->display->display_options['sorts']['created']['id'] = 'created';
|
||||
$handler->display->display_options['sorts']['created']['table'] = 'node';
|
||||
$handler->display->display_options['sorts']['created']['field'] = 'created';
|
||||
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
|
||||
/* Filter criterion: Content: Published */
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 1;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
/* Filter criterion: Content: Title */
|
||||
$handler->display->display_options['filters']['title']['id'] = 'title';
|
||||
$handler->display->display_options['filters']['title']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['title']['field'] = 'title';
|
||||
$handler->display->display_options['filters']['title']['operator'] = 'contains';
|
||||
$handler->display->display_options['filters']['title']['exposed'] = TRUE;
|
||||
$handler->display->display_options['filters']['title']['expose']['operator_id'] = 'title_op';
|
||||
$handler->display->display_options['filters']['title']['expose']['label'] = 'Title contains';
|
||||
$handler->display->display_options['filters']['title']['expose']['operator'] = 'title_op';
|
||||
$handler->display->display_options['filters']['title']['expose']['identifier'] = 'title';
|
||||
$handler->display->display_options['filters']['title']['expose']['required'] = 0;
|
||||
$handler->display->display_options['filters']['title']['expose']['multiple'] = FALSE;
|
||||
/* Filter criterion: Content: Type */
|
||||
$handler->display->display_options['filters']['type']['id'] = 'type';
|
||||
$handler->display->display_options['filters']['type']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['type']['field'] = 'type';
|
||||
$handler->display->display_options['filters']['type']['exposed'] = TRUE;
|
||||
$handler->display->display_options['filters']['type']['expose']['operator_id'] = 'type_op';
|
||||
$handler->display->display_options['filters']['type']['expose']['label'] = 'Type';
|
||||
$handler->display->display_options['filters']['type']['expose']['operator'] = 'type_op';
|
||||
$handler->display->display_options['filters']['type']['expose']['identifier'] = 'type';
|
||||
$handler->display->display_options['filters']['type']['expose']['reduce'] = 0;
|
||||
|
||||
/* Display: Page */
|
||||
$handler = $view->new_display('page', 'Page', 'page_1');
|
||||
$handler->display->display_options['path'] = 'admin/structure/menu/manage/add_existing_content';
|
||||
|
||||
$views[$view->name] = $view;
|
||||
|
||||
return $views;
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
|
||||
#menu-overview-form tr.ok td {
|
||||
background: #dfd;
|
||||
}
|
||||
|
||||
.menu-overview-title-edit-trigger
|
||||
{
|
||||
margin-left: 8px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
tr:hover .menu-overview-title-edit-trigger {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#menu-overview-form table.sticky-header {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
table#menu-overview .menu-enabled .form-type-textfield,
|
||||
table#menu-overview .menu-disabled .form-type-textfield {
|
||||
display: inline;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.menu-enabled .form-type-textfield input,
|
||||
.menu-disabled .form-type-textfield input {
|
||||
/*border-width: 0px;*/
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
.menu-additem .form-item-additem-hidden input {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.menu-additem .form-item-additem-title input {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.menu-additem td {
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
.menu-additem .tabledrag-changed {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
td.menu-target-content {
|
||||
color: #888;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.menu-target-content {
|
||||
width: 90px;
|
||||
}
|
||||
|
||||
.menu-operations {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
|
||||
/* ctools dropbutton styling */
|
||||
|
||||
|
||||
.ctools-button {
|
||||
margin-top: -1em;
|
||||
}
|
||||
|
||||
|
||||
.ctools-button ul {
|
||||
margin: 0em !important;
|
||||
/* evil "!important" to override even more eveler theme style */
|
||||
}
|
||||
|
||||
|
||||
/* Taken from views/css/views-admin.ctools.css */
|
||||
|
||||
|
||||
|
||||
/* @group Buttons */
|
||||
|
||||
|
||||
.ctools-button-processed {
|
||||
background-color: #ffffff;
|
||||
border-color: #cccccc;
|
||||
font-size: 11px;
|
||||
padding-bottom: 2px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.ctools-button-processed,
|
||||
.ctools-button-processed input {
|
||||
text-transform: lowercase;
|
||||
}
|
||||
|
||||
.ctools-button-processed:hover {
|
||||
border-color: #b8b8b8;
|
||||
}
|
||||
|
||||
.ctools-button-processed:active {
|
||||
border-color: #a0a0a0;
|
||||
}
|
||||
|
||||
.ctools-button-processed .ctools-content {
|
||||
padding-bottom: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed .ctools-content {
|
||||
border-right: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed .ctools-content ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ctools-content ul.actions {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.ctools-button-processed .ctools-content a {
|
||||
background-image: none;
|
||||
border: medium none;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open:hover {
|
||||
border-color: #D0D0D0;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open {
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed .ctools-link {
|
||||
border-left: 1px solid #ffffff;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open .ctools-content {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed li a,
|
||||
.ctools-dropbutton-processed li input {
|
||||
padding-right: 9px;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open li + li {
|
||||
border-top: 1px solid #efefef;
|
||||
margin-top: 4px;
|
||||
padding-bottom: 0;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.ctools-twisty:focus {
|
||||
outline: medium none;
|
||||
}
|
||||
|
||||
.ctools-no-js .ctools-content ul {
|
||||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#menu-overview .ctools-button-processed {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 4px;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
.ctools-button-processed li a,
|
||||
.ctools-button-processed input {
|
||||
background: none;
|
||||
border: medium;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
padding-bottom: 0;
|
||||
padding-left: 12px;
|
||||
padding-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.ctools-button-processed input:hover {
|
||||
background: none;
|
||||
}
|
||||
*/
|
||||
/* @end */
|
||||
|
||||
|
||||
|
||||
/* Taken from views/css/views-admin.seven.css */
|
||||
|
||||
|
||||
|
||||
/* @group Buttons */
|
||||
|
||||
.ctools-button-processed ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Override for input elements that are themed like ctools-buttons */
|
||||
.ctools-button-processed input.form-submit:hover {
|
||||
background-image: none;
|
||||
color: #0074BD;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.ctools-button-processed input.form-submit:active {
|
||||
background: none;
|
||||
border: medium none;
|
||||
color: #0074BD;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
|
||||
|
||||
/* @group Buttons */
|
||||
|
||||
.ctools-button-processed {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(249, 249, 249, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
-moz-border-radius: 11px 11px 11px 11px;
|
||||
-webkit-border-radius: 11px 11px 11px 11px;
|
||||
border-radius: 11px 11px 11px 11px;
|
||||
}
|
||||
|
||||
.ctools-button-processed:hover {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(241, 241, 241, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open:hover {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(249, 249, 249, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open {
|
||||
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
}
|
||||
|
||||
/* @end */
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by dreizwo.de.
|
||||
* User: jakobs
|
||||
* Date: 16.08.2012
|
||||
* Time: 13:59:48
|
||||
* @author markus jakobs <jakobs@dreizwo.de>
|
||||
*/
|
||||
|
||||
require_once 'content_menu_filter.php';
|
||||
|
||||
class content_menu_domain_filter implements content_menu_filter {
|
||||
|
||||
private $active;
|
||||
private $domain;
|
||||
|
||||
function __construct() {
|
||||
$this->domain = $this->_content_menu_domainacccess();
|
||||
$this->active = $this->domain ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
public function addFilterWidget(&$form, &$form_state, $form_id) {
|
||||
// add a selection filter based only if multilang{
|
||||
if ($this->active) {
|
||||
foreach ($this->_content_menu_domain_list() as $did => $dom) {
|
||||
$options[$did] = $dom['sitename'];
|
||||
}
|
||||
$form['domainselect'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Filter menu by domain'),
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->domain['domain_id'],
|
||||
'#ajax' => array(
|
||||
'callback' => '_content_menu_filter_elements_by_domain',
|
||||
)
|
||||
);
|
||||
$form['#content_menu_filter_widget'][] = 'domainselect';
|
||||
}
|
||||
}
|
||||
|
||||
public function hideElement($el) {
|
||||
if ($this->active) {
|
||||
//hide on different lang
|
||||
if (isset($el['#item']['options']['domain_menu_access'])) {
|
||||
//unset if explicit hidden
|
||||
if (isset($el['#item']['options']['domain_menu_access']['hide']) &&
|
||||
in_array(
|
||||
'd' . $this->domain['domain_id'], $el['#item']['options']['domain_menu_access']['hide'])
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
//if shown empty && not in shown => unset too
|
||||
if (!empty($el['#item']['options']['domain_menu_access']['show']) &&
|
||||
!in_array(
|
||||
'd' . $this->domain['domain_id'], $el['#item']['options']['domain_menu_access']['show'])
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
private function _content_menu_domainacccess() {
|
||||
if (module_exists('domain')) {
|
||||
$domains = $this->_content_menu_domain_list();
|
||||
|
||||
if (isset($_SESSION['content_menu_domain_filter'])) {
|
||||
return $domains[$_SESSION['content_menu_domain_filter']];
|
||||
}
|
||||
if (count($domains) > 1) {
|
||||
return domain_default(FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
private function _content_menu_domain_list() {
|
||||
$cache = &drupal_static(__FUNCTION__, array());
|
||||
if (empty($cache['domains'])) {
|
||||
$domains = array();
|
||||
$query = db_select('domain', 'd')
|
||||
->fields('d',
|
||||
array(
|
||||
'domain_id',
|
||||
'sitename',
|
||||
'subdomain',
|
||||
'scheme',
|
||||
'valid',
|
||||
'weight',
|
||||
'is_default'
|
||||
))
|
||||
->orderBy('weight');
|
||||
// Get the domains.
|
||||
$result = $query->execute();
|
||||
while ($domain = $result->fetchAssoc()) {
|
||||
$domains[$domain['domain_id']] = domain_api($domain);
|
||||
}
|
||||
$cache['domains'] = $domains;
|
||||
return $domains;
|
||||
}
|
||||
return $cache['domains'];
|
||||
}
|
||||
}
|
||||
|
||||
function _content_menu_filter_elements_by_domain($form, &$form_state) {
|
||||
$domain = $form_state['values']['domainselect'];
|
||||
ctools_include('ajax');
|
||||
$_SESSION['content_menu_domain_filter'] = $domain;
|
||||
$commands[] = ctools_ajax_command_reload();
|
||||
print ajax_render($commands);
|
||||
exit;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by dreizwo.de.
|
||||
* User: jakobs
|
||||
* Date: 16.08.2012
|
||||
* Time: 14:00:29
|
||||
* @author markus jakobs <jakobs@dreizwo.de>
|
||||
*/
|
||||
|
||||
interface content_menu_filter {
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param $el the menuitem
|
||||
* @return true if a element should be hidden
|
||||
*/
|
||||
public function hideElement($el);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param $form
|
||||
* @param $form_state
|
||||
* @param $form_id
|
||||
* @return add the filter widget,
|
||||
* to display the filter on top its recommended to add
|
||||
* $form['#content_menu_filter_widget'][] = 'name_of_filter_widget';
|
||||
* otherwise the filter will be displayed as child after the table
|
||||
*/
|
||||
public function addFilterWidget(&$form, &$form_state, $form_id);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by dreizwo.de.
|
||||
* User: jakobs
|
||||
* Date: 16.08.2012
|
||||
* Time: 14:00:17
|
||||
* @author markus jakobs <jakobs@dreizwo.de>
|
||||
*/
|
||||
|
||||
require_once 'content_menu_filter.php';
|
||||
|
||||
class content_menu_language_filter implements content_menu_filter {
|
||||
|
||||
private $active;
|
||||
private $language;
|
||||
|
||||
function __construct($menu_name) {
|
||||
$this->active = $this->_content_menu_multilanguage_support($menu_name);
|
||||
$this->language = $this->_content_menu_language();
|
||||
}
|
||||
|
||||
public function addFilterWidget(&$form, &$form_state, $form_id) {
|
||||
if ($this->active) {
|
||||
$options = array(
|
||||
'' => t('-- Current (@lang) --', array('@lang' => t($GLOBALS['language']->name))),
|
||||
'all' => t('-- All --'),
|
||||
);
|
||||
foreach (language_list() as $key => $lang) {
|
||||
$options[$key] = t($lang->name);
|
||||
}
|
||||
$form['langselect'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Filter menu by language'),
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->language,
|
||||
// @todo Remove ctools dependency as ajax is actually not used.
|
||||
// Refactor to use own form and submit handler instead.
|
||||
'#ajax' => array(
|
||||
'callback' => '_content_menu_filter_elements_by_language',
|
||||
)
|
||||
);
|
||||
$form['#content_menu_filter_widget'][] = 'langselect';
|
||||
}
|
||||
}
|
||||
|
||||
public function hideElement($el) {
|
||||
// If this filter is active...
|
||||
$lang = $this->language;
|
||||
if ($this->active && ($lang != 'all')) {
|
||||
if ($lang == '') {
|
||||
$lang = $GLOBALS['language']->language;
|
||||
}
|
||||
// Check every menu item with a specific language...
|
||||
if (isset($el['#item']['language']) && ($el['#item']['language'] != LANGUAGE_NONE)) {
|
||||
if ($el['#item']['language'] != $lang) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
private function _content_menu_multilanguage_support($menuname) {
|
||||
$i18n_mode = 0;
|
||||
$menu = menu_load($menuname);
|
||||
$i18n_mode = $menu && isset($menu['i18n_mode']) ? $menu['i18n_mode'] : 0;
|
||||
return (drupal_multilingual() && ($i18n_mode != 0));
|
||||
}
|
||||
|
||||
private function _content_menu_language() {
|
||||
$lang = '';
|
||||
if ($this->active) {
|
||||
if (isset($_SESSION['content_menu_lang_filter'])) {
|
||||
$lang = $_SESSION['content_menu_lang_filter'];
|
||||
}
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function _content_menu_filter_elements_by_language($form, &$form_state) {
|
||||
$lang = $form_state['values']['langselect'];
|
||||
ctools_include('ajax');
|
||||
$_SESSION['content_menu_lang_filter'] = $lang;
|
||||
if ($lang = '') {
|
||||
unset($_SESSION['content_menu_lang_filter']);
|
||||
}
|
||||
$commands[] = ctools_ajax_command_reload();
|
||||
print ajax_render($commands);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user