Skip to content

Commit

Permalink
namespaces, autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Nov 22, 2017
1 parent 98b960a commit 1af46e0
Show file tree
Hide file tree
Showing 73 changed files with 606 additions and 504 deletions.
2 changes: 1 addition & 1 deletion admin/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
xoops_cp_header();

$adminObject->displayNavigation(basename(__FILE__));
$adminObject->setPaypal('[email protected]');
$adminObject::setPaypal('[email protected]');
$adminObject->displayAbout(false);

require_once __DIR__ . '/admin_footer.php';
14 changes: 5 additions & 9 deletions admin/admin_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,17 @@
require_once __DIR__ . '/../include/config.php';

$moduleDirName = basename(dirname(__DIR__));

if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) {
} else {
$moduleHelper = Xmf\Module\Helper::getHelper('system');
}
$helper = \Xmf\Module\Helper::getHelper($moduleDirName);
$adminObject = \Xmf\Module\Admin::getInstance();

$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32);
$pathModIcon32 = $moduleHelper->getModule()->getInfo('modicons32');
$pathModIcon32 = $helper->getModule()->getInfo('modicons32');

// Load language files
$moduleHelper->loadLanguage('admin');
$moduleHelper->loadLanguage('modinfo');
$moduleHelper->loadLanguage('main');
$helper->loadLanguage('admin');
$helper->loadLanguage('modinfo');
$helper->loadLanguage('main');

