Skip to content

Commit e93f117

Browse files
author
zyspec
committed
initial commit
1 parent 9475dae commit e93f117

73 files changed

Lines changed: 3440 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
![alt XOOPS CMS](http://xoops.org/images/logoXoops4GithubRepository.png)
2+
## XoopsFaq module for [XOOPS CMS 2.5.9+](https://xoops.org)
3+
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](LICENSE)
4+
[![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](http://xoops.org)
5+
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/XoopsModules25x/xoopsfaq.svg?style=flat)](https://scrutinizer-ci.com/g/XoopsModules25x/xoopsfaq/?branch=master)
6+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2c1ce57c3e6f4d5b9b55198b4305cd14)](https://www.codacy.com/app/XoopsModules25x/xoopsfaq_2)
7+
[![Code Climate](https://img.shields.io/codeclimate/github/XoopsModules25x/xoopsfaq.svg?style=flat)](https://codeclimate.com/github/XoopsModules25x/xoopsfaq)
8+
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/67dff878-c997-4264-a709-7dede15759d6/mini.png)](https://insight.sensiolabs.com/projects/67dff878-c997-4264-a709-7dede15759d6)
9+
[![Latest Pre-Release](https://img.shields.io/github/tag/XoopsModules25x/xoopsfaq.svg?style=flat)](https://github.com/XoopsModules25x/xoopsfaq/tags/)
10+
[![Latest Version](https://img.shields.io/github/release/XoopsModules25x/xoopsfaq.svg?style=flat)](https://github.com/XoopsModules25x/xoopsfaq/releases/)
11+
12+
XOOPS FAQ is a [XOOPS](http://xoops.org) module to create Frequently Asked Questions (FAQs) and organize
13+
them by categories. Each category allows the administrator to create an unlimited number of questions and answers.
14+
15+
*FAQs can be organized into a virtually unlimited number of categories
16+
*Visibility of categories (and FAQs by inheritance) can be restricted using XOOPs Group Permissions
17+
*Virtually unlimited number of FAQs per category
18+
*Display of FAQs uses XOOPS templating system
19+
*Supports XOOPS commenting
20+
*FAQ answer display is controlled by javascript (in non-bootsrap themes) to provide a show/hide accordion effect
21+
*Uses XOOPS editors to allow for rich text display of FAQ answers.
22+
*Three (3) cloneable blocks are available to display Categories, Random FAQ, and most Recent FAQ(s)
23+
*Blocks allow varying visibility based on group permissions
24+
25+
[![Translations on Transifex](http://xoops.org/images/translations-transifex-blue.svg)](https://www.transifex.com/xoops)
26+
27+
Current and upcoming "next generation" versions of XOOPS CMS are being crafted on GitHub at: https://github.com/XOOPS

admin/about.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/*
3+
You may not change or alter any portion of this comment or credits of
4+
supporting developers from this source code or any supporting source code
5+
which is considered copyrighted (c) material of the original comment or credit
6+
authors.
7+
8+
This program is distributed in the hope that it will be useful, but
9+
WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
12+
/**
13+
* Category Admin file
14+
*
15+
* @package module\xoopsfaq\admin
16+
* @author Mage, Mamba
17+
* @author XOOPS Module Development Team
18+
* @copyright Copyright (c) 2001-2017 {@link http://xoops.org XOOPS Project}
19+
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
20+
* @since:: 1.23
21+
*
22+
* @see Xmf\Module\Admin
23+
*/
24+
25+
include_once __DIR__ . '/admin_header.php';
26+
27+
xoops_cp_header();
28+
29+
$adminObject->displayNavigation('about.php');
30+
$adminObject->setPaypal('xoopsfoundation@gmail.com');
31+
$adminObject->displayAbout(false);
32+
33+
include __DIR__ . '/admin_footer.php';

admin/admin_footer.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/*
3+
You may not change or alter any portion of this comment or credits of
4+
supporting developers from this source code or any supporting source code
5+
which is considered copyrighted (c) material of the original comment or credit
6+
authors.
7+
8+
This program is distributed in the hope that it will be useful, but
9+
WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
12+
/**
13+
* Admin page footer file
14+
*
15+
* @package module\xoopsfaq\admin
16+
* @author Magic.Shao <magic.shao@gmail.com>, Susheng Yang <ezskyyoung@gmail.com>
17+
* @author XOOPS Module Development Team
18+
* @copyright Copyright (c) 2001-2017 {@link http://xoops.org XOOPS Project}
19+
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
20+
* @since:: 1.23
21+
*
22+
* @see Xmf\Module\Admin
23+
*/
24+
echo "<div class='adminfooter'>\n"
25+
. "<div class='center'>\n"
26+
. "<a href='http://www.xoops.org' rel='external' target='_blank'>"
27+
. "<img src='" . Xmf\Module\Admin::iconUrl('xoopsmicrobutton.gif', '32') . "' "
28+
. "alt='XOOPS' title='XOOPS'></a>\n"
29+
. "</div>\n"
30+
. _AM_MODULEADMIN_ADMIN_FOOTER . "\n"
31+
. "</div>\n";
32+
33+
xoops_cp_footer();

admin/admin_header.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/*
3+
You may not change or alter any portion of this comment or credits of
4+
supporting developers from this source code or any supporting source code
5+
which is considered copyrighted (c) material of the original comment or credit
6+
authors.
7+
8+
This program is distributed in the hope that it will be useful, but
9+
WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
12+
/**
13+
* Admin display footer file
14+
*
15+
* @package module\xoopsfaq\admin
16+
* @author XOOPS Module Development Team
17+
* @copyright Copyright (c) 2001-2017 {@link http://xoops.org XOOPS Project}
18+
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
19+
* @since:: 1.23
20+
*
21+
* @see Xmf\Module\Admin
22+
* @see Xmf\Module\Helper
23+
*/
24+
25+
$moduleDirName = basename(dirname(__DIR__));
26+
require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
27+
require_once $GLOBALS['xoops']->path('include/cp_header.php');
28+
29+
$xfHelper = Xmf\Module\Helper::getHelper($moduleDirName);
30+
$adminObject = Xmf\Module\Admin::getInstance();
31+
xoops_load('constants', $moduleDirName);
32+
33+
// Load language files
34+
$xfHelper->loadLanguage('admin');
35+
$xfHelper->loadLanguage('modinfo');
36+
$xfHelper->loadLanguage('main');

admin/category.php

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
/*
3+
You may not change or alter any portion of this comment or credits of
4+
supporting developers from this source code or any supporting source code
5+
which is considered copyrighted (c) material of the original comment or credit
6+
authors.
7+
8+
This program is distributed in the hope that it will be useful, but
9+
WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
12+
/**
13+
* Category Admin file
14+
*
15+
* @package module\xoopsfaq\admin
16+
* @author John Neill
17+
* @author XOOPS Module Development Team
18+
* @copyright Copyright (c) 2001-2017 {@link http://xoops.org XOOPS Project}
19+
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
20+
* @since:: 1.23
21+
*
22+
* @see Xmf\Request
23+
* @see Xmf\Module\Helper\Permission
24+
*/
25+
use Xmf\Request;
26+
27+
require_once __DIR__ . '/admin_header.php';
28+
xoops_cp_header();
29+
30+
$xfCatHandler = $xfHelper->getHandler('category');
31+
32+
$op = Request::getCmd('op', 'default');
33+
switch ($op) {
34+
case 'edit':
35+
$adminObject->displayNavigation('category.php');
36+
$catId = Request::getInt('category_id', null);
37+
$obj = $xfCatHandler->get($catId);
38+
if ($obj instanceof XoopsfaqCategory) {
39+
$obj->displayForm();
40+
} else {
41+
$xfCatHandler->displayError(_AM_XOOPSFAQ_ERROR_COULD_NOT_EDIT_CAT);
42+
}
43+
break;
44+
45+
case 'delete':
46+
$ok = Request::getInt('ok', XoopsfaqConstants::CONFIRM_NOT_OK);
47+
$catId = Request::getInt('category_id', XoopsfaqConstants::DEFAULT_CATEGORY);
48+
if (XoopsfaqConstants::CONFIRM_OK === (int)$ok) {
49+
// check to make sure this passes form submission security
50+
if ($GLOBALS['xoopsSecurity'] instanceof XoopsSecurity) {
51+
if (!$GLOBALS['xoopsSecurity']->check()) {
52+
// failed xoops security check
53+
$xfHelper->redirect('admin/index.php', XoopsfaqConstants::REDIRECT_DELAY_MEDIUM, $GLOBALS['xoopsSecurity']->getErrors(true));
54+
}
55+
} else {
56+
$xfHelper->redirect('admin/index.php', XoopsfaqConstants::REDIRECT_DELAY_MEDIUM, _MD_XOOPSFAQ_INVALID_SECURITY_TOKEN);
57+
}
58+
59+
$obj = $xfCatHandler->get($catId);
60+
if ($obj instanceof XoopsfaqCategory && !$obj->isNew()) {
61+
// Delete all FAQs in this category
62+
$xfFaqHandler = $xfHelper->getHandler('contents');
63+
$criteria = new Criteria('contents_cid', $catId);
64+
$success = $xfFaqHandler->deleteAll($criteria);
65+
// Delete the category
66+
if (true === $xfCatHandler->delete($obj)) {
67+
// Delete comments
68+
xoops_comment_delete($xfHelper->getModule()->getVar('mid'), $catId);
69+
$xfHelper->redirect('admin/category.php', XoopsfaqConstants::REDIRECT_DELAY_MEDIUM, _AM_XOOPSFAQ_DBSUCCESS);
70+
// Delete permissions
71+
$permHelper = new Xmf\Module\Helper\Permission();
72+
$permHelper->deletePermissionForItem('viewcat', $catId);
73+
}
74+
}
75+
$xfCatHandler->displayError(_AM_XOOPSFAQ_ERROR_COULD_NOT_DEL_CAT);
76+
} else {
77+
$adminObject->displayNavigation('category.php');
78+
xoops_confirm(array('op' => 'delete', 'category_id' => $catId, 'ok' => XoopsfaqConstants::CONFIRM_OK), 'category.php', _AM_XOOPSFAQ_RUSURE_CAT);
79+
}
80+
break;
81+
82+
case 'save':
83+
if ( ($GLOBALS['xoopsSecurity'] instanceof XoopsSecurity) ) {
84+
if ( !$GLOBALS['xoopsSecurity']->check() ) {
85+
// failed xoops security check
86+
$xfHelper->redirect('admin/index.php', 3, $GLOBALS['xoopsSecurity']->getErrors(true));
87+
}
88+
} else {
89+
$xfHelper->redirect('admin/index.php', XoopsfaqConstants::REDIRECT_DELAY_MEDIUM, _MD_XOOPSFAQ_INVALID_SECURITY_TOKEN);
90+
}
91+
92+
$catId = Request::getInt('category_id', XoopsfaqConstants::DEFAULT_CATEGORY, 'POST');
93+
$obj = $xfCatHandler->get($catId); // creates category if catId = 0, else gets requested category
94+
if ($obj instanceof XoopsfaqCategory) {
95+
$obj->setVar('category_title', Request::getString('category_title', ''));
96+
$obj->setVar('category_order', Request::getInt('category_order', XoopsfaqConstants::DEFAULT_ORDER));
97+
if ($savedId = $xfCatHandler->insert($obj)) {
98+
// Save group permissions
99+
$permHelper = new Xmf\Module\Helper\Permission();
100+
$name = $permHelper->defaultFieldName('viewcat', $catId);
101+
$groups = Xmf\Request::getArray($name, array(), 'POST');
102+
$permHelper->savePermissionForItem('viewcat', $savedId, $groups);
103+
$xfHelper->redirect('admin/category.php', XoopsfaqConstants::REDIRECT_DELAY_MEDIUM, _AM_XOOPSFAQ_DBSUCCESS);
104+
}
105+
}
106+
$xfCatHandler->displayError(_AM_XOOPSFAQ_ERROR_COULD_NOT_ADD_CAT);
107+
break;
108+
109+
case 'default':
110+
default:
111+
$adminObject->displayNavigation('category.php');
112+
$adminObject->addItemButton(_XO_XOOPSFAQ_ADDCAT, 'category.php?op=edit', 'add' , '');
113+
$adminObject->displayButton('left');
114+
$xfCatHandler->displayAdminListing('order');
115+
break;
116+
}
117+
include_once __DIR__ . '/admin_footer.php';

admin/index.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/*
3+
You may not change or alter any portion of this comment or credits of
4+
supporting developers from this source code or any supporting source code
5+
which is considered copyrighted (c) material of the original comment or credit
6+
authors.
7+
8+
This program is distributed in the hope that it will be useful, but
9+
WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
12+
/**
13+
* Admin index file
14+
*
15+
* @package module\xoopsfaq\admin
16+
* @author Raul Recio (aka UNFOR)
17+
* @author XOOPS Module Development Team
18+
* @copyright Copyright (c) 2001-2017 {@link http://xoops.org XOOPS Project}
19+
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
20+
*
21+
* @see Xmf\Module\Admin
22+
*/
23+
24+
include_once __DIR__ . '/admin_header.php';
25+
xoops_cp_header();
26+
27+
//-----------------------
28+
$xfFaqHandler = $xfHelper->getHandler('contents');
29+
$totalFaqs = $xfFaqHandler->getCount();
30+
31+
$criteriaPublished = new CriteriaCompo();
32+
$criteriaPublished->add(new Criteria('contents_publish', XoopsfaqConstants::NOT_PUBLISHED, '>'));
33+
$criteriaPublished->add(new Criteria('contents_publish', time(), '<='));
34+
35+
$criteria = new CriteriaCompo();
36+
$criteria->add(new Criteria('contents_active', XoopsfaqConstants::ACTIVE, '='));
37+
$criteria->add($criteriaPublished);
38+
$totalPublishedFaqs = $xfFaqHandler->getCount($criteria);
39+
40+
$xfCatHandler = $xfHelper->getHandler('category');
41+
$totalCats = $xfCatHandler->getCount();
42+
43+
$totalNonpublishedFaqs = $totalFaqs - $totalPublishedFaqs;
44+
45+
$adminObject->addInfoBox(_MD_XOOPSFAQ_FAQ_CONF);
46+
$adminObject->AddInfoBoxLine(sprintf('<span class="infolabel">' . _MD_XOOPSFAQ_TOTAL_CATEGORIES . '</span>', '<span class="infotext green bold">' . $totalCats . '</span>'));
47+
$adminObject->AddInfoBoxLine(sprintf('<span class="infolabel">' . _MD_XOOPSFAQ_TOTAL_PUBLISHED . '</span>', '<span class="infotext green bold">' . $totalPublishedFaqs . '</span>'));
48+
$adminObject->AddInfoBoxLine(sprintf('<span class="infolabel">' . _MD_XOOPSFAQ_TOTAL_INACTIVE . '</span>', '<span class="infotext red bold">' . $totalNonpublishedFaqs . '</span>'));
49+
$adminObject->AddInfoBoxLine(sprintf('<span class="infolabel">' . _MD_XOOPSFAQ_TOTAL_FAQS . '</span>', '<span class="infotext green bold">' . $totalFaqs . '</span>'));
50+
51+
$adminObject->displayNavigation('index.php');
52+
$adminObject->displayIndex();
53+
54+
include __DIR__ . '/admin_footer.php';

0 commit comments

Comments
 (0)