A few output elements are used often, so just retrieve them once and make them global...
[squirrelmail.git] / plugins / calendar / functions.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
1c7143ad 4 * Other calendar plugin functions.
7c67a5e8 5 *
4b5049de 6 * @copyright &copy; 2002-2007 The SquirrelMail Project Team
4b4abf93 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
ea5f4b8e 9 * @package plugins
10 * @subpackage calendar
d61a01d4 11 */
12
09b143cc 13/**
14 * Add link to menu at top of content pane
15 *
16 * @return void
17 *
18 */
19function calendar_do() {
20
551c7b53 21 global $oTemplate, $nbsp;
09b143cc 22 $output = makeInternalLink('plugins/calendar/calendar.php',_("Calendar"),'right')
23 . $nbsp . $nbsp;
24 return array('menuline' => $output);
25
26}
27
ea5f4b8e 28/**
1c7143ad 29 * Adds second layer of calendar links to upper menu
ea5f4b8e 30 * @return void
31 */
d61a01d4 32function calendar_header() {
d61a01d4 33 global $color,$year,$day,$month;
34
b01b21d0 35 echo html_tag( 'table', '', '', $color[0], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) .
36 html_tag( 'tr' ) .
37 html_tag( 'td', '', 'left', '', 'width="100%"' );
d61a01d4 38
c435f076 39 displayInternalLink("plugins/calendar/calendar.php?year=$year&amp;month=$month",_("Month View"),"right");
1ba8cd6b 40 echo "&nbsp;&nbsp;\n";
c435f076 41 displayInternalLink("plugins/calendar/day.php?year=$year&amp;month=$month&amp;day=$day",_("Day View"),"right");
1ba8cd6b 42 echo "&nbsp;&nbsp;\n";
c435f076 43 // displayInternalLink("plugins/calendar/event_create.php?year=$year&amp;month=$month&amp;day=$day",_("Add Event"),"right");
1ba8cd6b 44 // echo "&nbsp;&nbsp;\n";
b01b21d0 45 echo '</td></tr>';
d61a01d4 46
47}
48
1c7143ad 49/**
50 * Generates html option tags with length values
51 *
52 * Hardcoded values from 0 minutes to 6 hours
53 * @param integer $selected selected option length
54 * @return void
55 */
d61a01d4 56function select_option_length($selected) {
d61a01d4 57 $eventlength = array(
1ba8cd6b 58 '0' => _("0 min."),
59 '15' => _("15 min."),
6fe63d4e 60 '30' => _("30 min."),
1ba8cd6b 61 '45' => _("45 min."),
62 '60' => _("1 hr."),
63 '90' => _("1.5 hr."),
64 '120' => _("2 hr."),
65 '150' => _("2.5 hr."),
66 '180' => _("3 hr."),
67 '210' => _("3.5 hr."),
68 '240' => _("4 hr."),
69 '300' => _("5 hr."),
70 '360' => _("6 hr.")
d61a01d4 71 );
72
73 while( $bar = each($eventlength)) {
1c7143ad 74 if($bar['key']==$selected){
75 echo ' <option value="'.$bar['key'].'" selected="selected">'.$bar['value']."</option>\n";
d61a01d4 76 } else {
1c7143ad 77 echo ' <option value="'.$bar['key'].'">'.$bar['value']."</option>\n";
d61a01d4 78 }
79 }
80}
81
1c7143ad 82/**
83 * Generates html option tags with minute values
84 *
85 * Hardcoded values in 5 minute intervals
86 * @param integer $selected selected value
87 * @return void
88 */
d61a01d4 89function select_option_minute($selected) {
90 $eventminute = array(
1c7143ad 91 '00'=>'00',
92 '05'=>'05',
93 '10'=>'10',
94 '15'=>'15',
95 '20'=>'20',
96 '25'=>'25',
97 '30'=>'30',
98 '35'=>'35',
99 '40'=>'40',
100 '45'=>'45',
101 '50'=>'50',
102 '55'=>'55'
d61a01d4 103 );
104
105 while ( $bar = each($eventminute)) {
1c7143ad 106 if ($bar['key']==$selected){
107 echo ' <option value="'.$bar['key'].'" selected="selected">'.$bar['value']."</option>\n";
d61a01d4 108 } else {
1c7143ad 109 echo ' <option value="'.$bar['key'].'">'.$bar['value']."</option>\n";
d61a01d4 110 }
111 }
112}
113
1c7143ad 114/**
115 * Generates html option tags with hour values
116 * @param integer $selected selected value
117 * @return void
118 * @todo 12/24 hour format
119 */
d61a01d4 120function select_option_hour($selected) {
121
122 for ($i=0;$i<24;$i++){
123 ($i<10)? $ih = "0" . $i : $ih = $i;
124 if ($ih==$selected){
6fd95361 125 echo ' <option value="'.$ih.'" selected="selected">'.$i."</option>\n";
d61a01d4 126 } else {
6fd95361 127 echo ' <option value="'.$ih.'">'.$i."</option>\n";
d61a01d4 128 }
129 }
130}
131
1c7143ad 132/**
133 * Generates html option tags with priority values
134 * @param integer $selected selected value
135 * @return void
136 */
d61a01d4 137function select_option_priority($selected) {
138 $eventpriority = array(
1ba8cd6b 139 '0' => _("Normal"),
140 '1' => _("High"),
d61a01d4 141 );
142
143 while( $bar = each($eventpriority)) {
1c7143ad 144 if($bar['key']==$selected){
145 echo ' <option value="'.$bar['key'].'" selected="selected">'.$bar['value']."</option>\n";
d61a01d4 146 } else {
1c7143ad 147 echo ' <option value="'.$bar['key'].'">'.$bar['value']."</option>\n";
d61a01d4 148 }
149 }
150}
151
1c7143ad 152/**
153 * Generates html option tags with year values
154 *
155 * Hardcoded values from 1902 to 2037
156 * @param integer $selected selected value
157 * @return void
158 */
d61a01d4 159function select_option_year($selected) {
160
98a792df 161 for ($i=1902;$i<2038;$i++){
d61a01d4 162 if ($i==$selected){
6fd95361 163 echo ' <option value="'.$i.'" selected="selected">'.$i."</option>\n";
d61a01d4 164 } else {
6fd95361 165 echo ' <option value="'.$i.'">'.$i."</option>\n";
d61a01d4 166 }
167 }
168}
169
1c7143ad 170/**
171 * Generates html option tags with month values
172 * @param integer $selected selected value
173 * @return void
174 */
d61a01d4 175function select_option_month($selected) {
176
177 for ($i=1;$i<13;$i++){
178 $im=date('m',mktime(0,0,0,$i,1,1));
e1baa507 179 $is = getMonthAbrv( date('m',mktime(0,0,0,$i,1,1)) );
d61a01d4 180 if ($im==$selected){
6fd95361 181 echo ' <option value="'.$im.'" selected="selected">'.$is."</option>\n";
d61a01d4 182 } else {
6fd95361 183 echo ' <option value="'.$im.'">'.$is."</option>\n";
d61a01d4 184 }
185 }
186}
187
1c7143ad 188/**
189 * Generates html option tags with day of month values
190 *
191 * Hardcoded values from 1 to 31
192 * @param integer $selected selected value
193 * @return void
194 */
d61a01d4 195function select_option_day($selected) {
196
197 for ($i=1;$i<32;$i++){
198 ($i<10)? $ih="0".$i : $ih=$i;
199 if ($i==$selected){
6fd95361 200 echo ' <option value="'.$ih.'" selected="selected">'.$i."</option>\n";
d61a01d4 201 } else {
6fd95361 202 echo ' <option value="'.$ih.'">'.$i."</option>\n";
d61a01d4 203 }
204 }
205}
206