/[drupal]/contributions/modules/vocabindex/vocabindex.module
ViewVC logotype

Contents of /contributions/modules/vocabindex/vocabindex.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Fri Jan 11 15:43:15 2008 UTC (22 months, 2 weeks ago) by xano
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +130 -138 lines
File MIME type: text/x-php
*** empty log message ***
1 <?php
2 /* $Id$ */
3
4 /**
5 *Define all menu paths in one central place. This makes it easier to change the paths without having to search the entire code.
6 */
7 function _vocabindex_menu_paths($path)
8 {
9 $paths=array(
10 'taxonomy'=>'admin/content/taxonomy',
11 'admin_main'=>'admin/content/vocabindex',
12 'admin_paths'=>'admin/content/vocabindex/paths',
13 'admin_refresh'=>'admin/content/vocabindex/refresh',
14 'admin_settings'=>'admin/content/vocabindex/settings',
15 );
16
17 return $paths[$path];
18 }
19
20 /**
21 *Implementation of hook_perm()
22 */
23 function vocabindex_perm()
24 {
25 return array('manage vocabulary index pages', 'view vocabulary index pages');
26 }
27
28 /**
29 *Implementation of hook_menu()
30 */
31 function vocabindex_menu()
32 {
33 //The settings page
34 $items[_vocabindex_menu_paths('admin_main')]=array(
35 'title'=>'Vocabulary index pages',
36 'description'=>'Create index pages for vocabularies.',
37 'access arguments'=>array('manage vocabulary index pages'),
38 'page callback'=>'vocabindex_page_admin_paths',
39 'file'=>'vocabindex.admin.inc',
40 );
41
42 $items[_vocabindex_menu_paths('admin_paths')]=array(
43 'title'=>'Paths',
44 'type'=>MENU_DEFAULT_LOCAL_TASK,
45 'file'=>'vocabindex.admin.inc',
46 );
47
48 $items[_vocabindex_menu_paths('admin_settings')]=array(
49 'title'=>'Settings',
50 'description'=>'General settings.',
51 'page callback'=>'drupal_get_form',
52 'page arguments'=>array('vocabindex_admin'),
53 'type'=>MENU_LOCAL_TASK,
54 'file'=>'vocabindex.admin.inc',
55 );
56
57 $items[_vocabindex_menu_paths('admin_refresh')]=array(
58 'title'=>'Refresh',
59 'description'=>'Refresh all the index pages.',
60 'page callback'=>'vocabindex_page_admin_refresh',
61 'type'=>MENU_LOCAL_TASK,
62 'file'=>'vocabindex.admin.inc',
63 );
64
65 $result=db_query("SELECT vi.path, v.name, v.description FROM {vocabindex} vi LEFT JOIN {vocabulary} v ON vi.vid=v.vid");
66 while($row=db_fetch_object($result))
67 {
68 //Menu callbacks for every vocabindex page
69 $items[$row->path]=array(
70 'title'=>$row->name,
71 'description'=>$row->description,
72 'access arguments'=>array('view vocabulary index pages'),
73 'page callback'=>'vocabindex_view_page',
74 'page arguments'=>array($row->path),
75 'type'=>MENU_SUGGESTED_ITEM,
76 'file'=>'vocabindex.view.inc',
77 );
78 }
79
80 return $items;
81 }
82
83 /**
84 *Implementation of hook_theme()
85 */
86 function vocabindex_theme()
87 {
88 $functions['vocabindex_page']=array(
89 'template'=>'vocabindex_page',
90 'arguments'=>array(
91 'description'=>NULL,
92 'list'=>NULL,
93 ),
94 );
95
96 $functions['vocabindex_list']=array(
97 'template'=>'vocabindex_list',
98 'arguments'=>array(
99 'list_items'=>NULL,
100 'list_style'=>'threaded',
101 ),
102 );
103
104 $functions['vocabindex_list_item']=array(
105 'template'=>'vocabindex_list_item',
106 'arguments'=>array(
107 'url'=>NULL,
108 'name'=>NULL,
109 'description'=>NULL,
110 'zebra'=>NULL,
111 'children'=>NULL,
112 ),
113 );
114
115 return $functions;
116 }
117
118 /**
119 *Implementation of hook_taxonomy()
120 */
121 function vocabindex_taxonomy($op, $type, $array=NULL)
122 {
123 //Include necessary files
124 require_once(drupal_get_path('module', 'vocabindex').'/vocabindex.admin.inc');
125
126 if($type=='vocabulary')
127 {
128 $vocab=$array;
129
130 if($op=='update')
131 {
132 //Don't automatically refresh by default, as users won't expect their menu items to disappear.
133 if(variable_get('vocabindex_vocab_auto_refresh', FALSE))
134 {
135 $path=db_result(db_query("SELECT path FROM {vocabindex} WHERE vid = %d", $vocab['vid']));
136 vocabindex_create_index($vocab['vid'], $path);
137 }
138 }
139 if($op=='delete')
140 {
141 vocabindex_delete_index(NULL, $vocab['vid']);
142 }
143
144 menu_rebuild();
145 }
146 }

  ViewVC Help
Powered by ViewVC 1.1.2