Subversion Repositories Applications.papyrus

Rev

Rev 1087 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
493 ddelon 1
<?php
2
/**
3
* Description: A "personal planner" with some WML for fun
4
* Note this is done the stupid way - a giant if/else for WML or HTML
5
* could be greatly simplified with some HTML/WML rendering classes...
6
*/
7
function getmicrotime(){
8
    list($usec, $sec) = explode(" ",microtime());
9
    return ((float)$usec + (float)$sec);
10
}
11
$start = getmicrotime();
12
 
13
if ( !@include 'Calendar/Calendar.php' ) {
14
    define('CALENDAR_ROOT','../../');
15
}
16
require_once CALENDAR_ROOT.'Month/Weekdays.php';
17
require_once CALENDAR_ROOT.'Day.php';
18
 
19
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
20
if (!isset($_GET['m'])) $_GET['m'] = date('n');
21
if (!isset($_GET['d'])) $_GET['d'] = date('j');
22
 
23
$Month = & new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
24
$Day = & new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']);
25
$selection = array($Day);
26
 
27
#-----------------------------------------------------------------------------#
28
if ( isset($_GET['mime']) && $_GET['mime']=='wml' ) {
29
    header ('Content-Type: text/vnd.wap.wml');
30
    echo ( '<?xml version="1.0"?>' );
31
?>
32
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
33
<wml>
34
<big><strong>Personal Planner Rendered with WML</strong></big>
35
<?php
36
if ( isset($_GET['viewday']) ) {
37
?>
38
<p><strong>Viewing <?php echo ( date('l, jS of F, Y',$Day->getTimeStamp()) ); ?></strong></p>
39
<p>
40
<anchor>
41
Back to Month View
42
<go href="<?php
43
echo ( "?y=".$Day->thisYear()."&amp;m=".
44
        $Day->thisMonth()."&amp;d=".$Day->thisDay()."&amp;mime=wml" );
45
?>"/>
46
</anchor>
47
</p>
48
<table>
49
<?php
50
    $Day->build();
51
    while ( $Hour = & $Day->fetch() ) {
52
        echo ( "<tr>\n" );
53
        echo ( "<td>".date('g a',$Hour->getTimeStamp())."</td><td>Free time!</td>\n" );
54
        echo ( "</tr>\n" );
55
    }
56
?>
57
</table>
58
<?php
59
} else {
60
?>
61
<p><strong><?php echo ( date('F Y',$Month->getTimeStamp()) ); ?></strong></p>
62
<table>
63
<tr>
64
<td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td><td>S</td>
65
</tr>
66
<?php
67
$Month->build($selection);
68
while ( $Day = $Month->fetch() ) {
69
    if ( $Day->isFirst() ) {
70
        echo ( "<tr>\n" );
71
    }
72
    if ( $Day->isEmpty() ) {
73
        echo ( "<td></td>\n" );
74
    } else if ( $Day->isSelected() ) {
75
        echo ( "<td><anchor><strong><u>".$Day->thisDay()."</u></strong>\n<go href=\"".$_SERVER['PHP_SELF']."?viewday=true&amp;y=".
76
            $Day->thisYear()."&amp;m=".$Day->thisMonth()."&amp;d=".$Day->thisDay().
77
            "&amp;mime=wml\" />\n</anchor></td>\n" );
78
    } else {
79
        echo ( "<td><anchor>".$Day->thisDay()."\n<go href=\"?viewday=true&amp;y=".
80
            $Day->thisYear()."&amp;m=".$Day->thisMonth()."&amp;d=".$Day->thisDay().
81
            "&amp;mime=wml\" /></anchor></td>\n" );
82
    }
83
    if ( $Day->isLast() ) {
84
        echo ( "</tr>\n" );
85
    }
86
}
87
?>
88
<tr>
89
<td>
90
<anchor>
91
&lt;&lt;
92
<go href="<?php
93
echo ( "?y=".$Month->thisYear()."&amp;m=".
94
        $Month->prevMonth()."&amp;d=".$Month->thisDay()."&amp;mime=wml" );
95
?>"/>
96
</anchor>
97
</td>
98
<td></td><td></td><td></td><td></td><td></td>
99
<td>
100
<anchor>
101
&gt;&gt;
102
<go href="<?php
103
echo ( "?y=".$Month->thisYear()."&amp;m=".
104
        $Month->nextMonth()."&amp;d=".$Month->thisDay()."&amp;mime=wml" );
105
?>"/>
106
</anchor>
107
</td>
108
</tr>
109
</table>
110
 
111
<?php
112
}
113
?>
114
<p><a href="<?php echo ( $_SERVER['PHP_SELF'] ); ?>">Back to HTML</a></p>
115
<?php echo ( '<p>Took: '.(getmicrotime()-$start).' seconds</p>' ); ?>
116
</wml>
117
<?php
118
#-----------------------------------------------------------------------------#
119
} else {
120
?>
121
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
122
<html>
123
<head>
124
<title> HTML (+WML) Personal Planner </title>
125
</head>
126
<body>
127
<h1>Personal Planner Rendered with HTML</h1>
128
<p>To view in WML, click <a href="<?php echo ( $_SERVER['PHP_SELF'] ); ?>?mime=wml">here</a> or place a ?mime=wml at the end of any URL.
129
Note that <a href="http://www.opera.com/download">Opera</a> supports WML natively and Mozilla / Firefox has the WMLBrowser
130
plugin: <a href="http://wmlbrowser.mozdev.org">wmlbrowser.mozdev.org</a></p>
131
<?php
132
if ( isset($_GET['viewday']) ) {
133
?>
134
<p><strong>Viewing <?php echo ( date('l, jS of F, Y',$Day->getTimeStamp()) ); ?></strong></p>
135
<p>
136
<anchor>
137
<a href="<?php
138
echo ( "?y=".$Day->thisYear()."&amp;m=".
139
        $Day->thisMonth()."&amp;d=".$Day->thisDay());
140
?>">Back to Month View</a>
141
</p>
142
<table>
143
<?php
144
    $Day->build();
145
    while ( $Hour = & $Day->fetch() ) {
146
        echo ( "<tr>\n" );
147
        echo ( "<td>".date('g a',$Hour->getTimeStamp())."</td><td>Free time!</td>\n" );
148
        echo ( "</tr>\n" );
149
    }
150
?>
151
</table>
152
<?php
153
} else {
154
?>
155
<p><strong><?php echo ( date('F Y',$Month->getTimeStamp()) ); ?></strong></p>
156
<table>
157
<tr>
158
<td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td><td>S</td>
159
</tr>
160
<?php
161
$Month->build($selection);
162
while ( $Day = $Month->fetch() ) {
163
    if ( $Day->isFirst() ) {
164
        echo ( "<tr>\n" );
165
    }
166
    if ( $Day->isEmpty() ) {
167
        echo ( "<td></td>\n" );
168
    } else if ( $Day->isSelected() ) {
169
        echo ( "<td><a href=\"".$_SERVER['PHP_SELF']."?viewday=true&amp;y=".
170
            $Day->thisYear()."&amp;m=".$Day->thisMonth()."&amp;d=".$Day->thisDay().
171
            "&amp;wml\"><strong><u>".$Day->thisDay()."</u></strong></a></td>\n" );
172
    } else {
173
        echo ( "<td><a href=\"".$_SERVER['PHP_SELF']."?viewday=true&amp;y=".
174
            $Day->thisYear()."&amp;m=".$Day->thisMonth()."&amp;d=".$Day->thisDay().
175
            "\">".$Day->thisDay()."</a></td>\n" );
176
    }
177
    if ( $Day->isLast() ) {
178
        echo ( "</tr>\n" );
179
    }
180
}
181
?>
182
<tr>
183
<td>
184
<a href="<?php
185
echo ( "?y=".$Month->thisYear()."&amp;m=".
186
        $Month->prevMonth()."&amp;d=".$Month->thisDay() );
187
?>">
188
&lt;&lt;</a>
189
</td>
190
<td></td><td></td><td></td><td></td><td></td>
191
<td>
192
<a href="<?php
193
echo ( "?y=".$Month->thisYear()."&amp;m=".
194
        $Month->nextMonth()."&amp;d=".$Month->thisDay() );
195
?>">&gt;&gt;</a>
196
</td>
197
</tr>
198
</table>
199
 
200
<?php
201
}
202
?>
203
 
204
 
205
<?php echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); ?>
206
</body>
207
</html>
208
<?php
209
}
210
?>