Completed
Pull Request — master (#11)
by
unknown
01:52
created

index.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * About
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright      The XOOPS Co.Ltd. http://www.xoops.com.cn
13
 * @copyright      XOOPS Project (http://xoops.org)
14
 * @license        GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package        about
16
 * @since          1.0.0
17
 * @author         Mengjue Shao <[email protected]>
18
 * @author         Susheng Yang <[email protected]>
19
 */
20
21
include_once __DIR__ . '/header.php';
22
include_once __DIR__ . '/include/functions.render.php';
23
24
$page_id      = Xmf\Request::getInt('page_id', 0);
25
//$page_id      = isset($_REQUEST['page_id']) ? $_REQUEST['page_id'] : '';
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
$page_handler = $abtHelper->getHandler('page');
27
28
$myts = MyTextSanitizer::getInstance();
29
30
// Menu
31
$menu_criteria = new CriteriaCompo();
32
$menu_criteria->add(new Criteria('page_status', AboutConstants::PUBLISHED), 'AND');
33
$menu_criteria->add(new Criteria('page_menu_status', AboutConstants::IN_MENU), 'AND');
34
$menu_criteria->setSort('page_order');
35
$menu_criteria->order = 'ASC';
36
$fields = array('page_id', 'page_pid', 'page_menu_title', 'page_blank',
37
                'page_menu_status', 'page_status', 'page_text'
38
);
39
$menu = $page_handler->getAll($menu_criteria, $fields, false);
40
41
foreach ($menu as $k => $v) {
42
    $page_text = trim($v['page_text']);
43
    $menu[$k]['page_text'] = false;
44
    if (preg_match('/https?\:\/\//', $page_text)) {
45
        $menu[$k]['page_text'] = true;
46
    }
47
//    $menu[$k]['page_text'] = trim($v['page_text']) === 'http://' ? true : false;
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
}
49
$page_menu = $page_handler->menuTree($menu);
50
51
// Display
52
if (AboutConstants::PAGE == $abtHelper->getConfig('display', AboutConstants::PAGE) || !empty($page_id)) {
53
    // Fun menu display
54
    $criteria = new CriteriaCompo();
55
    if (!empty($page_id)) {
56
        $criteria->add(new Criteria('page_id', $page_id));
57
    } else {
58
        $criteria->add(new Criteria('page_index', AboutConstants::DEFAULT_INDEX));
59
    }
60
    $criteria->add(new Criteria('page_status', AboutConstants::PUBLISHED));
61
62
    $criteria->setSort('page_order');
63
    $criteria->order = 'ASC';
64
    $page = current($page_handler->getObjects($criteria, null, false, false));
65
    if (!empty($page)) {
66
        $xoopsOption['xoops_pagetitle'] = $myts->htmlSpecialChars($page['page_title'] . ' - ' . $abtHelper->getModule()->name());
67
        $xoopsOption['template_main']   = about_getTemplate('page', $page['page_tpl']);
68
    } else {
69
        $xoopsOption['xoops_pagetitle'] = $myts->htmlSpecialChars(_MD_ABOUT_INDEX . ' - ' . $abtHelper->getModule()->name());
70
        $xoopsOption['template_main']   = about_getTemplate();
71
    }
72
73
    include XOOPS_ROOT_PATH . '/header.php';
74
    $GLOBALS['xoTheme']->addStylesheet("modules/{$moduleDirName}/assets/css/style.css");
75
    $GLOBALS['xoTheme']->addStylesheet("modules/{$moduleDirName}/assets/js/jquery-treeview/jquery.treeview.css");
76
    $GLOBALS['xoTheme']->addScript("browse.php?Frameworks/jquery/jquery.js");
77
    $GLOBALS['xoTheme']->addScript("modules/{$moduleDirName}/assets/js/jquery-treeview/jquery.treeview.js");
78
79
    if (!empty($page)) {
80
        $page['page_text'] = $myts->undoHtmlSpecialChars($page['page_text']);
81
        if (AboutConstants::PAGE_TYPE_LINK == $page['page_type']) {
82
            header('location: ' . $page['page_text']);
83
        }
84
        $xoTheme->addMeta('meta', 'description', $myts->htmlSpecialChars($page['page_menu_title']));
85
        $xoopsTpl->assign('pagemenu', $page_menu);
86
        $xoopsTpl->assign('page', $page);
87
    }
88
89
} else {
90
    // List (Category) display
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
    $xoopsOption['xoops_pagetitle'] = $abtHelper->getModule()->name();
92
    $xoopsOption['template_main']   = about_getTemplate('list');
93
    include XOOPS_ROOT_PATH . '/header.php';
94
    $GLOBALS['xoTheme']->addStylesheet("modules/{$moduleDirName}/assets/css/style.css");
95
96
    $criteria = new CriteriaCompo();
97
    $criteria->add(new Criteria('page_status', AboutConstants::PUBLISHED));
98
    $criteria->setSort('page_order');
99
    $criteria->order = 'ASC';
100
    $list = $page_handler->getAll($criteria, null, false);
101
    foreach ($list as $k => $v) {
102
        $text = strip_tags($myts->undoHtmlSpecialChars($v['page_text']));
103
        $list[$k]['page_text']     = xoops_substr($text, 0, $abtHelper->getConfig('str_ereg', AboutConstants::DEFAULT_EREG));
104
        $list[$k]['page_pushtime'] = formatTimestamp($v['page_pushtime'], _SHORTDATESTRING);
105
    }
106
    $xoopsTpl->assign('list', $list);
107
}
108
109
// get bread
110
if (!empty($bread)) {
111
    $bread = array_reverse($page_handler->getBread($menu, $page_id), true);
112
    foreach ($bread as $k => $v) {
113
        if ($k != $page_id) {
114
            $xoBreadcrumbs[] = array('title' => $v, 'link' => $abtHelper->url("index.php?page_id={$k}"));
115
        } else {
116
            $xoBreadcrumbs[] = array('title' => $v);
117
        }
118
        $tree_open[$k] = $k;
119
    }
120
    $xoopsTpl->assign('tree_open', $tree_open);
121
}
122
$xoopsTpl->assign('page_id', $page_id);
123
124
include_once __DIR__ . '/footer.php';
125