mambax7 /
xoopsheadline
| 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 {@link https://xoops.org/ XOOPS Project} |
||
| 14 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
| 15 | * @package |
||
| 16 | * @since |
||
| 17 | * @author XOOPS Development Team |
||
| 18 | */ |
||
| 19 | |||
| 20 | use Xmf\Module\Admin; |
||
| 21 | use Xmf\Request; |
||
| 22 | use XoopsModules\Xoopsheadline\Helper; |
||
| 23 | use XoopsModules\Xoopsheadline\XoopsheadlineUtility; |
||
| 24 | /** @var Helper $helper */ |
||
| 25 | |||
| 26 | require_once dirname(__DIR__, 2) . '/mainfile.php'; |
||
| 27 | |||
| 28 | $helper = Helper::getInstance(); |
||
| 29 | |||
| 30 | $hlman = $helper->getHandler('Headline'); |
||
| 31 | $hlid = (!empty($_GET['id']) && (Request::getInt('id', 0, 'GET') > 0)) ? Request::getInt('id', 0, 'GET') : 0; |
||
| 32 | |||
| 33 | $GLOBALS['xoopsOption']['template_main'] = 'xoopsheadline_index.tpl'; |
||
| 34 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 35 | |||
| 36 | $criteria = new \CriteriaCompo(); |
||
| 37 | $criteria->add(new \Criteria('headline_display', 1, '=')); |
||
| 38 | $criteria->add(new \Criteria('headline_xml', '', '!=')); |
||
| 39 | switch ((int)$helper->getConfig('sortby')) { |
||
| 40 | case 1: |
||
| 41 | $criteria->setSort('headline_name'); |
||
| 42 | $criteria->setOrder('DESC'); |
||
| 43 | break; |
||
| 44 | case 2: |
||
| 45 | $criteria->setSort('headline_name'); |
||
| 46 | $criteria->setOrder('ASC'); |
||
| 47 | break; |
||
| 48 | case 3: |
||
| 49 | $criteria->setSort('headline_weight'); |
||
| 50 | $criteria->setOrder('DESC'); |
||
| 51 | break; |
||
| 52 | case 4: |
||
| 53 | default: |
||
| 54 | $criteria->setSort('headline_weight'); |
||
| 55 | $criteria->setOrder('ASC'); |
||
| 56 | break; |
||
| 57 | } |
||
| 58 | $headlines = $hlman->getObjects($criteria); |
||
| 59 | |||
| 60 | global $xoopsModule; |
||
| 61 | $pathIcon16 = Admin::iconUrl('', 16); |
||
| 62 | $moduleDirName = $xoopsModule->getVar('dirname'); |
||
| 63 | |||
| 64 | $userIsAdmin = (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) ? true : false; |
||
| 65 | $count = count($headlines); |
||
| 66 | for ($i = 0; $i < $count; ++$i) { |
||
| 67 | $thisId = $headlines[$i]->getVar('headline_id'); |
||
| 68 | $editUrl = $userIsAdmin ? " <a href='" . XOOPS_URL . "/modules/{$moduleDirName}/admin/main.php?op=edit&headline_id={$thisId}'><img src='" . $pathIcon16 . "/edit.png' alt='" . _EDIT . "' title='" . _EDIT . "'></a>" : ''; |
||
| 69 | $xoopsTpl->append('feed_sites', ['id' => $thisId, 'name' => $headlines[$i]->getVar('headline_name'), 'editurl' => $editUrl]); |
||
| 70 | } |
||
| 71 | $xoopsTpl->assign('lang_headlines', _MD_HEADLINES_HEADLINES); |
||
| 72 | if (0 == $hlid) { |
||
| 73 | $hlid = $headlines[0]->getVar('headline_id'); |
||
| 74 | } |
||
| 75 | if ($hlid > 0) { |
||
| 76 | $headline = $hlman->get($hlid); |
||
| 77 | if (is_object($headline)) { |
||
| 78 | $renderer = XoopsheadlineUtility::getRenderer($headline); |
||
| 79 | if (!$renderer->renderFeed()) { |
||
| 80 | if (2 == $xoopsConfig['debug_mode']) { |
||
| 81 | $xoopsTpl->assign('headline', '<p>' . sprintf(_MD_HEADLINES_FAILGET, $headline->getVar('headline_name')) . '<br>' . $renderer->getErrors() . '</p>'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 82 | } |
||
| 83 | } else { |
||
| 84 | $xoopsTpl->assign('headline', $renderer->getFeed()); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | } |
||
| 88 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 89 |