19 require_once
'OPiQuotations/log.inc';
24 ini_set(
'display_errors',
'stdout');
25 ini_set(
'display_startup_errors', 1);
26 ini_set(
'html_errors', 1);
30 assert_options(ASSERT_ACTIVE,
true);
31 assert_options(ASSERT_WARNING,
true);
32 assert_options(ASSERT_BAIL,
true);
37 ini_set(
'display_errors',
'stderr');
38 ini_set(
'display_startup_errors', 0);
39 ini_set(
'html_errors', 0);
43 assert_options(ASSERT_ACTIVE,
false);
44 assert_options(ASSERT_WARNING,
false);
45 assert_options(ASSERT_BAIL,
false);
47 set_error_handler(
'\OPiQuotations\error_handler');
52 mb_internal_encoding(
'UTF-8');
53 mb_regex_encoding(
'UTF-8');
54 mb_http_output(
'UTF-8');
55 mb_detect_order(
'UTF-8');
60 assert(
'is_int($nb_quotations) && ($nb_quotations >= 0)');
65 return ceil($nb_quotations/$nb_by_page);
71 assert(
'is_int($nb_quotations) && ($nb_quotations >= 0)');
77 return $nb_by_page*($num_page - 1);
83 assert(
'is_int($n) && ($n >= 0)');
92 require_once
'OPiQuotations/OPiQuotations.inc';
102 'subject' =>
'sujet',
104 'translation' =>
'traduction',
105 'author' =>
'auteur',
106 'work' =>
'œuvre',
107 'nation' =>
'maxime');
108 $ALL_KEYS = array_merge(array_keys(
$LABELS), [
'id',
'all_marked',
'all',
'page',
'selection']);
111 'Twitter' =>
'Twitter - OPiCitationJour',
124 foreach ($_GET as $key=>$label) {
126 if ($key ===
'page') {
127 if ($label ===
'toutes') {
143 foreach (array(
'all',
'all_marked') as $key) {
144 if (isset($_params[$key])) {
151 foreach (
$params as $key=>$value) {
152 if ($value !== null) {
153 $params[$key] = preg_replace(
'/\.\.\./',
'…', # ellipsis
154 preg_replace(
'/\'/',
'’', # apostrophe
187 $ids = preg_replace(
'/(^[^0-9]+|[^0-9]+$)/',
'',
$param_value);
188 $ids = mb_split(
'[^\-0-9]+', $ids);
190 for (
$i = 0;
$i < count($ids);
$i++) {
192 $id = preg_replace(
'/(^[^0-9]+|[^0-9]+$)/',
'',
$id);
198 $a = mb_split(
'-',
$id);
202 $count_a = count($a);
204 for ($j = (
int)$a[0] + 1; $j <= (int)$a[$count_a - 1]; $j++) {
216 $ids = array_unique($ids, SORT_NUMERIC);
218 if ((count($ids) > 0) && ($ids[0] === 0)) {
225 if (count($ids) > 0) {
227 for (
$i = 0;
$i < count($ids) - 1;
$i++) {
228 if ($ids[
$i + 1] !== $ids[
$i] + 1) {
229 $a[] = ($first === $ids[
$i]
231 :
"$first-$ids[$i]");
232 $first = $ids[
$i + 1];
235 $a[] = ($first === $ids[
$i]
237 :
"$first-$ids[$i]");
247 $header =
'<strong>Numéro(s)</strong> '.implode(
', ', $a).
' : <strong>'.$nb_quotations.
'</strong> résultat'.
s($nb_quotations);
256 $header =
'<strong>Sujet</strong> "'.htmlspecialchars(
$param_value).
'" : <strong>'.$nb_quotations.
'</strong> résultat'.
s($nb_quotations);
263 $header =
'<strong>Texte</strong> "'.htmlspecialchars(
$param_value).
'" : <strong>'.$nb_quotations.
'</strong> résultat'.
s($nb_quotations);
270 $header =
'<strong>Auteur</strong> "'.htmlspecialchars(
$param_value).
'" : <strong>'.$nb_quotations.
'</strong> résultat'.
s($nb_quotations);
277 $header =
'<strong>Œuvre</strong> "'.htmlspecialchars(
$param_value).
'" : <strong>'.$nb_quotations.
'</strong> résultat'.
s($nb_quotations);
284 $header =
'<strong>Maxime</strong> "'.htmlspecialchars(
$param_value).
'" : <strong>'.$nb_quotations.
'</strong> résultat'.
s($nb_quotations);
291 $header =
'<strong>Traduction</strong> "'.htmlspecialchars(
$param_value).
'" : <strong>'.$nb_quotations.
'</strong> résultat'.
s($nb_quotations);
300 $SELECTION_LINKS = array(
'Facebook' =>
' postées sur la page Facebook <strong><a class="icon-Facebook monospace" href="https://www.facebook.com/1OPiCitationParJour">1OPiCitationParJour</a></strong>',
301 'Twitter' =>
' postées sur le compte Twitter <strong><a class="icon-Twitter monospace" href="https://twitter.com/OPiCitationJour">@OPiCitationJour</a></strong>',
302 'Web' =>
' ayant un lien vers le <strong><a class="icon-Web no-decoration">Web</a></strong>');
304 $header =
'Les <strong>'.$nb_quotations.
'</strong> citations'.$SELECTION_LINKS[
$param_value];
309 $header =
'Mes <strong>'.$nb_quotations.
'</strong> citations <strong class="mark">favorites</strong>';
314 $header =
'<strong>Toutes</strong> les '.$nb_quotations.
' citations';
318 $header =
'<strong>'.count($quots).
'</strong> citations choisies <strong>aléatoirement</strong>';
321 assert(
'count($quots) === $NB_FOR_RANDOM');
329 $keywords = [
'citation',
'citations',
'maxime',
'maximes',
'proverbe',
'proverbes',
'littérature',
'français'];
332 $title =
'OPiCitations n°'.$quots[0]->id().
' — Dictionnaire de citations';
334 $desc =
'OPiCitations n°'.$quots[0]->id().
' : 335 '.htmlspecialchars($quots[0]->to_text());
340 foreach ([$quots[0]->subject(),
341 ($quots[0]->is_maxim()
342 ? $quots[0]->nation()
343 : $quots[0]->author()), $quots[0]->work()] as $keyword) {
344 if ($keyword !== null) {
346 $a = explode(
' ', $keyword);
355 foreach ($a as $keyword) {
356 $keywords[] = htmlspecialchars($keyword);
369 $title =
'OPiCitations — Dictionnaire de citations';
371 $desc =
'Dictionnaire de citations.';
384 $url_site =
'http://'.$_SERVER[
'HTTP_HOST'].dirname($_SERVER[
'PHP_SELF']).
'/';
388 $url .=
'?id='.$quots[0]->id();
392 $url .=
'?'.$param_key;
393 if ($param_value !== null) {
394 $url .=
'='.rawurlencode($param_value);
402 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
404 <meta name=
"viewport" content=
"width=device-width, initial-scale=1">
406 <meta name=
"author" content=
"Olivier Pirson">
407 <meta name=
"description" content=
"<?php echo $desc; ?>">
408 <meta name=
"keywords" content=
"<?php echo implode(',', $keywords); ?>">
409 <meta name=
"keywords" lang=
"en" content=
"quotation,quotations,maxim,maxims,proverb,proverbs,literature,French">
411 <title><?php echo
$title; ?></title>
413 <link rel=
"stylesheet" type=
"text/css" href=
"/OPiCitations/public/css/style.min.css">
414 <style title=
"highlight"></style>
416 <script src=
"/OPiCitations/public/js/OPiQuotations.automatic-min.js" async=
"async"></script>
418 <link rel=
"icon" type=
"image/x-icon" href=
"/OPiCitations/favicon.ico">
420 <link rel=
"canonical" href=
"<?php echo $url; ?>">
422 <meta
property=
"og:image" content=
"<?php echo $url_site; ?>public/img/OPiQuotations<?php 424 $all_is_maxim = !empty($quots) || ($param_key === 'nation'); 427 foreach ($quots as $quot) { 428 if (!$quot->is_maxim()) { 429 $all_is_maxim = false; 439 unset($all_is_maxim); 442 <meta
property=
"og:description" content=
"<?php echo $desc_open_graph; ?>">
443 <meta
property=
"og:title" content=
"<?php echo $title; ?>">
444 <meta
property=
"og:type" content=
"website">
445 <meta
property=
"og:url" content=
"<?php echo $url; ?>">
447 <meta name=
"msapplication-TileColor" content=
"#fdfdd0">
448 <meta name=
"msapplication-square150x150logo" content=
"/OPiCitations/public/img/OPiQuotations-64x64-t.png">
456 foreach (
$LABELS as $key=>$label) {
457 if (isset(
$lists[$key])) {
458 echo
'<section id="list-', $key,
'" class="list" aria-haspopup="true"> 460 <div class="close">×</div> 461 <h2><span id="list-', $key,
'-nb"></span> ', mb_strtolower($label),
's</h2> 463 <div id="list-', $key,
'-container">Chargement…</div> 475 <nav
id=
"control-panel">
476 <div
id=
"control-panel-right-border"><div><span>→</span></div><div><span>→</span></div></div>
477 <div
id=
"control-panel-close" class=
"close">×</div>
479 <header
id=
"please-don-t-use-IE">
480 <p>Je vous en supplie,<br>utilisez un <i>vrai</i> navigateur !</p>
483 <strong><a href=
"https://www.mozilla.org/fr/firefox/">Firefox</a></strong>.
487 <form
class=
"big-buttons" action=
"#">
489 <li><button onclick=
"document.location.assign('./'); return false;"><?php echo
$NB_FOR_RANDOM; ?> choisies <strong>aléatoirement</strong></button></li>
490 <li><button name=
"all"><strong>Toutes</strong> les citations</button></li>
494 <li><button name=
"selection" value=
"Web" title=
"Toutes celles ayant un lien vers le Web"><span></span></button></li>
495 <li><button name=
"selection" value=
"Twitter" title=
"Toutes celles postées sur le compte Twitter"><span>❶</span></button></li>
496 <li><button name=
"selection" value=
"Facebook" title=
"Toutes celles postées sur la page Facebook"><span>❶</span></button></li>
497 <li><button name=
"all_marked" title=
"Mes favorites"><span></span></button></li>
508 foreach (
$LABELS as $key=>$label) {
509 echo
' <li class="', $key,
'"> 513 :
'ou ').
'<label for="', $key,
'">', $label,
'</label> : 515 if (isset(
$lists[$key])) {
516 echo
' <button class="list-open">liste ' 517 .(in_array($key, array(
'author',
'work'))
519 :
'de ').$label.
's</button> 524 <input id="', $key,
'" name="', $key,
'" type="search"', (isset(
$params[$key])
525 ?
' value="'.htmlspecialchars(
$params[$key]).
'"' 526 : null), ($key ===
'ids' 527 ?
' placeholder="Ex.: 260 ou 259-261 ou 260,3241"' 543 echo
' <button id="highlight-on-off" title="(Néglige certaines occurences utilisant certains caractères non-alphanumériques.)">Surligner</button>';
547 <a
class=
"go-bottom" href=
"#bottom"><span>↓</span></a>
548 <a
class=
"go-top" href=
"#top"><span>↑</span></a>
555 <h2
id=
"about-open">À propos de</h2>
556 <div aria-haspopup=
"true">
557 <div
id=
"about-close" class=
"close">×</div>
559 <a
class=
"no-decoration no-prefix" href=
"<?php echo $url_site; ?>">O<span
class=
"surname">Pi</span>Citations</a>
561 <p
class=
"right">version 03.00.00 — 24 octobre 2019</p>
564 Ensemble de citations pour l’essentiel jadis récoltées par mes soins au hasard de mes lectures.
567 (Accumulées dans un antique programme écrit en AMOS BASIC sur <a href=
"http://www.opimedia.be/DS/grenier/#Amiga">Amiga</a>,
568 et déjà réutilisées par ce vieux
569 <a href=
"http://www.opimedia.be/DS/grenier/#enre">programme</a>
570 écrit en C sous M$-DOS.)
573 Vous pouvez me contacter par e-mail pour me signaler toute erreur constatée,
574 ou pour toute autre raison :
575 <a rel=
"nofollow" class=
"URL" href=
"mailto:olivier.pirson.opi@gmail.com?subject=OPiCitations">olivier.pirson.opi@gmail.com</a>
578 <strong>❶</strong> citation choisie aléatoirement <strong>postée chaque matin</strong>
581 sur le compte Twitter
582 <a
class=
"icon-Twitter monospace" href=
"https://twitter.com/OPiCitationJour">@OPiCitationJour</a>
586 <a
class=
"icon-Facebook monospace" href=
"https://www.facebook.com/1OPiCitationParJour">1OPiCitationParJour</a>
591 Une version réduite de cette application Web n’affichant qu’une seule citation
592 (pouvant être utilisée en tant qu’<span
class=
"monospace"><iframe></span>
593 pour l’inclure dans une autre page Web) :
594 <strong><a
class=
"one-OPiQuotation" href=
"une-OPiCitation.php" target=
"_blank">❶une O<span
class=
"surname">Pi</span>Citation</a></strong>
597 Application Web écrite en <abbr>PHP</abbr>/MySQL/<abbr>HTML</abbr>5/Sass/JavaScript, sous licence libre <abbr lang=
"en" title=
"GNU General Public License">GPL</abbr>.
601 Sources complètes (avec le fichier de citations) sur Bitbucket :<br>
602 <strong><a lang=
"en" class=
"URL" href=
"https://bitbucket.org/OPiMedia/opiquotations">https:
604 <li><strong><a lang=
"en" href=
"http://www.opimedia.be/DS/webdev/PHP/OPiQuotations/docs/">Online <abbr>HTML</abbr> documentation</a></strong></li>
606 <div
class=
"sep ds-jf-opi">
607 D’autres citations sur mes sites :
609 <a href=
"http://www.opimedia.be/DS/citations/"><img src=
"/OPiCitations/public/img/DS-t.png" width=
"80" height=
"34" alt=
"[DS]"></a>
610 <a href=
"http://www.opimedia.be/JF/citations/"><img src=
"/OPiCitations/public/img/JF-t.png" width=
"41" height=
"34" alt=
"[JF]"></a>
611 <a href=
"http://www.opimedia.be/citations/"><img src=
"/OPiCitations/public/img/OPi-t.png" width=
"41" height=
"34" alt=
"[OPi]"></a>
616 <a
class=
"donate" href=
"http://www.opimedia.be/donate/"><img src=
"/OPiCitations/public/img/Faire-un-don-124x26-t.png" width=
"124" height=
"26" alt=
"[Faire un don]"></a>
617 <a
class=
"opi" href=
"http://www.opimedia.be/">Olivier <span
class=
"surname">Pirson</span> O<span
class=
"surname">Pi</span></a>
627 <a
class=
"no-decoration no-prefix" href=
"<?php echo $url_site; ?>"><span>O<span
class=
"surname">Pi</span>Citations</span></a>
637 <small>(sur <strong>'.$opiquotations->nb().
'</strong> citations)</small> 638 <div class="clear"></div> 643 global $nb_quotations;
652 $params = explode(
'&', $_SERVER[
'QUERY_STRING']);
653 $count_params = count(
$params);
654 for (
$i = 0;
$i < $count_params; ++
$i) {
655 if (preg_match(
'/^page=/',
$params[
$i])) {
664 echo
'<div class="page-links"> 667 <li><a href="?'.implode(
'&',
$params).
'">Toutes</a> ;</li> 673 for (
$i = 1;
$i <= $nb_page; ++
$i) {
682 echo (
$i === $num_page
683 ?
'<li class="selected"><a>'.
$i.
'</a></li> 685 :
'<li><a href="?'.implode(
'&',
$params).
'">'.
$i.
'</a></li> 701 foreach ($quots as
$quot) {
702 echo $quot->to_html(
$search,
true, null,
703 'h2',
'une-OPiCitation.php',
712 <nav
id=
"right-panel" aria-haspopup=
"true">
713 <a
class=
"go-top" href=
"#top"><span>↑</span></a>
714 <a
class=
"go-bottom" href=
"#bottom"><span>↓</span></a>
717 <div
id=
"bottom"></div>
if(!isset($_GET['no-link-OPiQuotations'])) endif
nb_to_nb_page($nb_quotations)
nb_to_offset($nb_quotations)
if(!empty($params)) $search
Class to get OPiQuotation and informations from the databse.
if($header !==null) $desc_open_graph
html_text_cut($html_text, $max_length, $hellip='…', $reduce=true)
If length of $html_text <= $max_length characters then return $html_text, else return $html_text cutt...