getVar("dirname") . "/class/admin.php" ; $index_admin = new ModuleAdmin() ; echo $index_admin->addNavigation('cate.php') ; /*** 引入檔案 ***/ /*** 函數檔 ***/ function cate_form($cate_sn=null){ include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php"); if(!empty($cate_sn)){ $cate=get_cate($cate_sn); }else{ $cate=array(); } //建立表單物件 post , get $form = new XoopsThemeForm('分類設定', 'cate', 'cate.php', 'post'); //建立文字輸入框物件 $XoopsFormText =new XoopsFormText('分類標題', 'cate_title', 40 , 255 , $cate['cate_title']); $XoopsFormText->setDescription ("請設定一個分類名稱"); $form->addElement($XoopsFormText , true); $form->addElement(new XoopsFormText('分類排序', 'cate_sort', 4 , 4 , $cate['cate_sort']) , true); //建立單選物件 $XoopsFormRadio =new XoopsFormRadio('是否使用', 'cate_enable' , $cate['cate_enable']); //$XoopsFormRadio->addOption('1', '是'); //$XoopsFormRadio->addOption('0', '否'); $options['1']='是'; $options['0']='否'; $XoopsFormRadio->addOptionArray($options); $form->addElement($XoopsFormRadio); if(!empty($cate_sn)){ $form->addElement(new XoopsFormHidden('op', 'update')); $form->addElement(new XoopsFormHidden('cate_sn', $cate_sn)); }else{ $form->addElement(new XoopsFormHidden('op', 'insert')); } $Tray1=new XoopsFormElementTray('', ' ', 'name'); $Tray1->addElement(new XoopsFormButton('', '', '送出', 'submit')); $Tray1->addElement(new XoopsFormButton('', '', '清除', 'reset')); $form->addElement($Tray1); $form->addElement(new XoopsFormHiddenToken()); $f=$form->render(); return $f; } //取得某筆分類資料陣列 function get_cate($cate_sn=null){ global $xoopsDB; $sql="select * from ".$xoopsDB->prefix("tad_note_cate")." where `cate_sn` = '{$cate_sn}'"; $result = $xoopsDB->query($sql) or redirect_header('cate.php', 3, mysql_error()); $cate=$xoopsDB->fetchArray($result); return $cate; } //寫入函數 function insert_cate(){ global $xoopsDB; if(!$GLOBALS['xoopsSecurity']->check()){ $error=implode("" , $GLOBALS['xoopsSecurity']->getErrors()); redirect_header($_SERVER['PHP_SELF'],3, $error); exit; } $sql="insert into ".$xoopsDB->prefix("tad_note_cate")." (`cate_title` , `cate_sort` , `cate_enable`) values('{$_POST['cate_title']}' , '{$_POST['cate_sort']}' , '{$_POST['cate_enable']}')"; $xoopsDB->queryF($sql) or redirect_header('cate.php', 3, mysql_error()); } //列出所有分類資料 function list_cate(){ global $xoopsDB; $sql="select * from ".$xoopsDB->prefix("tad_note_cate")." order by `cate_sort`"; $result = $xoopsDB->query($sql) or redirect_header('cate.php', 3, mysql_error()); $main="
進階搜尋
51人線上 (12人在瀏覽線上書籍)
會員: 0
訪客: 51