'admin/content/taxonomy', 'admin_main'=>'admin/content/vocabindex', 'admin_paths'=>'admin/content/vocabindex/paths', 'admin_refresh'=>'admin/content/vocabindex/refresh', 'admin_settings'=>'admin/content/vocabindex/settings', ); return $paths[$path]; } /** *Implementation of hook_perm() */ function vocabindex_perm() { return array('manage vocabulary index pages', 'view vocabulary index pages'); } /** *Implementation of hook_menu() */ function vocabindex_menu() { //The settings page $items[_vocabindex_menu_paths('admin_main')]=array( 'title'=>'Vocabulary index pages', 'description'=>'Create index pages for vocabularies.', 'access arguments'=>array('manage vocabulary index pages'), 'page callback'=>'vocabindex_page_admin_paths', 'file'=>'vocabindex.admin.inc', ); $items[_vocabindex_menu_paths('admin_paths')]=array( 'title'=>'Paths', 'type'=>MENU_DEFAULT_LOCAL_TASK, 'file'=>'vocabindex.admin.inc', ); $items[_vocabindex_menu_paths('admin_settings')]=array( 'title'=>'Settings', 'description'=>'General settings.', 'page callback'=>'drupal_get_form', 'page arguments'=>array('vocabindex_admin'), 'type'=>MENU_LOCAL_TASK, 'file'=>'vocabindex.admin.inc', ); $items[_vocabindex_menu_paths('admin_refresh')]=array( 'title'=>'Refresh', 'description'=>'Refresh all the index pages.', 'page callback'=>'vocabindex_page_admin_refresh', 'type'=>MENU_LOCAL_TASK, 'file'=>'vocabindex.admin.inc', ); $result=db_query("SELECT vi.path, v.name, v.description FROM {vocabindex} vi LEFT JOIN {vocabulary} v ON vi.vid=v.vid"); while($row=db_fetch_object($result)) { //Menu callbacks for every vocabindex page $items[$row->path]=array( 'title'=>$row->name, 'description'=>$row->description, 'access arguments'=>array('view vocabulary index pages'), 'page callback'=>'vocabindex_view_page', 'page arguments'=>array($row->path), 'type'=>MENU_SUGGESTED_ITEM, 'file'=>'vocabindex.view.inc', ); } return $items; } /** *Implementation of hook_theme() */ function vocabindex_theme() { $functions['vocabindex_page']=array( 'template'=>'vocabindex_page', 'arguments'=>array( 'description'=>NULL, 'list'=>NULL, ), ); $functions['vocabindex_list']=array( 'template'=>'vocabindex_list', 'arguments'=>array( 'list_items'=>NULL, 'list_style'=>'threaded', ), ); $functions['vocabindex_list_item']=array( 'template'=>'vocabindex_list_item', 'arguments'=>array( 'url'=>NULL, 'name'=>NULL, 'description'=>NULL, 'zebra'=>NULL, 'children'=>NULL, ), ); return $functions; } /** *Implementation of hook_taxonomy() */ function vocabindex_taxonomy($op, $type, $array=NULL) { //Include necessary files require_once(drupal_get_path('module', 'vocabindex').'/vocabindex.admin.inc'); if($type=='vocabulary') { $vocab=$array; if($op=='update') { //Don't automatically refresh by default, as users won't expect their menu items to disappear. if(variable_get('vocabindex_vocab_auto_refresh', FALSE)) { $path=db_result(db_query("SELECT path FROM {vocabindex} WHERE vid = %d", $vocab['vid'])); vocabindex_create_index($vocab['vid'], $path); } } if($op=='delete') { vocabindex_delete_index(NULL, $vocab['vid']); } menu_rebuild(); } }