Highway to PSR2
[openemr.git] / interface / main / calendar / modules / PostCalendar / plugins / function.pc_view_select.php
blobca2686a70e6e351c4b9324d165ee1e69c55e83ff
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_view_select($args)
29 @define('_PC_FORM_TEMPLATE', true);
30 $Date = postcalendar_getDate();
31 if (!isset($y)) {
32 $y = substr($Date, 0, 4);
35 if (!isset($m)) {
36 $m = substr($Date, 4, 2);
39 if (!isset($d)) {
40 $d = substr($Date, 6, 2);
43 $tplview = pnVarCleanFromInput('tplview');
44 $viewtype = pnVarCleanFromInput('viewtype');
45 if (!isset($viewtype)) {
46 $viewtype = _SETTING_DEFAULT_VIEW;
49 $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
50 $mdir = pnVarPrepForOS($modinfo['directory']);
51 unset($modinfo);
52 $pcTemplate = pnVarPrepForOS(_SETTING_TEMPLATE);
53 if (empty($pcTemplate)) {
54 $pcTemplate = 'default';
57 $viewlist = array();
58 $handle = opendir("modules/$mdir/pntemplates/$pcTemplate/views/$viewtype");
60 $hide_list = array('.','..','CVS','index.html');
61 while ($f=readdir($handle)) {
62 if (!in_array($f, $hide_list)) {
63 $viewlist[] = $f;
67 closedir($handle);
68 unset($no_list);
69 sort($viewlist);
70 $tcount = count($viewlist);
71 //$options = "<select id=\"tplview\" name=\"tplview\" class=\"$args[class]\">"; - pennfirm
72 $options = "<select id=\"tplview\" name=\"viewtype\" class=\"$args[class]\">";
73 $selected = $tplview;
74 for ($t=0; $t<$tcount; $t++) {
75 $id = str_replace('.html', '', $viewlist[$t]);
76 $sel = $selected == $id ? 'selected' : '';
77 $options .= "<option value=\"$id\" $sel class=\"$args[class]\">$id</option>";
80 $options .= '</select>';
82 if (!isset($args['label'])) {
83 $args['label'] = _PC_TPL_VIEW_SUBMIT;
86 $submit = '<input type="submit" valign="middle" name="submit" value="'.$args['label'].'" class="'.$args['class'].'" />';
87 // build the form
88 if ($t > 1) {
89 echo $options,$submit;