You are here

menu_editor.module in Menu Editor 6.3

Same filename and directory in other branches
  1. 6 menu_editor.module
  2. 6.2 menu_editor.module
  3. 7 menu_editor.module

File

menu_editor.module
View source
<?php

/**
 * Implementation of hook_menu().
 */
function menu_editor_menu() {
  $items['admin/build/menu-customize/%menu/poweredit'] = array(
    'title' => 'Power Edit',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'menu_editor_overview_form',
      3,
    ),
    // 'title callback' => 'menu_editor_overview_title',
    // 'title arguments' => array(3),
    'access callback' => 'menu_editor_form_access',
    'access arguments' => array(
      3,
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'menu_editor.admin.inc',
  );
  return $items;
}
function menu_editor_perm() {
  $result = db_query("SELECT menu_name FROM {menu_custom} ORDER BY title");
  $perm = array();
  while ($menu = db_fetch_array($result)) {
    $perm[] = "menu edit {$menu['menu_name']}";
  }
  return $perm;
}
function menu_editor_form_access($menu) {
  return user_access('administer menus') || user_access("menu edit {$menu['menu_name']}");
}
function menu_editor_admin_menu() {
  $result = db_query("SELECT * FROM {menu_custom} ORDER BY title");
  $items = array();
  while ($menu = db_fetch_array($result)) {
    $items[] = array(
      'title' => $menu['title'],
      'path' => 'admin/build/menu-customize/' . $menu['menu_name'] . '/poweredit',
      'parent_path' => 'admin/build/menu/list',
      'weight' => 100,
    );
  }
  return $items;
}

/**
 * Implemenation of hook_theme().
 */
function menu_editor_theme() {
  return array(
    'menu_editor_overview_form' => array(
      'file' => 'menu_editor.admin.inc',
      'arguments' => array(
        'form' => NULL,
      ),
    ),
  );
}

/**
 * Title callback for the menu overview page and links.
 */
function menu_editor_overview_title($menu) {
  return $menu['title'];
}
function menu_editor_get_placeholders($menu) {
  static $placeholders = array();
  if (!isset($placeholders[$menu['menu_name']])) {
    $placeholders[$menu['menu_name']] = module_invoke_all('menu_editor_placeholders', $menu);
  }
  return $placeholders[$menu['menu_name']];
}
function menu_editor_module_implements_class($hook, $sort = FALSE, $refresh = FALSE) {
  static $implementations;
  if ($refresh) {
    $implementations = array();
    return;
  }
  if (!isset($implementations[$hook])) {
    $implementations[$hook] = array();
    $list = module_list(FALSE, TRUE, $sort);
    foreach ($list as $module) {
      $classname = $module . '_class_' . $hook;
      if (class_exists($classname)) {
        $implementations[$hook][$module] = $classname;
      }
    }
  }

  // The explicit cast forces a copy to be made. This is needed because
  // $implementations[$hook] is only a reference to an element of
  // $implementations and if there are nested foreaches (due to nested node
  // API calls, for example), they would both manipulate the same array's
  // references, which causes some modules' hooks not to be called.
  // See also http://www.zend.com/zend/art/ref-count.php.
  return (array) $implementations[$hook];
}