Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Aug 1, 2018
1 parent 6a20f5d commit 61342d4
Show file tree
Hide file tree
Showing 32 changed files with 66 additions and 146 deletions.
2 changes: 1 addition & 1 deletion admin/blockform.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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 Down
8 changes: 0 additions & 8 deletions admin/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@
if ($confirm) {
if (!$helper->getHandler('Category')->delete($categoryObj)) {
redirect_header('category.php', 1, _AM_PUBLISHER_DELETE_CAT_ERROR);
// exit();
}
redirect_header('category.php', 1, sprintf(_AM_PUBLISHER_COLISDELETED, $name));
// 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 Expand Up @@ -85,7 +83,6 @@
$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');
Expand All @@ -94,7 +91,6 @@
$categoryObj->setVar('image', $uploader->getSavedFileName());
} else {
redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR . $uploader->getErrors());
// exit();
}
}
} else {
Expand Down Expand Up @@ -131,7 +127,6 @@

if (!$categoryObj->store()) {
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');
Expand All @@ -151,7 +146,6 @@

if (!$categoryObj->store()) {
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');
Expand All @@ -161,7 +155,6 @@
}
//end of fx2024 code
redirect_header($redirect_to, 2, $redirect_msg);
// exit();
break;

//Added by fx2024
Expand All @@ -186,7 +179,6 @@

case 'cancel':
redirect_header('category.php', 1, sprintf(_AM_PUBLISHER_BACK2IDX, ''));
// exit();
break;
case 'default':
default:
Expand Down
2 changes: 0 additions & 2 deletions admin/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
if ('submit' === Request::getString('op', '', 'POST')) {
if (!$GLOBALS['xoopsSecurity']->check()) {
redirect_header('clone.php', 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
// exit();
}

// $clone = $_POST['clone'];
Expand All @@ -38,7 +37,6 @@
//check if name is valid
if (empty($clone) || preg_match('/[^a-zA-Z0-9\_\-]/', $clone)) {
redirect_header('clone.php', 3, sprintf(_AM_PUBLISHER_CLONE_INVALIDNAME, $clone));
// exit();
}

// Check wether the cloned module exists or not
Expand Down
6 changes: 0 additions & 6 deletions admin/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)

if ($fileObj->notLoaded()) {
redirect_header('javascript:history.go(-1)', 1, _AM_PUBLISHER_NOFILESELECTED);
// exit();
}

echo "<br>\n";
Expand Down Expand Up @@ -90,7 +89,6 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
$itemid = Request::getInt('itemid', 0, 'GET');
if ((0 == $fileid) && (0 == $itemid)) {
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_NOITEMSELECTED);
// exit();
}

Publisher\Utility::cpHeader();
Expand All @@ -117,11 +115,9 @@ 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()));
// exit;
}

redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 2, _AM_PUBLISHER_FILE_EDITING_SUCCESS);
// exit();
break;

case 'del':
Expand All @@ -136,11 +132,9 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
if ($confirm) {
if (!$helper->getHandler('File')->delete($fileObj)) {
redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 2, _AM_PUBLISHER_FILE_DELETE_ERROR);
// exit;
}

redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 2, sprintf(_AM_PUBLISHER_FILEISDELETED, $fileObj->name()));
// exit();
} else {
// no confirm: show deletion condition
$fileid = Request::getInt('fileid', 0, 'GET');
Expand Down
1 change: 0 additions & 1 deletion admin/import/ams.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
$imagecategory->setVar('imgcat_type', 'C');
try {
$imageCategoryHandler->insert($imagecategory);
// exit();
}
catch (\Exception $e) {
echo 'Caught exception: could not insert Image Category' . $e->getMessage() . 'n';
Expand Down
1 change: 0 additions & 1 deletion admin/import/xnews.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
$imagecategory->setVar('imgcat_type', 'C');
try {
$imageCategoryHandler->insert($imagecategory);
// exit();
}
catch (\Exception $e) {
echo "Caught exception: : couldn't insert Image Category " . $e->getMessage() . 'n';
Expand Down
1 change: 0 additions & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

use XoopsModules\Publisher;
use XoopsModules\Publisher\Common;

require_once __DIR__ . '/admin_header.php';
//require_once dirname(__DIR__) . '/class/Utility.php';
Expand Down
7 changes: 0 additions & 7 deletions admin/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
$totalcategories = $helper->getHandler('Category')->getCategoriesCount(-1);
if (0 == $totalcategories) {
redirect_header('category.php?op=mod', 3, _AM_PUBLISHER_NEED_CATEGORY_ITEM);
// exit();
}
}
Publisher\Utility::cpHeader();
Expand All @@ -62,7 +61,6 @@
$totalcategories = $helper->getHandler('Category')->getCategoriesCount(-1);
if (0 == $totalcategories) {
redirect_header('category.php?op=mod', 3, _AM_PUBLISHER_NEED_CATEGORY_ITEM);
// exit();
}
}

Expand Down Expand Up @@ -125,15 +123,13 @@
// Storing the item
if (!$itemObj->store()) {
redirect_header('javascript:history.go(-1)', 3, $error_msg . Publisher\Utility::formatErrors($itemObj->getErrors()));
// exit;
}

// attach file if any
if (($item_upload_file = Request::getArray('item_upload_file', '', 'FILES')) && '' !== $item_upload_file['name']) {
$file_upload_result = Publisher\Utility::uploadFile(false, false, $itemObj);
if (true !== $file_upload_result) {
redirect_header('javascript:history.go(-1)', 3, $file_upload_result);
// exit;
}
}

Expand All @@ -153,10 +149,8 @@
if ($confirm) {
if (!$helper->getHandler('Item')->delete($itemObj)) {
redirect_header('item.php', 2, _AM_PUBLISHER_ITEM_DELETE_ERROR . Publisher\Utility::formatErrors($itemObj->getErrors()));
// exit();
}
redirect_header('item.php', 2, sprintf(_AM_PUBLISHER_ITEMISDELETED, $itemObj->getTitle()));
// exit();
} else {
xoops_cp_header();
xoops_confirm(['op' => 'del', 'itemid' => $itemObj->itemid(), 'confirm' => 1, 'name' => $itemObj->getTitle()], 'item.php', _AM_PUBLISHER_DELETETHISITEM . " <br>'" . $itemObj->getTitle() . "'. <br> <br>", _AM_PUBLISHER_DELETE);
Expand Down Expand Up @@ -412,7 +406,6 @@ function publisher_editItem($showmenu = false, $itemid = 0, $clone = false)

if (null === $itemObj) {
redirect_header('item.php', 1, _AM_PUBLISHER_NOITEMSELECTED);
// exit();
}

if ($clone) {
Expand Down
1 change: 0 additions & 1 deletion archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

if (!($itemsCount > 0)) {
redirect_header(XOOPS_URL, 2, _MD_PUBLISHER_NO_TOP_PERMISSIONS);
//mb exit;
} else {
$years = [];
$months = [];
Expand Down
3 changes: 0 additions & 3 deletions author_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,17 @@
$uid = Request::getInt('uid', 0, 'GET');
if (0 == $uid) {
redirect_header('index.php', 2, _CO_PUBLISHER_ERROR);
// exit();
}

/** @var \XoopsMemberHandler $memberHandler */
$memberHandler = xoops_getHandler('member');
$thisuser = $memberHandler->getUser($uid);
if (!is_object($thisuser)) {
redirect_header('index.php', 2, _CO_PUBLISHER_ERROR);
// exit();
}

if (!$helper->getConfig('perm_author_items')) {
redirect_header('index.php', 2, _CO_PUBLISHER_ERROR);
//mb exit();
}

$myts = \MyTextSanitizer::getInstance();
Expand Down
30 changes: 15 additions & 15 deletions blocks/items_columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ function publisher_items_columns_show($options)
if ($scount > 0 && is_array($categoryItemsObj)) {
reset($categoryItemsObj);
//First Item
$thisitem = array_values($categoryItemsObj)[0];
$thisItem = array_values($categoryItemsObj)[0];

$mainItem['item_title'] = $thisitem->getTitle();
$mainItem['item_cleantitle'] = strip_tags($thisitem->getTitle());
$mainItem['item_link'] = $thisitem->itemid();
$mainItem['itemurl'] = $thisitem->getItemUrl();
$mainImage = $thisitem->getMainImage();
$mainItem['item_title'] = $thisItem->getTitle();
$mainItem['item_cleantitle'] = strip_tags($thisItem->getTitle());
$mainItem['item_link'] = $thisItem->itemid();
$mainItem['itemurl'] = $thisItem->getItemUrl();
$mainImage = $thisItem->getMainImage();

// check to see if GD function exist
$mainItem['item_image'] = $mainImage['image_path'];
if (!empty($mainImage['image_path']) && function_exists('imagecreatetruecolor')) {
$mainItem['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . '&amp;w=100';
}

$mainItem['item_summary'] = $thisitem->getBlockSummary($optCatTruncate);
$mainItem['item_summary'] = $thisItem->getBlockSummary($optCatTruncate);

$mainItem['item_cat_name'] = $mainItemCatObj->name();
$mainItem['item_cat_description'] = '' !== $mainItemCatObj->description() ? $mainItemCatObj->description() : $mainItemCatObj->name();
Expand All @@ -111,20 +111,20 @@ function publisher_items_columns_show($options)

//The Rest
if ($scount > 1) {
// while ((list($itemid, $thisitem) = each($categoryItemsObj)) !== false) {
foreach ($categoryItemsObj as $itemid => $thisitem) {
// while ((list($itemid, $thisItem) = each($categoryItemsObj)) !== false) {
foreach ($categoryItemsObj as $itemid => $thisItem) {
//TODO do I need to start with 2nd element?
$subItem['title'] = $thisitem->getTitle();
$subItem['cleantitle'] = strip_tags($thisitem->getTitle());
$subItem['link'] = $thisitem->getItemLink();
$subItem['itemurl'] = $thisitem->getItemUrl();
$subItem['summary'] = $thisitem->getBlockSummary($optCatTruncate);
$subItem['title'] = $thisItem->getTitle();
$subItem['cleantitle'] = strip_tags($thisItem->getTitle());
$subItem['link'] = $thisItem->getItemLink();
$subItem['itemurl'] = $thisItem->getItemUrl();
$subItem['summary'] = $thisItem->getBlockSummary($optCatTruncate);
$mainItem['subitem'][] = $subItem;
unset($subItem);
}
}
$columns[$k][] = $mainItem;
unset($thisitem, $mainItem);
unset($thisItem, $mainItem);
++$k;

if ($k == $optNumColumns) {
Expand Down
43 changes: 22 additions & 21 deletions blocks/items_spot.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function publisher_items_spot_show($options)
if (-1 != $optCategoryId && $optCatImage) {
/** @var Publisher\Category $cat */
$cat = $categoryHandler->get($optCategoryId);
$category['name'] = $cat->name();
$category['name'] = $cat->name;
$category['categoryurl'] = $cat->getCategoryUrl();
if ('blank.png' !== $cat->getImage()) {
$category['image_path'] = Publisher\Utility::getImageDir('category', false) . $cat->getImage();
Expand All @@ -70,8 +70,8 @@ function publisher_items_spot_show($options)
}
$block['category'] = $category;
}
foreach ($itemsObj as $key => $thisitem) {
$item = $thisitem->toArraySimple('default', 0, $optTruncate);
foreach ($itemsObj as $key => $thisItem) {
$item = $thisItem->toArraySimple('default', 0, $optTruncate);
if ($i < $itemsCount) {
$item['showline'] = true;
} else {
Expand All @@ -85,25 +85,26 @@ function publisher_items_spot_show($options)
}
}
} else {
$i = 1;
$itemsCount = count($selItems);
foreach ($selItems as $itemId) {
/** @var Publisher\Item $itemObj */
$itemObj = $itemHandler->get($itemId);
if (!$itemObj->notLoaded()) {
$item = $itemObj->toArraySimple();
$item['who_when'] = sprintf(_MB_PUBLISHER_WHO_WHEN, $itemObj->posterName, $itemObj->getDatesub);
if ($i < $itemsCount) {
$item['showline'] = true;
} else {
$item['showline'] = false;
$i = 1;
if (is_array($selItems) && count($selItems) > 0) {
foreach ($selItems as $itemId) {
/** @var Publisher\Item $itemObj */
$itemObj = $itemHandler->get($itemId);
if (!$itemObj->notLoaded()) {
$item = $itemObj->toArraySimple();
$item['who_when'] = sprintf(_MB_PUBLISHER_WHO_WHEN, $itemObj->posterName, $itemObj->getDatesub);
if ($i < $itemsCount) {
$item['showline'] = true;
} else {
$item['showline'] = false;
}
if ($optTruncate > 0) {
$block['truncate'] = true;
$item['summary'] = Publisher\Utility::truncateHtml($item['summary'], $optTruncate);
}
$block['items'][] = $item;
++$i;
}
if ($optTruncate > 0) {
$block['truncate'] = true;
$item['summary'] = Publisher\Utility::truncateHtml($item['summary'], $optTruncate);
}
$block['items'][] = $item;
++$i;
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions category.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@
// if the selected category was not found, exit
if (!is_object($categoryObj) || $categoryObj->notLoaded()) {
redirect_header('javascript:history.go(-1)', 1, _MD_PUBLISHER_NOCATEGORYSELECTED);
// exit();
}

// Check user permissions to access this category
if (!$categoryObj->checkPermission()) {
redirect_header('javascript:history.go(-1)', 1, _NOPERM);
// exit;
}

// At which record shall we start
Expand All @@ -52,7 +50,6 @@
// why?
if (!isset($totalItems[$categoryid]) || 0 == $totalItems[$categoryid]) {
//redirect_header("index.php", 1, _MD_PUBLISHER_MAINNOFAQS);
//exit;
}

// Added by skalpa: custom template support
Expand Down Expand Up @@ -186,9 +183,9 @@
if (count($itemsObj) > 0) {
/*$userids = array();
if ($itemsObj) {
foreach ($itemsObj as $key => $thisitem) {
$itemids[] = $thisitem->getVar('itemid');
$userids[$thisitem->uid()] = 1;
foreach ($itemsObj as $key => $thisItem) {
$itemids[] = $thisItem->getVar('itemid');
$userids[$thisItem->uid()] = 1;
}
}
$memberHandler = xoops_getHandler('member');
Expand Down
1 change: 0 additions & 1 deletion class/CategoryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/

use XoopsModules\Publisher;
use XoopsModules\Publisher\Constants;

// defined('XOOPS_ROOT_PATH') || die('Restricted access');

Expand Down
Loading

0 comments on commit 61342d4

Please sign in to comment.