| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
| 3 |
* @file |
* @file |
| 4 |
* Enables the use of an Administration Control Panel. |
* Enables the use of graphical Control Panels that can be used for site navigation. |
| 5 |
*/ |
*/ |
| 6 |
|
|
| 7 |
/** |
/** |
| 10 |
function controlpanel_help($section) { |
function controlpanel_help($section) { |
| 11 |
switch ($section) { |
switch ($section) { |
| 12 |
case 'admin/modules#description': |
case 'admin/modules#description': |
| 13 |
return t('Enables the use of an Administration Control Panel.'); |
return t('Enables the use of a graphical Control Panel.'); |
| 14 |
} |
} |
| 15 |
} |
} |
| 16 |
|
|
| 23 |
|
|
| 24 |
if ($may_cache) { |
if ($may_cache) { |
| 25 |
$items[] = array('path' => 'controlpanel', 'title' => t('control panel'), |
$items[] = array('path' => 'controlpanel', 'title' => t('control panel'), |
| 26 |
'callback' => 'controlpanel_admin_controlpanel', |
'callback' => 'controlpanel_build_controlpanel', |
| 27 |
'access' => TRUE); |
'access' => TRUE); |
|
} |
|
|
if ($may_cache) { |
|
| 28 |
// Admin control panel |
// Admin control panel |
| 29 |
$items[] = array('path' => 'admin/controlpanel', |
$items[] = array('path' => 'admin/controlpanel', |
| 30 |
'callback' => 'controlpanel_admin_controlpanel', |
'callback' => 'controlpanel_build_controlpanel', |
| 31 |
'access' => user_access('administer site configuration'), |
'access' => user_access('administer site configuration'), |
| 32 |
'type' => MENU_CALLBACK); |
'type' => MENU_CALLBACK); |
| 33 |
} |
} |
| 35 |
} |
} |
| 36 |
|
|
| 37 |
/** |
/** |
| 38 |
* Menu callback: admin control panel. |
* Menu callback: control panel. |
| 39 |
*/ |
*/ |
| 40 |
function controlpanel_admin_controlpanel() { |
function controlpanel_build_controlpanel() { |
| 41 |
if (file_exists('misc/collapse.js')) { |
if (file_exists('misc/collapse.js') && variable_get('controlpanel_child_collapsable', 1)) { |
| 42 |
drupal_add_js('misc/collapse.js'); |
drupal_add_js('misc/collapse.js'); |
| 43 |
} |
} |
| 44 |
drupal_set_html_head('<style type="text/css">@import url('.drupal_get_path('module','controlpanel').'/controlpanel.css);</style>'); |
drupal_set_html_head('<style type="text/css">@import url('.drupal_get_path('module','controlpanel').'/controlpanel.css);</style>'); |
| 49 |
$mid = $menu['path index'][variable_get('controlpanel_menu_path', 'admin')]; |
$mid = $menu['path index'][variable_get('controlpanel_menu_path', 'admin')]; |
| 50 |
$content .= '<fieldset class="collapsible">'; |
$content .= '<fieldset class="collapsible">'; |
| 51 |
$content .= '<legend>' . $menu['items'][$mid]['title'] . '</legend>'; |
$content .= '<legend>' . $menu['items'][$mid]['title'] . '</legend>'; |
| 52 |
$content .= _controlpanel_build_controlpanel($mid); |
$content .= theme('controlpanel_panel_view', $mid); |
| 53 |
|
|
| 54 |
if (variable_get('controlpanel_build_children', 0) && (variable_get('controlpanel_child_levels', 2) > 1) && ($menu_visible[$mid]['children'])) { |
if (variable_get('controlpanel_build_children', 0) && (variable_get('controlpanel_child_levels', 2) > 1) && ($menu_visible[$mid]['children'])) { |
| 55 |
$content = _controlpanel_build_child_panels($mid, 0, $content); |
$content = theme('controlpanel_child_panel_view', $mid, 0, $content); |
| 56 |
} |
} |
| 57 |
$content .= '</fieldset>'; |
$content .= '</fieldset>'; |
| 58 |
|
|
| 59 |
print theme('page', $content); |
print theme('page', $content); |
| 60 |
} |
} |
| 61 |
|
|
|
function _controlpanel_build_child_panels($mid, $depth, $content){ |
|
|
$menu = menu_get_menu(); |
|
|
$menu_visible = $menu['visible']; |
|
|
if ($depth < variable_get('controlpanel_child_levels', 2)-1) { |
|
|
foreach ($menu_visible[$mid]['children'] as $cid) { |
|
|
if (isset($menu_visible[$cid]) && $menu_visible[$cid]['children']) { |
|
|
$content .= '<fieldset class="collapsible collapsed">'; |
|
|
$content .= '<legend>' . $menu['items'][$cid]['title'] . '</legend>'; |
|
|
$content .= _controlpanel_build_controlpanel($cid); |
|
|
$content = _controlpanel_build_child_panels($cid, $depth + 1, $content); |
|
|
} |
|
|
} |
|
|
} |
|
|
$content .= '</fieldset>'; |
|
|
return $content; |
|
|
} |
|
|
|
|
| 62 |
/** |
/** |
| 63 |
* Build the control panel items |
* Build a control panel |
| 64 |
*/ |
*/ |
| 65 |
function _controlpanel_build_controlpanel($pid) { |
function theme_controlpanel_panel_view($pid) { |
| 66 |
$content = ''; |
$content = ''; |
| 67 |
$menu = menu_get_menu(); |
$menu = menu_get_menu(); |
| 68 |
$menu_visible = $menu['visible']; |
$menu_visible = $menu['visible']; |
|
|
|
| 69 |
$image_directory = variable_get('controlpanel_image_path', 'modules/controlpanel/images'); |
$image_directory = variable_get('controlpanel_image_path', 'modules/controlpanel/images'); |
| 70 |
|
|
| 71 |
$content .= '<div class=control-panel>'; |
$content .= '<div class=control-panel>'; |
| 72 |
if (isset($menu_visible[$pid]) && $menu_visible[$pid]['children']) { |
if (isset($menu_visible[$pid]) && $menu_visible[$pid]['children']) { |
| 73 |
foreach ($menu_visible[$pid]['children'] as $mid) { |
foreach ($menu_visible[$pid]['children'] as $mid) { |
| 74 |
$content .= '<div class=control-panel-item>'; |
$content .= '<div class="control-panel-item control-panel-icon-size-' . variable_get('controlpanel_icon_size', '36x36') . '">'; |
| 75 |
$content .= '<a href=' . $menu_visible[$mid]['path'] . '>'; |
$content .= '<a href=' . $menu_visible[$mid]['path'] . '>'; |
| 76 |
$file_name = $image_directory . '/' . str_replace('/', '_', $menu_visible[$mid]['path']) . '.png'; |
$file_name = $image_directory . '/' . str_replace('/', '_', $menu_visible[$mid]['path']) . '.png'; |
| 77 |
if (file_exists($file_name)) { |
if (file_exists($file_name)) { |
| 93 |
} |
} |
| 94 |
|
|
| 95 |
/** |
/** |
| 96 |
|
* Build child panel(s) |
| 97 |
|
*/ |
| 98 |
|
function theme_controlpanel_child_panel_view($mid, $depth, $content){ |
| 99 |
|
$menu = menu_get_menu(); |
| 100 |
|
$menu_visible = $menu['visible']; |
| 101 |
|
if ($depth < variable_get('controlpanel_child_levels', 2)-1) { |
| 102 |
|
foreach ($menu_visible[$mid]['children'] as $cid) { |
| 103 |
|
if (isset($menu_visible[$cid]) && $menu_visible[$cid]['children']) { |
| 104 |
|
$content .= '<fieldset class="collapsible collapsed">'; |
| 105 |
|
$content .= '<legend>' . $menu['items'][$cid]['title'] . '</legend>'; |
| 106 |
|
$content .= theme('controlpanel_panel_view', $cid); |
| 107 |
|
$content = theme('controlpanel_child_panel_view', $cid, $depth + 1, $content); |
| 108 |
|
} |
| 109 |
|
} |
| 110 |
|
} |
| 111 |
|
$content .= '</fieldset>'; |
| 112 |
|
return $content; |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
/** |
| 116 |
* Implementation of hook_settings(). |
* Implementation of hook_settings(). |
| 117 |
*/ |
*/ |
| 118 |
function controlpanel_settings() { |
function controlpanel_settings() { |
| 119 |
$child_levels = drupal_map_assoc(array(2, 3, 4)); |
$child_levels = drupal_map_assoc(array(2, 3, 4)); |
| 120 |
|
$icon_sizes = drupal_map_assoc(array('24x24', '36x36', '48x48')); |
| 121 |
//$output = form_textfield(t('Path for Control Panel image files'), 'controlpanel_image_path', variable_get('controlpanel_image_path', 'modules/controlpanel/images'), 60, 70, t('This should be the directory where the image icons files for the control panel are stored. If unsure, specify "modules/controlpanel/images".')); |
//$output = form_textfield(t('Path for Control Panel image files'), 'controlpanel_image_path', variable_get('controlpanel_image_path', 'modules/controlpanel/images'), 60, 70, t('This should be the directory where the image icons files for the control panel are stored. If unsure, specify "modules/controlpanel/images".')); |
| 122 |
$output = form_textfield(t('Control Panel menu path'), 'controlpanel_menu_path', variable_get('controlpanel_menu_path', 'admin'), 60, 70, t('Enter the path of the menu structure you want displayed in the Control Panel.')); |
$output = form_textfield(t('Control Panel menu path'), 'controlpanel_menu_path', variable_get('controlpanel_menu_path', 'admin'), 60, 70, t('Enter the path of the menu structure you want displayed in the Control Panel.')); |
| 123 |
|
$output .= form_select(t('Icon size'), 'controlpanel_icon_size', variable_get('controlpanel_icon_size', '36x36'), $icon_sizes, t('Select the size of the control panel icons.')); |
| 124 |
$group = form_item(t('Build Child Menu Panels'), form_checkbox(t('Enabled'), 'controlpanel_build_children', 1, variable_get('controlpanel_build_children', 0)), t('Check this box to recursively build child panels.')); |
$group = form_item(t('Build Child Menu Panels'), form_checkbox(t('Enabled'), 'controlpanel_build_children', 1, variable_get('controlpanel_build_children', 0)), t('Check this box to recursively build child panels.')); |
| 125 |
$group .= form_select(t('Number of levels'), 'controlpanel_child_levels', variable_get('controlpanel_child_levels', 2), $child_levels, t('Select how many control panel levels to build.')); |
$group .= form_select(t('Number of levels'), 'controlpanel_child_levels', variable_get('controlpanel_child_levels', 2), $child_levels, t('Select how many control panel levels to build.')); |
| 126 |
|
if (file_exists('misc/collapse.js')) { |
| 127 |
|
$group .= form_item(t('Make child panels collapsable'), form_checkbox(t('Enabled'), 'controlpanel_child_collapsable', 1, variable_get('controlpanel_child_collapsable', 1))); |
| 128 |
|
} |
| 129 |
$output .= form_group(t('Child Panels'), $group); |
$output .= form_group(t('Child Panels'), $group); |
| 130 |
|
|
| 131 |
return $output; |
return $output; |