source: temp/test-xoops.ec-cube.net/html/modules/xoopsfaq/index.php @ 405

Revision 405, 4.6 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: index.php,v 1.3 2005/09/04 20:46:12 onokazu Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27
28include 'header.php';
29$myts =& MyTextSanitizer::getInstance();
30$cat_id = isset($_GET['cat_id']) ? intval($_GET['cat_id']) : 0;
31if ($cat_id < 1) {
32    // this page uses smarty template
33    // this must be set before including main header.php
34    $xoopsOption['template_main'] = 'xoopsfaq_index.html';
35    include XOOPS_ROOT_PATH.'/header.php';
36    $xoopsTpl->assign('lang_faq', _XD_DOCS);
37    $xoopsTpl->assign('lang_categories', _XD_CATEGORIES);
38    $result = $xoopsDB->query('SELECT category_id, category_title FROM '.$xoopsDB->prefix('xoopsfaq_categories').' ORDER BY category_order ASC');
39    while (list($id, $name) = $xoopsDB->fetchRow($result)) {
40        $category = array();
41        $category['name'] = $myts->makeTboxData4Show($name);
42        $category['id'] = $id;
43        $sql = 'SELECT contents_id, contents_title FROM '.$xoopsDB->prefix('xoopsfaq_contents').' WHERE contents_visible=1 AND category_id='.$id.' ORDER BY contents_order ASC';
44        $result2 = $xoopsDB->query($sql);
45        while ($myrow = $xoopsDB->fetchArray($result2)) {
46            $category['questions'][] = array('id' => $myrow['contents_id'], 'title' => $myts->makeTboxData4Show($myrow['contents_title']));
47        }
48        $xoopsTpl->append_by_ref('categories', $category);
49        unset($category);
50    }
51} else {
52    // this page uses smarty template
53    // this must be set before including main header.php
54    $xoopsOption['template_main'] = 'xoopsfaq_category.html';
55    include XOOPS_ROOT_PATH.'/header.php';
56    $xoopsTpl->assign('lang_faq', _XD_DOCS);
57    $xoopsTpl->assign('lang_toc', _XD_TOC);
58    $xoopsTpl->assign('lang_main', _XD_MAIN);
59    $xoopsTpl->assign('lang_backtotop', _XD_BACKTOTOP);
60    $xoopsTpl->assign('lang_backtoindex', _XD_BACKTOINDEX);
61    $result = $xoopsDB->query('SELECT category_title FROM '.$xoopsDB->prefix('xoopsfaq_categories').' WHERE category_id='.$cat_id);
62    list($name) = $xoopsDB->fetchRow($result);
63    $xoopsTpl->assign('category_name', $myts->makeTboxData4Show($name));
64
65    $result = $xoopsDB->query('SELECT contents_id, category_id, contents_title, contents_contents, contents_time, contents_nohtml, contents_nosmiley, contents_noxcode FROM '.$xoopsDB->prefix('xoopsfaq_contents').' WHERE contents_visible=1 AND category_id='.$cat_id.' ORDER BY contents_order ASC');
66    $question = array();
67    while (list($id, $cat_id, $title, $contents, $time, $nohtml, $nosmiley, $noxcode) = $xoopsDB->fetchRow($result)) {
68        $title = $myts->makeTboxData4Show($title);
69        $question['title'] = $title;
70        $question['id'] = $id;
71        $html = !empty($nohtml) ? 0 :1;
72        $smiley = !empty($nosmiley) ? 0 :1;
73        $xcode = !empty($noxcode) ? 0 :1;
74        $question['answer'] = $myts->makeTareaData4Show($contents, $html, $smiley, $xcode);
75        $xoopsTpl->append('questions', $question);
76    }
77    include XOOPS_ROOT_PATH.'/include/comment_view.php';
78}
79
80include XOOPS_ROOT_PATH.'/footer.php';
81?>
Note: See TracBrowser for help on using the repository browser.