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

Contents of /contributions/modules/dapi/dapi.module

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


Revision 1.1 - (show annotations) (download) (as text)
Fri Aug 24 16:37:08 2007 UTC (2 years, 3 months ago) by rooey
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
File MIME type: text/x-php
Initial check-in.

Fully functional with dapi_loadicons and dapi_seticons hooks
1 <?php
2 /* $Id$ */
3
4 // if we include this here will the dependant modules still need it??
5 //include_once('includes/dapicommon.inc.php');
6
7 /**
8 * Display help and module information
9 * @param section which section of the site we're displaying help
10 * @return help text for section
11 */
12 function dapi_help($section='') {
13
14 $output = '';
15
16 switch ($section) {
17 case "admin/help#dapi":
18 $output = '<p>'. t("Druapl API + - An extension to drupal's API providing additional hooks."). '</p>';
19 break;
20 }
21
22 return $output;
23 } // function dapi_help
24
25
26 function dapi_perms() {
27
28 return array('access dapi applications panel', 'administer dapi');
29
30 } // function dapi_dapi
31
32
33 function dapi_block($op='list', $delta=0) {
34 // listing of blocks, such as on the admin/block page
35 if ($op == "list") {
36 $block[0]["info"] = t("eServGlobal");
37 return $block;
38 } else if ($op == 'view') {
39 // our block content
40 // content variable that will be returned for display
41 $block_content = '';
42 $block_content .=
43 "<div class=\"more-link\">".
44 l(
45 t("more"),
46 "dapi",
47 array(
48 "title" => t("More eServGlobal information.")
49 )
50 )."</div>";
51
52 // set up the block
53 $block['subject'] = 'eServGlobal';
54 $block['content'] = $block_content;
55 return $block;
56 }
57 } // function dapi_block
58
59
60 function dapi_menu() {
61
62 $items = array();
63
64 // Administration Options
65 $items[] = array(
66 'path' => 'admin/settings/dapi',
67 'title' => t('Drupalicons settings'),
68 'callback' => 'drupal_get_form',
69 'callback arguments' => 'dapi_admin',
70 'access' => user_access('administer dapi'),
71 'description' => ('Configure the Equipment & Resource Management tool'),
72 'type' => MENU_NORMAL_ITEM,
73 );
74
75 // User-level Menus
76 $items[] = array(
77 'path' => 'dapi',
78 'title' => t('Applications'),
79 'callback' => 'dapi_all',
80 'access' => user_access('access dapi applications panel'),
81 'type' => MENU_NORMAL_ITEM
82 );
83
84 return $items;
85 } // function dapi_menu
86
87
88 function dapi_admin() {
89
90 $form ['dapi_main'] = array(
91 '#type' => 'fieldset',
92 '#title' => 'Display configuration',
93 '#collapsible' => TRUE,
94 '#collapsed' => FALSE
95 );
96 $form['dapi_main']['dapi_view_split'] = array(
97 '#type' => 'checkbox',
98 '#title' => t('Display by group'),
99 '#default_value' => variable_get('dapi_view_split', FALSE),
100 '#description' => t("Tick this option to split the icon view into groups.")
101 );
102
103 return system_settings_form($form);
104 } //function dapi_admin
105
106
107 function dapi_all() {
108 $splitview = variable_get('dapi_view_split', FALSE);
109 $page_content = dapi_loadicons($module = NULL, $splitview);
110 print theme('page', $page_content);
111 }
112
113 function dapi_loadicons($module = NULL, $splitview) {
114 drupal_add_css(drupal_get_path('module', 'dapi') .'/dapi.css', 'module');
115
116 $page_content = '';
117
118 $icons = module_invoke_all('dapi_seticons');
119
120 $i=0;
121
122 usort($icons, 'dapi_arraysort');
123
124 // are we looking for module-specific icons
125
126 if ($module != NULL) {
127
128 // check to see if this icon is part of the module we are looking for
129 $newarr = array();
130 $i = 0;
131
132 while ($icons[$i]) {
133 if ($icons[$i]['module'] == $module) $newarr[] = $icons[$i];
134 $i++;
135 }
136 $icons = $newarr;
137 }
138
139 // remove any hidden icons
140 $newarr = array();
141 $i = 0;
142 while ($icons[$i]) {
143 if ((!((array_key_exists('attributes', $icons[$i])) && (in_array('hidden', $icons[$i]['attributes']))) || $module == $icons[$i]['module'])) $newarr[] = $icons[$i];
144 $i++;
145 }
146 $icons = $newarr;
147
148 //msg_r($icons);
149
150 $i = 0;
151
152 $page_content .= ('<div class="dapi-block">');
153 while ($icons[$i]) {
154 if ($icons[$i]['access'] == 1) {
155 if ($splitview == TRUE) {
156 if ($icons[$i]['group'] != $icons[$i -1]['group']) $page_content .= ('<div class="dapi-header">'.$icons[$i]['group'].'</div>');
157 }
158 $page_content .= ('<div class="dapi-icon" title="'.$icons[$i]['description'].'"><center><a href="'.$icons[$i]['path'].'">
159 <img src="'.$icons[$i]['icon'].'"><br>'.$icons[$i]['title'].'</a></center></div>');
160 if ($splitview == TRUE ) {
161 if ($icons[$i]['group'] != $icons[$i +1]['group']) $page_content .= ('<div class="dapi-newline"></div>');
162 }
163 }
164 $i++;
165 }
166 $page_content .= ('</div>');
167
168 return $page_content;
169 } // function dapi_loadicons
170
171 function dapi_arraysort($arr1, $arr2) {
172 $data = strcmp($arr1['group'],$arr2['group']);
173 if ($data == 0) $data = strcmp($arr1['title'],$arr2['title']);
174 return $data;
175 }
176
177 function dapi_form() {
178 global $user;
179 $form['dapi'] = array(
180 '#type' => 'fieldset',
181 '#collapsible' => FALSE,
182 '#collapsed' => FALSE
183 );
184
185 $form['dapi']['welcome-note'] = array(
186 '#value' => '<p>Hello '.$user->name.', welcome to eServGlobal Remote Access Services.</p>'
187 );
188
189 $form['dapi']['information-note'] = array(
190 '#value' => variable_get('dapi_ras_information','')
191 );
192
193 return $form;
194 } // function dapi_form;

  ViewVC Help
Powered by ViewVC 1.1.2