| 1 |
<?php |
| 2 |
/* Copyright 2014 Baptiste Placé |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License, version 2, as |
| 6 |
published by the Free Software Foundation. |
| 7 |
|
| 8 |
This program is distributed in the hope that it will be useful, |
| 9 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
GNU General Public License for more details. |
| 12 |
|
| 13 |
You should have received a copy of the GNU General Public License |
| 14 |
along with this program; if not, write to the Free Software |
| 15 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 |
*/ |
| 17 |
/** |
| 18 |
* Class: iCalendrier |
| 19 |
* Description: Un simple calendrier qui affiche des infos du jour, comme le numéro de semaine, la date, la fête du jour et la phase de lune. |
| 20 |
* Version: 1.0 |
| 21 |
* Author: Baptiste Placé |
| 22 |
* Author URI: https://icalendrier.fr/ |
| 23 |
* License: GNU General Public License, version 2 |
| 24 |
*/ |
| 25 |
|
| 26 |
require_once dirname(__FILE__) . "/FeteDuJour.php"; |
| 27 |
|
| 28 |
|
| 29 |
class Icalendrier |
| 30 |
{ |
| 31 |
|
| 32 |
protected $nameDay; |
| 33 |
|
| 34 |
protected $lang; |
| 35 |
|
| 36 |
protected $langs = array( |
| 37 |
"fr", |
| 38 |
"en", |
| 39 |
"es", |
| 40 |
"pt", |
| 41 |
"it", |
| 42 |
"de", |
| 43 |
"pt-BR", |
| 44 |
"ro", |
| 45 |
); |
| 46 |
|
| 47 |
protected $siteUrls = array( |
| 48 |
'fr' => "https://icalendrier.fr/", |
| 49 |
'en' => "http://icalendars.net/", |
| 50 |
'es' => "http://icalendario.net/", |
| 51 |
'pt' => "http://icalendario.pt/", |
| 52 |
'pt-BR' => "http://icalendario.br.com/", |
| 53 |
'it' => "http://icalendario.it/", |
| 54 |
'de' => "http://ikalender.org/", |
| 55 |
'ro' => "https://www.noutati-ortodoxe.ro/calendar-ortodox/", |
| 56 |
); |
| 57 |
|
| 58 |
protected $siteLabels = array( |
| 59 |
'fr' => "iCalendrier.fr", |
| 60 |
'en' => "iCalendars.net", |
| 61 |
'es' => "iCalendario.net", |
| 62 |
'pt' => "iCalendario.pt", |
| 63 |
'pt-BR' => "iCalendario.br.com", |
| 64 |
'it' => "iCalendario.it", |
| 65 |
'de' => "iKalender.org", |
| 66 |
'ro' => "noutati-ortodoxe.ro", |
| 67 |
); |
| 68 |
|
| 69 |
protected $todayLabels = array( |
| 70 |
'fr' => "Aujourd'hui", |
| 71 |
'en' => "Today", |
| 72 |
'es' => "Hoy en día", |
| 73 |
'pt' => "Hoje", |
| 74 |
'pt-BR' => "Hoje", |
| 75 |
'it' => "Oggi", |
| 76 |
'de' => "Heute", |
| 77 |
'ro' => "Astăzi", |
| 78 |
); |
| 79 |
|
| 80 |
protected $localDays = array( |
| 81 |
'fr' => array( |
| 82 |
'Lundi', |
| 83 |
'Mardi', |
| 84 |
'Mercredi', |
| 85 |
'Jeudi', |
| 86 |
'Vendredi', |
| 87 |
'Samedi', |
| 88 |
'Dimanche', |
| 89 |
), |
| 90 |
'en' => array( |
| 91 |
'Monday', |
| 92 |
'Tuesday', |
| 93 |
'Wednesday', |
| 94 |
'Thursday', |
| 95 |
'Friday', |
| 96 |
'Saturday', |
| 97 |
'Sunday', |
| 98 |
), |
| 99 |
'es' => array( |
| 100 |
'Lunes', |
| 101 |
'Martes', |
| 102 |
'Miércoles', |
| 103 |
'Jueves', |
| 104 |
'Viernes', |
| 105 |
'Sábado', |
| 106 |
'Domingo', |
| 107 |
), |
| 108 |
'pt' => array( |
| 109 |
'Segunda-feira', |
| 110 |
'Terca-feira', |
| 111 |
'Quarta-feira', |
| 112 |
'Quinta-feira', |
| 113 |
'Sexta-feira', |
| 114 |
'Sábado', |
| 115 |
'Domingo', |
| 116 |
), |
| 117 |
'pt-BR' => array( |
| 118 |
'Segunda-feira', |
| 119 |
'Terca-feira', |
| 120 |
'Quarta-feira', |
| 121 |
'Quinta-feira', |
| 122 |
'Sexta-feira', |
| 123 |
'Sábado', |
| 124 |
'Domingo', |
| 125 |
), |
| 126 |
'it' => array( |
| 127 |
'Lunedí', |
| 128 |
'Martedí', |
| 129 |
'Mercoledí', |
| 130 |
'Giovedì', |
| 131 |
'Venerdí', |
| 132 |
'Sabato', |
| 133 |
'Domenica', |
| 134 |
), |
| 135 |
'de' => array( |
| 136 |
'Montag', |
| 137 |
'Dienstag', |
| 138 |
'Mittwoch', |
| 139 |
'Donnerstag', |
| 140 |
'Freitag', |
| 141 |
'Samstag', |
| 142 |
'Sonntag', |
| 143 |
), |
| 144 |
'ro' => array( |
| 145 |
'Luni', |
| 146 |
'Marți', |
| 147 |
'Miercuri', |
| 148 |
'Joi', |
| 149 |
'Vineri', |
| 150 |
'Sâmbătă', |
| 151 |
'Duminică', |
| 152 |
), |
| 153 |
); |
| 154 |
|
| 155 |
protected $shortLocalDays = array( |
| 156 |
'fr' => array( |
| 157 |
'Lundi', |
| 158 |
'Mardi', |
| 159 |
'Mercredi', |
| 160 |
'Jeudi', |
| 161 |
'Vendredi', |
| 162 |
'Samedi', |
| 163 |
'Dimanche', |
| 164 |
), |
| 165 |
'en' => array( |
| 166 |
'Monday', |
| 167 |
'Tuesday', |
| 168 |
'Wednesday', |
| 169 |
'Thursday', |
| 170 |
'Friday', |
| 171 |
'Saturday', |
| 172 |
'Sunday', |
| 173 |
), |
| 174 |
'es' => array( |
| 175 |
'Lunes', |
| 176 |
'Martes', |
| 177 |
'Miércoles', |
| 178 |
'Jueves', |
| 179 |
'Viernes', |
| 180 |
'Sábado', |
| 181 |
'Domingo', |
| 182 |
), |
| 183 |
'pt' => array( |
| 184 |
'Seg.-feira', |
| 185 |
'Terca-feira', |
| 186 |
'Quarta-feira', |
| 187 |
'Quinta-feira', |
| 188 |
'Sexta-feira', |
| 189 |
'Sábado', |
| 190 |
'Domingo', |
| 191 |
), |
| 192 |
'pt-BR' => array( |
| 193 |
'Seg.-feira', |
| 194 |
'Terca-feira', |
| 195 |
'Quarta-feira', |
| 196 |
'Quinta-feira', |
| 197 |
'Sexta-feira', |
| 198 |
'Sábado', |
| 199 |
'Domingo', |
| 200 |
), |
| 201 |
'it' => array( |
| 202 |
'Lunedí', |
| 203 |
'Martedí', |
| 204 |
'Mercoledí', |
| 205 |
'Giovedì', |
| 206 |
'Venerdí', |
| 207 |
'Sabato', |
| 208 |
'Domenica', |
| 209 |
), |
| 210 |
'de' => array( |
| 211 |
'Montag', |
| 212 |
'Dienstag', |
| 213 |
'Mittwoch', |
| 214 |
'Donnerstag', |
| 215 |
'Freitag', |
| 216 |
'Samstag', |
| 217 |
'Sonntag', |
| 218 |
), |
| 219 |
'ro' => array( |
| 220 |
'Luni', |
| 221 |
'Marți', |
| 222 |
'Miercuri', |
| 223 |
'Joi', |
| 224 |
'Vineri', |
| 225 |
'Sâmbătă', |
| 226 |
'Duminică', |
| 227 |
), |
| 228 |
); |
| 229 |
|
| 230 |
protected $weekLabels = array( |
| 231 |
'fr' => "Semaine", |
| 232 |
'en' => "Week", |
| 233 |
'es' => "Semana", |
| 234 |
'pt' => "Semana", |
| 235 |
'pt-BR' => "Semana", |
| 236 |
'it' => "Settimana", |
| 237 |
'de' => "Woche", |
| 238 |
'ro' => "Săptămâna", |
| 239 |
); |
| 240 |
|
| 241 |
protected $shortWeekLabels = array( |
| 242 |
'fr' => "Sem.", |
| 243 |
'en' => "Week", |
| 244 |
'es' => "Sem.", |
| 245 |
'pt' => "Sem.", |
| 246 |
'pt-BR' => "Sem.", |
| 247 |
'it' => "Sett.", |
| 248 |
'de' => "Wo.", |
| 249 |
'ro' => "Săpt.", |
| 250 |
); |
| 251 |
|
| 252 |
protected $shortMonthLabels = array( |
| 253 |
'fr' => array( |
| 254 |
'Jan.', |
| 255 |
'Fév.', |
| 256 |
'Mars', |
| 257 |
'Avr.', |
| 258 |
'Mai', |
| 259 |
'Juin', |
| 260 |
'Juil.', |
| 261 |
'Août', |
| 262 |
'Sep.', |
| 263 |
'Oct.', |
| 264 |
'Nov.', |
| 265 |
'Déc.' |
| 266 |
), |
| 267 |
'en' => array( |
| 268 |
'Jan.', |
| 269 |
'Feb.', |
| 270 |
'Mar.', |
| 271 |
'Apr.', |
| 272 |
'May', |
| 273 |
'June', |
| 274 |
'July', |
| 275 |
'Aug.', |
| 276 |
'Sep.', |
| 277 |
'Oct.', |
| 278 |
'Nov.', |
| 279 |
'Dec.' |
| 280 |
), |
| 281 |
'es' => array( |
| 282 |
'Ene.', |
| 283 |
'Feb.', |
| 284 |
'Mar.', |
| 285 |
'Abril', |
| 286 |
'Mayo', |
| 287 |
'Junio', |
| 288 |
'Julio', |
| 289 |
'Ago.', |
| 290 |
'Sep.', |
| 291 |
'Oct.', |
| 292 |
'Nov.', |
| 293 |
'Dic.' |
| 294 |
), |
| 295 |
'pt' => array( |
| 296 |
'Jan.', |
| 297 |
'Fev.', |
| 298 |
'Mar.', |
| 299 |
'Abr.', |
| 300 |
'Maio', |
| 301 |
'Jun.', |
| 302 |
'Jul.', |
| 303 |
'Ago.', |
| 304 |
'Set.', |
| 305 |
'Out.', |
| 306 |
'Nov.', |
| 307 |
'Dez.' |
| 308 |
), |
| 309 |
'pt-BR' => array( |
| 310 |
'Jan.', |
| 311 |
'Fev.', |
| 312 |
'Mar.', |
| 313 |
'Abr.', |
| 314 |
'Maio', |
| 315 |
'Jun.', |
| 316 |
'Jul.', |
| 317 |
'Ago.', |
| 318 |
'Set.', |
| 319 |
'Out.', |
| 320 |
'Nov.', |
| 321 |
'Dez.' |
| 322 |
), |
| 323 |
'it' => array( |
| 324 |
'Gen.', |
| 325 |
'Feb.', |
| 326 |
'Mar.', |
| 327 |
'Apr.', |
| 328 |
'Mag.', |
| 329 |
'Giu.', |
| 330 |
'Lug.', |
| 331 |
'Ago.', |
| 332 |
'Set.', |
| 333 |
'Ott.', |
| 334 |
'Nov.', |
| 335 |
'Dic.' |
| 336 |
), |
| 337 |
'de' => array( |
| 338 |
'Jan.', |
| 339 |
'Feb.', |
| 340 |
'März', |
| 341 |
'Apr.', |
| 342 |
'Mai', |
| 343 |
'Juni', |
| 344 |
'Juli', |
| 345 |
'Aug.', |
| 346 |
'Sep.', |
| 347 |
'Okt.', |
| 348 |
'Nov.', |
| 349 |
'Dez.' |
| 350 |
), |
| 351 |
'ro' => array( |
| 352 |
'Ian.', |
| 353 |
'Feb.', |
| 354 |
'Mar.', |
| 355 |
'Apr.', |
| 356 |
'Mai', |
| 357 |
'Iun.', |
| 358 |
'Iul.', |
| 359 |
'Aug.', |
| 360 |
'Sep.', |
| 361 |
'Oct.', |
| 362 |
'Nov.', |
| 363 |
'Dec.' |
| 364 |
), |
| 365 |
); |
| 366 |
|
| 367 |
protected $monthLabels = array( |
| 368 |
'fr' => array( |
| 369 |
'Janvier', |
| 370 |
'Février', |
| 371 |
'Mars', |
| 372 |
'Avril', |
| 373 |
'Mai', |
| 374 |
'Juin', |
| 375 |
'Juillet', |
| 376 |
'Août', |
| 377 |
'Septembre', |
| 378 |
'Octobre', |
| 379 |
'Novembre', |
| 380 |
'Décembre' |
| 381 |
), |
| 382 |
'en' => array( |
| 383 |
'January', |
| 384 |
'February', |
| 385 |
'March', |
| 386 |
'April', |
| 387 |
'May', |
| 388 |
'June', |
| 389 |
'July', |
| 390 |
'August', |
| 391 |
'September', |
| 392 |
'October', |
| 393 |
'November', |
| 394 |
'December' |
| 395 |
), |
| 396 |
'es' => array( |
| 397 |
'Enero', |
| 398 |
'Febrero', |
| 399 |
'Marzo', |
| 400 |
'Abril', |
| 401 |
'Mayo', |
| 402 |
'Junio', |
| 403 |
'Julio', |
| 404 |
'Agosto', |
| 405 |
'Septiembre', |
| 406 |
'Octubre', |
| 407 |
'Noviembre', |
| 408 |
'Diciembre' |
| 409 |
), |
| 410 |
'pt' => array( |
| 411 |
'Janeiro', |
| 412 |
'Fevereiro', |
| 413 |
'Março', |
| 414 |
'Abril', |
| 415 |
'Maio', |
| 416 |
'Junho', |
| 417 |
'Julho', |
| 418 |
'Agosto', |
| 419 |
'Setembro', |
| 420 |
'Outubro', |
| 421 |
'Novembro', |
| 422 |
'Dezembro' |
| 423 |
), |
| 424 |
'pt-BR' => array( |
| 425 |
'Janeiro', |
| 426 |
'Fevereiro', |
| 427 |
'Março', |
| 428 |
'Abril', |
| 429 |
'Maio', |
| 430 |
'Junho', |
| 431 |
'Julho', |
| 432 |
'Agosto', |
| 433 |
'Setembro', |
| 434 |
'Outubro', |
| 435 |
'Novembro', |
| 436 |
'Dezembro' |
| 437 |
), |
| 438 |
'it' => array( |
| 439 |
'Gennaio', |
| 440 |
'Febbraio', |
| 441 |
'Marzo', |
| 442 |
'Aprile', |
| 443 |
'Maggio', |
| 444 |
'Giugno', |
| 445 |
'Luglio', |
| 446 |
'Agosto', |
| 447 |
'Settembre', |
| 448 |
'Ottobre', |
| 449 |
'Novembre', |
| 450 |
'Dicembre' |
| 451 |
), |
| 452 |
'de' => array( |
| 453 |
'Januar', |
| 454 |
'Februar', |
| 455 |
'März', |
| 456 |
'April', |
| 457 |
'Mai', |
| 458 |
'Juni', |
| 459 |
'Juli', |
| 460 |
'August', |
| 461 |
'September', |
| 462 |
'Oktober', |
| 463 |
'November', |
| 464 |
'Dezember' |
| 465 |
), |
| 466 |
'ro' => array( |
| 467 |
'Ianuarie', |
| 468 |
'Februarie', |
| 469 |
'Martie', |
| 470 |
'Aprilie', |
| 471 |
'Mai', |
| 472 |
'Iunie', |
| 473 |
'Iulie', |
| 474 |
'August', |
| 475 |
'Septembrie', |
| 476 |
'Octombrie', |
| 477 |
'Noiembrie', |
| 478 |
'Decembrie' |
| 479 |
), |
| 480 |
); |
| 481 |
|
| 482 |
protected $localMoonPhases = array( |
| 483 |
'fr' => array( |
| 484 |
'New Moon' => 'Nouvelle lune', |
| 485 |
'Waxing Crescent' => 'Premier croissant', |
| 486 |
'First Quarter' => 'Premier quartier', |
| 487 |
'Waxing Gibbous' => 'Gibbeuse croissante', |
| 488 |
'Full Moon' => 'Pleine lune', |
| 489 |
'Waning Gibbous' => 'Gibbeuse décroissante', |
| 490 |
'Third Quarter' => 'Dernier quartier', |
| 491 |
'Waning Crescent' => 'Dernier croissant', |
| 492 |
), |
| 493 |
'en' => array( |
| 494 |
'New Moon' => 'New Moon', |
| 495 |
'Waxing Crescent' => 'Waxing Crescent', |
| 496 |
'First Quarter' => 'First Quarter', |
| 497 |
'Waxing Gibbous' => 'Waxing Gibbous', |
| 498 |
'Full Moon' => 'Full Moon', |
| 499 |
'Waning Gibbous' => 'Waning Gibbous', |
| 500 |
'Third Quarter' => 'Third Quarter', |
| 501 |
'Waning Crescent' => 'Waning Crescent', |
| 502 |
), |
| 503 |
'es' => array( |
| 504 |
'New Moon' => 'Luna Nueva', |
| 505 |
'Waxing Crescent' => 'Luna Nueva Visible', |
| 506 |
'First Quarter' => 'Cuarto Creciente', |
| 507 |
'Waxing Gibbous' => 'Luna Gibosa Creciente', |
| 508 |
'Full Moon' => 'Luna Llena', |
| 509 |
'Waning Gibbous' => 'Luna Gibosa Menguante', |
| 510 |
'Third Quarter' => 'Cuarto Menguante', |
| 511 |
'Waning Crescent' => 'Luna Menguante', |
| 512 |
), |
| 513 |
'pt' => array( |
| 514 |
'New Moon' => 'Lua nova', |
| 515 |
'Waxing Crescent' => 'Lua crescente', |
| 516 |
'First Quarter' => 'Quarto Crescente', |
| 517 |
'Waxing Gibbous' => 'Lua crescente convexa', |
| 518 |
'Full Moon' => 'Lua Cheia', |
| 519 |
'Waning Gibbous' => 'Lua minguante convexa', |
| 520 |
'Third Quarter' => 'Quarto Minguante', |
| 521 |
'Waning Crescent' => 'Lua minguante', |
| 522 |
), |
| 523 |
'pt-BR' => array( |
| 524 |
'New Moon' => 'Lua nova', |
| 525 |
'Waxing Crescent' => 'Lua crescente', |
| 526 |
'First Quarter' => 'Quarto Crescente', |
| 527 |
'Waxing Gibbous' => 'Lua crescente convexa', |
| 528 |
'Full Moon' => 'Lua Cheia', |
| 529 |
'Waning Gibbous' => 'Lua minguante convexa', |
| 530 |
'Third Quarter' => 'Quarto Minguante', |
| 531 |
'Waning Crescent' => 'Lua minguante', |
| 532 |
), |
| 533 |
'it' => array( |
| 534 |
'New Moon' => 'Luna nuova', |
| 535 |
'Waxing Crescent' => 'Luna crescente', |
| 536 |
'First Quarter' => 'Primo quarto', |
| 537 |
'Waxing Gibbous' => 'Gibbosa crescente', |
| 538 |
'Full Moon' => 'Luna piena', |
| 539 |
'Waning Gibbous' => 'Gibbosa calante', |
| 540 |
'Third Quarter' => 'Ultimo quarto', |
| 541 |
'Waning Crescent' => 'Luna calante', |
| 542 |
), |
| 543 |
'de' => array( |
| 544 |
'New Moon' => 'Neumond', |
| 545 |
'Waxing Crescent' => 'Erstes Viertel', |
| 546 |
'First Quarter' => 'Zunehmender Halbmond', |
| 547 |
'Waxing Gibbous' => 'Zweites Viertel', |
| 548 |
'Full Moon' => 'Vollmond', |
| 549 |
'Waning Gibbous' => 'Drittes Viertel', |
| 550 |
'Third Quarter' => 'Abnehmender Halbmond', |
| 551 |
'Waning Crescent' => 'Letztes Viertel', |
| 552 |
), |
| 553 |
'ro' => array( |
| 554 |
'New Moon' => 'Lună nouă', |
| 555 |
'Waxing Crescent' => 'Prima creștere', |
| 556 |
'First Quarter' => 'Primul pătrar', |
| 557 |
'Waxing Gibbous' => 'Lună în creștere', |
| 558 |
'Full Moon' => 'Lună plină', |
| 559 |
'Waning Gibbous' => 'Lună în descreștere', |
| 560 |
'Third Quarter' => 'Al treilea pătrar', |
| 561 |
'Waning Crescent' => 'Ultima creștere', |
| 562 |
), |
| 563 |
); |
| 564 |
|
| 565 |
|
| 566 |
public function __construct($lang = 'en', $timezone = 0) |
| 567 |
{ |
| 568 |
if ( ! in_array($lang, $this->langs)) { |
| 569 |
$this->lang = "en"; // Default En |
| 570 |
} else { |
| 571 |
$this->lang = $lang; |
| 572 |
} |
| 573 |
|
| 574 |
if (('0' != $timezone) and (function_exists('date_default_timezone_set'))) { |
| 575 |
date_default_timezone_set($timezone); |
| 576 |
} |
| 577 |
|
| 578 |
$this->nameDay = new NameDay(); |
| 579 |
} |
| 580 |
|
| 581 |
/** |
| 582 |
* @param array $parameters showLink, bgColor, style |
| 583 |
* |
| 584 |
* @return string |
| 585 |
*/ |
| 586 |
public function iCalendrierComp($parameters = []) |
| 587 |
{ |
| 588 |
$html = ''; |
| 589 |
|
| 590 |
$showLink = isset($parameters['showLink']) ? (bool)$parameters['showLink'] : false; |
| 591 |
$bgColor = isset($parameters['bgColor']) ? $parameters['bgColor'] : false; |
| 592 |
$styleClassname = isset($parameters['style']) && 'default' !== $parameters['style'] ? ' ' . $parameters['style'] : ''; |
| 593 |
|
| 594 |
$html .= '<div class="icalComp' . $styleClassname . '">'; |
| 595 |
$html .= '<div class="ccomp">'; |
| 596 |
if ($bgColor) { |
| 597 |
$html .= ' <div class="cheight" style="background:' . $bgColor . ' !important;">'; |
| 598 |
} else { |
| 599 |
$html .= ' <div class="cheight">'; |
| 600 |
} |
| 601 |
|
| 602 |
$html .= ' <div class="ctitle">'; |
| 603 |
if ($showLink) { |
| 604 |
$html .= ' <a href="' . $this->siteUrls[$this->lang] . '">' . $this->todayLabels[$this->lang] . '</a>'; |
| 605 |
} else { |
| 606 |
$html .= '<a href="javascript:void(0)">' . $this->todayLabels[$this->lang] . '</a>'; |
| 607 |
} |
| 608 |
$html .= ' </div>'; |
| 609 |
|
| 610 |
$html .= ' <div class="cephem">'; |
| 611 |
$html .= ' <div class="today">'; |
| 612 |
$html .= ' <span class="daysem">'; |
| 613 |
|
| 614 |
|
| 615 |
$html .= $this->shortLocalDays[$this->lang][date('N') - 1]; |
| 616 |
|
| 617 |
$html .= " - "; |
| 618 |
|
| 619 |
$html .= $this->shortWeekLabels[$this->lang] . " " . ltrim(date('W'), '0'); |
| 620 |
|
| 621 |
$html .= ' </span>'; |
| 622 |
|
| 623 |
$day = date('d'); |
| 624 |
$daydig1 = substr($day, 0, 1); |
| 625 |
$daydig2 = substr($day, 1, 1); |
| 626 |
|
| 627 |
$html .= ' <span class="day">'; |
| 628 |
$html .= ' <span class="daydig1">'; |
| 629 |
$html .= $daydig1; |
| 630 |
$html .= ' </span>'; |
| 631 |
$html .= ' <span class="daydig1">'; |
| 632 |
$html .= $daydig2; |
| 633 |
$html .= ' </span>'; |
| 634 |
$html .= ' </span>'; |
| 635 |
|
| 636 |
|
| 637 |
$html .= ' <span class="month">'; |
| 638 |
|
| 639 |
$html .= $this->shortMonthLabels[$this->lang][date('n') - 1]; |
| 640 |
|
| 641 |
$html .= ' </span>'; |
| 642 |
$html .= ' <span class="fete">'; |
| 643 |
|
| 644 |
$html .= $this->nameDay->today($this->lang); |
| 645 |
|
| 646 |
$html .= ' </span>'; |
| 647 |
$html .= ' <span class="moon">'; |
| 648 |
|
| 649 |
$html .= $this->getMoonSide($this->lang); |
| 650 |
|
| 651 |
$html .= ' </span>'; |
| 652 |
$html .= ' </div>'; |
| 653 |
$html .= ' </div>'; |
| 654 |
$html .= ' </div>'; |
| 655 |
$html .= '</div>'; |
| 656 |
$html .= '</div>'; |
| 657 |
|
| 658 |
return $html; |
| 659 |
} |
| 660 |
|
| 661 |
/** |
| 662 |
* Wide calendar |
| 663 |
* |
| 664 |
* @param $parameters |
| 665 |
* |
| 666 |
* @return string |
| 667 |
*/ |
| 668 |
public function iCalendrierWide($parameters) |
| 669 |
{ |
| 670 |
$html = ""; |
| 671 |
|
| 672 |
$showLink = isset($parameters['showLink']) ? (bool)$parameters['showLink'] : false; |
| 673 |
$bgColor = isset($parameters['bgColor']) ? $parameters['bgColor'] : false; |
| 674 |
$styleClassname = isset($parameters['style']) && 'default' !== $parameters['style'] ? ' ' . $parameters['style'] : ''; |
| 675 |
|
| 676 |
if ($bgColor) { |
| 677 |
$html .= '<div class="icalWide' . $styleClassname . '" style="background:' . $bgColor . ' !important;">'; |
| 678 |
} else { |
| 679 |
$html .= '<div class="icalWide' . $styleClassname . '">'; |
| 680 |
} |
| 681 |
|
| 682 |
$html .= '<div class="today">'; |
| 683 |
|
| 684 |
$html .= '<span class="ctitle">'; |
| 685 |
if ($showLink) { |
| 686 |
$html .= '<a href="' . $this->siteUrls[$this->lang] . '">' . $this->todayLabels[$this->lang] . '</a>'; |
| 687 |
} else { |
| 688 |
$html .= '<a href="javascript:void(0)">' . $this->todayLabels[$this->lang] . '</a>'; |
| 689 |
} |
| 690 |
$html .= '</span>'; |
| 691 |
|
| 692 |
|
| 693 |
$html .= '<span class="day">'; |
| 694 |
|
| 695 |
$html .= $this->shortLocalDays[$this->lang][date('N') - 1]; |
| 696 |
|
| 697 |
$html .= '</span>'; |
| 698 |
|
| 699 |
$html .= '<span class="num">' . date('d') . '</span>'; |
| 700 |
|
| 701 |
$html .= '<span class="month">'; |
| 702 |
|
| 703 |
$html .= $this->monthLabels[$this->lang][date('n') - 1]; |
| 704 |
$html .= '</span>'; |
| 705 |
|
| 706 |
$html .= '<span class="more">'; |
| 707 |
$html .= $this->weekLabels[$this->lang] . " " . ltrim(date('W'), '0'); |
| 708 |
|
| 709 |
$html .= ' | '; |
| 710 |
|
| 711 |
$html .= $this->nameDay->today($this->lang); |
| 712 |
$html .= '</span>'; |
| 713 |
|
| 714 |
$html .= '<span class="moon">'; |
| 715 |
|
| 716 |
$html .= $this->getMoonSide($this->lang); |
| 717 |
|
| 718 |
$html .= '</span>'; |
| 719 |
|
| 720 |
$html .= '</div>'; |
| 721 |
$html .= '</div>'; |
| 722 |
|
| 723 |
return $html; |
| 724 |
} |
| 725 |
|
| 726 |
/** |
| 727 |
* Select the moon character |
| 728 |
* @return string |
| 729 |
*/ |
| 730 |
protected function getMoonSide() |
| 731 |
{ |
| 732 |
require_once(dirname(__FILE__) . '/Solaris/MoonPhase.php'); |
| 733 |
|
| 734 |
$now = new DateTime(); |
| 735 |
|
| 736 |
if (intval($now->format("G")) >= 7) { |
| 737 |
// 7 heure du matin ou +, on prend la prochaine nuit à minuit |
| 738 |
$now->setTime(0, 0); // Minuit |
| 739 |
$now->add(new DateInterval("P1D")); |
| 740 |
$moon = new Solaris_MoonPhase($now->format("U")); |
| 741 |
} else { |
| 742 |
// avant 7 heures du matin, on prend la nuit en cours ou presque finie |
| 743 |
$now->setTime(0, 0); // Minuit |
| 744 |
$moon = new Solaris_MoonPhase($now->format("U")); |
| 745 |
} |
| 746 |
|
| 747 |
$phase = $moon->phase(); |
| 748 |
|
| 749 |
// Utilisation de la font |
| 750 |
|
| 751 |
// 29 "phases" pour correspondre à la font |
| 752 |
$moonCharacters = array(0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', '@', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0); |
| 753 |
|
| 754 |
$totalCharacters = count($moonCharacters); |
| 755 |
$step = 1 / ($totalCharacters - 1); |
| 756 |
|
| 757 |
if ($phase < $step / 2) { |
| 758 |
$index = 0; |
| 759 |
} elseif ($phase > (1 - $step / 2)) { |
| 760 |
$index = 28; |
| 761 |
} else { |
| 762 |
for ($i = 1; $i <= 27; $i++) { |
| 763 |
// Passage dans l'interval qui entoure l'illustration |
| 764 |
if ($phase >= ($step / 2 + ($i - 1) * $step) && $phase < ($step / 2 + $i * $step)) { |
| 765 |
$index = $i; |
| 766 |
} |
| 767 |
} |
| 768 |
} |
| 769 |
|
| 770 |
$html = '<span class="phase">' . $moonCharacters[$index] . '</span>'; |
| 771 |
$html .= $this->localMoonPhases[$this->lang][$moon->phase_name()]; |
| 772 |
|
| 773 |
return $html; |
| 774 |
} |
| 775 |
|
| 776 |
} |
| 777 |
|
| 778 |
|
| 779 |
|