Highway to PSR2
[openemr.git] / interface / main / calendar / modules / PostCalendar / plugins / function.pc_date_select.php
bloba1df84729360578819efbea2d12d4da348d1e96b
1 <?php
2 /**
3 * $Id$
5 * PostCalendar::PostNuke Events Calendar Module
6 * Copyright (C) 2002 The PostCalendar Team
7 * http://postcalendar.tv
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * To read the license please read the docs/license.txt or visit
24 * http://www.gnu.org/copyleft/gpl.html
27 function smarty_function_pc_date_select($args)
29 $print = pnVarCleanFromInput('print');
30 $tplview = pnVarCleanFromInput('tplview');
31 $viewtype = pnVarCleanFromInput('viewtype');
32 if (!isset($viewtype)) {
33 $viewtype = _SETTING_DEFAULT_VIEW;
36 $Date = postcalendar_getDate();
38 if (!isset($y)) {
39 $y = substr($Date, 0, 4);
42 if (!isset($m)) {
43 $m = substr($Date, 4, 2);
46 if (!isset($d)) {
47 $d = substr($Date, 6, 2);
50 if (!isset($args['day']) || strtolower($args['day']) == 'on') {
51 $args['day'] = true;
52 @define('_PC_FORM_DATE', true);
53 } else {
54 $args['day'] = false;
57 if (!isset($args['month']) || strtolower($args['month']) == 'on') {
58 $args['month'] = true;
59 @define('_PC_FORM_DATE', true);
60 } else {
61 $args['month'] = false;
64 if (!isset($args['year']) || strtolower($args['year']) == 'on') {
65 $args['year'] = true;
66 @define('_PC_FORM_DATE', true);
67 } else {
68 $args['year'] = false;
71 if (!isset($args['view']) || strtolower($args['view']) == 'on') {
72 $args['view'] = true;
73 @define('_PC_FORM_VIEW_TYPE', true);
74 } else {
75 $args['view'] = false;
78 $dayselect=$monthselect=$yearselect=$viewselect='';
79 $output = new pnHTML();
80 $output->SetOutputMode(_PNH_RETURNOUTPUT);
81 if ($args['day'] === true) {
82 $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildDaySelect', array('pc_day'=>$d));
83 $dayselect = $output->FormSelectMultiple('jumpday', $sel_data);
86 if ($args['month'] === true) {
87 $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildMonthSelect', array('pc_month'=>$m));
88 $monthselect = $output->FormSelectMultiple('jumpmonth', $sel_data);
91 if ($args['year'] === true) {
92 $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildYearSelect', array('pc_year'=>$y));
93 $yearselect = $output->FormSelectMultiple('jumpyear', $sel_data);
96 if ($args['view'] === true) {
97 $sel_data = array();
98 $sel_data[0]['id'] = 'day';
99 $sel_data[0]['selected'] = $viewtype=='day';
100 $sel_data[0]['name'] = _CAL_DAYVIEW;
101 $sel_data[1]['id'] = 'week';
102 $sel_data[1]['selected'] = $viewtype=='week';
103 $sel_data[1]['name'] = _CAL_WEEKVIEW;
104 $sel_data[2]['id'] = 'month';
105 $sel_data[2]['selected'] = $viewtype=='month';
106 $sel_data[2]['name'] = _CAL_MONTHVIEW;
107 $sel_data[3]['id'] = 'year';
108 $sel_data[3]['selected'] = $viewtype=='year';
109 $sel_data[3]['name'] = _CAL_YEARVIEW;
110 $viewselect = $output->FormSelectMultiple('viewtype', $sel_data);
113 if (!isset($args['label'])) {
114 $args['label'] = _PC_JUMP_MENU_SUBMIT;
117 $jumpsubmit = '<input type="submit" valign="middle" name="submit" value="'.$args['label'].'" />';
118 $output->SetOutputMode(_PNH_KEEPOUTPUT);
120 $orderArray = array('day'=>$dayselect,
121 'month'=>$monthselect,
122 'year'=>$yearselect,
123 'view'=>$viewselect,
124 'jump'=>$jumpsubmit);
126 if (isset($args['order'])) {
127 $newOrder = array();
128 $order = explode(',', $args['order']);
129 foreach ($order as $tmp_order) {
130 array_push($newOrder, $orderArray[$tmp_order]);
133 foreach ($orderArray as $key => $old_order) {
134 if (!in_array($key, $newOrder)) {
135 array_push($newOrder, $orderArray[$old_order]);
139 $order = $newOrder;
140 } else {
141 $order = $orderArray;
144 foreach ($order as $element) {
145 echo $element;