diff -urp Download/automaticmenu/automaticmenu.info /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/automaticmenu/automaticmenu.info --- Download/automaticmenu/automaticmenu.info 2008-06-18 14:01:08.000000000 +0200 +++ /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/automaticmenu/automaticmenu.info 2009-08-28 09:55:35.000000000 +0200 @@ -1,10 +1,10 @@ ; $Id: automaticmenu.info,v 1.1 2008/06/18 00:18:09 lupusstudios Exp $ name = AutomaticMenu description = Automatically create menu items for new content. -version = VERSION package = AutomaticMenu ; Information added by drupal.org packaging script on 2008-06-18 version = "5.x-1.x-dev" project = "automaticmenu" datestamp = "1213790468" +core = 6.x diff -urp Download/automaticmenu/automaticmenu.module /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/automaticmenu/automaticmenu.module --- Download/automaticmenu/automaticmenu.module 2008-06-18 02:18:09.000000000 +0200 +++ /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/automaticmenu/automaticmenu.module 2009-08-28 13:59:02.000000000 +0200 @@ -13,19 +13,18 @@ /** * Implementation of hook_menu(). */ -function automaticmenu_menu($may_cache) { +function automaticmenu_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/automaticmenu', - 'title' => t('AutomaticMenu'), - 'description' => t('Configure automatic menu creation for new content.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => 'automaticmenu_settings', - 'access' => user_access('administer automaticmenu'), - 'type' => MENU_NORMAL_ITEM, - ); - } + + $items['admin/build/automaticmenu'] = array( + 'title' => 'AutomaticMenu', + 'description' => 'Configure automatic menu creation for new content.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('automaticmenu_settings'), + 'access arguments' => array('administer automaticmenu'), + 'type' => MENU_NORMAL_ITEM, + ); + return $items; } @@ -39,8 +38,8 @@ function automaticmenu_perm() { /** * Implementation of hook_help(). */ -function automaticmenu_help($section = 'admin/help#automenu') { - switch ($section) { +function automaticmenu_help($path, $arg) { + switch ($path) { case 'admin/help#automaticmenu': case 'admin/settings/modules#automaticmenu': $output = t('AutomaticMenu.'); @@ -60,7 +59,7 @@ function automaticmenu_settings() { '#title' => t('AutomaticMenu Settings'), '#collapsible' => FALSE, ); - + $form['automenu']['automenu_enabled'] = array( '#type' => 'checkbox', '#title' => t('Enable AutomaticMenu'), @@ -74,13 +73,13 @@ function automaticmenu_settings() { '#default_value' => variable_get('automenu_notice', true), '#description' => t('Display on-screen messages when AutomaticMenu items are created.'), ); - + $form['automenu']['types'] = array( '#type' => 'fieldset', '#title' => t('Content Types'), '#collapsible' => FALSE, ); - + $form['automenu']['types']['intro'] = array( '#type' => 'item', '#description' => t('Use the table below to enable AutomaticMenu for individual content types and to select the parent item under which the new menu item will be created.'), @@ -91,54 +90,152 @@ function automaticmenu_settings() { '#value' => '', ); - - $menu_list = menu_parent_options(0); + if (module_exists('i18n')) { + i18n_selection_mode ('off'); + } + $menu_list = menu_parent_options(menu_get_menus(), array('mlid' => 0)); + if (module_exists('i18n')) { + i18n_selection_mode ('reset'); + } + + if (module_exists('locale')) { + $languages = array('' => t('Language neutral')) + locale_language_list('name'); + } + else { + $languages = array(); + } $node_type_list = node_get_types(); foreach ($node_type_list as $key => $item) { - $form['automenu']['types']['automenu_type_enabled_'. $key] = array( - '#type' => 'checkbox', - '#title' => $key, - '#default_value' => variable_get('automenu_type_enabled_'. $key, false), - '#prefix' => "", - ); - - $form['automenu']['types']['automenu_type_parent_'. $key] = array( - '#type' => 'select', - '#options' => $menu_list, - '#default_value' => variable_get('automenu_type_parent_'. $key, 0), - '#prefix' => "", - ); - - $form['automenu']['types']['automenu_type_weight_'. $key] = array( - '#type' => 'weight', - '#default_value' => variable_get('automenu_type_weight_'. $key, 0), - '#prefix' => "", - ); - - $form['automenu']['types']['automenu_type_tree_'. $key] = array( - '#type' => 'checkbox', - '#default_value' => variable_get('automenu_type_tree_'. $key, true), - '#prefix' => "", - ); - - $form['automenu']['types']['automenu_type_bread_'. $key] = array( - '#type' => 'checkbox', - '#default_value' => variable_get('automenu_type_bread_'. $key, true), - '#prefix' => "", - ); + if (variable_get('language_content_type_'. $key, 0) && count($languages)) { + foreach ($languages as $lang_code => $lang_name) { + if (!empty($lang_code)) { + // language + $form['automenu']['types']['automenu_type_enabled_'. $key .'_'. $lang_code] = array( + '#type' => 'checkbox', + '#title' => $key .'_'. $lang_code, + '#default_value' => variable_get('automenu_type_enabled_'. $key .'_'. $lang_code, false), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_parent_'. $key .'_'. $lang_code] = array( + '#type' => 'select', + '#options' => $menu_list, + '#default_value' => variable_get('automenu_type_parent_'. $key .'_'. $lang_code, 0), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_weight_'. $key .'_'. $lang_code] = array( + '#type' => 'weight', + '#default_value' => variable_get('automenu_type_weight_'. $key .'_'. $lang_code, 0), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_tree_'. $key .'_'. $lang_code] = array( + '#type' => 'checkbox', + '#default_value' => variable_get('automenu_type_tree_'. $key .'_'. $lang_code, true), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_bread_'. $key .'_'. $lang_code] = array( + '#type' => 'checkbox', + '#default_value' => variable_get('automenu_type_bread_'. $key .'_'. $lang_code, true), + '#prefix' => "", + ); + } + else { + // Language neutral + $form['automenu']['types']['automenu_type_enabled_'. $key .'_'. $lang_code] = array( + '#type' => 'checkbox', + '#title' => $key .'_'. $lang_code, + '#default_value' => variable_get('automenu_type_enabled_'. $key .'_'. $lang_code, false), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_parent_'. $key .'_'. $lang_code] = array( + '#type' => 'select', + '#options' => $menu_list, + '#default_value' => variable_get('automenu_type_parent_'. $key .'_'. $lang_code, 0), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_weight_'. $key .'_'. $lang_code] = array( + '#type' => 'weight', + '#default_value' => variable_get('automenu_type_weight_'. $key .'_'. $lang_code, 0), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_tree_'. $key .'_'. $lang_code] = array( + '#type' => 'checkbox', + '#default_value' => variable_get('automenu_type_tree_'. $key .'_'. $lang_code, true), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_bread_'. $key .'_'. $lang_code] = array( + '#type' => 'checkbox', + '#default_value' => variable_get('automenu_type_bread_'. $key .'_'. $lang_code, true), + '#prefix' => "", + ); + } + } + } + else { + // no multilanguage options + $form['automenu']['types']['automenu_type_enabled_'. $key] = array( + '#type' => 'checkbox', + '#title' => $key, + '#default_value' => variable_get('automenu_type_enabled_'. $key, false), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_parent_'. $key] = array( + '#type' => 'select', + '#options' => $menu_list, + '#default_value' => variable_get('automenu_type_parent_'. $key, 0), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_weight_'. $key] = array( + '#type' => 'weight', + '#default_value' => variable_get('automenu_type_weight_'. $key, 0), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_tree_'. $key] = array( + '#type' => 'checkbox', + '#default_value' => variable_get('automenu_type_tree_'. $key, true), + '#prefix' => "", + ); + + $form['automenu']['types']['automenu_type_bread_'. $key] = array( + '#type' => 'checkbox', + '#default_value' => variable_get('automenu_type_bread_'. $key, true), + '#prefix' => "", + ); + + } } $form['automenu']['types']['closetable'] = array( '#type' => 'markup', '#value' => '
'. t('Content Type') .''. t('Parent Menu') .''. t('Weight') .''. t('In Menu Tree') .''. t('In Bread Crumb') .'
", - '#suffix' => "", - '#suffix' => "", - '#suffix' => "", - '#suffix' => "", - '#suffix' => "
", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "
", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "
", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "", + '#suffix' => "
', ); - + return system_settings_form($form); } @@ -146,36 +243,87 @@ function automaticmenu_settings() { // Hook into drupal's node api function automaticmenu_nodeapi(&$node, $op, $arg) { + $new_menu = array(); + // If AutoMenu is enabled, and is enabled for this node type - if (variable_get('automenu_enabled', false) && variable_get('automenu_type_enabled_'. $node->type, false)) { + if (variable_get('automenu_enabled', false)) { switch ($op) { // If we're doing a node insert operation case 'insert': // Change display properties of menu item based on advanced preferences - $menu_type = 112; - if (variable_get('automenu_type_tree_'. $node->type, true)) - $menu_type = $menu_type + 2; - if (variable_get('automenu_type_bread_'. $node->type, true)) - $menu_type = $menu_type + 4; - - // Build new menu item - $new_menu = array( - 'pid' => variable_get('automenu_type_parent_'. $node->type, 0), - 'path' => 'node/'. $node->nid, - 'title' => $node->title, - 'weight' => variable_get('automenu_type_weight_'. $node->type, 0), - 'type' => $menu_type, - ); - - // Tell Drupal we're chaning the menus - menu_rebuild(); - // Save the new menu item - menu_save_item($new_menu); - // Call a menu rebuild - _menu_build(); - // Send notification if it's enabled - if (variable_get('automenu_notice', true)) { - drupal_set_message(t('AutomaticMenu Item Added')); + if (variable_get('language_content_type_'. $node->type, 0)) { + if (variable_get('automenu_type_enabled_'. $node->type .'_'. $node->language, false)) { + // language specific + // Build new menu item + $menu = explode(':', variable_get('automenu_type_parent_'. $node->type .'_'. $node->language, 0)); + $new_menu = array( + 'plid' => $menu[1], + 'link_path' => 'node/'. $node->nid, + 'link_title' => $node->title, + 'weight' => variable_get('automenu_type_weight_'. $node->type .'_'. $node->language, 0), + 'router_path' => 'node/%', + 'expanded' => false, + 'menu_name' => $menu[0], + 'options' => array ( + 'attributes' => array ( + 'title' => $node->title + ), + 'langcode' => $node->language + ) + ); + } + else if (variable_get('automenu_type_enabled_'. $node->type .'_', false)) { + // Build new menu item + $menu = explode(':', variable_get('automenu_type_parent_'. $node->type .'_', 0)); + $new_menu = array( + 'plid' => $menu[1], + 'link_path' => 'node/'. $node->nid, + 'link_title' => $node->title, + 'weight' => variable_get('automenu_type_weight_'. $node->type .'_', 0), + 'router_path' => 'node/%', + 'expanded' => false, + 'menu_name' => $menu[0], + 'options' => array ( + 'attributes' => array ( + 'title' => $node->title + ), + 'langcode' => $node->language + ) + ); + } + } + else { + if (variable_get('automenu_type_enabled_'. $node->type, false)) { + // Build new menu item + $menu = explode(':', variable_get('automenu_type_parent_'. $node->type, 0)); + $new_menu = array( + 'plid' => $menu[1], + 'link_path' => 'node/'. $node->nid, + 'link_title' => $node->title, + 'weight' => variable_get('automenu_type_weight_'. $node->type, 0), + 'router_path' => 'node/%', + 'expanded' => false, + 'menu_name' => $menu[0], + 'options' => array ( + 'attributes' => array ( + 'title' => $node->title + ), + 'langcode' => $node->language + ) + ); + } + } + + if (!empty($new_menu)) { + // Save the new menu item + menu_link_save ($new_menu); + + // Rebuild menu + menu_rebuild(); + // Send notification if it's enabled + if (variable_get('automenu_notice', true)) { + drupal_set_message(t('AutomaticMenu Item Added')); + } } break; } Only in /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/automaticmenu/: .svn