@@ -20,21 +20,21 @@ |
||
| 20 | 20 | * Retourne la liste des menus favoris par défaut ainsi que leur rang |
| 21 | 21 | */ |
| 22 | 22 | function inc_definir_menus_favoris_dist() { |
| 23 | - $liste = [ |
|
| 23 | + $liste = [ |
|
| 24 | 24 | |
| 25 | - // Menu Édition, |
|
| 26 | - 'auteurs' => 1, |
|
| 27 | - 'rubriques' => 2, |
|
| 28 | - 'articles' => 3, |
|
| 25 | + // Menu Édition, |
|
| 26 | + 'auteurs' => 1, |
|
| 27 | + 'rubriques' => 2, |
|
| 28 | + 'articles' => 3, |
|
| 29 | 29 | |
| 30 | - // Menu Maintenance |
|
| 31 | - 'admin_vider' => 1, |
|
| 30 | + // Menu Maintenance |
|
| 31 | + 'admin_vider' => 1, |
|
| 32 | 32 | |
| 33 | - // Menu Configurations |
|
| 34 | - 'configurer_identite' => 1, |
|
| 35 | - 'admin_plugin' => 2, |
|
| 33 | + // Menu Configurations |
|
| 34 | + 'configurer_identite' => 1, |
|
| 35 | + 'admin_plugin' => 2, |
|
| 36 | 36 | |
| 37 | - ]; |
|
| 37 | + ]; |
|
| 38 | 38 | |
| 39 | - return $liste; |
|
| 39 | + return $liste; |
|
| 40 | 40 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/texte'); |
@@ -19,105 +19,105 @@ discard block |
||
| 19 | 19 | // https://code.spip.net/@inc_plonger_dist |
| 20 | 20 | function inc_plonger_dist($id_rubrique, $idom = '', $list = [], $col = 1, $exclu = 0, $do = 'aff') { |
| 21 | 21 | |
| 22 | - if ($list) { |
|
| 23 | - $id_rubrique = $list[$col - 1]; |
|
| 24 | - } |
|
| 22 | + if ($list) { |
|
| 23 | + $id_rubrique = $list[$col - 1]; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - $ret = ''; |
|
| 26 | + $ret = ''; |
|
| 27 | 27 | |
| 28 | - # recherche les filles et petites-filles de la rubrique donnee |
|
| 29 | - # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 30 | - # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 31 | - # racine... sauf vers elle-meme ou sa propre branche) |
|
| 32 | - $ordre = []; |
|
| 33 | - $rub = []; |
|
| 28 | + # recherche les filles et petites-filles de la rubrique donnee |
|
| 29 | + # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 30 | + # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 31 | + # racine... sauf vers elle-meme ou sa propre branche) |
|
| 32 | + $ordre = []; |
|
| 33 | + $rub = []; |
|
| 34 | 34 | |
| 35 | - $res = sql_select( |
|
| 36 | - 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
|
| 37 | - 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
|
| 38 | - 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 35 | + $res = sql_select( |
|
| 36 | + 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
|
| 37 | + 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
|
| 38 | + 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 39 | 39 | AND rub1.id_rubrique!=' . sql_quote($exclu) . ' |
| 40 | 40 | AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')', |
| 41 | - '', |
|
| 42 | - '0+rub1.titre,rub1.titre' |
|
| 43 | - ); |
|
| 41 | + '', |
|
| 42 | + '0+rub1.titre,rub1.titre' |
|
| 43 | + ); |
|
| 44 | 44 | |
| 45 | - while ($row = sql_fetch($res)) { |
|
| 46 | - if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 47 | - $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 48 | - if ($row['id_parent'] == $id_rubrique) { |
|
| 49 | - $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 50 | - if ($row['langue_choisie'] != 'oui') { |
|
| 51 | - $t .= ' <small title="' |
|
| 52 | - . traduire_nom_langue($row['lang']) |
|
| 53 | - . '">[' . $row['lang'] . ']</small>'; |
|
| 54 | - } |
|
| 55 | - $ordre[$row['id_rubrique']] = $t; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - $next = isset($list[$col]) ? $list[$col] : 0; |
|
| 60 | - if ($ordre) { |
|
| 61 | - $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 62 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 63 | - $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 45 | + while ($row = sql_fetch($res)) { |
|
| 46 | + if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 47 | + $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 48 | + if ($row['id_parent'] == $id_rubrique) { |
|
| 49 | + $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 50 | + if ($row['langue_choisie'] != 'oui') { |
|
| 51 | + $t .= ' <small title="' |
|
| 52 | + . traduire_nom_langue($row['lang']) |
|
| 53 | + . '">[' . $row['lang'] . ']</small>'; |
|
| 54 | + } |
|
| 55 | + $ordre[$row['id_rubrique']] = $t; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + $next = isset($list[$col]) ? $list[$col] : 0; |
|
| 60 | + if ($ordre) { |
|
| 61 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 62 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 63 | + $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 64 | 64 | |
| 65 | - foreach ($ordre as $id => $titrebrut) { |
|
| 66 | - $titre = supprimer_numero($titrebrut); |
|
| 65 | + foreach ($ordre as $id => $titrebrut) { |
|
| 66 | + $titre = supprimer_numero($titrebrut); |
|
| 67 | 67 | |
| 68 | - $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 69 | - if (isset($rub[$id]['enfants'])) { |
|
| 70 | - $classe2 = " class='rub-ouverte'"; |
|
| 71 | - $url = "\nhref='$rec&id=$id'"; |
|
| 72 | - } else { |
|
| 73 | - $classe2 = $url = ''; |
|
| 74 | - $url = "\nhref='javascript:void(0)'"; |
|
| 75 | - } |
|
| 68 | + $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 69 | + if (isset($rub[$id]['enfants'])) { |
|
| 70 | + $classe2 = " class='rub-ouverte'"; |
|
| 71 | + $url = "\nhref='$rec&id=$id'"; |
|
| 72 | + } else { |
|
| 73 | + $classe2 = $url = ''; |
|
| 74 | + $url = "\nhref='javascript:void(0)'"; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $js_func = $do . '_selection_titre'; |
|
| 78 | - $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 79 | - . (!is_array($list) ? ' false' |
|
| 80 | - : "aff_selection_provisoire($id,$args)") |
|
| 77 | + $js_func = $do . '_selection_titre'; |
|
| 78 | + $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 79 | + . (!is_array($list) ? ' false' |
|
| 80 | + : "aff_selection_provisoire($id,$args)") |
|
| 81 | 81 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 82 | 82 | # et l'affichage de son titre dans le bandeau |
| 83 | - . "\"\nondblclick=\"" |
|
| 84 | - . "$js_func(this." |
|
| 85 | - . 'firstChild.nodeValue,' |
|
| 86 | - . $id |
|
| 87 | - . ",'selection_rubrique','id_parent');" |
|
| 88 | - . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 89 | - . '"'; |
|
| 83 | + . "\"\nondblclick=\"" |
|
| 84 | + . "$js_func(this." |
|
| 85 | + . 'firstChild.nodeValue,' |
|
| 86 | + . $id |
|
| 87 | + . ",'selection_rubrique','id_parent');" |
|
| 88 | + . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 89 | + . '"'; |
|
| 90 | 90 | |
| 91 | - $ret .= "<div class='" |
|
| 92 | - . (($id == $next) ? 'item on' : 'item') |
|
| 93 | - . "'><div class='" |
|
| 94 | - . $classe1 |
|
| 95 | - . "'><div$classe2><a" |
|
| 96 | - . $url |
|
| 97 | - . $click |
|
| 98 | - . '>' |
|
| 99 | - . $titre |
|
| 100 | - . '</a></div></div></div>'; |
|
| 101 | - } |
|
| 102 | - } |
|
| 91 | + $ret .= "<div class='" |
|
| 92 | + . (($id == $next) ? 'item on' : 'item') |
|
| 93 | + . "'><div class='" |
|
| 94 | + . $classe1 |
|
| 95 | + . "'><div$classe2><a" |
|
| 96 | + . $url |
|
| 97 | + . $click |
|
| 98 | + . '>' |
|
| 99 | + . $titre |
|
| 100 | + . '</a></div></div></div>'; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - $idom2 = $idom . '_col_' . ($col + 1); |
|
| 105 | - $left = ($col * 250); |
|
| 104 | + $idom2 = $idom . '_col_' . ($col + 1); |
|
| 105 | + $left = ($col * 250); |
|
| 106 | 106 | |
| 107 | - return http_img_pack( |
|
| 108 | - 'loader.svg', |
|
| 109 | - '', |
|
| 110 | - "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 111 | - . ($left - 30) |
|
| 112 | - . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
|
| 113 | - ) |
|
| 114 | - . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 115 | - . ($left - 250) |
|
| 116 | - . "px;'>" |
|
| 117 | - . $ret |
|
| 118 | - . "\n</div>\n<div id='$idom2'>" |
|
| 119 | - . ($next |
|
| 120 | - ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 121 | - : '') |
|
| 122 | - . "\n</div>"; |
|
| 107 | + return http_img_pack( |
|
| 108 | + 'loader.svg', |
|
| 109 | + '', |
|
| 110 | + "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 111 | + . ($left - 30) |
|
| 112 | + . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
|
| 113 | + ) |
|
| 114 | + . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 115 | + . ($left - 250) |
|
| 116 | + . "px;'>" |
|
| 117 | + . $ret |
|
| 118 | + . "\n</div>\n<div id='$idom2'>" |
|
| 119 | + . ($next |
|
| 120 | + ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 121 | + : '') |
|
| 122 | + . "\n</div>"; |
|
| 123 | 123 | } |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | $res = sql_select( |
| 36 | 36 | 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
| 37 | 37 | 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
| 38 | - 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 39 | - AND rub1.id_rubrique!=' . sql_quote($exclu) . ' |
|
| 40 | - AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')', |
|
| 38 | + 'rub1.id_parent = '.sql_quote($id_rubrique).' |
|
| 39 | + AND rub1.id_rubrique!=' . sql_quote($exclu).' |
|
| 40 | + AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu).')', |
|
| 41 | 41 | '', |
| 42 | 42 | '0+rub1.titre,rub1.titre' |
| 43 | 43 | ); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | if ($row['langue_choisie'] != 'oui') { |
| 51 | 51 | $t .= ' <small title="' |
| 52 | 52 | . traduire_nom_langue($row['lang']) |
| 53 | - . '">[' . $row['lang'] . ']</small>'; |
|
| 53 | + . '">['.$row['lang'].']</small>'; |
|
| 54 | 54 | } |
| 55 | 55 | $ordre[$row['id_rubrique']] = $t; |
| 56 | 56 | } |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | $next = isset($list[$col]) ? $list[$col] : 0; |
| 60 | 60 | if ($ordre) { |
| 61 | - $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 61 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1)); |
|
| 62 | 62 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
| 63 | - $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 63 | + $args = "'$idom',this,$col,'".$GLOBALS['spip_lang_left']."','$info',event"; |
|
| 64 | 64 | |
| 65 | 65 | foreach ($ordre as $id => $titrebrut) { |
| 66 | 66 | $titre = supprimer_numero($titrebrut); |
| 67 | 67 | |
| 68 | - $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 68 | + $classe1 = 'petit-item '.($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 69 | 69 | if (isset($rub[$id]['enfants'])) { |
| 70 | 70 | $classe2 = " class='rub-ouverte'"; |
| 71 | 71 | $url = "\nhref='$rec&id=$id'"; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $url = "\nhref='javascript:void(0)'"; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $js_func = $do . '_selection_titre'; |
|
| 77 | + $js_func = $do.'_selection_titre'; |
|
| 78 | 78 | $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
| 79 | 79 | . (!is_array($list) ? ' false' |
| 80 | 80 | : "aff_selection_provisoire($id,$args)") |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $idom2 = $idom . '_col_' . ($col + 1); |
|
| 104 | + $idom2 = $idom.'_col_'.($col + 1); |
|
| 105 | 105 | $left = ($col * 250); |
| 106 | 106 | |
| 107 | 107 | return http_img_pack( |
| 108 | 108 | 'loader.svg', |
| 109 | 109 | '', |
| 110 | - "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 110 | + "class='loader' style='visibility: hidden; position: absolute; ".$GLOBALS['spip_lang_left'].': ' |
|
| 111 | 111 | . ($left - 30) |
| 112 | 112 | . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
| 113 | 113 | ) |
| 114 | - . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 114 | + . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; ".$GLOBALS['spip_lang_left'].': ' |
|
| 115 | 115 | . ($left - 250) |
| 116 | 116 | . "px;'>" |
| 117 | 117 | . $ret |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/boutons'); |
@@ -37,33 +37,33 @@ discard block |
||
| 37 | 37 | * Contexte |
| 38 | 38 | **/ |
| 39 | 39 | function definir_barre_contexte($contexte = null) { |
| 40 | - if (is_null($contexte)) { |
|
| 41 | - $contexte = $_GET; |
|
| 42 | - } elseif (is_string($contexte)) { |
|
| 43 | - $contexte = unserialize($contexte); |
|
| 44 | - } |
|
| 45 | - if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 46 | - if (!function_exists('trouver_objet_exec')) { |
|
| 47 | - include_spip('inc/pipelines_ecrire'); |
|
| 48 | - } |
|
| 49 | - if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 50 | - $_id = $e['id_table_objet']; |
|
| 51 | - if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 52 | - $table = $e['table_objet_sql']; |
|
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 54 | - if (isset($row['id_rubrique'])) { |
|
| 55 | - $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 56 | - if (isset($row['id_secteur'])) { |
|
| 57 | - $contexte['id_secteur'] = $row['id_secteur']; |
|
| 58 | - } |
|
| 59 | - } elseif (isset($row['id_groupe'])) { |
|
| 60 | - // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 61 | - $contexte['id_groupe'] = $row['id_groupe']; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - return $contexte; |
|
| 40 | + if (is_null($contexte)) { |
|
| 41 | + $contexte = $_GET; |
|
| 42 | + } elseif (is_string($contexte)) { |
|
| 43 | + $contexte = unserialize($contexte); |
|
| 44 | + } |
|
| 45 | + if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 46 | + if (!function_exists('trouver_objet_exec')) { |
|
| 47 | + include_spip('inc/pipelines_ecrire'); |
|
| 48 | + } |
|
| 49 | + if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 50 | + $_id = $e['id_table_objet']; |
|
| 51 | + if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 52 | + $table = $e['table_objet_sql']; |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 54 | + if (isset($row['id_rubrique'])) { |
|
| 55 | + $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 56 | + if (isset($row['id_secteur'])) { |
|
| 57 | + $contexte['id_secteur'] = $row['id_secteur']; |
|
| 58 | + } |
|
| 59 | + } elseif (isset($row['id_groupe'])) { |
|
| 60 | + // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 61 | + $contexte['id_groupe'] = $row['id_groupe']; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + return $contexte; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -79,92 +79,92 @@ discard block |
||
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | 81 | function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) { |
| 82 | - include_spip('inc/autoriser'); |
|
| 83 | - $boutons_admin = []; |
|
| 82 | + include_spip('inc/autoriser'); |
|
| 83 | + $boutons_admin = []; |
|
| 84 | 84 | |
| 85 | - // les boutons du core, issus de ecrire/paquet.xml |
|
| 86 | - $liste_boutons = []; |
|
| 85 | + // les boutons du core, issus de ecrire/paquet.xml |
|
| 86 | + $liste_boutons = []; |
|
| 87 | 87 | |
| 88 | - // ajouter les boutons issus des plugin via paquet.xml |
|
| 89 | - if ( |
|
| 90 | - function_exists('boutons_plugins') |
|
| 91 | - and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 92 | - ) { |
|
| 93 | - $liste_boutons = &$liste_boutons_plugins; |
|
| 94 | - } |
|
| 88 | + // ajouter les boutons issus des plugin via paquet.xml |
|
| 89 | + if ( |
|
| 90 | + function_exists('boutons_plugins') |
|
| 91 | + and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 92 | + ) { |
|
| 93 | + $liste_boutons = &$liste_boutons_plugins; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - foreach ($liste_boutons as $id => $infos) { |
|
| 97 | - $parent = ''; |
|
| 98 | - // les boutons principaux ne sont pas soumis a autorisation |
|
| 99 | - if ( |
|
| 100 | - !isset($infos['parent']) |
|
| 101 | - or !($parent = $infos['parent']) |
|
| 102 | - or !$autorise |
|
| 103 | - or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte]) |
|
| 104 | - ) { |
|
| 105 | - if ( |
|
| 106 | - $parent |
|
| 107 | - and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 108 | - and isset($boutons_admin[$parent]) |
|
| 109 | - ) { |
|
| 110 | - if (!is_array($boutons_admin[$parent]->sousmenu)) { |
|
| 111 | - $boutons_admin[$parent]->sousmenu = []; |
|
| 112 | - } |
|
| 113 | - $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 114 | - if ($position < 0) { |
|
| 115 | - $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 116 | - } |
|
| 117 | - $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 118 | - + [ |
|
| 119 | - $id => new Bouton( |
|
| 120 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 121 | - $infos['titre'], // titre |
|
| 122 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 123 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 124 | - ) |
|
| 125 | - ] |
|
| 126 | - + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 127 | - } |
|
| 128 | - if ( |
|
| 129 | - !$parent |
|
| 130 | - // provisoire, eviter les vieux boutons |
|
| 131 | - and (!in_array($id, ['forum', 'statistiques_visites'])) |
|
| 132 | - and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte])) |
|
| 133 | - ) { |
|
| 134 | - $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 135 | - $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 136 | - + [ |
|
| 137 | - $id => new Bouton( |
|
| 138 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 139 | - $infos['titre'], // titre |
|
| 140 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 141 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 142 | - ) |
|
| 143 | - ] |
|
| 144 | - + array_slice($boutons_admin, $position, 100); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 96 | + foreach ($liste_boutons as $id => $infos) { |
|
| 97 | + $parent = ''; |
|
| 98 | + // les boutons principaux ne sont pas soumis a autorisation |
|
| 99 | + if ( |
|
| 100 | + !isset($infos['parent']) |
|
| 101 | + or !($parent = $infos['parent']) |
|
| 102 | + or !$autorise |
|
| 103 | + or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte]) |
|
| 104 | + ) { |
|
| 105 | + if ( |
|
| 106 | + $parent |
|
| 107 | + and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 108 | + and isset($boutons_admin[$parent]) |
|
| 109 | + ) { |
|
| 110 | + if (!is_array($boutons_admin[$parent]->sousmenu)) { |
|
| 111 | + $boutons_admin[$parent]->sousmenu = []; |
|
| 112 | + } |
|
| 113 | + $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 114 | + if ($position < 0) { |
|
| 115 | + $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 116 | + } |
|
| 117 | + $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 118 | + + [ |
|
| 119 | + $id => new Bouton( |
|
| 120 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 121 | + $infos['titre'], // titre |
|
| 122 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 123 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 124 | + ) |
|
| 125 | + ] |
|
| 126 | + + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 127 | + } |
|
| 128 | + if ( |
|
| 129 | + !$parent |
|
| 130 | + // provisoire, eviter les vieux boutons |
|
| 131 | + and (!in_array($id, ['forum', 'statistiques_visites'])) |
|
| 132 | + and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte])) |
|
| 133 | + ) { |
|
| 134 | + $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 135 | + $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 136 | + + [ |
|
| 137 | + $id => new Bouton( |
|
| 138 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 139 | + $infos['titre'], // titre |
|
| 140 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 141 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 142 | + ) |
|
| 143 | + ] |
|
| 144 | + + array_slice($boutons_admin, $position, 100); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 149 | 149 | |
| 150 | - // définir les favoris et positions d’origine |
|
| 151 | - if ($boutons_admin) { |
|
| 152 | - $menus_favoris = obtenir_menus_favoris(); |
|
| 153 | - $i = 1; |
|
| 154 | - foreach ($boutons_admin as $key => $menu) { |
|
| 155 | - $menu->favori = table_valeur($menus_favoris, $key, false); |
|
| 156 | - $menu->position = $i++; |
|
| 157 | - if ($menu->sousmenu) { |
|
| 158 | - $j = 1; |
|
| 159 | - foreach ($menu->sousmenu as $key => $bouton) { |
|
| 160 | - $bouton->favori = table_valeur($menus_favoris, $key, false); |
|
| 161 | - $bouton->position = $j++; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - } |
|
| 150 | + // définir les favoris et positions d’origine |
|
| 151 | + if ($boutons_admin) { |
|
| 152 | + $menus_favoris = obtenir_menus_favoris(); |
|
| 153 | + $i = 1; |
|
| 154 | + foreach ($boutons_admin as $key => $menu) { |
|
| 155 | + $menu->favori = table_valeur($menus_favoris, $key, false); |
|
| 156 | + $menu->position = $i++; |
|
| 157 | + if ($menu->sousmenu) { |
|
| 158 | + $j = 1; |
|
| 159 | + foreach ($menu->sousmenu as $key => $bouton) { |
|
| 160 | + $bouton->favori = table_valeur($menus_favoris, $key, false); |
|
| 161 | + $bouton->position = $j++; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - return $boutons_admin; |
|
| 167 | + return $boutons_admin; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -176,22 +176,22 @@ discard block |
||
| 176 | 176 | * @return Bouton[] |
| 177 | 177 | */ |
| 178 | 178 | function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) { |
| 179 | - foreach ($menus as $menu) { |
|
| 180 | - if ($menu->sousmenu) { |
|
| 181 | - $libelles = $isfavoris = $favoris = []; |
|
| 182 | - foreach ($menu->sousmenu as $key => $item) { |
|
| 183 | - $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 184 | - $isfavoris[$key] = (bool)$item->favori; |
|
| 185 | - $favoris[$key] = $item->favori; |
|
| 186 | - } |
|
| 187 | - if ($avec_favoris) { |
|
| 188 | - array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 189 | - } else { |
|
| 190 | - array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - return $menus; |
|
| 179 | + foreach ($menus as $menu) { |
|
| 180 | + if ($menu->sousmenu) { |
|
| 181 | + $libelles = $isfavoris = $favoris = []; |
|
| 182 | + foreach ($menu->sousmenu as $key => $item) { |
|
| 183 | + $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 184 | + $isfavoris[$key] = (bool)$item->favori; |
|
| 185 | + $favoris[$key] = $item->favori; |
|
| 186 | + } |
|
| 187 | + if ($avec_favoris) { |
|
| 188 | + array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 189 | + } else { |
|
| 190 | + array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + return $menus; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return Bouton[] |
| 203 | 203 | */ |
| 204 | 204 | function trier_boutons_enfants_par_favoris_alpha($menus) { |
| 205 | - return trier_boutons_enfants_par_alpha($menus, true); |
|
| 205 | + return trier_boutons_enfants_par_alpha($menus, true); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
@@ -215,23 +215,23 @@ discard block |
||
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | 217 | function bandeau_creer_url($url, $args = '', $contexte = null) { |
| 218 | - if (!preg_match(',[\/\?],', $url)) { |
|
| 219 | - $url = generer_url_ecrire($url, $args, true); |
|
| 220 | - // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 221 | - // &truc=@machin@ |
|
| 222 | - // @machin@ etant remplace par _request('machin') |
|
| 223 | - $url = str_replace('&', '&', $url); |
|
| 224 | - while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 225 | - if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 226 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 227 | - } |
|
| 228 | - $val = _request($matches[2], $contexte); |
|
| 229 | - $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
|
| 230 | - } |
|
| 231 | - $url = str_replace('&', '&', $url); |
|
| 232 | - } |
|
| 218 | + if (!preg_match(',[\/\?],', $url)) { |
|
| 219 | + $url = generer_url_ecrire($url, $args, true); |
|
| 220 | + // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 221 | + // &truc=@machin@ |
|
| 222 | + // @machin@ etant remplace par _request('machin') |
|
| 223 | + $url = str_replace('&', '&', $url); |
|
| 224 | + while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 225 | + if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 226 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 227 | + } |
|
| 228 | + $val = _request($matches[2], $contexte); |
|
| 229 | + $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
|
| 230 | + } |
|
| 231 | + $url = str_replace('&', '&', $url); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - return $url; |
|
| 234 | + return $url; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * Code HTML du bandeau |
| 242 | 242 | */ |
| 243 | 243 | function inc_bandeau_dist() { |
| 244 | - return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 244 | + return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -250,13 +250,13 @@ discard block |
||
| 250 | 250 | * @return array |
| 251 | 251 | */ |
| 252 | 252 | function obtenir_menus_favoris() { |
| 253 | - if ( |
|
| 254 | - isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 255 | - and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 256 | - and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 257 | - ) { |
|
| 258 | - return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 259 | - } |
|
| 260 | - $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 261 | - return $definir_menus_favoris(); |
|
| 253 | + if ( |
|
| 254 | + isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 255 | + and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 256 | + and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 257 | + ) { |
|
| 258 | + return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 259 | + } |
|
| 260 | + $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 261 | + return $definir_menus_favoris(); |
|
| 262 | 262 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $_id = $e['id_table_objet']; |
| 51 | 51 | if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
| 52 | 52 | $table = $e['table_objet_sql']; |
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=".intval($id)); |
|
| 54 | 54 | if (isset($row['id_rubrique'])) { |
| 55 | 55 | $contexte['id_rubrique'] = $row['id_rubrique']; |
| 56 | 56 | if (isset($row['id_secteur'])) { |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
| 118 | 118 | + [ |
| 119 | 119 | $id => new Bouton( |
| 120 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 121 | - $infos['titre'], // titre |
|
| 120 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 121 | + $infos['titre'], // titre |
|
| 122 | 122 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 123 | 123 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 124 | 124 | ) |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | $boutons_admin = array_slice($boutons_admin, 0, $position) |
| 136 | 136 | + [ |
| 137 | 137 | $id => new Bouton( |
| 138 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 139 | - $infos['titre'], // titre |
|
| 138 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 139 | + $infos['titre'], // titre |
|
| 140 | 140 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 141 | 141 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 142 | 142 | ) |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $libelles = $isfavoris = $favoris = []; |
| 182 | 182 | foreach ($menu->sousmenu as $key => $item) { |
| 183 | 183 | $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
| 184 | - $isfavoris[$key] = (bool)$item->favori; |
|
| 184 | + $isfavoris[$key] = (bool) $item->favori; |
|
| 185 | 185 | $favoris[$key] = $item->favori; |
| 186 | 186 | } |
| 187 | 187 | if ($avec_favoris) { |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $url = str_replace('&', '&', $url); |
| 224 | 224 | while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
| 225 | 225 | if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
| 226 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 226 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($contexte['id_rubrique'])); |
|
| 227 | 227 | } |
| 228 | 228 | $val = _request($matches[2], $contexte); |
| 229 | 229 | $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | include_spip('base/objets'); |
| 23 | 23 | |
@@ -57,115 +57,115 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | 59 | function urls_decoder_url($url, $fond = '', $contexte = [], $assembler = false) { |
| 60 | - static $current_base = null; |
|
| 60 | + static $current_base = null; |
|
| 61 | 61 | |
| 62 | - // les anciennes fonctions modifient directement les globales |
|
| 63 | - // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | - $save = [ |
|
| 65 | - isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null, |
|
| 66 | - isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null, |
|
| 67 | - isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null, |
|
| 68 | - isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null, |
|
| 69 | - $GLOBALS['profondeur_url'] |
|
| 70 | - ]; |
|
| 62 | + // les anciennes fonctions modifient directement les globales |
|
| 63 | + // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | + $save = [ |
|
| 65 | + isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null, |
|
| 66 | + isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null, |
|
| 67 | + isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null, |
|
| 68 | + isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null, |
|
| 69 | + $GLOBALS['profondeur_url'] |
|
| 70 | + ]; |
|
| 71 | 71 | |
| 72 | - if (is_null($current_base)) { |
|
| 73 | - include_spip('inc/filtres_mini'); |
|
| 74 | - // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | - $current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './'); |
|
| 76 | - } |
|
| 77 | - if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | - $url = substr($url, strlen($current_base)); |
|
| 79 | - } |
|
| 72 | + if (is_null($current_base)) { |
|
| 73 | + include_spip('inc/filtres_mini'); |
|
| 74 | + // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | + $current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './'); |
|
| 76 | + } |
|
| 77 | + if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | + $url = substr($url, strlen($current_base)); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // si on est en train d'assembler la page principale, |
|
| 82 | - // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | - // sinon extraire la bonne portion d'url |
|
| 84 | - if ($assembler) { |
|
| 85 | - if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | - $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | - } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | - $url = $_ENV['url_propre']; |
|
| 89 | - } else { |
|
| 90 | - $qs = explode('?', $url); |
|
| 91 | - // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | - $url = ltrim($qs[0], '/'); |
|
| 93 | - $url = explode('/', $url); |
|
| 94 | - while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | - array_shift($url); |
|
| 96 | - } |
|
| 97 | - $qs[0] = implode('/', $url); |
|
| 98 | - $url = implode('?', $qs); |
|
| 99 | - } |
|
| 100 | - } |
|
| 81 | + // si on est en train d'assembler la page principale, |
|
| 82 | + // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | + // sinon extraire la bonne portion d'url |
|
| 84 | + if ($assembler) { |
|
| 85 | + if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | + $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | + } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | + $url = $_ENV['url_propre']; |
|
| 89 | + } else { |
|
| 90 | + $qs = explode('?', $url); |
|
| 91 | + // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | + $url = ltrim($qs[0], '/'); |
|
| 93 | + $url = explode('/', $url); |
|
| 94 | + while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | + array_shift($url); |
|
| 96 | + } |
|
| 97 | + $qs[0] = implode('/', $url); |
|
| 98 | + $url = implode('?', $qs); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | - unset($_ENV['url_propre']); |
|
| 104 | - include_spip('inc/filtres_mini'); |
|
| 105 | - if (strpos($url, '://') === false) { |
|
| 106 | - $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | - } else { |
|
| 108 | - $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | - } |
|
| 102 | + unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | + unset($_ENV['url_propre']); |
|
| 104 | + include_spip('inc/filtres_mini'); |
|
| 105 | + if (strpos($url, '://') === false) { |
|
| 106 | + $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | + } else { |
|
| 108 | + $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - $url_redirect = ''; |
|
| 112 | - $renommer = generer_url_entite('', '', '', '', true); |
|
| 113 | - if (!$renommer and !function_exists('recuperer_parametres_url')) { |
|
| 114 | - $renommer = charger_fonction('page', 'urls'); |
|
| 115 | - } // fallback pour decoder l'url |
|
| 116 | - if ($renommer) { |
|
| 117 | - $a = $renommer($url, $fond, $contexte); |
|
| 118 | - if (is_array($a)) { |
|
| 119 | - list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); |
|
| 120 | - if ($url_redirect == $url) { |
|
| 121 | - $url_redirect = ''; |
|
| 122 | - } // securite pour eviter une redirection infinie |
|
| 123 | - if ($assembler and strlen($url_redirect)) { |
|
| 124 | - spip_log("Redirige $url vers $url_redirect"); |
|
| 125 | - include_spip('inc/headers'); |
|
| 126 | - redirige_par_entete($url_redirect, '', 301); |
|
| 127 | - } |
|
| 128 | - if (isset($nfond)) { |
|
| 129 | - $fond = $nfond; |
|
| 130 | - } else { |
|
| 131 | - if ( |
|
| 132 | - $fond == '' |
|
| 133 | - or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 134 | - ) { |
|
| 135 | - $fond = $type; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - if (isset($ncontexte)) { |
|
| 139 | - $contexte = $ncontexte; |
|
| 140 | - } |
|
| 141 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 142 | - $contexte['type'] = $type; |
|
| 143 | - } |
|
| 144 | - if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 145 | - $contexte['type-page'] = $type; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - } // compatibilite <= 1.9.2 |
|
| 149 | - elseif (function_exists('recuperer_parametres_url')) { |
|
| 150 | - $GLOBALS['fond'] = $fond; |
|
| 151 | - $GLOBALS['contexte'] = $contexte; |
|
| 152 | - recuperer_parametres_url($fond, nettoyer_uri()); |
|
| 153 | - // fond est en principe modifiee directement |
|
| 154 | - $contexte = $GLOBALS['contexte']; |
|
| 155 | - } |
|
| 111 | + $url_redirect = ''; |
|
| 112 | + $renommer = generer_url_entite('', '', '', '', true); |
|
| 113 | + if (!$renommer and !function_exists('recuperer_parametres_url')) { |
|
| 114 | + $renommer = charger_fonction('page', 'urls'); |
|
| 115 | + } // fallback pour decoder l'url |
|
| 116 | + if ($renommer) { |
|
| 117 | + $a = $renommer($url, $fond, $contexte); |
|
| 118 | + if (is_array($a)) { |
|
| 119 | + list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); |
|
| 120 | + if ($url_redirect == $url) { |
|
| 121 | + $url_redirect = ''; |
|
| 122 | + } // securite pour eviter une redirection infinie |
|
| 123 | + if ($assembler and strlen($url_redirect)) { |
|
| 124 | + spip_log("Redirige $url vers $url_redirect"); |
|
| 125 | + include_spip('inc/headers'); |
|
| 126 | + redirige_par_entete($url_redirect, '', 301); |
|
| 127 | + } |
|
| 128 | + if (isset($nfond)) { |
|
| 129 | + $fond = $nfond; |
|
| 130 | + } else { |
|
| 131 | + if ( |
|
| 132 | + $fond == '' |
|
| 133 | + or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 134 | + ) { |
|
| 135 | + $fond = $type; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + if (isset($ncontexte)) { |
|
| 139 | + $contexte = $ncontexte; |
|
| 140 | + } |
|
| 141 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 142 | + $contexte['type'] = $type; |
|
| 143 | + } |
|
| 144 | + if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 145 | + $contexte['type-page'] = $type; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + } // compatibilite <= 1.9.2 |
|
| 149 | + elseif (function_exists('recuperer_parametres_url')) { |
|
| 150 | + $GLOBALS['fond'] = $fond; |
|
| 151 | + $GLOBALS['contexte'] = $contexte; |
|
| 152 | + recuperer_parametres_url($fond, nettoyer_uri()); |
|
| 153 | + // fond est en principe modifiee directement |
|
| 154 | + $contexte = $GLOBALS['contexte']; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - // retablir les globales |
|
| 158 | - list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save; |
|
| 157 | + // retablir les globales |
|
| 158 | + list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save; |
|
| 159 | 159 | |
| 160 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 161 | - // d'inversion url => objet |
|
| 162 | - // maintenir pour compat ? |
|
| 163 | - #if ($assembler) { |
|
| 164 | - # unset($_SERVER['REDIRECT_url_propre']); |
|
| 165 | - # unset($_ENV['url_propre']); |
|
| 166 | - #} |
|
| 160 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 161 | + // d'inversion url => objet |
|
| 162 | + // maintenir pour compat ? |
|
| 163 | + #if ($assembler) { |
|
| 164 | + # unset($_SERVER['REDIRECT_url_propre']); |
|
| 165 | + # unset($_ENV['url_propre']); |
|
| 166 | + #} |
|
| 167 | 167 | |
| 168 | - return [$fond, $contexte, $url_redirect]; |
|
| 168 | + return [$fond, $contexte, $url_redirect]; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
@@ -179,24 +179,24 @@ discard block |
||
| 179 | 179 | * @return string|array |
| 180 | 180 | */ |
| 181 | 181 | function urls_liste_objets($preg = true) { |
| 182 | - static $url_objets = null; |
|
| 183 | - if (is_null($url_objets)) { |
|
| 184 | - $url_objets = []; |
|
| 185 | - // recuperer les tables_objets_sql declarees |
|
| 186 | - $tables_objets = lister_tables_objets_sql(); |
|
| 187 | - foreach ($tables_objets as $t => $infos) { |
|
| 188 | - if ($infos['page']) { |
|
| 189 | - $url_objets[] = $infos['type']; |
|
| 190 | - $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 194 | - } |
|
| 195 | - if (!$preg) { |
|
| 196 | - return $url_objets; |
|
| 197 | - } |
|
| 182 | + static $url_objets = null; |
|
| 183 | + if (is_null($url_objets)) { |
|
| 184 | + $url_objets = []; |
|
| 185 | + // recuperer les tables_objets_sql declarees |
|
| 186 | + $tables_objets = lister_tables_objets_sql(); |
|
| 187 | + foreach ($tables_objets as $t => $infos) { |
|
| 188 | + if ($infos['page']) { |
|
| 189 | + $url_objets[] = $infos['type']; |
|
| 190 | + $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 194 | + } |
|
| 195 | + if (!$preg) { |
|
| 196 | + return $url_objets; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - return implode('|', array_map('preg_quote', $url_objets)); |
|
| 199 | + return implode('|', array_map('preg_quote', $url_objets)); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -210,26 +210,26 @@ discard block |
||
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | 212 | function nettoyer_url_page($url, $contexte = []) { |
| 213 | - $url_objets = urls_liste_objets(); |
|
| 214 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 213 | + $url_objets = urls_liste_objets(); |
|
| 214 | + $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | + $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 217 | 217 | |
| 218 | - if ( |
|
| 219 | - preg_match($raccourci_url_page_html, $url, $regs) |
|
| 220 | - or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 221 | - or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 222 | - ) { |
|
| 223 | - $regs = array_pad($regs, 4, null); |
|
| 224 | - $type = objet_type($regs[1]); |
|
| 225 | - $_id = id_table_objet($type); |
|
| 226 | - $contexte[$_id] = $regs[2]; |
|
| 227 | - $suite = $regs[3]; |
|
| 218 | + if ( |
|
| 219 | + preg_match($raccourci_url_page_html, $url, $regs) |
|
| 220 | + or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 221 | + or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 222 | + ) { |
|
| 223 | + $regs = array_pad($regs, 4, null); |
|
| 224 | + $type = objet_type($regs[1]); |
|
| 225 | + $_id = id_table_objet($type); |
|
| 226 | + $contexte[$_id] = $regs[2]; |
|
| 227 | + $suite = $regs[3]; |
|
| 228 | 228 | |
| 229 | - return [$contexte, $type, null, $type, $suite]; |
|
| 230 | - } |
|
| 229 | + return [$contexte, $type, null, $type, $suite]; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - return []; |
|
| 232 | + return []; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -248,33 +248,33 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | */ |
| 250 | 250 | function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, $connect = '') { |
| 251 | - static $furls = []; |
|
| 252 | - if (!isset($furls[$objet])) { |
|
| 253 | - if ( |
|
| 254 | - function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 255 | - // ou definie par un plugin |
|
| 256 | - or $f = charger_fonction($f, 'urls', true) |
|
| 257 | - ) { |
|
| 258 | - $furls[$objet] = $f; |
|
| 259 | - } else { |
|
| 260 | - $furls[$objet] = ''; |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - if ($furls[$objet]) { |
|
| 264 | - return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 265 | - } |
|
| 266 | - // si pas de flag public fourni |
|
| 267 | - // le calculer en fonction de la declaration de statut |
|
| 268 | - if (is_null($public) and !$connect) { |
|
| 269 | - $public = objet_test_si_publie($objet, $id, $connect); |
|
| 270 | - } |
|
| 271 | - if ($public or $connect) { |
|
| 272 | - return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
|
| 273 | - } |
|
| 274 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 275 | - if (!function_exists('objet_info')) { |
|
| 276 | - include_spip('inc/filtres'); |
|
| 277 | - } |
|
| 251 | + static $furls = []; |
|
| 252 | + if (!isset($furls[$objet])) { |
|
| 253 | + if ( |
|
| 254 | + function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 255 | + // ou definie par un plugin |
|
| 256 | + or $f = charger_fonction($f, 'urls', true) |
|
| 257 | + ) { |
|
| 258 | + $furls[$objet] = $f; |
|
| 259 | + } else { |
|
| 260 | + $furls[$objet] = ''; |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + if ($furls[$objet]) { |
|
| 264 | + return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 265 | + } |
|
| 266 | + // si pas de flag public fourni |
|
| 267 | + // le calculer en fonction de la declaration de statut |
|
| 268 | + if (is_null($public) and !$connect) { |
|
| 269 | + $public = objet_test_si_publie($objet, $id, $connect); |
|
| 270 | + } |
|
| 271 | + if ($public or $connect) { |
|
| 272 | + return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
|
| 273 | + } |
|
| 274 | + $a = id_table_objet($objet) . '=' . intval($id); |
|
| 275 | + if (!function_exists('objet_info')) { |
|
| 276 | + include_spip('inc/filtres'); |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 279 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 280 | 280 | } |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function nettoyer_url_page($url, $contexte = []) { |
| 213 | 213 | $url_objets = urls_liste_objets(); |
| 214 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 214 | + $raccourci_url_page_html = ',^(?:[^?]*/)?('.$url_objets.')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | + $raccourci_url_page_id = ',^(?:[^?]*/)?('.$url_objets.')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('.$url_objets.')([0-9]+)=?(&.*)?$,'; |
|
| 217 | 217 | |
| 218 | 218 | if ( |
| 219 | 219 | preg_match($raccourci_url_page_html, $url, $regs) |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | static $furls = []; |
| 252 | 252 | if (!isset($furls[$objet])) { |
| 253 | 253 | if ( |
| 254 | - function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 254 | + function_exists($f = 'generer_url_ecrire_'.$objet) |
|
| 255 | 255 | // ou definie par un plugin |
| 256 | 256 | or $f = charger_fonction($f, 'urls', true) |
| 257 | 257 | ) { |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | if ($public or $connect) { |
| 272 | 272 | return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
| 273 | 273 | } |
| 274 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 274 | + $a = id_table_objet($objet).'='.intval($id); |
|
| 275 | 275 | if (!function_exists('objet_info')) { |
| 276 | 276 | include_spip('inc/filtres'); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 279 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a.($args ? "&$args" : '')).($ancre ? "#$ancre" : ''); |
|
| 280 | 280 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // |
@@ -22,54 +22,54 @@ discard block |
||
| 22 | 22 | // https://code.spip.net/@image_math |
| 23 | 23 | function produire_image_math($tex) { |
| 24 | 24 | |
| 25 | - switch ($GLOBALS['traiter_math']) { |
|
| 26 | - // Attention: mathml desactiv'e pour l'instant |
|
| 27 | - case 'mathml': |
|
| 28 | - $ext = '.xhtml'; |
|
| 29 | - $server = $GLOBALS['mathml_server']; |
|
| 30 | - break; |
|
| 31 | - case 'tex': |
|
| 32 | - $ext = '.png'; |
|
| 33 | - $server = $GLOBALS['tex_server']; |
|
| 34 | - break; |
|
| 35 | - default: |
|
| 36 | - return $tex; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 40 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 41 | - @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 42 | - } |
|
| 43 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - if (!@file_exists($fichier)) { |
|
| 47 | - // Aller chercher l'image sur le serveur |
|
| 48 | - if ($server) { |
|
| 49 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 50 | - include_spip('inc/distant'); |
|
| 51 | - recuperer_url($url, ['file' => $fichier]); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - // Composer la reponse selon presence ou non de l'image |
|
| 57 | - $tex = entites_html($tex); |
|
| 58 | - if (@file_exists($fichier)) { |
|
| 59 | - // MathML |
|
| 60 | - if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 61 | - return implode('', file($fichier)); |
|
| 62 | - } // TeX |
|
| 63 | - else { |
|
| 64 | - list(, , , $size) = @spip_getimagesize($fichier); |
|
| 65 | - $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 66 | - |
|
| 67 | - return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 68 | - } |
|
| 69 | - } else // pas de fichier |
|
| 70 | - { |
|
| 71 | - return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 72 | - } |
|
| 25 | + switch ($GLOBALS['traiter_math']) { |
|
| 26 | + // Attention: mathml desactiv'e pour l'instant |
|
| 27 | + case 'mathml': |
|
| 28 | + $ext = '.xhtml'; |
|
| 29 | + $server = $GLOBALS['mathml_server']; |
|
| 30 | + break; |
|
| 31 | + case 'tex': |
|
| 32 | + $ext = '.png'; |
|
| 33 | + $server = $GLOBALS['tex_server']; |
|
| 34 | + break; |
|
| 35 | + default: |
|
| 36 | + return $tex; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 40 | + if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 41 | + @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 42 | + } |
|
| 43 | + $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + if (!@file_exists($fichier)) { |
|
| 47 | + // Aller chercher l'image sur le serveur |
|
| 48 | + if ($server) { |
|
| 49 | + spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 50 | + include_spip('inc/distant'); |
|
| 51 | + recuperer_url($url, ['file' => $fichier]); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + // Composer la reponse selon presence ou non de l'image |
|
| 57 | + $tex = entites_html($tex); |
|
| 58 | + if (@file_exists($fichier)) { |
|
| 59 | + // MathML |
|
| 60 | + if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 61 | + return implode('', file($fichier)); |
|
| 62 | + } // TeX |
|
| 63 | + else { |
|
| 64 | + list(, , , $size) = @spip_getimagesize($fichier); |
|
| 65 | + $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 66 | + |
|
| 67 | + return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 68 | + } |
|
| 69 | + } else // pas de fichier |
|
| 70 | + { |
|
| 71 | + return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -104,52 +104,52 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | function traiter_math($letexte, $source = '', $defaire_amp = false) { |
| 106 | 106 | |
| 107 | - $texte_a_voir = $letexte; |
|
| 108 | - while (($debut = strpos($texte_a_voir, '<math>')) !== false) { |
|
| 109 | - if (!$fin = strpos($texte_a_voir, '</math>')) { |
|
| 110 | - $fin = strlen($texte_a_voir); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 114 | - $texte_milieu = substr( |
|
| 115 | - $texte_a_voir, |
|
| 116 | - $debut + strlen('<math>'), |
|
| 117 | - $fin - $debut - strlen('<math>') |
|
| 118 | - ); |
|
| 119 | - $texte_fin = substr( |
|
| 120 | - $texte_a_voir, |
|
| 121 | - $fin + strlen('</math>'), |
|
| 122 | - strlen($texte_a_voir) |
|
| 123 | - ); |
|
| 124 | - |
|
| 125 | - // Les doubles $$x^2$$ en mode 'div' |
|
| 126 | - while ((preg_match(',[$][$]([^$]+)[$][$],', $texte_milieu, $regs))) { |
|
| 127 | - $expression = $regs[1]; |
|
| 128 | - if ($defaire_amp) { |
|
| 129 | - $expression = str_replace('&', '&', $expression); |
|
| 130 | - } |
|
| 131 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 132 | - $pos = strpos($texte_milieu, $regs[0]); |
|
| 133 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 134 | - . code_echappement($echap, $source) |
|
| 135 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // Les simples $x^2$ en mode 'span' |
|
| 139 | - while ((preg_match(',[$]([^$]+)[$],', $texte_milieu, $regs))) { |
|
| 140 | - $expression = $regs[1]; |
|
| 141 | - if ($defaire_amp) { |
|
| 142 | - $expression = str_replace('&', '&', $expression); |
|
| 143 | - } |
|
| 144 | - $echap = produire_image_math($expression); |
|
| 145 | - $pos = strpos($texte_milieu, $regs[0]); |
|
| 146 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 147 | - . code_echappement($echap, $source) |
|
| 148 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $texte_a_voir; |
|
| 107 | + $texte_a_voir = $letexte; |
|
| 108 | + while (($debut = strpos($texte_a_voir, '<math>')) !== false) { |
|
| 109 | + if (!$fin = strpos($texte_a_voir, '</math>')) { |
|
| 110 | + $fin = strlen($texte_a_voir); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 114 | + $texte_milieu = substr( |
|
| 115 | + $texte_a_voir, |
|
| 116 | + $debut + strlen('<math>'), |
|
| 117 | + $fin - $debut - strlen('<math>') |
|
| 118 | + ); |
|
| 119 | + $texte_fin = substr( |
|
| 120 | + $texte_a_voir, |
|
| 121 | + $fin + strlen('</math>'), |
|
| 122 | + strlen($texte_a_voir) |
|
| 123 | + ); |
|
| 124 | + |
|
| 125 | + // Les doubles $$x^2$$ en mode 'div' |
|
| 126 | + while ((preg_match(',[$][$]([^$]+)[$][$],', $texte_milieu, $regs))) { |
|
| 127 | + $expression = $regs[1]; |
|
| 128 | + if ($defaire_amp) { |
|
| 129 | + $expression = str_replace('&', '&', $expression); |
|
| 130 | + } |
|
| 131 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 132 | + $pos = strpos($texte_milieu, $regs[0]); |
|
| 133 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 134 | + . code_echappement($echap, $source) |
|
| 135 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // Les simples $x^2$ en mode 'span' |
|
| 139 | + while ((preg_match(',[$]([^$]+)[$],', $texte_milieu, $regs))) { |
|
| 140 | + $expression = $regs[1]; |
|
| 141 | + if ($defaire_amp) { |
|
| 142 | + $expression = str_replace('&', '&', $expression); |
|
| 143 | + } |
|
| 144 | + $echap = produire_image_math($expression); |
|
| 145 | + $pos = strpos($texte_milieu, $regs[0]); |
|
| 146 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 147 | + . code_echappement($echap, $source) |
|
| 148 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return $texte_a_voir; |
|
| 155 | 155 | } |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Regarder dans le repertoire local des images TeX et blocs MathML |
| 40 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | + if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/')) { |
|
| 41 | 41 | @mkdir($dir_tex, _SPIP_CHMOD); |
| 42 | 42 | } |
| 43 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | + $fichier = $dir_tex.md5(trim($tex)).$ext; |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | if (!@file_exists($fichier)) { |
| 47 | 47 | // Aller chercher l'image sur le serveur |
| 48 | 48 | if ($server) { |
| 49 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | + spip_log($url = $server.'?'.rawurlencode($tex)); |
|
| 50 | 50 | include_spip('inc/distant'); |
| 51 | 51 | recuperer_url($url, ['file' => $fichier]); |
| 52 | 52 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | return implode('', file($fichier)); |
| 62 | 62 | } // TeX |
| 63 | 63 | else { |
| 64 | - list(, , , $size) = @spip_getimagesize($fichier); |
|
| 64 | + list(,,, $size) = @spip_getimagesize($fichier); |
|
| 65 | 65 | $alt = "alt=\"$tex\" title=\"$tex\""; |
| 66 | 66 | |
| 67 | 67 | return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | if ($defaire_amp) { |
| 129 | 129 | $expression = str_replace('&', '&', $expression); |
| 130 | 130 | } |
| 131 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">".produire_image_math($expression)."</p>\n"; |
|
| 132 | 132 | $pos = strpos($texte_milieu, $regs[0]); |
| 133 | 133 | $texte_milieu = substr($texte_milieu, 0, $pos) |
| 134 | 134 | . code_echappement($echap, $source) |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | . substr($texte_milieu, $pos + strlen($regs[0])); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | + $texte_a_voir = $texte_debut.$texte_milieu.$texte_fin; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return $texte_a_voir; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * Date au format SQL tel que `2008-04-01` |
| 37 | 37 | **/ |
| 38 | 38 | function extraire_date($texte) { |
| 39 | - // format = 2001-08 |
|
| 40 | - if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 41 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 42 | - } |
|
| 39 | + // format = 2001-08 |
|
| 40 | + if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 41 | + return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -61,29 +61,29 @@ discard block |
||
| 61 | 61 | * - une chaîne vide si la date est considérée nulle |
| 62 | 62 | **/ |
| 63 | 63 | function normaliser_date($date, $forcer_jour = false) { |
| 64 | - $date = vider_date($date); |
|
| 65 | - if ($date) { |
|
| 66 | - if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 67 | - $date = date('Y-m-d H:i:s', $date); |
|
| 68 | - } |
|
| 69 | - if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 70 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 72 | - } else { |
|
| 73 | - if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 74 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 76 | - } else { |
|
| 77 | - $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ($forcer_jour) { |
|
| 82 | - $date = str_replace('-00', '-01', $date); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - return $date; |
|
| 64 | + $date = vider_date($date); |
|
| 65 | + if ($date) { |
|
| 66 | + if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 67 | + $date = date('Y-m-d H:i:s', $date); |
|
| 68 | + } |
|
| 69 | + if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 70 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | + $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 72 | + } else { |
|
| 73 | + if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 74 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | + $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 76 | + } else { |
|
| 77 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ($forcer_jour) { |
|
| 82 | + $date = str_replace('-00', '-01', $date); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + return $date; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -96,22 +96,22 @@ discard block |
||
| 96 | 96 | * - Une chaine vide |
| 97 | 97 | **/ |
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | - if ( |
|
| 100 | - !$verif_format_date |
|
| 101 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 102 | - preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 103 | - ) { |
|
| 104 | - if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 105 | - return ''; |
|
| 106 | - } |
|
| 107 | - if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 108 | - return ''; |
|
| 109 | - } |
|
| 110 | - if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 111 | - return ''; |
|
| 112 | - } // eviter le bug GMT-1 |
|
| 113 | - } |
|
| 114 | - return $letexte; |
|
| 99 | + if ( |
|
| 100 | + !$verif_format_date |
|
| 101 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 102 | + preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 103 | + ) { |
|
| 104 | + if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 105 | + return ''; |
|
| 106 | + } |
|
| 107 | + if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 108 | + return ''; |
|
| 109 | + } |
|
| 110 | + if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 111 | + return ''; |
|
| 112 | + } // eviter le bug GMT-1 |
|
| 113 | + } |
|
| 114 | + return $letexte; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | **/ |
| 128 | 128 | function recup_heure($date) { |
| 129 | 129 | |
| 130 | - static $d = [0, 0, 0]; |
|
| 131 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 132 | - return $d; |
|
| 133 | - } |
|
| 130 | + static $d = [0, 0, 0]; |
|
| 131 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 132 | + return $d; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - array_shift($r); |
|
| 135 | + array_shift($r); |
|
| 136 | 136 | |
| 137 | - return $r; |
|
| 137 | + return $r; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | * @return int heures, sinon 0 |
| 149 | 149 | **/ |
| 150 | 150 | function heures($numdate) { |
| 151 | - $date_array = recup_heure($numdate); |
|
| 152 | - if ($date_array) { |
|
| 153 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 154 | - } |
|
| 151 | + $date_array = recup_heure($numdate); |
|
| 152 | + if ($date_array) { |
|
| 153 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - return $heures; |
|
| 156 | + return $heures; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -167,12 +167,12 @@ discard block |
||
| 167 | 167 | * @return int minutes, sinon 0 |
| 168 | 168 | **/ |
| 169 | 169 | function minutes($numdate) { |
| 170 | - $date_array = recup_heure($numdate); |
|
| 171 | - if ($date_array) { |
|
| 172 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 173 | - } |
|
| 170 | + $date_array = recup_heure($numdate); |
|
| 171 | + if ($date_array) { |
|
| 172 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - return $minutes; |
|
| 175 | + return $minutes; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | * @return int secondes, sinon 0 |
| 187 | 187 | **/ |
| 188 | 188 | function secondes($numdate) { |
| 189 | - $date_array = recup_heure($numdate); |
|
| 190 | - if ($date_array) { |
|
| 191 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 192 | - } |
|
| 189 | + $date_array = recup_heure($numdate); |
|
| 190 | + if ($date_array) { |
|
| 191 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - return $secondes; |
|
| 194 | + return $secondes; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | * @return string L'heure formatée dans la langue en cours. |
| 211 | 211 | **/ |
| 212 | 212 | function heures_minutes($numdate, $forme = '') { |
| 213 | - if ($forme != 'abbr') { |
|
| 214 | - return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 215 | - } |
|
| 216 | - else { |
|
| 217 | - return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 218 | - } |
|
| 213 | + if ($forme != 'abbr') { |
|
| 214 | + return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 215 | + } |
|
| 216 | + else { |
|
| 217 | + return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 218 | + } |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -240,56 +240,56 @@ discard block |
||
| 240 | 240 | * @return array [année, mois, jour, heures, minutes, secondes] |
| 241 | 241 | **/ |
| 242 | 242 | function recup_date($numdate, $forcer_jour = true) { |
| 243 | - if (!$numdate) { |
|
| 244 | - return ''; |
|
| 245 | - } |
|
| 246 | - $heures = $minutes = $secondes = 0; |
|
| 247 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 248 | - $jour = $regs[1]; |
|
| 249 | - $mois = $regs[2]; |
|
| 250 | - $annee = $regs[3]; |
|
| 251 | - if ($annee < 90) { |
|
| 252 | - $annee = 2000 + $annee; |
|
| 253 | - } elseif ($annee < 100) { |
|
| 254 | - $annee = 1900 + $annee; |
|
| 255 | - } |
|
| 256 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 257 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 258 | - $annee = $regs[1]; |
|
| 259 | - $mois = $regs[2]; |
|
| 260 | - $jour = $regs[3]; |
|
| 261 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 262 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 263 | - $annee = $regs[1]; |
|
| 264 | - $mois = $regs[2]; |
|
| 265 | - $jour = ''; |
|
| 266 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 267 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 268 | - $annee = $regs[1]; |
|
| 269 | - $mois = $regs[2]; |
|
| 270 | - $jour = $regs[3]; |
|
| 271 | - $heures = $regs[4]; |
|
| 272 | - $minutes = $regs[5]; |
|
| 273 | - $secondes = $regs[6]; |
|
| 274 | - } else { |
|
| 275 | - $annee = $mois = $jour = ''; |
|
| 276 | - } |
|
| 277 | - if ($annee > 4000) { |
|
| 278 | - $annee -= 9000; |
|
| 279 | - } |
|
| 280 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 281 | - $jour = substr($jour, 1); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - if ($forcer_jour and $jour == '0') { |
|
| 285 | - $jour = '1'; |
|
| 286 | - } |
|
| 287 | - if ($forcer_jour and $mois == '0') { |
|
| 288 | - $mois = '1'; |
|
| 289 | - } |
|
| 290 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 291 | - return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 292 | - } |
|
| 243 | + if (!$numdate) { |
|
| 244 | + return ''; |
|
| 245 | + } |
|
| 246 | + $heures = $minutes = $secondes = 0; |
|
| 247 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 248 | + $jour = $regs[1]; |
|
| 249 | + $mois = $regs[2]; |
|
| 250 | + $annee = $regs[3]; |
|
| 251 | + if ($annee < 90) { |
|
| 252 | + $annee = 2000 + $annee; |
|
| 253 | + } elseif ($annee < 100) { |
|
| 254 | + $annee = 1900 + $annee; |
|
| 255 | + } |
|
| 256 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 257 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 258 | + $annee = $regs[1]; |
|
| 259 | + $mois = $regs[2]; |
|
| 260 | + $jour = $regs[3]; |
|
| 261 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 262 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 263 | + $annee = $regs[1]; |
|
| 264 | + $mois = $regs[2]; |
|
| 265 | + $jour = ''; |
|
| 266 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 267 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 268 | + $annee = $regs[1]; |
|
| 269 | + $mois = $regs[2]; |
|
| 270 | + $jour = $regs[3]; |
|
| 271 | + $heures = $regs[4]; |
|
| 272 | + $minutes = $regs[5]; |
|
| 273 | + $secondes = $regs[6]; |
|
| 274 | + } else { |
|
| 275 | + $annee = $mois = $jour = ''; |
|
| 276 | + } |
|
| 277 | + if ($annee > 4000) { |
|
| 278 | + $annee -= 9000; |
|
| 279 | + } |
|
| 280 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 281 | + $jour = substr($jour, 1); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + if ($forcer_jour and $jour == '0') { |
|
| 285 | + $jour = '1'; |
|
| 286 | + } |
|
| 287 | + if ($forcer_jour and $mois == '0') { |
|
| 288 | + $mois = '1'; |
|
| 289 | + } |
|
| 290 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 291 | + return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 292 | + } |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | * La date relative ou complète |
| 317 | 317 | **/ |
| 318 | 318 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */) { |
| 319 | - return sinon( |
|
| 320 | - date_relative($date, $decalage_maxi), |
|
| 321 | - affdate_heure($date) |
|
| 322 | - ); |
|
| 319 | + return sinon( |
|
| 320 | + date_relative($date, $decalage_maxi), |
|
| 321 | + affdate_heure($date) |
|
| 322 | + ); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -352,85 +352,85 @@ discard block |
||
| 352 | 352 | **/ |
| 353 | 353 | function date_relative($date, $decalage_maxi = 0, $ref_date = null) { |
| 354 | 354 | |
| 355 | - if (is_null($ref_date)) { |
|
| 356 | - $ref_time = time(); |
|
| 357 | - } else { |
|
| 358 | - $ref_time = strtotime($ref_date); |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - if (!$date) { |
|
| 362 | - return; |
|
| 363 | - } |
|
| 364 | - $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 365 | - |
|
| 366 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 367 | - return ''; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - if ($decal < 0) { |
|
| 371 | - $il_y_a = 'date_dans'; |
|
| 372 | - $decal = -1 * $decal; |
|
| 373 | - } else { |
|
| 374 | - $il_y_a = 'date_il_y_a'; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 378 | - return affdate_court($date); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - if ($decal > 3600 * 24 * 30) { |
|
| 382 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 383 | - if ($mois < 2) { |
|
| 384 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 385 | - } else { |
|
| 386 | - $delai = "$mois " . _T('date_mois'); |
|
| 387 | - } |
|
| 388 | - } else { |
|
| 389 | - if ($decal > 3600 * 24 * 7) { |
|
| 390 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 391 | - if ($semaines < 2) { |
|
| 392 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 393 | - } else { |
|
| 394 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 395 | - } |
|
| 396 | - } else { |
|
| 397 | - if ($decal > 3600 * 24) { |
|
| 398 | - $jours = floor($decal / (3600 * 24)); |
|
| 399 | - if ($jours < 2) { |
|
| 400 | - return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 401 | - } else { |
|
| 402 | - $delai = "$jours " . _T('date_jours'); |
|
| 403 | - } |
|
| 404 | - } else { |
|
| 405 | - if ($decal >= 3600) { |
|
| 406 | - $heures = floor($decal / 3600); |
|
| 407 | - if ($heures < 2) { |
|
| 408 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 409 | - } else { |
|
| 410 | - $delai = "$heures " . _T('date_heures'); |
|
| 411 | - } |
|
| 412 | - } else { |
|
| 413 | - if ($decal >= 60) { |
|
| 414 | - $minutes = floor($decal / 60); |
|
| 415 | - if ($minutes < 2) { |
|
| 416 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 417 | - } else { |
|
| 418 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 419 | - } |
|
| 420 | - } else { |
|
| 421 | - $secondes = ceil($decal); |
|
| 422 | - if ($secondes < 2) { |
|
| 423 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 424 | - } else { |
|
| 425 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - return _T($il_y_a, ['delai' => $delai]); |
|
| 355 | + if (is_null($ref_date)) { |
|
| 356 | + $ref_time = time(); |
|
| 357 | + } else { |
|
| 358 | + $ref_time = strtotime($ref_date); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + if (!$date) { |
|
| 362 | + return; |
|
| 363 | + } |
|
| 364 | + $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 365 | + |
|
| 366 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 367 | + return ''; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + if ($decal < 0) { |
|
| 371 | + $il_y_a = 'date_dans'; |
|
| 372 | + $decal = -1 * $decal; |
|
| 373 | + } else { |
|
| 374 | + $il_y_a = 'date_il_y_a'; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 378 | + return affdate_court($date); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + if ($decal > 3600 * 24 * 30) { |
|
| 382 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 383 | + if ($mois < 2) { |
|
| 384 | + $delai = "$mois " . _T('date_un_mois'); |
|
| 385 | + } else { |
|
| 386 | + $delai = "$mois " . _T('date_mois'); |
|
| 387 | + } |
|
| 388 | + } else { |
|
| 389 | + if ($decal > 3600 * 24 * 7) { |
|
| 390 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 391 | + if ($semaines < 2) { |
|
| 392 | + $delai = "$semaines " . _T('date_une_semaine'); |
|
| 393 | + } else { |
|
| 394 | + $delai = "$semaines " . _T('date_semaines'); |
|
| 395 | + } |
|
| 396 | + } else { |
|
| 397 | + if ($decal > 3600 * 24) { |
|
| 398 | + $jours = floor($decal / (3600 * 24)); |
|
| 399 | + if ($jours < 2) { |
|
| 400 | + return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 401 | + } else { |
|
| 402 | + $delai = "$jours " . _T('date_jours'); |
|
| 403 | + } |
|
| 404 | + } else { |
|
| 405 | + if ($decal >= 3600) { |
|
| 406 | + $heures = floor($decal / 3600); |
|
| 407 | + if ($heures < 2) { |
|
| 408 | + $delai = "$heures " . _T('date_une_heure'); |
|
| 409 | + } else { |
|
| 410 | + $delai = "$heures " . _T('date_heures'); |
|
| 411 | + } |
|
| 412 | + } else { |
|
| 413 | + if ($decal >= 60) { |
|
| 414 | + $minutes = floor($decal / 60); |
|
| 415 | + if ($minutes < 2) { |
|
| 416 | + $delai = "$minutes " . _T('date_une_minute'); |
|
| 417 | + } else { |
|
| 418 | + $delai = "$minutes " . _T('date_minutes'); |
|
| 419 | + } |
|
| 420 | + } else { |
|
| 421 | + $secondes = ceil($decal); |
|
| 422 | + if ($secondes < 2) { |
|
| 423 | + $delai = "$secondes " . _T('date_une_seconde'); |
|
| 424 | + } else { |
|
| 425 | + $delai = "$secondes " . _T('date_secondes'); |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + return _T($il_y_a, ['delai' => $delai]); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
@@ -456,32 +456,32 @@ discard block |
||
| 456 | 456 | **/ |
| 457 | 457 | function date_relativecourt($date, $decalage_maxi = 0) { |
| 458 | 458 | |
| 459 | - if (!$date) { |
|
| 460 | - return; |
|
| 461 | - } |
|
| 462 | - $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 463 | - |
|
| 464 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 465 | - return ''; |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - if ($decal < -24 * 3600) { |
|
| 469 | - $retour = date_relative($date, $decalage_maxi); |
|
| 470 | - } elseif ($decal < 0) { |
|
| 471 | - $retour = _T('date_demain'); |
|
| 472 | - } else { |
|
| 473 | - if ($decal < (3600 * 24)) { |
|
| 474 | - $retour = _T('date_aujourdhui'); |
|
| 475 | - } else { |
|
| 476 | - if ($decal < (3600 * 24 * 2)) { |
|
| 477 | - $retour = _T('date_hier'); |
|
| 478 | - } else { |
|
| 479 | - $retour = date_relative($date, $decalage_maxi); |
|
| 480 | - } |
|
| 481 | - } |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - return $retour; |
|
| 459 | + if (!$date) { |
|
| 460 | + return; |
|
| 461 | + } |
|
| 462 | + $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 463 | + |
|
| 464 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 465 | + return ''; |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + if ($decal < -24 * 3600) { |
|
| 469 | + $retour = date_relative($date, $decalage_maxi); |
|
| 470 | + } elseif ($decal < 0) { |
|
| 471 | + $retour = _T('date_demain'); |
|
| 472 | + } else { |
|
| 473 | + if ($decal < (3600 * 24)) { |
|
| 474 | + $retour = _T('date_aujourdhui'); |
|
| 475 | + } else { |
|
| 476 | + if ($decal < (3600 * 24 * 2)) { |
|
| 477 | + $retour = _T('date_hier'); |
|
| 478 | + } else { |
|
| 479 | + $retour = date_relative($date, $decalage_maxi); |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + return $retour; |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -500,174 +500,174 @@ discard block |
||
| 500 | 500 | * @return mixed|string |
| 501 | 501 | */ |
| 502 | 502 | function affdate_base($numdate, $vue, $options = []) { |
| 503 | - if (is_string($options)) { |
|
| 504 | - $options = ['param' => $options]; |
|
| 505 | - } |
|
| 506 | - $date_array = recup_date($numdate, false); |
|
| 507 | - if (!$date_array) { |
|
| 508 | - return; |
|
| 509 | - } |
|
| 510 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 511 | - |
|
| 512 | - // 1er, 21st, etc. |
|
| 513 | - $journum = $jour; |
|
| 514 | - |
|
| 515 | - if ($jour == 0) { |
|
| 516 | - $jour = ''; |
|
| 517 | - $njour = 0; |
|
| 518 | - } else { |
|
| 519 | - $njour = intval($jour); |
|
| 520 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 521 | - $jour = $jourth; |
|
| 522 | - } |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - $mois = intval($mois); |
|
| 526 | - if ($mois > 0 and $mois < 13) { |
|
| 527 | - /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 528 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 529 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 530 | - if ($jour) { |
|
| 531 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 532 | - } else { |
|
| 533 | - $jourmois = $nommois; |
|
| 534 | - } |
|
| 535 | - } else { |
|
| 536 | - $nommois = ''; |
|
| 537 | - $jourmois = ''; |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - if ($annee < 0) { |
|
| 541 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 542 | - $avjc = true; |
|
| 543 | - } else { |
|
| 544 | - $avjc = false; |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - switch ($vue) { |
|
| 548 | - case 'saison': |
|
| 549 | - case 'saison_annee': |
|
| 550 | - $saison = ''; |
|
| 551 | - if ($mois > 0) { |
|
| 552 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 553 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 554 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 555 | - } |
|
| 556 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 557 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 558 | - } |
|
| 559 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 560 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 561 | - } |
|
| 562 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 563 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - if ($vue == 'saison') { |
|
| 567 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 568 | - } else { |
|
| 569 | - return $saison ? trim(_T( |
|
| 570 | - 'date_fmt_saison_annee', |
|
| 571 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 572 | - )) : ''; |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - case 'court': |
|
| 576 | - if ($avjc) { |
|
| 577 | - return $annee; |
|
| 578 | - } |
|
| 579 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 580 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 581 | - return $annee; |
|
| 582 | - } |
|
| 583 | - if ($annee != $a) { |
|
| 584 | - return _T( |
|
| 585 | - 'date_fmt_mois_annee', |
|
| 586 | - ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 587 | - ); |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - return _T( |
|
| 591 | - 'date_fmt_jour_mois', |
|
| 592 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 593 | - ); |
|
| 594 | - |
|
| 595 | - case 'jourcourt': |
|
| 596 | - if ($avjc) { |
|
| 597 | - return $annee; |
|
| 598 | - } |
|
| 599 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 600 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 601 | - return $annee; |
|
| 602 | - } |
|
| 603 | - if ($annee != $a) { |
|
| 604 | - return _T( |
|
| 605 | - 'date_fmt_jour_mois_annee', |
|
| 606 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 607 | - ); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - return _T( |
|
| 611 | - 'date_fmt_jour_mois', |
|
| 612 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 613 | - ); |
|
| 614 | - |
|
| 615 | - case 'entier': |
|
| 616 | - if ($avjc) { |
|
| 617 | - return $annee; |
|
| 618 | - } |
|
| 619 | - if ($jour) { |
|
| 620 | - return _T( |
|
| 621 | - 'date_fmt_jour_mois_annee', |
|
| 622 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 623 | - ); |
|
| 624 | - } elseif ($mois) { |
|
| 625 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 626 | - } else { |
|
| 627 | - return $annee; |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - case 'nom_mois': |
|
| 631 | - return $nommois; |
|
| 632 | - |
|
| 633 | - case 'mois': |
|
| 634 | - return sprintf('%02s', $mois); |
|
| 635 | - |
|
| 636 | - case 'jour': |
|
| 637 | - return $jour; |
|
| 638 | - |
|
| 639 | - case 'journum': |
|
| 640 | - return $journum; |
|
| 641 | - |
|
| 642 | - case 'nom_jour': |
|
| 643 | - if (!$mois or !$njour) { |
|
| 644 | - return ''; |
|
| 645 | - } |
|
| 646 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 647 | - $nom = 1 + date('w', $nom); |
|
| 648 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 649 | - |
|
| 650 | - return _T('date_jour_' . $nom . $param); |
|
| 651 | - |
|
| 652 | - case 'mois_annee': |
|
| 653 | - if ($avjc) { |
|
| 654 | - return $annee; |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 658 | - |
|
| 659 | - case 'annee': |
|
| 660 | - return $annee; |
|
| 661 | - |
|
| 662 | - // Cas d'une vue non definie : retomber sur le format |
|
| 663 | - // de date propose par http://www.php.net/date |
|
| 664 | - default: |
|
| 665 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 666 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee)) { |
|
| 667 | - $time = strtotime($numdate); |
|
| 668 | - } |
|
| 669 | - return date($vue, $time); |
|
| 670 | - } |
|
| 503 | + if (is_string($options)) { |
|
| 504 | + $options = ['param' => $options]; |
|
| 505 | + } |
|
| 506 | + $date_array = recup_date($numdate, false); |
|
| 507 | + if (!$date_array) { |
|
| 508 | + return; |
|
| 509 | + } |
|
| 510 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 511 | + |
|
| 512 | + // 1er, 21st, etc. |
|
| 513 | + $journum = $jour; |
|
| 514 | + |
|
| 515 | + if ($jour == 0) { |
|
| 516 | + $jour = ''; |
|
| 517 | + $njour = 0; |
|
| 518 | + } else { |
|
| 519 | + $njour = intval($jour); |
|
| 520 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 521 | + $jour = $jourth; |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + $mois = intval($mois); |
|
| 526 | + if ($mois > 0 and $mois < 13) { |
|
| 527 | + /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 528 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 529 | + $nommois = _T('date_mois_' . $mois . $param); |
|
| 530 | + if ($jour) { |
|
| 531 | + $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 532 | + } else { |
|
| 533 | + $jourmois = $nommois; |
|
| 534 | + } |
|
| 535 | + } else { |
|
| 536 | + $nommois = ''; |
|
| 537 | + $jourmois = ''; |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + if ($annee < 0) { |
|
| 541 | + $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 542 | + $avjc = true; |
|
| 543 | + } else { |
|
| 544 | + $avjc = false; |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + switch ($vue) { |
|
| 548 | + case 'saison': |
|
| 549 | + case 'saison_annee': |
|
| 550 | + $saison = ''; |
|
| 551 | + if ($mois > 0) { |
|
| 552 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 553 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 554 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 555 | + } |
|
| 556 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 557 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 558 | + } |
|
| 559 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 560 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 561 | + } |
|
| 562 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 563 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + if ($vue == 'saison') { |
|
| 567 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 568 | + } else { |
|
| 569 | + return $saison ? trim(_T( |
|
| 570 | + 'date_fmt_saison_annee', |
|
| 571 | + ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 572 | + )) : ''; |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + case 'court': |
|
| 576 | + if ($avjc) { |
|
| 577 | + return $annee; |
|
| 578 | + } |
|
| 579 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 580 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 581 | + return $annee; |
|
| 582 | + } |
|
| 583 | + if ($annee != $a) { |
|
| 584 | + return _T( |
|
| 585 | + 'date_fmt_mois_annee', |
|
| 586 | + ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 587 | + ); |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + return _T( |
|
| 591 | + 'date_fmt_jour_mois', |
|
| 592 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 593 | + ); |
|
| 594 | + |
|
| 595 | + case 'jourcourt': |
|
| 596 | + if ($avjc) { |
|
| 597 | + return $annee; |
|
| 598 | + } |
|
| 599 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 600 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 601 | + return $annee; |
|
| 602 | + } |
|
| 603 | + if ($annee != $a) { |
|
| 604 | + return _T( |
|
| 605 | + 'date_fmt_jour_mois_annee', |
|
| 606 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 607 | + ); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + return _T( |
|
| 611 | + 'date_fmt_jour_mois', |
|
| 612 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 613 | + ); |
|
| 614 | + |
|
| 615 | + case 'entier': |
|
| 616 | + if ($avjc) { |
|
| 617 | + return $annee; |
|
| 618 | + } |
|
| 619 | + if ($jour) { |
|
| 620 | + return _T( |
|
| 621 | + 'date_fmt_jour_mois_annee', |
|
| 622 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 623 | + ); |
|
| 624 | + } elseif ($mois) { |
|
| 625 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 626 | + } else { |
|
| 627 | + return $annee; |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + case 'nom_mois': |
|
| 631 | + return $nommois; |
|
| 632 | + |
|
| 633 | + case 'mois': |
|
| 634 | + return sprintf('%02s', $mois); |
|
| 635 | + |
|
| 636 | + case 'jour': |
|
| 637 | + return $jour; |
|
| 638 | + |
|
| 639 | + case 'journum': |
|
| 640 | + return $journum; |
|
| 641 | + |
|
| 642 | + case 'nom_jour': |
|
| 643 | + if (!$mois or !$njour) { |
|
| 644 | + return ''; |
|
| 645 | + } |
|
| 646 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 647 | + $nom = 1 + date('w', $nom); |
|
| 648 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 649 | + |
|
| 650 | + return _T('date_jour_' . $nom . $param); |
|
| 651 | + |
|
| 652 | + case 'mois_annee': |
|
| 653 | + if ($avjc) { |
|
| 654 | + return $annee; |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 658 | + |
|
| 659 | + case 'annee': |
|
| 660 | + return $annee; |
|
| 661 | + |
|
| 662 | + // Cas d'une vue non definie : retomber sur le format |
|
| 663 | + // de date propose par http://www.php.net/date |
|
| 664 | + default: |
|
| 665 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 666 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee)) { |
|
| 667 | + $time = strtotime($numdate); |
|
| 668 | + } |
|
| 669 | + return date($vue, $time); |
|
| 670 | + } |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | |
@@ -694,11 +694,11 @@ discard block |
||
| 694 | 694 | * Nom du jour |
| 695 | 695 | **/ |
| 696 | 696 | function nom_jour($numdate, $forme = '') { |
| 697 | - if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 698 | - $forme = ''; |
|
| 699 | - } |
|
| 697 | + if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 698 | + $forme = ''; |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | - return affdate_base($numdate, 'nom_jour', $forme); |
|
| 701 | + return affdate_base($numdate, 'nom_jour', $forme); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | /** |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | * Numéro du jour |
| 721 | 721 | **/ |
| 722 | 722 | function jour($numdate) { |
| 723 | - return affdate_base($numdate, 'jour'); |
|
| 723 | + return affdate_base($numdate, 'jour'); |
|
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | /** |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | * Numéro du jour |
| 739 | 739 | **/ |
| 740 | 740 | function journum($numdate) { |
| 741 | - return affdate_base($numdate, 'journum'); |
|
| 741 | + return affdate_base($numdate, 'journum'); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | /** |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | * Numéro du mois (sur 2 chiffres) |
| 757 | 757 | **/ |
| 758 | 758 | function mois($numdate) { |
| 759 | - return affdate_base($numdate, 'mois'); |
|
| 759 | + return affdate_base($numdate, 'mois'); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
@@ -780,11 +780,11 @@ discard block |
||
| 780 | 780 | * Nom du mois |
| 781 | 781 | **/ |
| 782 | 782 | function nom_mois($numdate, $forme = '') { |
| 783 | - if (!($forme == 'abbr')) { |
|
| 784 | - $forme = ''; |
|
| 785 | - } |
|
| 783 | + if (!($forme == 'abbr')) { |
|
| 784 | + $forme = ''; |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | - return affdate_base($numdate, 'nom_mois', $forme); |
|
| 787 | + return affdate_base($numdate, 'nom_mois', $forme); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | * Année (sur 4 chiffres) |
| 803 | 803 | **/ |
| 804 | 804 | function annee($numdate) { |
| 805 | - return affdate_base($numdate, 'annee'); |
|
| 805 | + return affdate_base($numdate, 'annee'); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | |
@@ -832,11 +832,11 @@ discard block |
||
| 832 | 832 | * La date formatée |
| 833 | 833 | **/ |
| 834 | 834 | function saison($numdate, $hemisphere = 'nord') { |
| 835 | - if ($hemisphere != 'sud') { |
|
| 836 | - $hemisphere = 'nord'; |
|
| 837 | - } |
|
| 835 | + if ($hemisphere != 'sud') { |
|
| 836 | + $hemisphere = 'nord'; |
|
| 837 | + } |
|
| 838 | 838 | |
| 839 | - return affdate_base($numdate, 'saison', $hemisphere); |
|
| 839 | + return affdate_base($numdate, 'saison', $hemisphere); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | |
@@ -865,11 +865,11 @@ discard block |
||
| 865 | 865 | * La date formatée |
| 866 | 866 | **/ |
| 867 | 867 | function saison_annee($numdate, $hemisphere = 'nord') { |
| 868 | - if ($hemisphere != 'sud') { |
|
| 869 | - $hemisphere = 'nord'; |
|
| 870 | - } |
|
| 868 | + if ($hemisphere != 'sud') { |
|
| 869 | + $hemisphere = 'nord'; |
|
| 870 | + } |
|
| 871 | 871 | |
| 872 | - return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 872 | + return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | /** |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | * La date formatée |
| 898 | 898 | **/ |
| 899 | 899 | function affdate($numdate, $format = 'entier') { |
| 900 | - return affdate_base($numdate, $format); |
|
| 900 | + return affdate_base($numdate, $format); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | * La date formatée |
| 925 | 925 | **/ |
| 926 | 926 | function affdate_court($numdate, $annee_courante = null) { |
| 927 | - return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 927 | + return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | * La date formatée |
| 952 | 952 | **/ |
| 953 | 953 | function affdate_jourcourt($numdate, $annee_courante = null) { |
| 954 | - return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 954 | + return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | /** |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | * La date formatée |
| 970 | 970 | **/ |
| 971 | 971 | function affdate_mois_annee($numdate) { |
| 972 | - return affdate_base($numdate, 'mois_annee'); |
|
| 972 | + return affdate_base($numdate, 'mois_annee'); |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | /** |
@@ -987,16 +987,16 @@ discard block |
||
| 987 | 987 | * La date formatée |
| 988 | 988 | **/ |
| 989 | 989 | function affdate_heure($numdate) { |
| 990 | - $date_array = recup_date($numdate); |
|
| 991 | - if (!$date_array) { |
|
| 992 | - return; |
|
| 993 | - } |
|
| 994 | - list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 995 | - |
|
| 996 | - return _T('date_fmt_jour_heure', [ |
|
| 997 | - 'jour' => affdate($numdate), |
|
| 998 | - 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 999 | - ]); |
|
| 990 | + $date_array = recup_date($numdate); |
|
| 991 | + if (!$date_array) { |
|
| 992 | + return; |
|
| 993 | + } |
|
| 994 | + list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 995 | + |
|
| 996 | + return _T('date_fmt_jour_heure', [ |
|
| 997 | + 'jour' => affdate($numdate), |
|
| 998 | + 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 999 | + ]); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1028,117 +1028,117 @@ discard block |
||
| 1028 | 1028 | * Texte de la date |
| 1029 | 1029 | */ |
| 1030 | 1030 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '') { |
| 1031 | - $abbr = $jour = ''; |
|
| 1032 | - $affdate = 'affdate_jourcourt'; |
|
| 1033 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1034 | - $abbr = 'abbr'; |
|
| 1035 | - } |
|
| 1036 | - if (strpos($forme, 'annee') !== false) { |
|
| 1037 | - $affdate = 'affdate'; |
|
| 1038 | - } |
|
| 1039 | - if (strpos($forme, 'jour') !== false) { |
|
| 1040 | - $jour = 'jour'; |
|
| 1041 | - } |
|
| 1042 | - |
|
| 1043 | - $dtstart = $dtend = $dtabbr = ''; |
|
| 1044 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1045 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1046 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1047 | - $dtabbr = '</abbr>'; |
|
| 1048 | - } |
|
| 1049 | - |
|
| 1050 | - $date_debut = strtotime($date_debut); |
|
| 1051 | - $date_fin = strtotime($date_fin); |
|
| 1052 | - $d = date('Y-m-d', $date_debut); |
|
| 1053 | - $f = date('Y-m-d', $date_fin); |
|
| 1054 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1055 | - $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1056 | - $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1057 | - |
|
| 1058 | - if ($d == $f) { // meme jour |
|
| 1059 | - $nomjour = nom_jour($d, $abbr); |
|
| 1060 | - $s = $affdate($d); |
|
| 1061 | - $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1062 | - if ($h) { |
|
| 1063 | - if ($hd == $hf) { |
|
| 1064 | - // Lundi 20 fevrier a 18h25 |
|
| 1065 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1066 | - $s = "$dtstart$s$dtabbr"; |
|
| 1067 | - } else { |
|
| 1068 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1069 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1070 | - $s = _T( |
|
| 1071 | - 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1072 | - [ |
|
| 1073 | - 'jour' => spip_ucfirst($s), |
|
| 1074 | - 'heure_debut' => $hd, |
|
| 1075 | - 'heure_fin' => $hf, |
|
| 1076 | - 'dtstart' => $dtstart, |
|
| 1077 | - 'dtend' => $dtend, |
|
| 1078 | - 'dtabbr' => $dtabbr |
|
| 1079 | - ], |
|
| 1080 | - [ |
|
| 1081 | - 'sanitize' => false |
|
| 1082 | - ] |
|
| 1083 | - ); |
|
| 1084 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1085 | - else { |
|
| 1086 | - $s = spip_ucfirst(_T( |
|
| 1087 | - 'date_fmt_jour_heure_debut_fin', |
|
| 1088 | - ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1089 | - )); |
|
| 1090 | - } |
|
| 1091 | - } |
|
| 1092 | - } else { |
|
| 1093 | - if ($dtabbr && $dtstart) { |
|
| 1094 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1095 | - } else { |
|
| 1096 | - $s = spip_ucfirst($s); |
|
| 1097 | - } |
|
| 1098 | - } |
|
| 1099 | - } else { |
|
| 1100 | - if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1101 | - if (!$h) { |
|
| 1102 | - $date_debut = jour($d); |
|
| 1103 | - } else { |
|
| 1104 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1105 | - } |
|
| 1106 | - $date_fin = $affdate($f); |
|
| 1107 | - if ($jour) { |
|
| 1108 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1109 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1110 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1111 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1112 | - } |
|
| 1113 | - if ($h) { |
|
| 1114 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1115 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1116 | - } |
|
| 1117 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1118 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1119 | - |
|
| 1120 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1121 | - } else { |
|
| 1122 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1123 | - $date_fin = $affdate($f); |
|
| 1124 | - if ($jour) { |
|
| 1125 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1126 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1127 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1128 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1129 | - } |
|
| 1130 | - if ($h) { |
|
| 1131 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1132 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1133 | - } |
|
| 1134 | - |
|
| 1135 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1136 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1137 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1138 | - } |
|
| 1139 | - } |
|
| 1140 | - |
|
| 1141 | - return $s; |
|
| 1031 | + $abbr = $jour = ''; |
|
| 1032 | + $affdate = 'affdate_jourcourt'; |
|
| 1033 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1034 | + $abbr = 'abbr'; |
|
| 1035 | + } |
|
| 1036 | + if (strpos($forme, 'annee') !== false) { |
|
| 1037 | + $affdate = 'affdate'; |
|
| 1038 | + } |
|
| 1039 | + if (strpos($forme, 'jour') !== false) { |
|
| 1040 | + $jour = 'jour'; |
|
| 1041 | + } |
|
| 1042 | + |
|
| 1043 | + $dtstart = $dtend = $dtabbr = ''; |
|
| 1044 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1045 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1046 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1047 | + $dtabbr = '</abbr>'; |
|
| 1048 | + } |
|
| 1049 | + |
|
| 1050 | + $date_debut = strtotime($date_debut); |
|
| 1051 | + $date_fin = strtotime($date_fin); |
|
| 1052 | + $d = date('Y-m-d', $date_debut); |
|
| 1053 | + $f = date('Y-m-d', $date_fin); |
|
| 1054 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1055 | + $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1056 | + $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1057 | + |
|
| 1058 | + if ($d == $f) { // meme jour |
|
| 1059 | + $nomjour = nom_jour($d, $abbr); |
|
| 1060 | + $s = $affdate($d); |
|
| 1061 | + $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1062 | + if ($h) { |
|
| 1063 | + if ($hd == $hf) { |
|
| 1064 | + // Lundi 20 fevrier a 18h25 |
|
| 1065 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1066 | + $s = "$dtstart$s$dtabbr"; |
|
| 1067 | + } else { |
|
| 1068 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1069 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1070 | + $s = _T( |
|
| 1071 | + 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1072 | + [ |
|
| 1073 | + 'jour' => spip_ucfirst($s), |
|
| 1074 | + 'heure_debut' => $hd, |
|
| 1075 | + 'heure_fin' => $hf, |
|
| 1076 | + 'dtstart' => $dtstart, |
|
| 1077 | + 'dtend' => $dtend, |
|
| 1078 | + 'dtabbr' => $dtabbr |
|
| 1079 | + ], |
|
| 1080 | + [ |
|
| 1081 | + 'sanitize' => false |
|
| 1082 | + ] |
|
| 1083 | + ); |
|
| 1084 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1085 | + else { |
|
| 1086 | + $s = spip_ucfirst(_T( |
|
| 1087 | + 'date_fmt_jour_heure_debut_fin', |
|
| 1088 | + ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1089 | + )); |
|
| 1090 | + } |
|
| 1091 | + } |
|
| 1092 | + } else { |
|
| 1093 | + if ($dtabbr && $dtstart) { |
|
| 1094 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1095 | + } else { |
|
| 1096 | + $s = spip_ucfirst($s); |
|
| 1097 | + } |
|
| 1098 | + } |
|
| 1099 | + } else { |
|
| 1100 | + if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1101 | + if (!$h) { |
|
| 1102 | + $date_debut = jour($d); |
|
| 1103 | + } else { |
|
| 1104 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1105 | + } |
|
| 1106 | + $date_fin = $affdate($f); |
|
| 1107 | + if ($jour) { |
|
| 1108 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1109 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1110 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1111 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1112 | + } |
|
| 1113 | + if ($h) { |
|
| 1114 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1115 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1116 | + } |
|
| 1117 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1118 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1119 | + |
|
| 1120 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1121 | + } else { |
|
| 1122 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1123 | + $date_fin = $affdate($f); |
|
| 1124 | + if ($jour) { |
|
| 1125 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1126 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1127 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1128 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1129 | + } |
|
| 1130 | + if ($h) { |
|
| 1131 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1132 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1136 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1137 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1138 | + } |
|
| 1139 | + } |
|
| 1140 | + |
|
| 1141 | + return $s; |
|
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | /** |
@@ -1159,10 +1159,10 @@ discard block |
||
| 1159 | 1159 | * Date au format ical |
| 1160 | 1160 | **/ |
| 1161 | 1161 | function date_ical($date, $addminutes = 0) { |
| 1162 | - list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1163 | - list($annee, $mois, $jour) = recup_date($date); |
|
| 1162 | + list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1163 | + list($annee, $mois, $jour) = recup_date($date); |
|
| 1164 | 1164 | |
| 1165 | - return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1165 | + return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | |
@@ -1186,11 +1186,11 @@ discard block |
||
| 1186 | 1186 | * La date formatée |
| 1187 | 1187 | **/ |
| 1188 | 1188 | function date_iso($date_heure) { |
| 1189 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1190 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1191 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1189 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1190 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1191 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1192 | 1192 | |
| 1193 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1193 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | /** |
@@ -1213,11 +1213,11 @@ discard block |
||
| 1213 | 1213 | * La date formatée |
| 1214 | 1214 | **/ |
| 1215 | 1215 | function date_822($date_heure) { |
| 1216 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1217 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1218 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1216 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1217 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1218 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1219 | 1219 | |
| 1220 | - return date('r', $time); |
|
| 1220 | + return date('r', $time); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | /** |
@@ -1233,11 +1233,11 @@ discard block |
||
| 1233 | 1233 | * Date au format `Ymd` |
| 1234 | 1234 | **/ |
| 1235 | 1235 | function date_anneemoisjour($d) { |
| 1236 | - if (!$d) { |
|
| 1237 | - $d = date('Y-m-d'); |
|
| 1238 | - } |
|
| 1236 | + if (!$d) { |
|
| 1237 | + $d = date('Y-m-d'); |
|
| 1238 | + } |
|
| 1239 | 1239 | |
| 1240 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1240 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
@@ -1253,11 +1253,11 @@ discard block |
||
| 1253 | 1253 | * Date au format `Ym` |
| 1254 | 1254 | **/ |
| 1255 | 1255 | function date_anneemois($d) { |
| 1256 | - if (!$d) { |
|
| 1257 | - $d = date('Y-m-d'); |
|
| 1258 | - } |
|
| 1256 | + if (!$d) { |
|
| 1257 | + $d = date('Y-m-d'); |
|
| 1258 | + } |
|
| 1259 | 1259 | |
| 1260 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1260 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | /** |
@@ -1273,13 +1273,13 @@ discard block |
||
| 1273 | 1273 | * Date au lundi de la même semaine au format `Ymd` |
| 1274 | 1274 | **/ |
| 1275 | 1275 | function date_debut_semaine($annee, $mois, $jour) { |
| 1276 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1277 | - if ($w_day == 0) { |
|
| 1278 | - $w_day = 7; |
|
| 1279 | - } // Gaffe: le dimanche est zero |
|
| 1280 | - $debut = $jour - $w_day + 1; |
|
| 1276 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1277 | + if ($w_day == 0) { |
|
| 1278 | + $w_day = 7; |
|
| 1279 | + } // Gaffe: le dimanche est zero |
|
| 1280 | + $debut = $jour - $w_day + 1; |
|
| 1281 | 1281 | |
| 1282 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1282 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | 1285 | /** |
@@ -1295,11 +1295,11 @@ discard block |
||
| 1295 | 1295 | * Date au dimanche de la même semaine au format `Ymd` |
| 1296 | 1296 | **/ |
| 1297 | 1297 | function date_fin_semaine($annee, $mois, $jour) { |
| 1298 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1299 | - if ($w_day == 0) { |
|
| 1300 | - $w_day = 7; |
|
| 1301 | - } // Gaffe: le dimanche est zero |
|
| 1302 | - $debut = $jour - $w_day + 1; |
|
| 1298 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1299 | + if ($w_day == 0) { |
|
| 1300 | + $w_day = 7; |
|
| 1301 | + } // Gaffe: le dimanche est zero |
|
| 1302 | + $debut = $jour - $w_day + 1; |
|
| 1303 | 1303 | |
| 1304 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1304 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1305 | 1305 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | function extraire_date($texte) { |
| 39 | 39 | // format = 2001-08 |
| 40 | 40 | if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
| 41 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 41 | + return $regs[1].'-'.sprintf('%02d', $regs[2]).'-01'; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 70 | 70 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 71 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 71 | + $date = $regs[1].'-00-00'.$regs[3]; |
|
| 72 | 72 | } else { |
| 73 | 73 | if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 74 | 74 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 75 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 75 | + $date = preg_replace('@/@', '-', $regs[1]).'-00'.$regs[3]; |
|
| 76 | 76 | } else { |
| 77 | 77 | $date = date('Y-m-d H:i:s', strtotime($date)); |
| 78 | 78 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | 99 | if ( |
| 100 | 100 | !$verif_format_date |
| 101 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 101 | + or (in_array(strlen($letexte), [10, 19]) and |
|
| 102 | 102 | preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
| 103 | 103 | ) { |
| 104 | 104 | if (strncmp('0000-00-00', $letexte, 10) == 0) { |
@@ -381,17 +381,17 @@ discard block |
||
| 381 | 381 | if ($decal > 3600 * 24 * 30) { |
| 382 | 382 | $mois = floor($decal / (3600 * 24 * 30)); |
| 383 | 383 | if ($mois < 2) { |
| 384 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 384 | + $delai = "$mois "._T('date_un_mois'); |
|
| 385 | 385 | } else { |
| 386 | - $delai = "$mois " . _T('date_mois'); |
|
| 386 | + $delai = "$mois "._T('date_mois'); |
|
| 387 | 387 | } |
| 388 | 388 | } else { |
| 389 | 389 | if ($decal > 3600 * 24 * 7) { |
| 390 | 390 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 391 | 391 | if ($semaines < 2) { |
| 392 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 392 | + $delai = "$semaines "._T('date_une_semaine'); |
|
| 393 | 393 | } else { |
| 394 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 394 | + $delai = "$semaines "._T('date_semaines'); |
|
| 395 | 395 | } |
| 396 | 396 | } else { |
| 397 | 397 | if ($decal > 3600 * 24) { |
@@ -399,30 +399,30 @@ discard block |
||
| 399 | 399 | if ($jours < 2) { |
| 400 | 400 | return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
| 401 | 401 | } else { |
| 402 | - $delai = "$jours " . _T('date_jours'); |
|
| 402 | + $delai = "$jours "._T('date_jours'); |
|
| 403 | 403 | } |
| 404 | 404 | } else { |
| 405 | 405 | if ($decal >= 3600) { |
| 406 | 406 | $heures = floor($decal / 3600); |
| 407 | 407 | if ($heures < 2) { |
| 408 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 408 | + $delai = "$heures "._T('date_une_heure'); |
|
| 409 | 409 | } else { |
| 410 | - $delai = "$heures " . _T('date_heures'); |
|
| 410 | + $delai = "$heures "._T('date_heures'); |
|
| 411 | 411 | } |
| 412 | 412 | } else { |
| 413 | 413 | if ($decal >= 60) { |
| 414 | 414 | $minutes = floor($decal / 60); |
| 415 | 415 | if ($minutes < 2) { |
| 416 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 416 | + $delai = "$minutes "._T('date_une_minute'); |
|
| 417 | 417 | } else { |
| 418 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 418 | + $delai = "$minutes "._T('date_minutes'); |
|
| 419 | 419 | } |
| 420 | 420 | } else { |
| 421 | 421 | $secondes = ceil($decal); |
| 422 | 422 | if ($secondes < 2) { |
| 423 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 423 | + $delai = "$secondes "._T('date_une_seconde'); |
|
| 424 | 424 | } else { |
| 425 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 425 | + $delai = "$secondes "._T('date_secondes'); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | $njour = 0; |
| 518 | 518 | } else { |
| 519 | 519 | $njour = intval($jour); |
| 520 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 520 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 521 | 521 | $jour = $jourth; |
| 522 | 522 | } |
| 523 | 523 | } |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | $mois = intval($mois); |
| 526 | 526 | if ($mois > 0 and $mois < 13) { |
| 527 | 527 | /* Traiter le cas "abbr" pour les noms de mois */ |
| 528 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 529 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 528 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_'.$options['param'] : ''); |
|
| 529 | + $nommois = _T('date_mois_'.$mois.$param); |
|
| 530 | 530 | if ($jour) { |
| 531 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 531 | + $jourmois = _T('date_de_mois_'.$mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 532 | 532 | } else { |
| 533 | 533 | $jourmois = $nommois; |
| 534 | 534 | } |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | if ($annee < 0) { |
| 541 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 541 | + $annee = -$annee.' '._T('date_avant_jc'); |
|
| 542 | 542 | $avjc = true; |
| 543 | 543 | } else { |
| 544 | 544 | $avjc = false; |
@@ -564,11 +564,11 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | if ($vue == 'saison') { |
| 567 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 567 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 568 | 568 | } else { |
| 569 | 569 | return $saison ? trim(_T( |
| 570 | 570 | 'date_fmt_saison_annee', |
| 571 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 571 | + ['saison' => _T('date_saison_'.$saison), 'annee' => $annee] |
|
| 572 | 572 | )) : ''; |
| 573 | 573 | } |
| 574 | 574 | |
@@ -645,9 +645,9 @@ discard block |
||
| 645 | 645 | } |
| 646 | 646 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 647 | 647 | $nom = 1 + date('w', $nom); |
| 648 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 648 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 649 | 649 | |
| 650 | - return _T('date_jour_' . $nom . $param); |
|
| 650 | + return _T('date_jour_'.$nom.$param); |
|
| 651 | 651 | |
| 652 | 652 | case 'mois_annee': |
| 653 | 653 | if ($avjc) { |
@@ -1042,8 +1042,8 @@ discard block |
||
| 1042 | 1042 | |
| 1043 | 1043 | $dtstart = $dtend = $dtabbr = ''; |
| 1044 | 1044 | if (strpos($forme, 'hcal') !== false) { |
| 1045 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1046 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1045 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1046 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1047 | 1047 | $dtabbr = '</abbr>'; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
@@ -1091,7 +1091,7 @@ discard block |
||
| 1091 | 1091 | } |
| 1092 | 1092 | } else { |
| 1093 | 1093 | if ($dtabbr && $dtstart) { |
| 1094 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1094 | + $s = $dtstart.spip_ucfirst($s).$dtabbr; |
|
| 1095 | 1095 | } else { |
| 1096 | 1096 | $s = spip_ucfirst($s); |
| 1097 | 1097 | } |
@@ -1114,8 +1114,8 @@ discard block |
||
| 1114 | 1114 | $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
| 1115 | 1115 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1116 | 1116 | } |
| 1117 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1118 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1117 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1118 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1119 | 1119 | |
| 1120 | 1120 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1121 | 1121 | } else { |
@@ -1132,8 +1132,8 @@ discard block |
||
| 1132 | 1132 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1136 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1135 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1136 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1137 | 1137 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1138 | 1138 | } |
| 1139 | 1139 | } |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | $d = date('Y-m-d'); |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1240 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | $d = date('Y-m-d'); |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1260 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | /** |
@@ -212,8 +212,7 @@ |
||
| 212 | 212 | function heures_minutes($numdate, $forme = '') { |
| 213 | 213 | if ($forme != 'abbr') { |
| 214 | 214 | return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
| 215 | - } |
|
| 216 | - else { |
|
| 215 | + } else { |
|
| 217 | 216 | return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
| 218 | 217 | } |
| 219 | 218 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | include_spip('inc/config'); |
@@ -32,31 +32,31 @@ discard block |
||
| 32 | 32 | * @return array |
| 33 | 33 | */ |
| 34 | 34 | function cvtconf_formulaire_charger($flux) { |
| 35 | - if ( |
|
| 36 | - $form = $flux['args']['form'] |
|
| 37 | - and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX |
|
| 38 | - ) { |
|
| 39 | - // Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé |
|
| 40 | - include_spip('inc/autoriser'); |
|
| 41 | - if (!autoriser('configurer', '_' . substr($form, 11))) { |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 35 | + if ( |
|
| 36 | + $form = $flux['args']['form'] |
|
| 37 | + and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX |
|
| 38 | + ) { |
|
| 39 | + // Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé |
|
| 40 | + include_spip('inc/autoriser'); |
|
| 41 | + if (!autoriser('configurer', '_' . substr($form, 11))) { |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // S'il n'y a pas de fonction charger(), on génère un contexte automatiquement |
|
| 46 | - if (!charger_fonction('charger', "formulaires/$form/", true)) { |
|
| 47 | - $flux['data'] = cvtconf_formulaires_configurer_recense($form); |
|
| 48 | - $flux['data']['editable'] = true; |
|
| 49 | - if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
|
| 50 | - if (!_AJAX) { |
|
| 51 | - var_dump($flux['data']); |
|
| 52 | - } |
|
| 53 | - // reinjecter pour la trace au traitement |
|
| 54 | - $flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />"; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - } |
|
| 45 | + // S'il n'y a pas de fonction charger(), on génère un contexte automatiquement |
|
| 46 | + if (!charger_fonction('charger', "formulaires/$form/", true)) { |
|
| 47 | + $flux['data'] = cvtconf_formulaires_configurer_recense($form); |
|
| 48 | + $flux['data']['editable'] = true; |
|
| 49 | + if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
|
| 50 | + if (!_AJAX) { |
|
| 51 | + var_dump($flux['data']); |
|
| 52 | + } |
|
| 53 | + // reinjecter pour la trace au traitement |
|
| 54 | + $flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />"; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - return $flux; |
|
| 59 | + return $flux; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -66,16 +66,16 @@ discard block |
||
| 66 | 66 | * @return array |
| 67 | 67 | */ |
| 68 | 68 | function cvtconf_formulaire_traiter($flux) { |
| 69 | - if ( |
|
| 70 | - $form = $flux['args']['form'] |
|
| 71 | - and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX |
|
| 72 | - and !charger_fonction('traiter', "formulaires/$form/", true) // sans fonction traiter() |
|
| 73 | - ) { |
|
| 74 | - $trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']); |
|
| 75 | - $flux['data'] = ['message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true]; |
|
| 76 | - } |
|
| 69 | + if ( |
|
| 70 | + $form = $flux['args']['form'] |
|
| 71 | + and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX |
|
| 72 | + and !charger_fonction('traiter', "formulaires/$form/", true) // sans fonction traiter() |
|
| 73 | + ) { |
|
| 74 | + $trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']); |
|
| 75 | + $flux['data'] = ['message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true]; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - return $flux; |
|
| 78 | + return $flux; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -91,32 +91,32 @@ discard block |
||
| 91 | 91 | * @return string |
| 92 | 92 | */ |
| 93 | 93 | function cvtconf_formulaires_configurer_enregistre($form, $args) { |
| 94 | - $valeurs = []; |
|
| 95 | - // charger les valeurs |
|
| 96 | - // ce qui permet de prendre en charge une fonction charger() existante |
|
| 97 | - // qui prend alors la main sur l'auto detection |
|
| 98 | - if ($charger_valeurs = charger_fonction('charger', "formulaires/$form/", true)) { |
|
| 99 | - $valeurs = call_user_func_array($charger_valeurs, $args); |
|
| 100 | - } |
|
| 101 | - $valeurs = pipeline( |
|
| 102 | - 'formulaire_charger', |
|
| 103 | - [ |
|
| 104 | - 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => false], |
|
| 105 | - 'data' => $valeurs |
|
| 106 | - ] |
|
| 107 | - ); |
|
| 108 | - // ne pas stocker editable ! |
|
| 109 | - unset($valeurs['editable']); |
|
| 94 | + $valeurs = []; |
|
| 95 | + // charger les valeurs |
|
| 96 | + // ce qui permet de prendre en charge une fonction charger() existante |
|
| 97 | + // qui prend alors la main sur l'auto detection |
|
| 98 | + if ($charger_valeurs = charger_fonction('charger', "formulaires/$form/", true)) { |
|
| 99 | + $valeurs = call_user_func_array($charger_valeurs, $args); |
|
| 100 | + } |
|
| 101 | + $valeurs = pipeline( |
|
| 102 | + 'formulaire_charger', |
|
| 103 | + [ |
|
| 104 | + 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => false], |
|
| 105 | + 'data' => $valeurs |
|
| 106 | + ] |
|
| 107 | + ); |
|
| 108 | + // ne pas stocker editable ! |
|
| 109 | + unset($valeurs['editable']); |
|
| 110 | 110 | |
| 111 | - // recuperer les valeurs postees |
|
| 112 | - $store = []; |
|
| 113 | - foreach ($valeurs as $k => $v) { |
|
| 114 | - if (substr($k, 0, 1) !== '_') { |
|
| 115 | - $store[$k] = _request($k); |
|
| 116 | - } |
|
| 117 | - } |
|
| 111 | + // recuperer les valeurs postees |
|
| 112 | + $store = []; |
|
| 113 | + foreach ($valeurs as $k => $v) { |
|
| 114 | + if (substr($k, 0, 1) !== '_') { |
|
| 115 | + $store[$k] = _request($k); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - return cvtconf_configurer_stocker($form, $valeurs, $store); |
|
| 119 | + return cvtconf_configurer_stocker($form, $valeurs, $store); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -132,31 +132,31 @@ discard block |
||
| 132 | 132 | * @return array |
| 133 | 133 | */ |
| 134 | 134 | function cvtconf_definir_configurer_conteneur($form, $valeurs) { |
| 135 | - // stocker en base |
|
| 136 | - // par defaut, dans un casier serialize dans spip_meta (idem CFG) |
|
| 137 | - $casier = substr($form, 11); |
|
| 138 | - $table = 'meta'; |
|
| 139 | - $prefixe = ''; |
|
| 140 | - $stockage = ''; |
|
| 135 | + // stocker en base |
|
| 136 | + // par defaut, dans un casier serialize dans spip_meta (idem CFG) |
|
| 137 | + $casier = substr($form, 11); |
|
| 138 | + $table = 'meta'; |
|
| 139 | + $prefixe = ''; |
|
| 140 | + $stockage = ''; |
|
| 141 | 141 | |
| 142 | - if (isset($valeurs['_meta_casier'])) { |
|
| 143 | - $casier = $valeurs['_meta_casier']; |
|
| 144 | - } |
|
| 145 | - if (isset($valeurs['_meta_prefixe'])) { |
|
| 146 | - $prefixe = $valeurs['_meta_prefixe']; |
|
| 147 | - } |
|
| 148 | - if (isset($valeurs['_meta_stockage'])) { |
|
| 149 | - $stockage = $valeurs['_meta_stockage'] . '::'; |
|
| 150 | - } |
|
| 142 | + if (isset($valeurs['_meta_casier'])) { |
|
| 143 | + $casier = $valeurs['_meta_casier']; |
|
| 144 | + } |
|
| 145 | + if (isset($valeurs['_meta_prefixe'])) { |
|
| 146 | + $prefixe = $valeurs['_meta_prefixe']; |
|
| 147 | + } |
|
| 148 | + if (isset($valeurs['_meta_stockage'])) { |
|
| 149 | + $stockage = $valeurs['_meta_stockage'] . '::'; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - // si on indique juste une table, il faut vider les autres proprietes |
|
| 153 | - // car par defaut on utilise ni casier ni prefixe dans ce cas |
|
| 154 | - if (isset($valeurs['_meta_table'])) { |
|
| 155 | - $table = $valeurs['_meta_table']; |
|
| 156 | - $casier = (isset($valeurs['_meta_casier']) ? $valeurs['_meta_casier'] : ''); |
|
| 157 | - } |
|
| 152 | + // si on indique juste une table, il faut vider les autres proprietes |
|
| 153 | + // car par defaut on utilise ni casier ni prefixe dans ce cas |
|
| 154 | + if (isset($valeurs['_meta_table'])) { |
|
| 155 | + $table = $valeurs['_meta_table']; |
|
| 156 | + $casier = (isset($valeurs['_meta_casier']) ? $valeurs['_meta_casier'] : ''); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - return [$table, $casier, $prefixe, $stockage]; |
|
| 159 | + return [$table, $casier, $prefixe, $stockage]; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -167,48 +167,48 @@ discard block |
||
| 167 | 167 | * @return array |
| 168 | 168 | */ |
| 169 | 169 | function cvtconf_formulaires_configurer_recense($form) { |
| 170 | - $valeurs = ['editable' => ' ']; |
|
| 170 | + $valeurs = ['editable' => ' ']; |
|
| 171 | 171 | |
| 172 | - // sinon cas analyse du squelette |
|
| 173 | - if ( |
|
| 174 | - $f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/') |
|
| 175 | - and lire_fichier($f, $contenu) |
|
| 176 | - ) { |
|
| 177 | - for ($i = 0; $i < 2; $i++) { |
|
| 178 | - // a la seconde iteration, evaluer le fond avec les valeurs deja trouvees |
|
| 179 | - // permet de trouver aussi les name="#GET{truc}" |
|
| 180 | - if ($i == 1) { |
|
| 181 | - $contenu = recuperer_fond("formulaires/$form", $valeurs); |
|
| 182 | - } |
|
| 172 | + // sinon cas analyse du squelette |
|
| 173 | + if ( |
|
| 174 | + $f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/') |
|
| 175 | + and lire_fichier($f, $contenu) |
|
| 176 | + ) { |
|
| 177 | + for ($i = 0; $i < 2; $i++) { |
|
| 178 | + // a la seconde iteration, evaluer le fond avec les valeurs deja trouvees |
|
| 179 | + // permet de trouver aussi les name="#GET{truc}" |
|
| 180 | + if ($i == 1) { |
|
| 181 | + $contenu = recuperer_fond("formulaires/$form", $valeurs); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - $balises = array_merge( |
|
| 185 | - extraire_balises($contenu, 'input'), |
|
| 186 | - extraire_balises($contenu, 'textarea'), |
|
| 187 | - extraire_balises($contenu, 'select') |
|
| 188 | - ); |
|
| 184 | + $balises = array_merge( |
|
| 185 | + extraire_balises($contenu, 'input'), |
|
| 186 | + extraire_balises($contenu, 'textarea'), |
|
| 187 | + extraire_balises($contenu, 'select') |
|
| 188 | + ); |
|
| 189 | 189 | |
| 190 | - foreach ($balises as $b) { |
|
| 191 | - if ( |
|
| 192 | - $n = extraire_attribut($b, 'name') |
|
| 193 | - and preg_match(',^([\w\-]+)(\[\w*\])?$,', $n, $r) |
|
| 194 | - and !in_array($n, ['formulaire_action', 'formulaire_action_args']) |
|
| 195 | - and extraire_attribut($b, 'type') !== 'submit' |
|
| 196 | - ) { |
|
| 197 | - $valeurs[$r[1]] = ''; |
|
| 198 | - // recuperer les valeurs _meta_xx qui peuvent etre fournies |
|
| 199 | - // en input hidden dans le squelette |
|
| 200 | - if (strncmp($r[1], '_meta_', 6) == 0) { |
|
| 201 | - $valeurs[$r[1]] = extraire_attribut($b, 'value'); |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 190 | + foreach ($balises as $b) { |
|
| 191 | + if ( |
|
| 192 | + $n = extraire_attribut($b, 'name') |
|
| 193 | + and preg_match(',^([\w\-]+)(\[\w*\])?$,', $n, $r) |
|
| 194 | + and !in_array($n, ['formulaire_action', 'formulaire_action_args']) |
|
| 195 | + and extraire_attribut($b, 'type') !== 'submit' |
|
| 196 | + ) { |
|
| 197 | + $valeurs[$r[1]] = ''; |
|
| 198 | + // recuperer les valeurs _meta_xx qui peuvent etre fournies |
|
| 199 | + // en input hidden dans le squelette |
|
| 200 | + if (strncmp($r[1], '_meta_', 6) == 0) { |
|
| 201 | + $valeurs[$r[1]] = extraire_attribut($b, 'value'); |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | |
| 209 | - cvtconf_configurer_lire_meta($form, $valeurs); |
|
| 209 | + cvtconf_configurer_lire_meta($form, $valeurs); |
|
| 210 | 210 | |
| 211 | - return $valeurs; |
|
| 211 | + return $valeurs; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -220,26 +220,26 @@ discard block |
||
| 220 | 220 | * @return string |
| 221 | 221 | */ |
| 222 | 222 | function cvtconf_configurer_stocker($form, $valeurs, $store) { |
| 223 | - $trace = ''; |
|
| 224 | - list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
|
| 225 | - // stocker en base |
|
| 226 | - // par defaut, dans un casier serialize dans spip_meta (idem CFG) |
|
| 227 | - if (!isset($GLOBALS[$table])) { |
|
| 228 | - lire_metas($table); |
|
| 229 | - } |
|
| 223 | + $trace = ''; |
|
| 224 | + list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
|
| 225 | + // stocker en base |
|
| 226 | + // par defaut, dans un casier serialize dans spip_meta (idem CFG) |
|
| 227 | + if (!isset($GLOBALS[$table])) { |
|
| 228 | + lire_metas($table); |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 232 | - $table = ($table) ? "/$table/" : ''; |
|
| 233 | - $casier = ($casier) ? rtrim($casier, '/') . '/' : ''; // slash final, sinon rien |
|
| 231 | + $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 232 | + $table = ($table) ? "/$table/" : ''; |
|
| 233 | + $casier = ($casier) ? rtrim($casier, '/') . '/' : ''; // slash final, sinon rien |
|
| 234 | 234 | |
| 235 | - foreach ($store as $k => $v) { |
|
| 236 | - ecrire_config("$stockage$table$prefixe$casier$k", $v); |
|
| 237 | - if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
|
| 238 | - $trace .= "<br />table $table : " . $prefixe . $k . " = $v;"; |
|
| 239 | - } |
|
| 240 | - } |
|
| 235 | + foreach ($store as $k => $v) { |
|
| 236 | + ecrire_config("$stockage$table$prefixe$casier$k", $v); |
|
| 237 | + if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
|
| 238 | + $trace .= "<br />table $table : " . $prefixe . $k . " = $v;"; |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - return $trace; |
|
| 242 | + return $trace; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -249,21 +249,21 @@ discard block |
||
| 249 | 249 | * @param array $valeurs |
| 250 | 250 | */ |
| 251 | 251 | function cvtconf_configurer_lire_meta($form, &$valeurs) { |
| 252 | - list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
|
| 252 | + list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
|
| 253 | 253 | |
| 254 | - $table = ($table) ? "/$table/" : ''; |
|
| 255 | - $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 256 | - if ($casier) { |
|
| 257 | - $meta = lire_config("$stockage$table$prefixe$casier"); |
|
| 258 | - $prefixe = ''; |
|
| 259 | - } else { |
|
| 260 | - $table = rtrim($table, '/'); |
|
| 261 | - $meta = lire_config("$stockage$table"); |
|
| 262 | - } |
|
| 254 | + $table = ($table) ? "/$table/" : ''; |
|
| 255 | + $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 256 | + if ($casier) { |
|
| 257 | + $meta = lire_config("$stockage$table$prefixe$casier"); |
|
| 258 | + $prefixe = ''; |
|
| 259 | + } else { |
|
| 260 | + $table = rtrim($table, '/'); |
|
| 261 | + $meta = lire_config("$stockage$table"); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - foreach ($valeurs as $k => $v) { |
|
| 265 | - if (substr($k, 0, 1) !== '_') { |
|
| 266 | - $valeurs[$k] = (isset($meta[$prefixe . $k]) ? $meta[$prefixe . $k] : null); |
|
| 267 | - } |
|
| 268 | - } |
|
| 264 | + foreach ($valeurs as $k => $v) { |
|
| 265 | + if (substr($k, 0, 1) !== '_') { |
|
| 266 | + $valeurs[$k] = (isset($meta[$prefixe . $k]) ? $meta[$prefixe . $k] : null); |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | 269 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | ) { |
| 39 | 39 | // Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé |
| 40 | 40 | include_spip('inc/autoriser'); |
| 41 | - if (!autoriser('configurer', '_' . substr($form, 11))) { |
|
| 41 | + if (!autoriser('configurer', '_'.substr($form, 11))) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | and !charger_fonction('traiter', "formulaires/$form/", true) // sans fonction traiter() |
| 73 | 73 | ) { |
| 74 | 74 | $trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']); |
| 75 | - $flux['data'] = ['message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true]; |
|
| 75 | + $flux['data'] = ['message_ok' => _T('config_info_enregistree').$trace, 'editable' => true]; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $flux; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $prefixe = $valeurs['_meta_prefixe']; |
| 147 | 147 | } |
| 148 | 148 | if (isset($valeurs['_meta_stockage'])) { |
| 149 | - $stockage = $valeurs['_meta_stockage'] . '::'; |
|
| 149 | + $stockage = $valeurs['_meta_stockage'].'::'; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // si on indique juste une table, il faut vider les autres proprietes |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | // sinon cas analyse du squelette |
| 173 | 173 | if ( |
| 174 | - $f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/') |
|
| 174 | + $f = find_in_path($form.'.'._EXTENSION_SQUELETTES, 'formulaires/') |
|
| 175 | 175 | and lire_fichier($f, $contenu) |
| 176 | 176 | ) { |
| 177 | 177 | for ($i = 0; $i < 2; $i++) { |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | lire_metas($table); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 231 | + $prefixe = ($prefixe ? $prefixe.'_' : ''); |
|
| 232 | 232 | $table = ($table) ? "/$table/" : ''; |
| 233 | - $casier = ($casier) ? rtrim($casier, '/') . '/' : ''; // slash final, sinon rien |
|
| 233 | + $casier = ($casier) ? rtrim($casier, '/').'/' : ''; // slash final, sinon rien |
|
| 234 | 234 | |
| 235 | 235 | foreach ($store as $k => $v) { |
| 236 | 236 | ecrire_config("$stockage$table$prefixe$casier$k", $v); |
| 237 | 237 | if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
| 238 | - $trace .= "<br />table $table : " . $prefixe . $k . " = $v;"; |
|
| 238 | + $trace .= "<br />table $table : ".$prefixe.$k." = $v;"; |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
| 253 | 253 | |
| 254 | 254 | $table = ($table) ? "/$table/" : ''; |
| 255 | - $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 255 | + $prefixe = ($prefixe ? $prefixe.'_' : ''); |
|
| 256 | 256 | if ($casier) { |
| 257 | 257 | $meta = lire_config("$stockage$table$prefixe$casier"); |
| 258 | 258 | $prefixe = ''; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | foreach ($valeurs as $k => $v) { |
| 265 | 265 | if (substr($k, 0, 1) !== '_') { |
| 266 | - $valeurs[$k] = (isset($meta[$prefixe . $k]) ? $meta[$prefixe . $k] : null); |
|
| 266 | + $valeurs[$k] = (isset($meta[$prefixe.$k]) ? $meta[$prefixe.$k] : null); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -18,18 +18,18 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!defined('_ACTIVER_PUCE_RAPIDE')) { |
| 25 | - /** |
|
| 26 | - * Activer le changement rapide de statut sur les listes d'objets ? |
|
| 27 | - * |
|
| 28 | - * Peut ralentir un site sur des listes très longues. |
|
| 29 | - * |
|
| 30 | - * @var bool |
|
| 31 | - **/ |
|
| 32 | - define('_ACTIVER_PUCE_RAPIDE', true); |
|
| 25 | + /** |
|
| 26 | + * Activer le changement rapide de statut sur les listes d'objets ? |
|
| 27 | + * |
|
| 28 | + * Peut ralentir un site sur des listes très longues. |
|
| 29 | + * |
|
| 30 | + * @var bool |
|
| 31 | + **/ |
|
| 32 | + define('_ACTIVER_PUCE_RAPIDE', true); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -57,31 +57,31 @@ discard block |
||
| 57 | 57 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 58 | 58 | */ |
| 59 | 59 | function inc_puce_statut_dist( |
| 60 | - $id_objet, |
|
| 61 | - $statut, |
|
| 62 | - $id_parent, |
|
| 63 | - $type, |
|
| 64 | - $ajax = false, |
|
| 65 | - $menu_rapide = _ACTIVER_PUCE_RAPIDE |
|
| 60 | + $id_objet, |
|
| 61 | + $statut, |
|
| 62 | + $id_parent, |
|
| 63 | + $type, |
|
| 64 | + $ajax = false, |
|
| 65 | + $menu_rapide = _ACTIVER_PUCE_RAPIDE |
|
| 66 | 66 | ) { |
| 67 | - static $f_puce_statut = []; |
|
| 68 | - $type = objet_type($type); |
|
| 69 | - // cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques |
|
| 70 | - if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) { |
|
| 71 | - $f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true); |
|
| 72 | - } |
|
| 73 | - if ($f_puce_statut[$type]) { |
|
| 74 | - return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // si statut_image trouve quelque chose (et '' est quelque chose) |
|
| 78 | - // composer une puce, avec si possible changement rapide |
|
| 79 | - elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) { |
|
| 80 | - return $puce; |
|
| 81 | - } // sinon fausse puce avec le type de l'image |
|
| 82 | - else { |
|
| 83 | - return http_img_pack("$type-16.png", ''); |
|
| 84 | - } |
|
| 67 | + static $f_puce_statut = []; |
|
| 68 | + $type = objet_type($type); |
|
| 69 | + // cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques |
|
| 70 | + if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) { |
|
| 71 | + $f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true); |
|
| 72 | + } |
|
| 73 | + if ($f_puce_statut[$type]) { |
|
| 74 | + return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // si statut_image trouve quelque chose (et '' est quelque chose) |
|
| 78 | + // composer une puce, avec si possible changement rapide |
|
| 79 | + elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) { |
|
| 80 | + return $puce; |
|
| 81 | + } // sinon fausse puce avec le type de l'image |
|
| 82 | + else { |
|
| 83 | + return http_img_pack("$type-16.png", ''); |
|
| 84 | + } |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -110,41 +110,41 @@ discard block |
||
| 110 | 110 | * null si pas capable de déterminer l'image |
| 111 | 111 | */ |
| 112 | 112 | function statut_image($objet, $statut) { |
| 113 | - $src = null; |
|
| 114 | - $table = table_objet_sql($objet); |
|
| 115 | - $desc = lister_tables_objets_sql($table); |
|
| 116 | - if (isset($desc['statut_images'])) { |
|
| 117 | - // si une declaration statut_images |
|
| 118 | - // mais rien pour le statut demande, ne rien afficher |
|
| 119 | - $src = ''; |
|
| 120 | - if (isset($desc['statut_images'][$statut])) { |
|
| 121 | - $src = $desc['statut_images'][$statut]; |
|
| 122 | - } // sinon image par defaut ? |
|
| 123 | - elseif (isset($desc['statut_images'][0])) { |
|
| 124 | - $src = $desc['statut_images'][0]; |
|
| 125 | - } |
|
| 126 | - } else { |
|
| 127 | - switch ($statut) { |
|
| 128 | - case 'prepa': |
|
| 129 | - $src = 'puce-preparer-xx.svg?12px'; |
|
| 130 | - break; |
|
| 131 | - case 'prop': |
|
| 132 | - $src = 'puce-proposer-xx.svg?12px'; |
|
| 133 | - break; |
|
| 134 | - case 'publie': |
|
| 135 | - $src = 'puce-publier-xx.svg?12px'; |
|
| 136 | - break; |
|
| 137 | - case 'refuse': |
|
| 138 | - $src = 'puce-refuser-xx.svg?12px'; |
|
| 139 | - break; |
|
| 140 | - case 'poubelle': |
|
| 141 | - case 'poub': |
|
| 142 | - $src = 'puce-supprimer-xx.svg?12px'; |
|
| 143 | - break; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return $src; |
|
| 113 | + $src = null; |
|
| 114 | + $table = table_objet_sql($objet); |
|
| 115 | + $desc = lister_tables_objets_sql($table); |
|
| 116 | + if (isset($desc['statut_images'])) { |
|
| 117 | + // si une declaration statut_images |
|
| 118 | + // mais rien pour le statut demande, ne rien afficher |
|
| 119 | + $src = ''; |
|
| 120 | + if (isset($desc['statut_images'][$statut])) { |
|
| 121 | + $src = $desc['statut_images'][$statut]; |
|
| 122 | + } // sinon image par defaut ? |
|
| 123 | + elseif (isset($desc['statut_images'][0])) { |
|
| 124 | + $src = $desc['statut_images'][0]; |
|
| 125 | + } |
|
| 126 | + } else { |
|
| 127 | + switch ($statut) { |
|
| 128 | + case 'prepa': |
|
| 129 | + $src = 'puce-preparer-xx.svg?12px'; |
|
| 130 | + break; |
|
| 131 | + case 'prop': |
|
| 132 | + $src = 'puce-proposer-xx.svg?12px'; |
|
| 133 | + break; |
|
| 134 | + case 'publie': |
|
| 135 | + $src = 'puce-publier-xx.svg?12px'; |
|
| 136 | + break; |
|
| 137 | + case 'refuse': |
|
| 138 | + $src = 'puce-refuser-xx.svg?12px'; |
|
| 139 | + break; |
|
| 140 | + case 'poubelle': |
|
| 141 | + case 'poub': |
|
| 142 | + $src = 'puce-supprimer-xx.svg?12px'; |
|
| 143 | + break; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return $src; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -172,40 +172,40 @@ discard block |
||
| 172 | 172 | * @return string |
| 173 | 173 | */ |
| 174 | 174 | function statut_titre($objet, $statut) { |
| 175 | - $titre = ''; |
|
| 176 | - $table = table_objet_sql($objet); |
|
| 177 | - $desc = lister_tables_objets_sql($table); |
|
| 178 | - if (isset($desc['statut_titres'])) { |
|
| 179 | - // si une declaration statut_titres |
|
| 180 | - // mais rien pour le statut demande, ne rien afficher |
|
| 181 | - if (isset($desc['statut_titres'][$statut])) { |
|
| 182 | - $titre = $desc['statut_titres'][$statut]; |
|
| 183 | - } // sinon image par defaut ? |
|
| 184 | - elseif (isset($desc['statut_titres'][0])) { |
|
| 185 | - $titre = $desc['statut_titres'][0]; |
|
| 186 | - } |
|
| 187 | - } else { |
|
| 188 | - switch ($statut) { |
|
| 189 | - case 'prepa': |
|
| 190 | - $titre = 'texte_statut_en_cours_redaction'; |
|
| 191 | - break; |
|
| 192 | - case 'prop': |
|
| 193 | - $titre = 'texte_statut_propose_evaluation'; |
|
| 194 | - break; |
|
| 195 | - case 'publie': |
|
| 196 | - $titre = 'texte_statut_publie'; |
|
| 197 | - break; |
|
| 198 | - case 'refuse': |
|
| 199 | - $titre = 'texte_statut_refuse'; |
|
| 200 | - break; |
|
| 201 | - case 'poubelle': |
|
| 202 | - case 'poub': |
|
| 203 | - $titre = 'texte_statut_poubelle'; |
|
| 204 | - break; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - return $titre ? _T($titre) : ''; |
|
| 175 | + $titre = ''; |
|
| 176 | + $table = table_objet_sql($objet); |
|
| 177 | + $desc = lister_tables_objets_sql($table); |
|
| 178 | + if (isset($desc['statut_titres'])) { |
|
| 179 | + // si une declaration statut_titres |
|
| 180 | + // mais rien pour le statut demande, ne rien afficher |
|
| 181 | + if (isset($desc['statut_titres'][$statut])) { |
|
| 182 | + $titre = $desc['statut_titres'][$statut]; |
|
| 183 | + } // sinon image par defaut ? |
|
| 184 | + elseif (isset($desc['statut_titres'][0])) { |
|
| 185 | + $titre = $desc['statut_titres'][0]; |
|
| 186 | + } |
|
| 187 | + } else { |
|
| 188 | + switch ($statut) { |
|
| 189 | + case 'prepa': |
|
| 190 | + $titre = 'texte_statut_en_cours_redaction'; |
|
| 191 | + break; |
|
| 192 | + case 'prop': |
|
| 193 | + $titre = 'texte_statut_propose_evaluation'; |
|
| 194 | + break; |
|
| 195 | + case 'publie': |
|
| 196 | + $titre = 'texte_statut_publie'; |
|
| 197 | + break; |
|
| 198 | + case 'refuse': |
|
| 199 | + $titre = 'texte_statut_refuse'; |
|
| 200 | + break; |
|
| 201 | + case 'poubelle': |
|
| 202 | + case 'poub': |
|
| 203 | + $titre = 'texte_statut_poubelle'; |
|
| 204 | + break; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + return $titre ? _T($titre) : ''; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -225,37 +225,37 @@ discard block |
||
| 225 | 225 | * @return string |
| 226 | 226 | */ |
| 227 | 227 | function statut_texte_instituer($objet, $statut) { |
| 228 | - $texte = ''; |
|
| 229 | - $table = table_objet_sql($objet); |
|
| 230 | - $desc = lister_tables_objets_sql($table); |
|
| 231 | - if (isset($desc['statut_textes_instituer'])) { |
|
| 232 | - // si une declaration statut_titres |
|
| 233 | - // mais rien pour le statut demande, ne rien afficher |
|
| 234 | - if (isset($desc['statut_textes_instituer'][$statut])) { |
|
| 235 | - $texte = $desc['statut_textes_instituer'][$statut]; |
|
| 236 | - } |
|
| 237 | - } else { |
|
| 238 | - switch ($statut) { |
|
| 239 | - case 'prepa': |
|
| 240 | - $texte = 'texte_statut_en_cours_redaction'; |
|
| 241 | - break; |
|
| 242 | - case 'prop': |
|
| 243 | - $texte = 'texte_statut_propose_evaluation'; |
|
| 244 | - break; |
|
| 245 | - case 'publie': |
|
| 246 | - $texte = 'texte_statut_publie'; |
|
| 247 | - break; |
|
| 248 | - case 'refuse': |
|
| 249 | - $texte = 'texte_statut_refuse'; |
|
| 250 | - break; |
|
| 251 | - case 'poubelle': |
|
| 252 | - case 'poub': |
|
| 253 | - $texte = 'texte_statut_poubelle'; |
|
| 254 | - break; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - return $texte ? _T($texte) : ''; |
|
| 228 | + $texte = ''; |
|
| 229 | + $table = table_objet_sql($objet); |
|
| 230 | + $desc = lister_tables_objets_sql($table); |
|
| 231 | + if (isset($desc['statut_textes_instituer'])) { |
|
| 232 | + // si une declaration statut_titres |
|
| 233 | + // mais rien pour le statut demande, ne rien afficher |
|
| 234 | + if (isset($desc['statut_textes_instituer'][$statut])) { |
|
| 235 | + $texte = $desc['statut_textes_instituer'][$statut]; |
|
| 236 | + } |
|
| 237 | + } else { |
|
| 238 | + switch ($statut) { |
|
| 239 | + case 'prepa': |
|
| 240 | + $texte = 'texte_statut_en_cours_redaction'; |
|
| 241 | + break; |
|
| 242 | + case 'prop': |
|
| 243 | + $texte = 'texte_statut_propose_evaluation'; |
|
| 244 | + break; |
|
| 245 | + case 'publie': |
|
| 246 | + $texte = 'texte_statut_publie'; |
|
| 247 | + break; |
|
| 248 | + case 'refuse': |
|
| 249 | + $texte = 'texte_statut_refuse'; |
|
| 250 | + break; |
|
| 251 | + case 'poubelle': |
|
| 252 | + case 'poub': |
|
| 253 | + $texte = 'texte_statut_poubelle'; |
|
| 254 | + break; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + return $texte ? _T($texte) : ''; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -275,16 +275,16 @@ discard block |
||
| 275 | 275 | * @return string |
| 276 | 276 | */ |
| 277 | 277 | function puce_statut_auteur_dist($id, $statut, $id_parent, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) { |
| 278 | - $img = statut_image('auteur', $statut); |
|
| 279 | - if (!$img) { |
|
| 280 | - return ''; |
|
| 281 | - } |
|
| 282 | - $alt = statut_titre('auteur', $statut); |
|
| 278 | + $img = statut_image('auteur', $statut); |
|
| 279 | + if (!$img) { |
|
| 280 | + return ''; |
|
| 281 | + } |
|
| 282 | + $alt = statut_titre('auteur', $statut); |
|
| 283 | 283 | |
| 284 | - $fond = ''; |
|
| 285 | - $titre = ''; |
|
| 284 | + $fond = ''; |
|
| 285 | + $titre = ''; |
|
| 286 | 286 | |
| 287 | - /* |
|
| 287 | + /* |
|
| 288 | 288 | if ($type != 'auteur') { |
| 289 | 289 | $img2 = chemin_image('del-16.png'); |
| 290 | 290 | $titre = _T('titre_image_redacteur'); |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | */ |
| 296 | 296 | |
| 297 | - return http_img_pack($img, $alt, $fond, $alt); |
|
| 297 | + return http_img_pack($img, $alt, $fond, $alt); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
| 301 | 301 | function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) { |
| 302 | - return http_img_pack('rubrique-16.png', ''); |
|
| 302 | + return http_img_pack('rubrique-16.png', ''); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -323,110 +323,110 @@ discard block |
||
| 323 | 323 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 324 | 324 | **/ |
| 325 | 325 | function puce_statut_changement_rapide( |
| 326 | - $id, |
|
| 327 | - $statut, |
|
| 328 | - $id_rubrique, |
|
| 329 | - $type = 'article', |
|
| 330 | - $ajax = false, |
|
| 331 | - $menu_rapide = _ACTIVER_PUCE_RAPIDE |
|
| 326 | + $id, |
|
| 327 | + $statut, |
|
| 328 | + $id_rubrique, |
|
| 329 | + $type = 'article', |
|
| 330 | + $ajax = false, |
|
| 331 | + $menu_rapide = _ACTIVER_PUCE_RAPIDE |
|
| 332 | 332 | ) { |
| 333 | - $src = statut_image($type, $statut); |
|
| 334 | - if (!$src) { |
|
| 335 | - return $src; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - if ( |
|
| 339 | - !$id |
|
| 340 | - or !_SPIP_AJAX |
|
| 341 | - or !$menu_rapide |
|
| 342 | - ) { |
|
| 343 | - $ajax_node = ''; |
|
| 344 | - } else { |
|
| 345 | - $ajax_node = " class='imgstatut$type$id'"; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - |
|
| 349 | - $t = statut_titre($type, $statut); |
|
| 350 | - $inser_puce = http_img_pack($src, $t, $ajax_node, $t); |
|
| 351 | - |
|
| 352 | - if (!$ajax_node) { |
|
| 353 | - return $inser_puce; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - $table = table_objet_sql($type); |
|
| 357 | - $desc = lister_tables_objets_sql($table); |
|
| 358 | - if (!isset($desc['statut_textes_instituer'])) { |
|
| 359 | - return $inser_puce; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - if (!function_exists('autoriser')) { |
|
| 363 | - include_spip('inc/autoriser'); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique) |
|
| 367 | - if ($id_rubrique) { |
|
| 368 | - if (!autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 369 | - return $inser_puce; |
|
| 370 | - } |
|
| 371 | - } // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie |
|
| 372 | - else { |
|
| 373 | - if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) { |
|
| 374 | - return $inser_puce; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - $coord = array_flip(array_keys($desc['statut_textes_instituer'])); |
|
| 379 | - if (!isset($coord[$statut])) { |
|
| 380 | - return $inser_puce; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - $unit = 18/*widh de img*/ + 0/*padding*/ |
|
| 384 | - ; |
|
| 385 | - $margin = 0; /* marge a gauche + droite */ |
|
| 386 | - $zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/ |
|
| 387 | - ; |
|
| 388 | - $clip = $zero + ($unit * $coord[$statut]); |
|
| 389 | - |
|
| 390 | - if ($ajax) { |
|
| 391 | - $width = $unit * count($desc['statut_textes_instituer']) + $margin; |
|
| 392 | - $out = "<span class='puce_objet_fixe $type'>" |
|
| 393 | - . $inser_puce |
|
| 394 | - . '</span>' |
|
| 395 | - . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>"; |
|
| 396 | - $i = 0; |
|
| 397 | - foreach ($desc['statut_textes_instituer'] as $s => $t) { |
|
| 398 | - $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t)); |
|
| 399 | - } |
|
| 400 | - $out .= '</span>'; |
|
| 401 | - |
|
| 402 | - return $out; |
|
| 403 | - } else { |
|
| 404 | - $nom = 'puce_statut_'; |
|
| 405 | - $action = generer_url_ecrire('puce_statut', '', true); |
|
| 406 | - $lang_dir = lang_dir(lang_typo()); |
|
| 407 | - |
|
| 408 | - return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>" |
|
| 409 | - . $inser_puce |
|
| 410 | - . '</span>'; |
|
| 411 | - } |
|
| 333 | + $src = statut_image($type, $statut); |
|
| 334 | + if (!$src) { |
|
| 335 | + return $src; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + if ( |
|
| 339 | + !$id |
|
| 340 | + or !_SPIP_AJAX |
|
| 341 | + or !$menu_rapide |
|
| 342 | + ) { |
|
| 343 | + $ajax_node = ''; |
|
| 344 | + } else { |
|
| 345 | + $ajax_node = " class='imgstatut$type$id'"; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + |
|
| 349 | + $t = statut_titre($type, $statut); |
|
| 350 | + $inser_puce = http_img_pack($src, $t, $ajax_node, $t); |
|
| 351 | + |
|
| 352 | + if (!$ajax_node) { |
|
| 353 | + return $inser_puce; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + $table = table_objet_sql($type); |
|
| 357 | + $desc = lister_tables_objets_sql($table); |
|
| 358 | + if (!isset($desc['statut_textes_instituer'])) { |
|
| 359 | + return $inser_puce; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + if (!function_exists('autoriser')) { |
|
| 363 | + include_spip('inc/autoriser'); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique) |
|
| 367 | + if ($id_rubrique) { |
|
| 368 | + if (!autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 369 | + return $inser_puce; |
|
| 370 | + } |
|
| 371 | + } // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie |
|
| 372 | + else { |
|
| 373 | + if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) { |
|
| 374 | + return $inser_puce; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + $coord = array_flip(array_keys($desc['statut_textes_instituer'])); |
|
| 379 | + if (!isset($coord[$statut])) { |
|
| 380 | + return $inser_puce; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + $unit = 18/*widh de img*/ + 0/*padding*/ |
|
| 384 | + ; |
|
| 385 | + $margin = 0; /* marge a gauche + droite */ |
|
| 386 | + $zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/ |
|
| 387 | + ; |
|
| 388 | + $clip = $zero + ($unit * $coord[$statut]); |
|
| 389 | + |
|
| 390 | + if ($ajax) { |
|
| 391 | + $width = $unit * count($desc['statut_textes_instituer']) + $margin; |
|
| 392 | + $out = "<span class='puce_objet_fixe $type'>" |
|
| 393 | + . $inser_puce |
|
| 394 | + . '</span>' |
|
| 395 | + . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>"; |
|
| 396 | + $i = 0; |
|
| 397 | + foreach ($desc['statut_textes_instituer'] as $s => $t) { |
|
| 398 | + $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t)); |
|
| 399 | + } |
|
| 400 | + $out .= '</span>'; |
|
| 401 | + |
|
| 402 | + return $out; |
|
| 403 | + } else { |
|
| 404 | + $nom = 'puce_statut_'; |
|
| 405 | + $action = generer_url_ecrire('puce_statut', '', true); |
|
| 406 | + $lang_dir = lang_dir(lang_typo()); |
|
| 407 | + |
|
| 408 | + return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>" |
|
| 409 | + . $inser_puce |
|
| 410 | + . '</span>'; |
|
| 411 | + } |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | |
| 415 | 415 | function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act = '') { |
| 416 | - $h = generer_action_auteur('instituer_objet', "$type-$id-$statut"); |
|
| 417 | - $t = supprimer_tags($titre); |
|
| 416 | + $h = generer_action_auteur('instituer_objet', "$type-$id-$statut"); |
|
| 417 | + $t = supprimer_tags($titre); |
|
| 418 | 418 | |
| 419 | - return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>'; |
|
| 419 | + return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // compat |
| 423 | 423 | // La couleur du statut |
| 424 | 424 | |
| 425 | 425 | function puce_statut($statut, $atts = '') { |
| 426 | - $src = statut_image('article', $statut); |
|
| 427 | - if (!$src) { |
|
| 428 | - return ''; |
|
| 429 | - } |
|
| 426 | + $src = statut_image('article', $statut); |
|
| 427 | + if (!$src) { |
|
| 428 | + return ''; |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - return http_img_pack($src, statut_titre('article', $statut), $atts); |
|
| 431 | + return http_img_pack($src, statut_titre('article', $statut), $atts); |
|
| 432 | 432 | } |
@@ -416,7 +416,7 @@ |
||
| 416 | 416 | $h = generer_action_auteur('instituer_objet', "$type-$id-$statut"); |
| 417 | 417 | $t = supprimer_tags($titre); |
| 418 | 418 | |
| 419 | - return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>'; |
|
| 419 | + return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>".http_img_pack($img, $t).'</a>'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // compat |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -54,64 +54,64 @@ discard block |
||
| 54 | 54 | * true si le statut change effectivement |
| 55 | 55 | **/ |
| 56 | 56 | function calculer_rubriques_if($id_rubrique, $modifs, $infos = [], $postdate = false) { |
| 57 | - $neuf = false; |
|
| 58 | - |
|
| 59 | - // Compat avec l'ancienne signature |
|
| 60 | - if (is_string($infos)) { |
|
| 61 | - $infos = ['statut_ancien' => $infos]; |
|
| 62 | - } |
|
| 63 | - if (!isset($infos['statut_ancien'])) { |
|
| 64 | - $infos['statut_ancien'] = ''; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // On recherche quels statuts tester |
|
| 68 | - if ( |
|
| 69 | - isset($infos['objet']) |
|
| 70 | - and include_spip('inc/filtres') |
|
| 71 | - and $declaration_statut = objet_info($infos['objet'], 'statut') |
|
| 72 | - and is_array($declaration_statut) |
|
| 73 | - ) { |
|
| 74 | - foreach ($declaration_statut as $champ_statut) { |
|
| 75 | - if ($champ_statut['champ'] == 'statut') { |
|
| 76 | - $statuts_publies = array_map('trim', explode(',', $champ_statut['publie'])); |
|
| 77 | - break; // stop on a trouvé le bon champ |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - else { |
|
| 82 | - $statuts_publies = ['publie']; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - if (in_array($infos['statut_ancien'], $statuts_publies)) { |
|
| 86 | - if ( |
|
| 87 | - isset($modifs['statut']) |
|
| 88 | - or isset($modifs['id_rubrique']) |
|
| 89 | - or ($postdate and strtotime($postdate) > time()) |
|
| 90 | - ) { |
|
| 91 | - $neuf |= depublier_branche_rubrique_if($id_rubrique); |
|
| 92 | - } |
|
| 93 | - // ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur |
|
| 94 | - if ($postdate) { |
|
| 95 | - calculer_prochain_postdate(true); |
|
| 96 | - $neuf |= (strtotime($postdate) <= time()); // par securite |
|
| 97 | - } elseif (isset($modifs['id_rubrique'])) { |
|
| 98 | - $neuf |= publier_branche_rubrique($modifs['id_rubrique']); |
|
| 99 | - } |
|
| 100 | - } elseif (isset($modifs['statut']) and in_array($modifs['statut'], $statuts_publies)) { |
|
| 101 | - if ($postdate) { |
|
| 102 | - calculer_prochain_postdate(true); |
|
| 103 | - $neuf |= (strtotime($postdate) <= time()); // par securite |
|
| 104 | - } else { |
|
| 105 | - $neuf |= publier_branche_rubrique($id_rubrique); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - if ($neuf) { // Sauver la date de la derniere mise a jour (pour menu_rubriques) |
|
| 110 | - ecrire_meta('date_calcul_rubriques', date('U')); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $langues = calculer_langues_utilisees(); |
|
| 114 | - ecrire_meta('langues_utilisees', $langues); |
|
| 57 | + $neuf = false; |
|
| 58 | + |
|
| 59 | + // Compat avec l'ancienne signature |
|
| 60 | + if (is_string($infos)) { |
|
| 61 | + $infos = ['statut_ancien' => $infos]; |
|
| 62 | + } |
|
| 63 | + if (!isset($infos['statut_ancien'])) { |
|
| 64 | + $infos['statut_ancien'] = ''; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // On recherche quels statuts tester |
|
| 68 | + if ( |
|
| 69 | + isset($infos['objet']) |
|
| 70 | + and include_spip('inc/filtres') |
|
| 71 | + and $declaration_statut = objet_info($infos['objet'], 'statut') |
|
| 72 | + and is_array($declaration_statut) |
|
| 73 | + ) { |
|
| 74 | + foreach ($declaration_statut as $champ_statut) { |
|
| 75 | + if ($champ_statut['champ'] == 'statut') { |
|
| 76 | + $statuts_publies = array_map('trim', explode(',', $champ_statut['publie'])); |
|
| 77 | + break; // stop on a trouvé le bon champ |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + else { |
|
| 82 | + $statuts_publies = ['publie']; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + if (in_array($infos['statut_ancien'], $statuts_publies)) { |
|
| 86 | + if ( |
|
| 87 | + isset($modifs['statut']) |
|
| 88 | + or isset($modifs['id_rubrique']) |
|
| 89 | + or ($postdate and strtotime($postdate) > time()) |
|
| 90 | + ) { |
|
| 91 | + $neuf |= depublier_branche_rubrique_if($id_rubrique); |
|
| 92 | + } |
|
| 93 | + // ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur |
|
| 94 | + if ($postdate) { |
|
| 95 | + calculer_prochain_postdate(true); |
|
| 96 | + $neuf |= (strtotime($postdate) <= time()); // par securite |
|
| 97 | + } elseif (isset($modifs['id_rubrique'])) { |
|
| 98 | + $neuf |= publier_branche_rubrique($modifs['id_rubrique']); |
|
| 99 | + } |
|
| 100 | + } elseif (isset($modifs['statut']) and in_array($modifs['statut'], $statuts_publies)) { |
|
| 101 | + if ($postdate) { |
|
| 102 | + calculer_prochain_postdate(true); |
|
| 103 | + $neuf |= (strtotime($postdate) <= time()); // par securite |
|
| 104 | + } else { |
|
| 105 | + $neuf |= publier_branche_rubrique($id_rubrique); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + if ($neuf) { // Sauver la date de la derniere mise a jour (pour menu_rubriques) |
|
| 110 | + ecrire_meta('date_calcul_rubriques', date('U')); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $langues = calculer_langues_utilisees(); |
|
| 114 | + ecrire_meta('langues_utilisees', $langues); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -129,22 +129,22 @@ discard block |
||
| 129 | 129 | * true si le statut change effectivement |
| 130 | 130 | */ |
| 131 | 131 | function publier_branche_rubrique($id_rubrique) { |
| 132 | - $id_pred = $id_rubrique; |
|
| 133 | - while (true) { |
|
| 134 | - sql_updateq( |
|
| 135 | - 'spip_rubriques', |
|
| 136 | - ['statut' => 'publie', 'date' => date('Y-m-d H:i:s')], |
|
| 137 | - 'id_rubrique=' . intval($id_rubrique) |
|
| 138 | - ); |
|
| 139 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique)); |
|
| 140 | - if (!$id_parent) { |
|
| 141 | - break; |
|
| 142 | - } |
|
| 143 | - $id_rubrique = $id_parent; |
|
| 144 | - } |
|
| 132 | + $id_pred = $id_rubrique; |
|
| 133 | + while (true) { |
|
| 134 | + sql_updateq( |
|
| 135 | + 'spip_rubriques', |
|
| 136 | + ['statut' => 'publie', 'date' => date('Y-m-d H:i:s')], |
|
| 137 | + 'id_rubrique=' . intval($id_rubrique) |
|
| 138 | + ); |
|
| 139 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique)); |
|
| 140 | + if (!$id_parent) { |
|
| 141 | + break; |
|
| 142 | + } |
|
| 143 | + $id_rubrique = $id_parent; |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | 146 | # spip_log(" publier_branche_rubrique($id_rubrique $id_pred"); |
| 147 | - return $id_pred != $id_rubrique; |
|
| 147 | + return $id_pred != $id_rubrique; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -162,20 +162,20 @@ discard block |
||
| 162 | 162 | * true si le statut change effectivement |
| 163 | 163 | */ |
| 164 | 164 | function depublier_branche_rubrique_if($id_rubrique) { |
| 165 | - $date = date('Y-m-d H:i:s'); // figer la date |
|
| 166 | - |
|
| 167 | - # spip_log("depublier_branche_rubrique($id_rubrique ?"); |
|
| 168 | - $id_pred = $id_rubrique; |
|
| 169 | - while ($id_pred) { |
|
| 170 | - if (!depublier_rubrique_if($id_pred, $date)) { |
|
| 171 | - return $id_pred != $id_rubrique; |
|
| 172 | - } |
|
| 173 | - // passer au parent si on a depublie |
|
| 174 | - $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred)); |
|
| 175 | - $id_pred = $r['id_parent']; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - return $id_pred != $id_rubrique; |
|
| 165 | + $date = date('Y-m-d H:i:s'); // figer la date |
|
| 166 | + |
|
| 167 | + # spip_log("depublier_branche_rubrique($id_rubrique ?"); |
|
| 168 | + $id_pred = $id_rubrique; |
|
| 169 | + while ($id_pred) { |
|
| 170 | + if (!depublier_rubrique_if($id_pred, $date)) { |
|
| 171 | + return $id_pred != $id_rubrique; |
|
| 172 | + } |
|
| 173 | + // passer au parent si on a depublie |
|
| 174 | + $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred)); |
|
| 175 | + $id_pred = $r['id_parent']; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + return $id_pred != $id_rubrique; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -192,61 +192,61 @@ discard block |
||
| 192 | 192 | * true si la rubrique a été dépubliée |
| 193 | 193 | */ |
| 194 | 194 | function depublier_rubrique_if($id_rubrique, $date = null) { |
| 195 | - if (is_null($date)) { |
|
| 196 | - $date = date('Y-m-d H:i:s'); |
|
| 197 | - } |
|
| 198 | - $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 199 | - ' AND date <= ' . sql_quote($date) : ''; |
|
| 200 | - |
|
| 201 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 202 | - return false; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - // verifier qu'elle existe et est bien publiee |
|
| 206 | - $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 207 | - if (!$r or $r['statut'] !== 'publie') { |
|
| 208 | - return false; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - // On met le nombre de chaque type d'enfants dans un tableau |
|
| 212 | - // Le type de l'objet est au pluriel |
|
| 213 | - $compte = [ |
|
| 214 | - 'articles' => sql_countsel( |
|
| 215 | - 'spip_articles', |
|
| 216 | - 'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates" |
|
| 217 | - ), |
|
| 218 | - 'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"), |
|
| 219 | - 'documents' => sql_countsel( |
|
| 220 | - 'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document', |
|
| 221 | - 'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') " |
|
| 222 | - ) |
|
| 223 | - ]; |
|
| 224 | - |
|
| 225 | - // On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants |
|
| 226 | - $compte = pipeline( |
|
| 227 | - 'objet_compte_enfants', |
|
| 228 | - [ |
|
| 229 | - 'args' => [ |
|
| 230 | - 'objet' => 'rubrique', |
|
| 231 | - 'id_objet' => $id_rubrique, |
|
| 232 | - 'statut' => 'publie', |
|
| 233 | - 'date' => $date |
|
| 234 | - ], |
|
| 235 | - 'data' => $compte |
|
| 236 | - ] |
|
| 237 | - ); |
|
| 238 | - |
|
| 239 | - // S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas |
|
| 240 | - foreach ($compte as $objet => $n) { |
|
| 241 | - if ($n) { |
|
| 242 | - return false; |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique)); |
|
| 195 | + if (is_null($date)) { |
|
| 196 | + $date = date('Y-m-d H:i:s'); |
|
| 197 | + } |
|
| 198 | + $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 199 | + ' AND date <= ' . sql_quote($date) : ''; |
|
| 200 | + |
|
| 201 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + // verifier qu'elle existe et est bien publiee |
|
| 206 | + $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 207 | + if (!$r or $r['statut'] !== 'publie') { |
|
| 208 | + return false; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + // On met le nombre de chaque type d'enfants dans un tableau |
|
| 212 | + // Le type de l'objet est au pluriel |
|
| 213 | + $compte = [ |
|
| 214 | + 'articles' => sql_countsel( |
|
| 215 | + 'spip_articles', |
|
| 216 | + 'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates" |
|
| 217 | + ), |
|
| 218 | + 'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"), |
|
| 219 | + 'documents' => sql_countsel( |
|
| 220 | + 'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document', |
|
| 221 | + 'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') " |
|
| 222 | + ) |
|
| 223 | + ]; |
|
| 224 | + |
|
| 225 | + // On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants |
|
| 226 | + $compte = pipeline( |
|
| 227 | + 'objet_compte_enfants', |
|
| 228 | + [ |
|
| 229 | + 'args' => [ |
|
| 230 | + 'objet' => 'rubrique', |
|
| 231 | + 'id_objet' => $id_rubrique, |
|
| 232 | + 'statut' => 'publie', |
|
| 233 | + 'date' => $date |
|
| 234 | + ], |
|
| 235 | + 'data' => $compte |
|
| 236 | + ] |
|
| 237 | + ); |
|
| 238 | + |
|
| 239 | + // S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas |
|
| 240 | + foreach ($compte as $objet => $n) { |
|
| 241 | + if ($n) { |
|
| 242 | + return false; |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique)); |
|
| 247 | 247 | |
| 248 | 248 | # spip_log("depublier_rubrique $id_pred"); |
| 249 | - return true; |
|
| 249 | + return true; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
@@ -269,18 +269,18 @@ discard block |
||
| 269 | 269 | **/ |
| 270 | 270 | function calculer_rubriques() { |
| 271 | 271 | |
| 272 | - calculer_rubriques_publiees(); |
|
| 272 | + calculer_rubriques_publiees(); |
|
| 273 | 273 | |
| 274 | - // Apres chaque (de)publication |
|
| 275 | - // recalculer les langues utilisees sur le site |
|
| 276 | - $langues = calculer_langues_utilisees(); |
|
| 277 | - ecrire_meta('langues_utilisees', $langues); |
|
| 274 | + // Apres chaque (de)publication |
|
| 275 | + // recalculer les langues utilisees sur le site |
|
| 276 | + $langues = calculer_langues_utilisees(); |
|
| 277 | + ecrire_meta('langues_utilisees', $langues); |
|
| 278 | 278 | |
| 279 | - // Sauver la date de la derniere mise a jour (pour menu_rubriques) |
|
| 280 | - ecrire_meta('date_calcul_rubriques', date('U')); |
|
| 279 | + // Sauver la date de la derniere mise a jour (pour menu_rubriques) |
|
| 280 | + ecrire_meta('date_calcul_rubriques', date('U')); |
|
| 281 | 281 | |
| 282 | - // on calcule la date du prochain article post-date |
|
| 283 | - calculer_prochain_postdate(); |
|
| 282 | + // on calcule la date du prochain article post-date |
|
| 283 | + calculer_prochain_postdate(); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
@@ -297,61 +297,61 @@ discard block |
||
| 297 | 297 | **/ |
| 298 | 298 | function calculer_rubriques_publiees() { |
| 299 | 299 | |
| 300 | - // Mettre les compteurs a zero |
|
| 301 | - sql_updateq('spip_rubriques', ['date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa']); |
|
| 302 | - |
|
| 303 | - // |
|
| 304 | - // Publier et dater les rubriques qui ont un article publie |
|
| 305 | - // |
|
| 306 | - |
|
| 307 | - // Afficher les articles post-dates ? |
|
| 308 | - $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 309 | - 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 310 | - |
|
| 311 | - $r = sql_select( |
|
| 312 | - 'R.id_rubrique AS id, max(A.date) AS date_h', |
|
| 313 | - 'spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique', |
|
| 314 | - "A.date>R.date_tmp AND A.statut='publie' $postdates ", |
|
| 315 | - 'R.id_rubrique' |
|
| 316 | - ); |
|
| 317 | - while ($row = sql_fetch($r)) { |
|
| 318 | - sql_updateq( |
|
| 319 | - 'spip_rubriques', |
|
| 320 | - ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
|
| 321 | - 'id_rubrique=' . intval($row['id']) |
|
| 322 | - ); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - // point d'entree pour permettre a des plugins de gerer le statut |
|
| 326 | - // autrement (par ex: toute rubrique est publiee des sa creation) |
|
| 327 | - // Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates |
|
| 328 | - // c'est statut_tmp/date_tmp qu'il doit modifier |
|
| 329 | - // [C'est un trigger... a renommer en trig_calculer_rubriques ?] |
|
| 330 | - pipeline('calculer_rubriques', null); |
|
| 331 | - |
|
| 332 | - |
|
| 333 | - // Les rubriques qui ont une rubrique fille plus recente |
|
| 334 | - // on tourne tant que les donnees remontent vers la racine. |
|
| 335 | - do { |
|
| 336 | - $continuer = false; |
|
| 337 | - $r = sql_select( |
|
| 338 | - 'R.id_rubrique AS id, max(SR.date_tmp) AS date_h', |
|
| 339 | - 'spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent', |
|
| 340 | - "(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ", |
|
| 341 | - 'R.id_rubrique' |
|
| 342 | - ); |
|
| 343 | - while ($row = sql_fetch($r)) { |
|
| 344 | - sql_updateq( |
|
| 345 | - 'spip_rubriques', |
|
| 346 | - ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
|
| 347 | - 'id_rubrique=' . intval($row['id']) |
|
| 348 | - ); |
|
| 349 | - $continuer = true; |
|
| 350 | - } |
|
| 351 | - } while ($continuer); |
|
| 352 | - |
|
| 353 | - // Enregistrement des modifs |
|
| 354 | - sql_update('spip_rubriques', ['date' => 'date_tmp', 'statut' => 'statut_tmp']); |
|
| 300 | + // Mettre les compteurs a zero |
|
| 301 | + sql_updateq('spip_rubriques', ['date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa']); |
|
| 302 | + |
|
| 303 | + // |
|
| 304 | + // Publier et dater les rubriques qui ont un article publie |
|
| 305 | + // |
|
| 306 | + |
|
| 307 | + // Afficher les articles post-dates ? |
|
| 308 | + $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 309 | + 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 310 | + |
|
| 311 | + $r = sql_select( |
|
| 312 | + 'R.id_rubrique AS id, max(A.date) AS date_h', |
|
| 313 | + 'spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique', |
|
| 314 | + "A.date>R.date_tmp AND A.statut='publie' $postdates ", |
|
| 315 | + 'R.id_rubrique' |
|
| 316 | + ); |
|
| 317 | + while ($row = sql_fetch($r)) { |
|
| 318 | + sql_updateq( |
|
| 319 | + 'spip_rubriques', |
|
| 320 | + ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
|
| 321 | + 'id_rubrique=' . intval($row['id']) |
|
| 322 | + ); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + // point d'entree pour permettre a des plugins de gerer le statut |
|
| 326 | + // autrement (par ex: toute rubrique est publiee des sa creation) |
|
| 327 | + // Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates |
|
| 328 | + // c'est statut_tmp/date_tmp qu'il doit modifier |
|
| 329 | + // [C'est un trigger... a renommer en trig_calculer_rubriques ?] |
|
| 330 | + pipeline('calculer_rubriques', null); |
|
| 331 | + |
|
| 332 | + |
|
| 333 | + // Les rubriques qui ont une rubrique fille plus recente |
|
| 334 | + // on tourne tant que les donnees remontent vers la racine. |
|
| 335 | + do { |
|
| 336 | + $continuer = false; |
|
| 337 | + $r = sql_select( |
|
| 338 | + 'R.id_rubrique AS id, max(SR.date_tmp) AS date_h', |
|
| 339 | + 'spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent', |
|
| 340 | + "(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ", |
|
| 341 | + 'R.id_rubrique' |
|
| 342 | + ); |
|
| 343 | + while ($row = sql_fetch($r)) { |
|
| 344 | + sql_updateq( |
|
| 345 | + 'spip_rubriques', |
|
| 346 | + ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
|
| 347 | + 'id_rubrique=' . intval($row['id']) |
|
| 348 | + ); |
|
| 349 | + $continuer = true; |
|
| 350 | + } |
|
| 351 | + } while ($continuer); |
|
| 352 | + |
|
| 353 | + // Enregistrement des modifs |
|
| 354 | + sql_update('spip_rubriques', ['date' => 'date_tmp', 'statut' => 'statut_tmp']); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -366,123 +366,123 @@ discard block |
||
| 366 | 366 | * @return void |
| 367 | 367 | **/ |
| 368 | 368 | function propager_les_secteurs() { |
| 369 | - // Profondeur 0 |
|
| 370 | - // Toutes les rubriques racines sont de profondeur 0 |
|
| 371 | - // et fixer les id_secteur des rubriques racines |
|
| 372 | - sql_update('spip_rubriques', ['id_secteur' => 'id_rubrique', 'profondeur' => 0], 'id_parent=0'); |
|
| 373 | - // Toute rubrique non racine est de profondeur >0 |
|
| 374 | - sql_updateq('spip_rubriques', ['profondeur' => 1], 'id_parent<>0 AND profondeur=0'); |
|
| 375 | - |
|
| 376 | - // securite : pas plus d'iteration que de rubriques dans la base |
|
| 377 | - $maxiter = sql_countsel('spip_rubriques'); |
|
| 378 | - |
|
| 379 | - // reparer les rubriques qui n'ont pas l'id_secteur de leur parent |
|
| 380 | - // on fait profondeur par profondeur |
|
| 381 | - |
|
| 382 | - $prof = 0; |
|
| 383 | - do { |
|
| 384 | - $continuer = false; |
|
| 385 | - |
|
| 386 | - // Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes |
|
| 387 | - // on fixe le profondeur $prof+1 |
|
| 388 | - |
|
| 389 | - // Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1 |
|
| 390 | - // on teste A.profondeur > $prof+1 car : |
|
| 391 | - // - toutes les rubriques de profondeur 0 à $prof sont bonnes |
|
| 392 | - // - si A.profondeur = $prof+1 c'est bon |
|
| 393 | - // - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques |
|
| 394 | - $maxiter2 = $maxiter; |
|
| 395 | - while ( |
|
| 396 | - $maxiter2-- |
|
| 397 | - and $rows = sql_allfetsel( |
|
| 398 | - 'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur', |
|
| 399 | - 'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique', |
|
| 400 | - 'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)', |
|
| 401 | - '', |
|
| 402 | - 'R.id_secteur', |
|
| 403 | - '0,100' |
|
| 404 | - ) |
|
| 405 | - ) { |
|
| 406 | - $id_secteur = null; |
|
| 407 | - $ids = []; |
|
| 408 | - while ($row = array_shift($rows)) { |
|
| 409 | - if ($row['id_secteur'] !== $id_secteur) { |
|
| 410 | - if (count($ids)) { |
|
| 411 | - sql_updateq( |
|
| 412 | - 'spip_rubriques', |
|
| 413 | - ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1], |
|
| 414 | - sql_in('id_rubrique', $ids) |
|
| 415 | - ); |
|
| 416 | - } |
|
| 417 | - $id_secteur = $row['id_secteur']; |
|
| 418 | - $ids = []; |
|
| 419 | - } |
|
| 420 | - $ids[] = $row['id']; |
|
| 421 | - } |
|
| 422 | - if (count($ids)) { |
|
| 423 | - sql_updateq( |
|
| 424 | - 'spip_rubriques', |
|
| 425 | - ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1], |
|
| 426 | - sql_in('id_rubrique', $ids) |
|
| 427 | - ); |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - // Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees |
|
| 433 | - $maxiter2 = $maxiter; |
|
| 434 | - while ( |
|
| 435 | - $maxiter2-- |
|
| 436 | - and $rows = sql_allfetsel( |
|
| 437 | - 'id_rubrique as id', |
|
| 438 | - 'spip_rubriques', |
|
| 439 | - 'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select( |
|
| 440 | - 'zzz.id_rubrique', |
|
| 441 | - 'spip_rubriques AS zzz', |
|
| 442 | - 'zzz.profondeur=' . intval($prof) |
|
| 443 | - ) . ')', |
|
| 444 | - '', |
|
| 445 | - '', |
|
| 446 | - '0,100' |
|
| 447 | - ) |
|
| 448 | - ) { |
|
| 449 | - $rows = array_column($rows, 'id'); |
|
| 450 | - sql_updateq('spip_rubriques', ['profondeur' => $prof + 2], sql_in('id_rubrique', $rows)); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - // ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK |
|
| 454 | - // si pas de rubrique a profondeur $prof+1 pas la peine de continuer |
|
| 455 | - // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse) |
|
| 456 | - // on arrete les frais |
|
| 457 | - if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) { |
|
| 458 | - $prof++; |
|
| 459 | - $continuer = true; |
|
| 460 | - } |
|
| 461 | - } while ($continuer and $maxiter--); |
|
| 462 | - |
|
| 463 | - // loger si la table des rubriques semble foireuse |
|
| 464 | - // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles |
|
| 465 | - if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) { |
|
| 466 | - spip_log( |
|
| 467 | - 'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)', |
|
| 468 | - _LOG_CRITIQUE |
|
| 469 | - ); |
|
| 470 | - sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1)); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - // reparer les articles |
|
| 474 | - $r = sql_select( |
|
| 475 | - 'A.id_article AS id, R.id_secteur AS secteur', |
|
| 476 | - 'spip_articles AS A, spip_rubriques AS R', |
|
| 477 | - 'A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur' |
|
| 478 | - ); |
|
| 479 | - |
|
| 480 | - while ($row = sql_fetch($r)) { |
|
| 481 | - sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id'])); |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - // avertir les plugins qui peuvent faire leur mises a jour egalement |
|
| 485 | - pipeline('trig_propager_les_secteurs', ''); |
|
| 369 | + // Profondeur 0 |
|
| 370 | + // Toutes les rubriques racines sont de profondeur 0 |
|
| 371 | + // et fixer les id_secteur des rubriques racines |
|
| 372 | + sql_update('spip_rubriques', ['id_secteur' => 'id_rubrique', 'profondeur' => 0], 'id_parent=0'); |
|
| 373 | + // Toute rubrique non racine est de profondeur >0 |
|
| 374 | + sql_updateq('spip_rubriques', ['profondeur' => 1], 'id_parent<>0 AND profondeur=0'); |
|
| 375 | + |
|
| 376 | + // securite : pas plus d'iteration que de rubriques dans la base |
|
| 377 | + $maxiter = sql_countsel('spip_rubriques'); |
|
| 378 | + |
|
| 379 | + // reparer les rubriques qui n'ont pas l'id_secteur de leur parent |
|
| 380 | + // on fait profondeur par profondeur |
|
| 381 | + |
|
| 382 | + $prof = 0; |
|
| 383 | + do { |
|
| 384 | + $continuer = false; |
|
| 385 | + |
|
| 386 | + // Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes |
|
| 387 | + // on fixe le profondeur $prof+1 |
|
| 388 | + |
|
| 389 | + // Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1 |
|
| 390 | + // on teste A.profondeur > $prof+1 car : |
|
| 391 | + // - toutes les rubriques de profondeur 0 à $prof sont bonnes |
|
| 392 | + // - si A.profondeur = $prof+1 c'est bon |
|
| 393 | + // - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques |
|
| 394 | + $maxiter2 = $maxiter; |
|
| 395 | + while ( |
|
| 396 | + $maxiter2-- |
|
| 397 | + and $rows = sql_allfetsel( |
|
| 398 | + 'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur', |
|
| 399 | + 'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique', |
|
| 400 | + 'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)', |
|
| 401 | + '', |
|
| 402 | + 'R.id_secteur', |
|
| 403 | + '0,100' |
|
| 404 | + ) |
|
| 405 | + ) { |
|
| 406 | + $id_secteur = null; |
|
| 407 | + $ids = []; |
|
| 408 | + while ($row = array_shift($rows)) { |
|
| 409 | + if ($row['id_secteur'] !== $id_secteur) { |
|
| 410 | + if (count($ids)) { |
|
| 411 | + sql_updateq( |
|
| 412 | + 'spip_rubriques', |
|
| 413 | + ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1], |
|
| 414 | + sql_in('id_rubrique', $ids) |
|
| 415 | + ); |
|
| 416 | + } |
|
| 417 | + $id_secteur = $row['id_secteur']; |
|
| 418 | + $ids = []; |
|
| 419 | + } |
|
| 420 | + $ids[] = $row['id']; |
|
| 421 | + } |
|
| 422 | + if (count($ids)) { |
|
| 423 | + sql_updateq( |
|
| 424 | + 'spip_rubriques', |
|
| 425 | + ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1], |
|
| 426 | + sql_in('id_rubrique', $ids) |
|
| 427 | + ); |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + // Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees |
|
| 433 | + $maxiter2 = $maxiter; |
|
| 434 | + while ( |
|
| 435 | + $maxiter2-- |
|
| 436 | + and $rows = sql_allfetsel( |
|
| 437 | + 'id_rubrique as id', |
|
| 438 | + 'spip_rubriques', |
|
| 439 | + 'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select( |
|
| 440 | + 'zzz.id_rubrique', |
|
| 441 | + 'spip_rubriques AS zzz', |
|
| 442 | + 'zzz.profondeur=' . intval($prof) |
|
| 443 | + ) . ')', |
|
| 444 | + '', |
|
| 445 | + '', |
|
| 446 | + '0,100' |
|
| 447 | + ) |
|
| 448 | + ) { |
|
| 449 | + $rows = array_column($rows, 'id'); |
|
| 450 | + sql_updateq('spip_rubriques', ['profondeur' => $prof + 2], sql_in('id_rubrique', $rows)); |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + // ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK |
|
| 454 | + // si pas de rubrique a profondeur $prof+1 pas la peine de continuer |
|
| 455 | + // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse) |
|
| 456 | + // on arrete les frais |
|
| 457 | + if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) { |
|
| 458 | + $prof++; |
|
| 459 | + $continuer = true; |
|
| 460 | + } |
|
| 461 | + } while ($continuer and $maxiter--); |
|
| 462 | + |
|
| 463 | + // loger si la table des rubriques semble foireuse |
|
| 464 | + // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles |
|
| 465 | + if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) { |
|
| 466 | + spip_log( |
|
| 467 | + 'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)', |
|
| 468 | + _LOG_CRITIQUE |
|
| 469 | + ); |
|
| 470 | + sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1)); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + // reparer les articles |
|
| 474 | + $r = sql_select( |
|
| 475 | + 'A.id_article AS id, R.id_secteur AS secteur', |
|
| 476 | + 'spip_articles AS A, spip_rubriques AS R', |
|
| 477 | + 'A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur' |
|
| 478 | + ); |
|
| 479 | + |
|
| 480 | + while ($row = sql_fetch($r)) { |
|
| 481 | + sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id'])); |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + // avertir les plugins qui peuvent faire leur mises a jour egalement |
|
| 485 | + pipeline('trig_propager_les_secteurs', ''); |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | |
@@ -497,23 +497,23 @@ discard block |
||
| 497 | 497 | * true si un changement a eu lieu |
| 498 | 498 | **/ |
| 499 | 499 | function calculer_langues_rubriques_etape() { |
| 500 | - $s = sql_select( |
|
| 501 | - 'A.id_rubrique AS id_rubrique, R.lang AS lang', |
|
| 502 | - 'spip_rubriques AS A, spip_rubriques AS R', |
|
| 503 | - "A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang" |
|
| 504 | - ); |
|
| 505 | - |
|
| 506 | - $t = false; |
|
| 507 | - while ($row = sql_fetch($s)) { |
|
| 508 | - $id_rubrique = $row['id_rubrique']; |
|
| 509 | - $t = sql_updateq( |
|
| 510 | - 'spip_rubriques', |
|
| 511 | - ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
|
| 512 | - 'id_rubrique=' . intval($id_rubrique) |
|
| 513 | - ); |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - return $t; |
|
| 500 | + $s = sql_select( |
|
| 501 | + 'A.id_rubrique AS id_rubrique, R.lang AS lang', |
|
| 502 | + 'spip_rubriques AS A, spip_rubriques AS R', |
|
| 503 | + "A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang" |
|
| 504 | + ); |
|
| 505 | + |
|
| 506 | + $t = false; |
|
| 507 | + while ($row = sql_fetch($s)) { |
|
| 508 | + $id_rubrique = $row['id_rubrique']; |
|
| 509 | + $t = sql_updateq( |
|
| 510 | + 'spip_rubriques', |
|
| 511 | + ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
|
| 512 | + 'id_rubrique=' . intval($id_rubrique) |
|
| 513 | + ); |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + return $t; |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -533,38 +533,38 @@ discard block |
||
| 533 | 533 | **/ |
| 534 | 534 | function calculer_langues_rubriques() { |
| 535 | 535 | |
| 536 | - // rubriques (recursivite) |
|
| 537 | - sql_updateq( |
|
| 538 | - 'spip_rubriques', |
|
| 539 | - ['lang' => $GLOBALS['meta']['langue_site'], 'langue_choisie' => 'non'], |
|
| 540 | - "id_parent=0 AND langue_choisie != 'oui'" |
|
| 541 | - ); |
|
| 542 | - while (calculer_langues_rubriques_etape()) { |
|
| 543 | - ; |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - // articles |
|
| 547 | - $s = sql_select( |
|
| 548 | - 'A.id_article AS id_article, R.lang AS lang', |
|
| 549 | - 'spip_articles AS A, spip_rubriques AS R', |
|
| 550 | - "A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang" |
|
| 551 | - ); |
|
| 552 | - while ($row = sql_fetch($s)) { |
|
| 553 | - $id_article = $row['id_article']; |
|
| 554 | - sql_updateq( |
|
| 555 | - 'spip_articles', |
|
| 556 | - ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
|
| 557 | - 'id_article=' . intval($id_article) |
|
| 558 | - ); |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - if ($GLOBALS['meta']['multi_rubriques'] == 'oui') { |
|
| 562 | - $langues = calculer_langues_utilisees(); |
|
| 563 | - ecrire_meta('langues_utilisees', $langues); |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - // avertir les plugins qui peuvent faire leur mises a jour egalement |
|
| 567 | - pipeline('trig_calculer_langues_rubriques', ''); |
|
| 536 | + // rubriques (recursivite) |
|
| 537 | + sql_updateq( |
|
| 538 | + 'spip_rubriques', |
|
| 539 | + ['lang' => $GLOBALS['meta']['langue_site'], 'langue_choisie' => 'non'], |
|
| 540 | + "id_parent=0 AND langue_choisie != 'oui'" |
|
| 541 | + ); |
|
| 542 | + while (calculer_langues_rubriques_etape()) { |
|
| 543 | + ; |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + // articles |
|
| 547 | + $s = sql_select( |
|
| 548 | + 'A.id_article AS id_article, R.lang AS lang', |
|
| 549 | + 'spip_articles AS A, spip_rubriques AS R', |
|
| 550 | + "A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang" |
|
| 551 | + ); |
|
| 552 | + while ($row = sql_fetch($s)) { |
|
| 553 | + $id_article = $row['id_article']; |
|
| 554 | + sql_updateq( |
|
| 555 | + 'spip_articles', |
|
| 556 | + ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
|
| 557 | + 'id_article=' . intval($id_article) |
|
| 558 | + ); |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + if ($GLOBALS['meta']['multi_rubriques'] == 'oui') { |
|
| 562 | + $langues = calculer_langues_utilisees(); |
|
| 563 | + ecrire_meta('langues_utilisees', $langues); |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + // avertir les plugins qui peuvent faire leur mises a jour egalement |
|
| 567 | + pipeline('trig_calculer_langues_rubriques', ''); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | |
@@ -581,80 +581,80 @@ discard block |
||
| 581 | 581 | * Liste des langues utilisées séparées par des virgules |
| 582 | 582 | **/ |
| 583 | 583 | function calculer_langues_utilisees($serveur = '') { |
| 584 | - include_spip('public/interfaces'); |
|
| 585 | - include_spip('public/compiler'); |
|
| 586 | - include_spip('public/composer'); |
|
| 587 | - include_spip('public/phraser_html'); |
|
| 588 | - $langues = []; |
|
| 589 | - |
|
| 590 | - $langues[$GLOBALS['meta']['langue_site']] = 1; |
|
| 591 | - |
|
| 592 | - include_spip('base/objets'); |
|
| 593 | - $tables = lister_tables_objets_sql(); |
|
| 594 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 595 | - |
|
| 596 | - foreach (array_keys($tables) as $t) { |
|
| 597 | - $desc = $trouver_table($t, $serveur); |
|
| 598 | - // c'est une table avec des langues |
|
| 599 | - if ( |
|
| 600 | - $desc['exist'] |
|
| 601 | - and isset($desc['field']['lang']) |
|
| 602 | - and isset($desc['field']['langue_choisie']) |
|
| 603 | - ) { |
|
| 604 | - $boucle = new Boucle(); |
|
| 605 | - $boucle->show = $desc; |
|
| 606 | - $boucle->nom = 'calculer_langues_utilisees'; |
|
| 607 | - $boucle->id_boucle = $desc['table_objet']; |
|
| 608 | - $boucle->id_table = $desc['table_objet']; |
|
| 609 | - $boucle->primary = $desc['key']['PRIMARY KEY'] ?? ''; |
|
| 610 | - $boucle->sql_serveur = $serveur; |
|
| 611 | - $boucle->select[] = 'DISTINCT lang'; |
|
| 612 | - $boucle->from[$desc['table_objet']] = $t; |
|
| 613 | - $boucle->separateur[] = ','; |
|
| 614 | - $boucle->return = '$Pile[$SP][\'lang\']'; |
|
| 615 | - $boucle->iterateur = 'sql'; |
|
| 616 | - |
|
| 617 | - $boucle->descr['nom'] = 'calculer_langues_utilisees'; // eviter notice php |
|
| 618 | - $boucle->descr['sourcefile'] = 'internal'; |
|
| 619 | - $boucle->descr['gram'] = 'html'; |
|
| 620 | - |
|
| 621 | - $boucle = pipeline('pre_boucle', $boucle); |
|
| 622 | - |
|
| 623 | - if ( |
|
| 624 | - isset($desc['statut']) |
|
| 625 | - and $desc['statut'] |
|
| 626 | - ) { |
|
| 627 | - $boucles = [ |
|
| 628 | - 'calculer_langues_utilisees' => $boucle, |
|
| 629 | - ]; |
|
| 630 | - // generer un nom de fonction "anonyme" unique |
|
| 631 | - do { |
|
| 632 | - $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . rand(); |
|
| 633 | - } while (function_exists($functionname)); |
|
| 634 | - $code = calculer_boucle('calculer_langues_utilisees', $boucles); |
|
| 635 | - $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code; |
|
| 636 | - $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();'; |
|
| 637 | - $res = ''; |
|
| 638 | - eval($code); |
|
| 639 | - $res = explode(',', $res); |
|
| 640 | - foreach ($res as $lang) { |
|
| 641 | - $langues[$lang] = 1; |
|
| 642 | - } |
|
| 643 | - } else { |
|
| 644 | - $res = sql_select(implode(',', $boucle->select), $boucle->from); |
|
| 645 | - while ($row = sql_fetch($res)) { |
|
| 646 | - $langues[$row['lang']] = 1; |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - |
|
| 652 | - $langues = array_filter(array_keys($langues)); |
|
| 653 | - sort($langues); |
|
| 654 | - $langues = join(',', $langues); |
|
| 655 | - spip_log("langues utilisees: $langues"); |
|
| 656 | - |
|
| 657 | - return $langues; |
|
| 584 | + include_spip('public/interfaces'); |
|
| 585 | + include_spip('public/compiler'); |
|
| 586 | + include_spip('public/composer'); |
|
| 587 | + include_spip('public/phraser_html'); |
|
| 588 | + $langues = []; |
|
| 589 | + |
|
| 590 | + $langues[$GLOBALS['meta']['langue_site']] = 1; |
|
| 591 | + |
|
| 592 | + include_spip('base/objets'); |
|
| 593 | + $tables = lister_tables_objets_sql(); |
|
| 594 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 595 | + |
|
| 596 | + foreach (array_keys($tables) as $t) { |
|
| 597 | + $desc = $trouver_table($t, $serveur); |
|
| 598 | + // c'est une table avec des langues |
|
| 599 | + if ( |
|
| 600 | + $desc['exist'] |
|
| 601 | + and isset($desc['field']['lang']) |
|
| 602 | + and isset($desc['field']['langue_choisie']) |
|
| 603 | + ) { |
|
| 604 | + $boucle = new Boucle(); |
|
| 605 | + $boucle->show = $desc; |
|
| 606 | + $boucle->nom = 'calculer_langues_utilisees'; |
|
| 607 | + $boucle->id_boucle = $desc['table_objet']; |
|
| 608 | + $boucle->id_table = $desc['table_objet']; |
|
| 609 | + $boucle->primary = $desc['key']['PRIMARY KEY'] ?? ''; |
|
| 610 | + $boucle->sql_serveur = $serveur; |
|
| 611 | + $boucle->select[] = 'DISTINCT lang'; |
|
| 612 | + $boucle->from[$desc['table_objet']] = $t; |
|
| 613 | + $boucle->separateur[] = ','; |
|
| 614 | + $boucle->return = '$Pile[$SP][\'lang\']'; |
|
| 615 | + $boucle->iterateur = 'sql'; |
|
| 616 | + |
|
| 617 | + $boucle->descr['nom'] = 'calculer_langues_utilisees'; // eviter notice php |
|
| 618 | + $boucle->descr['sourcefile'] = 'internal'; |
|
| 619 | + $boucle->descr['gram'] = 'html'; |
|
| 620 | + |
|
| 621 | + $boucle = pipeline('pre_boucle', $boucle); |
|
| 622 | + |
|
| 623 | + if ( |
|
| 624 | + isset($desc['statut']) |
|
| 625 | + and $desc['statut'] |
|
| 626 | + ) { |
|
| 627 | + $boucles = [ |
|
| 628 | + 'calculer_langues_utilisees' => $boucle, |
|
| 629 | + ]; |
|
| 630 | + // generer un nom de fonction "anonyme" unique |
|
| 631 | + do { |
|
| 632 | + $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . rand(); |
|
| 633 | + } while (function_exists($functionname)); |
|
| 634 | + $code = calculer_boucle('calculer_langues_utilisees', $boucles); |
|
| 635 | + $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code; |
|
| 636 | + $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();'; |
|
| 637 | + $res = ''; |
|
| 638 | + eval($code); |
|
| 639 | + $res = explode(',', $res); |
|
| 640 | + foreach ($res as $lang) { |
|
| 641 | + $langues[$lang] = 1; |
|
| 642 | + } |
|
| 643 | + } else { |
|
| 644 | + $res = sql_select(implode(',', $boucle->select), $boucle->from); |
|
| 645 | + while ($row = sql_fetch($res)) { |
|
| 646 | + $langues[$row['lang']] = 1; |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + |
|
| 652 | + $langues = array_filter(array_keys($langues)); |
|
| 653 | + sort($langues); |
|
| 654 | + $langues = join(',', $langues); |
|
| 655 | + spip_log("langues utilisees: $langues"); |
|
| 656 | + |
|
| 657 | + return $langues; |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
@@ -671,9 +671,9 @@ discard block |
||
| 671 | 671 | * incluant les rubriques noeuds et toutes leurs descendances |
| 672 | 672 | */ |
| 673 | 673 | function calcul_branche_in($id) { |
| 674 | - $calcul_branche_in = charger_fonction('calcul_branche_in', 'inc'); |
|
| 674 | + $calcul_branche_in = charger_fonction('calcul_branche_in', 'inc'); |
|
| 675 | 675 | |
| 676 | - return $calcul_branche_in($id); |
|
| 676 | + return $calcul_branche_in($id); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | /** |
@@ -691,9 +691,9 @@ discard block |
||
| 691 | 691 | * incluant les rubriques transmises et toutes leurs parentées |
| 692 | 692 | */ |
| 693 | 693 | function calcul_hierarchie_in($id, $tout = true) { |
| 694 | - $calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc'); |
|
| 694 | + $calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc'); |
|
| 695 | 695 | |
| 696 | - return $calcul_hierarchie_in($id, $tout); |
|
| 696 | + return $calcul_hierarchie_in($id, $tout); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | |
@@ -714,40 +714,40 @@ discard block |
||
| 714 | 714 | * incluant les rubriques noeuds et toutes leurs descendances |
| 715 | 715 | */ |
| 716 | 716 | function inc_calcul_branche_in_dist($id) { |
| 717 | - static $b = []; |
|
| 718 | - |
|
| 719 | - // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN |
|
| 720 | - if (!is_array($id)) { |
|
| 721 | - $id = explode(',', $id); |
|
| 722 | - } |
|
| 723 | - $id = join(',', array_map('intval', $id)); |
|
| 724 | - if (isset($b[$id])) { |
|
| 725 | - return $b[$id]; |
|
| 726 | - } |
|
| 727 | - |
|
| 728 | - // Notre branche commence par la rubrique de depart |
|
| 729 | - $branche = $r = $id; |
|
| 730 | - |
|
| 731 | - // On ajoute une generation (les filles de la generation precedente) |
|
| 732 | - // jusqu'a epuisement, en se protegeant des references circulaires |
|
| 733 | - $maxiter = 10000; |
|
| 734 | - while ( |
|
| 735 | - $maxiter-- and $filles = sql_allfetsel( |
|
| 736 | - 'id_rubrique', |
|
| 737 | - 'spip_rubriques', |
|
| 738 | - sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT') |
|
| 739 | - ) |
|
| 740 | - ) { |
|
| 741 | - $r = join(',', array_column($filles, 'id_rubrique')); |
|
| 742 | - $branche .= ',' . $r; |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
|
| 746 | - if (strlen($branche) < 10000) { |
|
| 747 | - $b[$id] = $branche; |
|
| 748 | - } |
|
| 749 | - |
|
| 750 | - return $branche; |
|
| 717 | + static $b = []; |
|
| 718 | + |
|
| 719 | + // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN |
|
| 720 | + if (!is_array($id)) { |
|
| 721 | + $id = explode(',', $id); |
|
| 722 | + } |
|
| 723 | + $id = join(',', array_map('intval', $id)); |
|
| 724 | + if (isset($b[$id])) { |
|
| 725 | + return $b[$id]; |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + // Notre branche commence par la rubrique de depart |
|
| 729 | + $branche = $r = $id; |
|
| 730 | + |
|
| 731 | + // On ajoute une generation (les filles de la generation precedente) |
|
| 732 | + // jusqu'a epuisement, en se protegeant des references circulaires |
|
| 733 | + $maxiter = 10000; |
|
| 734 | + while ( |
|
| 735 | + $maxiter-- and $filles = sql_allfetsel( |
|
| 736 | + 'id_rubrique', |
|
| 737 | + 'spip_rubriques', |
|
| 738 | + sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT') |
|
| 739 | + ) |
|
| 740 | + ) { |
|
| 741 | + $r = join(',', array_column($filles, 'id_rubrique')); |
|
| 742 | + $branche .= ',' . $r; |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
|
| 746 | + if (strlen($branche) < 10000) { |
|
| 747 | + $b[$id] = $branche; |
|
| 748 | + } |
|
| 749 | + |
|
| 750 | + return $branche; |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | |
@@ -769,45 +769,45 @@ discard block |
||
| 769 | 769 | * incluant les rubriques transmises et toutes leurs parentées |
| 770 | 770 | */ |
| 771 | 771 | function inc_calcul_hierarchie_in_dist($id, $tout = true) { |
| 772 | - static $b = []; |
|
| 773 | - |
|
| 774 | - // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN |
|
| 775 | - if (!is_array($id)) { |
|
| 776 | - $id = explode(',', $id); |
|
| 777 | - } |
|
| 778 | - $id = join(',', array_map('intval', $id)); |
|
| 779 | - |
|
| 780 | - if (isset($b[$id])) { |
|
| 781 | - // Notre branche commence par la rubrique de depart si $tout=true |
|
| 782 | - return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id]; |
|
| 783 | - } |
|
| 784 | - |
|
| 785 | - $hier = ''; |
|
| 786 | - |
|
| 787 | - // On ajoute une generation (les filles de la generation precedente) |
|
| 788 | - // jusqu'a epuisement, en se protegeant des references circulaires |
|
| 789 | - $ids_nouveaux_parents = $id; |
|
| 790 | - $maxiter = 10000; |
|
| 791 | - while ( |
|
| 792 | - $maxiter-- and $parents = sql_allfetsel( |
|
| 793 | - 'id_parent', |
|
| 794 | - 'spip_rubriques', |
|
| 795 | - sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT') |
|
| 796 | - ) |
|
| 797 | - ) { |
|
| 798 | - $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent')); |
|
| 799 | - $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : ''); |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
|
| 803 | - if (strlen($hier) < 10000) { |
|
| 804 | - $b[$id] = $hier; |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - // Notre branche commence par la rubrique de depart si $tout=true |
|
| 808 | - $hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier; |
|
| 809 | - |
|
| 810 | - return $hier; |
|
| 772 | + static $b = []; |
|
| 773 | + |
|
| 774 | + // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN |
|
| 775 | + if (!is_array($id)) { |
|
| 776 | + $id = explode(',', $id); |
|
| 777 | + } |
|
| 778 | + $id = join(',', array_map('intval', $id)); |
|
| 779 | + |
|
| 780 | + if (isset($b[$id])) { |
|
| 781 | + // Notre branche commence par la rubrique de depart si $tout=true |
|
| 782 | + return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id]; |
|
| 783 | + } |
|
| 784 | + |
|
| 785 | + $hier = ''; |
|
| 786 | + |
|
| 787 | + // On ajoute une generation (les filles de la generation precedente) |
|
| 788 | + // jusqu'a epuisement, en se protegeant des references circulaires |
|
| 789 | + $ids_nouveaux_parents = $id; |
|
| 790 | + $maxiter = 10000; |
|
| 791 | + while ( |
|
| 792 | + $maxiter-- and $parents = sql_allfetsel( |
|
| 793 | + 'id_parent', |
|
| 794 | + 'spip_rubriques', |
|
| 795 | + sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT') |
|
| 796 | + ) |
|
| 797 | + ) { |
|
| 798 | + $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent')); |
|
| 799 | + $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : ''); |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
|
| 803 | + if (strlen($hier) < 10000) { |
|
| 804 | + $b[$id] = $hier; |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + // Notre branche commence par la rubrique de depart si $tout=true |
|
| 808 | + $hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier; |
|
| 809 | + |
|
| 810 | + return $hier; |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | |
@@ -825,47 +825,47 @@ discard block |
||
| 825 | 825 | * @return void |
| 826 | 826 | **/ |
| 827 | 827 | function calculer_prochain_postdate($check = false) { |
| 828 | - include_spip('base/abstract_sql'); |
|
| 829 | - if ($check) { |
|
| 830 | - $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 831 | - 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 832 | - |
|
| 833 | - $r = sql_select( |
|
| 834 | - 'DISTINCT A.id_rubrique AS id', |
|
| 835 | - 'spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique', |
|
| 836 | - "R.statut != 'publie' AND A.statut='publie'$postdates" |
|
| 837 | - ); |
|
| 838 | - while ($row = sql_fetch($r)) { |
|
| 839 | - publier_branche_rubrique($row['id']); |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - pipeline('trig_calculer_prochain_postdate', ''); |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - $t = sql_fetsel( |
|
| 846 | - 'date', |
|
| 847 | - 'spip_articles', |
|
| 848 | - "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), |
|
| 849 | - '', |
|
| 850 | - 'date', |
|
| 851 | - '1' |
|
| 852 | - ); |
|
| 853 | - |
|
| 854 | - if ($t) { |
|
| 855 | - $t = $t['date']; |
|
| 856 | - if ( |
|
| 857 | - !isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 858 | - or $t <> $GLOBALS['meta']['date_prochain_postdate'] |
|
| 859 | - ) { |
|
| 860 | - ecrire_meta('date_prochain_postdate', strtotime($t)); |
|
| 861 | - ecrire_meta('derniere_modif', time()); |
|
| 862 | - } |
|
| 863 | - } else { |
|
| 864 | - effacer_meta('date_prochain_postdate'); |
|
| 865 | - ecrire_meta('derniere_modif', time()); |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - spip_log("prochain postdate: $t"); |
|
| 828 | + include_spip('base/abstract_sql'); |
|
| 829 | + if ($check) { |
|
| 830 | + $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 831 | + 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 832 | + |
|
| 833 | + $r = sql_select( |
|
| 834 | + 'DISTINCT A.id_rubrique AS id', |
|
| 835 | + 'spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique', |
|
| 836 | + "R.statut != 'publie' AND A.statut='publie'$postdates" |
|
| 837 | + ); |
|
| 838 | + while ($row = sql_fetch($r)) { |
|
| 839 | + publier_branche_rubrique($row['id']); |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + pipeline('trig_calculer_prochain_postdate', ''); |
|
| 843 | + } |
|
| 844 | + |
|
| 845 | + $t = sql_fetsel( |
|
| 846 | + 'date', |
|
| 847 | + 'spip_articles', |
|
| 848 | + "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), |
|
| 849 | + '', |
|
| 850 | + 'date', |
|
| 851 | + '1' |
|
| 852 | + ); |
|
| 853 | + |
|
| 854 | + if ($t) { |
|
| 855 | + $t = $t['date']; |
|
| 856 | + if ( |
|
| 857 | + !isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 858 | + or $t <> $GLOBALS['meta']['date_prochain_postdate'] |
|
| 859 | + ) { |
|
| 860 | + ecrire_meta('date_prochain_postdate', strtotime($t)); |
|
| 861 | + ecrire_meta('derniere_modif', time()); |
|
| 862 | + } |
|
| 863 | + } else { |
|
| 864 | + effacer_meta('date_prochain_postdate'); |
|
| 865 | + ecrire_meta('derniere_modif', time()); |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + spip_log("prochain postdate: $t"); |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | /** |
@@ -890,62 +890,62 @@ discard block |
||
| 890 | 890 | */ |
| 891 | 891 | function creer_rubrique_nommee($titre, $id_parent = 0, $serveur = '') { |
| 892 | 892 | |
| 893 | - // eclater l'arborescence demandee |
|
| 894 | - // echapper les </multi> et autres balises fermantes html |
|
| 895 | - $titre = preg_replace(',</([a-z][^>]*)>,ims', "<@\\1>", $titre); |
|
| 896 | - $arbo = explode('/', preg_replace(',^/,', '', $titre)); |
|
| 897 | - include_spip('base/abstract_sql'); |
|
| 898 | - foreach ($arbo as $titre) { |
|
| 899 | - // retablir les </multi> et autres balises fermantes html |
|
| 900 | - $titre = preg_replace(',<@([a-z][^>]*)>,ims', "</\\1>", $titre); |
|
| 901 | - $r = sql_getfetsel( |
|
| 902 | - 'id_rubrique', |
|
| 903 | - 'spip_rubriques', |
|
| 904 | - 'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent), |
|
| 905 | - $groupby = [], |
|
| 906 | - $orderby = [], |
|
| 907 | - $limit = '', |
|
| 908 | - $having = [], |
|
| 909 | - $serveur |
|
| 910 | - ); |
|
| 911 | - if ($r !== null) { |
|
| 912 | - $id_parent = $r; |
|
| 913 | - } else { |
|
| 914 | - $id_rubrique = sql_insertq('spip_rubriques', [ |
|
| 915 | - 'titre' => $titre, |
|
| 916 | - 'id_parent' => $id_parent, |
|
| 917 | - 'statut' => 'prepa' |
|
| 918 | - ], $desc = [], $serveur); |
|
| 919 | - if ($id_parent > 0) { |
|
| 920 | - $data = sql_fetsel( |
|
| 921 | - 'id_secteur,lang', |
|
| 922 | - 'spip_rubriques', |
|
| 923 | - "id_rubrique=$id_parent", |
|
| 924 | - $groupby = [], |
|
| 925 | - $orderby = [], |
|
| 926 | - $limit = '', |
|
| 927 | - $having = [], |
|
| 928 | - $serveur |
|
| 929 | - ); |
|
| 930 | - $id_secteur = $data['id_secteur']; |
|
| 931 | - $lang = $data['lang']; |
|
| 932 | - } else { |
|
| 933 | - $id_secteur = $id_rubrique; |
|
| 934 | - $lang = $GLOBALS['meta']['langue_site']; |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - sql_updateq( |
|
| 938 | - 'spip_rubriques', |
|
| 939 | - ['id_secteur' => $id_secteur, 'lang' => $lang], |
|
| 940 | - 'id_rubrique=' . intval($id_rubrique), |
|
| 941 | - $desc = '', |
|
| 942 | - $serveur |
|
| 943 | - ); |
|
| 944 | - |
|
| 945 | - // pour la recursion |
|
| 946 | - $id_parent = $id_rubrique; |
|
| 947 | - } |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - return intval($id_parent); |
|
| 893 | + // eclater l'arborescence demandee |
|
| 894 | + // echapper les </multi> et autres balises fermantes html |
|
| 895 | + $titre = preg_replace(',</([a-z][^>]*)>,ims', "<@\\1>", $titre); |
|
| 896 | + $arbo = explode('/', preg_replace(',^/,', '', $titre)); |
|
| 897 | + include_spip('base/abstract_sql'); |
|
| 898 | + foreach ($arbo as $titre) { |
|
| 899 | + // retablir les </multi> et autres balises fermantes html |
|
| 900 | + $titre = preg_replace(',<@([a-z][^>]*)>,ims', "</\\1>", $titre); |
|
| 901 | + $r = sql_getfetsel( |
|
| 902 | + 'id_rubrique', |
|
| 903 | + 'spip_rubriques', |
|
| 904 | + 'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent), |
|
| 905 | + $groupby = [], |
|
| 906 | + $orderby = [], |
|
| 907 | + $limit = '', |
|
| 908 | + $having = [], |
|
| 909 | + $serveur |
|
| 910 | + ); |
|
| 911 | + if ($r !== null) { |
|
| 912 | + $id_parent = $r; |
|
| 913 | + } else { |
|
| 914 | + $id_rubrique = sql_insertq('spip_rubriques', [ |
|
| 915 | + 'titre' => $titre, |
|
| 916 | + 'id_parent' => $id_parent, |
|
| 917 | + 'statut' => 'prepa' |
|
| 918 | + ], $desc = [], $serveur); |
|
| 919 | + if ($id_parent > 0) { |
|
| 920 | + $data = sql_fetsel( |
|
| 921 | + 'id_secteur,lang', |
|
| 922 | + 'spip_rubriques', |
|
| 923 | + "id_rubrique=$id_parent", |
|
| 924 | + $groupby = [], |
|
| 925 | + $orderby = [], |
|
| 926 | + $limit = '', |
|
| 927 | + $having = [], |
|
| 928 | + $serveur |
|
| 929 | + ); |
|
| 930 | + $id_secteur = $data['id_secteur']; |
|
| 931 | + $lang = $data['lang']; |
|
| 932 | + } else { |
|
| 933 | + $id_secteur = $id_rubrique; |
|
| 934 | + $lang = $GLOBALS['meta']['langue_site']; |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + sql_updateq( |
|
| 938 | + 'spip_rubriques', |
|
| 939 | + ['id_secteur' => $id_secteur, 'lang' => $lang], |
|
| 940 | + 'id_rubrique=' . intval($id_rubrique), |
|
| 941 | + $desc = '', |
|
| 942 | + $serveur |
|
| 943 | + ); |
|
| 944 | + |
|
| 945 | + // pour la recursion |
|
| 946 | + $id_parent = $id_rubrique; |
|
| 947 | + } |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + return intval($id_parent); |
|
| 951 | 951 | } |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | sql_updateq( |
| 135 | 135 | 'spip_rubriques', |
| 136 | 136 | ['statut' => 'publie', 'date' => date('Y-m-d H:i:s')], |
| 137 | - 'id_rubrique=' . intval($id_rubrique) |
|
| 137 | + 'id_rubrique='.intval($id_rubrique) |
|
| 138 | 138 | ); |
| 139 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique)); |
|
| 139 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique='.intval($id_rubrique)); |
|
| 140 | 140 | if (!$id_parent) { |
| 141 | 141 | break; |
| 142 | 142 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | return $id_pred != $id_rubrique; |
| 172 | 172 | } |
| 173 | 173 | // passer au parent si on a depublie |
| 174 | - $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred)); |
|
| 174 | + $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id_pred)); |
|
| 175 | 175 | $id_pred = $r['id_parent']; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | $date = date('Y-m-d H:i:s'); |
| 197 | 197 | } |
| 198 | 198 | $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
| 199 | - ' AND date <= ' . sql_quote($date) : ''; |
|
| 199 | + ' AND date <= '.sql_quote($date) : ''; |
|
| 200 | 200 | |
| 201 | 201 | if (!$id_rubrique = intval($id_rubrique)) { |
| 202 | 202 | return false; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // verifier qu'elle existe et est bien publiee |
| 206 | - $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 206 | + $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 207 | 207 | if (!$r or $r['statut'] !== 'publie') { |
| 208 | 208 | return false; |
| 209 | 209 | } |
@@ -213,12 +213,12 @@ discard block |
||
| 213 | 213 | $compte = [ |
| 214 | 214 | 'articles' => sql_countsel( |
| 215 | 215 | 'spip_articles', |
| 216 | - 'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates" |
|
| 216 | + 'id_rubrique='.intval($id_rubrique)." AND statut='publie'$postdates" |
|
| 217 | 217 | ), |
| 218 | - 'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"), |
|
| 218 | + 'rubriques' => sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)." AND statut='publie'"), |
|
| 219 | 219 | 'documents' => sql_countsel( |
| 220 | 220 | 'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document', |
| 221 | - 'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') " |
|
| 221 | + 'L.id_objet='.intval($id_rubrique)." AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') " |
|
| 222 | 222 | ) |
| 223 | 223 | ]; |
| 224 | 224 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique)); |
|
| 246 | + sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique='.intval($id_rubrique)); |
|
| 247 | 247 | |
| 248 | 248 | # spip_log("depublier_rubrique $id_pred"); |
| 249 | 249 | return true; |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | // Afficher les articles post-dates ? |
| 308 | 308 | $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
| 309 | - 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 309 | + 'AND A.date <= '.sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 310 | 310 | |
| 311 | 311 | $r = sql_select( |
| 312 | 312 | 'R.id_rubrique AS id, max(A.date) AS date_h', |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | sql_updateq( |
| 319 | 319 | 'spip_rubriques', |
| 320 | 320 | ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
| 321 | - 'id_rubrique=' . intval($row['id']) |
|
| 321 | + 'id_rubrique='.intval($row['id']) |
|
| 322 | 322 | ); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | sql_updateq( |
| 345 | 345 | 'spip_rubriques', |
| 346 | 346 | ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
| 347 | - 'id_rubrique=' . intval($row['id']) |
|
| 347 | + 'id_rubrique='.intval($row['id']) |
|
| 348 | 348 | ); |
| 349 | 349 | $continuer = true; |
| 350 | 350 | } |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | and $rows = sql_allfetsel( |
| 398 | 398 | 'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur', |
| 399 | 399 | 'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique', |
| 400 | - 'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)', |
|
| 400 | + 'R.profondeur='.intval($prof).' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)', |
|
| 401 | 401 | '', |
| 402 | 402 | 'R.id_secteur', |
| 403 | 403 | '0,100' |
@@ -436,11 +436,11 @@ discard block |
||
| 436 | 436 | and $rows = sql_allfetsel( |
| 437 | 437 | 'id_rubrique as id', |
| 438 | 438 | 'spip_rubriques', |
| 439 | - 'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select( |
|
| 439 | + 'profondeur='.intval($prof + 1).' AND id_parent NOT IN ('.sql_get_select( |
|
| 440 | 440 | 'zzz.id_rubrique', |
| 441 | 441 | 'spip_rubriques AS zzz', |
| 442 | - 'zzz.profondeur=' . intval($prof) |
|
| 443 | - ) . ')', |
|
| 442 | + 'zzz.profondeur='.intval($prof) |
|
| 443 | + ).')', |
|
| 444 | 444 | '', |
| 445 | 445 | '', |
| 446 | 446 | '0,100' |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | // si pas de rubrique a profondeur $prof+1 pas la peine de continuer |
| 455 | 455 | // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse) |
| 456 | 456 | // on arrete les frais |
| 457 | - if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) { |
|
| 457 | + if (sql_countsel('spip_rubriques', 'profondeur='.intval($prof + 1))) { |
|
| 458 | 458 | $prof++; |
| 459 | 459 | $continuer = true; |
| 460 | 460 | } |
@@ -462,12 +462,12 @@ discard block |
||
| 462 | 462 | |
| 463 | 463 | // loger si la table des rubriques semble foireuse |
| 464 | 464 | // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles |
| 465 | - if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) { |
|
| 465 | + if (sql_countsel('spip_rubriques', 'profondeur>'.intval($prof + 1))) { |
|
| 466 | 466 | spip_log( |
| 467 | - 'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)', |
|
| 467 | + 'Les rubriques de profondeur>'.($prof + 1).' semblent suspectes (branches morte ou reference circulaire dans les parents)', |
|
| 468 | 468 | _LOG_CRITIQUE |
| 469 | 469 | ); |
| 470 | - sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1)); |
|
| 470 | + sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>'.intval($prof + 1)); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // reparer les articles |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | ); |
| 479 | 479 | |
| 480 | 480 | while ($row = sql_fetch($r)) { |
| 481 | - sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id'])); |
|
| 481 | + sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article='.intval($row['id'])); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | // avertir les plugins qui peuvent faire leur mises a jour egalement |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | $t = sql_updateq( |
| 510 | 510 | 'spip_rubriques', |
| 511 | 511 | ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
| 512 | - 'id_rubrique=' . intval($id_rubrique) |
|
| 512 | + 'id_rubrique='.intval($id_rubrique) |
|
| 513 | 513 | ); |
| 514 | 514 | } |
| 515 | 515 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | sql_updateq( |
| 555 | 555 | 'spip_articles', |
| 556 | 556 | ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
| 557 | - 'id_article=' . intval($id_article) |
|
| 557 | + 'id_article='.intval($id_article) |
|
| 558 | 558 | ); |
| 559 | 559 | } |
| 560 | 560 | |
@@ -629,11 +629,11 @@ discard block |
||
| 629 | 629 | ]; |
| 630 | 630 | // generer un nom de fonction "anonyme" unique |
| 631 | 631 | do { |
| 632 | - $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . rand(); |
|
| 632 | + $functionname = 'f_calculer_langues_utilisees_'.$boucle->id_table.'_'.time().'_'.rand(); |
|
| 633 | 633 | } while (function_exists($functionname)); |
| 634 | 634 | $code = calculer_boucle('calculer_langues_utilisees', $boucles); |
| 635 | - $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code; |
|
| 636 | - $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();'; |
|
| 635 | + $code = '$SP=0; $command=array();$command["connect"] = $connect = "'.$serveur.'"; $Pile=array(0=>array());'."\n".$code; |
|
| 636 | + $code = 'function '.$functionname.'(){'.$code.'};$res = '.$functionname.'();'; |
|
| 637 | 637 | $res = ''; |
| 638 | 638 | eval($code); |
| 639 | 639 | $res = explode(',', $res); |
@@ -735,11 +735,11 @@ discard block |
||
| 735 | 735 | $maxiter-- and $filles = sql_allfetsel( |
| 736 | 736 | 'id_rubrique', |
| 737 | 737 | 'spip_rubriques', |
| 738 | - sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT') |
|
| 738 | + sql_in('id_parent', $r).' AND '.sql_in('id_rubrique', $r, 'NOT') |
|
| 739 | 739 | ) |
| 740 | 740 | ) { |
| 741 | 741 | $r = join(',', array_column($filles, 'id_rubrique')); |
| 742 | - $branche .= ',' . $r; |
|
| 742 | + $branche .= ','.$r; |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | if (isset($b[$id])) { |
| 781 | 781 | // Notre branche commence par la rubrique de depart si $tout=true |
| 782 | - return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id]; |
|
| 782 | + return $tout ? (strlen($b[$id]) ? $b[$id].",$id" : $id) : $b[$id]; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | $hier = ''; |
@@ -792,11 +792,11 @@ discard block |
||
| 792 | 792 | $maxiter-- and $parents = sql_allfetsel( |
| 793 | 793 | 'id_parent', |
| 794 | 794 | 'spip_rubriques', |
| 795 | - sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT') |
|
| 795 | + sql_in('id_rubrique', $ids_nouveaux_parents).' AND '.sql_in('id_parent', $hier, 'NOT') |
|
| 796 | 796 | ) |
| 797 | 797 | ) { |
| 798 | 798 | $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent')); |
| 799 | - $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : ''); |
|
| 799 | + $hier = $ids_nouveaux_parents.(strlen($hier) ? ','.$hier : ''); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | include_spip('base/abstract_sql'); |
| 829 | 829 | if ($check) { |
| 830 | 830 | $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
| 831 | - 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 831 | + 'AND A.date <= '.sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 832 | 832 | |
| 833 | 833 | $r = sql_select( |
| 834 | 834 | 'DISTINCT A.id_rubrique AS id', |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | $t = sql_fetsel( |
| 846 | 846 | 'date', |
| 847 | 847 | 'spip_articles', |
| 848 | - "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), |
|
| 848 | + "statut='publie' AND date > ".sql_quote(date('Y-m-d H:i:s')), |
|
| 849 | 849 | '', |
| 850 | 850 | 'date', |
| 851 | 851 | '1' |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | $r = sql_getfetsel( |
| 902 | 902 | 'id_rubrique', |
| 903 | 903 | 'spip_rubriques', |
| 904 | - 'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent), |
|
| 904 | + 'titre = '.sql_quote($titre).' AND id_parent='.intval($id_parent), |
|
| 905 | 905 | $groupby = [], |
| 906 | 906 | $orderby = [], |
| 907 | 907 | $limit = '', |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | sql_updateq( |
| 938 | 938 | 'spip_rubriques', |
| 939 | 939 | ['id_secteur' => $id_secteur, 'lang' => $lang], |
| 940 | - 'id_rubrique=' . intval($id_rubrique), |
|
| 940 | + 'id_rubrique='.intval($id_rubrique), |
|
| 941 | 941 | $desc = '', |
| 942 | 942 | $serveur |
| 943 | 943 | ); |
@@ -77,8 +77,7 @@ |
||
| 77 | 77 | break; // stop on a trouvé le bon champ |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - } |
|
| 81 | - else { |
|
| 80 | + } else { |
|
| 82 | 81 | $statuts_publies = ['publie']; |
| 83 | 82 | } |
| 84 | 83 | |