/[drupal]/contributions/modules/storm/storm.theme.inc
ViewVC logotype

Contents of /contributions/modules/storm/storm.theme.inc

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


Revision 1.12 - (show annotations) (download) (as text)
Tue Sep 8 11:38:47 2009 UTC (2 months, 2 weeks ago) by magnity
Branch: MAIN
Changes since 1.11: +2 -2 lines
File MIME type: text/x-php
Task #510742 by Magnity: Port to Drupal 7
1 <?php
2 // $Id: storm.theme.inc,v 1.11 2009/09/04 09:41:59 magnity Exp $
3
4 /**
5 * @file
6 * Provides theme functions for Storm modules
7 */
8
9 /**
10 * @function
11 * Theme function to create the Storm Dashboard
12 */
13 // See 498108: Proposed to refactor creation of Storm Dashboard
14 function theme_storm_dashboard() {
15 $o = '<div id="stormdashboard">';
16 $o .= '<dl class="stormdashboard">';
17
18 $o .= '<div class="stormdashboard">';
19 $o .= theme('storm_link', '', 'stormorganization');
20 $o .= theme('storm_link', '', 'stormperson');
21 $o .= theme('storm_link', '', 'stormteammember');
22 $o .= theme('storm_link', '', 'stormproject');
23 $o .= theme('storm_link', '', 'stormtask');
24 $o .= theme('storm_link', '', 'stormticket');
25 $o .= theme('storm_link', '', 'stormtimetracking');
26 $o .= '</div>';
27
28 $o .= '<div class="stormdashboard">';
29 $o .= theme('storm_link', '', 'stormnote');
30 $o .= theme('storm_link', '', 'storminvoice');
31 $o .= theme('storm_link', '', 'stormexpense');
32 $o .= theme('storm_link', '', 'stormknowledgebase');
33 $o .= theme('storm_link', '', 'stormattribute');
34 $o .= theme('storm_link', '', 'stormconfiguration');
35
36 $o .= '</div>';
37 $o .= '</dl>';
38 $o .= '</div>';
39 return $o;
40 }
41
42 function theme_storm_form_group($form) {
43 drupal_add_css(drupal_get_path('module', 'storm') .'/storm.css', 'module');
44
45 $row = array();
46 foreach (element_children($form) as $key) {
47 array_push($row, drupal_render($form[$key]));
48 }
49 $rows[] = array('data' => $row, 'class' => 'formgroup');
50 $output = theme('table', array(), $rows, array('class' => 'formgroup'));
51 return $output;
52 }
53
54 function theme_datetime($element) {
55 return theme('form_element', $element, '<div class="container-inline">'. $element['#children'] .'</div>');
56 }
57
58 function theme_dateext($element) {
59 return theme('form_element', $element, '<div class="container-inline">'. $element['#children'] .'</div>');
60 }
61
62 function theme_storm_list_report($header, $rows, $title, $footer) {
63 $css_all_file = drupal_get_path('module', 'storm') .'/storm_list_report_all.css';
64 $css_print_file = drupal_get_path('module', 'storm') .'/storm_list_report_print.css';
65 $query_string = '?'. drupal_substr(variable_get('css_js_query_string', '0'), 0, 1);
66
67 $o = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
68 $o .= '<html xmlns="http://www.w3.org/1999/xhtml">';
69 $o .= '<head>';
70 $o .= '<title>'. (drupal_get_title() ? strip_tags(drupal_get_title()) : variable_get('site_name', 'Drupal')) .'</title>';
71 $o .= '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . $css_all_file . $query_string .'" />';
72 $o .= '<link type="text/css" rel="stylesheet" media="print" href="'. base_path() . $css_print_file . $query_string .'" />';
73 $o .= '</head>';
74 $o .= '<body>';
75 $o .= '<table class="storm_report_header"><tr>';
76 $o .= '<td class="storm_report_myorganization">';
77 $o .= '<div class="site_name">'. variable_get('site_name', '') .'</div>';
78 $o .= '<div class="site_slogan">'. variable_get('site_slogan', '') .'</div>';
79 $o .= '</td>'; $o .= '<td class="storm_report_header">'. variable_get('storm_report_header', '') .'</td>';
80 $o .= '</tr></table>';
81 $o .= '<div class="storm_list_report_title">'. $title .'</div>';
82 $o .= '<div class="storm_list_report_data">';
83 $o .= theme('table', $header, $rows);
84 $o .= '</div>';
85 $o .= '<div class="storm_list_report_footer">'. $footer .'</div>';
86 $o .= '</body>';
87 $o .= '</html>';
88
89 return $o;
90 }
91
92 function theme_storm_report($header, $content, $title, $footer, $headtitle='') {
93 $css_all_file = drupal_get_path('module', 'storm') .'/storm_report_all.css';
94 $css_print_file = drupal_get_path('module', 'storm') .'/storm_report_print.css';
95 $query_string = '?'. drupal_substr(variable_get('css_js_query_string', '0'), 0, 1);
96
97 $o = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
98 $o .= '<html xmlns="http://www.w3.org/1999/xhtml">';
99 $o .= '<head>';
100 $o .= '<title>'. ($headtitle ? strip_tags($headtitle) : $title) .'</title>';
101 $o .= '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . $css_all_file . $query_string .'" />';
102 $o .= '<link type="text/css" rel="stylesheet" media="print" href="'. base_path() . $css_print_file . $query_string .'" />';
103 $o .= '</head>';
104 $o .= '<body>';
105 $o .= '<table class="storm_report_header"><tr>';
106 $myorg = node_load(variable_get('storm_organization_nid'));
107 $o .= '<td class="storm_report_myorganization">';
108 $o .= '<div class="site_name">'. variable_get('site_name', '') .'</div>';
109 $o .= '<div class="site_slogan">'. variable_get('site_slogan', '') .'</div>';
110 $o .= '</td>';
111 $o .= '<td class="storm_report_header">'. variable_get('storm_report_header', '') .'</td>';
112 $o .= '</tr></table>';
113 $o .= '<div class="storm_report_title">'. $title .'</div>';
114 $o .= '<div id="storm_report_content">';
115 $o .= $content;
116 $o .= '</div>';
117 $o .= '<div class="storm_report_footer">'. $footer .'</div>';
118 $o .= '</body>';
119 $o .= '</html>';
120
121 return $o;
122 }
123
124 function theme_storm_view_item($label, $value) {
125 $o = '<div class="label"><span class="label">'. t($label) .' : </span></div><div class="value">'. $value .'</div>';
126 return $o;
127 }
128
129 function theme_storm_link($source_module='', $destination_module='', $node_nid=0, $weight=0) {
130 switch ($source_module) {
131
132 case "stormorganization":
133 $params_key = 'organization_nid';
134 break;
135
136 case "stormproject":
137 $params_key = 'project_nid';
138 break;
139
140 case "stormtask":
141 $params_key = 'task_nid';
142 break;
143
144 case "stormticket":
145 $params_key = 'ticket_nid';
146 break;
147 }
148
149 switch ($destination_module) {
150 case "stormattribute":
151 $user_access_check = 'Storm attribute: access';
152 $list_text = 'Attributes';
153 $list_path = 'storm/attributes/';
154 $add_icon_type = 'stormattribute';
155 $add_path = 'storm/attributes/add';
156 $dt_id = 'stormattributes';
157 break;
158
159 case "stormconfiguration":
160 $user_access_check = 'access administration pages';
161 $list_text = 'Configuration';
162 $list_path = 'admin/storm';
163 $add_icon_type = '';
164 $add_path = '';
165 $dt_id = 'stormconfiguration';
166 break;
167
168 case "stormexpense":
169 $user_access_check = 'Storm expense: access';
170 $list_text = 'Expenses';
171 $list_path = 'storm/expenses/';
172 $add_icon_type = 'stormexpense';
173 $add_path = 'node/add/'. $destination_module;
174 $dt_id = 'stormexpenses';
175 break;
176
177 case "storminvoice":
178 $user_access_check = 'Storm invoice: access';
179 $list_text = 'Invoices';
180 $list_path = 'storm/invoices/';
181 $add_icon_type = 'storminvoice';
182 $add_path = 'node/add/'. $destination_module;
183 $dt_id = 'storminvoices';
184 break;
185
186 case "stormknowledgebase":
187 $user_access_check = 'Storm knowledgebase: access';
188 $list_text = 'Knowledge base';
189 $list_path = 'storm/knowledgebase/';
190 $add_icon_type = 'stormknowledgebase';
191 $add_path = 'node/add/'. $destination_module;
192 $dt_id = 'stormknowledgebase';
193 break;
194
195 case "stormnote":
196 $user_access_check = 'Storm note: access';
197 $list_text = 'Notes';
198 $list_path = 'storm/notes/';
199 $add_icon_type = 'stormnote';
200 $add_path = 'node/add/'. $destination_module;
201 $dt_id = 'stormnotes';
202 break;
203
204 case "stormorganization":
205 $user_access_check = 'Storm organization: access';
206 $list_text = 'Organizations';
207 $list_path = 'storm/organizations/';
208 $add_icon_type = 'stormorganization';
209 $add_path = 'node/add/'. $destination_module;
210 $dt_id = 'stormorganizations';
211 break;
212
213 case "stormperson":
214 $user_access_check = 'Storm person: access';
215 $list_text = 'People';
216 $list_path = 'storm/people/';
217 $add_icon_type = 'stormperson';
218 $add_path = 'node/add/'. $destination_module;
219 $dt_id = 'stormpeople';
220 break;
221
222 case "stormproject":
223 $user_access_check = 'Storm project: access';
224 $list_text = 'Projects';
225 $list_path = 'storm/projects/';
226 $add_icon_type = 'stormproject';
227 $add_path = 'node/add/'. $destination_module;
228 $dt_id = 'stormprojects';
229 break;
230
231 case "stormtask":
232 $user_access_check = 'Storm task: access';
233 $list_text = 'Tasks';
234 $list_path = 'storm/tasks/';
235 $add_icon_type = 'stormtask';
236 $add_path = 'node/add/'. $destination_module;
237 $dt_id = 'stormtasks';
238 break;
239
240 case "stormteammember":
241 $user_access_check = 'Storm teammember: access';
242 $list_text = 'Team members';
243 $list_path = 'storm/teammembers/';
244 $add_icon_type = 'stormteammember';
245 $add_path = 'storm/teammembers/add';
246 $dt_id = 'stormteammembers';
247 break;
248
249 case "stormticket":
250 $user_access_check = 'Storm ticket: access';
251 $list_text = 'Tickets';
252 $list_path = 'storm/tickets/';
253 $add_icon_type = 'stormticket';
254 $add_path = 'node/add/'. $destination_module;
255 $dt_id = 'stormtickets';
256 break;
257
258 case "stormtimetracking":
259 $user_access_check = 'Storm timetracking: access';
260 $list_text = 'Timetrackings';
261 $list_path = 'storm/timetrackings/';
262 $add_icon_type = 'stormtimetracking';
263 $node_links_key = 'timetrackings';
264 $add_path = 'node/add/'. $destination_module;
265 $dt_id = 'stormtimetrackings';
266
267 break;
268 }
269
270 if (($destination_module=='stormconfiguration' && user_access($user_access_check)) || (module_exists($destination_module) && user_access($user_access_check))) {
271 if ($node_nid == 0) {
272 $params = array();
273 }
274 else {
275 $params = array('query' => array($params_key => $node_nid));
276 }
277 $v = l(t($list_text), $list_path, $params);
278
279 if (!$add_icon_type=='') {
280 $i->type = $add_icon_type;
281 if ($node_nid == 0) {
282 $params = $_GET;
283 }
284 else {
285 $params = $_GET;
286 $params[$params_key] = $node_nid;
287 }
288 if (drupal_function_exists('storm_icon_add')) {
289 $v .= storm_icon_add($add_path, $i, $params);
290 }
291 }
292
293 if ($node_nid == 0) {
294 $r = '<dt id="'. $dt_id .'" class="stormcomponent">';
295 $r .= $v;
296 $r .= '</dt>';
297 }
298 else {
299 $r = array(
300 '#prefix' => '<dt id="'. $dt_id .'" class="stormcomponent">',
301 '#suffix' => '</dt>',
302 '#value' => $v,
303 '#weight' => $weight,
304 );
305 }
306 return $r;
307 }
308 }

  ViewVC Help
Powered by ViewVC 1.1.2