$imagearray = [
'editimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_edit.png' alt='" . _AM_PUBLISHER_ICO_EDIT . "' align='middle'>",
Expand Down
24 changes: 12 additions & 12 deletions admin/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@

switch ($op) {
case 'del':
$categoryObj = $publisher->getHandler('category')->get($categoryid);
$categoryObj = $helper->getHandler('category')->get($categoryid);
$confirm = Request::getInt('confirm', '', 'POST');
$name = Request::getString('name', '', 'POST');
if ($confirm) {
if (!$publisher->getHandler('category')->delete($categoryObj)) {
if (!$helper->getHandler('category')->delete($categoryObj)) {
redirect_header('category.php', 1, _AM_PUBLISHER_DELETE_CAT_ERROR);
// exit();
}
Expand Down Expand Up @@ -65,9 +65,9 @@

$parentid = Request::getInt('parentid');
if (0 != $categoryid) {
$categoryObj = $publisher->getHandler('category')->get($categoryid);
$categoryObj = $helper->getHandler('category')->get($categoryid);
} else {
$categoryObj = $publisher->getHandler('category')->create();
$categoryObj = $helper->getHandler('category')->create();
}

// Uploading the image, if any
Expand All @@ -78,9 +78,9 @@
$temp2 = Request::getArray('xoops_upload_file', [], 'POST');
if ($filename = $temp2[0]) {
// TODO : implement publisher mimetype management
$max_size = $publisher->getConfig('maximum_filesize');
$max_imgwidth = $publisher->getConfig('maximum_image_width');
$max_imgheight = $publisher->getConfig('maximum_image_height');
$max_size = $helper->getConfig('maximum_filesize');
$max_imgwidth = $helper->getConfig('maximum_image_width');
$max_imgheight = $helper->getConfig('maximum_image_height');
$allowed_mimetypes = PublisherUtility::getAllowedImagesTypes();
if (('' == $temp['tmp_name']) || !is_readable($temp['tmp_name'])) {
redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR);
Expand Down Expand Up @@ -143,7 +143,7 @@
for ($i = 0; $i < $sizeof; ++$i) {
$temp = Request::getArray('scname', [], 'POST');
if ('' != $temp[$i]) {
$categoryObj = $publisher->getHandler('category')->create();
$categoryObj = $helper->getHandler('category')->create();
$temp2 = Request::getArray('scname', [], 'POST');
$categoryObj->setVar('name', $temp2[$i]);
$categoryObj->setVar('parentid', $parentCat);
Expand All @@ -169,7 +169,7 @@
$categoryid = 0;
$nb_subcats = Request::getInt('nb_subcats', 0, 'POST') + Request::getInt('nb_sub_yet', 0, 'POST');

$categoryObj = $publisher->getHandler('category')->create();
$categoryObj = $helper->getHandler('category')->create();
$categoryObj->setVar('name', Request::getString('name', '', 'POST'));
$categoryObj->setVar('description', Request::getString('description', '', 'POST'));
$categoryObj->setVar('weight', Request::getInt('weight', 0, 'POST'));
Expand Down Expand Up @@ -199,7 +199,7 @@
echo '</div></form>';

// Creating the objects for top categories
$categoriesObj = $publisher->getHandler('category')->getCategories($publisher->getConfig('idxcat_perpage'), $startcategory, 0);
$categoriesObj = $helper->getHandler('category')->getCategories($helper->getConfig('idxcat_perpage'), $startcategory, 0);

PublisherUtility::openCollapsableBar('createdcategories', 'createdcategoriesicon', _AM_PUBLISHER_CATEGORIES_TITLE, _AM_PUBLISHER_CATEGORIES_DSC);

Expand All @@ -210,7 +210,7 @@
echo "<th width='60' class='bg3' width='65' align='center'><strong>" . _CO_PUBLISHER_WEIGHT . '</strong></td>';
echo "<th width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
echo '</tr>';
$totalCategories = $publisher->getHandler('category')->getCategoriesCount(0);
$totalCategories = $helper->getHandler('category')->getCategoriesCount(0);
if (count($categoriesObj) > 0) {
foreach ($categoriesObj as $key => $thiscat) {
PublisherUtility::displayCategory($thiscat);
Expand All @@ -224,7 +224,7 @@
}
echo "</table>\n";
require_once $GLOBALS['xoops']->path('class/pagenav.php');
$pagenav = new XoopsPageNav($totalCategories, $publisher->getConfig('idxcat_perpage'), $startcategory, 'startcategory');
$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');
Expand Down
2 changes: 1 addition & 1 deletion admin/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
echo $msg;
} else {
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
$form = new XoopsThemeForm(sprintf(_AM_PUBLISHER_CLONE_TITLE, $publisher->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true);
$form = new XoopsThemeForm(sprintf(_AM_PUBLISHER_CLONE_TITLE, $helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true);
$clone = new XoopsFormText(_AM_PUBLISHER_CLONE_NAME, 'clone', 20, 20, '');
$clone->setDescription(_AM_PUBLISHER_CLONE_NAME_DSC);
$form->addElement($clone, true);
Expand Down
15 changes: 8 additions & 7 deletions admin/file.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 @@ -31,13 +32,13 @@
*/
function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
{
$publisher = Publisher::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
if (0 != $fileid) {
// Creating the File object
$fileObj = $publisher->getHandler('file')->get($fileid);
$fileObj = $helper->getHandler('file')->get($fileid);

if ($fileObj->notLoaded()) {
redirect_header('javascript:history.go(-1)', 1, _AM_PUBLISHER_NOFILESELECTED);
Expand All @@ -50,7 +51,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
PublisherUtility::openCollapsableBar('editfile', 'editfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
} else {
// there's no parameter, so we're adding an item
$fileObj = $publisher->getHandler('file')->create();
$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>';
Expand Down Expand Up @@ -100,9 +101,9 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)

// Creating the file object
if (0 != $fileid) {
$fileObj = $publisher->getHandler('file')->get($fileid);
$fileObj = $helper->getHandler('file')->get($fileid);
} else {
$fileObj = $publisher->getHandler('file')->create();
$fileObj = $helper->getHandler('file')->create();
}

// Putting the values in the file object
Expand All @@ -124,13 +125,13 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
$fileid = Request::getInt('fileid', 0, 'POST');
$fileid = Request::getInt('fileid', $fileid, 'GET');

$fileObj = $publisher->getHandler('file')->get($fileid);
$fileObj = $helper->getHandler('file')->get($fileid);

$confirm = Request::getInt('confirm', 0, 'POST');
$title = Request::getString('title', '', 'POST');

if ($confirm) {
if (!$publisher->getHandler('file')->delete($fileObj)) {
if (!$helper->getHandler('file')->delete($fileObj)) {
redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 2, _AM_PUBLISHER_FILE_DELETE_ERROR);
// exit;
}
Expand Down
2 changes: 1 addition & 1 deletion admin/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
switch ($op) {
case 'importExecute':
$importfile = Request::getString('importfile', 'nonselected', 'POST');
$importfile_path = $GLOBALS['xoops']->path('modules/' . $publisher->getModule()->dirname() . '/admin/import/' . $importfile . '.php');
$importfile_path = $GLOBALS['xoops']->path('modules/' . $helper->getModule()->dirname() . '/admin/import/' . $importfile . '.php');
require_once $importfile_path;
break;

Expand Down
12 changes: 6 additions & 6 deletions admin/import/ams.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
$newCat['oldid'] = $arrCat['topic_id'];
$newCat['oldpid'] = $arrCat['topic_pid'];
/* @var $categoryObj PublisherCategory */
$categoryObj = $publisher->getHandler('category')->create();
$categoryObj = $helper->getHandler('category')->create();

$categoryObj->setVar('parentid', $arrCat['topic_pid']);
$categoryObj->setVar('image', $arrCat['topic_imgurl']);
Expand Down Expand Up @@ -253,7 +253,7 @@
}
}

if (!$publisher->getHandler('category')->insert($categoryObj)) {
if (!$helper->getHandler('category')->insert($categoryObj)) {
echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_ERROR, $arrCat['topic_title']) . '<br>';
continue;
}
Expand Down Expand Up @@ -292,7 +292,7 @@
// insert article

/** @var XoopsPersistableObjectHandler $itemObj */
$itemObj = $publisher->getHandler('item')->create();
$itemObj = $helper->getHandler('item')->create();

$itemObj->setVar('categoryid', $categoryObj->categoryid());
$itemObj->setVar('title', $arrArticle['title']);
Expand Down Expand Up @@ -354,7 +354,7 @@
if (file_exists($filename)) {
if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filerealname']))) {
/** @var PublisherFile $fileObj */
$fileObj = $publisher->getHandler('file')->create();
$fileObj = $helper->getHandler('file')->create();
$fileObj->setVar('name', $arrFile['filerealname']);
$fileObj->setVar('description', $arrFile['filerealname']);
$fileObj->setVar('status', PublisherConstants::PUBLISHER_STATUS_FILE_ACTIVE);
Expand Down Expand Up @@ -405,15 +405,15 @@
} else {
$newpid = $newCatArray[$oldpid]['newid'];
}
$publisher->getHandler('category')->updateAll('parentid', $newpid, $criteria);
$helper->getHandler('category')->updateAll('parentid', $newpid, $criteria);
unset($criteria);
}
unset($oldid, $newCat);

// Looping through the comments to link them to the new articles and module
echo _AM_PUBLISHER_IMPORT_COMMENTS . '<br>';

$publisher_module_id = $publisher->getModule()->mid();
$publisher_module_id = $helper->getModule()->mid();

/** @var XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
Expand Down
4 changes: 2 additions & 2 deletions admin/import/cjaycontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) {
// insert article
/** @var PublisherItem $itemObj */
$itemObj = $publisher->getHandler('item')->create();
$itemObj = $helper->getHandler('item')->create();
$itemObj->setVar('itemid', $arrArticle['id']);
// $itemObj->setVar('categoryid', $categoryObj->categoryid());
$itemObj->setVar('title', $arrArticle['title']);
Expand Down Expand Up @@ -158,7 +158,7 @@
// Looping through the comments to link them to the new articles and module
echo _AM_PUBLISHER_IMPORT_COMMENTS . '<br>';

$publisher_module_id = $publisher->getModule()->mid();
$publisher_module_id = $helper->getModule()->mid();
/** @var XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new CriteriaCompo();
Expand Down
16 changes: 8 additions & 8 deletions admin/import/fmcontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

// Publisher parent category
xoops_load('tree');
$categoryHdlr = $publisher->getHandler('category');
$categoryHdlr = $helper->getHandler('category');
$catObjs = $categoryHdlr->getAll();
$myObjTree = new XoopsObjectTree($catObjs, 'categoryid', 'parentid');
$moduleDirName = basename(dirname(__DIR__));
Expand Down Expand Up @@ -158,7 +158,7 @@

// create Publsher category to hold FmContent Content items with no Topic (content_topic=0)
/* @var $categoryObj PublisherCategory */
$categoryObj = $publisher->getHandler('category')->create();
$categoryObj = $helper->getHandler('category')->create();
$categoryObj->setVars([
'parentid' => $parentId,
'name' => _AM_PUBLISHER_IMPORT_FMCONTENT_NAME,
Expand All @@ -176,7 +176,7 @@

// insert articles for this category
foreach ($fmContentObjs as $thisFmContentObj) {
$itemObj = $publisher->getHandler('item')->create();
$itemObj = $helper->getHandler('item')->create();
$itemObj->setVars([
'categoryid' => $categoryObj->categoryid(),
'title' => $thisFmContentObj->getVar('content_title'),
Expand Down Expand Up @@ -240,7 +240,7 @@
'oldpid' => $thisFmTopicObj->getVar('topic_pid')
];

$categoryObj = $publisher->getHandler('category')->create();
$categoryObj = $helper->getHandler('category')->create();

$categoryObj->setVars([
'parentid' => $thisFmTopicObj->getVar('topic_pid'),
Expand All @@ -255,7 +255,7 @@
$categoryObj->setVar('image', $thisFmTopicObj->getVar('topic_img'));
}
}
if (!$publisher->getHandler('category')->insert($categoryObj)) {
if (!$helper->getHandler('category')->insert($categoryObj)) {
echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_ERROR, $thisFmTopicObj->getVar('topic_title')) . "<br>\n";
continue;
}
Expand All @@ -274,7 +274,7 @@
// insert articles for this category
/** @var PublisherItem $itemObj */
foreach ($fmContentObjs as $thisFmContentObj) {
$itemObj = $publisher->getHandler('item')->create();
$itemObj = $helper->getHandler('item')->create();
$itemObj->setVars([
'categoryid' => $CatIds['newid'],
'title' => $thisFmContentObj->getVar('content_title'),
Expand Down Expand Up @@ -330,15 +330,15 @@
$criteria->add(new Criteria('categoryid', $CatIds['newid']));
$oldpid = $CatIds['oldpid'];
$newpid = (0 == $oldpid) ? $parentId : $newCatArray[$oldpid]['newid'];
$publisher->getHandler('category')->updateAll('parentid', $newpid, $criteria);
$helper->getHandler('category')->updateAll('parentid', $newpid, $criteria);
unset($criteria);
}
unset($oldid, $CatIds);

// Looping through the comments to link them to the new articles and module
echo _AM_PUBLISHER_IMPORT_COMMENTS . "<br>\n";

$publisher_module_id = $publisher->getModule()->mid();
$publisher_module_id = $helper->getModule()->mid();
/** @var XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new CriteriaCompo();
Expand Down
10 changes: 5 additions & 5 deletions admin/import/news.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
$newCat['oldid'] = $arrCat['topic_id'];
$newCat['oldpid'] = $arrCat['topic_pid'];
/* @var $categoryObj PublisherCategory */
$categoryObj = $publisher->getHandler('category')->create();
$categoryObj = $helper->getHandler('category')->create();

$categoryObj->setVar('parentid', $arrCat['topic_pid']);
$categoryObj->setVar('weight', 0);
Expand All @@ -136,7 +136,7 @@
}
}

if (!$publisher->getHandler('category')->insert($categoryObj)) {
if (!$helper->getHandler('category')->insert($categoryObj)) {
echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_ERROR, $arrCat['topic_title']) . '<br>';
continue;
}
Expand All @@ -151,7 +151,7 @@
while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) {
// insert article
/** @var PublisherItem $itemObj */
$itemObj = $publisher->getHandler('item')->create();
$itemObj = $helper->getHandler('item')->create();

$itemObj->setVar('categoryid', $categoryObj->categoryid());
$itemObj->setVar('title', $arrArticle['title']);
Expand Down Expand Up @@ -246,15 +246,15 @@
} else {
$newpid = $newCatArray[$oldpid]['newid'];
}
$publisher->getHandler('category')->updateAll('parentid', $newpid, $criteria);
$helper->getHandler('category')->updateAll('parentid', $newpid, $criteria);
unset($criteria);
}
unset($oldid, $newCat);

// Looping through the comments to link them to the new articles and module
echo _AM_PUBLISHER_IMPORT_COMMENTS . '<br>';

$publisher_module_id = $publisher->getModule()->mid();
$publisher_module_id = $helper->getModule()->mid();
/** @var XoopsCommentHandler $commentHandler */
$commentHandler = xoops_getHandler('comment');
$criteria = new CriteriaCompo();
Expand Down
Loading

0 comments on commit 1af46e0

Please sign in to comment.