Toggle main menu visibility
新聞
下載
教材
影音
討論
其他選單
好站連結
行事曆
電子相簿
常見問題
萬用表單
即時留言簿
友站消息
社大學員
:::
登入
登入
帳號
密碼
登入
重整畫面
:::
所有書籍
「1041 XOOPS模組開發」目錄
MarkDown
9-5 /include/notification.inc.php
1. XOOPS的開發環境
1-1 xoops_version.php
1-2 languages/tchinese_utf8/modinfo.php
1-3 images/logo.png
1-4 tad_ebook 資料表
1-5 tad_ebook_page 資料表
2. 後台頁面與表單物件
2-1 sql/mysql.sql
2-2 xoops_version.php
2-3 admin/menu.php
2-4 language/tchinese_utf8/modinfo.php
2-5 templates/tad_ebook_adm_main.html
2-6 admin/main.php
3. 樣板與管理功能
3-1 admin/main.php
3-2 temaplates/tad_ebook_adm_main.html
4. 前台頁面與HTML表單
4-1 admin/main.php
4-2 /templates/tad_ebook_adm_main.html
4-3 /interface_menu.php
4-4 /post.php
4-5 /templates/tad_ebook_post.html
4-6 /xoops_version.php
5. 前台顯示及各種控管
5-1 /post.php
5-2 /templates/tad_ebook_post.html
5-3 /index.php
5-4 /templates/tad_ebook_index.html
5-5 /xoops_version.php
6. XOOPS群組與權限
6-1 /admin/menu.php
6-2 /admin/groupperm.php
6-3 /modules/system/admin/groupperm.php
6-4 /interface_menu.php
6-5 /xoops_version.php
6-6 /function.php
6-7 /verify.php
6-8 /templates/tad_ebook_verify.html
6-9 /post.php
6-10 /templates/tad_ebook_post.html
7. 搜尋、語系、偏好設定、自動功能
7-1 /templates/tad_ebook_post.html
7-2 /xoops_version.php
7-3 /include/search.php
7-4 /admin/main.php
7-5 /language/tchinese_utf8/admin.php
7-6 /templates/tad_ebook_adm_main.html
7-7 /language/tchinese_utf8/modinfo.php
7-8 /post.php
7-9 /include/onUpdate.php
7-10 /include/onInstall.php
7-11 /sql/mysql.sql
7-12 /include/onUninstall.php
7-13 /index.php
8. 上傳、區塊與BootStrapS3
8-1 /xoops_version.php
8-2 /sql/mysql.sql
8-3 /include/onUpdate.php
8-4 /admin/main.php
8-5 /templates/tad_ebook_adm_main.html
8-6 /blocks/tad_ebook_list.php
8-7 /templates/blocks/tad_ebook_list.html
8-8 /index.php
8-9 /templates/tad_ebook_index.html
9. 評論與通知功能
9-1 /xoops_version.php
9-2 /index.php
9-3 /templates/tad_ebook_index.html
9-4 /comment_new.php
9-5 /include/notification.inc.php
9-6 /admin/main.php
9-7 /language/tchinese_utf8/mail_template/new_ebook.tpl
9-8 Uniform Server的信件設定
9-9 /templates/tad_ebook_index_b3.html
9-10 /templates/tad_ebook_verify_b3.html
9-11 bootstrap2與bootstrap3水平表單結構
9-12 /templates/tad_ebook_post_b3.html
9-13 /templates/tad_ebook_adm_main_b3.html
9-7 /language/tchinese_utf8/mail_template/new_ebook.tpl
1041 XOOPS模組開發 ============== ``` prefix('tad_ebook'); $sql="select * from `{$tbl}` where ebook_sn='{$ebook_sn}'"; $result=$xoopsDB->query($sql) or die(mysql_error()); $all=$xoopsDB->fetchArray($result); $ebook_title=$myts->htmlSpecialChars($all['ebook_title']); $ebook_post_date=strtotime($myts->htmlSpecialChars($all['ebook_post_date'])); $ebook_publish_date=strtotime($myts->htmlSpecialChars($all['ebook_publish_date'])); $ebook_content=$myts->displayTarea($all['ebook_content'], 1, 1, 1, 1, 0); $op='update_ebook'; }else{ $ebook_title = ""; $ebook_post_date = time() + 3600 * 24 * 14; $ebook_publish_date = time() + 3600 * 24 * 28; $ebook_content=""; $op='insert_ebook'; } //引入表單物件 include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php"); $form = new XoopsThemeForm('電子校刊管理表單', 'ebook', 'main.php', 'post', true); $form->setExtra("enctype='multipart/form-data'"); $Text = new XoopsFormText('電子校刊標題', 'ebook_title', 200 , 80 , $ebook_title); //$Text->setExtra("style='width: 400px; color: white; background-color: #000000;'"); $Text->setExtra("style='width: 400px;'"); $Text->setExtra("placeholder='"._MA_TADEBOOK_PLACEHOLDER."'"); $form->addElement($Text); $DateSelect=new XoopsFormTextDateSelect('投稿截止日', 'ebook_post_date', 15, $ebook_post_date); $DateSelect->setExtra("style='width: 100px;'"); $form->addElement($DateSelect); $DateSelect1=new XoopsFormTextDateSelect(_MA_TADEBOOK_PUBLIC_DATE, 'ebook_publish_date', 15, $ebook_publish_date); $DateSelect1->setExtra("style='width: 100px;'"); $form->addElement($DateSelect1); //CK編輯器 if(!file_exists(XOOPS_ROOT_PATH."/modules/tadtools/ck.php")){ redirect_header("http://www.tad0616.net/modules/tad_uploader/index.php?of_cat_sn=50",3, _TAD_NEED_TADTOOLS); } include_once XOOPS_ROOT_PATH."/modules/tadtools/ck.php"; $fck=new CKEditor("tad_ebook","ebook_content",$ebook_content); $fck->setHeight(350); $editor=$fck->render(); $form->addElement(new XoopsFormLabel('內容說明', $editor)); //上傳表單(enctype='multipart/form-data') include_once XOOPS_ROOT_PATH."/modules/tadtools/TadUpFiles.php" ; $TadUpFiles=new TadUpFiles("tad_ebook"); $TadUpFiles->set_col('ebook_sn',$ebook_sn); $upform=$TadUpFiles->upform(true,'ebook_pic'); $form->addElement(new XoopsFormLabel('上傳封面圖', "
$upform
")); $Tray=new XoopsFormElementTray('', ' ', ''); $Tray->addElement(new XoopsFormButton('', '', _SUBMIT, 'submit')); $Tray->addElement(new XoopsFormButton('', '', _RESET, 'reset')); $form->addElement($Tray); $form->addElement(new XoopsFormHidden('ebook_sn', $ebook_sn)); $form->addElement(new XoopsFormHidden('op', $op)); //安全機制 $form->addElement(new XoopsFormHiddenToken('XOOPS_TOKEN_REQUEST',360)); $ebook_form = $form->render(); $xoopsTpl->assign('ebook_form' , $ebook_form); } //寫入資料庫 function insert_ebook(){ global $xoopsDB; //安全判斷 if(!$GLOBALS['xoopsSecurity']->check()){ //錯誤訊息 $error=implode("
" , $GLOBALS['xoopsSecurity']->getErrors()); //轉向到首頁 redirect_header($_SERVER['PHP_SELF'],3, $error); } $myts =& MyTextSanitizer::getInstance(); $ebook_title=$myts->addSlashes($_POST['ebook_title']); $ebook_post_date=$myts->addSlashes($_POST['ebook_post_date']); $ebook_publish_date=$myts->addSlashes($_POST['ebook_publish_date']); $ebook_content=$myts->addSlashes($_POST['ebook_content']); $tbl=$xoopsDB->prefix('tad_ebook'); $sql="insert into `{$tbl}` (`ebook_title` ,`ebook_post_date` , `ebook_publish_date` , `ebook_content`) values('{$ebook_title}' , '{$ebook_post_date}' ,'{$ebook_publish_date}' ,'{$ebook_content}')"; $xoopsDB->query($sql) or die(mysql_error()); $ebook_sn=$xoopsDB->getInsertId(); //儲存: include_once XOOPS_ROOT_PATH."/modules/tadtools/TadUpFiles.php" ; $TadUpFiles=new TadUpFiles("tad_ebook"); $TadUpFiles->set_col('ebook_sn',$ebook_sn,0); $TadUpFiles->upload_file('ebook_pic',1024,150,NULL,NULL,true); $extra_tags['EBOOK_TITLE'] = $ebook_title; $extra_tags['POST_DATE'] = $ebook_post_date; $extra_tags['PUBLISH_DATE'] = $ebook_publish_date; $notification_handler =& xoops_gethandler('notification'); $notification_handler->triggerEvent ('global', 0 , 'new_ebook', $extra_tags); } //列出所有書籍 function ebook_list(){ global $xoopsDB , $xoopsTpl; //單一檔案真實路徑: include_once XOOPS_ROOT_PATH."/modules/tadtools/TadUpFiles.php" ; $TadUpFiles=new TadUpFiles("tad_ebook"); $myts =& MyTextSanitizer::getInstance(); $tbl=$xoopsDB->prefix('tad_ebook'); $sql="select * from `{$tbl}` order by ebook_sn desc"; $result=$xoopsDB->query($sql) or die(mysql_error()); $i=0; $all_data=""; while($all=$xoopsDB->fetchArray($result)){ $all['ebook_title']=$myts->htmlSpecialChars($all['ebook_title']); $all['del_title']=urlencode($all['ebook_title']); $all['ebook_post_date']=$myts->htmlSpecialChars($all['ebook_post_date']); $all['ebook_publish_date']=$myts->htmlSpecialChars($all['ebook_publish_date']); $TadUpFiles->set_col('ebook_sn',$all['ebook_sn']); $all['ebook_pic']=$TadUpFiles->get_pic_file('thumb'); $all_data[$i]=$all; $i++; } //die(var_export($all_data)); $xoopsTpl->assign('all_data' , $all_data); } //從資料庫刪除 function del_ebook($ebook_sn=""){ global $xoopsDB; $tbl=$xoopsDB->prefix('tad_ebook'); $sql="delete from `{$tbl}` where ebook_sn='{$ebook_sn}'"; $xoopsDB->queryF($sql) or die(mysql_error()); include_once XOOPS_ROOT_PATH."/modules/tadtools/TadUpFiles.php" ; $TadUpFiles=new TadUpFiles("tad_ebook"); $TadUpFiles->set_col('ebook_sn',$ebook_sn); $TadUpFiles->del_files(); } //更新資料庫 function update_ebook($ebook_sn=""){ global $xoopsDB; //安全判斷 if(!$GLOBALS['xoopsSecurity']->check()){ //錯誤訊息 $error=implode("
" , $GLOBALS['xoopsSecurity']->getErrors()); //轉向到首頁 redirect_header($_SERVER['PHP_SELF'],3, $error); } $myts =& MyTextSanitizer::getInstance(); $ebook_title=$myts->addSlashes($_POST['ebook_title']); $ebook_post_date=$myts->addSlashes($_POST['ebook_post_date']); $ebook_publish_date=$myts->addSlashes($_POST['ebook_publish_date']); $ebook_content=$myts->addSlashes($_POST['ebook_content']); $tbl=$xoopsDB->prefix('tad_ebook'); $sql=" update `{$tbl}` set `ebook_title`='{$ebook_title}' , `ebook_post_date`='{$ebook_post_date}' , `ebook_publish_date`='{$ebook_publish_date}', `ebook_content`='{$ebook_content}' where ebook_sn='{$ebook_sn}'"; $xoopsDB->queryF($sql) or die(mysql_error()); //儲存: include_once XOOPS_ROOT_PATH."/modules/tadtools/TadUpFiles.php" ; $TadUpFiles=new TadUpFiles("tad_ebook"); $TadUpFiles->set_col('ebook_sn',$ebook_sn,0); $TadUpFiles->upload_file('ebook_pic',1024,150,NULL,NULL,true); } /*-----------執行動作判斷區----------*/ $op=empty($_REQUEST['op'])?"":$_REQUEST['op']; $ebook_sn=isset($_REQUEST['ebook_sn'])?intval($_REQUEST['ebook_sn']):""; switch($op){ case "insert_ebook": insert_ebook(); //header("location:{$_SERVER['PHP_SELF']}"); redirect_header($_SERVER['PHP_SELF'],3, "儲存完成!"); exit; break; case "del_ebook": del_ebook($ebook_sn); header("location:{$_SERVER['PHP_SELF']}"); exit; break; case "update_ebook": update_ebook($ebook_sn); header("location:{$_SERVER['PHP_SELF']}"); exit; break; case "edit_ebook": ebook_form($ebook_sn); break; default: ebook_form(); ebook_list(); break; } /*-----------引入檔案區--------------*/ include_once 'footer.php'; ?> ```
:::
搜尋
search
進階搜尋
QR Code 區塊
快速登入
所有討論區
「PHP全端開發」線上課程討論區
XOOPS使用討論區
一般研習學員
社大學員專用
路過哈啦區
XOOPS佈景設計
XOOPS模組開發
Tad書籍區
即時留言簿
書籍目錄
展開
|
闔起
線上使用者
56
人線上 (
21
人在瀏覽
線上書籍
)
會員: 0
訪客: 56
更多…