} if (isset($_POST['save']) && !empty($_POST['data']['dict'])) { $_POST['data']['dict']['word'] = pb_lang_merge($_POST['data']['multi']); $vals = $_POST['data']['dict']; if (isset($_POST['id'])) { $id = intval($_POST['id']); } if (!empty($id)) { $vals['modified'] = $time_stamp; $result = $dict->save($vals, "update", $id); } else { $vals['created'] = $vals['modified'] = $time_stamp; $result = $dict->save($vals); } if (!$result) { flash(); } } if (isset($_GET['q'])) { $conditions[] = "word like '%" . $_GET['q'] . "%'"; } if (isset($_REQUEST['del']) && !empty($_REQUEST['id'])) { $deleted = false; $deleted = $dict->del($_REQUEST['id']); } $amount = $dict->findCount(null, $conditions); $page->setPagenav($amount); $result = $dict->findAll("Dict.*,t.name AS typename", array("LEFT JOIN {$tb_prefix}dicttypes t ON Dict.dicttype_id=t.id"), $conditions, "Dict.id DESC", $page->firstcount, $page->displaypg); setvar("Items", $result); setvar("ByPages", $page->pagenav); template($tpl_file);
require "../share.inc.php"; uses("dicttype", "dict"); $conditions = array(); $dict = new Dicts(); $dicttype = new Dicttypes(); $viewhelper->setPosition(L("dictionary", "tpl"), "dict/"); $viewhelper->setTitle(L("dictionary", "tpl")); if (isset($_GET['do'])) { $do = trim($_GET['do']); if ($do == "search") { if (!empty($_GET['q'])) { $conditions[] = "word like '%" . $_GET['q'] . "%'"; } if (isset($_GET['typeid'])) { $type_id = intval($_GET['typeid']); $conditions[] = "dicttype_id='" . $type_id . "'"; } $amount = $dict->findCount(null, $conditions); $result = $dict->findAll("Dict.*,dp.name AS typename", array("LEFT JOIN {$tb_prefix}dicttypes dp ON dp.id=Dict.dicttype_id"), $conditions, "Dict.id DESC", $pos, $limit); if (!empty($result)) { setvar("items", $result); setvar("paging", array('total' => $amount)); } render("dict/list"); exit; } } //get dictionary types. $dict_types = $dicttype->getAllTypes(); setvar("Dictypes", $dict_types); render("dict/index");