Skip to content

Commit

Permalink
1.06 Alpha, namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Nov 25, 2017
1 parent 1af46e0 commit a93e21b
Show file tree
Hide file tree
Showing 64 changed files with 534 additions and 380 deletions.
10 changes: 6 additions & 4 deletions admin/admin_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
* @author The SmartFactory <www.smartfactory.ca>
*/


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/common.php';
//require_once __DIR__ . '/../class/utility.php';
require_once __DIR__ . '/../include/config.php';

$moduleDirName = basename(dirname(__DIR__));
$helper = \Xmf\Module\Helper::getHelper($moduleDirName);
$helper = publisher\Helper::getInstance();
$adminObject = \Xmf\Module\Admin::getInstance();

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

use Xmf\Request;
use Xoopsmodules\publisher;

require_once __DIR__ . '/admin_header.php';

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

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

case 'addcategory':
Expand All @@ -81,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 = PublisherUtility::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(PublisherUtility::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 @@ -129,13 +130,13 @@
}

if (!$categoryObj->store()) {
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_CATEGORY_SAVE_ERROR . PublisherUtility::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
PublisherUtility::saveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
PublisherUtility::saveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit');
PublisherUtility::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 @@ -149,13 +150,13 @@
$categoryObj->setVar('parentid', $parentCat);

if (!$categoryObj->store()) {
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . PublisherUtility::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
PublisherUtility::saveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
PublisherUtility::saveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit');
PublisherUtility::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 @@ -177,8 +178,8 @@
$categoryObj->setVar('parentid', $parentCat);
}

PublisherUtility::cpHeader();
PublisherUtility::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 @@ -189,7 +190,7 @@
break;
case 'default':
default:
PublisherUtility::cpHeader();
publisher\Utility::cpHeader();
//publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES);

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

PublisherUtility::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 @@ -213,7 +214,7 @@
$totalCategories = $helper->getHandler('category')->getCategoriesCount(0);
if (count($categoriesObj) > 0) {
foreach ($categoriesObj as $key => $thiscat) {
PublisherUtility::displayCategory($thiscat);
publisher\Utility::displayCategory($thiscat);
}
unset($key, $thiscat);
} else {
Expand All @@ -227,7 +228,7 @@
$pagenav = new XoopsPageNav($totalCategories, $helper->getConfig('idxcat_perpage'), $startcategory, 'startcategory');
echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
echo '<br>';
PublisherUtility::closeCollapsableBar('createdcategories', 'createdcategoriesicon');
publisher\Utility::closeCollapsableBar('createdcategories', 'createdcategoriesicon');
echo '<br>';
//editcat(false);
break;
Expand Down
7 changes: 4 additions & 3 deletions admin/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
*/

use Xmf\Request;
use Xoopsmodules\publisher;

require_once __DIR__ . '/admin_header.php';

PublisherUtility::cpHeader();
publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_CLONE);
PublisherUtility::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 @@ -78,7 +79,7 @@
}

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

require_once __DIR__ . '/admin_footer.php';

Expand Down
20 changes: 10 additions & 10 deletions admin/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
PublisherUtility::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>';
PublisherUtility::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) {
PublisherUtility::closeCollapsableBar('editfile', 'editfileicon');
publisher\Utility::closeCollapsableBar('editfile', 'editfileicon');
} else {
PublisherUtility::closeCollapsableBar('addfile', 'addfileicon');
publisher\Utility::closeCollapsableBar('addfile', 'addfileicon');
}
}

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

case 'uploadanother':
PublisherUtility::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();
}

PublisherUtility::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 . PublisherUtility::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');

PublisherUtility::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:
PublisherUtility::cpHeader();
publisher\Utility::cpHeader();
//publisher_adminMenu(2, _AM_PUBLISHER_ITEMS);
break;
}
Expand Down
7 changes: 4 additions & 3 deletions admin/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

use Xmf\Request;
use Xoopsmodules\publisher;

require_once __DIR__ . '/admin_header.php';

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

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

PublisherUtility::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 @@ -173,7 +174,7 @@

// End of collapsable bar

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

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

use Xmf\Request;
use Xoopsmodules\publisher;

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

PublisherUtility::cpHeader();
publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
PublisherUtility::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 @@ -152,15 +153,15 @@
}
}

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

if ('go' === $op) {
PublisherUtility::cpHeader();
publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
require_once dirname(dirname(__DIR__)) . '/include/common.php';
PublisherUtility::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 @@ -263,7 +264,7 @@
$src = $GLOBALS['xoops']->path('uploads/AMS/topics/');
$dst = $GLOBALS['xoops']->path('uploads');

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

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

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

// Saving category permissions
$groupsIds = $gpermHandler->getGroupIds('nw_view', $arrCat['topic_id'], $ams_module_id);
PublisherUtility::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);
PublisherUtility::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);
PublisherUtility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_moderation');
publisher\Utility::saveCategoryPermissions($groupsIds, $categoryObj->categoryid(), 'category_moderation');

$newCatArray[$newCat['oldid']] = $newCat;
unset($newCat);
Expand Down Expand Up @@ -438,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>';

PublisherUtility::closeCollapsableBar('amsimportgo', 'amsimportgoicon');
publisher\Utility::closeCollapsableBar('amsimportgo', 'amsimportgoicon');
xoops_cp_footer();
}
13 changes: 7 additions & 6 deletions admin/import/cjaycontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

use Xmf\Request;
use Xoopsmodules\publisher;

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

PublisherUtility::cpHeader();
publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
PublisherUtility::openCollapsableBar('cjaycontentimport', 'cjaycontentimporticon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_INFO);
publisher\Utility::openCollapsableBar('cjaycontentimport', 'cjaycontentimporticon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_INFO);

$result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('cjaycontent'));
list($totalArticles) = $GLOBALS['xoopsDB']->fetchRow($result);
Expand All @@ -78,15 +79,15 @@
}
// }

PublisherUtility::closeCollapsableBar('cjaycontentimport', 'cjaycontentimporticon');
publisher\Utility::closeCollapsableBar('cjaycontentimport', 'cjaycontentimporticon');
xoops_cp_footer();
}

if ('go' === $op) {
PublisherUtility::cpHeader();
publisher\Utility::cpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT);
require_once dirname(dirname(__DIR__)) . '/include/common.php';
PublisherUtility::openCollapsableBar('cjaycontentimportgo', 'cjaycontentimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);
publisher\Utility::openCollapsableBar('cjaycontentimportgo', 'cjaycontentimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT);
/* @var $moduleHandler XoopsModuleHandler */
$moduleHandler = xoops_getHandler('module');
$moduleObj = $moduleHandler->getByDirname('cjaycontent');
Expand Down Expand Up @@ -182,6 +183,6 @@
echo sprintf(_AM_PUBLISHER_IMPORTED_ARTICLES, $cnt_imported_articles) . '<br>';
echo "<br><a href='" . PUBLISHER_URL . "/'>" . _AM_PUBLISHER_IMPORT_GOTOMODULE . '</a><br>';

PublisherUtility::closeCollapsableBar('cjaycontentimportgo', 'cjaycontentimportgoicon');
publisher\Utility::closeCollapsableBar('cjaycontentimportgo', 'cjaycontentimportgoicon');
xoops_cp_footer();
}
Loading

0 comments on commit a93e21b

Please sign in to comment.