@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @package SPIP\Core\SQL\Upgrade |
| 19 | 19 | **/ |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('base/medias'); |
@@ -27,27 +27,27 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // http://archives.rezo.net/archives/spip-zone.mbox/C6RZKNBUNJYN42IOEOC4QKVCA233AMLI/ |
| 29 | 29 | $GLOBALS['maj'][13833] = [ |
| 30 | - ['sql_alter', 'TABLE spip_documents_liens ADD INDEX objet(id_objet,objet)'] |
|
| 30 | + ['sql_alter', 'TABLE spip_documents_liens ADD INDEX objet(id_objet,objet)'] |
|
| 31 | 31 | ]; |
| 32 | 32 | |
| 33 | 33 | // 2.1 |
| 34 | 34 | |
| 35 | 35 | $GLOBALS['maj'][13904] = [ |
| 36 | - ['sql_alter', "TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"], |
|
| 37 | - [ |
|
| 38 | - 'sql_update', |
|
| 39 | - 'spip_auteurs', |
|
| 40 | - ['webmestre' => "'oui'"], |
|
| 41 | - sql_in('id_auteur', defined('_ID_WEBMESTRES') ? explode( |
|
| 42 | - ':', |
|
| 43 | - _ID_WEBMESTRES |
|
| 44 | - ) : (autoriser('configurer') ? [$GLOBALS['visiteur_session']['id_auteur']] : [0])) |
|
| 45 | - ] // le webmestre est celui qui fait l'upgrade si rien de defini |
|
| 36 | + ['sql_alter', "TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"], |
|
| 37 | + [ |
|
| 38 | + 'sql_update', |
|
| 39 | + 'spip_auteurs', |
|
| 40 | + ['webmestre' => "'oui'"], |
|
| 41 | + sql_in('id_auteur', defined('_ID_WEBMESTRES') ? explode( |
|
| 42 | + ':', |
|
| 43 | + _ID_WEBMESTRES |
|
| 44 | + ) : (autoriser('configurer') ? [$GLOBALS['visiteur_session']['id_auteur']] : [0])) |
|
| 45 | + ] // le webmestre est celui qui fait l'upgrade si rien de defini |
|
| 46 | 46 | ]; |
| 47 | 47 | |
| 48 | 48 | // sites plantes en mode "'su" au lieu de "sus" |
| 49 | 49 | $GLOBALS['maj'][13929] = [ |
| 50 | - ['sql_update', 'spip_syndic', ['syndication' => "'sus'"], "syndication LIKE '\\'%'"] |
|
| 50 | + ['sql_update', 'spip_syndic', ['syndication' => "'sus'"], "syndication LIKE '\\'%'"] |
|
| 51 | 51 | ]; |
| 52 | 52 | |
| 53 | 53 | // Types de fichiers m4a/m4b/m4p/m4u/m4v/dv |
@@ -61,24 +61,24 @@ discard block |
||
| 61 | 61 | // La version 14588 etait une mauvaise piste: |
| 62 | 62 | // Retour en arriere pour ceux qui l'ont subi, ne rien faire sinon |
| 63 | 63 | if (@$GLOBALS['meta']['version_installee'] >= 14588) { |
| 64 | - // "mode" est un mot-cle d'Oracle |
|
| 65 | - $GLOBALS['maj'][14588] = [ |
|
| 66 | - ['sql_alter', 'TABLE spip_documents DROP INDEX mode'], |
|
| 67 | - [ |
|
| 68 | - 'sql_alter', |
|
| 69 | - "TABLE spip_documents CHANGE mode genre ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 70 | - ], |
|
| 71 | - ['sql_alter', 'TABLE spip_documents ADD INDEX genre(genre)'] |
|
| 72 | - ]; |
|
| 73 | - // solution moins intrusive au pb de mot-cle d'Oracle, retour avant 14588 |
|
| 74 | - $GLOBALS['maj'][14598] = [ |
|
| 75 | - ['sql_alter', 'TABLE spip_documents DROP INDEX genre'], |
|
| 76 | - [ |
|
| 77 | - 'sql_alter', |
|
| 78 | - "TABLE spip_documents CHANGE genre mode ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 79 | - ], |
|
| 80 | - ['sql_alter', 'TABLE spip_documents ADD INDEX mode(mode)'] |
|
| 81 | - ]; |
|
| 64 | + // "mode" est un mot-cle d'Oracle |
|
| 65 | + $GLOBALS['maj'][14588] = [ |
|
| 66 | + ['sql_alter', 'TABLE spip_documents DROP INDEX mode'], |
|
| 67 | + [ |
|
| 68 | + 'sql_alter', |
|
| 69 | + "TABLE spip_documents CHANGE mode genre ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 70 | + ], |
|
| 71 | + ['sql_alter', 'TABLE spip_documents ADD INDEX genre(genre)'] |
|
| 72 | + ]; |
|
| 73 | + // solution moins intrusive au pb de mot-cle d'Oracle, retour avant 14588 |
|
| 74 | + $GLOBALS['maj'][14598] = [ |
|
| 75 | + ['sql_alter', 'TABLE spip_documents DROP INDEX genre'], |
|
| 76 | + [ |
|
| 77 | + 'sql_alter', |
|
| 78 | + "TABLE spip_documents CHANGE genre mode ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 79 | + ], |
|
| 80 | + ['sql_alter', 'TABLE spip_documents ADD INDEX mode(mode)'] |
|
| 81 | + ]; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Restauration correcte des types mime des fichiers Ogg |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | * @package SPIP\Core\SQL\Upgrade |
| 19 | 19 | **/ |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | $GLOBALS['maj'][23375] = [ |
| 26 | - ['sql_alter', 'TABLE spip_auteurs CHANGE prefs prefs text'], |
|
| 26 | + ['sql_alter', 'TABLE spip_auteurs CHANGE prefs prefs text'], |
|
| 27 | 27 | ]; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @package SPIP\Core\SQL\Upgrade |
| 21 | 21 | **/ |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -35,49 +35,49 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function maj_timestamp_mysql($tables = null) { |
| 37 | 37 | |
| 38 | - include_spip('base/dump'); |
|
| 39 | - if (is_null($tables)) { |
|
| 40 | - $tables = base_lister_toutes_tables(); |
|
| 41 | - } elseif (is_string($tables)) { |
|
| 42 | - $tables = [$tables]; |
|
| 43 | - } elseif (!is_array($tables)) { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 38 | + include_spip('base/dump'); |
|
| 39 | + if (is_null($tables)) { |
|
| 40 | + $tables = base_lister_toutes_tables(); |
|
| 41 | + } elseif (is_string($tables)) { |
|
| 42 | + $tables = [$tables]; |
|
| 43 | + } elseif (!is_array($tables)) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - // rien a faire si base non mysql |
|
| 48 | - if (strncmp($GLOBALS['connexions'][0]['type'], 'mysql', 5) !== 0) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 47 | + // rien a faire si base non mysql |
|
| 48 | + if (strncmp($GLOBALS['connexions'][0]['type'], 'mysql', 5) !== 0) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 53 | - // forcer le vidage de cache |
|
| 54 | - $trouver_table(''); |
|
| 52 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 53 | + // forcer le vidage de cache |
|
| 54 | + $trouver_table(''); |
|
| 55 | 55 | |
| 56 | - foreach ($tables as $table) { |
|
| 57 | - if (time() >= _TIME_OUT) { |
|
| 58 | - return; |
|
| 59 | - } |
|
| 60 | - if ($desc = $trouver_table($table)) { |
|
| 61 | - $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 62 | - $d = array_diff($desc['field'], $fields_corrected); |
|
| 63 | - if ($d) { |
|
| 64 | - spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 65 | - foreach ($desc['field'] as $field => $type) { |
|
| 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]); |
|
| 69 | - $trouver_table(''); |
|
| 70 | - $new_desc = $trouver_table($table); |
|
| 71 | - spip_log( |
|
| 72 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 74 | - ); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 56 | + foreach ($tables as $table) { |
|
| 57 | + if (time() >= _TIME_OUT) { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 60 | + if ($desc = $trouver_table($table)) { |
|
| 61 | + $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 62 | + $d = array_diff($desc['field'], $fields_corrected); |
|
| 63 | + if ($d) { |
|
| 64 | + spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 65 | + foreach ($desc['field'] as $field => $type) { |
|
| 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]); |
|
| 69 | + $trouver_table(''); |
|
| 70 | + $new_desc = $trouver_table($table); |
|
| 71 | + spip_log( |
|
| 72 | + "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // forcer le vidage de cache |
|
| 82 | - $trouver_table(''); |
|
| 81 | + // forcer le vidage de cache |
|
| 82 | + $trouver_table(''); |
|
| 83 | 83 | } |
@@ -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 | } |
@@ -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'); |
@@ -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 strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | - and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 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 strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | + and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 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 | } |
@@ -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 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $res = admin_repair_tables(); |
| 40 | 40 | if (!$res) { |
| 41 | - $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 41 | + $res = "<div class='error'>"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error()."</div>\n"; |
|
| 42 | 42 | } else { |
| 43 | 43 | include_spip('inc/rubriques'); |
| 44 | 44 | calculer_rubriques(); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $res .= pipeline('base_admin_repair', $res); |
| 49 | 49 | echo minipres( |
| 50 | 50 | _T('texte_tentative_recuperation'), |
| 51 | - $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 51 | + $res.generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | $count = sql_countsel($tab); |
| 92 | 92 | |
| 93 | 93 | if ($count > 1) { |
| 94 | - $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 94 | + $m .= '('._T('texte_compte_elements', ['count' => $count]).")\n"; |
|
| 95 | 95 | } else { |
| 96 | 96 | if ($count == 1) { |
| 97 | - $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 97 | + $m .= '('._T('texte_compte_element', ['count' => $count]).")\n"; |
|
| 98 | 98 | } else { |
| 99 | - $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 99 | + $m .= '('._T('texte_vide').")\n"; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | and $msg = join( |
| 106 | 106 | ' ', |
| 107 | 107 | (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
| 108 | - ) . ' ' |
|
| 108 | + ).' ' |
|
| 109 | 109 | and strpos($msg, ' OK ') === false |
| 110 | 110 | ) { |
| 111 | 111 | $class = " class='notice'"; |
| 112 | - $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 112 | + $m .= '<br /><tt>'.spip_htmlentities($msg)."</tt>\n"; |
|
| 113 | 113 | } else { |
| 114 | - $m .= ' ' . _T('texte_table_ok'); |
|
| 114 | + $m .= ' '._T('texte_table_ok'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $res .= "<div$class>$m</div>"; |
@@ -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 | /** |
@@ -36,20 +36,20 @@ discard block |
||
| 36 | 36 | **/ |
| 37 | 37 | function base_repair_dist($titre = '', $reprise = '') { |
| 38 | 38 | |
| 39 | - $res = admin_repair_tables(); |
|
| 40 | - if (!$res) { |
|
| 41 | - $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 42 | - } else { |
|
| 43 | - include_spip('inc/rubriques'); |
|
| 44 | - calculer_rubriques(); |
|
| 45 | - propager_les_secteurs(); |
|
| 46 | - } |
|
| 47 | - include_spip('inc/minipres'); |
|
| 48 | - $res .= pipeline('base_admin_repair', $res); |
|
| 49 | - echo minipres( |
|
| 50 | - _T('texte_tentative_recuperation'), |
|
| 51 | - $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | - ); |
|
| 39 | + $res = admin_repair_tables(); |
|
| 40 | + if (!$res) { |
|
| 41 | + $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 42 | + } else { |
|
| 43 | + include_spip('inc/rubriques'); |
|
| 44 | + calculer_rubriques(); |
|
| 45 | + propager_les_secteurs(); |
|
| 46 | + } |
|
| 47 | + include_spip('inc/minipres'); |
|
| 48 | + $res .= pipeline('base_admin_repair', $res); |
|
| 49 | + echo minipres( |
|
| 50 | + _T('texte_tentative_recuperation'), |
|
| 51 | + $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | + ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -63,59 +63,59 @@ discard block |
||
| 63 | 63 | **/ |
| 64 | 64 | function admin_repair_tables() { |
| 65 | 65 | |
| 66 | - $repair = sql_serveur('repair', '', true); |
|
| 66 | + $repair = sql_serveur('repair', '', true); |
|
| 67 | 67 | |
| 68 | - // recreer les tables manquantes eventuelles |
|
| 69 | - include_spip('base/create'); |
|
| 70 | - creer_base(); |
|
| 71 | - $tables = sql_alltable(); |
|
| 68 | + // recreer les tables manquantes eventuelles |
|
| 69 | + include_spip('base/create'); |
|
| 70 | + creer_base(); |
|
| 71 | + $tables = sql_alltable(); |
|
| 72 | 72 | |
| 73 | - $res = ''; |
|
| 74 | - foreach ($tables as $tab) { |
|
| 75 | - $class = ''; |
|
| 76 | - $m = "<strong>$tab</strong> "; |
|
| 77 | - spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 78 | - // supprimer la meta avant de lancer la reparation |
|
| 79 | - // car le repair peut etre long ; on ne veut pas boucler |
|
| 80 | - effacer_meta('admin_repair'); |
|
| 81 | - if ($repair) { |
|
| 82 | - $result_repair = sql_repair($tab); |
|
| 83 | - if (!$result_repair) { |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 86 | - } |
|
| 73 | + $res = ''; |
|
| 74 | + foreach ($tables as $tab) { |
|
| 75 | + $class = ''; |
|
| 76 | + $m = "<strong>$tab</strong> "; |
|
| 77 | + spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 78 | + // supprimer la meta avant de lancer la reparation |
|
| 79 | + // car le repair peut etre long ; on ne veut pas boucler |
|
| 80 | + effacer_meta('admin_repair'); |
|
| 81 | + if ($repair) { |
|
| 82 | + $result_repair = sql_repair($tab); |
|
| 83 | + if (!$result_repair) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // essayer de maj la table (creation de champs manquants) |
|
| 89 | - maj_tables($tab); |
|
| 88 | + // essayer de maj la table (creation de champs manquants) |
|
| 89 | + maj_tables($tab); |
|
| 90 | 90 | |
| 91 | - $count = sql_countsel($tab); |
|
| 91 | + $count = sql_countsel($tab); |
|
| 92 | 92 | |
| 93 | - if ($count > 1) { |
|
| 94 | - $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 95 | - } else { |
|
| 96 | - if ($count == 1) { |
|
| 97 | - $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 98 | - } else { |
|
| 99 | - $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 100 | - } |
|
| 101 | - } |
|
| 93 | + if ($count > 1) { |
|
| 94 | + $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 95 | + } else { |
|
| 96 | + if ($count == 1) { |
|
| 97 | + $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 98 | + } else { |
|
| 99 | + $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - if ( |
|
| 104 | - $result_repair |
|
| 105 | - and $msg = join( |
|
| 106 | - ' ', |
|
| 107 | - (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
|
| 108 | - ) . ' ' |
|
| 109 | - and strpos($msg, ' OK ') === false |
|
| 110 | - ) { |
|
| 111 | - $class = " class='notice'"; |
|
| 112 | - $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 113 | - } else { |
|
| 114 | - $m .= ' ' . _T('texte_table_ok'); |
|
| 115 | - } |
|
| 103 | + if ( |
|
| 104 | + $result_repair |
|
| 105 | + and $msg = join( |
|
| 106 | + ' ', |
|
| 107 | + (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
|
| 108 | + ) . ' ' |
|
| 109 | + and strpos($msg, ' OK ') === false |
|
| 110 | + ) { |
|
| 111 | + $class = " class='notice'"; |
|
| 112 | + $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 113 | + } else { |
|
| 114 | + $m .= ' ' . _T('texte_table_ok'); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - $res .= "<div$class>$m</div>"; |
|
| 118 | - } |
|
| 117 | + $res .= "<div$class>$m</div>"; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - return $res; |
|
| 120 | + return $res; |
|
| 121 | 121 | } |
@@ -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 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -36,22 +36,22 @@ discard block |
||
| 36 | 36 | * Description de la boucle complétée des champs |
| 37 | 37 | */ |
| 38 | 38 | function iterateur_php_dist($b, $iteratorName) { |
| 39 | - $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 40 | - $b->show = [ |
|
| 41 | - 'field' => [ |
|
| 42 | - 'cle' => 'STRING', |
|
| 43 | - 'valeur' => 'STRING', |
|
| 44 | - ] |
|
| 45 | - ]; |
|
| 46 | - foreach (get_class_methods($iteratorName) as $method) { |
|
| 47 | - $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /* |
|
| 39 | + $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 40 | + $b->show = [ |
|
| 41 | + 'field' => [ |
|
| 42 | + 'cle' => 'STRING', |
|
| 43 | + 'valeur' => 'STRING', |
|
| 44 | + ] |
|
| 45 | + ]; |
|
| 46 | + foreach (get_class_methods($iteratorName) as $method) { |
|
| 47 | + $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /* |
|
| 51 | 51 | foreach (get_class_vars($iteratorName) as $property) { |
| 52 | 52 | $b->show['field'][ strtolower($property) ] = 'PROPERTY'; |
| 53 | 53 | } |
| 54 | 54 | */ |
| 55 | 55 | |
| 56 | - return $b; |
|
| 56 | + return $b; |
|
| 57 | 57 | } |