// // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // include '../../../include/cp_header.php'; if ( file_exists("../language/".$xoopsConfig['language']."/main.php") ) { include "../language/".$xoopsConfig['language']."/main.php"; } else { include "../language/english/main.php"; } $op = "listcat"; if (isset($HTTP_GET_VARS)) { foreach ($HTTP_GET_VARS as $k => $v) { $$k = $v; } } if (isset($HTTP_POST_VARS)) { foreach ($HTTP_POST_VARS as $k => $v) { $$k = $v; } } if ( !empty($contents_preview) ) { $myts =& MyTextSanitizer::getInstance(); xoops_cp_header(); $html = empty($contents_nohtml) ? 1 : 0; $smiley = empty($contents_nosmiley) ? 1 : 0; $xcode = empty($contents_noxcode) ? 1 : 0; $p_title = $myts->makeTboxData4Preview($contents_title); $p_contents = $myts->makeTareaData4Preview($contents_contents, $html, $smiley, $xcode); echo"
$p_title
$p_contents

"; $contents_title = $myts->makeTboxData4PreviewInForm($contents_title); $contents_contents = $myts->makeTareaData4PreviewInForm($contents_contents); include "contentsform.php"; xoops_cp_footer(); exit(); } if ($op == "listcat") { $myts =& MyTextSanitizer::getInstance(); xoops_cp_header(); echo "

"._XD_DOCS."

"; $result = $xoopsDB->query("SELECT c.category_id, c.category_title, c.category_order, COUNT(f.category_id) FROM ".$xoopsDB->prefix("xoopsfaq_categories")." c LEFT JOIN ".$xoopsDB->prefix("xoopsfaq_contents")." f ON f.category_id=c.category_id GROUP BY c.category_id ORDER BY c.category_order ASC"); $count = 0; while ( list($cat_id, $category, $category_order, $faq_count) = $xoopsDB->fetchRow($result) ) { $category=$myts->makeTboxData4Edit($category); echo ""; $count++; } if ($count > 0) { echo ""; } echo "
"._XD_CATEGORY.""._XD_ORDER.""._XD_CONTENTS." 
$faq_count " ._XD_CONTENTS." | "._DELETE."


"._XD_ADDCAT."

"._XD_TITLE."
"._XD_ORDER."
 
"; xoops_cp_footer(); exit(); } if ($op == "addcatgo") { $myts =& MyTextSanitizer::getInstance(); $category = $myts->makeTboxData4Save($category); $newid = $xoopsDB->genId($xoopsDB->prefix("xoopsfaq_categories")."_category_id_seq"); $sql = "INSERT INTO ".$xoopsDB->prefix("xoopsfaq_categories")." (category_id, category_title, category_order) VALUES ($newid, '".$category."', ".intval($order).")"; if (!$xoopsDB->query($sql)) { xoops_cp_header(); echo "Could not add category"; xoops_cp_footer(); } else { redirect_header("index.php?op=listcat",1,_XD_DBSUCCESS); } exit(); } if ($op == "editcatgo") { $myts =& MyTextSanitizer::getInstance(); $count = count($newcategory); for ($i = 0; $i < $count; $i++) { if ( $newcategory[$i] != $oldcategory[$i] || $neworder[$i] != $oldorder[$i] ) { $category = $myts->makeTboxData4Save($newcategory[$i]); $sql = "UPDATE ".$xoopsDB->prefix("xoopsfaq_categories")." SET category_title='".$category."', category_order=".intval($neworder[$i])." WHERE category_id=".$cat_id[$i].""; $xoopsDB->query($sql); } } redirect_header("index.php?op=listcat",1,_XD_DBSUCCESS); exit(); } if ($op == "listcontents") { $myts =& MyTextSanitizer::getInstance(); xoops_cp_header(); $sql = "SELECT category_title FROM ".$xoopsDB->prefix("xoopsfaq_categories")." WHERE category_id='".$cat_id."'"; $result = $xoopsDB->query($sql); list($category) = $xoopsDB->fetchRow($result); $category = $myts->makeTboxData4Show($category); echo "" ._XD_MAIN." »» ".$category."

"._XD_CONTENTS."

"; $result = $xoopsDB->query("SELECT contents_id, contents_title, contents_time, contents_order, contents_visible FROM ".$xoopsDB->prefix("xoopsfaq_contents")." WHERE category_id='".$cat_id."' ORDER BY contents_order"); $count = 0; while(list($id, $title, $time, $order, $visible) = $xoopsDB->fetchRow($result)) { $title = $myts->makeTboxData4Show($title); echo ""; $checked = ($visible == 1) ? " checked='checked'" : ""; echo ""; $count++; } if ($count > 0) { echo ""; } echo "
"._XD_TITLE.""._XD_ORDER.""._XD_DISPLAY." 
".$title." "._EDIT." | "._DELETE."


"._XD_ADDCONTENTS."

