Файл: Arhmobi_esdcms/faq/cat.php
Строк: 35
<?php
include_once '../sys/inc/start.php';
$doc = new document();
$doc->title = __('FAQ');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
header('Refresh: 1; url=./');
$doc->err(__('Ошибка выбора раздела'));
exit;
}
$id_top = (int) $_GET['id'];
$q = $db->prepare("SELECT * FROM `faq_cat` WHERE `id` = ?");
$q->execute(Array($id_top));
if (!$topic = $q->fetch()) {
header('Refresh: 1; url=./');
$doc->err(__('Категория не доступна'));
exit;
}
$doc->title .= ' - ' . $topic['name'];
$pages = new pages($db->query("SELECT COUNT(*) FROM `faq` WHERE `id_cat` = '$topic[id]' ")->fetchColumn());
if (isset($_POST ['faq']) && isset($_POST ['name'])) {
$faq = text::input_text($_POST ['faq']);
$name = text::for_name($_POST ['name']);
if ($faq && $name) {
$res = $db->prepare("INSERT INTO `faq` (`name`,`id_cat`,`faqq`) VALUES (?, ?, ?)");
$res->execute(Array($name,$topic['id'],$faq));
} else {
$doc->err(__('Поле вопроса или ответа пусты'));
}
}
if ($user->group >= 4) {
$form = new form('?id='.$topic['id'].'&' . passgen());
$form->text('name', __('Вопрос'),NULL,1,30);
$form->textarea('faq', __('Ответ'));
$form->button(__('Отправить'));
$form->display();
}
$listing = new listing();
$q = $db->query("SELECT * FROM `faq` WHERE `id_cat` = '$topic[id]' ORDER BY `id` ".$dcms->root_asc_desc);
if ($arr = $q->fetchAll()) {
foreach ($arr AS $faq) {
$post = $listing->post();
$post->id = 'faqq_m_' . $faq['id'];
$post->title = '<b>Вопрос:</b> '. $faq['name'];
$post->post = '<b>Ответ:</b>'.text::toOutput($faq['faqq']);
$post->icon('info');
if ($user->group >=4) {
$post->action('delete', 'faq.del.php?id='.$faq['id'].'');
$post->action('edit', "faq.edit.php?id=$faq[id]&return=" . URL);
}
}
}
$listing->display(__('Категория пуста'));
if ($user->group >=4) {
$doc->act(__('Параметры раздела'), 'cat.edit.php?id=' . $topic['id'] . "&return=" . URL);
}
$doc->ret(__('FAQ'), './');
?>