title, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " time=\"" . $this->time . "\"\n"); fwrite($fp, " description=\"" . htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " flyer=\"" . $this->flyer . "\">\n"); fwrite($fp, " \n"); } public function show() { global $ICONS_DIR, $EVENT_PAGE; $icons = new Icons($ICONS_DIR."/"); $icon = $icons->icons[$this->flyer]; $content = Markdown(htmlspecialchars_decode($this->description)); $str = "
Looking ok?
"; $form = new Form("add"); $form->addWidget(new Hidden($vars)); $form->addWidget(new Button("yes")); $form->render(); $form = new Form("retry"); $form->addWidget(new Hidden($vars)); $form->addWidget(new Button("no")); $form->render(); break; case "retry": $title = $vars["title"]; $time = DateTimeEdit::toTimestamp($vars, "time"); $description = $vars["description"]; $flyer = $vars["icon"]; default: $form = new Form("preview"); $form->addWidget(new LineEdit("Title", "title", $title)); $form->addWidget(new DateTimeEdit("Time", "time", $time)); $form->addWidget(new TextEdit("Description", "description", $description)); $form->addWidget(new ImageComboBox("Icon", "icon", $icon, new Icons($ICONS_DIR."/"))); $form->addWidget(new Button("Add event")); $form->render(); break; } } public function admin_edit($action, $vars) { global $ICONS_DIR; switch($action) { case "add": $this->events[$vars["eventid"]]->title = $vars["title"]; $this->events[$vars["eventid"]]->time = DateTimeEdit::toTimestamp($vars, "time"); $this->events[$vars["eventid"]]->description = $vars["description"]; $this->events[$vars["eventid"]]->flyer = $vars["icon"]; $this->write(); echo "\"" . $this->events[$vars["eventid"]]->title . "\" has now been edited."; break; case "preview": $event = new Event($vars["title"], DatetimeEdit::toTimestamp($vars, "time"), $vars["description"], $vars["icon"]); echo "Looking ok?
"; $form = new Form("add"); $form->addWidget(new Hidden($vars)); $form->addWidget(new Button("yes")); $form->render(); $form = new Form("retry"); $form->addWidget(new Hidden($vars)); $form->addWidget(new Button("no")); $form->render(); break; case "edit": case "retry": if(isset($vars["title"])) $title = $vars["title"]; else $title = $this->events[$vars["eventid"]]->title; if(isset($vars["time_year"])) $time = DateTimeEdit::toTimestamp($vars, "time"); else $time = $this->events[$vars["eventid"]]->time; if(isset($vars["description"])) $description = $vars["description"]; else $description = $this->events[$vars["eventid"]]->description; if(isset($vars["icon"])) $icon = $vars["icon"]; else $icon = $this->events[$vars["eventid"]]->flyer; $form = new Form("preview"); $form->addWidget(new Hidden($vars)); $form->addWidget(new LineEdit("Title", "title", $title)); $form->addWidget(new DateTimeEdit("Time", "time", $time)); $form->addWidget(new TextEdit("Description", "description", $description)); $form->addWidget(new ImageComboBox("Icon", "icon", $icon, new Icons($ICONS_DIR."/"))); $form->addWidget(new Button("Update event")); $form->render(); break; case "select": default: $eventlist = array(); foreach($this->events as $event) { $eventlist[$event->title] = $event->time; } $form = new Form("edit"); $form->addWidget(new ComboBox("Edit this event:", "eventid", "", $eventlist)); $form->addWidget(new Button("Edit...")); $form->render(); break; } } public function admin_delete($action, $vars) { switch($action) { case "delete": echo "\"". $this->events[$vars["eventid"]]->title . "\" has now been deleted."; unset($this->events[$vars["eventid"]]); $this->write(); break; case "confirm": echo "Really delete: " . $this->events[$vars["eventid"]]->title . "?"; $form = new Form("delete"); $form->addWidget(new Hidden($vars)); $form->addWidget(new Button("yes")); $form->render(); $form = new Form("select"); $form->addWidget(new Hidden($vars)); $form->addWidget(new Button("no")); $form->render(); break; case "select": default: $eventlist = array(); foreach($this->events as $event) { $eventlist[$event->title] = $event->time; } $form = new Form("confirm"); $form->addWidget(new ComboBox("Delete this event:", "eventid", "", $eventlist)); $form->addWidget(new Button("Delete...")); $form->render(); break; } } public function admin($sub, $action, $vars) { switch($sub) { case "add": $this->admin_add($action, $vars); break; case "edit": $this->admin_edit($action, $vars); break; case "delete": $this->admin_delete($action, $vars); break; } } public function run($params) { global $eventid; $single = false; $show = "all"; $number = -1; $str = ""; $str .= "