Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Aug 1, 2018
1 parent 4bd6621 commit 7e303ac
Show file tree
Hide file tree
Showing 96 changed files with 1,174 additions and 1,280 deletions.
11 changes: 5 additions & 6 deletions admin/admin_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
* @author The SmartFactory <www.smartfactory.ca>
*/


use XoopsModules\Publisher;

require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
//require_once $GLOBALS['xoops']->path('www/class/xoopsformloader.php');

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

$moduleDirName = basename(dirname(__DIR__));

Expand All @@ -34,8 +33,8 @@
/** @var Xmf\Module\Admin $adminObject */
$adminObject = \Xmf\Module\Admin::getInstance();

$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32);
$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32);
if (is_object($helper->getModule())) {
$pathModIcon32 = $helper->getModule()->getInfo('modicons32');
}
Expand All @@ -49,7 +48,7 @@
'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'>"
'offline' => "<img src='" . PUBLISHER_IMAGES_URL . "/off.png' alt='" . _AM_PUBLISHER_ICO_OFFLINE . "' align='middle'>",
];

$myts = \MyTextSanitizer::getInstance();
Expand Down
8 changes: 3 additions & 5 deletions admin/blockform.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
*/



require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';

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

$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
if (isset($block['name'])) {
Expand Down Expand Up @@ -65,7 +63,7 @@
$form->addElement($ctype_select);
} else {
if ('' !== $block['template']) {
/** @var \XoopsTplfileHandler $tplfileHandler */
/** @var \XoopsTplfileHandler $tplfileHandler */
$tplfileHandler = xoops_getHandler('tplfile');
$btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
if (count($btemplate) > 0) {
Expand Down
54 changes: 25 additions & 29 deletions admin/blocksadmin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* 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.
Expand All @@ -18,10 +17,10 @@

require __DIR__ . '/admin_header.php';

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

if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule)
if (!is_object($xoopsModule) || !is_object($GLOBALS['xoopsUser'])
|| !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'));
}
Expand Down Expand Up @@ -49,16 +48,13 @@
$bid = Request::getInt('bid', 0, 'GET');
}

/**
*
*/
function listBlocks()
{
global $xoopsModule, $pathIcon16;
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = strtoupper($moduleDirName); //$capsDirName
$db = \XoopsDatabaseFactory::getDatabaseConnection();
$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
$db = \XoopsDatabaseFactory::getDatabaseConnection();
xoops_loadLanguage('admin', 'system');
xoops_loadLanguage('admin/blocksadmin', 'system');
xoops_loadLanguage('admin/groups', 'system');
Expand Down Expand Up @@ -120,7 +116,7 @@ function listBlocks()
'86400' => _DAY,
'259200' => sprintf(_DAYS, 3),
'604800' => _WEEK,
'2592000' => _MONTH
'2592000' => _MONTH,
];
foreach ($block_arr as $i) {
$groups_perms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
Expand Down Expand Up @@ -292,7 +288,7 @@ function cloneBlock($bid)
/** @var \Xmf\Module\Admin $adminObject */
$adminObject = \Xmf\Module\Admin::getInstance();
$adminObject->displayNavigation(basename(__FILE__));
$moduleDirName = basename(dirname(__DIR__));
$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName

xoops_loadLanguage('admin', 'system');
Expand Down Expand Up @@ -325,26 +321,26 @@ function cloneBlock($bid)
'bid' => $myblock->getVar('bid'),
'edit_form' => $myblock->getOptions(),
'template' => $myblock->getVar('template'),
'options' => $myblock->getVar('options')
'options' => $myblock->getVar('options'),
];
echo '<a href="blocksadmin.php">' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
require_once __DIR__ . '/blockform.php';
require_once __DIR__ . '/blockform.php';
$form->display();
// xoops_cp_footer();
require_once __DIR__ . '/admin_footer.php';
exit();
}

