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

reference.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
/**
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
 * Affichage des références d'une catégorie
24
 *
25
 * @param integer $article_id Le numéro de la référence
26
 */
27
require __DIR__ . '/header.php';
28
$xoopsOption['template_main'] = 'references_reference.tpl';
29
require XOOPS_ROOT_PATH . '/header.php';
30
31
$baseurl   = REFERENCES_URL . basename(__FILE__);
32
$artice_id = isset($_GET['article_id']) ? (int)$_GET['article_id'] : 0;
33
if ($artice_id == 0) {
34
    references_utils::redirect(_MD_REFERENCES_ERROR4, 'index.php', 4);
35
}
36
$article = null;
37
$article = $h_references_articles->get($artice_id);
38
if (!is_object($article)) {
39
    references_utils::redirect(_MD_REFERENCES_ERROR4, 'index.php', 4);
40
}
41
// Vérification des permissions
42
$handlers = references_handler::getInstance();
43
if (!$handlers->h_references_articles->userCanSeeReference($article)) {
44
    references_utils::redirect(_NOPERM, 'index.php', 4);
45
}
46
47
// Chargement de la catégorie
48
$category = null;
49
$category = $h_references_categories->get($article->getVar('article_category_id'));
50
if (!is_object($category)) {
51
    references_utils::redirect(_MD_REFERENCES_ERROR2, 'index.php', 4);
52
}
53
$xoopsTpl->assign('category', $category->toArray());
54
$xoopsTpl->assign('article', $article->toArray());
55
56
$_SESSION['reference']['current_article'] = $article->getVar('article_title', 'n');
57
58
// Breadcrumb
59
$breadcrumb = array(
60
    $category->getUrl() => $category->getVar('category_title'),
61
    $baseurl            => $article->getVar('article_title')
62
);
63
$xoopsTpl->assign('breadcrumb', references_utils::breadcrumb($breadcrumb));
64
65
$xoopsTpl->assign('use_rss', references_utils::getModuleOption('use_rss'));
66
67
// MooTools
68
$xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools.js');
69
$xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools-1.2-more.js');
70 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...
71
    $xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js');
72
} else {
73
    $xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js');
74
}
75
76
$categoriesSelect = $h_references_categories->getCategoriesSelect('categoriesSelect', $category->getVar('category_id'));
77
$xoopsTpl->assign('categoriesSelect', $categoriesSelect);
78
$xoTheme->addStylesheet(REFERENCES_JS_URL . 'css/slimbox.css');
79
$xoTheme->addStylesheet(REFERENCES_JS_URL . 'css/accordion.css');
80
$xoopsTpl->assign('isAdmin', references_utils::isAdmin());
81
82
// ****************************************************************************************************************************
83
$xoopsTpl->assign('thumbsWidth', references_utils::getModuleOption('thumbs_width'));
84
$xoopsTpl->assign('thumbsHeight', references_utils::getModuleOption('thumbs_height'));
85
86
$metaTitle    = $article->getVar('article_title', 'n') . ' - ' . $xoopsModule->name();
87
$metaKeywords = references_utils::createMetaKeywords($article->getVar('article_text', 'n'));
88
references_utils::setMetas($metaTitle, $metaTitle, $metaKeywords);
89
require XOOPS_ROOT_PATH . '/footer.php';
90