Skip to content

Commit

Permalink
namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Jan 4, 2018
1 parent 18bba0c commit 5c68486
Show file tree
Hide file tree
Showing 72 changed files with 653 additions and 563 deletions.
12 changes: 7 additions & 5 deletions admin/admin_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@
*/


use Xoopsmodules\publisher;
use XoopsModules\Publisher;

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

require_once __DIR__ . '/../include/common.php';
//require_once __DIR__ . '/../class/Utility.php';
require_once __DIR__ . '/../include/config.php';
include __DIR__ . '/../preloads/autoloader.php';


$moduleDirName = basename(dirname(__DIR__));
$helper = publisher\Helper::getInstance();

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

$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
Expand Down
38 changes: 19 additions & 19 deletions admin/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

use Xmf\Request;
use Xoopsmodules\publisher;
use XoopsModules\Publisher;

require_once __DIR__ . '/admin_header.php';

Expand Down Expand Up @@ -57,8 +57,8 @@
$nb_subcats += Request::getInt('nb_sub_yet', 4, 'POST');
//end of fx2024 code

publisher\Utility::cpHeader();
publisher\Utility::editCategory(true, $categoryid, $nb_subcats);
Publisher\Utility::cpHeader();
Publisher\Utility::editCategory(true, $categoryid, $nb_subcats);
break;

case 'addcategory':
Expand All @@ -82,14 +82,14 @@
$max_size = $helper->getConfig('maximum_filesize');
$max_imgwidth = $helper->getConfig('maximum_image_width');
$max_imgheight = $helper->getConfig('maximum_image_height');
$allowed_mimetypes = publisher\Utility::getAllowedImagesTypes();
$allowed_mimetypes = Publisher\Utility::getAllowedImagesTypes();
if (('' == $temp['tmp_name']) || !is_readable($temp['tmp_name'])) {
redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR);
// exit();
}

xoops_load('XoopsMediaUploader');
$uploader = new \XoopsMediaUploader(publisher\Utility::getImageDir('category'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
$uploader = new \XoopsMediaUploader(Publisher\Utility::getImageDir('category'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
if ($uploader->fetchMedia($filename) && $uploader->upload()) {
$categoryObj->setVar('image', $uploader->getSavedFileName());
} else {
Expand Down Expand Up @@ -130,13 +130,13 @@
}

if (!$categoryObj->store()) {
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_CATEGORY_SAVE_ERROR . publisher\Utility::formatErrors($categoryObj->getErrors()));
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_CATEGORY_SAVE_ERROR . Publisher\Utility::formatErrors($categoryObj->getErrors()));
// exit;
}
// TODO : put this function in the category class
publisher\Utility::saveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
publisher\Utility::saveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit');
publisher\Utility::saveCategoryPermissions($grpmoderation, $categoryObj->categoryid(), 'category_moderation');
Publisher\Utility::saveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
Publisher\Utility::saveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit');
Publisher\Utility::saveCategoryPermissions($grpmoderation, $categoryObj->categoryid(), 'category_moderation');

//Added by fx2024
$parentCat = $categoryObj->categoryid();
Expand All @@ -150,13 +150,13 @@
$categoryObj->setVar('parentid', $parentCat);

if (!$categoryObj->store()) {
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . publisher\Utility::formatErrors($categoryObj->getErrors()));
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . Publisher\Utility::formatErrors($categoryObj->getErrors()));
// exit;
}
// TODO : put this function in the category class
publisher\Utility::saveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
publisher\Utility::saveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit');
publisher\Utility::saveCategoryPermissions($grpmoderation, $categoryObj->categoryid(), 'category_moderation');
Publisher\Utility::saveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
Publisher\Utility::saveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit');
Publisher\Utility::saveCategoryPermissions($grpmoderation, $categoryObj->categoryid(), 'category_moderation');
}
}
//end of fx2024 code
Expand All @@ -178,8 +178,8 @@
$categoryObj->setVar('parentid', $parentCat);
}

publisher\Utility::cpHeader();
publisher\Utility::editCategory(true, $categoryid, $nb_subcats, $categoryObj);
Publisher\Utility::cpHeader();
Publisher\Utility::editCategory(true, $categoryid, $nb_subcats, $categoryObj);
exit();
break;
//end of fx2024 code
Expand All @@ -190,7 +190,7 @@
break;
case 'default':
default:
publisher\Utility::cpHeader();
Publisher\Utility::cpHeader();
//publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES);

echo "<br>\n";
Expand All @@ -202,7 +202,7 @@
// Creating the objects for top categories
$categoriesObj = $helper->getHandler('category')->getCategories($helper->getConfig('idxcat_perpage'), $startcategory, 0);

publisher\Utility::openCollapsableBar('createdcategories', 'createdcategoriesicon', _AM_PUBLISHER_CATEGORIES_TITLE, _AM_PUBLISHER_CATEGORIES_DSC);
Publisher\Utility::openCollapsableBar('createdcategories', 'createdcategoriesicon', _AM_PUBLISHER_CATEGORIES_TITLE, _AM_PUBLISHER_CATEGORIES_DSC);

echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
echo '<tr>';
Expand All @@ -214,7 +214,7 @@
$totalCategories = $helper->getHandler('category')->getCategoriesCount(0);
if (count($categoriesObj) > 0) {
foreach ($categoriesObj as $key => $thiscat) {
publisher\Utility::displayCategory($thiscat);
Publisher\Utility::displayCategory($thiscat);
}
unset($key, $thiscat);
} else {
Expand All @@ -228,7 +228,7 @@
$pagenav = new \XoopsPageNav($totalCategories, $helper->getConfig('idxcat_perpage'), $startcategory, 'startcategory');
echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
echo '<br>';
publisher\Utility::closeCollapsableBar('createdcategories', 'createdcategoriesicon');
Publisher\Utility::closeCollapsableBar('createdcategories', 'createdcategoriesicon');
echo '<br>';
//editcat(false);
break;
Expand Down
8 changes: 4 additions & 4 deletions admin/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/

use Xmf\Request;
use Xoopsmodules\publisher;
use XoopsModules\Publisher;

require_once __DIR__ . '/admin_header.php';

publisher\Utility::cpHeader();
Publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_CLONE);
publisher\Utility::openCollapsableBar('clone', 'cloneicon', _AM_PUBLISHER_CLONE, _AM_PUBLISHER_CLONE_DSC);
Publisher\Utility::openCollapsableBar('clone', 'cloneicon', _AM_PUBLISHER_CLONE, _AM_PUBLISHER_CLONE_DSC);

if ('submit' === Request::getString('op', '', 'POST')) {
if (!$GLOBALS['xoopsSecurity']->check()) {
Expand Down Expand Up @@ -79,7 +79,7 @@
}

// End of collapsable bar
publisher\Utility::closeCollapsableBar('clone', 'cloneicon');
Publisher\Utility::closeCollapsableBar('clone', 'cloneicon');

require_once __DIR__ . '/admin_footer.php';

Expand Down
24 changes: 12 additions & 12 deletions admin/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

use Xmf\Request;
use Xoopsmodules\publisher;
use XoopsModules\Publisher;

require_once __DIR__ . '/admin_header.php';

Expand All @@ -32,7 +32,7 @@
*/
function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
{
$helper = publisher\Helper::getInstance();
$helper = Publisher\Helper::getInstance();
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');

// if there is a parameter, and the id exists, retrieve data: we're editing a file
Expand All @@ -48,37 +48,37 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
echo "<br>\n";
echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 6px 0 0; '>" . _AM_PUBLISHER_FILE_EDITING . '</span>';
echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_PUBLISHER_FILE_EDITING_DSC . '</span>';
publisher\Utility::openCollapsableBar('editfile', 'editfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
Publisher\Utility::openCollapsableBar('editfile', 'editfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
} else {
// there's no parameter, so we're adding an item
$fileObj = $helper->getHandler('file')->create();
$fileObj->setVar('itemid', $itemid);
echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 6px 0 0; '>" . _AM_PUBLISHER_FILE_ADDING . '</span>';
echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_PUBLISHER_FILE_ADDING_DSC . '</span>';
publisher\Utility::openCollapsableBar('addfile', 'addfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
Publisher\Utility::openCollapsableBar('addfile', 'addfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
}

// FILES UPLOAD FORM
$uploadForm = $fileObj->getForm();
$uploadForm->display();

if (0 != $fileid) {
publisher\Utility::closeCollapsableBar('editfile', 'editfileicon');
Publisher\Utility::closeCollapsableBar('editfile', 'editfileicon');
} else {
publisher\Utility::closeCollapsableBar('addfile', 'addfileicon');
Publisher\Utility::closeCollapsableBar('addfile', 'addfileicon');
}
}

$false = false;
/* -- Available operations -- */
switch ($op) {
case 'uploadfile':
publisher\Utility::uploadFile(false, true, $false);
Publisher\Utility::uploadFile(false, true, $false);
exit;
break;

case 'uploadanother':
publisher\Utility::uploadFile(true, true, $false);
Publisher\Utility::uploadFile(true, true, $false);
exit;
break;

Expand All @@ -90,7 +90,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
// exit();
}

publisher\Utility::cpHeader();
Publisher\Utility::cpHeader();
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');

publisher_editFile(true, $fileid, $itemid);
Expand All @@ -113,7 +113,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)

// Storing the file
if (!$fileObj->store()) {
redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 3, _AM_PUBLISHER_FILE_EDITING_ERROR . publisher\Utility::formatErrors($fileObj->getErrors()));
redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 3, _AM_PUBLISHER_FILE_EDITING_ERROR . Publisher\Utility::formatErrors($fileObj->getErrors()));
// exit;
}

Expand Down Expand Up @@ -142,7 +142,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
// no confirm: show deletion condition
$fileid = Request::getInt('fileid', 0, 'GET');

publisher\Utility::cpHeader();
Publisher\Utility::cpHeader();
xoops_confirm(['op' => 'del', 'fileid' => $fileObj->fileid(), 'confirm' => 1, 'name' => $fileObj->name()], 'file.php', _AM_PUBLISHER_DELETETHISFILE . ' <br>' . $fileObj->name() . ' <br> <br>', _AM_PUBLISHER_DELETE);
xoops_cp_footer();
}
Expand All @@ -152,7 +152,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)

