Skip to content

Commit

Permalink
reversing to old way of checking editors, updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Aug 1, 2018
1 parent 6f22aa9 commit 6a20f5d
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 34 deletions.
1 change: 1 addition & 0 deletions admin/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
}

// FILES UPLOAD FORM
/** @var Publisher\File $fileObj */
$uploadForm = $fileObj->getForm();
$uploadForm->display();

Expand Down
1 change: 1 addition & 0 deletions admin/import/fmcontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
$moduleObj = $moduleHandler->getByDirname('fmcontent');
$fm_module_id = $moduleObj->getVar('mid');

/** @var \XoopsPersistableObjectHandler $fmTopicHdlr */
$fmTopicHdlr = xoops_getModuleHandler('topic', 'fmcontent');
$fmTopicCount = $fmTopicHdlr->getCount(new \Criteria('topic_modid', $fm_module_id));

Expand Down
1 change: 1 addition & 0 deletions admin/import/xnews.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@
$itemObj->setVar('notifypub', $arrArticle['notifypub']);
//-------- image

/** @var \XoopsImageHandler $imgHandler */
$imgHandler = xoops_getHandler('image');

$criteria = new \Criteria('image_name', $arrArticle['picture']);
Expand Down
2 changes: 2 additions & 0 deletions admin/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
$modname = $module->name();
$dirName = $helper->getDirname();

/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$xoopsModule0 = $moduleHandler->getByDirname(basename(dirname(__DIR__)));
global $xoopsModule;
Expand All @@ -51,6 +52,7 @@
$configcat = Request::getString('configcat', '', 'GET');

