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; }
function showinput() { global $lang; global $conf; global $user; global $site; global $catid; global $file; $site->title($lang['file']['modify']); $site->addfooter("help.php?on=file#change", "help", $lang['menu']['help'], $lang['menu']['helpalt']); if (!$user->entrycan("changeentry", $file->entry())) { $site->addcontent(notice($lang['entry']['nochangeallowed'])); return false; } if ($_POST['cancel']) { redirect("entry.php?id=" . $file->entry()->id()); } $form = new CodeKBForm("file.php", "modify"); $form->addhidden("id", $file->id()); $form->addhidden("cat", $catid); $form->addtext("name", $file->name()); $form->addlabel("name", $lang['file']['name']); $form->setrequired("name"); $form->addfile("upload"); $form->addlabel("upload", $lang['file']['upload']); $form->addcombo("highlight", $conf['highlight']['binary'], null, $conf['highlight']['binary'] == $file->highlight()); foreach ($conf['highlight']['languages'] as $language) { $form->addcombo("highlight", $language, null, $language == $file->highlight()); } $form->addlabel("highlight", $lang['file']['language']); $db = new CodeKBDatabase(); $db->dosql("SELECT name, symbol " . "FROM symbols " . "WHERE symbol LIKE 'type_%'"); while ($val = $db->row()) { $form->addradio("symbol", $val['name'], icon($val['name'], $val['name']), $val['name'] == $file->symbol(), false); } $form->addbutton("submit"); $form->addbutton("cancel"); if ($_POST['submit']) { if (!$form->fill()) { $site->addcontent(notice($lang['general']['missing'])); } else { global $HTTP_POST_FILES; if (is_uploaded_file($HTTP_POST_FILES['upload']['tmp_name'])) { $upload = "upload"; } else { $upload = false; } try { $file->change($form->value("name"), $form->value("highlight"), $form->value("symbol"), $upload); if ($form->value("highlight") == $conf['highlight']['binary']) { redirect("entry.php?id=" . $file->entry()->id() . "&cat=" . $catid); } else { redirect("file.php?id=" . $file->id() . "&cat=" . $catid); } } catch (Exception $e) { $site->addcontent(notice($lang['entry']['failedfilechange'])); } } } $dialog = new CodeKBTemplate("dialog"); $dialog->push("legend", $lang['file']['modify']); $dialogitem = new CodeKBTemplate("dialogitem"); $content = $form->head(); $content .= $form->get("name"); $dialogitem->push("top", $content); $dialogitem->push("head", "(" . $lang['file']['newuploadexplain'] . ")<br />\n"); $dialogitem->push("content1", $form->get()); $dialogitem->push("tail", $form->tail()); $dialog->push("content", $dialogitem); $site->addcontent($dialog); return true; }
function showsort() { global $lang; global $user; global $site; global $conf; global $category; $site->title($lang['sort']['changeview']); $site->addfooter("help.php?on=category#view", "help", $lang['menu']['help'], $lang['menu']['helpalt']); $sort = $_SESSION['sort'] ? $_SESSION['sort'] : urldecode($_COOKIE['codekb_sort']); $order = $_SESSION['order'] != "" ? $_SESSION['order'] : urldecode($_COOKIE['codekb_order']); $age = $_SESSION['age'] != "" ? $_SESSION['age'] : urldecode($_COOKIE['codekb_age']); $whichage = $_SESSION['wage'] != "" ? $_SESSION['wage'] : urldecode($_COOKIE['codekb_wage']); $entriesperpage = $_SESSION['epp'] != "" ? $_SESSION['epp'] : urldecode($_COOKIE['codekb_epp']); if (!$entriesperpage) { $entriesperpage = $conf['layout']['entriesperpage']; } $dialog = new CodeKBTemplate("dialog"); $dialogitem = new CodeKBTemplate("dialogitem"); $form = new CodeKBForm("category.php", "cookie"); $form->addhidden("id", $category->id()); $form->addcombo("sort", $lang['sort']['sortbyname'], null, !$sort || $sort == $lang['sort']['sortbyname']); $form->addcombo("sort", $lang['sort']['sortbycreatedate'], null, $sort == $lang['sort']['sortbycreatedate']); $form->addcombo("sort", $lang['sort']['sortbymodifydate'], null, $sort == $lang['sort']['sortbymodifydate']); $form->addlabel("sort", $lang['sort']['sortby']); $form->addcombo("order", $lang['sort']['ascending'], null, !$order || $order == $lang['sort']['ascending']); $form->addcombo("order", $lang['sort']['descending'], null, $order == $lang['sort']['descending']); $form->addcheckbox("save", $lang['sort']['save']); $form->addcombo("age", $lang['search']['1day'], null, $age == $lang['search']['1day']); $form->addcombo("age", $lang['search']['7days'], null, $age == $lang['search']['7days']); $form->addcombo("age", $lang['search']['1month'], null, $age == $lang['search']['1month']); $form->addcombo("age", $lang['search']['3months'], null, $age == $lang['search']['3months']); $form->addcombo("age", $lang['search']['6months'], null, $age == $lang['search']['6months']); $form->addcombo("age", $lang['search']['1year'], null, $age == $lang['search']['1year']); $form->addcombo("age", $lang['search']['all'], null, !$age || $age == $lang['search']['all']); $form->addlabel("age", $lang['search']['notolder']); $form->addradio("whichage", $lang['sort']['sortbycreatedate'], $lang['sort']['sortbycreatedate'], !$whichage || $whichage == $lang['sort']['sortbycreatedate']); $form->addradio("whichage", $lang['sort']['sortbymodifydate'], $lang['sort']['sortbymodifydate'], $whichage == $lang['sort']['sortbymodifydate']); $form->addcombo("epp", "5", null, $entriesperpage == 5); $form->addcombo("epp", "10", null, $entriesperpage == 10); $form->addcombo("epp", "15", null, $entriesperpage == 15); $form->addcombo("epp", "20", null, $entriesperpage == 20); $form->addcombo("epp", "25", null, $entriesperpage == 25); $form->addcombo("epp", "30", null, $entriesperpage == 30); $form->addcombo("epp", "50", null, $entriesperpage == 50); $form->addcombo("epp", "100", null, $entriesperpage == 100); $form->addcombo("epp", $lang['search']['all'], null, $entriesperpage == $lang['search']['all']); $form->addlabel("epp", $lang['search']['entriesperpage']); $form->addbutton("submit"); $form->addbutton("cancel"); $dialogitem->push("head", $form->head()); $content = $form->get("sort"); $content .= $form->get("order"); $content .= "<br /><br /><br />" . $form->get("save"); $dialogitem->push("content1", $content); $content = $form->get("age"); $content .= $form->get("whichage"); $dialogitem->push("content2", $content); $content = $form->get("epp"); $dialogitem->push("content3", $content); $dialogitem->push("tail", "<br />" . $form->tail()); $dialog->push("legend", $lang['sort']['changeview']); $dialog->push("content", $dialogitem); $site->addcontent($dialog); return true; }
function showfiles() { global $lang; global $conf; global $user; global $site; global $category; global $entry; $site->title($lang['entry']['files']); $site->addfooter("help.php?on=file", "help", $lang['menu']['help'], $lang['menu']['helpalt']); if ($category) { $cat = $category->id(); } if (!$user->entrycan("changeentry", $entry)) { $site->addcontent(notice($lang['entry']['nochangeallowed'])); return false; } if ($_POST['cancel']) { redirect("entry.php?id=" . $entry->id() . "&cat=" . $cat); } $form1 = new CodeKBForm("entry.php", "files"); $form1->addhidden("id", $entry->id()); $form1->addhidden("cat", $cat); $form1->addfile("upload"); $form1->addlabel("upload", $lang['file']['upload']); $form1->addcombo("highlight", $conf['highlight']['binary']); while ($language = next($conf['highlight']['languages'])) { $form1->addcombo("highlight", $language, null, $language == "text"); } $form1->addlabel("highlight", $lang['file']['language']); $db = new CodeKBDatabase(); $db->dosql("SELECT name, symbol " . "FROM symbols " . "WHERE symbol LIKE 'type_%'"); while ($val = $db->row()) { $form1->addradio("symbol", $val['name'], icon($val['name'], $val['name']), $val['name'] == "Unkown", false); } $form1->addsubmit("addfile"); $form1->addcancel(); $form2 = new CodeKBForm("entry.php", "files"); $form2->addhidden("id", $entry->id()); $form2->addhidden("cat", $cat); $filesofentry = $entry->listfiles(); foreach ($filesofentry as $val) { $form2->addcheckbox("file_" . $val['id'], icon($val['symbol'], $val['name']) . " " . $val['name'] . " (" . url("file.php?id=" . $val['id'] . "&cat=" . $cat . "&action=modify", $lang['general']['modify']) . ")"); } $form2->addsubmit("removefile", $lang['general']['delete']); $form2->addcancel(); if ($_POST['addfile'] && $form1->fill()) { try { $ret = $entry->addfile("upload", $form1->value("highlight"), $form1->value("symbol")); $newfile = new CodeKBFile($ret, $user); $site->addcontent(notice($lang['file']['addsucc'])); $form2->addcheckbox("file_" . $newfile->id(), icon($newfile->symbol(), $newfile->name()) . " " . $newfile->name() . " (" . url("file.php?id=" . $newfile->id() . "&cat=" . $cat . "&action=modify", $lang['general']['modify']) . ")"); unset($newfile); } catch (Exception $e) { if ($e->getCode() == 1) { $site->addcontent(notice($lang['file']['uploadfailed'])); } else { $site->addcontent(notice($lang['file']['failedadd'])); } } } if ($_POST['removefile'] && $form2->fill()) { foreach ($filesofentry as $val) { try { if ($form2->value("file_" . $val['id']) == "1") { $tmpfile = new CodeKBFile($val['id'], $user); $tmpfile->delete(); unset($tmpfile); $notice = $lang['file']['delsucc']; $form2->remove("file_" . $val['id']); } } catch (Exception1 $e) { $notice = $lang['file']['failedremove']; break; } } $site->addcontent(notice($notice)); } $dialog = new CodeKBTemplate("dialog"); $dialog->push("legend", $lang['entry']['files']); $dialogcode = ""; $dialogitem1 = new CodeKBTemplate("dialogitem"); $content = $form1->head(); $content .= $lang['file']['addexplain'] . "<br /><br />\n"; $dialogitem1->push("head", $content); $dialogitem1->push("content1", $form1->get()); $dialogitem1->push("tail", $form1->tail()); $dialogcode .= $dialogitem1->__toString(); $content = $form2->head(); $content .= $lang['file']['removeexplain'] . "<br /><br />\n"; $dialogitem2 = new CodeKBTemplate("dialogitem"); $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; }