Completed
Pull Request — master (#4)
by Michael
02:44
created

column.php (1 issue)

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
// $Id: column.php,v 0.0.1 2005/10/24 20:30:00 domifara Exp $
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% 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...
3
/**
4
 * $Id: column.php v 1.5 23 August 2004 hsalazar Exp $
5
 * Module: Soapbox
6
 * Version: v 1.5
7
 * Release Date: 23 August 2004
8
 * Author: hsalazar
9
 * Licence: GNU
10
 */
11
12
include __DIR__ . '/header.php';
13
$op = '';
14
//HACK for cache by domifara
15
if (is_object($xoopsUser)) {
16
    $xoopsConfig['module_cache'] = 0; //disable caching since the URL will be the same, but content different from one user to another
17
}
18
19
$xoopsOption['template_main'] = 'sb_column.tpl';
20
include_once(XOOPS_ROOT_PATH . "/header.php");
21
22
$moduleDirName = $myts->htmlSpecialChars(basename(__DIR__));
23 View Code Duplication
if ($moduleDirName !== "soapbox" && $moduleDirName !== "" && !preg_match('/^(\D+)(\d*)$/', $moduleDirName)) {
24
    echo("invalid dirname: " . htmlspecialchars($moduleDirName, ENT_QUOTES));
25
}
26
27
$columnID = Xmf\Request::getInt('columnID', 0, 'GET');
28
//---GET view sort --
29
$sortname = isset($_GET['sortname']) ? strtolower(trim(strip_tags($myts->stripSlashesGPC($_GET['sortname'])))) : 'datesub';
30
if (!in_array($sortname, array('datesub', 'weight', 'counter', 'rating', 'headline'))) {
31
    $sortname = 'datesub';
32
}
33
$sortorder = isset($_GET['sortorder']) ? strtoupper(trim(strip_tags($myts->stripSlashesGPC($_GET['sortorder'])))) : 'DESC';
34
if (!in_array($sortorder, array('ASC', 'DESC'))) {
35
    $sortorder = 'DESC';
36
}
37
//---------------
38
include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
39
$start = Xmf\Request::getInt('start', 0, 'GET');
40
41
//-------------------------------------
42
$_entrydata_handler =& xoops_getmodulehandler('entryget', $xoopsModule->dirname());
43
//-------------------------------------
44
$_entryob_arr =& $_entrydata_handler->getArticlesAllPermcheck((int)($xoopsModuleConfig['indexperpage']), $start, true, true, 0, 0, null, $sortname, $sortorder, $columnID, null, true, false);
45
$totalarts    = $_entrydata_handler->total_getArticlesAllPermcheck;
46
if (empty($_entryob_arr) || $totalarts == 0) {
47
    redirect_header(XOOPS_URL . "/modules/" . $moduleDirName . "/index.php", 1, _MD_SOAPBOX_MAINNOTOPICS);
48
}
49
//get category object
50
$_categoryob =& $_entryob_arr[0]->_sbcolumns;
51
//get vars
52
53
$category = array();
54
$category = $_categoryob->toArray(); //all assign
55
56
$category['colid']      = $columnID;
57
$category['author']     = getLinkedUnameFromId($category['author'], 0);
58
$category['authorname'] = getAuthorName($category['author']);
59
$category['image']      = $category['colimage'];
60
$category['total']      = $totalarts;
61
$xoopsTpl->assign('category', $category);
62
63
//------------------------------------------------------
64
foreach ($_entryob_arr as $_entryob) {
65
    //-----------
66
    unset($articles);
67
    $articles = array();
68
    //get vars
69
    $articles = $_entryob->toArray();
70
    //--------------------
71
    $articles['id']      = $articles['articleID'];
72
    $articles['datesub'] = $myts->htmlSpecialChars(formatTimestamp($articles['datesub'], $xoopsModuleConfig['dateformat']));;
73
    //        $articles['poster'] = XoopsUserUtility::getUnameFromId( $articles['uid'] );
74
    $articles['poster']   = getLinkedUnameFromId($category['author']);
75
    $articles['bodytext'] = xoops_substr($articles['bodytext'], 0, 255);
76
    //--------------------
77 View Code Duplication
    if ($articles['submit'] != 0) {
78
        $articles['headline'] = '[' . _MD_SOAPBOX_SELSUBMITS . ']' . $articles['headline'];
79
        $articles['teaser']   = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC;
80
        $articles['lead']     = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC;
81
    } elseif ($_entryob->getVar('datesub') == 0 || $_entryob->getVar('datesub') > time()) {
82
        $articles['headline'] = '[' . _MD_SOAPBOX_SELWAITEPUBLISH . ']' . $articles['headline'];
83
        $articles['teaser']   = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC;
84
        $articles['lead']     = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC;
85
    }
86
    //--------------------
87
    if (!empty($articles['artimage']) && $articles['artimage'] != 'blank.png' && file_exists(XOOPS_ROOT_PATH . '/' . $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir']) . '/' . $articles['artimage'])) {
88
        $articles['image'] = XOOPS_URL . '/' . $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir']) . '/' . $articles['artimage'];
89
    } else {
90
        $articles['image'] = '';
91
    }
92
    if ($xoopsModuleConfig['includerating'] == 1) {
93
        $xoopsTpl->assign('showrating', 1);
94
        $rating = $articles['rating'];
95
        $votes  = $articles['votes'];
96
        if ($rating != 0.00) {
97
            $articles['rating'] = _MD_SOAPBOX_RATING . ": " . $myts->htmlSpecialChars(number_format($rating, 2));
98
            $articles['votes']  = _MD_SOAPBOX_VOTES . ": " . $myts->htmlSpecialChars($votes);
99
        } else {
100
            $articles['rating'] = _MD_SOAPBOX_RATING . ": 0.00";
101
            $articles['votes']  = _MD_SOAPBOX_VOTES . ": 0";
102
        }
103
    }
104
    //--------------------
105
    // Functional links
106
    $articles['adminlinks'] = $_entrydata_handler->getadminlinks($_entryob, $_categoryob);
107
    $articles['userlinks']  = $_entrydata_handler->getuserlinks($_entryob);
108
109
    $xoopsTpl->append('articles', $articles);
110
}
111
112
$pagenav            = new XoopsPageNav($totalarts, (int)($xoopsModuleConfig['indexperpage']), $start, 'start', 'columnID=' . $articles['columnID'] . '&sortname=' . $sortname . '&sortorder=' . $sortorder);
113
$category['navbar'] = '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
114
115
$xoopsTpl->assign('xoops_pagetitle', $category['name']);
116
$xoopsTpl->assign('category', $category);
117
118
$xoopsTpl->assign('lang_modulename', $xoopsModule->name());
119
$xoopsTpl->assign('lang_moduledirname', $moduleDirName);
120
$xoopsTpl->assign('imgdir', $myts->htmlSpecialChars($xoopsModuleConfig['sbimgdir']));
121
$xoopsTpl->assign('uploaddir', $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir']));
122
123
$xoopsTpl->assign('sortname', $sortname);
124
$xoopsTpl->assign('sortorder', $sortorder);
125
126
$xoopsTpl->assign("xoops_module_header", '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/style.css" />');
127
128
include(XOOPS_ROOT_PATH . "/footer.php");
129