case 'default':
default:
publisher\Utility::cpHeader();
Publisher\Utility::cpHeader();
//publisher_adminMenu(2, _AM_PUBLISHER_ITEMS);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions admin/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

use Xmf\Request;
use Xoopsmodules\publisher;
use XoopsModules\Publisher;

require_once __DIR__ . '/admin_header.php';

Expand All @@ -36,10 +36,10 @@
default:
$importfile = 'none';

publisher\Utility::cpHeader();
Publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);

publisher\Utility::openCollapsableBar('import', 'importicon', _AM_PUBLISHER_IMPORT_TITLE, _AM_PUBLISHER_IMPORT_INFO);
Publisher\Utility::openCollapsableBar('import', 'importicon', _AM_PUBLISHER_IMPORT_TITLE, _AM_PUBLISHER_IMPORT_INFO);

xoops_load('XoopsFormLoader');
/* @var $moduleHandler XoopsModuleHandler */
Expand Down Expand Up @@ -174,7 +174,7 @@

// End of collapsable bar

publisher\Utility::closeCollapsableBar('import', 'importicon');
Publisher\Utility::closeCollapsableBar('import', 'importicon');

break;
}
Expand Down
22 changes: 11 additions & 11 deletions admin/import/ams.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

use Xmf\Request;
use Xoopsmodules\publisher;
use XoopsModules\Publisher;

require_once dirname(__DIR__) . '/admin_header.php';
$myts = \MyTextSanitizer::getInstance();
Expand All @@ -34,9 +34,9 @@
if ('start' === $op) {
xoops_load('XoopsFormLoader');

publisher\Utility::cpHeader();
Publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
publisher\Utility::openCollapsableBar('amsimport', 'amsimporticon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_INFO);
Publisher\Utility::openCollapsableBar('amsimport', 'amsimporticon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_INFO);

$result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('ams_topics'));
list($totalCat) = $GLOBALS['xoopsDB']->fetchRow($result);
Expand Down Expand Up @@ -153,15 +153,15 @@
}
}

publisher\Utility::closeCollapsableBar('amsimport', 'amsimporticon');
Publisher\Utility::closeCollapsableBar('amsimport', 'amsimporticon');
xoops_cp_footer();
}

if ('go' === $op) {
publisher\Utility::cpHeader();
Publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
require_once dirname(dirname(__DIR__)) . '/include/common.php';
publisher\Utility::openCollapsableBar('amsimportgo', 'amsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);
Publisher\Utility::openCollapsableBar('amsimportgo', 'amsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);
/* @var $moduleHandler XoopsModuleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname('ams');
Expand Down Expand Up @@ -264,7 +264,7 @@
$src = $GLOBALS['xoops']->path('uploads/AMS/topics/');
$dst = $GLOBALS['xoops']->path('uploads');

publisher\Utility::recurseCopy($src, $dst);
Publisher\Utility::recurseCopy($src, $dst);

//populate the Image Manager with images from xNews articles (by Bleekk)

Expand Down Expand Up @@ -384,12 +384,12 @@

// Saving category permissions
$groupsIds = $gpermHandler->getGroupIds('nw_view', $arrCat['topic_id'], $ams_module_id);
publisher\Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
Publisher\Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_read');
$groupsIds = $gpermHandler->getGroupIds('nw_submit', $arrCat['topic_id'], $ams_module_id);
publisher\Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');
Publisher\Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'item_submit');

$groupsIds = $gpermHandler->getGroupIds('nw_approve', $arrCat['topic_id'], $ams_module_id);
publisher\Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_moderation');
Publisher\Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_moderation');

$newCatArray[$newCat['oldid']] = $newCat;
unset($newCat);
Expand Down Expand Up @@ -439,6 +439,6 @@
echo sprintf(_AM_PUBLISHER_IMPORTED_ARTICLES, $cnt_imported_articles) . '<br>';
echo "<br><a href='" . PUBLISHER_URL . "/'>" . _AM_PUBLISHER_IMPORT_GOTOMODULE . '</a><br>';

publisher\Utility::closeCollapsableBar('amsimportgo', 'amsimportgoicon');
Publisher\Utility::closeCollapsableBar('amsimportgo', 'amsimportgoicon');
xoops_cp_footer();
}
Loading

0 comments on commit 5c68486

Please sign in to comment.