/**
* @param $bid
* @param $bside
* @param $bweight
* @param $bvisible
* @param $bcachetime
* @param $bmodule
* @param $options
* @param int $bid
* @param string $bside
* @param int $bweight
* @param bool $bvisible
* @param int $bcachetime
* @param string $bmodule
* @param null|array $options
*/
function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options)
function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options = null)
{
xoops_loadLanguage('admin', 'system');
xoops_loadLanguage('admin/blocksadmin', 'system');
Expand All @@ -365,7 +361,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
//$clone->setVar('content', $_POST['bcontent']);
$clone->setVar('title', Request::getString('btitle', '', 'POST'));
$clone->setVar('bcachetime', $bcachetime);
if (isset($options) && (0 < count($options))) {
if (null !== $options && (count($options) > 0)) {
$options = implode('|', $options);
$clone->setVar('options', $options);
}
Expand All @@ -386,7 +382,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule,
/** @var \XoopsTplfileHandler $tplfileHandler */
$tplfileHandler = xoops_getHandler('tplfile');
$btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid);
if (0 < count($btemplate)) {
if (count($btemplate) > 0) {
$tplclone = $btemplate[0]->xoopsClone();
$tplclone->setVar('tpl_id', 0);
$tplclone->setVar('tpl_refid', $newid);
Expand Down Expand Up @@ -436,7 +432,7 @@ function xtubeEditBlock($bid)
/** @var \Xmf\Module\Admin $adminObject */
$adminObject = \Xmf\Module\Admin::getInstance();
$adminObject->displayNavigation(basename(__FILE__));
$moduleDirName = basename(dirname(__DIR__));
$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName

xoops_loadLanguage('admin', 'system');
Expand Down Expand Up @@ -468,10 +464,10 @@ function xtubeEditBlock($bid)
'bid' => $myblock->getVar('bid'),
'edit_form' => $myblock->getOptions(),
'template' => $myblock->getVar('template'),
'options' => $myblock->getVar('options')
'options' => $myblock->getVar('options'),
];
echo '<a href="blocksadmin.php">' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
require_once __DIR__ . '/blockform.php';
require_once __DIR__ . '/blockform.php';
$form->display();
// xoops_cp_footer();
require_once __DIR__ . '/admin_footer.php';
Expand Down Expand Up @@ -499,7 +495,7 @@ function xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetim
$myblock->setVar('bcachetime', $bcachetime);
$myblock->store();

if (!empty($bmodule) && 0 < count($bmodule)) {
if (!empty($bmodule) && count($bmodule) > 0) {
$sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid);
$GLOBALS['xoopsDB']->query($sql);
if (in_array(0, $bmodule)) {
Expand Down Expand Up @@ -541,7 +537,7 @@ function xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetim
|| $oldbcachetime[$i] !== $bcachetime[$i]) {
xtubeSetOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
}
if (!empty($bmodule[$i]) && 0 < count($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]);
$GLOBALS['xoopsDB']->query($sql);
if (in_array(0, $bmodule[$i])) {
Expand Down
2 changes: 1 addition & 1 deletion admin/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// exit();
}
redirect_header('category.php', 1, sprintf(_AM_PUBLISHER_COLISDELETED, $name));
// exit();
// exit();
} else {
xoops_cp_header();
xoops_confirm(['op' => 'del', 'categoryid' => $categoryObj->categoryid(), 'confirm' => 1, 'name' => $categoryObj->name()], 'category.php', _AM_PUBLISHER_DELETECOL . " '" . $categoryObj->name() . "'. <br> <br>" . _AM_PUBLISHER_DELETE_CAT_CONFIRM, _AM_PUBLISHER_DELETE);
Expand Down
53 changes: 27 additions & 26 deletions admin/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@
}

$patterns = [
strtolower(PUBLISHER_DIRNAME) => strtolower($clone),
strtoupper(PUBLISHER_DIRNAME) => strtoupper($clone),
ucfirst(strtolower(PUBLISHER_DIRNAME)) => ucfirst(strtolower($clone))
mb_strtolower(PUBLISHER_DIRNAME) => mb_strtolower($clone),
mb_strtoupper(PUBLISHER_DIRNAME) => mb_strtoupper($clone),
ucfirst(mb_strtolower(PUBLISHER_DIRNAME)) => ucfirst(mb_strtolower($clone)),
];

$patKeys = array_keys($patterns);
$patValues = array_values($patterns);
PublisherClone::cloneFileFolder(PUBLISHER_ROOT_PATH);
$logocreated = PublisherClone::createLogo(strtolower($clone));
$logocreated = PublisherClone::createLogo(mb_strtolower($clone));

$msg = '';
if (is_dir($GLOBALS['xoops']->path('modules/' . strtolower($clone)))) {
$msg .= sprintf(_AM_PUBLISHER_CLONE_CONGRAT, "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>" . ucfirst(strtolower($clone)) . '</a>') . "<br>\n";
if (is_dir($GLOBALS['xoops']->path('modules/' . mb_strtolower($clone)))) {
$msg .= sprintf(_AM_PUBLISHER_CLONE_CONGRAT, "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>" . ucfirst(mb_strtolower($clone)) . '</a>') . "<br>\n";
if (!$logocreated) {
$msg .= _AM_PUBLISHER_CLONE_IMAGEFAIL;
}
Expand Down Expand Up @@ -114,20 +114,22 @@ public static function cloneFileFolder($path)

if (is_dir($path)) {
// create new dir
mkdir($newPath);
if (!mkdir($newPath) && !is_dir($newPath)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $newPath));
}

// check all files in dir, and process it
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if (0 !== strpos($file, '.')) {
if (0 !== mb_strpos($file, '.')) {
self::cloneFileFolder("{$path}/{$file}");
}
}
closedir($handle);
}
} else {
$noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf'];
if (in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), $noChangeExtensions)) {
if (in_array(mb_strtolower(pathinfo($path, PATHINFO_EXTENSION)), $noChangeExtensions, true)) {
// image
copy($path, $newPath);
} else {
Expand All @@ -148,24 +150,23 @@ public static function createLogo($dirname)
{
if (!extension_loaded('gd')) {
return false;
} else {
$requiredFunctions = [
'imagecreatefrompng',
'imagecolorallocate',
'imagefilledrectangle',
'imagepng',
'imagedestroy',
'imagefttext',
'imagealphablending',
'imagesavealpha'
];
foreach ($requiredFunctions as $func) {
if (!function_exists($func)) {
return false;
}
}
$requiredFunctions = [
'imagecreatefrompng',
'imagecolorallocate',
'imagefilledrectangle',
'imagepng',
'imagedestroy',
'imagefttext',
'imagealphablending',
'imagesavealpha',
];
foreach ($requiredFunctions as $func) {
if (!function_exists($func)) {
return false;
}
// unset($func);
}
// unset($func);

if (!file_exists($imageBase = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'))
|| !file_exists($font = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/VeraBd.ttf'))) {
Expand All @@ -183,7 +184,7 @@ public static function createLogo($dirname)

// Write text
$textColor = imagecolorallocate($imageModule, 0, 0, 0);
$spaceToBorder = (80 - strlen($dirname) * 6.5) / 2;
$spaceToBorder = (80 - mb_strlen($dirname) * 6.5) / 2;
imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, ucfirst($dirname), []);

// Set transparency color
Expand Down
2 changes: 1 addition & 1 deletion admin/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
}

redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 2, sprintf(_AM_PUBLISHER_FILEISDELETED, $fileObj->name()));
// exit();
// exit();
} else {
// no confirm: show deletion condition
$fileid = Request::getInt('fileid', 0, 'GET');
Expand Down
Loading

0 comments on commit 7e303ac

Please sign in to comment.