|
8 | 8 | $page = new Page('Add Happening', 'Happening'); |
9 | 9 | $title = "<h2><img src=\"/img/processinghappenings.gif\" alt=\"Processing Happenings\" /></h2>"; |
10 | 10 |
|
11 | | -$sdate = isset($_POST['sdate']) ? strtotime(trim($_POST['sdate'])) : false; |
12 | | -$edate = isset($_POST['edate']) && $_POST['edate'] != '' ? strtotime(trim($_POST['edate'])) : false; |
| 11 | +$date = isset($_POST['date']) ? trim($_POST['date']) : false; |
13 | 12 | $body = isset($_POST['body']) ? strip_tags($_POST['body'], '<a><b><strong><i><em>') : false; |
14 | 13 |
|
15 | 14 | if (!$_POST['preview'] && |
16 | | - $sdata !== false && $body !== false && |
17 | | - $sdata !== -1 && $edata !== -1) { // valid input |
| 15 | + $date !== false && $body !== false ) { // valid input |
18 | 16 |
|
19 | 17 | // let's first check back if he / she just added something and |
20 | 18 | // politely ask to come back a little later ... |
|
52 | 50 | // add data |
53 | 51 | $newxml = <<<XML |
54 | 52 | <item> |
55 | | - <startdate></startdate> |
56 | | - <enddate></enddate> |
| 53 | + <date></date> |
57 | 54 | <description></description> |
58 | 55 | </item> |
59 | 56 | XML; |
|
62 | 59 | $xml2 = $doc2->documentElement; |
63 | 60 |
|
64 | 61 | $one =& $xml2->childNodes[0]; |
65 | | - $one->setText(date($date_format, $sdate)); |
66 | | - $two =& $xml2->childNodes[1]; |
67 | | - $two->setText( $edate ? date($date_format, $edate) : '' ); |
68 | | - $three =& $xml2->childNodes[2]; |
69 | | - $three->setText($body); |
| 62 | + $one->setText($date); |
| 63 | + $two =& $xml2->childNodes[1]; |
| 64 | + $two->setText($body); |
70 | 65 |
|
71 | 66 | $xml->appendChild($xml2); |
72 | 67 |
|
|
89 | 84 |
|
90 | 85 | $msg = array(); |
91 | 86 | if (count($_POST) !== 0) { |
92 | | - if (!$sdate) { |
93 | | - $msg['sdate'] = 'Please enter a starting date'; |
94 | | - } else if ($sdate == -1) { |
95 | | - $msg['sdate'] = 'Please enter a valid date'; |
96 | | - } |
97 | | - if ($edate == -1) { |
98 | | - $msg['edate'] = 'Please enter a valid date'; |
| 87 | + if (!$date) { |
| 88 | + $msg['date'] = 'Please enter a date'; |
99 | 89 | } |
100 | 90 | if (!$body) { |
101 | 91 | $msg['body'] = 'Please fill in this field'; |
|
105 | 95 | $msg = array_map(create_function('$str', 'return "<p class=\"error\">$str</p>";'), $msg); |
106 | 96 |
|
107 | 97 | if ($_POST['preview']) { // preview |
108 | | - $sdate = date($date_format, $sdate); |
109 | | - $edate = $edate ? date($date_format, $edate) : ''; |
110 | | - $datestring = $sdate . ($edate ? " – $edate" : ''); |
111 | 98 | $preview = <<<PREV |
112 | 99 | <dl> |
113 | | - <dt>{$datestring}</dt> |
| 100 | + <dt>{$date}</dt> |
114 | 101 | <dd>{$body}</dd> |
115 | 102 | </dl> |
116 | 103 | PREV; |
|
120 | 107 | $happening_form = <<<H_FORM |
121 | 108 | <form accept-charset="utf-8" action="{$_SERVER['PHP_SELF']}" method="post" name="mform"> |
122 | 109 |
|
123 | | - <label>Start Date: <em>format: 01 January 05</em></label><br /> |
124 | | - <input name="sdate" type="text" size="12" value="{$sdate}" /><br /> |
125 | | - {$msg['sdate']}<br /> |
126 | | - |
127 | | - <label>End Date: <em>(Optional)</em></label><br /> |
128 | | - <input name="edate" type="text" size="12" value="{$edate}" /><br /> |
129 | | - {$msg['edate']}<br /> |
| 110 | + <label>Date: <em>format: 01 January 05</em></label><br /> |
| 111 | + <input name="date" type="text" size="12" value="{$date}" /><br /> |
| 112 | + {$msg['date']}<br /> |
130 | 113 | |
131 | 114 | <label>What’s Happening?: <em>Allowed html: <a>, <strong>, <em></em></label><br /> |
132 | 115 | <textarea name="body" cols="40" rows="3">{$body}</textarea><br /> |
|
137 | 120 | <br /> |
138 | 121 | <br /> |
139 | 122 | |
140 | | - <input type="image" src="https://github.com/img/submit.gif" value="Submit" alt="Submit" /><input type="image" src="https://github.com/img/preview.gif" name="preview" value="Preview" alt="Preview" /> |
| 123 | + <input type="image" src="https://github.com/img/submit.gif" value="Submit" alt="Submit" /> <input type="image" src="https://github.com/img/preview.gif" name="preview" value="Preview" alt="Preview" /> |
141 | 124 |
|
142 | 125 | </form> |
143 | 126 |
|
|
0 commit comments