Completed
Push — master ( 15390a...45d748 )
by cam
06:41
created

commencer_page.php ➔ init_body_class()   C

Complexity

Conditions 7
Paths 64

Size

Total Lines 26
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 20
nc 64
nop 0
dl 0
loc 26
rs 6.7272
c 0
b 0
f 0
1
<?php
2
3
/***************************************************************************\
4
 *  SPIP, Systeme de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright (c) 2001-2017                                                *
7
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
8
 *                                                                         *
9
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
10
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11
\***************************************************************************/
12
13
/**
14
 * Présentation de l'interface privee (exec PHP), début du HTML
15
 *
16
 * @package SPIP\Core\Presentation
17
 **/
18
19
if (!defined('_ECRIRE_INC_VERSION')) {
20
	return;
21
}
22
23
/**
24
 * Débute une page HTML pour l'espace privé
25
 *
26
 * Préferer l'usage des squelettes prive/squelettes/.
27
 *
28
 * @uses init_entete()
29
 * @uses init_body()
30
 * @example
31
 *     ```
32
 *     $commencer_page = charger_fonction('commencer_page','inc');
33
 *     echo $commencer_page($titre);
34
 *     ```
35
 *
36
 * @param string $titre Titre de la page
37
 * @param string $rubrique ?
38
 * @param string $sous_rubrique ?
39
 * @param string $id_rubrique ?
40
 * @param bool $menu ?
41
 * @param bool $minipres ?
42
 * @param bool $alertes ?
43
 * @return string Code HTML
44
 **/
45
function inc_commencer_page_dist(
46
	$titre = "",
47
	$rubrique = "accueil",
48
	$sous_rubrique = "accueil",
49
	$id_rubrique = "",
50
	$menu = true,
51
	$minipres = false,
52
	$alertes = true
53
) {
54
55
	include_spip('inc/headers');
56
57
	http_no_cache();
58
59
	return init_entete($titre, $id_rubrique, $minipres)
60
	. init_body($rubrique, $sous_rubrique, $id_rubrique, $menu)
61
	. "<div id='page'>"
62
	. auteurs_recemment_connectes($GLOBALS['connect_id_auteur'])
63
	. ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '')
64
	. '<div class="largeur">';
65
}
66
67
/**
68
 * Envoi du DOCTYPE et du `<head><title>   </head>`
69
 *
70
 * @uses _DOCTYPE_ECRIRE
71
 * @uses textebrut()
72
 * @uses typo()
73
 * @uses html_lang_attributes()
74
 * @uses init_head()
75
 *
76
 * @param string $titre
77
 *     Titre de la page
78
 * @param integer $dummy
79
 *     Valeur non utilisée…
80
 * @param bool $minipres
81
 * @return string
82
 *     Entête du fichier HTML avec le DOCTYPE
83
 */
84
function init_entete($titre = '', $dummy = 0, $minipres = false) {
85
	include_spip('inc/texte');
86 View Code Duplication
	if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']["nom_site"]))) {
0 ignored issues
show
Duplication introduced by
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...
87
		$nom_site_spip = _T('info_mon_site_spip');
88
	}
89
90
	$titre = "["
91
		. $nom_site_spip
92
		. "]"
93
		. ($titre ? " " . textebrut(typo($titre)) : "");
94
95
	return _DOCTYPE_ECRIRE
96
	. html_lang_attributes()
97
	. "<head>\n"
98
	. init_head($titre, $dummy, $minipres)
99
	. "</head>\n";
100
}
101
102
/**
103
 * Retourne le code HTML du head (intégration des JS et CSS) de l'espace privé
104
 *
105
 * Code HTML récupéré du squelette `prive/squelettes/head/dist`
106
 *
107
 * @param string $titre
108
 * @param integer $dummy
109
 * @param bool $minipres
110
 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|array? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
111
 */
112
function init_head($titre = '', $dummy = 0, $minipres = false) {
0 ignored issues
show
Unused Code introduced by
The parameter $dummy is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
113
	return recuperer_fond("prive/squelettes/head/dist", array('titre' => $titre, 'minipres' => $minipres ? ' ' : ''));
114
}
115
116
/**
117
 * Fonction envoyant la double série d'icônes de rédac
118
 *
119
 * @uses init_body_class()
120
 * @uses inc_bandeau_dist()
121
 *
122
 * @pipeline_appel body_prive
123
 *
124
 * @global mixed $connect_id_auteur
125
 * @global mixed $auth_can_disconnect
126
 *
127
 * @param string $rubrique
128
 * @param string $sous_rubrique
129
 * @param integer $id_rubrique
0 ignored issues
show
Documentation introduced by
Should the type for parameter $id_rubrique not be string|integer?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
130
 * @param bool $menu
131
 * @return string
132
 */
133
function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) {
0 ignored issues
show
Unused Code introduced by
The parameter $rubrique is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $sous_rubrique is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $id_rubrique is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
134
135
	$res = pipeline('body_prive', "<body class='"
136
		. init_body_class() . " " . _request('exec') . "'"
137
		. ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : "")
138
		. '>');
139
140
	if (!$menu) {
141
		return $res;
142
	}
143
144
145
	$bandeau = charger_fonction('bandeau', 'inc');
146
147
	return $res
148
	. $bandeau();
149
}
150
151
/**
152
 * Calcule les classes CSS à intégrer à la balise `<body>` de l'espace privé
153
 *
154
 * Les classes sont calculées en fonction des préférences de l'utilisateur,
155
 * par exemple s'il choisit d'avoir ou non les icônes.
156
 *
157
 * @return string Classes CSS (séparées par des espaces)
158
 */
159
function init_body_class() {
160
	$GLOBALS['spip_display'] = isset($GLOBALS['visiteur_session']['prefs']['display'])
161
		? $GLOBALS['visiteur_session']['prefs']['display']
162
		: 2;
163
	$spip_display_navigation = isset($GLOBALS['visiteur_session']['prefs']['display_navigation'])
164
		? $GLOBALS['visiteur_session']['prefs']['display_navigation']
165
		: 'navigation_avec_icones';
166
	$spip_display_outils = isset($GLOBALS['visiteur_session']['prefs']['display_outils'])
167
		? ($GLOBALS['visiteur_session']['prefs']['display_outils'] ? 'navigation_avec_outils' : 'navigation_sans_outils')
168
		: 'navigation_avec_outils';
169
	$GLOBALS['spip_ecran'] = isset($_COOKIE['spip_ecran']) ? $_COOKIE['spip_ecran'] : "etroit";
170
171
	$display_class = array(
172
		0 => 'icones_img_texte'
173
		/*init*/,
174
		1 => 'icones_texte',
175
		2 => 'icones_img_texte',
176
		3 => 'icones_img'
177
	);
178
179
	$couleur = isset($GLOBALS['visiteur_session']['prefs']['couleur'])
180
		? $GLOBALS['visiteur_session']['prefs']['couleur']
181
		: 9;
182
183
	return $GLOBALS['spip_ecran'] . " couleur_$couleur $spip_display_navigation $spip_display_outils " . $display_class[$GLOBALS['spip_display']];
184
}
185
186
187
/**
188
 * Afficher la liste des auteurs connectés à l'espace privé
189
 *
190
 * @param integer $id_auteur
191
 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|array? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
192
 */
193
function auteurs_recemment_connectes($id_auteur) {
0 ignored issues
show
Unused Code introduced by
The parameter $id_auteur is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
194
	return recuperer_fond('prive/objets/liste/auteurs_enligne');
195
}
196