function showextended() { global $lang; global $conf; global $site; global $user; $site->title($lang['search']['extended']); $form = new CodeKBForm("search.php", "search"); $form->addtext("query"); $form->addlabel("query", $lang['search']['keywords']); $form->addtext("author"); $form->addlabel("author", $lang['search']['author']); $form->addmultiselect("cats", "0", $lang['category']['root']); $tmpcat = new CodeKBCategory(0, $user); $array = $tmpcat->listcategories("name", 1); while (is_array($array) && ($val = array_shift($array))) { $form->addmultiselect("cats", $val['id'], str_repeat("-", $val['reclevel'] * 2) . " " . $val['name']); } unset($tmpcat); $form->addlabel("cats", $lang['search']['category']); $form->addcombo("sort", $lang['sort']['sortbyname'], null, true); $form->addcombo("sort", $lang['sort']['sortbycreatedate']); $form->addcombo("sort", $lang['sort']['sortbymodifydate']); $form->addlabel("sort", $lang['sort']['sortby']); $form->addcombo("order", $lang['sort']['ascending'], null, true); $form->addcombo("order", $lang['sort']['descending']); $form->addcombo("age", $lang['search']['1day']); $form->addcombo("age", $lang['search']['7days']); $form->addcombo("age", $lang['search']['1month']); $form->addcombo("age", $lang['search']['3months']); $form->addcombo("age", $lang['search']['6months']); $form->addcombo("age", $lang['search']['1year']); $form->addcombo("age", $lang['search']['all'], null, true); $form->addlabel("age", $lang['search']['notolder']); $form->addradio("whichage", $lang['sort']['sortbycreatedate'], $lang['sort']['sortbycreatedate'], true); $form->addradio("whichage", $lang['sort']['sortbymodifydate'], $lang['sort']['sortbymodifydate']); $form->addbutton(null, $lang['search']['search']); $form->addbutton("cancel"); $dialog = new CodeKBTemplate("dialog"); $dialog->push("legend", $lang['search']['extended']); $dialogitem = new CodeKBTemplate("dialogitem"); $content = $form->head(); $content .= $form->get("query") . "<br />\n"; $content .= $form->get("author") . "<br />\n"; $dialogitem->push("top", $content); $dialogitem->push("content1", $form->get("cats")); $content = $form->get("sort"); $content .= $form->get("order"); $content .= "<br /><br />\n"; $content .= $form->get("age"); $content .= $form->get("whichage"); $dialogitem->push("content2", $content); $content = "<br />\n"; $content .= $form->tail(); $dialogitem->push("tail", $content); $dialog->push("content", $dialogitem); $site->addcontent($dialog); return true; }
public function output() { global $conf; global $lang; $header = new CodeKBTemplate("header"); $header->push("stylesheet", $conf['general']['stylesheet']); $header->push("favicon", $conf['general']['imagepath'] . "/codekb.ico"); $header->push("title", $this->_title); $header->push("headline", $conf['general']['title']); array_unshift($this->_menu, array("home.php", $lang['menu']['home'], $lang['menu']['homealt']), array("category.php", $lang['menu']['browse'], $lang['menu']['browsealt'])); if ($this->_user->isadmin()) { array_push($this->_menu, array("admin.php", $lang['menu']['admin'], $lang['menu']['adminalt'])); } if ($this->_user->valid()) { array_push($this->_menu, array("login.php?action=logout", $lang['menu']['logout'] . " [<em>" . htmlentities($this->_user->name()) . "</em>]", $lang['menu']['logoutalt'])); } else { array_push($this->_menu, array("login.php", $lang['menu']['login'], $lang['menu']['loginalt'])); } $menuitems = ""; while ($menuentry = array_shift($this->_menu)) { $menuitems .= "\t\t" . url($menuentry[0], $menuentry[1], $menuentry[2]); if (count($this->_menu) != 0) { $menuitems .= " | \n"; } } $search = new CodeKBForm("search.php", "search"); $search->addtext("query"); $menuitems .= $search->head(); $searchstring = url("help.php", $lang['menu']['help'], $lang['menu']['helpalt']) . " | \n"; $searchstring .= url("search.php", $lang['menu']['search'], $lang['menu']['searchalt']) . " \n"; $searchstring .= $search->get("query"); $tail = $search->tail(); $menu = new CodeKBTemplate("menu"); $menu->push("menu", $menuitems); $menu->push("search", $searchstring); $menu->push("tail", $tail); echo $header; echo $menu; if ($this->_navigation) { echo $this->_navigation; } echo $this->_content; $footeritems = ""; while ($menuentry = array_shift($this->_footer)) { $footeritems .= "\t\t" . url($menuentry[0], icon($menuentry[1], $menuentry[2]), $menuentry[3]) . " \n"; $footeritems .= "\t\t" . url($menuentry[0], $menuentry[2], $menuentry[3]) . " \n"; } if ($conf['layout']['jumptonavigation']) { $footerform = new CodeKBForm("category.php", "list"); $tmpcat = new CodeKBCategory(0, $this->_user); $footerform->addcombo("id", "0", $lang['category']['root'], $this->_catid == 0, "jump"); $array = $tmpcat->listcategories("name", 1); foreach ($array as $val) { if ($this->_user->can("see", $val['id'])) { $footerform->addcombo("id", $val['id'], str_repeat("-", $val['reclevel'] * 2) . " " . $val['name'], $this->_catid == $val['id'], "jump"); } } unset($tmpcat); $footerform->addbutton("jump", $lang['general']['go']); $navi = $footerform->head(); $navi .= $footerform->get("id"); $navi .= $footerform->tail(); } $query_num = CodeKBDatabase::querycount(); $endtime = microtime(true); $debug = ""; if ($conf['err']['debug']) { CodeKBException::backtrace(); $debug = "<span style=\"font-size: xx-small;\">(Execution time: " . round($endtime - $this->_starttime, 4) . " / " . $query_num . " Queries)</span>"; } $footer = new CodeKBTemplate("footer"); $footer->push("footer", $footeritems); $footer->push("runtime", $debug); $footer->push("navigation", $navi); echo $footer; }
function showlinks() { global $lang; global $user; global $site; global $category; global $entry; $site->title($lang['entry']['link']); $site->addfooter("help.php?on=entry#link", "help", $lang['menu']['help'], $lang['menu']['helpalt']); if (!$user->entrycan("delentry", $entry) && !$user->entrycan("addentry", $entry)) { $site->addcontent(notice($lang['entry']['nochangeallowed'])); return false; } if ($category) { $cat = $category->id(); } if ($_POST['cancel']) { redirect("entry.php?id=" . $entry->id() . "&cat=" . $cat); } if ($user->entrycan("addentry", $entry)) { $form1 = new CodeKBForm("entry.php", "link"); $form1->addhidden("id", $entry->id()); $form1->addhidden("cat", $cat); $tmpcat = new CodeKBCategory(0, $user); if ($user->can("addentry", $tmpcat)) { $form1->addcombo("newcat", "0", $lang['category']['root']); } $array = $tmpcat->listcategories("name", 1); foreach ($array as $val) { if ($user->can("addentry", $val['id'])) { $form1->addcombo("newcat", $val['id'], str_repeat("-", $val['reclevel'] * 2) . " " . $val['name']); } } unset($tmpcat); $form1->addlabel("newcat", $lang['entry']['linkadd']); $form1->addsubmit("addlink"); $form1->addcancel(); } if ($user->entrycan("delentry", $entry)) { $form2 = new CodeKBForm("entry.php", "link"); $form2->addhidden("id", $entry->id()); $form2->addhidden("cat", $cat); $catsofentry = $entry->categories(); foreach ($catsofentry as $val) { $thiscat = new CodeKBCategory($val, $user); $form2->addcheckbox("cat_" . $thiscat->id(), $thiscat->name()); unset($thiscat); } $form2->addsubmit("unlink", $lang['general']['delete']); $form2->addcancel(); } if ($_POST['addlink'] && $form1->fill()) { try { $newcat = new CodeKBCategory($form1->value("newcat"), $user); if ($entry->addlink($form1->value("newcat"))) { $site->addcontent(notice(phrasereplace($lang['entry']['linkaddsucc'], "%1%", $newcat->name()))); if ($form2) { $form2->addcheckbox("cat_" . $newcat->id(), $newcat->name()); } } else { $site->addcontent(notice($lang['entry']['failedchange'])); } unset($newcat); } catch (Exception $e) { if ($e->getCode() == 1) { $site->addcontent(notice($lang['entry']['duplicate'])); $form1->setmissing("newcat"); } else { $site->addcontent(notice($lang['entry']['failedchange'])); } } } if ($_POST['unlink'] && is_object($form2) && $form2->fill()) { $id = $entry->id(); foreach ($catsofentry as $val) { if ($form2->value("cat_" . $val) == "1") { try { $entry->delink($val); $notice = $lang['entry']['linkremovesucc']; $form2->remove("cat_" . $val); } catch (Exception $e) { $form2->setmissing("cat_" . $val); $notice = $lang['entry']['failedunlink']; break; } } } if (!$user->entrycan("see", $entry, false)) { redirect("category.php?id=" . $cat); } $site->addcontent(notice($notice)); } $dialog = new CodeKBTemplate("dialog"); $dialog->push("legend", $lang['entry']['link']); $dialogcode = ""; if ($form1) { $dialogitem1 = new CodeKBTemplate("dialogitem"); $content = $form1->head(); $content .= $lang['entry']['linkaddexplain'] . "<br /><br />\n"; $dialogitem1->push("head", $content); $dialogitem1->push("content1", $form1->get()); $dialogitem1->push("tail", $form1->tail()); $dialogcode .= $dialogitem1->__toString(); } if ($form2) { $dialogitem2 = new CodeKBTemplate("dialogitem"); $content = $form2->head(); $content .= $lang['entry']['linkremoveexplain'] . "<br /><br />\n"; $dialogitem2->push("head", $content); $content = "<div class = \"forms\">\n"; $content .= $form2->get(); $content .= "</div>"; $dialogitem2->push("content1", $content); $dialogitem2->push("tail", $form2->tail()); $dialogcode .= $dialogitem2->__toString(); } $dialog->push("content", $dialogcode); $site->addcontent($dialog); return true; }
public function delete(&$dbobj = null, $level = 0) { // return values // 1 aborted recursion // Are we at the first recursion level? if (is_null($dbobj)) { $first = true; $db = new CodeKBDatabase(); $db->start(); $dbobj =& $db; } else { $first = false; $db =& $dbobj; } if ($this->_id == 0 || !$this->_user->can("delcat", $this)) { $db->abort(); return false; } $entries = $this->listentries(); foreach ($entries as $val) { $tmpentry = new CodeKBEntry($val['id'], $this->_user); $tmpentry->delink($this->_id); unset($tmpentry); } $db->dosql("SELECT id " . "FROM categories " . "WHERE parent = {$db->number($this->_id)}", $level); while ($val = $db->row($level)) { $subcat = new CodeKBCategory($val['id'], $this->_user); if (!$subcat->delete($db, $level + 1)) { $db->abort(); throw new CodeKBException(__METHOD__, "category", "faileddel", null, 1); } unset($subcat); } $db->dosql("DELETE FROM rights " . "WHERE category = {$db->number($this->_id)}", $level); $db->dosql("DELETE FROM categories " . "WHERE id = {$db->number($this->_id)}", $level); if ($first) { $db->commit(); } else { return $db->success(); } if ($db->success()) { return true; } $db->abort(); throw new CodeKBException(__METHOD__, "category", "faileddel"); }