');
- $addcol = new \XoopsFormLabel('', ' | ');
- $addbreak = new \XoopsFormLabel('', ' ');
+ $opentable = new \XoopsFormLabel('', '');
+ $addcol = new \XoopsFormLabel('', ' | ');
+ $addbreak = new \XoopsFormLabel('', ' ');
$closetable = new \XoopsFormLabel('', ' | ');
$GLOBALS['xoTheme']->addScript(PUBLISHER_URL . '/assets/js/ajaxupload.3.9.js');
- $js_data = new \XoopsFormLabel(
+ $js_data = new \XoopsFormLabel(
'', '
';
// }
- } else {
- $pdfButton .= "itemid() . "' rel='nofollow' target='_blank'> ";
- $pdfButton .= ' ';
- }
- return $pdfButton;
+ } else {
+ $pdfButton .= "itemid() . "' rel='nofollow' target='_blank'> ";
+ $pdfButton .= ' ';
}
- /**
+ return $pdfButton;
+ }
+
+ /**
* @return string
*/
public function getPrintLinks()
{
- $printLinks = '';
+ $printLinks = '';
// Print button
$printLinks .= "itemid(), $this->short_url()) . "' rel='nofollow' target='_blank'> ";
$printLinks .= ' ';
+
return $printLinks;
}
@@ -528,15 +529,15 @@ public function sendNotifications($notifications = [])
{
/** @var \XoopsNotificationHandler $notificationHandler */
$notificationHandler = \xoops_getHandler('notification');
- $tags = [];
+ $tags = [];
- $tags['MODULE_NAME'] = $this->helper->getModule()->getVar('name');
- $tags['ITEM_NAME'] = $this->getTitle();
- $tags['ITEM_SUBNAME'] = $this->getSubtitle();
+ $tags['MODULE_NAME'] = $this->helper->getModule()->getVar('name');
+ $tags['ITEM_NAME'] = $this->getTitle();
+ $tags['ITEM_SUBNAME'] = $this->getSubtitle();
$tags['CATEGORY_NAME'] = $this->getCategoryName();
- $tags['CATEGORY_URL'] = PUBLISHER_URL . '/category.php?categoryid=' . $this->categoryid();
- $tags['ITEM_BODY'] = $this->body();
- $tags['DATESUB'] = $this->getDatesub();
+ $tags['CATEGORY_URL'] = PUBLISHER_URL . '/category.php?categoryid=' . $this->categoryid();
+ $tags['ITEM_BODY'] = $this->body();
+ $tags['DATESUB'] = $this->getDatesub();
foreach ($notifications as $notification) {
switch ($notification) {
case Constants::PUBLISHER_NOTIFY_ITEM_PUBLISHED:
@@ -566,8 +567,8 @@ public function sendNotifications($notifications = [])
public function setDefaultPermissions()
{
$memberHandler = \xoops_getHandler('member');
- $groups = $memberHandler->getGroupList();
- $groupIds = 0 < \count($groups) ? \array_keys($groups) : [];
+ $groups = $memberHandler->getGroupList();
+ $groupIds = \count($groups) > 0 ? \array_keys($groups) : [];
/*
$j = 0;
$groupIds = [];
@@ -639,7 +640,7 @@ public function getItemLink($class = false, $maxsize = 0)
public function getWhoAndWhen()
{
$posterName = $this->getLinkedPosterName();
- $postdate = $this->getDatesub();
+ $postdate = $this->getDatesub();
return \sprintf(\_CO_PUBLISHER_POSTEDBY, $posterName, $postdate);
}
@@ -718,11 +719,11 @@ public function getImages()
static $ret;
$itemid = $this->getVar('itemid');
if (!isset($ret[$itemid])) {
- $ret[$itemid]['main'] = '';
+ $ret[$itemid]['main'] = '';
$ret[$itemid]['others'] = [];
- $imagesIds = [];
- $image = $this->getVar('image');
- $images = $this->getVar('images');
+ $imagesIds = [];
+ $image = $this->getVar('image');
+ $images = $this->getVar('images');
if ('' != $images) {
$imagesIds = \explode('|', $images);
}
@@ -732,8 +733,8 @@ public function getImages()
$imageObjs = [];
if (\count($imagesIds) > 0) {
$imageHandler = \xoops_getHandler('image');
- $criteria = new \CriteriaCompo(new \Criteria('image_id', '(' . \implode(',', $imagesIds) . ')', 'IN'));
- $imageObjs = $imageHandler->getObjects($criteria, true);
+ $criteria = new \CriteriaCompo(new \Criteria('image_id', '(' . \implode(',', $imagesIds) . ')', 'IN'));
+ $imageObjs = $imageHandler->getObjects($criteria, true);
unset($criteria);
}
foreach ($imageObjs as $id => $imageObj) {
@@ -763,35 +764,35 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS
$itemPageId = -1;
if (\is_numeric($display)) {
$itemPageId = $display;
- $display = 'all';
+ $display = 'all';
}
- $item['itemid'] = $this->itemid();
- $item['uid'] = $this->uid();
- $item['itemurl'] = $this->getItemUrl();
- $item['titlelink'] = $this->getItemLink('titlelink', $maxCharTitle);
- $item['subtitle'] = $this->subtitle();
- $item['datesub'] = $this->getDatesub();
+ $item['itemid'] = $this->itemid();
+ $item['uid'] = $this->uid();
+ $item['itemurl'] = $this->getItemUrl();
+ $item['titlelink'] = $this->getItemLink('titlelink', $maxCharTitle);
+ $item['subtitle'] = $this->subtitle();
+ $item['datesub'] = $this->getDatesub();
$item['dateexpire'] = $this->getDateExpire();
- $item['counter'] = $this->counter();
- $item['hits'] = ' ' . $this->counter() . ' ' . _READS . '';
- $item['who'] = $this->getWho();
- $item['when'] = $this->getWhen();
- $item['category'] = $this->getCategoryName();
- $item['categorylink'] = $this->getCategoryLink();
- $item['cancomment'] = $this->cancomment();
+ $item['counter'] = $this->counter();
+ $item['hits'] = ' ' . $this->counter() . ' ' . _READS . '';
+ $item['who'] = $this->getWho();
+ $item['when'] = $this->getWhen();
+ $item['category'] = $this->getCategoryName();
+ $item['categorylink'] = $this->getCategoryLink();
+ $item['cancomment'] = $this->cancomment();
$comments = $this->comments();
- if ($comments > 0) {
- //shows 1 comment instead of 1 comm. if comments ==1
- //langugage file modified accordingly
- if (1 == $comments) {
- $item['comments'] = ' ' . \_MD_PUBLISHER_ONECOMMENT . ' ';
- } else {
- $item['comments'] = ' ' . $comments . ' ' . \_MD_PUBLISHER_COMMENTS . ' ';
- }
+ if ($comments > 0) {
+ //shows 1 comment instead of 1 comm. if comments ==1
+ //langugage file modified accordingly
+ if (1 == $comments) {
+ $item['comments'] = ' ' . \_MD_PUBLISHER_ONECOMMENT . ' ';
} else {
- $item['comments'] = ' ' . \_MD_PUBLISHER_NO_COMMENTS . ' ';
+ $item['comments'] = ' ' . $comments . ' ' . \_MD_PUBLISHER_COMMENTS . ' ';
}
- $item = $this->getMainImage($item);
+ } else {
+ $item['comments'] = ' ' . \_MD_PUBLISHER_NO_COMMENTS . ' ';
+ }
+ $item = $this->getMainImage($item);
switch ($display) {
case 'summary':
$item = $this->toArrayFull($item);
@@ -813,9 +814,9 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS
if (!$summary) {
$summary = $this->getBody($maxCharSummary);
}
- $item['summary'] = $summary;
+ $item['summary'] = $summary;
$item['truncated'] = $maxCharSummary > 0 && mb_strlen($summary) > $maxCharSummary;
- $item = $this->toArrayFull($item);
+ $item = $this->toArrayFull($item);
break;
case 'all':
$item = $this->toArrayFull($item);
@@ -825,9 +826,9 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS
// Highlighting searched words
$highlight = true;
if ($highlight && Request::getString('keywords', '', 'GET')) {
- $myts = \MyTextSanitizer::getInstance();
+ $myts = \MyTextSanitizer::getInstance();
$keywords = $myts->htmlSpecialChars(\trim(\urldecode(Request::getString('keywords', '', 'GET'))));
- $fields = ['title', 'maintext', 'summary'];
+ $fields = ['title', 'maintext', 'summary'];
foreach ($fields as $field) {
if (isset($item[$field])) {
$item[$field] = $this->highlight($item[$field], $keywords);
@@ -845,21 +846,21 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS
*/
public function toArrayFull($item)
{
- $item['title'] = $this->getTitle();
- $item['clean_title'] = $this->getTitle();
- $item['itemurl'] = $this->getItemUrl();
-
- $item['adminlink'] = $this->getAdminLinks();
- $item['pdfbutton'] = $this->getPdfButton();
- $item['printlink'] = $this->getPrintLinks();
+ $item['title'] = $this->getTitle();
+ $item['clean_title'] = $this->getTitle();
+ $item['itemurl'] = $this->getItemUrl();
+
+ $item['adminlink'] = $this->getAdminLinks();
+ $item['pdfbutton'] = $this->getPdfButton();
+ $item['printlink'] = $this->getPrintLinks();
$item['categoryPath'] = $this->getCategoryPath($this->helper->getConfig('format_linked_path'));
- $item['who_when'] = $this->getWhoAndWhen();
- $item['who'] = $this->getWho();
- $item['when'] = $this->getWhen();
- $item['category'] = $this->getCategoryName();
- $item['body'] = $this->getBody();
- $item['more'] = $this->getItemUrl();
- $item = $this->getMainImage($item);
+ $item['who_when'] = $this->getWhoAndWhen();
+ $item['who'] = $this->getWho();
+ $item['when'] = $this->getWhen();
+ $item['category'] = $this->getCategoryName();
+ $item['body'] = $this->getBody();
+ $item['more'] = $this->getItemUrl();
+ $item = $this->getMainImage($item);
return $item;
}
@@ -873,7 +874,7 @@ public function toArrayFull($item)
public function toArrayAll($item, $itemPageId)
{
$item['maintext'] = $this->buildMainText($itemPageId, $this->getBody());
- $item = $this->getOtherImages($item);
+ $item = $this->getOtherImages($item);
return $item;
}
@@ -885,14 +886,14 @@ public function toArrayAll($item, $itemPageId)
*/
public function getMainImage($item = [])
{
- $images = $this->getImages();
+ $images = $this->getImages();
$item['image_path'] = '';
$item['image_name'] = '';
if (\is_object($images['main'])) {
- $dimensions = \getimagesize($GLOBALS['xoops']->path('uploads/' . $images['main']->getVar('image_name')));
- $item['image_width'] = $dimensions[0];
+ $dimensions = \getimagesize($GLOBALS['xoops']->path('uploads/' . $images['main']->getVar('image_name')));
+ $item['image_width'] = $dimensions[0];
$item['image_height'] = $dimensions[1];
- $item['image_path'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name');
+ $item['image_path'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name');
// check to see if GD function exist
if (!\function_exists('imagecreatetruecolor')) {
$item['image_thumb'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name');
@@ -912,14 +913,14 @@ public function getMainImage($item = [])
*/
public function getOtherImages($item = [])
{
- $images = $this->getImages();
+ $images = $this->getImages();
$item['images'] = [];
- $i = 0;
+ $i = 0;
foreach ($images['others'] as $image) {
- $dimensions = \getimagesize($GLOBALS['xoops']->path('uploads/' . $image->getVar('image_name')));
- $item['images'][$i]['width'] = $dimensions[0];
+ $dimensions = \getimagesize($GLOBALS['xoops']->path('uploads/' . $image->getVar('image_name')));
+ $item['images'][$i]['width'] = $dimensions[0];
$item['images'][$i]['height'] = $dimensions[1];
- $item['images'][$i]['path'] = XOOPS_URL . '/uploads/' . $image->getVar('image_name');
+ $item['images'][$i]['path'] = XOOPS_URL . '/uploads/' . $image->getVar('image_name');
// check to see if GD function exist
if (!\function_exists('imagecreatetruecolor')) {
$item['images'][$i]['thumb'] = XOOPS_URL . '/uploads/' . $image->getVar('image_name');
@@ -977,8 +978,8 @@ protected function convertForJapanese($str)
return $str;
}
// presume OS Browser
- $agent = Request::getString('HTTP_USER_AGENT', '', 'SERVER');
- $os = '';
+ $agent = Request::getString('HTTP_USER_AGENT', '', 'SERVER');
+ $os = '';
$browser = '';
// if (preg_match("/Win/i", $agent)) {
if (false !== mb_stripos($agent, 'Win')) {
@@ -1050,7 +1051,7 @@ public function setVarsFromRequest()
// $this->setVar('categoryid', $categoryid);}
if (\is_object($GLOBALS['xoopsUser'])) {
$userTimeoffset = $GLOBALS['xoopsUser']->getVar('timezone_offset');
- }else{
+ } else {
$userTimeoffset = null;
}
$this->setVar('categoryid', Request::getInt('categoryid', 0, 'POST'));
@@ -1069,15 +1070,15 @@ public function setVarsFromRequest()
//Image hack
$imageItemIds = [];
- $sql = 'SELECT image_id, image_name FROM ' . $GLOBALS['xoopsDB']->prefix('image');
+ $sql = 'SELECT image_id, image_name FROM ' . $GLOBALS['xoopsDB']->prefix('image');
$result = $GLOBALS['xoopsDB']->query($sql, 0, 0);
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
$imageName = $myrow['image_name'];
- $id = $myrow['image_id'];
+ $id = $myrow['image_id'];
if ($imageName == $imageFeatured) {
$this->setVar('image', $id);
}
- if (\in_array($imageName, $imageItem)) {
+ if (\in_array($imageName, $imageItem, true)) {
$imageItemIds[] = $id;
}
}
@@ -1107,11 +1108,11 @@ public function setVarsFromRequest()
$dateTimeObj->setTime(0, 0, (int)$resTime['time']);
$serverTimestamp = userTimeToServerTime($dateTimeObj->getTimestamp(), $userTimeoffset);
$this->setVar('datesub', $serverTimestamp);
- // }
+ // }
} elseif ($this->isNew()) {
$this->setVar('datesub', \time());
}
-
+
// date expire
if (0 !== Request::getInt('use_expire_yn', 0, 'POST')) {
if ('' !== Request::getString('dateexpire', '', 'POST')) {
diff --git a/class/ItemHandler.php b/class/ItemHandler.php
index 8a117d00..60d541b5 100644
--- a/class/ItemHandler.php
+++ b/class/ItemHandler.php
@@ -17,7 +17,6 @@
/**
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
* @author The SmartFactory
@@ -25,7 +24,6 @@
use XoopsModules\Publisher;
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
@@ -34,7 +32,6 @@
* of Q&A class objects.
*
* @author marcan
- * @package Publisher
*/
class ItemHandler extends \XoopsPersistableObjectHandler
{
@@ -46,10 +43,6 @@ class ItemHandler extends \XoopsPersistableObjectHandler
protected $resultCatCounts = [];
- /**
- * @param \XoopsDatabase|null $db
- * @param \XoopsModules\Publisher\Helper|null $helper
- */
public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\Helper $helper = null)
{
/** @var Publisher\Helper $this ->helper */
@@ -178,8 +171,8 @@ public function delete(\XoopsObject $item, $force = false)
*/
public function &getObjects(\CriteriaElement $criteria = null, $idKey = 'none', $as_object = true, $notNullFields = null)
{
- $limit = $start = 0;
- $ret = [];
+ $limit = $start = 0;
+ $ret = [];
$notNullFields = (null !== $notNullFields) ?: '';
$sql = 'SELECT * FROM ' . $this->db->prefix($this->helper->getDirname() . '_items');
@@ -420,7 +413,7 @@ public function getAllExpired($limit = 0, $start = 0, $categoryid = -1, $sort =
*/
public function getPreviousPublished($obj)
{
- $ret = false;
+ $ret = false;
$otherCriteria = new \CriteriaCompo();
$otherCriteria->add(new \Criteria('datesub', $obj->getVar('datesub'), '<'));
$objs = $this->getItems(1, 0, [Constants::PUBLISHER_STATUS_PUBLISHED], $obj->getVar('categoryid'), 'datesub', 'DESC', '', true, $otherCriteria, 'none');
@@ -438,7 +431,7 @@ public function getPreviousPublished($obj)
*/
public function getNextPublished($obj)
{
- $ret = false;
+ $ret = false;
$otherCriteria = new \CriteriaCompo();
$otherCriteria->add(new \Criteria('datesub', $obj->getVar('datesub'), '>'));
$otherCriteria->add(new \Criteria('datesub', \time(), '<='));
@@ -563,7 +556,7 @@ public function getItems($limit = 0, $start = 0, $status = '', $categoryid = -1,
$criteria->setStart($start);
$criteria->setSort($sort);
$criteria->order = $order; // patch for XOOPS <= 2.5.10 does not set order correctly using setOrder() method
- $ret = &$this->getObjects($criteria, $idKey, $notNullFields);
+ $ret = &$this->getObjects($criteria, $idKey, $notNullFields);
return $ret;
}
@@ -573,13 +566,13 @@ public function getItems($limit = 0, $start = 0, $status = '', $categoryid = -1,
* @param string $status
* @param int $categoryId
*
- * @return bool
* @throws \Exception
* @throws \Exception
+ * @return bool
*/
public function getRandomItem($field = '', $status = '', $categoryId = -1)
{
- $ret = false;
+ $ret = false;
$notNullFields = $field;
// Getting the number of published Items
$totalItems = $this->getItemsCount($categoryId, $status, $notNullFields);
@@ -588,7 +581,7 @@ public function getRandomItem($field = '', $status = '', $categoryId = -1)
$entryNumber = \random_int(0, $totalItems); //TODO switch in PHP 7 to random_int()
// $entryNumber2 = random_int(0, $totalItems);
- $item = $this->getItems(1, $entryNumber, $status, $categoryId, $sort = 'datesub', $order = 'DESC', $notNullFields);
+ $item = $this->getItems(1, $entryNumber, $status, $categoryId, $sort = 'datesub', $order = 'DESC', $notNullFields);
if ($item) {
$ret = $item[0];
}
@@ -670,14 +663,14 @@ public function notNullFieldClause($notNullFields = '', $withAnd = false)
*/
public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0, $categories = [], $sortby = 0, $searchin = '', $extra = '')
{
- $count = 0;
- $ret = [];
+ $count = 0;
+ $ret = [];
$criteriaKeywords = $criteriaPermissions = $criteriaUser = null;
- /* @var \XoopsGroupPermHandler $grouppermHandler */
+ /** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = \xoops_getHandler('groupperm');
- $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
- $searchin = empty($searchin) ? ['title', 'body', 'summary'] : (\is_array($searchin) ? $searchin : [$searchin]);
- if (\in_array('all', $searchin) || 0 === \count($searchin)) {
+ $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
+ $searchin = empty($searchin) ? ['title', 'body', 'summary'] : (\is_array($searchin) ? $searchin : [$searchin]);
+ if (\in_array('all', $searchin, true) || 0 === \count($searchin)) {
$searchin = ['title', 'subtitle', 'body', 'summary', 'meta_keywords'];
//add support for searching in tags if Tag module exists and is active
if (false !== $this->helper::getHelper('tag')) {
@@ -685,7 +678,7 @@ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0,
}
}
if ($userid && \is_array($userid)) {
- $userid = \array_map('\intval', $userid);
+ $userid = \array_map('\intval', $userid);
$criteriaUser = new \CriteriaCompo();
$criteriaUser->add(new \Criteria('uid', '(' . \implode(',', $userid) . ')', 'IN'), 'OR');
} elseif (\is_numeric($userid) && $userid > 0) {
@@ -736,7 +729,7 @@ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0,
$criteriaPermissions->add($grantedCategories, 'AND');
} elseif (\count($categories) > 0) {
$criteriaPermissions = new \CriteriaCompo();
- $grantedCategories = new \Criteria('categoryid', '(' . \implode(',', $categories) . ')', 'IN');
+ $grantedCategories = new \Criteria('categoryid', '(' . \implode(',', $categories) . ')', 'IN');
$criteriaPermissions->add($grantedCategories, 'AND');
}
$criteriaItemsStatus = new \CriteriaCompo();
@@ -765,7 +758,7 @@ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0,
$order = 'DESC';
}
$criteria->order = $order; // patch for XOOPS <= 2.5.10, does not set order correctly using setOrder() method
- $ret = &$this->getObjects($criteria);
+ $ret = &$this->getObjects($criteria);
return $ret;
}
@@ -778,11 +771,11 @@ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0,
*/
public function getLastPublishedByCat($categoriesObj, $status = [Constants::PUBLISHER_STATUS_PUBLISHED])
{
- $ret = [];
+ $ret = [];
$catIds = [];
foreach ($categoriesObj as $parentid) {
foreach ($parentid as $category) {
- $catId = $category->getVar('categoryid');
+ $catId = $category->getVar('categoryid');
$catIds[$catId] = $catId;
}
}
@@ -815,12 +808,12 @@ public function getLastPublishedByCat($categoriesObj, $status = [Constants::PUBL
unset($item);
}
*/
- $sql = 'SELECT mi.categoryid, mi.itemid, mi.title, mi.short_url, mi.uid, mi.datesub';
- $sql .= ' FROM (SELECT categoryid, MAX(datesub) AS date FROM ' . $this->db->prefix($this->helper->getDirname() . '_items');
- $sql .= ' WHERE status IN (' . \implode(',', $status) . ')';
- $sql .= ' AND categoryid IN (' . \implode(',', $catIds) . ')';
- $sql .= ' GROUP BY categoryid)mo';
- $sql .= ' JOIN ' . $this->db->prefix($this->helper->getDirname() . '_items') . ' mi ON mi.datesub = mo.date';
+ $sql = 'SELECT mi.categoryid, mi.itemid, mi.title, mi.short_url, mi.uid, mi.datesub';
+ $sql .= ' FROM (SELECT categoryid, MAX(datesub) AS date FROM ' . $this->db->prefix($this->helper->getDirname() . '_items');
+ $sql .= ' WHERE status IN (' . \implode(',', $status) . ')';
+ $sql .= ' AND categoryid IN (' . \implode(',', $catIds) . ')';
+ $sql .= ' GROUP BY categoryid)mo';
+ $sql .= ' JOIN ' . $this->db->prefix($this->helper->getDirname() . '_items') . ' mi ON mi.datesub = mo.date';
$result = $this->db->query($sql);
while (false !== ($row = $this->db->fetchArray($result))) {
// $item = new Item();
@@ -843,12 +836,12 @@ public function countArticlesByCat($parentid, $catsCount, $spaces = '')
{
// global $resultCatCounts;
$newspaces = $spaces . '--';
- $thecount = 0;
+ $thecount = 0;
foreach ($catsCount[$parentid] as $subCatId => $count) {
- $thecount += $count;
+ $thecount += $count;
$this->resultCatCounts[$subCatId] = $count;
if (isset($catsCount[$subCatId])) {
- $thecount += $this->countArticlesByCat($subCatId, $catsCount, $newspaces);
+ $thecount += $this->countArticlesByCat($subCatId, $catsCount, $newspaces);
$this->resultCatCounts[$subCatId] = $thecount;
}
}
@@ -867,16 +860,16 @@ public function getCountsByCat($catId, $status, $inSubCat = false)
{
// global $resultCatCounts;
- $ret = [];
+ $ret = [];
$catsCount = [];
- $sql = 'SELECT c.parentid, i.categoryid, COUNT(*) AS count FROM ' . $this->db->prefix($this->helper->getDirname() . '_items') . ' AS i INNER JOIN ' . $this->db->prefix($this->helper->getDirname() . '_categories') . ' AS c ON i.categoryid=c.categoryid';
+ $sql = 'SELECT c.parentid, i.categoryid, COUNT(*) AS count FROM ' . $this->db->prefix($this->helper->getDirname() . '_items') . ' AS i INNER JOIN ' . $this->db->prefix($this->helper->getDirname() . '_categories') . ' AS c ON i.categoryid=c.categoryid';
if ((int)$catId > 0) {
$sql .= ' WHERE i.categoryid = ' . (int)$catId;
$sql .= ' AND i.status IN (' . \implode(',', $status) . ')';
} else {
$sql .= ' WHERE i.status IN (' . \implode(',', $status) . ')';
}
- $sql .= ' GROUP BY i.categoryid ORDER BY c.parentid ASC, i.categoryid ASC';
+ $sql .= ' GROUP BY i.categoryid ORDER BY c.parentid ASC, i.categoryid ASC';
$result = $this->db->query($sql);
if (!$result) {
return $ret;
diff --git a/class/Metagen.php b/class/Metagen.php
index 5416ef59..3dfd728f 100644
--- a/class/Metagen.php
+++ b/class/Metagen.php
@@ -17,7 +17,6 @@
/**
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
* @author The SmartFactory
@@ -25,8 +24,6 @@
use XoopsModules\Publisher;
-
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
@@ -84,7 +81,7 @@ public function __construct($title, $keywords = '', $description = '', $category
{
/** @var \XoopsModules\Publisher\Helper $this ->helper */
$this->helper = \XoopsModules\Publisher\Helper::getInstance();
- $this->myts = \MyTextSanitizer::getInstance();
+ $this->myts = \MyTextSanitizer::getInstance();
$this->setCategoryPath($categoryPath);
$this->setTitle($title);
$this->setDescription($description);
@@ -99,10 +96,10 @@ public function __construct($title, $keywords = '', $description = '', $category
*/
public function setTitle($title)
{
- $this->title = $this->html2text($title);
+ $this->title = $this->html2text($title);
$this->originalTitle = $this->title;
- $titleTag = [];
- $titleTag['module'] = $this->helper->getModule()->getVar('name');
+ $titleTag = [];
+ $titleTag['module'] = $this->helper->getModule()->getVar('name');
if (isset($this->title) && ('' != $this->title) && (mb_strtoupper($this->title) != mb_strtoupper($titleTag['module']))) {
$titleTag['title'] = $this->title;
}
@@ -138,7 +135,7 @@ public function setKeywords($keywords)
*/
public function setCategoryPath($categoryPath)
{
- $categoryPath = $this->html2text($categoryPath);
+ $categoryPath = $this->html2text($categoryPath);
$this->categoryPath = $categoryPath;
}
@@ -147,8 +144,8 @@ public function setCategoryPath($categoryPath)
*/
public function setDescription($description)
{
- $description = $this->html2text($description);
- $description = $this->purifyText($description);
+ $description = $this->html2text($description);
+ $description = $this->purifyText($description);
$this->description = $description;
}
@@ -168,10 +165,10 @@ public function createMetaDescription($maxWords = 30)
{
$description = $this->purifyText($this->description);
$description = $this->html2text($description);
- $words = \explode(' ', $description);
- $ret = '';
- $i = 1;
- $wordCount = \count($words);
+ $words = \explode(' ', $description);
+ $ret = '';
+ $i = 1;
+ $wordCount = \count($words);
foreach ($words as $word) {
$ret .= $word;
if ($i < $wordCount) {
@@ -191,15 +188,15 @@ public function createMetaDescription($maxWords = 30)
*/
public function findMetaKeywords($text, $minChar)
{
- $keywords = [];
- $text = $this->purifyText($text);
- $text = $this->html2text($text);
+ $keywords = [];
+ $text = $this->purifyText($text);
+ $text = $this->html2text($text);
$originalKeywords = \explode(' ', $text);
foreach ($originalKeywords as $originalKeyword) {
$secondRoundKeywords = \explode("'", $originalKeyword);
foreach ($secondRoundKeywords as $secondRoundKeyword) {
if (mb_strlen($secondRoundKeyword) >= $minChar) {
- if (!\in_array($secondRoundKeyword, $keywords)) {
+ if (!\in_array($secondRoundKeyword, $keywords, true)) {
$keywords[] = \trim($secondRoundKeyword);
}
}
@@ -214,11 +211,11 @@ public function findMetaKeywords($text, $minChar)
*/
public function createMetaKeywords()
{
- $keywords = $this->findMetaKeywords($this->originalTitle . ' ' . $this->description, $this->minChar);
+ $keywords = $this->findMetaKeywords($this->originalTitle . ' ' . $this->description, $this->minChar);
$moduleKeywords = $this->helper->getConfig('seo_meta_keywords');
if ('' != $moduleKeywords) {
$moduleKeywords = \explode(',', $moduleKeywords);
- $keywords = \array_merge($keywords, \array_map('\trim', $moduleKeywords));
+ $keywords = \array_merge($keywords, \array_map('\trim', $moduleKeywords));
}
$ret = \implode(',', $keywords);
@@ -237,7 +234,7 @@ public function autoBuildMetaKeywords()
*/
public function buildAutoMetaTags()
{
- $this->keywords = $this->createMetaKeywords();
+ $this->keywords = $this->createMetaKeywords();
$this->description = $this->createMetaDescription();
//$this->title = $this->createTitleTag();
}
@@ -318,8 +315,8 @@ public static function generateSeoTitle($title = '', $withExt = true)
'/%7E/', // ~
"/\./", // .
];
- $repPat = ['-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-'];
- $title = preg_replace($pattern, $repPat, $title);
+ $repPat = ['-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-'];
+ $title = preg_replace($pattern, $repPat, $title);
// Transformation des caractères accentués
$pattern = [
'/%B0/', // °
@@ -339,17 +336,19 @@ public static function generateSeoTitle($title = '', $withExt = true)
'/%F4/', // ô
'/%F6/', // ö
];
- $repPat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
- $title = \preg_replace($pattern, $repPat, $title);
+ $repPat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
+ $title = \preg_replace($pattern, $repPat, $title);
$tableau = \explode('-', $title); // Transforms the string in table //Transforme la chaine de caractères en tableau
$tableau = \array_filter($tableau, ['XoopsModules\Publisher\Metagen', 'emptyString']); // Remove empty strings of the table //Supprime les chaines vides du tableau
- $title = \implode('-', $tableau); // Transforms a character string in table separated by a hyphen //Transforme un tableau en chaine de caractères séparé par un tiret
+ $title = \implode('-', $tableau); // Transforms a character string in table separated by a hyphen //Transforme un tableau en chaine de caractères séparé par un tiret
if ($title && !(\is_array($title))) {
if ($withExt) {
$title .= '.html';
}
+
return $title;
}
+
return '';
}
diff --git a/class/Mimetype.php b/class/Mimetype.php
index 78117b28..9dc06f37 100644
--- a/class/Mimetype.php
+++ b/class/Mimetype.php
@@ -19,7 +19,6 @@
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
* @author The SmartFactory
@@ -27,15 +26,12 @@
use XoopsModules\Publisher;
-
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
* Mimetype class
*
* @author Eric Juden
- * @package publisher
*/
class Mimetype extends \XoopsObject
{
diff --git a/class/MimetypeHandler.php b/class/MimetypeHandler.php
index 121ce0e8..65d97409 100644
--- a/class/MimetypeHandler.php
+++ b/class/MimetypeHandler.php
@@ -19,7 +19,6 @@
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
* @author The SmartFactory
@@ -27,8 +26,6 @@
use XoopsModules\Publisher;
-
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
@@ -38,9 +35,6 @@ class MimetypeHandler extends BaseObjectHandler
{
/**
* Constructor
- *
- * @param \XoopsDatabase|null $db
- * @param \XoopsModules\Publisher\Helper|null $helper
*/
public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\Helper $helper = null)
{
@@ -52,8 +46,8 @@ public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\H
}
$this->publisherIsAdmin = $this->helper->isUserAdmin();
- $this->db = $db;
- $this->className = Mimetype::class;
+ $this->db = $db;
+ $this->className = Mimetype::class;
}
/**
@@ -96,9 +90,9 @@ public function get($id = null, $fields = null)
*/
public function &getObjects(\CriteriaElement $criteria = null, $idAsKey = false, $asObject = true) //&getObjects($criteria = null)
{
- $ret = [];
+ $ret = [];
$limit = $start = 0;
- $sql = $this->selectQuery($criteria);
+ $sql = $this->selectQuery($criteria);
if (null !== $criteria) {
$limit = $criteria->getLimit();
$start = $criteria->getStart();
@@ -111,7 +105,7 @@ public function &getObjects(\CriteriaElement $criteria = null, $idAsKey = false,
}
// Add each returned record to the result array
while (false !== ($myrow = $this->db->fetchArray($result))) {
- $obj = new $this->className($myrow);
+ $obj = new $this->className($myrow);
$ret[] = $obj;
unset($obj);
}
@@ -166,7 +160,7 @@ public function getArray($mimeExt = null)
*/
public function checkMimeTypes($postField)
{
- $ret = false;
+ $ret = false;
$allowed_mimetypes = $this->getArrayByType();
if (empty($allowed_mimetypes)) {
return $ret;
@@ -219,7 +213,7 @@ private function selectQuery(\CriteriaElement $criteria = null, $join = false)
if ($join) {
throw new \RuntimeException('no need for join...');
}
- } catch (\Exception $e) {
+ } catch (\Throwable $e) {
/** @var Publisher\Helper $helper */
$helper = Publisher\Helper::getInstance();
$helper->addLog($e);
diff --git a/class/MimetypesUtility.php b/class/MimetypesUtility.php
index 20fc9bab..dfcce795 100644
--- a/class/MimetypesUtility.php
+++ b/class/MimetypesUtility.php
@@ -19,7 +19,6 @@
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
* @author The SmartFactory
@@ -49,8 +48,8 @@ public static function add()
Publisher\Utility::openCollapsableBar('mimemaddtable', 'mimeaddicon', \_AM_PUBLISHER_MIME_ADD_TITLE);
- $session = Publisher\Session::getInstance();
- $mimeType = $session->get('publisher_addMime');
+ $session = Publisher\Session::getInstance();
+ $mimeType = $session->get('publisher_addMime');
$mimeErrors = $session->get('publisher_addMimeErr');
//Display any form errors
@@ -59,17 +58,17 @@ public static function add()
}
if (false === $mimeType) {
- $mimeExt = '';
- $mimeName = '';
+ $mimeExt = '';
+ $mimeName = '';
$mimeTypes = '';
$mimeAdmin = 1;
- $mimeUser = 1;
+ $mimeUser = 1;
} else {
- $mimeExt = $mimeType['mime_ext'];
- $mimeName = $mimeType['mime_name'];
+ $mimeExt = $mimeType['mime_ext'];
+ $mimeName = $mimeType['mime_name'];
$mimeTypes = $mimeType['mime_types'];
$mimeAdmin = $mimeType['mime_admin'];
- $mimeUser = $mimeType['mime_user'];
+ $mimeUser = $mimeType['mime_user'];
}
// Display add form
@@ -130,36 +129,36 @@ public static function add()
\xoops_cp_footer();
} else {
$hasErrors = false;
- $mimeExt = Request::getString('mime_ext', '', 'POST');
- $mimeName = Request::getString('mime_name', '', 'POST');
+ $mimeExt = Request::getString('mime_ext', '', 'POST');
+ $mimeName = Request::getString('mime_name', '', 'POST');
$mimeTypes = Request::getText('mime_types', '', 'POST');
$mimeAdmin = Request::getInt('mime_admin', 0, 'POST');
- $mimeUser = Request::getInt('mime_user', 0, 'POST');
+ $mimeUser = Request::getInt('mime_user', 0, 'POST');
//Validate Mimetype entry
if ('' === \trim($mimeExt)) {
- $hasErrors = true;
+ $hasErrors = true;
$error['mime_ext'][] = \_AM_PUBLISHER_VALID_ERR_MIME_EXT;
}
if ('' === \trim($mimeName)) {
- $hasErrors = true;
+ $hasErrors = true;
$error['mime_name'][] = \_AM_PUBLISHER_VALID_ERR_MIME_NAME;
}
if ('' === \trim($mimeTypes)) {
- $hasErrors = true;
+ $hasErrors = true;
$error['mime_types'][] = \_AM_PUBLISHER_VALID_ERR_MIME_TYPES;
}
if ($hasErrors) {
- $session = Publisher\Session::getInstance();
- $mime = [];
- $mime['mime_ext'] = $mimeExt;
- $mime['mime_name'] = $mimeName;
+ $session = Publisher\Session::getInstance();
+ $mime = [];
+ $mime['mime_ext'] = $mimeExt;
+ $mime['mime_name'] = $mimeName;
$mime['mime_types'] = $mimeTypes;
$mime['mime_admin'] = $mimeAdmin;
- $mime['mime_user'] = $mimeUser;
+ $mime['mime_user'] = $mimeUser;
$session->set('publisher_addMime', $mime);
$session->set('publisher_addMimeErr', $error);
\header('Location: ' . Publisher\Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'add'], false));
@@ -209,8 +208,8 @@ public static function edit()
/** @var Publisher\MimetypeHandler $mimetypeHandler */
$mimetypeHandler = $helper->getHandler('Mimetype');
global $start, $limit;
- $mimeId = 0;
- $error = [];
+ $mimeId = 0;
+ $error = [];
$hasErrors = false;
if (0 == Request::getInt('id', 0, 'GET')) {
\redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php', 3, \_AM_PUBLISHER_MESSAGE_NO_ID);
@@ -220,8 +219,8 @@ public static function edit()
$mimeTypeObj = $mimetypeHandler->get($mimeId); // Retrieve mimetype object
if (!Request::getString('edit_mime', '', 'POST')) {
- $session = Publisher\Session::getInstance();
- $mimeType = $session->get('publisher_editMime_' . $mimeId);
+ $session = Publisher\Session::getInstance();
+ $mimeType = $session->get('publisher_editMime_' . $mimeId);
$mimeErrors = $session->get('publisher_editMimeErr_' . $mimeId);
// Display header
@@ -236,17 +235,17 @@ public static function edit()
}
if (false === $mimeType) {
- $mimeExt = $mimeTypeObj->getVar('mime_ext');
- $mimeName = $mimeTypeObj->getVar('mime_name', 'e');
+ $mimeExt = $mimeTypeObj->getVar('mime_ext');
+ $mimeName = $mimeTypeObj->getVar('mime_name', 'e');
$mimeTypes = $mimeTypeObj->getVar('mime_types', 'e');
$mimeAdmin = $mimeTypeObj->getVar('mime_admin');
- $mimeUser = $mimeTypeObj->getVar('mime_user');
+ $mimeUser = $mimeTypeObj->getVar('mime_user');
} else {
- $mimeExt = $mimeType['mime_ext'];
- $mimeName = $mimeType['mime_name'];
+ $mimeExt = $mimeType['mime_ext'];
+ $mimeName = $mimeType['mime_name'];
$mimeTypes = $mimeType['mime_types'];
$mimeAdmin = $mimeType['mime_admin'];
- $mimeUser = $mimeType['mime_user'];
+ $mimeUser = $mimeType['mime_user'];
}
// Display edit form
@@ -296,7 +295,7 @@ public static function edit()
require_once \dirname(__DIR__) . '/admin/admin_footer.php';
} else {
$mimeAdmin = 0;
- $mimeUser = 0;
+ $mimeUser = 0;
if (1 == Request::getInt('mime_admin', 0, 'POST')) {
$mimeAdmin = 1;
}
@@ -306,28 +305,28 @@ public static function edit()
//Validate Mimetype entry
if ('' === Request::getString('mime_ext', '', 'POST')) {
- $hasErrors = true;
+ $hasErrors = true;
$error['mime_ext'][] = \_AM_PUBLISHER_VALID_ERR_MIME_EXT;
}
if ('' === Request::getString('mime_name', '', 'POST')) {
- $hasErrors = true;
+ $hasErrors = true;
$error['mime_name'][] = \_AM_PUBLISHER_VALID_ERR_MIME_NAME;
}
if ('' === Request::getString('mime_types', '', 'POST')) {
- $hasErrors = true;
+ $hasErrors = true;
$error['mime_types'][] = \_AM_PUBLISHER_VALID_ERR_MIME_TYPES;
}
if ($hasErrors) {
- $session = Publisher\Session::getInstance();
- $mime = [];
- $mime['mime_ext'] = Request::getString('mime_ext', '', 'POST');
- $mime['mime_name'] = Request::getString('mime_name', '', 'POST');
+ $session = Publisher\Session::getInstance();
+ $mime = [];
+ $mime['mime_ext'] = Request::getString('mime_ext', '', 'POST');
+ $mime['mime_name'] = Request::getString('mime_name', '', 'POST');
$mime['mime_types'] = Request::getText('mime_types', '', 'POST');
$mime['mime_admin'] = $mimeAdmin;
- $mime['mime_user'] = $mimeUser;
+ $mime['mime_user'] = $mimeUser;
$session->set('publisher_editMime_' . $mimeId, $mime);
$session->set('publisher_editMimeErr_' . $mimeId, $error);
\header('Location: ' . Publisher\Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'edit', 'id' => $mimeId], false));
@@ -381,9 +380,9 @@ public static function manage()
Publisher\Utility::cpHeader();
////publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES);
Publisher\Utility::openCollapsableBar('mimemanagetable', 'mimemanageicon', \_AM_PUBLISHER_MIME_MANAGE_TITLE, \_AM_PUBLISHER_MIME_INFOTEXT);
- $crit = new \CriteriaCompo();
+ $crit = new \CriteriaCompo();
$order = Request::getString('order', 'ASC', 'POST');
- $sort = Request::getString('sort', 'mime_ext', 'POST');
+ $sort = Request::getString('sort', 'mime_ext', 'POST');
$crit->setOrder($order);
$crit->setStart($start);
@@ -391,7 +390,7 @@ public static function manage()
$crit->setSort($sort);
$mimetypes = $mimetypeHandler->getObjects($crit); // Retrieve a list of all mimetypes
$mimeCount = $mimetypeHandler->getCount();
- $nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=manage&limit=$limit");
+ $nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=manage&limit=$limit");
echo "";
echo "";
@@ -518,7 +517,7 @@ public static function search()
}
$order = Request::getString('order', 'ASC');
- $sort = Request::getString('sort', 'mime_name');
+ $sort = Request::getString('sort', 'mime_name');
Publisher\Utility::cpHeader();
//publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES . " > " . _AM_PUBLISHER_BUTTON_SEARCH);
@@ -554,7 +553,7 @@ public static function search()
} else {
$searchField = Request::getString('search_by', '');
$searchField = isset($aSearchBy[$searchField]) ? $searchField : 'mime_ext';
- $searchText = Request::getString('search_text', '');
+ $searchText = Request::getString('search_text', '');
$crit = new \Criteria($searchField, '%' . $GLOBALS['xoopsDB']->escape($searchText) . '%', 'LIKE');
$crit->setSort($sort);
@@ -563,7 +562,7 @@ public static function search()
$crit->setStart($start);
$mimeCount = $mimetypeHandler->getCount($crit);
$mimetypes = $mimetypeHandler->getObjects($crit);
- $nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=search&limit=$limit&order=$order&sort=$sort&mime_search=1&search_by=$searchField&search_text=" . \htmlentities($searchText, \ENT_QUOTES));
+ $nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=search&limit=$limit&order=$order&sort=$sort&mime_search=1&search_by=$searchField&search_text=" . \htmlentities($searchText, \ENT_QUOTES));
// Display results
echo '';
@@ -684,7 +683,7 @@ public static function updateMimeValue()
// op=updateMimeValue&id=65&mime_admin=0&limit=15&start=0
Publisher\Utility::cpHeader();
$hiddens = [
- 'id' => Request::getInt('id', 0, 'GET'),
+ 'id' => Request::getInt('id', 0, 'GET'),
'start' => Request::getInt('start', 0, 'GET'),
'limit' => Request::getInt('limit', 15, 'GET'),
];
@@ -695,10 +694,10 @@ public static function updateMimeValue()
$mimeTypeObj = $helper->getHandler('Mimetype')->get($hiddens['id']);
if (Request::hasVar('mime_admin')) {
$hiddens['mime_admin'] = Request::getInt('mime_admin', 0, 'GET');
- $msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_ADMIN, $mimeTypeObj->getVar('mime_name'));
+ $msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_ADMIN, $mimeTypeObj->getVar('mime_name'));
} else {
$hiddens['mime_user'] = Request::getInt('mime_user', 0, 'GET');
- $msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_USER, $mimeTypeObj->getVar('mime_name'));
+ $msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_USER, $mimeTypeObj->getVar('mime_name'));
}
$action = PUBLISHER_ADMIN_URL . '/mimetypes.php?op=confirmUpdateMimeValue';
@@ -714,9 +713,9 @@ public static function confirmUpdateMimeValue()
$helper = Publisher\Helper::getInstance();
/** @var Publisher\MimetypeHandler $mimetypeHandler */
$mimetypeHandler = $helper->getHandler('Mimetype');
- $limit = Request::getInt('limit', 0, 'POST');
- $start = Request::getInt('start', 0, 'POST');
- $mimeId = Request::getInt('id', 0, 'POST');
+ $limit = Request::getInt('limit', 0, 'POST');
+ $start = Request::getInt('start', 0, 'POST');
+ $mimeId = Request::getInt('id', 0, 'POST');
if (0 === $mimeId) {
\redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php', 3, \_AM_PUBLISHER_MESSAGE_NO_ID);
}
@@ -771,7 +770,7 @@ public static function clearAddSession()
*/
public static function clearEditSessionVars($id)
{
- $id = (int)$id;
+ $id = (int)$id;
$session = Publisher\Session::getInstance();
$session->del("publisher_editMime_$id");
$session->del("publisher_editMimeErr_$id");
diff --git a/class/MyTextSanitizerExtension.php b/class/MyTextSanitizerExtension.php
index 082e95ea..4f319a98 100644
--- a/class/MyTextSanitizerExtension.php
+++ b/class/MyTextSanitizerExtension.php
@@ -17,15 +17,10 @@
/**
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
- * @subpackage Include
* @since 1.0
* @author trabis
* @author Taiwen Jiang (phppp or D.J.)
*/
-
-use XoopsModules\Publisher;
-
\define('MYTEXTSANITIZER_EXTENDED_MEDIA', 1);
/**
@@ -59,12 +54,12 @@ public static function getInstance()
*/
public function wmp(&$patterns, &$replacements)
{
- $patterns[] = "/\[wmp=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/wmp\]/sU";
- $rp = "\n";
+ $patterns[] = "/\[wmp=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/wmp\]/sU";
+ $rp = "\n";
$replacements[] = $rp;
}
@@ -107,7 +102,7 @@ public function displayFlash($url, $width = false, $height = false)
*/
public function flash(&$patterns, &$replacements)
{
- $patterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/esU";
+ $patterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/esU";
$replacements[] = "Publisher\MyTextSanitizerExtension::displayFlash( '\\5', '\\3', '\\4' )";
}
@@ -117,34 +112,34 @@ public function flash(&$patterns, &$replacements)
*/
public function mms(&$patterns, &$replacements)
{
- $patterns[] = "/\[mms=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/mms\]/sU";
- $rp = "';
+ $patterns[] = "/\[mms=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/mms\]/sU";
+ $rp = "';
$replacements[] = $rp;
}
@@ -155,40 +150,40 @@ public function mms(&$patterns, &$replacements)
public function rtsp(&$patterns, &$replacements)
{
$patterns[] = "/\[rtsp=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/rtsp\]/sU";
- $rp = "';
- $rp .= " ';
+ $rp = "';
+ $rp .= " ';
$replacements[] = $rp;
}
diff --git a/class/PermissionHandler.php b/class/PermissionHandler.php
index 7b4f65b8..57cb79e2 100644
--- a/class/PermissionHandler.php
+++ b/class/PermissionHandler.php
@@ -19,8 +19,6 @@
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Class
- * @subpackage Handlers
* @since 1.0
* @author trabis
* @author The SmartFactory
@@ -28,7 +26,6 @@
use XoopsModules\Publisher;
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
@@ -41,10 +38,6 @@ class PermissionHandler extends \XoopsObjectHandler
*/
public $helper;
- /**
- * @param \XoopsDatabase|null $db
- * @param \XoopsModules\Publisher\Helper|null $helper
- */
public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\Helper $helper = null)
{
/** @var \XoopsModules\Publisher\Helper $this ->helper */
@@ -69,18 +62,18 @@ public function getGrantedGroupsById($gpermName, $id)
if (isset($items[$gpermName][$id])) {
return $items[$gpermName][$id];
}
- $groups = [];
+ $groups = [];
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('gperm_modid', $this->helper->getModule()->getVar('mid')));
$criteria->add(new \Criteria('gperm_name', $gpermName));
$criteria->add(new \Criteria('gperm_itemid', $id));
//Instead of calling groupperm handler and get objects, we will save some memory and do it our way
/** @var \XoopsMySQLDatabase $db */
- $db = \XoopsDatabaseFactory::getDatabaseConnection();
+ $db = \XoopsDatabaseFactory::getDatabaseConnection();
$limit = $start = 0;
- $sql = 'SELECT gperm_groupid FROM ' . $db->prefix('group_permission');
+ $sql = 'SELECT gperm_groupid FROM ' . $db->prefix('group_permission');
if (null !== $criteria && $criteria instanceof \CriteriaElement) {
- $sql .= ' ' . $criteria->renderWhere();
+ $sql .= ' ' . $criteria->renderWhere();
$limit = $criteria->getLimit();
$start = $criteria->getStart();
}
@@ -113,15 +106,15 @@ public function getGrantedItems($gpermName)
$criteria->add(new \Criteria('gperm_modid', $this->helper->getModule()->getVar('mid')));
//Get user's groups
- $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
+ $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
$criteria2 = new \CriteriaCompo();
foreach ($groups as $gid) {
$criteria2->add(new \Criteria('gperm_groupid', $gid), 'OR');
}
$criteria->add($criteria2);
- $db = \XoopsDatabaseFactory::getDatabaseConnection();
- $sql = 'SELECT gperm_itemid FROM ' . $db->prefix('group_permission');
- $sql .= ' ' . $criteria->renderWhere();
+ $db = \XoopsDatabaseFactory::getDatabaseConnection();
+ $sql = 'SELECT gperm_itemid FROM ' . $db->prefix('group_permission');
+ $sql .= ' ' . $criteria->renderWhere();
$result = $db->query($sql, 0, 0);
while (false !== ($myrow = $db->fetchArray($result))) {
$ret[$myrow['gperm_itemid']] = $myrow['gperm_itemid'];
@@ -162,9 +155,9 @@ public function isGranted($gpermName, $id)
*/
public function saveItemPermissions($groups, $itemId, $permName)
{
- $result = true;
+ $result = true;
$moduleId = $this->helper->getModule()->getVar('mid');
- /* @var \XoopsGroupPermHandler $grouppermHandler */
+ /** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = \xoops_getHandler('groupperm');
// First, if the permissions are already there, delete them
$grouppermHandler->deleteByModule($moduleId, $permName, $itemId);
@@ -190,7 +183,7 @@ public function saveItemPermissions($groups, $itemId, $permName)
*/
public function deletePermissions($itemId, $gpermName)
{
- $result = true;
+ $result = true;
$grouppermHandler = \xoops_getHandler('groupperm');
$grouppermHandler->deleteByModule($this->helper->getModule()->getVar('mid'), $gpermName, $itemId);
diff --git a/class/Rating.php b/class/Rating.php
index ab914428..fe848661 100644
--- a/class/Rating.php
+++ b/class/Rating.php
@@ -18,12 +18,9 @@
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
*/
-
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
diff --git a/class/RatingHandler.php b/class/RatingHandler.php
index 79007bdc..31e87e73 100644
--- a/class/RatingHandler.php
+++ b/class/RatingHandler.php
@@ -18,12 +18,9 @@
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
*/
-
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
@@ -33,7 +30,6 @@ class RatingHandler extends \XoopsPersistableObjectHandler
{
/**
* RatingHandler constructor.
- * @param \XoopsDatabase|null $db
*/
public function __construct(\XoopsDatabase $db = null)
{
diff --git a/class/Resizer.php b/class/Resizer.php
index 503cf9e0..306bcad6 100644
--- a/class/Resizer.php
+++ b/class/Resizer.php
@@ -19,7 +19,6 @@
*
* @copyright module for xoops
* @license GPL 2.0 or later
- * @package XOOPS common
* @since 1.0
* @min_xoops 2.5.9
* @author Goffy - Wedega - Email: - Website:
@@ -27,14 +26,14 @@
*/
class Resizer
{
- public $sourceFile = '';
- public $endFile = '';
- public $maxWidth = 0;
- public $maxHeight = 0;
+ public $sourceFile = '';
+ public $endFile = '';
+ public $maxWidth = 0;
+ public $maxHeight = 0;
public $imageMimetype = '';
- public $jpgQuality = 90;
- public $mergeType = 0;
- public $mergePos = 0;
+ public $jpgQuality = 90;
+ public $mergeType = 0;
+ public $mergePos = 0;
/**
* resize image if size exceed given width/height
@@ -57,7 +56,7 @@ public function resizeImage()
return 'Unsupported format';
}
- $width = \imagesx($img);
+ $width = \imagesx($img);
$height = \imagesy($img);
if ($width > $this->maxWidth || $height > $this->maxHeight) {
@@ -66,16 +65,16 @@ public function resizeImage()
if ($width < $this->maxWidth) {
$new_width = $width;
} else {
- $new_width = $this->maxWidth;
- $divisor = $width / $new_width;
+ $new_width = $this->maxWidth;
+ $divisor = $width / $new_width;
$new_height = \floor($height / $divisor);
}
} elseif ($height < $this->maxHeight) {
$new_height = $height;
} else {
$new_height = $this->maxHeight;
- $divisor = $height / $new_height;
- $new_width = \floor($width / $divisor);
+ $divisor = $height / $new_height;
+ $new_width = \floor($width / $divisor);
}
// Create a new temporary image.
@@ -139,19 +138,19 @@ public function resizeAndCrop()
[$original_w, $original_h] = \getimagesize($this->sourceFile);
// RESIZE IMAGE AND PRESERVE PROPORTIONS
- $max_width_resize = $this->maxWidth;
+ $max_width_resize = $this->maxWidth;
$max_height_resize = $this->maxHeight;
if ($original_w > $original_h) {
$max_height_ratio = $this->maxHeight / $original_h;
$max_width_resize = (int)\round($original_w * $max_height_ratio);
} else {
- $max_width_ratio = $this->maxWidth / $original_w;
+ $max_width_ratio = $this->maxWidth / $original_w;
$max_height_resize = (int)\round($original_h * $max_width_ratio);
}
if ($max_width_resize < $this->maxWidth) {
- $max_height_ratio = $this->maxWidth / $max_width_resize;
+ $max_height_ratio = $this->maxWidth / $max_width_resize;
$max_height_resize = (int)\round($this->maxHeight * $max_height_ratio);
- $max_width_resize = $this->maxWidth;
+ $max_width_resize = $this->maxWidth;
}
// CREATE THE PROPORTIONAL IMAGE RESOURCE
@@ -162,7 +161,7 @@ public function resizeAndCrop()
// CREATE THE CENTERED CROPPED IMAGE TO THE SPECIFIED DIMENSIONS
$final = \imagecreatetruecolor($this->maxWidth, $this->maxHeight);
- $max_width_offset = 0;
+ $max_width_offset = 0;
$max_height_offset = 0;
if ($this->maxWidth < $max_width_resize) {
$max_width_offset = (int)\round(($max_width_resize - $this->maxWidth) / 2);
@@ -185,12 +184,12 @@ public function resizeAndCrop()
public function mergeImage()
{
$dest = \imagecreatefromjpeg($this->endFile);
- $src = \imagecreatefromjpeg($this->sourceFile);
+ $src = \imagecreatefromjpeg($this->sourceFile);
if (4 == $this->mergeType) {
- $imgWidth = (int)\round($this->maxWidth / 2 - 1);
+ $imgWidth = (int)\round($this->maxWidth / 2 - 1);
$imgHeight = (int)\round($this->maxHeight / 2 - 1);
- $posCol2 = (int)\round($this->maxWidth / 2 + 1);
- $posRow2 = (int)\round($this->maxHeight / 2 + 1);
+ $posCol2 = (int)\round($this->maxWidth / 2 + 1);
+ $posRow2 = (int)\round($this->maxHeight / 2 + 1);
switch ($this->mergePos) {
case 1:
\imagecopy($dest, $src, 0, 0, 0, 0, $imgWidth, $imgHeight); //top left
@@ -207,11 +206,11 @@ public function mergeImage()
}
}
if (6 == $this->mergeType) {
- $imgWidth = (int)\round($this->maxWidth / 3 - 1);
+ $imgWidth = (int)\round($this->maxWidth / 3 - 1);
$imgHeight = (int)\round($this->maxHeight / 2 - 1);
- $posCol2 = (int)\round($this->maxWidth / 3 + 1);
- $posCol3 = $posCol2 + (int)\round($this->maxWidth / 3 + 1);
- $posRow2 = (int)\round($this->maxHeight / 2 + 1);
+ $posCol2 = (int)\round($this->maxWidth / 3 + 1);
+ $posCol3 = $posCol2 + (int)\round($this->maxWidth / 3 + 1);
+ $posRow2 = (int)\round($this->maxHeight / 2 + 1);
switch ($this->mergePos) {
case 1:
diff --git a/class/Seo.php b/class/Seo.php
index 8f625547..0c7911d3 100644
--- a/class/Seo.php
+++ b/class/Seo.php
@@ -26,8 +26,6 @@
use XoopsModules\Publisher;
-
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
@@ -56,7 +54,7 @@ public static function getTitle($title = '', $withExt = true)
$title = \rawurlencode(mb_strtolower($title));
// Transformation des ponctuations
- $pattern = [
+ $pattern = [
'/%09/', // Tab
'/%20/', // Space
'/%21/', // !
@@ -87,13 +85,13 @@ public static function getTitle($title = '', $withExt = true)
"/\./", // .
];
$repPattern = ['-', '-', '', '', '', '-100', '', '-', '', '', '', '-', '', '', '', '-', '', '', '-at-', '', '-', '', '-', '', '-', '', '-', ''];
- $title = \preg_replace($pattern, $repPattern, $title);
+ $title = \preg_replace($pattern, $repPattern, $title);
// Transformation des caractères accentués
// è é ê ë ç à â ä î ï ù ü û ô ö
- $pattern = ['/%B0/', '/%E8/', '/%E9/', '/%EA/', '/%EB/', '/%E7/', '/%E0/', '/%E2/', '/%E4/', '/%EE/', '/%EF/', '/%F9/', '/%FC/', '/%FB/', '/%F4/', '/%F6/'];
+ $pattern = ['/%B0/', '/%E8/', '/%E9/', '/%EA/', '/%EB/', '/%E7/', '/%E0/', '/%E2/', '/%E4/', '/%EE/', '/%EF/', '/%F9/', '/%FC/', '/%FB/', '/%F4/', '/%F6/'];
$repPattern = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
- $title = \preg_replace($pattern, $repPattern, $title);
+ $title = \preg_replace($pattern, $repPattern, $title);
if (\count($title) > 0) {
if ($withExt) {
diff --git a/class/Session.php b/class/Session.php
index 690ff3b4..1dd6148d 100644
--- a/class/Session.php
+++ b/class/Session.php
@@ -18,15 +18,12 @@
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
* @author Harry Fuecks (PHP Anthology Volume II)
*/
//namespace Publisher;
-
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
diff --git a/class/ThemeTabForm.php b/class/ThemeTabForm.php
index 86919173..afeabc3d 100644
--- a/class/ThemeTabForm.php
+++ b/class/ThemeTabForm.php
@@ -18,19 +18,15 @@
*
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
* @since 1.0
* @author trabis
* @author John Neill
*/
-
-
require_once \dirname(__DIR__) . '/include/common.php';
/**
* XoopsThemeTabForm
*
- * @package
* @author John
* @copyright Copyright (c) 2009
*/
@@ -112,10 +108,10 @@ public function __construct($title, $name, $action, $method = 'post', $addtoken
$GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js');
$GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/system/css/ui/' . \xoops_getModuleOption('jquery_theme', 'system') . '/ui.all.css');
- $this->title = $title;
- $this->name = $name;
- $this->action = $action;
- $this->method = $method;
+ $this->title = $title;
+ $this->name = $name;
+ $this->action = $action;
+ $this->method = $method;
$this->summary = $summary;
if ($addtoken) {
$this->addElement(new \XoopsFormHiddenToken());
@@ -124,13 +120,10 @@ public function __construct($title, $name, $action, $method = 'post', $addtoken
//function render() {}
- /**
- * @param \XoopsTpl $tpl
- */
public function assign(\XoopsTpl $tpl)
{
- $i = -1;
- $tab = -1;
+ $i = -1;
+ $tab = -1;
$elements = [];
if (\count($this->getRequired()) > 0) {
$this->elements[] = "';
@@ -147,16 +140,16 @@ public function assign(\XoopsTpl $tpl)
}
if (\is_string($ele)) {
$elements[$i]['body'] = $ele;
- $elements[$i]['tab'] = $tab;
+ $elements[$i]['tab'] = $tab;
continue;
}
- $eleName = $ele->getName();
- $eleDescription = $ele->getDescription();
- $n = $eleName ?: $i;
- $elements[$n]['name'] = $eleName;
- $elements[$n]['caption'] = $ele->getCaption();
- $elements[$n]['body'] = $ele->render();
- $elements[$n]['hidden'] = $ele->isHidden() ? true : false;
+ $eleName = $ele->getName();
+ $eleDescription = $ele->getDescription();
+ $n = $eleName ?: $i;
+ $elements[$n]['name'] = $eleName;
+ $elements[$n]['caption'] = $ele->getCaption();
+ $elements[$n]['body'] = $ele->render();
+ $elements[$n]['hidden'] = $ele->isHidden() ? true : false;
$elements[$n]['required'] = $ele->isRequired();
if ('' != $eleDescription) {
$elements[$n]['description'] = $eleDescription;
@@ -167,15 +160,15 @@ public function assign(\XoopsTpl $tpl)
$tpl->assign(
$this->getName(),
[
- 'title' => $this->getTitle(),
- 'id' => 'tab_' . \preg_replace('/[^a-z0-9]+/i', '', $this->getTitle()),
- 'name' => $this->getName(),
- 'action' => $this->getAction(),
- 'method' => $this->getMethod(),
- 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '();"' . $this->getExtra(),
+ 'title' => $this->getTitle(),
+ 'id' => 'tab_' . \preg_replace('/[^a-z0-9]+/i', '', $this->getTitle()),
+ 'name' => $this->getName(),
+ 'action' => $this->getAction(),
+ 'method' => $this->getMethod(),
+ 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '();"' . $this->getExtra(),
'javascript' => $js,
- 'tabs' => $this->formTabs,
- 'elements' => $elements,
+ 'tabs' => $this->formTabs,
+ 'elements' => $elements,
]
);
}
@@ -210,7 +203,7 @@ public function endTabs()
public function startFormTabs($tabText)
{
$this->formTabs[] = $tabText;
- $ret = 'addTab';
+ $ret = 'addTab';
return $ret;
}
@@ -337,7 +330,7 @@ public function &getElements($recurse = false)
*/
public function getElementNames()
{
- $ret = [];
+ $ret = [];
$elements = &$this->getElements(true);
foreach ($elements as $iValue) {
$ret[] = $iValue->getName();
@@ -428,7 +421,7 @@ public function getElementValues($encode = false)
{
// will not use getElementByName() for performance..
$elements = &$this->getElements(true);
- $values = [];
+ $values = [];
foreach ($elements as $i => $iValue) {
$name = $iValue->getName(false);
if ($name && \method_exists($elements[$i], 'getValue')) {
@@ -555,7 +548,7 @@ public function renderValidationJS($withtags = true)
$js .= "\n\n');
}
- } catch (\Exception $e) {
+ } catch (\Throwable $e) {
echo 'Caught exception: ', $e->getMessage(), "\n", ' ';
}
}
@@ -102,17 +101,17 @@ public static function createDir()
if (static::getPathStatus('root', true) < 0) {
$thePath = static::getUploadDir();
- $res = static::mkdir($thePath);
- $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED;
+ $res = static::mkdir($thePath);
+ $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED;
}
if (static::getPathStatus('images', true) < 0) {
$thePath = static::getImageDir();
- $res = static::mkdir($thePath);
+ $res = static::mkdir($thePath);
if ($res) {
$source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png';
- $dest = $thePath . 'blank.png';
+ $dest = $thePath . 'blank.png';
static::copyr($source, $dest);
}
$msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED;
@@ -120,11 +119,11 @@ public static function createDir()
if (static::getPathStatus('images/category', true) < 0) {
$thePath = static::getImageDir('category');
- $res = static::mkdir($thePath);
+ $res = static::mkdir($thePath);
if ($res) {
$source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png';
- $dest = $thePath . 'blank.png';
+ $dest = $thePath . 'blank.png';
static::copyr($source, $dest);
}
$msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED;
@@ -132,11 +131,11 @@ public static function createDir()
if (static::getPathStatus('images/item', true) < 0) {
$thePath = static::getImageDir('item');
- $res = static::mkdir($thePath);
+ $res = static::mkdir($thePath);
if ($res) {
$source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png';
- $dest = $thePath . 'blank.png';
+ $dest = $thePath . 'blank.png';
static::copyr($source, $dest);
}
$msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED;
@@ -144,8 +143,8 @@ public static function createDir()
if (static::getPathStatus('content', true) < 0) {
$thePath = static::getUploadDir(true, 'content');
- $res = static::mkdir($thePath);
- $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED;
+ $res = static::mkdir($thePath);
+ $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED;
}
}
@@ -236,7 +235,7 @@ public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCa
$helper = Publisher\Helper::getInstance();
// if there is a parameter, and the id exists, retrieve data: we're editing a category
- /* @var Publisher\Category $categoryObj */
+ /** @var Publisher\Category $categoryObj */
if (0 != $categoryId) {
// Creating the category object for the selected category
$categoryObj = $helper->getHandler('Category')->get($categoryId);
@@ -270,9 +269,9 @@ public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCa
static::openCollapsableBar('subcatstable', 'subcatsicon', \_AM_PUBLISHER_SUBCAT_CAT, \_AM_PUBLISHER_SUBCAT_CAT_DSC);
// Get the total number of sub-categories
$categoriesObj = $helper->getHandler('Category')->get($selCat);
- $totalsubs = $helper->getHandler('Category')->getCategoriesCount($selCat);
+ $totalsubs = $helper->getHandler('Category')->getCategoriesCount($selCat);
// creating the categories objects that are published
- $subcatsObj = $helper->getHandler('Category')->getCategories(0, 0, $categoriesObj->categoryid());
+ $subcatsObj = $helper->getHandler('Category')->getCategories(0, 0, $categoriesObj->categoryid());
$totalSCOnPage = \count($subcatsObj);
echo "";
echo '';
@@ -307,9 +306,9 @@ public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCa
// Get the total number of published ITEMS
$totalitems = $helper->getHandler('Item')->getItemsCount($selCat, [Constants::PUBLISHER_STATUS_PUBLISHED]);
// creating the items objects that are published
- $itemsObj = $helper->getHandler('Item')->getAllPublished($helper->getConfig('idxcat_perpage'), $startitem, $selCat);
+ $itemsObj = $helper->getHandler('Item')->getAllPublished($helper->getConfig('idxcat_perpage'), $startitem, $selCat);
$totalitemsOnPage = \count($itemsObj);
- $allcats = $helper->getHandler('Category')->getObjects(null, true);
+ $allcats = $helper->getHandler('Category')->getObjects(null, true);
echo "";
echo '';
echo "" . \_AM_PUBLISHER_ITEMID . ' | ';
@@ -321,8 +320,8 @@ public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCa
if ($totalitems > 0) {
for ($i = 0; $i < $totalitemsOnPage; ++$i) {
$categoryObj = $allcats[$itemsObj[$i]->categoryid()];
- $modify = "getModule()->dirname() . "/assets/images/links/edit.gif' title='" . \_AM_PUBLISHER_EDITITEM . "' alt='" . \_AM_PUBLISHER_EDITITEM . "'>";
- $delete = "itemid() . "'>getModule()->dirname() . "/assets/images/links/edit.gif' title='" . \_AM_PUBLISHER_EDITITEM . "' alt='" . \_AM_PUBLISHER_EDITITEM . "'>";
+ $delete = "getConfig('idxcat_perpage'), $startitem, 'startitem', $pagenavExtraArgs);
@@ -587,13 +586,13 @@ public static function getPathStatus($item, $getStatus = false)
}
if (\is_writable($thePath)) {
$pathCheckResult = 1;
- $pathStatus = \_AM_PUBLISHER_AVAILABLE;
+ $pathStatus = \_AM_PUBLISHER_AVAILABLE;
} elseif (!@\is_dir($thePath)) {
$pathCheckResult = -1;
- $pathStatus = \_AM_PUBLISHER_NOTAVAILABLE . " " . \_AM_PUBLISHER_CREATETHEDIR . '';
+ $pathStatus = \_AM_PUBLISHER_NOTAVAILABLE . " " . \_AM_PUBLISHER_CREATETHEDIR . '';
} else {
$pathCheckResult = -2;
- $pathStatus = \_AM_PUBLISHER_NOTWRITABLE . " " . \_AM_PUBLISHER_SETMPERM . '';
+ $pathStatus = \_AM_PUBLISHER_NOTWRITABLE . " " . \_AM_PUBLISHER_SETMPERM . '';
}
if (!$getStatus) {
return $pathStatus;
@@ -742,10 +741,10 @@ public static function userIsAuthor($itemObj)
public static function userIsModerator($itemObj)
{
/** @var Publisher\Helper $helper */
- $helper = Publisher\Helper::getInstance();
+ $helper = Publisher\Helper::getInstance();
$categoriesGranted = $helper->getHandler('Permission')->getGrantedItems('category_moderation');
- return (\is_object($itemObj) && \in_array($itemObj->categoryid(), $categoriesGranted));
+ return (\is_object($itemObj) && \in_array($itemObj->categoryid(), $categoriesGranted, true));
}
/**
@@ -764,7 +763,7 @@ public static function saveCategoryPermissions($groups, $categoryId, $permName)
$result = true;
$moduleId = $helper->getModule()->getVar('mid');
- /* @var \XoopsGroupPermHandler $grouppermHandler */
+ /** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = \xoops_getHandler('groupperm');
// First, if the permissions are already there, delete them
$grouppermHandler->deleteByModule($moduleId, $permName, $categoryId);
@@ -788,10 +787,10 @@ public static function saveCategoryPermissions($groups, $categoryId, $permName)
*/
public static function openCollapsableBar($tablename = '', $iconname = '', $tabletitle = '', $tabledsc = '', $open = true)
{
- $image = 'open12.gif';
+ $image = 'open12.gif';
$display = 'none';
if ($open) {
- $image = 'close12.gif';
+ $image = 'close12.gif';
$display = 'block';
}
@@ -816,7 +815,7 @@ public static function closeCollapsableBar($name, $icon)
$cookieName = $path . '_publisher_collaps_' . $name;
$cookieName = \str_replace('.', '_', $cookieName);
- $cookie = static::getCookieVar($cookieName, '');
+ $cookie = static::getCookieVar($cookieName, '');
if ('none' === $cookie) {
echo '
@@ -865,8 +864,8 @@ public static function getCurrentUrls()
// $phpself = $_SERVER['SCRIPT_NAME'];
// $httphost = $_SERVER['HTTP_HOST'];
// $querystring = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
- $phpself = Request::getString('SCRIPT_NAME', '', 'SERVER');
- $httphost = Request::getString('HTTP_HOST', '', 'SERVER');
+ $phpself = Request::getString('SCRIPT_NAME', '', 'SERVER');
+ $httphost = Request::getString('HTTP_HOST', '', 'SERVER');
$querystring = Request::getString('QUERY_STRING', '', 'SERVER');
if ('' != $querystring) {
@@ -875,12 +874,12 @@ public static function getCurrentUrls()
$currenturl = $http . $httphost . $phpself . $querystring;
- $urls = [];
- $urls['http'] = $http;
- $urls['httphost'] = $httphost;
- $urls['phpself'] = $phpself;
+ $urls = [];
+ $urls['http'] = $http;
+ $urls['httphost'] = $httphost;
+ $urls['phpself'] = $phpself;
$urls['querystring'] = $querystring;
- $urls['full'] = $currenturl;
+ $urls['full'] = $currenturl;
return $urls;
}
@@ -913,7 +912,7 @@ public static function addCategoryOption(Publisher\Category $categoryObj, $selec
}
$ret .= " | |