"; $contents_title = ""; $contents_contents = ""; $contents_order = 0; $contents_visible = 1; $contents_nohtml = 0; $contents_nosmiley = 0; $contents_noxcode = 0; $contents_id = 0; $category_id = $cat_id; $op = "addcontentsgo"; include "contentsform.php"; xoops_cp_footer(); exit(); } if ($op == "quickeditcontents") { $myts =& MyTextSanitizer::getInstance(); $count = count($id); for ($i = 0; $i < $count; $i++) { $index = $id[$i]; if ( $neworder[$index] != $oldorder[$index] || $newvisible[$index] != $oldvisible[$index] ) { $xoopsDB->query("UPDATE ".$xoopsDB->prefix("xoopsfaq_contents")." SET contents_order=".intval($neworder[$index]).", contents_visible=".intval($newvisible[$index])." WHERE contents_id=".$index.""); } } redirect_header("index.php?op=listcontents&cat_id=$cat_id",1,_XD_DBSUCCESS); exit(); } if ($op == "addcontentsgo") { $myts =& MyTextSanitizer::getInstance(); $title = $myts->makeTboxData4Save($contents_title); $contents = $myts->makeTareaData4Save($contents_contents); $newid = $xoopsDB->genId($xoopsDB->prefix("xoopsfaq_contents")."_contents_id_seq"); $sql = "INSERT INTO ".$xoopsDB->prefix("xoopsfaq_contents")." (contents_id, category_id, contents_title, contents_contents, contents_time, contents_order, contents_visible, contents_nohtml, contents_nosmiley, contents_noxcode) VALUES (".$newid.", ".$category_id.", '".$title."', '".$contents."', ".time().", ".intval($contents_order).", ".intval($contents_visible).", ".intval($contents_nohtml).", ".intval($contents_nosmiley).", ".intval($contents_noxcode).")"; if (!$xoopsDB->query($sql)) { xoops_cp_header(); echo "Could not add contents"; xoops_cp_footer(); } else { redirect_header("index.php?op=listcontents&cat_id=$category_id",1,_XD_DBSUCCESS); } exit(); } if ($op == "editcontents") { $myts =& MyTextSanitizer::getInstance(); xoops_cp_header(); $sql = "SELECT category_title FROM ".$xoopsDB->prefix("xoopsfaq_categories")." WHERE category_id='".$cat_id."'"; $result = $xoopsDB->query($sql); list($category) = $xoopsDB->fetchRow($result); $category = $myts->makeTboxData4Show($category); $result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("xoopsfaq_contents")." WHERE contents_id='$id'"); $myrow = $xoopsDB->fetchArray($result); $contents_title = $myts->makeTboxData4Edit($myrow['contents_title']); $contents_contents = $myts->makeTareaData4Edit($myrow['contents_contents']); $contents_order = $myrow['contents_order']; $contents_visible = $myrow['contents_visible']; $contents_nohtml = $myrow['contents_nohtml']; $contents_nosmiley = $myrow['contents_nosmiley']; $contents_noxcode = $myrow['contents_noxcode']; $contents_id = $myrow['contents_id']; $category_id = $myrow['category_id']; $op = "editcontentsgo"; echo "" ._XD_MAIN." »» ".$category." »» "._XD_EDITCONTENTS."

"._XD_EDITCONTENTS."

"; include "contentsform.php"; xoops_cp_footer(); exit(); } if ($op == "editcontentsgo") { $myts =& MyTextSanitizer::getInstance(); $title = $myts->makeTboxData4Save($contents_title); $contents = $myts->makeTareaData4Save($contents_contents); $nohtml = empty($contents_nohtml) ? 0 : 1; $nosmiley = empty($contents_nosmiley) ? 0 : 1; $noxcode = empty($contents_noxcode) ? 0 : 1; $sql = "UPDATE ".$xoopsDB->prefix("xoopsfaq_contents")." set contents_title='".$title."', contents_contents='".$contents."', contents_time=".time().", contents_order=".intval($contents_order).", contents_visible=".intval($contents_visible).", contents_nohtml=".$nohtml.", contents_nosmiley=".$nosmiley.", contents_noxcode=".$noxcode." WHERE contents_id=".$contents_id.""; if (!$xoopsDB->query($sql)) { xoops_cp_header(); echo "Could not update contents"; xoops_cp_footer(); } else { redirect_header("index.php?op=listcontents&cat_id=$category_id",1,_XD_DBSUCCESS); } exit(); } if ($op == "delcat") { if ($ok == 1) { $sql = sprintf("DELETE FROM %s WHERE category_id = %u", $xoopsDB->prefix("xoopsfaq_categories"), $cat_id); if (!$xoopsDB->query($sql)) { xoops_cp_header(); echo "Could not delete category"; xoops_cp_footer(); } else { $sql = sprintf("DELETE FROM %s WHERE category_id = %u", $xoopsDB->prefix("xoopsfaq_contents"), $cat_id); $xoopsDB->query($sql); // delete comments xoops_comment_delete($xoopsModule->getVar('mid'), $cat_id); redirect_header("index.php?op=listcat",1,_XD_DBSUCCESS); } exit(); } else { xoops_cp_header(); xoops_confirm(array('op' => 'delcat', 'cat_id' => $cat_id, 'ok' => 1), 'index.php', _XD_RUSURECAT); xoops_cp_footer(); exit(); } } if ($op == "delcontents") { if ($ok == 1) { $sql = sprintf("DELETE FROM %s WHERE contents_id = %u", $xoopsDB->prefix("xoopsfaq_contents"), $id); if (!$xoopsDB->query($sql)) { xoops_cp_header(); echo "Could not delete contents"; xoops_cp_footer(); } else { redirect_header("index.php?op=listcontents&cat_id=$cat_id",1,_XD_DBSUCCESS); } exit(); } else { xoops_cp_header(); xoops_confirm(array('op' => 'delcontents', 'id' => $id, 'ok' => 1), 'index.php', _XD_RUSURECAT); xoops_cp_footer(); exit(); } } ?>