Completed
Pull Request — master (#12)
by
unknown
01:54
created

letter.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
 *
4
 * Module: Lexikon - glossary module
5
 * Version: v 1.00
6
 * Release Date: 8 May 2004
7
 * Author: hsalazar
8
 * Licence: GNU
9
 */
10
11
include __DIR__ . '/header.php';
12
$GLOBALS['xoopsOption']['template_main'] = 'lx_letter.tpl';
13
include_once XOOPS_ROOT_PATH . '/header.php';
14
include_once XOOPS_ROOT_PATH . '/modules/lexikon/include/common.inc.php';
15
16
global $xoTheme, $xoopsUser;
17
$myts = MyTextSanitizer::getInstance();
18
19
$init = isset($_GET['init']) ? $_GET['init'] : 0;
20
$xoopsTpl->assign('firstletter', $init);
21
include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
22
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
23
24
$publishedwords = LexikonUtility::countWords();
25
$xoopsTpl->assign('publishedwords', $publishedwords);
26
27
//permissions
28
$gpermHandler = xoops_getHandler('groupperm');
29
$groups       = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
30
$module_id    = $xoopsModule->getVar('mid');
31
$allowed_cats = $gpermHandler->getItemIds('lexikon_view', $groups, $module_id);
32
$catids       = implode(',', $allowed_cats);
33
$catperms     = " AND categoryID IN ($catids) ";
34
35
$xoopsTpl->assign('multicats', (int)$xoopsModuleConfig['multicats']);
36
37
// To display the linked letter list
38
$alpha = LexikonUtility::getAlphaArray();
39
$xoopsTpl->assign('alpha', $alpha);
40
41
list($howmanyother) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '#' AND offline ='0' " . $catperms . ''));
42
$xoopsTpl->assign('totalother', $howmanyother);
43
44
// To display the list of categories
45 View Code Duplication
if ($xoopsModuleConfig['multicats'] == 1) {
46
    $xoopsTpl->assign('block0', LexikonUtility::getCategoryArray());
47
    $xoopsTpl->assign('layout', CONFIG_CATEGORY_LAYOUT_PLAIN);
48
    if (LexikonUtility::getModuleOption('useshots')) {
49
        $xoopsTpl->assign('show_screenshot', true);
50
        $xoopsTpl->assign('logo_maximgwidth', $xoopsModuleConfig['logo_maximgwidth']);
51
        $xoopsTpl->assign('lang_noscreenshot', _MD_LEXIKON_NOSHOTS);
52
    } else {
53
        $xoopsTpl->assign('show_screenshot', false);
54
    }
55
}
56
57
// No initial: we need to see all letters
58
if (!$init) {
59
    $entriesarray = array();
60
    $pagetype     = 0;
61
62
    // How many entries will we show in this page?
63
    //$queryA = "SELECT w. * , c.name AS catname FROM ".$xoopsDB -> prefix( 'lxentries' )." w LEFT JOIN ".$xoopsDB -> prefix( 'lxcategories' )." c ON w.categoryID = c.categoryID WHERE w.submit = '0' AND w.offline = '0' ORDER BY w.term ASC";
64
    //$resultA = $xoopsDB -> query ($queryA, $xoopsModuleConfig['indexperpage'], $start );
65
    $queryA  = 'SELECT * FROM ' . $xoopsDB->prefix('lxentries') . " WHERE offline = '0' AND submit = '0' " . $catperms . ' ORDER BY term ASC';
66
    $resultA = $xoopsDB->query($queryA, $xoopsModuleConfig['indexperpage'], $start);
67
68
    $allentries   = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . " WHERE submit ='0' AND offline = '0' " . $catperms . ' ORDER BY term ASC ');
69
    $totalentries = $xoopsDB->getRowsNum($allentries);
70
    $xoopsTpl->assign('totalentries', $totalentries);
71
72
    while (list($entryID, $categoryID, $term, $init, $definition, $ref, $url, $uid, $submit, $datesub, $counter, $html, $smiley, $xcodes, $breaks, $block, $offline, $comments) = $xoopsDB->fetchRow($resultA)) {
73
        $eachentry        = array();
74
        $xoopsModule      = XoopsModule::getByDirname('lexikon');
75
        $eachentry['dir'] = $xoopsModule->dirname();
76
77 View Code Duplication
        if ($xoopsModuleConfig['multicats'] == 1) {
78
            $eachentry['catid'] = (int)$categoryID;
79
            $resultF            = $xoopsDB->query('SELECT name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = $categoryID ORDER BY name ASC");
80
            while (list($name) = $xoopsDB->fetchRow($resultF)) {
81
                $eachentry['catname'] = $myts->htmlSpecialChars($name);
82
            }
83
        }
84
85
        $eachentry['id']   = (int)$entryID;
86
        $eachentry['term'] = ucfirst($myts->htmlSpecialChars($term));
87
88 View Code Duplication
        if (($xoopsModuleConfig['com_rule'] != 0) || (($xoopsModuleConfig['com_rule'] != 0) && is_object($xoopsUser))) {
89
            if ($comments != 0) {
90
                $eachentry['comments'] = "<a href='entry.php?entryID=" . $eachentry['id'] . "'>" . $comments . '&nbsp;' . _COMMENTS . '</a>';
91
            } else {
92
                $eachentry['comments'] = '';
93
            }
94
        }
95
96 View Code Duplication
        if (!XOOPS_USE_MULTIBYTES) {
97
            $eachentry['definition'] = $myts->displayTarea($definition, $html, $smiley, $xcodes, 1, $breaks);
98
        }
99
100
        // Functional links
101
        $microlinks              = LexikonUtility::getServiceLinks($eachentry);
102
        $eachentry['microlinks'] = $microlinks;
103
104
        $entriesarray['single'][] = $eachentry;
105
    }
106
    $pagenav                = new XoopsPageNav($totalentries, $xoopsModuleConfig['indexperpage'], $start, 'start');
107
    $entriesarray['navbar'] = '<div style="text-align:right;">' . $pagenav->renderNav(6) . '</div>';
108
109
    $xoopsTpl->assign('entriesarray', $entriesarray);
110
    $xoopsTpl->assign('pagetype', '0');
111
    $xoopsTpl->assign('pageinitial', _MD_LEXIKON_ALL);
112
113
    LexikonUtility::createPageTitle($myts->htmlSpecialChars(_MD_LEXIKON_BROWSELETTER . ' - ' . _MD_LEXIKON_ALL));
114
} else {    // $init does exist
115
    $pagetype = 1;
116
    // There IS an initial letter, so we want to show just that letter's terms
117
    $entriesarray2 = array();
118
119
    // How many entries will we show in this page?
120
    if ($init == _MD_LEXIKON_OTHER) {
121
        //$queryB = "SELECT * FROM " . $xoopsDB -> prefix( 'lxentries' ) . " WHERE submit ='0' AND offline = '0' AND init = '#' ORDER BY term ASC";
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% 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...
122
        $queryB  = 'SELECT entryID, categoryID, term, definition, uid, html, smiley, xcodes, breaks, comments FROM '
123
                   . $xoopsDB->prefix('lxentries')
124
                   . " WHERE submit ='0' AND offline = '0' AND init = '#' "
125
                   . $catperms
126
                   . '  ORDER BY term ASC';
127
        $resultB = $xoopsDB->query($queryB, $xoopsModuleConfig['indexperpage'], $start);
128
    } else {
129
        //$queryB = "SELECT * FROM " . $xoopsDB -> prefix( 'lxentries' ) . " WHERE submit ='0' AND offline = '0' AND init = '$init' AND init != '#' ORDER BY term ASC";
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% 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...
130
        $queryB  = 'SELECT entryID, categoryID, term, definition, uid, html, smiley, xcodes, breaks, comments FROM '
131
                   . $xoopsDB->prefix('lxentries')
132
                   . " WHERE submit ='0' AND offline = '0' AND init = '$init' AND init != '#' "
133
                   . $catperms
134
                   . '  ORDER BY term ASC';
135
        $resultB = $xoopsDB->query($queryB, $xoopsModuleConfig['indexperpage'], $start);
136
    }
137
138
    $entrieshere = $xoopsDB->getRowsNum($resultB);
139
    if ($entrieshere == 0) {
140
        redirect_header('javascript:history.go(-1)', 1, _MD_LEXIKON_NOTERMSINLETTER);
141
    }
142
143
    if ($init == _MD_LEXIKON_OTHER) {
144
        $allentries = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '#' AND submit ='0' AND offline = '0' " . $catperms . '  ORDER BY term ASC ');
145
    } else {
146
        $allentries = $xoopsDB->query('SELECT entryID FROM '
147
                                      . $xoopsDB->prefix('lxentries')
148
                                      . " WHERE init = '$init' AND init != '#' AND submit ='0' AND offline = '0' "
149
                                      . $catperms
150
                                      . '  ORDER BY term ASC ');
151
    }
152
    $totalentries = $xoopsDB->getRowsNum($allentries);
153
    $xoopsTpl->assign('totalentries', $totalentries);
154
    LexikonUtility::createPageTitle($myts->htmlSpecialChars(_MD_LEXIKON_BROWSELETTER . (isset($init['init']) ? (' - ' . $init['init']) : '')));
155
156
    //while (list( $entryID, $categoryID, $term, $init, $definition, $ref, $url, $uid, $submit, $datesub, $counter, $html, $smiley, $xcodes, $breaks, $block, $offline, $notifypub, $request, $comments ) = $xoopsDB->fetchRow($resultB)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% 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...
157
    while (list($entryID, $categoryID, $term, $definition, $uid, $html, $smiley, $xcodes, $breaks, $comments) = $xoopsDB->fetchRow($resultB)) {
158
        $eachentry        = array();
159
        $xoopsModule      = XoopsModule::getByDirname('lexikon');
160
        $eachentry['dir'] = $xoopsModule->dirname();
161
162 View Code Duplication
        if ($xoopsModuleConfig['multicats'] == 1) {
163
            $eachentry['catid'] = (int)$categoryID;
164
            $resultF            = $xoopsDB->query('SELECT name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = $categoryID ORDER BY name ASC");
165
            while (list($name) = $xoopsDB->fetchRow($resultF)) {
166
                $eachentry['catname'] = $myts->htmlSpecialChars($name);
167
            }
168
        }
169
        $eachentry['id']   = (int)$entryID;
170
        $eachentry['term'] = ucfirst($myts->htmlSpecialChars($term));
171
        //$eachentry['init'] = $init;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
172
        if ($init === '#') {
173
            $eachentry['init'] = _MD_LEXIKON_OTHER;
174
        } else {
175
            $eachentry['init'] = $init;
176
        }
177
178 View Code Duplication
        if (($xoopsModuleConfig['com_rule'] != 0) || (($xoopsModuleConfig['com_rule'] != 0) && is_object($xoopsUser))) {
179
            if ($comments != 0) {
180
                $eachentry['comments'] = "<a href='entry.php?entryID=" . $eachentry['id'] . "'>" . $comments . '&nbsp;' . _COMMENTS . '</a>';
181
            } else {
182
                $eachentry['comments'] = '';
183
            }
184
        }
185 View Code Duplication
        if (!XOOPS_USE_MULTIBYTES) {
186
            $eachentry['definition'] = $myts->displayTarea($definition, $html, $smiley, $xcodes, 1, $breaks);
187
        }
188
189
        // Functional links
190
        $microlinks              = LexikonUtility::getServiceLinks($eachentry);
191
        $eachentry['microlinks'] = $microlinks;
192
193
        $entriesarray2['single'][] = $eachentry;
194
    }
195
    $pagenav                 = new XoopsPageNav($totalentries, $xoopsModuleConfig['indexperpage'], $start, 'init=' . $eachentry['init'] . '&start');
196
    $entriesarray2['navbar'] = '<div style="text-align:right;">' . $pagenav->renderNav(6) . '</div>';
197
198
    $xoopsTpl->assign('entriesarray2', $entriesarray2);
199
    $xoopsTpl->assign('pagetype', '1');
200
    if ($eachentry['init'] === '#') {
201
        $xoopsTpl->assign('pageinitial', _MD_LEXIKON_OTHER);
202
        LexikonUtility::createPageTitle($myts->htmlSpecialChars(_MD_LEXIKON_BROWSELETTER . ' - ' . _MD_LEXIKON_OTHER));
203
    } else {
204
        $xoopsTpl->assign('pageinitial', ucfirst($eachentry['init']));
205
    }
206
}
207
208
$xoopsTpl->assign('lang_modulename', $xoopsModule->name());
209
$xoopsTpl->assign('lang_moduledirname', $xoopsModule->getVar('dirname'));
210
$xoopsTpl->assign('alpha', $alpha);
211
if ($xoopsModuleConfig['syndication'] == 1) {
212
    $xoopsTpl->assign('syndication', true);
213
}
214
if ($xoopsUser) {
215
    $xoopsTpl->assign('syndication', true);
216
}
217
// Meta data
218
if ($publishedwords != 0) {
219
    $meta_description = xoops_substr(LexikonUtility::convertHtml2text($eachentry['definition']), 0, 150);
220
    if ($xoopsModuleConfig['multicats'] == 1) {
221
        LexikonUtility::extractKeywords($xoopsModule->name() . ' ,' . $eachentry['term'] . ', ' . $meta_description);
222
        LexikonUtility::getMetaDescription($myts->htmlSpecialChars($xoopsModule->name()) . ' ' . $eachentry['catname'] . ' ' . $eachentry['term']);
223
    } else {
224
        LexikonUtility::extractKeywords($myts->htmlSpecialChars($xoopsModule->name()) . ', ' . $eachentry['term'] . ', ' . $meta_description);
225
        LexikonUtility::getMetaDescription($myts->htmlSpecialChars($xoopsModule->name()) . ' ' . $eachentry['term'] . ' ' . $meta_description);
226
    }
227
}
228
229
$xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="assets/css/style.css" />');
230
231
include XOOPS_ROOT_PATH . '/footer.php';
232