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

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
 * Version : $Id:
20
 * ****************************************************************************
21
 */
22
23
/*
24
 * Page d'index du module, liste des articles
25
 */
26
require 'header.php';
27
$xoopsOption['template_main'] = 'references_index.html';
28
require XOOPS_ROOT_PATH.'/header.php';
29
require_once REFERENCES_PATH.'class/registryfile.php';
30
31
$limit = references_utils::getModuleOption('items_index_page');
32
$start = $index = 0;
33
$article_id = isset($_GET['article_id']) ? intval($_GET['article_id']) : 0;	// Utiliser pour afficher un article particulier
34
35
// Texte � afficher sur la page d'accueil
36
$registry = new references_registryfile();
37
$xoopsTpl->assign('welcomeMsg', nl2br($registry->getfile(REFERENCES_TEXTFILE1)));
38
$xoopsTpl->assign('use_rss', references_utils::getModuleOption('use_rss'));
39
40
// MooTools
41
$xoTheme->addScript(REFERENCES_JS_URL.'js/mootools.js');
42
$xoTheme->addScript(REFERENCES_JS_URL.'js/mootools-1.2-more.js');
43
44 View Code Duplication
if (isset($xoopsConfig) && file_exists(REFERENCES_PATH.'language/'.$xoopsConfig['language'].'/slimbox.js')) {
45
	$xoTheme->addScript(REFERENCES_URL.'language/'.$xoopsConfig['language'].'/slimbox.js');
46
} else {
47
	$xoTheme->addScript(REFERENCES_JS_URL.'js/slimbox.js');
48
}
49
50
$categories = $h_references_categories->getCategories();
51
$categoriesSelect = $h_references_categories->getCategoriesSelect();
52
$xoopsTpl->assign('categoriesSelect', $categoriesSelect);
53
$categoriesForTemplate = array();
54
55
//$xoTheme->addScript(REFERENCES_JS_URL.'js/accordion.js');
56
$xoTheme->addStylesheet(REFERENCES_JS_URL.'css/slimbox.css');
57
$xoTheme->addStylesheet(REFERENCES_JS_URL.'css/accordion.css');
58
59
// ****************************************************************************************************************************
60
$xoopsTpl->assign('thumbsWidth', references_utils::getModuleOption('thumbs_width'));
61
$xoopsTpl->assign('thumbsHeight', references_utils::getModuleOption('thumbs_height'));
62
63
$lastTitle = $lastKeywords = '';
64
$refFounded = false;
65
$mostRecentReferenceDate = 0;
66
if ($limit > 0 ) {
67
    $uniqueCategories = $h_references_articles->getDistinctCategoriesIds();
68
    foreach($uniqueCategories as $categoryId) {
69
        $items = array();
70
        $items = $h_references_articles->getRecentArticles($start, $limit, references_utils::getModuleOption('sort_field'), references_utils::getModuleOption('sort_order'), true, $categoryId);
71
        $categoryTitle = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : '';
72
        $categoryWeight = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_weight') : 0;
73
        if(count($items) > 0) {
74
            foreach($items as $item) {
75
                $articleData = array();
76
                $articleData = $item->toArray();
77
                if($item->getVar('article_id') == $article_id) {
78
                    $xoopsTpl->assign('defaultArticle', $index);
79
                    $refFounded = true;
80
                }
81
                $index++;
82
                $articleData['article_category_id'] = $categoryId;
83
                $articleData['article_category_title'] = $categoryTitle;
84
                $articleData['article_category_weight'] = $categoryWeight;
85
                $categoriesForTemplate[$categoryWeight.'-'.$categoryId]['articles'][] = $articleData;
86
                $categoriesForTemplate[$categoryWeight.'-'.$categoryId]['categoryTitle']= $categoryTitle;
87
                $categoriesForTemplate[$categoryWeight.'-'.$categoryId]['categoryId']= $categoryId;
88
    	        if($item->getVar('article_timestamp') > $mostRecentReferenceDate) {
89
    	            $mostRecentReferenceDate = $item->getVar('article_timestamp');
90
            	    $lastTitle = strip_tags($item->getVar('article_title', 'n')).', '.$item->getVar('article_date');
91
    	            $lastKeywords = strip_tags($item->getVar('article_text', 'n'));
92
    	        }
93
            }
94
        }
95
    }
96
    if(!$refFounded) {
97
    	$xoopsTpl->assign('defaultArticle', 0);
98
    }
99
    if(count($categoriesForTemplate) > 0) {
100
        ksort($categoriesForTemplate);
101
    }
102
    $xoopsTpl->assign('categories', $categoriesForTemplate);
103
}
104
105
$xoopsTpl->assign('isAdmin', references_utils::isAdmin());
106
$metaTitle = $lastTitle.' - '.$xoopsModule->name();
107
$metaKeywords = references_utils::createMetaKeywords($lastTitle.' '.$lastKeywords);
108
109
references_utils::setMetas($metaTitle, $metaTitle, $metaKeywords);
110
require XOOPS_ROOT_PATH.'/footer.php';
111
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...