mambax7 /
publisher
| 1 | <?php |
||
| 2 | /* |
||
| 3 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ |
||
| 14 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license |
||
| 15 | * @package Publisher |
||
| 16 | * @subpackage Blocks |
||
| 17 | * @since 1.0 |
||
| 18 | * @author trabis <[email protected]> |
||
| 19 | * @author The SmartFactory <www.smartfactory.ca> |
||
| 20 | */ |
||
| 21 | |||
| 22 | use XoopsModules\Publisher; |
||
| 23 | |||
| 24 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||
| 25 | |||
| 26 | require_once dirname(__DIR__) . '/include/common.php'; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param $options |
||
| 30 | * |
||
| 31 | * @return array |
||
| 32 | */ |
||
| 33 | function publisher_date_to_date_show($options) |
||
| 34 | { |
||
| 35 | $myts = \MyTextSanitizer::getInstance(); |
||
| 36 | /** @var Publisher\Helper $helper */ |
||
| 37 | $helper = Publisher\Helper::getInstance(); |
||
| 38 | |||
| 39 | $block = $newItems = []; |
||
| 40 | |||
| 41 | $criteria = new \CriteriaCompo(); |
||
| 42 | $criteria->add(new \Criteria('datesub', strtotime($options[0]), '>')); |
||
| 43 | $criteria->add(new \Criteria('datesub', isset($options[1]) ? strtotime($options[1]) : '', '<')); |
||
| 44 | $criteria->setSort('datesub'); |
||
| 45 | $criteria->setOrder('DESC'); |
||
| 46 | |||
| 47 | // creating the ITEM objects that belong to the selected category |
||
| 48 | $itemsObj = $helper->getHandler('Item')->getObjects($criteria); |
||
| 49 | $totalItems = count($itemsObj); |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 50 | |||
| 51 | if ($itemsObj) { |
||
|
0 ignored issues
–
show
The expression
$itemsObj of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||
| 52 | foreach ($itemsObj as $iValue) { |
||
| 53 | $newItems['itemid'] = $iValue->itemid(); |
||
| 54 | $newItems['title'] = $iValue->getTitle(); |
||
| 55 | $newItems['categoryname'] = $iValue->getCategoryName(); |
||
| 56 | $newItems['categoryid'] = $iValue->categoryid(); |
||
| 57 | $newItems['date'] = $iValue->getDatesub(); |
||
| 58 | $newItems['poster'] = $iValue->getLinkedPosterName(); |
||
| 59 | $newItems['itemlink'] = $iValue->getItemLink(false, isset($options[3]) ? $options[3] : 65); |
||
| 60 | $newItems['categorylink'] = $iValue->getCategoryLink(); |
||
| 61 | $block['items'][] = $newItems; |
||
| 62 | } |
||
| 63 | |||
| 64 | $block['lang_title'] = _MB_PUBLISHER_ITEMS; |
||
| 65 | $block['lang_category'] = _MB_PUBLISHER_CATEGORY; |
||
| 66 | $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; |
||
| 67 | $block['lang_date'] = _MB_PUBLISHER_DATE; |
||
| 68 | $moduleName = $myts->displayTarea($helper->getModule()->getVar('name')); |
||
| 69 | $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . ' ' . $moduleName; |
||
| 70 | $block['lang_articles_from_to'] = sprintf(_MB_PUBLISHER_ARTICLES_FROM_TO, $options[0], isset($options[1]) ? $options[1] : 0); |
||
| 71 | } |
||
| 72 | |||
| 73 | return $block; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param $options |
||
| 78 | * |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | function publisher_date_to_date_edit($options) |
||
| 82 | { |
||
| 83 | // require_once PUBLISHER_ROOT_PATH . '/class/blockform.php'; |
||
| 84 | xoops_load('XoopsFormLoader'); |
||
| 85 | xoops_load('XoopsFormTextDateSelect'); |
||
| 86 | |||
| 87 | $form = new Publisher\BlockForm(); |
||
| 88 | $fromEle = new \XoopsFormTextDateSelect(_MB_PUBLISHER_FROM, 'options[0]', 15, strtotime($options[0])); |
||
| 89 | // $fromEle->setNocolspan(); |
||
| 90 | $untilEle = new \XoopsFormTextDateSelect(_MB_PUBLISHER_UNTIL, 'options[1]', 15, isset($options[1]) ? strtotime($options[1]) : ''); |
||
| 91 | // $untilEle->setNocolspan(); |
||
| 92 | |||
| 93 | $form->addElement($fromEle); |
||
| 94 | $form->addElement($untilEle); |
||
| 95 | |||
| 96 | return $form->render(); |
||
| 97 | } |
||
| 98 |