Skip to content

Commit

Permalink
Merge pull request #154 from mambax7/master
Browse files Browse the repository at this point in the history
1.08 Alpha 3
  • Loading branch information
mambax7 authored Jan 1, 2021
2 parents c65278a + edaa71f commit 70e25ba
Show file tree
Hide file tree
Showing 188 changed files with 4,912 additions and 1,794 deletions.
9 changes: 6 additions & 3 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ build:
override: true
tests:
override:
- php-scrutinizer-run --enable-security-analysis
- php-scrutinizer-run --enable-security-analysis
environment:
php:
version: "7.2"
filter:
dependency_paths:
- XoopsCore25/*
- tag/*
- XoopsCore25/*
- tag/*
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ 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).
- **[PSR-12 Coding Standard](https://www.php-fig.org/psr/psr-12/)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
- **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.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

**Happy coding, and _May the Source be with You_!**
Happy coding, and **_May the Source be with You_**!
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png)
![alt XOOPS CMS](https://xoops.org/images/logoXoopsPhp8.png)
## Publisher module for [XOOPS CMS 2.5.10+](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)](https://www.gnu.org/licenses/gpl-2.0.html)
Expand Down
7 changes: 6 additions & 1 deletion admin/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
* @since 1.0
* @author Mage, Mamba
*/
require_once __DIR__ . '/admin_header.php';

use Xmf\Module\Admin;

/** @var Admin $adminObject */

require __DIR__ . '/admin_header.php';
xoops_cp_header();

$adminObject->displayNavigation(basename(__FILE__));
Expand Down
5 changes: 4 additions & 1 deletion admin/admin_footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
* @since
* @author XOOPS Development Team
*/
$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32);

use Xmf\Module\Admin;

$pathIcon32 = Admin::iconUrl('', 32);

echo "<div class='adminfooter'>\n" . " <div style='text-align: center;'>\n" . " <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . " </div>\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . '</div>';

Expand Down
9 changes: 3 additions & 6 deletions admin/admin_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Xmf\Module\Admin;
use XoopsModules\Publisher\Helper;
use XoopsModules\Publisher\Common\Configurator;

require dirname(__DIR__) . '/preloads/autoloader.php';

Expand All @@ -46,12 +47,8 @@
$helper->loadLanguage('modinfo');
$helper->loadLanguage('main');

$imagearray = [
'editimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_edit.png' alt='" . _AM_PUBLISHER_ICO_EDIT . "' align='middle'>",
'deleteimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_delete.png' alt='" . _AM_PUBLISHER_ICO_DELETE . "' align='middle'>",
'online' => "<img src='" . PUBLISHER_IMAGES_URL . "/on.png' alt='" . _AM_PUBLISHER_ICO_ONLINE . "' align='middle'>",
'offline' => "<img src='" . PUBLISHER_IMAGES_URL . "/off.png' alt='" . _AM_PUBLISHER_ICO_OFFLINE . "' align='middle'>",
];
$configurator = new Configurator();
$icons = $configurator->icons;

$myts = \MyTextSanitizer::getInstance();

Expand Down
2 changes: 1 addition & 1 deletion admin/blockform.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
}

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

Expand Down
59 changes: 33 additions & 26 deletions admin/blocksadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@

use Xmf\Module\Admin;
use Xmf\Request;
use XoopsModules\Publisher\{
Common\Configurator,
Helper
};

require __DIR__ . '/admin_header.php';
include_once $GLOBALS['xoops']->path('class/xoopsblock.php');

$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
Expand Down Expand Up @@ -66,6 +71,9 @@ function listBlocks()
xoops_loadLanguage('admin/blocksadmin', 'system');
xoops_loadLanguage('admin/groups', 'system');

$configurator = new Configurator();
$icons = $configurator->icons;

