Completed
Push — master ( 369c90...324e29 )
by Michael
04:57
created

index.php (2 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
 * references - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 *
14
 * @copyright       Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
15
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
16
 * @package         references
17
 * @author          Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
18
 *
19
 * ****************************************************************************
20
 */
21
22
/*
23
 * Page d'index du module, liste des articles
24
 */
25
require __DIR__ . '/header.php';
26
$xoopsOption['template_main'] = 'references_index.tpl';
27
require XOOPS_ROOT_PATH . '/header.php';
28
require_once REFERENCES_PATH . 'class/registryfile.php';
29
30
$limit      = references_utils::getModuleOption('items_index_page');
31
$start      = $index = 0;
32
$article_id = isset($_GET['article_id']) ? (int)$_GET['article_id'] : 0;    // Utiliser pour afficher un article particulier
33
34
// Texte à afficher sur la page d'accueil
35
$registry = new references_registryfile();
36
$xoopsTpl->assign('welcomeMsg', nl2br($registry->getfile(REFERENCES_TEXTFILE1)));
37
$xoopsTpl->assign('use_rss', references_utils::getModuleOption('use_rss'));
38
39
// MooTools
40
$xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools.js');
41
$xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools-1.2-more.js');
42
43 View Code Duplication
if (isset($xoopsConfig) && file_exists(REFERENCES_PATH . 'language/' . $xoopsConfig['language'] . '/slimbox.js')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    $xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js');
45
} else {
46
    $xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js');
47
}
48
49
$categories       = $h_references_categories->getCategories();
50
$categoriesSelect = $h_references_categories->getCategoriesSelect();
51
$xoopsTpl->assign('categoriesSelect', $categoriesSelect);
52
$categoriesForTemplate = array();
53
54
//$xoTheme->addScript(REFERENCES_JS_URL.'js/accordion.js');
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...
55
$xoTheme->addStylesheet(REFERENCES_JS_URL . 'css/slimbox.css');
56
$xoTheme->addStylesheet(REFERENCES_JS_URL . 'css/accordion.css');
57
58
// ****************************************************************************************************************************
59
$xoopsTpl->assign('thumbsWidth', references_utils::getModuleOption('thumbs_width'));
60
$xoopsTpl->assign('thumbsHeight', references_utils::getModuleOption('thumbs_height'));
61
62
$lastTitle               = $lastKeywords = '';
63
$refFounded              = false;
64
$mostRecentReferenceDate = 0;
65
if ($limit > 0) {
66
    $uniqueCategories = $h_references_articles->getDistinctCategoriesIds();
67
    foreach ($uniqueCategories as $categoryId) {
68
        $items          = array();
69
        $items          = $h_references_articles->getRecentArticles($start, $limit, references_utils::getModuleOption('sort_field'), references_utils::getModuleOption('sort_order'), true, $categoryId);
70
        $categoryTitle  = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : '';
71
        $categoryWeight = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_weight') : 0;
72
        if (count($items) > 0) {
73
            foreach ($items as $item) {
74
                $articleData = array();
75
                $articleData = $item->toArray();
76
                if ($item->getVar('article_id') == $article_id) {
77
                    $xoopsTpl->assign('defaultArticle', $index);
78
                    $refFounded = true;
79
                }
80
                ++$index;
81
                $articleData['article_category_id']                                          = $categoryId;
82
                $articleData['article_category_title']                                       = $categoryTitle;
83
                $articleData['article_category_weight']                                      = $categoryWeight;
84
                $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['articles'][]    = $articleData;
85
                $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['categoryTitle'] = $categoryTitle;
86
                $categoriesForTemplate[$categoryWeight . '-' . $categoryId]['categoryId']    = $categoryId;
87
                if ($item->getVar('article_timestamp') > $mostRecentReferenceDate) {
88
                    $mostRecentReferenceDate = $item->getVar('article_timestamp');
89
                    $lastTitle               = strip_tags($item->getVar('article_title', 'n')) . ', ' . $item->getVar('article_date');
90
                    $lastKeywords            = strip_tags($item->getVar('article_text', 'n'));
91
                }
92
            }
93
        }
94
    }
95
    if (!$refFounded) {
96
        $xoopsTpl->assign('defaultArticle', 0);
97
    }
98
    if (count($categoriesForTemplate) > 0) {
99
        ksort($categoriesForTemplate);
100
    }
101
    $xoopsTpl->assign('categories', $categoriesForTemplate);
102
}
103
104
$xoopsTpl->assign('isAdmin', references_utils::isAdmin());
105
$metaTitle    = $lastTitle . ' - ' . $xoopsModule->name();
106
$metaKeywords = references_utils::createMetaKeywords($lastTitle . ' ' . $lastKeywords);
107
108
references_utils::setMetas($metaTitle, $metaTitle, $metaKeywords);
109
require XOOPS_ROOT_PATH . '/footer.php';
110