Completed
Push — master ( c4c9cf...3be32e )
by Michael
01:19
created

index.php (4 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
 You may not change or alter any portion of this comment or credits of
4
 supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit
6
 authors.
7
8
 This program is distributed in the hope that it will be useful, but
9
 WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * Module: RandomQuote
14
 *
15
 * @category        Module
16
 * @package         randomquote
17
 * @author          XOOPS Module Development Team
18
 * @copyright       {@link http://xoops.org 2001-2016 XOOPS Project}
19
 * @license         {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
20
 * @link            http://xoops.org XOOPS
21
 */
22
23
require_once __DIR__ . '/header.php';
24
$xoopsOption                  = (!isset($xoopsOption)) ? array() : $xoopsOption;
25
$xoopsOption['template_main'] = 'randomquote_index.tpl';
26
require_once $GLOBALS['xoops']->path('www/header.php');
27
require_once $GLOBALS['xoops']->path('www/class/pagenav.php');
28
xoops_load('xoopsrequest');
29
30
$myts = MyTextSanitizer::getInstance();
31
32
// keywords
33
$prefKeywords = $GLOBALS['xoopsModuleConfig']['keywords'];
34
$prefKeywords = $myts->undoHtmlSpecialChars($myts->displayTarea($prefKeywords));
35
if (isset($xoTheme) && is_object($xoTheme)) {
36
    $xoTheme->addMeta('meta', 'keywords', strip_tags($prefKeywords));
37
} else { // Compatibility for old Xoops versions
38
    $xoopsTpl->assign('xoops_meta_keywords', strip_tags($prefKeywords));
39
}
40
41
// description
42
$prefDesc = _MA_RANDOMQUOTE_DESC;
43
$prefDesc = $myts->undoHtmlSpecialChars($myts->displayTarea($prefDesc));
44
if (isset($xoTheme) && is_object($xoTheme)) {
45
    $xoTheme->addMeta('meta', 'description', strip_tags($prefDesc));
46
} else { // Compatibility for old Xoops versions
47
    $xoopsTpl->assign('xoops_meta_description', strip_tags($prefDesc));
48
}
49
50
$GLOBALS['xoopsTpl']->assign(array('xoops_mpageurl'  => $GLOBALS['xoops']->url("www/modules/{$moduleDirName}/index.php"),
51
                                   'randomquote_url' => $GLOBALS['xoops']->url("www/modules/{$moduleDirName}"),
52
                                   'adv'             => $GLOBALS['xoopsModuleConfig']['advertise'],
53
                                   //                                 'social_bookmarks' => $GLOBALS['xoopsModuleConfig']['social_bookmarks'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% 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...
54
                                   //                                       'fbcomments' => $GLOBALS['xoopsModuleConfig']['fbcomments'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% 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...
55
                                   'admin'           => $GLOBALS['xoops']->url("www/modules/{$moduleDirName}/admin/index.php"),
56
                                   'copyright'       => "<a href='http://xoops.org' title='XOOPS Project' target='_blank'>
57
                     <img src='" . $GLOBALS['xoops']->url("www/modules/{$moduleDirName}/assets/images/logo_module.png") . "' alt='XOOPS Project'></a>",
58
                                   'breadcrumb'      => '<a href="' . $GLOBALS['xoops']->url('www') . '">' . _YOURHOME . '</a>  &raquo; ' . $GLOBALS['xoopsModule']->name(),));
59
60
$quotesHandler = xoops_getModuleHandler('quotes', $moduleDirName);
61
62
$aQuote   = Request::getInt('id', RandomquoteConstants::DEFAULT_ID);
63
$criteria = new CriteriaCompo();
64
$criteria->add(new Criteria('quote_status', RandomquoteConstants::STATUS_ONLINE)); //only show online quotes
65
if ($aQuote) { // this is done to accomodate the tags module
66
    $criteria->add(new Criteria('id', $aQuote)); // if only want to see a single quote
67
}
68
$criteria->setSort('author');
69
$criteria->setOrder('ASC');
70
$quoteObjArray = $quotesHandler->getAll($criteria);
71
$numrows       = (!empty($quoteObjArray)) ? count($quoteObjArray) : 0;
72
//$numrows    = $quotesHandler->getCount();
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
73
//Table view
74
if ($numrows) {
75
    $bodyTxt = "<table class='outer width100 outer bspacing1'>\n"
76
               . "  <thead>\n"
77
               . "  <tr>\n"
78
               . "    <th class='txtcenter'>"
79
               . _MA_RANDOMQUOTE_QUOTES_QUOTE
80
               . "</th>\n"
81
               . "    <th class='txtcenter'>"
82
               . _MA_RANDOMQUOTE_QUOTES_AUTHOR
83
               . "</th>\n"
84
               . "  </tr>\n"
85
               . "  </thead>\n"
86
               . "  <tbody>\n";
87
88
    $class = 'even';
89
90
    foreach ($quoteObjArray as $thisQuote) {
91
        //        if (0 == $quotes_arr[$i]->getVar("quotes_pid")) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
92
        $class = ('even' == $class) ? 'odd' : 'even';
93
        $bodyTxt .= "  <tr class='{$class}'>\n" . '    <td> ' . $thisQuote->getVar('quote') . "</td>\n" . "    <td class='txtcenter'>" . $thisQuote->getVar('author') . "</td>\n" . "  </tr>\n";
94
        $GLOBALS['xoopsTpl']->append('sets', array('quote'  => $thisQuote->getVar('quote'),
95
                                                   'author' => $thisQuote->getVar('author')));
96
        //        }
97
    }
98
    $bodyTxt .= "  </tbody>\n" . "</table><br><br>\n";
99
} else {
100
    $bodyTxt = "<div class='txtcenter bold italic'>\n" . ' ' . _MA_RANDOMQUOTE_NO_QUOTES . "\n" . "</div>\n";
101
}
102
$GLOBALS['xoopsTpl']->assign('bodyTxt', $bodyTxt);
103
//
104
require_once $GLOBALS['xoops']->path('/footer.php');
105