This repository was archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAffichage.class.php
More file actions
377 lines (349 loc) · 17.9 KB
/
Affichage.class.php
File metadata and controls
377 lines (349 loc) · 17.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?php
include_once 'locales/lang.php';
include_once 'Edge.class.php';
include_once 'Twig.class.php';
class Affichage {
static $niveaux_medailles=[
'Photographe' => [1 => 50, 2 => 150, 3 => 600],
'Createur' => [1 => 20, 2 => 70, 3 => 150],
'Duckhunter' => [1 => 1, 2 => 3, 3 => 5]
];
static function onglets_magazines(array $onglets_pays,array $onglets_magazines) {
$magazine_courant = $_GET['onglet_magazine'] ?? null;
Twig::$twig->display('publication_tabs.twig', [
'country_names' => $onglets_pays,
'publication_names' => $onglets_magazines,
'current_publicationcode' => $magazine_courant,
'current_countrycode' => is_null($magazine_courant) ? null : explode('/', $magazine_courant)[0],
]);
}
static function onglets($onglet_courant, $tab_onglets, $argument, $prefixe) {
Twig::$twig->display('tabs.twig', [
'current_tab' => $onglet_courant,
'tabs' => $tab_onglets,
'argument' => $argument,
'prefix' => $prefixe,
]);
}
/**
* @param Liste $liste
* @param string $pays
* @param string $magazine
*/
static function afficher_numeros($liste, $pays, $magazine) {
date_default_timezone_set('Europe/Paris');
[$numeros,$sous_titres] =Inducks::get_numeros($pays,$magazine);
if ($numeros==false) {
echo AUCUN_NUMERO_REPERTORIE.$magazine.' ('.PAYS_PUBLICATION.' : '.$pays.')';
?><br /><br /><?php
echo QUESTION_SUPPRIMER_MAGAZINE;
$liste->sous_liste($pays,$magazine)->afficher('Classique');
?><br />
<a href="?action=gerer&supprimer_magazine=<?=$pays.'.'.$magazine?>"><?=OUI?></a>
<a href="?action=gerer"><?=NON?></a><?php
if (!Util::isLocalHost()) {
@mail('admin@ducksmanager.net', 'Erreur de recuperation de numeros', AUCUN_NUMERO_REPERTORIE . $magazine . ' (' . PAYS_PUBLICATION . ' : ' . $pays . ')');
}
}
else {
$liste->nettoyer_collection();
$nb_possedes = 0;
$numeros = array_map(function ($numero, $sous_titre) use ($liste, $pays, $magazine, &$nb_possedes) {
$infos_numero = $liste->get_numero_collection($pays, $magazine, $numero);
$o = new stdClass();
$o->est_possede = false;
if (!is_null($infos_numero)) {
$nb_possedes++;
$o->est_possede = true;
[/*Pays*/, /*Magazine*/, /*Numero*/, $o->etat, $o->av, $o->id_acquisition, $o->date_acquisition, $o->description_acquisition] = $infos_numero;
$o->etat = array_key_exists($o->etat, Database::$etats) ? $o->etat : 'indefini';
}
$o->sous_titre = $sous_titre;
$o->numero = $numero;
return $o;
}, $numeros, $sous_titres);
Twig::$twig->display('issue_list.twig', [
'country' => $pays,
'publicationcode' => $magazine,
'publicationname' => Inducks::get_nom_complet_magazine($pays, $magazine),
'possessed_number' => $nb_possedes,
'non_possessed_number' => count($numeros) - $nb_possedes,
'issues' => $numeros,
'locale' => $_SESSION['lang']
]);
}
}
static function afficher_evenements_recents($evenements) {
if (count($evenements->evenements) > 0) {
include_once 'Edge.class.php';
$magazines_complets=Inducks::get_noms_complets_magazines($evenements->publicationcodes);
$details_collections=DM_Core::$d->get_details_collections($evenements->ids_utilisateurs);
foreach($evenements->evenements as $evenements_date) {
foreach($evenements_date as $type=>$evenements_type) {
foreach($evenements_type as $evenement) {
?><div class="evenement evenement_<?=$type?>"><?php
switch($type) {
case 'inscriptions':
self::afficher_texte_utilisateur($details_collections[$evenement->id_utilisateur]);
?><?=NEWS_A_COMMENCE_COLLECTION?>
<?php
break;
case 'medaille':
switch($evenement->contribution) {
case 'photographe': $titre_medaille = TITRE_MEDAILLE_PHOTOGRAPHE; break;
case 'createur': $titre_medaille = TITRE_MEDAILLE_CREATEUR; break;
case 'duckhunter': $titre_medaille = TITRE_MEDAILLE_DUCKHUNTER; break;
default: break 2;
}
self::afficher_texte_utilisateur($details_collections[$evenement->id_utilisateur]);
?><?=sprintf(NEWS_A_OBTENU_MEDAILLE, $titre_medaille, $evenement->niveau)?>
<?php
break;
case 'bouquineries':
self::afficher_texte_utilisateur($details_collections[$evenement->id_utilisateur]);?>
<?=NEWS_A_AJOUTE_BOUQUINERIE.' ' ?>
<i><a href="?action=bouquineries"><?=$evenement->nom_bouquinerie?></a></i>.
<?php
break;
case 'ajouts':
$numero=$evenement->numero_exemple;
if (!array_key_exists($numero->Pays.'/'.$numero->Magazine, $magazines_complets)) {
$evenement->cpt++;
continue 2;
}
self::afficher_texte_utilisateur($details_collections[$evenement->id_utilisateur]);
?><?=NEWS_A_AJOUTE?>
<?php self::afficher_texte_numero($numero->Pays, $magazines_complets[$numero->Pays . '/' . $numero->Magazine], $numero->Numero); ?>
<?php
if ($evenement->cpt > 0) {
?>
<?=ET?> <?=$evenement->cpt?>
<?=$evenement->cpt === 1 ? NEWS_AUTRE_NUMERO : NEWS_AUTRES_NUMEROS?>
<?php } ?>
<?=NEWS_A_SA_COLLECTION?><?php
break;
case 'tranches_pretes':
$numero=$evenement->numeros[0];
if (!array_key_exists($numero->Pays.'/'.$numero->Magazine, $magazines_complets)) {
$evenement->cpt++;
continue 2;
}
$contributeurs = array_filter(array_unique($evenement->ids_utilisateurs));
foreach($contributeurs as $i => $idContributeur) {
self::afficher_texte_utilisateur($details_collections[$idContributeur]);
?><?= $i < count($contributeurs) -2 ? ', ' : ($i < count($contributeurs) - 1 ? ' ' . ET . ' ' : '');
}
?><?=count($contributeurs) === 1 ? NEWS_A_CREE_TRANCHE : NEWS_ONT_CREE_TRANCHE?>
<a href="javascript:void(0)" class="has_tooltip edge_tooltip underlined">
<?php
self::afficher_texte_numero(
$numero->Pays,
$magazines_complets[$numero->Pays.'/'.$numero->Magazine],
$numero->Numero,
count($evenement->numeros) - 1,
false
);?>
</a>
<span class="cache tooltip_content">
<div class="edge_container">
<?php
foreach($evenement->numeros as $numero) {
$e=new Edge($numero->Pays, $numero->Magazine, $numero->Numero, $numero->Numero, true);
echo $e->getImgHTML(true);
}
?></div><?php
foreach($evenement->numeros as $numero) {
self::afficher_texte_numero(
$numero->Pays, $magazines_complets[$numero->Pays . '/' . $numero->Magazine], $numero->Numero
);
?><br /><?php
}
?>
</span>
<?=NEWS_ONT_CREE_TRANCHE_2?>
<?php
break;
}
self::afficher_temps_passe((int)$evenement->diffsecondes);
?></div><?php
}
}
}
}
}
static function afficher_dernieres_tranches_publiees() {
$id_user= empty($_SESSION['id_user']) ? null : $_SESSION['id_user'];
$resultat_tranches_collection_ajoutees = DM_Core::$d->get_tranches_collection_ajoutees($id_user, true);
$nb_nouvelles_tranches = count($resultat_tranches_collection_ajoutees);
if ($nb_nouvelles_tranches > 0) {
$magazines_complets = Inducks::get_noms_complets_magazines(array_map(function($tranche) { return $tranche['publicationcode']; }, $resultat_tranches_collection_ajoutees));
$liste_numeros = array_map(function($tranche) use ($magazines_complets) {
return '<li>'.Twig::$twig->render('issue.twig', [
'country' => explode('/', $tranche['publicationcode'])[0],
'magazine' => $magazines_complets[$tranche['publicationcode']],
'issuenumber' => $tranche['issuenumber']
]).'</li>';
}, $resultat_tranches_collection_ajoutees);
self::accordeon(
'nouvelles-tranches',
sprintf($nb_nouvelles_tranches === 1 ? BIBLIOTHEQUE_NOUVELLE_TRANCHE_TITRE : BIBLIOTHEQUE_NOUVELLES_TRANCHES_TITRE, $nb_nouvelles_tranches),
'<ul class="liste_histoires no-indent">'.implode('', $liste_numeros).'</ul>',
$nb_nouvelles_tranches === 1 ? BIBLIOTHEQUE_NOUVELLE_TRANCHE_CONTENU : BIBLIOTHEQUE_NOUVELLES_TRANCHES_CONTENU
);
}
}
static function accordeon($id, $title, $content, $footer = null, $icon = 'glyphicon-info-sign', $collapsed = true) {
Twig::$twig->display('accordion.twig', compact('id', 'collapsed', 'icon', 'title', 'content', 'footer'));
}
static function afficher_temps_passe($diff_seconds) {
Twig::$twig->display('ago.twig', compact('diff_seconds'));
}
static function afficher_texte_numero($country, $magazine, $issuenumber, $other_issues_number = 0, $allow_wrap = true) {
Twig::$twig->display('issue.twig', compact('country', 'magazine', 'issuenumber', 'other_issues_number', 'allow_wrap'));
}
static function afficher_texte_numero_template() {
?><div class="template issue_title">
<span class="nowrap">
<img class="flag" />
</span>
<span class="publication_name"></span> <span class="issuenumber"></span>
</div><?php
}
static function afficher_infobulle_tranche_template() {
?><div class="template tooltip_edge_content">
<?=DECOUVRIR_COUVERTURE?>.
<div class="has-no-edge">
<?=TRANCHE_NON_DISPONIBLE1?><br />
<div class="is-not-bookcase-share">
<?=TRANCHE_NON_DISPONIBLE2?><br />
<div class="template progress-wrapper">
<img class="possede-medaille medaille_objectif gauche" />
<img class="possede-medaille-non-max medaille_objectif droite" />
<div class="progress">
<div class="progress-current progress-bar progress-bar-muted" role="progressbar"></div>
<div class="progress-extra progress-bar progress-bar-success active nowrap show_overflow progress-bar-striped" role="progressbar">
</div>
</div>
</div>
<div class="progress-info">
<?= TRANCHE_NON_DISPONIBLE3 ?>
<span class="progress-extra-points"></span> <?=POINTS?> !
</div>
<br />
<a href="https://edgecreator.ducksmanager.net" target="_blank" class="btn btn-info">
<?= ENVOYER_PHOTO_DE_TRANCHE ?>
</a>
</div>
</div>
</div><?php
}
static function afficher_proposition_photo_tranche() {
?><?=sprintf(INVITATION_ENVOI_PHOTOS_TRANCHES, '<span class="max-points-to-earn"></span>')?>
<div class="carousel small slide">
<!-- Indicators -->
<ol class="carousel-indicators">
<li class="indicator template"></li>
</ol>
<img class="possede-medaille medaille_objectif gauche" />
<div class="carousel-inner">
<div class="item template">
</div>
</div>
<img class="possede-medaille-non-max medaille_objectif droite" />
<!-- Left and right controls -->
<a class="left carousel-control" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
<div class="wrapper_envoyer_tranches">
<a href="https://edgecreator.ducksmanager.net" target="_blank" class="btn btn-info">
<?=ENVOYER_PHOTOS_DE_TRANCHE?></a>
</div>
</div>
<?php
}
static function afficher_texte_utilisateur($userData) {
$medals = self::get_medailles([
'Photographe'=> $userData['Points']['Photographe'],
'Createur' => $userData['Points']['Createur'],
'Duckhunter' => $userData['Points']['Duckhunter']
]);
Twig::$twig->display('user.twig', ['DOMAIN' => Util::DOMAIN, 'user_data' => $userData, 'medals' => $medals]);
}
static function afficher_texte_histoire($code, $title, $comment) {
Twig::$twig->display('story.twig', compact('code', 'title', 'comment'));
}
static function valider_formulaire_inscription($user, $pass, $pass2) {
$erreur=null;
if (isset($user)) {
if (preg_match('#^[-_A-Za-z0-9]{3,15}$#', $user) === 0) {
return UTILISATEUR_INVALIDE;
}
if (strlen($pass) <6) {
return MOT_DE_PASSE_6_CHAR_ERREUR;
}
if ($pass !== $pass2) {
return MOTS_DE_PASSE_DIFFERENTS;
}
if (DM_Core::$d->user_exists($user)) {
return UTILISATEUR_EXISTANT;
}
}
else {
return UTILISATEUR_INVALIDE;
}
return null;
}
static function partager_page() {
?><div class="a2a_kit a2a_kit_size_32 a2a_default_style"
data-a2a-url="<?=Edge::get_lien_bibliotheque($_SESSION['user'])?>"
data-a2a-title="Ma bibliothèque DucksManager">
<a class="noborder a2a_button_email"></a>
<a class="noborder a2a_button_facebook"></a>
<a class="noborder a2a_button_twitter"></a>
<a class="noborder a2a_button_google_plus"></a>
</div><?php
}
public static function afficher_stats_collection_court($nb_pays, $nb_magazines, $nb_numeros) {
echo sprintf(
'%s %s.<br />%s %s %s %s %s.',
$nb_numeros,
NUMEROS,
POSSESSION_MAGAZINES_2,
$nb_magazines,
POSSESSION_MAGAZINES_3,
$nb_pays,
PAYS
);
}
public static function get_medailles($points)
{
$points_et_niveaux = [];
foreach ($points as $contribution => $points_contribution) {
$points_et_niveaux[$contribution] = ['Cpt' => $points_contribution, 'Niveau' => 0];
foreach (self::$niveaux_medailles[$contribution] as $niveau => $points_min) {
if ($points_contribution >= $points_min) {
$points_et_niveaux[$contribution]['Niveau'] = $niveau;
}
}
}
return $points_et_niveaux;
}
public static function afficher_statut_connexion($est_connecte) {
?><div id="login">
<a class="logo_petit" href="<?= isset($_SESSION['user']) ? '/?action=gerer' : '/' ?>"><img src="/logo_nom.jpg" /></a>
<div id="texte_connecte"><?php
if ($est_connecte) {?>
<img id="light" src="vert.png" alt="O" />
<span><?=$_SESSION['user']?></span><?php
}
?>
</div>
</div><?php
}
}
?>