-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbigmenu.module
127 lines (120 loc) · 4.16 KB
/
bigmenu.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* @file alternative to core menu management
*
* Needed when menus get to big to load on one page.
*
* CONFLICTS WITH tiny_menu. Appropriately enough.
*
* Some of the code here - especially the form cache rebuild trigger in
* bigmenu_slice_form_js() and the parameters sent on the AJAX URL string feel
* quite ungainly.
* However the main target - to be able to layer on this flexibility without
* modifying core - made a few work-arounds neccessary.
*
* I did NOT use full Drupal core AHAH routines, as they seemed to rely on the
* entire form being submitted and rebuilt in the background each page load.
*
* As the focus of this module is on *scaling* - I couldn't add that overhead,
* so the subforms are generated independently, not as part of the main overview
* form. This is why the bigmenu_slice_form_js() cheats form_cache a little bit.
*
* @author Dan (dman) Morrison [email protected]
* @version 2011
*/
/**
* Implements hook_entity_type_build()
*
* @param array $entity_types
*/
function bigmenu_entity_type_build(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['menu']->setFormClass('edit_bigmenu', 'Drupal\bigmenu\MenuFormController');
$entity_types['menu']->setFormClass('edit_bigmenu_slice', 'Drupal\bigmenu\MenuSliceFormController');
}
/**
* Declare admin links and AJAX callbacks
*
* hook_menu()
*/
//function bigmenu_menu() {
// $items['admin/structure/bigmenu-customize/%menu'] = array(
// 'title' => 'Customize menu',
// 'page callback' => 'drupal_get_form',
// 'page arguments' => array('bigmmenu_overview_form', 3),
// 'title callback' => 'menu_overview_title',
// 'title arguments' => array(3),
// 'access arguments' => array('use bigmenu'),
// 'type' => MENU_CALLBACK,
// );
// // Edit just a part of a menu. Arg 5 is the parent menu link id
// $items['admin/structure/bigmenu-customize/%menu/subform/%menau_link'] = array(
// 'title' => 'Edit a slice of a menu',
// 'page callback' => 'drupal_get_form',
// 'page arguments' => array('bigmenu_slice_form', 3, 5),
// 'title callback' => 'bigmenu_parent_title',
// 'title arguments' => array(5),
// 'access arguments' => array('use bigmenu'),
// 'type' => MENU_CALLBACK,
// 'file' => 'bigmenu.admin.inc',
// );
// // Same as above, but triggers an equivalent json response
// // This also expects arg 7,8 to be a form ID and form cache id
// $items['admin/structure/bigmenu-customize/%menu/subform/%menu_link/js'] = array(
// 'page callback' => 'bigmenu_slice_form_js',
// 'page arguments' => array(3, 5),
// 'access arguments' => array('use bigmenu'),
// 'type' => MENU_CALLBACK,
// 'file' => 'bigmenu.admin.inc',
// );
// $items['admin/config/user-interface/bigmenu'] = array(
// 'title' => t('Big Menu Settings'),
// 'page callback' => 'drupal_get_form',
// 'page arguments' => array('bigmenu_settings'),
// 'description' => t('Configure settings for bigmenu module.'),
// 'access arguments' => array('administer bigmenu'),
// 'type' => MENU_NORMAL_ITEM,
// 'file' => 'bigmenu.admin.inc',
// );
//
// return $items;
//}
/**
* Take over core menu admin page
*
* hook_menu_alter()
*
* TODO - should be an admin toggle for this setting
*/
function bigmenu_menu_alter(&$items) {
$items['admin/structure/menu/manage/%menu']['page arguments'] = array('bigmenu_overview_form', 4);
$items['admin/structure/menu/manage/%menu']['file'] = 'bigmenu.admin.inc';
$items['admin/structure/menu/manage/%menu']['file path'] = drupal_get_path('module', 'bigmenu');
}
/**
* Implemenation of hook_theme().
*/
function bigmenu_theme() {
return array(
'bigmenu_overview_form' => array(
'file' => 'bigmenu.admin.inc',
'arguments' => array('form' => NULL),
'render element' => 'form',
),
);
}
/**
* Implements hook_permission().
*/
function bigmenu_permission() {
return array(
'administer bigmenu' => array(
'title' => t('Administer Big Menu'),
'description' => t('Allows configuration of Big Menu'),
),
'use bigmenu' => array(
'title' => t('Use Big Menu'),
'description' => t('Allows the use of Big Menu'),
),
);
}