if ('showmod' === $op) {
/** @var \XoopsConfigHandler $configHandler */
$configHandler = xoops_getHandler('config');

$config = $configHandler->getConfigs(new \Criteria('conf_modid', $modId));
Expand Down
4 changes: 3 additions & 1 deletion blocks/date_to_date.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function publisher_date_to_date_show($options)
$criteria->setOrder('DESC');

// creating the ITEM objects that belong to the selected category
$itemsObj = $helper->getHandler('Item')->getObjects($criteria);
/** @var Publisher\ItemHandler $itemHandler */
$itemHandler = $helper->getHandler('Item');
$itemsObj = $itemHandler->getObjects($criteria);
// $totalItems = count($itemsObj);

if (is_array($itemsObj) && count($itemsObj) > 0) {
Expand Down
9 changes: 5 additions & 4 deletions blocks/items_columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ function publisher_items_columns_show($options)
// global $xoTheme;
/** @var Publisher\Helper $helper */
$helper = Publisher\Helper::getInstance();

/** @var Publisher\CategoryHandler $categoryHandler */
$categoryHandler = $helper->getHandler('Category');
/** @var Publisher\ItemHandler $itemHandler */
$itemHandler = $helper->getHandler('Item');
//Column Settings
$optNumColumns = isset($options[0]) ? (int)$options[0] : '2';
$selCategories = isset($options[1]) ? explode(',', $options[1]) : [];
Expand All @@ -52,8 +55,6 @@ function publisher_items_columns_show($options)
$selCategoriesObj = [];

//get permited categories only once
/** @var Publisher\CategoryHandler $categoryHandler */
$categoryHandler = $helper->getHandler('Category');
$categoriesObj = $categoryHandler->getCategories(0, 0, -1);

//if not selected 'all', let's get the selected ones
Expand Down Expand Up @@ -82,7 +83,7 @@ function publisher_items_columns_show($options)
$columns = $mainItem = $subItem = [];

foreach ($selCategoriesObj as $categoryId => $mainItemCatObj) {
$categoryItemsObj = $helper->getHandler('Item')->getAllPublished($optCatItems, 0, $categoryId);
$categoryItemsObj = $itemHandler->getAllPublished($optCatItems, 0, $categoryId);
$scount = count($categoryItemsObj);
if ($scount > 0 && is_array($categoryItemsObj)) {
reset($categoryItemsObj);
Expand Down
11 changes: 8 additions & 3 deletions blocks/items_spot.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ function publisher_items_spot_show($options)
$helper = Publisher\Helper::getInstance();
/** @var Publisher\CategoryHandler $categoryHandler */
$categoryHandler = $helper->getHandler('Category');
/** @var Publisher\ItemHandler $itemHandler */
$itemHandler = $helper->getHandler('Item');

$optDisplayLast = $options[0];
$optItemsCount = $options[1];
$optCategoryId = $options[2];
Expand All @@ -51,11 +54,12 @@ function publisher_items_spot_show($options)
}
$block = [];
if (1 == $optDisplayLast) {
$itemsObj = $helper->getHandler('Item')->getAllPublished($optItemsCount, 0, $optCategoryId, $sort = 'datesub', $order = 'DESC', 'summary');
$itemsObj = $itemHandler->getAllPublished($optItemsCount, 0, $optCategoryId, $sort = 'datesub', $order = 'DESC', 'summary');
$i = 1;
$itemsCount = count($itemsObj);
if ($itemsObj) {
if (-1 != $optCategoryId && $optCatImage) {
/** @var Publisher\Category $cat */
$cat = $categoryHandler->get($optCategoryId);
$category['name'] = $cat->name();
$category['categoryurl'] = $cat->getCategoryUrl();
Expand Down Expand Up @@ -84,10 +88,11 @@ function publisher_items_spot_show($options)
$i = 1;
$itemsCount = count($selItems);
foreach ($selItems as $itemId) {
$itemObj = $helper->getHandler('Item')->get($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());
$item['who_when'] = sprintf(_MB_PUBLISHER_WHO_WHEN, $itemObj->posterName, $itemObj->getDatesub);
if ($i < $itemsCount) {
$item['showline'] = true;
} else {
Expand Down
36 changes: 30 additions & 6 deletions class/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ class Category extends \XoopsObject
* @var array
*/
public $categoryPath = false;
public $categoryid;
public $parentid;
public $name;
public $description;
public $image;
public $total;
public $weight;
public $created;
public $template;
public $header;
public $meta_keywords;
public $meta_description;
public $short_url;
public $moderator;

/**
* constructor
Expand Down Expand Up @@ -101,7 +115,7 @@ public function checkPermission()
if ($GLOBALS['publisherIsAdmin']) {
return true;
}
if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->getVar('uid') == $this->moderator()) {
if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->getVar('uid') == $this->moderator) {
return true;
}
/** @var \XoopsModules\Publisher\PermissionHandler $permissionHandler */
Expand Down Expand Up @@ -152,7 +166,9 @@ public function getCategoryPath($withAllLink = true)
}
$parentid = $this->parentid();
if (0 != $parentid) {
$parentObj = $this->helper->getHandler('Category')->get($parentid);
/** @var Publisher\CategoryHandler $categoryHandler */
$categoryHandler = $this->helper->getHandler('Category');
$parentObj = $categoryHandler->get($parentid);
// if ($parentObj->notLoaded()) {
// exit;
// }
Expand Down Expand Up @@ -183,7 +199,9 @@ public function getCategoryPathForMetaTitle()
$ret = '';
$parentid = $this->parentid();
if (0 != $parentid) {
$parentObj = $this->helper->getHandler('Category')->get($parentid);
/** @var Publisher\CategoryHandler $categoryHandler */
$categoryHandler = $this->helper->getHandler('Category');
$parentObj = $categoryHandler->get($parentid);
// if ($parentObj->notLoaded()) {
// exit('NOT LOADED');
// }
Expand All @@ -210,23 +228,29 @@ public function getCategoryPathForMetaTitle()
*/
public function getGroupsRead()
{
return $this->helper->getHandler('Permission')->getGrantedGroupsById('category_read', $this->categoryid());
/** @var Publisher\PermissionHandler $permissionHandler */
$permissionHandler = $this->helper->getHandler('Permission');
return $permissionHandler->getGrantedGroupsById('category_read', $this->categoryid());
}

/**
* @return array|null
*/
public function getGroupsSubmit()
{
return $this->helper->getHandler('Permission')->getGrantedGroupsById('item_submit', $this->categoryid());
/** @var Publisher\PermissionHandler $permissionHandler */
$permissionHandler = $this->helper->getHandler('Permission');
return $permissionHandler->getGrantedGroupsById('item_submit', $this->categoryid());
}

/**
* @return array|null
*/
public function getGroupsModeration()
{
return $this->helper->getHandler('Permission')->getGrantedGroupsById('category_moderation', $this->categoryid());
/** @var Publisher\PermissionHandler $permissionHandler */
$permissionHandler = $this->helper->getHandler('Permission');
return $permissionHandler->getGrantedGroupsById('category_moderation', $this->categoryid());
}

/**
Expand Down
32 changes: 19 additions & 13 deletions class/CategoryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,19 @@ public function get($id = null, $fields = null)
public function insert(\XoopsObject $category, $force = false) //insert(&$category, $force = false)
{
// Auto create meta tags if empty
if (!$category->meta_keywords() || !$category->meta_description()) {
$publisherMetagen = new Publisher\Metagen($category->name(), $category->getVar('meta_keywords'), $category->getVar('description'));
if (!$category->meta_keywords()) {
/** @var \XoopsModules\Publisher\Category $category */
if (!$category->meta_keywords || !$category->meta_description) {
$publisherMetagen = new Publisher\Metagen($category->name, $category->getVar('meta_keywords'), $category->getVar('description'));
if (!$category->meta_keywords) {
$category->setVar('meta_keywords', $publisherMetagen->keywords);
}
if (!$category->meta_description()) {
if (!$category->meta_description) {
$category->setVar('meta_description', $publisherMetagen->description);
}
}
// Auto create short_url if empty
if (!$category->short_url()) {
$category->setVar('short_url', Metagen::generateSeoTitle($category->name('n'), false));
if (!$category->short_url) {
$category->setVar('short_url', Publisher\Metagen::generateSeoTitle($category->name('n'), false));
}
$ret = parent::insert($category, $force);

Expand All @@ -112,12 +113,13 @@ public function insert(\XoopsObject $category, $force = false) //insert(&$catego
*/
public function delete(\XoopsObject $category, $force = false) //delete(&$category, $force = false)
{
/** @var \XoopsModules\Publisher\Category $category */
// Deleting this category ITEMs
$criteria = new \Criteria('categoryid', $category->categoryid());
$criteria = new \Criteria('categoryid', $category->categoryid);
$this->helper->getHandler('Item')->deleteAll($criteria);
unset($criteria);
// Deleting the sub categories
$subcats =& $this->getCategories(0, 0, $category->categoryid());
$subcats =& $this->getCategories(0, 0, $category->categoryid);
foreach ($subcats as $subcat) {
$this->delete($subcat);
}
Expand All @@ -127,9 +129,9 @@ public function delete(\XoopsObject $category, $force = false) //delete(&$catego
return false;
}
$moduleId = $this->helper->getModule()->getVar('mid');
xoops_groupperm_deletebymoditem($moduleId, 'category_read', $category->categoryid());
xoops_groupperm_deletebymoditem($moduleId, 'item_submit', $category->categoryid());
xoops_groupperm_deletebymoditem($moduleId, 'category_moderation', $category->categoryid());
xoops_groupperm_deletebymoditem($moduleId, 'category_read', $category->categoryid);
xoops_groupperm_deletebymoditem($moduleId, 'item_submit', $category->categoryid);
xoops_groupperm_deletebymoditem($moduleId, 'category_moderation', $category->categoryid);

return true;
}
Expand Down Expand Up @@ -180,7 +182,9 @@ public function &getCategories($limit = 0, $start = 0, $parentid = 0, $sort = 'w
$criteria->add(new \Criteria('parentid', $parentid));
}
if (!$GLOBALS['publisherIsAdmin']) {
$categoriesGranted = $this->helper->getHandler('Permission')->getGrantedItems('category_read');
/** @var Publisher\PermissionHandler $permissionHandler */
$permissionHandler = $this->helper->getHandler('Permission');
$categoriesGranted = $permissionHandler->getGrantedItems('category_read');
if (count($categoriesGranted) > 0) {
$criteria->add(new \Criteria('categoryid', '(' . implode(',', $categoriesGranted) . ')', 'IN'));
} else {
Expand Down Expand Up @@ -406,6 +410,8 @@ public function publishedItemsCount($catId = 0)
*/
public function itemsCount($catId = 0, $status = '')
{
return $this->helper->getHandler('Item')->getCountsByCat($catId, $status);
/** @var Publisher\ItemHandler $itemHandler */
$itemHandler = $this->helper->getHandler('Item');
return $itemHandler->getCountsByCat($catId, $status);
}
}
12 changes: 8 additions & 4 deletions class/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ public function __call($method, $args)
*/
public function checkUpload($postField, $allowedMimetypes, &$errors)
{
$errors = [];
if (!$this->helper->getHandler('Mimetype')->checkMimeTypes($postField)) {
/** @var Publisher\MimetypeHandler $mimetypeHandler */
$mimetypeHandler = $this->helper->getHandler('Mimetype');
$errors = [];
if (!$mimetypeHandler->checkMimeTypes($postField)) {
$errors[] = _CO_PUBLISHER_MESSAGE_WRONG_MIMETYPE;

return false;
}
if (0 === count($allowedMimetypes)) {
$allowedMimetypes = $this->helper->getHandler('Mimetype')->getArrayByType();
$allowedMimetypes = $mimetypeHandler->getArrayByType();
}
$maxfilesize = $this->helper->getConfig('maximum_filesize');
$maxfilewidth = $this->helper->getConfig('maximum_image_width');
Expand All @@ -122,9 +124,11 @@ public function checkUpload($postField, $allowedMimetypes, &$errors)
*/
public function storeUpload($postField, $allowedMimetypes, &$errors)
{
/** @var Publisher\MimetypeHandler $mimetypeHandler */
$mimetypeHandler = $this->helper->getHandler('Mimetype');
$itemid = $this->getVar('itemid');
if (0 === count($allowedMimetypes)) {
$allowedMimetypes = $this->helper->getHandler('Mimetype')->getArrayByType();
$allowedMimetypes = $mimetypeHandler->getArrayByType();
}
$maxfilesize = $this->helper->getConfig('maximum_filesize');
$maxfilewidth = $this->helper->getConfig('maximum_image_width');
Expand Down
2 changes: 1 addition & 1 deletion class/ItemHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function insert(\XoopsObject $item, $force = false) //insert(&$item, $fo
}
// Auto create short_url if empty
if (!$item->short_url()) {
$item->setVar('short_url', mb_substr(Metagen::generateSeoTitle($item->getVar('title', 'n'), false), 0, 254));
$item->setVar('short_url', mb_substr(Publisher\Metagen::generateSeoTitle($item->getVar('title', 'n'), false), 0, 254));
}
}
if (!parent::insert($item, $force)) {
Expand Down
3 changes: 2 additions & 1 deletion class/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,8 @@ public static function getEditors($allowedEditors = null)
$nohtml = false;
xoops_load('XoopsEditorHandler');
$editorHandler = \XoopsEditorHandler::getInstance();
$editors = array_flip($editorHandler->getList()); //$editorHandler->getList($nohtml);
// $editors = array_flip($editorHandler->getList()); //$editorHandler->getList($nohtml);
$editors = $editorHandler->getList($nohtml);
foreach ($editors as $name => $title) {
$key = static::stringToInt($name);
if (is_array($allowedEditors)) {
Expand Down
3 changes: 2 additions & 1 deletion docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<h5>1.06 Final [2018-08-01]</h5> Dev: XOOPS 2.5.9, PHP 7.2.8
<hr>
- cosmetics (mamba)
- fixes (mamba)
- reversing to old way of checking editors (mamba)
- fix installation error (mamba)

<h5>1.06 RC 1 [2018-07-15]</h5> Dev: XOOPS 2.5.9, PHP 7.2.7
<hr>
Expand Down

0 comments on commit 6a20f5d

Please sign in to comment.