@@ -64,13 +64,13 @@ |
||
| 64 | 64 | spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
| 65 | 65 | foreach ($desc['field'] as $field => $type) { |
| 66 | 66 | if ($desc['field'][$field] !== $fields_corrected[$field]) { |
| 67 | - spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 68 | - sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 67 | + spip_log("Adaptation TIMESTAMP table $table", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 68 | + sql_alter("table $table change $field $field ".$fields_corrected[$field]); |
|
| 69 | 69 | $trouver_table(''); |
| 70 | 70 | $new_desc = $trouver_table($table); |
| 71 | 71 | spip_log( |
| 72 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 72 | + "Apres conversion $table : ".var_export($new_desc['field'], true), |
|
| 73 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @package SPIP\Core\SQL\Upgrade |
| 20 | 20 | **/ |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -34,49 +34,49 @@ discard block |
||
| 34 | 34 | **/ |
| 35 | 35 | function maj_timestamp_mysql($tables = null) { |
| 36 | 36 | |
| 37 | - include_spip('base/dump'); |
|
| 38 | - if (is_null($tables)) { |
|
| 39 | - $tables = base_lister_toutes_tables(); |
|
| 40 | - } elseif (is_string($tables)) { |
|
| 41 | - $tables = [$tables]; |
|
| 42 | - } elseif (!is_array($tables)) { |
|
| 43 | - return; |
|
| 44 | - } |
|
| 37 | + include_spip('base/dump'); |
|
| 38 | + if (is_null($tables)) { |
|
| 39 | + $tables = base_lister_toutes_tables(); |
|
| 40 | + } elseif (is_string($tables)) { |
|
| 41 | + $tables = [$tables]; |
|
| 42 | + } elseif (!is_array($tables)) { |
|
| 43 | + return; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // rien a faire si base non mysql |
|
| 47 | - if (!str_starts_with($GLOBALS['connexions'][0]['type'], 'mysql')) { |
|
| 48 | - return; |
|
| 49 | - } |
|
| 46 | + // rien a faire si base non mysql |
|
| 47 | + if (!str_starts_with($GLOBALS['connexions'][0]['type'], 'mysql')) { |
|
| 48 | + return; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 52 | - // forcer le vidage de cache |
|
| 53 | - $trouver_table(''); |
|
| 51 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 52 | + // forcer le vidage de cache |
|
| 53 | + $trouver_table(''); |
|
| 54 | 54 | |
| 55 | - foreach ($tables as $table) { |
|
| 56 | - if (time() >= _TIME_OUT) { |
|
| 57 | - return; |
|
| 58 | - } |
|
| 59 | - if ($desc = $trouver_table($table)) { |
|
| 60 | - $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 61 | - $d = array_diff($desc['field'], $fields_corrected); |
|
| 62 | - if ($d) { |
|
| 63 | - spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 64 | - foreach ($desc['field'] as $field => $type) { |
|
| 65 | - if ($desc['field'][$field] !== $fields_corrected[$field]) { |
|
| 66 | - spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 67 | - sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 68 | - $trouver_table(''); |
|
| 69 | - $new_desc = $trouver_table($table); |
|
| 70 | - spip_log( |
|
| 71 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 72 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 55 | + foreach ($tables as $table) { |
|
| 56 | + if (time() >= _TIME_OUT) { |
|
| 57 | + return; |
|
| 58 | + } |
|
| 59 | + if ($desc = $trouver_table($table)) { |
|
| 60 | + $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 61 | + $d = array_diff($desc['field'], $fields_corrected); |
|
| 62 | + if ($d) { |
|
| 63 | + spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 64 | + foreach ($desc['field'] as $field => $type) { |
|
| 65 | + if ($desc['field'][$field] !== $fields_corrected[$field]) { |
|
| 66 | + spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 67 | + sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 68 | + $trouver_table(''); |
|
| 69 | + $new_desc = $trouver_table($table); |
|
| 70 | + spip_log( |
|
| 71 | + "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 72 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - // forcer le vidage de cache |
|
| 81 | - $trouver_table(''); |
|
| 80 | + // forcer le vidage de cache |
|
| 81 | + $trouver_table(''); |
|
| 82 | 82 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('maj/legacy/v30'); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | #if (!$sql_desc) $sql_desc = false; |
| 86 | 86 | #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 87 | 87 | if (!$sql_desc) { |
| 88 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 88 | + spip_log("Echec creation table $table", 'maj'._LOG_CRITIQUE); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } else { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if (isset($desc['field'])) { |
| 98 | 98 | foreach ($desc['field'] as $field => $type) { |
| 99 | 99 | if (!isset($sql_desc['field'][$field])) { |
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 100 | + sql_alter("TABLE $table ADD $field $type".($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | 101 | } |
| 102 | 102 | $last = $field; |
| 103 | 103 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Installation |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/acces'); |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | 35 | function base_determine_autoinc($table, $desc = []) { |
| 36 | - if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | - $autoinc = true; |
|
| 38 | - } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | - $autoinc = false; |
|
| 40 | - } else { |
|
| 41 | - // essayer de faire au mieux ! |
|
| 42 | - $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | - and !str_contains($desc['key']['PRIMARY KEY'], ',') |
|
| 44 | - and !str_contains($desc['field'][$desc['key']['PRIMARY KEY']], 'default')); |
|
| 45 | - } |
|
| 36 | + if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | + $autoinc = true; |
|
| 38 | + } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | + $autoinc = false; |
|
| 40 | + } else { |
|
| 41 | + // essayer de faire au mieux ! |
|
| 42 | + $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | + and !str_contains($desc['key']['PRIMARY KEY'], ',') |
|
| 44 | + and !str_contains($desc['field'][$desc['key']['PRIMARY KEY']], 'default')); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $autoinc; |
|
| 47 | + return $autoinc; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -61,58 +61,58 @@ discard block |
||
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | 63 | function creer_ou_upgrader_table($table, $desc, $autoinc, $upgrade = false, $serveur = '') { |
| 64 | - #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | - $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | - #if (!$sql_desc) $sql_desc = false; |
|
| 67 | - #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | - if (!$sql_desc) { |
|
| 69 | - if ($autoinc === 'auto') { |
|
| 70 | - $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | - } |
|
| 72 | - #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | - if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | - } |
|
| 76 | - // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | - #if (!$sql_desc) $sql_desc = false; |
|
| 79 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | - if (!$sql_desc) { |
|
| 81 | - // on retente avec un sleep ? |
|
| 82 | - sleep(1); |
|
| 83 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | - #if (!$sql_desc) $sql_desc = false; |
|
| 86 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | - if (!$sql_desc) { |
|
| 88 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | - // ajouter les champs manquants |
|
| 94 | - // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | - // c'est toujours a faire manuellement |
|
| 96 | - $last = ''; |
|
| 97 | - if (isset($desc['field'])) { |
|
| 98 | - foreach ($desc['field'] as $field => $type) { |
|
| 99 | - if (!isset($sql_desc['field'][$field])) { |
|
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | - } |
|
| 102 | - $last = $field; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - if (isset($desc['key'])) { |
|
| 106 | - foreach ($desc['key'] as $key => $type) { |
|
| 107 | - // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | - // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | - if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | - sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | - } |
|
| 112 | - $last = $field; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 64 | + #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | + $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | + #if (!$sql_desc) $sql_desc = false; |
|
| 67 | + #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | + if (!$sql_desc) { |
|
| 69 | + if ($autoinc === 'auto') { |
|
| 70 | + $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | + } |
|
| 72 | + #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | + if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | + } |
|
| 76 | + // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | + #if (!$sql_desc) $sql_desc = false; |
|
| 79 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | + if (!$sql_desc) { |
|
| 81 | + // on retente avec un sleep ? |
|
| 82 | + sleep(1); |
|
| 83 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | + #if (!$sql_desc) $sql_desc = false; |
|
| 86 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | + if (!$sql_desc) { |
|
| 88 | + spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | + // ajouter les champs manquants |
|
| 94 | + // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | + // c'est toujours a faire manuellement |
|
| 96 | + $last = ''; |
|
| 97 | + if (isset($desc['field'])) { |
|
| 98 | + foreach ($desc['field'] as $field => $type) { |
|
| 99 | + if (!isset($sql_desc['field'][$field])) { |
|
| 100 | + sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | + } |
|
| 102 | + $last = $field; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + if (isset($desc['key'])) { |
|
| 106 | + foreach ($desc['key'] as $key => $type) { |
|
| 107 | + // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | + // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | + if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | + sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | + } |
|
| 112 | + $last = $field; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -134,26 +134,26 @@ discard block |
||
| 134 | 134 | * @return void |
| 135 | 135 | */ |
| 136 | 136 | function alterer_base($tables_inc, $tables_noinc, $up = false, $serveur = '') { |
| 137 | - if ($up === false) { |
|
| 138 | - $old = false; |
|
| 139 | - $up = []; |
|
| 140 | - } else { |
|
| 141 | - $old = true; |
|
| 142 | - if (!is_array($up)) { |
|
| 143 | - $up = [$up]; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - foreach ($tables_inc as $k => $v) { |
|
| 147 | - if (!$old or in_array($k, $up)) { |
|
| 148 | - creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 149 | - } |
|
| 150 | - } |
|
| 137 | + if ($up === false) { |
|
| 138 | + $old = false; |
|
| 139 | + $up = []; |
|
| 140 | + } else { |
|
| 141 | + $old = true; |
|
| 142 | + if (!is_array($up)) { |
|
| 143 | + $up = [$up]; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + foreach ($tables_inc as $k => $v) { |
|
| 147 | + if (!$old or in_array($k, $up)) { |
|
| 148 | + creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - foreach ($tables_noinc as $k => $v) { |
|
| 153 | - if (!$old or in_array($k, $up)) { |
|
| 154 | - creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 155 | - } |
|
| 156 | - } |
|
| 152 | + foreach ($tables_noinc as $k => $v) { |
|
| 153 | + if (!$old or in_array($k, $up)) { |
|
| 154 | + creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | function creer_base($serveur = '') { |
| 175 | 175 | |
| 176 | - // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 177 | - // de la conformite de la base |
|
| 178 | - // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 176 | + // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 177 | + // de la conformite de la base |
|
| 178 | + // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 179 | 179 | |
| 180 | - alterer_base( |
|
| 181 | - lister_tables_principales(), |
|
| 182 | - lister_tables_auxiliaires(), |
|
| 183 | - false, |
|
| 184 | - $serveur |
|
| 185 | - ); |
|
| 180 | + alterer_base( |
|
| 181 | + lister_tables_principales(), |
|
| 182 | + lister_tables_auxiliaires(), |
|
| 183 | + false, |
|
| 184 | + $serveur |
|
| 185 | + ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | * @return void |
| 203 | 203 | */ |
| 204 | 204 | function maj_tables($upgrade_tables = [], $serveur = '') { |
| 205 | - alterer_base( |
|
| 206 | - lister_tables_principales(), |
|
| 207 | - lister_tables_auxiliaires(), |
|
| 208 | - $upgrade_tables, |
|
| 209 | - $serveur |
|
| 210 | - ); |
|
| 205 | + alterer_base( |
|
| 206 | + lister_tables_principales(), |
|
| 207 | + lister_tables_auxiliaires(), |
|
| 208 | + $upgrade_tables, |
|
| 209 | + $serveur |
|
| 210 | + ); |
|
| 211 | 211 | } |
@@ -1395,8 +1395,7 @@ |
||
| 1395 | 1395 | 'champ' => $parent_methode['champ'], |
| 1396 | 1396 | 'table' => $table, |
| 1397 | 1397 | ]; |
| 1398 | - } |
|
| 1399 | - elseif (isset($parent_methode['champ_type'])) { |
|
| 1398 | + } elseif (isset($parent_methode['champ_type'])) { |
|
| 1400 | 1399 | $parent = [ |
| 1401 | 1400 | 'objet' => $ligne[$parent_methode['champ_type']], |
| 1402 | 1401 | 'id_objet' => intval($ligne[$parent_methode['champ']]), |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | $infos['url_voir'] = $infos['type']; |
| 707 | 707 | } |
| 708 | 708 | if (!isset($infos['url_edit'])) { |
| 709 | - $infos['url_edit'] = $infos['url_voir'] . ($infos['editable'] ? '_edit' : ''); |
|
| 709 | + $infos['url_edit'] = $infos['url_voir'].($infos['editable'] ? '_edit' : ''); |
|
| 710 | 710 | } |
| 711 | 711 | if (!isset($infos['icone_objet'])) { |
| 712 | 712 | $infos['icone_objet'] = $infos['type']; |
@@ -718,48 +718,48 @@ discard block |
||
| 718 | 718 | $infos['texte_retour'] = 'icone_retour'; |
| 719 | 719 | } |
| 720 | 720 | if (!isset($infos['texte_modifier'])) { |
| 721 | - $infos['texte_modifier'] = $infos['type'] . ':' . 'icone_modifier_' . $infos['type']; |
|
| 721 | + $infos['texte_modifier'] = $infos['type'].':'.'icone_modifier_'.$infos['type']; |
|
| 722 | 722 | } |
| 723 | 723 | if (!isset($infos['texte_creer'])) { |
| 724 | - $infos['texte_creer'] = $infos['type'] . ':' . 'icone_creer_' . $infos['type']; |
|
| 724 | + $infos['texte_creer'] = $infos['type'].':'.'icone_creer_'.$infos['type']; |
|
| 725 | 725 | } |
| 726 | 726 | if (!isset($infos['texte_creer_associer'])) { |
| 727 | - $infos['texte_creer_associer'] = $infos['type'] . ':' . 'texte_creer_associer_' . $infos['type']; |
|
| 727 | + $infos['texte_creer_associer'] = $infos['type'].':'.'texte_creer_associer_'.$infos['type']; |
|
| 728 | 728 | } |
| 729 | 729 | if (!isset($infos['texte_ajouter'])) { |
| 730 | 730 | // Ajouter un X |
| 731 | - $infos['texte_ajouter'] = $infos['type'] . ':' . 'texte_ajouter_' . $infos['type']; |
|
| 731 | + $infos['texte_ajouter'] = $infos['type'].':'.'texte_ajouter_'.$infos['type']; |
|
| 732 | 732 | } |
| 733 | 733 | if (!isset($infos['texte_objets'])) { |
| 734 | - $infos['texte_objets'] = $infos['type'] . ':' . 'titre_' . $infos['table_objet']; |
|
| 734 | + $infos['texte_objets'] = $infos['type'].':'.'titre_'.$infos['table_objet']; |
|
| 735 | 735 | } |
| 736 | 736 | if (!isset($infos['texte_objet'])) { |
| 737 | - $infos['texte_objet'] = $infos['type'] . ':' . 'titre_' . $infos['type']; |
|
| 737 | + $infos['texte_objet'] = $infos['type'].':'.'titre_'.$infos['type']; |
|
| 738 | 738 | } |
| 739 | 739 | if (!isset($infos['texte_logo_objet'])) { |
| 740 | 740 | // objet:titre_logo_objet "Logo de ce X" |
| 741 | - $infos['texte_logo_objet'] = $infos['type'] . ':' . 'titre_logo_' . $infos['type']; |
|
| 741 | + $infos['texte_logo_objet'] = $infos['type'].':'.'titre_logo_'.$infos['type']; |
|
| 742 | 742 | } |
| 743 | 743 | if (!isset($infos['texte_langue_objet'])) { |
| 744 | 744 | // objet:texte_langue_objet "Langue de ce X" |
| 745 | - $infos['texte_langue_objet'] = $infos['type'] . ':' . 'titre_langue_' . $infos['type']; |
|
| 745 | + $infos['texte_langue_objet'] = $infos['type'].':'.'titre_langue_'.$infos['type']; |
|
| 746 | 746 | } |
| 747 | 747 | if (!isset($infos['texte_definir_comme_traduction_objet'])) { |
| 748 | 748 | // "Ce X est une traduction du X numéro :" |
| 749 | - $infos['texte_definir_comme_traduction_objet'] = $infos['type'] . ':' . 'texte_definir_comme_traduction_' . $infos['type']; |
|
| 749 | + $infos['texte_definir_comme_traduction_objet'] = $infos['type'].':'.'texte_definir_comme_traduction_'.$infos['type']; |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | // objet:info_aucun_objet |
| 753 | 753 | if (!isset($infos['info_aucun_objet'])) { |
| 754 | - $infos['info_aucun_objet'] = $infos['type'] . ':' . 'info_aucun_' . $infos['type']; |
|
| 754 | + $infos['info_aucun_objet'] = $infos['type'].':'.'info_aucun_'.$infos['type']; |
|
| 755 | 755 | } |
| 756 | 756 | // objet:info_1_objet |
| 757 | 757 | if (!isset($infos['info_1_objet'])) { |
| 758 | - $infos['info_1_objet'] = $infos['type'] . ':' . 'info_1_' . $infos['type']; |
|
| 758 | + $infos['info_1_objet'] = $infos['type'].':'.'info_1_'.$infos['type']; |
|
| 759 | 759 | } |
| 760 | 760 | // objet:info_nb_objets |
| 761 | 761 | if (!isset($infos['info_nb_objets'])) { |
| 762 | - $infos['info_nb_objets'] = $infos['type'] . ':' . 'info_nb_' . $infos['table_objet']; |
|
| 762 | + $infos['info_nb_objets'] = $infos['type'].':'.'info_nb_'.$infos['table_objet']; |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | if (!isset($infos['champs_editables'])) { |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | } |
| 960 | 960 | $ts = sql_alltable(null, $serveur); // toutes les tables "spip_" (ou prefixe perso) |
| 961 | 961 | $connexion = $GLOBALS['connexions'][$serveur ?: 0]; |
| 962 | - $spip = $connexion['prefixe'] . '_'; |
|
| 962 | + $spip = $connexion['prefixe'].'_'; |
|
| 963 | 963 | foreach ($ts as $t) { |
| 964 | 964 | $t = substr($t, strlen($spip)); |
| 965 | 965 | $tables[$serveur]["spip_$t"] = $t; |
@@ -1028,10 +1028,10 @@ discard block |
||
| 1028 | 1028 | if ($serveur !== false) { |
| 1029 | 1029 | $t = lister_tables_spip($serveur); |
| 1030 | 1030 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 1031 | - $typetrim = rtrim($type, 's') . 's'; |
|
| 1031 | + $typetrim = rtrim($type, 's').'s'; |
|
| 1032 | 1032 | if ( |
| 1033 | 1033 | (isset($t[$typetrim]) or in_array($typetrim, $t)) |
| 1034 | - and ($desc = $trouver_table(rtrim($type, 's') . 's', $serveur)) |
|
| 1034 | + and ($desc = $trouver_table(rtrim($type, 's').'s', $serveur)) |
|
| 1035 | 1035 | ) { |
| 1036 | 1036 | return $desc['id_table']; |
| 1037 | 1037 | } elseif ( |
@@ -1041,11 +1041,11 @@ discard block |
||
| 1041 | 1041 | return $desc['id_table']; |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | - spip_log('table_objet(' . $type . ') calculee sans verification'); |
|
| 1044 | + spip_log('table_objet('.$type.') calculee sans verification'); |
|
| 1045 | 1045 | #spip_log(debug_backtrace(),'db'); |
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | - return rtrim($type, 's') . 's'; # cas historique ne devant plus servir, sauf si $serveur=false |
|
| 1048 | + return rtrim($type, 's').'s'; # cas historique ne devant plus servir, sauf si $serveur=false |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | /** |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | function objet_test_si_publie($objet, $id_objet, $serveur = '') { |
| 1230 | 1230 | // voir si une fonction est definie pour faire le boulot |
| 1231 | 1231 | // elle a la priorite dans ce cas |
| 1232 | - if ($f = charger_fonction($objet . '_test_si_publie', 'base', true)) { |
|
| 1232 | + if ($f = charger_fonction($objet.'_test_si_publie', 'base', true)) { |
|
| 1233 | 1233 | return $f($objet, $id_objet, $serveur); |
| 1234 | 1234 | } |
| 1235 | 1235 | |
@@ -1251,7 +1251,7 @@ discard block |
||
| 1251 | 1251 | $boucle->sql_serveur = $serveur; |
| 1252 | 1252 | $boucle->select[] = $id_table_objet; |
| 1253 | 1253 | $boucle->from[$table_objet] = table_objet_sql($objet, $serveur); |
| 1254 | - $boucle->where[] = $id_table . '.' . $id_table_objet . '=' . intval($id_objet); |
|
| 1254 | + $boucle->where[] = $id_table.'.'.$id_table_objet.'='.intval($id_objet); |
|
| 1255 | 1255 | |
| 1256 | 1256 | $boucle->descr['nom'] = 'objet_test_si_publie'; // eviter notice php |
| 1257 | 1257 | $boucle->descr['sourcefile'] = 'internal'; |
@@ -1378,7 +1378,7 @@ discard block |
||
| 1378 | 1378 | ? "{$parent_methode['source_champ']} = $id_objet" |
| 1379 | 1379 | : "$cle_objet = $id_objet"; |
| 1380 | 1380 | if (isset($parent_methode['source_champ_type'])) { |
| 1381 | - $where[] = "{$parent_methode['source_champ_type']} = " . sql_quote($objet); |
|
| 1381 | + $where[] = "{$parent_methode['source_champ_type']} = ".sql_quote($objet); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | // -- Condition supplémentaire sur la détection du parent |
| 1384 | 1384 | if (isset($parent_methode['table_condition'])) { |
@@ -1502,11 +1502,11 @@ discard block |
||
| 1502 | 1502 | $where = []; |
| 1503 | 1503 | // -- L'identifiant du parent |
| 1504 | 1504 | if (isset($_methode_parent['champ'])) { |
| 1505 | - $where[] = $_methode_parent['champ'] . ' = ' . $id_objet; |
|
| 1505 | + $where[] = $_methode_parent['champ'].' = '.$id_objet; |
|
| 1506 | 1506 | } |
| 1507 | 1507 | // -- Si le parent est variable |
| 1508 | 1508 | if (isset($_methode_parent['champ_type'])) { |
| 1509 | - $where[] = $_methode_parent['champ_type'] . ' = ' . sql_quote($objet); |
|
| 1509 | + $where[] = $_methode_parent['champ_type'].' = '.sql_quote($objet); |
|
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | 1512 | // On détermine la table, le champ id des enfants et on complète éventuellement les conditions |
@@ -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 | /** |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * @return void |
| 33 | 33 | **/ |
| 34 | 34 | function array_set_merge(&$table, $index, $valeur) { |
| 35 | - if (!isset($table[$index])) { |
|
| 36 | - $table[$index] = $valeur; |
|
| 37 | - } else { |
|
| 38 | - $table[$index] = array_merge($table[$index], $valeur); |
|
| 39 | - } |
|
| 35 | + if (!isset($table[$index])) { |
|
| 36 | + $table[$index] = $valeur; |
|
| 37 | + } else { |
|
| 38 | + $table[$index] = array_merge($table[$index], $valeur); |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -55,441 +55,441 @@ discard block |
||
| 55 | 55 | * - string (interne) si table '::md5' retourne un hash |
| 56 | 56 | */ |
| 57 | 57 | function lister_tables_objets_sql(?string $table_sql = null, $desc = []) { |
| 58 | - static $deja_la = false; |
|
| 59 | - static $infos_tables = null; |
|
| 60 | - static $md5 = null; |
|
| 61 | - static $plugin_hash = null; |
|
| 62 | - |
|
| 63 | - // plugins hash connu ? non si _CACHE_PLUGINS_OPT est pas encore chargé. |
|
| 64 | - $_PLUGINS_HASH = defined('_PLUGINS_HASH') ? _PLUGINS_HASH : '!_CACHE_PLUGINS_OPT'; |
|
| 65 | - |
|
| 66 | - // prealablement recuperer les tables_principales |
|
| 67 | - if (is_null($infos_tables) or $plugin_hash !== $_PLUGINS_HASH) { |
|
| 68 | - // pas de reentrance (cas base/serial) |
|
| 69 | - if ($deja_la) { |
|
| 70 | - spip_log('Re-entrance anormale sur lister_tables_objets_sql : ' |
|
| 71 | - . var_export(debug_backtrace(), true), _LOG_CRITIQUE); |
|
| 72 | - |
|
| 73 | - return ($table_sql === '::md5' ? $md5 : []); |
|
| 74 | - } |
|
| 75 | - $deja_la = true; |
|
| 76 | - $plugin_hash = $_PLUGINS_HASH; // avant de lancer les pipelines |
|
| 77 | - |
|
| 78 | - // recuperer les declarations explicites ancienne mode |
|
| 79 | - // qui servent a completer declarer_tables_objets_sql |
|
| 80 | - base_serial($GLOBALS['tables_principales']); |
|
| 81 | - base_auxiliaires($GLOBALS['tables_auxiliaires']); |
|
| 82 | - $infos_tables = [ |
|
| 83 | - 'spip_articles' => [ |
|
| 84 | - 'page' => 'article', |
|
| 85 | - 'texte_retour' => 'icone_retour_article', |
|
| 86 | - 'texte_modifier' => 'icone_modifier_article', |
|
| 87 | - 'texte_creer' => 'icone_ecrire_article', |
|
| 88 | - 'texte_objets' => 'public:articles', |
|
| 89 | - 'texte_objet' => 'public:article', |
|
| 90 | - 'texte_signale_edition' => 'texte_travail_article', |
|
| 91 | - 'info_aucun_objet' => 'info_aucun_article', |
|
| 92 | - 'info_1_objet' => 'info_1_article', |
|
| 93 | - 'info_nb_objets' => 'info_nb_articles', |
|
| 94 | - 'texte_logo_objet' => 'logo_article', |
|
| 95 | - 'texte_langue_objet' => 'titre_langue_article', |
|
| 96 | - 'texte_definir_comme_traduction_objet' => 'trad_lier', |
|
| 97 | - 'titre' => 'titre, lang', |
|
| 98 | - 'date' => 'date', |
|
| 99 | - 'principale' => 'oui', |
|
| 100 | - 'introduction_longueur' => '500', |
|
| 101 | - 'champs_editables' => [ |
|
| 102 | - 'surtitre', |
|
| 103 | - 'titre', |
|
| 104 | - 'soustitre', |
|
| 105 | - 'descriptif', |
|
| 106 | - 'nom_site', |
|
| 107 | - 'url_site', |
|
| 108 | - 'chapo', |
|
| 109 | - 'texte', |
|
| 110 | - 'ps', |
|
| 111 | - 'virtuel' |
|
| 112 | - ], |
|
| 113 | - 'champs_versionnes' => [ |
|
| 114 | - 'id_rubrique', |
|
| 115 | - 'surtitre', |
|
| 116 | - 'titre', |
|
| 117 | - 'soustitre', |
|
| 118 | - 'jointure_auteurs', |
|
| 119 | - 'descriptif', |
|
| 120 | - 'nom_site', |
|
| 121 | - 'url_site', |
|
| 122 | - 'chapo', |
|
| 123 | - 'texte', |
|
| 124 | - 'ps' |
|
| 125 | - ], |
|
| 126 | - 'field' => [ |
|
| 127 | - 'id_article' => 'bigint(21) NOT NULL', |
|
| 128 | - 'surtitre' => "text DEFAULT '' NOT NULL", |
|
| 129 | - 'titre' => "text DEFAULT '' NOT NULL", |
|
| 130 | - 'soustitre' => "text DEFAULT '' NOT NULL", |
|
| 131 | - 'id_rubrique' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 132 | - 'descriptif' => "text DEFAULT '' NOT NULL", |
|
| 133 | - 'chapo' => "mediumtext DEFAULT '' NOT NULL", |
|
| 134 | - 'texte' => "longtext DEFAULT '' NOT NULL", |
|
| 135 | - 'ps' => "mediumtext DEFAULT '' NOT NULL", |
|
| 136 | - 'date' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 137 | - 'statut' => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 138 | - 'id_secteur' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 139 | - 'maj' => 'TIMESTAMP', |
|
| 140 | - 'export' => "VARCHAR(10) DEFAULT 'oui'", |
|
| 141 | - 'date_redac' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 142 | - 'visites' => "integer DEFAULT '0' NOT NULL", |
|
| 143 | - 'referers' => "integer DEFAULT '0' NOT NULL", |
|
| 144 | - 'popularite' => "DOUBLE DEFAULT '0' NOT NULL", |
|
| 145 | - 'accepter_forum' => "CHAR(3) DEFAULT '' NOT NULL", |
|
| 146 | - 'date_modif' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 147 | - 'lang' => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 148 | - 'langue_choisie' => "VARCHAR(3) DEFAULT 'non'", |
|
| 149 | - 'id_trad' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 150 | - 'nom_site' => "tinytext DEFAULT '' NOT NULL", |
|
| 151 | - 'url_site' => "text DEFAULT '' NOT NULL", |
|
| 152 | - 'virtuel' => "text DEFAULT '' NOT NULL", |
|
| 153 | - ], |
|
| 154 | - 'key' => [ |
|
| 155 | - 'PRIMARY KEY' => 'id_article', |
|
| 156 | - 'KEY id_rubrique' => 'id_rubrique', |
|
| 157 | - 'KEY id_secteur' => 'id_secteur', |
|
| 158 | - 'KEY id_trad' => 'id_trad', |
|
| 159 | - 'KEY lang' => 'lang', |
|
| 160 | - 'KEY statut' => 'statut, date', |
|
| 161 | - ], |
|
| 162 | - 'join' => [ |
|
| 163 | - 'id_article' => 'id_article', |
|
| 164 | - 'id_rubrique' => 'id_rubrique' |
|
| 165 | - ], |
|
| 166 | - 'parent' => [ |
|
| 167 | - ['type' => 'rubrique', 'champ' => 'id_rubrique'] |
|
| 168 | - ], |
|
| 169 | - 'rechercher_champs' => [ |
|
| 170 | - 'surtitre' => 5, |
|
| 171 | - 'titre' => 8, |
|
| 172 | - 'soustitre' => 5, |
|
| 173 | - 'chapo' => 3, |
|
| 174 | - 'texte' => 1, |
|
| 175 | - 'ps' => 1, |
|
| 176 | - 'nom_site' => 1, |
|
| 177 | - 'url_site' => 1, |
|
| 178 | - 'descriptif' => 4 |
|
| 179 | - ], |
|
| 180 | - 'rechercher_jointures' => [ |
|
| 181 | - 'auteur' => ['nom' => 10], |
|
| 182 | - ], |
|
| 183 | - 'statut' => [ |
|
| 184 | - [ |
|
| 185 | - 'champ' => 'statut', |
|
| 186 | - 'publie' => 'publie', |
|
| 187 | - 'previsu' => 'publie,prop,prepa/auteur', |
|
| 188 | - 'post_date' => 'date', |
|
| 189 | - 'exception' => ['statut', 'tout'] |
|
| 190 | - ] |
|
| 191 | - ], |
|
| 192 | - 'statut_titres' => [ |
|
| 193 | - 'prepa' => 'info_article_redaction', |
|
| 194 | - 'prop' => 'info_article_propose', |
|
| 195 | - 'publie' => 'info_article_publie', |
|
| 196 | - 'refuse' => 'info_article_refuse', |
|
| 197 | - 'poubelle' => 'info_article_supprime' |
|
| 198 | - ], |
|
| 199 | - 'statut_textes_instituer' => [ |
|
| 200 | - 'prepa' => 'texte_statut_en_cours_redaction', |
|
| 201 | - 'prop' => 'texte_statut_propose_evaluation', |
|
| 202 | - 'publie' => 'texte_statut_publie', |
|
| 203 | - 'refuse' => 'texte_statut_refuse', |
|
| 204 | - 'poubelle' => 'texte_statut_poubelle', |
|
| 205 | - ], |
|
| 206 | - 'texte_changer_statut' => 'texte_article_statut', |
|
| 207 | - 'aide_changer_statut' => 'artstatut', |
|
| 208 | - 'tables_jointures' => [ |
|
| 209 | - 'profondeur' => 'rubriques', |
|
| 210 | - #'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
|
| 211 | - ], |
|
| 212 | - ], |
|
| 213 | - 'spip_auteurs' => [ |
|
| 214 | - 'page' => 'auteur', |
|
| 215 | - 'texte_retour' => 'icone_retour', |
|
| 216 | - 'texte_ajouter' => 'titre_ajouter_un_auteur', |
|
| 217 | - 'texte_modifier' => 'admin_modifier_auteur', |
|
| 218 | - 'texte_objets' => 'icone_auteurs', |
|
| 219 | - 'texte_objet' => 'public:auteur', |
|
| 220 | - 'info_aucun_objet' => 'info_aucun_auteur', |
|
| 221 | - 'info_1_objet' => 'info_1_auteur', |
|
| 222 | - 'info_nb_objets' => 'info_nb_auteurs', |
|
| 223 | - 'texte_logo_objet' => 'logo_auteur', |
|
| 224 | - 'texte_creer_associer' => 'creer_et_associer_un_auteur', |
|
| 225 | - 'titre' => "nom AS titre, '' AS lang", |
|
| 226 | - 'date' => 'date', |
|
| 227 | - 'principale' => 'oui', |
|
| 228 | - 'champs_editables' => ['nom', 'email', 'lang', 'bio', 'nom_site', 'url_site', 'imessage', 'pgp'], |
|
| 229 | - 'champs_versionnes' => ['nom', 'bio', 'lang', 'email', 'nom_site', 'url_site', 'login'], |
|
| 230 | - 'field' => [ |
|
| 231 | - 'id_auteur' => 'bigint(21) NOT NULL', |
|
| 232 | - 'nom' => "text DEFAULT '' NOT NULL", |
|
| 233 | - 'bio' => "text DEFAULT '' NOT NULL", |
|
| 234 | - 'email' => "tinytext DEFAULT '' NOT NULL", |
|
| 235 | - 'nom_site' => "tinytext DEFAULT '' NOT NULL", |
|
| 236 | - 'url_site' => "text DEFAULT '' NOT NULL", |
|
| 237 | - 'login' => 'VARCHAR(255) BINARY', |
|
| 238 | - 'pass' => "tinytext DEFAULT '' NOT NULL", |
|
| 239 | - 'low_sec' => "tinytext DEFAULT '' NOT NULL", |
|
| 240 | - 'statut' => "varchar(255) DEFAULT '0' NOT NULL", |
|
| 241 | - 'webmestre' => "varchar(3) DEFAULT 'non' NOT NULL", |
|
| 242 | - 'maj' => 'TIMESTAMP', |
|
| 243 | - 'pgp' => "TEXT DEFAULT '' NOT NULL", |
|
| 244 | - 'htpass' => "tinytext DEFAULT '' NOT NULL", |
|
| 245 | - 'en_ligne' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 246 | - 'alea_actuel' => 'tinytext', |
|
| 247 | - 'alea_futur' => 'tinytext', |
|
| 248 | - 'prefs' => 'text', |
|
| 249 | - 'cookie_oubli' => 'tinytext', |
|
| 250 | - 'source' => "VARCHAR(10) DEFAULT 'spip' NOT NULL", |
|
| 251 | - 'lang' => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 252 | - 'imessage' => "VARCHAR(3) DEFAULT '' NOT NULL", |
|
| 253 | - 'backup_cles' => "mediumtext DEFAULT '' NOT NULL", |
|
| 254 | - ], |
|
| 255 | - 'key' => [ |
|
| 256 | - 'PRIMARY KEY' => 'id_auteur', |
|
| 257 | - 'KEY login' => 'login', |
|
| 258 | - 'KEY statut' => 'statut', |
|
| 259 | - 'KEY en_ligne' => 'en_ligne', |
|
| 260 | - ], |
|
| 261 | - 'join' => [ |
|
| 262 | - 'id_auteur' => 'id_auteur', |
|
| 263 | - 'login' => 'login' |
|
| 264 | - ], |
|
| 265 | - 'rechercher_champs' => [ |
|
| 266 | - 'nom' => 5, |
|
| 267 | - 'bio' => 1, |
|
| 268 | - 'email' => 1, |
|
| 269 | - 'nom_site' => 1, |
|
| 270 | - 'url_site' => 1, |
|
| 271 | - 'login' => 1 |
|
| 272 | - ], |
|
| 273 | - // 2 conditions pour les auteurs : statut!=poubelle, |
|
| 274 | - // et avoir des articles publies |
|
| 275 | - 'statut' => [ |
|
| 276 | - [ |
|
| 277 | - 'champ' => 'statut', |
|
| 278 | - 'publie' => '!5poubelle', |
|
| 279 | - 'previsu' => '!5poubelle', |
|
| 280 | - 'exception' => 'statut' |
|
| 281 | - ], |
|
| 282 | - [ |
|
| 283 | - 'champ' => [ |
|
| 284 | - ['spip_auteurs_liens', 'id_auteur'], |
|
| 285 | - [ |
|
| 286 | - 'spip_articles', |
|
| 287 | - ['id_objet', 'id_article', 'objet', 'article'] |
|
| 288 | - ], |
|
| 289 | - 'statut' |
|
| 290 | - ], |
|
| 291 | - 'publie' => 'publie', |
|
| 292 | - 'previsu' => '!', |
|
| 293 | - 'post_date' => 'date', |
|
| 294 | - 'exception' => ['statut', 'lien', 'tout'] |
|
| 295 | - ], |
|
| 296 | - ], |
|
| 297 | - 'statut_images' => [ |
|
| 298 | - 'auteur-6forum-16.png', |
|
| 299 | - '0minirezo' => 'auteur-0minirezo-16.png', |
|
| 300 | - '1comite' => 'auteur-1comite-16.png', |
|
| 301 | - '6forum' => 'auteur-6forum-16.png', |
|
| 302 | - '5poubelle' => 'auteur-5poubelle-16.png', |
|
| 303 | - 'nouveau' => '' |
|
| 304 | - ], |
|
| 305 | - 'statut_titres' => [ |
|
| 306 | - 'titre_image_visiteur', |
|
| 307 | - '0minirezo' => 'titre_image_administrateur', |
|
| 308 | - '1comite' => 'titre_image_redacteur_02', |
|
| 309 | - '6forum' => 'titre_image_visiteur', |
|
| 310 | - '5poubelle' => 'titre_image_auteur_supprime', |
|
| 311 | - ], |
|
| 312 | - 'tables_jointures' => [#'auteurs_liens' // declaration generique plus bas |
|
| 313 | - ], |
|
| 314 | - ], |
|
| 315 | - 'spip_rubriques' => [ |
|
| 316 | - 'page' => 'rubrique', |
|
| 317 | - 'url_voir' => 'rubrique', |
|
| 318 | - 'url_edit' => 'rubrique_edit', |
|
| 319 | - 'texte_retour' => 'icone_retour', |
|
| 320 | - 'texte_objets' => 'public:rubriques', |
|
| 321 | - 'texte_objet' => 'public:rubrique', |
|
| 322 | - 'texte_modifier' => 'icone_modifier_rubrique', |
|
| 323 | - 'texte_creer' => 'icone_creer_rubrique', |
|
| 324 | - 'texte_ajouter' => 'titre_ajouter_une_rubrique', |
|
| 325 | - 'texte_creer_associer' => 'creer_et_associer_une_rubrique', |
|
| 326 | - 'info_aucun_objet' => 'info_aucun_rubrique', |
|
| 327 | - 'info_1_objet' => 'info_1_rubrique', |
|
| 328 | - 'info_nb_objets' => 'info_nb_rubriques', |
|
| 329 | - 'texte_logo_objet' => 'logo_rubrique', |
|
| 330 | - 'texte_langue_objet' => 'titre_langue_rubrique', |
|
| 331 | - 'texte_definir_comme_traduction_objet' => 'texte_definir_comme_traduction_rubrique', |
|
| 332 | - 'titre' => 'titre, lang', |
|
| 333 | - 'date' => 'date', |
|
| 334 | - 'principale' => 'oui', |
|
| 335 | - 'introduction_longueur' => '600', |
|
| 336 | - 'champs_editables' => ['titre', 'texte', 'descriptif', 'extra'], |
|
| 337 | - 'champs_versionnes' => ['titre', 'descriptif', 'texte'], |
|
| 338 | - 'field' => [ |
|
| 339 | - 'id_rubrique' => 'bigint(21) NOT NULL', |
|
| 340 | - 'id_parent' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 341 | - 'titre' => "text DEFAULT '' NOT NULL", |
|
| 342 | - 'descriptif' => "text DEFAULT '' NOT NULL", |
|
| 343 | - 'texte' => "longtext DEFAULT '' NOT NULL", |
|
| 344 | - 'id_secteur' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 345 | - 'maj' => 'TIMESTAMP', |
|
| 346 | - 'statut' => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 347 | - 'date' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 348 | - 'lang' => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 349 | - 'langue_choisie' => "VARCHAR(3) DEFAULT 'non'", |
|
| 350 | - 'statut_tmp' => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 351 | - 'date_tmp' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 352 | - 'profondeur' => "smallint(5) DEFAULT '0' NOT NULL" |
|
| 353 | - ], |
|
| 354 | - 'key' => [ |
|
| 355 | - 'PRIMARY KEY' => 'id_rubrique', |
|
| 356 | - 'KEY lang' => 'lang', |
|
| 357 | - 'KEY id_parent' => 'id_parent', |
|
| 358 | - ], |
|
| 359 | - 'parent' => [ |
|
| 360 | - ['type' => 'rubrique', 'champ' => 'id_parent'] |
|
| 361 | - ], |
|
| 362 | - 'rechercher_champs' => [ |
|
| 363 | - 'titre' => 8, |
|
| 364 | - 'descriptif' => 5, |
|
| 365 | - 'texte' => 1 |
|
| 366 | - ], |
|
| 367 | - 'statut' => [ |
|
| 368 | - [ |
|
| 369 | - 'champ' => 'statut', |
|
| 370 | - 'publie' => 'publie', |
|
| 371 | - 'previsu' => '!', |
|
| 372 | - 'exception' => ['statut', 'tout'] |
|
| 373 | - ], |
|
| 374 | - ], |
|
| 375 | - 'tables_jointures' => [#'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
|
| 376 | - ], |
|
| 377 | - ], |
|
| 378 | - // toutes les tables ont le droit a une jointure sur les auteurs |
|
| 379 | - ['tables_jointures' => ['id_auteur' => 'auteurs_liens']] |
|
| 380 | - ]; |
|
| 381 | - |
|
| 382 | - // avant d'appeller les pipeline qui peuvent generer une reentrance a l'install |
|
| 383 | - // initialiser la signature |
|
| 384 | - $md5 = md5(serialize($infos_tables)); |
|
| 385 | - |
|
| 386 | - $GLOBALS['tables_principales'] = pipeline('declarer_tables_principales', $GLOBALS['tables_principales']); |
|
| 387 | - $GLOBALS['tables_auxiliaires'] = pipeline('declarer_tables_auxiliaires', $GLOBALS['tables_auxiliaires']); |
|
| 388 | - $infos_tables = pipeline('declarer_tables_objets_sql', $infos_tables); |
|
| 389 | - |
|
| 390 | - // completer les informations manquantes ou implicites |
|
| 391 | - $all = []; |
|
| 392 | - foreach (array_keys($infos_tables) as $t) { |
|
| 393 | - // les cles numeriques servent a declarer |
|
| 394 | - // les proprietes applicables a tous les objets |
|
| 395 | - // on les mets de cote |
|
| 396 | - if (is_numeric($t)) { |
|
| 397 | - $all = array_merge_recursive($all, $infos_tables[$t]); |
|
| 398 | - unset($infos_tables[$t]); |
|
| 399 | - } else { |
|
| 400 | - $infos_tables[$t] = renseigner_table_objet_sql($t, $infos_tables[$t]); |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // repercuter les proprietes generales communes a tous les objets |
|
| 405 | - foreach (array_keys($infos_tables) as $t) { |
|
| 406 | - foreach ($all as $i => $v) { |
|
| 407 | - if (in_array($i, ['tables_jointures', 'champs_versionnes'])) { |
|
| 408 | - $add = $all[$i]; |
|
| 409 | - // eviter les doublons de declaration de table jointure (ex des mots sur auteurs) |
|
| 410 | - // pour les declarations generiques avec cles numeriques |
|
| 411 | - if ($i == 'tables_jointures' and isset($infos_tables[$t][$i]) and is_countable($infos_tables[$t][$i]) ? count($infos_tables[$t][$i]) : 0) { |
|
| 412 | - $doublons = array_intersect($infos_tables[$t][$i], $add); |
|
| 413 | - foreach ($doublons as $d) { |
|
| 414 | - if ( |
|
| 415 | - is_numeric(array_search($d, $infos_tables[$t][$i])) |
|
| 416 | - and is_numeric($k = array_search($d, $add)) |
|
| 417 | - ) { |
|
| 418 | - unset($add[$k]); |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - $infos_tables[$t][$i] = array_merge($infos_tables[$t][$i] ?? [], $add); |
|
| 423 | - } else { |
|
| 424 | - $infos_tables[$t][$i] = array_merge_recursive( |
|
| 425 | - $infos_tables[$t][$i] ?? [], |
|
| 426 | - $all[$i] |
|
| 427 | - ); |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - // completer les tables principales et auxiliaires |
|
| 433 | - // avec celles declarees uniquement dans declarer_table_objets_sql |
|
| 434 | - // pour assurer la compat en transition |
|
| 435 | - foreach ($infos_tables as $table => $infos) { |
|
| 436 | - $principale_ou_auxiliaire = ($infos['principale'] ? 'tables_principales' : 'tables_auxiliaires'); |
|
| 437 | - // memoriser des champs eventuels declares par des plugins dans le pipeline tables_xxx |
|
| 438 | - // qui a ete appelle avant |
|
| 439 | - $mem = ($GLOBALS[$principale_ou_auxiliaire][$table] ?? []); |
|
| 440 | - // l'ajouter au tableau |
|
| 441 | - $GLOBALS[$principale_ou_auxiliaire][$table] = []; |
|
| 442 | - if (isset($infos['field']) and isset($infos['key'])) { |
|
| 443 | - foreach (['field', 'key', 'join'] as $k) { |
|
| 444 | - if (isset($infos_tables[$table][$k])) { |
|
| 445 | - $GLOBALS[$principale_ou_auxiliaire][$table][$k] = &$infos_tables[$table][$k]; |
|
| 446 | - } |
|
| 447 | - } |
|
| 448 | - } else { |
|
| 449 | - // ici on ne renvoie que les declarations, donc RIEN |
|
| 450 | - // pour avoir la vrai description en base, il faut passer par trouver_table |
|
| 451 | - $GLOBALS[$principale_ou_auxiliaire][$table] = []; |
|
| 452 | - } |
|
| 453 | - if (is_countable($mem) ? count($mem) : 0) { |
|
| 454 | - foreach (array_keys($mem) as $k) { |
|
| 455 | - if (isset($GLOBALS[$principale_ou_auxiliaire][$table][$k])) { |
|
| 456 | - $GLOBALS[$principale_ou_auxiliaire][$table][$k] = array_merge( |
|
| 457 | - $GLOBALS[$principale_ou_auxiliaire][$table][$k], |
|
| 458 | - $mem[$k] |
|
| 459 | - ); |
|
| 460 | - } else { |
|
| 461 | - $GLOBALS[$principale_ou_auxiliaire][$table][$k] = $mem[$k]; |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - // recuperer les interfaces (table_titre, table_date) |
|
| 468 | - // on ne le fait que dans un second temps pour que table_objet soit fonctionnel |
|
| 469 | - // dans le pipeline de declarer_tables_interfaces |
|
| 470 | - include_spip('public/interfaces'); |
|
| 471 | - foreach (array_keys($infos_tables) as $t) { |
|
| 472 | - $infos_tables[$t] = renseigner_table_objet_interfaces($t, $infos_tables[$t]); |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - $deja_la = false; |
|
| 476 | - // signature |
|
| 477 | - $md5 = md5(serialize($infos_tables)); |
|
| 478 | - } |
|
| 479 | - if ($table_sql === '::md5') { |
|
| 480 | - return $md5; |
|
| 481 | - } |
|
| 482 | - if ($table_sql and !isset($infos_tables[$table_sql])) { |
|
| 483 | - #$desc = renseigner_table_objet_sql($table_sql,$desc); |
|
| 484 | - $desc = renseigner_table_objet_interfaces($table_sql, $desc); |
|
| 485 | - |
|
| 486 | - return $desc; |
|
| 487 | - } |
|
| 488 | - if ($table_sql) { |
|
| 489 | - return $infos_tables[$table_sql] ?? []; |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - return $infos_tables; |
|
| 58 | + static $deja_la = false; |
|
| 59 | + static $infos_tables = null; |
|
| 60 | + static $md5 = null; |
|
| 61 | + static $plugin_hash = null; |
|
| 62 | + |
|
| 63 | + // plugins hash connu ? non si _CACHE_PLUGINS_OPT est pas encore chargé. |
|
| 64 | + $_PLUGINS_HASH = defined('_PLUGINS_HASH') ? _PLUGINS_HASH : '!_CACHE_PLUGINS_OPT'; |
|
| 65 | + |
|
| 66 | + // prealablement recuperer les tables_principales |
|
| 67 | + if (is_null($infos_tables) or $plugin_hash !== $_PLUGINS_HASH) { |
|
| 68 | + // pas de reentrance (cas base/serial) |
|
| 69 | + if ($deja_la) { |
|
| 70 | + spip_log('Re-entrance anormale sur lister_tables_objets_sql : ' |
|
| 71 | + . var_export(debug_backtrace(), true), _LOG_CRITIQUE); |
|
| 72 | + |
|
| 73 | + return ($table_sql === '::md5' ? $md5 : []); |
|
| 74 | + } |
|
| 75 | + $deja_la = true; |
|
| 76 | + $plugin_hash = $_PLUGINS_HASH; // avant de lancer les pipelines |
|
| 77 | + |
|
| 78 | + // recuperer les declarations explicites ancienne mode |
|
| 79 | + // qui servent a completer declarer_tables_objets_sql |
|
| 80 | + base_serial($GLOBALS['tables_principales']); |
|
| 81 | + base_auxiliaires($GLOBALS['tables_auxiliaires']); |
|
| 82 | + $infos_tables = [ |
|
| 83 | + 'spip_articles' => [ |
|
| 84 | + 'page' => 'article', |
|
| 85 | + 'texte_retour' => 'icone_retour_article', |
|
| 86 | + 'texte_modifier' => 'icone_modifier_article', |
|
| 87 | + 'texte_creer' => 'icone_ecrire_article', |
|
| 88 | + 'texte_objets' => 'public:articles', |
|
| 89 | + 'texte_objet' => 'public:article', |
|
| 90 | + 'texte_signale_edition' => 'texte_travail_article', |
|
| 91 | + 'info_aucun_objet' => 'info_aucun_article', |
|
| 92 | + 'info_1_objet' => 'info_1_article', |
|
| 93 | + 'info_nb_objets' => 'info_nb_articles', |
|
| 94 | + 'texte_logo_objet' => 'logo_article', |
|
| 95 | + 'texte_langue_objet' => 'titre_langue_article', |
|
| 96 | + 'texte_definir_comme_traduction_objet' => 'trad_lier', |
|
| 97 | + 'titre' => 'titre, lang', |
|
| 98 | + 'date' => 'date', |
|
| 99 | + 'principale' => 'oui', |
|
| 100 | + 'introduction_longueur' => '500', |
|
| 101 | + 'champs_editables' => [ |
|
| 102 | + 'surtitre', |
|
| 103 | + 'titre', |
|
| 104 | + 'soustitre', |
|
| 105 | + 'descriptif', |
|
| 106 | + 'nom_site', |
|
| 107 | + 'url_site', |
|
| 108 | + 'chapo', |
|
| 109 | + 'texte', |
|
| 110 | + 'ps', |
|
| 111 | + 'virtuel' |
|
| 112 | + ], |
|
| 113 | + 'champs_versionnes' => [ |
|
| 114 | + 'id_rubrique', |
|
| 115 | + 'surtitre', |
|
| 116 | + 'titre', |
|
| 117 | + 'soustitre', |
|
| 118 | + 'jointure_auteurs', |
|
| 119 | + 'descriptif', |
|
| 120 | + 'nom_site', |
|
| 121 | + 'url_site', |
|
| 122 | + 'chapo', |
|
| 123 | + 'texte', |
|
| 124 | + 'ps' |
|
| 125 | + ], |
|
| 126 | + 'field' => [ |
|
| 127 | + 'id_article' => 'bigint(21) NOT NULL', |
|
| 128 | + 'surtitre' => "text DEFAULT '' NOT NULL", |
|
| 129 | + 'titre' => "text DEFAULT '' NOT NULL", |
|
| 130 | + 'soustitre' => "text DEFAULT '' NOT NULL", |
|
| 131 | + 'id_rubrique' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 132 | + 'descriptif' => "text DEFAULT '' NOT NULL", |
|
| 133 | + 'chapo' => "mediumtext DEFAULT '' NOT NULL", |
|
| 134 | + 'texte' => "longtext DEFAULT '' NOT NULL", |
|
| 135 | + 'ps' => "mediumtext DEFAULT '' NOT NULL", |
|
| 136 | + 'date' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 137 | + 'statut' => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 138 | + 'id_secteur' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 139 | + 'maj' => 'TIMESTAMP', |
|
| 140 | + 'export' => "VARCHAR(10) DEFAULT 'oui'", |
|
| 141 | + 'date_redac' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 142 | + 'visites' => "integer DEFAULT '0' NOT NULL", |
|
| 143 | + 'referers' => "integer DEFAULT '0' NOT NULL", |
|
| 144 | + 'popularite' => "DOUBLE DEFAULT '0' NOT NULL", |
|
| 145 | + 'accepter_forum' => "CHAR(3) DEFAULT '' NOT NULL", |
|
| 146 | + 'date_modif' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 147 | + 'lang' => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 148 | + 'langue_choisie' => "VARCHAR(3) DEFAULT 'non'", |
|
| 149 | + 'id_trad' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 150 | + 'nom_site' => "tinytext DEFAULT '' NOT NULL", |
|
| 151 | + 'url_site' => "text DEFAULT '' NOT NULL", |
|
| 152 | + 'virtuel' => "text DEFAULT '' NOT NULL", |
|
| 153 | + ], |
|
| 154 | + 'key' => [ |
|
| 155 | + 'PRIMARY KEY' => 'id_article', |
|
| 156 | + 'KEY id_rubrique' => 'id_rubrique', |
|
| 157 | + 'KEY id_secteur' => 'id_secteur', |
|
| 158 | + 'KEY id_trad' => 'id_trad', |
|
| 159 | + 'KEY lang' => 'lang', |
|
| 160 | + 'KEY statut' => 'statut, date', |
|
| 161 | + ], |
|
| 162 | + 'join' => [ |
|
| 163 | + 'id_article' => 'id_article', |
|
| 164 | + 'id_rubrique' => 'id_rubrique' |
|
| 165 | + ], |
|
| 166 | + 'parent' => [ |
|
| 167 | + ['type' => 'rubrique', 'champ' => 'id_rubrique'] |
|
| 168 | + ], |
|
| 169 | + 'rechercher_champs' => [ |
|
| 170 | + 'surtitre' => 5, |
|
| 171 | + 'titre' => 8, |
|
| 172 | + 'soustitre' => 5, |
|
| 173 | + 'chapo' => 3, |
|
| 174 | + 'texte' => 1, |
|
| 175 | + 'ps' => 1, |
|
| 176 | + 'nom_site' => 1, |
|
| 177 | + 'url_site' => 1, |
|
| 178 | + 'descriptif' => 4 |
|
| 179 | + ], |
|
| 180 | + 'rechercher_jointures' => [ |
|
| 181 | + 'auteur' => ['nom' => 10], |
|
| 182 | + ], |
|
| 183 | + 'statut' => [ |
|
| 184 | + [ |
|
| 185 | + 'champ' => 'statut', |
|
| 186 | + 'publie' => 'publie', |
|
| 187 | + 'previsu' => 'publie,prop,prepa/auteur', |
|
| 188 | + 'post_date' => 'date', |
|
| 189 | + 'exception' => ['statut', 'tout'] |
|
| 190 | + ] |
|
| 191 | + ], |
|
| 192 | + 'statut_titres' => [ |
|
| 193 | + 'prepa' => 'info_article_redaction', |
|
| 194 | + 'prop' => 'info_article_propose', |
|
| 195 | + 'publie' => 'info_article_publie', |
|
| 196 | + 'refuse' => 'info_article_refuse', |
|
| 197 | + 'poubelle' => 'info_article_supprime' |
|
| 198 | + ], |
|
| 199 | + 'statut_textes_instituer' => [ |
|
| 200 | + 'prepa' => 'texte_statut_en_cours_redaction', |
|
| 201 | + 'prop' => 'texte_statut_propose_evaluation', |
|
| 202 | + 'publie' => 'texte_statut_publie', |
|
| 203 | + 'refuse' => 'texte_statut_refuse', |
|
| 204 | + 'poubelle' => 'texte_statut_poubelle', |
|
| 205 | + ], |
|
| 206 | + 'texte_changer_statut' => 'texte_article_statut', |
|
| 207 | + 'aide_changer_statut' => 'artstatut', |
|
| 208 | + 'tables_jointures' => [ |
|
| 209 | + 'profondeur' => 'rubriques', |
|
| 210 | + #'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
|
| 211 | + ], |
|
| 212 | + ], |
|
| 213 | + 'spip_auteurs' => [ |
|
| 214 | + 'page' => 'auteur', |
|
| 215 | + 'texte_retour' => 'icone_retour', |
|
| 216 | + 'texte_ajouter' => 'titre_ajouter_un_auteur', |
|
| 217 | + 'texte_modifier' => 'admin_modifier_auteur', |
|
| 218 | + 'texte_objets' => 'icone_auteurs', |
|
| 219 | + 'texte_objet' => 'public:auteur', |
|
| 220 | + 'info_aucun_objet' => 'info_aucun_auteur', |
|
| 221 | + 'info_1_objet' => 'info_1_auteur', |
|
| 222 | + 'info_nb_objets' => 'info_nb_auteurs', |
|
| 223 | + 'texte_logo_objet' => 'logo_auteur', |
|
| 224 | + 'texte_creer_associer' => 'creer_et_associer_un_auteur', |
|
| 225 | + 'titre' => "nom AS titre, '' AS lang", |
|
| 226 | + 'date' => 'date', |
|
| 227 | + 'principale' => 'oui', |
|
| 228 | + 'champs_editables' => ['nom', 'email', 'lang', 'bio', 'nom_site', 'url_site', 'imessage', 'pgp'], |
|
| 229 | + 'champs_versionnes' => ['nom', 'bio', 'lang', 'email', 'nom_site', 'url_site', 'login'], |
|
| 230 | + 'field' => [ |
|
| 231 | + 'id_auteur' => 'bigint(21) NOT NULL', |
|
| 232 | + 'nom' => "text DEFAULT '' NOT NULL", |
|
| 233 | + 'bio' => "text DEFAULT '' NOT NULL", |
|
| 234 | + 'email' => "tinytext DEFAULT '' NOT NULL", |
|
| 235 | + 'nom_site' => "tinytext DEFAULT '' NOT NULL", |
|
| 236 | + 'url_site' => "text DEFAULT '' NOT NULL", |
|
| 237 | + 'login' => 'VARCHAR(255) BINARY', |
|
| 238 | + 'pass' => "tinytext DEFAULT '' NOT NULL", |
|
| 239 | + 'low_sec' => "tinytext DEFAULT '' NOT NULL", |
|
| 240 | + 'statut' => "varchar(255) DEFAULT '0' NOT NULL", |
|
| 241 | + 'webmestre' => "varchar(3) DEFAULT 'non' NOT NULL", |
|
| 242 | + 'maj' => 'TIMESTAMP', |
|
| 243 | + 'pgp' => "TEXT DEFAULT '' NOT NULL", |
|
| 244 | + 'htpass' => "tinytext DEFAULT '' NOT NULL", |
|
| 245 | + 'en_ligne' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 246 | + 'alea_actuel' => 'tinytext', |
|
| 247 | + 'alea_futur' => 'tinytext', |
|
| 248 | + 'prefs' => 'text', |
|
| 249 | + 'cookie_oubli' => 'tinytext', |
|
| 250 | + 'source' => "VARCHAR(10) DEFAULT 'spip' NOT NULL", |
|
| 251 | + 'lang' => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 252 | + 'imessage' => "VARCHAR(3) DEFAULT '' NOT NULL", |
|
| 253 | + 'backup_cles' => "mediumtext DEFAULT '' NOT NULL", |
|
| 254 | + ], |
|
| 255 | + 'key' => [ |
|
| 256 | + 'PRIMARY KEY' => 'id_auteur', |
|
| 257 | + 'KEY login' => 'login', |
|
| 258 | + 'KEY statut' => 'statut', |
|
| 259 | + 'KEY en_ligne' => 'en_ligne', |
|
| 260 | + ], |
|
| 261 | + 'join' => [ |
|
| 262 | + 'id_auteur' => 'id_auteur', |
|
| 263 | + 'login' => 'login' |
|
| 264 | + ], |
|
| 265 | + 'rechercher_champs' => [ |
|
| 266 | + 'nom' => 5, |
|
| 267 | + 'bio' => 1, |
|
| 268 | + 'email' => 1, |
|
| 269 | + 'nom_site' => 1, |
|
| 270 | + 'url_site' => 1, |
|
| 271 | + 'login' => 1 |
|
| 272 | + ], |
|
| 273 | + // 2 conditions pour les auteurs : statut!=poubelle, |
|
| 274 | + // et avoir des articles publies |
|
| 275 | + 'statut' => [ |
|
| 276 | + [ |
|
| 277 | + 'champ' => 'statut', |
|
| 278 | + 'publie' => '!5poubelle', |
|
| 279 | + 'previsu' => '!5poubelle', |
|
| 280 | + 'exception' => 'statut' |
|
| 281 | + ], |
|
| 282 | + [ |
|
| 283 | + 'champ' => [ |
|
| 284 | + ['spip_auteurs_liens', 'id_auteur'], |
|
| 285 | + [ |
|
| 286 | + 'spip_articles', |
|
| 287 | + ['id_objet', 'id_article', 'objet', 'article'] |
|
| 288 | + ], |
|
| 289 | + 'statut' |
|
| 290 | + ], |
|
| 291 | + 'publie' => 'publie', |
|
| 292 | + 'previsu' => '!', |
|
| 293 | + 'post_date' => 'date', |
|
| 294 | + 'exception' => ['statut', 'lien', 'tout'] |
|
| 295 | + ], |
|
| 296 | + ], |
|
| 297 | + 'statut_images' => [ |
|
| 298 | + 'auteur-6forum-16.png', |
|
| 299 | + '0minirezo' => 'auteur-0minirezo-16.png', |
|
| 300 | + '1comite' => 'auteur-1comite-16.png', |
|
| 301 | + '6forum' => 'auteur-6forum-16.png', |
|
| 302 | + '5poubelle' => 'auteur-5poubelle-16.png', |
|
| 303 | + 'nouveau' => '' |
|
| 304 | + ], |
|
| 305 | + 'statut_titres' => [ |
|
| 306 | + 'titre_image_visiteur', |
|
| 307 | + '0minirezo' => 'titre_image_administrateur', |
|
| 308 | + '1comite' => 'titre_image_redacteur_02', |
|
| 309 | + '6forum' => 'titre_image_visiteur', |
|
| 310 | + '5poubelle' => 'titre_image_auteur_supprime', |
|
| 311 | + ], |
|
| 312 | + 'tables_jointures' => [#'auteurs_liens' // declaration generique plus bas |
|
| 313 | + ], |
|
| 314 | + ], |
|
| 315 | + 'spip_rubriques' => [ |
|
| 316 | + 'page' => 'rubrique', |
|
| 317 | + 'url_voir' => 'rubrique', |
|
| 318 | + 'url_edit' => 'rubrique_edit', |
|
| 319 | + 'texte_retour' => 'icone_retour', |
|
| 320 | + 'texte_objets' => 'public:rubriques', |
|
| 321 | + 'texte_objet' => 'public:rubrique', |
|
| 322 | + 'texte_modifier' => 'icone_modifier_rubrique', |
|
| 323 | + 'texte_creer' => 'icone_creer_rubrique', |
|
| 324 | + 'texte_ajouter' => 'titre_ajouter_une_rubrique', |
|
| 325 | + 'texte_creer_associer' => 'creer_et_associer_une_rubrique', |
|
| 326 | + 'info_aucun_objet' => 'info_aucun_rubrique', |
|
| 327 | + 'info_1_objet' => 'info_1_rubrique', |
|
| 328 | + 'info_nb_objets' => 'info_nb_rubriques', |
|
| 329 | + 'texte_logo_objet' => 'logo_rubrique', |
|
| 330 | + 'texte_langue_objet' => 'titre_langue_rubrique', |
|
| 331 | + 'texte_definir_comme_traduction_objet' => 'texte_definir_comme_traduction_rubrique', |
|
| 332 | + 'titre' => 'titre, lang', |
|
| 333 | + 'date' => 'date', |
|
| 334 | + 'principale' => 'oui', |
|
| 335 | + 'introduction_longueur' => '600', |
|
| 336 | + 'champs_editables' => ['titre', 'texte', 'descriptif', 'extra'], |
|
| 337 | + 'champs_versionnes' => ['titre', 'descriptif', 'texte'], |
|
| 338 | + 'field' => [ |
|
| 339 | + 'id_rubrique' => 'bigint(21) NOT NULL', |
|
| 340 | + 'id_parent' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 341 | + 'titre' => "text DEFAULT '' NOT NULL", |
|
| 342 | + 'descriptif' => "text DEFAULT '' NOT NULL", |
|
| 343 | + 'texte' => "longtext DEFAULT '' NOT NULL", |
|
| 344 | + 'id_secteur' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 345 | + 'maj' => 'TIMESTAMP', |
|
| 346 | + 'statut' => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 347 | + 'date' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 348 | + 'lang' => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 349 | + 'langue_choisie' => "VARCHAR(3) DEFAULT 'non'", |
|
| 350 | + 'statut_tmp' => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 351 | + 'date_tmp' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 352 | + 'profondeur' => "smallint(5) DEFAULT '0' NOT NULL" |
|
| 353 | + ], |
|
| 354 | + 'key' => [ |
|
| 355 | + 'PRIMARY KEY' => 'id_rubrique', |
|
| 356 | + 'KEY lang' => 'lang', |
|
| 357 | + 'KEY id_parent' => 'id_parent', |
|
| 358 | + ], |
|
| 359 | + 'parent' => [ |
|
| 360 | + ['type' => 'rubrique', 'champ' => 'id_parent'] |
|
| 361 | + ], |
|
| 362 | + 'rechercher_champs' => [ |
|
| 363 | + 'titre' => 8, |
|
| 364 | + 'descriptif' => 5, |
|
| 365 | + 'texte' => 1 |
|
| 366 | + ], |
|
| 367 | + 'statut' => [ |
|
| 368 | + [ |
|
| 369 | + 'champ' => 'statut', |
|
| 370 | + 'publie' => 'publie', |
|
| 371 | + 'previsu' => '!', |
|
| 372 | + 'exception' => ['statut', 'tout'] |
|
| 373 | + ], |
|
| 374 | + ], |
|
| 375 | + 'tables_jointures' => [#'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
|
| 376 | + ], |
|
| 377 | + ], |
|
| 378 | + // toutes les tables ont le droit a une jointure sur les auteurs |
|
| 379 | + ['tables_jointures' => ['id_auteur' => 'auteurs_liens']] |
|
| 380 | + ]; |
|
| 381 | + |
|
| 382 | + // avant d'appeller les pipeline qui peuvent generer une reentrance a l'install |
|
| 383 | + // initialiser la signature |
|
| 384 | + $md5 = md5(serialize($infos_tables)); |
|
| 385 | + |
|
| 386 | + $GLOBALS['tables_principales'] = pipeline('declarer_tables_principales', $GLOBALS['tables_principales']); |
|
| 387 | + $GLOBALS['tables_auxiliaires'] = pipeline('declarer_tables_auxiliaires', $GLOBALS['tables_auxiliaires']); |
|
| 388 | + $infos_tables = pipeline('declarer_tables_objets_sql', $infos_tables); |
|
| 389 | + |
|
| 390 | + // completer les informations manquantes ou implicites |
|
| 391 | + $all = []; |
|
| 392 | + foreach (array_keys($infos_tables) as $t) { |
|
| 393 | + // les cles numeriques servent a declarer |
|
| 394 | + // les proprietes applicables a tous les objets |
|
| 395 | + // on les mets de cote |
|
| 396 | + if (is_numeric($t)) { |
|
| 397 | + $all = array_merge_recursive($all, $infos_tables[$t]); |
|
| 398 | + unset($infos_tables[$t]); |
|
| 399 | + } else { |
|
| 400 | + $infos_tables[$t] = renseigner_table_objet_sql($t, $infos_tables[$t]); |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + // repercuter les proprietes generales communes a tous les objets |
|
| 405 | + foreach (array_keys($infos_tables) as $t) { |
|
| 406 | + foreach ($all as $i => $v) { |
|
| 407 | + if (in_array($i, ['tables_jointures', 'champs_versionnes'])) { |
|
| 408 | + $add = $all[$i]; |
|
| 409 | + // eviter les doublons de declaration de table jointure (ex des mots sur auteurs) |
|
| 410 | + // pour les declarations generiques avec cles numeriques |
|
| 411 | + if ($i == 'tables_jointures' and isset($infos_tables[$t][$i]) and is_countable($infos_tables[$t][$i]) ? count($infos_tables[$t][$i]) : 0) { |
|
| 412 | + $doublons = array_intersect($infos_tables[$t][$i], $add); |
|
| 413 | + foreach ($doublons as $d) { |
|
| 414 | + if ( |
|
| 415 | + is_numeric(array_search($d, $infos_tables[$t][$i])) |
|
| 416 | + and is_numeric($k = array_search($d, $add)) |
|
| 417 | + ) { |
|
| 418 | + unset($add[$k]); |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + $infos_tables[$t][$i] = array_merge($infos_tables[$t][$i] ?? [], $add); |
|
| 423 | + } else { |
|
| 424 | + $infos_tables[$t][$i] = array_merge_recursive( |
|
| 425 | + $infos_tables[$t][$i] ?? [], |
|
| 426 | + $all[$i] |
|
| 427 | + ); |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + // completer les tables principales et auxiliaires |
|
| 433 | + // avec celles declarees uniquement dans declarer_table_objets_sql |
|
| 434 | + // pour assurer la compat en transition |
|
| 435 | + foreach ($infos_tables as $table => $infos) { |
|
| 436 | + $principale_ou_auxiliaire = ($infos['principale'] ? 'tables_principales' : 'tables_auxiliaires'); |
|
| 437 | + // memoriser des champs eventuels declares par des plugins dans le pipeline tables_xxx |
|
| 438 | + // qui a ete appelle avant |
|
| 439 | + $mem = ($GLOBALS[$principale_ou_auxiliaire][$table] ?? []); |
|
| 440 | + // l'ajouter au tableau |
|
| 441 | + $GLOBALS[$principale_ou_auxiliaire][$table] = []; |
|
| 442 | + if (isset($infos['field']) and isset($infos['key'])) { |
|
| 443 | + foreach (['field', 'key', 'join'] as $k) { |
|
| 444 | + if (isset($infos_tables[$table][$k])) { |
|
| 445 | + $GLOBALS[$principale_ou_auxiliaire][$table][$k] = &$infos_tables[$table][$k]; |
|
| 446 | + } |
|
| 447 | + } |
|
| 448 | + } else { |
|
| 449 | + // ici on ne renvoie que les declarations, donc RIEN |
|
| 450 | + // pour avoir la vrai description en base, il faut passer par trouver_table |
|
| 451 | + $GLOBALS[$principale_ou_auxiliaire][$table] = []; |
|
| 452 | + } |
|
| 453 | + if (is_countable($mem) ? count($mem) : 0) { |
|
| 454 | + foreach (array_keys($mem) as $k) { |
|
| 455 | + if (isset($GLOBALS[$principale_ou_auxiliaire][$table][$k])) { |
|
| 456 | + $GLOBALS[$principale_ou_auxiliaire][$table][$k] = array_merge( |
|
| 457 | + $GLOBALS[$principale_ou_auxiliaire][$table][$k], |
|
| 458 | + $mem[$k] |
|
| 459 | + ); |
|
| 460 | + } else { |
|
| 461 | + $GLOBALS[$principale_ou_auxiliaire][$table][$k] = $mem[$k]; |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + // recuperer les interfaces (table_titre, table_date) |
|
| 468 | + // on ne le fait que dans un second temps pour que table_objet soit fonctionnel |
|
| 469 | + // dans le pipeline de declarer_tables_interfaces |
|
| 470 | + include_spip('public/interfaces'); |
|
| 471 | + foreach (array_keys($infos_tables) as $t) { |
|
| 472 | + $infos_tables[$t] = renseigner_table_objet_interfaces($t, $infos_tables[$t]); |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + $deja_la = false; |
|
| 476 | + // signature |
|
| 477 | + $md5 = md5(serialize($infos_tables)); |
|
| 478 | + } |
|
| 479 | + if ($table_sql === '::md5') { |
|
| 480 | + return $md5; |
|
| 481 | + } |
|
| 482 | + if ($table_sql and !isset($infos_tables[$table_sql])) { |
|
| 483 | + #$desc = renseigner_table_objet_sql($table_sql,$desc); |
|
| 484 | + $desc = renseigner_table_objet_interfaces($table_sql, $desc); |
|
| 485 | + |
|
| 486 | + return $desc; |
|
| 487 | + } |
|
| 488 | + if ($table_sql) { |
|
| 489 | + return $infos_tables[$table_sql] ?? []; |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + return $infos_tables; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | |
@@ -504,27 +504,27 @@ discard block |
||
| 504 | 504 | **/ |
| 505 | 505 | function base_serial(&$tables_principales) { |
| 506 | 506 | |
| 507 | - $spip_jobs = [ |
|
| 508 | - 'id_job' => 'bigint(21) NOT NULL', |
|
| 509 | - 'descriptif' => "text DEFAULT '' NOT NULL", |
|
| 510 | - 'fonction' => 'varchar(255) NOT NULL', //nom de la fonction |
|
| 511 | - 'args' => "longblob DEFAULT '' NOT NULL", // arguments |
|
| 512 | - 'md5args' => "char(32) NOT NULL default ''", // signature des arguments |
|
| 513 | - 'inclure' => 'varchar(255) NOT NULL', // fichier a inclure ou path/ pour charger_fonction |
|
| 514 | - 'priorite' => 'smallint(6) NOT NULL default 0', |
|
| 515 | - 'date' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", // date au plus tot |
|
| 516 | - 'status' => 'tinyint NOT NULL default 1', |
|
| 517 | - ]; |
|
| 518 | - |
|
| 519 | - $spip_jobs_key = [ |
|
| 520 | - 'PRIMARY KEY' => 'id_job', |
|
| 521 | - 'KEY date' => 'date', |
|
| 522 | - 'KEY status' => 'status', |
|
| 523 | - ]; |
|
| 524 | - |
|
| 525 | - /// Attention: mes_fonctions peut avoir deja defini cette variable |
|
| 526 | - /// il faut donc rajouter, mais pas reinitialiser |
|
| 527 | - $tables_principales['spip_jobs'] = ['field' => &$spip_jobs, 'key' => &$spip_jobs_key]; |
|
| 507 | + $spip_jobs = [ |
|
| 508 | + 'id_job' => 'bigint(21) NOT NULL', |
|
| 509 | + 'descriptif' => "text DEFAULT '' NOT NULL", |
|
| 510 | + 'fonction' => 'varchar(255) NOT NULL', //nom de la fonction |
|
| 511 | + 'args' => "longblob DEFAULT '' NOT NULL", // arguments |
|
| 512 | + 'md5args' => "char(32) NOT NULL default ''", // signature des arguments |
|
| 513 | + 'inclure' => 'varchar(255) NOT NULL', // fichier a inclure ou path/ pour charger_fonction |
|
| 514 | + 'priorite' => 'smallint(6) NOT NULL default 0', |
|
| 515 | + 'date' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", // date au plus tot |
|
| 516 | + 'status' => 'tinyint NOT NULL default 1', |
|
| 517 | + ]; |
|
| 518 | + |
|
| 519 | + $spip_jobs_key = [ |
|
| 520 | + 'PRIMARY KEY' => 'id_job', |
|
| 521 | + 'KEY date' => 'date', |
|
| 522 | + 'KEY status' => 'status', |
|
| 523 | + ]; |
|
| 524 | + |
|
| 525 | + /// Attention: mes_fonctions peut avoir deja defini cette variable |
|
| 526 | + /// il faut donc rajouter, mais pas reinitialiser |
|
| 527 | + $tables_principales['spip_jobs'] = ['field' => &$spip_jobs, 'key' => &$spip_jobs_key]; |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | |
@@ -536,71 +536,71 @@ discard block |
||
| 536 | 536 | * @return void |
| 537 | 537 | **/ |
| 538 | 538 | function base_auxiliaires(&$tables_auxiliaires) { |
| 539 | - $spip_resultats = [ |
|
| 540 | - 'recherche' => "char(16) DEFAULT '' NOT NULL", |
|
| 541 | - 'id' => 'INT UNSIGNED NOT NULL', |
|
| 542 | - 'points' => "INT UNSIGNED DEFAULT '0' NOT NULL", |
|
| 543 | - 'table_objet' => "varchar(30) DEFAULT '' NOT NULL", |
|
| 544 | - 'serveur' => "char(16) DEFAULT '' NOT NULL", // hash md5 partiel du serveur de base ('' pour le serveur principal) |
|
| 545 | - 'maj' => 'TIMESTAMP' |
|
| 546 | - ]; |
|
| 547 | - |
|
| 548 | - $spip_resultats_key = [// pas de cle ni index, ca fait des insertions plus rapides et les requetes jointes utilisees en recheche ne sont pas plus lentes ... |
|
| 549 | - ]; |
|
| 550 | - |
|
| 551 | - $spip_auteurs_liens = [ |
|
| 552 | - 'id_auteur' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 553 | - 'id_objet' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 554 | - 'objet' => "VARCHAR (25) DEFAULT '' NOT NULL", |
|
| 555 | - 'vu' => "VARCHAR(6) DEFAULT 'non' NOT NULL" |
|
| 556 | - ]; |
|
| 557 | - |
|
| 558 | - $spip_auteurs_liens_key = [ |
|
| 559 | - 'PRIMARY KEY' => 'id_auteur,id_objet,objet', |
|
| 560 | - 'KEY id_auteur' => 'id_auteur', |
|
| 561 | - 'KEY id_objet' => 'id_objet', |
|
| 562 | - 'KEY objet' => 'objet', |
|
| 563 | - ]; |
|
| 564 | - |
|
| 565 | - $spip_meta = [ |
|
| 566 | - 'nom' => 'VARCHAR (255) NOT NULL', |
|
| 567 | - 'valeur' => "text DEFAULT ''", |
|
| 568 | - 'impt' => "ENUM('non', 'oui') DEFAULT 'oui' NOT NULL", |
|
| 569 | - 'maj' => 'TIMESTAMP' |
|
| 570 | - ]; |
|
| 571 | - |
|
| 572 | - $spip_meta_key = [ |
|
| 573 | - 'PRIMARY KEY' => 'nom' |
|
| 574 | - ]; |
|
| 575 | - |
|
| 576 | - $spip_jobs_liens = [ |
|
| 577 | - 'id_job' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 578 | - 'id_objet' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 579 | - 'objet' => "VARCHAR (25) DEFAULT '' NOT NULL", |
|
| 580 | - ]; |
|
| 581 | - |
|
| 582 | - $spip_jobs_liens_key = [ |
|
| 583 | - 'PRIMARY KEY' => 'id_job,id_objet,objet', |
|
| 584 | - 'KEY id_job' => 'id_job' |
|
| 585 | - ]; |
|
| 586 | - |
|
| 587 | - $tables_auxiliaires['spip_auteurs_liens'] = [ |
|
| 588 | - 'field' => &$spip_auteurs_liens, |
|
| 589 | - 'key' => &$spip_auteurs_liens_key |
|
| 590 | - ]; |
|
| 591 | - |
|
| 592 | - $tables_auxiliaires['spip_meta'] = [ |
|
| 593 | - 'field' => &$spip_meta, |
|
| 594 | - 'key' => &$spip_meta_key |
|
| 595 | - ]; |
|
| 596 | - $tables_auxiliaires['spip_resultats'] = [ |
|
| 597 | - 'field' => &$spip_resultats, |
|
| 598 | - 'key' => &$spip_resultats_key |
|
| 599 | - ]; |
|
| 600 | - $tables_auxiliaires['spip_jobs_liens'] = [ |
|
| 601 | - 'field' => &$spip_jobs_liens, |
|
| 602 | - 'key' => &$spip_jobs_liens_key |
|
| 603 | - ]; |
|
| 539 | + $spip_resultats = [ |
|
| 540 | + 'recherche' => "char(16) DEFAULT '' NOT NULL", |
|
| 541 | + 'id' => 'INT UNSIGNED NOT NULL', |
|
| 542 | + 'points' => "INT UNSIGNED DEFAULT '0' NOT NULL", |
|
| 543 | + 'table_objet' => "varchar(30) DEFAULT '' NOT NULL", |
|
| 544 | + 'serveur' => "char(16) DEFAULT '' NOT NULL", // hash md5 partiel du serveur de base ('' pour le serveur principal) |
|
| 545 | + 'maj' => 'TIMESTAMP' |
|
| 546 | + ]; |
|
| 547 | + |
|
| 548 | + $spip_resultats_key = [// pas de cle ni index, ca fait des insertions plus rapides et les requetes jointes utilisees en recheche ne sont pas plus lentes ... |
|
| 549 | + ]; |
|
| 550 | + |
|
| 551 | + $spip_auteurs_liens = [ |
|
| 552 | + 'id_auteur' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 553 | + 'id_objet' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 554 | + 'objet' => "VARCHAR (25) DEFAULT '' NOT NULL", |
|
| 555 | + 'vu' => "VARCHAR(6) DEFAULT 'non' NOT NULL" |
|
| 556 | + ]; |
|
| 557 | + |
|
| 558 | + $spip_auteurs_liens_key = [ |
|
| 559 | + 'PRIMARY KEY' => 'id_auteur,id_objet,objet', |
|
| 560 | + 'KEY id_auteur' => 'id_auteur', |
|
| 561 | + 'KEY id_objet' => 'id_objet', |
|
| 562 | + 'KEY objet' => 'objet', |
|
| 563 | + ]; |
|
| 564 | + |
|
| 565 | + $spip_meta = [ |
|
| 566 | + 'nom' => 'VARCHAR (255) NOT NULL', |
|
| 567 | + 'valeur' => "text DEFAULT ''", |
|
| 568 | + 'impt' => "ENUM('non', 'oui') DEFAULT 'oui' NOT NULL", |
|
| 569 | + 'maj' => 'TIMESTAMP' |
|
| 570 | + ]; |
|
| 571 | + |
|
| 572 | + $spip_meta_key = [ |
|
| 573 | + 'PRIMARY KEY' => 'nom' |
|
| 574 | + ]; |
|
| 575 | + |
|
| 576 | + $spip_jobs_liens = [ |
|
| 577 | + 'id_job' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 578 | + 'id_objet' => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 579 | + 'objet' => "VARCHAR (25) DEFAULT '' NOT NULL", |
|
| 580 | + ]; |
|
| 581 | + |
|
| 582 | + $spip_jobs_liens_key = [ |
|
| 583 | + 'PRIMARY KEY' => 'id_job,id_objet,objet', |
|
| 584 | + 'KEY id_job' => 'id_job' |
|
| 585 | + ]; |
|
| 586 | + |
|
| 587 | + $tables_auxiliaires['spip_auteurs_liens'] = [ |
|
| 588 | + 'field' => &$spip_auteurs_liens, |
|
| 589 | + 'key' => &$spip_auteurs_liens_key |
|
| 590 | + ]; |
|
| 591 | + |
|
| 592 | + $tables_auxiliaires['spip_meta'] = [ |
|
| 593 | + 'field' => &$spip_meta, |
|
| 594 | + 'key' => &$spip_meta_key |
|
| 595 | + ]; |
|
| 596 | + $tables_auxiliaires['spip_resultats'] = [ |
|
| 597 | + 'field' => &$spip_resultats, |
|
| 598 | + 'key' => &$spip_resultats_key |
|
| 599 | + ]; |
|
| 600 | + $tables_auxiliaires['spip_jobs_liens'] = [ |
|
| 601 | + 'field' => &$spip_jobs_liens, |
|
| 602 | + 'key' => &$spip_jobs_liens_key |
|
| 603 | + ]; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | |
@@ -657,129 +657,129 @@ discard block |
||
| 657 | 657 | * @return array |
| 658 | 658 | */ |
| 659 | 659 | function renseigner_table_objet_sql($table_sql, &$infos) { |
| 660 | - if (!isset($infos['type'])) { |
|
| 661 | - // si on arrive de base/trouver_table, on a la cle primaire : |
|
| 662 | - // s'en servir pour extrapoler le type |
|
| 663 | - if (isset($infos['key']['PRIMARY KEY'])) { |
|
| 664 | - $primary = $infos['key']['PRIMARY KEY']; |
|
| 665 | - $primary = explode(',', $primary); |
|
| 666 | - $primary = reset($primary); |
|
| 667 | - $infos['type'] = preg_replace(',^spip_|^id_|s$,', '', $primary); |
|
| 668 | - } else { |
|
| 669 | - $infos['type'] = preg_replace(',^spip_|s$,', '', $table_sql); |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - if (!isset($infos['type_surnoms'])) { |
|
| 673 | - $infos['type_surnoms'] = []; |
|
| 674 | - } |
|
| 675 | - |
|
| 676 | - if (!isset($infos['table_objet'])) { |
|
| 677 | - $infos['table_objet'] = preg_replace(',^spip_,', '', $table_sql); |
|
| 678 | - } |
|
| 679 | - if (!isset($infos['table_objet_surnoms'])) { |
|
| 680 | - $infos['table_objet_surnoms'] = []; |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - if (!isset($infos['principale'])) { |
|
| 684 | - $infos['principale'] = (isset($GLOBALS['tables_principales'][$table_sql]) ? 'oui' : false); |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - // normaliser pour pouvoir tester en php $infos['principale']? |
|
| 688 | - // et dans une boucle {principale=oui} |
|
| 689 | - $infos['principale'] = (($infos['principale'] and $infos['principale'] != 'non') ? 'oui' : false); |
|
| 690 | - |
|
| 691 | - // declarer et normaliser pour pouvoir tester en php $infos['editable']? |
|
| 692 | - // et dans une boucle {editable=oui} |
|
| 693 | - if (!isset($infos['editable'])) { |
|
| 694 | - $infos['editable'] = 'oui'; |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - $infos['editable'] = (($infos['editable'] and $infos['editable'] != 'non') ? 'oui' : false); |
|
| 698 | - |
|
| 699 | - // les urls publiques sont par defaut page=type pour les tables principales, et rien pour les autres |
|
| 700 | - // seules les exceptions sont donc a declarer |
|
| 701 | - if (!isset($infos['page'])) { |
|
| 702 | - $infos['page'] = ($infos['principale'] ? $infos['type'] : ''); |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - if (!isset($infos['url_voir'])) { |
|
| 706 | - $infos['url_voir'] = $infos['type']; |
|
| 707 | - } |
|
| 708 | - if (!isset($infos['url_edit'])) { |
|
| 709 | - $infos['url_edit'] = $infos['url_voir'] . ($infos['editable'] ? '_edit' : ''); |
|
| 710 | - } |
|
| 711 | - if (!isset($infos['icone_objet'])) { |
|
| 712 | - $infos['icone_objet'] = $infos['type']; |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - // chaines de langue |
|
| 716 | - // par defaut : objet:icone_xxx_objet |
|
| 717 | - if (!isset($infos['texte_retour'])) { |
|
| 718 | - $infos['texte_retour'] = 'icone_retour'; |
|
| 719 | - } |
|
| 720 | - if (!isset($infos['texte_modifier'])) { |
|
| 721 | - $infos['texte_modifier'] = $infos['type'] . ':' . 'icone_modifier_' . $infos['type']; |
|
| 722 | - } |
|
| 723 | - if (!isset($infos['texte_creer'])) { |
|
| 724 | - $infos['texte_creer'] = $infos['type'] . ':' . 'icone_creer_' . $infos['type']; |
|
| 725 | - } |
|
| 726 | - if (!isset($infos['texte_creer_associer'])) { |
|
| 727 | - $infos['texte_creer_associer'] = $infos['type'] . ':' . 'texte_creer_associer_' . $infos['type']; |
|
| 728 | - } |
|
| 729 | - if (!isset($infos['texte_ajouter'])) { |
|
| 730 | - // Ajouter un X |
|
| 731 | - $infos['texte_ajouter'] = $infos['type'] . ':' . 'texte_ajouter_' . $infos['type']; |
|
| 732 | - } |
|
| 733 | - if (!isset($infos['texte_objets'])) { |
|
| 734 | - $infos['texte_objets'] = $infos['type'] . ':' . 'titre_' . $infos['table_objet']; |
|
| 735 | - } |
|
| 736 | - if (!isset($infos['texte_objet'])) { |
|
| 737 | - $infos['texte_objet'] = $infos['type'] . ':' . 'titre_' . $infos['type']; |
|
| 738 | - } |
|
| 739 | - if (!isset($infos['texte_logo_objet'])) { |
|
| 740 | - // objet:titre_logo_objet "Logo de ce X" |
|
| 741 | - $infos['texte_logo_objet'] = $infos['type'] . ':' . 'titre_logo_' . $infos['type']; |
|
| 742 | - } |
|
| 743 | - if (!isset($infos['texte_langue_objet'])) { |
|
| 744 | - // objet:texte_langue_objet "Langue de ce X" |
|
| 745 | - $infos['texte_langue_objet'] = $infos['type'] . ':' . 'titre_langue_' . $infos['type']; |
|
| 746 | - } |
|
| 747 | - if (!isset($infos['texte_definir_comme_traduction_objet'])) { |
|
| 748 | - // "Ce X est une traduction du X numéro :" |
|
| 749 | - $infos['texte_definir_comme_traduction_objet'] = $infos['type'] . ':' . 'texte_definir_comme_traduction_' . $infos['type']; |
|
| 750 | - } |
|
| 751 | - |
|
| 752 | - // objet:info_aucun_objet |
|
| 753 | - if (!isset($infos['info_aucun_objet'])) { |
|
| 754 | - $infos['info_aucun_objet'] = $infos['type'] . ':' . 'info_aucun_' . $infos['type']; |
|
| 755 | - } |
|
| 756 | - // objet:info_1_objet |
|
| 757 | - if (!isset($infos['info_1_objet'])) { |
|
| 758 | - $infos['info_1_objet'] = $infos['type'] . ':' . 'info_1_' . $infos['type']; |
|
| 759 | - } |
|
| 760 | - // objet:info_nb_objets |
|
| 761 | - if (!isset($infos['info_nb_objets'])) { |
|
| 762 | - $infos['info_nb_objets'] = $infos['type'] . ':' . 'info_nb_' . $infos['table_objet']; |
|
| 763 | - } |
|
| 764 | - |
|
| 765 | - if (!isset($infos['champs_editables'])) { |
|
| 766 | - $infos['champs_editables'] = []; |
|
| 767 | - } |
|
| 768 | - if (!isset($infos['champs_versionnes'])) { |
|
| 769 | - $infos['champs_versionnes'] = []; |
|
| 770 | - } |
|
| 771 | - if (!isset($infos['rechercher_champs'])) { |
|
| 772 | - $infos['rechercher_champs'] = []; |
|
| 773 | - } |
|
| 774 | - if (!isset($infos['rechercher_jointures'])) { |
|
| 775 | - $infos['rechercher_jointures'] = []; |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - if (!isset($infos['modeles'])) { |
|
| 779 | - $infos['modeles'] = [$infos['type']]; |
|
| 780 | - } |
|
| 781 | - |
|
| 782 | - return $infos; |
|
| 660 | + if (!isset($infos['type'])) { |
|
| 661 | + // si on arrive de base/trouver_table, on a la cle primaire : |
|
| 662 | + // s'en servir pour extrapoler le type |
|
| 663 | + if (isset($infos['key']['PRIMARY KEY'])) { |
|
| 664 | + $primary = $infos['key']['PRIMARY KEY']; |
|
| 665 | + $primary = explode(',', $primary); |
|
| 666 | + $primary = reset($primary); |
|
| 667 | + $infos['type'] = preg_replace(',^spip_|^id_|s$,', '', $primary); |
|
| 668 | + } else { |
|
| 669 | + $infos['type'] = preg_replace(',^spip_|s$,', '', $table_sql); |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + if (!isset($infos['type_surnoms'])) { |
|
| 673 | + $infos['type_surnoms'] = []; |
|
| 674 | + } |
|
| 675 | + |
|
| 676 | + if (!isset($infos['table_objet'])) { |
|
| 677 | + $infos['table_objet'] = preg_replace(',^spip_,', '', $table_sql); |
|
| 678 | + } |
|
| 679 | + if (!isset($infos['table_objet_surnoms'])) { |
|
| 680 | + $infos['table_objet_surnoms'] = []; |
|
| 681 | + } |
|
| 682 | + |
|
| 683 | + if (!isset($infos['principale'])) { |
|
| 684 | + $infos['principale'] = (isset($GLOBALS['tables_principales'][$table_sql]) ? 'oui' : false); |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + // normaliser pour pouvoir tester en php $infos['principale']? |
|
| 688 | + // et dans une boucle {principale=oui} |
|
| 689 | + $infos['principale'] = (($infos['principale'] and $infos['principale'] != 'non') ? 'oui' : false); |
|
| 690 | + |
|
| 691 | + // declarer et normaliser pour pouvoir tester en php $infos['editable']? |
|
| 692 | + // et dans une boucle {editable=oui} |
|
| 693 | + if (!isset($infos['editable'])) { |
|
| 694 | + $infos['editable'] = 'oui'; |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + $infos['editable'] = (($infos['editable'] and $infos['editable'] != 'non') ? 'oui' : false); |
|
| 698 | + |
|
| 699 | + // les urls publiques sont par defaut page=type pour les tables principales, et rien pour les autres |
|
| 700 | + // seules les exceptions sont donc a declarer |
|
| 701 | + if (!isset($infos['page'])) { |
|
| 702 | + $infos['page'] = ($infos['principale'] ? $infos['type'] : ''); |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + if (!isset($infos['url_voir'])) { |
|
| 706 | + $infos['url_voir'] = $infos['type']; |
|
| 707 | + } |
|
| 708 | + if (!isset($infos['url_edit'])) { |
|
| 709 | + $infos['url_edit'] = $infos['url_voir'] . ($infos['editable'] ? '_edit' : ''); |
|
| 710 | + } |
|
| 711 | + if (!isset($infos['icone_objet'])) { |
|
| 712 | + $infos['icone_objet'] = $infos['type']; |
|
| 713 | + } |
|
| 714 | + |
|
| 715 | + // chaines de langue |
|
| 716 | + // par defaut : objet:icone_xxx_objet |
|
| 717 | + if (!isset($infos['texte_retour'])) { |
|
| 718 | + $infos['texte_retour'] = 'icone_retour'; |
|
| 719 | + } |
|
| 720 | + if (!isset($infos['texte_modifier'])) { |
|
| 721 | + $infos['texte_modifier'] = $infos['type'] . ':' . 'icone_modifier_' . $infos['type']; |
|
| 722 | + } |
|
| 723 | + if (!isset($infos['texte_creer'])) { |
|
| 724 | + $infos['texte_creer'] = $infos['type'] . ':' . 'icone_creer_' . $infos['type']; |
|
| 725 | + } |
|
| 726 | + if (!isset($infos['texte_creer_associer'])) { |
|
| 727 | + $infos['texte_creer_associer'] = $infos['type'] . ':' . 'texte_creer_associer_' . $infos['type']; |
|
| 728 | + } |
|
| 729 | + if (!isset($infos['texte_ajouter'])) { |
|
| 730 | + // Ajouter un X |
|
| 731 | + $infos['texte_ajouter'] = $infos['type'] . ':' . 'texte_ajouter_' . $infos['type']; |
|
| 732 | + } |
|
| 733 | + if (!isset($infos['texte_objets'])) { |
|
| 734 | + $infos['texte_objets'] = $infos['type'] . ':' . 'titre_' . $infos['table_objet']; |
|
| 735 | + } |
|
| 736 | + if (!isset($infos['texte_objet'])) { |
|
| 737 | + $infos['texte_objet'] = $infos['type'] . ':' . 'titre_' . $infos['type']; |
|
| 738 | + } |
|
| 739 | + if (!isset($infos['texte_logo_objet'])) { |
|
| 740 | + // objet:titre_logo_objet "Logo de ce X" |
|
| 741 | + $infos['texte_logo_objet'] = $infos['type'] . ':' . 'titre_logo_' . $infos['type']; |
|
| 742 | + } |
|
| 743 | + if (!isset($infos['texte_langue_objet'])) { |
|
| 744 | + // objet:texte_langue_objet "Langue de ce X" |
|
| 745 | + $infos['texte_langue_objet'] = $infos['type'] . ':' . 'titre_langue_' . $infos['type']; |
|
| 746 | + } |
|
| 747 | + if (!isset($infos['texte_definir_comme_traduction_objet'])) { |
|
| 748 | + // "Ce X est une traduction du X numéro :" |
|
| 749 | + $infos['texte_definir_comme_traduction_objet'] = $infos['type'] . ':' . 'texte_definir_comme_traduction_' . $infos['type']; |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + // objet:info_aucun_objet |
|
| 753 | + if (!isset($infos['info_aucun_objet'])) { |
|
| 754 | + $infos['info_aucun_objet'] = $infos['type'] . ':' . 'info_aucun_' . $infos['type']; |
|
| 755 | + } |
|
| 756 | + // objet:info_1_objet |
|
| 757 | + if (!isset($infos['info_1_objet'])) { |
|
| 758 | + $infos['info_1_objet'] = $infos['type'] . ':' . 'info_1_' . $infos['type']; |
|
| 759 | + } |
|
| 760 | + // objet:info_nb_objets |
|
| 761 | + if (!isset($infos['info_nb_objets'])) { |
|
| 762 | + $infos['info_nb_objets'] = $infos['type'] . ':' . 'info_nb_' . $infos['table_objet']; |
|
| 763 | + } |
|
| 764 | + |
|
| 765 | + if (!isset($infos['champs_editables'])) { |
|
| 766 | + $infos['champs_editables'] = []; |
|
| 767 | + } |
|
| 768 | + if (!isset($infos['champs_versionnes'])) { |
|
| 769 | + $infos['champs_versionnes'] = []; |
|
| 770 | + } |
|
| 771 | + if (!isset($infos['rechercher_champs'])) { |
|
| 772 | + $infos['rechercher_champs'] = []; |
|
| 773 | + } |
|
| 774 | + if (!isset($infos['rechercher_jointures'])) { |
|
| 775 | + $infos['rechercher_jointures'] = []; |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + if (!isset($infos['modeles'])) { |
|
| 779 | + $infos['modeles'] = [$infos['type']]; |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + return $infos; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | /** |
@@ -796,30 +796,30 @@ discard block |
||
| 796 | 796 | * @return array |
| 797 | 797 | */ |
| 798 | 798 | function renseigner_table_objet_interfaces($table_sql, &$infos) { |
| 799 | - if (!isset($infos['titre'])) { |
|
| 800 | - if (isset($infos['table_objet']) and isset($GLOBALS['table_titre'][$infos['table_objet']])) { |
|
| 801 | - $infos['titre'] = $GLOBALS['table_titre'][$infos['table_objet']]; |
|
| 802 | - } else { |
|
| 803 | - $infos['titre'] = ((isset($infos['field']['titre'])) ? 'titre,' : "'' as titre,"); |
|
| 804 | - $infos['titre'] .= ((isset($infos['field']['lang'])) ? 'lang' : "'' as lang"); |
|
| 805 | - } |
|
| 806 | - } |
|
| 807 | - if (!isset($infos['date'])) { |
|
| 808 | - if (isset($infos['table_objet']) and isset($GLOBALS['table_date'][$infos['table_objet']])) { |
|
| 809 | - $infos['date'] = $GLOBALS['table_date'][$infos['table_objet']]; |
|
| 810 | - } else { |
|
| 811 | - $infos['date'] = ((isset($infos['field']['date'])) ? 'date' : ''); |
|
| 812 | - } |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - $infos['statut'] ??= $GLOBALS['table_statut'][$table_sql] ?? ''; |
|
| 816 | - $infos['tables_jointures'] ??= []; |
|
| 817 | - |
|
| 818 | - if (isset($GLOBALS['tables_jointures'][$table_sql])) { |
|
| 819 | - $infos['tables_jointures'] = array_merge($infos['tables_jointures'], $GLOBALS['tables_jointures'][$table_sql]); |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - return $infos; |
|
| 799 | + if (!isset($infos['titre'])) { |
|
| 800 | + if (isset($infos['table_objet']) and isset($GLOBALS['table_titre'][$infos['table_objet']])) { |
|
| 801 | + $infos['titre'] = $GLOBALS['table_titre'][$infos['table_objet']]; |
|
| 802 | + } else { |
|
| 803 | + $infos['titre'] = ((isset($infos['field']['titre'])) ? 'titre,' : "'' as titre,"); |
|
| 804 | + $infos['titre'] .= ((isset($infos['field']['lang'])) ? 'lang' : "'' as lang"); |
|
| 805 | + } |
|
| 806 | + } |
|
| 807 | + if (!isset($infos['date'])) { |
|
| 808 | + if (isset($infos['table_objet']) and isset($GLOBALS['table_date'][$infos['table_objet']])) { |
|
| 809 | + $infos['date'] = $GLOBALS['table_date'][$infos['table_objet']]; |
|
| 810 | + } else { |
|
| 811 | + $infos['date'] = ((isset($infos['field']['date'])) ? 'date' : ''); |
|
| 812 | + } |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + $infos['statut'] ??= $GLOBALS['table_statut'][$table_sql] ?? ''; |
|
| 816 | + $infos['tables_jointures'] ??= []; |
|
| 817 | + |
|
| 818 | + if (isset($GLOBALS['tables_jointures'][$table_sql])) { |
|
| 819 | + $infos['tables_jointures'] = array_merge($infos['tables_jointures'], $GLOBALS['tables_jointures'][$table_sql]); |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + return $infos; |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | /** |
@@ -830,13 +830,13 @@ discard block |
||
| 830 | 830 | * Liste et descriptions des tables principales |
| 831 | 831 | **/ |
| 832 | 832 | function lister_tables_principales() { |
| 833 | - static $done = false; |
|
| 834 | - if (!$done or !(is_countable($GLOBALS['tables_principales']) ? count($GLOBALS['tables_principales']) : 0)) { |
|
| 835 | - lister_tables_objets_sql(); |
|
| 836 | - $done = true; |
|
| 837 | - } |
|
| 833 | + static $done = false; |
|
| 834 | + if (!$done or !(is_countable($GLOBALS['tables_principales']) ? count($GLOBALS['tables_principales']) : 0)) { |
|
| 835 | + lister_tables_objets_sql(); |
|
| 836 | + $done = true; |
|
| 837 | + } |
|
| 838 | 838 | |
| 839 | - return $GLOBALS['tables_principales']; |
|
| 839 | + return $GLOBALS['tables_principales']; |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -847,13 +847,13 @@ discard block |
||
| 847 | 847 | * Liste et descriptions des tables auxiliaires |
| 848 | 848 | **/ |
| 849 | 849 | function lister_tables_auxiliaires() { |
| 850 | - static $done = false; |
|
| 851 | - if (!$done or !(is_countable($GLOBALS['tables_auxiliaires']) ? count($GLOBALS['tables_auxiliaires']) : 0)) { |
|
| 852 | - lister_tables_objets_sql(); |
|
| 853 | - $done = true; |
|
| 854 | - } |
|
| 850 | + static $done = false; |
|
| 851 | + if (!$done or !(is_countable($GLOBALS['tables_auxiliaires']) ? count($GLOBALS['tables_auxiliaires']) : 0)) { |
|
| 852 | + lister_tables_objets_sql(); |
|
| 853 | + $done = true; |
|
| 854 | + } |
|
| 855 | 855 | |
| 856 | - return $GLOBALS['tables_auxiliaires']; |
|
| 856 | + return $GLOBALS['tables_auxiliaires']; |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
@@ -862,45 +862,45 @@ discard block |
||
| 862 | 862 | * @return array |
| 863 | 863 | */ |
| 864 | 864 | function lister_tables_objets_surnoms() { |
| 865 | - static $surnoms = null; |
|
| 866 | - static $md5 = null; |
|
| 867 | - if ( |
|
| 868 | - !$surnoms |
|
| 869 | - or $md5 != lister_tables_objets_sql('::md5') |
|
| 870 | - ) { |
|
| 871 | - // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions |
|
| 872 | - // pour compatibilite, car il faut dorenavent utiliser |
|
| 873 | - // declarer_table_objets_sql |
|
| 874 | - $surnoms = pipeline( |
|
| 875 | - 'declarer_tables_objets_surnoms', |
|
| 876 | - [ |
|
| 877 | - # pour les modeles |
|
| 878 | - # a enlever ? |
|
| 879 | - 'doc' => 'documents', |
|
| 880 | - 'img' => 'documents', |
|
| 881 | - 'emb' => 'documents', |
|
| 882 | - ] |
|
| 883 | - ); |
|
| 884 | - $infos_tables = lister_tables_objets_sql(); |
|
| 885 | - foreach ($infos_tables as $t => $infos) { |
|
| 886 | - // cas de base type=>table |
|
| 887 | - // et preg_replace(',^spip_|^id_|s$,',table)=>table |
|
| 888 | - if ($infos['table_objet']) { // securite, si la fonction est appelee trop tot, c'est vide |
|
| 889 | - // optimisations pour table_objet |
|
| 890 | - //$surnoms[$infos['type']] = $infos['table_objet']; |
|
| 891 | - $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['table_objet']; |
|
| 892 | - $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['table_objet']; |
|
| 893 | - if (is_array($infos['table_objet_surnoms']) and count($infos['table_objet_surnoms'])) { |
|
| 894 | - foreach ($infos['table_objet_surnoms'] as $surnom) { |
|
| 895 | - $surnoms[$surnom] = $infos['table_objet']; |
|
| 896 | - } |
|
| 897 | - } |
|
| 898 | - } |
|
| 899 | - } |
|
| 900 | - $md5 = lister_tables_objets_sql('::md5'); |
|
| 901 | - } |
|
| 902 | - |
|
| 903 | - return $surnoms; |
|
| 865 | + static $surnoms = null; |
|
| 866 | + static $md5 = null; |
|
| 867 | + if ( |
|
| 868 | + !$surnoms |
|
| 869 | + or $md5 != lister_tables_objets_sql('::md5') |
|
| 870 | + ) { |
|
| 871 | + // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions |
|
| 872 | + // pour compatibilite, car il faut dorenavent utiliser |
|
| 873 | + // declarer_table_objets_sql |
|
| 874 | + $surnoms = pipeline( |
|
| 875 | + 'declarer_tables_objets_surnoms', |
|
| 876 | + [ |
|
| 877 | + # pour les modeles |
|
| 878 | + # a enlever ? |
|
| 879 | + 'doc' => 'documents', |
|
| 880 | + 'img' => 'documents', |
|
| 881 | + 'emb' => 'documents', |
|
| 882 | + ] |
|
| 883 | + ); |
|
| 884 | + $infos_tables = lister_tables_objets_sql(); |
|
| 885 | + foreach ($infos_tables as $t => $infos) { |
|
| 886 | + // cas de base type=>table |
|
| 887 | + // et preg_replace(',^spip_|^id_|s$,',table)=>table |
|
| 888 | + if ($infos['table_objet']) { // securite, si la fonction est appelee trop tot, c'est vide |
|
| 889 | + // optimisations pour table_objet |
|
| 890 | + //$surnoms[$infos['type']] = $infos['table_objet']; |
|
| 891 | + $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['table_objet']; |
|
| 892 | + $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['table_objet']; |
|
| 893 | + if (is_array($infos['table_objet_surnoms']) and count($infos['table_objet_surnoms'])) { |
|
| 894 | + foreach ($infos['table_objet_surnoms'] as $surnom) { |
|
| 895 | + $surnoms[$surnom] = $infos['table_objet']; |
|
| 896 | + } |
|
| 897 | + } |
|
| 898 | + } |
|
| 899 | + } |
|
| 900 | + $md5 = lister_tables_objets_sql('::md5'); |
|
| 901 | + } |
|
| 902 | + |
|
| 903 | + return $surnoms; |
|
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | /** |
@@ -909,35 +909,35 @@ discard block |
||
| 909 | 909 | * @return array |
| 910 | 910 | */ |
| 911 | 911 | function lister_types_surnoms() { |
| 912 | - static $surnoms = null; |
|
| 913 | - static $md5 = null; |
|
| 914 | - if ( |
|
| 915 | - !$surnoms |
|
| 916 | - or $md5 != lister_tables_objets_sql('::md5') |
|
| 917 | - ) { |
|
| 918 | - // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions |
|
| 919 | - // pour compatibilite, car il faut dorenavent utiliser |
|
| 920 | - // declarer_table_objets_sql |
|
| 921 | - $surnoms = pipeline('declarer_type_surnoms', ['racine-site' => 'site']); |
|
| 922 | - $infos_tables = lister_tables_objets_sql(); |
|
| 923 | - foreach ($infos_tables as $t => $infos) { |
|
| 924 | - if ($infos['type']) { // securite, si la fonction est appelee trop tot, c'est vide |
|
| 925 | - // optimisations pour objet_type |
|
| 926 | - //$surnoms[$infos['type']] = $infos['type']; |
|
| 927 | - $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['type']; |
|
| 928 | - $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['type']; |
|
| 929 | - // surnoms declares |
|
| 930 | - if (is_array($infos['type_surnoms']) and count($infos['type_surnoms'])) { |
|
| 931 | - foreach ($infos['type_surnoms'] as $surnom) { |
|
| 932 | - $surnoms[$surnom] = $infos['type']; |
|
| 933 | - } |
|
| 934 | - } |
|
| 935 | - } |
|
| 936 | - } |
|
| 937 | - $md5 = lister_tables_objets_sql('::md5'); |
|
| 938 | - } |
|
| 939 | - |
|
| 940 | - return $surnoms; |
|
| 912 | + static $surnoms = null; |
|
| 913 | + static $md5 = null; |
|
| 914 | + if ( |
|
| 915 | + !$surnoms |
|
| 916 | + or $md5 != lister_tables_objets_sql('::md5') |
|
| 917 | + ) { |
|
| 918 | + // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions |
|
| 919 | + // pour compatibilite, car il faut dorenavent utiliser |
|
| 920 | + // declarer_table_objets_sql |
|
| 921 | + $surnoms = pipeline('declarer_type_surnoms', ['racine-site' => 'site']); |
|
| 922 | + $infos_tables = lister_tables_objets_sql(); |
|
| 923 | + foreach ($infos_tables as $t => $infos) { |
|
| 924 | + if ($infos['type']) { // securite, si la fonction est appelee trop tot, c'est vide |
|
| 925 | + // optimisations pour objet_type |
|
| 926 | + //$surnoms[$infos['type']] = $infos['type']; |
|
| 927 | + $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['type']; |
|
| 928 | + $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['type']; |
|
| 929 | + // surnoms declares |
|
| 930 | + if (is_array($infos['type_surnoms']) and count($infos['type_surnoms'])) { |
|
| 931 | + foreach ($infos['type_surnoms'] as $surnom) { |
|
| 932 | + $surnoms[$surnom] = $infos['type']; |
|
| 933 | + } |
|
| 934 | + } |
|
| 935 | + } |
|
| 936 | + } |
|
| 937 | + $md5 = lister_tables_objets_sql('::md5'); |
|
| 938 | + } |
|
| 939 | + |
|
| 940 | + return $surnoms; |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | /** |
@@ -951,22 +951,22 @@ discard block |
||
| 951 | 951 | * Couples (nom de la table SQL => même nom, sans 'spip_' devant) |
| 952 | 952 | **/ |
| 953 | 953 | function lister_tables_spip($serveur = '') { |
| 954 | - static $tables = []; |
|
| 955 | - if (!isset($tables[$serveur])) { |
|
| 956 | - $tables[$serveur] = []; |
|
| 957 | - if (!function_exists('sql_alltable')) { |
|
| 958 | - include_spip('base/abstract_sql'); |
|
| 959 | - } |
|
| 960 | - $ts = sql_alltable(null, $serveur); // toutes les tables "spip_" (ou prefixe perso) |
|
| 961 | - $connexion = $GLOBALS['connexions'][$serveur ?: 0]; |
|
| 962 | - $spip = $connexion['prefixe'] . '_'; |
|
| 963 | - foreach ($ts as $t) { |
|
| 964 | - $t = substr($t, strlen($spip)); |
|
| 965 | - $tables[$serveur]["spip_$t"] = $t; |
|
| 966 | - } |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - return $tables[$serveur]; |
|
| 954 | + static $tables = []; |
|
| 955 | + if (!isset($tables[$serveur])) { |
|
| 956 | + $tables[$serveur] = []; |
|
| 957 | + if (!function_exists('sql_alltable')) { |
|
| 958 | + include_spip('base/abstract_sql'); |
|
| 959 | + } |
|
| 960 | + $ts = sql_alltable(null, $serveur); // toutes les tables "spip_" (ou prefixe perso) |
|
| 961 | + $connexion = $GLOBALS['connexions'][$serveur ?: 0]; |
|
| 962 | + $spip = $connexion['prefixe'] . '_'; |
|
| 963 | + foreach ($ts as $t) { |
|
| 964 | + $t = substr($t, strlen($spip)); |
|
| 965 | + $tables[$serveur]["spip_$t"] = $t; |
|
| 966 | + } |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + return $tables[$serveur]; |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | |
@@ -981,18 +981,18 @@ discard block |
||
| 981 | 981 | * Couples (nom de la table SQL => même nom) |
| 982 | 982 | **/ |
| 983 | 983 | function lister_toutes_tables($serveur) { |
| 984 | - static $tables = []; |
|
| 985 | - if (!isset($tables[$serveur])) { |
|
| 986 | - $tables[$serveur] = []; |
|
| 987 | - if (!function_exists('sql_alltable')) { |
|
| 988 | - include_spip('base/abstract_sql'); |
|
| 989 | - } |
|
| 990 | - $ts = sql_alltable('%', $serveur); // toutes les tables |
|
| 991 | - foreach ($ts as $t) { |
|
| 992 | - $tables[$serveur][$t] = $t; |
|
| 993 | - } |
|
| 994 | - } |
|
| 995 | - return $tables[$serveur]; |
|
| 984 | + static $tables = []; |
|
| 985 | + if (!isset($tables[$serveur])) { |
|
| 986 | + $tables[$serveur] = []; |
|
| 987 | + if (!function_exists('sql_alltable')) { |
|
| 988 | + include_spip('base/abstract_sql'); |
|
| 989 | + } |
|
| 990 | + $ts = sql_alltable('%', $serveur); // toutes les tables |
|
| 991 | + foreach ($ts as $t) { |
|
| 992 | + $tables[$serveur][$t] = $t; |
|
| 993 | + } |
|
| 994 | + } |
|
| 995 | + return $tables[$serveur]; |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | /** |
@@ -1013,39 +1013,39 @@ discard block |
||
| 1013 | 1013 | **/ |
| 1014 | 1014 | function table_objet(string $type, string $serveur = ''): string { |
| 1015 | 1015 | |
| 1016 | - if ($type) { |
|
| 1017 | - $type = preg_replace(',^spip_|^id_|s$,', '', $type); |
|
| 1018 | - } |
|
| 1019 | - if (!strlen($type)) { |
|
| 1020 | - return ''; |
|
| 1021 | - } |
|
| 1022 | - |
|
| 1023 | - $surnoms = lister_tables_objets_surnoms(); |
|
| 1024 | - if (isset($surnoms[$type])) { |
|
| 1025 | - return $surnoms[$type]; |
|
| 1026 | - } |
|
| 1027 | - |
|
| 1028 | - if ($serveur !== false) { |
|
| 1029 | - $t = lister_tables_spip($serveur); |
|
| 1030 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1031 | - $typetrim = rtrim($type, 's') . 's'; |
|
| 1032 | - if ( |
|
| 1033 | - (isset($t[$typetrim]) or in_array($typetrim, $t)) |
|
| 1034 | - and ($desc = $trouver_table(rtrim($type, 's') . 's', $serveur)) |
|
| 1035 | - ) { |
|
| 1036 | - return $desc['id_table']; |
|
| 1037 | - } elseif ( |
|
| 1038 | - (isset($t[$type]) or in_array($type, $t)) |
|
| 1039 | - and ($desc = $trouver_table($type, $serveur)) |
|
| 1040 | - ) { |
|
| 1041 | - return $desc['id_table']; |
|
| 1042 | - } |
|
| 1043 | - |
|
| 1044 | - spip_log('table_objet(' . $type . ') calculee sans verification'); |
|
| 1045 | - #spip_log(debug_backtrace(),'db'); |
|
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - return rtrim($type, 's') . 's'; # cas historique ne devant plus servir, sauf si $serveur=false |
|
| 1016 | + if ($type) { |
|
| 1017 | + $type = preg_replace(',^spip_|^id_|s$,', '', $type); |
|
| 1018 | + } |
|
| 1019 | + if (!strlen($type)) { |
|
| 1020 | + return ''; |
|
| 1021 | + } |
|
| 1022 | + |
|
| 1023 | + $surnoms = lister_tables_objets_surnoms(); |
|
| 1024 | + if (isset($surnoms[$type])) { |
|
| 1025 | + return $surnoms[$type]; |
|
| 1026 | + } |
|
| 1027 | + |
|
| 1028 | + if ($serveur !== false) { |
|
| 1029 | + $t = lister_tables_spip($serveur); |
|
| 1030 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1031 | + $typetrim = rtrim($type, 's') . 's'; |
|
| 1032 | + if ( |
|
| 1033 | + (isset($t[$typetrim]) or in_array($typetrim, $t)) |
|
| 1034 | + and ($desc = $trouver_table(rtrim($type, 's') . 's', $serveur)) |
|
| 1035 | + ) { |
|
| 1036 | + return $desc['id_table']; |
|
| 1037 | + } elseif ( |
|
| 1038 | + (isset($t[$type]) or in_array($type, $t)) |
|
| 1039 | + and ($desc = $trouver_table($type, $serveur)) |
|
| 1040 | + ) { |
|
| 1041 | + return $desc['id_table']; |
|
| 1042 | + } |
|
| 1043 | + |
|
| 1044 | + spip_log('table_objet(' . $type . ') calculee sans verification'); |
|
| 1045 | + #spip_log(debug_backtrace(),'db'); |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + return rtrim($type, 's') . 's'; # cas historique ne devant plus servir, sauf si $serveur=false |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | /** |
@@ -1066,33 +1066,33 @@ discard block |
||
| 1066 | 1066 | **/ |
| 1067 | 1067 | function table_objet_sql(string $type, string $serveur = ''): string { |
| 1068 | 1068 | |
| 1069 | - $nom = table_objet($type, $serveur); |
|
| 1070 | - if (!strlen($nom)) { |
|
| 1071 | - return ''; |
|
| 1072 | - } |
|
| 1073 | - if (!isset($GLOBALS['table_des_tables']['articles'])) { |
|
| 1074 | - // eviter de multiples inclusions |
|
| 1075 | - include_spip('public/interfaces'); |
|
| 1076 | - } |
|
| 1077 | - if (isset($GLOBALS['table_des_tables'][$nom])) { |
|
| 1078 | - $nom = $GLOBALS['table_des_tables'][$nom]; |
|
| 1079 | - $nom = "spip_$nom"; |
|
| 1080 | - } else { |
|
| 1081 | - $infos_tables = lister_tables_objets_sql(); |
|
| 1082 | - if (isset($infos_tables["spip_$nom"])) { |
|
| 1083 | - $nom = "spip_$nom"; |
|
| 1084 | - } elseif ($serveur !== false) { |
|
| 1085 | - $t = lister_tables_spip($serveur); |
|
| 1086 | - if (isset($t[$nom]) or in_array($nom, $t)) { |
|
| 1087 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1088 | - if ($desc = $trouver_table($nom, $serveur)) { |
|
| 1089 | - return $desc['table_sql']; |
|
| 1090 | - } |
|
| 1091 | - } |
|
| 1092 | - } |
|
| 1093 | - } |
|
| 1094 | - |
|
| 1095 | - return $nom; |
|
| 1069 | + $nom = table_objet($type, $serveur); |
|
| 1070 | + if (!strlen($nom)) { |
|
| 1071 | + return ''; |
|
| 1072 | + } |
|
| 1073 | + if (!isset($GLOBALS['table_des_tables']['articles'])) { |
|
| 1074 | + // eviter de multiples inclusions |
|
| 1075 | + include_spip('public/interfaces'); |
|
| 1076 | + } |
|
| 1077 | + if (isset($GLOBALS['table_des_tables'][$nom])) { |
|
| 1078 | + $nom = $GLOBALS['table_des_tables'][$nom]; |
|
| 1079 | + $nom = "spip_$nom"; |
|
| 1080 | + } else { |
|
| 1081 | + $infos_tables = lister_tables_objets_sql(); |
|
| 1082 | + if (isset($infos_tables["spip_$nom"])) { |
|
| 1083 | + $nom = "spip_$nom"; |
|
| 1084 | + } elseif ($serveur !== false) { |
|
| 1085 | + $t = lister_tables_spip($serveur); |
|
| 1086 | + if (isset($t[$nom]) or in_array($nom, $t)) { |
|
| 1087 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1088 | + if ($desc = $trouver_table($nom, $serveur)) { |
|
| 1089 | + return $desc['table_sql']; |
|
| 1090 | + } |
|
| 1091 | + } |
|
| 1092 | + } |
|
| 1093 | + } |
|
| 1094 | + |
|
| 1095 | + return $nom; |
|
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | 1098 | /** |
@@ -1111,35 +1111,35 @@ discard block |
||
| 1111 | 1111 | * Nom de la clé primaire |
| 1112 | 1112 | **/ |
| 1113 | 1113 | function id_table_objet(string $type, string $serveur = ''): ?string { |
| 1114 | - static $trouver_table = null; |
|
| 1115 | - $type = objet_type($type, $serveur); |
|
| 1116 | - if (!$type) { |
|
| 1117 | - return null; |
|
| 1118 | - } |
|
| 1119 | - $t = table_objet($type); |
|
| 1120 | - if (!$trouver_table) { |
|
| 1121 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1122 | - } |
|
| 1123 | - |
|
| 1124 | - $ts = lister_tables_spip($serveur); |
|
| 1125 | - if ( |
|
| 1126 | - in_array($t, $ts) |
|
| 1127 | - or in_array($t, lister_toutes_tables($serveur)) |
|
| 1128 | - ) { |
|
| 1129 | - $desc = $trouver_table($t, $serveur); |
|
| 1130 | - if (isset($desc['key']['PRIMARY KEY'])) { |
|
| 1131 | - return $desc['key']['PRIMARY KEY']; |
|
| 1132 | - } |
|
| 1133 | - if (!$desc or isset($desc['field']["id_$type"])) { |
|
| 1134 | - return "id_$type"; |
|
| 1135 | - } |
|
| 1136 | - // sinon renvoyer le premier champ de la table... |
|
| 1137 | - $keys = array_keys($desc['field']); |
|
| 1138 | - |
|
| 1139 | - return array_shift($keys); |
|
| 1140 | - } |
|
| 1141 | - |
|
| 1142 | - return "id_$type"; |
|
| 1114 | + static $trouver_table = null; |
|
| 1115 | + $type = objet_type($type, $serveur); |
|
| 1116 | + if (!$type) { |
|
| 1117 | + return null; |
|
| 1118 | + } |
|
| 1119 | + $t = table_objet($type); |
|
| 1120 | + if (!$trouver_table) { |
|
| 1121 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1122 | + } |
|
| 1123 | + |
|
| 1124 | + $ts = lister_tables_spip($serveur); |
|
| 1125 | + if ( |
|
| 1126 | + in_array($t, $ts) |
|
| 1127 | + or in_array($t, lister_toutes_tables($serveur)) |
|
| 1128 | + ) { |
|
| 1129 | + $desc = $trouver_table($t, $serveur); |
|
| 1130 | + if (isset($desc['key']['PRIMARY KEY'])) { |
|
| 1131 | + return $desc['key']['PRIMARY KEY']; |
|
| 1132 | + } |
|
| 1133 | + if (!$desc or isset($desc['field']["id_$type"])) { |
|
| 1134 | + return "id_$type"; |
|
| 1135 | + } |
|
| 1136 | + // sinon renvoyer le premier champ de la table... |
|
| 1137 | + $keys = array_keys($desc['field']); |
|
| 1138 | + |
|
| 1139 | + return array_shift($keys); |
|
| 1140 | + } |
|
| 1141 | + |
|
| 1142 | + return "id_$type"; |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | /** |
@@ -1158,60 +1158,60 @@ discard block |
||
| 1158 | 1158 | * Type de l'objet |
| 1159 | 1159 | **/ |
| 1160 | 1160 | function objet_type(string $table_objet, string $serveur = ''): ?string { |
| 1161 | - if (!$table_objet) { |
|
| 1162 | - return null; |
|
| 1163 | - } |
|
| 1164 | - $surnoms = lister_types_surnoms(); |
|
| 1165 | - |
|
| 1166 | - // scenario de base |
|
| 1167 | - // le type est decline a partir du nom de la table en enlevant le prefixe eventuel |
|
| 1168 | - // et la marque du pluriel |
|
| 1169 | - // on accepte id_xx en entree aussi |
|
| 1170 | - $type = preg_replace(',^spip_|^id_|s$,', '', $table_objet); |
|
| 1171 | - if (isset($surnoms[$type])) { |
|
| 1172 | - return $surnoms[$type]; |
|
| 1173 | - } |
|
| 1174 | - |
|
| 1175 | - // securite : eliminer les caracteres non \w |
|
| 1176 | - $type = preg_replace(',[^\w-],', '', $type); |
|
| 1177 | - |
|
| 1178 | - // si le type redonne bien la table c'est bon |
|
| 1179 | - // oui si table_objet ressemblait deja a un type |
|
| 1180 | - if ( |
|
| 1181 | - $type == $table_objet |
|
| 1182 | - or (table_objet($type, $serveur) == $table_objet) |
|
| 1183 | - or (table_objet_sql($type, $serveur) == $table_objet) |
|
| 1184 | - ) { |
|
| 1185 | - return $type; |
|
| 1186 | - } |
|
| 1187 | - |
|
| 1188 | - // si on ne veut pas chercher en base |
|
| 1189 | - if ($serveur === false) { |
|
| 1190 | - return $type; |
|
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - // sinon on passe par la cle primaire id_xx pour trouver le type |
|
| 1194 | - // car le s a la fin est incertain |
|
| 1195 | - // notamment en cas de pluriel derogatoire |
|
| 1196 | - // id_jeu/spip_jeux id_journal/spip_journaux qui necessitent tout deux |
|
| 1197 | - // une declaration jeu => jeux, journal => journaux |
|
| 1198 | - // dans le pipeline declarer_tables_objets_surnoms |
|
| 1199 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1200 | - $ts = lister_tables_spip($serveur); |
|
| 1201 | - $desc = false; |
|
| 1202 | - if (in_array($table_objet, $ts)) { |
|
| 1203 | - $desc = $trouver_table($table_objet); |
|
| 1204 | - } |
|
| 1205 | - if (!$desc and in_array($table_objet = table_objet($type, $serveur), $ts)) { |
|
| 1206 | - $desc = $trouver_table($table_objet, $serveur); |
|
| 1207 | - } |
|
| 1208 | - // si le type est declare : bingo ! |
|
| 1209 | - if ($desc and isset($desc['type'])) { |
|
| 1210 | - return $desc['type']; |
|
| 1211 | - } |
|
| 1212 | - |
|
| 1213 | - // on a fait ce qu'on a pu |
|
| 1214 | - return $type; |
|
| 1161 | + if (!$table_objet) { |
|
| 1162 | + return null; |
|
| 1163 | + } |
|
| 1164 | + $surnoms = lister_types_surnoms(); |
|
| 1165 | + |
|
| 1166 | + // scenario de base |
|
| 1167 | + // le type est decline a partir du nom de la table en enlevant le prefixe eventuel |
|
| 1168 | + // et la marque du pluriel |
|
| 1169 | + // on accepte id_xx en entree aussi |
|
| 1170 | + $type = preg_replace(',^spip_|^id_|s$,', '', $table_objet); |
|
| 1171 | + if (isset($surnoms[$type])) { |
|
| 1172 | + return $surnoms[$type]; |
|
| 1173 | + } |
|
| 1174 | + |
|
| 1175 | + // securite : eliminer les caracteres non \w |
|
| 1176 | + $type = preg_replace(',[^\w-],', '', $type); |
|
| 1177 | + |
|
| 1178 | + // si le type redonne bien la table c'est bon |
|
| 1179 | + // oui si table_objet ressemblait deja a un type |
|
| 1180 | + if ( |
|
| 1181 | + $type == $table_objet |
|
| 1182 | + or (table_objet($type, $serveur) == $table_objet) |
|
| 1183 | + or (table_objet_sql($type, $serveur) == $table_objet) |
|
| 1184 | + ) { |
|
| 1185 | + return $type; |
|
| 1186 | + } |
|
| 1187 | + |
|
| 1188 | + // si on ne veut pas chercher en base |
|
| 1189 | + if ($serveur === false) { |
|
| 1190 | + return $type; |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + // sinon on passe par la cle primaire id_xx pour trouver le type |
|
| 1194 | + // car le s a la fin est incertain |
|
| 1195 | + // notamment en cas de pluriel derogatoire |
|
| 1196 | + // id_jeu/spip_jeux id_journal/spip_journaux qui necessitent tout deux |
|
| 1197 | + // une declaration jeu => jeux, journal => journaux |
|
| 1198 | + // dans le pipeline declarer_tables_objets_surnoms |
|
| 1199 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1200 | + $ts = lister_tables_spip($serveur); |
|
| 1201 | + $desc = false; |
|
| 1202 | + if (in_array($table_objet, $ts)) { |
|
| 1203 | + $desc = $trouver_table($table_objet); |
|
| 1204 | + } |
|
| 1205 | + if (!$desc and in_array($table_objet = table_objet($type, $serveur), $ts)) { |
|
| 1206 | + $desc = $trouver_table($table_objet, $serveur); |
|
| 1207 | + } |
|
| 1208 | + // si le type est declare : bingo ! |
|
| 1209 | + if ($desc and isset($desc['type'])) { |
|
| 1210 | + return $desc['type']; |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + // on a fait ce qu'on a pu |
|
| 1214 | + return $type; |
|
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | /** |
@@ -1227,62 +1227,62 @@ discard block |
||
| 1227 | 1227 | * @return bool |
| 1228 | 1228 | */ |
| 1229 | 1229 | function objet_test_si_publie($objet, $id_objet, $serveur = '') { |
| 1230 | - // voir si une fonction est definie pour faire le boulot |
|
| 1231 | - // elle a la priorite dans ce cas |
|
| 1232 | - if ($f = charger_fonction($objet . '_test_si_publie', 'base', true)) { |
|
| 1233 | - return $f($objet, $id_objet, $serveur); |
|
| 1234 | - } |
|
| 1235 | - |
|
| 1236 | - // sinon on se fie a la declaration de l'objet si presente |
|
| 1237 | - $id_table = $table_objet = table_objet($objet); |
|
| 1238 | - $id_table_objet = id_table_objet($objet, $serveur); |
|
| 1239 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1240 | - if ( |
|
| 1241 | - $desc = $trouver_table($table_objet, $serveur) |
|
| 1242 | - and isset($desc['statut']) |
|
| 1243 | - and $desc['statut'] |
|
| 1244 | - ) { |
|
| 1245 | - $boucle = new Boucle(); |
|
| 1246 | - $boucle->show = $desc; |
|
| 1247 | - $boucle->nom = 'objet_test_si_publie'; |
|
| 1248 | - $boucle->id_boucle = $id_table; |
|
| 1249 | - $boucle->id_table = $id_table; |
|
| 1250 | - $boucle->primary = $desc['key']['PRIMARY KEY'] ?? ''; |
|
| 1251 | - $boucle->sql_serveur = $serveur; |
|
| 1252 | - $boucle->select[] = $id_table_objet; |
|
| 1253 | - $boucle->from[$table_objet] = table_objet_sql($objet, $serveur); |
|
| 1254 | - $boucle->where[] = $id_table . '.' . $id_table_objet . '=' . intval($id_objet); |
|
| 1255 | - |
|
| 1256 | - $boucle->descr['nom'] = 'objet_test_si_publie'; // eviter notice php |
|
| 1257 | - $boucle->descr['sourcefile'] = 'internal'; |
|
| 1258 | - $boucle->descr['gram'] = 'html'; |
|
| 1259 | - |
|
| 1260 | - include_spip('public/compiler'); |
|
| 1261 | - include_spip('public/composer'); |
|
| 1262 | - instituer_boucle($boucle, false, true); |
|
| 1263 | - $res = calculer_select( |
|
| 1264 | - $boucle->select, |
|
| 1265 | - $boucle->from, |
|
| 1266 | - $boucle->from_type, |
|
| 1267 | - $boucle->where, |
|
| 1268 | - $boucle->join, |
|
| 1269 | - $boucle->group, |
|
| 1270 | - $boucle->order, |
|
| 1271 | - $boucle->limit, |
|
| 1272 | - $boucle->having, |
|
| 1273 | - $table_objet, |
|
| 1274 | - $id_table, |
|
| 1275 | - $serveur |
|
| 1276 | - ); |
|
| 1277 | - if (sql_fetch($res)) { |
|
| 1278 | - return true; |
|
| 1279 | - } |
|
| 1280 | - |
|
| 1281 | - return false; |
|
| 1282 | - } |
|
| 1283 | - |
|
| 1284 | - // si pas d'info statut ni de fonction : l'objet est publie |
|
| 1285 | - return true; |
|
| 1230 | + // voir si une fonction est definie pour faire le boulot |
|
| 1231 | + // elle a la priorite dans ce cas |
|
| 1232 | + if ($f = charger_fonction($objet . '_test_si_publie', 'base', true)) { |
|
| 1233 | + return $f($objet, $id_objet, $serveur); |
|
| 1234 | + } |
|
| 1235 | + |
|
| 1236 | + // sinon on se fie a la declaration de l'objet si presente |
|
| 1237 | + $id_table = $table_objet = table_objet($objet); |
|
| 1238 | + $id_table_objet = id_table_objet($objet, $serveur); |
|
| 1239 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1240 | + if ( |
|
| 1241 | + $desc = $trouver_table($table_objet, $serveur) |
|
| 1242 | + and isset($desc['statut']) |
|
| 1243 | + and $desc['statut'] |
|
| 1244 | + ) { |
|
| 1245 | + $boucle = new Boucle(); |
|
| 1246 | + $boucle->show = $desc; |
|
| 1247 | + $boucle->nom = 'objet_test_si_publie'; |
|
| 1248 | + $boucle->id_boucle = $id_table; |
|
| 1249 | + $boucle->id_table = $id_table; |
|
| 1250 | + $boucle->primary = $desc['key']['PRIMARY KEY'] ?? ''; |
|
| 1251 | + $boucle->sql_serveur = $serveur; |
|
| 1252 | + $boucle->select[] = $id_table_objet; |
|
| 1253 | + $boucle->from[$table_objet] = table_objet_sql($objet, $serveur); |
|
| 1254 | + $boucle->where[] = $id_table . '.' . $id_table_objet . '=' . intval($id_objet); |
|
| 1255 | + |
|
| 1256 | + $boucle->descr['nom'] = 'objet_test_si_publie'; // eviter notice php |
|
| 1257 | + $boucle->descr['sourcefile'] = 'internal'; |
|
| 1258 | + $boucle->descr['gram'] = 'html'; |
|
| 1259 | + |
|
| 1260 | + include_spip('public/compiler'); |
|
| 1261 | + include_spip('public/composer'); |
|
| 1262 | + instituer_boucle($boucle, false, true); |
|
| 1263 | + $res = calculer_select( |
|
| 1264 | + $boucle->select, |
|
| 1265 | + $boucle->from, |
|
| 1266 | + $boucle->from_type, |
|
| 1267 | + $boucle->where, |
|
| 1268 | + $boucle->join, |
|
| 1269 | + $boucle->group, |
|
| 1270 | + $boucle->order, |
|
| 1271 | + $boucle->limit, |
|
| 1272 | + $boucle->having, |
|
| 1273 | + $table_objet, |
|
| 1274 | + $id_table, |
|
| 1275 | + $serveur |
|
| 1276 | + ); |
|
| 1277 | + if (sql_fetch($res)) { |
|
| 1278 | + return true; |
|
| 1279 | + } |
|
| 1280 | + |
|
| 1281 | + return false; |
|
| 1282 | + } |
|
| 1283 | + |
|
| 1284 | + // si pas d'info statut ni de fonction : l'objet est publie |
|
| 1285 | + return true; |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | |
@@ -1317,124 +1317,124 @@ discard block |
||
| 1317 | 1317 | * Retourne un tableau décrivant les parents trouvés |
| 1318 | 1318 | */ |
| 1319 | 1319 | function objet_lister_parents($objet, $id_objet, $parent_direct_seulement = false) { |
| 1320 | - $parents = []; |
|
| 1321 | - |
|
| 1322 | - // Si on trouve une ou des méthodes de parent |
|
| 1323 | - if ($parent_methodes = objet_type_decrire_infos_parents($objet)) { |
|
| 1324 | - // On identifie les informations sur l'objet source dont on cherche le parent. |
|
| 1325 | - include_spip('base/abstract_sql'); |
|
| 1326 | - $table_objet = table_objet_sql($objet); |
|
| 1327 | - $cle_objet = id_table_objet($objet); |
|
| 1328 | - $id_objet = intval($id_objet); |
|
| 1329 | - |
|
| 1330 | - // On teste chacun méthode dans l'ordre, et dès qu'on a trouvé un parent on s'arrête |
|
| 1331 | - foreach ($parent_methodes as $parent_methode) { |
|
| 1332 | - // Champ identifiant le parent (id et éventuellement le type) |
|
| 1333 | - // -- cette identification ne dépend pas du fait que le parent soit stocké dans une table de différente |
|
| 1334 | - // de celle de l'objet source |
|
| 1335 | - $select = []; |
|
| 1336 | - if (isset($parent_methode['champ'])) { |
|
| 1337 | - $select[] = $parent_methode['champ']; |
|
| 1338 | - } |
|
| 1339 | - if (isset($parent_methode['champ_type'])) { |
|
| 1340 | - $select[] = $parent_methode['champ_type']; |
|
| 1341 | - } |
|
| 1342 | - |
|
| 1343 | - // Détermination de la table du parent et des conditions sur l'objet source et le parent. |
|
| 1344 | - $condition_objet_invalide = false; |
|
| 1345 | - $where = []; |
|
| 1346 | - if (!isset($parent_methode['table'])) { |
|
| 1347 | - // Le parent est stocké dans la même table que l'objet source : |
|
| 1348 | - // -- toutes les conditions s'appliquent à la table source. |
|
| 1349 | - $table = $table_objet; |
|
| 1350 | - $where = ["$cle_objet = $id_objet"]; |
|
| 1351 | - // -- Condition supplémentaire sur la détection du parent |
|
| 1352 | - if (isset($parent_methode['condition'])) { |
|
| 1353 | - $where[] = $parent_methode['condition']; |
|
| 1354 | - } |
|
| 1355 | - } elseif (!$parent_direct_seulement) { |
|
| 1356 | - // Le parent est stocké dans une table différente de l'objet source. |
|
| 1357 | - // -- on vérifie d'emblée si il y a une condition sur l'objet source et si celle-ci est vérifiée |
|
| 1358 | - // Si non, on peut arrêter le traitement. |
|
| 1359 | - if (isset($parent_methode['condition'])) { |
|
| 1360 | - $where = [ |
|
| 1361 | - "$cle_objet = $id_objet", |
|
| 1362 | - $parent_methode['condition'] |
|
| 1363 | - ]; |
|
| 1364 | - if (!sql_countsel($table_objet, $where)) { |
|
| 1365 | - $condition_objet_invalide = true; |
|
| 1366 | - } |
|
| 1367 | - } |
|
| 1368 | - |
|
| 1369 | - // Si pas de condition sur l'objet source ou que la condition est vérifiée, on peut construire |
|
| 1370 | - // la requête sur la table qui accueille le parent. |
|
| 1371 | - if (!$condition_objet_invalide) { |
|
| 1372 | - $table = $parent_methode['table']; |
|
| 1373 | - // On construit les conditions en fonction de l'identification de l'objet source |
|
| 1374 | - $where = []; |
|
| 1375 | - // -- si le champ_source de l'id n'est pas précisé c'est qu'il est déjà connu et donc que c'est |
|
| 1376 | - // le même que celui de l'objet source. |
|
| 1377 | - $where[] = isset($parent_methode['source_champ']) |
|
| 1378 | - ? "{$parent_methode['source_champ']} = $id_objet" |
|
| 1379 | - : "$cle_objet = $id_objet"; |
|
| 1380 | - if (isset($parent_methode['source_champ_type'])) { |
|
| 1381 | - $where[] = "{$parent_methode['source_champ_type']} = " . sql_quote($objet); |
|
| 1382 | - } |
|
| 1383 | - // -- Condition supplémentaire sur la détection du parent |
|
| 1384 | - if (isset($parent_methode['table_condition'])) { |
|
| 1385 | - $where[] = $parent_methode['table_condition']; |
|
| 1386 | - } |
|
| 1387 | - } |
|
| 1388 | - } |
|
| 1389 | - |
|
| 1390 | - // On lance la requête de récupération du parent |
|
| 1391 | - $is_table_lien = (strpos($table, '_liens') !== false and substr($table, -6) === '_liens'); |
|
| 1392 | - if ( |
|
| 1393 | - !$condition_objet_invalide |
|
| 1394 | - and $where |
|
| 1395 | - and ($lignes = sql_allfetsel($is_table_lien ? '*' : $select, $table, $where)) |
|
| 1396 | - ) { |
|
| 1397 | - foreach ($lignes as $ligne) { |
|
| 1398 | - // Si le type est fixe |
|
| 1399 | - if (isset($parent_methode['type'])) { |
|
| 1400 | - $parent = [ |
|
| 1401 | - 'objet' => $parent_methode['type'], |
|
| 1402 | - 'id_objet' => intval($ligne[$parent_methode['champ']]), |
|
| 1403 | - 'champ' => $parent_methode['champ'], |
|
| 1404 | - 'table' => $table, |
|
| 1405 | - ]; |
|
| 1406 | - } |
|
| 1407 | - elseif (isset($parent_methode['champ_type'])) { |
|
| 1408 | - $parent = [ |
|
| 1409 | - 'objet' => $ligne[$parent_methode['champ_type']], |
|
| 1410 | - 'id_objet' => intval($ligne[$parent_methode['champ']]), |
|
| 1411 | - 'champ' => $parent_methode['champ'], |
|
| 1412 | - 'champ_type' => $parent_methode['champ_type'], |
|
| 1413 | - 'table' => $table, |
|
| 1414 | - ]; |
|
| 1415 | - } |
|
| 1416 | - if ($is_table_lien) { |
|
| 1417 | - $parent['lien'] = $ligne; |
|
| 1418 | - } |
|
| 1419 | - $parents[] = $parent; |
|
| 1420 | - } |
|
| 1421 | - } |
|
| 1422 | - } |
|
| 1423 | - } |
|
| 1424 | - |
|
| 1425 | - // On passe par un pipeline avant de retourner |
|
| 1426 | - $parents = pipeline( |
|
| 1427 | - 'objet_lister_parents', |
|
| 1428 | - [ |
|
| 1429 | - 'args' => [ |
|
| 1430 | - 'objet' => $objet, |
|
| 1431 | - 'id_objet' => $id_objet, |
|
| 1432 | - ], |
|
| 1433 | - 'data' => $parents, |
|
| 1434 | - ] |
|
| 1435 | - ); |
|
| 1436 | - |
|
| 1437 | - return $parents; |
|
| 1320 | + $parents = []; |
|
| 1321 | + |
|
| 1322 | + // Si on trouve une ou des méthodes de parent |
|
| 1323 | + if ($parent_methodes = objet_type_decrire_infos_parents($objet)) { |
|
| 1324 | + // On identifie les informations sur l'objet source dont on cherche le parent. |
|
| 1325 | + include_spip('base/abstract_sql'); |
|
| 1326 | + $table_objet = table_objet_sql($objet); |
|
| 1327 | + $cle_objet = id_table_objet($objet); |
|
| 1328 | + $id_objet = intval($id_objet); |
|
| 1329 | + |
|
| 1330 | + // On teste chacun méthode dans l'ordre, et dès qu'on a trouvé un parent on s'arrête |
|
| 1331 | + foreach ($parent_methodes as $parent_methode) { |
|
| 1332 | + // Champ identifiant le parent (id et éventuellement le type) |
|
| 1333 | + // -- cette identification ne dépend pas du fait que le parent soit stocké dans une table de différente |
|
| 1334 | + // de celle de l'objet source |
|
| 1335 | + $select = []; |
|
| 1336 | + if (isset($parent_methode['champ'])) { |
|
| 1337 | + $select[] = $parent_methode['champ']; |
|
| 1338 | + } |
|
| 1339 | + if (isset($parent_methode['champ_type'])) { |
|
| 1340 | + $select[] = $parent_methode['champ_type']; |
|
| 1341 | + } |
|
| 1342 | + |
|
| 1343 | + // Détermination de la table du parent et des conditions sur l'objet source et le parent. |
|
| 1344 | + $condition_objet_invalide = false; |
|
| 1345 | + $where = []; |
|
| 1346 | + if (!isset($parent_methode['table'])) { |
|
| 1347 | + // Le parent est stocké dans la même table que l'objet source : |
|
| 1348 | + // -- toutes les conditions s'appliquent à la table source. |
|
| 1349 | + $table = $table_objet; |
|
| 1350 | + $where = ["$cle_objet = $id_objet"]; |
|
| 1351 | + // -- Condition supplémentaire sur la détection du parent |
|
| 1352 | + if (isset($parent_methode['condition'])) { |
|
| 1353 | + $where[] = $parent_methode['condition']; |
|
| 1354 | + } |
|
| 1355 | + } elseif (!$parent_direct_seulement) { |
|
| 1356 | + // Le parent est stocké dans une table différente de l'objet source. |
|
| 1357 | + // -- on vérifie d'emblée si il y a une condition sur l'objet source et si celle-ci est vérifiée |
|
| 1358 | + // Si non, on peut arrêter le traitement. |
|
| 1359 | + if (isset($parent_methode['condition'])) { |
|
| 1360 | + $where = [ |
|
| 1361 | + "$cle_objet = $id_objet", |
|
| 1362 | + $parent_methode['condition'] |
|
| 1363 | + ]; |
|
| 1364 | + if (!sql_countsel($table_objet, $where)) { |
|
| 1365 | + $condition_objet_invalide = true; |
|
| 1366 | + } |
|
| 1367 | + } |
|
| 1368 | + |
|
| 1369 | + // Si pas de condition sur l'objet source ou que la condition est vérifiée, on peut construire |
|
| 1370 | + // la requête sur la table qui accueille le parent. |
|
| 1371 | + if (!$condition_objet_invalide) { |
|
| 1372 | + $table = $parent_methode['table']; |
|
| 1373 | + // On construit les conditions en fonction de l'identification de l'objet source |
|
| 1374 | + $where = []; |
|
| 1375 | + // -- si le champ_source de l'id n'est pas précisé c'est qu'il est déjà connu et donc que c'est |
|
| 1376 | + // le même que celui de l'objet source. |
|
| 1377 | + $where[] = isset($parent_methode['source_champ']) |
|
| 1378 | + ? "{$parent_methode['source_champ']} = $id_objet" |
|
| 1379 | + : "$cle_objet = $id_objet"; |
|
| 1380 | + if (isset($parent_methode['source_champ_type'])) { |
|
| 1381 | + $where[] = "{$parent_methode['source_champ_type']} = " . sql_quote($objet); |
|
| 1382 | + } |
|
| 1383 | + // -- Condition supplémentaire sur la détection du parent |
|
| 1384 | + if (isset($parent_methode['table_condition'])) { |
|
| 1385 | + $where[] = $parent_methode['table_condition']; |
|
| 1386 | + } |
|
| 1387 | + } |
|
| 1388 | + } |
|
| 1389 | + |
|
| 1390 | + // On lance la requête de récupération du parent |
|
| 1391 | + $is_table_lien = (strpos($table, '_liens') !== false and substr($table, -6) === '_liens'); |
|
| 1392 | + if ( |
|
| 1393 | + !$condition_objet_invalide |
|
| 1394 | + and $where |
|
| 1395 | + and ($lignes = sql_allfetsel($is_table_lien ? '*' : $select, $table, $where)) |
|
| 1396 | + ) { |
|
| 1397 | + foreach ($lignes as $ligne) { |
|
| 1398 | + // Si le type est fixe |
|
| 1399 | + if (isset($parent_methode['type'])) { |
|
| 1400 | + $parent = [ |
|
| 1401 | + 'objet' => $parent_methode['type'], |
|
| 1402 | + 'id_objet' => intval($ligne[$parent_methode['champ']]), |
|
| 1403 | + 'champ' => $parent_methode['champ'], |
|
| 1404 | + 'table' => $table, |
|
| 1405 | + ]; |
|
| 1406 | + } |
|
| 1407 | + elseif (isset($parent_methode['champ_type'])) { |
|
| 1408 | + $parent = [ |
|
| 1409 | + 'objet' => $ligne[$parent_methode['champ_type']], |
|
| 1410 | + 'id_objet' => intval($ligne[$parent_methode['champ']]), |
|
| 1411 | + 'champ' => $parent_methode['champ'], |
|
| 1412 | + 'champ_type' => $parent_methode['champ_type'], |
|
| 1413 | + 'table' => $table, |
|
| 1414 | + ]; |
|
| 1415 | + } |
|
| 1416 | + if ($is_table_lien) { |
|
| 1417 | + $parent['lien'] = $ligne; |
|
| 1418 | + } |
|
| 1419 | + $parents[] = $parent; |
|
| 1420 | + } |
|
| 1421 | + } |
|
| 1422 | + } |
|
| 1423 | + } |
|
| 1424 | + |
|
| 1425 | + // On passe par un pipeline avant de retourner |
|
| 1426 | + $parents = pipeline( |
|
| 1427 | + 'objet_lister_parents', |
|
| 1428 | + [ |
|
| 1429 | + 'args' => [ |
|
| 1430 | + 'objet' => $objet, |
|
| 1431 | + 'id_objet' => $id_objet, |
|
| 1432 | + ], |
|
| 1433 | + 'data' => $parents, |
|
| 1434 | + ] |
|
| 1435 | + ); |
|
| 1436 | + |
|
| 1437 | + return $parents; |
|
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | /** |
@@ -1446,17 +1446,17 @@ discard block |
||
| 1446 | 1446 | * @return array |
| 1447 | 1447 | */ |
| 1448 | 1448 | function objet_lister_parents_par_type($objet, $id_objet) { |
| 1449 | - $parents = objet_lister_parents($objet, $id_objet); |
|
| 1449 | + $parents = objet_lister_parents($objet, $id_objet); |
|
| 1450 | 1450 | |
| 1451 | - $parents_par_type = []; |
|
| 1452 | - foreach ($parents as $parent) { |
|
| 1453 | - if (!isset($parents_par_type[$parent['objet']])) { |
|
| 1454 | - $parents_par_type[$parent['objet']] = []; |
|
| 1455 | - } |
|
| 1456 | - $parents_par_type[$parent['objet']][] = $parent['id_objet']; |
|
| 1457 | - } |
|
| 1451 | + $parents_par_type = []; |
|
| 1452 | + foreach ($parents as $parent) { |
|
| 1453 | + if (!isset($parents_par_type[$parent['objet']])) { |
|
| 1454 | + $parents_par_type[$parent['objet']] = []; |
|
| 1455 | + } |
|
| 1456 | + $parents_par_type[$parent['objet']][] = $parent['id_objet']; |
|
| 1457 | + } |
|
| 1458 | 1458 | |
| 1459 | - return $parents_par_type; |
|
| 1459 | + return $parents_par_type; |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | |
@@ -1489,85 +1489,85 @@ discard block |
||
| 1489 | 1489 | * Retourne un tableau de tableaux, avec comme clés les types des objets, et dans chacun un tableau des identifiants trouvés |
| 1490 | 1490 | */ |
| 1491 | 1491 | function objet_lister_enfants($objet, $id_objet) { |
| 1492 | - $enfants = []; |
|
| 1493 | - |
|
| 1494 | - // Si on trouve des types d'enfants et leurs méthodes |
|
| 1495 | - if ($enfants_methodes = objet_type_decrire_infos_enfants($objet)) { |
|
| 1496 | - include_spip('base/abstract_sql'); |
|
| 1497 | - $id_objet = intval($id_objet); |
|
| 1498 | - |
|
| 1499 | - // On parcourt tous les types d'enfants trouvés |
|
| 1500 | - foreach ($enfants_methodes as $objet_enfant => $_methode_parent) { |
|
| 1501 | - // On construit les conditions d'identification du parent |
|
| 1502 | - $where = []; |
|
| 1503 | - // -- L'identifiant du parent |
|
| 1504 | - if (isset($_methode_parent['champ'])) { |
|
| 1505 | - $where[] = $_methode_parent['champ'] . ' = ' . $id_objet; |
|
| 1506 | - } |
|
| 1507 | - // -- Si le parent est variable |
|
| 1508 | - if (isset($_methode_parent['champ_type'])) { |
|
| 1509 | - $where[] = $_methode_parent['champ_type'] . ' = ' . sql_quote($objet); |
|
| 1510 | - } |
|
| 1511 | - |
|
| 1512 | - // On détermine la table, le champ id des enfants et on complète éventuellement les conditions |
|
| 1513 | - if (!isset($_methode_parent['table'])) { |
|
| 1514 | - // Les enfants sont stockés dans la même table que l'objet parent : |
|
| 1515 | - $table_enfant = table_objet_sql($objet_enfant); |
|
| 1516 | - $cle_objet_enfant = id_table_objet($objet_enfant); |
|
| 1517 | - |
|
| 1518 | - // S'il y a une condition supplémentaire |
|
| 1519 | - if (isset($_methode_parent['condition'])) { |
|
| 1520 | - $where[] = $_methode_parent['condition']; |
|
| 1521 | - } |
|
| 1522 | - } else { |
|
| 1523 | - // Les enfants sont stockés dans une table différente de l'objet parent. |
|
| 1524 | - $table_enfant = $_methode_parent['table']; |
|
| 1525 | - $cle_objet_enfant = $_methode_parent['source_champ'] ?? id_table_objet($objet_enfant); |
|
| 1526 | - |
|
| 1527 | - // S'il y a une condition supplémentaire |
|
| 1528 | - if (isset($_methode_parent['table_condition'])) { |
|
| 1529 | - $where[] = $_methode_parent['table_condition']; |
|
| 1530 | - } |
|
| 1531 | - } |
|
| 1532 | - |
|
| 1533 | - // On lance la requête |
|
| 1534 | - $is_table_lien = (strpos($table_enfant, '_liens') !== false and substr($table_enfant, -6) === '_liens'); |
|
| 1535 | - if ($rows = sql_allfetsel($is_table_lien ? '*' : $cle_objet_enfant, $table_enfant, $where)) { |
|
| 1536 | - $enfant = [ |
|
| 1537 | - 'objet' => $objet_enfant, |
|
| 1538 | - 'id_objet' => 0, |
|
| 1539 | - 'table' => $table_enfant |
|
| 1540 | - ]; |
|
| 1541 | - if (isset($_methode_parent['champ'])) { |
|
| 1542 | - $enfant['champ'] = $_methode_parent['champ']; |
|
| 1543 | - } |
|
| 1544 | - if (isset($_methode_parent['champ_type'])) { |
|
| 1545 | - $enfant['champ_type'] = $_methode_parent['champ_type']; |
|
| 1546 | - } |
|
| 1547 | - foreach ($rows as $row) { |
|
| 1548 | - $enfant['id_objet'] = intval($row[$cle_objet_enfant]); |
|
| 1549 | - if ($is_table_lien) { |
|
| 1550 | - $enfant['lien'] = $row; |
|
| 1551 | - } |
|
| 1552 | - $enfants[] = $enfant; |
|
| 1553 | - } |
|
| 1554 | - } |
|
| 1555 | - } |
|
| 1556 | - } |
|
| 1557 | - |
|
| 1558 | - // On passe par un pipeline avant de retourner |
|
| 1559 | - $enfants = pipeline( |
|
| 1560 | - 'objet_lister_enfants', |
|
| 1561 | - [ |
|
| 1562 | - 'args' => [ |
|
| 1563 | - 'objet' => $objet, |
|
| 1564 | - 'id_objet' => $id_objet, |
|
| 1565 | - ], |
|
| 1566 | - 'data' => $enfants, |
|
| 1567 | - ] |
|
| 1568 | - ); |
|
| 1569 | - |
|
| 1570 | - return $enfants; |
|
| 1492 | + $enfants = []; |
|
| 1493 | + |
|
| 1494 | + // Si on trouve des types d'enfants et leurs méthodes |
|
| 1495 | + if ($enfants_methodes = objet_type_decrire_infos_enfants($objet)) { |
|
| 1496 | + include_spip('base/abstract_sql'); |
|
| 1497 | + $id_objet = intval($id_objet); |
|
| 1498 | + |
|
| 1499 | + // On parcourt tous les types d'enfants trouvés |
|
| 1500 | + foreach ($enfants_methodes as $objet_enfant => $_methode_parent) { |
|
| 1501 | + // On construit les conditions d'identification du parent |
|
| 1502 | + $where = []; |
|
| 1503 | + // -- L'identifiant du parent |
|
| 1504 | + if (isset($_methode_parent['champ'])) { |
|
| 1505 | + $where[] = $_methode_parent['champ'] . ' = ' . $id_objet; |
|
| 1506 | + } |
|
| 1507 | + // -- Si le parent est variable |
|
| 1508 | + if (isset($_methode_parent['champ_type'])) { |
|
| 1509 | + $where[] = $_methode_parent['champ_type'] . ' = ' . sql_quote($objet); |
|
| 1510 | + } |
|
| 1511 | + |
|
| 1512 | + // On détermine la table, le champ id des enfants et on complète éventuellement les conditions |
|
| 1513 | + if (!isset($_methode_parent['table'])) { |
|
| 1514 | + // Les enfants sont stockés dans la même table que l'objet parent : |
|
| 1515 | + $table_enfant = table_objet_sql($objet_enfant); |
|
| 1516 | + $cle_objet_enfant = id_table_objet($objet_enfant); |
|
| 1517 | + |
|
| 1518 | + // S'il y a une condition supplémentaire |
|
| 1519 | + if (isset($_methode_parent['condition'])) { |
|
| 1520 | + $where[] = $_methode_parent['condition']; |
|
| 1521 | + } |
|
| 1522 | + } else { |
|
| 1523 | + // Les enfants sont stockés dans une table différente de l'objet parent. |
|
| 1524 | + $table_enfant = $_methode_parent['table']; |
|
| 1525 | + $cle_objet_enfant = $_methode_parent['source_champ'] ?? id_table_objet($objet_enfant); |
|
| 1526 | + |
|
| 1527 | + // S'il y a une condition supplémentaire |
|
| 1528 | + if (isset($_methode_parent['table_condition'])) { |
|
| 1529 | + $where[] = $_methode_parent['table_condition']; |
|
| 1530 | + } |
|
| 1531 | + } |
|
| 1532 | + |
|
| 1533 | + // On lance la requête |
|
| 1534 | + $is_table_lien = (strpos($table_enfant, '_liens') !== false and substr($table_enfant, -6) === '_liens'); |
|
| 1535 | + if ($rows = sql_allfetsel($is_table_lien ? '*' : $cle_objet_enfant, $table_enfant, $where)) { |
|
| 1536 | + $enfant = [ |
|
| 1537 | + 'objet' => $objet_enfant, |
|
| 1538 | + 'id_objet' => 0, |
|
| 1539 | + 'table' => $table_enfant |
|
| 1540 | + ]; |
|
| 1541 | + if (isset($_methode_parent['champ'])) { |
|
| 1542 | + $enfant['champ'] = $_methode_parent['champ']; |
|
| 1543 | + } |
|
| 1544 | + if (isset($_methode_parent['champ_type'])) { |
|
| 1545 | + $enfant['champ_type'] = $_methode_parent['champ_type']; |
|
| 1546 | + } |
|
| 1547 | + foreach ($rows as $row) { |
|
| 1548 | + $enfant['id_objet'] = intval($row[$cle_objet_enfant]); |
|
| 1549 | + if ($is_table_lien) { |
|
| 1550 | + $enfant['lien'] = $row; |
|
| 1551 | + } |
|
| 1552 | + $enfants[] = $enfant; |
|
| 1553 | + } |
|
| 1554 | + } |
|
| 1555 | + } |
|
| 1556 | + } |
|
| 1557 | + |
|
| 1558 | + // On passe par un pipeline avant de retourner |
|
| 1559 | + $enfants = pipeline( |
|
| 1560 | + 'objet_lister_enfants', |
|
| 1561 | + [ |
|
| 1562 | + 'args' => [ |
|
| 1563 | + 'objet' => $objet, |
|
| 1564 | + 'id_objet' => $id_objet, |
|
| 1565 | + ], |
|
| 1566 | + 'data' => $enfants, |
|
| 1567 | + ] |
|
| 1568 | + ); |
|
| 1569 | + |
|
| 1570 | + return $enfants; |
|
| 1571 | 1571 | } |
| 1572 | 1572 | |
| 1573 | 1573 | /** |
@@ -1579,17 +1579,17 @@ discard block |
||
| 1579 | 1579 | * @return array |
| 1580 | 1580 | */ |
| 1581 | 1581 | function objet_lister_enfants_par_type($objet, $id_objet) { |
| 1582 | - $enfants = objet_lister_enfants($objet, $id_objet); |
|
| 1582 | + $enfants = objet_lister_enfants($objet, $id_objet); |
|
| 1583 | 1583 | |
| 1584 | - $enfants_par_type = []; |
|
| 1585 | - foreach ($enfants as $enfant) { |
|
| 1586 | - if (!isset($enfants_par_type[$enfant['objet']])) { |
|
| 1587 | - $enfants_par_type[$enfant['objet']] = []; |
|
| 1588 | - } |
|
| 1589 | - $enfants_par_type[$enfant['objet']][] = $enfant['id_objet']; |
|
| 1590 | - } |
|
| 1584 | + $enfants_par_type = []; |
|
| 1585 | + foreach ($enfants as $enfant) { |
|
| 1586 | + if (!isset($enfants_par_type[$enfant['objet']])) { |
|
| 1587 | + $enfants_par_type[$enfant['objet']] = []; |
|
| 1588 | + } |
|
| 1589 | + $enfants_par_type[$enfant['objet']][] = $enfant['id_objet']; |
|
| 1590 | + } |
|
| 1591 | 1591 | |
| 1592 | - return $enfants_par_type; |
|
| 1592 | + return $enfants_par_type; |
|
| 1593 | 1593 | } |
| 1594 | 1594 | |
| 1595 | 1595 | /** |
@@ -1601,35 +1601,35 @@ discard block |
||
| 1601 | 1601 | * Retourne un tableau de tableau contenant les informations de type et de champ pour trouver le parent ou false sinon |
| 1602 | 1602 | */ |
| 1603 | 1603 | function objet_type_decrire_infos_parents($objet) { |
| 1604 | - static $parents = []; |
|
| 1605 | - |
|
| 1606 | - // Si on ne l'a pas encore cherché pour cet objet |
|
| 1607 | - if (!isset($parents[$objet])) { |
|
| 1608 | - $parents[$objet] = false; |
|
| 1609 | - $table = table_objet_sql($objet); |
|
| 1610 | - |
|
| 1611 | - // Si on trouve bien la description de cet objet |
|
| 1612 | - if ($infos = lister_tables_objets_sql($table)) { |
|
| 1613 | - if (isset($infos['parent']) and is_array($infos['parent'])) { |
|
| 1614 | - // S'il y a une description explicite de parent, c'est prioritaire |
|
| 1615 | - // -- on traite les cas où il y a une ou plusieurs description mais on renvoie toujours un tableau |
|
| 1616 | - // de description |
|
| 1617 | - if (!isset($infos['parent'][0])) { |
|
| 1618 | - $parents[$objet] = [$infos['parent']]; |
|
| 1619 | - } else { |
|
| 1620 | - $parents[$objet] = $infos['parent']; |
|
| 1621 | - } |
|
| 1622 | - } elseif (isset($infos['field']['id_rubrique'])) { |
|
| 1623 | - // Sinon on cherche des cas courants connus magiquement, à commencer par id_rubrique |
|
| 1624 | - $parents[$objet] = [['type' => 'rubrique', 'champ' => 'id_rubrique']]; |
|
| 1625 | - } elseif (isset($infos['field']['id_parent'])) { |
|
| 1626 | - // Sinon on cherche un champ id_parent, ce qui signifie que l'objet est parent de lui-même |
|
| 1627 | - $parents[$objet] = [['type' => $objet, 'champ' => 'id_parent']]; |
|
| 1628 | - } |
|
| 1629 | - } |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - return $parents[$objet]; |
|
| 1604 | + static $parents = []; |
|
| 1605 | + |
|
| 1606 | + // Si on ne l'a pas encore cherché pour cet objet |
|
| 1607 | + if (!isset($parents[$objet])) { |
|
| 1608 | + $parents[$objet] = false; |
|
| 1609 | + $table = table_objet_sql($objet); |
|
| 1610 | + |
|
| 1611 | + // Si on trouve bien la description de cet objet |
|
| 1612 | + if ($infos = lister_tables_objets_sql($table)) { |
|
| 1613 | + if (isset($infos['parent']) and is_array($infos['parent'])) { |
|
| 1614 | + // S'il y a une description explicite de parent, c'est prioritaire |
|
| 1615 | + // -- on traite les cas où il y a une ou plusieurs description mais on renvoie toujours un tableau |
|
| 1616 | + // de description |
|
| 1617 | + if (!isset($infos['parent'][0])) { |
|
| 1618 | + $parents[$objet] = [$infos['parent']]; |
|
| 1619 | + } else { |
|
| 1620 | + $parents[$objet] = $infos['parent']; |
|
| 1621 | + } |
|
| 1622 | + } elseif (isset($infos['field']['id_rubrique'])) { |
|
| 1623 | + // Sinon on cherche des cas courants connus magiquement, à commencer par id_rubrique |
|
| 1624 | + $parents[$objet] = [['type' => 'rubrique', 'champ' => 'id_rubrique']]; |
|
| 1625 | + } elseif (isset($infos['field']['id_parent'])) { |
|
| 1626 | + // Sinon on cherche un champ id_parent, ce qui signifie que l'objet est parent de lui-même |
|
| 1627 | + $parents[$objet] = [['type' => $objet, 'champ' => 'id_parent']]; |
|
| 1628 | + } |
|
| 1629 | + } |
|
| 1630 | + } |
|
| 1631 | + |
|
| 1632 | + return $parents[$objet]; |
|
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | 1635 | /** |
@@ -1641,36 +1641,36 @@ discard block |
||
| 1641 | 1641 | * Retourne un tableau de tableaux contenant chacun les informations d'un type d'enfant |
| 1642 | 1642 | */ |
| 1643 | 1643 | function objet_type_decrire_infos_enfants($objet) { |
| 1644 | - static $enfants = []; |
|
| 1645 | - |
|
| 1646 | - // Si on a déjà fait la recherche pour ce type d'objet |
|
| 1647 | - if (!isset($enfants[$objet])) { |
|
| 1648 | - $enfants[$objet] = []; |
|
| 1649 | - $tables = lister_tables_objets_sql(); |
|
| 1650 | - |
|
| 1651 | - // On parcourt toutes les tables d'objet, et on cherche si chacune peut être enfant |
|
| 1652 | - foreach ($tables as $table => $infos) { |
|
| 1653 | - $objet_enfant = objet_type($table); |
|
| 1654 | - |
|
| 1655 | - // On ne va pas refaire les tests des différents cas, on réutilise |
|
| 1656 | - if ($parent_methodes = objet_type_decrire_infos_parents($objet_enfant)) { |
|
| 1657 | - // On parcourt les différents cas possible, si certains peuvent concerner l'objet demandé |
|
| 1658 | - foreach ($parent_methodes as $parent_methode) { |
|
| 1659 | - // Si la méthode qu'on teste n'exclut pas le parent demandé |
|
| 1660 | - if (!isset($parent_methode['exclus']) or !in_array($objet, $parent_methode['exclus'])) { |
|
| 1661 | - // Si le type du parent est fixe et directement l'objet demandé |
|
| 1662 | - if (isset($parent_methode['type']) and isset($parent_methode['champ']) and $parent_methode['type'] == $objet) { |
|
| 1663 | - $enfants[$objet][$objet_enfant] = $parent_methode; |
|
| 1664 | - } |
|
| 1665 | - // Si le type est variable, alors l'objet demandé peut forcément être parent |
|
| 1666 | - elseif (isset($parent_methode['champ_type']) and isset($parent_methode['champ'])) { |
|
| 1667 | - $enfants[$objet][$objet_enfant] = $parent_methode; |
|
| 1668 | - } |
|
| 1669 | - } |
|
| 1670 | - } |
|
| 1671 | - } |
|
| 1672 | - } |
|
| 1673 | - } |
|
| 1674 | - |
|
| 1675 | - return $enfants[$objet]; |
|
| 1644 | + static $enfants = []; |
|
| 1645 | + |
|
| 1646 | + // Si on a déjà fait la recherche pour ce type d'objet |
|
| 1647 | + if (!isset($enfants[$objet])) { |
|
| 1648 | + $enfants[$objet] = []; |
|
| 1649 | + $tables = lister_tables_objets_sql(); |
|
| 1650 | + |
|
| 1651 | + // On parcourt toutes les tables d'objet, et on cherche si chacune peut être enfant |
|
| 1652 | + foreach ($tables as $table => $infos) { |
|
| 1653 | + $objet_enfant = objet_type($table); |
|
| 1654 | + |
|
| 1655 | + // On ne va pas refaire les tests des différents cas, on réutilise |
|
| 1656 | + if ($parent_methodes = objet_type_decrire_infos_parents($objet_enfant)) { |
|
| 1657 | + // On parcourt les différents cas possible, si certains peuvent concerner l'objet demandé |
|
| 1658 | + foreach ($parent_methodes as $parent_methode) { |
|
| 1659 | + // Si la méthode qu'on teste n'exclut pas le parent demandé |
|
| 1660 | + if (!isset($parent_methode['exclus']) or !in_array($objet, $parent_methode['exclus'])) { |
|
| 1661 | + // Si le type du parent est fixe et directement l'objet demandé |
|
| 1662 | + if (isset($parent_methode['type']) and isset($parent_methode['champ']) and $parent_methode['type'] == $objet) { |
|
| 1663 | + $enfants[$objet][$objet_enfant] = $parent_methode; |
|
| 1664 | + } |
|
| 1665 | + // Si le type est variable, alors l'objet demandé peut forcément être parent |
|
| 1666 | + elseif (isset($parent_methode['champ_type']) and isset($parent_methode['champ'])) { |
|
| 1667 | + $enfants[$objet][$objet_enfant] = $parent_methode; |
|
| 1668 | + } |
|
| 1669 | + } |
|
| 1670 | + } |
|
| 1671 | + } |
|
| 1672 | + } |
|
| 1673 | + } |
|
| 1674 | + |
|
| 1675 | + return $enfants[$objet]; |
|
| 1676 | 1676 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | // Determiner l'action demandee |
| 36 | 36 | // |
| 37 | 37 | |
| 38 | -$exec = (string)_request('exec'); |
|
| 38 | +$exec = (string) _request('exec'); |
|
| 39 | 39 | $reinstall = (!is_null(_request('reinstall'))) ? _request('reinstall') : ($exec == 'install' ? 'oui' : null); |
| 40 | 40 | // |
| 41 | 41 | // Les scripts d'insallation n'authentifient pas, forcement, |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | or (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']['statut'] == '0minirezo') |
| 122 | 122 | ) |
| 123 | 123 | ) { |
| 124 | - spip_log('Quand la meta admin vaut ' . |
|
| 125 | - $GLOBALS['meta']['admin'] . |
|
| 126 | - ' seul un admin peut se connecter et sans AJAX.' . |
|
| 124 | + spip_log('Quand la meta admin vaut '. |
|
| 125 | + $GLOBALS['meta']['admin']. |
|
| 126 | + ' seul un admin peut se connecter et sans AJAX.'. |
|
| 127 | 127 | ' En cas de probleme, detruire cette meta.'); |
| 128 | 128 | die(_T('info_travaux_texte')); |
| 129 | 129 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** Drapeau indiquant que l'on est dans l'espace privé */ |
| 20 | 20 | define('_ESPACE_PRIVE', true); |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - include 'inc_version.php'; |
|
| 22 | + include 'inc_version.php'; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | include_spip('inc/cookie'); |
@@ -35,18 +35,18 @@ discard block |
||
| 35 | 35 | // alors il faut blinder les variables d'URL |
| 36 | 36 | // |
| 37 | 37 | if (autoriser_sans_cookie($exec, false)) { |
| 38 | - if (!isset($reinstall)) { |
|
| 39 | - $reinstall = 'non'; |
|
| 40 | - } |
|
| 41 | - $var_auth = true; |
|
| 38 | + if (!isset($reinstall)) { |
|
| 39 | + $reinstall = 'non'; |
|
| 40 | + } |
|
| 41 | + $var_auth = true; |
|
| 42 | 42 | } else { |
| 43 | - // Authentification, redefinissable |
|
| 44 | - $auth = charger_fonction('auth', 'inc'); |
|
| 45 | - $var_auth = $auth(); |
|
| 46 | - if ($var_auth) { |
|
| 47 | - echo auth_echec($var_auth); |
|
| 48 | - exit; |
|
| 49 | - } |
|
| 43 | + // Authentification, redefinissable |
|
| 44 | + $auth = charger_fonction('auth', 'inc'); |
|
| 45 | + $var_auth = $auth(); |
|
| 46 | + if ($var_auth) { |
|
| 47 | + echo auth_echec($var_auth); |
|
| 48 | + exit; |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // initialiser a la langue par defaut |
@@ -57,29 +57,29 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | if (_request('action') or _request('var_ajax') or _request('formulaire_action')) { |
| 60 | - if (!autoriser_sans_cookie($exec)) { |
|
| 61 | - // Charger l'aiguilleur qui va mettre sur la bonne voie les traitements derogatoires |
|
| 62 | - include_spip('public/aiguiller'); |
|
| 63 | - if ( |
|
| 64 | - // cas des appels actions ?action=xxx |
|
| 65 | - traiter_appels_actions() |
|
| 66 | - or |
|
| 67 | - // cas des hits ajax sur les inclusions ajax |
|
| 68 | - traiter_appels_inclusions_ajax() |
|
| 69 | - or |
|
| 70 | - // cas des formulaires charger/verifier/traiter |
|
| 71 | - traiter_formulaires_dynamiques() |
|
| 72 | - ) { |
|
| 73 | - exit; |
|
| 74 | - } // le hit est fini ! |
|
| 75 | - } |
|
| 60 | + if (!autoriser_sans_cookie($exec)) { |
|
| 61 | + // Charger l'aiguilleur qui va mettre sur la bonne voie les traitements derogatoires |
|
| 62 | + include_spip('public/aiguiller'); |
|
| 63 | + if ( |
|
| 64 | + // cas des appels actions ?action=xxx |
|
| 65 | + traiter_appels_actions() |
|
| 66 | + or |
|
| 67 | + // cas des hits ajax sur les inclusions ajax |
|
| 68 | + traiter_appels_inclusions_ajax() |
|
| 69 | + or |
|
| 70 | + // cas des formulaires charger/verifier/traiter |
|
| 71 | + traiter_formulaires_dynamiques() |
|
| 72 | + ) { |
|
| 73 | + exit; |
|
| 74 | + } // le hit est fini ! |
|
| 75 | + } |
|
| 76 | 76 | } |
| 77 | 77 | // securiser les redirect du back-office |
| 78 | 78 | if (_request('redirect')) { |
| 79 | - if (!function_exists('securiser_redirect_action')) { |
|
| 80 | - include_spip('public/aiguiller'); |
|
| 81 | - } |
|
| 82 | - set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 79 | + if (!function_exists('securiser_redirect_action')) { |
|
| 80 | + include_spip('public/aiguiller'); |
|
| 81 | + } |
|
| 82 | + set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | // Controle de la version, sauf si on est deja en train de s'en occuper |
| 91 | 91 | if ( |
| 92 | - !$reinstall == 'oui' |
|
| 93 | - and !_AJAX |
|
| 94 | - and isset($GLOBALS['meta']['version_installee']) |
|
| 95 | - and ($GLOBALS['spip_version_base'] != (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 92 | + !$reinstall == 'oui' |
|
| 93 | + and !_AJAX |
|
| 94 | + and isset($GLOBALS['meta']['version_installee']) |
|
| 95 | + and ($GLOBALS['spip_version_base'] != (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 96 | 96 | ) { |
| 97 | - $exec = 'demande_mise_a_jour'; |
|
| 97 | + $exec = 'demande_mise_a_jour'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Quand une action d'administration est en cours (meta "admin"), |
@@ -104,39 +104,39 @@ discard block |
||
| 104 | 104 | // sinon c'est qu'elle a ete interrompue et il faut la reprendre |
| 105 | 105 | |
| 106 | 106 | elseif (isset($GLOBALS['meta']['admin'])) { |
| 107 | - if (preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)) { |
|
| 108 | - [, $var_f, $n] = $l; |
|
| 109 | - } |
|
| 110 | - if ( |
|
| 111 | - _AJAX |
|
| 112 | - or !( |
|
| 113 | - isset($_COOKIE['spip_admin']) |
|
| 114 | - or (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']['statut'] == '0minirezo') |
|
| 115 | - ) |
|
| 116 | - ) { |
|
| 117 | - spip_log('Quand la meta admin vaut ' . |
|
| 118 | - $GLOBALS['meta']['admin'] . |
|
| 119 | - ' seul un admin peut se connecter et sans AJAX.' . |
|
| 120 | - ' En cas de probleme, detruire cette meta.'); |
|
| 121 | - die(_T('info_travaux_texte')); |
|
| 122 | - } |
|
| 123 | - if ($n) { |
|
| 124 | - [, $var_f, $n] = $l; |
|
| 125 | - if (tester_url_ecrire("base_$var_f")) { |
|
| 126 | - $var_f = "base_$var_f"; |
|
| 127 | - } |
|
| 128 | - if ($var_f != $exec) { |
|
| 129 | - spip_log("Le script $var_f lance par auteur$n se substitue a l'exec $exec"); |
|
| 130 | - $exec = $var_f; |
|
| 131 | - set_request('exec', $exec); |
|
| 132 | - } |
|
| 133 | - } |
|
| 107 | + if (preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)) { |
|
| 108 | + [, $var_f, $n] = $l; |
|
| 109 | + } |
|
| 110 | + if ( |
|
| 111 | + _AJAX |
|
| 112 | + or !( |
|
| 113 | + isset($_COOKIE['spip_admin']) |
|
| 114 | + or (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']['statut'] == '0minirezo') |
|
| 115 | + ) |
|
| 116 | + ) { |
|
| 117 | + spip_log('Quand la meta admin vaut ' . |
|
| 118 | + $GLOBALS['meta']['admin'] . |
|
| 119 | + ' seul un admin peut se connecter et sans AJAX.' . |
|
| 120 | + ' En cas de probleme, detruire cette meta.'); |
|
| 121 | + die(_T('info_travaux_texte')); |
|
| 122 | + } |
|
| 123 | + if ($n) { |
|
| 124 | + [, $var_f, $n] = $l; |
|
| 125 | + if (tester_url_ecrire("base_$var_f")) { |
|
| 126 | + $var_f = "base_$var_f"; |
|
| 127 | + } |
|
| 128 | + if ($var_f != $exec) { |
|
| 129 | + spip_log("Le script $var_f lance par auteur$n se substitue a l'exec $exec"); |
|
| 130 | + $exec = $var_f; |
|
| 131 | + set_request('exec', $exec); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | // si nom pas plausible, prendre le script par defaut |
| 136 | 136 | // attention aux deux cas 404/403 qui commencent par un 4 ! |
| 137 | 137 | elseif (!preg_match(',^[a-z4_][0-9a-z_-]*$,i', $exec)) { |
| 138 | - $exec = 'accueil'; |
|
| 139 | - set_request('exec', $exec); |
|
| 138 | + $exec = 'accueil'; |
|
| 139 | + set_request('exec', $exec); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // si la langue est specifiee par cookie et ne correspond pas |
@@ -144,19 +144,19 @@ discard block |
||
| 144 | 144 | // on appelle directement la fonction, car un appel d'action peut conduire a une boucle infinie |
| 145 | 145 | // si le cookie n'est pas pose correctement dans l'action |
| 146 | 146 | if ( |
| 147 | - !$var_auth and isset($_COOKIE['spip_lang_ecrire']) |
|
| 148 | - and $_COOKIE['spip_lang_ecrire'] <> $GLOBALS['visiteur_session']['lang'] |
|
| 147 | + !$var_auth and isset($_COOKIE['spip_lang_ecrire']) |
|
| 148 | + and $_COOKIE['spip_lang_ecrire'] <> $GLOBALS['visiteur_session']['lang'] |
|
| 149 | 149 | ) { |
| 150 | - include_spip('action/converser'); |
|
| 151 | - action_converser_post($GLOBALS['visiteur_session']['lang'], true); |
|
| 150 | + include_spip('action/converser'); |
|
| 151 | + action_converser_post($GLOBALS['visiteur_session']['lang'], true); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | if ($var_f = tester_url_ecrire($exec)) { |
| 155 | - $var_f = charger_fonction($var_f); |
|
| 156 | - $var_f(); // at last |
|
| 155 | + $var_f = charger_fonction($var_f); |
|
| 156 | + $var_f(); // at last |
|
| 157 | 157 | } else { |
| 158 | - // Rien de connu: rerouter vers exec=404 au lieu d'echouer |
|
| 159 | - // ce qui permet de laisser la main a un plugin |
|
| 160 | - $var_f = charger_fonction('404'); |
|
| 161 | - $var_f($exec); |
|
| 158 | + // Rien de connu: rerouter vers exec=404 au lieu d'echouer |
|
| 159 | + // ce qui permet de laisser la main a un plugin |
|
| 160 | + $var_f = charger_fonction('404'); |
|
| 161 | + $var_f($exec); |
|
| 162 | 162 | } |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | 'valeur' => $adresse_ldap |
| 59 | 59 | ], |
| 60 | 60 | 'port_ldap' => [ |
| 61 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 61 | + 'label' => _T('entree_port_annuaire').'<br />'._T('texte_port_annuaire'), |
|
| 62 | 62 | 'valeur' => $port_ldap |
| 63 | 63 | ], |
| 64 | 64 | 'tls_ldap' => [ |
| 65 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 65 | + 'label' => '<b>'._T('tls_ldap').'</b>', |
|
| 66 | 66 | 'valeur' => $tls_ldap, |
| 67 | 67 | 'alternatives' => [ |
| 68 | 68 | 'non' => _T('item_non'), |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ] |
| 81 | 81 | ) |
| 82 | 82 | |
| 83 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 83 | + . "\n<p>"._T('texte_acces_ldap_anonyme_1').'</p>' |
|
| 84 | 84 | . fieldset( |
| 85 | 85 | _T('connexion_ldap'), |
| 86 | 86 | [ |
@@ -10,89 +10,89 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function install_etape_ldap1_dist() { |
| 17 | - $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 18 | - ? _INSTALL_HOST_LDAP |
|
| 19 | - : 'localhost'; |
|
| 17 | + $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 18 | + ? _INSTALL_HOST_LDAP |
|
| 19 | + : 'localhost'; |
|
| 20 | 20 | |
| 21 | - $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 22 | - ? _INSTALL_PORT_LDAP |
|
| 23 | - : 389; |
|
| 21 | + $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 22 | + ? _INSTALL_PORT_LDAP |
|
| 23 | + : 389; |
|
| 24 | 24 | |
| 25 | - $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 26 | - ? _INSTALL_TLS_LDAP |
|
| 27 | - : 'non'; |
|
| 25 | + $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 26 | + ? _INSTALL_TLS_LDAP |
|
| 27 | + : 'non'; |
|
| 28 | 28 | |
| 29 | - $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 30 | - ? _INSTALL_PROTOCOLE_LDAP |
|
| 31 | - : 3; // on essaie 2 en cas d'echec |
|
| 29 | + $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 30 | + ? _INSTALL_PROTOCOLE_LDAP |
|
| 31 | + : 3; // on essaie 2 en cas d'echec |
|
| 32 | 32 | |
| 33 | - $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 34 | - ? _INSTALL_USER_LDAP |
|
| 35 | - : ''; |
|
| 33 | + $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 34 | + ? _INSTALL_USER_LDAP |
|
| 35 | + : ''; |
|
| 36 | 36 | |
| 37 | - $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 38 | - ? _INSTALL_PASS_LDAP |
|
| 39 | - : ''; |
|
| 37 | + $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 38 | + ? _INSTALL_PASS_LDAP |
|
| 39 | + : ''; |
|
| 40 | 40 | |
| 41 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 42 | - echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 41 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 42 | + echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 43 | 43 | |
| 44 | - echo info_etape( |
|
| 45 | - _T('titre_connexion_ldap'), |
|
| 46 | - info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 47 | - ); |
|
| 44 | + echo info_etape( |
|
| 45 | + _T('titre_connexion_ldap'), |
|
| 46 | + info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 47 | + ); |
|
| 48 | 48 | |
| 49 | - echo generer_form_ecrire('install', ( |
|
| 50 | - "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 51 | - . fieldset( |
|
| 52 | - _T('entree_adresse_annuaire'), |
|
| 53 | - [ |
|
| 54 | - 'adresse_ldap' => [ |
|
| 55 | - 'label' => _T('texte_adresse_annuaire_1'), |
|
| 56 | - 'valeur' => $adresse_ldap |
|
| 57 | - ], |
|
| 58 | - 'port_ldap' => [ |
|
| 59 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 60 | - 'valeur' => $port_ldap |
|
| 61 | - ], |
|
| 62 | - 'tls_ldap' => [ |
|
| 63 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 64 | - 'valeur' => $tls_ldap, |
|
| 65 | - 'alternatives' => [ |
|
| 66 | - 'non' => _T('item_non'), |
|
| 67 | - 'oui' => _T('item_oui') |
|
| 68 | - ] |
|
| 69 | - ], |
|
| 70 | - 'protocole_ldap' => [ |
|
| 71 | - 'label' => _T('protocole_ldap'), |
|
| 72 | - 'valeur' => $protocole_ldap, |
|
| 73 | - 'alternatives' => [ |
|
| 74 | - '3' => '3', |
|
| 75 | - '2' => '2' |
|
| 76 | - ] |
|
| 77 | - ] |
|
| 78 | - ] |
|
| 79 | - ) |
|
| 49 | + echo generer_form_ecrire('install', ( |
|
| 50 | + "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 51 | + . fieldset( |
|
| 52 | + _T('entree_adresse_annuaire'), |
|
| 53 | + [ |
|
| 54 | + 'adresse_ldap' => [ |
|
| 55 | + 'label' => _T('texte_adresse_annuaire_1'), |
|
| 56 | + 'valeur' => $adresse_ldap |
|
| 57 | + ], |
|
| 58 | + 'port_ldap' => [ |
|
| 59 | + 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 60 | + 'valeur' => $port_ldap |
|
| 61 | + ], |
|
| 62 | + 'tls_ldap' => [ |
|
| 63 | + 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 64 | + 'valeur' => $tls_ldap, |
|
| 65 | + 'alternatives' => [ |
|
| 66 | + 'non' => _T('item_non'), |
|
| 67 | + 'oui' => _T('item_oui') |
|
| 68 | + ] |
|
| 69 | + ], |
|
| 70 | + 'protocole_ldap' => [ |
|
| 71 | + 'label' => _T('protocole_ldap'), |
|
| 72 | + 'valeur' => $protocole_ldap, |
|
| 73 | + 'alternatives' => [ |
|
| 74 | + '3' => '3', |
|
| 75 | + '2' => '2' |
|
| 76 | + ] |
|
| 77 | + ] |
|
| 78 | + ] |
|
| 79 | + ) |
|
| 80 | 80 | |
| 81 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 82 | - . fieldset( |
|
| 83 | - _T('connexion_ldap'), |
|
| 84 | - [ |
|
| 85 | - 'login_ldap' => [ |
|
| 86 | - 'label' => _T('texte_login_ldap_1'), |
|
| 87 | - 'valeur' => $login_ldap |
|
| 88 | - ], |
|
| 89 | - 'pass_ldap' => [ |
|
| 90 | - 'label' => _T('entree_passe_ldap'), |
|
| 91 | - 'valeur' => $pass_ldap |
|
| 92 | - ] |
|
| 93 | - ] |
|
| 94 | - ) |
|
| 95 | - . bouton_suivant())); |
|
| 81 | + . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 82 | + . fieldset( |
|
| 83 | + _T('connexion_ldap'), |
|
| 84 | + [ |
|
| 85 | + 'login_ldap' => [ |
|
| 86 | + 'label' => _T('texte_login_ldap_1'), |
|
| 87 | + 'valeur' => $login_ldap |
|
| 88 | + ], |
|
| 89 | + 'pass_ldap' => [ |
|
| 90 | + 'label' => _T('entree_passe_ldap'), |
|
| 91 | + 'valeur' => $pass_ldap |
|
| 92 | + ] |
|
| 93 | + ] |
|
| 94 | + ) |
|
| 95 | + . bouton_suivant())); |
|
| 96 | 96 | |
| 97 | - echo $minipage->installFinPage(); |
|
| 97 | + echo $minipage->installFinPage(); |
|
| 98 | 98 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // creer le repertoire cache, qui sert partout ! |
| 23 | 23 | if (!@file_exists(_DIR_CACHE)) { |
| 24 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 24 | + $rep = preg_replace(','._DIR_TMP.',', '', _DIR_CACHE); |
|
| 25 | 25 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | echo '<p>' |
| 40 | 40 | . _T( |
| 41 | 41 | 'plugin_info_plugins_dist_1', |
| 42 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | + ['plugins_dist' => '<tt>'.joli_repertoire(_DIR_PLUGINS_DIST).'</tt>'] |
|
| 43 | 43 | ) |
| 44 | 44 | . '</p>'; |
| 45 | 45 | |
@@ -10,70 +10,70 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/headers'); |
| 17 | 17 | |
| 18 | 18 | function install_etape_4_dist() { |
| 19 | 19 | |
| 20 | - // creer le repertoire cache, qui sert partout ! |
|
| 21 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 22 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 23 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 24 | - } |
|
| 20 | + // creer le repertoire cache, qui sert partout ! |
|
| 21 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 22 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 23 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 27 | - echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 26 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 27 | + echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 28 | 28 | |
| 29 | - echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 29 | + echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 30 | 30 | |
| 31 | - echo "<div class='success'><b>" |
|
| 32 | - . _T('info_derniere_etape') |
|
| 33 | - . '</b><p>' |
|
| 34 | - . _T('info_utilisation_spip') |
|
| 35 | - . '</p></div>'; |
|
| 31 | + echo "<div class='success'><b>" |
|
| 32 | + . _T('info_derniere_etape') |
|
| 33 | + . '</b><p>' |
|
| 34 | + . _T('info_utilisation_spip') |
|
| 35 | + . '</p></div>'; |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - echo '<p>' |
|
| 39 | - . _T( |
|
| 40 | - 'plugin_info_plugins_dist_1', |
|
| 41 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | - ) |
|
| 43 | - . '</p>'; |
|
| 38 | + echo '<p>' |
|
| 39 | + . _T( |
|
| 40 | + 'plugin_info_plugins_dist_1', |
|
| 41 | + ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | + ) |
|
| 43 | + . '</p>'; |
|
| 44 | 44 | |
| 45 | - // installer les extensions |
|
| 46 | - include_spip('inc/plugin'); |
|
| 47 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 48 | - echo $afficher( |
|
| 49 | - self(), |
|
| 50 | - liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 51 | - [], |
|
| 52 | - [], |
|
| 53 | - _DIR_PLUGINS_DIST, |
|
| 54 | - 'afficher_nom_plugin' |
|
| 55 | - ); |
|
| 45 | + // installer les extensions |
|
| 46 | + include_spip('inc/plugin'); |
|
| 47 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 48 | + echo $afficher( |
|
| 49 | + self(), |
|
| 50 | + liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 51 | + [], |
|
| 52 | + [], |
|
| 53 | + _DIR_PLUGINS_DIST, |
|
| 54 | + 'afficher_nom_plugin' |
|
| 55 | + ); |
|
| 56 | 56 | |
| 57 | - // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 58 | - // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 59 | - // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 60 | - // et procede alors a l'installation |
|
| 61 | - if ( |
|
| 62 | - !isset($GLOBALS['meta']['version_installee']) |
|
| 63 | - || $GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee'])) |
|
| 64 | - ) { |
|
| 65 | - plugin_installes_meta(); |
|
| 66 | - } |
|
| 57 | + // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 58 | + // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 59 | + // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 60 | + // et procede alors a l'installation |
|
| 61 | + if ( |
|
| 62 | + !isset($GLOBALS['meta']['version_installee']) |
|
| 63 | + || $GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee'])) |
|
| 64 | + ) { |
|
| 65 | + plugin_installes_meta(); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - // mettre a jour si necessaire l'adresse du site |
|
| 69 | - // securite si on arrive plus a se loger |
|
| 70 | - include_spip('inc/config'); |
|
| 71 | - appliquer_adresse_site(''); |
|
| 68 | + // mettre a jour si necessaire l'adresse du site |
|
| 69 | + // securite si on arrive plus a se loger |
|
| 70 | + include_spip('inc/config'); |
|
| 71 | + appliquer_adresse_site(''); |
|
| 72 | 72 | |
| 73 | - // aller a la derniere etape qui clos l'install et redirige |
|
| 74 | - $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 75 | - . bouton_suivant(_T('login_espace_prive')); |
|
| 73 | + // aller a la derniere etape qui clos l'install et redirige |
|
| 74 | + $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 75 | + . bouton_suivant(_T('login_espace_prive')); |
|
| 76 | 76 | |
| 77 | - echo generer_form_ecrire('install', $suite); |
|
| 78 | - echo $minipage->installFinPage(); |
|
| 77 | + echo generer_form_ecrire('install', $suite); |
|
| 78 | + echo $minipage->installFinPage(); |
|
| 79 | 79 | } |
@@ -107,8 +107,8 @@ |
||
| 107 | 107 | function message_crash_tables() { |
| 108 | 108 | if ($crash = verifier_crash_tables()) { |
| 109 | 109 | return |
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 110 | + '<strong>'._T('texte_recuperer_base').'</strong><br />' |
|
| 111 | + . ' <tt>'.join(', ', $crash).'</tt><br />' |
|
| 112 | 112 | . generer_form_ecrire( |
| 113 | 113 | 'base_repair', |
| 114 | 114 | _T('texte_crash_base'), |
@@ -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 | /** |
@@ -35,19 +35,19 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function genie_maintenance_dist($t) { |
| 37 | 37 | |
| 38 | - // (re)mettre .htaccess avec deny from all |
|
| 39 | - // dans les deux repertoires dits inaccessibles par http |
|
| 40 | - include_spip('inc/acces'); |
|
| 41 | - verifier_htaccess(_DIR_ETC); |
|
| 42 | - verifier_htaccess(_DIR_TMP); |
|
| 43 | - verifier_htaccess(_DIR_VENDOR); |
|
| 38 | + // (re)mettre .htaccess avec deny from all |
|
| 39 | + // dans les deux repertoires dits inaccessibles par http |
|
| 40 | + include_spip('inc/acces'); |
|
| 41 | + verifier_htaccess(_DIR_ETC); |
|
| 42 | + verifier_htaccess(_DIR_TMP); |
|
| 43 | + verifier_htaccess(_DIR_VENDOR); |
|
| 44 | 44 | |
| 45 | - // Verifier qu'aucune table n'est crashee |
|
| 46 | - if (!_request('reinstall')) { |
|
| 47 | - verifier_crash_tables(); |
|
| 48 | - } |
|
| 45 | + // Verifier qu'aucune table n'est crashee |
|
| 46 | + if (!_request('reinstall')) { |
|
| 47 | + verifier_crash_tables(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return 1; |
|
| 50 | + return 1; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -64,33 +64,33 @@ discard block |
||
| 64 | 64 | * des tables qui ont crashé. |
| 65 | 65 | */ |
| 66 | 66 | function verifier_crash_tables() { |
| 67 | - if (spip_connect()) { |
|
| 68 | - include_spip('base/serial'); |
|
| 69 | - include_spip('base/auxiliaires'); |
|
| 70 | - $crash = []; |
|
| 71 | - foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 72 | - foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 73 | - if ( |
|
| 74 | - !sql_select('*', $table, '', '', '', 1) |
|
| 75 | - and !defined('spip_interdire_cache') |
|
| 76 | - ) { # cas "LOST CONNECTION" |
|
| 77 | - $crash[] = $table; |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - #$crash[] = 'test'; |
|
| 82 | - if ($crash) { |
|
| 83 | - ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 84 | - spip_log('crash des tables', 'err'); |
|
| 85 | - spip_log($crash, 'err'); |
|
| 86 | - } else { |
|
| 87 | - effacer_meta('message_crash_tables'); |
|
| 88 | - } |
|
| 67 | + if (spip_connect()) { |
|
| 68 | + include_spip('base/serial'); |
|
| 69 | + include_spip('base/auxiliaires'); |
|
| 70 | + $crash = []; |
|
| 71 | + foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 72 | + foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 73 | + if ( |
|
| 74 | + !sql_select('*', $table, '', '', '', 1) |
|
| 75 | + and !defined('spip_interdire_cache') |
|
| 76 | + ) { # cas "LOST CONNECTION" |
|
| 77 | + $crash[] = $table; |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + #$crash[] = 'test'; |
|
| 82 | + if ($crash) { |
|
| 83 | + ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 84 | + spip_log('crash des tables', 'err'); |
|
| 85 | + spip_log($crash, 'err'); |
|
| 86 | + } else { |
|
| 87 | + effacer_meta('message_crash_tables'); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - return $crash; |
|
| 91 | - } |
|
| 90 | + return $crash; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return false; |
|
| 93 | + return false; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | * @return string |
| 107 | 107 | */ |
| 108 | 108 | function message_crash_tables() { |
| 109 | - if ($crash = verifier_crash_tables()) { |
|
| 110 | - return |
|
| 111 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 112 | - . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 113 | - . generer_form_ecrire( |
|
| 114 | - 'base_repair', |
|
| 115 | - _T('texte_crash_base'), |
|
| 116 | - '', |
|
| 117 | - _T('bouton_tenter_recuperation') |
|
| 118 | - ); |
|
| 119 | - } |
|
| 120 | - return ''; |
|
| 109 | + if ($crash = verifier_crash_tables()) { |
|
| 110 | + return |
|
| 111 | + '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 112 | + . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 113 | + . generer_form_ecrire( |
|
| 114 | + 'base_repair', |
|
| 115 | + _T('texte_crash_base'), |
|
| 116 | + '', |
|
| 117 | + _T('bouton_tenter_recuperation') |
|
| 118 | + ); |
|
| 119 | + } |
|
| 120 | + return ''; |
|
| 121 | 121 | } |
@@ -561,11 +561,9 @@ discard block |
||
| 561 | 561 | if (!isset($msg[$p])) { |
| 562 | 562 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 563 | 563 | $msg[$p] = [$resume['erreur']]; |
| 564 | - } |
|
| 565 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 564 | + } elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | 565 | $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
| 567 | - } |
|
| 568 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 566 | + } elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | 567 | $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
| 570 | 568 | } |
| 571 | 569 | } else { |
@@ -954,8 +952,7 @@ discard block |
||
| 954 | 952 | if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
| 955 | 953 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 956 | 954 | } |
| 957 | - } |
|
| 958 | - else { |
|
| 955 | + } else { |
|
| 959 | 956 | foreach ($info['chemin'] as $chemin) { |
| 960 | 957 | if ( |
| 961 | 958 | !isset($chemin['version']) or plugin_version_compatible( |
@@ -1425,8 +1422,7 @@ discard block |
||
| 1425 | 1422 | echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
| 1426 | 1423 | $trace, |
| 1427 | 1424 | "\n"; |
| 1428 | - } |
|
| 1429 | - else { |
|
| 1425 | + } else { |
|
| 1430 | 1426 | include_spip('inc/filtres_boites'); |
| 1431 | 1427 | echo "<div class='install-plugins svp_retour'>" |
| 1432 | 1428 | . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
@@ -1463,8 +1459,7 @@ discard block |
||
| 1463 | 1459 | if (file_exists($nom)) { |
| 1464 | 1460 | if (substr($nom, -4) == '.php') { |
| 1465 | 1461 | $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
| 1466 | - } |
|
| 1467 | - else { |
|
| 1462 | + } else { |
|
| 1468 | 1463 | $fichier_tmp = $nom . '.tmp'; |
| 1469 | 1464 | } |
| 1470 | 1465 | file_put_contents($fichier_tmp, $contenu); |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -47,27 +47,27 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | **/ |
| 49 | 49 | function liste_plugin_files($dir_plugins = null) { |
| 50 | - static $plugin_files = []; |
|
| 51 | - if (is_null($dir_plugins)) { |
|
| 52 | - $dir_plugins = _DIR_PLUGINS; |
|
| 53 | - } |
|
| 54 | - if ( |
|
| 55 | - !isset($plugin_files[$dir_plugins]) |
|
| 56 | - or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0 |
|
| 57 | - ) { |
|
| 58 | - $plugin_files[$dir_plugins] = []; |
|
| 59 | - foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | - $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - sort($plugin_files[$dir_plugins]); |
|
| 64 | - // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | - // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | - $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return $plugin_files[$dir_plugins]; |
|
| 50 | + static $plugin_files = []; |
|
| 51 | + if (is_null($dir_plugins)) { |
|
| 52 | + $dir_plugins = _DIR_PLUGINS; |
|
| 53 | + } |
|
| 54 | + if ( |
|
| 55 | + !isset($plugin_files[$dir_plugins]) |
|
| 56 | + or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0 |
|
| 57 | + ) { |
|
| 58 | + $plugin_files[$dir_plugins] = []; |
|
| 59 | + foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | + $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + sort($plugin_files[$dir_plugins]); |
|
| 64 | + // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | + // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | + $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return $plugin_files[$dir_plugins]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -83,45 +83,45 @@ discard block |
||
| 83 | 83 | * Liste complète des répeertoires |
| 84 | 84 | **/ |
| 85 | 85 | function fast_find_plugin_dirs($dir, $max_prof = 100) { |
| 86 | - $fichiers = []; |
|
| 87 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | - if ($dir == '') { |
|
| 91 | - $dir = '.'; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if (!is_dir($dir)) { |
|
| 95 | - return $fichiers; |
|
| 96 | - } |
|
| 97 | - if (is_plugin_dir($dir, '')) { |
|
| 98 | - $fichiers[] = $dir; |
|
| 99 | - |
|
| 100 | - return $fichiers; |
|
| 101 | - } |
|
| 102 | - if ($max_prof <= 0) { |
|
| 103 | - return $fichiers; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $subdirs = []; |
|
| 107 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | - while (($f = readdir($d)) !== false) { |
|
| 109 | - if ( |
|
| 110 | - $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | - and $f != 'CVS' |
|
| 112 | - and is_dir($f = "$dir/$f") |
|
| 113 | - ) { |
|
| 114 | - $subdirs[] = $f; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - closedir($d); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - foreach ($subdirs as $d) { |
|
| 121 | - $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $fichiers; |
|
| 86 | + $fichiers = []; |
|
| 87 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | + if ($dir == '') { |
|
| 91 | + $dir = '.'; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (!is_dir($dir)) { |
|
| 95 | + return $fichiers; |
|
| 96 | + } |
|
| 97 | + if (is_plugin_dir($dir, '')) { |
|
| 98 | + $fichiers[] = $dir; |
|
| 99 | + |
|
| 100 | + return $fichiers; |
|
| 101 | + } |
|
| 102 | + if ($max_prof <= 0) { |
|
| 103 | + return $fichiers; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $subdirs = []; |
|
| 107 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | + while (($f = readdir($d)) !== false) { |
|
| 109 | + if ( |
|
| 110 | + $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | + and $f != 'CVS' |
|
| 112 | + and is_dir($f = "$dir/$f") |
|
| 113 | + ) { |
|
| 114 | + $subdirs[] = $f; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + closedir($d); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + foreach ($subdirs as $d) { |
|
| 121 | + $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $fichiers; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,27 +142,27 @@ discard block |
||
| 142 | 142 | **/ |
| 143 | 143 | function is_plugin_dir($dir, $dir_plugins = null) { |
| 144 | 144 | |
| 145 | - if (is_array($dir)) { |
|
| 146 | - foreach ($dir as $k => $d) { |
|
| 147 | - if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | - unset($dir[$k]); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $dir; |
|
| 153 | - } |
|
| 154 | - if (is_null($dir_plugins)) { |
|
| 155 | - $dir_plugins = _DIR_PLUGINS; |
|
| 156 | - } |
|
| 157 | - $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | - |
|
| 159 | - foreach ($search as $s) { |
|
| 160 | - if (file_exists($s)) { |
|
| 161 | - return $dir; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return ''; |
|
| 145 | + if (is_array($dir)) { |
|
| 146 | + foreach ($dir as $k => $d) { |
|
| 147 | + if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | + unset($dir[$k]); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $dir; |
|
| 153 | + } |
|
| 154 | + if (is_null($dir_plugins)) { |
|
| 155 | + $dir_plugins = _DIR_PLUGINS; |
|
| 156 | + } |
|
| 157 | + $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | + |
|
| 159 | + foreach ($search as $s) { |
|
| 160 | + if (file_exists($s)) { |
|
| 161 | + return $dir; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return ''; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** Regexp d'extraction des informations d'un intervalle de compatibilité */ |
@@ -189,51 +189,51 @@ discard block |
||
| 189 | 189 | **/ |
| 190 | 190 | function plugin_version_compatible($intervalle, $version, $avec_quoi = '') { |
| 191 | 191 | |
| 192 | - if (!strlen($intervalle)) { |
|
| 193 | - return true; |
|
| 194 | - } |
|
| 195 | - if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | - return false; |
|
| 197 | - } |
|
| 198 | - // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | - // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | - $minimum = $regs[1]; |
|
| 201 | - $maximum = $regs[2]; |
|
| 202 | - |
|
| 203 | - // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | - // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | - // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | - // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | - // entre plugins) |
|
| 208 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | - if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | - return true; |
|
| 211 | - } |
|
| 212 | - // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | - // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $minimum_inc = $intervalle[0] == '['; |
|
| 217 | - $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | - |
|
| 219 | - if (strlen($minimum)) { |
|
| 220 | - if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | - return false; |
|
| 222 | - } |
|
| 223 | - if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | - return false; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - if (strlen($maximum)) { |
|
| 228 | - if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | - return false; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - return true; |
|
| 192 | + if (!strlen($intervalle)) { |
|
| 193 | + return true; |
|
| 194 | + } |
|
| 195 | + if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 198 | + // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | + // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | + $minimum = $regs[1]; |
|
| 201 | + $maximum = $regs[2]; |
|
| 202 | + |
|
| 203 | + // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | + // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | + // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | + // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | + // entre plugins) |
|
| 208 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | + if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | + return true; |
|
| 211 | + } |
|
| 212 | + // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | + // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $minimum_inc = $intervalle[0] == '['; |
|
| 217 | + $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | + |
|
| 219 | + if (strlen($minimum)) { |
|
| 220 | + if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | + return false; |
|
| 222 | + } |
|
| 223 | + if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | + return false; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + if (strlen($maximum)) { |
|
| 228 | + if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | + return false; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + return true; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -250,62 +250,62 @@ discard block |
||
| 250 | 250 | * @return array |
| 251 | 251 | */ |
| 252 | 252 | function liste_plugin_valides($liste_plug, $force = false) { |
| 253 | - $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | - $infos = [ |
|
| 256 | - // lister les extensions qui sont automatiquement actives |
|
| 257 | - '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | - '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | - ]; |
|
| 260 | - |
|
| 261 | - // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | - // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | - $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | - $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | - $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | - $liste_non_classee = [ |
|
| 267 | - 'SPIP' => [ |
|
| 268 | - 'nom' => 'SPIP', |
|
| 269 | - 'etat' => 'stable', |
|
| 270 | - 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | - 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | - 'dir' => '', |
|
| 273 | - ] |
|
| 274 | - ]; |
|
| 275 | - |
|
| 276 | - $invalides = []; |
|
| 277 | - foreach ($liste_ext as $plug) { |
|
| 278 | - if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - foreach ($liste_plug as $plug) { |
|
| 283 | - if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | - if (is_array($r)) { |
|
| 286 | - $invalides = array_merge($invalides, $r); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | - $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | - foreach ($liste_plug as $plug) { |
|
| 294 | - if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | - if (is_array($r)) { |
|
| 297 | - $invalides = array_merge($invalides, $r); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | - |
|
| 305 | - // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | - $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | - |
|
| 308 | - return [$infos, $liste_non_classee, $invalides]; |
|
| 253 | + $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | + $infos = [ |
|
| 256 | + // lister les extensions qui sont automatiquement actives |
|
| 257 | + '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | + '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | + ]; |
|
| 260 | + |
|
| 261 | + // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | + // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | + $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | + $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | + $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | + $liste_non_classee = [ |
|
| 267 | + 'SPIP' => [ |
|
| 268 | + 'nom' => 'SPIP', |
|
| 269 | + 'etat' => 'stable', |
|
| 270 | + 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | + 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | + 'dir' => '', |
|
| 273 | + ] |
|
| 274 | + ]; |
|
| 275 | + |
|
| 276 | + $invalides = []; |
|
| 277 | + foreach ($liste_ext as $plug) { |
|
| 278 | + if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + foreach ($liste_plug as $plug) { |
|
| 283 | + if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | + if (is_array($r)) { |
|
| 286 | + $invalides = array_merge($invalides, $r); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | + $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | + foreach ($liste_plug as $plug) { |
|
| 294 | + if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | + if (is_array($r)) { |
|
| 297 | + $invalides = array_merge($invalides, $r); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | + |
|
| 305 | + // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | + $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | + |
|
| 308 | + return [$infos, $liste_non_classee, $invalides]; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -325,38 +325,38 @@ discard block |
||
| 325 | 325 | * array description short si on ne le retient pas (pour memorisation dans une table des erreurs) |
| 326 | 326 | */ |
| 327 | 327 | function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) { |
| 328 | - $i = $infos[$dir_type][$plug]; |
|
| 329 | - // minimum syndical pour afficher si le xml avait des erreurs éventuelles |
|
| 330 | - $short_desc = [ |
|
| 331 | - 'dir' => $plug, |
|
| 332 | - 'dir_type' => $dir_type |
|
| 333 | - ]; |
|
| 334 | - if (empty($i['prefix'])) { |
|
| 335 | - // erreur xml ? mais sans connaissance du prefix, on retourne le chemin… |
|
| 336 | - $short_desc['erreur'] = $i['erreur'] ?? ['?']; |
|
| 337 | - return [$plug => $short_desc]; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - $p = strtoupper($i['prefix']); |
|
| 341 | - $short_desc['nom'] = $i['nom']; |
|
| 342 | - $short_desc['etat'] = $i['etat']; |
|
| 343 | - $short_desc['version'] = $i['version']; |
|
| 344 | - |
|
| 345 | - if (isset($i['erreur']) and $i['erreur']) { |
|
| 346 | - $short_desc['erreur'] = $i['erreur']; |
|
| 347 | - return [$p => $short_desc]; |
|
| 348 | - } |
|
| 349 | - if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 350 | - return [$p => $short_desc]; |
|
| 351 | - } |
|
| 352 | - if ( |
|
| 353 | - !isset($liste[$p]) |
|
| 354 | - or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 355 | - ) { |
|
| 356 | - $liste[$p] = $short_desc; |
|
| 357 | - } |
|
| 358 | - // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 359 | - return $p; |
|
| 328 | + $i = $infos[$dir_type][$plug]; |
|
| 329 | + // minimum syndical pour afficher si le xml avait des erreurs éventuelles |
|
| 330 | + $short_desc = [ |
|
| 331 | + 'dir' => $plug, |
|
| 332 | + 'dir_type' => $dir_type |
|
| 333 | + ]; |
|
| 334 | + if (empty($i['prefix'])) { |
|
| 335 | + // erreur xml ? mais sans connaissance du prefix, on retourne le chemin… |
|
| 336 | + $short_desc['erreur'] = $i['erreur'] ?? ['?']; |
|
| 337 | + return [$plug => $short_desc]; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + $p = strtoupper($i['prefix']); |
|
| 341 | + $short_desc['nom'] = $i['nom']; |
|
| 342 | + $short_desc['etat'] = $i['etat']; |
|
| 343 | + $short_desc['version'] = $i['version']; |
|
| 344 | + |
|
| 345 | + if (isset($i['erreur']) and $i['erreur']) { |
|
| 346 | + $short_desc['erreur'] = $i['erreur']; |
|
| 347 | + return [$p => $short_desc]; |
|
| 348 | + } |
|
| 349 | + if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 350 | + return [$p => $short_desc]; |
|
| 351 | + } |
|
| 352 | + if ( |
|
| 353 | + !isset($liste[$p]) |
|
| 354 | + or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 355 | + ) { |
|
| 356 | + $liste[$p] = $short_desc; |
|
| 357 | + } |
|
| 358 | + // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 359 | + return $p; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -372,47 +372,47 @@ discard block |
||
| 372 | 372 | * @param array $infos |
| 373 | 373 | */ |
| 374 | 374 | function plugin_fixer_procure(&$liste, &$infos) { |
| 375 | - foreach ($liste as $p => $resume) { |
|
| 376 | - $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 377 | - if (isset($i['procure']) and $i['procure']) { |
|
| 378 | - foreach ($i['procure'] as $procure) { |
|
| 379 | - $p = strtoupper($procure['nom']); |
|
| 380 | - $dir = $resume['dir']; |
|
| 381 | - if ($dir) { |
|
| 382 | - $dir .= '/'; |
|
| 383 | - } |
|
| 384 | - $dir .= 'procure:' . $procure['nom']; |
|
| 385 | - |
|
| 386 | - $procure['etat'] = '?'; |
|
| 387 | - $procure['dir_type'] = $resume['dir_type']; |
|
| 388 | - $procure['dir'] = $dir; |
|
| 389 | - |
|
| 390 | - // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 391 | - // on ajoute cette version a la liste |
|
| 392 | - if ( |
|
| 393 | - !isset($liste[$p]) |
|
| 394 | - or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 395 | - ) { |
|
| 396 | - $liste[$p] = $procure; |
|
| 397 | - |
|
| 398 | - // on fournit une information minimale pour ne pas perturber la compilation |
|
| 399 | - $infos[$resume['dir_type']][$dir] = [ |
|
| 400 | - 'prefix' => $procure['nom'], |
|
| 401 | - 'nom' => $procure['nom'], |
|
| 402 | - 'etat' => $procure['etat'], |
|
| 403 | - 'version' => $procure['version'], |
|
| 404 | - 'chemin' => [], |
|
| 405 | - 'necessite' => [], |
|
| 406 | - 'utilise' => [], |
|
| 407 | - 'lib' => [], |
|
| 408 | - 'menu' => [], |
|
| 409 | - 'onglet' => [], |
|
| 410 | - 'procure' => [], |
|
| 411 | - ]; |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - } |
|
| 375 | + foreach ($liste as $p => $resume) { |
|
| 376 | + $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 377 | + if (isset($i['procure']) and $i['procure']) { |
|
| 378 | + foreach ($i['procure'] as $procure) { |
|
| 379 | + $p = strtoupper($procure['nom']); |
|
| 380 | + $dir = $resume['dir']; |
|
| 381 | + if ($dir) { |
|
| 382 | + $dir .= '/'; |
|
| 383 | + } |
|
| 384 | + $dir .= 'procure:' . $procure['nom']; |
|
| 385 | + |
|
| 386 | + $procure['etat'] = '?'; |
|
| 387 | + $procure['dir_type'] = $resume['dir_type']; |
|
| 388 | + $procure['dir'] = $dir; |
|
| 389 | + |
|
| 390 | + // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 391 | + // on ajoute cette version a la liste |
|
| 392 | + if ( |
|
| 393 | + !isset($liste[$p]) |
|
| 394 | + or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 395 | + ) { |
|
| 396 | + $liste[$p] = $procure; |
|
| 397 | + |
|
| 398 | + // on fournit une information minimale pour ne pas perturber la compilation |
|
| 399 | + $infos[$resume['dir_type']][$dir] = [ |
|
| 400 | + 'prefix' => $procure['nom'], |
|
| 401 | + 'nom' => $procure['nom'], |
|
| 402 | + 'etat' => $procure['etat'], |
|
| 403 | + 'version' => $procure['version'], |
|
| 404 | + 'chemin' => [], |
|
| 405 | + 'necessite' => [], |
|
| 406 | + 'utilise' => [], |
|
| 407 | + 'lib' => [], |
|
| 408 | + 'menu' => [], |
|
| 409 | + 'onglet' => [], |
|
| 410 | + 'procure' => [], |
|
| 411 | + ]; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -426,20 +426,20 @@ discard block |
||
| 426 | 426 | * @return array |
| 427 | 427 | */ |
| 428 | 428 | function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) { |
| 429 | - foreach ($liste as $prefix => $infos) { |
|
| 430 | - if ( |
|
| 431 | - !$dir_plugins |
|
| 432 | - or ( |
|
| 433 | - defined($infos['dir_type']) |
|
| 434 | - and constant($infos['dir_type']) == $dir_plugins) |
|
| 435 | - ) { |
|
| 436 | - $liste[$prefix] = $infos['dir']; |
|
| 437 | - } else { |
|
| 438 | - unset($liste[$prefix]); |
|
| 439 | - } |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - return $liste; |
|
| 429 | + foreach ($liste as $prefix => $infos) { |
|
| 430 | + if ( |
|
| 431 | + !$dir_plugins |
|
| 432 | + or ( |
|
| 433 | + defined($infos['dir_type']) |
|
| 434 | + and constant($infos['dir_type']) == $dir_plugins) |
|
| 435 | + ) { |
|
| 436 | + $liste[$prefix] = $infos['dir']; |
|
| 437 | + } else { |
|
| 438 | + unset($liste[$prefix]); |
|
| 439 | + } |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return $liste; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -454,9 +454,9 @@ discard block |
||
| 454 | 454 | * @return array |
| 455 | 455 | */ |
| 456 | 456 | function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) { |
| 457 | - include_spip('plugins/installer'); |
|
| 457 | + include_spip('plugins/installer'); |
|
| 458 | 458 | |
| 459 | - return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 459 | + return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
@@ -487,54 +487,54 @@ discard block |
||
| 487 | 487 | * qui n'ont pas satisfait leurs dépendances |
| 488 | 488 | **/ |
| 489 | 489 | function plugin_trier($infos, $liste_non_classee) { |
| 490 | - $toute_la_liste = $liste_non_classee; |
|
| 491 | - $liste = $ordre = []; |
|
| 492 | - $count = 0; |
|
| 493 | - |
|
| 494 | - while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 495 | - #echo "tour::";var_dump($liste_non_classee); |
|
| 496 | - $count = $c; |
|
| 497 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 498 | - $plug = $resume['dir']; |
|
| 499 | - $dir_type = $resume['dir_type']; |
|
| 500 | - $info1 = $infos[$dir_type][$plug]; |
|
| 501 | - // si des plugins sont necessaires, |
|
| 502 | - // on ne peut inserer qu'apres eux |
|
| 503 | - foreach ($info1['necessite'] as $need) { |
|
| 504 | - $nom = strtoupper($need['nom']); |
|
| 505 | - $compat = $need['compatibilite'] ?? ''; |
|
| 506 | - if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 507 | - $info1 = false; |
|
| 508 | - break; |
|
| 509 | - } |
|
| 510 | - } |
|
| 511 | - if (!$info1) { |
|
| 512 | - continue; |
|
| 513 | - } |
|
| 514 | - // idem si des plugins sont utiles, |
|
| 515 | - // sauf si ils sont de toute facon absents de la liste |
|
| 516 | - foreach ($info1['utilise'] as $need) { |
|
| 517 | - $nom = strtoupper($need['nom']); |
|
| 518 | - $compat = $need['compatibilite'] ?? ''; |
|
| 519 | - if (isset($toute_la_liste[$nom])) { |
|
| 520 | - if ( |
|
| 521 | - !isset($liste[$nom]) or |
|
| 522 | - !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 523 | - ) { |
|
| 524 | - $info1 = false; |
|
| 525 | - break; |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - } |
|
| 529 | - if ($info1) { |
|
| 530 | - $ordre[$p] = $info1; |
|
| 531 | - $liste[$p] = $liste_non_classee[$p]; |
|
| 532 | - unset($liste_non_classee[$p]); |
|
| 533 | - } |
|
| 534 | - } |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - return [$liste, $ordre, $liste_non_classee]; |
|
| 490 | + $toute_la_liste = $liste_non_classee; |
|
| 491 | + $liste = $ordre = []; |
|
| 492 | + $count = 0; |
|
| 493 | + |
|
| 494 | + while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 495 | + #echo "tour::";var_dump($liste_non_classee); |
|
| 496 | + $count = $c; |
|
| 497 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 498 | + $plug = $resume['dir']; |
|
| 499 | + $dir_type = $resume['dir_type']; |
|
| 500 | + $info1 = $infos[$dir_type][$plug]; |
|
| 501 | + // si des plugins sont necessaires, |
|
| 502 | + // on ne peut inserer qu'apres eux |
|
| 503 | + foreach ($info1['necessite'] as $need) { |
|
| 504 | + $nom = strtoupper($need['nom']); |
|
| 505 | + $compat = $need['compatibilite'] ?? ''; |
|
| 506 | + if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 507 | + $info1 = false; |
|
| 508 | + break; |
|
| 509 | + } |
|
| 510 | + } |
|
| 511 | + if (!$info1) { |
|
| 512 | + continue; |
|
| 513 | + } |
|
| 514 | + // idem si des plugins sont utiles, |
|
| 515 | + // sauf si ils sont de toute facon absents de la liste |
|
| 516 | + foreach ($info1['utilise'] as $need) { |
|
| 517 | + $nom = strtoupper($need['nom']); |
|
| 518 | + $compat = $need['compatibilite'] ?? ''; |
|
| 519 | + if (isset($toute_la_liste[$nom])) { |
|
| 520 | + if ( |
|
| 521 | + !isset($liste[$nom]) or |
|
| 522 | + !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 523 | + ) { |
|
| 524 | + $info1 = false; |
|
| 525 | + break; |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | + if ($info1) { |
|
| 530 | + $ordre[$p] = $info1; |
|
| 531 | + $liste[$p] = $liste_non_classee[$p]; |
|
| 532 | + unset($liste_non_classee[$p]); |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + return [$liste, $ordre, $liste_non_classee]; |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /** |
@@ -551,40 +551,40 @@ discard block |
||
| 551 | 551 | * Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent |
| 552 | 552 | **/ |
| 553 | 553 | function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = []) { |
| 554 | - static $erreurs = []; |
|
| 555 | - |
|
| 556 | - if (!is_array($liste)) { |
|
| 557 | - $liste = []; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 561 | - $liste = array_diff_key($liste, $liste_non_classee); |
|
| 562 | - |
|
| 563 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 564 | - $dir_type = $resume['dir_type']; |
|
| 565 | - $plug = $resume['dir']; |
|
| 566 | - $k = $infos[$dir_type][$plug]; |
|
| 567 | - |
|
| 568 | - $plug = constant($dir_type) . $plug; |
|
| 569 | - if (!isset($msg[$p])) { |
|
| 570 | - if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 571 | - $msg[$p] = [$resume['erreur']]; |
|
| 572 | - } |
|
| 573 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 574 | - $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 575 | - } |
|
| 576 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 577 | - $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 578 | - } |
|
| 579 | - } else { |
|
| 580 | - foreach ($msg[$p] as $c => $l) { |
|
| 581 | - $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - $erreurs[$plug] = $msg[$p]; |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 554 | + static $erreurs = []; |
|
| 555 | + |
|
| 556 | + if (!is_array($liste)) { |
|
| 557 | + $liste = []; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 561 | + $liste = array_diff_key($liste, $liste_non_classee); |
|
| 562 | + |
|
| 563 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 564 | + $dir_type = $resume['dir_type']; |
|
| 565 | + $plug = $resume['dir']; |
|
| 566 | + $k = $infos[$dir_type][$plug]; |
|
| 567 | + |
|
| 568 | + $plug = constant($dir_type) . $plug; |
|
| 569 | + if (!isset($msg[$p])) { |
|
| 570 | + if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 571 | + $msg[$p] = [$resume['erreur']]; |
|
| 572 | + } |
|
| 573 | + elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 574 | + $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 575 | + } |
|
| 576 | + elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 577 | + $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 578 | + } |
|
| 579 | + } else { |
|
| 580 | + foreach ($msg[$p] as $c => $l) { |
|
| 581 | + $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + $erreurs[$plug] = $msg[$p]; |
|
| 585 | + } |
|
| 586 | + |
|
| 587 | + ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
@@ -599,25 +599,25 @@ discard block |
||
| 599 | 599 | * - Liste des erreurs ou code HTML des erreurs |
| 600 | 600 | **/ |
| 601 | 601 | function plugin_donne_erreurs($raw = false, $raz = true) { |
| 602 | - if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 603 | - return $raw ? [] : ''; |
|
| 604 | - } |
|
| 605 | - $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 606 | - // Compat ancienne version |
|
| 607 | - if (!$list) { |
|
| 608 | - $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 609 | - } elseif (!$raw) { |
|
| 610 | - foreach ($list as $plug => $msg) { |
|
| 611 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 613 | - } |
|
| 614 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 615 | - } |
|
| 616 | - if ($raz) { |
|
| 617 | - effacer_meta('plugin_erreur_activation'); |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - return $list; |
|
| 602 | + if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 603 | + return $raw ? [] : ''; |
|
| 604 | + } |
|
| 605 | + $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 606 | + // Compat ancienne version |
|
| 607 | + if (!$list) { |
|
| 608 | + $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 609 | + } elseif (!$raw) { |
|
| 610 | + foreach ($list as $plug => $msg) { |
|
| 611 | + $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | + . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 613 | + } |
|
| 614 | + $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 615 | + } |
|
| 616 | + if ($raz) { |
|
| 617 | + effacer_meta('plugin_erreur_activation'); |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + return $list; |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -637,21 +637,21 @@ discard block |
||
| 637 | 637 | * |
| 638 | 638 | **/ |
| 639 | 639 | function plugin_necessite($n, $liste, $balise = 'necessite') { |
| 640 | - $msg = []; |
|
| 641 | - foreach ($n as $need) { |
|
| 642 | - $id = strtoupper($need['nom']); |
|
| 643 | - $r = plugin_controler_necessite( |
|
| 644 | - $liste, |
|
| 645 | - $id, |
|
| 646 | - $need['compatibilite'] ?? '', |
|
| 647 | - $balise |
|
| 648 | - ); |
|
| 649 | - if ($r) { |
|
| 650 | - $msg[] = $r; |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - return $msg; |
|
| 640 | + $msg = []; |
|
| 641 | + foreach ($n as $need) { |
|
| 642 | + $id = strtoupper($need['nom']); |
|
| 643 | + $r = plugin_controler_necessite( |
|
| 644 | + $liste, |
|
| 645 | + $id, |
|
| 646 | + $need['compatibilite'] ?? '', |
|
| 647 | + $balise |
|
| 648 | + ); |
|
| 649 | + if ($r) { |
|
| 650 | + $msg[] = $r; |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + return $msg; |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
@@ -673,19 +673,19 @@ discard block |
||
| 673 | 673 | * Message d'erreur lorsque la dépendance est absente. |
| 674 | 674 | **/ |
| 675 | 675 | function plugin_controler_necessite($liste, $nom, $intervalle, $balise) { |
| 676 | - if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 677 | - return ''; |
|
| 678 | - } |
|
| 679 | - // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 680 | - if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 681 | - return ''; |
|
| 682 | - } |
|
| 683 | - return plugin_message_incompatibilite( |
|
| 684 | - $intervalle, |
|
| 685 | - (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 686 | - $nom, |
|
| 687 | - $balise |
|
| 688 | - ); |
|
| 676 | + if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 677 | + return ''; |
|
| 678 | + } |
|
| 679 | + // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 680 | + if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 681 | + return ''; |
|
| 682 | + } |
|
| 683 | + return plugin_message_incompatibilite( |
|
| 684 | + $intervalle, |
|
| 685 | + (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 686 | + $nom, |
|
| 687 | + $balise |
|
| 688 | + ); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -702,70 +702,70 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) { |
| 704 | 704 | |
| 705 | - // prendre en compte les erreurs de dépendances à PHP |
|
| 706 | - // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 707 | - $type = 'plugin'; |
|
| 708 | - if ($nom === 'SPIP') { |
|
| 709 | - $type = 'spip'; |
|
| 710 | - } elseif ($nom === 'PHP') { |
|
| 711 | - $type = 'php'; |
|
| 712 | - } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 713 | - $type = 'extension_php'; |
|
| 714 | - [, $nom] = explode(':', $nom, 2); |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 718 | - $minimum = $regs[1]; |
|
| 719 | - $maximum = $regs[2]; |
|
| 720 | - |
|
| 721 | - $minimum_inclus = $intervalle[0] == '['; |
|
| 722 | - $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 723 | - |
|
| 724 | - if (strlen($minimum)) { |
|
| 725 | - if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 726 | - return _T("plugin_{$balise}_{$type}", [ |
|
| 727 | - 'plugin' => $nom, |
|
| 728 | - 'version' => ' ≥ ' . $minimum |
|
| 729 | - ]); |
|
| 730 | - } |
|
| 731 | - if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 732 | - return _T("plugin_{$balise}_{$type}", [ |
|
| 733 | - 'plugin' => $nom, |
|
| 734 | - 'version' => ' > ' . $minimum |
|
| 735 | - ]); |
|
| 736 | - } |
|
| 737 | - } |
|
| 738 | - |
|
| 739 | - if (strlen($maximum)) { |
|
| 740 | - if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 741 | - return _T("plugin_{$balise}_{$type}", [ |
|
| 742 | - 'plugin' => $nom, |
|
| 743 | - 'version' => ' ≤ ' . $maximum |
|
| 744 | - ]); |
|
| 745 | - } |
|
| 746 | - if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 747 | - return _T("plugin_{$balise}_plugin", [ |
|
| 748 | - 'plugin' => $nom, |
|
| 749 | - 'version' => ' < ' . $maximum |
|
| 750 | - ]); |
|
| 751 | - } |
|
| 752 | - } |
|
| 753 | - } |
|
| 754 | - |
|
| 755 | - // note : il ne peut pas y avoir d'erreur sur |
|
| 756 | - // - un 'utilise' sans version. |
|
| 757 | - // - un 'php' sans version. |
|
| 758 | - return _T("plugin_necessite_{$type}_sans_version", ['plugin' => $nom]); |
|
| 705 | + // prendre en compte les erreurs de dépendances à PHP |
|
| 706 | + // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 707 | + $type = 'plugin'; |
|
| 708 | + if ($nom === 'SPIP') { |
|
| 709 | + $type = 'spip'; |
|
| 710 | + } elseif ($nom === 'PHP') { |
|
| 711 | + $type = 'php'; |
|
| 712 | + } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 713 | + $type = 'extension_php'; |
|
| 714 | + [, $nom] = explode(':', $nom, 2); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 718 | + $minimum = $regs[1]; |
|
| 719 | + $maximum = $regs[2]; |
|
| 720 | + |
|
| 721 | + $minimum_inclus = $intervalle[0] == '['; |
|
| 722 | + $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 723 | + |
|
| 724 | + if (strlen($minimum)) { |
|
| 725 | + if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 726 | + return _T("plugin_{$balise}_{$type}", [ |
|
| 727 | + 'plugin' => $nom, |
|
| 728 | + 'version' => ' ≥ ' . $minimum |
|
| 729 | + ]); |
|
| 730 | + } |
|
| 731 | + if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 732 | + return _T("plugin_{$balise}_{$type}", [ |
|
| 733 | + 'plugin' => $nom, |
|
| 734 | + 'version' => ' > ' . $minimum |
|
| 735 | + ]); |
|
| 736 | + } |
|
| 737 | + } |
|
| 738 | + |
|
| 739 | + if (strlen($maximum)) { |
|
| 740 | + if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 741 | + return _T("plugin_{$balise}_{$type}", [ |
|
| 742 | + 'plugin' => $nom, |
|
| 743 | + 'version' => ' ≤ ' . $maximum |
|
| 744 | + ]); |
|
| 745 | + } |
|
| 746 | + if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 747 | + return _T("plugin_{$balise}_plugin", [ |
|
| 748 | + 'plugin' => $nom, |
|
| 749 | + 'version' => ' < ' . $maximum |
|
| 750 | + ]); |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + // note : il ne peut pas y avoir d'erreur sur |
|
| 756 | + // - un 'utilise' sans version. |
|
| 757 | + // - un 'php' sans version. |
|
| 758 | + return _T("plugin_necessite_{$type}_sans_version", ['plugin' => $nom]); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | |
| 762 | 762 | function plugin_controler_lib($lib, $url) { |
| 763 | - /* Feature sortie du core, voir STP |
|
| 763 | + /* Feature sortie du core, voir STP |
|
| 764 | 764 | * if ($url) { |
| 765 | 765 | include_spip('inc/charger_plugin'); |
| 766 | 766 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 767 | 767 | }*/ |
| 768 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 768 | + return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * true si il y a eu des modifications sur la liste des plugins actifs, false sinon |
| 781 | 781 | **/ |
| 782 | 782 | function actualise_plugins_actifs($pipe_recherche = false) { |
| 783 | - return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 783 | + return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | |
@@ -807,116 +807,116 @@ discard block |
||
| 807 | 807 | **/ |
| 808 | 808 | function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') { |
| 809 | 809 | |
| 810 | - // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 811 | - $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 812 | - |
|
| 813 | - // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 814 | - if (!$cache and !spip_connect()) { |
|
| 815 | - return false; |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - if ($operation != 'raz') { |
|
| 819 | - $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 820 | - $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 821 | - if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 822 | - $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 823 | - $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 824 | - $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 825 | - } |
|
| 826 | - // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 827 | - // on les reinjecte ici |
|
| 828 | - if ( |
|
| 829 | - isset($GLOBALS['meta']['plugin_attente']) |
|
| 830 | - and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 831 | - ) { |
|
| 832 | - $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - if ($operation == 'ajoute') { |
|
| 836 | - $plugin = array_merge($plugin_valides, $plugin); |
|
| 837 | - } elseif ($operation == 'enleve') { |
|
| 838 | - $plugin = array_diff($plugin_valides, $plugin); |
|
| 839 | - } else { |
|
| 840 | - $plugin = $plugin_valides; |
|
| 841 | - } |
|
| 842 | - } |
|
| 843 | - $actifs_avant = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 844 | - |
|
| 845 | - // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 846 | - if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 847 | - $plugin = $ajouter_dependances($plugin); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - // recharger le xml des plugins a activer |
|
| 851 | - // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 852 | - // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 853 | - // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 854 | - // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 855 | - [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true); |
|
| 856 | - // trouver l'ordre d'activation |
|
| 857 | - [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste); |
|
| 858 | - if ($invalides or $reste) { |
|
| 859 | - plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 860 | - } |
|
| 861 | - |
|
| 862 | - // Ignorer les plugins necessitant une lib absente |
|
| 863 | - // et preparer la meta d'entete Http |
|
| 864 | - $err = $msg = $header = []; |
|
| 865 | - foreach ($plugin_valides as $p => $resume) { |
|
| 866 | - // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 867 | - if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') { |
|
| 868 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 869 | - } |
|
| 870 | - if ($resume['dir']) { |
|
| 871 | - foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 872 | - if (!find_in_path($l['nom'], 'lib/')) { |
|
| 873 | - $err[$p] = $resume; |
|
| 874 | - $msg[$p][] = $l; |
|
| 875 | - unset($plugin_valides[$p]); |
|
| 876 | - } |
|
| 877 | - } |
|
| 878 | - } |
|
| 879 | - } |
|
| 880 | - if ($err) { |
|
| 881 | - plugins_erreurs($err, '', $infos, $msg); |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 885 | - effacer_meta('message_crash_plugins'); |
|
| 886 | - } |
|
| 887 | - ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 888 | - $liste = array_diff_key($liste, $plugin_valides); |
|
| 889 | - ecrire_meta('plugin_attente', serialize($liste)); |
|
| 890 | - $header = strtolower(implode(',', $header)); |
|
| 891 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 892 | - ecrire_fichier( |
|
| 893 | - _DIR_VAR . 'config.txt', |
|
| 894 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 895 | - ); |
|
| 896 | - } else { |
|
| 897 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 898 | - } |
|
| 899 | - // generer charger_plugins_chemin.php |
|
| 900 | - plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 901 | - // generer les fichiers |
|
| 902 | - // - charger_plugins_options.php |
|
| 903 | - // - charger_plugins_fonctions.php |
|
| 904 | - plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 905 | - // charger les chemins des plugins et les fichiers d'options |
|
| 906 | - // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 907 | - plugins_amorcer_plugins_actifs(); |
|
| 908 | - // mise a jour de la matrice des pipelines |
|
| 909 | - $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 910 | - // generer le fichier _CACHE_PIPELINE |
|
| 911 | - pipeline_precompile($prepend_code); |
|
| 912 | - |
|
| 913 | - if (spip_connect()) { |
|
| 914 | - // lancer et initialiser les nouveaux crons ! |
|
| 915 | - include_spip('inc/genie'); |
|
| 916 | - genie_queue_watch_dist(); |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 810 | + // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 811 | + $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 812 | + |
|
| 813 | + // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 814 | + if (!$cache and !spip_connect()) { |
|
| 815 | + return false; |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + if ($operation != 'raz') { |
|
| 819 | + $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 820 | + $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 821 | + if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 822 | + $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 823 | + $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 824 | + $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 825 | + } |
|
| 826 | + // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 827 | + // on les reinjecte ici |
|
| 828 | + if ( |
|
| 829 | + isset($GLOBALS['meta']['plugin_attente']) |
|
| 830 | + and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 831 | + ) { |
|
| 832 | + $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + if ($operation == 'ajoute') { |
|
| 836 | + $plugin = array_merge($plugin_valides, $plugin); |
|
| 837 | + } elseif ($operation == 'enleve') { |
|
| 838 | + $plugin = array_diff($plugin_valides, $plugin); |
|
| 839 | + } else { |
|
| 840 | + $plugin = $plugin_valides; |
|
| 841 | + } |
|
| 842 | + } |
|
| 843 | + $actifs_avant = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 844 | + |
|
| 845 | + // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 846 | + if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 847 | + $plugin = $ajouter_dependances($plugin); |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + // recharger le xml des plugins a activer |
|
| 851 | + // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 852 | + // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 853 | + // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 854 | + // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 855 | + [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true); |
|
| 856 | + // trouver l'ordre d'activation |
|
| 857 | + [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste); |
|
| 858 | + if ($invalides or $reste) { |
|
| 859 | + plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + // Ignorer les plugins necessitant une lib absente |
|
| 863 | + // et preparer la meta d'entete Http |
|
| 864 | + $err = $msg = $header = []; |
|
| 865 | + foreach ($plugin_valides as $p => $resume) { |
|
| 866 | + // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 867 | + if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') { |
|
| 868 | + $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 869 | + } |
|
| 870 | + if ($resume['dir']) { |
|
| 871 | + foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 872 | + if (!find_in_path($l['nom'], 'lib/')) { |
|
| 873 | + $err[$p] = $resume; |
|
| 874 | + $msg[$p][] = $l; |
|
| 875 | + unset($plugin_valides[$p]); |
|
| 876 | + } |
|
| 877 | + } |
|
| 878 | + } |
|
| 879 | + } |
|
| 880 | + if ($err) { |
|
| 881 | + plugins_erreurs($err, '', $infos, $msg); |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 885 | + effacer_meta('message_crash_plugins'); |
|
| 886 | + } |
|
| 887 | + ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 888 | + $liste = array_diff_key($liste, $plugin_valides); |
|
| 889 | + ecrire_meta('plugin_attente', serialize($liste)); |
|
| 890 | + $header = strtolower(implode(',', $header)); |
|
| 891 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 892 | + ecrire_fichier( |
|
| 893 | + _DIR_VAR . 'config.txt', |
|
| 894 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 895 | + ); |
|
| 896 | + } else { |
|
| 897 | + @unlink(_DIR_VAR . 'config.txt'); |
|
| 898 | + } |
|
| 899 | + // generer charger_plugins_chemin.php |
|
| 900 | + plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 901 | + // generer les fichiers |
|
| 902 | + // - charger_plugins_options.php |
|
| 903 | + // - charger_plugins_fonctions.php |
|
| 904 | + plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 905 | + // charger les chemins des plugins et les fichiers d'options |
|
| 906 | + // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 907 | + plugins_amorcer_plugins_actifs(); |
|
| 908 | + // mise a jour de la matrice des pipelines |
|
| 909 | + $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 910 | + // generer le fichier _CACHE_PIPELINE |
|
| 911 | + pipeline_precompile($prepend_code); |
|
| 912 | + |
|
| 913 | + if (spip_connect()) { |
|
| 914 | + // lancer et initialiser les nouveaux crons ! |
|
| 915 | + include_spip('inc/genie'); |
|
| 916 | + genie_queue_watch_dist(); |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | /** |
@@ -935,74 +935,74 @@ discard block |
||
| 935 | 935 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 936 | 936 | **/ |
| 937 | 937 | function plugins_precompile_chemin($plugin_valides, $ordre) { |
| 938 | - $chemins = [ |
|
| 939 | - 'public' => [], |
|
| 940 | - 'prive' => [] |
|
| 941 | - ]; |
|
| 942 | - $contenu = ''; |
|
| 943 | - foreach ($ordre as $p => $info) { |
|
| 944 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 945 | - if (isset($plugin_valides[$p])) { |
|
| 946 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 947 | - $plug = $plugin_valides[$p]['dir']; |
|
| 948 | - // definir le plugin, donc le path avant l'include du fichier options |
|
| 949 | - // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 950 | - |
|
| 951 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 952 | - |
|
| 953 | - $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 954 | - if ( |
|
| 955 | - $prefix !== 'SPIP' |
|
| 956 | - and !str_contains($dir, ':') // exclure le cas des procure: |
|
| 957 | - ) { |
|
| 958 | - $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 959 | - if (!$info['chemin']) { |
|
| 960 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 961 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 962 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 963 | - $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 964 | - } |
|
| 965 | - } |
|
| 966 | - else { |
|
| 967 | - foreach ($info['chemin'] as $chemin) { |
|
| 968 | - if ( |
|
| 969 | - !isset($chemin['version']) or plugin_version_compatible( |
|
| 970 | - $chemin['version'], |
|
| 971 | - $GLOBALS['spip_version_branche'], |
|
| 972 | - 'spip' |
|
| 973 | - ) |
|
| 974 | - ) { |
|
| 975 | - $dir = $chemin['path']; |
|
| 976 | - if (strlen($dir) and $dir[0] == '/') { |
|
| 977 | - $dir = substr($dir, 1); |
|
| 978 | - } |
|
| 979 | - if (strlen($dir) and $dir == './') { |
|
| 980 | - $dir = ''; |
|
| 981 | - } |
|
| 982 | - if (strlen($dir)) { |
|
| 983 | - $dir = rtrim($dir, '/') . '/'; |
|
| 984 | - } |
|
| 985 | - if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 986 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 987 | - } |
|
| 988 | - if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 989 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 990 | - } |
|
| 991 | - } |
|
| 992 | - } |
|
| 993 | - } |
|
| 994 | - } |
|
| 995 | - } |
|
| 996 | - } |
|
| 997 | - if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 998 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 999 | - ',', |
|
| 1000 | - array_reverse($chemins['public']) |
|
| 1001 | - ) . "]);\n" |
|
| 1002 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 1003 | - } |
|
| 1004 | - |
|
| 1005 | - ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 938 | + $chemins = [ |
|
| 939 | + 'public' => [], |
|
| 940 | + 'prive' => [] |
|
| 941 | + ]; |
|
| 942 | + $contenu = ''; |
|
| 943 | + foreach ($ordre as $p => $info) { |
|
| 944 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 945 | + if (isset($plugin_valides[$p])) { |
|
| 946 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 947 | + $plug = $plugin_valides[$p]['dir']; |
|
| 948 | + // definir le plugin, donc le path avant l'include du fichier options |
|
| 949 | + // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 950 | + |
|
| 951 | + $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 952 | + |
|
| 953 | + $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 954 | + if ( |
|
| 955 | + $prefix !== 'SPIP' |
|
| 956 | + and !str_contains($dir, ':') // exclure le cas des procure: |
|
| 957 | + ) { |
|
| 958 | + $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 959 | + if (!$info['chemin']) { |
|
| 960 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 961 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 962 | + if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 963 | + $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 964 | + } |
|
| 965 | + } |
|
| 966 | + else { |
|
| 967 | + foreach ($info['chemin'] as $chemin) { |
|
| 968 | + if ( |
|
| 969 | + !isset($chemin['version']) or plugin_version_compatible( |
|
| 970 | + $chemin['version'], |
|
| 971 | + $GLOBALS['spip_version_branche'], |
|
| 972 | + 'spip' |
|
| 973 | + ) |
|
| 974 | + ) { |
|
| 975 | + $dir = $chemin['path']; |
|
| 976 | + if (strlen($dir) and $dir[0] == '/') { |
|
| 977 | + $dir = substr($dir, 1); |
|
| 978 | + } |
|
| 979 | + if (strlen($dir) and $dir == './') { |
|
| 980 | + $dir = ''; |
|
| 981 | + } |
|
| 982 | + if (strlen($dir)) { |
|
| 983 | + $dir = rtrim($dir, '/') . '/'; |
|
| 984 | + } |
|
| 985 | + if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 986 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 987 | + } |
|
| 988 | + if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 989 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 990 | + } |
|
| 991 | + } |
|
| 992 | + } |
|
| 993 | + } |
|
| 994 | + } |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | + if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 998 | + $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 999 | + ',', |
|
| 1000 | + array_reverse($chemins['public']) |
|
| 1001 | + ) . "]);\n" |
|
| 1002 | + . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 1003 | + } |
|
| 1004 | + |
|
| 1005 | + ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | /** |
@@ -1020,67 +1020,67 @@ discard block |
||
| 1020 | 1020 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 1021 | 1021 | **/ |
| 1022 | 1022 | function plugins_precompile_xxxtions($plugin_valides, $ordre) { |
| 1023 | - $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1024 | - $boutons = []; |
|
| 1025 | - $onglets = []; |
|
| 1026 | - $sign = ''; |
|
| 1027 | - |
|
| 1028 | - foreach ($ordre as $p => $info) { |
|
| 1029 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1030 | - if (isset($plugin_valides[$p])) { |
|
| 1031 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1032 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1033 | - $dir = constant($dir_type); |
|
| 1034 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1035 | - if ($info['menu']) { |
|
| 1036 | - $boutons = array_merge($boutons, $info['menu']); |
|
| 1037 | - } |
|
| 1038 | - if ($info['onglet']) { |
|
| 1039 | - $onglets = array_merge($onglets, $info['onglet']); |
|
| 1040 | - } |
|
| 1041 | - foreach ($contenu as $charge => $v) { |
|
| 1042 | - // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1043 | - // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1044 | - // donc ni sa relecture, ni sa detection |
|
| 1045 | - if ( |
|
| 1046 | - !isset($info[$charge]) |
|
| 1047 | - and $dir // exclure le cas du plugin "SPIP" |
|
| 1048 | - and !str_contains($dir, ':') // exclure le cas des procure: |
|
| 1049 | - and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1050 | - ) { |
|
| 1051 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1052 | - $info[$charge] = [$file]; |
|
| 1053 | - } |
|
| 1054 | - } |
|
| 1055 | - if (isset($info[$charge])) { |
|
| 1056 | - $files = $info[$charge]; |
|
| 1057 | - foreach ($files as $k => $file) { |
|
| 1058 | - // on genere un if file_exists devant chaque include |
|
| 1059 | - // pour pouvoir garder le meme niveau d'erreur general |
|
| 1060 | - $file = trim($file); |
|
| 1061 | - if ( |
|
| 1062 | - !is_readable("$dir$plug/$file") |
|
| 1063 | - // uniquement pour les paquet.xml |
|
| 1064 | - and file_exists("$dir$plug/paquet.xml") |
|
| 1065 | - ) { |
|
| 1066 | - unset($info[$charge][$k]); |
|
| 1067 | - } else { |
|
| 1068 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1069 | - $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1070 | - } |
|
| 1071 | - } |
|
| 1072 | - } |
|
| 1073 | - } |
|
| 1074 | - $sign .= md5(serialize($info)); |
|
| 1075 | - } |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1079 | - $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1080 | - . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1081 | - |
|
| 1082 | - ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1083 | - ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1023 | + $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1024 | + $boutons = []; |
|
| 1025 | + $onglets = []; |
|
| 1026 | + $sign = ''; |
|
| 1027 | + |
|
| 1028 | + foreach ($ordre as $p => $info) { |
|
| 1029 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1030 | + if (isset($plugin_valides[$p])) { |
|
| 1031 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1032 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1033 | + $dir = constant($dir_type); |
|
| 1034 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1035 | + if ($info['menu']) { |
|
| 1036 | + $boutons = array_merge($boutons, $info['menu']); |
|
| 1037 | + } |
|
| 1038 | + if ($info['onglet']) { |
|
| 1039 | + $onglets = array_merge($onglets, $info['onglet']); |
|
| 1040 | + } |
|
| 1041 | + foreach ($contenu as $charge => $v) { |
|
| 1042 | + // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1043 | + // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1044 | + // donc ni sa relecture, ni sa detection |
|
| 1045 | + if ( |
|
| 1046 | + !isset($info[$charge]) |
|
| 1047 | + and $dir // exclure le cas du plugin "SPIP" |
|
| 1048 | + and !str_contains($dir, ':') // exclure le cas des procure: |
|
| 1049 | + and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1050 | + ) { |
|
| 1051 | + if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1052 | + $info[$charge] = [$file]; |
|
| 1053 | + } |
|
| 1054 | + } |
|
| 1055 | + if (isset($info[$charge])) { |
|
| 1056 | + $files = $info[$charge]; |
|
| 1057 | + foreach ($files as $k => $file) { |
|
| 1058 | + // on genere un if file_exists devant chaque include |
|
| 1059 | + // pour pouvoir garder le meme niveau d'erreur general |
|
| 1060 | + $file = trim($file); |
|
| 1061 | + if ( |
|
| 1062 | + !is_readable("$dir$plug/$file") |
|
| 1063 | + // uniquement pour les paquet.xml |
|
| 1064 | + and file_exists("$dir$plug/paquet.xml") |
|
| 1065 | + ) { |
|
| 1066 | + unset($info[$charge][$k]); |
|
| 1067 | + } else { |
|
| 1068 | + $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1069 | + $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1070 | + } |
|
| 1071 | + } |
|
| 1072 | + } |
|
| 1073 | + } |
|
| 1074 | + $sign .= md5(serialize($info)); |
|
| 1075 | + } |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1079 | + $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1080 | + . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1081 | + |
|
| 1082 | + ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1083 | + ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | /** |
@@ -1099,24 +1099,24 @@ discard block |
||
| 1099 | 1099 | * @return string Code php |
| 1100 | 1100 | */ |
| 1101 | 1101 | function plugin_ongletbouton($nom, $val) { |
| 1102 | - if (!$val) { |
|
| 1103 | - $val = []; |
|
| 1104 | - } |
|
| 1105 | - |
|
| 1106 | - $val = serialize($val); |
|
| 1107 | - $md5 = md5($val); |
|
| 1108 | - |
|
| 1109 | - if (!defined("_UPDATED_$nom")) { |
|
| 1110 | - define("_UPDATED_$nom", $val); |
|
| 1111 | - define("_UPDATED_md5_$nom", $md5); |
|
| 1112 | - } |
|
| 1113 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1114 | - |
|
| 1115 | - return |
|
| 1116 | - "if (!function_exists('$nom')) {\n" |
|
| 1117 | - . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1118 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1119 | - . "}\n"; |
|
| 1102 | + if (!$val) { |
|
| 1103 | + $val = []; |
|
| 1104 | + } |
|
| 1105 | + |
|
| 1106 | + $val = serialize($val); |
|
| 1107 | + $md5 = md5($val); |
|
| 1108 | + |
|
| 1109 | + if (!defined("_UPDATED_$nom")) { |
|
| 1110 | + define("_UPDATED_$nom", $val); |
|
| 1111 | + define("_UPDATED_md5_$nom", $md5); |
|
| 1112 | + } |
|
| 1113 | + $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1114 | + |
|
| 1115 | + return |
|
| 1116 | + "if (!function_exists('$nom')) {\n" |
|
| 1117 | + . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1118 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1119 | + . "}\n"; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | /** |
@@ -1131,15 +1131,15 @@ discard block |
||
| 1131 | 1131 | **/ |
| 1132 | 1132 | function plugins_amorcer_plugins_actifs() { |
| 1133 | 1133 | |
| 1134 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1135 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1136 | - } |
|
| 1134 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1135 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1136 | + } |
|
| 1137 | 1137 | |
| 1138 | - if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1139 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 1140 | - } else { |
|
| 1141 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1142 | - } |
|
| 1138 | + if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1139 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 1140 | + } else { |
|
| 1141 | + spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1142 | + } |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | /** |
@@ -1162,140 +1162,140 @@ discard block |
||
| 1162 | 1162 | * Couples (nom du pipeline => Code PHP à insérer au début du pipeline) |
| 1163 | 1163 | **/ |
| 1164 | 1164 | function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) { |
| 1165 | - static $liste_pipe_manquants = []; |
|
| 1166 | - if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1167 | - $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - $prepend_code = []; |
|
| 1171 | - |
|
| 1172 | - foreach ($ordre as $p => $info) { |
|
| 1173 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1174 | - if (isset($plugin_valides[$p])) { |
|
| 1175 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1176 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1177 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1178 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1179 | - if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1180 | - foreach ($info['pipeline'] as $pipe) { |
|
| 1181 | - $nom = $pipe['nom']; |
|
| 1182 | - if (isset($pipe['action'])) { |
|
| 1183 | - $action = $pipe['action']; |
|
| 1184 | - } else { |
|
| 1185 | - $action = $nom; |
|
| 1186 | - } |
|
| 1187 | - $nomlower = strtolower($nom); |
|
| 1188 | - if ( |
|
| 1189 | - $nomlower != $nom |
|
| 1190 | - and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1191 | - and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1192 | - ) { |
|
| 1193 | - $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1194 | - unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1195 | - } |
|
| 1196 | - $nom = $nomlower; |
|
| 1197 | - // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1198 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1199 | - $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1200 | - } |
|
| 1201 | - if ($action) { |
|
| 1202 | - if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) { |
|
| 1203 | - $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1204 | - ',(\|\||$),', |
|
| 1205 | - "|$prefix$action\\1", |
|
| 1206 | - $GLOBALS['spip_pipeline'][$nom], |
|
| 1207 | - 1 |
|
| 1208 | - ); |
|
| 1209 | - } |
|
| 1210 | - if (isset($pipe['inclure'])) { |
|
| 1211 | - $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1212 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1213 | - } |
|
| 1214 | - } |
|
| 1215 | - } |
|
| 1216 | - } |
|
| 1217 | - if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) { |
|
| 1218 | - if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1219 | - $prepend_code['taches_generales_cron'] = ''; |
|
| 1220 | - } |
|
| 1221 | - foreach ($info['genie'] as $genie) { |
|
| 1222 | - $nom = $prefix . $genie['nom']; |
|
| 1223 | - $periode = max(60, intval($genie['periode'])); |
|
| 1224 | - if (charger_fonction($nom, 'genie', true)) { |
|
| 1225 | - $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1226 | - } else { |
|
| 1227 | - spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1228 | - } |
|
| 1229 | - } |
|
| 1230 | - } |
|
| 1231 | - if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) { |
|
| 1232 | - if (!isset($prepend_code['insert_head_css'])) { |
|
| 1233 | - $prepend_code['insert_head_css'] = ''; |
|
| 1234 | - } |
|
| 1235 | - if (!isset($prepend_code['header_prive_css'])) { |
|
| 1236 | - $prepend_code['header_prive_css'] = ''; |
|
| 1237 | - } |
|
| 1238 | - foreach ($info['style'] as $style) { |
|
| 1239 | - if (isset($style['path']) and $style['path']) { |
|
| 1240 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1241 | - } else { |
|
| 1242 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1243 | - } |
|
| 1244 | - $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1245 | - if (isset($style['media']) and strlen($style['media'])) { |
|
| 1246 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1247 | - } |
|
| 1248 | - $code .= "/>';\n"; |
|
| 1249 | - if ($style['type'] != 'prive') { |
|
| 1250 | - $prepend_code['insert_head_css'] .= $code; |
|
| 1251 | - } |
|
| 1252 | - if ($style['type'] != 'public') { |
|
| 1253 | - $prepend_code['header_prive_css'] .= $code; |
|
| 1254 | - } |
|
| 1255 | - } |
|
| 1256 | - } |
|
| 1257 | - if (!isset($prepend_code['insert_head'])) { |
|
| 1258 | - $prepend_code['insert_head'] = ''; |
|
| 1259 | - } |
|
| 1260 | - if (!isset($prepend_code['header_prive'])) { |
|
| 1261 | - $prepend_code['header_prive'] = ''; |
|
| 1262 | - } |
|
| 1263 | - if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
|
| 1264 | - foreach ($info['script'] as $script) { |
|
| 1265 | - if (isset($script['path']) and $script['path']) { |
|
| 1266 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1267 | - } else { |
|
| 1268 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1269 | - } |
|
| 1270 | - $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1271 | - if ($script['type'] != 'prive') { |
|
| 1272 | - $prepend_code['insert_head'] .= $code; |
|
| 1273 | - } |
|
| 1274 | - if ($script['type'] != 'public') { |
|
| 1275 | - $prepend_code['header_prive'] .= $code; |
|
| 1276 | - } |
|
| 1277 | - } |
|
| 1278 | - } |
|
| 1279 | - } |
|
| 1280 | - } |
|
| 1281 | - |
|
| 1282 | - $prepend_code['insert_head'] = |
|
| 1283 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1284 | - . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1285 | - . $prepend_code['insert_head']; |
|
| 1286 | - $prepend_code['header_prive'] = |
|
| 1287 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1288 | - . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1289 | - . $prepend_code['header_prive']; |
|
| 1290 | - |
|
| 1291 | - // on ajoute les pipe qui ont ete recenses manquants |
|
| 1292 | - foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1293 | - if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1294 | - $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1295 | - } |
|
| 1296 | - } |
|
| 1297 | - |
|
| 1298 | - return $prepend_code; |
|
| 1165 | + static $liste_pipe_manquants = []; |
|
| 1166 | + if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1167 | + $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + $prepend_code = []; |
|
| 1171 | + |
|
| 1172 | + foreach ($ordre as $p => $info) { |
|
| 1173 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1174 | + if (isset($plugin_valides[$p])) { |
|
| 1175 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1176 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1177 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1178 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1179 | + if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1180 | + foreach ($info['pipeline'] as $pipe) { |
|
| 1181 | + $nom = $pipe['nom']; |
|
| 1182 | + if (isset($pipe['action'])) { |
|
| 1183 | + $action = $pipe['action']; |
|
| 1184 | + } else { |
|
| 1185 | + $action = $nom; |
|
| 1186 | + } |
|
| 1187 | + $nomlower = strtolower($nom); |
|
| 1188 | + if ( |
|
| 1189 | + $nomlower != $nom |
|
| 1190 | + and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1191 | + and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1192 | + ) { |
|
| 1193 | + $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1194 | + unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1195 | + } |
|
| 1196 | + $nom = $nomlower; |
|
| 1197 | + // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1198 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1199 | + $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1200 | + } |
|
| 1201 | + if ($action) { |
|
| 1202 | + if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) { |
|
| 1203 | + $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1204 | + ',(\|\||$),', |
|
| 1205 | + "|$prefix$action\\1", |
|
| 1206 | + $GLOBALS['spip_pipeline'][$nom], |
|
| 1207 | + 1 |
|
| 1208 | + ); |
|
| 1209 | + } |
|
| 1210 | + if (isset($pipe['inclure'])) { |
|
| 1211 | + $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1212 | + "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1213 | + } |
|
| 1214 | + } |
|
| 1215 | + } |
|
| 1216 | + } |
|
| 1217 | + if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) { |
|
| 1218 | + if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1219 | + $prepend_code['taches_generales_cron'] = ''; |
|
| 1220 | + } |
|
| 1221 | + foreach ($info['genie'] as $genie) { |
|
| 1222 | + $nom = $prefix . $genie['nom']; |
|
| 1223 | + $periode = max(60, intval($genie['periode'])); |
|
| 1224 | + if (charger_fonction($nom, 'genie', true)) { |
|
| 1225 | + $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1226 | + } else { |
|
| 1227 | + spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1228 | + } |
|
| 1229 | + } |
|
| 1230 | + } |
|
| 1231 | + if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) { |
|
| 1232 | + if (!isset($prepend_code['insert_head_css'])) { |
|
| 1233 | + $prepend_code['insert_head_css'] = ''; |
|
| 1234 | + } |
|
| 1235 | + if (!isset($prepend_code['header_prive_css'])) { |
|
| 1236 | + $prepend_code['header_prive_css'] = ''; |
|
| 1237 | + } |
|
| 1238 | + foreach ($info['style'] as $style) { |
|
| 1239 | + if (isset($style['path']) and $style['path']) { |
|
| 1240 | + $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1241 | + } else { |
|
| 1242 | + $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1243 | + } |
|
| 1244 | + $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1245 | + if (isset($style['media']) and strlen($style['media'])) { |
|
| 1246 | + $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1247 | + } |
|
| 1248 | + $code .= "/>';\n"; |
|
| 1249 | + if ($style['type'] != 'prive') { |
|
| 1250 | + $prepend_code['insert_head_css'] .= $code; |
|
| 1251 | + } |
|
| 1252 | + if ($style['type'] != 'public') { |
|
| 1253 | + $prepend_code['header_prive_css'] .= $code; |
|
| 1254 | + } |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1257 | + if (!isset($prepend_code['insert_head'])) { |
|
| 1258 | + $prepend_code['insert_head'] = ''; |
|
| 1259 | + } |
|
| 1260 | + if (!isset($prepend_code['header_prive'])) { |
|
| 1261 | + $prepend_code['header_prive'] = ''; |
|
| 1262 | + } |
|
| 1263 | + if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
|
| 1264 | + foreach ($info['script'] as $script) { |
|
| 1265 | + if (isset($script['path']) and $script['path']) { |
|
| 1266 | + $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1267 | + } else { |
|
| 1268 | + $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1269 | + } |
|
| 1270 | + $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1271 | + if ($script['type'] != 'prive') { |
|
| 1272 | + $prepend_code['insert_head'] .= $code; |
|
| 1273 | + } |
|
| 1274 | + if ($script['type'] != 'public') { |
|
| 1275 | + $prepend_code['header_prive'] .= $code; |
|
| 1276 | + } |
|
| 1277 | + } |
|
| 1278 | + } |
|
| 1279 | + } |
|
| 1280 | + } |
|
| 1281 | + |
|
| 1282 | + $prepend_code['insert_head'] = |
|
| 1283 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1284 | + . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1285 | + . $prepend_code['insert_head']; |
|
| 1286 | + $prepend_code['header_prive'] = |
|
| 1287 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1288 | + . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1289 | + . $prepend_code['header_prive']; |
|
| 1290 | + |
|
| 1291 | + // on ajoute les pipe qui ont ete recenses manquants |
|
| 1292 | + foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1293 | + if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1294 | + $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1295 | + } |
|
| 1296 | + } |
|
| 1297 | + |
|
| 1298 | + return $prepend_code; |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1322,62 +1322,62 @@ discard block |
||
| 1322 | 1322 | **/ |
| 1323 | 1323 | function pipeline_precompile($prepend_code = []) { |
| 1324 | 1324 | |
| 1325 | - $all_pipes = $all_pipes_end = ''; |
|
| 1326 | - if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1327 | - $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1328 | - unset($GLOBALS['spip_pipeline']['all']); |
|
| 1329 | - $all_pipes = trim(array_shift($a)); |
|
| 1330 | - if ($all_pipes) { |
|
| 1331 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1332 | - } |
|
| 1333 | - if (count($a)) { |
|
| 1334 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1335 | - } |
|
| 1336 | - } |
|
| 1337 | - $content = ''; |
|
| 1338 | - foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1339 | - $s_inc = ''; |
|
| 1340 | - $s_call = ''; |
|
| 1341 | - if ($all_pipes) { |
|
| 1342 | - $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1343 | - } |
|
| 1344 | - if ($all_pipes_end) { |
|
| 1345 | - $pipeline .= $all_pipes_end; |
|
| 1346 | - } |
|
| 1347 | - $pipe = array_filter(explode('|', $pipeline)); |
|
| 1348 | - // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1349 | - foreach ($pipe as $fonc) { |
|
| 1350 | - $fonc = trim($fonc); |
|
| 1351 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1352 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1353 | - $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1354 | - $file = "'$file'"; |
|
| 1355 | - // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1356 | - if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1357 | - $dir = $regs[1]; |
|
| 1358 | - $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1359 | - if (defined($root_dir)) { |
|
| 1360 | - $dir = $root_dir; |
|
| 1361 | - } |
|
| 1362 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1363 | - $file = str_replace("''.", '', $file); |
|
| 1364 | - $file = str_replace(constant($dir), '', $file); |
|
| 1365 | - } |
|
| 1366 | - $s_inc .= "include_once_check($file);\n"; |
|
| 1367 | - } |
|
| 1368 | - } |
|
| 1369 | - if (strlen($s_inc)) { |
|
| 1370 | - $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1371 | - } |
|
| 1372 | - $content .= "// Pipeline $action \n" |
|
| 1373 | - . "function execute_pipeline_$action(&\$val){\n" |
|
| 1374 | - . $s_inc |
|
| 1375 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1376 | - . $s_call |
|
| 1377 | - . "return \$val;\n}\n"; |
|
| 1378 | - } |
|
| 1379 | - ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1380 | - clear_path_cache(); |
|
| 1325 | + $all_pipes = $all_pipes_end = ''; |
|
| 1326 | + if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1327 | + $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1328 | + unset($GLOBALS['spip_pipeline']['all']); |
|
| 1329 | + $all_pipes = trim(array_shift($a)); |
|
| 1330 | + if ($all_pipes) { |
|
| 1331 | + $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1332 | + } |
|
| 1333 | + if (count($a)) { |
|
| 1334 | + $all_pipes_end = '||' . array_shift($a); |
|
| 1335 | + } |
|
| 1336 | + } |
|
| 1337 | + $content = ''; |
|
| 1338 | + foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1339 | + $s_inc = ''; |
|
| 1340 | + $s_call = ''; |
|
| 1341 | + if ($all_pipes) { |
|
| 1342 | + $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1343 | + } |
|
| 1344 | + if ($all_pipes_end) { |
|
| 1345 | + $pipeline .= $all_pipes_end; |
|
| 1346 | + } |
|
| 1347 | + $pipe = array_filter(explode('|', $pipeline)); |
|
| 1348 | + // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1349 | + foreach ($pipe as $fonc) { |
|
| 1350 | + $fonc = trim($fonc); |
|
| 1351 | + $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1352 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1353 | + $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1354 | + $file = "'$file'"; |
|
| 1355 | + // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1356 | + if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1357 | + $dir = $regs[1]; |
|
| 1358 | + $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1359 | + if (defined($root_dir)) { |
|
| 1360 | + $dir = $root_dir; |
|
| 1361 | + } |
|
| 1362 | + $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1363 | + $file = str_replace("''.", '', $file); |
|
| 1364 | + $file = str_replace(constant($dir), '', $file); |
|
| 1365 | + } |
|
| 1366 | + $s_inc .= "include_once_check($file);\n"; |
|
| 1367 | + } |
|
| 1368 | + } |
|
| 1369 | + if (strlen($s_inc)) { |
|
| 1370 | + $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1371 | + } |
|
| 1372 | + $content .= "// Pipeline $action \n" |
|
| 1373 | + . "function execute_pipeline_$action(&\$val){\n" |
|
| 1374 | + . $s_inc |
|
| 1375 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1376 | + . $s_call |
|
| 1377 | + . "return \$val;\n}\n"; |
|
| 1378 | + } |
|
| 1379 | + ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1380 | + clear_path_cache(); |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | |
@@ -1390,12 +1390,12 @@ discard block |
||
| 1390 | 1390 | * true si le plugin est actif, false sinon |
| 1391 | 1391 | **/ |
| 1392 | 1392 | function plugin_est_installe($plug_path) { |
| 1393 | - $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1394 | - if (!$plugin_installes) { |
|
| 1395 | - return false; |
|
| 1396 | - } |
|
| 1393 | + $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1394 | + if (!$plugin_installes) { |
|
| 1395 | + return false; |
|
| 1396 | + } |
|
| 1397 | 1397 | |
| 1398 | - return in_array($plug_path, $plugin_installes); |
|
| 1398 | + return in_array($plug_path, $plugin_installes); |
|
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | |
@@ -1408,46 +1408,46 @@ discard block |
||
| 1408 | 1408 | * @uses plugins_installer_dist() |
| 1409 | 1409 | **/ |
| 1410 | 1410 | function plugin_installes_meta() { |
| 1411 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1412 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 1413 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1417 | - $meta_plug_installes = []; |
|
| 1418 | - foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1419 | - if ($plug = $resume['dir']) { |
|
| 1420 | - $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1421 | - if ($infos) { |
|
| 1422 | - if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1423 | - $meta_plug_installes[] = $plug; |
|
| 1424 | - } |
|
| 1425 | - if (is_array($infos)) { |
|
| 1426 | - [$ok, $trace] = $infos['install_test']; |
|
| 1427 | - $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1428 | - $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1429 | - if (_IS_CLI) { |
|
| 1430 | - include_spip('inc/filtres'); |
|
| 1431 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1432 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1433 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1434 | - $trace, |
|
| 1435 | - "\n"; |
|
| 1436 | - } |
|
| 1437 | - else { |
|
| 1438 | - include_spip('inc/filtres_boites'); |
|
| 1439 | - echo "<div class='install-plugins svp_retour'>" |
|
| 1440 | - . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1441 | - . $trace |
|
| 1442 | - . "<div class='result'>$result</div>" |
|
| 1443 | - . boite_fermer() |
|
| 1444 | - . '</div>'; |
|
| 1445 | - } |
|
| 1446 | - } |
|
| 1447 | - } |
|
| 1448 | - } |
|
| 1449 | - } |
|
| 1450 | - ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1411 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1412 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 1413 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1414 | + } |
|
| 1415 | + |
|
| 1416 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1417 | + $meta_plug_installes = []; |
|
| 1418 | + foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1419 | + if ($plug = $resume['dir']) { |
|
| 1420 | + $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1421 | + if ($infos) { |
|
| 1422 | + if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1423 | + $meta_plug_installes[] = $plug; |
|
| 1424 | + } |
|
| 1425 | + if (is_array($infos)) { |
|
| 1426 | + [$ok, $trace] = $infos['install_test']; |
|
| 1427 | + $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1428 | + $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1429 | + if (_IS_CLI) { |
|
| 1430 | + include_spip('inc/filtres'); |
|
| 1431 | + $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1432 | + $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1433 | + echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1434 | + $trace, |
|
| 1435 | + "\n"; |
|
| 1436 | + } |
|
| 1437 | + else { |
|
| 1438 | + include_spip('inc/filtres_boites'); |
|
| 1439 | + echo "<div class='install-plugins svp_retour'>" |
|
| 1440 | + . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1441 | + . $trace |
|
| 1442 | + . "<div class='result'>$result</div>" |
|
| 1443 | + . boite_fermer() |
|
| 1444 | + . '</div>'; |
|
| 1445 | + } |
|
| 1446 | + } |
|
| 1447 | + } |
|
| 1448 | + } |
|
| 1449 | + } |
|
| 1450 | + ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | /** |
@@ -1461,29 +1461,29 @@ discard block |
||
| 1461 | 1461 | * Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante |
| 1462 | 1462 | **/ |
| 1463 | 1463 | function ecrire_fichier_php($nom, $contenu, $comment = '') { |
| 1464 | - if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1465 | - $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1466 | - } |
|
| 1467 | - |
|
| 1468 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1469 | - // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1470 | - // si pas de modif on ne touche pas au fichier initial |
|
| 1471 | - if (file_exists($nom)) { |
|
| 1472 | - if (substr($nom, -4) == '.php') { |
|
| 1473 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1474 | - } |
|
| 1475 | - else { |
|
| 1476 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1477 | - } |
|
| 1478 | - file_put_contents($fichier_tmp, $contenu); |
|
| 1479 | - if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1480 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1481 | - @unlink($fichier_tmp); |
|
| 1482 | - return; |
|
| 1483 | - } |
|
| 1484 | - @unlink($fichier_tmp); |
|
| 1485 | - } |
|
| 1486 | - ecrire_fichier($nom, $contenu); |
|
| 1487 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1488 | - spip_clear_opcode_cache(realpath($nom)); |
|
| 1464 | + if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1465 | + $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1469 | + // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1470 | + // si pas de modif on ne touche pas au fichier initial |
|
| 1471 | + if (file_exists($nom)) { |
|
| 1472 | + if (substr($nom, -4) == '.php') { |
|
| 1473 | + $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1474 | + } |
|
| 1475 | + else { |
|
| 1476 | + $fichier_tmp = $nom . '.tmp'; |
|
| 1477 | + } |
|
| 1478 | + file_put_contents($fichier_tmp, $contenu); |
|
| 1479 | + if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1480 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1481 | + @unlink($fichier_tmp); |
|
| 1482 | + return; |
|
| 1483 | + } |
|
| 1484 | + @unlink($fichier_tmp); |
|
| 1485 | + } |
|
| 1486 | + ecrire_fichier($nom, $contenu); |
|
| 1487 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1488 | + spip_clear_opcode_cache(realpath($nom)); |
|
| 1489 | 1489 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | if ($dir) { |
| 382 | 382 | $dir .= '/'; |
| 383 | 383 | } |
| 384 | - $dir .= 'procure:' . $procure['nom']; |
|
| 384 | + $dir .= 'procure:'.$procure['nom']; |
|
| 385 | 385 | |
| 386 | 386 | $procure['etat'] = '?'; |
| 387 | 387 | $procure['dir_type'] = $resume['dir_type']; |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | $plug = $resume['dir']; |
| 566 | 566 | $k = $infos[$dir_type][$plug]; |
| 567 | 567 | |
| 568 | - $plug = constant($dir_type) . $plug; |
|
| 568 | + $plug = constant($dir_type).$plug; |
|
| 569 | 569 | if (!isset($msg[$p])) { |
| 570 | 570 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 571 | 571 | $msg[$p] = [$resume['erreur']]; |
@@ -608,10 +608,10 @@ discard block |
||
| 608 | 608 | $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
| 609 | 609 | } elseif (!$raw) { |
| 610 | 610 | foreach ($list as $plug => $msg) { |
| 611 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 611 | + $list[$plug] = '<li>'._T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | + . '<ul><li>'.implode('</li><li>', $msg).'</li></ul></li>'; |
|
| 613 | 613 | } |
| 614 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 614 | + $list = '<ul>'.join("\n", $list).'</ul>'; |
|
| 615 | 615 | } |
| 616 | 616 | if ($raz) { |
| 617 | 617 | effacer_meta('plugin_erreur_activation'); |
@@ -725,13 +725,13 @@ discard block |
||
| 725 | 725 | if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
| 726 | 726 | return _T("plugin_{$balise}_{$type}", [ |
| 727 | 727 | 'plugin' => $nom, |
| 728 | - 'version' => ' ≥ ' . $minimum |
|
| 728 | + 'version' => ' ≥ '.$minimum |
|
| 729 | 729 | ]); |
| 730 | 730 | } |
| 731 | 731 | if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
| 732 | 732 | return _T("plugin_{$balise}_{$type}", [ |
| 733 | 733 | 'plugin' => $nom, |
| 734 | - 'version' => ' > ' . $minimum |
|
| 734 | + 'version' => ' > '.$minimum |
|
| 735 | 735 | ]); |
| 736 | 736 | } |
| 737 | 737 | } |
@@ -740,13 +740,13 @@ discard block |
||
| 740 | 740 | if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
| 741 | 741 | return _T("plugin_{$balise}_{$type}", [ |
| 742 | 742 | 'plugin' => $nom, |
| 743 | - 'version' => ' ≤ ' . $maximum |
|
| 743 | + 'version' => ' ≤ '.$maximum |
|
| 744 | 744 | ]); |
| 745 | 745 | } |
| 746 | 746 | if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
| 747 | 747 | return _T("plugin_{$balise}_plugin", [ |
| 748 | 748 | 'plugin' => $nom, |
| 749 | - 'version' => ' < ' . $maximum |
|
| 749 | + 'version' => ' < '.$maximum |
|
| 750 | 750 | ]); |
| 751 | 751 | } |
| 752 | 752 | } |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | include_spip('inc/charger_plugin'); |
| 766 | 766 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 767 | 767 | }*/ |
| 768 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 768 | + return _T('plugin_necessite_lib', ['lib' => $lib])." <a href='$url'>$url</a>"; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | foreach ($plugin_valides as $p => $resume) { |
| 866 | 866 | // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
| 867 | 867 | if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') { |
| 868 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 868 | + $header[] = $p.($resume['version'] ? '('.$resume['version'].')' : ''); |
|
| 869 | 869 | } |
| 870 | 870 | if ($resume['dir']) { |
| 871 | 871 | foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
@@ -890,11 +890,11 @@ discard block |
||
| 890 | 890 | $header = strtolower(implode(',', $header)); |
| 891 | 891 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 892 | 892 | ecrire_fichier( |
| 893 | - _DIR_VAR . 'config.txt', |
|
| 894 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 893 | + _DIR_VAR.'config.txt', |
|
| 894 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP').' '.$GLOBALS['spip_version_affichee'].' @ www.spip.net + '.$header |
|
| 895 | 895 | ); |
| 896 | 896 | } else { |
| 897 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 897 | + @unlink(_DIR_VAR.'config.txt'); |
|
| 898 | 898 | } |
| 899 | 899 | // generer charger_plugins_chemin.php |
| 900 | 900 | plugins_precompile_chemin($plugin_valides, $ordre); |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | // definir le plugin, donc le path avant l'include du fichier options |
| 949 | 949 | // permet de faire des include_spip pour attraper un inc_ du plugin |
| 950 | 950 | |
| 951 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 951 | + $dir = $dir_type.".'".$plug."/'"; |
|
| 952 | 952 | |
| 953 | 953 | $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
| 954 | 954 | if ( |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | if (!$info['chemin']) { |
| 960 | 960 | $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
| 961 | 961 | $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
| 962 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 962 | + if (is_dir(constant($dir_type).$plug.'/squelettes/')) { |
|
| 963 | 963 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 964 | 964 | } |
| 965 | 965 | } |
@@ -980,13 +980,13 @@ discard block |
||
| 980 | 980 | $dir = ''; |
| 981 | 981 | } |
| 982 | 982 | if (strlen($dir)) { |
| 983 | - $dir = rtrim($dir, '/') . '/'; |
|
| 983 | + $dir = rtrim($dir, '/').'/'; |
|
| 984 | 984 | } |
| 985 | 985 | if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
| 986 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 986 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 987 | 987 | } |
| 988 | 988 | if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
| 989 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 989 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | } |
@@ -995,11 +995,11 @@ discard block |
||
| 995 | 995 | } |
| 996 | 996 | } |
| 997 | 997 | if (count($chemins['public']) or count($chemins['prive'])) { |
| 998 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 998 | + $contenu .= 'if (_DIR_RESTREINT) _chemin(['.implode( |
|
| 999 | 999 | ',', |
| 1000 | 1000 | array_reverse($chemins['public']) |
| 1001 | - ) . "]);\n" |
|
| 1002 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 1001 | + )."]);\n" |
|
| 1002 | + . 'else _chemin(['.implode(',', array_reverse($chemins['prive']))."]);\n"; |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | and !str_contains($dir, ':') // exclure le cas des procure: |
| 1049 | 1049 | and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
| 1050 | 1050 | ) { |
| 1051 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1051 | + if (is_readable("$dir$plug/".($file = $info['prefix'].'_'.$charge.'.php'))) { |
|
| 1052 | 1052 | $info[$charge] = [$file]; |
| 1053 | 1053 | } |
| 1054 | 1054 | } |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | ) { |
| 1066 | 1066 | unset($info[$charge][$k]); |
| 1067 | 1067 | } else { |
| 1068 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1068 | + $_file = $root_dir_type.".'$plug/$file'"; |
|
| 1069 | 1069 | $contenu[$charge] .= "include_once_check($_file);\n"; |
| 1070 | 1070 | } |
| 1071 | 1071 | } |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | } |
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1078 | + $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options']; |
|
| 1079 | 1079 | $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
| 1080 | 1080 | . plugin_ongletbouton('onglets_plugins', $onglets); |
| 1081 | 1081 | |
@@ -1110,12 +1110,12 @@ discard block |
||
| 1110 | 1110 | define("_UPDATED_$nom", $val); |
| 1111 | 1111 | define("_UPDATED_md5_$nom", $md5); |
| 1112 | 1112 | } |
| 1113 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1113 | + $val = "unserialize('".str_replace("'", "\'", $val)."')"; |
|
| 1114 | 1114 | |
| 1115 | 1115 | return |
| 1116 | 1116 | "if (!function_exists('$nom')) {\n" |
| 1117 | 1117 | . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
| 1118 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1118 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 1119 | 1119 | . "}\n"; |
| 1120 | 1120 | } |
| 1121 | 1121 | |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | if (@is_readable(_CACHE_PLUGINS_OPT)) { |
| 1139 | 1139 | include_once(_CACHE_PLUGINS_OPT); |
| 1140 | 1140 | } else { |
| 1141 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1141 | + spip_log('pipelines desactives: impossible de produire '._CACHE_PLUGINS_OPT); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | 1144 | |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | $dir_type = $plugin_valides[$p]['dir_type']; |
| 1176 | 1176 | $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
| 1177 | 1177 | $plug = $plugin_valides[$p]['dir']; |
| 1178 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1178 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'].'_'); |
|
| 1179 | 1179 | if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
| 1180 | 1180 | foreach ($info['pipeline'] as $pipe) { |
| 1181 | 1181 | $nom = $pipe['nom']; |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | } |
| 1210 | 1210 | if (isset($pipe['inclure'])) { |
| 1211 | 1211 | $GLOBALS['spip_matrice']["$prefix$action"] = |
| 1212 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1212 | + "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 1213 | 1213 | } |
| 1214 | 1214 | } |
| 1215 | 1215 | } |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | $prepend_code['taches_generales_cron'] = ''; |
| 1220 | 1220 | } |
| 1221 | 1221 | foreach ($info['genie'] as $genie) { |
| 1222 | - $nom = $prefix . $genie['nom']; |
|
| 1222 | + $nom = $prefix.$genie['nom']; |
|
| 1223 | 1223 | $periode = max(60, intval($genie['periode'])); |
| 1224 | 1224 | if (charger_fonction($nom, 'genie', true)) { |
| 1225 | 1225 | $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
@@ -1237,13 +1237,13 @@ discard block |
||
| 1237 | 1237 | } |
| 1238 | 1238 | foreach ($info['style'] as $style) { |
| 1239 | 1239 | if (isset($style['path']) and $style['path']) { |
| 1240 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1240 | + $code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) "; |
|
| 1241 | 1241 | } else { |
| 1242 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1242 | + $code = "if (\$f='".addslashes($style['url'])."') "; |
|
| 1243 | 1243 | } |
| 1244 | 1244 | $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
| 1245 | 1245 | if (isset($style['media']) and strlen($style['media'])) { |
| 1246 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1246 | + $code .= ' media="'.addslashes($style['media']).'"'; |
|
| 1247 | 1247 | } |
| 1248 | 1248 | $code .= "/>';\n"; |
| 1249 | 1249 | if ($style['type'] != 'prive') { |
@@ -1263,9 +1263,9 @@ discard block |
||
| 1263 | 1263 | if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
| 1264 | 1264 | foreach ($info['script'] as $script) { |
| 1265 | 1265 | if (isset($script['path']) and $script['path']) { |
| 1266 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1266 | + $code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) "; |
|
| 1267 | 1267 | } else { |
| 1268 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1268 | + $code = "if (\$f='".addslashes($script['url'])."') "; |
|
| 1269 | 1269 | } |
| 1270 | 1270 | $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
| 1271 | 1271 | if ($script['type'] != 'prive') { |
@@ -1328,10 +1328,10 @@ discard block |
||
| 1328 | 1328 | unset($GLOBALS['spip_pipeline']['all']); |
| 1329 | 1329 | $all_pipes = trim(array_shift($a)); |
| 1330 | 1330 | if ($all_pipes) { |
| 1331 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1331 | + $all_pipes = '|'.ltrim($all_pipes, '|'); |
|
| 1332 | 1332 | } |
| 1333 | 1333 | if (count($a)) { |
| 1334 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1334 | + $all_pipes_end = '||'.array_shift($a); |
|
| 1335 | 1335 | } |
| 1336 | 1336 | } |
| 1337 | 1337 | $content = ''; |
@@ -1348,7 +1348,7 @@ discard block |
||
| 1348 | 1348 | // Eclater le pipeline en filtres et appliquer chaque filtre |
| 1349 | 1349 | foreach ($pipe as $fonc) { |
| 1350 | 1350 | $fonc = trim($fonc); |
| 1351 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1351 | + $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 1352 | 1352 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 1353 | 1353 | $file = $GLOBALS['spip_matrice'][$fonc]; |
| 1354 | 1354 | $file = "'$file'"; |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | if (defined($root_dir)) { |
| 1360 | 1360 | $dir = $root_dir; |
| 1361 | 1361 | } |
| 1362 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1362 | + $file = str_replace($regs[0], "'.".$dir.".'", $file); |
|
| 1363 | 1363 | $file = str_replace("''.", '', $file); |
| 1364 | 1364 | $file = str_replace(constant($dir), '', $file); |
| 1365 | 1365 | } |
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | $content .= "// Pipeline $action \n" |
| 1373 | 1373 | . "function execute_pipeline_$action(&\$val){\n" |
| 1374 | 1374 | . $s_inc |
| 1375 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1375 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '') |
|
| 1376 | 1376 | . $s_call |
| 1377 | 1377 | . "return \$val;\n}\n"; |
| 1378 | 1378 | } |
@@ -1428,9 +1428,9 @@ discard block |
||
| 1428 | 1428 | $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
| 1429 | 1429 | if (_IS_CLI) { |
| 1430 | 1430 | include_spip('inc/filtres'); |
| 1431 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1432 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1433 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1431 | + $trace = ltrim(textebrut($trace)."\n".$result); |
|
| 1432 | + $trace = ' '.str_replace("\n", "\n ", $trace); |
|
| 1433 | + echo "\n".($ok ? 'OK ' : '/!\ ').textebrut($titre)."\n", |
|
| 1434 | 1434 | $trace, |
| 1435 | 1435 | "\n"; |
| 1436 | 1436 | } |
@@ -1465,15 +1465,15 @@ discard block |
||
| 1465 | 1465 | $GLOBALS['fichier_php_compile_recent'] = 0; |
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1468 | + $contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>'; |
|
| 1469 | 1469 | // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
| 1470 | 1470 | // si pas de modif on ne touche pas au fichier initial |
| 1471 | 1471 | if (file_exists($nom)) { |
| 1472 | 1472 | if (substr($nom, -4) == '.php') { |
| 1473 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1473 | + $fichier_tmp = substr($nom, 0, -4).'.tmp.php'; |
|
| 1474 | 1474 | } |
| 1475 | 1475 | else { |
| 1476 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1476 | + $fichier_tmp = $nom.'.tmp'; |
|
| 1477 | 1477 | } |
| 1478 | 1478 | file_put_contents($fichier_tmp, $contenu); |
| 1479 | 1479 | if (md5_file($nom) == md5_file($fichier_tmp)) { |