Toggle main menu visibility
新聞
下載
教材
影音
討論
其他選單
好站連結
行事曆
電子相簿
常見問題
萬用表單
即時留言簿
友站消息
社大學員
:::
登入
登入
帳號
密碼
登入
重整畫面
:::
所有書籍
「[1071]XOOPS模組開發」目錄
MarkDown
9-4 interface_menu.php
1. XOOPS模組基礎架構
1-1 xoops_version.php
1-2 sql/mysql.sql
1-3 admin/menu.php
1-4 language/tchinese_utf8
1-5 admin/main.php
1-6 templates/snews_adm_main.tpl
1-7 admin/topic.php
1-8 templates/snews_adm_topic.tpl
2. 表單、資料庫、使用者物件
2-1 admin/main.php
2-2 templates/snews_adm_main.tpl
2-3 templates/op_snews_list.tpl
2-4 templates/op_snews_form.tpl
2-5 sql/mysql.php
2-6 xoops_version.php
2-7 function.php
3. 前台顯示、編輯、刪除
3-1 index.php
3-2 xoops_version.php
3-3 menu.php
3-4 header.php
3-5 templates/snews_index.tpl
3-6 templates/op_snews_show.tpl
3-7 templates/op_snews_list.tpl
3-8 admin/main.php
4. 首頁精選文章輪播
4-1 admin/main.php
4-2 index.php
4-3 templates/op_snews_show.tpl
4-4 templates/op_snews_list.tpl
5. 自動生成群組並做權限判斷
5-1 xoops_version.php
5-2 interface_menu.php
5-3 header.php
5-4 index.php
5-5 admin/main.php
5-6 include/onUpdate.php
5-7 include/onInstall.php
5-8 include/onUninstall.php
5-9 templates/op_snews_list.tpl
5-10 templates/op_snews_show.tpl
5-11 include/search.php
6. json應用與XOOPS區塊
6-1 xoops_version.php
6-2 language/tchinese_utf8/modinfo.php
6-3 index.php
6-4 html.php
6-5 templates/op_snews_show.tpl
6-6 function.php
6-7 blocks/snews_block_focus.php
6-8 blocks/snews_block_focus.tpl
6-9 css/module.css
6-10 interface_menu.php
6-11 language/tchinese_utf8/blocks.php
6-12 templates/op_snews_list.tpl
6-13 function_block.php
7. 產生PDF及拉動排序
7-1 templates/snews_index.tpl
7-2 templates/op_snews_list.tpl
7-3 index.php
7-4 css/module.css
7-5 templates/op_snews_show.tpl
7-6 pdf.php
7-7 interface_menu.php
7-8 pdf_all.php
8. Excel匯出匯入及點擊編輯
8-1 interface_menu.php
8-2 focus.php
8-3 function.php
8-4 templates/op_snews_focus.tpl
8-5 save_sort.php
8-6 excel.php
8-7 excel2.php
8-8 import.php
8-9 templates/op_import_form.tpl
9. 產生word檔、壓縮及解壓
9-1 index.php
9-2 templates/op_snews_show.tpl
9-3 save.php
9-4 interface_menu.php
9-5 word.php
9-6 zip.php
9-7 templates/op_zip_import.tpl
9-6 zip.php
\[1071\]XOOPS模組開發 ================= ``` setDefaultFontName('標楷體'); //設定預設字型 $phpWord->setDefaultFontSize(9); //設定預設字型大小 $sectionStyle = array( // 'orientation' => 'portrait', //landscape(橫);portrait(直) 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.5), 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.5), 'marginRight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.5), 'marginBottom' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.5), // 'colsNum' => 2, //幾欄 // 'pageNumberingStart' => 1, //第幾頁 // 'borderTopSize' => 2, //上邊框 // 'borderTopColor' => '0000FF', //上邊框顏色 // 'lineNumbering' => array('start' => 1, 'increment' => 1), //行號設定 ); $section = $phpWord->addSection($sectionStyle); //建立一個區域 $sn=(int)$_GET['sn']; if($sn){ $filename=snews_word($sn); }else{ $filename=snews_word_list(); } // $cellStyle = array('bgColor' => 'ffffff'); //正常格子 // $cellRowSpan = array('vMerge' => 'restart'); //垂直合併 // $cellContinue = array('vMerge' => 'continue'); //略過 // $cellColSpan = array('gridSpan' => 2); //水平合併 // $tableStyle = array('borderColor' => '000000', 'borderSize' => 6, 'cellMargin' => 80); // $table = $section->addTable($tableStyle); // $table->addRow(); // $table->addCell(2000, $cellColSpan)->addText('A'); // $table->addCell(1000, $cellRowSpan)->addText('B'); // $table->addRow(); // $table->addCell(1000, $cellRowSpan)->addText('C'); // $table->addCell(1000, $cellStyle)->addText('D'); // $table->addCell(1000, $cellContinue); // $table->addRow(); // $table->addCell(1000, $cellContinue); // $table->addCell(2000, $cellColSpan)->addText('E'); $filename = iconv("UTF-8", "Big5", $filename); if($_GET['type']=="odt"){ //輸出 odt $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); header('Content-Type: application/vnd.oasis.opendocument.text'); header("Content-Disposition: attachment;filename={$filename}.odt"); }else{ //輸出 docx $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); header('Content-Type: application/vnd.ms-word'); header("Content-Disposition: attachment;filename={$filename}.docx"); } header('Cache-Control: max-age=0'); $objWriter->save('php://output'); function snews_word($sn){ global $xoopsDB, $section,$phpWord; $myts = MyTextSanitizer::getInstance(); $tbl = $xoopsDB->prefix('snews'); $sql = "SELECT * FROM `$tbl` WHERE `sn` = '{$sn}'"; $result = $xoopsDB->query($sql) or web_error($sql); $snews = $xoopsDB->fetchArray($result); // $content = $myts->displayTarea($snews['content'], 1, 0, 0, 0, 0); $word_title= $myts->htmlSpecialChars($snews['title']); $username = $myts->htmlSpecialChars($snews['username']); $fontStyle = array('color' => '000000', 'size' => 24, 'bold' => true); $paragraphStyle = array('align' => 'center', 'valign' => 'center','spaceAfter'=>500); $phpWord->addTitleStyle(1, $fontStyle, $paragraphStyle); //設定標題N樣式 $section->addTitle( $word_title, 1 ); //新增標題 $fontStyle = array('color' => '000000', 'size' => 14, 'bold' => false); $paragraphStyle = array('align' => 'center'); $section->addText($username, $fontStyle, $paragraphStyle); $fontStyle = array('color' => '000000', 'size' => 12, 'bold' => false); $paragraphStyle = array('align' => 'both'); $images=linkExtractor($snews['content']); $snews['content']=replace_images($snews['content']); $content = strip_tags($snews['content']); $contents = explode("\n",$content); $i=0; // die(var_export($contents)); foreach($contents as $content){ // $content = str_replace(array("\n", "\r", " "), '', strip_tags($content)); if(strpos($content,'巷談集圖片')!==false){ $style=array('width'=>600); $section->addImage( $images[$i], $style ); $i++; }else{ $content = $myts->htmlSpecialChars($content); $section->addText($content, $fontStyle, $paragraphStyle); } } $word_title= str_replace(array(" "), '' , $word_title); return $word_title; } function snews_word_list(){ global $xoopsDB, $section,$phpWord; $topic['1'] = '街巷故事'; $topic['2'] = '市井觀點'; $topic['3'] = '私房知識塾'; $word_title="所有文章"; $fontStyle = array('color' => '000000', 'size' => 24, 'bold' => true); $paragraphStyle = array('align' => 'center', 'valign' => 'center','spaceAfter'=>500); $phpWord->addTitleStyle(1, $fontStyle, $paragraphStyle); //設定標題N樣式 $section->addTitle( $word_title, 1 ); //新增標題 $tableStyle = array('borderColor' => '000000', 'borderSize' => 6, 'cellMargin' => 80); $table = $section->addTable($tableStyle); $rowStyle = array('cantSplit' => true, 'tblHeader' => true); $table->addRow(10, $rowStyle); $cellStyle = array('bgColor' => 'CFCFCF'); $fontStyle = array('size' => 12, 'bold' => true); $paragraphStyle = array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2), $cellStyle)->addText('分類', $fontStyle, $paragraphStyle); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $cellStyle)->addText('日期', $fontStyle, $paragraphStyle); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(6), $cellStyle)->addText('標題', $fontStyle, $paragraphStyle); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $cellStyle)->addText('作者', $fontStyle, $paragraphStyle); $myts = MyTextSanitizer::getInstance(); $tbl = $xoopsDB->prefix('snews'); $sql = "SELECT * FROM `$tbl` ORDER BY `topic_sn`, `update_time` DESC"; $result = $xoopsDB->query($sql) or web_error($sql); $cellStyle = array('bgColor' => 'FFFFFF'); $fontStyle = array('size' => 12, 'bold' => false); $cellRowSpan = array('vMerge' => 'restart'); //垂直合併 $cellContinue = array('vMerge' => 'continue'); //略過 $cellColSpan = array('gridSpan' => 2); //水平合併 $old_topic_sn = ''; while ($snews = $xoopsDB->fetchArray($result)) { $topic_sn=$snews['topic_sn']; $snews['update_time'] = $myts->htmlSpecialChars($snews['update_time']); $snews['title'] = $myts->htmlSpecialChars($snews['title']); $snews['username'] = $myts->htmlSpecialChars($snews['username']); if($topic_sn != $old_topic_sn){ $topicStyle = $cellRowSpan; }else{ $topicStyle =$cellContinue; } $old_topic_sn=$topic_sn; $table->addRow(10, $rowStyle); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2), $topicStyle)->addText($topic[$topic_sn], $fontStyle); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $cellStyle)->addText($snews['update_time'], $fontStyle); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(6), $cellStyle)->addText($snews['title'], $fontStyle); $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $cellStyle)->addText($snews['username'], $fontStyle); // $all_news[$topic_sn][]=$snews; } // foreach($all_news as $topic_sn=>$topic_snews){ // $i=0; // foreach($topic_snews as $snews){ // $table->addRow(10, $rowStyle); // $topicStyle = $i?$cellContinue:$cellRowSpan; // $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2), $topicStyle)->addText($topic[$topic_sn], $fontStyle); // $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $cellStyle)->addText($snews['update_time'], $fontStyle); // $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(6), $cellStyle)->addText($snews['title'], $fontStyle); // $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(4), $cellStyle)->addText($snews['username'], $fontStyle); // $i++; // } // } return $word_title; } //從網頁語法中抓出圖片連結的函數 function linkExtractor($html){ $linkArray = array(); if (preg_match_all('/
]*)[\"\']?[^>]*>/i', $html, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { array_push($linkArray, $match[1]); } } return $linkArray; } //將網頁語法中的圖片語法取代為自訂文字, function replace_images($html){ $html = preg_replace('/
]*)[\"\']?[^>]*>/i', '巷談集圖片', $html); return $html; } ```
:::
搜尋
search
進階搜尋
QR Code 區塊
快速登入
所有討論區
「PHP全端開發」線上課程討論區
XOOPS使用討論區
一般研習學員
社大學員專用
路過哈啦區
XOOPS佈景設計
XOOPS模組開發
Tad書籍區
即時留言簿
書籍目錄
展開
|
闔起
線上使用者
55
人線上 (
11
人在瀏覽
線上書籍
)
會員: 0
訪客: 55
更多…