/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
/** @var \XoopsMemberHandler $memberHandler */
Expand All @@ -81,8 +89,7 @@ function listBlocks()
ksort($moduleList);
echo "
<h4 style='text-align:left;'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
// $moduleHandler = xoops_getHandler('module');
echo "<form action='" . \Xmf\Request::getString('SCRIPT_NAME', '', 'SERVER') . "' name='blockadmin' method='post'>";
echo "<form action='" . Request::getString('SCRIPT_NAME', '', 'SERVER') . "' name='blockadmin' method='post'>";
echo $GLOBALS['xoopsSecurity']->getTokenHTML();
echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
<tr valign='middle'><th align='center'>"
Expand Down Expand Up @@ -111,10 +118,10 @@ function listBlocks()
. constant('CO_' . $moduleDirNameUpper . '_' . 'ACTION')
. '</th></tr>
';
$blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
$blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
$blockCount = count($blockArray);
$class = 'even';
$cachetimes = [
$class = 'even';
$cachetimes = [
'0' => _NOCACHE,
'30' => sprintf(_SECONDS, 30),
'60' => _MINUTE,
Expand All @@ -129,9 +136,9 @@ function listBlocks()
];
foreach ($blockArray as $i) {
$groupsPerms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
$sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
$result = $db->query($sql);
$modules = [];
$sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
$result = $db->query($sql);
$modules = [];
while (false !== ($row = $db->fetchArray($result))) {
$modules[] = (int)$row['module_id'];
}
Expand Down Expand Up @@ -257,12 +264,10 @@ function listBlocks()

// Actions

echo "<td class='$class' align='center'><a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'>
</a> <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'>
echo "<td class='$class' align='center'><a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'>" . $icons->edit . "</a> <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'>
</a>";
if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
</a>";
if (!in_array($i->getVar('block_type'), ['S', 'M'])) {
echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'>" . $icons->delete . '</a>';
}
echo "
<input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
Expand Down Expand Up @@ -313,8 +318,8 @@ function cloneBlock($bid)
while (false !== ($row = $db->fetchArray($result))) {
$modules[] = (int)$row['module_id'];
}
$isCustom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type'));
$block = [
$isCustom = (in_array($myblock->getVar('block_type'), ['C', 'E']));
$block = [
'title' => $myblock->getVar('title') . ' Clone',
'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
'name' => $myblock->getVar('name'),
Expand Down Expand Up @@ -375,7 +380,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
$clone->setVar('options', $options);
}
$clone->setVar('bid', 0);
if ('C' === $block->getVar('block_type') || 'E' === $block->getVar('block_type')) {
if (in_array($block->getVar('block_type'), ['C', 'E'])) {
$clone->setVar('block_type', 'E');
} else {
$clone->setVar('block_type', 'D');
Expand Down Expand Up @@ -404,9 +409,8 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
$db->query($sql);
}
$groups = &$GLOBALS['xoopsUser']->getGroups();
$count = count($groups);
for ($i = 0; $i < $count; ++$i) {
$sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')";
foreach ($groups as $iValue) {
$sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
$db->query($sql);
}
redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED);
Expand All @@ -419,8 +423,9 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
* @param bool $visible
* @param string $side
* @param int $bcachetime
* @param null $bmodule
*/
function setOrder($bid, $title, $weight, $visible, $side, $bcachetime)
function setOrder($bid, $title, $weight, $visible, $side, $bcachetime, $bmodule = null)
{
$myblock = new \XoopsBlock($bid);
$myblock->setVar('title', $title);
Expand Down Expand Up @@ -456,8 +461,8 @@ function editBlock($bid)
while (false !== ($row = $db->fetchArray($result))) {
$modules[] = (int)$row['module_id'];
}
$isCustom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type'));
$block = [
$isCustom = (in_array($myblock->getVar('block_type'), ['C', 'E']));
$block = [
'title' => $myblock->getVar('title'),
'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK'),
// 'name' => $myblock->getVar('name'),
Expand Down Expand Up @@ -504,14 +509,16 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
$myblock->setVar('visible', $bvisible);
$myblock->setVar('side', $bside);
$myblock->setVar('bcachetime', $bcachetime);
$helper = Helper::getInstance();
$helper->loadLanguage('common');
//update block options
if (isset($options)) {
$optionsCount = count($options);
if ($optionsCount > 0) {
//Convert array values to comma-separated
for ($i = 0; $i < $optionsCount; ++$i) {
if (is_array($options[$i])) {
$options[$i] = implode(',', $options[$i]);
foreach ($options as $i => $iValue) {
if (is_array($iValue)) {
$options[$i] = implode(',', $iValue);
}
}
$options = implode('|', $options);
Expand Down Expand Up @@ -562,7 +569,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b
if ($oldtitle[$i] !== $title[$i] || $oldweight[$i] !== $weight[$i] || $oldvisible[$i] !== $visible[$i]
|| $oldside[$i] !== $side[$i]
|| $oldbcachetime[$i] !== $bcachetime[$i]) {
setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]=null);
setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
}
if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) {
$sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i]);
Expand Down
12 changes: 7 additions & 5 deletions admin/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
*/

use Xmf\Request;
use XoopsModules\Publisher\{
use XoopsModules\Publisher\{Helper,
Utility
};

/** @var Helper $helper */

require_once __DIR__ . '/admin_header.php';

$op = Request::getCmd('op', Request::getCmd('op', '', 'POST'), 'GET');
Expand Down Expand Up @@ -72,7 +74,7 @@

// Uploading the image, if any
// Retreive the filename to be uploaded
$temp = Request::getArray('image_file', '', 'FILES');
$temp = Request::getArray('image_file', '', 'FILES');
$imageFile = $temp['name'];
if ($imageFile) {
// $filename = Request::getArray('xoops_upload_file', array(), 'POST')[0];
Expand All @@ -81,8 +83,8 @@
if ($filename) {
// TODO : implement publisher mimetype management
$maxSize = $helper->getConfig('maximum_filesize');
$maxImageWidth = $helper->getConfig('maximum_image_width');
$maxImageHeight = $helper->getConfig('maximum_image_height');
$maxImageWidth = $helper->getConfig('maximum_image_width');
$maxImageHeight = $helper->getConfig('maximum_image_height');
$allowedMimetypes = Utility::getAllowedImagesTypes();
if (('' == $temp['tmp_name']) || !is_readable($temp['tmp_name'])) {
redirect_header('<script>javascript:history.go(-1)</script>', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR);
Expand Down Expand Up @@ -162,7 +164,7 @@
//Added by fx2024

case 'addsubcats':
$categoryId = 0;
$categoryId = 0;
$numberSubcats = Request::getInt('nb_subcats', 0, 'POST') + Request::getInt('nb_sub_yet', 0, 'POST');

$categoryObj = $helper->getHandler('Category')->create();
Expand Down
3 changes: 1 addition & 2 deletions admin/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
*/

use Xmf\Request;
use XoopsModules\Publisher\{
Cloner,
use XoopsModules\Publisher\{Cloner,
Utility
};

Expand Down
7 changes: 4 additions & 3 deletions admin/feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
* @author Fernando Santos (topet05) <[email protected]>
*/

use Xmf\Module\Admin;
use Xmf\Request;
use \XoopsModules\Publisher\Common\ModuleFeedback;

require __DIR__ . '/admin_header.php';

$adminObject = \Xmf\Module\Admin::getInstance();
$adminObject = Admin::getInstance();

$feedback = new ModuleFeedback();

Expand All @@ -45,7 +46,7 @@
$feedback->name = $GLOBALS['xoopsUser']->getVar('name');
$feedback->email = $GLOBALS['xoopsUser']->getVar('email');
$feedback->site = XOOPS_URL;
$form = $feedback->getFormFeedback();
$form = $feedback->getFormFeedback();
echo $form->display();
break;
case 'send':
Expand All @@ -58,7 +59,7 @@

$your_name = Request::getString('your_name', '');
$your_site = Request::getString('your_site', '');
$yourMail = Request::getString('your_mail', '');
$yourMail = Request::getString('your_mail', '');
$fb_type = Request::getString('fb_type', '');
$fb_content = Request::getText('fb_content', '');
$fb_content = str_replace(["\r\n", "\n", "\r"], '<br>', $fb_content); //clean line break from dhtmltextarea
Expand Down
Loading

0 comments on commit 70e25ba

Please sign in to comment.