* @copyright 2010-2011 Rob Kaper <http://robkaper.nl/> * @license Released under the terms of the MIT license. */ if ($_POST) { $section = new Section($_POST['sectionId']); $errors = array(); if (!$user->id()) { $errors[] = "Je bent niet ingelogd."; } if (!$user->isAdmin()) { $errors[] = "Je hebt geen admin rechten."; } $section->setBaseURI($_POST['baseURI']); $section->setTitle($_POST['title']); $section->setType($_POST['type']); if (!$section->baseURI()) { $errors[] = "Je kunt de URL naam niet leeg laten."; } // if ( strstr( $section->baseURI(), "/" ) ) // $errors[] = "Een URL naam mag geen <q>/</q> bevatten."; if (!sizeof($errors)) { $section->save(); } if (isset($_POST['json'])) { $response = array(); $response['sectionId'] = $section->id(); $response['errors'] = $errors; header('Content-type: application/json'); echo json_encode($response); exit; }
} else { echo "<table>\n"; echo "<thead>\n"; echo "<tr>\n"; echo "<td colspan=\"3\"><a href=\"?id=0\"><img src=\"/kiki/img/iconic/black/pen_alt_fill_16x16.png\" alt=\"New\"></a></td>\n"; echo "<td colspan=\"3\">" . _("Create a new section") . "</td>\n"; echo "</tr>\n"; echo "<tr><th></th><th></th><th></th><th>URL</th><th>Title</th><th>Type</th></tr>\n"; echo "</thead>\n"; echo "<tbody>\n"; $q = "SELECT id,base_uri,title,type from sections ORDER BY base_uri ASC"; $rs = $db->query($q); if ($db->numRows($rs)) { $section = new Section(); while ($o = $db->fetchObject($rs)) { $section->setFromObject($o); echo "<tr>\n"; echo "<td><a href=\"?id=" . $section->id() . "\"><img src=\"/kiki/img/iconic/black/pen_alt_fill_16x16.png\" alt=\"Edit\"></a></td>\n"; echo "<td></td>\n"; // <a href=\"". $section->url(). "\"><img src=\"/kiki/img/iconic/black/magnifying_glass_16x16.png\" alt=\"View\"></a></td>\n"; echo "<td><a href=\"\"><img src=\"/kiki/img/iconic/black/trash_stroke_16x16.png\" alt=\"Delete\"></a></td>\n"; echo "<td>" . $section->baseURI() . "</td>\n"; echo "<td>" . $section->title() . "</td>\n"; echo "<td>" . $section->type() . "</td>\n"; echo "</tr>\n"; } } echo "</tbody>\n"; echo "</table>\n"; } $this->content = ob_get_clean();