-
Notifications
You must be signed in to change notification settings - Fork 62
/
component.php
443 lines (392 loc) · 11.5 KB
/
component.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<?php
/**
* component.php
*
* Contains functions to return layout components of the web pages
*
* Licensed under the GNU GPL. For full terms see the file LICENSE.
*
* @package OpenClinic
* @copyright 2002-2013 jact
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @version CVS: $Id: component.php,v 1.11 2013/01/13 16:28:39 jact Exp $
* @author jact <[email protected]>
* @since 0.8
*/
require_once(dirname(__FILE__) . "/../lib/exe_protect.php");
executionProtection(__FILE__);
require_once(dirname(__FILE__) . "/../lib/HTML.php");
/**
* Functions:
* string appLogo(void)
* string menuBar(string $tab)
* string logos(void)
* string miniLogos(void)
* array patientLinks(int $idPatient, string $nav)
* string sfLinks(void)
* string shortcuts(string $tab = null, string $nav = null)
* string navigation(array $links)
* string clinicInfo(void)
*/
/**
* string appLogo(void)
*
* Returns a paragraph with the application's logo
*
* @return string p#logo
* @access public
*/
function appLogo()
{
$logo = '../img/' . 'openclinic-1.png'; // @fixme OPEN_APP_LOGO
list($width, $height, $type, $attr) = getimagesize($logo);
$logo = HTML::image($logo, 'OpenClinic' /* @fixme OPEN_APP_NAME */, array('width' => $width, 'height' => $height));
$logo = HTML::link($logo, '../index.php', null, array('accesskey' => 1));
$html = HTML::para($logo, array('id' => 'logo'));
return $html;
}
/**
* string menuBar(string $tab)
*
* Returns a layer called tabs with a section menu
*
* @param string $tab selected section
* @param array $section options list
* @return string layer with a section menu
* @access public
*/
function menuBar($tab)
{
$_links = array(
"home" => array(_("Home"), "../home/index.php"),
"medical" => array(_("Medical Records"), "../medical/index.php"),
//"stats" => array("Statistics", "../stats/index.php"),
"admin" => array(_("Admin"), "../admin/index.php")
);
/*if ( !isset($_SESSION['auth']['invalid_token'])
&& isset($_SESSION['auth']['is_admin']) && $_SESSION['auth']['is_admin'])
{
$_links["admin"] = array(_("Admin"), "../admin/index.php");
}*/
$_html = HTML::start('div', array('id' => 'tabs'));
$_array = null;
$_sentinel = true;
foreach ($_links as $_key => $_value)
{
$_options = null;
if ($_sentinel)
{
$_sentinel = false;
$_options = array('class' => 'first');
}
if ($tab == $_key)
{
$_options['class'] = (isset($_options['class'])) ? $_options['class'] . ' selected' : 'selected';
}
$_array[] = HTML::link($_value[0], $_value[1], null, $_options);
}
$_html .= HTML::itemList($_array);
$_html .= HTML::end('div'); // #tabs
return $_html;
}
/**
* string logos(void)
*
* Returns ul#logos with links
*
* @return string ul#logos
* @access public
*/
function logos()
{
$_links = null;
$_links[] = HTML::link(
HTML::image(
'../img/openclinic-2.png',
_("Powered by OpenClinic"),
array('width' => 130, 'height' => 29)
),
'http://openclinic.sourceforge.net'
);
$thankCoresis = HTML::image('../img/thank.png', 'OpenClinic Logo thanks to Coresis',
array('width' => 65, 'height' => 30)
);
$thankCoresis .= HTML::image('../img/coresis.png', 'OpenClinic Logo thanks to Coresis',
array('width' => 65, 'height' => 30)
);
$thankCoresis = str_replace(PHP_EOL, '', $thankCoresis);
$_links[] = HTML::link($thankCoresis, 'http://www.coresis.com');
unset($thankCoresis);
$_links[] = HTML::link(
HTML::image(
'../img/sf-logo.png',
'Project hosted in SourceForge.net',
array('width' => 130, 'height' => 37)
),
'http://sourceforge.net'
);
return HTML::itemList($_links, array('id' => 'logos'));
}
/**
* string miniLogos(void)
*
* @return string ul#mini_logos
* @access public
*/
function miniLogos()
{
$_links = null;
$_links[] = HTML::link(
HTML::image(
'../img/php-logo.gif',
'Powered by PHP',
array('width' => 80, 'height' => 15)
),
'http://www.php.net'
);
$_links[] = HTML::link(
HTML::image(
'../img/mysql-logo.png',
'Works with MySQL',
array('width' => 80, 'height' => 15)
),
'http://www.mysql.com'
);
$_links[] = HTML::link(
HTML::image(
'../img/valid-xhtml11.png',
'Valid XHTML 1.1',
array('width' => 80, 'height' => 15)
),
'http://validator.w3.org/check/referer'
);
$_links[] = HTML::link(
HTML::image(
'../img/valid-css.png',
'Valid CSS',
array('width' => 80, 'height' => 15)
),
'http://jigsaw.w3.org/css-validator',
array('uri' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])
);
return HTML::itemList($_links, array('id' => 'mini_logos'));
}
/**
* array patientLinks(int $idPatient, string $nav)
*
* Returns an array with links about a patient
*
* @param int $idPatient
* @param string $nav
* @return array
* @access public
* @since 0.8
*/
function patientLinks($idPatient, $nav)
{
$linkList = array(
"relatives" => array(_("View Relatives"), "../medical/relative_list.php"),
//"preventive" => array(_("Datos Preventivos"), ""), // I don't know how implement it
"history" => array(_("Clinic History"), "../medical/history_list.php"),
"problems" => array(_("Medical Problems Report"), "../medical/problem_list.php")
);
$array = null;
foreach ($linkList as $key => $value)
{
$array[] = HTML::link($value[0], $value[1], array('id_patient' => $idPatient),
$nav == $key ? array('class' => 'selected') : null
);
}
unset($linkList);
$array[] = ($nav == "print")
? array(_("Print Medical Record"), array('class' => 'selected'))
: HTML::link(_("Print Medical Record"), '../medical/print_medical_record.php',
array('id_patient' => $idPatient),
array('class' => 'popup')
);
return $array;
}
/**
* string sfLinks(void)
*
* Returns a layer called sf_links with a links list
*
* @return string layer with a links list
* @access public
*/
function sfLinks()
{
$_sfLinks = array(
_("Project Page") => 'http://sourceforge.net/projects/openclinic/',
//_("Mailing Lists") => 'http://sourceforge.net/mail/?group_id=70742',
_("Downloads") => 'http://sourceforge.net/project/showfiles.php?group_id=70742',
_("Report Bugs") => 'http://sourceforge.net/tracker/?group_id=70742&atid=528857',
//_("Tasks") => 'http://sourceforge.net/pm/?group_id=70742',
_("Forums") => 'http://sourceforge.net/forum/?group_id=70742',
//_("Developers"), 'http://sourceforge.net/project/memberlist.php?group_id=70742'
);
$_array = null;
foreach ($_sfLinks as $_key => $_value)
{
$_array[] = HTML::link($_key, $_value);
}
$_html = HTML::itemList($_array, array('id' => 'sf_links'));
return $_html;
}
/**
* string shortcuts(string $tab = null, string $nav = null)
*
* Returns an ul#shortcuts with links
*
* @param string $tab (optional)
* @param string $nav (optional)
* @return string ul#shortcuts
* @access public
* @see OPEN_DEMO
*/
function shortcuts($tab = null, $nav = null)
{
$_links = null;
if (defined("OPEN_DEMO") && !OPEN_DEMO)
{
$sessLogin = isset($_SESSION['auth']['login_session']) ? $_SESSION['auth']['login_session'] : '';
if ( !empty($sessLogin) && !isset($_SESSION['auth']['invalid_token']) )
{
$_links[] = HTML::link(_("Logout"), '../auth/logout.php')
. ' ['
. HTML::link($sessLogin, '../admin/user_edit_form.php',
array(
'id_user' => $_SESSION['auth']['user_id'],
'all' => 'Y'
),
array('title' => _("manage your user account"))
)
. ']';
}
else
{
$_links[] = HTML::link(_("Log in"), '../auth/login_form.php'); // @fixme login
}
}
$_links[] = HTML::link(_("OpenClinic Readme"), '../index.html');
/*if (isset($tab) && isset($nav))
{
$_links[] = HTML::link(_("Help"), '../doc/index.php',
array(
'tab' => $tab,
'nav' => $nav
),
array(
'title' => _("Opens a new window"),
'class' => 'popup'
)
);
}*/
if (isset($_SESSION['auth']['is_admin']) && ($_SESSION['auth']['is_admin'] === true && !OPEN_DEMO))
{
$_serverVar = (strpos(PHP_SAPI, 'cgi') !== false)
? $_SERVER['PATH_TRANSLATED']
: $_SERVER['SCRIPT_FILENAME'];
$_links[] = HTML::link(_("View source code"), '../shared/view_source.php',
array(
'file' => $_serverVar
),
array(
'title' => _("Opens a new window"),
'class' => 'popup'
)
);
}
if (defined("OPEN_DEMO") && OPEN_DEMO)
{
$_links[] = HTML::link(_("Demo version features"), '../demo_version.html');
}
$_html = HTML::itemList($_links, array('id' => 'shortcuts'));
return $_html;
}
/**
* string navigation(array $links)
*
* @param array $links
* array(
* string,
* array(
* string,
* string,
* ),
* string
* )
* @return string list of links
* @access public
*/
function navigation($links)
{
$_html = HTML::start('ul');
foreach ($links as $value)
{
if (is_array($value))
{
$_html .= navigation($value);
}
else
{
$_html .= HTML::start('li') . $value;
}
if ( !is_array(next($links)) )
{
$_html .= HTML::end('li');
}
}
$_html .= HTML::end('ul');
return $_html;
}
/**
* string clinicInfo(void)
*
* @return string div#clinic_info (microformat hCard)
* @access public
* @see OPEN_CLINIC_NAME
* @see OPEN_CLINIC_URL
* @see OPEN_CLINIC_HOURS
* @see OPEN_CLINIC_ADDRESS
* @see OPEN_CLINIC_PHONE
*/
function clinicInfo()
{
if ( !defined("OPEN_CLINIC_NAME") || !OPEN_CLINIC_NAME )
{
return;
}
$_html = HTML::start('div', array('id' => 'clinic_info', 'class' => 'vcard contact'));
$_name = OPEN_CLINIC_NAME;
if (defined("OPEN_CLINIC_URL") && OPEN_CLINIC_URL)
{
$_name = HTML::link($_name, OPEN_CLINIC_URL, null, array('class' => 'url'));
}
$_html .= HTML::para($_name, array('class' => 'fn org'));
if (defined("OPEN_CLINIC_HOURS") && OPEN_CLINIC_HOURS)
{
$_html .= HTML::para(sprintf(_("Clinic hours: %s"), OPEN_CLINIC_HOURS));
}
if ((defined("OPEN_CLINIC_ADDRESS") && OPEN_CLINIC_ADDRESS)
|| (defined("OPEN_CLINIC_PHONE") && OPEN_CLINIC_PHONE))
{
$_html .= HTML::start('address', array('class' => 'adr'));
if (defined("OPEN_CLINIC_ADDRESS") && OPEN_CLINIC_ADDRESS)
{
$_html .= HTML::para(sprintf(_("Clinic address: %s"), HTML::tag('span', OPEN_CLINIC_ADDRESS,
array('class' => 'street-address')))
);
}
if (defined("OPEN_CLINIC_PHONE") && OPEN_CLINIC_PHONE)
{
$_html .= HTML::para(sprintf(_("Clinic phone: %s"),
HTML::tag('span', OPEN_CLINIC_PHONE, array('class' => 'tel value')))
);
}
$_html .= HTML::end('address');
}
$_html .= HTML::end('div');
return $_html;
}
?>