Skip to content

Commit

Permalink
Merge pull request #88 from mambax7/master
Browse files Browse the repository at this point in the history
2.01_Beta-1
  • Loading branch information
ggoffy authored Oct 28, 2021
2 parents d41337f + 5c5ecb7 commit f89f00b
Show file tree
Hide file tree
Showing 292 changed files with 10,148 additions and 3,262 deletions.
2 changes: 2 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# language: php
build:
environment:
php: 8.0.11
nodes:
tests: true
analysis:
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png)
# Contributing to [XOOPS CMS](https://xoops.org)
[![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org)
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html)

Contributions are **welcome** and will be fully **credited**.

Expand All @@ -10,8 +10,8 @@ We accept contributions via Pull Requests on [Github](https://github.com/XoopsMo
## Pull Requests

- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
- **Add tests!** - We encourage to provide tests for your contributions.
- **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are kept up-to-date.
- **Add tests!** - We encourage providing tests for your contributions.
- **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are up-to-date.
- **Consider our release cycle** - We try to follow [Semantic Versioning v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
- **Create feature branches** - Don't ask us to pull from your master branch.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png)
## TdmDownloads module for [XOOPS CMS 2.5.9+](https://xoops.org)
[![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org)
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html)

[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/XoopsModules25x/tdmdownloads.svg?style=flat)](https://scrutinizer-ci.com/g/XoopsModules25x/tdmdownloads/?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/95b12220e0ac4056b9af52af708379c9)](https://www.codacy.com/app/mambax7/tdmdownloads_2)
[![Code Climate](https://img.shields.io/codeclimate/github/XoopsModules25x/tdmdownloads.svg?style=flat)](https://codeclimate.com/github/mambax7/tdmdownloads)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/68207475-07ff-4567-a282-6e2f119077d2/mini.png)](https://insight.sensiolabs.com/projects/68207475-07ff-4567-a282-6e2f119077d2)
[![Latest Pre-Release](https://img.shields.io/github/tag/XoopsModules25x/tdmdownloads.svg?style=flat)](https://github.com/XoopsModules25x/tdmdownloads/tags/)
[![Latest Version](https://img.shields.io/github/release/XoopsModules25x/tdmdownloads.svg?style=flat)](https://github.com/XoopsModules25x/tdmdownloads/releases/)

**TdmDownloads** module for [XOOPS CMS](https://xoops.org) creates a downloads section where users can download/submit/rate various files..
**TdmDownloads** module for [XOOPS CMS](https://xoops.org) creates a Downloads section where users can download/submit/rate various files.

[![Tutorial Available](https://xoops.org/images/tutorial-available-blue.svg)](https://xoops.gitbook.io/tdmdownloads-tutorial/) Tutorial: see [GitBook](https://xoops.gitbook.io/tdmdownloads-tutorial/).
To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/tdmdownloads-tutorial)
Expand All @@ -19,4 +18,4 @@ To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/

Please visit us on https://xoops.org

Current and upcoming "next generation" versions of XOOPS CMS are being crafted on GitHub at: https://github.com/XOOPS
Current and upcoming "next generation" versions of XOOPS CMS are crafted on GitHub at: https://github.com/XOOPS
13 changes: 8 additions & 5 deletions admin/about.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
<?php declare(strict_types=1);

/**
* TDMDownload
*
Expand All @@ -10,21 +11,23 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright Gregory Mage (Aka Mage)
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @author Gregory Mage (Aka Mage)
*/

use Xmf\Module\Admin;

require __DIR__ . '/admin_header.php';
$templateMain = 'tdmdownloads_admin_about.tpl';

xoops_cp_header();
// pour file protection
$xoopsUrl = parse_url(XOOPS_URL);
$xoopsUrl = str_replace('www.', '', $xoopsUrl['host']);
$xoopsUrl = str_replace('www.', '', $xoopsUrl['host']??'');
$fileProtection = _AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION_INFO1 . '<br><br>' . XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/downloads/' . '<br><br>' . _AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION_INFO2 . '<br><br>';
$fileProtection .= 'RewriteEngine on' . '<br>' . 'RewriteCond %{HTTP_REFERER} !' . $xoopsUrl . "/.*$ [NC]<br>ReWriteRule \.*$ - [F]";
$fileProtection .= 'RewriteEngine on' . '<br>' . 'RewriteCond %s{HTTP_REFERER} !' . $xoopsUrl . '/.*$ [NC]<br>ReWriteRule \.*$ - [F]';

$adminObject = \Xmf\Module\Admin::getInstance();
$adminObject = Admin::getInstance();
$adminObject->addInfoBox(_AM_TDMDOWNLOADS_ABOUT_FILEPROTECTION);
$adminObject->addInfoBoxLine(sprintf($fileProtection, '', '', 'information'), '');

Expand Down
6 changes: 3 additions & 3 deletions admin/admin_footer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
<?php declare(strict_types=1);

/*
* 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
Expand All @@ -11,12 +12,11 @@

/**
* @copyright XOOPS Project (https://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package
* @since
* @author XOOPS Development Team
*/

if (isset($templateMain)) {
$GLOBALS['xoopsTpl']->display("db:{$templateMain}");
}
Expand Down
30 changes: 19 additions & 11 deletions admin/admin_header.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
<?php declare(strict_types=1);

/**
* TDMDownload
*
Expand All @@ -10,13 +11,17 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright Gregory Mage (Aka Mage)
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @author Gregory Mage (Aka Mage)
*/
use XoopsModules\Tdmdownloads\Tree;

use Xmf\Module\Admin;
use XoopsModules\Tdmdownloads\{
Helper,
Tree};

// Include xoops admin header
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
require_once dirname(__DIR__, 3) . '/include/cp_header.php';

require_once XOOPS_ROOT_PATH . '/kernel/module.php';
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
Expand All @@ -30,15 +35,16 @@
$moduleDirName = basename(dirname(__DIR__));

/** @var \XoopsModules\Tdmdownloads\Helper $helper */
$helper = \XoopsModules\Tdmdownloads\Helper::getInstance();
$helper = Helper::getInstance();

/** @var \Xmf\Module\Admin $adminObject */
$adminObject = \Xmf\Module\Admin::getInstance();
$adminObject = Admin::getInstance();

$myts = \MyTextSanitizer::getInstance();

if ($xoopsUser) {
$xoopsModule = \XoopsModule::getByDirname($moduleDirName);

if (!$xoopsUser->isAdmin($xoopsModule->mid())) {
redirect_header(XOOPS_URL . '/', 3, _NOPERM);
}
Expand All @@ -48,6 +54,7 @@

if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
require_once $GLOBALS['xoops']->path('class/template.php');

$xoopsTpl = new \XoopsTpl();
}

Expand All @@ -61,6 +68,7 @@

if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
require_once $GLOBALS['xoops']->path('class/theme.php');

$GLOBALS['xoTheme'] = new \xos_opal_Theme();
}

Expand All @@ -81,12 +89,12 @@
//permission
/** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');
$groups = XOOPS_GROUP_ANONYMOUS;
$groups = XOOPS_GROUP_ANONYMOUS;
if (is_object($xoopsUser)) {
$groups = $xoopsUser->getGroups();
}
$perm_submit = $grouppermHandler->checkRight('tdmdownloads_ac', 4, $groups, $xoopsModule->getVar('mid')) ? true : false;
$perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $xoopsModule->getVar('mid')) ? true : false;
$perm_vote = $grouppermHandler->checkRight('tdmdownloads_ac', 16, $groups, $xoopsModule->getVar('mid')) ? true : false;
$perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false;
$perm_submit = $grouppermHandler->checkRight('tdmdownloads_ac', 4, $groups, $xoopsModule->getVar('mid')) ? true : false;
$perm_modif = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $xoopsModule->getVar('mid')) ? true : false;
$perm_vote = $grouppermHandler->checkRight('tdmdownloads_ac', 16, $groups, $xoopsModule->getVar('mid')) ? true : false;
$perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false;
$perm_autoapprove = $grouppermHandler->checkRight('tdmdownloads_ac', 64, $groups, $xoopsModule->getVar('mid')) ? true : false;
89 changes: 54 additions & 35 deletions admin/blockform.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
<?php declare(strict_types=1);

/**
* 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
Expand All @@ -9,29 +10,31 @@
* @category Module
* @author XOOPS Development Team
* @copyright XOOPS Project
* @link https://www.xoops.org
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @link https://xoops.org
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
*/
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';

$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
$moduleDirNameUpper = \mb_strtoupper($moduleDirName); //$capsDirName

$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
if (isset($block['name'])) {
$form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_NAME, $block['name']));
}
$side_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']);
$side_select->addOptionArray([
0 => _AM_SYSTEM_BLOCKS_SBLEFT,
1 => _AM_SYSTEM_BLOCKS_SBRIGHT,
3 => _AM_SYSTEM_BLOCKS_CBLEFT,
4 => _AM_SYSTEM_BLOCKS_CBRIGHT,
5 => _AM_SYSTEM_BLOCKS_CBCENTER,
7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
9 => _AM_SYSTEM_BLOCKS_CBBOTTOM,
]);
$side_select->addOptionArray(
[
0 => _AM_SYSTEM_BLOCKS_SBLEFT,
1 => _AM_SYSTEM_BLOCKS_SBRIGHT,
3 => _AM_SYSTEM_BLOCKS_CBLEFT,
4 => _AM_SYSTEM_BLOCKS_CBRIGHT,
5 => _AM_SYSTEM_BLOCKS_CBCENTER,
7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
9 => _AM_SYSTEM_BLOCKS_CBBOTTOM,
]
);
$form->addElement($side_select);
$form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
$form->addElement(new \XoopsFormRadioYN(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
Expand All @@ -49,50 +52,66 @@
$form->addElement(new \XoopsFormText(_AM_TITLE, 'btitle', 50, 255, $block['title']), false);
if ($block['is_custom']) {
$textarea = new \XoopsFormDhtmlTextArea(_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);

$textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">' . _AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>');

$form->addElement($textarea, true);

$ctype_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
$ctype_select->addOptionArray([
'H' => _AM_SYSTEM_BLOCKS_HTML,
'P' => _AM_SYSTEM_BLOCKS_PHP,
'S' => _AM_SYSTEM_BLOCKS_AFWSMILE,
'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE,
]);

$ctype_select->addOptionArray(
[
'H' => _AM_SYSTEM_BLOCKS_HTML,
'P' => _AM_SYSTEM_BLOCKS_PHP,
'S' => _AM_SYSTEM_BLOCKS_AFWSMILE,
'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE,
]
);

$form->addElement($ctype_select);
} else {
if ('' !== $block['template']) {
/** @var XoopsTplfileHandler $tplfileHandler */

$tplfileHandler = xoops_getHandler('tplfile');

/** @var \XoopsTplfile[] $btemplate */

$btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);

if (count($btemplate) > 0) {
$form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . _AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
} else {
/** @var \XoopsTplfile[] $btemplate2 */
$btemplate2 = &$tplfileHandler->find('default', 'block', $block['bid']);

$btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);

if (count($btemplate2) > 0) {
$form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . _AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
}
}
}

if (false !== $block['edit_form']) {
$form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form']));
}
}
$cache_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
$cache_select->addOptionArray([
'0' => _NOCACHE,
'30' => sprintf(_SECONDS, 30),
'60' => _MINUTE,
'300' => sprintf(_MINUTES, 5),
'1800' => sprintf(_MINUTES, 30),
'3600' => _HOUR,
'18000' => sprintf(_HOURS, 5),
'86400' => _DAY,
'259200' => sprintf(_DAYS, 3),
'604800' => _WEEK,
'2592000' => _MONTH,
]);
$cache_select->addOptionArray(
[
'0' => _NOCACHE,
'30' => sprintf(_SECONDS, 30),
'60' => _MINUTE,
'300' => sprintf(_MINUTES, 5),
'1800' => sprintf(_MINUTES, 30),
'3600' => _HOUR,
'18000' => sprintf(_HOURS, 5),
'86400' => _DAY,
'259200' => sprintf(_DAYS, 3),
'604800' => _WEEK,
'2592000' => _MONTH,
]
);
$form->addElement($cache_select);

/** @var \XoopsGroupPermHandler $grouppermHandler */
Expand All @@ -112,7 +131,7 @@
}

//Submit buttons
$buttonTray = new \XoopsFormElementTray('', '');
$buttonTray = new \XoopsFormElementTray('', '');
$submit_button = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit');
$buttonTray->addElement($submit_button);

Expand Down
Loading

0 comments on commit f89f00b

Please sign in to comment.